xsd

T

timothy-tim

I am fairly new to XSD so I assume this is probably a FAQ.

I have a Complex Type say "Foo" which is present as child element of
many xs:element.

In just one of these elements Bar, I want Foo to have additional
attributes/Facets

for example in the schema below
<xs:complexType name="Bar">
<xs:sequence>
<xs:element name="Foo" type="Foo" maxOccurs="unbounded"
minOccurs="0">
</xs:element>
</xs:sequence>
</xs:complexType>

I want Foo to have an additional attirubtute called IsTrue="xs:Boolean"


How do I achive this? Do I have to declare a new type for this?

-Tim
 
G

George Bina

Hi,

Yes, you need to declare a new type that will extend Foo and will add
the attribute that you want. You can do that either with a local type
declaration like

<xs:element name="Foo" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:extension base="Foo">
<xs:attribute name="isTrue" type="xs:boolean"/>
</xs:extension>
</xs:complexType>
</xs:element>

or by defining a new named type and refer to that instead of Foo.

Best Regards,
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top