+2006-02-28 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * XmlSchema.cs: Do not define namespace for zero-length TargetNamespace
+ and report XmlSchemaException when compiling XmlSchema with
+ zero-length TargetNamespace.
+
2006-02-01 Atsushi Enomoto <atsushi@ximian.com>
* BuiltInDatatype.cs : anyURI could be such relative path that
//4. targetNamespace should be of type anyURI or absent
if (TargetNamespace != null) {
+ if (TargetNamespace.Length == 0)
+ error (handler, "The targetNamespace attribute cannot have have empty string as its value.");
+
if(!XmlSchemaUtil.CheckAnyUri (TargetNamespace))
error(handler, TargetNamespace+" is not a valid value for targetNamespace attribute of schema");
}
// Add the xml schema namespace. (It is done
// only when no entry exists in Namespaces).
nss.Add ("xs", XmlSchema.Namespace);
- if (TargetNamespace != null)
+ if (TargetNamespace != null && TargetNamespace.Length != 0)
nss.Add ("tns", TargetNamespace);
}
+2006-02-28 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * XmlSchemaTests.cs: Added test for writing XmlSchema with
+ zero-length TargetNamespace. Added test for compiling XmlSchema
+ with zero-length TargetNamespace. Replaced Console.WriteLine with
+ AssertEquals.
+
2006-02-06 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaDatatypeTests.cs: (TestAnyType) NotDotNet -> Ignore.
AssertCompiledElement (element, qname, cType);
}
+ [Test]
+ [ExpectedException (typeof (XmlSchemaException))]
+ public void TestCompile_ZeroLength_TargetNamespace ()
+ {
+ XmlSchema schema = new XmlSchema ();
+ schema.TargetNamespace = string.Empty;
+ Assert (!schema.IsCompiled);
+
+ // MS.NET 1.x: The Namespace '' is an invalid URI.
+ // MS.NET 2.0: The targetNamespace attribute cannot have empty string as its value.
+ schema.Compile (null);
+ }
+
[Test]
[ExpectedException (typeof (XmlSchemaException))]
public void TestCompileNonSchema ()
{
XmlTextReader xtr = new XmlTextReader ("<root/>", XmlNodeType.Document, null);
XmlSchema schema = XmlSchema.Read (xtr, null);
- xtr.Close ();\r
+ xtr.Close ();
}
[Test]
xw = new XmlTextWriter (sw);
xs.TargetNamespace = "urn:foo";
xs.Write (xw);
- Console.WriteLine ("#2", "<xs:schema xmlns:tns=\"urn:foo\" targetNamespace=\"urn:foo\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" />", doc.DocumentElement.OuterXml);
+ doc.LoadXml (sw.ToString ());
+ AssertEquals ("#2", "<xs:schema xmlns:tns=\"urn:foo\" targetNamespace=\"urn:foo\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" />", doc.DocumentElement.OuterXml);
+
+ // Zero-length TargetNamespace
+ xs = new XmlSchema ();
+ sw = new StringWriter ();
+ xw = new XmlTextWriter (sw);
+ xs.TargetNamespace = string.Empty;
+ xs.Write (xw);
+ doc.LoadXml (sw.ToString ());
+ AssertEquals ("#2b", "<xs:schema targetNamespace=\"\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" />", doc.DocumentElement.OuterXml);
// XmlSerializerNamespaces
xs = new XmlSchema ();