# Parsing archetype xml with JAXB **Category:** [Technical (archive)](https://discourse.openehr.org/c/technical-archive/156) **Created:** 2008-06-05 13:03 UTC **Views:** 4 **Replies:** 11 **URL:** https://discourse.openehr.org/t/parsing-archetype-xml-with-jaxb/14762 --- ## Post #1 by @Greg_Caulton 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 --- ## Post #2 by @system 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/](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 --- ## Post #3 by @thomas.beale 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 --- ## Post #4 by @system > 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 ;-) Good point, Tom! =) It could be even posted on the Java-list. /Rong --- ## Post #5 by @Greg_Caulton > > 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 --- ## Post #6 by @system > > > > 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/](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](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](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 --- ## Post #7 by @Greg_Caulton > 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 :\-\) > 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 ;\-\) > > \- thomas beale Don't worry, I won't show the one line of code :\-\) thanks\! Greg http://www.patientos.org --- ## Post #8 by @Adam_Flinton 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 :\-\) > >> 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 ;\-\) >> >> \- thomas beale >>     > Don't worry, I won't show the one line of code :\-\) > > 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 --- ## Post #9 by @system > > 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](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 :-) Excellent! Let's talk about creating synergies between the two projects! =) /Rong --- ## Post #10 by @system > 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](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 :-) > > > > > >> 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 ;-) > >> > >> - thomas beale > >> > > > > Don't worry, I won't show the one line of code :-) > > > > 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 --- ## Post #11 by @Adam_Flinton >> 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 --- ## Post #12 by @erik.sundvall 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 --- **Canonical:** https://discourse.openehr.org/t/parsing-archetype-xml-with-jaxb/14762 **Original content:** https://discourse.openehr.org/t/parsing-archetype-xml-with-jaxb/14762