I'm using Saxon The following is extracted from a much larger transform:


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"




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


    <xsl:function name="e:getPhase" as="xs:string">

        <xsl:text>Mixed Life Cycle</xsl:text>



    <xsl:template match="/">


        <xsl:variable name="phaseMap">

            <item phase="Planning"                   section="partTwo"/>

            <item phase="Full-Acquisition"           section="partTwo"/>

            <item phase="Operations and Maintenance" section="partThree"/>

            <item phase="Mixed Life Cycle"           section="partTwo"/>

            <item phase="Multi-Agency Collaboration" section="partFour"/>




            <xsl:variable name="phase" select="e:getPhase()"/>

            <xsl:variable name="part" select="$phaseMap/item[@phase=$phase]/@section"/>

            <example><xsl:value-of select="$part"/></example>






This small example produces the desired effect (the <example> tag text is "partTwo"), and Oxygen/XML’s debugger shows the correct variable values for $phase and $part.


When this construct is embedded in a much larger stylesheet, $part evaluates to an undefined value and produces incorrect output (the <example> tag text is empty).


If I replace the select expression in the definition of $part with




it starts working, and the Oxygen/XML debugger shows the expected values.


I've been unable to reproduce this in a simple example.  Apart from the size of the stylesheet, the only major difference between this example and the real thing is the function e:getPhase(), which does a lot more work in the full transform.  However, I have confirmed that $phase always has the expected value in both the full transform and the simple example above. The problem appears to be in the evaluation of the variable definition for $part.


At this point I don’t know if this is a bug in Saxon or a problem in Oxygen/XML, but I’m asking here in case it’s a known problem.