Thanks! That was it.
Zafar Abbas wrote:
> You should not add the XmlSchemaImport object to schema.items, rather to
> schema.Includes collection.
>
> "doughboy" <jihohan@gmail.com> wrote in message
> news:1153243705.173943.29920@h48g2000cwc.googlegroups.com...
> > 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.Schema.XmlSchemaImport 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:import> vs <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 GenerateBlankSchema()
> > {
> > XmlSchema schema = new XmlSchema();
> > schema.ElementFormDefault = XmlSchemaForm.Qualified;
> > schema.AttributeFormDefault = XmlSchemaForm.Unqualified;
> > schema.TargetNamespace =
> > "
http://schemas.infinityinfo.com/coretypes"; > > schema.Namespaces.Add("ii",
> > "
http://schemas.infinityinfo.com/datatypes");
> > XmlSchemaImport import = new XmlSchemaImport();
> > import.Namespace =
> > "
http://schemas.infinityinfo.com/datatypes"; > > schema.Items.Add(import);
> > return schema;
> > }
> >
> > I've tried the overload that takes XmlNamespaceManager as the second
> > parameter but same thing.
> >
> > Jiho
> >