[ 
https://issues.apache.org/jira/browse/XALANJ-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13109518#comment-13109518
 ] 

Dean Wang commented on XALANJ-2543:
-----------------------------------

I tested M$XML and Saxon. It seems to be a common behaviour. Could anyone tell 
me why document() function could affect the context outside the XPath 
expression?
http://www.w3.org/TR/xslt#document did not tell any thing about the context 
change.

> document() function changed the context inside for-each
> -------------------------------------------------------
>
>                 Key: XALANJ-2543
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2543
>             Project: XalanJ2
>          Issue Type: Bug
>      Security Level: No security risk; visible to anyone(Ordinary problems in 
> Xalan projects.  Anybody can view the issue.) 
>          Components: XPath-function
>    Affects Versions: 2.7.1
>         Environment: Java 1.5 and 1.6
>            Reporter: Dean Wang
>            Priority: Minor
>              Labels: context, document, function
>
> 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

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscr...@xml.apache.org
For additional commands, e-mail: xalan-dev-h...@xml.apache.org

Reply via email to