simple-framework

SimpleFramwork XML: Element with Inner Text and Child Elements

风格不统一 提交于 2019-12-06 08:30:58
I have the following situtation in deserializing xml using SimpleFramework of specific format that cannot be changed... <Question ID="Q1"> THIS INNER TEXT IS THE ISSUE <Criteria Type="Normal" Source="OEM"> <Value Type="0">45.7</Value> <Value Type="100">42.7</Value> </Criteria> <Criteria Type="Impact" Source="OEM"> <Value Type="0">45.7</Value> <Value Type="100">42.7</Value> </Criteria> <!-- CRITERIA CAN HAVE ANY NUMBER --> </Question> and here is the class I wrote for Question @Root (name="Question") public class Question { @Attribute (name="ID") private String id; @ElementList (inline=true,

can't parse xml with CDATA block using SimpleXML and Retrofit

妖精的绣舞 提交于 2019-12-06 07:33:03
i can't seem to get value from only element with CDATA block, only return empty value, hope you guys can help, this is my xml data: <response> <error> <![CDATA[OK]]> </error> <limit>10</limit> <offset>0</offset> <number_of_page_results>10</number_of_page_results> <number_of_total_results>481312</number_of_total_results> <status_code>1</status_code> <results> <issue> <aliases/> <api_detail_url> <![CDATA[http://comicvine.gamespot.com/api/issue/4000-6/]]> </api_detail_url> <cover_date> <![CDATA[1952-10-01]]> </cover_date> <date_added>2008-06-06 11:10:16</date_added> <date_last_updated>2015-07-11

SimpleXML enum case-sensitivity

依然范特西╮ 提交于 2019-12-06 06:54:39
问题 I have been trying to create an XML using the simplexml library (v2.6.2) http://simple.sourceforge.net/home.php The XML I want to create has to hold an enum value, which should be case-sensitive. Following is the POJO : package pojos; public enum MyEnum { NEW("new"), OLD("old"); private final String value; MyEnum(String v) { value = v; } public String value() { return value; } public static MyEnum fromValue(String v) { for (MyEnum c: MyEnum.values()) { if (c.value.equals(v)) { return c; } }

Simple XML framework on android, class attribute

我的未来我决定 提交于 2019-12-06 04:07:28
Ive got a weird problem with simplexml framework on android. Im trying to read and fill an object called weatherdata from a xml source. XML File (no control on this one): <weatherdata> <product class="pointData"> .... </product> </weatherdata> So my java file looks like : @Root(name = "weatherdata", strict=false) public class Weatherdata { @Element(name="product", required = true) protected ProductType product; But I get a very weird error : 01-14 14:22:28.919: W/System.err(18011): java.lang.ClassNotFoundException: pointData in loader dalvik.system.PathClassLoader If i try to class=ProductType

Cannot get SOAP envelope body using Retrofit 2 and Simple XML Converter

。_饼干妹妹 提交于 2019-12-06 01:44:36
问题 I am using Retrofit 2.2.0 and Retrofit SimpleXML Converter 2.2.0. I added SimpleXmlConverter to the Retrofit instance with the addConverterFactory method. The problem is that when I receive the response, it gets the following error java.lang.RuntimeException: org.simpleframework.xml.core.ElementException: Element 'Body' does not have a match in class ResponseEnvelope at line 1 I should get an XML response like this: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

simpleframework, deserializing an empty element to an empty string instead of null

倾然丶 夕夏残阳落幕 提交于 2019-12-05 22:58:48
问题 I use simpleframework (http://simple.sourceforge.net/) in a project for my serializing / deserializing needs, but it doesn't work as expected (well, atleast not how I expect) when dealing with empty / null String values. If I serialize an object with an empty String value, it will show as an empty xml element. So this MyObject object = new MyObject(); object.setAttribute(""); // attribute is String would serialize as <object> <attribute></attribute> </object> But deserializing that empty

Should I consider the Simple XML Framework for Java?

感情迁移 提交于 2019-12-05 21:28:16
问题 Lately the Simple XML Framework gained popularity and some sites are presenting it. I am thinking about replacing Apache Xerces-J with a new framework and I am considering Simple to be its successor. Do you have any experiences with Simple ? What are its advantages and disadvantages? Is it recommended for the use with enterprise software/within a servlet container or application server? 回答1: JAXB is the enterprise standard for converting objects to/from XML. There are many implementations:

SimpleXML framework: element with element or text

柔情痞子 提交于 2019-12-04 16:12:08
I must to parse XML which can have two forms: <Command><Variable/></Command> or: <Command>some text</Command> How can I do this? When I try to declare both @Element and @Text in class responsible for Command parsing then exception is thrown when I try to parse XML to instance of this class. My current version of code: @Root(name = "Command", strict = false) public class AppCommand { @Element(name = "Variable", required = false) @Getter private Variable variable; @Text(required = false) @Getter private String content; } And exception is: Text annotation @org.simpleframework.xml.Text(required

SimpleXML enum case-sensitivity

前提是你 提交于 2019-12-04 14:46:29
I have been trying to create an XML using the simplexml library (v2.6.2) http://simple.sourceforge.net/home.php The XML I want to create has to hold an enum value, which should be case-sensitive. Following is the POJO : package pojos; public enum MyEnum { NEW("new"), OLD("old"); private final String value; MyEnum(String v) { value = v; } public String value() { return value; } public static MyEnum fromValue(String v) { for (MyEnum c: MyEnum.values()) { if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); } } Following is the serializer code : import java.io.File;

Cannot get SOAP envelope body using Retrofit 2 and Simple XML Converter

寵の児 提交于 2019-12-04 06:54:19
I am using Retrofit 2.2.0 and Retrofit SimpleXML Converter 2.2.0. I added SimpleXmlConverter to the Retrofit instance with the addConverterFactory method. The problem is that when I receive the response, it gets the following error java.lang.RuntimeException: org.simpleframework.xml.core.ElementException: Element 'Body' does not have a match in class ResponseEnvelope at line 1 I should get an XML response like this: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <ns:autenticarUsuarioPorEmailResponse xmlns:ns="http://business.curitiba.org.br"> <ns