[
Lists Home |
Date Index |
Thread Index
]
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
> -----Original Message-----
> From: Sambasivarao_Potla [SMTP:Sambasivarao_Potla@satyam.com]
> Sent: Thursday, April 25, 2002 6:32 AM
> To: 'xml-dev@lists.xml.org'
> Subject: [xml-dev] Adding PI in XML Document
>
> Hi All,
>
> How to add stylesheet processing intstruction in a xml document which is
> generated by DOM.
>
> 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.
>
> When I tried with following code..
>
> String data = "type=\"text/xsl\" href=\"cdcatalog.xsl\"";
> ProcessingInstruction pi =
> doc.createProcessingInstruction("xml-stylesheet",data);
> root.insertBefore((Node)pi,root.getFirstChild());
>
> Then I found the following in xml document
> <?xml version="1.0" ?>
> <root>
> <?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>
> .....
> </root>
>
> But I want to generate like
>
> <?xml version="1.0" ?>
> <?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>
> <root>
> .....
> </root>
>
>
> TIA,
> Samba
> **************************************************************************
>
> This email (including any attachments) is intended for the sole use of the
> intended recipient/s and may contain material that is CONFIDENTIAL AND
> PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying
> or
> distribution or forwarding of any or all of the contents in this message
> is
> STRICTLY PROHIBITED. If you are not the intended recipient, please contact
> the sender by email and delete all copies; your cooperation in this regard
> is appreciated.
> **************************************************************************
>
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
|