Hi Siegfried,

I'm not an expert in xpath/xquery but I'm pretty sure that $this doesn't
represent the internal current node that is processed by the engine.

So you'll probably want to rewrite the expression to something like
this:
xo.selectPath(".//[EMAIL PROTECTED]//@id]");

As for $this, it's just a variable that is bound to the XmlObject that
you are calling the selectPath method from. The '$this' construction is
not in the latest XPath/Xquery spec so it was deprecated, instead "."
should be used.

The current XmlObject can be bound to any user specified variable name
as in the following example:

        XmlOptions options = new XmlOptions();
        options.setXqueryCurrentNodeVar("myVariable");
        XmlObject[] res = xo.selectPath("declare variable $myVariable
external; $myVariable//el1", options);

Which is equivalent to:

        XmlObject[] res = xo.selectPath(".//el1", options);

And to the following (since in the context of the xpath engine the xo is
considered the root):

        XmlObject[] res = xo.selectPath("//el1", options);

Since we don't control Saxon, we can't promise that expressions
confirming to the spec will work. We can only work on making sure we
make the right calls into Saxon.

Cezar


> -----Original Message-----
> From: Siegfried Baiz [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 14, 2006 12:11 PM
> To: user@xmlbeans.apache.org
> Subject: selectPath with FilterExpression using $this
> 
> Hello,
> 
> for a given XmlObject xo with an ID-Attribute 'id',
> I've tried to launch the following xpath-expression:
> 
>     xo.selectPath("//[EMAIL PROTECTED]/@id]")
> 
> in order to get all nodes (with idRef-Attribute) refering to my node
xo.
> 
> Unfortunatlly this expression seems not to work. I always get an
> java.lang.ArrayIndexOutOfBoundsException from the underlying
>
net.sf.saxon.expr.XPathContextMajor.setLocalVariable(XPathContextMajor.j
av
> a:213)
> 
> At
>
http://xmlbeans.apache.org/docs/2.0.0/guide/conSelectingXMLwithXQueryPat
hX
> Path.html
> I found the following notice:
>       "Notice in the query expression that the variable $this
represents
>        the current context node (the XmlObject that you are querying
> from).
>        In this example you are querying from the document level
> XmlObject."
> 
> After reading that sentence I've been thinking, that $this is somehow
> similar to "curent()" in XSLT, but maybe a got the meaning wrong.
> 
> Does anyone know whats the problem here rsp.
> is there a better way to accomplish the same thing?
> 
> Thanks a lot,
> 
> Siggi
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to