moxy

Check my JAXB implementation

最后都变了- 提交于 2019-12-23 03:00:19
问题 I am trying to use Eclipselink's MOXy. I put jaxb.properties file in the same directory as my annotated classes and it contains the entry: javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory Is there anyway I can be sure this implementation is being used at runtime? For example, I can check my StAX implementation is Woodstox by checking: inputFactory.getClass().getName() is equal com.ctc.wstx.stax.WstxInputFactory Is there anything similar I can do to check my JAXB

Override JAXB annotation Mapping with MOXY oxm binding file

我与影子孤独终老i 提交于 2019-12-22 22:20:14
问题 I'm trying to implement two differents mappings for certains of my objects. The first mapping is done using JAXB annotations on my classes. It's working fine. The second mapping is really simple : it should take every Java attribute. To do this I wrote a very simple xml bindings file : <?xml version="1.0"?> <xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="com.foo" xml-mapping-metadata-complete="true"> <java-types> <java-type name="com.foo

List wrappers in JAXB MOXy

安稳与你 提交于 2019-12-22 17:08:34
问题 I am declaring a List object property with: @XmlRootElement(namespace = "...") @XmlType public class Test { private List<String> myList; @XmlElementWrapper(name = "myListWrapper") @XmlElement(name = "myList") public List<String> getMyList() { return myList; } } When an instance of this class with an empty list myList is marshalled, MOXy is not generating an empty wrapper MyListWrapper . However, JAXB RI would do it. The generated XML looks like this when using the RI: <ns2:test xmlns:ns2="...

JAXB: Intercept during unmarshalling?

孤者浪人 提交于 2019-12-22 08:36:28
问题 I've got a typical web service using JAX-RS and JAXB, and upon unmarshalling I would like to know which setters were explicitly called by JAXB. This effectively lets me know which elements were included in the document provided by the caller. I know I can probably solve this with an XmlAdapter , but I have a lot of classes in a number of different packages, and I don't want to create adapters for each and every one of them. Nor do I want to put hooks into each and every setter. I would like a

Exception : “Missing class indicator field from database row [UnmarshalRecordImpl()].” when unmarshalling XML using EclipseLink JAXB (MOXy)

99封情书 提交于 2019-12-21 06:04:48
问题 Is it any way to unmarshalling with @XmlDescriminatorNode/@XmlDescrimintatorValue annotations next XML, or any workaround: <assets> <asset type="full"> <data_file role="source"> <locale name="ru-RU"/> </data_file> <data_file role="extension"> <locale name="ru-RU"/> </data_file> <data_file> <locale name="ru-RU"/> </data_file> </asset> </assets> My mapping classes: @XmlRootElement(name="data_file") @XmlAccessorType(XmlAccessType.FIELD) @XmlDiscriminatorNode("@role") public abstract class

Jaxb Inheritance using Substitution but not to root Element

99封情书 提交于 2019-12-21 04:36:14
问题 I was going through the Blaise's Blog http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-substitution.html for Jaxb Inheritance using Substitution. I want to implement the same but not to the root element. I am looking this type of XML as a output. <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <configuration> <customer> <address> <street>1 A Street</street> </address> <address> <street>2 B Street</street> </address> <phoneNumber> <mobileNo>xxx-xxx-xxxx</mobileNo> <

Configure CXF JAX-WS service to work with MOXY

天涯浪子 提交于 2019-12-20 04:50:26
问题 Although I've added a jaxb.properties with MOXY factory and I see that the JAXB was switched to moxy, CXF has a method named createRIContext in the JAXBUtils class which loads hard coded the sun JAXB implementation. Is there a way to override it and use moxy instead? The problematic code is the following: // fall back if we're using another jaxb implementation try { riContext = JAXBUtils.createRIContext(contextClasses .toArray(new Class[contextClasses.size()]), tns); } It loads hard coded the

JAXB for lists to be returned naturally for JSON or XML

邮差的信 提交于 2019-12-19 16:26:52
问题 I'm using MOXy with Jersey to implement a RESTful API and want to return lists naturally for JSON and XML, by which I mean that the XML contains an element tag for the overall collection as well as the collection items, whereas the JSON contains a tag for the collection only. For example, I want to return an "organisation" resource with nested lists of facilities and locations. As XML: <organisation> <id>1</id> <name>XYZ</name> <facilities> <facility> <id>1</id> <text>Telephone</text> <

Compiling XML schema to Java with key/keyref identity constraints

浪尽此生 提交于 2019-12-19 10:05:21
问题 Lets say I have the following XML schema: <xs:schema xmlns="http://www.example.com/data" xmlns:data="http://www.example.com/data" targetNamespace="http://www.example.com/data" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="data"> <xs:complexType> <xs:all> <xs:element name="countries"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="country" type="country"/> </xs:choice> </xs:complexType> </xs:element> <xs

JAXB inheritance in MOXY

大兔子大兔子 提交于 2019-12-19 08:54:16
问题 I have two classes: package a; class A { private <type> fieldOfClassA; // getters, and setters } package b; class B extends A{ private <type> fieldOfClassB; // getters, and setters } I want to marshal class B to an xml element and add the attribute fieldOfClassB, and fieldOfClassA from class A but it prints the following warning message during marshalling: Ignoring attribute [fieldOfClassA] on class [b.B] as no Property was generated for it. Note that the two class is from two different