Parsing archetype xml with JAXB

Hi,

I used JAXB to generate java files from the XSD files but I am not
getting very far with the unmarshalling, currently I get:

javax.xml.bind.UnmarshalException: Unable to create an instance of
test123.COBJECT: Unable to create an instance of test123.COBJECT

when executing the following code:

JAXBContext jc = JAXBContext.newInstance(ARCHETYPE.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
JAXBElement<ARCHETYPE> root = unmarshaller.unmarshal(new
StreamSource(new File(filename)), ARCHETYPE.class);

I've tried both XML from subversion and XML freshly generated from the
Ocean Archetype Editor. the test123 is just the package I put the
JAXB generated java files into, not related to the problem.

I don't suppose anyone has run in this issue...?

thanks!

Greg

http://www.patientos.org

Hi Greg,

Have you tried XMLBeans? I have good experience in RM XML data binding using XMLBeans, http://www.openehr.org/svn/ref_impl_java/SANDBOX/xml-binding/

Haven’t tried it with AOM XML binding, but it shouldn’t be too different I suppose.

Regards,
Rong

Greg - I think this question would be better on the implementers list -
to avoid causing too many heart attacks among the readers of this list

Greg - I think this question would be better on the implementers list -
to avoid causing too many heart attacks among the readers of this list
on seeing actual code :wink:

Good point, Tom! =)
It could be even posted on the Java-list.
/Rong

Hi Greg,

Have you tried XMLBeans? I have good experience in RM XML data binding using
XMLBeans, http://www.openehr.org/svn/ref_impl_java/SANDBOX/xml-binding/

Haven't tried it with AOM XML binding, but it shouldn't be too different I
suppose.

Regards,
Rong

Hmm, well perhaps I should just use the ref_impl_java jar files to
parse the ADL ?

Either way is fine - I just want to have the archetype in a java
object I can navigate and pull out the information I need to create
the data elements and forms.

This must be an old link to a single jar:

http://www.openehr.org/svn/ref_impl_java/TRUNK/docs/download.htm

Is there somewhere else I can download a single all in one openehr jar
? Multiple is fine too of course.

thanks!

Greg

Hi Greg,

Have you tried XMLBeans? I have good experience in RM XML data binding using
XMLBeans, http://www.openehr.org/svn/ref_impl_java/SANDBOX/xml-binding/

Haven’t tried it with AOM XML binding, but it shouldn’t be too different I
suppose.

Regards,
Rong

Hmm, well perhaps I should just use the ref_impl_java jar files to
parse the ADL ?

Either way is fine - I just want to have the archetype in a java
object I can navigate and pull out the information I need to create
the data elements and forms.

This must be an old link to a single jar:

http://www.openehr.org/svn/ref_impl_java/TRUNK/docs/download.htm

Is there somewhere else I can download a single all in one openehr jar
? Multiple is fine too of course.

If you are familiar with Maven, the best way is to check out the latest version from the trunk and build from source. You could also download jars from the continuous integration server from here http://openehr.cambiosys.org/continuum. Just click the component and follow the link “working copy” and pick up the jar files form the sub-directory “target”.

Cheers,
Rong

If you are familiar with Maven, the best way is to check out the latest
version from the trunk and build from source. You could also download jars
from the continuous integration server from here
http://openehr.cambiosys.org/continuum. Just click the component and follow
the link "working copy" and pick up the jar files form the sub-directory
"target".

Cheers,
Rong

Awesome, one jar and one line of code and I have the Archetype object
from the source ADL - sweet. I'll thank you in person next week :slight_smile:

Greg - I think this question would be better on the implementers list -
to avoid causing too many heart attacks among the readers of this list
on seeing actual code :wink:

- thomas beale

Don't worry, I won't show the one line of code :slight_smile:

thanks!

Greg

http://www.patientos.org

Greg Caulton wrote:

If you are familiar with Maven, the best way is to check out the latest
version from the trunk and build from source. You could also download jars
from the continuous integration server from here
http://openehr.cambiosys.org/continuum. Just click the component and follow
the link "working copy" and pick up the jar files form the sub-directory
"target".

Cheers,
Rong
    
Awesome, one jar and one line of code and I have the Archetype object
from the source ADL - sweet. I'll thank you in person next week :slight_smile:

Greg - I think this question would be better on the implementers list -
to avoid causing too many heart attacks among the readers of this list
on seeing actual code :wink:

- thomas beale
    
Don't worry, I won't show the one line of code :slight_smile:

thanks!

A) Given an ADL how long does it take to create an object from the ADL?
B) Is there anyway within that code to then write out the XML ?
C) Has there been any forwards movement on starting with an XML &
getting to the same object (& possibly then writing out the ADL)?

i.e. at some point I'd like to be able to test round tripping i.e. load
an ADL, generate XML, load this XML & gen the ADL, then compare the 2 ADL.

& be able to do this starting with the XML form i.e. load an XML,
generate ADL, load this ADL & gen the XML, then compare the 2 XML.

Adam

If you are familiar with Maven, the best way is to check out the latest
version from the trunk and build from source. You could also download jars
from the continuous integration server from here
http://openehr.cambiosys.org/continuum. Just click the component and follow
the link “working copy” and pick up the jar files form the sub-directory
“target”.

Cheers,
Rong

Awesome, one jar and one line of code and I have the Archetype object
from the source ADL - sweet. I’ll thank you in person next week :slight_smile:

Excellent! Let’s talk about creating synergies between the two projects! =)

/Rong

Greg Caulton wrote:

If you are familiar with Maven, the best way is to check out the latest
version from the trunk and build from source. You could also download jars
from the continuous integration server from here
http://openehr.cambiosys.org/continuum. Just click the component and follow
the link “working copy” and pick up the jar files form the sub-directory
“target”.

Cheers,
Rong

Awesome, one jar and one line of code and I have the Archetype object
from the source ADL - sweet. I’ll thank you in person next week :slight_smile:

Greg - I think this question would be better on the implementers list -
to avoid causing too many heart attacks among the readers of this list
on seeing actual code :wink:

  • thomas beale

Don’t worry, I won’t show the one line of code :slight_smile:

thanks!

A) Given an ADL how long does it take to create an object from the ADL?
B) Is there anyway within that code to then write out the XML ?
C) Has there been any forwards movement on starting with an XML &
getting to the same object (& possibly then writing out the ADL)?

Hi Adam,

Parsing ADL into AOM is already supported by the adl-parser from the Java project. Serializing AOM into XML is also supported. The code for parsing XML into AOM is donated by Zilics and will be merged with the components on the Trunk.

So we are not far away from the round trip goals between ADL and XML. What’s left is to map AOM classes and the XML binding classes generated from the schema.

Cheers,
Rong

A) Given an ADL how long does it take to create an object from the ADL?
B) Is there anyway within that code to then write out the XML ?
C) Has there been any forwards movement on starting with an XML &
getting to the same object (& possibly then writing out the ADL)?

Hi Adam,

Parsing ADL into AOM is already supported by the adl-parser from the Java
project.

Yes I know, however I am thinking in terms of time from ADL > AOM > XML
in a batch fashion (i.e. processing many ADL'es).

Serializing AOM into XML is also supported. The code for parsing
XML into AOM is donated by Zilics and will be merged with the components on
the Trunk.

A) Any idea wrt timing?
B) Is this the same code as with the liu.se Java based archetype editor
& if so does anyone from Linkoping have any ideas wrt time from the
above entering trunk & it being put into the Archetype editor?

So we are not far away from the round trip goals between ADL and XML. What's
left is to map AOM classes and the XML binding classes generated from the
schema.
  

Excellent.

If you need any help at any point with this, let me know.

Adam

Hi!

Serializing AOM into XML is also supported. The code for parsing
XML into AOM is donated by Zilics and will be merged with the components on
the Trunk.

A) Any idea wrt timing?
B) Is this the same code as with the liu.se Java based archetype editor
& if so does anyone from Linkoping have any ideas wrt time from the
above entering trunk & it being put into the Archetype editor?

The code used to serialise AOM to XML in the LiU Archetype editor was
committed to the java reference implementation a long time ago and was
later updated to produce nicer XML by Humberto Naves (working for
Zilics?).
Its a fairly straight-forward single java file for one-way AOM->XML:
http://www.openehr.org/svn/ref_impl_java/TRUNK/xml-serializer/src/main/java/org/openehr/am/serialize/XMLSerializer.java

The Zilics-donated code mentioned by Rong I believe covers _a lot
more_ than the above file, someone else will probably reply to that
later.

When updates might be put into the LiU Archetype Editor is partly an
open question. The development is currently not fully funded, but we
have people actively investigating possible future directions for the
editor including looking at possibilities for integration with other
projects such as the Eclipse based LinkEHR http://www.linkehr.com/
(now open source) and the zilincs-donated (mutable AM/RM) code.

Best regards,
Erik Sundvall
erisu@imt.liu.se http://www.imt.liu.se/~erisu/ Tel: +46-13-227579