You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Andre Scheunemann <an...@toonboom.com> on 2007/06/01 19:06:07 UTC

XPATH question

Hi,

I'm trying to select nodes that have attributes that contain a certain 
string.
This is done using:   //*[jcr:contains(@*,'some text')]

But I want to limit the searched attributes to those of a specific name 
space.
Is there a way to do this?

I have tried the following:   //*[jcr:contains(@xx:*,'some text')] where 
xx is the name space abbreveation
but this gives an exception.

Any help would be appreciated.

Thanks,

Andre





Re: XPATH question

Posted by Marcel Reutegger <ma...@gmx.net>.
Andre Scheunemann wrote:
> Thanks for the reply.  Here are a couple more questions:
> 
> I would like to limit the selection to nodes matching a pattern such as 
> *.abc
> I've tried the following without success:
>    //*[jcr:like(name(), '%abc)]
>    //*[@jcr:path, '%abc')]

this is not possible, the only operator that is supported on the node name is 
equals and you also need to prefix the name() function with fn:

//*[fn:name() = 'abc']

> Is there a way to combine multiple nodetype tests in a single search for 
> example:
>    element(*, nt:file)  and element(*, someMixinType)
>    element(*, nt:file)  or  element(*, nt:folder)

you can use the property jcr:primaryType and jcr:mixinTypes, but you have to 
take care of the node type inheritance yourself.

//element(*, nt:file)

returns all nt:file nodes as well as all nodes with a sub type of nt:file.

//*[@jcr:primaryType = 'nt:file']

will only return node with exactly the primary type nt:file. but you can now add 
more clauses:

//*[@jcr:primaryType = 'nt:file' and jcr:mixinTypes = 'someMixinType']

or another example:

//*[@jcr:primaryType = 'nt:file' or jcr:primaryType = 'nt:folder']

regards
  marcel

Re: XPATH question

Posted by Andre Scheunemann <an...@toonboom.com>.
Thanks for the reply.  Here are a couple more questions:

I would like to limit the selection to nodes matching a pattern such as 
*.abc
I've tried the following without success:
    //*[jcr:like(name(), '%abc)]
    //*[@jcr:path, '%abc')]


Is there a way to combine multiple nodetype tests in a single search for 
example:
    element(*, nt:file)  and element(*, someMixinType)
    element(*, nt:file)  or  element(*, nt:folder)

Thanks,
    Andre

Marcel Reutegger wrote:
> Andre Scheunemann wrote:
>> I'm trying to select nodes that have attributes that contain a 
>> certain string.
>> This is done using:   //*[jcr:contains(@*,'some text')]
>>
>> But I want to limit the searched attributes to those of a specific 
>> name space.
>> Is there a way to do this?
>>
>> I have tried the following:   //*[jcr:contains(@xx:*,'some text')] 
>> where xx is the name space abbreveation
>> but this gives an exception.
>
> this is not possible currently, you have to add a jcr:contains 
> function for each property with the given namespace. e.g.:
>
> //*[jcr:contains(@xx:a,'some text') or jcr:contains(@xx:b,'some text')]
>
> regards
>  marcel
>
>


Re: XPATH question

Posted by Marcel Reutegger <ma...@gmx.net>.
Andre Scheunemann wrote:
> I'm trying to select nodes that have attributes that contain a certain 
> string.
> This is done using:   //*[jcr:contains(@*,'some text')]
> 
> But I want to limit the searched attributes to those of a specific name 
> space.
> Is there a way to do this?
> 
> I have tried the following:   //*[jcr:contains(@xx:*,'some text')] where 
> xx is the name space abbreveation
> but this gives an exception.

this is not possible currently, you have to add a jcr:contains function for each 
property with the given namespace. e.g.:

//*[jcr:contains(@xx:a,'some text') or jcr:contains(@xx:b,'some text')]

regards
  marcel