[jdom-interest] Test - Expanding <script> element.

Jason Hunter jhunter at xquery.com
Wed Mar 16 14:58:10 PST 2005


The SAX parser pulls the DTD declared in the doctype and when an element 
has a default valued attribute, adds it to the content model.  SAX 
doesn't care if the attribute is in the .xml file or the .dtd file; it's 
treated the same.

The interesting remaining question is, does an element with 
xml:space="preserve" get expanded even if it has no text?

-jh-

Daniel Rubio wrote:

> 
> Just replicated the "would-be" bug, here is what I found out from making 
> the test:
>                         .- This behavior happens only if the 
> input/document has a defined Doctype, in this case XHTML Strict or 
> Transitional
>                .- If there is no Doctype in the input/document the 
> behavior is as expected, not even the xml:space="preserve" attribute is 
> added to the output.
> 
>   What baffles me now is what JAR/Library in the stack takes this 
> Doctype input and produces an altered final output (The not expanding 
> the particular script tag appropriately and adding the 
> xml:space="preserve" attribute) .
> 
> Any ideas (Xerces , Jaxen or something else in JDOM ) ? 
> Daniel
> Attaching Test.java and and testData.html
> 
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> 
> import org.jdom.*;
> import org.jdom.output.*; 
> import org.jdom.input.*; 
> import java.io.*;
> 
> public class Test { 
>     
>     public static void main(String[] args) { 
> 	try { 
> 	    
> 	    SAXBuilder builder = new SAXBuilder();
> 	    Document doc = builder.build("testData.html");
> 	    Format documentFormat = Format.getPrettyFormat();
> 	    documentFormat.setExpandEmptyElements(true);
> 
> 	    // Adding the doctype at this point is still irrelevant 
> 	    // DocType dtd = new DocType("html","-//W3C//DTD XHTML 1.0 Strict//EN","http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"); 
> 	    // doc.setDocType(dtd);	    
> 	    
> 	    XMLOutputter outputter = new XMLOutputter(documentFormat);
> 	    outputter.output(doc, System.out);
> 	} catch (JDOMException jdom) { 
> 	    jdom.printStackTrace();
> 	} catch (IOException io) { 
> 	    io.printStackTrace();
> 	} 
> 	
>     }
> }
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com


More information about the jdom-interest mailing list