tag:blogger.com,1999:blog-1710464868724994296.post1878841028455754447..comments2014-05-29T01:45:58.311-04:00Comments on Java XML and JSON Binding: How Does JAXB Compare to Simple?Blaise Doughan to same question asked by Paul Taylor, is...Refering to same question asked by Paul Taylor, is there any tool to convert the JAXB class to SimpleXML classes?Abhijeet Wadkar for the info, I am trying to convert some j...Thanks for the info, I am trying to convert some jaxb objects to simpleXML, and having hard time to convert this tag<br /><br />@XmlTransient<br />@XmlElementWrapper(EclipseLink JAXB (MOXy)</a> lead, I have not investigated the existence of such a tool. However, I'm more than happy to help people port form SimpleXML to JAXB.<br /><br />-BlaiseBlaise Doughan happy with JAXB but now I need to write somethi...Im happy with JAXB but now I need to write something on Android, JAXB isnt suitable for this but SimpleXml is. Do you of any tool that could convert JAXB clases to Simple ones ?Paul Taylor Bala, I can't speak to how Simple is imple...Hi Bala,<br /><br />I can't speak to how Simple is implemented. In <a href="" rel="nofollow">EclipseLink JAXB (MOXy)</a> we leverage a <a href="" rel="nofollow">java.io.BufferedWriter</a> to solve this problem for writing.<br /><br />-BlaiseBlaise Doughan colleague says that the XML serialisation and d...My colleague says that the XML serialisation and deserialisation with Simple is inefficient, only writing/reading a few bytes at a time to/from disk. According to him, it looks like the serialisation writes one attribute at a time. The deserialisation is even worse, reading a single byte at a time from disk.<br /><br />Is this claim true?<br /><br />BalaAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1710464868724994296.post-44224485180315906502011-01-05T15:41:31.999-05:002011-01-05T15:41:31.999-05:00Hi Tom, Thanks for the suggestion. I have entere...Hi Tom,<br /><br />Thanks for the suggestion. I have entered the following enhancement request for <a href="" rel="nofollow">EclipseLink MOXy</a>:<br /><br />- <a href="" rel="nofollow">Enhancement: Customizable Name Mangling Algorithm</a><br /><br />-BlaiseBlaise Doughan, This looks useful, however I think it works a...Hi,<br /><br />This looks useful, however I think it works a little better in Simple. You can simply style the attributes and elements with a Style object, this avoids, which means you get transparent serialization and deserialization regardless of case. <br /><br />It would be good to support a feature that can intercept the marshalling and unmarshalling and adapt the names transparently.<br /><br />TomAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1710464868724994296.post-84191036442567935772010-12-07T16:39:38.257-05:002010-12-07T16:39:38.257-05:00Hi BODYLANG, I have posted an example on how case...Hi BODYLANG,<br /><br />I have posted an example on how case insensitive unmarshalling could be done using JAXB today:<br /><br />- <a href="" rel="nofollow">Case Insensitive Unmarshalling with JAXB</a><br /><br />-BlaiseBlaise Doughan BODYLANG, Agreed a visitor could be used to re...Hi BODYLANG,<br /><br />Agreed a visitor could be used to remove unwanted field, but since Simple XML markets itself as being simple, extra steps count against it there.<br /><br />However you could use extra steps to support case insensitive mapping in JAXB (and probably Simple XML). You could map all your properties to lower case node names, and then wrap an XMLStreamReader to call toLowerCase() on all attribute/element names it returned.<br /><br />I have added an enhance request for EclipseLink JAXB (MOXy) for this issue, feel free to provide additional information:<br /><br />- <a href="" rel="nofollow"></a><br /><br />-BlaiseBlaise Doughan All, regarding the case of using extra attribut...Hi All,<br />regarding the case of using extra attribute like the "class" from the simpleXml it could be solved by using a Visitor implementation that can inspect the serilization process and remove any un-wantred field.<br />But I have a small question, can we in JAXB, SimpleXML de-serilize an XML even if the case differs (case in-sensitive)?B0DYLANG, With JAXB you can optionally registe...Christopher,<br /><br />With JAXB you can optionally register an instance of <a href="" rel="nofollow">javax.xml.validation.Schema</a> with both the marshaller and unmarshaller to validate against an XSD.<br /><br />JAXB requires a no-arg constructor. You can workaround this issue through the use of XmlAdapter. I will post an example of how to do this on my blog soon.<br /><br />I have entered the following enhancement request to cover support for multi-arg constructors. Feel free to add any information you feel is relevant.<br /><br />- <a href="" rel="nofollow"></a><br /><br />-BlaiseBlaise Doughan am new to JAXB and simple but found this useful....I am new to JAXB and simple but found this useful. <br /><br /><br />I like the fact that for validation, JAXB is led by XSD. My understanding of simple is that you really have to re-write your XSD constraints into your annotations to get the validation of the XML. That's a big weakness, if my understanding is right. <br /><br />However, I liked the fact that in simple, I was not forced to having a no-arg constructor. I want immutable classes. I liked having a constructor which looked like this<br /><br /><br />public XmlMessage(@Attribute(</a>Blaise Doughan tutorial I have one question. Is there a way...Nice tutorial<br /><br />I have one question.<br />Is there a way to marshall/unmarshall a collection of objects without having to create a new java wrapper class.<br /><br />RegardsAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1710464868724994296.post-32883839606105758682010-10-27T10:16:34.693-04:002010-10-27T10:16:34.693-04:00Anonymous, Simple If we change the Simple @Eleme...Anonymous,<br /><br /><b>Simple</b><br /><br />If we change the Simple @ElementList annotation we used on the "phoneNumbers" property to be the following @ElementList(<br /><br />I presume this means that the when unmarshalling the XML the java.uti.List property should be populated with an instance of java.util.ArrayList.<br /><br />For this type of mechanism to work, the following needs to be true:<br />- Both the object used to produce XML, and the object used to consume the XML both need to use ArrayList for that value.<br />- If there is an XML schema associated with this XML it needs to account for the class attribute.<br /><br /><b>JAXB</b><br /><br />If you initialize a property with a particular implementation of list then JAXB will use that initialized list. If one was not pre-initialized an implementation will be chosen for you (both Metro and MOXy will use ArrayList). In EclipseLink 2.2, MOXy will offer the ability to specify List implementation in its XML version of the metadata.<br /><br />-BlaiseBlaise Doughan've used Simple and one of the nice things ab...I've used Simple and one of the nice things about it is the ability to use polymorphisim via fields or property methods, for example.<br /><br />@ElementList<br />private List list = new MyListType()<br /><br />Can JAXB figure out a list assignment like this? If so does it require an annotation with a specific type to use?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1710464868724994296.post-91882908402247317222010-10-26T09:26:12.234-04:002010-10-26T09:26:12.234-04:00In this example I set a couple of JAXB annotations...In this example I set a couple of JAXB annotations at the package level. This can be done by using a class named <a href="" rel="nofollow">package-info</a>.<br /><br /><b>@XmlAccessorType</b><br />The @XmlAccessorType can also be set at the type level. To eliminate its use all together simply annotate the public get (or set) method instead of the private field.<br /><br /><b>@XmlSchema</b><br />JAXB has support for <a href="" rel="nofollow">specifying namespace information</a> at the package, type, and property/field levels.<br /><br />Alternatively MOXy offers the ability to represent the JAXB metadata as an XML file:<br /><br />- <a href="" rel="nofollow"></a>Blaise Doughan find the package level annotations awkward to lo...I find the package level annotations awkward to look at. Is there another way to achieve the same result?tskaufma