jaxb2

JAXB lists namespaces in root element (-> each element)

妖精的绣舞 提交于 2019-12-02 01:19:55
问题 By default, jaxb 2 lists all (all possible required) namespaces in root element during marshalling: Is there a way to describe namespace in each element instead of root element ?: It also solves the problem of "unnecessary namespaces", which is also important in my case. Any suggestions appreciated. 来源: https://stackoverflow.com/questions/2385405/jaxb-lists-namespaces-in-root-element-each-element

Unable to understand JAXB Unmarshalling behaviour

陌路散爱 提交于 2019-12-02 01:00:46
Reference to my previous post . I have following code which is reading XML from the file. logger.log(Level.INFO, "testSchemaChange"); JAXBContext jaxbContext = JAXBContext.newInstance("com.store.web.ws.v1.model"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); JAXBElement<BookType> jeBookType = (JAXBElement<BookType>) unmarshaller.unmarshal(new File (BOOK_XML)); BookType bookType = jeBookType.getValue(); logger.log(Level.INFO, "Book recieved: " + bookType.getISBN()); I am seeding an XML with Book as my root element instead of BookList . This example is working fine as long as i

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

廉价感情. 提交于 2019-12-02 00:28:54
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 its own java namespace. After that the executios of A.xsd and B.xsd should know about the stuff generated

JAXB2: Mapping nested elements into the same Java class

点点圈 提交于 2019-12-01 19:20:14
I'm having trouble trying to map nested elements into the same Java class. XML What I'm trying to do here is to set id attribute and text element into SlideText class. <module name="test project"> <slide id="1"> <layout> <text>hello</text> </layout> </slide> </module> Module class @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Module { @XmlAttribute private String name; @XmlElements({ @XmlElement(name = "slide", type = SlideText.class) }) private Slide slide; } Slide class @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public abstract class Slide { @XmlAttribute

com.sun.istack.SAXException2 : Instance … is substituting “java.lang.Object”, but … is bound to an anonymous type

[亡魂溺海] 提交于 2019-12-01 17:24:43
I'm upgrading a project to jaxb 2.2.7 from version 1.x. I've got the app working some of the time, but on some responses I see this: java.lang.RuntimeException: javax.xml.bind.MarshalException - with linked exception: [com.sun.istack.SAXException2: Instance of "com.mycompany.global.er.decoupling.binding.response.PricePointType$BalanceImpactRates$BalanceImpactRate" is substituting "java.lang.Object", but "com.mycompany.global.er.decoupling.binding.response.PricePointType$BalanceImpactRates$BalanceImpactRate" is bound to an anonymous type.] This worked fine in jaxb 1.0. I've no idea what the

com.sun.istack.SAXException2 : Instance … is substituting “java.lang.Object”, but … is bound to an anonymous type

孤者浪人 提交于 2019-12-01 16:10:19
问题 I'm upgrading a project to jaxb 2.2.7 from version 1.x. I've got the app working some of the time, but on some responses I see this: java.lang.RuntimeException: javax.xml.bind.MarshalException - with linked exception: [com.sun.istack.SAXException2: Instance of "com.mycompany.global.er.decoupling.binding.response.PricePointType$BalanceImpactRates$BalanceImpactRate" is substituting "java.lang.Object", but "com.mycompany.global.er.decoupling.binding.response.PricePointType$BalanceImpactRates

jaxb2-maven-plugin only executing first execution

点点圈 提交于 2019-12-01 15:20:20
I'm trying to convert multiple XSDs to POJOs in different packages using JAXB using the jaxb-maven plugin. I've set it up to use multiple execution blocks, the first execution block executes, then I get a message saying: No changes detected in schema or binding files This is an extract from my pom.xml: ... <build> <pluginManagement> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId> <version>1.5</version> </plugin> </pluginManagement> <plugins> <!-- JAXB GENERATOR PLUGIN --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin<

Reading the Custom XML Processing Instruction through JAXB Unmarshelling

99封情书 提交于 2019-12-01 11:03:33
Is there a way to read the custom xml processing instruction when unmarshelling through JAXB. Example, <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <customer > <id>100</id> <age>40</age> <name>Sachin</name> </customer> <?CustomExtn Number="AC7654321" LastName="Szychlinski"?> In the above xml when unmarshelling, the CustomExtn is not present after unmarshelling. Is there a way i can read this in the Java Class? You can use JAXB with StAX to get the Processing Instruction data: Demo import javax.xml.bind.*; import javax.xml.stream.*; import javax.xml.transform.stream.StreamSource;

How to marshal a JAXB class instance as its superclass

▼魔方 西西 提交于 2019-12-01 09:04:30
问题 Is it possible to marshal a JAXB annotated class instance as its superclass (which is also a JAXB annotated class)? @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "BenamningTYPE", propOrder = {"benamningId"}) @XmlSeeAlso({MoreDetailedBenamningTYPE.class}) public class BenamningTYPE { ... @XmlElement(name = "BenamningId", required = true) protected IdentifierTYPE benamningId; ... } And the extended type: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "MoreDetailedBenamningTYPE",

JAXB marshalling exception javax.xml.stream.FactoryConfigurationError running with Java 5

感情迁移 提交于 2019-12-01 08:47:47
I am trying a simple JAXB marshaling in my JUit test class and I am using Java 5. I get this error while running the test. javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.XMLOutputFactoryBase not found I have added the following dependencies in my pom. <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.2</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-xjc</artifactId> <version>2.2</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId>