You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mm...@locus.apache.org on 2000/09/14 17:50:20 UTC
cvs commit: xml-xalan/java/src/org/apache/xpath/patterns StepPattern.java
mmidy 00/09/14 08:50:19
Modified: java/src/org/apache/xpath/compiler OpMap.java
java/src/org/apache/xpath/patterns StepPattern.java
Log:
Make sure attribute nodes are not matching node() for match patterns.
Revision Changes Path
1.3 +12 -3 xml-xalan/java/src/org/apache/xpath/compiler/OpMap.java
Index: OpMap.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/compiler/OpMap.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- OpMap.java 2000/07/30 22:40:50 1.2
+++ OpMap.java 2000/09/14 15:50:17 1.3
@@ -356,10 +356,19 @@
{
int argLenOfStep = getArgLengthOfStep(opPosOfStep);
// System.out.println("getStepLocalName.argLenOfStep: "+argLenOfStep);
- int index = (argLenOfStep == 3) ? m_opMap[opPosOfStep+5]
- : ((argLenOfStep == 1) ? -3 : -2);
+ int index;
+ switch(argLenOfStep)
+ {
+ case 0: index = OpCodes.EMPTY; break;
+ case 1: index = OpCodes.ELEMWILDCARD; break;
+ case 2: index = m_opMap[opPosOfStep+4]; break;
+ case 3: index = m_opMap[opPosOfStep+5]; break;
+ default: index = OpCodes.EMPTY; break; // Should assert error
+ }
+ // int index = (argLenOfStep == 3) ? m_opMap[opPosOfStep+5]
+ // : ((argLenOfStep == 1) ? -3 : -2);
if(index >= 0)
- return (String)m_tokenQueue[index];
+ return (String)m_tokenQueue[index].toString();
else if(OpCodes.ELEMWILDCARD == index)
return NodeTest.WILD;
else
1.6 +11 -1 xml-xalan/java/src/org/apache/xpath/patterns/StepPattern.java
Index: StepPattern.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/patterns/StepPattern.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StepPattern.java 2000/09/13 22:14:37 1.5
+++ StepPattern.java 2000/09/14 15:50:18 1.6
@@ -6,6 +6,7 @@
import org.apache.xalan.utils.PrefixResolver;
import org.apache.xpath.axes.SubContextList;
+import org.w3c.dom.traversal.NodeFilter;
import org.w3c.dom.Node;
import org.w3c.dom.traversal.NodeIterator;
@@ -65,7 +66,16 @@
public XObject executeStep(XPathContext xctxt)
throws org.xml.sax.SAXException
{
- XObject score = super.execute(xctxt);
+ XObject score;
+ Node context = xctxt.getCurrentNode();
+ int nodeType = context.getNodeType();
+ int whatToShow = getWhatToShow();
+ if(nodeType == Node.ATTRIBUTE_NODE &&
+ whatToShow != NodeFilter.SHOW_ATTRIBUTE)
+ score = NodeTest.SCORE_NONE;
+ else
+ score = super.execute(xctxt);
+
if(score == NodeTest.SCORE_NONE)
{
// System.out.println("executeStep: "+this.m_name+" = "+score);