You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Carsten Schlipf <ca...@hp.com> on 2007/08/15 21:25:37 UTC

JXPath: Does not understand ancestor:: and descendant::?

Hello,

on the JXPath user's guide I have read that the axes "parent::" and
"ancestor::" may be used. However in my code I get JXPathExceptions:

        JXPathContext context = JXPathContext.newContext(object);
        context.getValue("ancestor::");

The call to getValue(String) throws the JXPathException with the
following message:

        Invalid XPath: 'ancestor::'. Syntax error after: 'a'.

A similar exception is thrown for 'descendant::' and 'parent::'. Am I
missing something? Do I have to set a special mode or register the
DescendantContext, AncestorContext and ParentContext classes as
functions somehow? I tried the later but didn't succeed.

Thank you very much for help!

Carsten

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: JXPath: Does not understand ancestor:: and descendant::?

Posted by Carsten Schlipf <ca...@hp.com>.
Thank you very much, Sergey.

I was just wondering, since it worked on
http://www.whitebeam.org/library/guide/TechNotes/xpathtestbed.rhtm.

Regards,
Carsten

Sergey Vladimirov wrote:
> Carsten,
> 
> As for every axis, node test should be specified:
>  - "parent::*"
>  - "ancestor::*"
>  - "descendant::somenodename"
> 
> Hope this'll help,
> Sergey
> 
> 2007/8/15, Carsten Schlipf <ca...@hp.com>:
>> Hello,
>>
>> on the JXPath user's guide I have read that the axes "parent::" and
>> "ancestor::" may be used. However in my code I get JXPathExceptions:
>>
>>        JXPathContext context = JXPathContext.newContext(object);
>>        context.getValue("ancestor::");
>>
>> The call to getValue(String) throws the JXPathException with the
>> following message:
>>
>>        Invalid XPath: 'ancestor::'. Syntax error after: 'a'.
>>
>> A similar exception is thrown for 'descendant::' and 'parent::'. Am I
>> missing something? Do I have to set a special mode or register the
>> DescendantContext, AncestorContext and ParentContext classes as
>> functions somehow? I tried the later but didn't succeed.
>>
>> Thank you very much for help!
>>
>> Carsten
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: JXPath: Does not understand ancestor:: and descendant::?

Posted by Sergey Vladimirov <vl...@gmail.com>.
Carsten,

As for every axis, node test should be specified:
 - "parent::*"
 - "ancestor::*"
 - "descendant::somenodename"

Hope this'll help,
Sergey

2007/8/15, Carsten Schlipf <ca...@hp.com>:
>
> Hello,
>
> on the JXPath user's guide I have read that the axes "parent::" and
> "ancestor::" may be used. However in my code I get JXPathExceptions:
>
>        JXPathContext context = JXPathContext.newContext(object);
>        context.getValue("ancestor::");
>
> The call to getValue(String) throws the JXPathException with the
> following message:
>
>        Invalid XPath: 'ancestor::'. Syntax error after: 'a'.
>
> A similar exception is thrown for 'descendant::' and 'parent::'. Am I
> missing something? Do I have to set a special mode or register the
> DescendantContext, AncestorContext and ParentContext classes as
> functions somehow? I tried the later but didn't succeed.
>
> Thank you very much for help!
>
> Carsten
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>


-- 
Sergey Vladimirov