zongaro     2003/12/08 10:25:43

  Modified:    java/src/org/apache/xalan/res XSLTErrorResources.java
               test/tests/conferr/variableerr variableerr05.xsl
                        variableerr06.xsl
               java/src/org/apache/xalan/templates ElemVariable.java
                        ElemWithParam.java
  Added:       test/tests/conferr/variableerr variableerr21.xml
                        variableerr21.xsl
  Log:
  Applying patch from Richard Cao ([EMAIL PROTECTED]) for Bugzilla bug report
  797.
  
  Added code that checks whether an xsl:param, xsl:variable or xsl:with-param
  has both a select attribute and content.  Also, new test case to test for
  message in case of xsl:with-param, and updated messages in existing tests for
  xsl:param and xsl:variable.
  
  Revision  Changes    Path
  1.42      +11 -1     
xml-xalan/java/src/org/apache/xalan/res/XSLTErrorResources.java
  
  Index: XSLTErrorResources.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/res/XSLTErrorResources.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- XSLTErrorResources.java   3 Sep 2003 19:49:41 -0000       1.41
  +++ XSLTErrorResources.java   8 Dec 2003 18:25:43 -0000       1.42
  @@ -433,7 +433,9 @@
     public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET";
     public static final String ER_FUNCTION_NOT_FOUND = 
         "ER_FUNCTION_NOT_FOUND"; 
  -
  +  public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = 
  +     "ER_CANT_HAVE_CONTENT_AND_SELECT";
  +     
     public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE";
     public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = 
         "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR";
  @@ -2145,6 +2147,14 @@
       { ER_FUNCTION_NOT_FOUND,
        "The function named {0} does not exist"},
   
  +    // Note to translators:  This message indicates that the XSLT instruction
  +    // that is named by the substitution text {0} must not contain other XSLT
  +    // instructions (content) or a "select" attribute.  The word "select" is
  +    // an XSLT keyword in this case and must not be translated.
  +//  ER_CANT_HAVE_CONTENT_AND_SELECT
  +//  public static final int ER_CANT_HAVE_CONTENT_AND_SELECT = 255;
  +    { ER_CANT_HAVE_CONTENT_AND_SELECT,
  +     "The {0} element must not have both content and a select attribute."},
   
   
   
  
  
  
  1.2       +2 -2      
xml-xalan/test/tests/conferr/variableerr/variableerr05.xsl
  
  Index: variableerr05.xsl
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/tests/conferr/variableerr/variableerr05.xsl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- variableerr05.xsl 14 Dec 2001 22:47:29 -0000      1.1
  +++ variableerr05.xsl 8 Dec 2003 18:25:43 -0000       1.2
  @@ -6,7 +6,7 @@
     <!-- DocVersion: 19991116 -->
     <!-- Section: 11.2 Values of Variables and Parameters  -->
     <!-- Purpose: Test for xsl:variable with both content and select. -->
  -  <!-- ExpectedException: xsl:variable cannot have both content and select 
attribute. -->
  +  <!-- ExpectedException: xsl:variable element must not have both content 
and a select attribute. -->
     <!-- Author: David Marston -->
   
   <xsl:template match="doc">
  @@ -16,4 +16,4 @@
     </out>
   </xsl:template>
   
  -</xsl:stylesheet>
  \ No newline at end of file
  +</xsl:stylesheet>
  
  
  
  1.2       +2 -2      
xml-xalan/test/tests/conferr/variableerr/variableerr06.xsl
  
  Index: variableerr06.xsl
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/tests/conferr/variableerr/variableerr06.xsl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- variableerr06.xsl 14 Dec 2001 22:47:29 -0000      1.1
  +++ variableerr06.xsl 8 Dec 2003 18:25:43 -0000       1.2
  @@ -6,7 +6,7 @@
     <!-- DocVersion: 19991116 -->
     <!-- Section: 11.2 Values of Variables and Parameters  -->
     <!-- Purpose: Test for xsl:param with both content and select. -->
  -  <!-- ExpectedException: xsl:param cannot have both content and select 
attribute. -->
  +  <!-- ExpectedException: xsl:param element must not have both content and a 
select attribute. -->
     <!-- Author: David Marston -->
   
   <xsl:param name="n" select="3">2</xsl:param>
  @@ -17,4 +17,4 @@
     </out>
   </xsl:template>
   
  -</xsl:stylesheet>
  \ No newline at end of file
  +</xsl:stylesheet>
  
  
  
  1.1                  
xml-xalan/test/tests/conferr/variableerr/variableerr21.xml
  
  Index: variableerr21.xml
  ===================================================================
  <?xml version="1.0"?>
  <doc>
    <item>1</item>
    <item>2</item>
    <item>3</item>
  </doc>
  
  
  1.1                  
xml-xalan/test/tests/conferr/variableerr/variableerr21.xsl
  
  Index: variableerr21.xsl
  ===================================================================
  <?xml version="1.0"?>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="1.0">
  
    <!-- FileName: variableerr21 -->
    <!-- Document: http://www.w3.org/TR/xslt -->
    <!-- DocVersion: 19991116 -->
    <!-- Section: 11.6 Passing Parameters to Templates  -->
    <!-- Purpose: Test for xsl:with-param with both content and select. -->
    <!-- ExpectedException: xsl:with-param element must not have both content 
and a select attribute. -->
    <!-- Author: Richard Cao -->
  
  <xsl:template match="doc">
    <xsl:call-template name="foo">
      <xsl:with-param name="bar" select="3">2</xsl:with-param>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template name="foo">
    <xsl:param name="bar" select="0"/>
    <out>
      <xsl:value-of select="$bar"/>
    </out>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.25      +22 -0     
xml-xalan/java/src/org/apache/xalan/templates/ElemVariable.java
  
  Index: ElemVariable.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemVariable.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- ElemVariable.java 17 Oct 2003 20:59:20 -0000      1.24
  +++ ElemVariable.java 8 Dec 2003 18:25:43 -0000       1.25
  @@ -66,6 +66,7 @@
   import org.apache.xpath.objects.XRTreeFrag;
   import org.apache.xpath.objects.XRTreeFragSelectWrapper;
   import org.apache.xpath.objects.XString;
  +import org.apache.xalan.res.XSLTErrorResources;
   
   /**
    * Implement xsl:variable.
  @@ -548,6 +549,27 @@
                        return true;
        }
        return false;
  +  }
  +  
  +  /**
  +   * Add a child to the child list. If the select attribute
  +   * is present, an error will be raised.
  +   *
  +   * @param elem New element to append to this element's children list
  +   *
  +   * @return null if the select attribute was present, otherwise the 
  +   * child just added to the child list 
  +   */
  +  public ElemTemplateElement appendChild(ElemTemplateElement elem)
  +  {
  +    // cannot have content and select
  +    if (m_selectPattern != null)
  +    {
  +      error(XSLTErrorResources.ER_CANT_HAVE_CONTENT_AND_SELECT, 
  +          new Object[]{"xsl:" + this.getNodeName()});
  +      return null;
  +    }
  +    return super.appendChild(elem);
     }
   
   }
  
  
  
  1.13      +22 -1     
xml-xalan/java/src/org/apache/xalan/templates/ElemWithParam.java
  
  Index: ElemWithParam.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemWithParam.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ElemWithParam.java        17 Oct 2003 20:59:19 -0000      1.12
  +++ ElemWithParam.java        8 Dec 2003 18:25:43 -0000       1.13
  @@ -58,6 +58,7 @@
   
   import javax.xml.transform.TransformerException;
   
  +import org.apache.xalan.res.XSLTErrorResources;
   import org.apache.xalan.transformer.TransformerImpl;
   import org.apache.xml.utils.QName;
   import org.apache.xpath.XPath;
  @@ -273,7 +274,27 @@
                m_selectPattern.getExpression().callVisitors(m_selectPattern, 
visitor);
       super.callChildVisitors(visitor, callAttrs);
     }
  -
  +  
  +  /**
  +   * Add a child to the child list. If the select attribute
  +   * is present, an error will be raised.
  +   *
  +   * @param elem New element to append to this element's children list
  +   *
  +   * @return null if the select attribute was present, otherwise the 
  +   * child just added to the child list 
  +   */
  +  public ElemTemplateElement appendChild(ElemTemplateElement elem)
  +  {
  +    // cannot have content and select
  +    if (m_selectPattern != null)
  +    {
  +      error(XSLTErrorResources.ER_CANT_HAVE_CONTENT_AND_SELECT, 
  +          new Object[]{"xsl:" + this.getNodeName()});
  +      return null;
  +    }
  +    return super.appendChild(elem);
  +  }
   
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to