After using JAXB with XSD schema, I have finally discovered that it´s MUCH better to make it with files and jaxd binding files. Supposing you want to generate the classes for a web-app xml file, in the Maven pom.xml you need to add something like: In the specified schema directory there must be both the […]
Currently I am developing an application to rename some jboss configuration content. Using JAXB, I had made marshalling and unmarshalling methods, creating a new JAXBcontext instance each time the single methods were invoked (for each xml file!). The application was incredibly slow. Taking up to 45 minutes to complete the tasks. Then I have discovered […]
Let´s consider an xml file with entity references. In your dtd schema you can specify the reference. If you need to unmarshal an xml file with entity references, first of all you need to expand them. Then you can unmarshal the file passing it as a string file. I would like to find a better […]
With JAXB you need to dhandle special characters you can just choose between two options. Otherwise you need to define your own character handler. The following class shows you how to handle both CDATA elements and special characters. In your marshaller method just add the following property:
If you want to specify that element values are CDATA, you can create an adapter class like this: import javax.xml.bind.annotation.adapters.XmlAdapter; In the bean class, generated by JAXB add the following annotation. In this way any occurrence of the elements with the annotation above will be automatically parsed as CDATA.