473,608 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:simpleTy pe name="typeTitle ">
<xsd:restrictio n base="xsd:ID">
<xsd:maxLengt h value="100"/>
<xsd:whiteSpa ce 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
"distinctDa ta" 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 2836
On Mar 2, 11:00 pm, "RickH"
<passp...@windc restsoftware.co mwrote:
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 "distinctDa ta"
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...@windc restsoftware.co mwrote:
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:simpleTy pe name="typeTitle ">
<xsd:restrictio n base="xsd:ID">
<xsd:maxLengt h value="100"/>
<xsd:whiteSpa ce 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
"distinctDa ta" 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"
elementFormDefa ult="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"
elementFormDefa ult="qualified" >

<!-- Simple Types -->

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

<xs:simpleTyp e name="typeFileP ath">
<xs:restricti on base="xs:string ">
<xs:whiteSpac e value="preserve "/>
</xs:restriction>
</xs:simpleType>

<xs:simpleTyp e name="typeFitPa ge">
<xs:restricti on base="xs:string ">
<xs:enumerati on value="HEIGHT"/>
<xs:enumerati on value="WIDTH"/>
<xs:enumerati on value="Height"/>
<xs:enumerati on value="Width"/>
<xs:enumerati on value="height"/>
<xs:enumerati on value="width"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleTyp e name="typeRatin g">
<xs:restricti on base="xs:intege r">
<xs:minInclusiv e value="1"/>
<xs:maxInclusiv e value="5"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleTyp e name="typeVolum e">
<xs:restricti on base="xs:intege r">
<xs:minInclusiv e value="0"/>
<xs:maxInclusiv e value="100"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleTyp e name="typeBalan ce">
<xs:restricti on base="xs:intege r">
<xs:minInclusiv e value="-100"/>
<xs:maxInclusiv e value="100"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleTyp e name="typeTimeS ignature">
<xs:restricti on base="xs:string ">
<xs:pattern value="[123456789][/][123456789]"/>
</xs:restriction>
</xs:simpleType>

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

<xs:simpleTyp e name="typeMessa ge">
<xs:restricti on base="xs:string ">
<xs:whiteSpac e value="preserve "/>
<xs:maxLength value="500"/>
</xs:restriction>
</xs:simpleType>

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

<xs:complexTy pe name="typeSongD ata">
<xs:sequence>
<xs:element name="Title" type="typeTitle "/>
<xs:element name="Audio" type="typeFileP ath"/>
<xs:element name="Sheet" type="typeFileP ath"/>
<xs:element name="Page" type="xs:positi veInteger" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Composers " type="xs:string " minOccurs="0"
maxOccurs="1"/>
<xs:element name="FitPage" type="typeFitPa ge" 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="GeneralRa ting" type="typeRatin g" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Difficult yRating" type="typeRatin g" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Rehearsal Rating" type="typeRatin g" minOccurs="0"
maxOccurs="1"/>
<xs:element name="TimeSigna ture" type="typeTimeS ignature"
minOccurs="0" maxOccurs="1"/>
<xs:element name="Key" type="typeKey" minOccurs="0" maxOccurs="1"/>
<xs:element name="TempoBPM" type="xs:positi veInteger" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Volume" type="typeVolum e" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Balance" type="typeBalan ce" minOccurs="0"
maxOccurs="1"/>
</xs:sequence>
</xs:complexType>

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

<xs:complexTy pe name="typeSong" >
<xs:sequence>
<xs:element name="Song" type="typeSongD ata"/>
</xs:sequence>
</xs:complexType>

<!-- Complex Collection Types -->

<xs:complexTy pe name="typeSongs ">
<xs:sequence>
<xs:element name="Song" type="typeSongD ata" minOccurs="0"
maxOccurs="unbo unded" />
</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:noNamespace SchemaLocation= "Schema/songs.xsd">
<Song>
<Title>One</Title>
<Audio>hw1.wa v</Audio>
<Sheet>testcute pdf.pdf</Sheet>
<Page>2</Page>
<Composers>Jobi m</Composers>
<Keywords>Latin ,Cuban,Slow</Keywords>
<GeneralRating> 3</GeneralRating>
<DifficultyRati ng>3</DifficultyRatin g>
<RehearsalRatin g>3</RehearsalRating >
</Song>
<Song>
<Title>a song</Title>
<Audio>hw1.wa v</Audio>
<Sheet>testcute pdf.pdf</Sheet>
<Page>2</Page>
<FitPage>widt h</FitPage>
</Song>
<Song>
<Title>Route 66 Hal Leonard Best of Swing 13</Title>
<Audio>hw1.wa v</Audio>
<Sheet>testcute pdf.pdf</Sheet>
<Page>2</Page>
<FitPage>widt h</FitPage>
</Song>
<Song>
<Title>the song</Title>
<Audio>hw1.wa v</Audio>
<Sheet>testcute pdf.pdf</Sheet>
<Page>2</Page>
<FitPage>widt h</FitPage>
</Song>
<Song>
<Title>Two</Title>
<Audio>Route 66 Hal Leonard Best of Swing 13.wma</Audio>
<Sheet>IACRefer ence.pdf</Sheet>
<Page>1</Page>
<FitPage>height </FitPage>
<StartAt>00:00: 03</StartAt>
<Keywords>swing ,road</Keywords>
<GeneralRating> 4</GeneralRating>
<DifficultyRati ng>4</DifficultyRatin g>
<RehearsalRatin g>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.wa v</Audio>
<Sheet>IACRefer ence.pdf</Sheet>
<Page>11</Page>
</Song>
<Song>
<Title>Four</Title>
<Audio>hw1xxxx. wav</Audio>
<Sheet>testcute pdfXXXX.pdf</Sheet>
<Page>1</Page>
</Song>
<Song>
<Title>Five</Title>
<Audio>hw1.wa v</Audio>
<Sheet>testcute pdf.pdf</Sheet>
<Page>1</Page>
</Song>
<Song>
<Title>Six</Title>
<Audio>hw2.wa v</Audio>
<Sheet>nabble_j avascript_error .pdf</Sheet>
<Page>1</Page>
</Song>
<Song>
<Title>a song</Title>
<Audio>hw1.wa v</Audio>
<Sheet>testcute pdf.pdf</Sheet>
<Page>2</Page>
<FitPage>widt h</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
2382
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 I must use synchronuous server callback for this. Data passed to server is larger tham 2KB, so POST method should be used. Unfortunately, W3C standard does not support synchrunuous server callbacks. It allows using <iframe src=> trick or <script...
43
4950
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 libraries. I'm not sure if that's a good thing or not. AFAIK, most of Qt is compatable with the Standard Library. That is, QLT can interoperate with STL, and you can convert back and forth between std::string and Qt::QString, etc. Are there any...
1
3996
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 trim() function on every signle column. here is an example: DTSDestination("first_name") = DTSSource("last_name") My question is: Is there any easier way to get ride of the training spaces for all columns when exporing a table? It is too time...
5
2943
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, I have used individual entry fields for each variable. I would now like to use text area boxes to simplify the data entry (this way, data can be produced by another program--FORTRAN, "C", etc.--but analyzed online, so long as it is first...
93
2563
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 under consideration for the ANSI C and C++ standards? Are they likely to be accepted into the standards? Which compilers support those types, and which do not?
5
2713
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 more documents to share/use during a meeting presentation. What would be the most efficient way to approach this? This is the logic I'm currently considering: Page 1: Meeting Information input with link to a document upload page (this page...
9
2814
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 the including "colors markup" is useless of the marks, the marks is unneccessary extra information. The most used way to make colored view of C++ programs is usage of classes of C++ language words (already included in C++): reserved words, user...
4
1599
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 validation and and some processing, like allowing the user to import data into the db from upstream. Trying to decide between datasets, and creating an object model layer. Articles like...
4
1657
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: http://mail.python.org/pipermail/python-dev/2007-February/070921.html http://mail.python.org/pipermail/python-dev/2007-February/071155.html http://mail.python.org/pipermail/python-dev/2007-February/071181.html I'd love to have feedback on this PEP: - from a user's perspective (would you want to write...
0
8071
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...
1
8164
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
6831
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
6017
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
5489
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
4039
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2482
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1613
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1345
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.