By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,200 Members | 1,607 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,200 IT Pros & Developers. It's quick & easy.

How can I redefine an element in an extended type?

P: n/a
Hello,

I'm struggling to extend the types defined in a schema. I've searched
this group (and others) with no luck so far. I have the following two
schemas:

<!-- foobar.xsd -->
<!-- A 'base' schema which will be 'extended' by customer specific ones
-->
<xs:schema ...>
<xs:complexType name="foo">
<xs:sequence>
<xs:element name="fooName" type="xs:string"/>
<xs:element name="bar" type="bar"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="bar">
<xs:sequence>
<xs:element name="barName" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

<!-- customerA-foobar.xsd -->
<!-- A version of the base schema for customer A -->
<xs:schema ...>
<xs:complexType name="customerAFoo">
<xs:complexContent>
<xs:extension base="foo">
<xs:sequence>
<xs:element name="fooCode" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:complexType name="customerABar">
<xs:complexContent>
<xs:extension base="bar">
<xs:sequence>
<xs:element name="barCode" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>

I need to redefine the 'bar' element in 'customerAFoo' so that it's
type is a 'customerABar', but that isn't allowed for 'xs:extension'
unless I use 'xs:redefines'. 'xs:redefines' isn't working for me
because I'm using the XMLBeans tool to generate Java classes from these
schema, and when I use 'xs:redefines', XMLBeans doesn't understand that
customerAFoo extends foo, etc.

Is there another way to express the fact that, for a customerAFoo, the
'bar' element should be a 'customerABar'? Should I be using
substitution groups or xsi:type somewhere?

Thanks for your help.

Apr 11 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.