sboag       00/12/09 21:19:57

  Modified:    java/src/org/apache/xalan/templates TemplateList.java
  Log:
  Set the PrefixResolver to the template being matched before executing
  the match expression.  This is needed so that XSLT functions,
  like xsl:key, can get to their template context.  This fixes test idkey03.
  
  Revision  Changes    Path
  1.26      +10 -2     
xml-xalan/java/src/org/apache/xalan/templates/TemplateList.java
  
  Index: TemplateList.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/TemplateList.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- TemplateList.java 2000/12/05 16:33:45     1.25
  +++ TemplateList.java 2000/12/10 05:19:57     1.26
  @@ -67,6 +67,7 @@
   import javax.xml.transform.TransformerException;
   
   import org.apache.xml.utils.QName;
  +import org.apache.xml.utils.PrefixResolver;
   import org.apache.xpath.XPath;
   import org.apache.xpath.compiler.PsuedoNames;
   import org.apache.xpath.patterns.NodeTest;
  @@ -522,6 +523,10 @@
   
       if (null != head)
       {
  +      // XSLT functions, such as xsl:key, need to be able to get to 
  +      // current ElemTemplateElement via a cast to the prefix resolver.
  +      // Setting this fixes bug idkey03.
  +      PrefixResolver savedPR = xctxt.getNamespaceContext();
         try
         {
           xctxt.pushCurrentNodeAndExpression(targetNode, targetNode);
  @@ -532,14 +537,16 @@
             {
               continue;
             }
  -
  +          ElemTemplate template = head.getTemplate();        
  +          xctxt.setNamespaceContext(template);
  +          
             if ((head.m_stepPattern.execute(xctxt) != NodeTest.SCORE_NONE)
                     && head.matchMode(mode))
             {
               if (quietConflictWarnings)
                 checkConflicts(head, xctxt, targetNode, mode);
   
  -            return head.getTemplate();
  +            return template;
             }
           }
           while (null != (head = head.getNext()));
  @@ -547,6 +554,7 @@
         finally
         {
           xctxt.popCurrentNodeAndExpression();
  +        xctxt.setNamespaceContext(savedPR);
         }
       }
   
  
  
  

Reply via email to