You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Matthew P Foemmel <MF...@thoughtworks.com> on 2005/08/25 20:54:19 UTC
"instanceof" function for xpath queries
Hi all,
I was wondering if there was an easy way to search a repository for all
nodes of a specific type, including subtypes? For example, the xpath
query:
//*[@jcr:primaryType='my:nodeType']
will match all nodes with the exact type 'my:nodetype', but not nodes with
types that inherit from it. I guess what I'd like to see is an "is"
function that works like the "instanceof" function in Java:
//*[is(my:nodeType)]
I've read the JSR-170 spec and checked out some of the xpath query code,
but couldn't find support for something like this. I feel like I'm missing
something obvious though...
Cheers,
Matthew Foemmel
ThoughtWorks, Inc.
Re: "instanceof" function for xpath queries
Posted by Matthew P Foemmel <MF...@thoughtworks.com>.
That did the trick - thanks!
Matthew Foemmel
ThoughtWorks, Inc.
Peeter Piegaze <pe...@gmail.com> wrote on 08/25/2005 04:18:42 PM:
> The XPath function you are looking for is element(). For example,
>
> //element(*, nt:file)
>
> will find all the nodes in the workspace of primary type nt:file,
> including nodes
> whose primary node type is a *subtype* of nt:file.
>
> -Peeter
>
> On 8/25/05, Matthew P Foemmel <MF...@thoughtworks.com> wrote:
> > Hi all,
> >
> > I was wondering if there was an easy way to search a repository for
all
> > nodes of a specific type, including subtypes? For example, the xpath
> > query:
> >
> > //*[@jcr:primaryType='my:nodeType']
> >
> > will match all nodes with the exact type 'my:nodetype', but not nodes
with
> > types that inherit from it. I guess what I'd like to see is an "is"
> > function that works like the "instanceof" function in Java:
> >
> > //*[is(my:nodeType)]
> >
> > I've read the JSR-170 spec and checked out some of the xpath query
code,
> > but couldn't find support for something like this. I feel like I'm
missing
> > something obvious though...
> >
> > Cheers,
> >
> > Matthew Foemmel
> > ThoughtWorks, Inc.
> >
Re: "instanceof" function for xpath queries
Posted by Peeter Piegaze <pe...@gmail.com>.
The XPath function you are looking for is element(). For example,
//element(*, nt:file)
will find all the nodes in the workspace of primary type nt:file,
including nodes
whose primary node type is a *subtype* of nt:file.
-Peeter
On 8/25/05, Matthew P Foemmel <MF...@thoughtworks.com> wrote:
> Hi all,
>
> I was wondering if there was an easy way to search a repository for all
> nodes of a specific type, including subtypes? For example, the xpath
> query:
>
> //*[@jcr:primaryType='my:nodeType']
>
> will match all nodes with the exact type 'my:nodetype', but not nodes with
> types that inherit from it. I guess what I'd like to see is an "is"
> function that works like the "instanceof" function in Java:
>
> //*[is(my:nodeType)]
>
> I've read the JSR-170 spec and checked out some of the xpath query code,
> but couldn't find support for something like this. I feel like I'm missing
> something obvious though...
>
> Cheers,
>
> Matthew Foemmel
> ThoughtWorks, Inc.
>