Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2006-01-06 07:47:46 +0300
committerAtsushi Eno <atsushieno@gmail.com>2006-01-06 07:47:46 +0300
commit12b7f166b639343c0b87773e7e4af58738f19937 (patch)
tree6a224f8bf53532651f07c310a7597529771f5ad0 /mcs/class/System.XML
parent6b7a7509dfbe0c53b57bf378027465184556eff9 (diff)
2006-01-06 Atsushi Enomoto <atsushi@ximian.com>
* XmlValidatingReader.cs : In ReadTypedValue(), treat Whitespace nodes as target string nodes as well as other text nodes. * XsdValidatingReader.cs : Don't use normalized string as input to AssessStringValid(). It incorrectly invalidates strings against simple types with length- related facets. Now that we don't ignore whitespaces, we need to explicitly allow pure whitespace texts in ElementOnly/Empty model. * XmlSchemaSimpleTypeRestriction.cs : maxLength and minLength were likely to be ignored in ValidateNonListValueWithFacets(). * XmlSchemaValidator.cs : Don't use normalized string value as the input to AssessStringValid(). * XsdValidatingReaderTests.cs : test for ReadTypeValue() that it does not ignore whitespace nodes, and it does not normalize string incorrectly. svn path=/trunk/mcs/; revision=55129
Diffstat (limited to 'mcs/class/System.XML')
-rw-r--r--mcs/class/System.XML/Mono.Xml.Schema/ChangeLog9
-rw-r--r--mcs/class/System.XML/Mono.Xml.Schema/XsdValidatingReader.cs7
-rw-r--r--mcs/class/System.XML/System.Xml.Schema/ChangeLog7
-rw-r--r--mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs2
-rw-r--r--mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidator.cs4
-rw-r--r--mcs/class/System.XML/System.Xml/ChangeLog5
-rw-r--r--mcs/class/System.XML/System.Xml/XmlValidatingReader.cs1
-rw-r--r--mcs/class/System.XML/Test/System.Xml/ChangeLog6
-rw-r--r--mcs/class/System.XML/Test/System.Xml/XsdValidatingReaderTests.cs28
9 files changed, 63 insertions, 6 deletions
diff --git a/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog b/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog
index 1f45f1b132c..5bda8228106 100644
--- a/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog
+++ b/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog
@@ -1,3 +1,12 @@
+2006-01-06 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XsdValidatingReader.cs :
+ Don't use normalized string as input to AssessStringValid(). It
+ incorrectly invalidates strings against simple types with length-
+ related facets.
+ Now that we don't ignore whitespaces, we need to explicitly allow
+ pure whitespace texts in ElementOnly/Empty model.
+
2005-12-26 Atsushi Enomoto <atsushi@ximian.com>
* XsdValidatingReader.cs : Fixed the bug that only the last schema
diff --git a/mcs/class/System.XML/Mono.Xml.Schema/XsdValidatingReader.cs b/mcs/class/System.XML/Mono.Xml.Schema/XsdValidatingReader.cs
index 056adeeaa1d..3d712392ec4 100644
--- a/mcs/class/System.XML/Mono.Xml.Schema/XsdValidatingReader.cs
+++ b/mcs/class/System.XML/Mono.Xml.Schema/XsdValidatingReader.cs
@@ -526,7 +526,7 @@ namespace Mono.Xml.Schema
switch (ct.ContentType) {
case XmlSchemaContentType.ElementOnly:
case XmlSchemaContentType.Empty:
- if (value.Length > 0)
+ if (value.Length > 0 && !XmlChar.IsWhitespace (value))
HandleError ("Character content not allowed.");
break;
}
@@ -624,9 +624,9 @@ namespace Mono.Xml.Schema
// mmm, will check later.
SimpleType baseType = st.BaseXmlSchemaType as SimpleType;
if (baseType != null) {
- AssessStringValid(baseType, dt, normalized);
+ AssessStringValid(baseType, dt, value);
}
- if (!str.ValidateValueWithFacets (normalized, NameTable)) {
+ if (!str.ValidateValueWithFacets (value, NameTable)) {
HandleError ("Specified value was invalid against the facets.");
break;
}
@@ -1595,6 +1595,7 @@ namespace Mono.Xml.Schema
case XmlNodeType.CDATA:
case XmlNodeType.SignificantWhitespace:
+ case XmlNodeType.Whitespace:
case XmlNodeType.Text:
// FIXME: does this check make sense?
ComplexType ct = Context.ActualType as ComplexType;
diff --git a/mcs/class/System.XML/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/System.Xml.Schema/ChangeLog
index 3c2394acacc..1969b4b2ca6 100644
--- a/mcs/class/System.XML/System.Xml.Schema/ChangeLog
+++ b/mcs/class/System.XML/System.Xml.Schema/ChangeLog
@@ -1,3 +1,10 @@
+2006-01-06 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlSchemaSimpleTypeRestriction.cs : maxLength and minLength were
+ likely to be ignored in ValidateNonListValueWithFacets().
+ * XmlSchemaValidator.cs : Don't use normalized string value as the
+ input to AssessStringValid().
+
2005-12-08 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaSet.cs :
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs
index 567efb887d5..2a4a8962c8b 100644
--- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs
@@ -694,7 +694,7 @@ namespace System.Xml.Schema
if (! ( (dt is XsdQName) || (dt is XsdNotation))) {
// Length potentially slower now, so only calculate if needed
- if (! (lengthFacet == -1) && (maxLengthFacet == -1) && (minLengthFacet == -1)) {
+ if (! ((lengthFacet == -1) && (maxLengthFacet == -1) && (minLengthFacet == -1))) {
// numeric
// : length
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidator.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidator.cs
index 26d5bba0a17..d5702d2445f 100644
--- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidator.cs
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidator.cs
@@ -1034,9 +1034,9 @@ namespace System.Xml.Schema
// mmm, will check later.
SimpleType baseType = st.BaseXmlSchemaType as SimpleType;
if (baseType != null) {
- ret = AssessStringValid (baseType, dt, normalized);
+ ret = AssessStringValid (baseType, dt, value);
}
- if (!str.ValidateValueWithFacets (normalized, nameTable)) {
+ if (!str.ValidateValueWithFacets (value, nameTable)) {
HandleError ("Specified value was invalid against the facets.");
break;
}
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog
index 82eca321b54..d30ee0e34e4 100644
--- a/mcs/class/System.XML/System.Xml/ChangeLog
+++ b/mcs/class/System.XML/System.Xml/ChangeLog
@@ -1,5 +1,10 @@
2006-01-06 Atsushi Enomoto <atsushi@ximian.com>
+ * XmlValidatingReader.cs : In ReadTypedValue(), treat Whitespace
+ nodes as target string nodes as well as other text nodes.
+
+2006-01-06 Atsushi Enomoto <atsushi@ximian.com>
+
* XmlValidatingReader.cs : ReadTypedValue() was not working with
non-XmlSchemaDatatype types.
diff --git a/mcs/class/System.XML/System.Xml/XmlValidatingReader.cs b/mcs/class/System.XML/System.Xml/XmlValidatingReader.cs
index 8b22eb6a31e..4a8c3764008 100644
--- a/mcs/class/System.XML/System.Xml/XmlValidatingReader.cs
+++ b/mcs/class/System.XML/System.Xml/XmlValidatingReader.cs
@@ -564,6 +564,7 @@ namespace System.Xml
do {
Read ();
switch (NodeType) {
+ case XmlNodeType.Whitespace:
case XmlNodeType.SignificantWhitespace:
case XmlNodeType.Text:
case XmlNodeType.CDATA:
diff --git a/mcs/class/System.XML/Test/System.Xml/ChangeLog b/mcs/class/System.XML/Test/System.Xml/ChangeLog
index 69ad13b7d2e..d8c563d1bea 100644
--- a/mcs/class/System.XML/Test/System.Xml/ChangeLog
+++ b/mcs/class/System.XML/Test/System.Xml/ChangeLog
@@ -1,5 +1,11 @@
2006-01-06 Atsushi Enomoto <atsushi@ximian.com>
+ * XsdValidatingReaderTests.cs : test for ReadTypeValue() that it
+ does not ignore whitespace nodes, and it does not normalize string
+ incorrectly.
+
+2006-01-06 Atsushi Enomoto <atsushi@ximian.com>
+
* XsdValidatingReaderTests.cs : test for ReadTypeValue() with simple
type restriction.
diff --git a/mcs/class/System.XML/Test/System.Xml/XsdValidatingReaderTests.cs b/mcs/class/System.XML/Test/System.Xml/XsdValidatingReaderTests.cs
index 407aabb6a16..3ed1698c6b6 100644
--- a/mcs/class/System.XML/Test/System.Xml/XsdValidatingReaderTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml/XsdValidatingReaderTests.cs
@@ -261,5 +261,33 @@ namespace MonoTests.System.Xml
AssertEquals ("xx", vr.ReadTypedValue ());
AssertEquals (XmlNodeType.EndElement, vr.NodeType);
}
+
+ // If we normalize string before validating with facets,
+ // this test will fail. It will also fail if ReadTypedValue()
+ // ignores whitespace nodes.
+ [Test]
+ public void ReadTypedValueWhitespaces ()
+ {
+ string xml = "<root> </root><!-- after -->";
+ string xsd = @"
+<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
+ <xs:element name='root'>
+ <xs:simpleType>
+ <xs:restriction base='xs:string'>
+ <xs:minLength value='2' />
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+</xs:schema>";
+ XmlTextReader xir =
+ new XmlTextReader (xml, XmlNodeType.Document, null);
+ XmlTextReader xsr =
+ new XmlTextReader (xsd, XmlNodeType.Document, null);
+ XmlValidatingReader vr = new XmlValidatingReader (xir);
+ vr.Schemas.Add (XmlSchema.Read (xsr, null));
+ vr.Read (); // root
+ AssertEquals (" ", vr.ReadTypedValue ());
+ AssertEquals (XmlNodeType.EndElement, vr.NodeType);
+ }
}
}