jaxb2

JAXB appending unneeded namespace declarations to tags

北战南征 提交于 2019-12-03 06:55: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:auth> instead of: <ns:auth xmlns:ns="urn:ietf:params:xml:ns:ilf-auth>compton@ilf</ns:auth> Is there any

@XmlRegistry - how does it work?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 04:36:41
问题 I have found some examples of JAXB2 @XmlRegistry over the internet but no good in-depth tutorials that talk about the concept of using @XmlRegistry with @XmlElementDecl , wonder if its a concept not much explored in general. Anyways here is my question, first some sample classes that I am using to unmarshall an xml using JAXB: The main class I am trying to unmarshal using JAXB - Employee.java package com.test.jaxb; import java.util.List; import javax.xml.bind.JAXBElement; import javax.xml

Why does JAXB sometimes map to JAXBElement?

偶尔善良 提交于 2019-12-02 22:43:27
There is a placeholder answer over at the unofficial guide with a link to an article which (to me) seems quite unrelated. I use XJC to generate my JAXB classes and while most of them map to each other as expected, some elements get mapped to JAXBElement<Foo> . This is most annoying for graphs with cycles, where sometimes the parent node of a Foo element will be the JAXBElement<Foo> , which doesn't itself have a parent property, breaking the cycle. I can think of various workarounds, but it would be much nicer if someone could explain this behaviour to me. Why does JAXB sometimes map a <Foo>

@XmlRegistry - how does it work?

江枫思渺然 提交于 2019-12-02 17:47:18
I have found some examples of JAXB2 @XmlRegistry over the internet but no good in-depth tutorials that talk about the concept of using @XmlRegistry with @XmlElementDecl , wonder if its a concept not much explored in general. Anyways here is my question, first some sample classes that I am using to unmarshall an xml using JAXB: The main class I am trying to unmarshal using JAXB - Employee.java package com.test.jaxb; import java.util.List; import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlElementDecl; import javax.xml.bind.annotation.XmlRegistry; import javax.xml.bind

jaxb when xsi:nil=true if any child element exists it is still showing

自闭症网瘾萝莉.ら 提交于 2019-12-02 09:23:56
I have the below xml output, how can we hide the child element (endDate) when parent element has attribute xsi:nil=true even child element is nillable=true? //XML Output <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <snapshots xmlns:xsi="w3.org/2001/XMLSchema-instance"; xmlns:ns3="ws.mycompany.com"; mask="PAC"> <Offers> <Offer xsi:type="wsMarketingOfferOP" entityId="1234" xsi:nil="true"> <endDate xsi:nil="true"/> </Offer> </Offers> </snapshots> // Snapshots class @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "OffersElement"}) @XmlRootElement(name =

Flexible marshalling with JAXB

别等时光非礼了梦想. 提交于 2019-12-02 05:15:43
问题 I'm hoping to have a flexible way of marshalling objects. A verbose version for single objects and a less-verbose version for multiple object versions. For example, consider my department model: GET /locations/1: <location id='1'> <link rel="self" href="http://example.com/locations/1"/> <link rel="parent" href="http://example.com/serviceareas/1"/> <name>location 01</name> <departments> <department id='1'> <link rel="self" href="http://example.com/departments/1"/> <name>department 01</name> <

Complex XML using Spring Batch; StaxEventItemWriter ; Jaxb2Marshaller

核能气质少年 提交于 2019-12-02 05:12:07
问题 I need to write a slightly complex XML using Spring Batch. Can anyone please help me with the appropriate Spring configuration? Below is the Output the process requires. <XML> <USERLIST ID="something" NAME="Sample"> <USER ID="userID" NAME="Name"/> <USER ID="userID" NAME="Name"/> ........ </USERLIST> <XML> The 'UserList' in the XML above only needs to occur once This is the spring configuration I have so far. <bean id="userXMLWriter" class="org.springframework.batch.item.xml

maven-jaxb2-plugin episode of same project in Maven, possible?

心已入冬 提交于 2019-12-02 04:01:59
问题 I have a basic.xsd and two other A.xsd and B.xsd . A.xsd and B.xsd get converted into two different java packages, therefore I need two Maven executions of the same plugin. Both XSDs refer to basic.xsd for some shared classes. If basic.xsd would come from a different project I could solve this problem really nicely through using episodes to prevent duplicate classes. But how can I refer to the current project? My first execution of the plugin is to generate only classes from basic.xsd into

Build non trivial XML file with StaxEventItemWriter

柔情痞子 提交于 2019-12-02 01:56:33
问题 I need to dump content of some database tables to XML file with this structure <dump> <table name="tableName1"> <records> <record> <first column name>value</first column name> <second column name>value</second column name> <third column name>value</third column name> </record> <record>...</record> </records> </table> <table name="tableName2">...</table> </dump> The real number of records for every table in unknown, so I can't store all data for a single table in memory and dump to XML. My job

Complex XML using Spring Batch; StaxEventItemWriter ; Jaxb2Marshaller

拈花ヽ惹草 提交于 2019-12-02 01:29:38
I need to write a slightly complex XML using Spring Batch. Can anyone please help me with the appropriate Spring configuration? Below is the Output the process requires. <XML> <USERLIST ID="something" NAME="Sample"> <USER ID="userID" NAME="Name"/> <USER ID="userID" NAME="Name"/> ........ </USERLIST> <XML> The 'UserList' in the XML above only needs to occur once This is the spring configuration I have so far. <bean id="userXMLWriter" class="org.springframework.batch.item.xml.StaxEventItemWriter"> <property name="resource" value="file:outputs/users.xml" /> <property name="encoding" value="ISO