Re: Is this <xs:unique> correct?

Kevin Burges <xmldude@burieddreams.com> writes:

> If I have a schema representing a document like this:
> 
> <file>
>   <group>
>     <field name="field1"/>
>     <datefield name="field1"/>
>   </group>
>   <section>
>     <field name="field3"/>
>   </section>
> </file>
> 
> 
> And I have the following xs:unique defined in the <file> element:
> 
> <xs:unique name="FieldName">
>   <xs:selector xpath=".//datefield | .//field"/>
>   <xs:field xpath="@name"/>
> </xs:unique>
> 
> 
> Should that make the instance document above invalid (as there are two
> fields called "field1")?

Yes - the document is invalid per the schema, for the reason you give.

> I've tried this in XMLSpy4, which seems to claim full W3C Schema
> compliance, and it does not give me an error.

Two possible reasons why this might be true:

 1) You haven't shown us the whole schema -- can you confirm that
    there is no targetNamespace?  If there were, then your instance
    must have a namespace declaration, and your selector XPath is wrong,
    because it doesn't have qualified names in the pattern.

 2) The REC is not clear about whether whitespace is allowed in the
    pattern.  I think on balance it should be, but there is certainly
    grounds for arguing that it should not be.  I will raise an issue
    on this with the WG.  Try removing the whitespace and trying
    again.  I had to do this, and then fixed XSV to remove whitespace
    automatically, before XSV would find the error.

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 Friday, 14 September 2001 08:19:38 UTC