RE: Problem designing complexType accepting a specified element a nd a llowing any others

Hess Yvan writes:


> In general manner, I would like to define a king of bag
> element ("metadata") where the order of the elements is
> not important, that contains predefined elements that
> must occurs with a given occurrences (min and max) and
> that also accepts any king of others elements (same or
> others namespaces).

Various things of this sort were considered during the design of XML 
schema.  What you're coming pretty close to asking for is a specification 
that accepts almost anything at all, as long as it has at least a minimum 
number of certain elements.    I can see use cases for that, and we 
certainly did consider raising maxOccurs in an all group.

On the other hand, there's a case to be made that vocabularies that work 
like this tend not to be very strong uses of markup.  What does it mean if 
I have:

<x>
        <lastName>...</lastName>
        <firstName>...</firstName>
        <unknown/>
        <firstName>...</firstName>
        <firstName>...</firstName>
        <firstName>...</firstName>
        <lastName>...</lastName>
        <unknown/>
        <unknown/>
        <lastName>...</lastName>
</x>

which is the sort of content that would be validated by your bag with 
maxOccurs>1 for firstName and lastName.  Do the various tags have anything 
to do with each other?   Are there implied groupings that matter?  You've 
basically got a soup full of tags with some interesting constraints on the 
total numbers of <firstNames>, etc., but in many such cases there are 
implied relationships that you could mark up better.

Schema validation would enforce some constraints on this pile of tags if 
we had the <bag> feature, but it's not clear to me that it would make an 
80/20 cut with respect to complexity.  In many cases where bags of tags 
like this are used, nested markup would be better:


<x>
 
        <name>
          <lastName>...</lastName>
        </name>
        <name>
          <firstName>...</firstName>
          <lastName>...</lastName>
        </name>
        <unknownXextension/>
        <name>
          <firstName>...</firstName>
        </name>
        <name>
          <firstName>...</firstName>
          <unknownNameExtension/>
        </name>
        <name>
          <firstName>...</firstName>
        </name>
        <unknownXextension/>
        <name>
          <lastName>...</lastName>
        </name>
</x>

Not a great example, but I hope you get the point.  Marking up the 
relationships between the tags in the bag is often more robust, and then 
of course schema can do a better job of describing them.

--------------------------------------
Noah Mendelsohn 
IBM Corporation
One Rogers Street
Cambridge, MA 02142
1-617-693-4036
--------------------------------------

Received on Friday, 12 March 2004 17:26:06 UTC