# Java XML-Archetype Parser? **Category:** [Reference Implementation: Java (archive)](https://discourse.openehr.org/c/reference-implementation-java-archive/154) **Created:** 2008-01-08 20:41 UTC **Views:** 2 **Replies:** 14 **URL:** https://discourse.openehr.org/t/java-xml-archetype-parser/12730 --- ## Post #1 by @system Dear all, Does anybody know of any current initiative and/or interest to develop a Java\-based XML\-Archetype Parser? Cheers Sebastian --- ## Post #2 by @system Sebastian Garde schreef: > Dear all, > > Does anybody know of any current initiative and/or interest to develop a > Java\-based XML\-Archetype Parser? >   If XML will be the archetype\-language of the future, I think there will be a need for such a parser\. However, the building of it seems to me easier than the building of a the ADL\-parser\. But I must say, I did not really study into the matter\. Bert --- ## Post #3 by @system Hi Sebastian, The XML parser can be generated by published AOM schema so it should be straight forward I think. If the parsed object form should be connected to the current openehr-aom component, we need to make a converter. In fact, I think both parsing and serializing XML archetypes can be facilitated by using AOM schema. Cheers, Rong --- ## Post #4 by @Humberto_Naves In fact! I use a XML parser for archetypes, templates, composition and versions, that was automatically generated by the XSD schemes available (Not only a parser, but a serializer too). In a recent talk with Rong, we discussed the possibility of incorporating my parser into ref_impl_java project, and I think that is a great idea :-) But that integrations is not straightforward because that parser use a different AM/RM (a mutable one), so I have to do a little work before committing it. As soon as I get an extra time, the parser will be public available, so I ask you to have a little patient... Regards, Humberto --- ## Post #5 by @system Sounds great Humberto and Rong, thanks for confirming this\. I suspected it would not be too hard with the existing schemas\. Do you use Castor for this? Cheers Sebastian Humberto Naves wrote: --- ## Post #6 by @erik.sundvall Hi\! --- ## Post #7 by @Humberto_Naves I tried to use Castor, but since I have both the schemes and the Object Model, Castor wasn't useful for me... So I had to write my own generator :-( The first step is to bind each xs:complexType of the schema with the corresponding class and to bind each attribute/element with the corresponding attribute of the class, and that binding is constructed automatically. The generated parser uses JDOM for XML parsing. Sample code generated follows: --- ## Post #8 by @Humberto_Naves Sure thing! But first, I have to finish the "turnImmutable()" method :-( --- ## Post #9 by @Humberto_Naves So, the XML will be the archetype-language of the future? And what about the ADL? --- ## Post #10 by @system I don't think that is decided\. Personally I see adl as the primary one\. Sebastian Humberto Naves wrote: --- ## Post #11 by @Tim_Cook2 Having been working on both ADL and XML parsers over the past weeks\. I agree with Sebastian\. It is readily apparent to me that ADL is a much richer \(semantically\) serialization than the XML\. Now, maybe that just means that the tools need improvement so they can produce better XML representations? Note that I am not an expert on either of these\. It's just my observations as I am building parsers\. Cheers, Tim --- ## Post #12 by @mikael Tim Cook wrote: Hi, > Sebastian Garde wrote: >> I don't think that is decided\. Personally I see adl as the >> primary one\. > Having been working on both ADL and XML parsers over the past weeks\. > I agree with Sebastian\. > > It is readily apparent to me that ADL is a much richer > \(semantically\) serialization than the XML\. \[\.\.\.\] On the other hand there exists a very large community building tools for XML, but it is only the relatively small openEHR\-community that builds tools for ADL\. I therefore think we in general are able to reuse more tools and environments for handling archetypes in XML than in ADL\.   Greetings,   Mikael --- ## Post #13 by @Humberto_Naves Just putting more wood on the fire: 1) I think ADL is a lot less verbose and more concise... (beautiful to the eye of an human :-) 2) But, XML is well-known and more easy to parse(beautiful to the eye of a machine :-) I hope that this discussion doesn't become an endless one... Humberto --- ## Post #14 by @thomas.beale Humberto Naves wrote: > So, the XML will be the archetype-language of the future? And what about the ADL? ADL will always remain the 'standard' language of archetypes, since it is (by definition) the languageof archetypes. XML renditions are just that. As long as they properly express what is in an ADL archetype, they work, which is the case today. Not providing ADL archetypes will mean that the archetypes are unlikely to be hosted on openEHR.org however. An open source ADL / XML reader/writer should be available soon. - thomas --- ## Post #15 by @erik.sundvall Hi Thomas and Humberto! Could you please give us info or a short status update on your tools and models that were mentioned below? > In fact! I use a XML parser for archetypes, templates, composition and versions, that was automatically generated by the XSD schemes available (Not only a parser, but a serializer too). In a recent talk with Rong, we discussed the possibility of incorporating my parser into ref_impl_java project, and I think that is a great idea :-) But that integrations is not straightforward because that parser use a different AM/RM (a mutable one), so I have to do a little work before committing it. As soon as I get an extra time, the parser will be public available, so I ask you to have a little patient... > Regards, > Humberto Is it possible to have a look at your mutable AM/RM even if it has not been mapped and connected to the current ref-impl-version (initially by Rong et al)? Could the further development of the new (initially schema generated) mutable RM/AM and the mapping/connection work to the current immutable AM/RM be done in a branch in the public repository? We have some master thesis students that probably will have an interest in this or similar approaches. --- **Canonical:** https://discourse.openehr.org/t/java-xml-archetype-parser/12730 **Original content:** https://discourse.openehr.org/t/java-xml-archetype-parser/12730