OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Python SAX utilities XML Generator and default namespaces

[ Lists Home | Date Index | Thread Index ]

I neglected to mention that today I downloaded Python 2.3.3 dated 
2003-12-18 and am getting this error ... I think I'm running with the 
latest stuff.

....................... Ken

At 2004-04-28 14:30 -0400, I wrote:
>Is there an incantation when using XMLGenerator for Python SAX to work 
>with default namespaces?  Below is what I thought would be an identity 
>transform (modulo syntax issues) of an XML document, yet it is throwing an 
>error when using the default namespace on input (but not when using a 
>prefixed namespace on input).
>
>Looking at the SAX Utilities documentation in Python I don't see any 
>reference to the default namespace.
>
>Thanks for any help anyone can be on this.
>
>................... Ken
>
>
>Z:\data\KenData\dev\python>type passthrough.py
>import sys
>from xml.sax import make_parser, SAXParseException
>from xml.sax.saxutils import XMLGenerator
>
>handler = XMLGenerator()
>parser = make_parser()
>parser.setFeature( "http://xml.org/sax/features/namespaces";, 1 )
>parser.setContentHandler( handler )
>
>try: # processing the input file using the defined SAX events
>     parser.parse( sys.stdin )
>except IOError, (errno, strerror):
>     errorExit( "I/O error(%s): %s: %s" % (errno, strerror, file) )
>except SAXParseException:
>     errorExit( "File does not parse as well-formed XML: %s" % file )
>
># end of file
>
>Z:\data\KenData\dev\python>type pass1.xml
><a:doc xmlns:a="a"><hello/></a:doc>
>
>Z:\data\KenData\dev\python>python passthrough.py <pass1.xml
><?xml version="1.0" encoding="iso-8859-1"?>
><a:doc xmlns:a="a"><hello></hello></a:doc>
>Z:\data\KenData\dev\python>type pass2.xml
><doc xmlns="a"><hello/></doc>
>
>Z:\data\KenData\dev\python>python passthrough.py <pass2.xml
><?xml version="1.0" encoding="iso-8859-1"?>
>Traceback (most recent call last):
>   File "passthrough.py", line 11, in ?
>     parser.parse( sys.stdin )
>   File "p:\python\lib\xml\sax\expatreader.py", line 91, in parse
>     xmlreader.IncrementalParser.parse(self, source)
>   File "p:\python\lib\xml\sax\xmlreader.py", line 123, in parse
>     self.feed(buffer)
>   File "p:\python\lib\xml\sax\expatreader.py", line 144, in feed
>     self._parser.Parse(data, isFinal)
>   File "p:\python\lib\xml\sax\expatreader.py", line 253, in start_element_ns
>     AttributesNSImpl(newattrs, qnames))
>   File "p:\python\lib\xml\sax\saxutils.py", line 95, in startElementNS
>     name = self._current_context[name[0]] + ":" + name[1]
>TypeError: unsupported operand types for +: 'NoneType' and 'str'
>
>Z:\data\KenData\dev\python>


--
Public courses: Spring 2004 world tour of hands-on XSL instruction
Each week:   Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO

Hong Kong May 17-21; Bremen Germany May 24-28; Helsinki June 14-18

World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/x/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS