[XML-SIG] xmllib setliteral misfeature?

Sjoerd Mullender sjoerd@oratrix.nl
Mon, 20 Sep 1999 12:09:36 +0200


What can I say?
The current version (in the Python CVS repository, probably not in the
XML repository) does this correctly.  I seem to remember fixing this
fairly recently, so that's probably why it doesn't behave right in
your version.

The output that I get is this:

starttag jabber
data 123
data <
data tjipp>456
data <
data /tjipp>789
endtag jabber

On Sun, Sep 19 1999 Anders Qvist wrote:

> (I am not on the mailing list, so please reply accordingly.))
> 
> Consider if you will, the following program:
> 
> #!/usr/bin/python
> from xmllib import XMLParser
> class Parser (XMLParser):
>     def __init__(self):
>         XMLParser.__init__(self)
>         self.feed("<jabber>123<tjipp>456</tjipp>789</jabber>")
>     def unknown_starttag (self, tag, attributes):
>         print "starttag " + tag
>         self.setliteral()
>     def unknown_endtag (self, tag):
>         print "endtag " + tag
>     def handle_data (self, data):
>         print "data " + data
> test = Parser()
> 
> According to xmllib doc, setliteral() is supposed to do the following:
> 
>    setliteral ()
>           Enter literal mode (CDATA mode). This mode is automatically
>           exited when the close tag matching the last unclosed open tag
>           is encountered.
> 
> If I feed the XMLParser this "<jabber>123<tjipp>456</tjipp>789</jabber>"
> and call setliteral() in unknown_starttag(), I interpret the above doc as
> meaning that I should get the following output:
> 
>     starttag jabber
>     data 123
>     data <
>     data tjipp>456
>     data 654
>     data <
>     data /tjipp>
>     data 789
>     endtag jabber
> 
> Or something similar. I don't however. Rather I get the following:
> 
>     starttag jabber
>     data 123
>     data <
>     data tjipp>456
>     data 654
>     endtag tjipp     <= Why call to unknown_endtag here?
>     data 789
>     endtag jabber
> 
> As you can see, the internal tag generates a call to unknown_endtag. This
> does not seem to be in accordance with the docs. Is this a bug or am I
> missing something? I'm using the Debian package for python, version
> 1.5.2-3.
> 
> Anders "Quest" Qvist
> NetGuide Scandinavia
> 
> And we who listen to the sky, or walk the dusty grade,
> Or break the very atoms down, to see how they are made,
> Or study cells, or living things, seek truth with open hand;
> The profoundest act of worship is to try to understand.
> 
> -- Catherine Faber, "The Word of God"
> 
> 
> 
> 

-- Sjoerd Mullender <sjoerd.mullender@oratrix.com>