I have an XSD where I define an abstract base type. Other XSD files derive their types from the abstract base type. The base type defining XSD is in its own namespace, and the other XSD files have their own namespaces also. The problem I'm having is that the XML file which leverages the derived types won't recognize the derived types. Example:
BaseType.xsd
DerviedType.xsdCode:<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" targetNamespace="urn:MyBaseType" xmlns:mbt="urn:MyBaseType"> <complexType name="AbstractBaseType" abstract="true"> <choice maxOccurs="unbounded"> <element name="SomeElement"> <complexType> <attribute name="Name"/> </complexType> </element> </choice> </complexType> <element name="ElementUsingAbstractType" type="mbt:AbstractBaseType"/> </schema>
Test.xml:Code:<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" xmlns:mbt="urn:MyBaseType" xmlns:mdt="urn:MyDerivedType" targetNamespace="urn:MyDerivedType"> <import namespace="urn:MyBaseType" schemaLocation="BaseType.xsd"/> <complexType name="MyDerivedType"> <complexContent> <extension base="mbt:AbstractBaseType"> <sequence> <element name="SomeValue"></element> </sequence> </extension> </complexContent> </complexType> </schema>
Result from VS intellisense:Code:<mbt:MyBaseType xmlns:mm="urn:MyBaseType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:MyBaseType BaseType.xsd urn:MyDerivedType DerivedType.xsd"> <ElementUsingAbstractType xsi:type="mdt:MyDerivedType" Name="Foo"> <Value>Bar</Value> </ElementUsingAbstractType> </mbt:MyBaseType>
"This is an invalid xsi:type 'mdt:MyDerivedType'"
I've tried omitting the prefix to just xsi:type="MyDerivedType" in the XML too, though it doesn't work. There are no errors being reported by VS2008 in any of the XSD files, so I'm not sure what I'm doing wrong.


Reply With Quote


Bookmarks