xs:Key is working on Tamino 4.4?

All,

I’m working with Tamino 4.4 and I want to set a constrain using xs:key. I know that Tamino 4.4 schema supports xs:key, but I’m not sure if the feature is working.

I made the following simple schema with a constrain xs:key, the problem is that I can insert several times the Person document with the same ID, it supposes that the ID should be unique due to it was declared as the key elemet.

Also I would like to use keyRef for integrity but I want to solve this first issue.

Is something wrong in my shema? or is not xs:key constrain supported by Tamino?

Does Tamino 4.4 manage the ref integrity whit xs:key and xs:keyRef?

Here is the Schema code:

<?xml version = "1.0" encoding = "UTF-8"?>
<xs:schema xmlns:tsd = "http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition" xmlns:xs = "http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <tsd:schemaInfo name = "test">
        <tsd:collection name = "test"></tsd:collection>
        <tsd:doctype name = "Person">
          <tsd:logical>
            <tsd:content>closed</tsd:content>
          </tsd:logical>
        </tsd:doctype>
      </tsd:schemaInfo>
    </xs:appinfo>
  </xs:annotation>
  <xs:element name = "Person">
    <xs:complexType>
      <xs:sequence>
        <xs:element name = "ID" type = "xs:string"></xs:element>
        <xs:element name = "Name" type = "xs:string"></xs:element>
      </xs:sequence>
    </xs:complexType>
    <xs:key name = "Person_key">
      <xs:selector xpath = "Person"></xs:selector>
      <xs:field xpath = "ID"></xs:field>
    </xs:key>
  </xs:element>
</xs:schema>

Thanks in advance,

Claudio,

the xs:key is working as specified: it guarantees uniqueness WITHIN A SINGLE document. What you expect, is uniqueness AMONG SEVERAL documents. There is no standard feature in XML Schema to express this. However, there is a Tamino feature providing exactly this functionality: tsd:unique (please use the documentation search to find out the details)

Regards

Harald

Hi Claudio

in addition to Harald’s remark, you should correct the value of the xpath attribute of xs:selector to be “.” (for tsd:unique this is the built-in default):

<xs:element name = “Person”>
xs:complexType
xs:sequence
<xs:element name = “ID” type = “xs:string”></xs:element>
<xs:element name = “Name” type = “xs:string”></xs:element>
</xs:sequence>
</xs:complexType>
<xs:key name = “Person_key”>
<xs:selector xpath = “.”></xs:selector>
<xs:field xpath = “ID”></xs:field>
</xs:key>
</xs:element>

Regards
Uli

Hi,

Thanks Harald and Uli for your answers.

About the Harald’s question… I’m expected unique values of a specific element among several documents and I think that xs:keyRef also works within a single document, isn’t it?

Regards,

Claudio

Hi Claudio

indeed - xs:keyRef has only a scope of a single document.
So far, Tamino does not support an analogon to xs:keyRef having
a scope of all documents in a doctype.

Regards
Uli