Re: CDATA vs. Escaped characters
> Using <doc>foo<![CDATA[bar]]>baz</doc>, the DOM gives you 3 children of > element 'doc' ...or in SAX, 3 separate calls to characters(): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Sorry to nit-pick, but this doesn't necessarily have to be so. SAX1 allows the parser to resutn character data in any cobination of events it likes. i.e. <foo>123456</foo> could appear as 1 characters("123456", 0, 6) event, one characters("123", 0, 3) and one characters("456", 4, 3) event, or even 6 different events. SAX 1 itself ignores CDATA sections, so these possibilities are the same regardless. SAX2 allows you to receive lexical events, including CDATA section boundaries, but this is an option you turn on. If you don't, considerations are the same as above (except, of course, that the SAX2 characters event just transmits the text object rather than a chunk of text plus offsets. In short: In SAX1, no guarantees of how you get character events, though you're probably right in practice for most parsers In SAX2, same as SAX1 unless you ask for lexical events, in which case you get at least 3 events in the case you mentioned, and possibly more. -- Uche Ogbuji Principal Consultant uche.ogbuji@f... +1 720 320 2046 Fourthought, Inc. http://Fourthought.com 4735 East Walnut St, Boulder, CO 80301-2537, USA XML strategy, XML tools (http://4Suite.org), knowledge management
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format