[xsl] context and conditional statement problem

Subject: [xsl] context and conditional statement problem
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Tue, 7 Dec 2004 09:05:20 -0500
I'm totally stumped. I've got a course syllabus document (and schema), which includes among other things this:

    <assignments>
      <assignment idref="breakfast" due="2004-01-19">
      </assignment>
      <assignment idref="econ-global" due="2004-02-03">
      </assignment>
      <assignment idref="tshirt-travels" due="2004-02-20">
      </assignment>
      <assignment idref="terror" due="2004-03-23">
      </assignment>
      <assignment idref="migrant-culture" due="2004-04-14">
      </assignment>
    </assignments>

These then point to a separate file, which has stuff like:

  <assignment id="econ-global">
    ...
  </assignment>

Sooo, I create a global variable to pull in these nodes:

<xsl:variable name="assignment-links" select="//assignment/@idref" />
<xsl:variable name="assignments-db" select="document('assignments.xml')" />
<xsl:variable name="assignments">
<assignments>
<xsl:for-each select="$assignment-links">
<xsl:copy-of select="$assignments-db/assignments/assignment[@id='{.}']" />
<test XXX="{.}"/>
</xsl:for-each>
</assignments>
</xsl:variable>


The conditional statement doesn't work. However -- and this is what I don't understand -- if I put in a valid value in place of the current '{.}', it does work. Similarly, note the test element correctly gets the id values from the other file:

           <h3 id="assignments">Assignments</h3>
            <ol></ol>
            <assignments>
               <test XXX="breakfast"></test>
               <test XXX="econ-global"></test>
               <test XXX="tshirt-travels"></test>
               <test XXX="terror"></test>
               <test XXX="migrant-culture"></test>
            </assignments>

Here's the template I use above (mostly to try to understand what's going on):

  <xsl:template match="assignments">
    <h3 id="assignments">Assignments</h3>
    <ol>
      <xsl:apply-templates select="$assignments/assignment"/>
    </ol>
    <xsl:copy-of select="$assignments" />
  </xsl:template>

Any ideas?

Bruce

Current Thread