On 11/11/2011 5:11 AM, Thomas Beale wrote: > > In the current ADL 1.4-based XSDs used in openEHR, occurrences, > cardinality and existence are expressed as XML elements. We will want > to improve this for ADL 1.5 based XML. Now, we don't want to only take > care of XML; we also need to make it work for JSON, and (internally) > for dADL - neither of the latter have XML's 'attributes'. Many people > have asked for more efficient ways of serialising. Here are some ideas > for ADL 1.5 XML, JSON etc. > > ~~~~~~~~~~ first question: occurrences and cardinality ~~~~~~~~~~~~~~~~ > Occurrences and cardinality are proper intervals in the AOM > representation. The most simplified object structure (JSON and dADL) > for occurrences and cardinality could look as follows (I use dADL & > occurrences here): > > occurrences = < > lower = <2> -- Integer field > upper = <10> -- Integer field > > > > but the upper limit is commonly unbounded, i.e. '*' in typical > UML-like syntax. We could do: > > occurrences = < > lower = <2> -- Integer field > upper_bounded = <True> -- Boolean field > >
Why cant' the absence of a value mean unbounded? occurrences = < lower = <2> > Means 2..* I vaguely remember us discussing this many moons ago but I've forgotten the rationale.. Also, what about inclusive/exclusive values at either end of the interval? I know that this isn't an issue for occurence and cardinality intervals which are always inclusive - but are we proposing that the representation of normal intervals will not use the same mechanisms are you are proposing here? > ~~~~~~~~~~~~~ second question:existence ~~~~~~~~~~~~ > Existence as an interval can be 0..0 (prohibited, commonly used in > templates), 0..1 (optional, typical in the RM) and 1..1 (used in > templates and sometimes in archetypes). Now, since archetypes and > templates are /constraint/ structures, they can only /further > /constrain the RM in ADL/AOM 1.5. The only possibilities for this are > actually "0..0" and "1..1", so we could collapse existence onto a > single Boolean for serialised representation (it could also be a > single Boolean in the AOM, but that would be a breaking change, and > since we already use Intervals for occurrences and cardinality, it > does not seem worth the trouble). > > Thus in JSON/dADL it could be: > > some_attr = < > existence = <True|False> > > > > In XML: > > <attributes rm_attribute_name="name"*existence*="true"> > .... > </attributes> > If it was just to optimize the XML I'd give this a vote of 'meh'.. but given that existence is not really an interval because as you say it has very few possible valid values, I think the removal of the ambiguity by turning it into a single boolean is probably worthwhile. Andrew