No duplicate elements

Is there a way to define in TSD4 that a element with a specific attribute may only occur once ?
I assume there is, but I can’t find it.

Example:
Allowed - lexon id attributes are different

<context id="115" label="SmallXchangeStoryA1">
    <lexon id="1366" term1="Service" role1="ByMeansOf" role2="" term2="WebSite" />
    <lexon id="1395" term1="BusnessInstitution" role1="Have" role2="" term2="Headquarter" />
</context>

Not allowed - lexon id attributes are equal

<context id="115" label="SmallXchangeStoryA1">
    <lexon id="1366" term1="Service" role1="ByMeansOf" role2="" term2="WebSite" />
    <lexon id="1366" term1="StockExchange" role1="SubtypeOf" role2="SupertypeOf" term2="Service" />
</context>

Thanks !

Hi,
From TSD4.2 (Tamino Version 4.2) there is the logical schema property “tsd:unique”. You can specify, at the doctype level, which elements/attributes must be unique per xml instance. You can set the tsd:unique property in the Schema Editor by selecting the doctype node and clicking “Insert, TSD Unique”. You must then set the field XPaths of the elements/attributes that comprise the unique “key”.
There’s more in the documentation under Tamino XML Schema Reference Guide/Tamino Extensions…/tsd:unique.
HTH

Thanks for the quick reply !

Aaah, I’m testing it with the XML StarterKit (=Tamino 4.1.4.1). That’s why i couldn’t find it.

Well that brings me to another problem. Because now i’ll have to check the id attributes myself.

I would like to get the highest id attribute from a lexon.
I’ve tried the max() function as well in XQuery as in X-Query but I always the a NaN result. The count() function, however, does return a valid result.

max(//lexon[@id])

I also think I know why that is:
count() requires a node sequence
while
max() requires a sequence of items

So now is my question:
How could i retrieve the highest lexon id value (as example shown in my previous post) ?

Hi Paul

Bill’s proposal is unfortunately only partly correct as tsd:unique
(which is supported since Tamino 4.2)

  1. is a constraint across all documents in a doctype
  2. allows only for cardinality 1 of referenced nodes

In XSD, the identity constraints (xsd:unique, xsd:key) will allow for the constraint you need applying to multiple occurences of a logical node within a single document.
Unfortunately, this is not yet supported by Tamino 4.2, but - at least some good news - Tamino 4.4 will support that feature!

Best regards
Uli

Sorry I missed that - thanks Uli.
Bill.

With regard to the max() problem, try max(context/lexon/@id).
That should work.

Thanks !! That works indeed !