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 Ragunath Marudhachalam <rm...@circuitvision.com> on 2002/04/22 21:28:39 UTC

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


Re: How to add this the xsl reference to xml document... --- In a hurry

Posted by Scott Vachalek <sc...@Integrisoft.COM>.
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" <rm...@circuitvision.com>
To: <xe...@xml.apache.org>
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: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org