Duh, so of course: - . represents the "current" node that the Xpath evaluator is processing - $this represents the node where the Xpath was started on and is something outside of the Xpath standard
So, if you want to get the node having an attribute 'idref' with value equals to that of the 'id' attribute of XmlObject xo, what has been suggested at some point in this thread does in fact work (assuming the latest fixes and updates): xo.selectPath("//[EMAIL PROTECTED]/@id]") Radu -----Original Message----- From: Radu Preotiuc-Pietro Sent: Thursday, March 30, 2006 1:56 PM To: user@xmlbeans.apache.org Subject: RE: selectPath with FilterExpression using $this I was curious to try this myself with the new Saxon 8.6 integration (available from the SVN head only, for the moment) and what I found is that the path you are suggesting ("//[EMAIL PROTECTED]/@id]") works (no exception) but for some reason doesn't return anything. On the other hand, "//[EMAIL PROTECTED]'1'" returns the expected result, so on one hand I am wondering if this is maybe a bug in the free version of Saxon and on the other you can use this to workaround the problem by doing .selectPath("//[EMAIL PROTECTED]'" + node.getId() + "'"). If anyone else has other insights into why the original path does not work (with more Xpath/Saxon knowledge), I'd also be interested to know. Thanks, Radu -----Original Message----- From: Cezar Andrei Sent: Wednesday, March 29, 2006 3:30 PM To: user@xmlbeans.apache.org Subject: RE: selectPath with FilterExpression using $this 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] _______________________________________________________________________ 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] _______________________________________________________________________ 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]