> I am trying to include a xsd:unique element in my schema to make an
> attribute of an element unique at the whole document level.
> The problem with my schema is that it only validates the duplicate id
> <Response> elements inside the same <Question> element, not at the whole
> document level as I want. Is there any way to achieve this?
Why don't you simply type that attribute as type xs:ID?
If you want to use the xs:unique element then you need to put it in the
definition of the root element (e.g. the Form element).

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Miguel Isidoro - 28 Jul 2006 11:06 GMT
Problem solved. Thanks for the tip. I had already tried that but with the
wrong syntax. Here is the example I have:
<xs:key name="responseNameKey">
<xs:selector xpath="./QuestionList/Question/ResponseList/Response |
./QuestionList/Question/ResponseList/Response/ResponseOptions/ResponseOption
./QuestionList/Question/QuestionGroupList/QuestionGroup/ResponseList/Response
./QuestionList/Question/QuestionGroupList/QuestionGroup/ResponseList/Response/ResponseOptions/ResponseOption
./QuestionList/Question/QuestionGroupList/QuestionGroup/QuestionList/Question/ResponseList/Response
./QuestionList/Question/QuestionGroupList/QuestionGroup/QuestionList/Question/ResponseList/Response/ResponseOptions/ResponseOption" />
<xs:field xpath="@name" />
</xs:key>
It is this complicated because not all elements have an attribute that
should be considered an unique key, so I enumerated the elements that have
the attribute that can't be repeated. I included this schema fragment at the
root level.
Tnanks a lot
Miguel
> > I am trying to include a xsd:unique element in my schema to make an
> > attribute of an element unique at the whole document level.
[quoted text clipped - 7 lines]
> If you want to use the xs:unique element then you need to put it in the
> definition of the root element (e.g. the Form element).