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

XSD w3 standard ID data type (that allows spaces)?

Hello,

I would like to create a user XSD data type that inherits from the w3
standard data type called ID to make sure a certain repeated element
always contains distinct values. The problem is I would like this
element to also allow spaces to be present. By default the ID data
type does not allow spaces.

How can I inherit ID and also allow the entry of spaces in the data of
a new derived data type? This is a title column where I dont want to
allow a duplicate title to ever be entered and the title is also to be
a user-friendly distinct key, so I am reluctant to use system type
keys or guids. I tried the following but my document still fails to
validate when a space is entered in the elements that are typed as
"typeTitle" below:

Schema:

<xsd:simpleType name="typeTitle">
<xsd:restriction base="xsd:ID">
<xsd:maxLength value="100"/>
<xsd:whiteSpace value="preserve"/>
</xsd:restriction>
</xsd:simpleType>

<xsd:element name="Title" type="typeTitle"/>

Test data that passes validation:

<Titles>
<Title>abc</Title>
<Title>xyz</Title>
</Titles>

Test data that passes distinctness but fails with spaces (I need a
data type that allows this doc to only be validated for distinctness):

<Titles>
<Title>Gone With The Wind</Title>
<Title>Satin Doll</Title>
</Titles>

I'm using the Microsoft XML DOM.

Maybe there is some other w3 data type I am not aware of maybe called
"distinctData" or something that will allow all characters and only
implement the distinctness rule of ID's?

Thanks for any help
Rick

Mar 2 '07 #1
6 2816
On Mar 2, 11:00 pm, "RickH"
<passp...@windcrestsoftware.comwrote:
How can I inherit ID and also allow the entry of spaces
in the data of a new derived data type?
I believe you can't.
Maybe there is some other w3 data type I am not aware of
maybe called "distinctData"
No, but see:

http://www.perlmonks.org/index.pl?node_id=542341
or something that will allow all characters and only
implement the distinctness rule of ID's?
Sort of. See W3C's XML Schema Primer, 5.1.

(I think some selfless hero should step forward and start
a ctx FAQ. This one's certainly a contender for the top
spot in the XML Schema section.)

--
roy axenov

Mar 2 '07 #2
On Mar 2, 3:00 pm, "RickH" <passp...@windcrestsoftware.comwrote:
Hello,

I would like to create a user XSD data type that inherits from the w3
standard data type called ID to make sure a certain repeated element
always contains distinct values. The problem is I would like this
element to also allow spaces to be present. By default the ID data
type does not allow spaces.

How can I inherit ID and also allow the entry of spaces in the data of
a new derived data type? This is a title column where I dont want to
allow a duplicate title to ever be entered and the title is also to be
a user-friendly distinct key, so I am reluctant to use system type
keys or guids. I tried the following but my document still fails to
validate when a space is entered in the elements that are typed as
"typeTitle" below:

Schema:

<xsd:simpleType name="typeTitle">
<xsd:restriction base="xsd:ID">
<xsd:maxLength value="100"/>
<xsd:whiteSpace value="preserve"/>
</xsd:restriction>
</xsd:simpleType>

<xsd:element name="Title" type="typeTitle"/>

Test data that passes validation:

<Titles>
<Title>abc</Title>
<Title>xyz</Title>
</Titles>

Test data that passes distinctness but fails with spaces (I need a
data type that allows this doc to only be validated for distinctness):

<Titles>
<Title>Gone With The Wind</Title>
<Title>Satin Doll</Title>
</Titles>

I'm using the Microsoft XML DOM.

Maybe there is some other w3 data type I am not aware of maybe called
"distinctData" or something that will allow all characters and only
implement the distinctness rule of ID's?

Thanks for any help
Rick
Oops, nevermind, I just found the w3 chapter on Identity-constraint
Definition and use of the :key element. That sounds like what I need,
correct? As long as my constraint xPath query returns either 0 or 1
row for the data match, then the restriction knows it's distinct.

If you still want to answer this, thats ok, but I think I can figure
it out.

Mar 2 '07 #3
RickH wrote:
I would like to create a user XSD data type that inherits from the w3
standard data type called ID to make sure a certain repeated element
always contains distinct values.
Wrong solution. If what you want is unique values, you can say exactly
that in Schema by using (surprisingly enough) the "unique" constraint.
If you want a set of values which are unique at point of assertion but
can be referred to (like IDs, but separate from the official ID space),
use the "key" and "keyref" constraints.

http://www.w3.org/TR/2004/REC-xmlsch...8/#declare-key
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Mar 2 '07 #4
roy axenov wrote:
(I think some selfless hero should step forward and start
a ctx FAQ.
Well, there are a lot of other XML FAQs out there, so the first thing to
do would be to point to those... but, yeah, that thought has occurred to
me. Certainly that's how the XSL FAQ was assembled.

The most elegant solution (least effort for any one person, though
conversely least credit to any one person) would be to find a Wiki
somewhere that's willing to host this FAQ, and build it up collaboratively.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Mar 2 '07 #5
On Mar 3, 12:02 am, Joseph Kesselman
<keshlam-nos...@comcast.netwrote:
roy axenov wrote:
(I think some selfless hero should step forward and
start a ctx FAQ.

Well, there are a lot of other XML FAQs out there, so the
first thing to do would be to point to those...
Indeed, that's a very important part of any newsgroup FAQ's
job description.
Certainly that's how the XSL FAQ was assembled.
And that's its biggest problem, actually... I mean, it's an
excellent reading for anyone willing to improve their
overall XSL-fu, but I would expect neophytes to get lost in
its depths long before finding actual answers to basic
questions (short, concise and to the point).
The most elegant solution (least effort for any one
person, though conversely least credit to any one person)
would be to find a Wiki somewhere that's willing to host
this FAQ, and build it up collaboratively.
I suppose we'll need a slightly-less-selfless hero to step
forward with a Wiki hosting. Actually, collaboration of the
group regulars seems to be the only solution anyway, since
I don't believe there's any one person sufficiently
conversant in all aspects of XML technologies--even if we
consider only the more important aspects, without delving
into the grisly details of implementation-specific stuff
and useful-but-somewhat-esoteric tools. (And if such a
person exists, he/she is probably too busy with his/her
demigodly pursuits to spare the time for maintaining a
newsgroup FAQ.)

--
roy axenov

Mar 2 '07 #6
On Mar 2, 4:02 pm, Joseph Kesselman <keshlam-nos...@comcast.net>
wrote:
roy axenov wrote:
(I think some selfless hero should step forward and start
a ctx FAQ.

Well, there are a lot of other XML FAQs out there, so the first thing to
do would be to point to those... but, yeah, that thought has occurred to
me. Certainly that's how the XSL FAQ was assembled.

The most elegant solution (least effort for any one person, though
conversely least credit to any one person) would be to find a Wiki
somewhere that's willing to host this FAQ, and build it up collaboratively.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
I used the <xsd:uniqueat collection level to inspect the children
for distinctness:

Here is my final solution that works in case anyone is interested, my
code is spread over several include files so I'll just paste each with
the file name in upper case preceeding that files contents: (3 files
follow, the test file is last and makes ref to the songs.xsd file, and
songs.xsd includes by ref my global types)

SONGS.XSD
------------------------

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:include schemaLocation="types.xsd" />
<xs:element name="Songs" type="typeSongs">
<xs:unique name="keyTitle">
<xs:selector xpath="Song"/>
<xs:field xpath="Title"/>
</xs:unique>
</xs:element>
</xs:schema>

TYPES.XSD
------------------------

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">

<!-- Simple Types -->

<xs:simpleType name="typeTitle">
<xs:restriction base="xs:string">
<xs:maxLength value="100"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="typeFilePath">
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="typeFitPage">
<xs:restriction base="xs:string">
<xs:enumeration value="HEIGHT"/>
<xs:enumeration value="WIDTH"/>
<xs:enumeration value="Height"/>
<xs:enumeration value="Width"/>
<xs:enumeration value="height"/>
<xs:enumeration value="width"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="typeRating">
<xs:restriction base="xs:integer">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="5"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="typeVolume">
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="typeBalance">
<xs:restriction base="xs:integer">
<xs:minInclusive value="-100"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="typeTimeSignature">
<xs:restriction base="xs:string">
<xs:pattern value="[123456789][/][123456789]"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="typeKey">
<xs:restriction base="xs:string">
<xs:enumeration value="A Maj"/>
<xs:enumeration value="A# Maj"/>
<xs:enumeration value="Bb Maj"/>
<xs:enumeration value="B Maj"/>
<xs:enumeration value="B# Maj"/>
<xs:enumeration value="C Maj"/>
<xs:enumeration value="C# Maj"/>
<xs:enumeration value="Db Maj"/>
<xs:enumeration value="D Maj"/>
<xs:enumeration value="D# Maj"/>
<xs:enumeration value="Eb Maj"/>
<xs:enumeration value="E Maj"/>
<xs:enumeration value="E# Maj"/>
<xs:enumeration value="F Maj"/>
<xs:enumeration value="F# Maj"/>
<xs:enumeration value="Gb Maj"/>
<xs:enumeration value="G Maj"/>
<xs:enumeration value="G# Maj"/>
<xs:enumeration value="Ab Maj"/>
<xs:enumeration value="A Min"/>
<xs:enumeration value="A# Min"/>
<xs:enumeration value="Bb Min"/>
<xs:enumeration value="B Min"/>
<xs:enumeration value="B# Min"/>
<xs:enumeration value="C Min"/>
<xs:enumeration value="C# Min"/>
<xs:enumeration value="Db Min"/>
<xs:enumeration value="D Min"/>
<xs:enumeration value="D# Min"/>
<xs:enumeration value="Eb Min"/>
<xs:enumeration value="E Min"/>
<xs:enumeration value="E# Min"/>
<xs:enumeration value="F Min"/>
<xs:enumeration value="F# Min"/>
<xs:enumeration value="Gb Min"/>
<xs:enumeration value="G Min"/>
<xs:enumeration value="G# Min"/>
<xs:enumeration value="Ab Min"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="typeMessage">
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="500"/>
</xs:restriction>
</xs:simpleType>

<!-- Complex (1 level) Types -->

<xs:complexType name="typeSongData">
<xs:sequence>
<xs:element name="Title" type="typeTitle"/>
<xs:element name="Audio" type="typeFilePath"/>
<xs:element name="Sheet" type="typeFilePath"/>
<xs:element name="Page" type="xs:positiveInteger" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Composers" type="xs:string" minOccurs="0"
maxOccurs="1"/>
<xs:element name="FitPage" type="typeFitPage" minOccurs="0"
maxOccurs="1"/>
<xs:element name="StartAt" type="xs:time" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Keywords" type="xs:string" minOccurs="0"
maxOccurs="1"/>
<xs:element name="GeneralRating" type="typeRating" minOccurs="0"
maxOccurs="1"/>
<xs:element name="DifficultyRating" type="typeRating" minOccurs="0"
maxOccurs="1"/>
<xs:element name="RehearsalRating" type="typeRating" minOccurs="0"
maxOccurs="1"/>
<xs:element name="TimeSignature" type="typeTimeSignature"
minOccurs="0" maxOccurs="1"/>
<xs:element name="Key" type="typeKey" minOccurs="0" maxOccurs="1"/>
<xs:element name="TempoBPM" type="xs:positiveInteger" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Volume" type="typeVolume" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Balance" type="typeBalance" minOccurs="0"
maxOccurs="1"/>
</xs:sequence>
</xs:complexType>

<!-- Complex (2 level) Types -->

<xs:complexType name="typeSong">
<xs:sequence>
<xs:element name="Song" type="typeSongData"/>
</xs:sequence>
</xs:complexType>

<!-- Complex Collection Types -->

<xs:complexType name="typeSongs">
<xs:sequence>
<xs:element name="Song" type="typeSongData" minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>

</xs:schema>
SONGS.XML (this test file will fail with a duplicate Title)
------------------------------------------------------------------------------------

<Songs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="Schema/songs.xsd">
<Song>
<Title>One</Title>
<Audio>hw1.wav</Audio>
<Sheet>testcutepdf.pdf</Sheet>
<Page>2</Page>
<Composers>Jobim</Composers>
<Keywords>Latin,Cuban,Slow</Keywords>
<GeneralRating>3</GeneralRating>
<DifficultyRating>3</DifficultyRating>
<RehearsalRating>3</RehearsalRating>
</Song>
<Song>
<Title>a song</Title>
<Audio>hw1.wav</Audio>
<Sheet>testcutepdf.pdf</Sheet>
<Page>2</Page>
<FitPage>width</FitPage>
</Song>
<Song>
<Title>Route 66 Hal Leonard Best of Swing 13</Title>
<Audio>hw1.wav</Audio>
<Sheet>testcutepdf.pdf</Sheet>
<Page>2</Page>
<FitPage>width</FitPage>
</Song>
<Song>
<Title>the song</Title>
<Audio>hw1.wav</Audio>
<Sheet>testcutepdf.pdf</Sheet>
<Page>2</Page>
<FitPage>width</FitPage>
</Song>
<Song>
<Title>Two</Title>
<Audio>Route 66 Hal Leonard Best of Swing 13.wma</Audio>
<Sheet>IACReference.pdf</Sheet>
<Page>1</Page>
<FitPage>height</FitPage>
<StartAt>00:00:03</StartAt>
<Keywords>swing,road</Keywords>
<GeneralRating>4</GeneralRating>
<DifficultyRating>4</DifficultyRating>
<RehearsalRating>4</RehearsalRating>
<TimeSignature>4/4</TimeSignature>
<Key>F Maj</Key>
<TempoBPM>120</TempoBPM>
<Volume>100</Volume>
<Balance>0</Balance>
</Song>
<Song>
<Title>Three</Title>
<Audio>hw2.wav</Audio>
<Sheet>IACReference.pdf</Sheet>
<Page>11</Page>
</Song>
<Song>
<Title>Four</Title>
<Audio>hw1xxxx.wav</Audio>
<Sheet>testcutepdfXXXX.pdf</Sheet>
<Page>1</Page>
</Song>
<Song>
<Title>Five</Title>
<Audio>hw1.wav</Audio>
<Sheet>testcutepdf.pdf</Sheet>
<Page>1</Page>
</Song>
<Song>
<Title>Six</Title>
<Audio>hw2.wav</Audio>
<Sheet>nabble_javascript_error.pdf</Sheet>
<Page>1</Page>
</Song>
<Song>
<Title>a song</Title>
<Audio>hw1.wav</Audio>
<Sheet>testcutepdf.pdf</Sheet>
<Page>2</Page>
<FitPage>width</FitPage>
</Song>
</Songs>
Mar 2 '07 #7

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

Similar topics

1
by: Andrus | last post by:
User enters an item code to a browser <input type=text> field. I need to verify the code entered using server callback. If item code is wrong, user is not allowed to leave the field. So I think...
43
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own...
1
by: eddiekwang | last post by:
Hello, when I export data from a table to a text file, I get trailing spaces if the data type in char. (This dosen't happen if the data type is varchar). I can get rid of the spaces by using the...
5
by: Michael Hill | last post by:
Hi, folks. I am writing a Javascript program that accepts (x, y) data pairs from a text box and then analyzes that data in various ways. This is my first time using text area boxes; in the past,...
93
by: Matt | last post by:
Hi folks. Can you help with some questions? I gather that some types supported by g++ are nonstandard but have been proposed as standards. Are the long long and unsigned long long types still...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
9
by: Grizlyk | last post by:
Somebody have offered std colors to C++ in the msg here: http://groups.google.com/group/comp.lang.c++/browse_frm/thread/2e5bb3d36ece543b/1acf6cd7e3ebdbcd#1acf6cd7e3ebdbcd The main objection to...
4
by: Burt | last post by:
I'm working on a Windows app that pulls data from SQL Server, displays it on various forms and grids, and allows the user to update, insert, delete data. Some but not much business logic, just...
4
by: dustin | last post by:
I've been hacking away on this PEP for a while, and there has been some related discussion on python-dev that went into the PEP: ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...

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.