You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by sh...@apache.org on 2001/12/08 23:53:48 UTC

cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv JstlXmlTLV.java

shawn       01/12/08 14:53:48

  Modified:    standard/src/org/apache/taglibs/standard/resources
                        Resources.properties
               standard/src/org/apache/taglibs/standard/tlv JstlXmlTLV.java
  Log:
  Fixed error in XML library's validator:  <transform> may contain body
  even with 'source' attribute, providing that that body consists entirely
  of whitespace and <param> tags.  (The <param> tags, however, can contain
  arbitrary body if their 'value' attribute isn't specified.)
  
  Revision  Changes    Path
  1.3       +4 -0      jakarta-taglibs/standard/src/org/apache/taglibs/standard/resources/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/resources/Resources.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Resources.properties	2001/11/21 16:17:04	1.2
  +++ Resources.properties	2001/12/08 22:53:48	1.3
  @@ -118,6 +118,10 @@
       Filter supplied to &lt;parse&gt;, but default TransformerFactory \
       does not support SAX.
   
  +TRANSFORM_NO_TRANSFORMER=\
  +    &lt;transform&gt; needs either an 'xslt' attribute or a \
  +    'transformer' attribute
  +
   
   #########################################################################
   # JSTL core TLV messages
  
  
  
  1.4       +33 -1     jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlXmlTLV.java
  
  Index: JstlXmlTLV.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlXmlTLV.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JstlXmlTLV.java	2001/11/25 17:09:40	1.3
  +++ JstlXmlTLV.java	2001/12/08 22:53:48	1.4
  @@ -149,6 +149,7 @@
   	private String lastElementName = null;
   	private boolean bodyNecessary = false;
   	private boolean bodyIllegal = false;
  +	private Stack transformWithSource = new Stack();
   
   	public Handler() {
   	    // "install" the default evaluator
  @@ -225,6 +226,18 @@
   
   	    }
   
  +	    // Specific check, directly inside <transform source="...">
  +	    if (!transformWithSource.empty() &&
  +		    topDepth(transformWithSource) == (depth - 1)) {
  +		// only allow <param>
  +		if (!isTag(qn, PARAM))
  +		    fail(Resources.getMessage("TLV_ILLEGAL_BODY",
  +			prefix + ":" + TRANSFORM));
  +
  +		// thus, if we get the opportunity to hit depth++,
  +		// we know we've got a <param> subtag
  +	    }
  +
   	    // now, modify state
   
   	    // we're a choose, so record new choose-specific state
  @@ -236,7 +249,7 @@
   	    // set up a check against illegal attribute/body combinations
   	    bodyIllegal = false;
   	    bodyNecessary = false;
  -	    if (isTag(qn, PARSE) || isTag(qn, TRANSFORM)) {
  +	    if (isTag(qn, PARSE)) {
   		if (hasAttribute(a, SOURCE))
   		    bodyIllegal = true;
   	    } else if (isTag(qn, PARAM)) {
  @@ -244,6 +257,9 @@
   		    bodyIllegal = true;
   		else
   		    bodyNecessary = true;
  +	    } else if (isTag(qn, TRANSFORM)) {
  +		if (hasAttribute(a, SOURCE))
  +		    transformWithSource.push(new Integer(depth));
   	    }
   
   	    // record the most recent tag (for error reporting)
  @@ -274,6 +290,13 @@
   			(s.length() < 7 ? s : s.substring(0,7)));
   		fail(msg);
   	    }
  +
  +            // Specific check, directly inside <transform source="...">
  +            if (!transformWithSource.empty()
  +		    && topDepth(transformWithSource) == (depth - 1)) {
  +                fail(Resources.getMessage("TLV_ILLEGAL_BODY",
  +                    prefix + ":" + TRANSFORM));
  +            }
   	}
   
   	public void endElement(String ns, String ln, String qn) {
  @@ -294,6 +317,11 @@
   		chooseHasOtherwise.pop();
   	    }
   
  +	    // update <transform source="...">-related state
  +	    if (!transformWithSource.empty()
  +		    && topDepth(transformWithSource) == (depth - 1))
  +		transformWithSource.pop();
  +
   	    // update language state
   	    if (isTag(qn, EXPLANG))
   		expressionLanguage.pop();
  @@ -308,5 +336,9 @@
   		&& (depth - 1) == ((Integer) chooseDepths.peek()).intValue());
   	}
   
  +        // returns the top int depth (peeked at) from a Stack of Integer
  +        private int topDepth(Stack s) {
  +            return ((Integer) s.peek()).intValue();
  +        }
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>