Sean Bright
Usenet Archive
- Joined
- Dec 16, 2003
- Messages
- 10
- Reaction score
- 0
Hi there.
I'm having a problem which I hope is a simple one... Any help would be appreciated. I think it has something to do with the way attributes are (or are not) inherited in schemas...
This is the content of my XML Schema (minus the schema tag):
<xsd:complexType name="AType">
<xsd:attribute name="attr1" type="xsd:string" />
<xsd:attribute name="attr2" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="BType">
<xsd:complexContent>
<xsd:extension base="AType">
<xsd:attribute name="attr3" type="xsd:string" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="mydoc">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="a" type="AType"/>
<xsd:element name="b" type="BType"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
In my instance document, I simply want to be able to do the following:
<mydoc xmlns="http://foo.org/foo.xsd">
<a attr1="1" attr2="2"/>
<b attr1="1" attr2="2" attr3="3"/>
</mydoc>
Whenever I try to validate the document, however, I get an error that attr1 and attr2 are not valid for <b>. But <b> is of BType which extends AType and attr1 and attr2 are defined for AType. What am I missing?
Thanks in advance,
Sean
I'm having a problem which I hope is a simple one... Any help would be appreciated. I think it has something to do with the way attributes are (or are not) inherited in schemas...
This is the content of my XML Schema (minus the schema tag):
<xsd:complexType name="AType">
<xsd:attribute name="attr1" type="xsd:string" />
<xsd:attribute name="attr2" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="BType">
<xsd:complexContent>
<xsd:extension base="AType">
<xsd:attribute name="attr3" type="xsd:string" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="mydoc">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="a" type="AType"/>
<xsd:element name="b" type="BType"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
In my instance document, I simply want to be able to do the following:
<mydoc xmlns="http://foo.org/foo.xsd">
<a attr1="1" attr2="2"/>
<b attr1="1" attr2="2" attr3="3"/>
</mydoc>
Whenever I try to validate the document, however, I get an error that attr1 and attr2 are not valid for <b>. But <b> is of BType which extends AType and attr1 and attr2 are defined for AType. What am I missing?
Thanks in advance,
Sean