You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Craig Pfeifer <CE...@aethersystems.com> on 2001/02/28 23:25:51 UTC

loss of DOCTYPE element issues w/Xalan & Xerces

Hi

I wasn't sure whether to send this to the Xerces or the Xalan list, so here
we go.

The jist of the issue is that when we get transformation results from Xalan
as a DOM node, we lose the DOCTYPE element. We explicitly set the value of
the DOCTYPE element for the document via the doctype-system and
doctype-public attributes of the xsl:output element in our XSLT Stylesheet:

<Stylesheet fragment start>
<xsl:output 
	method="xml" 
	encoding="UTF-8" 
	omit-xml-declaration="no" 
	indent="no" 
	doctype-system="http://www.wapforum.org/DTD/wml12.dtd"
	doctype-public="-//WAPFORUM//DTD WML 1.2//EN"
/>
<Stylesheet fragment end>

When I get the results of my Xalan transformation via the XSLTResultTarget
like this:
(translation is a proper StylesheetRoot object, contentInputSource is a
proper XSLTInputSource object)

<code fragment start>
XSLTResultTarget xsltResults = new XSLTResultTarget();
translation.process(contentInputSource, xsltResults);
Node n = xsltResults.getNode();

of = new OutputFormat(n);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLSerializer xmlSerializer = new XMLSerializer(baos, of);
xmlSerializer.serialize(doc);
System.out.println(new String(baos.toByteArray()));
<code fragment end>

The DOCTYPE element is omitted (even if I use OutputFormat's
setOmitDocumentType(false) method).

However, if I get the results of my Xalan transformation directly from the
XSLTResultTarget via writing it directly to file:

<code fragment start>
XSLTResultTarget xsltResults = new XSLTResultTarget("myTransResults.xml");
translation.process(contentInputSource, xsltResults);
<code fragment end>

The DOCTYPE element is included in the file "myTransResults.xml" when it's
written to disk.

Does anyone have a clue as to a possible solution/workaround (aside from
explicitly setting the doctype every time we get a node from Xalan)? Is this
a bug? Is there a Xerces/Xalan config parameter I'm missing somewhere?

Thanks in advance,

Craig Pfeifer

Craig Pfeifer
Software Engineer
Aether Systems, Software Products Division
703.847.3303 x2053
cepfeifer@aethersystems.com