473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Schema attribute restriction

Hi, wondering if anybody could help me figure how to. in schema,
restrict the list of tokens I may have as an attribute value. For
example

<xs:complexType name="customer">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
</xs:sequence>
<xs:attribute name="life" use="optional">
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="session"/>
<xs:enumeration value="request"/>
<xs:enumeration value="context"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>

I would like "Norwegian_customer" to extend from customer but to allow
for the "life" attribute only the "session" value. This is what I am
doing so far but is not correct.

<xs:complexType name="Norwegian_customer">
<xs:complexContent>
<xs:restriction base="pf:customer">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
</xs:sequence>
<xs:attribute name="life" use="optional">
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="session"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
Thanks in advance

Jul 20 '05 #1
3 4022
Hi,

In order for this to work, the simple type of "life" in
Norwegian_customer has to explicitly say it is a restriction of the
simple type of "life" in customer. For this, you need to use a named
simple type, like this:

<xs:complexType name="customer">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
</xs:sequence>
<xs:attribute name="life" use="optional" type="lifetype"/>
</xs:complexType>

<xs:simpleType name="lifetype">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="session"/>
<xs:enumeration value="request"/>
<xs:enumeration value="context"/>
</xs:restriction>
</xs:simpleType>

<xs:complexType name="Norwegian_customer">
<xs:complexContent>
<xs:restriction base="pf:customer">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
</xs:sequence>
<xs:attribute name="life" use="optional">
<xs:simpleType>
<xs:restriction base="lifetype">
<xs:enumeration value="session"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:restriction>
</xs:complexContent>
</xs:complexType>

Hope that helps,
Priscilla
----------------------------------
Priscilla Walmsley
Author, Definitive XML Schema
http://www.datypic.com
----------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #2
NP
Thanks , though XMLSpy allows it , it does not seem able to validate it
using MSXML.

Thanks
Priscilla Walmsley wrote:
Hi,

In order for this to work, the simple type of "life" in
Norwegian_customer has to explicitly say it is a restriction of the
simple type of "life" in customer. For this, you need to use a named
simple type, like this:

<xs:complexType name="customer">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
</xs:sequence>
<xs:attribute name="life" use="optional" type="lifetype"/>
</xs:complexType>

<xs:simpleType name="lifetype">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="session"/>
<xs:enumeration value="request"/>
<xs:enumeration value="context"/>
</xs:restriction>
</xs:simpleType>

<xs:complexType name="Norwegian_customer">
<xs:complexContent>
<xs:restriction base="pf:customer">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
</xs:sequence>
<xs:attribute name="life" use="optional">
<xs:simpleType>
<xs:restriction base="lifetype">
<xs:enumeration value="session"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:restriction>
</xs:complexContent>
</xs:complexType>

Hope that helps,
Priscilla
----------------------------------
Priscilla Walmsley
Author, Definitive XML Schema
http://www.datypic.com
----------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Jul 20 '05 #3
What error message are you getting? Maybe if you post your whole schema
and instance it will be more obvious what is wrong.

Priscilla

----------------------------------
Priscilla Walmsley
Author, Definitive XML Schema
http://www.datypic.com
----------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: M Rao | last post by:
I have xml data coming in as a stream from a web service running against exchange server.The attributes for the elements dtstart and dtend, b:dt="dateTime.tz"...
0
by: Sahmiac | last post by:
Hello Everyone, I'm sure this question has been asked a million times, but I'm going crazy trying to get my xml validation to work. I've spent the day reading msdn, the dot net documentation and...
2
by: Rajesh Jain | last post by:
I Have 2 separate schemas. --------------Schema 1 is defined as below----------- <xs:schema targetNamespace="http://Schemas/1" xmlns="http://Schemas/1" xmlns:xs="http://www.w3.org/2001/XMLSchema"...
0
by: Vish | last post by:
I am trying to use xmldatadocument to load an xml file.The xml has the data as attributes, the datadocument is able to successfully parse the document into the tables and shows the right column...
2
by: Chuck Bowling | last post by:
AIML Schema: http://209.168.21.76/CommunityStarterKit/Downloads/258.aspx I have a Schema (in the link above) that I've been trying to make work in VS2003 for a while now and just can't seem to...
0
by: Deep Purple | last post by:
I started with the following error... ------------------------------------------------------- An error occured while loading the schema with TargetNamespace 'http://www.w3.org/2001/XMLSchema'...
3
by: shyam | last post by:
Hi ALL Just started to learm Schemas and I am stuck with this ================================================================== <xs:complexType> ....... <xs:sequence> ......
5
by: hello | last post by:
How can I define the schema so that myage element has to be double or null? <xs:simpleType name="myage"> <xs:restriction base="xs:double"> <xs:enumeration value="null"/> </xs:restriction>...
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
0
by: =?Utf-8?B?TGFzdGJ1aWxkZXJz?= | last post by:
Hi all, I have a weird problem which has been causing me a headache for the last two days. I have to dynamicly generate a schema in memory and load it into a dataset in memory to be returned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.