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

[SAX] Looking for the missing event

  • From: Philippe Poulard <Philippe.Poulard@s...>
  • To: XML Developers List <xml-dev@l...>
  • Date: Thu, 09 Nov 2006 18:41:08 +0100

dtd plist
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 ?

-- 
Cordialement,

               ///
              (. .)
  --------ooO--(_)--Ooo--------
|      Philippe Poulard       |
  -----------------------------
  http://reflex.gforge.inria.fr/
        Have the RefleX !


[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.