- From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
- Date: 08 Mar 2001 08:22:44 +0000
- To: "Christelle Erb" <christelle.erb@imag.fr>
- Cc: <xmlschema-dev@w3.org>
"Christelle Erb" <christelle.erb@imag.fr> writes: > Hi, > > I have some problem running the following example. > I've defined an identity-constraint on ISBN number with <xsd:unique>. > I would like that every book entry has a unique ISBN number in my > BookCatalogue. > But when I try to validate the XML file, my editor (XMLSpy) allows me to > create 2 books with the same ISBN number. > > Any ideas ?? > > Thanks for your help! > > --> file myschema.xsd ====================================================== > > > <?xml version="1.0"?> > <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" > xmlns="http://www.publishing.org/namespaces/BookCatalogue" > targetNamespace="http://www.publishing.org/namespaces/BookCatalogue" > elementFormDefault="qualified" > xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" > xsi:schemaLocation= > "http://www.w3.org/2000/10/XMLSchema > http://www.w3.org/2000/10/XMLSchema.xsd"> > <xsd:element name="BookCatalogue"> > <xsd:complexType> > <xsd:sequence> > <xsd:element name="Book" minOccurs="0" > maxOccurs="unbounded"> > <xsd:complexType> > <xsd:sequence> > <xsd:element name="Title" type="xsd:string" > minOccurs="1" maxOccurs="1"/> > <xsd:element name="Author" type="xsd:string" > minOccurs="1" maxOccurs="1"/> > <xsd:element name="Date" type="xsd:string" > minOccurs="1" maxOccurs="1"/> > <xsd:element name="ISBN" type="xsd:string" > minOccurs="0" maxOccurs="1"/> > <xsd:element name="Publisher" type="xsd:string" > minOccurs="1" maxOccurs="1"/> > </xsd:sequence> > </xsd:complexType> > </xsd:element> > </xsd:sequence> > </xsd:complexType> > <xsd:unique name="unique_ISBN"> > <xsd:selector xpath="Book"/> > <xsd:field xpath="ISBN"/> > </xsd:unique> > </xsd:element> > </xsd:schema> > > --> file mydata.xml ======================================================== > > <?xml version="1.0" encoding="UTF-8"?> > <BookCatalogue xmlns="http://www.publishing.org/namespaces/BookCatalogue" > xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" > xsi:schemaLocation="http://www.publishing.org/namespaces/BookCatalogue > F:\schemas\myschema.xsd"> > <Book> > <Title>Illusions The Adventures of a Reluctant > Messiah</Title> > <Author>Richard Bach</Author> > <Date>1977</Date> > <ISBN>0-440-34319-4</ISBN> > <Publisher>Dell Publishing Co.</Publisher> > </Book> > <Book> > <Title>The First and Last Freedom</Title> > <Author>J. Krishnamurti</Author> > <Date>1954</Date> > <ISBN>0-440-34319-4</ISBN> > <Publisher>Harper & Row</Publisher> > </Book> > </BookCatalogue> XMLSpy does not yet support Identity constraints, I believe -- check with their support people. Your schema looks correct to me, and should rule out the example you describe. ht -- Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh W3C Fellow 1999--2001, part-time member of W3C Team 2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440 Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk URL: http://www.ltg.ed.ac.uk/~ht/
Received on Thursday, 8 March 2001 03:22:47 UTC