Appending a ProcessingInstruction to org.w3c.dom.Document 2003-01-15 - By Øyvind Hvamstad
Hi, I'm generating xml on the fly for my report server, in this context I need to embedd a stylesheet inside the xml document. In order for this to work, I need a processing instruction to the parser: <?xsl-stylesheet type="text/xml" href="#stylesheet"?>. I try to do this in my dom structure as follows:
<snip language="java"> org.w3c.dom.Document doc = new org.apache.DocumentImpl(); org.w3c.dom.Element root = doc.createElement("doc"); doc.appendChild(root); org.w3c.dom.ProcessingInstruction pi = doc.createProcessingIntruction("xml-stylesheet", "type=\"text/xml\" href=\"#stylesheet\""); doc.insertBefore((Node)pi, doc.getFirstChild()); (also tried appendChild((Node)pi);) </snip>
This results in the following xml structure:
<?xml encoding="UTF-8"?> <root/>
When what I want is:
<?xml encoding="UTF-8"?> <?xsl-stylesheet type="text/xml" href="#stylesheet"?> <root/>
Could anyone tell me how to make the instruction append itself?
Thanks in advance
�yvind Hvamstad Norway
--------------------------------------------------------------------- To unsubscribe, e-mail: xerces-j-user-unsubscribe@(protected) For additional commands, e-mail: xerces-j-user-help@(protected)
|
|