You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@apache.org on 2002/06/10 23:34:40 UTC
cvs commit: xml-xalan/java/src/org/apache/xpath/compiler Lexer.java
sboag 2002/06/10 14:34:40
Modified: java/src/org/apache/xalan/processor StylesheetHandler.java
java/src/org/apache/xalan/templates ElemNumber.java
ElemTemplateElement.java
java/src/org/apache/xml/utils PrefixResolver.java
PrefixResolverDefault.java
java/src/org/apache/xpath/compiler Lexer.java
Log:
Patch submitted by Ilene_Seelemann@us.ibm.com for Bug 6798:
Added a method (handlesNullPrefixes) to the PrefixResolver interface so
that the resolver can indicate whether it supports null prefixes. Then, in the
tokenizer, if the prefix is null, and the resolver supports that, it continues
processing as if the prefix had a value. In Lexer.java, methods that have
changed are: tokenize, mapNSTokens.
In ElemNumber#getCountMatchPattern, pass MyPrefixResolver instance to default
psuedo match patterns.
Revision Changes Path
1.52 +7 -0 xml-xalan/java/src/org/apache/xalan/processor/StylesheetHandler.java
Index: StylesheetHandler.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/processor/StylesheetHandler.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- StylesheetHandler.java 10 Jun 2002 19:24:41 -0000 1.51
+++ StylesheetHandler.java 10 Jun 2002 21:34:40 -0000 1.52
@@ -1705,6 +1705,13 @@
}
return (version == -1)? Constants.XSLTVERSUPPORTED : version;
}
+ /**
+ * @see PrefixResolver#handlesNullPrefixes()
+ */
+ public boolean handlesNullPrefixes() {
+ return false;
+ }
+
}
1.25 +64 -3 xml-xalan/java/src/org/apache/xalan/templates/ElemNumber.java
Index: ElemNumber.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemNumber.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- ElemNumber.java 24 Mar 2002 00:57:53 -0000 1.24
+++ ElemNumber.java 10 Jun 2002 21:34:40 -0000 1.25
@@ -63,6 +63,9 @@
import org.apache.xml.dtm.DTM;
import org.apache.xml.dtm.DTMIterator;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+//import org.w3c.dom.xpath.XPathResult;
import org.xml.sax.*;
import java.util.*;
@@ -73,6 +76,8 @@
import org.apache.xpath.*;
import org.apache.xpath.objects.XObject;
import org.apache.xpath.compiler.XPathParser;
+import org.apache.xml.utils.PrefixResolver;
+import org.apache.xml.utils.PrefixResolverDefault;
import org.apache.xml.utils.QName;
import org.apache.xml.utils.StringBufferPool;
import org.apache.xml.utils.FastStringBuffer;
@@ -105,9 +110,56 @@
* </pre>
* @see <a href="http://www.w3.org/TR/xslt#number">number in XSLT Specification</a>
*/
-public class ElemNumber extends ElemTemplateElement
+public class ElemNumber extends ElemTemplateElement implements PrefixResolver
{
+ private class MyPrefixResolver implements PrefixResolver {
+
+ DTM dtm;
+ int handle;
+ boolean handleNullPrefix;
+
+ /**
+ * Constructor for MyPrefixResolver.
+ * @param xpathExpressionContext
+ */
+ public MyPrefixResolver(Node xpathExpressionContext, DTM dtm, int handle, boolean handleNullPrefix) {
+ this.dtm = dtm;
+ this.handle = handle;
+ this.handleNullPrefix = handleNullPrefix;
+ }
+
+ /**
+ * @see PrefixResolver#getNamespaceForPrefix(String, Node)
+ */
+ public String getNamespaceForPrefix(String prefix) {
+ return dtm.getNamespaceURI(handle);
+ }
+
+ /**
+ * @see PrefixResolver#getNamespaceForPrefix(String, Node)
+ * this shouldn't get called.
+ */
+ public String getNamespaceForPrefix(String prefix, Node context) {
+ return getNamespaceForPrefix(prefix);
+ }
+
+ /**
+ * @see PrefixResolver#getBaseIdentifier()
+ */
+ public String getBaseIdentifier() {
+ return ElemNumber.this.getBaseIdentifier();
+ }
+
+ /**
+ * @see PrefixResolver#handlesNullPrefixes()
+ */
+ public boolean handlesNullPrefixes() {
+ return handleNullPrefix;
+ }
+
+}
+
/**
* Only nodes are counted that match this pattern.
* @serial
@@ -721,11 +773,18 @@
switch (dtm.getNodeType(contextNode))
{
case DTM.ELEMENT_NODE :
+ MyPrefixResolver resolver;
+
+ if (dtm.getNamespaceURI(contextNode) == null) {
+ resolver = new MyPrefixResolver(dtm.getNode(contextNode), dtm,contextNode, false);
+ } else {
+ resolver = new MyPrefixResolver(dtm.getNode(contextNode), dtm,contextNode, true);
+ }
- // countMatchPattern = m_stylesheet.createMatchPattern(contextNode.getNodeName(), this);
- countMatchPattern = new XPath(dtm.getNodeName(contextNode), this, this,
+ countMatchPattern = new XPath(dtm.getNodeName(contextNode), this, resolver,
XPath.MATCH, support.getErrorListener());
break;
+
case DTM.ATTRIBUTE_NODE :
// countMatchPattern = m_stylesheet.createMatchPattern("@"+contextNode.getNodeName(), this);
@@ -2137,5 +2196,7 @@
return count;
}
} // end NumberFormatStringTokenizer
+
+
}
1.53 +7 -0 xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java
Index: ElemTemplateElement.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- ElemTemplateElement.java 16 May 2002 18:29:21 -0000 1.52
+++ ElemTemplateElement.java 10 Jun 2002 21:34:40 -0000 1.53
@@ -1676,4 +1676,11 @@
}
+ /**
+ * @see PrefixResolver#handlesNullPrefixes()
+ */
+ public boolean handlesNullPrefixes() {
+ return false;
+ }
+
}
1.3 +2 -0 xml-xalan/java/src/org/apache/xml/utils/PrefixResolver.java
Index: PrefixResolver.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/PrefixResolver.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PrefixResolver.java 12 Jun 2001 19:15:59 -0000 1.2
+++ PrefixResolver.java 10 Jun 2002 21:34:40 -0000 1.3
@@ -103,4 +103,6 @@
* may not accurately reflect that context information.
*/
public String getBaseIdentifier();
+
+ public boolean handlesNullPrefixes();
}
1.3 +7 -0 xml-xalan/java/src/org/apache/xml/utils/PrefixResolverDefault.java
Index: PrefixResolverDefault.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/PrefixResolverDefault.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PrefixResolverDefault.java 30 Nov 2000 22:58:50 -0000 1.2
+++ PrefixResolverDefault.java 10 Jun 2002 21:34:40 -0000 1.3
@@ -179,4 +179,11 @@
{
return null;
}
+ /**
+ * @see PrefixResolver#handlesNullPrefixes()
+ */
+ public boolean handlesNullPrefixes() {
+ return false;
+ }
+
}
1.10 +7 -2 xml-xalan/java/src/org/apache/xpath/compiler/Lexer.java
Index: Lexer.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/compiler/Lexer.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Lexer.java 12 Sep 2001 20:01:02 -0000 1.9
+++ Lexer.java 10 Jun 2002 21:34:40 -0000 1.10
@@ -392,7 +392,7 @@
isNum = false;
isStartOfPat = mapPatternElemPos(nesting, isStartOfPat, isAttrName);
- if (-1 != posOfNSSep)
+ if ((-1 != posOfNSSep) || (m_namespaceContext.handlesNullPrefixes()))
{
posOfNSSep = mapNSTokens(pat, startSubstring, posOfNSSep, nChars);
}
@@ -611,7 +611,12 @@
throws javax.xml.transform.TransformerException
{
- String prefix = pat.substring(startSubstring, posOfNSSep);
+ String prefix = "";
+
+ if ((startSubstring >= 0) && (posOfNSSep >= 0))
+ {
+ prefix = pat.substring(startSubstring, posOfNSSep);
+ }
String uName;
if ((null != m_namespaceContext) &&!prefix.equals("*")
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org