I accidentally put this on another group - this is the more likley home...
The first code fragment creates the simplest of XML Schemas is code. After
the “Compile()” method is called on the schemaset objetc, the schema element
count is zero – but I was expecting one element in the PSVI.
I saved the XML output in the console window to a file, and ran the second
code fragment below to load in the XML from the file, and compile the schema.
The element count of the schema is now 1 – as expected.
Why does the compile for a schema created in code not set to schema element
count to 1?
I also tried to add a second element after a schema was loaded from a file
(as in second fragment), but instead of getting 2 elements, scheme just shows
1
First Code Fragment
XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.ValidationEventHandler +=new
ValidationEventHandler(schemaSet_ValidationEventHa ndler);
XmlSchema s = new XmlSchema();
schemaSet.Add(s);
// add an element
XmlQualifiedName e1Type = new XmlQualifiedName("string",
"http://www.w3.org/2001/XMLSchema");
XmlSchemaElement e = new XmlSchemaElement();
e.SchemaTypeName = e1Type;
e.Name = "E1";
s.Items.Add(e);
schemaSet.Compile();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(new
NameTable());
nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
s.Write(Console.Out, nsmgr);
Second Code Fragment
XmlSchemaSet schemaSet = new XmlSchemaSet();
XmlSchema s = schemaSet.Add(null, @"C:\Temp\CompileTest.xsd");
--
Steve at Pixelda, North Yorkshire.