# Archetypes and XML-Schemas **Category:** [Technical (archive)](https://discourse.openehr.org/c/technical-archive/156) **Created:** 2010-05-11 14:48 UTC **Views:** 5 **Replies:** 11 **URL:** https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980 --- ## Post #1 by @Leonardo_Moretti XMLSerializer\.output\(\) \(xml\-serializer\-1\.0\.1\.jar\) produce XMLs that are not compliant with openEHR XML\-Schemas \(http://www.openehr.org/releases/1.0.2/its/XML-schema/index.html). Also the xml representation taken from http://openehr.org/knowledge/ are not valid XML instances respect to these schemas \(for example <http://jira.noemalife.loc:8080/secure/attachment/15267/openEHR-EHR-OBSERVATION.body_weight.v1.adl> openEHR\-EHR\-OBSERVATION\.body\_weight\.v1 <http://jira.noemalife.loc:8080/secure/attachment/15267/openEHR-EHR-OBSERVATION.body_weight.v1.adl>\)\. The main problem is that the order of the elements is not equals to that one specified in <xs:sequence> blocks of XSDs\. What is "wrong", the implementation or the schemas? The order of the elements in xml representation of an archetype must be fixed? Thanks leo --- ## Post #2 by @system Hi Leonardo, CKM is using the Java XML Serialiser to generate the XML presentation, so it is no surprise you are seeing the same effect there\. I would see the Schemas as the source of truth\. If it is a sequence in the schema then I believe that the order cannot simply be changed in the XML\. So, my opinion is that the XML Serialiser is probably wrong here \(although you may ask how much this order actually matters, practically and theoretically\) Mattias Forss \(who developed the XML Serialiser I believe\), Eric Sundvall or Rong Chen may be able to expand on it? Regards Sebastian Moretti Leonardo wrote: --- ## Post #3 by @system Hi Leonardo We are just about to produce a new XML schema for archetypes based on the new ADL 1\.5 and getting rid of a lot of clutter for XML which was not required\. For example one change I have been promoting is the recording of existence\. At present in the AOM it is an interval of 0\.\.1 which can be constrained to 0\.\.0 and 1\.\.1\. It is worth considering this carefully as an example of how we could simplify the expression in XML just as Thomas does in ADL\. First, the rule is that the reference model sets the minimum constraint\. This must be either 0\.\.1 \(optional\) or 1\.\.1 \(mandatory\) ie attributes in the reference model can be optional or mandatory \(no other choices\)\. If the attribute is mandatory then there is no logical existence constraint that can be applied\. So the constraint statements in the AOM that are possible for optional attributes are: 1\) 0\.\.0 \(prohibited\) and 2\) 1\.\.1 \(required\)\. This is a binary constraint\. For this reason we are proposing that existence is represented as an optional attribute with 2 values 'required' and 'prohibited'\. This is easy to read and can be transformed into the in memory interval easily during de\-serialisation\. It also means that existence will usually not appear in an actual archetype as it is rarely used\. It would be good to have other ideas on simplification of the XML schema as we move to the new 2\.1 AOM\. Cheers, Sam --- ## Post #4 by @Andrew_Patterson > This is a binary constraint\. For this reason we are proposing that existence > is represented as an optional attribute with 2 values > 'required' and 'prohibited'\. Sam, an optional attribute with 2 values actually allows 3 states\. Of course the default will map to one of the two values \- but this does allow 2 ways of expressing the same concept\. My two preferences for this situation \(representing binary constraints\) a\) mandatory attribute with 2 values \- or \- b\) an optional attribute with ONE possible value, and where    the absence of the value is the default\. Andrew --- ## Post #5 by @system Hi Andrew This is not quite correct as we are talking about constraint\. The default is what is in the RM\. The three states are: 1\. As in the RM \- no statement 2\. Required \(optional in RM\) 3\. Prohibited \(optional in RM\) Is that sensible \- Sam --- ## Post #6 by @Leonardo_Moretti Thanks to all, I agreee with Sebastian, the real point is knowing how much this order actually matters, practically and theoretically\! Currently, XML\-schemas are the only formal specs of how the xml must be done, so I think we need to be compliant with these\! @Sam Will new XML schema for archetypes be compatible with the current version of schemas? I\.e\., an archetype expressed in xml, valid respect to XML\-schema 1\.0\.2, will it be valid also respect to new XML\-schema? Regards, Leo Sebastian Garde\-2 wrote: --- ## Post #7 by @Leonardo_Moretti Moreover, XMLSerializer\.output\(\) produces xml fragments for DV\_ORDINAL like this: <children xsi:type="C\_DV\_ORDINAL">      <rm\_type\_name>DvOrdinal</rm\_type\_name> \.\.\. while I'm expecting to have this <children xsi:type="C\_DV\_ORDINAL">      <rm\_type\_name>DV\_ORDINAL</rm\_type\_name> \.\.\.\. Probably XMLSerializer is not so compliant with the standard\.\. Regards leo Sebastian Garde\-2 wrote: --- ## Post #8 by @system Leo, In that case, you are probably using an older version of the Serialiser. This has been fixed in Rev 504 earlier this year. See e.g. the APGAR score archetype at [http://openehr.org/knowledge/OKM.html#showArchetype_1013.1.172_7](http://openehr.org/knowledge/OKM.html#showArchetype_1013.1.172_7) Regards Sebastian Leonardo Moretti wrote: [details="(attachments)"] ![oceanlogo.png|84x82](upload://2EtFgZ1bS4JNl1d51FusTB7hg8M.png) [/details] --- ## Post #9 by @Leonardo_Moretti I'm using the jars found on http://www.openehr.org/wiki/display/projects/Java+Project+Download Is there a new release of these jars? Where can I download it? Thanks leo Sebastian Garde\-2 wrote: --- ## Post #10 by @system Hi Leonardo, yes that is the tagged "stable" version. I don't think there is a precompiled version of the latest trunk and you would need to compile from the trunk following the instructions here: [http://www.openehr.org/wiki/display/projects/Quick+start+guide+for+the+openEHR+Java+project](http://www.openehr.org/wiki/display/projects/Quick+start+guide+for+the+openEHR+Java+project) Sebastian Leonardo Moretti wrote: [details="(attachments)"] ![oceanlogo.png|84x82](upload://2EtFgZ1bS4JNl1d51FusTB7hg8M.png) [/details] --- ## Post #11 by @thomas.beale I would suggest that any wisdom generated in this discussion be added to the pages at http://www.openehr.org/wiki/display/spec/XML+Schemas \- thomas beale --- ## Post #12 by @Andrew_Patterson > This is not quite correct as we are talking about constraint\. The default is > what is in the RM\. The three states are: > 1\. As in the RM \- no statement > 2\. Required \(optional in RM\) > 3\. Prohibited \(optional in RM\) > > Is that sensible \- Sam Yes \- that's fine\. I was thinking you wanted to represent a 2\-state system \- but it really is a 3\-state system as you noted\. Andrew --- **Canonical:** https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980 **Original content:** https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980