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...@locus.apache.org on 2000/03/13 17:46:15 UTC
cvs commit: xml-xalan/src/org/apache/xalan/xpath SimpleNodeLocator.java XPathProcessorImpl.java
sboag 00/03/13 08:46:15
Modified: src/org/apache/xalan/xpath SimpleNodeLocator.java
XPathProcessorImpl.java
Log:
Fix for namespace axes (namespace::foo) namespace comparison -- compare using resolved namespace, instead of prefix.
Revision Changes Path
1.19 +2 -7 xml-xalan/src/org/apache/xalan/xpath/SimpleNodeLocator.java
Index: SimpleNodeLocator.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/SimpleNodeLocator.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- SimpleNodeLocator.java 2000/03/06 20:13:29 1.18
+++ SimpleNodeLocator.java 2000/03/13 16:46:14 1.19
@@ -1749,14 +1749,9 @@
{
if(isNamespace)
{
- String localAttrName
- = execContext.getLocalNameOfNode(context);
+ String namespace = ((Attr)context).getValue();
- // I'm not sure how the draft expects this to work, i.e.
- // can I do namespace::xmlns:foo or namespace::foo?
- // I let them do both, since I can not otherwise see how
- // one does the default namespace, i.e. namespace::xmlns.
- score = localAttrName.equals(targetLocalName)
+ score = namespace.equals(targetLocalName)
? XPath.MATCH_SCORE_QNAME : XPath.MATCH_SCORE_NONE;
}
else
1.27 +33 -14 xml-xalan/src/org/apache/xalan/xpath/XPathProcessorImpl.java
Index: XPathProcessorImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/XPathProcessorImpl.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- XPathProcessorImpl.java 2000/03/02 10:22:13 1.26
+++ XPathProcessorImpl.java 2000/03/13 16:46:14 1.27
@@ -2102,22 +2102,25 @@
throws org.xml.sax.SAXException
{
int opPos = m_xpath.m_opMap[XPath.MAPINDEX_LENGTH];
+ int axesType;
// The next blocks guarantee that a FROM_XXX will be added.
if(lookahead("::", 1))
{
- AxisName();
+ axesType = AxisName();
nextToken();
nextToken();
}
else if(tokenIs('@'))
{
- appendOp(2, XPath.FROM_ATTRIBUTES);
+ axesType = XPath.FROM_ATTRIBUTES;
+ appendOp(2, axesType);
nextToken();
}
else if(tokenIs('/'))
{
- appendOp(2, XPath.FROM_DESCENDANTS_OR_SELF);
+ axesType = XPath.FROM_DESCENDANTS_OR_SELF;
+ appendOp(2, axesType);
// Have to fix up for patterns such as '//@foo' or '//attribute::foo',
// which translate to 'descendant-or-self::node()/attribute::foo'.
@@ -2143,13 +2146,14 @@
}
else
{
- appendOp(2, XPath.FROM_CHILDREN);
+ axesType = XPath.FROM_CHILDREN;
+ appendOp(2, axesType);
}
// Make room for telling how long the step is without the predicate
m_xpath.m_opMap[XPath.MAPINDEX_LENGTH] += 1;
- NodeTest();
+ NodeTest(axesType);
// Tell how long the step is without the predicate
m_xpath.m_opMap[opPos + XPath.MAPINDEX_LENGTH + 1] = m_xpath.m_opMap[XPath.MAPINDEX_LENGTH] - opPos;
@@ -2160,7 +2164,7 @@
* Basis ::= AxisName '::' NodeTest
* | AbbreviatedBasis
*/
- protected void AxisName()
+ protected int AxisName()
throws org.xml.sax.SAXException
{
Object val = m_axisnames.get(m_token);
@@ -2168,7 +2172,9 @@
{
error(XPATHErrorResources.ER_ILLEGAL_AXIS_NAME, new Object[] {m_token}); //"illegal axis name: "+m_token);
}
- appendOp(2, ((Integer)val).intValue());
+ int axesType = ((Integer)val).intValue();
+ appendOp(2, axesType);
+ return axesType;
}
@@ -2178,7 +2184,7 @@
* | NodeType '(' ')'
* | 'processing-instruction' '(' Literal ')'
*/
- protected void NodeTest()
+ protected void NodeTest(int axesType)
throws org.xml.sax.SAXException
{
if(lookahead('(', 1))
@@ -2237,6 +2243,12 @@
}
else
{
+ if(XPath.FROM_NAMESPACE == axesType)
+ {
+ String prefix = (String)this.m_xpath.m_tokenQueue[this.m_xpath.m_opMap[m_queueMark-1]];
+ String namespace = ((PrefixResolver)m_namespaceContext).getNamespaceForPrefix(prefix);
+ this.m_xpath.m_tokenQueue[this.m_xpath.m_opMap[m_queueMark-1]] = namespace;
+ }
m_xpath.m_opMap[m_xpath.m_opMap[XPath.MAPINDEX_LENGTH]] = m_queueMark-1;
}
@@ -2505,26 +2517,31 @@
throws org.xml.sax.SAXException
{
int opPos = m_xpath.m_opMap[XPath.MAPINDEX_LENGTH];
+ int axesType;
// The next blocks guarantee that a MATCH_XXX will be added.
int matchTypePos = -1;
if(tokenIs('@'))
{
- appendOp(2, XPath.MATCH_ATTRIBUTE);
+ axesType = XPath.MATCH_ATTRIBUTE;
+ appendOp(2, axesType);
nextToken();
}
else if(this.lookahead("::", 1))
{
if(tokenIs("attribute"))
{
- appendOp(2, XPath.MATCH_ATTRIBUTE);
+ axesType = XPath.MATCH_ATTRIBUTE;
+ appendOp(2, axesType);
}
else if(tokenIs("child"))
{
- appendOp(2, XPath.MATCH_IMMEDIATE_ANCESTOR);
+ axesType = XPath.MATCH_IMMEDIATE_ANCESTOR;
+ appendOp(2, axesType);
}
else
{
+ axesType = -1;
this.error(XPATHErrorResources.ER_AXES_NOT_ALLOWED, new Object[] {this.m_token});
}
nextToken();
@@ -2532,7 +2549,8 @@
}
else if(tokenIs('/'))
{
- appendOp(2, XPath.MATCH_ANY_ANCESTOR);
+ axesType = XPath.MATCH_ANY_ANCESTOR;
+ appendOp(2, axesType);
nextToken();
}
else
@@ -2542,13 +2560,14 @@
nextToken();
}
matchTypePos = m_xpath.m_opMap[XPath.MAPINDEX_LENGTH];
- appendOp(2, XPath.MATCH_IMMEDIATE_ANCESTOR);
+ axesType = XPath.MATCH_IMMEDIATE_ANCESTOR;
+ appendOp(2, axesType);
}
// Make room for telling how long the step is without the predicate
m_xpath.m_opMap[XPath.MAPINDEX_LENGTH] += 1;
- NodeTest();
+ NodeTest(axesType);
// Tell how long the step is without the predicate
m_xpath.m_opMap[opPos + XPath.MAPINDEX_LENGTH + 1] = m_xpath.m_opMap[XPath.MAPINDEX_LENGTH] - opPos;