- From: Michael Brundage <xquery@attbi.com>
- Date: Sat, 31 May 2003 17:37:39 -0700
- To: <winkowski@mitre.org>, <public-qt-comments@w3.org>
If the built-in functions count, then pairwise equality can be tested using deep-equal deep-equal(/msg/a, /msg/b) or deep-equal(/msg/a/a1, /msg/b/b1) (depending on the effect you wanted; I couldn't tell whether you wanted equality only when for each a and b their children were equal, or if you just wanted all a1 equal to all b1) Ideally, we'd have full second-order functions, and then you could do apply-memberwise($path1, $path2, gt) and apply-memberwise($path3, $path2, eq) but unfortunately, it's not an ideal world. For general-purpose joins between two sequences (which is what you're essentially doing), you need to resort to FLWOR or quantification (some, every) expressions. -----Original Message----- From: public-qt-comments-request@w3.org [mailto:public-qt-comments-request@w3.org] On Behalf Of winkowski@mitre.org Sent: Friday, May 30, 2003 8:53 AM 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 Saturday, 31 May 2003 20:36:42 UTC