Lists Home |
Date Index |
> -----Original Message-----
> From: Deshpande, Gururaj [mailto:email@example.com]
> Sent: Thursday, April 25, 2002 10:14 PM
> To: 'Sambasivarao_Potla'; 'firstname.lastname@example.org'
> Subject: RE: [xml-dev] Adding PI in XML Document
> Instead of ProcessingInstruction, create a Node and append to document.
> Do this
> // xsl Processing instruction
> Node pi = document.createProcessingInstruction("xml-stylesheet",
> "type=\"text/xsl\" href=\"cdcatalog.xsl\"");
> - Gururaj
Sorry, Gururaj, but that answer seems wrong to me for two reasons.
1. Firstly, ProcessingInstructions are inherited from Nodes, so your answer
appears like a recasting of this:
> > Here is the code am trying
> > String data = "type=\"text/xsl\" href=\"cdcatalog.xsl\"";
> > ProcessingInstruction pi =
> > doc.createProcessingInstruction("xml-stylesheet",data);
> > doc.appendChild( pi );
> > But when I write to a file after finishing no pi appeares in xml
> > document.
And probably would have the same result.
Secondly, appending a child adds the PI at the end of the document, which is
not what Sambasivarao wants. Instead,
you do something like this:
String data = "type=\"text/xsl\" href=\"cdcatalog.xsl\"";
ProcessingInstruction pi =
That's my guess, based on testing something similar with Xerces C++ as the
base. The result: the PI was inserted before the element. I can't really see
any difference with a Java implementation.