# Archetypes and XML-Schemas

**URL:** https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980
**Category:** Technical (archive)
**Created:** [11 May 2010 14:48 UTC](https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980 "2010-05-11T14:48:50Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Leonardo\_Moretti](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/l/b38774/32.png) [@Leonardo\_Moretti](https://discourse.openehr.org/u/Leonardo_Moretti)
#### Post date: [11 May 2010 14:48 UTC](https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980/1 "2010-05-11T14:48:50Z")

</div>

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](http://www.openehr.org/releases/1.0.2/its/XML-schema/index.html)).  
Also the xml representation taken from [http://openehr.org/knowledge/](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&gt](http://jira.noemalife.loc:8080/secure/attachment/15267/openEHR-EHR-OBSERVATION.body_weight.v1.adl&gt);  
openEHR-EHR-OBSERVATION.body\_weight.v1  
\<[http://jira.noemalife.loc:8080/secure/attachment/15267/openEHR-EHR-OBSERVATION.body\_weight.v1.adl&gt;\](http://jira.noemalife.loc:8080/secure/attachment/15267/openEHR-EHR-OBSERVATION.body_weight.v1.adl&gt;%5C)).

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

---

<div class="post-metadata">

### Author: ![system](https://discourse.openehr.org/uploads/default/original/2X/f/f0a1dedb20c42747bddcafd6c7df9db5f34f003c.svg) [@system](https://discourse.openehr.org/u/system)
#### Post date: [11 May 2010 15:55 UTC](https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980/2 "2010-05-11T15:55:08Z")

</div>

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:

---

<div class="post-metadata">

### Author: ![system](https://discourse.openehr.org/uploads/default/original/2X/f/f0a1dedb20c42747bddcafd6c7df9db5f34f003c.svg) [@system](https://discourse.openehr.org/u/system)
#### Post date: [11 May 2010 20:16 UTC](https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980/3 "2010-05-11T20:16:56Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Andrew\_Patterson](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/a/76d3ee/32.png) [@Andrew\_Patterson](https://discourse.openehr.org/u/Andrew_Patterson)
#### Post date: [12 May 2010 00:23 UTC](https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980/4 "2010-05-12T00:23:34Z")

</div>

> 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  
&nbsp;&nbsp;&nbsp;the absence of the value is the default.

Andrew

---

<div class="post-metadata">

### Author: ![system](https://discourse.openehr.org/uploads/default/original/2X/f/f0a1dedb20c42747bddcafd6c7df9db5f34f003c.svg) [@system](https://discourse.openehr.org/u/system)
#### Post date: [12 May 2010 03:28 UTC](https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980/5 "2010-05-12T03:28:11Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Leonardo\_Moretti](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/l/b38774/32.png) [@Leonardo\_Moretti](https://discourse.openehr.org/u/Leonardo_Moretti)
#### Post date: [12 May 2010 08:36 UTC](https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980/6 "2010-05-12T08:36:45Z")

</div>

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:

---

<div class="post-metadata">

### Author: ![Leonardo\_Moretti](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/l/b38774/32.png) [@Leonardo\_Moretti](https://discourse.openehr.org/u/Leonardo_Moretti)
#### Post date: [12 May 2010 14:59 UTC](https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980/7 "2010-05-12T14:59:20Z")

</div>

Moreover,  
XMLSerializer.output() produces xml fragments for DV\_ORDINAL like this:  
\<children xsi:type="C\_DV\_ORDINAL"\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<rm\_type\_name\>DvOrdinal\</rm\_type\_name\> ...

while I'm expecting to have this  
\<children xsi:type="C\_DV\_ORDINAL"\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<rm\_type\_name\>DV\_ORDINAL\</rm\_type\_name\> ....

Probably XMLSerializer is not so compliant with the standard..

Regards  
leo

Sebastian Garde-2 wrote:

---

<div class="post-metadata">

### Author: ![system](https://discourse.openehr.org/uploads/default/original/2X/f/f0a1dedb20c42747bddcafd6c7df9db5f34f003c.svg) [@system](https://discourse.openehr.org/u/system)
#### Post date: [12 May 2010 15:12 UTC](https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980/8 "2010-05-12T15:12:15Z")

</div>

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:

> **(attachments)**
>
> ![oceanlogo.png](https://discourse.openehr.org/images/transparent.png)

---

<div class="post-metadata">

### Author: ![Leonardo\_Moretti](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/l/b38774/32.png) [@Leonardo\_Moretti](https://discourse.openehr.org/u/Leonardo_Moretti)
#### Post date: [12 May 2010 16:00 UTC](https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980/9 "2010-05-12T16:00:30Z")

</div>

I'm using the jars found on  
[http://www.openehr.org/wiki/display/projects/Java+Project+Download](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:

---

<div class="post-metadata">

### Author: ![system](https://discourse.openehr.org/uploads/default/original/2X/f/f0a1dedb20c42747bddcafd6c7df9db5f34f003c.svg) [@system](https://discourse.openehr.org/u/system)
#### Post date: [14 May 2010 08:05 UTC](https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980/10 "2010-05-14T08:05:32Z")

</div>

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:

> **(attachments)**
>
> ![oceanlogo.png](https://discourse.openehr.org/images/transparent.png)

---

<div class="post-metadata">

### Author: ![thomas.beale](https://discourse.openehr.org/user_avatar/discourse.openehr.org/thomas.beale/32/35_2.png) [@thomas.beale](https://discourse.openehr.org/u/thomas.beale)
#### Post date: [14 May 2010 08:28 UTC](https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980/11 "2010-05-14T08:28:12Z")

</div>

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](http://www.openehr.org/wiki/display/spec/XML+Schemas)

- thomas beale

---

<div class="post-metadata">

### Author: ![Andrew\_Patterson](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/a/76d3ee/32.png) [@Andrew\_Patterson](https://discourse.openehr.org/u/Andrew_Patterson)
#### Post date: [14 May 2010 10:48 UTC](https://discourse.openehr.org/t/archetypes-and-xml-schemas/14980/12 "2010-05-14T10:48:46Z")

</div>

> 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
