Re: [Simple-support] How to create Option Text and optional Object.
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2008-03-22 10:11:25
|
Hi,
You could use this.
@Root(name="ENV")
public class Env {
@ElementList(name="VIDEO")
private List<Cam> list;
}
@Root(name="CAM")
public class Cam {
@Attribute(name="ADDR")
private String addr;
@Text
private String text;
}
However the free text "Q" can not be supported as it
needs to be wrapped in an element. Free text and
elements can not be mixed in the schama currently.
Niall
--- John Matthews <jo...@qu...> wrote:
> I have an XML document and I am having troubles
> setting up my object
> class to parse into. Here is what I have:
> <ENV>
> <VIDEO>Q</VIDEO>
> </ENV>
> or it can be
> <ENV>
> <VIDEO>
> <CAM ADDR="1">TEXT</CAM>
> <CAM ADDR="2">TEXT</CAM>
> </VIDEO>
> </ENV>
>
> So how do I setup my one class to handle both
> situations?
> @Root
> public class Env {
> @Element(required=false)
> public Video video= new Video();
>
> @Root
> public static class Video {
> @Element(required=false)
> public Cam cam;
> }
>
> @Root
> public static class Cam {
> @Attribute(required=false)
> public String addr;
>
> public String text;
>
> @Text(required=false)
> public String getText() {
> return text;
> }
>
> @Text(required=false)
> public void setText(String text){
> this.text = text;
> }
> }
> }
>
>
-------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio
> 2008.
>
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
>
https://lists.sourceforge.net/lists/listinfo/simple-support
>
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
|