473,382 Members | 1,424 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,382 software developers and data experts.

Unique costraint in XML Schema

Hi,
I've a XML Schema with this user Type

<xsd:simpleType name="ResultArrayType">
<xsd:restriction base="xsd:nonNegativeInteger">
<xsd:maxExclusive value="1000"/>
</xsd:restriction>
</xsd:simpleType>

How can I add an unique costraint to this type?


Jul 20 '05 #1
7 7643


hyppos wrote:

I've a XML Schema with this user Type

<xsd:simpleType name="ResultArrayType">
<xsd:restriction base="xsd:nonNegativeInteger">
<xsd:maxExclusive value="1000"/>
</xsd:restriction>
</xsd:simpleType>

How can I add an unique costraint to this type?


You can use <xsd:unique> at the place where you use this type for an
element definition I think.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
I've a XML Schema with this user Type

<xsd:simpleType name="ResultArrayType">
<xsd:restriction base="xsd:nonNegativeInteger">
<xsd:maxExclusive value="1000"/>
</xsd:restriction>
</xsd:simpleType>

How can I add an unique costraint to this type?


You can use <xsd:unique> at the place where you use this type for an
element definition I think.

--


Could you give me an example?
Jul 20 '05 #3
You can use <xsd:unique> at the place where you use this type for an
element definition I think.

Like This?

<xsd:simpleType name="ResultArrayType">
<xsd:restriction base="xsd:unique">
<xsd:maxExclusive value="1000"/>
</xsd:restriction>
</xsd:simpleType>

unfortunately, doesn't work.
Jul 20 '05 #4
Hi,

You specify the uniqueness constraint on the element, not the type. For
example, if you had an element named "Number" with that type, and you
wanted its value to be unique within the scope of its parent element
"listOfNumbers", it would look something like this:
<xs:element name="listOfNumbers">
<xs:complexType>
<xs:sequence>
<xs:element name="Number" type="ResultArrayType"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="uniqueNum">
<xs:selector xpath="Number"/>
<xs:field xpath="."/>
</xs:unique>
</xs:element>

Hope that helps,
Priscilla

-----------------------------------------------------
Priscilla Walmsley
Author, Definitive XML Schema (Prentice Hall PTR)
http://www.datypic.com
-----------------------------------------------------

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


hyppos wrote:
You can use <xsd:unique> at the place where you use this type for an
element definition I think.


Like This?

<xsd:simpleType name="ResultArrayType">
<xsd:restriction base="xsd:unique">
<xsd:maxExclusive value="1000"/>
</xsd:restriction>
</xsd:simpleType>

unfortunately, doesn't work.


No, a type can't be unique, only an element or attribute in a certain
scope, see the example in
http://www.w3.org/TR/xmlschema-0/#specifyingUniqueness

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #6
Martin Honnen <ma*******@yahoo.de> writes:
No, a type can't be unique, only an element or attribute in a certain
scope, see the example in
http://www.w3.org/TR/xmlschema-0/#specifyingUniqueness


The advice is good, but there are a few glitches in the original
version of the Primer -- a better reference is the draft 2nd edition
at

http://www.w3.org/TR/2004/PER-xmlsch...yingUniqueness

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Jul 20 '05 #7

Thks to Everybody
Jul 20 '05 #8

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

Similar topics

3
by: Victor Engmark | last post by:
How do I define that the contents of an element should be unique only in a sub-tree of the whole XML file? In my case, I have several documents, each containing several files. The file names...
10
by: BuddhaBuddy | last post by:
Platform is DB2/NT 7.2.9 The table was created like this: CREATE TABLE MYTEST ( MYTESTOID bigint not null primary key, FK_OTHEROID bigint not null references other, FK_ANOTHEROID bigint not...
5
by: aj | last post by:
DB2 WSE 8.1 FP5 Red Hat AS 2.1 What is the difference between adding a unique constraint like: ALTER TABLE <SCHEMA>.<TABLE> ADD CONSTRAINT CC1131378283225 UNIQUE ( <COL1>) ; and adding a...
2
by: smachin1000 | last post by:
Hi All, In the sample schema & document below, I'd like the attribute "name" to be unique for all function elements under function_list. The tools I'm using (XML Spy and xmllint) all validate...
0
by: Torsten Munkelt | last post by:
Hi, I want to write an XML-schema saying that this document <root> <edge type="special"> <target type="one"/> </edge> <edge type="special"> <target type="one"/>
2
by: Aray | last post by:
I googled for it for few houres, but didn't resolve it, any hints will be thinkfull. I want to use the following XSD file to guarantee <element1is unique, but it doesn't work. The following...
1
by: cedric.louyot | last post by:
Hi, I've written a schema that looks like : <xs:schema> <xs:complexType name="myType"> <xs:sequence> <xs:element name="e1" type="T1" maxOccurs="unbounded"/> <xs:element name="e2"...
1
by: tthunder | last post by:
Hi @all, Please check the following XML file and XML schema definition below first: ------- XML File (full): ------- <?xml version="1.0" encoding="UTF-8"?>
0
by: icesign | last post by:
I know that the selector of these elements has a scope relative to the element being declared, but maybe there is a way to get beyond bounds of this scope or maybe just a way to extend base element?...
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
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.