Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-2543

document() function changed the context inside for-each

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.7.1
    • Fix Version/s: None
    • Component/s: XPath-function
    • Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)
    • Environment:
      Java 1.5 and 1.6

      Description

      I don't know if this is default/standard behaviour. But Sun JRE work fine with it, with Xalan 2.6.0

      XSL:
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="improvisation">
      <my:order>
      <order>3</order>
      <order>4</order>
      <order>2</order>
      <order>1</order>
      </my:order>

      <xsl:template match="/">
      <html>
      <body>
      <ul>
      <!-- document('')/*/my:order/order -->
      <xsl:for-each select="document('')//my:order/order" >
      <xsl:variable name="num" select="." />
      <li>Order: <xsl:value-of select="$num" /></li>
      <xsl:for-each select="/root/opt[@attr=$num]">
      <li>Value: <xsl:value-of select="." /></li>
      </xsl:for-each>
      </xsl:for-each>
      </ul>
      <ol>
      <xsl:for-each select="/root/opt">
      <li>XML: <xsl:value-of select="." /></li>
      </xsl:for-each>
      </ol>
      </body>
      </html>
      </xsl:template>

      </xsl:stylesheet>

      XML:
      <root>
      <opt attr="1">a</opt>
      <opt attr="2">b</opt>
      <opt attr="3">c</opt>
      <opt attr="4">d</opt>
      </root>

      Expected:
      <xsl:for-each select="/root/opt[@attr=$num]">
      return element from XML

      Acutal:
      <xsl:for-each select="/root/opt[@attr=$num]">
      has context in document('') and return nothing

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              wong.disaster Dean Wang
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: