[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Adding PI in XML Document


pi in xml
> -----Original Message-----
> From: Deshpande, Gururaj [mailto:gururaj.deshpande@f...]
> Sent: Thursday, April 25, 2002 10:14 PM
> To: 'Sambasivarao_Potla'; 'xml-dev@l...'
> Subject: RE:  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\"");
>     document.appendChild(pi);
>
> - 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 =
doc.createProcessingInstruction("xml-stylesheet",data);
doc.insertBefore((Node)pi,doc.getFirstChild());

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.

Regards,
Peter.




PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.