Hi Folks,
This is an extension to a question that I had last week ...
Recall that I want to group the <row> elements in the following XML. Each group
should consist of those <row> elements that have the same ARPT__IDENT,
TRM__IDENT values.
<Test>
<row>
<ARPT__IDENT>A</ARPT__IDENT>
<TRM__IDENT>X</TRM__IDENT>
<Data>Foo</Data>
</row>
<row>
<ARPT__IDENT>A</ARPT__IDENT>
<TRM__IDENT>X</TRM__IDENT>
<Data>Bar</Data>
</row>
<row>
<ARPT__IDENT>A</ARPT__IDENT>
<TRM__IDENT>Y</TRM__IDENT>
<Data>Blah</Data>
</row>
<row>
<ARPT__IDENT>A</ARPT__IDENT>
<TRM__IDENT>Y</TRM__IDENT>
<Data>Plugh</Data>
</row>
</Test>
That XML consists of two groups. Each group has two <row> elements.
Martin provided a great XPath 3.1 expression for doing the grouping:
<xsl:variable name="groups" as="array(element(row))*" select="
let $keys :=
distinct-values($rows/concat(ARPT__IDENT, '|', TRM__IDENT))
return
for $i in $keys
return
array {$rows[$i = concat(ARPT__IDENT, '|', TRM__IDENT)] }
"/>
In the following, I select the first group:
<xsl:variable name="first-group" select="$groups[1]" />
Next, I want to select the <row> element in the first group that has Foo as the
value of the <Data> element. I thought that this would be the appropriate XPath
expression:
<xsl:variable name="Foo-row-first-group" select="$first-group/row[Data eq
'Foo']"/>
Apparently it is not the appropriate XPath expression, because I get this error
message:
Axis step child::element(Q{}row) cannot
be used here: the context item is not a node
What is the appropriate XPath expression, please?
/Roger
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--