Print

Print


Dear oddists,

I found it hard to find an appropriate catchy subject for my problem  
so I guess you have to read the whole ;-)

What I want to achieve (in short):
<person>
   <persName type="reg">Weber, Carl Maria von</persName>
   <persName type="full">Weber, Carl Maria Friedrich Ernst von</ 
persName>
</person>
(It is an person entry from a (virtual) listPerson. IDs and much more  
content is skipped for the sake of readability.)
The persName type="reg" is mandatory, while the full name is optional.

This could easily be modeled with RelaxNG as
<rng:element name="person">
   <rng:element name="persName">
     <rng:ref name="macro.phraseSeq"/>
     <rng:attribute name="type">
      <rng:value>reg</rng:value>
     </rng:attribute>
   </rng:element>
   <rng:optional>
     <rng:element name="persName">
      <rng:ref name="macro.phraseSeq"/>
      <rng:attribute name="type">
        <rng:value>full</rng:value>
      </rng:attribute>
     </rng:element>
   </rng:optional>
</rng:element>

Now I'm stuck while trying to model this with ODD. As far as I see, I  
have two possibilities:
1. Define one elementSpec ident="persName" with both attribute values  
and constrain those via Schematron
2. Copy the above RelaxNG snippet into person content

The first solution is much more elegant (less code, more ODD-like)  
while the second is better supported by my favorite XML editor. I  
don't need two processing instructions to validate Schematron and  
RelaxNG rules as well as the possibility to make use of code  
completion. (This is of course an issue that should be raised on a  
different list.)

A third possibility that comes to my mind is to add new elements  
"fullName" and "regName" instead of differentiating via @types. Then I  
could constrain on (native ODD, without RelaxNG) elements without  
Schematron and gain code completion as well. Looks like the best of  
both 1 and 2?!

Are there further possibilities and how would you evaluate 1 to 3 - or  
have I something totally wrong?

Many thanks in advance
Peter