Project

Profile

Help

Bug #1903 ยป keymap.xsl

David Rudel, 2013-09-17 15:44

 
<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:saxon="http://saxon.sf.net/"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
>
<xsl:key name="key" match="cars/car" use="@id" saxon:range-key="yes"/>
<xsl:variable name="car.doc">
<cars>
<car id="1"/>
<car id="2"/>
<car id="3"/>
<car id="9"/>
</cars>
</xsl:variable>
<xsl:variable name="seq" select="0,1,2,3,4,5"/>

<xsl:template match="/">
<xsl:text>
</xsl:text>
<xsl:variable name="map1" select="saxon:key-map('key',$car.doc,'0','2')"/>
<xsl:value-of select="map:keys($map1)"/>
<xsl:text>
</xsl:text>
<xsl:variable name="map2" select="saxon:key-map('key',$car.doc,'5','8')"/>
<xsl:value-of select="map:keys($map2)"/>
</xsl:template>
</xsl:stylesheet>
    (1-1/1)