Philippe Nobili wrote:
> On 02/05/2010 04:52 PM, Hussein Shafie wrote:
>> Philippe Nobili wrote:
>>   
>>> We use XMLMind to write a simple XML schema; this schema makes use of
>>> the unique,key & keyref concepts to
>>> declare relationships between uniquely identified elements.
>>>
>>> The XML schema has been correctly validated by XMLMind and we are
>>> allowed to author, validate and save XML instances of the schema within
>>> XMLMind.
>>>
>>> However, the unique/key/keyref declarations do not seem to be taken into
>>> account during the instance's validation and instances are always
>>> considered as  valid by XMLMind validity tool although we added (on
>>> purpose) duplicated references and missing links.
>>>
>>> Since this is the first time we use XMLMind for this job, we do not know
>>> if this is supposed to work (int which case we have a bug in our XML
>>> schema) or not.
>>>
>>>     
>> * There are no known bugs related to the support of identity constraints.
>>
>> * There is nothing special to do to take in account unique/key/keyref
>> declarations.
>>
>> * In order to help you more, we need to have access to your schema + an
>> erroneous document instance. Before sending us these files, please take
>> the time to make sure that you didn't make a mistake. That is, please
>> carefully re-read your schema.
>>
>> You may also want to validate your schema and your erroneous document
>> instance against Xerces.
>>   
> Hello,
> 
> Thanks for your reply; it took us quite a bit of time to track down this
> issue;
> 
> 1. First, without un-checking the 'Enable cache' option, it is not
> really possible to develop and test an XML schema.  Now, I remember
> having read this somewhere from the XMLMind documentation...
> 
> 2. Then, the problem is the following. I'll try to make it as simple as
> possible:
> 
>  We have a map of attributes, each of these is identified by an unique
> value. If we write the Schema as follows:
> 
> <xs:element name="attributemap">
> 
>     <xs:complexType>
>       <xs:sequence>
>         <xs:element maxOccurs="unbounded" ref="attribute"/>
>       </xs:sequence>
>     </xs:complexType>
> 
>     <xs:unique name="AttributeKey">
>       <xs:selector xpath=".//attribute"/>
>       <xs:field xpath="@id"/>
>     </xs:unique>
> 
>   </xs:element>
> 
> Then afterwards, define the "attribute" element: xs:element
> name="attribute" etc etc...
> XML instances always appear as valid, even if attributes @id are duplicated.
> 
> If we re-write the XML schema by replacing the 'ref="attribute"' by the
> actual definition of the "attribute" element, it works as expected and
> the validation tool indicates duplicated @id.
> 
> We are not sure whether it is something that is not allowed when writing
> XML schemas or if this illustrates a software problem. Anyway, we now
> have a workaround.

Trying to find workarounds will not help you in the long term.

Therefore in an attempt to reproduce the above problem, I've written
attached files tunique.xsd and tunique.xml using XXE and everything
works fine for me.

My guess that you have a target namespace for your schema, that you
forgot to specify the prefix of your target namespace in some places.
That is, you should have specified something like:

 <xs:element name="attributemap">

    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="XXX:attribute"/>
      </xs:sequence>
    </xs:complexType>

    <xs:unique name="AttributeKey">
      <xs:selector xpath=".//XXX:attribute"/>
      <xs:field xpath="@id"/>
    </xs:unique>

  </xs:element>

XXX being a declared prefix for your target namespace.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tunique.xml
Type: text/xml
Size: 508 bytes
Desc: not available
Url : 
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20100208/23d3960e/attachment.xml
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tunique.xsd
Type: text/xml
Size: 893 bytes
Desc: not available
Url : 
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20100208/23d3960e/attachment-0001.xml
 

Reply via email to