diff options
author | Jason Diamond <injektilo@mono-cvs.ximian.com> | 2002-02-12 00:08:55 +0300 |
---|---|---|
committer | Jason Diamond <injektilo@mono-cvs.ximian.com> | 2002-02-12 00:08:55 +0300 |
commit | daa65c9207cc07e2e7f04fe6be2739fcf5def34f (patch) | |
tree | 56fb98421e1c3632c2e64ff06b53fbaa03e714a2 | |
parent | e3084fbe32afcac54123bdd4ff123689bcecd5a9 (diff) |
Fixed build to test our XML classes and not Microsoft's. Added initial namespace support.
svn path=/trunk/mcs/; revision=2333
-rw-r--r-- | mcs/class/System.XML/ChangeLog | 18 | ||||
-rw-r--r-- | mcs/class/System.XML/System.XML.build | 10 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlTextReader.cs | 23 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/System.XML_test.build | 6 | ||||
-rwxr-xr-x | mcs/class/System.XML/Test/Test.cs | 144 |
5 files changed, 188 insertions, 13 deletions
diff --git a/mcs/class/System.XML/ChangeLog b/mcs/class/System.XML/ChangeLog index 51e16bd5b16..c11071ebe19 100644 --- a/mcs/class/System.XML/ChangeLog +++ b/mcs/class/System.XML/ChangeLog @@ -1,3 +1,21 @@ +2002-02-10 Jason Diamond <jason@injektilo.org> + + * System.XML.build: Renamed the System.Xml.dll assembly to + System.XML.dll to match Microsoft. + + * System.XML.build, Test/System.XML_test.build: Added tasks to + clean .dll and .pdb files. + + * System.XML.build, Test/System.XML_test.build: Copy System.XML.dll + to Test directory and reference that. This makes it so our tests + test our code and not Microsoft's. + + * System.Xml/XmlTextReader.cs: Added support for parsing prefixes + and local names. + + * Test/Test.cs: Updated all tests to test the prefix and local name + properties. + 2002-01-23 Dick Porter <dick@ximian.com> * System.Xml/XmlNode.cs: Fixed IndexerName attribute so it diff --git a/mcs/class/System.XML/System.XML.build b/mcs/class/System.XML/System.XML.build index 39aae4dabfa..8b807234e6c 100644 --- a/mcs/class/System.XML/System.XML.build +++ b/mcs/class/System.XML/System.XML.build @@ -1,20 +1,20 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- NAnt build file for System.Xml.dll --> +<!-- NAnt build file for System.XML.dll --> -<project name="System.Xml" default="build"> +<project name="System.XML" default="build"> <property name="debug" value="false"/> <target name="build"> <mkdir dir="../lib"/> - <csc target="library" output="../lib/System.Xml.dll" debug="${debug}"> + <csc target="library" output="../lib/System.XML.dll" debug="${debug}"> <arg value="/nowarn:1595"/> - <arg value="/unsafe"/> <sources> <includes name="**/*.cs"/> <excludes name="Test/**"/> </sources> </csc> + <copy file="../lib/System.XML.dll" tofile="Test/System.XML.dll"/> <nant basedir="Test" target="build"/> </target> @@ -24,5 +24,7 @@ <target name="clean"> <nant basedir="Test" target="clean"/> + <delete file="../lib/System.XML.dll" failonerror="false"/> + <delete file="../lib/System.XML.pdb" failonerror="false"/> </target> </project> diff --git a/mcs/class/System.XML/System.Xml/XmlTextReader.cs b/mcs/class/System.XML/System.Xml/XmlTextReader.cs index 8fa9e7b266f..08769388a3f 100644 --- a/mcs/class/System.XML/System.Xml/XmlTextReader.cs +++ b/mcs/class/System.XML/System.Xml/XmlTextReader.cs @@ -270,8 +270,7 @@ namespace System.Xml {
get
{
- // TODO: implement me.
- return null;
+ return localName;
}
}
@@ -341,8 +340,7 @@ namespace System.Xml {
get
{
- // TODO: implement me.
- return null;
+ return prefix;
}
}
@@ -562,6 +560,8 @@ namespace System.Xml private XmlNodeType nodeType;
private string name;
+ private string prefix;
+ private string localName;
private bool isEmptyElement;
private string value;
private Hashtable attributes;
@@ -588,6 +588,8 @@ namespace System.Xml nodeType = XmlNodeType.None;
name = String.Empty;
+ prefix = String.Empty;
+ localName = string.Empty;
isEmptyElement = false;
value = String.Empty;
attributes = new Hashtable();
@@ -625,6 +627,19 @@ namespace System.Xml {
ClearAttributes();
}
+
+ int indexOfColon = name.IndexOf(':');
+
+ if (indexOfColon == -1)
+ {
+ prefix = String.Empty;
+ localName = name;
+ }
+ else
+ {
+ prefix = name.Substring(0, indexOfColon);
+ localName = name.Substring(indexOfColon + 1);
+ }
}
private void AddAttribute(string name, string value)
diff --git a/mcs/class/System.XML/Test/System.XML_test.build b/mcs/class/System.XML/Test/System.XML_test.build index 35e4e153176..012973138db 100644 --- a/mcs/class/System.XML/Test/System.XML_test.build +++ b/mcs/class/System.XML/Test/System.XML_test.build @@ -10,14 +10,14 @@ <target name="build"> <csc target="library" output="System.XML_test.dll" debug="${debug}"> + <arg value="/nowarn:1595"/> <sources> <includes name="**/*.cs"/> </sources> <references basedir="..\..\..\nunit"> <includes name="NUnitCore.dll"/> </references> - <arg value="/r:..\..\lib\System.XML.dll"/> - <arg value="/nowarn:1595"/> + <arg value="/r:.\System.XML.dll"/> </csc> </target> @@ -26,6 +26,8 @@ </target> <target name="clean"> + <delete file="System.XML.dll" failonerror="false"/> <delete file="System.XML_test.dll" failonerror="false"/> + <delete file="System.XML_test.pdb" failonerror="false"/> </target> </project> diff --git a/mcs/class/System.XML/Test/Test.cs b/mcs/class/System.XML/Test/Test.cs index cac9d0c6ed7..68385e1ddc2 100755 --- a/mcs/class/System.XML/Test/Test.cs +++ b/mcs/class/System.XML/Test/Test.cs @@ -34,6 +34,8 @@ namespace System.Xml int depth,
bool isEmptyElement,
string name,
+ string prefix,
+ string localName,
string value,
int attributeCount)
{
@@ -44,11 +46,44 @@ namespace System.Xml Assert(xmlReader.NodeType == nodeType);
Assert(xmlReader.Depth == depth);
Assert(xmlReader.IsEmptyElement == isEmptyElement);
- Assert(xmlReader.Name == name);
+
+ Assert(
+ String.Format(
+ "name was {0}, expected {1}",
+ xmlReader.Name,
+ name),
+ xmlReader.Name == name);
+
+ Assert(
+ String.Format(
+ "prefix was {0}, expected {1}",
+ xmlReader.Prefix,
+ prefix),
+ xmlReader.Prefix == prefix);
+
+ Assert(
+ String.Format(
+ "localName was {0}, expected {1}",
+ xmlReader.LocalName,
+ localName),
+ xmlReader.LocalName == localName);
+
Assert(xmlReader.HasValue == (value != String.Empty));
Assert(xmlReader.Value == value);
- Assert(xmlReader.HasAttributes == (attributeCount > 0));
- Assert(xmlReader.AttributeCount == attributeCount);
+
+ Assert(
+ String.Format(
+ "hasAttributes was {0}, expected {1}",
+ xmlReader.HasAttributes,
+ (attributeCount > 0)),
+ xmlReader.HasAttributes == (attributeCount > 0));
+
+ Assert(
+ String.Format(
+ "attributeCount was {0}, expected {1}",
+ xmlReader.AttributeCount,
+ attributeCount),
+ xmlReader.AttributeCount == attributeCount);
}
private void AssertAttribute(
@@ -86,6 +121,8 @@ namespace System.Xml 0, // depth
true, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -107,6 +144,8 @@ namespace System.Xml 0, //depth
true, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -128,6 +167,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -138,6 +179,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -159,6 +202,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -169,6 +214,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -190,6 +237,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -200,6 +249,8 @@ namespace System.Xml 1, //depth
true, // isEmptyElement
"bar", // name
+ String.Empty, // prefix
+ "bar", // localName
String.Empty, // value
0 // attributeCount
);
@@ -210,6 +261,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -231,6 +284,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -241,6 +296,8 @@ namespace System.Xml 1, //depth
false, // isEmptyElement
String.Empty, // name
+ String.Empty, // prefix
+ String.Empty, // localName
"bar", // value
0 // attributeCount
);
@@ -251,6 +308,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -272,6 +331,8 @@ namespace System.Xml 0, //depth
true, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
1 // attributeCount
);
@@ -299,6 +360,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
1 // attributeCount
);
@@ -315,6 +378,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -336,6 +401,8 @@ namespace System.Xml 0, //depth
true, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
2 // attributeCount
);
@@ -369,6 +436,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
"bar", // value
0 // attributeCount
);
@@ -379,6 +448,8 @@ namespace System.Xml 0, //depth
true, // isEmptyElement
"baz", // name
+ String.Empty, // prefix
+ "baz", // localName
String.Empty, // value
0 // attributeCount
);
@@ -400,6 +471,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
String.Empty, // name
+ String.Empty, // prefix
+ String.Empty, // localName
"foo", // value
0 // attributeCount
);
@@ -410,6 +483,8 @@ namespace System.Xml 0, //depth
true, // isEmptyElement
"bar", // name
+ String.Empty, // prefix
+ "bar", // localName
String.Empty, // value
0 // attributeCount
);
@@ -431,6 +506,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -441,6 +518,8 @@ namespace System.Xml 1, //depth
false, // isEmptyElement
String.Empty, // name
+ String.Empty, // prefix
+ String.Empty, // localName
"<>&'\"", // value
0 // attributeCount
);
@@ -451,6 +530,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -472,6 +553,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -482,6 +565,8 @@ namespace System.Xml 1, //depth
false, // isEmptyElement
"bar", // name
+ String.Empty, // prefix
+ "bar", // localName
String.Empty, // value
0 // attributeCount
);
@@ -492,6 +577,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -513,6 +600,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -523,6 +612,8 @@ namespace System.Xml 1, //depth
false, // isEmptyElement
String.Empty, // name
+ String.Empty, // prefix
+ String.Empty, // localName
"bar", // value
0 // attributeCount
);
@@ -533,6 +624,8 @@ namespace System.Xml 1, //depth
false, // isEmptyElement
"baz", // name
+ String.Empty, // prefix
+ "baz", // localName
String.Empty, // value
0 // attributeCount
);
@@ -543,6 +636,8 @@ namespace System.Xml 1, //depth
false, // isEmptyElement
String.Empty, // name
+ String.Empty, // prefix
+ String.Empty, // localName
"quux", // value
0 // attributeCount
);
@@ -553,6 +648,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -574,6 +671,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -584,6 +683,8 @@ namespace System.Xml 1, //depth
false, // isEmptyElement
String.Empty, // name
+ String.Empty, // prefix
+ String.Empty, // localName
"FOO", // value
0 // attributeCount
);
@@ -594,6 +695,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -615,6 +718,8 @@ namespace System.Xml 0, //depth
true, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
1 // attributeCount
);
@@ -642,6 +747,8 @@ namespace System.Xml 0, //depth
true, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
1 // attributeCount
);
@@ -669,6 +776,8 @@ namespace System.Xml 0, //depth
true, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
1 // attributeCount
);
@@ -696,6 +805,8 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
String.Empty, // value
0 // attributeCount
);
@@ -706,6 +817,8 @@ namespace System.Xml 1, //depth
false, // isEmptyElement
String.Empty, // name
+ String.Empty, // prefix
+ String.Empty, // localName
"<>&", // value
0 // attributeCount
);
@@ -716,6 +829,31 @@ namespace System.Xml 0, //depth
false, // isEmptyElement
"foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument(xmlReader);
+ }
+
+ public void TestEmptyElementInNamespace()
+ {
+ string xml = @"<foo:bar />";
+ XmlReader xmlReader =
+ new XmlTextReader(new StringReader(xml));
+
+ AssertStartDocument(xmlReader);
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, // depth
+ true, // isEmptyElement
+ "foo:bar", // name
+ "foo", // prefix
+ "bar", // localName
String.Empty, // value
0 // attributeCount
);
|