W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2001

Re: XML & CreateProcessingInstruction

From: Jayashree Krishnamoorthy <jayashree.krish@mphasis.com>
Date: Fri, 29 Jun 2001 10:19:20 -0400 (EDT)
Message-ID: <00c301c100a6$2ec63f80$561fa19b@ne.telecom.fedex.com>
To: "Joseph Kesselman" <keshlam@us.ibm.com>
Cc: <www-dom@w3.org>
Thank u. But when i give like this i am getting a compiling error

    DOMImplementation
domImpl=org.apache.xerces.dom.DOMImplementationImpl.getDOMImplementation();

saying  DOMImplementation  not found in type declaration. (i think must
becos DOMImplementation is a interface)

     But if i change DOMImplemetation to DOMImplementationImpl  this error
is fixed but i am not able to invoke createProcessingInstruction() method.
is there any work around for this?

Regards
Jayashree




----- Original Message -----
From: Joseph Kesselman <keshlam@us.ibm.com>
To: Jayashree Krishnamoorthy <jayashree.krish@mphasis.com>
Cc: <www-dom@w3.org>
Sent: Thursday, June 28, 2001 8:52 PM
Subject: Re: XML & CreateProcessingInstruction


>
> >    Document doc =
> (Document)Class.forName("org.apache.xerces.dom.DocumentImpl").newInstance
> ();
>
> Don't do that; it's not only nonportable but isn't really supported.
> Instead, obtain the DOMImplmentation obect (which currently does require a
> nonportable step):
>      DOMImplementation
>
domImpl=org.apache.xerces.dom.DOMImplementationImpl.getDOMImplementation();
> and then use
>      Document doc=domImpl.createDocument(...);
> Note that createDocument forces you to create the root element.
>
>
>
> Then, after you create the ProcessingInstruction node, remember to insert
> or append it as a child of some other node; otherwise it won't be part of
> your document tree. In this case, what you probably want to do is insert
it
> as a child of the Document node, before the Document Element:
>
>      ProcessingInstruction myPI = doc.createProcessingInstruction
> ("xml-stylesheet"," type=\"text/xsl\"
> href=\"http://localhost:8080/examples/jsp/XMLProject/quiz1_xsl.xsl\"");
>      doc.insertBefore(myPI,doc.getDocumentElement());
>
>
>
>
> ______________________________________
> Joe Kesselman  / IBM Research
>
Received on Friday, 29 June 2001 18:13:28 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:48 GMT