jaxb2

JAXB2 type restriction not working?

佐手、 提交于 2019-12-05 19:20:33
I have set up a test unit at github. Could someone please check why this is not working though the XML to unmarshal looks good? https://github.com/jjYBdx4IL/misc-tests/blob/master/src/test/java/jjybdx4il/jaxb/bugs/Stackoverflow26618647Test.java "<?xml version=\"1.0\" encoding=\"UTF-8\"?><message:GenericData xmlns:message=\"http://www.sdmx.org/resources/sdmxml/schemas/v2_1/message\" xmlns:common=\"http://www.sdmx.org/resources/sdmxml/schemas/v2_1/common\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:generic=\"http://www.sdmx.org/resources/sdmxml/schemas/v2_1/data/generic\" xsi

JAXB: Qualified attributes disables default namespace xmlns=“”?

穿精又带淫゛_ 提交于 2019-12-05 09:15:29
When I use @XmlSchema(attributeFormDefault = XmlNsForm.QUALIFIED, ...) or @XmlAttribute(namespace = "sample.com/y", ...) JAXB ignores @XmlSchema(namespace = "sample.com/x", ...) and instead of: <a xmlns="sample.com/y" xmlns:ns0="sample.com/y"> <b ns0:att=""/> </a> generates something like: <ns1:a xmlns:ns1="sample.com/x" xmlns:ns0="sample.com/y"> <ns1:b ns0:att=""/> </ns1:a> Is this an expected behavior? Is there any way to correct this? EclipseLink JAXB (MOXy) is handling the prefix qualification for elements differently depending upon the attribute form qualification (as demonstrated below).

Unmarshalling Error: unexpected element (uri:url, local:“objectname”). Expected elements are <{}objectname>

人盡茶涼 提交于 2019-12-05 05:37:53
I'm using jaxb2-marshaller to generate classes to communicate with a webservice. Java-classes are generated with use of some wsdl files. Everything is okay now, but when I'm trying to use some of the generated classes, i got this unmarshalling error, altough I use the generated ObjectFactory classes. Some of the stack: org.springframework.ws.soap.client.SoapFaultClientException: Unmarshalling Error: unexpected element (uri:"http://xxxxxxxxx", local:"customer"). Expected elements are <{}customer> at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault

Duplicated field in generated XML using JAXB

ⅰ亾dé卋堺 提交于 2019-12-05 05:01:14
This is my scenario. I have a generic class: public class Tuple<T> extends ArrayList<T> { //... public Tuple(T ...members) { this(Arrays.asList(members)); } @XmlElementWrapper(name = "tuple") @XmlElement(name = "value") public List<T> getList() { return this; } } And a child class: public class StringTuple extends Tuple<String> { public StringTuple(String ...members) { super(members); } //explanation of why overriding this method soon ... @XmlElementWrapper(name = "tuple") @XmlElement(name = "value") @Override public List<String> getList() { return this; } } These classes are referenced here:

How to specify the JAXB version in maven-jaxb2-plugin?

淺唱寂寞╮ 提交于 2019-12-05 01:16:06
问题 I need to use the latest version jaxb: 2.2.4-1, but maven or maven-jaxb2-plugin seems to pick up the one from the JDK. I tried specifying the version like this: <configuration> <specVersion>2.2</specVersion> ... </configuration> but the logs read: [INFO] [jaxb2:generate {execution: common}] [INFO] Started execution. [INFO] JAXB API is loaded from the [jar:file:/opt/jdk1.6.0_24/jre/lib/rt.jar!]. [INFO] Detected JAXB API version [2.1]. I tried to add dependencies to the correct versions of

Validate nested object from complex object using jaxb

假如想象 提交于 2019-12-04 18:09:44
I have a xml representation of object like OrderList (has list of) Orders and each order has a list of commodities. I want to validate my commodities and if not valid I want to remove them from order. If all commodities are invalid then I remove the order from the orderlist. I have been able to validate Orderlist JAXBContext jaxbContext = JAXBContext.newInstance("com.jaxb"); SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = sf.newSchema(new File(XSD)); JAXBSource source = new JAXBSource(jaxbContext, orderList); Validator validator = schema

What is the Jaxb equivalent of a Text node value?

China☆狼群 提交于 2019-12-04 16:26:48
问题 I am looking to convert a class that looks like this ... public class Amenity { public String id; public String value; } into the following XML using JaxB annotations: <amenity id="id-string-here">value-string-here</amenity> Does anyone know what annotation to use on the value member variable to accomplish this? The closest I've gotten so far is: @XmlRootElement public class Amenity { @XmlAttribute public String id; @XmlElement public String value; } Unfortunately this approach doesn't allow

JAXB generated classes of certain types implementing a custom interface

纵然是瞬间 提交于 2019-12-04 12:19:08
问题 I am working on an application that uses XJC to generate Java POJOs from XSDs. There are dozens of schemas, and that number will grow. The application also needs to be able to handle different versions of the same schema, which means that I will have multiple schemas defining common types. I am trying to customize the bindings so that certain core types implement a common interface. The Inheritance plugin of JAXB2 Basics seems to do what I need, but I can't seem to nail the right syntax. Here

JAXB appending unneeded namespace declarations to tags

天涯浪子 提交于 2019-12-04 10:47:34
问题 I'm implementing a homebrew subprotocol of XMPP, and i'm using combination of StAX and JAXB for parsing/marshalling mesages. And when I marshall a message I end up with loads of unneded namespace declarations: <ns2:auth xmlns:ns2="urn:ietf:params:xml:ns:ilf-auth" xmlns:ns4="ilf:iq:experiment:power" xmlns:ns3="ilf:iq:experiment:init" xmlns:ns5="ilf:iq:experiment:values" xmlns:ns6="ilf:iq:experiment:result" xmlns:ns7="ilf:iq:experiment:stop" xmlns:ns8="ilf:iq:experiment:end"> compton@ilf</ns2

convert object into JAXBElement

白昼怎懂夜的黑 提交于 2019-12-04 05:58:16
I want to implement a method which returns JAXBElement following is the code @XmlRootElement(name = "history") @XmlAccessorType(XmlAccessType.FIELD) public class IBHistoryInfo { @XmlElement(name="trade") private List<IBTradeInfo> mTrade; public void updateTradeValue(int reqId, String date, double open, double high, double low, double close, int volume, int count, double WAP, boolean hasGaps){ IBTradeInfo info = new IBTradeInfo(); info.setReqId(reqId); info.setDate(date); info.setOpen(open); info.setHigh(high); info.setLow(low); info.setClose(close); info.setVolume(volume); info.setCount(count)