xstream

In JAXB or Xstream is it possible to Filter out certain Child Elements on Type/value during unmarshall

自作多情 提交于 2019-12-11 01:10:55
问题 Hope everyone is well, quick question to see if anyone has any feedback. I was experimenting with both JaxB and Xstream over last two days. I was basically using the XML libraries to marshal and unmarshal XML to / from Java objects. Now this was a very simple task which I got working very quickly. However, the XML I want to unmarshal into a list of Java objects is very long and contains many child elements that could be ignored and not put into the list of java objects. For example the xml

Reading XML value to populate Java variable

六月ゝ 毕业季﹏ 提交于 2019-12-11 00:49:10
问题 I am working with xstream to convert some XML into Java objects. The XML pattern is of the below format: <Objects> <Object Type="System.Tuning" >4456</Object> <Object Type="System.Lag" >7789</Object> </Objects> Basically the parent Objects tag can have n number of Object tags. For this I have modelled my class like this: class ParentResponseObject { List <ResponseObject>responseObjects = new ArrayList<ResponseObject>(); public ParentResponseObject() { // TODO Auto-generated constructor stub }

Classloader issue in WebSphere Application server 7.x

孤人 提交于 2019-12-10 21:47:27
问题 com.ibm.xml.xlxp2.api.stax.XMLOutputFactoryImpl incompatible with javax.xml.stream.XMLOutputFactory com.ibm.xml.xlxp2.api.stax.XMLOutputFactoryImpl incompatible with javax.xml.stream.XMLInputFactory Removed "jsr173_1.0_api.jar", "stax-api-1.0-2.jar" that has "XMLOutputFactory" and "XMLInputFactory" classes from APP(Web-inf/lib) to avoid any collision with server versions. Also changed the war class loader order to "parent last" and policy to "Single class loader for application" in WebSphere

Spring MVC 3.2 - XStreamAlias Ignored

天涯浪子 提交于 2019-12-10 20:54:32
问题 Person.java: @XStreamAlias("person") public class Person { @XStreamAlias("id") private Long personProfileId; private String lastName; private String firstName; private String middleName; private String nameSuffix; private String namePrefix; // etc ... } Spring configuration: <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"> <property name="favorPathExtension" value="false" /> <property name="favorParameter" value="true" />

Xstream's jodatime Local Date display

亡梦爱人 提交于 2019-12-10 20:28:14
问题 I'm using xstrem to serialise a jodatime local date into xml. However when output the generated xml the LocalDate is not in an easily readable format. See below: <date> <iLocalMillis>1316563200000</iLocalMillis> <iChronology class="org.joda.time.chrono.ISOChronology" reference="../../tradeDate/iChronology"/> Any ideas how I can get xstream to display the date in a format that won't drive me up the wall? 回答1: Here's what I have used successfully. I believe I used the info at the link mentioned

Intercepting Xstream while parsing XML

*爱你&永不变心* 提交于 2019-12-10 10:49:27
问题 Suppose I have a simple Java class like this: public class User { String firstName; String lastName; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } } Now, suppose I want to parse the following XML: <user> <firstName>Homer</firstName> <lastName>Simpson</lastName> </user> I can do this with no

How can I disable unnecessary escaping in XStream?

99封情书 提交于 2019-12-09 17:41:29
问题 XStream by default unnecessarily escapes > , " ... etc. Is there a way to disable this (and only escape < , & )? 回答1: This is the result of the default PrettyPrintWriter. Personally, I like to escape both < and >. It makes the output look more balanced. If you want canonicalized XML output, you should use the C14N API provided in Java. If the streamed content includes XML, CDATA is a better option. Here is how I did it, XStream xstream = new XStream( new DomDriver() { public

Unwanted elements in XML via XSTREAM

夙愿已清 提交于 2019-12-08 13:50:23
问题 I am new to XStream I have following DTO @XStreamAlias("outline") public class OutlineItem implements java.io.Serializable { private static final long serialVersionUID = -2321669186524783800L; @XStreamAlias("text") @XStreamAsAttribute private String text; @XStreamAlias("removeMe") private List<OutlineItem> childItems; } once i do XStream stream = new XStream(); stream.processAnnotations(OutlineItem.class); stream.toXML(outlineItem); i get this as my output text <outline text="Test"> <removeMe

Converting XML to Java Map<String, Integer> with XStream

故事扮演 提交于 2019-12-08 04:14:17
问题 I'm converting XML to a Java Map with XStream. Each time I solve one problem, I run into another. Incredibly frustrating. Anyways, the XML looks something like this: <?xml version="1.0" encoding="UTF-8" ?> <root> <Durapipe type="int">1</Durapipe> <EXPLAIN type="int">2</EXPLAIN> <woods type="int">2</woods> <hanging type="int">3</hanging> <hastily type="int">2</hastily> <localized type="int">1</localized> <Schuster type="int">5</Schuster> .... </root> The Java in my main that I'm using to

Cucumber not serializing date string from datatable in feature file to a LocalDate field inside my pojo

房东的猫 提交于 2019-12-08 03:36:21
问题 Im trying to figure out how to parse date fields from my cucumber feature files in my step definitions. class Person{ String name LocalDate dob } scenario: do something with people Given list of people: |name|dob| | john| 20-09-2001| @Given("^list of people:") public void doSomething(List<Person> people) { } Please note i have no access to the Person class, Im sure i have to either write my own converter or register a converter written by someone from some library, after searching around the