[xsl] double document merge using keys

Subject: [xsl] double document merge using keys
From: Terry Ofner <tdofner@xxxxxxxxx>
Date: Thu, 24 Jun 2010 10:36:30 -0400
Is it possible to "key" on two values during a document merge? Let me

I have document that includes lesson name and the page range of the lesson:

Writing with Power
Pages 512

Collaborating Through the Writing Process
Pages 1332

I have transformed the information into the following xml:

       <Chapterlesson code="6.1.1">
         <lesson>Writing with Power </lesson>
      <Chapterlesson code="6.1.2">
         <lesson>Collaborating Through the Writing Process </lesson>

I have a set of standards that need to be aligned with each lesson. The
standards are coded to the page, not the lesson. Here is a snippet of the
current xml of standardDoc.xml:

   <stand startNum="5" endNum="5">19.A.4</stand>
   <stand startNum="11" endNum="11">14.D.2</stand>
   <stand startNum="11" endNum="11">14.D.3</stand>
   <stand startNum="13" endNum="14">14.A.2</stand>
   <stand startNum="15" endNum="15">14.A.1</stand>
   <stand startNum="16" endNum="16">14.A.1</stand>

The following stylesheet works as far as it goes. It only captures the
standards that match the start page of the lesson. What I need is way to
address standards with startNum >= $localStart and <= $localEnd. Is there a
way to do this using keys?

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

    <xsl:variable name="stand2page" select="document('stand2page.xml')"/>
    <xsl:key name="standPage" match="stand" use="@startNum"/>

<xsl:template match="Chapterlesson">
            <xsl:copy-of select="@*"/>
            <xsl:variable name="localStart" select="startNum"/>
            <xsl:variable name="localEnd" select="endNum"/>
            <xsl:for-each select="$stand2page">
                <stand><xsl:copy-of select="key('standPage',

Current Thread