Author: atsushi
Date: 2005-03-22 10:44:41 -0500 (Tue, 22 Mar 2005)
New Revision: 42118
Modified:
trunk/mcs/class/System.XML/System.Xml.XPath/ChangeLog
trunk/mcs/class/System.XML/System.Xml.XPath/Expression.cs
trunk/mcs/class/System.XML/Test/System.Xml.Xsl/ChangeLog
trunk/mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs
trunk/mcs/class/System.XML/Test/System.Xml.Xsl/standalone_tests/Makefile
Log:
2004-03-22 Atsushi Enomoto <[EMAIL PROTECTED]>
* Expression.cs : EvaluateBoolean() for RTF should check return true
for empty elements. Fixed static analysis for RTF.
* XslTransformTests.cs : added test 1)that examines pattern sanity and
2)that examines if empty element RTF is evaluated as true for bool.
--his line, and those below, will be ignored--
M System.Xml.XPath/ChangeLog
M System.Xml.XPath/Expression.cs
M Test/System.Xml.Xsl/ChangeLog
M Test/System.Xml.Xsl/XslTransformTests.cs
M Test/System.Xml.Xsl/standalone_tests/Makefile
Modified: trunk/mcs/class/System.XML/System.Xml.XPath/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/System.Xml.XPath/ChangeLog 2005-03-22
15:41:00 UTC (rev 42117)
+++ trunk/mcs/class/System.XML/System.Xml.XPath/ChangeLog 2005-03-22
15:44:41 UTC (rev 42118)
@@ -1,5 +1,10 @@
2004-03-22 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * Expression.cs : EvaluateBoolean() for RTF should check return true
+ for empty elements. Fixed static analysis for RTF.
+
+2004-03-22 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* Parser.jay, Tokenizer.cs : Now they are used as common code base for
XPath parser and XSLT pattern parser. Makefile now creates two
set of sources of them. (This change takes effect on the next change).
Modified: trunk/mcs/class/System.XML/System.Xml.XPath/Expression.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml.XPath/Expression.cs 2005-03-22
15:41:00 UTC (rev 42117)
+++ trunk/mcs/class/System.XML/System.Xml.XPath/Expression.cs 2005-03-22
15:44:41 UTC (rev 42118)
@@ -419,6 +419,10 @@
get { return HasStaticValue ? XPathFunctions.ToBoolean
(StaticValue) : false; }
}
+ public virtual XPathNavigator StaticValueAsNavigator {
+ get { return StaticValue as XPathNavigator; }
+ }
+
public abstract object Evaluate (BaseIterator iter);
public virtual BaseIterator EvaluateNodeSet (BaseIterator iter)
@@ -553,7 +557,7 @@
return (iterResult != null &&
iterResult.MoveNext ());
}
case XPathResultType.Navigator:
- return ((string) ((XPathNavigator)
result).Value).Length != 0;
+ return (((XPathNavigator)
result).HasChildren);
default:
throw new XPathException ("invalid node
type");
}
@@ -700,13 +704,17 @@
get {
if (!HasStaticValue)
return false;
+ if ((_left.ReturnType ==
XPathResultType.Navigator || _right.ReturnType == XPathResultType.Navigator) &&
_left.ReturnType == _right.ReturnType)
+ return
(_left.StaticValueAsNavigator.IsSamePosition (
+ _right.StaticValueAsNavigator))
+ == trueVal;
if (_left.ReturnType == XPathResultType.Boolean
| _right.ReturnType == XPathResultType.Boolean)
return (_left.StaticValueAsBoolean ==
_right.StaticValueAsBoolean) == trueVal;
if (_left.ReturnType == XPathResultType.Number
| _right.ReturnType == XPathResultType.Number)
return (_left.StaticValueAsNumber ==
_right.StaticValueAsNumber) == trueVal;
if (_left.ReturnType == XPathResultType.String
| _right.ReturnType == XPathResultType.String)
return (_left.StaticValueAsString ==
_right.StaticValueAsString) == trueVal;
- return _left.StaticValue == _right.StaticValue;
+ return _left.StaticValue == _right.StaticValue
== trueVal;
}
}
Modified: trunk/mcs/class/System.XML/Test/System.Xml.Xsl/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml.Xsl/ChangeLog 2005-03-22
15:41:00 UTC (rev 42117)
+++ trunk/mcs/class/System.XML/Test/System.Xml.Xsl/ChangeLog 2005-03-22
15:44:41 UTC (rev 42118)
@@ -1,3 +1,8 @@
+2005-03-22 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * XslTransformTests.cs : added test 1)that examines pattern sanity and
+ 2)that examines if empty element RTF is evaluated as true for bool.
+
2005-02-28 Atsushi Enomoto <[EMAIL PROTECTED]>
* MsxslScriptTests.cs,
Modified: trunk/mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs
2005-03-22 15:41:00 UTC (rev 42117)
+++ trunk/mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs
2005-03-22 15:44:41 UTC (rev 42118)
@@ -172,5 +172,37 @@
t.Load (new XPathDocument (new StringReader (xsl)));
t.Transform (new XPathDocument (new XmlTextReader (new
StringReader ("<root><foo attr='A'/><foo attr='B'/><foo attr='C'/></root>"))),
null, sw);
}
+
+ [Test]
+ public void EvaluateEmptyVariableAsBoolean ()
+ {
+ string xsl = @"<xsl:stylesheet
xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+<xsl:template match='/'>
+<xsl:variable name='var'><empty /></xsl:variable>
+ <root><xsl:if test='$var'>true</xsl:if></root>
+</xsl:template>
+</xsl:stylesheet>";
+ XslTransform t = new XslTransform ();
+ t.Load (new XPathDocument (new StringReader (xsl)));
+ StringWriter sw = new StringWriter ();
+ t.Transform (
+ new XPathDocument (new StringReader
("<root/>")),
+ null,
+ sw);
+ Assert (sw.ToString ().IndexOf ("true") > 0);
+ }
+
+ [Test]
+ [ExpectedException (typeof (XsltCompileException))]
+ public void NotAllowedPatternAxis ()
+ {
+ string xsl = @"<xsl:stylesheet
xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+<xsl:template match='/descendant-or-self::node()/elem'>
+<ERROR/>
+</xsl:template>
+</xsl:stylesheet>";
+ new XslTransform ().Load (new XPathDocument (
+ new StringReader (xsl)));
+ }
}
}
Modified:
trunk/mcs/class/System.XML/Test/System.Xml.Xsl/standalone_tests/Makefile
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml.Xsl/standalone_tests/Makefile
2005-03-22 15:41:00 UTC (rev 42117)
+++ trunk/mcs/class/System.XML/Test/System.Xml.Xsl/standalone_tests/Makefile
2005-03-22 15:44:41 UTC (rev 42118)
@@ -9,7 +9,7 @@
# - For MainSoft test, it is "diffreport.txt"
#
-RUNTIME = mono
+RUNTIME = mono --debug
CSCOMPILE = mcs
TESTS = testsuite/TESTS/Xalan_Conformance_Tests/whitespace/whitespace35.xsl
TARGET_RESULTS = Results
@@ -65,7 +65,7 @@
run-test-ms : alltest.exe xmlnorm.exe
$(RUNTIME) ./alltest.exe $(TARGET_RESULTS)
- $(RUNTIME) ./xmlnorm.exe -s testsuite/TESTS/$(TARGET_RESULTS)
testsuite/TESTS/norm-tmp
+ mono ./xmlnorm.exe -s testsuite/TESTS/$(TARGET_RESULTS)
testsuite/TESTS/norm-tmp
rm -rf testsuite/TESTS/$(TARGET_RESULTS)
mv testsuite/TESTS/norm-tmp testsuite/TESTS/$(TARGET_RESULTS)
diff -r -q testsuite/TESTS/ExpectedResults
testsuite/TESTS/$(TARGET_RESULTS) > diffreport.txt
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches