You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Øyvind Hvamstad <oy...@hvamstad.net> on 2003/01/15 10:47:56 UTC
Appending a ProcessingInstruction to org.w3c.dom.Document
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@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org