Suppose I have some schema:
<xsd:schema ...>
<xsd:element name="foo">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="fooElement" type="xs:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
This defines some element foo
which has inside it some element fooElement
with type string. I'd like to now extend element foo
to also have an element barElement
and call this extension bar
.
To complicate things, let's also suppose that someone else has defined foo
and the schema cannot be changed. While the example here is trivial, let's also assume that the contents of foo
might be more complicated, and that defining a new schema isn't quite as simple as copying the element fooElement
.
Effectively, I'd like to define a new schema:
<xsd:schema xmlns:fns="otherschema" ...>
<xsd:import namespace="otherschema" />
<xsd:element name="bar">
<xsd:complexContent>
<xsd:extension base="fns:foo">
<xsd:sequence>
<xsd:element name="barElement" type="xs:string" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:element>
</xsd:schema>
Unfortunately <xsd:extension>
's base
attribute only accepts XSD type arguments, not elements. How do I extend an element? (can I extend an element?)