OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] Adding PI in XML Document

[ Lists Home | Date Index | Thread Index ]

Hi Peter,

 Thanks!
	 I tried with   doc.insertBefore((Node)pi,doc.getFirstChild());  ..
then also  when I write to a file after finishing, no pi appeares in xml
      document.  I tried with putting this line of code before appending
root element and also after, but no result.
      I am using apache's DOM parser. 


Cheers,
Samba

> -----Original Message-----
> From:	Peter Murphy [SMTP:peterm@fast.fujitsu.com.au]
> Sent:	Friday, April 26, 2002 9:39 AM
> To:	Deshpande, Gururaj; 'Sambasivarao_Potla'; xml-dev@lists.xml.org
> Subject:	RE: [xml-dev] Adding PI in XML Document
> 
> > -----Original Message-----
> > From: Deshpande, Gururaj [mailto:gururaj.deshpande@flsmidth.com]
> > Sent: Thursday, April 25, 2002 10:14 PM
> > To: 'Sambasivarao_Potla'; 'xml-dev@lists.xml.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\"");
> >     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.
> 
> 
> 
> 
> -----------------------------------------------------------------
> 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>
************************************************************************** 
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.
**************************************************************************




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS