Re: XML & CreateProcessingInstruction

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 UTC