Re: [xsl] How to create xsl:key that has a composite value in its "use" attribute?

Subject: Re: [xsl] How to create xsl:key that has a composite value in its "use" attribute?
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 15 Mar 2025 14:34:02 -0000
On 15/03/2025 15:22, Roger L Costello costello@xxxxxxxxx wrote:
Thank you. Below is a sample input document. The ANAV row with NAV_IDENT =
HUM, NAV_CTRY = AR, NAV_TYPE = 1 matches two BDRY row elements and the result
should be:



<result>


<BDRY_IDENT>Boundary 1</BDRY_IDENT>

<BDRY_IDENT>Boundary 2</BDRY_IDENT>

</result>


For instance, when I use your shown key in the code

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
B  version="3.0"
B  xmlns:xs="http://www.w3.org/2001/XMLSchema";
B  exclude-result-prefixes="#all"
B  expand-text="yes">

B <xsl:output method="xml" indent="yes"/>

B <xsl:mode on-no-match="shallow-skip"/>

B  <xsl:keyB B B  name="ANAV-to-BDRY" match="BDRY/row"
B B B  use="NAV_IDENT, NAV_CTRY, NAV_TYPE "
B B B  composite="yes"/>

B  <xsl:template match="ANAV/row">
B B B  <xsl:copy>
B B B B B  <xsl:sequence select="ARPT_IDENT, key('ANAV-to-BDRY', (NAV_IDENT,
NAV_CTRY, NAV_TYPE))/BDRY_IDENT"/>
B B B  </xsl:copy>
B  </xsl:template>

</xsl:stylesheet>

the result is e.g.

<row>
B B  <ARPT_IDENT>ABC</ARPT_IDENT>
B B  <BDRY_IDENT>Boundary 1</BDRY_IDENT>
B B  <BDRY_IDENT>Boundary 2</BDRY_IDENT>
</row>
<row>
B B  <ARPT_IDENT>DEF</ARPT_IDENT>
B B  <BDRY_IDENT>Boundary 3</BDRY_IDENT>
B B  <BDRY_IDENT>Boundary 4</BDRY_IDENT>
</row>


which seems to make sense.


Current Thread