Doubt XML Composition in Object RM Openehr transformation

Hello everyone, I need to transform an XML composition into RM Object, but the examples I find don’t work for me.

I need to understand how I can perform this conversion performance.

I found this library

But it doesn’t recognize that my XML is a composite, as the tag names are not explicitly stated with the attributes, see example
habits.xml (5.1 KB)

I’m working with java 8 and this is an example I made based on library tests!

String xml;
try {
xml = loadXml();
XMLBinding binding = new XMLBinding();
COMPOSITION xobj = CompositionDocument.Factory.parse(xml).getComposition();
Object rmObj = binding.bindToRM(xobj);

	} catch (Exception e) {
		// TODO Auto-generated catch block

Your XML is not valid openEHR XML, you need to validate first against the schema.

For instance, there are no elements in openEHR XML like these:

  • Habits
  • Alcohol_use>

You can use the toolkit to generate valid XMLs

Hello, I discovered the problem, the problem is that the conversion does not occur because the XML is based entirely on the template (The xml is not incorrect), but that I would need a TDO of the template to be able to convert definitively into an object

In the template design tool by OCEAN contains this conversion only in C#, would you know if there is a tool to transform the template into JAVA(8)? since it creates with all inheritance correctly, the template contains several different areas and names, it would be almost impossible to create a manual object

I’ve been working with openehr for about 4 to 5 months and I feel very difficult to find tools (Specifically libraries) that help me in development, object and class specifications are magnificent and visualization tools like (archetype design), but I miss indications to help in the development, it is very difficult to find answers, the easiest way is to come to the forum

Hi Luiz, the XML is wrong against the canonical openEHR XSD, you need to have an XSD to know if it is correct or not.

For instance:

  1. the namespace “oe” is not defined and it is used, see the context element

  2. in the canonical XSD there is no element named “Habits” or “Alcohol_use” or “Consumption_Summary”, all elements that appear in your XML

So maybe the XML is valid against some XSD, but it is not valid against the canonical XSD openEHR - XML Schemas (ITS-XML) Component - 1.0.2

If you use the toolkit mentioned above you can generate XMLs from OPTs and validate them against the canonical XSD.

I’m sure the Java implementation parser works with canonical XML, but won’t work with the XML you provided.

Hope that helps.

Now I get it, I really appreciate your help.

I will try to convert the XML to XMLCanonical, is there a library that already does this?

Please check the Toolkit mentioned above.


For those who need to do this, it is necessary to have the template XSD at hand

In the code you will need to traverse the XSD looking for each matching name to convert your XML and put the Archetype node id

By doing this conversion and following the openehr validation rules you will be able to perform the conversion

Thank you Pablo!

1 Like