Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Restrictions on attribute values

Posted on 2007-03-27
Medium Priority
Last Modified: 2007-03-27

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:restriction base="xs:integer">
                        <xs:minInclusive value="0"/>
                        <xs:maxInclusive value="23"/>

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

Many thanks...

Question by:brdrok
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
LVL 60

Accepted Solution

Geert Bormans earned 2000 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:extension base="xs:string">
                    <xs:attribute name="time" >
                            <xs:restriction base="xs:integer">
                                <xs:minInclusive value="0"/>
                                <xs:maxInclusive value="23"/>



Author Comment

ID: 18800081

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

LVL 60

Expert Comment

by:Geert Bormans
ID: 18800374

Featured Post

Command Line Tips and Tricks

The command line is a powerful tool at the disposal of every Linux user. Although Linux distros come with beautiful user interfaces, it's worthwhile to learn the command line because it allows you to do a number of things that you otherwise cannot do from the GUI.  

Question has a verified solution.

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

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

721 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