jaxb

JAXB Locator - missing dependency?

On my current project we generate JAXB beans from an XSD file. We need line number information on the beans (beyond XSD validation errors!) so I used the -Xlocator option specified here: http://java.sun.com/webservices/docs/1.6/jaxb/xjc.html However, I'm missing the Locator class. The jar file referenced to on that six-year old page ca...

Memory leak with JAXB

Hi, I am getting Out of Memory error: Memory Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at org.apache.xerces.dom.CoreDocumentImpl.createElement(CoreDocumentImpl.java:564) I have a standalone Java program which fetches data from DB and create an XML file using DOM. I get the above error if the data ...

JAXB - generated classes implement interface

Is there a way to configure JAXB to so that a generated class implements a specified interface? I'm intending to use JAXB generated classes as DAO's and they should be able implement my DAO interface. ...

How to add DOCTYPE and xml processing instructions when marshalling with JAXB?

I am marshalling (serializing) JAXB beans to output stream. How can I add DOCTYPE declaration and xml processing instructions to ouput? I am doing currently marshalling like this: JAXBContext jaxbContext = JAXBContext.newInstance("com.example.package"); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Mar...

Is it possible the generate shared objects using JAXB?

I have 3 xsd files: a.xsd b.xsd shared.xsd shared.xsd is imported to both a.xsd and b.xsd using <xs:import schemaLocation="shared.xsd"/> shared.xsd defines <xs:element name="item"> <xs:complexType> .... If I generate java code using xjc a.xsd and b.xsd is generated into different packages and in each package a separate java c...

marshal Map<String, String> to .xml

If I have Map setup like: map.put("foo", "123"); map.put("bar", "456"); map.put("baz", "789"); then I want to do something like: for (String key : map.keySet().toArray(new String[0])) { // marshall out to .xml a tag with the name key and the // value map.get(key) } So what it will marshal out is something like: <map> ...

remove leading/trailing white spaces in JAXB?

How can I remove leading/trailing white space before/while marshalling in JAXB? ...

Applying a patch from java.net

I have a problem with Jaxb enumerations that is related to this bug https://jaxb.dev.java.net/issues/show_bug.cgi?id=708 A patch has been supplied to the issue that can resolve the problem. How can I apply this patch to resolve my problem ...

How do I customise date/time bindings using JAXWS and APT?

Im using JAXWS 2.1.7, using some classes to run through JAXWS's 'apt' to generate the WSDL. For dates, I use @XmlSchemaType(name="time") private Date wakeupTime; and this generates a schema with xs:time, but when this all comes out in XML, the value is something like <wakeupTime>1901-01-01T01:00:00 +10</wakeupTime> I want JUS...

JAXB adding namespace to parent but not to the child elements contained

I put together an XSD and used JAXB to generate classes out of it. Here are my XSDs- myDoc.xsd : <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns="http://www.mydoc.org" targetNamespace="http://www.mydoc.org" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mtp="http://www.mytypes.com" elementFormDefault="qu...

need to use custom classes instead of generated (by wsimport) in web-services

Hi, Could you, please, help with the following issue? When generate WS client code (with wsimport ant task), all classes are generated automatically in the same package (e.g. helloservice.endpoint) as web service, e.g. if my web-service has method public Node getNode(); so class helloservice.endpoint.Node is generated. Nevertheless, ...

XML strings in JAXB

I have a JPA entity class mimicking a table. Something like this: @XmlType(name="MyClassElementType") public class MyClass { String name; String xmlDesc; public MyClass() {} @XmlElement String getName() { return name; } void setName(String name) { this.name = name; } @XmlElement String getXmlDesc() { r...

JAXB - DO NOT unmarshall nested elements - possible?

Hi there, I've inherited a project which uses JAXB heavily to map XML messages onto Java objects. The problem I have is that some of the data which I receive (in this case nested XML of unknown form) has NOT to be unmarshalled, rather captured as a String. An example will help <a> <b></b> <c></c> <d> <!-- "Unknown" XML...

Jaxb doesn't generate Interface for element of complex type

I have an xsd (for basecamp xml) that contains <xsd:complexType name="ProjectType"> <xsd:sequence> <xsd:element name="announcement" type="TypedNilableStringElementType" maxOccurs="1" minOccurs="1"> </xsd:element> <xsd:element name="created-on" type="TypedDateElementType" maxOccurs="1" minOccurs="1"> ...

Unmarshalling an array of objects and arrays

Hi I'm very new to XML, and webservices but I'm recieving XML from a SOAP webservice that looks kind of like this: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <ArrayOfCreditCardSettlement xmlns="http://schemas.datacontract.org/2004/07/Borgun.Library.Common"&gt; <ns0:CreditCardSettlement xmlns="http://Borgun.Services...

What annotation/property defines the wsdl:definitions section of a wsdl in Jaxb?

We're using apache cxf 2.2.2 with JaxB and I need to change the wsdl:definitions name of an exported wsdl to something else. Does anyone know how I could change it, possibly via a JAXB annotation? ...

Java/JAXB: Unmarshall Xml to specific subclass based on an attribute

Is it possible to use JAXB to unmarshall xml to a specific Java class based on an attribute of the xml? <shapes> <shape type="square" points="4" square-specific-attribute="foo" /> <shape type="triangle" points="3" triangle-specific-attribute="bar" /> </shapes> I would like to have a List of Shape objects containing a triangle and ...

HyperJAXB and IDREFs

I have eventually managed to fiddle HyperJAXB so that when XSD has complexType A and this has an IDREF to complexType B, then HyperJAXB will generate @OneToOne JPA annotations between the the two generated entities. However now I'm facing another problem: the XSD has complex type X that can IDREF to either complex type Y or complex type...

how could I generate xsd dynamically...

Hello I want to generate a xsd file dynamically, I don't want to use jaxb because it creates alot of files when I use schemagen and I want the schema in one file only. any idea? thx al ...

Java XML Unmarshalling fails on ampersand (&amp;) using JAXB

I have the following XML: <?xml version="1.0" encoding="UTF-8"?> <details> ... <address1>Test&amp;Address</address1> ... </details> When I try to unmarshal it using JAXB, it throws the following exception: Caused by: org.xml.sax.SAXParseException: The reference to entity "Address" must end with the ';' delimiter. at org...