W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2003

Re: Defining uniqueness on optional element

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 27 Mar 2003 14:19:11 +0000
To: Cams Ismael <Ismael.Cams@siemens.com>
Cc: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Message-ID: <f5bk7ekyjs0.fsf@erasmus.inf.ed.ac.uk>

Cams Ismael <Ismael.Cams@siemens.com> writes:

> > There's no way to write identity constraints which make this OK but
> > rule out the obvious bad cases.  The problem is not that it's an
> > _error_ for a field of a unique constraint to be missing, it's just
> > that if a field _is_ missing then the selected element is not
> > considered at all.  So in the above example, a two-part unique on
> > 'root' which selects 'mayHaveDaughter' with fields '@f1' and 'd' will
> > not constrain empty 'mayHaveDaughter' elements at all.
> 
> I have tested the following:
> 
> Both MSXML4.0 and xsdvalid give an error that indicate 'c' as duplicate key.
> So if indeed all the <mayHaveDaughter> elements that have no <d> element are
> ignored, no error should be generated in this case. Or am I wrong with that
> ? In case of Xerces I get an error message: '[Error] unique.xml:7:27: Not
> enough values specified for <unique> identity constraint specified for
> element "root" ' In neither cases this is a valid error. 
> I have tried some other combinations and to me it seems like the parsers
> behave as following:
> 	* When one of the fields is not available there is still be checked
> on the other fields
> 
> I have tried to find this back in the recs, but I didn't succeed in it.
> 
> Am I missing something here ?

Well, XSV doesn't complain at all, and it does complain if I add
identical <d> elements to the last two <mayHaveDaughter> elts.

Not surprisingly, since I wrote it, I think XSV correctly implements
the spec. here and the validators you tested do not, in different ways.

I read the REC as requiring all the fields to match for a constraint
to apply at all, but not as identifying one match and one failure as
an error.

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@cogsci.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]
Received on Thursday, 27 March 2003 09:19:13 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:36 GMT