[jdom-interest] JDOMResult

Laurent Bihanic laurent.bihanic at atosorigin.com
Wed Feb 27 04:35:47 PST 2002


Hi Matt,

I'm not sure the <xsl:output> directive applies when the result is not a 
stream result: the XSLT 1.0 recommendation defines the xsl:output element in 
the context of "output the result tree as a sequence of bytes". When 
outputting to a JDOMResult, the result is not a sequence of byte but a SAX 
event stream.
For example, in your case, none of the "indent", "method" and "encoding" is 
relevant when the output is a SAX event stream. So, my guess would be that the 
xsl:output is globally ignored when the output is not a StreamResult.

Maybe you could try with another XSLT processor (e.g. SAXON 6.x) to see if 
this behaviour is consistent.

Laurent


Matt Preston wrote:
> Hi all,
> 
> I have been using the JDOMResult for some transformations where I need a
> JDOM Document at the end, but have run into a problem.  It seems that the
> Document produced never has a DocType set, even if my xsl stylesheet creates
> one.
> 
> e.g. I created a doctype with this xsl
> 
> <xsl:output indent="yes" method="xml" encoding="UTF-8"
> doctype-public="-//IPTC//NITF DTD 2.0//EN"
> doctype-system="http://www.nitf.org/site/nitf-documentation/nitf-2-5-no-comm
> ents.dtd"/>
> 
> I used this code to do the transformation
> 
>   JDOMResult _result = new JDOMResult();
>   StreamSource _source = new StreamSource(anInputStream);
>   _transformer.transform(_source, _result);
>   Document _document = _result.getDocument();
> 
> _document.getDocType() returns null.  If rather than using JDOMResult, I use
> a StreamResult and make the Document via a SAXBuilder, the Document has the
> correct DocType.
> 
> Has anyone else experienced this?
> 
> Cheers,
> Matt Preston
> 




More information about the jdom-interest mailing list