← Prev in month
← Prev in thread
Issue - 63 - For Each?
The following are thoughts I've had on how we could address issue 63.
Although these thoughts are still fairly rough I wanted to release them
now because 63 is on the agenda for the F2F. Since these are early
thoughts I reserve the right to disavow them at any time.
I thought an easy way to provide the feature asked for in 63 is to
provide a macro that has proven its utility in numerous structured
languages - For Each.
I was thinking of a syntax like:
<foreach sourceVariable="ncname" part="ncname"? \
iteratorVariableName="ncname" iteratorVariableType="qname"
standard-attributes>
standard-elements
<query language="anyURI">...</query>
activity
</foreach>
The idea is that the query element would be an expression that generates
zero or more nodes. Each generated node would be assigned to a local
variable whose name is given in iteratorVariableName and whose type is
iteratorVariableType. The foreach would then walk through each node one
by one in document order. If no nodes are returned then the activity
would do nothing.
For example:
foreach sourceVariable="orderManifest" part="somePart"\
iteratorVariableName="anOrder" iteratorVariableType="b:ar"
query language="http://www.w3.org/TR/1999/REC-xpath-19991116"
ordermanifest/orders
...
Would be a Macro for:
scope
variables
variable name="anOrder" type="b:ar"
variable name="currentInstanceNum" type="xs:int"
sequence
assign
copy
from
"1"
to variable="currentInstanceNum"
while condition="$currentInstanceNum <=\
count($orderList/somePart/ordermanifest/orders)"
assign
copy
from variable="orderList" part="somePart"
query
"(/ordermanifest/orders)[$currentInstanceNum]"
to variable="anOrder"
assign
copy
from
expression
"$currentInstanceNum+1"
to variable="currentInstanceNum"
...
← Prev in month
← Prev in thread