- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsI want to have XML elements that look the following:
<MyElement myAttr="true">5</MyElement
I want a restructed value on my element (1-10) plus an attribute. I can't get the attribute and the restricted type to work together in an XML schema. I've tried the following and always get errors:
<xs:element name="MyElement" default="4">
<xs:complexType mixed="true">
<xs:simpleContent>
<xs:restriction base="xs:unsignedInt">
<xs:minInclusive value="1" />
<xs:maxInclusive value="10" />
</xs:restriction>
<xs:extension base="xs:boolean">
<xs:attribute name="myAttr" type="xs:boolean" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
I've also tried removing the extension and just having:
<xs:element name="MyElement" default="4">
<xs:complexType mixed="true">
<xs:simpleContent>
<xs:restriction base="xs:unsignedInt">
<xs:minInclusive value="1" />
<xs:maxInclusive value="10" />
</xs:restriction>
<xs:attribute name="myAttr" type="xs:boolean" use="required" />
</xs:simpleContent>
</xs:complexType>
</xs:element>
Any ideas what I'm doing wrong here. What can I do to make all of these elements happy together? Thanks!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: GertonePosted on 2008-08-07 at 12:49:19ID: 22184659
you have a weird mix of restriction and extension.
I suggest that you make a simpleType which is named and then used as a base for extension
something like this
<xs:element name="MyElement" default="4">
<xs:complexType mixed="true">
<xs:simpleContent>
<xs:extension base="myType">
<xs:attribute name="myAttr" type="xs:boolean" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="myType">
<xs:restriction base="xs:unsignedInt">
<xs:minInclusive value="1" />
<xs:maxInclusive value="10" />
</xs:restriction>
</xs:simpleType>