I create a schema in memory and then I can write to a file fine. But
as soon as I add an import element I get an error when it goes to write
to the file.
The error message is:
The type System.Xml.Sche ma.XmlSchemaImp ort was not expected. Use the
XmlInclude or SoapInclude attribute to specify types that are not known
statically.
What does this mean? Is there a limitation to when I can use
<xs:importvs <xs:include>?
And why does it occur when I go to write it out? Is the schema
compiled at the time and is it looking to resolve the external schema?
If so, that description doesn't seem very accurate.
The following is the code that generates the schema (content gets
filled in later):
private XmlSchema GenerateBlankSc hema()
{
XmlSchema schema = new XmlSchema();
schema.ElementF ormDefault = XmlSchemaForm.Q ualified;
schema.Attribut eFormDefault = XmlSchemaForm.U nqualified;
schema.TargetNa mespace =
"http://schemas.infinit yinfo.com/coretypes";
schema.Namespac es.Add("ii",
"http://schemas.infinit yinfo.com/datatypes");
XmlSchemaImport import = new XmlSchemaImport ();
import.Namespac e =
"http://schemas.infinit yinfo.com/datatypes";
schema.Items.Ad d(import);
return schema;
}
I've tried the overload that takes XmlNamespaceMan ager as the second
parameter but same thing.
Jiho
as soon as I add an import element I get an error when it goes to write
to the file.
The error message is:
The type System.Xml.Sche ma.XmlSchemaImp ort was not expected. Use the
XmlInclude or SoapInclude attribute to specify types that are not known
statically.
What does this mean? Is there a limitation to when I can use
<xs:importvs <xs:include>?
And why does it occur when I go to write it out? Is the schema
compiled at the time and is it looking to resolve the external schema?
If so, that description doesn't seem very accurate.
The following is the code that generates the schema (content gets
filled in later):
private XmlSchema GenerateBlankSc hema()
{
XmlSchema schema = new XmlSchema();
schema.ElementF ormDefault = XmlSchemaForm.Q ualified;
schema.Attribut eFormDefault = XmlSchemaForm.U nqualified;
schema.TargetNa mespace =
"http://schemas.infinit yinfo.com/coretypes";
schema.Namespac es.Add("ii",
"http://schemas.infinit yinfo.com/datatypes");
XmlSchemaImport import = new XmlSchemaImport ();
import.Namespac e =
"http://schemas.infinit yinfo.com/datatypes";
schema.Items.Ad d(import);
return schema;
}
I've tried the overload that takes XmlNamespaceMan ager as the second
parameter but same thing.
Jiho
Comment