You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by zo...@apache.org on 2005/12/01 23:01:02 UTC

svn commit: r351494 - /xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Whitespace.java

Author: zongaro
Date: Thu Dec  1 14:00:53 2005
New Revision: 351494

URL: http://svn.apache.org/viewcvs?rev=351494&view=rev
Log:
Fix for XALANJ-2230.  There were two problems that together combined to make
a third:

1) By the time the NameTests in xsl:strip-space/xsl:preserve-space get to the
WhitespaceRule constructor, any namespace prefix has been resolved, and the
test rendered in a String as uri:local-name.  The problem was that this
constructor searched for the first colon in the String in order to separate
the URI from the local-name, but the URI could itself contain a colon.  It
should have searched for the last colon in the String.

2) For a NameTest that has no prefix, the code in parseContents() was looking
up the namespace associated with the default namespace.  However, the NameTest
should behave like any other XPath NameTest - i.e., a NameTest that is not a
wild-card that has no prefix should match only names that are in no namespace.
The namespace URI should only be looked up if there is a prefix.

3) If no URI was associated with the default namespace, a NameTest with no
prefix was rewritten in the form ":local-name" or ":*" for wild cards.  The
code in the WhitespaceRule constructor handled the local name case correctly,
but treated the wild card case as if it was testing for a namespace, but that
test never found a match.  Dropping the look up of the default namespace in the
problem described above eliminates these degenerate forms, which allows the
wild card to match appropriately.

Patch was reviewed by Christine Li (jycli () ca ! ibm ! com).

Modified:
    xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Whitespace.java

Modified: xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Whitespace.java
URL: http://svn.apache.org/viewcvs/xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Whitespace.java?rev=351494&r1=351493&r2=351494&view=diff
==============================================================================
--- xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Whitespace.java (original)
+++ xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Whitespace.java Thu Dec  1 14:00:53 2005
@@ -76,7 +76,7 @@
 	    _action = action;
 
 	    // Get the namespace and element name for this rule
-	    final int colon = element.indexOf(':');
+	    final int colon = element.lastIndexOf(':');
 	    if (colon >= 0) {
 		_namespace = element.substring(0,colon);
 		_element = element.substring(colon+1,element.length());
@@ -126,48 +126,46 @@
      * The element should have not contents (ignored if any).
      */
     public void parseContents(Parser parser) {
-	// Determine if this is an xsl:strip- or preserve-space element
-	_action = _qname.getLocalPart().endsWith("strip-space") 
-	    ? STRIP_SPACE : PRESERVE_SPACE;
-
-	// Determine the import precedence
-	_importPrecedence = parser.getCurrentImportPrecedence();
-
-	// Get the list of elements to strip/preserve
-	_elementList = getAttribute("elements");
-	if (_elementList == null || _elementList.length() == 0) {
-	    reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "elements");
-	    return;
-	}
-
-	final SymbolTable stable = parser.getSymbolTable();
-	StringTokenizer list = new StringTokenizer(_elementList);
-	StringBuffer elements = new StringBuffer(Constants.EMPTYSTRING);
-
-	while (list.hasMoreElements()) {
-	    String token = list.nextToken();
-	    String prefix;
-	    String namespace;
-	    int col;
-
-	    if ((col = token.indexOf(':')) != -1) {
-		prefix  = token.substring(0,col);
-	    }
-	    else {
-		prefix = Constants.EMPTYSTRING;
-	    }
-
-	    namespace = lookupNamespace(prefix);
-	    if (namespace != null)
-		elements.append(namespace+":"+
-				token.substring(col+1,token.length()));
-	    else
-		elements.append(token);
-
-	    if (list.hasMoreElements())
-		elements.append(" ");
-	}
-	_elementList = elements.toString();
+        // Determine if this is an xsl:strip- or preserve-space element
+        _action = _qname.getLocalPart().endsWith("strip-space") 
+            ? STRIP_SPACE : PRESERVE_SPACE;
+
+        // Determine the import precedence
+        _importPrecedence = parser.getCurrentImportPrecedence();
+
+        // Get the list of elements to strip/preserve
+        _elementList = getAttribute("elements");
+        if (_elementList == null || _elementList.length() == 0) {
+            reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "elements");
+            return;
+        }
+
+        final SymbolTable stable = parser.getSymbolTable();
+        StringTokenizer list = new StringTokenizer(_elementList);
+        StringBuffer elements = new StringBuffer(Constants.EMPTYSTRING);
+
+        while (list.hasMoreElements()) {
+            String token = list.nextToken();
+            String prefix;
+            String namespace;
+            int col = token.indexOf(':');
+
+            if (col != -1) {
+                namespace = lookupNamespace(token.substring(0,col));
+                if (namespace != null) {
+                    elements.append(namespace+":"+
+                                    token.substring(col+1,token.length()));
+                } else {
+                    elements.append(token);
+                }
+            } else {
+                elements.append(token);
+            }
+
+            if (list.hasMoreElements())
+                elements.append(" ");
+        }
+        _elementList = elements.toString();
     }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org