Re: [Simple-support] Text with Element?
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2011-08-31 09:02:55
|
Hi,
It cant be done with annotations like this, you can try a converter which should work. This should consume the whole outer element, to it will need to read the text and the element.
There sould be examples in the test cases.
Niall
--- On Tue, 30/8/11, Lee Jorgensen <n0...@co...> wrote:
From: Lee Jorgensen <n0...@co...>
Subject: [Simple-support] Text with Element?
To: sim...@li...
Received: Tuesday, 30 August, 2011, 8:37 PM
Per the tutorial:
The rules that govern the use of the Text
annotation are that there can only be one per schema class. Also,
this annotation cannot be used with the Element
annotation. Only the Attribute
annotation can be used with it as this annotation does not add any
content within the owning element.
... I fully understand why, and the reasons behind it. Now onto my
problem, I'm trying to decode XML that is produced (I don't have to
create it, just read), and they have the schema as such:
<creation-center>
<sub-center>subcenter info</sub-center>
creationcenter info
</creation-center>
The schema that I need to decode is:
-----
<xsd:complexType name="sourceType">
<xsd:all>
...
<xsd:element name="creation-center"
type="creation-centerType" minOccurs="0" maxOccurs="1"/>
...
</xsd:all>
</xsd:complexType>
<xsd:complexType name="creation-centerType" mixed="true">
<xsd:sequence>
<xsd:element name="sub-center" type="xsd:string"
minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
-----
My class that I'm currently trying to get to decode this XML is:
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Text;
@Element(name="creation-center")
public class CreationCenter {
// @Element(name="sub-center", required=false)
// private String sub_center;
@Text
private String creation_center;
////
// public String getSub_Center() {
// return sub_center;
// }
public String getCreation_Center() {
return creation_center;
}
}
If I don't comment out the "sub-center" element, the XML fails to
parse, obviously. How can I get both the main element text and the
sub-element?
Thanks.
-Lee.
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|