Handling Lexical Events
You saw earlier that if you are writing text out as XML, you need to know whether you are in a CDATA section. If you are, then angle brackets (<) and ampersands (&) should be output unchanged. But if you're not in a CDATA section, they should be replaced by the predefined entities < and &. But how do you know whether you're processing a CDATA section?
Then again, if you are filtering XML in some way, you want to pass comments along. Normally the parser ignores comments. How can you get comments so that you can echo them?
Finally, there are the parsed entity definitions. If an XML-filtering app sees &myEntity; it needs to echo the same string, and not the text that is inserted in its place. How do you go about doing ...
Get The J2EE™ Tutorial Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.