jaxb

Can I put annotations for multiple processors into a Java class?

I'm not really sure how annotations actually work. I'm using JAXB and JPA (with eclipselink) on the same classes, i. e. I get class definitions like this: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "Channel") @Entity public class Channel extends NamedEntity { @XmlAttribute @XmlSchemaType(name = "anyURI") @Column(n...

JAXB Java to XML: How not printing primitive type members when default

Hi guys, First attempt to use this cool site - after searching for 2 hours: So I have a Java Bean that is given (I can only annotate not change) and need to map it to XML using JAXB. I would like primitives types not to be printed when they contain their language default, or a user-defined default. As said I cannot change the java bea...

Why can't JAXB find my jaxb.index when running inside Apache Felix?

It's right there, in the package that it should be indexing. Still, when I call JAXBContext jc = JAXBContext.newInstance("my.package.name"); I get a JAXBException saying that "my.package.name" doesnt contain ObjectFactory.class or jaxb.index although it does contain both. What does work, but isn't quite what I want, is JAXBCo...

how to create customized marshalled output from JAXB??

I don't want to use XML file created by JAXB marshaller, can I customize it, so that i would give a preferrable format to marshal objects? ...

Unmarshalling XML using JAXB in restlet's acceptRepresentation method.

I've created an XML schema by annotating an existing Java domain model class, now when I try to use JAXB to unmarshall the representation received within my restlet webservice I'm getting a host of errors no matter what I seem to try. I'm new to both restlets and JAXB so pointing me in the direction of a decent example of using both woul...

Format XML with JAXB during unmarshal

Hi there, I want to format a XML document during unmarshal with JAXB. Unmarshal looks like: Unmarshaller u = createAndsetUpUnmarshaller(enableValidation, evtHandler, clazz); return u.unmarshal(new ByteArrayInputStream(stringSource.getBytes())); While marshaling one can format the code via: marshaller.setProperty(Marshaller.JAXB_FORM...

JAXB: unmarshaling data on a per-instance basis

I am using JAXB to unmarshal an XML file into a Java object model. Works great, except for one thing. I've been using parseMethod and printMethod to convert simple strings to a type of my choice, e.g.: <someElement tag='Bismarck' name='Dagwood' /> <someElement tag='Pierre' name='Herb' /> where the "tag" attribute, instead of being unm...

Anybody also epriences problems with JAXB validation, when XSD contains regular expression character class \w?

Hi, We are using JAXB 1.0.6 (the project has started with JDK1.4 and this is the last compatible version) to create XML-Files from a XSD specification. The XSD defines an attribute "email" with the following regexp pattern. <xs:simpleType name="EmailAddress"> <xs:restriction base="xs:string"> <xs:minLength value="0"/> <xs:maxLengt...

validating JAXB, but whitespace not ignored

some code snippets. The java coding doing the jaxb unmarshaling. pretty straightforward, copied out of tutorials online. JAXBContext jc = JAXBContext.newInstance( "xmlreadtest" ); Unmarshaller u = jc.createUnmarshaller(); // setting up for validation. SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_...

Can JAXB parse large XML files in chunks

I need to parse potentially large XML files, of which the schema is already provided to me in several XSD files, so XML binding is highly favored. I'd like to know if I can use JAXB to parse the file in chunks and if so, how. ...

How do I marshal nested lists as JSON using Jersey? I get an array of nulls or an array of one-element dictionaries containing an array.

I'm working on a project which uses Jersey to convert objects to JSON. I'd like to be able to write out nested lists, like so: {"data":[["one", "two", "three"], ["a", "b", "c"]]} The object I'd like to convert first represented data as a <LinkedList<LinkedList<String>>>, and I figured Jersey would just do the right thing. The above wa...

JAXB Annotations - Mapping interfaces and @XmlElementWrapper

I am having trouble with JAXB annotations for a field that is a list whose generified type is an interface. When I have it declared such as: @XmlAnyElement private List<Animal> animals; Every thing works correctly. But when I add a wrapper element, such as: @XmlElementWrapper @XmlAnyElement private List<Animal> animals; I find tha...

How do I get Groovy and JAXB to play nice together

I am trying to get JAXB to work with a groovy class of mine, however, it appears it doesn't work but the java version does. Here is the code... Here are the Scenarios if 2 and 3 are uncommented it works fine if 1 and 4 are uncommented I get... com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of Illeg...

Marshalling polymorphic objects in JAX-WS

I'm creating a JAX-WS type webservice, with operations that return an object WebServiceReply. The class WebServiceReply itself contains a field of type Object. The individual operations would populate that field with a few different data-types, depending on the operation. Publishing the WSDL (I'm using Netbeans 6.7), and getting a ASP.N...

Would it be accurate to say that JAXB is to XML as Hibernate is to a database schema?

If I want an ORM that helps me to develop a "database agnostic" application, then Hibernate would be a good fit, but if I need to map entities or objects to nodes in an XML file, then JAXB would be the right type of technology... would that be a correct assessment? ...

Unmarshalling XML to existing object using JAXB

I have an xsd generated from a set of existing java classes and currently it successfully unmarshalls XML messages into the object as expected, however what I'd like the ability to do is where I have an existing instance of the Object have the unmarshaller simply update the fields that are contained within the message passed to it for e...

JAXB ObjectFactory doubt!

Hi. The object Factory class of JAXB from java, does instances creation. OK. But, is there a way to change the method creation, passing a enum parameter like: public Country createCountry() { return new Country(); } to public Country createCountry(CountryType type) { switch (type) { case:US return new USCou...

JAXB: Can I make XmlAttribute's parameter "required=true" to default?

Hello! I have @XmlAttribute(required=true) in hundreds places in a projects. Can I make this default?... ...So that I then only need to specify @XmlAttribute(required=false) when needed. ...

How do you serialize an Exception subclass in JAXB?

How do you serialize a subclass of Exception? Here is my exception: @XmlType public static class ValidationFault extends Exception { public ValidationFault() { } } I have tried all sorts of variations on using @XmlTransient and @XmlAccessorType, but JAXB continually tries to serialize the getStackTrace/setStackTrace pair, which ...

Is there something like JAX-B for C#?

We are searching for an Library which supports the marshalling and unmarshalling like JAX-B in Java, is there any state-of-the-art library to use? ...