Author: atsushi
Date: 2005-05-10 01:24:54 -0400 (Tue, 10 May 2005)
New Revision: 44316
Modified:
trunk/mcs/class/System.XML/System.Xml/ChangeLog
trunk/mcs/class/System.XML/System.Xml/DTDValidatingReader.cs
trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog
trunk/mcs/class/System.XML/Test/System.Xml/XmlValidatingReaderTests.cs
Log:
2005-05-10 Atsushi Enomoto <[EMAIL PROTECTED]>
* DTDValidatingReader.cs : since namespace declarations might be
resolved differently due to entity handling, it holds its own set
of declared namespaces. NamespaceURI and LookupNamespace() use it.
* XmlValidatingReaderTests.cs : fixed TestPreserveEntityNotOnDotNet()
which was regarded as a bug while it was by design.
Modified: trunk/mcs/class/System.XML/System.Xml/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/ChangeLog 2005-05-10 05:21:15 UTC
(rev 44315)
+++ trunk/mcs/class/System.XML/System.Xml/ChangeLog 2005-05-10 05:24:54 UTC
(rev 44316)
@@ -1,3 +1,9 @@
+2005-05-10 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * DTDValidatingReader.cs : since namespace declarations might be
+ resolved differently due to entity handling, it holds its own set
+ of declared namespaces. NamespaceURI and LookupNamespace() use it.
+
2005-05-09 Atsushi Enomoto <[EMAIL PROTECTED]>
* XmlReader.cs : added ReadElementContentAsLong().
Modified: trunk/mcs/class/System.XML/System.Xml/DTDValidatingReader.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/DTDValidatingReader.cs
2005-05-10 05:21:15 UTC (rev 44315)
+++ trunk/mcs/class/System.XML/System.Xml/DTDValidatingReader.cs
2005-05-10 05:24:54 UTC (rev 44316)
@@ -69,6 +69,7 @@
attributeLocalNames = new Hashtable ();
attributeNamespaces = new Hashtable ();
attributePrefixes = new Hashtable ();
+ nsdecls = new Hashtable ();
this.validatingReader = validatingReader;
valueBuilder = new StringBuilder ();
idList = new ArrayList ();
@@ -104,6 +105,7 @@
Hashtable attributeLocalNames;
Hashtable attributeNamespaces;
Hashtable attributePrefixes;
+ Hashtable nsdecls;
StringBuilder valueBuilder;
ArrayList idList;
ArrayList missingIDReferences;
@@ -188,7 +190,8 @@
public override string LookupNamespace (string prefix)
{
- // Does it mean anything with DTD?
+ if (nsdecls.Count > 0 && nsdecls [prefix] != null)
+ return (string) nsdecls [prefix];
return reader.LookupNamespace (prefix);
}
@@ -363,6 +366,7 @@
attributeValues.Clear ();
attributeNamespaces.Clear ();
attributePrefixes.Clear ();
+ nsdecls.Clear ();
isWhitespace = false;
isSignificantWhitespace = false;
isText = false;
@@ -522,7 +526,12 @@
// SetupValidityIgnorantAttributes ();
ValidateAttributes (null, false);
}
-
+ foreach (string attr in attributes)
+ if (attr == "xmlns" ||
+ String.CompareOrdinal (attr, 0,
"xmlns", 0, 5) == 0)
+ nsdecls.Add (
+ attr == "xmlns" ?
String.Empty : attributePrefixes [attr],
+ attributeValues [attr]);
// If it is empty element then directly check
end element.
if (reader.IsEmptyElement)
goto case XmlNodeType.EndElement;
@@ -671,9 +680,11 @@
attributePrefixes.Add (attrName, reader.Prefix);
XmlReader targetReader = reader;
string attrValue = null;
- if (currentEntityHandling ==
EntityHandling.ExpandCharEntities)
- attrValue = reader.Value;
- else {
+ // It always resolves entity references on
attributes (documented as such).
+// if (currentEntityHandling ==
EntityHandling.ExpandCharEntities)
+// attrValue = reader.Value;
+// else
+ {
while (attributeValueEntityStack.Count
>= 0) {
if
(!targetReader.ReadAttributeValue ()) {
if
(attributeValueEntityStack.Count > 0) {
@@ -1080,6 +1091,8 @@
return (string) attributeNamespaces
[currentAttribute];
else if (IsDefault)
return String.Empty;
+ else if (nsdecls.Count > 0 && nsdecls [Prefix]
!= null)
+ return (string) nsdecls [Prefix];
else
return reader.NamespaceURI;
}
Modified: trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog 2005-05-10
05:21:15 UTC (rev 44315)
+++ trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog 2005-05-10
05:24:54 UTC (rev 44316)
@@ -1,3 +1,8 @@
+2005-05-10 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * XmlValidatingReaderTests.cs : fixed TestPreserveEntityNotOnDotNet()
+ which was regarded as a bug while it was by design.
+
2005-05-05 Atsushi Enomoto <[EMAIL PROTECTED]>
* XmlNamespaceManagerTests.cs : removed more atomizedName tests.
Modified: trunk/mcs/class/System.XML/Test/System.Xml/XmlValidatingReaderTests.cs
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml/XmlValidatingReaderTests.cs
2005-05-10 05:21:15 UTC (rev 44315)
+++ trunk/mcs/class/System.XML/Test/System.Xml/XmlValidatingReaderTests.cs
2005-05-10 05:24:54 UTC (rev 44316)
@@ -506,7 +506,7 @@
}
[Test]
- [Category("NotDotNet")]
+ // it used to be regarded as MS bug but it was not really.
public void TestPreserveEntityNotOnDotNet ()
{
string intSubset = "<!ELEMENT root EMPTY><!ATTLIST root
foo CDATA 'foo-def' bar CDATA 'bar-def'><!ENTITY ent 'entity string'>";
@@ -520,8 +520,7 @@
AssertEquals ("root", dvr.Name);
Assert (dvr.MoveToFirstAttribute ());
AssertEquals ("foo", dvr.Name);
- // MS BUG: it returns "entity string", however, entity
should not be exanded.
- AssertEquals ("&ent;", dvr.Value);
+ AssertEquals ("entity string", dvr.Value);
// ReadAttributeValue()
Assert (dvr.ReadAttributeValue ());
AssertEquals (XmlNodeType.EntityReference,
dvr.NodeType);
@@ -532,7 +531,7 @@
// bar
Assert (dvr.MoveToNextAttribute ());
AssertEquals ("bar", dvr.Name);
- AssertEquals ("internal &ent; value", dvr.Value);
+ AssertEquals ("internal entity string value",
dvr.Value);
// ReadAttributeValue()
Assert (dvr.ReadAttributeValue ());
AssertEquals (XmlNodeType.Text, dvr.NodeType);
@@ -560,7 +559,7 @@
// foo
Assert (dvr.MoveToFirstAttribute ());
AssertEquals ("foo", dvr.Name);
- AssertEquals ("&ent;", dvr.Value);
+ AssertEquals ("entity string", dvr.Value);
// ReadAttributeValue()
Assert (dvr.ReadAttributeValue ());
AssertEquals (XmlNodeType.EntityReference,
dvr.NodeType);
@@ -571,7 +570,7 @@
// bar
Assert (dvr.MoveToNextAttribute ());
AssertEquals ("bar", dvr.Name);
- AssertEquals ("internal &ent; value", dvr.Value);
+ AssertEquals ("internal entity string value",
dvr.Value);
// ReadAttributeValue()
Assert (dvr.ReadAttributeValue ());
AssertEquals (XmlNodeType.Text, dvr.NodeType);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches