Greetings,
I am writing an application that uses an extendible XML file. in order
to validate that XML I use a main XSD and in additional - few more
extensions XSD's that uses the types in the main XSD as base types.
my clients can define their own XSD's extensions and use my generic
application to process their XML's.
The problem:
I use the same namespace in all of the XSD's ( both base and extensions
), the first time I load a Schema into the XmlSchemaCollec tion it works
fine, but on the next schemas , the XmlSchemaCollec tion just overwrite
the previous ( maybe because of the same namespace ) and I only remain
with the most previously schema loaded.
code:
string[] schemas = new string[2]{"SchemaA.xsd", "SchemaB.xs d"};
for(int i=0 ;i< schemas.GetLeng th(0) ; i++)
{
XmlTextReader xsdReader =new XmlTextReader(s chemas[i]);
XmlSchema schem = XmlSchema.Read( xsdReader ,new
ValidationEvent Handler(SchemaH andler) );
collection.Add( schem);
}
SchemA.xsd :
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace ="MyOwnNS" elementFormDefa ult="qualified"
xmlns="MyOwnNS"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation= "BaseSchema.xsd "/>
<xs:complexTy pe name="Extendibl eA_Type">
<xs:complexCont ent>
<xs:extension base="Base_Type ">
<xs:sequence>
<xs:element name="blabla" type="xs:string " />
</xs:sequence>
</xs:extension>
</xs:complexConte nt>
</xs:complexType>
<xs:element name="Extendibl eA" substitutionGro up="BaseElement "
type="Extendibl eA_Type" />
</xs:schema>
SchemaB.xsd :
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace ="MyOwnNS" elementFormDefa ult="qualified"
xmlns="MyOwnNS"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation= "BaseSchema.xsd "/>
<xs:complexTy pe name="Extendibl eB_Type">
<xs:complexCont ent>
<xs:extension base="Base_Type ">
<xs:sequence>
<xs:element name="whiwhi" type="xs:intege r" />
</xs:sequence>
</xs:extension>
</xs:complexConte nt>
</xs:complexType>
<xs:element name="Extendibl eB" substitutionGro up="BaseElement "
type="Extendibl eB_Type" />
</xs:schema>
I didnt add the base schema but it has the same target namespace.
must I differ the schemas with different namespace's ?