[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] [SAX] Looking for the missing event
- From: Amandine Duffoux <aduffoux@isaip.uco.fr>
- To: Philippe Poulard <Philippe.Poulard@sophia.inria.fr>
- Date: Fri, 10 Nov 2006 15:26:22 +0100
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]