Solved

Restrictions on attribute values

Posted on 2007-03-27
3
368 Views
Last Modified: 2007-03-27
Hi,

XML and XSD newbie here.  Is it possible to restrict the values of an attribute?  Below is my try #1 but it doesn't work.

......
......
<xs:attribute name="intHour" type="xs:int" use="required" >
                <xs:simpleType>
                  <xs:restriction base="xs:integer">
                        <xs:minInclusive value="0"/>
                        <xs:maxInclusive value="23"/>
                  </xs:restriction>
            </xs:simpleType>
    </xs:attribute>
  </xs:complexType>

how can I make intHour only accept values from 0 to 23?

Many thanks...

0
Comment
Question by:brdrok
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 18799808
you can't give the type twice
If you set the type of the attribute (type="xs:int")
you can't redefine it in the xs:attribute content
drop that and you will be OK

    <xs:element name="test">
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="xs:string">
                    <xs:attribute name="time" >
                        <xs:simpleType>
                            <xs:restriction base="xs:integer">
                                <xs:minInclusive value="0"/>
                                <xs:maxInclusive value="23"/>
                            </xs:restriction>
                        </xs:simpleType>
                    </xs:attribute>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>

    cheers

Geert
0
 
LVL 7

Author Comment

by:brdrok
ID: 18800081
Awesome,

always great to have another pair of eyes looking at stuff =)

Thanks
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 18800374
welcome
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question