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 Djakisback <dj...@hotmail.com> on 2006/06/05 23:47:59 UTC

usage of getNodeObject()

Hi,
I'd like to get a DeferredNode with getNodeObject() of DeferredDocumentImpl
but it doesn't work like I'd want. Maybe someone could help me ? Here is my
code :

        DocumentBuilderFactoryImpl factory = new
DocumentBuilderFactoryImpl();
        DocumentBuilderImpl DOMParser =
(DocumentBuilderImpl)factory.newDocumentBuilder();
        DeferredDocumentImpl domTree =
(DeferredDocumentImpl)DOMParser.parse(new FileInputStream(fileName));

        domTree.getNodeObject(1);
        domTree.getNodeObject(2);
        domTree.getNodeObject(3);
        domTree.getNodeObject(4);
        domTree.getNodeObject(5);
       etc...

All theses lines : "domTree.getNodeObject(n);" make an
IllegalArgumentException : -1
Is someone could say me how I can get a node object in a
DeferredDocumentImpl from its fNodeIndex ?

Thank's for all.
Bye :)

--
View this message in context: http://www.nabble.com/usage-of-getNodeObject%28%29-t1738026.html#a4723034
Sent from the Xerces - J - Users forum at Nabble.com.


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


Re: usage of getNodeObject()

Posted by Djakisback <dj...@hotmail.com>.
Hi,
thank you very much for yours advises :).
Actually, my purpose was to save some fNodeIndex from a DOM tree in a file
for reloading them later and directly getting associated nodes in a DOM tree
(make an index of fNodeIndexes). But JAXP do no permit to get a node from
its fNodeIndex.
I've finally found a way using JAXP and getElementsByTagName() and personnal
numerotation  but I thought it was possible to use fNodeIndex for doing
that.

--
View this message in context: http://www.nabble.com/usage-of-getNodeObject%28%29-t1738026.html#a4767824
Sent from the Xerces - J - Users forum at Nabble.com.


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


Re: usage of getNodeObject()

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Djakisback <dj...@hotmail.com> wrote on 06/05/2006 05:47:59 PM:

> 
> Hi,
> I'd like to get a DeferredNode with getNodeObject() of 
DeferredDocumentImpl
> but it doesn't work like I'd want. Maybe someone could help me ? Here is 
my
> code :
> 
>         DocumentBuilderFactoryImpl factory = new
> DocumentBuilderFactoryImpl();
>         DocumentBuilderImpl DOMParser =
> (DocumentBuilderImpl)factory.newDocumentBuilder();
>         DeferredDocumentImpl domTree =
> (DeferredDocumentImpl)DOMParser.parse(new FileInputStream(fileName));
> 
>         domTree.getNodeObject(1);
>         domTree.getNodeObject(2);
>         domTree.getNodeObject(3);
>         domTree.getNodeObject(4);
>         domTree.getNodeObject(5);
>        etc...
> 
> All theses lines : "domTree.getNodeObject(n);" make an
> IllegalArgumentException : -1
> Is someone could say me how I can get a node object in a
> DeferredDocumentImpl from its fNodeIndex ?

What you are trying to do isn't supported. getNodeObject() is an internal 
method which must only be called by Xerces' DOM implementation. If you 
call it directly (assuming it doesn't fail immediately) it will probably 
corrupt the DOM since the node it returns will never be initialized 
properly. Coding to the implementation is usually a bad idea. You could 
have easily written the above using JAXP as:

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new FileInputStream(fileName));
...

> Thank's for all.
> Bye :)
> 
> --
> View this message in context: http://www.nabble.com/usage-of-
> getNodeObject%28%29-t1738026.html#a4723034
> Sent from the Xerces - J - Users forum at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

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