You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Julian <ce...@yahoo.com> on 2003/05/19 22:39:03 UTC

[JXPath] Pointers Iterator Returning Wrong Number Results

Hi All,

I am trying to use JXPath for the first time and when
I try to iterate over pointers for a given context, I
only get one of the two child objects expected. I have
tried various xpath expressions to retrieve the
children, but to no avail (e.g. /*,*, and child::*). 
Once I retrieve them I want to delete them, but again
only one is deleted from the Document. I must add that
I am doing this to test the capabilities of JXPath...I
will prob want to conduct more complicated xpaths and
iterations.  Could someone help me with this problem? 


Thanks A Lot,
Julian

<snippet>
            JXPathContext context =
JXPathContext.newContext(genNode);//node with children
in question
            Iterator genValues =
context.iteratePointers("*");//get all node's children

                while(genValues.hasNext()) {
                    
                    NodePointer nodePointer =
(NodePointer)genValues.next();
                   
                      Node testNode =
(Node)nodePointer.getNode();//get Node from pointer
                     
genNode.removeChild(testNode);//remove node in
question 
                }
</snippet>

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

Re: [JXPath] Pointers Iterator Returning Wrong Number Results

Posted by Julian <ce...@yahoo.com>.
Dmitri,

Thanks a ton!  You were absolutely correct.  Sorry
about not providing more info, I supposed I posted
with too much haste.  Either way, I collected the
pointers (which were referring to XML DOM from JAXP)
after iterating them and was able to easily manipulate
them per your suggestion.  You and JXPath are
great...I don't know how I survived before!

-Julian


--- Dmitri Plotnikov <dp...@yahoo.com> wrote:
> Julian,
> 
> Most likely the simultaneous modification is what is
> causing the
> observed behavior.  You might want to find all
> children you intend to
> delete first, and then actually delete them one by
> one starting with
> the last.
> 
> Anyway, in order to provide more concrete answer, I
> will need more
> information.  Please describe the data you are
> applying the XPath to.
> 
> Thanks,
> 
> - Dmitri
> 
> 
> --- Julian <ce...@yahoo.com> wrote:
> > Hi All,
> > 
> > I am trying to use JXPath for the first time and
> when
> > I try to iterate over pointers for a given
> context, I
> > only get one of the two child objects expected. I
> have
> > tried various xpath expressions to retrieve the
> > children, but to no avail (e.g. /*,*, and
> child::*). 
> > Once I retrieve them I want to delete them, but
> again
> > only one is deleted from the Document. I must add
> that
> > I am doing this to test the capabilities of
> JXPath...I
> > will prob want to conduct more complicated xpaths
> and
> > iterations.  Could someone help me with this
> problem? 
> > 
> > 
> > Thanks A Lot,
> > Julian
> > 
> > <snippet>
> >             JXPathContext context =
> > JXPathContext.newContext(genNode);//node with
> children
> > in question
> >             Iterator genValues =
> > context.iteratePointers("*");//get all node's
> children
> > 
> >                 while(genValues.hasNext()) {
> >                     
> >                     NodePointer nodePointer =
> > (NodePointer)genValues.next();
> >                    
> >                       Node testNode =
> > (Node)nodePointer.getNode();//get Node from
> pointer
> >                      
> > genNode.removeChild(testNode);//remove node in
> > question 
> >                 }
> > </snippet>
> > 
> > __________________________________
> > Do you Yahoo!?
> > The New Yahoo! Search - Faster. Easier. Bingo.
> > http://search.yahoo.com
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.
> http://search.yahoo.com
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
> 


=====
Live simply so others may simply live.
�
-Ghandi
�
Pluralitas non est ponenda sine neccesitate.
"Entities should not be multiplied unneccesarily"
�
-William of Occam

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

Re: [JXPath] Pointers Iterator Returning Wrong Number Results

Posted by Dmitri Plotnikov <dp...@yahoo.com>.
Julian,

Most likely the simultaneous modification is what is causing the
observed behavior.  You might want to find all children you intend to
delete first, and then actually delete them one by one starting with
the last.

Anyway, in order to provide more concrete answer, I will need more
information.  Please describe the data you are applying the XPath to.

Thanks,

- Dmitri


--- Julian <ce...@yahoo.com> wrote:
> Hi All,
> 
> I am trying to use JXPath for the first time and when
> I try to iterate over pointers for a given context, I
> only get one of the two child objects expected. I have
> tried various xpath expressions to retrieve the
> children, but to no avail (e.g. /*,*, and child::*). 
> Once I retrieve them I want to delete them, but again
> only one is deleted from the Document. I must add that
> I am doing this to test the capabilities of JXPath...I
> will prob want to conduct more complicated xpaths and
> iterations.  Could someone help me with this problem? 
> 
> 
> Thanks A Lot,
> Julian
> 
> <snippet>
>             JXPathContext context =
> JXPathContext.newContext(genNode);//node with children
> in question
>             Iterator genValues =
> context.iteratePointers("*");//get all node's children
> 
>                 while(genValues.hasNext()) {
>                     
>                     NodePointer nodePointer =
> (NodePointer)genValues.next();
>                    
>                       Node testNode =
> (Node)nodePointer.getNode();//get Node from pointer
>                      
> genNode.removeChild(testNode);//remove node in
> question 
>                 }
> </snippet>
> 
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.
> http://search.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com