jaxb

JSON Structure for List of Objects

I would like to know, whats the right structure for a list of objects in JSON. We are using JAXB to convert the POJO's to JSON. Here is the choices, Please direct me what is right. foos: [ foo:{..}, foo:{..} ] or foos : [ {...}, {...} ] If the first structure is ...

Can JAXB output an ArrayList as comma separated values?

I have something like @XmlElementWrapper(name="Mylist") List<Items> myItems = new ArrayList<Items>() and that comes out like <Mylist> <myItems>item 1</myItems> <myItems>item 2</myItems> <myItems>item 3</myItems> </Mylist> Is it possible to make this come out more like <Mylist> <myItems>item 1, item 2, item 3</myItems...

controlling the class names generated by JAXB for xsd:attributeGroup?

I am using JAXB to bind XML to Java for an application that I am writing. I have an element called measure which contains two amount elements called amount and maxAmount, with which I want to model a lower and an upper limiting value. amount and maxAmount are otherwise identical and I would like them to be implemented with the same class...

Display null for objects -JSON- JAXB

Hi All, I want to marshal null objects as null in the JSON representation. But, right now, Am not seeing the element in the JSON if the object is null. Example: @XmlAccessType(FIELD) @XmlType(name="foo" propOrder={"foo"} class foo{ @XmlElement private Integer foo; private Integer another_foo; .. getter() setter() } In m...

JAXB: how to marshall map into <key>value</key>

Hi all, The question is about JAXB Map marshalling - there is plenty of examples on how to marhsall a Map into a structure like follows: <map> <entry> <key> KEY </key> <value> VALUE </value> </entry> <entry> <key> KEY2 </key> <value> VALUE2 </value> </entry> <entry> ... </map> In fact, this is natively su...

Tell JAXB to unmarshal <xs:dateTime> to Date class using annotations

When using JAXB with Java-First, fields/properties of type java.util.Date are marshalled and unmarshalled as xs:dateTime and everything works as expected. But if the type of the field/property is Object, JAXB unmarshals xs:dateTimeto XMLGregorianCalendarImpl. I need to find a way that makes JAXB unmarshal date-time values to java.util....

Java/XML problem

Hello all, I'm having an issue generating XML via Java code. I have a class that for SailingAvailabilityResponseMessage. Within this class there are several other classes that are also used in the method I'm writing. Here is a snippet of what the SailingAvailabilityResponseMessage classes looks like: import javax.xml.bind.annotation...

Java generated XML showing up with special characters in .Net/SQL

We have a java desktop application that uses JAXB to generate an XML file which is then read by a .Net application and stored in a SQL server database. We're finding that carriage returns in Java and not coming over as carriage return/line feeds in .Net/SQL. Is there a way to tell Java or Jaxb to include both the carriage return and li...

How to use generic object List in JAXB XmlAdapter

I have two similar classes, that simply have a string name. I wanted to add an XML adapter to the Lists so that I could get a CSV string from each of them. I tried to declare my adapter like so: public class ListXmlAdapter extends XmlAdapter<String, ArrayList<Object>> { But when I try to use this I get illegal annotation exceptions ...

Mapping a Java property to several xml attributes using JAXB and MOXy

Hello, I have a simple class CustomQuoteRequest: public class CustomQuoteRequest { private String requestId; private String currencyPairCode; public String getRequestId() { return requestId; } public void setRequestId(String requestId) { this.requestId = requestId; } public String getCurrencyPairCode() { r...

Dynamic java bean from xsd

Hello, I have two applications, one acting as client and the other as server. In server application I generate ObjectFactory and classes using xjc from Eclipse. As a result, one of this classes is called widgetEvenCall. From the xsd: ... <xs:element name="widgetEventCall"> <xs:complexType> <xs:sequence> <xs:elem...

XML to DynaBeans from only xsd. Possible ?

Hello, my question seems simple but I'm going crazy :) Is there a way, using JAXB, Castor or XStream to convert XML into DynaBeans, considering that I have the xsd schema but no precompiled mapping classes and no ObjectFactory or similar ? Blaise Doughan suggested to use MOXy (thanks again, Blaise) but unfortunately I have no permissio...

Can JAXB/MOXy map element value and element attribute to same POJO field?

Hi I've just started working on web services using JAXB to unmarshall the incoming SOAP documents to our domain classes. I've run into a technical challenge, which is dictated by the OIO XML format used within danish govermental institutions. The format states among other things, that it is not allowed to use the xml schema attribute n...

JAXB workaround for Chameleon XSD imports?

Hi there, this is my first question, so please be gentle ;) I'm stuck with a weird problem. Essentially i get three XSD definitions like the following: PartA.xsd targetNameSpace="PartA" include="PartB.xsd" PartB.xsd <!-- no namespace definition!!! --> PartC.xsd targetNameSpace="PartC" inlude="PartB.xsd" import="PartA.xsd" The error...

JAXB Namespace Order

Is it possible to control the order of namespaces in documents generated via JAXB? I know, it is not relevant to XML standards, but somehow we need to generate namespace declarations in specific order? For example, currently we have generated <rootelement a="http://www.example.com/xom" b="http://www.example.com/crops"&gt; .. </rooteleme...

XML Schema reference

I have two XML Schemas. First (A.xsd) is located in a library jar file (mylib.jar) and the second one (B.xsd) is in my project. I want to import A.xsd into the B.xsd and validate incoming XML via Jaxb2Marshaller embedded validator. However I'm unable to make it work properly: it seems that inner XML validator of Jaxb2Marshaller does no...

How do I make more complex XSDs using JAXB?

Using JAXB I can create an XSD using code like: JAXBContext ctx = JAXBContext.newInstance(classes); ctx.generateSchema(new MySchemaOutputResolver()); That makes a goods XSD describing the structure of all the JAXB objects in the list of classes I pass in, however, I can't figure out how to add other types of XSD restrictions like minO...

[XJC] suppress Javadoc

when i compile a JAXB schema the generated classes are decorated with generic Javadoc comments. is it somehow possible to suppress generating these comments? ...

How do I get JSON data from my RESTful service using JEE 5?

I have a simple RESTful web service written in JEE 5. It works fine but I've decided to output JSON from the GET method. As an initial step I've only add one line of code: ObjectMapper mapper = new ObjectMapper(); That one line results in this error: 48d5-9878-2ef7c0a948c4;|StandardWrapperValve[Jersey Web Application]: PWC1406: Servl...

XML Schema to validate XML Schemas?

Does anyone know if its possible to validate an XML schema with another XML schema? If so, is there a reference implementation out there? I would like to parse a Schema doc using JAXB. ...