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...@apache.org on 2002/11/14 23:43:00 UTC
cvs commit: xml-xalan/java/src/org/apache/xpath/operations Is.java IsNot.java
mmidy 2002/11/14 14:43:00
Modified: java/src/org/apache/xalan/templates Tag: xslt20
ElemNumber.java
java/src/org/apache/xml/utils Tag: xslt20 Duration.java
java/src/org/apache/xpath/functions Tag: xslt20
FuncDeepEqual.java FuncSequenceDeepEqual.java
FuncSequenceNodeEqual.java
java/src/org/apache/xpath/operations Tag: xslt20 Is.java
IsNot.java
Log:
Fix some problems with deep-equal, sequence-deep-equal, is, isnot, etc...
Revision Changes Path
No revision
No revision
1.28.2.1.2.1 +21 -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.28.2.1
retrieving revision 1.28.2.1.2.1
diff -u -r1.28.2.1 -r1.28.2.1.2.1
--- ElemNumber.java 14 Aug 2002 19:21:28 -0000 1.28.2.1
+++ ElemNumber.java 14 Nov 2002 22:42:53 -0000 1.28.2.1.2.1
@@ -75,6 +75,7 @@
import org.apache.xpath.*;
import org.apache.xpath.objects.XObject;
+import org.apache.xpath.objects.XSequenceImpl;
import org.apache.xml.utils.PrefixResolver;
import org.apache.xml.utils.PrefixResolverDefault;
import org.apache.xml.utils.QName;
@@ -893,10 +894,25 @@
if (null != m_valueExpr)
{
XObject countObj = m_valueExpr.execute(xctxt, sourceNode, this);
- long count = (long)java.lang.Math.floor(countObj.num()+ 0.5);
+ if (countObj instanceof XSequenceImpl)
+ {
+ XSequenceImpl seq = (XSequenceImpl)countObj;
+ list = new long[seq.getLength()];
+ XObject item;
+ int i = 0;
+ while ((item = seq.next()) != null)
+ {
+ long count = (long)java.lang.Math.floor(item.num()+ 0.5);
+ list [i++] = count;
+ }
+ }
+ else
+ {
+ long count = (long)java.lang.Math.floor(countObj.num()+ 0.5);
- list = new long[1];
- list[0] = count;
+ list = new long[1];
+ list[0] = count;
+ }
}
else
{
@@ -1212,6 +1228,8 @@
formatter.setGroupingUsed(false);
}
}
+ else
+ formatter.setGroupingUsed(false);
return formatter;
}
No revision
No revision
1.1.2.1.2.1 +2 -2 xml-xalan/java/src/org/apache/xml/utils/Attic/Duration.java
Index: Duration.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/Attic/Duration.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.1.2.1
diff -u -r1.1.2.1 -r1.1.2.1.2.1
--- Duration.java 14 Aug 2002 19:45:36 -0000 1.1.2.1
+++ Duration.java 14 Nov 2002 22:42:54 -0000 1.1.2.1.2.1
@@ -155,7 +155,7 @@
public Duration(int[] xercesduration)
{
// I'm not sure how they're representing negative durations!?
- m_year = xercesduration[0];
+ m_year = Math.abs(xercesduration[0]);
m_month = xercesduration[1];
m_day = xercesduration[2];
m_hour = xercesduration[3];
@@ -167,7 +167,7 @@
public Duration(int year, int month, int day, int hour, int minute, double second)
{
// I'm not sure how they're representing negative durations!?
- m_year = year;
+ m_year = Math.abs(year);
m_month = month;
m_day = day;
m_hour = hour;
No revision
No revision
1.1.2.4 +12 -4 xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDeepEqual.java
Index: FuncDeepEqual.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDeepEqual.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- FuncDeepEqual.java 12 Nov 2002 19:03:51 -0000 1.1.2.3
+++ FuncDeepEqual.java 14 Nov 2002 22:42:57 -0000 1.1.2.4
@@ -160,11 +160,16 @@
}
- private boolean deepEqual(int node1, int node2, DTM dtm1, DTM dtm2, java.text.Collator collator)
+ static boolean deepEqual(int node1, int node2, DTM dtm1, DTM dtm2, java.text.Collator collator)
{
int type = dtm1.getNodeType(node1);
+ String uri1 = null;
if (type == dtm2.getNodeType(node2)
- && dtm1.getNodeName(node1).equals(dtm2.getNodeName(node2)))
+ && dtm1.getLocalName(node1).equals(dtm2.getLocalName(node2))
+ && ((uri1 = dtm1.getNamespaceURI(node1)) == null ?
+ dtm2.getNamespaceURI(node2) == null :
+ uri1.equals(dtm2.getNamespaceURI(node2))))
+ //dtm1.getNodeName(node1).equals(dtm2.getNodeName(node2)))
{
switch (type)
{
@@ -259,13 +264,16 @@
return false;
}
}
- return true;
+ else if (!dtm1.hasChildNodes(node1) && !dtm2.hasChildNodes(node2))
+ return true;
+ else
+ return false;
}
else
return false;
}
- private int getNonCommentOrPI(DTM dtm, int child)
+ static private int getNonCommentOrPI(DTM dtm, int child)
{
if (DTM.NULL == child)
return child;
1.1.2.2 +13 -5 xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncSequenceDeepEqual.java
Index: FuncSequenceDeepEqual.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncSequenceDeepEqual.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- FuncSequenceDeepEqual.java 10 Oct 2002 14:58:35 -0000 1.1.2.1
+++ FuncSequenceDeepEqual.java 14 Nov 2002 22:42:59 -0000 1.1.2.2
@@ -68,6 +68,7 @@
import org.apache.xpath.objects.XBoolean;
import java.util.Comparator;
import org.apache.xml.dtm.XType;
+import org.apache.xml.dtm.DTM;
import org.apache.xpath.parser.regexp.*;
import org.apache.xalan.res.XSLMessages;
import org.apache.xpath.res.XPATHErrorResources;
@@ -135,12 +136,19 @@
{
if(item1 instanceof XNodeSequenceSingleton)
{
- XNodeSequenceSingleton xnss = (XNodeSequenceSingleton)item1;
+ XNodeSequenceSingleton xnss1 = (XNodeSequenceSingleton)item1;
if (type == item2.getType())
{
- if (!xnss.deepEquals((XNodeSequenceSingleton)item2))
- return new XBoolean(false);
+ XNodeSequenceSingleton xnss2 = (XNodeSequenceSingleton)item2;
+ if (!xnss1.deepEquals(xnss2))
+ {
+ DTM dtm1 = xnss1.getDTM();
+ DTM dtm2 = xnss2.getDTM();
+ int node1 = xnss1.getNodeHandle();
+ int node2 = xnss2.getNodeHandle();
+ return new XBoolean(FuncDeepEqual.deepEqual(node1, node2, dtm1, dtm2, collator));
+ }
}
}
}
@@ -148,12 +156,12 @@
{
if (collator == null)
{
- if (!item1.equals(item2))
+ if (type != item2.getType() || !item1.equals(item2))
return new XBoolean(false);
}
else
{
- if (collator.equals(item1.str(), item2.str()))
+ if (type != item2.getType() || !collator.equals(item1.str(), item2.str()))
return new XBoolean(false);
}
}
1.1.2.2 +18 -2 xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncSequenceNodeEqual.java
Index: FuncSequenceNodeEqual.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncSequenceNodeEqual.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- FuncSequenceNodeEqual.java 10 Oct 2002 14:58:35 -0000 1.1.2.1
+++ FuncSequenceNodeEqual.java 14 Nov 2002 22:43:00 -0000 1.1.2.2
@@ -68,6 +68,7 @@
import org.apache.xpath.objects.XBoolean;
import java.util.Comparator;
import org.apache.xml.dtm.XType;
+import org.apache.xml.dtm.DTM;
import org.apache.xpath.parser.regexp.*;
import org.apache.xalan.res.XSLMessages;
import org.apache.xpath.res.XPATHErrorResources;
@@ -96,6 +97,9 @@
XSequence seq1 = m_arg0.execute(xctxt).xseq();
XSequence seq2 = m_arg1.execute(xctxt).xseq();
+ if (seq1.getLength() == 0 || seq2.getLength() == 0)
+ return XSequence.EMPTY;
+
if (seq1.getLength() != seq2.getLength())
return new XBoolean(false);
@@ -112,11 +116,23 @@
{
if(item1 instanceof XNodeSequenceSingleton)
{
- XNodeSequenceSingleton xnss = (XNodeSequenceSingleton)item1;
+ XNodeSequenceSingleton xnss1 = (XNodeSequenceSingleton)item1;
+ XNodeSequenceSingleton xnss2 = (XNodeSequenceSingleton)item2;
if (type == item2.getType())
{
- if (!xnss.deepEquals((XNodeSequenceSingleton)item2))
+ DTM dtm1 = xnss1.getDTM();
+ DTM dtm2 = xnss2.getDTM();
+ int node1 = xnss1.getNodeHandle();
+ int node2 = xnss2.getNodeHandle();
+
+ String uri1 = null;
+ if(!dtm1.getLocalName(node1).equals(dtm2.getLocalName(node2))
+ || !((uri1 = dtm1.getNamespaceURI(node1)) == null ?
+ dtm2.getNamespaceURI(node2) == null :
+ uri1.equals(dtm2.getNamespaceURI(node2)))
+ //(!dtm1.getNodeName(node1).equals(dtm2.getNodeName(node2))
+ || (!xnss1.deepEquals(xnss2)))
return new XBoolean(false);
}
}
No revision
No revision
1.1.2.1.2.1 +17 -4 xml-xalan/java/src/org/apache/xpath/operations/Attic/Is.java
Index: Is.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Attic/Is.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.1.2.1
diff -u -r1.1.2.1 -r1.1.2.1.2.1
--- Is.java 14 Aug 2002 20:07:05 -0000 1.1.2.1
+++ Is.java 14 Nov 2002 22:43:00 -0000 1.1.2.1.2.1
@@ -60,6 +60,8 @@
import org.apache.xpath.XPathContext;
import org.apache.xpath.objects.XBoolean;
import org.apache.xpath.objects.XObject;
+import org.apache.xpath.objects.XSequence;
+import org.apache.xml.dtm.XType;
/**
* The '=' operation expression executer.
@@ -81,7 +83,14 @@
throws javax.xml.transform.TransformerException
{
// Might need to be more sophisticated!
- return (left == right) ? XBoolean.S_TRUE : XBoolean.S_FALSE;
+ if (left.xseq().getLength() == 0 || right.xseq().getLength() == 0)
+ return XSequence.EMPTY;
+
+ if (left.getType() == XType.NODE && right.getType() == XType.NODE)
+ return (left.iter().nextNode() == right.iter().nextNode())? XBoolean.S_TRUE : XBoolean.S_FALSE;
+ //return (left.notEquals(right)) ? XBoolean.S_FALSE : XBoolean.S_TRUE;
+ else
+ return XBoolean.S_FALSE;
}
/**
@@ -100,9 +109,13 @@
{
XObject left = m_left.execute(xctxt, true);
XObject right = m_right.execute(xctxt, true);
-
- // Might need to be more sophisticated!
- boolean result = (left == right) ? true : false;
+
+ // Might need to be more sophisticated!
+ boolean result;
+ if (left.getType() == XType.NODE && right.getType() == XType.NODE)
+ result = (left.iter().nextNode() == right.iter().nextNode())? true : false;
+ else
+ result = false;
left.detach();
right.detach();
return result;
1.1.2.1.2.1 +10 -1 xml-xalan/java/src/org/apache/xpath/operations/Attic/IsNot.java
Index: IsNot.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Attic/IsNot.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.1.2.1
diff -u -r1.1.2.1 -r1.1.2.1.2.1
--- IsNot.java 14 Aug 2002 20:07:05 -0000 1.1.2.1
+++ IsNot.java 14 Nov 2002 22:43:00 -0000 1.1.2.1.2.1
@@ -58,6 +58,8 @@
import org.apache.xpath.objects.XObject;
import org.apache.xpath.objects.XBoolean;
+import org.apache.xpath.objects.XSequence;
+import org.apache.xml.dtm.XType;
/**
* The '!=' operation expression executer.
@@ -79,6 +81,13 @@
throws javax.xml.transform.TransformerException
{
// Might have to be more sophisticated!
- return (left != right) ? XBoolean.S_TRUE : XBoolean.S_FALSE;
+ if (left.xseq().getLength() == 0 || right.xseq().getLength() == 0)
+ return XSequence.EMPTY;
+
+ if (left.getType() == XType.NODE && right.getType() == XType.NODE)
+ return (left.iter().nextNode() == right.iter().nextNode())? XBoolean.S_FALSE : XBoolean.S_TRUE;
+ //return (left.notEquals(right)) ? XBoolean.S_FALSE : XBoolean.S_TRUE;
+ else
+ return XBoolean.S_FALSE;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org