473,796 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unique costraint in XML Schema

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

<xsd:simpleTy pe name="ResultArr ayType">
<xsd:restrictio n base="xsd:nonNe gativeInteger">
<xsd:maxExclusi ve value="1000"/>
</xsd:restriction >
</xsd:simpleType>

How can I add an unique costraint to this type?


Jul 20 '05 #1
7 7663


hyppos wrote:

I've a XML Schema with this user Type

<xsd:simpleTy pe name="ResultArr ayType">
<xsd:restrictio n base="xsd:nonNe gativeInteger">
<xsd:maxExclusi ve 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:simpleTy pe name="ResultArr ayType">
<xsd:restrictio n base="xsd:nonNe gativeInteger">
<xsd:maxExclusi ve 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:simpleTy pe name="ResultArr ayType">
<xsd:restrictio n base="xsd:uniqu e">
<xsd:maxExclusi ve 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="listOfNum bers">
<xs:complexType >
<xs:sequence>
<xs:element name="Number" type="ResultArr ayType"
maxOccurs="unbo unded"/>
</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:simpleTy pe name="ResultArr ayType">
<xsd:restrictio n base="xsd:uniqu e">
<xsd:maxExclusi ve 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*******@yaho o.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
1867
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 have to be unique only within each document. I.e., the following is valid: <doc> <file>AAA</file> <file>BBB</file> </doc>
10
26143
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 null references another, FK_LASTLYOID bigint not null references lastly, unique (FK_OTHEROID,FK_ANOTHEROID))
5
16737
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 unique index like:
2
1895
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 the sample document and do not pick up that the name is not unique. Any clues as to what could be going wrong? Thanks.
0
2560
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
3722
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 is my XSD file and XML file: ----------- test.xsd ---------------- <?xml version="1.0" encoding="UTF-8"?>
1
4024
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" type="xs:string"/> </xs:sequence>
1
6041
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
2826
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? Here’s a working example: <xs:schema id="schema" targetNamespace="http://tempuri.org/schema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/schema.xsd" xmlns:mstns="http://tempuri.org/schema.xsd" ...
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10456
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7548
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5442
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.