[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: [SAX] Looking for the missing event

  • From: Amandine Duffoux <aduffoux@i...>
  • To: Philippe Poulard <Philippe.Poulard@s...>
  • Date: Fri, 10 Nov 2006 15:26:22 +0100

sax comment event
Hi,

TransformerHandler inherits from LexicalHandler which enable to manage 
specifically comments (method comment).
http://java.sun.com/j2se/1.4.2/docs/api/org/xml/sax/ext/LexicalHandler.html#comment(char[],%20int,%20int)
However I don't think you can make the difference between comments from 
internal subset and external subset. If it is correctly nested, it will 
be displayed. Maybe someone else will have another idea ...

Philippe Poulard a écrit :

> hi,
>
> when I try this :
>
>         try {
>             TransformerHandler th = ((SAXTransformerFactory) 
> TransformerFactory.newInstance()).newTransformerHandler();
>             StringWriter sw = new StringWriter();
>             th.setResult(new StreamResult( sw ) );
>             SAXParser sp = SAXParserFactory.newInstance().newSAXParser();
>             System.out.println( sp.getClass().getName() );
>             XMLReader reader = sp.getXMLReader();
>             System.out.println( reader.getClass().getName() );
>             reader.setContentHandler( th );
>             reader.setDTDHandler( th );
>             reader.setProperty( XMLNames.LEXICAL_HANDLER_SAX_PROPERTY, 
> th );
>             String xml = "<?xml version=\"1.0\"?>" +
>                 "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 
> 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"+
>                 "<plist version=\"1.0\"/>";
>             reader.parse( new InputSource( new StringReader( xml ) ) );
>             System.out.println( sw );
>         } catch ( Exception e ) {
>             e.printStackTrace();
>             fail( e.toString() + " shouldn't be thrown.");
>         }
>
> ...I get this :
> org.apache.xerces.jaxp.SAXParserImpl
> org.apache.xerces.parsers.SAXParser
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" 
> "http://www.apple.com/DTDs/PropertyList-1.0.dtd"<!--- Primitive types 
> --><!-- Contents interpreted as Base-64 encoded --><!-- Contents 
> should conform to a subset of ISO 8601 (in particular, YYYY '-' MM '-' 
> DD 'T' HH ':' MM ':' SS 'Z'.  Smaller units may be omitted with a loss 
> of precision) --><!-- Numerical primitives --><!-- Boolean constant 
> true --><!-- Boolean constant false --><!-- Contents should represent 
> a floating point number matching ("+" | "-")? d+ ("."d*)? ("E" ("+" | 
> "-") d+)? where d is a digit 0-9.  --><!-- Contents should represent a 
> (possibly signed) integer number in base 10 -->>
> <plist version="1.0"/>
>
> the external DTD contains some XML comments that are reported in the 
> output ; the formatted result is incorrect :
> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" 
> "http://www.apple.com/DTDs/PropertyList-1.0.dtd"<!--- Primitive types
>
> instead of :
> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" 
> "http://www.apple.com/DTDs/PropertyList-1.0.dtd" [<!--- Primitive types
>
> or even rather :
> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" 
> "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
>
> The correct output should be the last, but I'm not sure that the 
> serializer can distinguish a comment that occurs in the internal 
> subset from a comment that occurs in the external subset : there 
> aren't such events, particularly if we look at TRAX 
> (javax.xml.transform.sax.TransformerHandler) and even if we also 
> consider org.xml.sax.ext.DeclHandler
>
> Is there a workaround ?
> Did I miss something ?
>

-- 
________________________________________________________________ 
tel (33)  02 41 96 65 53
Fax (33)  02 41 96 65 11 
Groupe ISAIP-ESAIP			
BP 80022 - 18 rue du 8 Mai 45		
49180 St Barthélémy Cédex		http://www.isaip.uco.fr



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.