simple-support Mailing List for Simple (Page 24)
Brought to you by:
niallg
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
(2) |
Mar
(2) |
Apr
(13) |
May
(13) |
Jun
(27) |
Jul
(4) |
Aug
(14) |
Sep
(7) |
Oct
|
Nov
(6) |
Dec
(24) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
|
Feb
(21) |
Mar
(10) |
Apr
(15) |
May
(24) |
Jun
(24) |
Jul
(30) |
Aug
(5) |
Sep
(19) |
Oct
(27) |
Nov
(16) |
Dec
(24) |
| 2009 |
Jan
(34) |
Feb
(24) |
Mar
(35) |
Apr
(26) |
May
(8) |
Jun
(17) |
Jul
(28) |
Aug
(31) |
Sep
(36) |
Oct
(35) |
Nov
(20) |
Dec
(16) |
| 2010 |
Jan
(40) |
Feb
(21) |
Mar
(47) |
Apr
(45) |
May
(34) |
Jun
(68) |
Jul
(46) |
Aug
(39) |
Sep
(47) |
Oct
(20) |
Nov
(42) |
Dec
(13) |
| 2011 |
Jan
(41) |
Feb
(16) |
Mar
(32) |
Apr
(44) |
May
(28) |
Jun
(35) |
Jul
(37) |
Aug
(33) |
Sep
(60) |
Oct
(20) |
Nov
(35) |
Dec
(23) |
| 2012 |
Jan
(34) |
Feb
(23) |
Mar
(34) |
Apr
(21) |
May
(48) |
Jun
(24) |
Jul
(31) |
Aug
(39) |
Sep
(25) |
Oct
(10) |
Nov
(27) |
Dec
(28) |
| 2013 |
Jan
(32) |
Feb
(24) |
Mar
(24) |
Apr
(9) |
May
(4) |
Jun
(6) |
Jul
(2) |
Aug
(5) |
Sep
|
Oct
(5) |
Nov
(1) |
Dec
(12) |
| 2014 |
Jan
(14) |
Feb
(16) |
Mar
(5) |
Apr
(3) |
May
(2) |
Jun
(8) |
Jul
(2) |
Aug
|
Sep
(6) |
Oct
|
Nov
(6) |
Dec
|
| 2015 |
Jan
(3) |
Feb
(15) |
Mar
(7) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
(1) |
| 2016 |
Jan
|
Feb
(6) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2019 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Jang-Soo L. <jan...@gm...> - 2011-12-02 05:35:49
|
Hello all, I just wanted to start by saying that using this framework has been really helpful so far. I'm trying to do something that might be somewhat non-standard. Here's the general idea: I want to deserialize XML into objects which all might have a certain subtype (not sub in terms of inheritance, but just as a separate class) as a field. An instance of that subtype would have information which would tell me where to get information from. The XML might look like many things, but they'd all potentially have one or more instances of a SubType within the hierarchy (some examples below). I'd have classes defined for each of these items, but I would like to shy away from writing multiple converters (Doesn't seem to have a good way to do this with one, but I might be mistaken), and my attempts at writing a custom Strategy are falling a bit flat. Part of it seems to be that when I write my own strategy and plug it into the Persister's constructor, the strategy's write code seems to be working as expected (can examine the object, look through the object via reflection for fields of type SubType and write XML I want to do), but the read code does not seem to work (Even though I've implemented Value and instantiate the innerValue via reflection and set the innerValue's properties, and then set the original Value's innerValue, it does not seem to stick). The read code is being run, I am sure of that [I see debug statements being hit], but it seems that whether I return null or an instantiated Value implementation from read, the Persister is choosing a different strategy [or does something else] to override the results of the custom strategy. Is there a good way to choose to override a default strategy? Alternatively, is there a better way to do this than writing multiple converters [without resorting to writing a converter for Object] and/or working with the strategy? I've also looked at Visitor, but I don't think that's what I want because I want to work with the object that's getting deserialized. Thanks in advance! <SomeObject> <SomeField class="SubType"> <URL>http://site/something.html</URL> </SomeField> </SomeObject> or it might look like <SomeObject> <SomeField class="SubType"> <URL>http://site/something.html</URL> </SomeField> <SomeField class="SubType"> <URL>http://site/something.html</URL> </SomeField> <SomeField class="SubType"> <URL>http://site/something.html</URL> </SomeField> </SomeObject> or it might look like <SomeItem> <SomeObject> <SomeField class="SubType"> <URL>http://site/something.html</URL> </SomeField> <SomeField class="SubType"> <URL>http://site/something.html</URL> </SomeField> <SomeField class="SubType"> <URL>http://site/something.html</URL> </SomeField> </SomeObject> </SomeItem> |
|
From: bubbleguuum <bub...@fr...> - 2011-12-01 22:19:21
|
Hi, I'm writing an Android app where XML parsing performance is important. The quicker, the better. Are there some things that can be disabled in parsing processing to make it faster ? Or some constructs that should be avoided ? I'm looking for any advice that can improve performance. I noticed that simple generate a lot of objects while parsing which in turn generate heavy garbage collection. Thanks! |
|
From: Shevek <sh...@an...> - 2011-11-29 02:41:27
|
Hi, I have a CustomArrayList which I would like to annotate in such a way that it gets replaced with a vanilla ArrayList in the serialized data. While the documentation refers to writeReplace() and shows an example of readResolve(), I cannot see an example of an equivalent of writeReplace, nor can I see how to do it without (e.g.) writing a Visitor or Converter or something to do heavy duty XML hackery on the OutputNode. Is there a simple answer, please? Thank you. S. |
|
From: Shevek <sh...@an...> - 2011-11-29 01:50:34
|
Hi,
public class PersisterFactoryTest {
@Root
public static class Foo {
private List<String> body;
public Foo(@ElementList(name = "body") List<String> body) {
this.body = body;
}
@ElementList(name = "body")
public List<String> getBody() {
return body;
}
}
@Test
public void testNewDeserializer() throws Exception {
List<String> body = new ArrayList<String>();
body.add(null);
body.add("index 1");
body.add(null);
body.add("index 3");
body.add(null);
Persister persister = new Persister();
persister.write(new Foo(body), System.out);
}
}
I get:
<foo>
<body class="java.util.ArrayList">
<string>index 1</string>
<string>index 3</string>
</body>
</foo>
Which deserializes to a different list without the nulls in it.
I like my nulls, they keep me warm on a cold winter's night, and make
sure that my array indices are still correct after deserialization. What
can I do to make them come back, please?
Funnily enough, arrays seem to work OK. Just not lists.
S.
|
|
From: Niall G. <gal...@ya...> - 2011-11-24 10:13:33
|
Take a look at org.simpleframework.xml.util.Dictionary, it can do this.
________________________________
From: Jason von Nieda <ja...@vo...>
To: sim...@li...
Sent: Wednesday, 23 November 2011 10:53 PM
Subject: [Simple-support] ElementMap without entry wrapper?
Hi folks, I am evaluating Simple for use as the configuration framework for an application I am writing. I am currently using XStream but I prefer Simple's explicit mapping vs. XStream's implicit mapping. I am trying to figure out how to emit a Map that does not include the redundant <entry> and key information.
Here is my test program:
==
package org.openpnp.app;
import java.io.StringWriter;
import java.util.HashMap;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.ElementMap;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
public class Test {
public static void main(String[] args) throws Exception {
Serializer serializer = new Persister();
StringWriter writer = new StringWriter();
serializer.write(new Machine(), writer);
System.out.println(writer.toString());
}
@Root
public static class Machine {
@ElementMap(attribute=true, key="id")
private HashMap<String, Head> heads = new HashMap<String, Head>();
public Machine() {
heads.put("1", new Head("1"));
heads.put("2", new Head("2"));
}
}
public static class Head {
@Attribute
private String id;
public Head(String id) {
this.id = id;
}
}
}
==
And the output:
==
<machine>
<heads>
<entry id="2">
<head id="2"/>
</entry>
<entry id="1">
<head id="1"/>
</entry>
</heads>
</machine>
==
And what I would prefer the output to look like:
==
<machine>
<heads>
<head id="2"/>
<head id="1"/>
</heads>
</machine>
==
I expect this to be possible because I am telling Simple that the key field is id. If it knows that, the entry element and it's id= attribute is redundant information. I am able to do this quite easily with XStream but I have not found a way to do it with Simple. Is it possible without writing my own Map converter?
Thanks,
Jason
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Jason v. N. <ja...@vo...> - 2011-11-23 23:54:18
|
Hi folks, I am evaluating Simple for use as the configuration framework for
an application I am writing. I am currently using XStream but I prefer
Simple's explicit mapping vs. XStream's implicit mapping. I am trying to
figure out how to emit a Map that does not include the redundant <entry>
and key information.
Here is my test program:
==
package org.openpnp.app;
import java.io.StringWriter;
import java.util.HashMap;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.ElementMap;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
public class Test {
public static void main(String[] args) throws Exception {
Serializer serializer = new Persister();
StringWriter writer = new StringWriter();
serializer.write(new Machine(), writer);
System.out.println(writer.toString());
}
@Root
public static class Machine {
@ElementMap(attribute=true, key="id")
private HashMap<String, Head> heads = new HashMap<String, Head>();
public Machine() {
heads.put("1", new Head("1"));
heads.put("2", new Head("2"));
}
}
public static class Head {
@Attribute
private String id;
public Head(String id) {
this.id = id;
}
}
}
==
And the output:
==
<machine>
<heads>
<entry id="2">
<head id="2"/>
</entry>
<entry id="1">
<head id="1"/>
</entry>
</heads>
</machine>
==
And what I would prefer the output to look like:
==
<machine>
<heads>
<head id="2"/>
<head id="1"/>
</heads>
</machine>
==
I expect this to be possible because I am telling Simple that the key field
is id. If it knows that, the entry element and it's id= attribute is
redundant information. I am able to do this quite easily with XStream but I
have not found a way to do it with Simple. Is it possible without writing
my own Map converter?
Thanks,
Jason
|
|
From: Niall G. <gal...@ya...> - 2011-11-23 07:41:27
|
You would need to write a Converter for this, there is no what to do this via the @ElementMap annotation. Try the @Convert annotation. ________________________________ From: Michael Daly <Mic...@Si...> To: "sim...@li..." <sim...@li...> Sent: Tuesday, 22 November 2011 9:28 PM Subject: [Simple-support] Parsing dynamic elements into a map We have some XML being returned as key-value pairs such that the element name is the key (and the inner text is the value). The keys (elements) are completely configurable, so the element (user, userName, address1, some_configurable_field) can be any text that a user defines. <patron> <user>31</user> <userName>IPA</userName> <address1> 1234 Lake Drive </address> <some_configurable_field> Configurable data </some_configurable_field> </patron> Is there a way to parse these values into a Map, such that: HashMap map = new HashMap(); key => value "user" => 31 "userName" => IPA "address1" => 1234 Lake Drive "some_configurable_field" => Configurable data for any dynamic element => value pair? Thanks any for any insight. Mike ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Michael D. <Mic...@Si...> - 2011-11-22 21:44:19
|
We have some XML being returned as key-value pairs such that the element name is the key (and the inner text is the value). The keys (elements) are completely configurable, so the element (user, userName, address1, some_configurable_field) can be any text that a user defines. <patron> <user>31</user> <userName>IPA</userName> <address1> 1234 Lake Drive </address> <some_configurable_field> Configurable data </some_configurable_field> </patron> Is there a way to parse these values into a Map, such that: HashMap map = new HashMap(); key => value "user" => 31 "userName" => IPA "address1" => 1234 Lake Drive "some_configurable_field" => Configurable data for any dynamic element => value pair? Thanks any for any insight. Mike |
|
From: Niall G. <gal...@ya...> - 2011-11-21 08:27:25
|
I think a transform would work better here. Sent from Yahoo!7 Mail on Android |
|
From: Niall G. <gal...@ya...> - 2011-11-17 10:31:15
|
You, could use a visitor to add it. Ill look in to a better solution. Sent from Yahoo!7 Mail on Android |
|
From: Ankit M. <ank...@ra...> - 2011-11-17 10:29:06
|
While putting it in one reference String I am escaping "".However in XML the same thing is not reflect..I used " to escape also..Still no ways... Is it possible to do??? On 11/12/2011 5:57 PM, Niall Gallagher wrote: > > > Try putting it all in the one reference string > > Sent from Yahoo!7 Mail on Android > > > ------------------------------------------------------------------------ > * From: * Ankit Murarka <ank...@ra...>; > * To: * <gal...@ya...>; > <sim...@li...>; > * Subject: * Specifying More than One Namespace without xmlns in XML > NameSpace > * Sent: * Sat, Nov 12, 2011 5:39:30 AM > > Hello All, > I am trying to do something like this:- > |<Test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Testing.xsd"> > > However when I used this| > |@Root(name="Test",strict=false) > @NamespaceList({ > @Namespace(reference="xsi=http://www.w3.org/2001/XMLSchema-instance"), > @Namespace(reference="xsi:noNamespaceSchemaLocation"="Testing.xsd") > }) > > I get two xmlns in my XML Namespace..Although it is understood that using two Namespace will generate two xmlns but how can > I generate the xsi:noNamespaceSchemaLocation in my xml.. > > I succeeded by using attribute Annotation inside my class but that is not what I want..It always better to specify things related to schema > before the beginning of the class..Also attribute is not made for that purpose.. > > Is it possible to do in simpleFramework. > > Thanks.. > | > -- Thanks& Regards, ----------------- Ankit Murarka Service Delivery Platform Landline:022-447-76595 |
|
From: Niall G. <gal...@ya...> - 2011-11-17 10:03:53
|
See the @Order annotation
________________________________
From: gato chalar <da...@gm...>
To: sim...@li...
Sent: Wednesday, 16 November 2011 8:49 PM
Subject: [Simple-support] positions of elements
Hi
I have a class like next one:
class A{
@Element
B b;
@Element
C c;
}
result at parsing:
<a >
<b>
<c>
</a>
How can I change the positions of elements?, in order to get:
<a >
<c>
<b>
</a>
Thanks a lot.
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Dawid W. <daw...@gm...> - 2011-11-17 07:22:08
|
There is no such thing as "declaration order" -- java reflection may (and does, depending on the jvm) return the fields/ methods in any order it likes to return it. http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getDeclaredMethods() "The elements in the array returned are not sorted and are not in any particular order." Dawid On Thu, Nov 17, 2011 at 7:20 AM, Jouni Latvatalo <Jou...@sa...> wrote: > Hi, > > By default the serialization of fields is done in declaration order, so the > simplest way would be to just declare C before B. If you need more control > see the Order –annotation in the documentation and tutorials. > > -J > > > On 16.11.11 22:49, "gato chalar" <da...@gm...> wrote: > > Hi > I have a class like next one: > class A{ > @Element > B b; > > @Element > C c; > } > > result at parsing: > > <a > > <b> > <c> > </a> > > How can I change the positions of elements?, in order to get: > > <a > > <c> > <b> > </a> > > Thanks a lot. > > > > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure > contains a definitive record of customers, application performance, > security threats, fraudulent activity, and more. Splunk takes this > data and makes sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-novd2d > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > > |
|
From: Jouni L. <Jou...@sa...> - 2011-11-17 06:33:23
|
Hi,
By default the serialization of fields is done in declaration order, so the simplest way would be to just declare C before B. If you need more control see the Order -annotation in the documentation and tutorials.
-J
On 16.11.11 22:49, "gato chalar" <da...@gm...> wrote:
Hi
I have a class like next one:
class A{
@Element
B b;
@Element
C c;
}
result at parsing:
<a >
<b>
<c>
</a>
How can I change the positions of elements?, in order to get:
<a >
<c>
<b>
</a>
Thanks a lot.
|
|
From: gato c. <da...@gm...> - 2011-11-16 20:50:47
|
Hi
I have a class like next one:
class A{
@Element
B b;
@Element
C c;
}
result at parsing:
<a >
<b>
<c>
</a>
How can I change the positions of elements?, in order to get:
<a >
<c>
<b>
</a>
Thanks a lot.
|
|
From: Jarrod S. <ja...@co...> - 2011-11-14 04:44:24
|
Hey Niall,
Sorry to bother you but have you any ideas on a solution for this? I'm
just asking because I'm nearing a deadline and will soon have to start
thinking about some hacks otherwise: probably loading the XML with a
traditional DOM parser to stomp the element names to all be <ERROR>,
write it out, then read it back in with Simple.
Thanks a lot,
Jarrod
On Fri, Nov 11, 2011 at 8:06 PM, Jarrod Smith <ja...@co...> wrote:
> So in a nutshell I need something that does the equivalent of:
>
> @ElementList(entry = "*", type = GenericAPIError.class)
>
> i.e. A wildcard for the entry parameter, and have it not care about
> the element name.
>
> On Fri, Nov 11, 2011 at 8:03 PM, Jarrod Smith <ja...@co...> wrote:
>> Thanks Niall,
>>
>> The XML response is of this form:
>>
>> <FAIL>
>>
>> <A>Error relating to A</A>
>> <B>Error relating to B</B>
>> <C>Error relating to C</C>
>> ...
>> <ERROR>General Error Message 1</ERROR>
>> <ERROR>General Error Message 2</ERROR>
>> <ERROR>General Error Message 3</ERROR>
>> ...
>> </FAIL>
>>
>> But I don't know what the A, B, C elements are actually named, only
>> that they just contain text, and won't be nested.
>>
>> I'm currently using an ElementListUnion which gets me halfway there,
>> but that still requires that I know what all the element names are
>> (which I can only find out by trial and error, which will take
>> forever). So I need a way to just parse the simple document format
>> above, and just chuck all the element values into a list, array,
>> whatever.
>>
>> Below is basically what I'm using at the moment, you can see the
>> different types of error element names I've managed to discover so
>> far.
>>
>> @Root(strict=false)
>> public class MyServerResponseErrorParser
>> {
>>
>> @ElementListUnion({
>> @ElementList(entry = "ERROR", inline = true, required = false, type
>> = GenericAPIError.class),
>> @ElementList(entry = "CONTACT", inline = true, required = false,
>> type = GenericAPIError.class),
>> @ElementList(entry = "SIGNUP", inline = true, required = false, type
>> = GenericAPIError.class),
>> @ElementList(entry = "PLAN", inline = true, required = false, type =
>> GenericAPIError.class),
>> @ElementList(entry = "PAYMENT", inline = true, required = false,
>> type = GenericAPIError.class),
>> @ElementList(entry = "PLAN_ID", inline = true, required = false,
>> type = GenericAPIError.class)})
>> public List<GenericAPIError> errors;
>>
>> }
>>
>> @Root
>> public class GenericAPIError
>> {
>> @Text
>> public String error;
>> }
>>
>>
>> Thanks a lot,
>> Jarrod.
>>
>> On Fri, Nov 11, 2011 at 7:19 PM, Niall Gallagher
>> <gal...@ya...> wrote:
>>>
>>> If you provide a code example with some xml ill see what the solution should be
>>>
>>> Sent from Yahoo!7 Mail on Android
>>>
>>> ________________________________
>>> From: Jarrod Smith <ja...@co...>;
>>> To: <sim...@li...>;
>>> Subject: Re: [Simple-support] Inline list of simple elements with different names
>>> Sent: Fri, Nov 11, 2011 12:35:22 AM
>>>
>>> I just found this thread:
>>> http://sourceforge.net/mailarchive/message.php?msg_id=26681126
>>>
>>> Cameron's was the exact same problem I am having. So it seems there is
>>> no way around this, without a setName() on the InputNode. Niall I
>>> don't understand your final suggestion in that thread to "use the
>>> Style interface" since that only applies to serialisation to XML, and
>>> not deserialising *from* XML, which is when Cameron and I are needing
>>> to modify the element names. Or am I missing something?
>>>
>>> To be clear, what I want to do is rename the <A>, <B>, <C> ... etc.
>>> elements below to all be <ERROR> nodes.
>>>
>>> Any suggestions greatly appreciated.
>>>
>>> - Jarrod
>>>
>>> On Sun, Nov 6, 2011 at 9:37 PM, Jarrod Smith <ja...@co...> wrote:
>>> > I have a doc that has something like the following structure:
>>> >
>>> > <FAIL | OK>
>>> >
>>> > <!-- In the FAIL Case: -->
>>> >
>>> > <A>Error relating to A</A>
>>> > <B>Error relating to B</B>
>>> > <C>Error relating to C</C>
>>> > ...
>>> > <ERROR>General Error Message</ERROR>
>>> > <ERROR>General Error Message</ERROR>
>>> > <ERROR>General Error Message</ERROR>
>>> > ...
>>> > </FAIL | OK>
>>> >
>>> > There could be a lot of different A, B, C, ...., and to make matters
>>> > worse, I haven't even been provided with a specification as to what
>>> > they all could be.
>>> >
>>> > The contents of the elements is always just a string. So the document
>>> > is really just a flat list of elements containing strings. Is there a
>>> > simple way for me to declare a Class to parse this?
>>> >
>>> > Something like:
>>> >
>>> > @Root
>>> > public class MyErrorClass {
>>> > @ElementList(inline=true)
>>> > public List<APIError> errors;
>>> > }
>>> >
>>> > @Root // <--- Don't want this to care about
>>> > the name of the element.
>>> > public class APIError
>>> > {
>>> > @Text
>>> > String error;
>>> > }
>>> >
>>> > Another idea I had was to just use a Visitor to stomp all the element
>>> > names and just make them all ERROR. But it doesn't look like you can
>>> > change the element name of an InputNode. Anyway, this idea would only
>>> > work if the TreeStrategy visits the document Root node before any
>>> > others, so I could set a flag indicating this was a <FAIL> document.
>>> >
>>> > Any suggestions appreciated.
>>> >
>>>
>>> ------------------------------------------------------------------------------
>>> RSA(R) Conference 2012
>>> Save $700 by Nov 18
>>> Register now
>>> http://p.sf.net/sfu/rsa-sfdev2dev1
>>> _______________________________________________
>>> Simple-support mailing list
>>> Sim...@li...
>>> https://lists.sourceforge.net/lists/listinfo/simple-support
>>
>
|
|
From: Niall G. <gal...@ya...> - 2011-11-12 12:28:01
|
Try putting it all in the one reference string Sent from Yahoo!7 Mail on Android |
|
From: Niall G. <gal...@ya...> - 2011-11-12 06:05:23
|
Read the documentation for treestrategy Sent from Yahoo!7 Mail on Android |
|
From: Ankit M. <ank...@ra...> - 2011-11-12 05:51:44
|
Hello All,
I am trying to do something like this:-
|<Test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Testing.xsd">
However when I used this|
|@Root(name="Test",strict=false)
@NamespaceList({
@Namespace(reference="xsi=http://www.w3.org/2001/XMLSchema-instance"),
@Namespace(reference="xsi:noNamespaceSchemaLocation"="Testing.xsd")
})
I get two xmlns in my XML Namespace..Although it is understood that using two Namespace will generate two xmlns but how can
I generate the xsi:noNamespaceSchemaLocation in my xml..
I succeeded by using attribute Annotation inside my class but that is not what I want..It always better to specify things related to schema
before the beginning of the class..Also attribute is not made for that purpose..
Is it possible to do in simpleFramework.
Thanks..
|
|
|
From: William D. <wd...@pr...> - 2011-11-11 17:54:25
|
Seems that there's a limitation in Simple that prevents the create of an ElementMap when the attribute for the key is named "class". This is not just an example, but resulted from an attempt to map real world data.
This doesn't work.... (Stack Trace at end of mail)
<Foo1>
<Bar class="A">1</Bar>
<Bar class="B">2</Bar>
<Bar class="C">3</Bar>
<Bar class="D">4</Bar>
<Bar class="E">5</Bar>
<Bar class="F">6</Bar>
</Foo1>
@Root
public class Foo1 {
@ElementMap(entry="Bar", key="class", attribute=true, inline=true)
private Map<Character,Short> bars = new HashMap<Character,Short>();
}
This does....
<Foo2>
<Bar baz="A">1</Bar>
<Bar baz="B">2</Bar>
<Bar baz="C">3</Bar>
<Bar baz="D">4</Bar>
<Bar baz="E">5</Bar>
<Bar baz="F">6</Bar>
</Foo2>
@Root
public class Foo2 {
@ElementMap(entry="Bar", key="baz", attribute=true, inline=true)
private Map<Character,Short> bars = new HashMap<Character,Short>();
}
Comments or assistance?
TIA,
wyldbill
java.lang.ClassNotFoundException: A
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.simpleframework.xml.strategy.Loader.load(Loader.java:50)
at org.simpleframework.xml.strategy.TreeStrategy.readValue(TreeStrategy.java:163)
at org.simpleframework.xml.strategy.TreeStrategy.read(TreeStrategy.java:102)
at org.simpleframework.xml.core.Source.getOverride(Source.java:370)
at org.simpleframework.xml.core.Factory.getConversion(Factory.java:207)
at org.simpleframework.xml.core.Factory.getOverride(Factory.java:139)
at org.simpleframework.xml.core.PrimitiveFactory.getInstance(PrimitiveFactory.java:82)
at org.simpleframework.xml.core.Primitive.readElement(Primitive.java:186)
at org.simpleframework.xml.core.Primitive.read(Primitive.java:124)
at org.simpleframework.xml.core.PrimitiveValue.readAttribute(PrimitiveValue.java:184)
at org.simpleframework.xml.core.PrimitiveValue.read(PrimitiveValue.java:119)
at org.simpleframework.xml.core.CompositeInlineMap.read(CompositeInlineMap.java:167)
at org.simpleframework.xml.core.CompositeInlineMap.read(CompositeInlineMap.java:142)
at org.simpleframework.xml.core.Composite.readVariable(Composite.java:682)
at org.simpleframework.xml.core.Composite.readInstance(Composite.java:635)
at org.simpleframework.xml.core.Composite.readUnion(Composite.java:610)
at org.simpleframework.xml.core.Composite.readElement(Composite.java:593)
at org.simpleframework.xml.core.Composite.readElements(Composite.java:506)
at org.simpleframework.xml.core.Composite.readSection(Composite.java:388)
at org.simpleframework.xml.core.Composite.read(Composite.java:367)
at org.simpleframework.xml.core.Composite.readDefault(Composite.java:262)
at org.simpleframework.xml.core.Composite.read(Composite.java:232)
at org.simpleframework.xml.core.Composite.read(Composite.java:202)
at org.simpleframework.xml.core.Composite.read(Composite.java:150)
at org.simpleframework.xml.core.Traverser.read(Traverser.java:92)
at org.simpleframework.xml.core.Persister.read(Persister.java:632)
at org.simpleframework.xml.core.Persister.read(Persister.java:613)
at org.simpleframework.xml.core.Persister.read(Persister.java:591)
at org.simpleframework.xml.core.Persister.read(Persister.java:550)
at org.simpleframework.xml.core.Persister.read(Persister.java:528)
at org.simpleframework.xml.core.Persister.read(Persister.java:433)
at Foo1Test.testExample_1(Foo1Test.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
|
|
From: Jarrod S. <ja...@co...> - 2011-11-11 09:06:19
|
So in a nutshell I need something that does the equivalent of:
@ElementList(entry = "*", type = GenericAPIError.class)
i.e. A wildcard for the entry parameter, and have it not care about
the element name.
On Fri, Nov 11, 2011 at 8:03 PM, Jarrod Smith <ja...@co...> wrote:
> Thanks Niall,
>
> The XML response is of this form:
>
> <FAIL>
>
> <A>Error relating to A</A>
> <B>Error relating to B</B>
> <C>Error relating to C</C>
> ...
> <ERROR>General Error Message 1</ERROR>
> <ERROR>General Error Message 2</ERROR>
> <ERROR>General Error Message 3</ERROR>
> ...
> </FAIL>
>
> But I don't know what the A, B, C elements are actually named, only
> that they just contain text, and won't be nested.
>
> I'm currently using an ElementListUnion which gets me halfway there,
> but that still requires that I know what all the element names are
> (which I can only find out by trial and error, which will take
> forever). So I need a way to just parse the simple document format
> above, and just chuck all the element values into a list, array,
> whatever.
>
> Below is basically what I'm using at the moment, you can see the
> different types of error element names I've managed to discover so
> far.
>
> @Root(strict=false)
> public class MyServerResponseErrorParser
> {
>
> @ElementListUnion({
> @ElementList(entry = "ERROR", inline = true, required = false, type
> = GenericAPIError.class),
> @ElementList(entry = "CONTACT", inline = true, required = false,
> type = GenericAPIError.class),
> @ElementList(entry = "SIGNUP", inline = true, required = false, type
> = GenericAPIError.class),
> @ElementList(entry = "PLAN", inline = true, required = false, type =
> GenericAPIError.class),
> @ElementList(entry = "PAYMENT", inline = true, required = false,
> type = GenericAPIError.class),
> @ElementList(entry = "PLAN_ID", inline = true, required = false,
> type = GenericAPIError.class)})
> public List<GenericAPIError> errors;
>
> }
>
> @Root
> public class GenericAPIError
> {
> @Text
> public String error;
> }
>
>
> Thanks a lot,
> Jarrod.
>
> On Fri, Nov 11, 2011 at 7:19 PM, Niall Gallagher
> <gal...@ya...> wrote:
>>
>> If you provide a code example with some xml ill see what the solution should be
>>
>> Sent from Yahoo!7 Mail on Android
>>
>> ________________________________
>> From: Jarrod Smith <ja...@co...>;
>> To: <sim...@li...>;
>> Subject: Re: [Simple-support] Inline list of simple elements with different names
>> Sent: Fri, Nov 11, 2011 12:35:22 AM
>>
>> I just found this thread:
>> http://sourceforge.net/mailarchive/message.php?msg_id=26681126
>>
>> Cameron's was the exact same problem I am having. So it seems there is
>> no way around this, without a setName() on the InputNode. Niall I
>> don't understand your final suggestion in that thread to "use the
>> Style interface" since that only applies to serialisation to XML, and
>> not deserialising *from* XML, which is when Cameron and I are needing
>> to modify the element names. Or am I missing something?
>>
>> To be clear, what I want to do is rename the <A>, <B>, <C> ... etc.
>> elements below to all be <ERROR> nodes.
>>
>> Any suggestions greatly appreciated.
>>
>> - Jarrod
>>
>> On Sun, Nov 6, 2011 at 9:37 PM, Jarrod Smith <ja...@co...> wrote:
>> > I have a doc that has something like the following structure:
>> >
>> > <FAIL | OK>
>> >
>> > <!-- In the FAIL Case: -->
>> >
>> > <A>Error relating to A</A>
>> > <B>Error relating to B</B>
>> > <C>Error relating to C</C>
>> > ...
>> > <ERROR>General Error Message</ERROR>
>> > <ERROR>General Error Message</ERROR>
>> > <ERROR>General Error Message</ERROR>
>> > ...
>> > </FAIL | OK>
>> >
>> > There could be a lot of different A, B, C, ...., and to make matters
>> > worse, I haven't even been provided with a specification as to what
>> > they all could be.
>> >
>> > The contents of the elements is always just a string. So the document
>> > is really just a flat list of elements containing strings. Is there a
>> > simple way for me to declare a Class to parse this?
>> >
>> > Something like:
>> >
>> > @Root
>> > public class MyErrorClass {
>> > @ElementList(inline=true)
>> > public List<APIError> errors;
>> > }
>> >
>> > @Root // <--- Don't want this to care about
>> > the name of the element.
>> > public class APIError
>> > {
>> > @Text
>> > String error;
>> > }
>> >
>> > Another idea I had was to just use a Visitor to stomp all the element
>> > names and just make them all ERROR. But it doesn't look like you can
>> > change the element name of an InputNode. Anyway, this idea would only
>> > work if the TreeStrategy visits the document Root node before any
>> > others, so I could set a flag indicating this was a <FAIL> document.
>> >
>> > Any suggestions appreciated.
>> >
>>
>> ------------------------------------------------------------------------------
>> RSA(R) Conference 2012
>> Save $700 by Nov 18
>> Register now
>> http://p.sf.net/sfu/rsa-sfdev2dev1
>> _______________________________________________
>> Simple-support mailing list
>> Sim...@li...
>> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|
|
From: Jarrod S. <ja...@co...> - 2011-11-11 09:03:31
|
Thanks Niall,
The XML response is of this form:
<FAIL>
<A>Error relating to A</A>
<B>Error relating to B</B>
<C>Error relating to C</C>
...
<ERROR>General Error Message 1</ERROR>
<ERROR>General Error Message 2</ERROR>
<ERROR>General Error Message 3</ERROR>
...
</FAIL>
But I don't know what the A, B, C elements are actually named, only
that they just contain text, and won't be nested.
I'm currently using an ElementListUnion which gets me halfway there,
but that still requires that I know what all the element names are
(which I can only find out by trial and error, which will take
forever). So I need a way to just parse the simple document format
above, and just chuck all the element values into a list, array,
whatever.
Below is basically what I'm using at the moment, you can see the
different types of error element names I've managed to discover so
far.
@Root(strict=false)
public class MyServerResponseErrorParser
{
@ElementListUnion({
@ElementList(entry = "ERROR", inline = true, required = false, type
= GenericAPIError.class),
@ElementList(entry = "CONTACT", inline = true, required = false,
type = GenericAPIError.class),
@ElementList(entry = "SIGNUP", inline = true, required = false, type
= GenericAPIError.class),
@ElementList(entry = "PLAN", inline = true, required = false, type =
GenericAPIError.class),
@ElementList(entry = "PAYMENT", inline = true, required = false,
type = GenericAPIError.class),
@ElementList(entry = "PLAN_ID", inline = true, required = false,
type = GenericAPIError.class)})
public List<GenericAPIError> errors;
}
@Root
public class GenericAPIError
{
@Text
public String error;
}
Thanks a lot,
Jarrod.
On Fri, Nov 11, 2011 at 7:19 PM, Niall Gallagher
<gal...@ya...> wrote:
>
> If you provide a code example with some xml ill see what the solution should be
>
> Sent from Yahoo!7 Mail on Android
>
> ________________________________
> From: Jarrod Smith <ja...@co...>;
> To: <sim...@li...>;
> Subject: Re: [Simple-support] Inline list of simple elements with different names
> Sent: Fri, Nov 11, 2011 12:35:22 AM
>
> I just found this thread:
> http://sourceforge.net/mailarchive/message.php?msg_id=26681126
>
> Cameron's was the exact same problem I am having. So it seems there is
> no way around this, without a setName() on the InputNode. Niall I
> don't understand your final suggestion in that thread to "use the
> Style interface" since that only applies to serialisation to XML, and
> not deserialising *from* XML, which is when Cameron and I are needing
> to modify the element names. Or am I missing something?
>
> To be clear, what I want to do is rename the <A>, <B>, <C> ... etc.
> elements below to all be <ERROR> nodes.
>
> Any suggestions greatly appreciated.
>
> - Jarrod
>
> On Sun, Nov 6, 2011 at 9:37 PM, Jarrod Smith <ja...@co...> wrote:
> > I have a doc that has something like the following structure:
> >
> > <FAIL | OK>
> >
> > <!-- In the FAIL Case: -->
> >
> > <A>Error relating to A</A>
> > <B>Error relating to B</B>
> > <C>Error relating to C</C>
> > ...
> > <ERROR>General Error Message</ERROR>
> > <ERROR>General Error Message</ERROR>
> > <ERROR>General Error Message</ERROR>
> > ...
> > </FAIL | OK>
> >
> > There could be a lot of different A, B, C, ...., and to make matters
> > worse, I haven't even been provided with a specification as to what
> > they all could be.
> >
> > The contents of the elements is always just a string. So the document
> > is really just a flat list of elements containing strings. Is there a
> > simple way for me to declare a Class to parse this?
> >
> > Something like:
> >
> > @Root
> > public class MyErrorClass {
> > @ElementList(inline=true)
> > public List<APIError> errors;
> > }
> >
> > @Root // <--- Don't want this to care about
> > the name of the element.
> > public class APIError
> > {
> > @Text
> > String error;
> > }
> >
> > Another idea I had was to just use a Visitor to stomp all the element
> > names and just make them all ERROR. But it doesn't look like you can
> > change the element name of an InputNode. Anyway, this idea would only
> > work if the TreeStrategy visits the document Root node before any
> > others, so I could set a flag indicating this was a <FAIL> document.
> >
> > Any suggestions appreciated.
> >
>
> ------------------------------------------------------------------------------
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Niall G. <gal...@ya...> - 2011-11-11 08:19:24
|
If you provide a code example with some xml ill see what the solution should be Sent from Yahoo!7 Mail on Android |
|
From: Niall G. <gal...@ya...> - 2011-11-11 08:17:30
|
Look at elementlistunion Sent from Yahoo!7 Mail on Android |
|
From: Jarrod S. <ja...@co...> - 2011-11-11 00:35:30
|
I just found this thread: http://sourceforge.net/mailarchive/message.php?msg_id=26681126 Cameron's was the exact same problem I am having. So it seems there is no way around this, without a setName() on the InputNode. Niall I don't understand your final suggestion in that thread to "use the Style interface" since that only applies to serialisation to XML, and not deserialising *from* XML, which is when Cameron and I are needing to modify the element names. Or am I missing something? To be clear, what I want to do is rename the <A>, <B>, <C> ... etc. elements below to all be <ERROR> nodes. Any suggestions greatly appreciated. - Jarrod On Sun, Nov 6, 2011 at 9:37 PM, Jarrod Smith <ja...@co...> wrote: > I have a doc that has something like the following structure: > > <FAIL | OK> > > <!-- In the FAIL Case: --> > > <A>Error relating to A</A> > <B>Error relating to B</B> > <C>Error relating to C</C> > ... > <ERROR>General Error Message</ERROR> > <ERROR>General Error Message</ERROR> > <ERROR>General Error Message</ERROR> > ... > </FAIL | OK> > > There could be a lot of different A, B, C, ...., and to make matters > worse, I haven't even been provided with a specification as to what > they all could be. > > The contents of the elements is always just a string. So the document > is really just a flat list of elements containing strings. Is there a > simple way for me to declare a Class to parse this? > > Something like: > > @Root > public class MyErrorClass { > @ElementList(inline=true) > public List<APIError> errors; > } > > @Root // <--- Don't want this to care about > the name of the element. > public class APIError > { > @Text > String error; > } > > Another idea I had was to just use a Visitor to stomp all the element > names and just make them all ERROR. But it doesn't look like you can > change the element name of an InputNode. Anyway, this idea would only > work if the TreeStrategy visits the document Root node before any > others, so I could set a flag indicating this was a <FAIL> document. > > Any suggestions appreciated. > |