Hi Ragunath,

As a matter of style, I think it's better to use "getDocumentElement()"
rather than "getFirstChild()" because if there are any other PIs or comments
in front, you might get unexpected results.

In this case, though, it looks like it should work.  I have some very
similar code that is working for me now (I'm using version 2.0.0).

Have you tried calling getFirstChild() after the insertion, to see if you
get your PI?  There could be a problem in the document serialization phase
where it's stripping the PI.

Hope this helps,
Scott

----- Original Message -----
From: "Ragunath Marudhachalam" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 22, 2002 12:28 PM
Subject: How to add this the xsl reference to xml document... --- In a hurry


> Hello All,
>
> could anyone suggest me how to add these lines(reference to a xsl
> document)in the xml document which i generate dynamically....
>
>
> I'm getting the following xml document, even though i had these code in my
> servlet.
>
>
> ProcessingInstruction pi =
> cvcontext.OutDocument.createProcessingInstruction("xml-stylesheet",
> "href=\"instruction.xsl\" type=\"text/xsl\"");
> cvcontext.OutDocument.insertBefore(pi,
> cvcontext.OutDocument.getFirstChild()); (cvcontext.outDocument is a
Document
> object)
>
> //if i print the document after these lines, i get this xml document.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <cv>
> <status>
> <type>Success</type>
> <statusbar>
> <code>CVM-00871</code><text>Action Completed</text>
> </statusbar>
> </status>
> </cv>
>
>
> but i'm expecting a document like this,
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml:stylesheet type="text/xsl" href="instruction.xsl" >
> <cv>
> <status>
> <type>Success</type>
> <statusbar>
> <code>CVM-00871</code><text>Action Completed</text>
> </statusbar>
> </status>
> </cv>
>
> Could anyone suggest me what i'm doing wrong. I would appreciate if
someone
> can help me with some sample code.
>
> Ragu
> CircuitVision
>
>


----------------------------------------------------------------------------
----


> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to