[XML-SIG] Sax2.FromXml 'feature'

Mike Olson Mike.Olson@fourthought.com
Mon, 11 Sep 2000 10:52:42 -0600


Lars Marius Garshol wrote:
> 
> * Alexandre Fayolle
> |
> | Now if I change the last line of the previous example to:
> |
> | fragment = Sax2.FromXml('<frag/><frag/>',document)
> |
> | I get an SAXParseException: Elements not allowed outside root element at
> | Unknown:1:12
> 
> As far as I can tell, this causes the DOM builder to hand the string
> to xmlproc for parsing, and xmlproc correctly complains that this XML
> document (it has no idea it is parsing only a fragment) contains
> markup outside the root element (the first element).
> 
> It would be very easy to add an option to xmlproc that would allow
> clients to tell it that it is parsing XML document fragments. We could
> also add this as a SAX 2.0 feature. However, this might open to abuse
> and parsing of strings that are not well-formed XML.
> 
> An alternative might be for this function to add a fake container
> element around the string to avoid this problem. Opinions, anyone?

I like the fake container idea.  If a user passes in a document, the
reader will wrap it with a container and unwrap it on output.

Mike

> 
> --Lars M.
> 
> _______________________________________________
> XML-SIG maillist  -  XML-SIG@python.org
> http://www.python.org/mailman/listinfo/xml-sig

-- 
Mike Olson				 Principal Consultant
mike.olson@fourthought.com               (303)583-9900 x 102
Fourthought, Inc.                         http://Fourthought.com 
Software-engineering, knowledge-management, XML, CORBA, Linux, Python