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 Gude Reshma <re...@yahoo.com> on 2002/04/12 10:26:04 UTC

Getting a null parent

hi,

I get a set of nodes & store them in a vector. Then i access the vector in a for loop & try to retrieve the parent of each node using node.getParentNode(); However this gives me null for some nodes, even when the parent is existing. How is it possible? How can the parent of any node be null??

Can anyone suggest what i'm doing wrong?

-Reshma



---------------------------------
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax

Re: Getting a null parent

Posted by Hasan Sheboul <hs...@cs.nmsu.edu>.
Try to make sure that the Document object is still accessible via the
class that contains the traversal code you wrote.

Gude Reshma wrote:

> this is my code:
>
> Vector v = new Vector();
>
> if(some condition ){ v.addElement(node)}
>
> for(int i =0; i < visize();i++)
>
> {
>
> Node n = (node)v.elementAt(i);
>
> Node parent = n.getParentNode(); // this gives me parent as null
> although parent exists.
>
> }
>
>   Andy Clark <an...@apache.org> wrote:
>
>      Gude Reshma wrote:
>      > I get a set of nodes & store them in a vector. Then i
>      access the
>      > vector in a for loop & try to retrieve the parent of each
>      node using
>      > node.getParentNode(); However this gives me null for some
>      nodes, even
>      > when the parent is existing. How is it possible? How can
>      the parent of
>      > any node be null??
>
>      Document, document fragment, and attribute nodes are defined
>
>      to have null parents. (Attribute nodes have an "owner
>      element",
>      not a "parent".) Also, any node not connected to the tree
>      has
>      a null parent.
>
>      Please provide more information about the types of nodes
>      that
>      you are storing in your vector. Perhaps a small test program
>
>      that shows the problem would be helpful to determine what is
>
>      wrong.
>
>      --
>      Andy Clark * andyc@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
>
>
> -----------------------------------------------------------------------
> Do You Yahoo!?
> Yahoo! Tax Center - online filing with TurboTax

Re: Getting a null parent

Posted by Gude Reshma <re...@yahoo.com>.
 thanx for the help. My problem is solved.
  Andy Clark <an...@apache.org> wrote: This is not enough information to reproduce the problem that
you are experiencing. What is the data? Is there any code
that modifies the tree? Where do these nodes that you're
adding to the Vector come from? What are the types of the
nodes added to the Vector? etc...

-- 
Andy Clark * andyc@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



---------------------------------
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax

Re: Getting a null parent

Posted by Andy Clark <an...@apache.org>.
This is not enough information to reproduce the problem that
you are experiencing. What is the data? Is there any code
that modifies the tree? Where do these nodes that you're
adding to the Vector come from? What are the types of the
nodes added to the Vector? etc...

-- 
Andy Clark * andyc@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


Re: Getting a null parent

Posted by Gude Reshma <re...@yahoo.com>.
this is my code: 
Vector v = new Vector(); 
if(some condition ){ v.addElement(node)} 
for(int i =0; i < visize();i++) 
{ 
Node n = (node)v.elementAt(i);
Node parent = n.getParentNode(); // this gives me parent as null although parent exists.
} 
 
  Andy Clark <an...@apache.org> wrote: Gude Reshma wrote:
> I get a set of nodes & store them in a vector. Then i access the
> vector in a for loop & try to retrieve the parent of each node using
> node.getParentNode(); However this gives me null for some nodes, even
> when the parent is existing. How is it possible? How can the parent of
> any node be null??

Document, document fragment, and attribute nodes are defined
to have null parents. (Attribute nodes have an "owner element",
not a "parent".) Also, any node not connected to the tree has
a null parent.

Please provide more information about the types of nodes that
you are storing in your vector. Perhaps a small test program
that shows the problem would be helpful to determine what is
wrong.

-- 
Andy Clark * andyc@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



---------------------------------
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax

Re: Getting a null parent

Posted by Andy Clark <an...@apache.org>.
Gude Reshma wrote:
> I get a set of nodes & store them in a vector. Then i access the
> vector in a for loop & try to retrieve the parent of each node using
> node.getParentNode(); However this gives me null for some nodes, even
> when the parent is existing. How is it possible? How can the parent of
> any node be null??

Document, document fragment, and attribute nodes are defined
to have null parents. (Attribute nodes have an "owner element",
not a "parent".) Also, any node not connected to the tree has
a null parent.

Please provide more information about the types of nodes that
you are storing in your vector. Perhaps a small test program
that shows the problem would be helpful to determine what is
wrong.

-- 
Andy Clark * andyc@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