unmarshalling

How to convert Date(ActionScript 3) to java.util.Date through a xml?

我的未来我决定 提交于 2019-11-29 12:50:24
I want to convert Date(ActionScript 3) to java.util.Date through a xml. First, write a user defined ActionScript class like this. public class User { public function User() { userDate = new Date(); } public var id:String = null; public var password:String = null; public var userDate:Date = null; } Second, create its instance and set each of values, so it converts ActionScript class to a xml for using XMLEncoder having its schema file. This is the result xml, and send this xml to a server for using a HTTPService. <User> <id>system</id> <password>manager</password> <userDate>Fri Jan 14 09:02:17

Golang marshal dynamic xml element name

我是研究僧i 提交于 2019-11-29 11:56:42
The xml file consists of two elements. Those elements have the same structure except for one element name. I tried to set a value to the XMLName property, but that didn't work. Xml: <!-- first element --> <PERSON> <ELEM1>...</ELEM1> <ELEM2>...</ELEM2> <ELEM3>...</ELEM3> <ELEM4>...</ELEM4> </PERSON> <!-- second element --> <SENDER> <ELEM1>...</ELEM1> <ELEM2>...</ELEM2> <ELEM3>...</ELEM3> <ELEM4>...</ELEM4> </SENDER> Is it possible to define a struct such that the element name is dynamic? type Person struct { XMLName string `xml:"???"` // How make this dynamic? e1 string `xml:"ELEM1"` e2 string

How to set custom ValidationEventHandler on JAXB unmarshaller when using annotations

人盡茶涼 提交于 2019-11-29 10:44:44
We’re using JAX-WS in combination with JAXB to receive and parse XML web service calls. It’s all annotation-based, i.e. we never get hold of the JAXBContext in our code. I need to set a custom ValidationEventHandler on the unmarshaller, so that if the date format for a particular field is not accepted, we can catch the error and report something nice back in the response. We have a XMLJavaTypeAdapter on the field in question, which does the parsing and throws an exception. I can’t see how to set a ValidationEventHandler onto the unmarshaller using the annotation-based configuration that we

Partial Unmarshalling of an XML using JAXB to skip some xmlElement

老子叫甜甜 提交于 2019-11-29 10:26:13
问题 I want to unmarshal an XML file to java object using JAXB. The XML file is very large and contains some nodes which I want to skip in some cases to improve performance as these elements are non editable by client java program. A sample XML is as follows: <Example id="10" date="1970-01-01" version="1.0"> <Properties>...</Properties> <Summary>...</Summary> <RawData> <Document id="1">...</Document> <Document id="2">...</Document> <Document id="3">...</Document> ------ ------ </RawData> <Location

Java Code to XML/XSD without using Annotation

我们两清 提交于 2019-11-29 09:30:21
问题 I need to marshall and unmarshall a Java class to XML. The class in not owned by me, that I cannot add anotations so that I can use JAXB. Is there a good way to convert the Java to XML with the given contraint? Also, thought a tool may be helpful, but I would be more intersted it there is some Java API to do the same. 回答1: Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group. DOMAIN MODEL I will use the following domain model for this answer. Note how

JAXB: how to make JAXB NOT to unmarshal empty string to 0

为君一笑 提交于 2019-11-29 07:02:29
I have a DTO class with a field such as: @XmlAttribute @NotNull private Integer number = null; I'm trying to unmarshal xml such as ... number="" ... I need the nuber field to stay null, so that a validation exception would be thrown. Instead JAXB unmarshals it as 0. How can I make it to behave correctly ? Arguable, it is behaving correctly. number="" does not mean null, it's an empty String, and JAXB is having to try and handle that correctly, and it decides that the closest thing to empty string for an Integer data type is zero. If you wanted a null , then the number attribute should be

Class not found when Unmarshalling Android Intent Parcelable

强颜欢笑 提交于 2019-11-29 05:37:13
I have a ArrayList that I am passing between activities . In this ArrayList are objects made from a class that has four variables in it. One of those variables is another ArrayList<object> that is from another class . I have implemented Parcelable on both and am pretty sure I have completed the parcelable methods properly. Here are the errors: Errors: 03-18 02:37:27.063: D/dalvikvm(3249): GC_FOR_ALLOC freed 82K, 6% free 3020K/3180K, paused 1ms, total 3ms 03-18 02:37:27.093: I/dalvikvm-heap(3249): Grow heap (frag case) to 3.626MB for 635808-byte allocation 03-18 02:37:27.103: D/dalvikvm(3249):

How to unmarshall an array of different types correctly?

好久不见. 提交于 2019-11-29 03:37:44
As long as I have key-value pairs unmarshalling is pretty straight forward but how would I unmarshall an array of different types in different order? The single elements are well defined and known but the order is not. I can not come up with a beautiful solution. Would I try and error over all elements? Is there some kind of union type that could do that for me? playground version package main import ( "encoding/json" "fmt" ) var my_json string = `{ "an_array":[ "with_a string", { "and":"some_more", "different":["nested", "types"] } ] }` type MyInner struct { And string Different []string }

Unmarshalling generic list with JAXB

社会主义新天地 提交于 2019-11-28 21:52:28
I've a service that returns this XML: <?xml version="1.0" encoding="UTF-8"?> <response> <status>success</status> <result> <project> <id>id1</id> <owner>owner1</owner> </project> <project> <id>id2</id> <owner>owner2</owner> </project> </result> or <?xml version="1.0" encoding="UTF-8"?> <response> <status>success</status> <result> <user> <id>id1</id> <name>name1</name> </user> <user> <id>id2</id> <name>name2</name> </user> </result> I want to unmarshall the retrieved XML using these classes: Result : @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Response<T> { @XmlElement

How to create java object from 'anyType' returned from service using JAXB?

元气小坏坏 提交于 2019-11-28 21:21:23
A web service is returning an object defined by the WSDL to be: <s:complexType mixed="true"><s:sequence><s:any/></s:sequence></s:complexType> When I print out this object's class info, it comes up as: class com.sun.org.apache.xerces.internal.dom.ElementNSImpl But I need to unmarshall this object as an object of the following class: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "info", "availability", "rateDetails", "reservation", "cancellation", "error" }) @XmlRootElement(name = "ArnResponse") public class ArnResponse { } I know the response is correct, since I know