- From: Kay, Michael <Michael.Kay@softwareag.com>
- Date: Mon, 2 Jun 2003 16:58:46 +0200
- To: winkowski@mitre.org, public-qt-comments@w3.org
You can achieve this in XPath 2.0 using constructs such as: every $i in 1 to count(/msg/a) satisfies /msg/a[$i]/a1 = /msg/b[$i]/b1 Regards, Michael Kay > -----Original Message----- > From: winkowski@mitre.org [mailto:winkowski@mitre.org] > Sent: 30 May 2003 16:53 > To: public-qt-comments@w3.org > Subject: support for aligned iterations > > > > I have a document such as: > > <msg> > <a> > <a1>xxx</a1> > </a> > <a> > <a1>xxx</a1> > </a> > <a> > <a1>xxx</a1> > </a> > <b> > <b1>xxx</b1> > </b> > <b> > <b1>xxx</b1> > </b> > <b> > <b1>xxx</b1> > </b> > <c> > <c1>xxx</c1> > </c> > <c> > <c1>xxx</c1> > </c> > <c> > <c1>xxx</c1> > </c> > </msg> > > I need to apply a test/operator over /msg/a/a1 and /msg/b/b1 > such that the evaluation is aligned over corresponding pairs > of a1,b1 in document order. That is, test the first > corresponding pair /msg/a[1]/a1 and /msg/b[1]/b1, the second > corresponding pair /msg/a[2]/a1 and /msg/b[2]/b1, etc... > > I am deriving the XPath expression directly from a constraint > language and would like to stick as close to XPath as > possible. These XPath expressions could then be compiled into > a language such as XSL or Java for evaluation. > > I found I needed to introduce a new variable notation ($$) > into XPath to indicate this. Say the test was equality then > an example is: /msg/a[position=$$A]/a1 = /msg/b[position=$$A]/b1 > > As a result I no longer produce XPath 1.0 but something else. > These new variables need to be addressed in the compilation > stage when building XSL or Java code. My question is will > XPath 2.0 support document ordered iteration over multiple paths? > > The constraint language consists of a statement and > condition. So a more complex rule stating that if > corresponding c1's are greater than the corresponding b1's > then the corresponding a1's must equal the corresponding > b1's: > (/msg/a[position=$$A]/a1 = /msg/b[position=$$A]/b1) and > (/msg/c[position=$$A]/c1 > /msg/b[position=$$A]/b1) > > Complex rules may result in multiple corresponding variables > as well ($$A, $$B, ...). > > - Dan > > >
Received on Monday, 2 June 2003 10:59:06 UTC