jaxb

How to return a long property as JSON string value with JAXB

巧了我就是萌 提交于 2020-01-04 04:11:12
问题 I have a Java class annotated with @XmlRootElement . This Java class has a long property ( private long id ) that I want to return to a JavaScript-client. I create the JSON as follows: MyEntity myInstance = new MyEntity("Benny Neugebauer", 2517564202727464120); StringWriter writer = new StringWriter(); JSONConfiguration config = JSONConfiguration.natural().build(); Class[] types = {MyEntity.class}; JSONJAXBContext context = new JSONJAXBContext(config, types); JSONMarshaller marshaller =

jaxb @XmlIDREF @XmlID work amazingly

倖福魔咒の 提交于 2020-01-04 02:32:24
问题 jaxb @XmlIDREF @XmlID work amazingly my xml input is <dept> <courses> <course id="1" units="4" level="UNDERGRAD" name="Fundamentals of Programming"/> <course id="2" units="3" level="UNDERGRAD" name="Advanced Programming"> <pre>1</pre> </course> <course id="3" units="3" level="UNDERGRAD" name="Discrete Mathematics"> <pre>1</pre> </course> <course id="4" units="3" level="UNDERGRAD" name="Data Structures"/> <course id="5" units="3" level="UNDERGRAD" name="Database Systems"> <pre>4</pre> <pre>2<

reordering XML tags

此生再无相见时 提交于 2020-01-04 01:50:55
问题 I am trying to implement something which is for writing back the content tree of java object to XML file (object marshalling) (I know there are a lot of APIs for doing that but its required from me), I want to let the user to reorder the tags as he/she wants, I know using annotation like what JAXB has may solve that, but I think using annotation may cause a lot of pain. it will be so helpful if any one could offer any good approach. Thanks 回答1: Note: I'm the EclipseLink JAXB (MOXy) lead and a

java jaxb simple parsing is requiring @XmlAccessorType(XmlAccessType.FIELD) annotation

断了今生、忘了曾经 提交于 2020-01-03 21:02:57
问题 I am trying to parse an xml to java objects, I've read and implemented the following tutorial: http://www.vogella.com/articles/JAXB/article.html (works perfectly) But when I create my own clases (similar to those in the tutorial) I get: Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Class has two properties of the same name "clienteList" Unless I use @XmlAccessorType(XmlAccessType.FIELD) on class Clientes

java jaxb simple parsing is requiring @XmlAccessorType(XmlAccessType.FIELD) annotation

荒凉一梦 提交于 2020-01-03 21:02:52
问题 I am trying to parse an xml to java objects, I've read and implemented the following tutorial: http://www.vogella.com/articles/JAXB/article.html (works perfectly) But when I create my own clases (similar to those in the tutorial) I get: Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Class has two properties of the same name "clienteList" Unless I use @XmlAccessorType(XmlAccessType.FIELD) on class Clientes

Convert Soap XML response to Object

眉间皱痕 提交于 2020-01-03 20:03:35
问题 i'm new to working with SOAP API's I have a soap response from an API <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <LoginResponse xmlns="http://test.org/ADMail_Service"> <LoginResult> <ErrorMessage>Successful login</ErrorMessage> <Status>true</Status> </LoginResult> </LoginResponse> </soapenv:Body> </soapenv:Envelope> I'm trying to transform this into an object. From reading articles online I'm trying to use JAXB to do this, but my object is

Convert Soap XML response to Object

夙愿已清 提交于 2020-01-03 19:59:55
问题 i'm new to working with SOAP API's I have a soap response from an API <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <LoginResponse xmlns="http://test.org/ADMail_Service"> <LoginResult> <ErrorMessage>Successful login</ErrorMessage> <Status>true</Status> </LoginResult> </LoginResponse> </soapenv:Body> </soapenv:Envelope> I'm trying to transform this into an object. From reading articles online I'm trying to use JAXB to do this, but my object is

Checking a java value with an xml schema

北城余情 提交于 2020-01-03 17:08:14
问题 is it possible to check a value in a java object with some rules in a xml schéma ? For exemple, I have a String txt = "blablabla" , and I should verify if it's ok for <xs:element name="foo" type="string32"/> , with string32 a restriction to 32 caract. length max. Is it possible ? If it's not possible with xml schema and jaxb, is there other schema langage which is possible ? Thanks. 回答1: You could do the following: import java.io.File; import javax.xml.XMLConstants; import javax.xml.bind

Parsing/Deserialize XML to JavaObjects

拈花ヽ惹草 提交于 2020-01-03 16:57:21
问题 i started a small new project and i want to deserialize objects from XML. i created a xsd: http://pastebin.com/n1pwjRGX and an example XML File : <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <hdb> <country code="DE"> <variableHoliday daysAfterEaster="49" name="PENTECOAST" /> <fixedHoliday month="JANUARY" day="1" name="NEWYEAR" /> <region code="sa"> <fixedHoliday month="APRIL" day="1" name="FUNNYDAY" /> <variableHoliday daysAfterEaster="0" name="EASTERSUNDAY" /> </region> <region

@xmlschema jaxb package-info.java compilation error

跟風遠走 提交于 2020-01-03 16:57:16
问题 I'm trying to use annotations at package level but I get compilation erros from Eclipse. I have a class Head with the following package/annotation: @javax.xml.bind.annotation.XmlSchema ( xmlns = { @javax.xml.bind.annotation.XmlNs(prefix = "com", namespaceURI="http://es.indra.transporte.common"), @javax.xml.bind.annotation.XmlNs( namespaceURI="http://www.w3.org/2001/XMLSchema") }, namespace = "http://es.indra.transporte.common", elementFormDefault = javax.xml.bind.annotation.XmlNsForm