ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xml-sig
xml-sig
[XML-SIG] Handling of attribute namespaces
by Juergen Hermann other posts by this author
Aug 31 2001 12:05PM messages near this date
[XML-SIG] Attribute namespace bug | [XML-SIG] Quixer's Ultimate Fake ID's
Hi!

Can someone explain why we have, in the following code, the handling 
for NS==None in tag names, but not in attribute names? Smells like a bug.

    def startElementNS(self, name, qname, attrs):
        if name[0] is None:
            name = name[1]
        elif self._current_context[name[0]] is None:
            # default namespace
            name = name[1]
        else:
            name = self._current_context[name[0]] + ":" + name[1]
        self._out.write('<' + name)

        for k,v in self._undeclared_ns_maps:
            if k is None:
                self._out.write(' xmlns="%s"' % v)
            else:
                self._out.write(' xmlns:%s="%s"' % (k,v))
        self._undeclared_ns_maps = []

        for (name, value) in attrs.items():
            name = self._current_context[name[0]] + ":" + name[1]
            self._out.write(' %s=%s' % (name, quoteattr(value)))
        self._out.write('> ')

What I get is this:
<?xml version="1.0" encoding="iso-8859-1"?> 
<bibliography> 
!!!! The following are the args to the __init__ of AttributeNSImpl!
  *** Attrs = {(None, u'id'): u'prescod:1999'}
*** Qnames = {(None, u'id'): u'id'}
<bookTraceback (most recent call last):
  File "tests/test.py", line 38, in ?
    parser.parse(os.path.join(os.path.dirname(sys.argv[0]), "books.xml"))
  File "/netsite/lib/python2.0/_xmlplus/sax/saxutils.py", line 208, in startElementNS
    name = self._current_context[name[0]] + ":" + name[1]
KeyError

When parsing this file:
<?xml version="1.0" encoding="ISO-8859-1"?> 

<!DOCTYPE bibliography SYSTEM "books.dtd"> 

<bibliography> 
  <book id="prescod:1999"> 
    <author> Paul Prescod, Charles F. Goldfarb</author>
    <title> The XML Handbook</title>
    <publisher> Prentice Hall</publisher>
    <year> 1999</year>
    <isbn> 0130147141</isbn>
    <comment> paperback, 2nd edition, 1074 pages</comment>
  </book> 

  <book id="beazley:1999"> 
    <author> David M. Beazley, Guido Van Rossum</author>
    <title> Python Essential Reference</title>
    <publisher> New Riders Publishing</publisher>
    <year> 1999</year>
    <isbn> 0735709017</isbn>
    <comment> paperback, 319 p.</comment>
  </book> 

  <book id="stumpp:1999"> 
    <author> Semmy Stumpp</author>
    <title> Projektmanagement mit MS-Project</title>
    <publisher> Markt &amp; Technik</publisher>
    <year> 1999</year>
    <isbn> 3-82725603-8</isbn>
    <comment> gebundene Ausgabe, 523 S., mit CD-ROM</comment>
  </book> 

</bibliography> 







_______________________________________________
XML-SIG maillist  -  XML-SIG@[...].org
http://mail.python.org/mailman/listinfo/xml-sig

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved