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 Friday, 30 May 2003 11:57:13 UTC