[Simple-support] Reading a list of elements
Brought to you by:
niallg
|
From: Courtney, P. <Phi...@sr...> - 2011-08-01 18:14:13
|
I am in the process of converting from JAXB generated classes (which we
have used on workstations and servers) to Simple for use in an Android
application (since JAXB is not supported on Android).
I have tried to follow the tutorial for Reading a list of elements. An
excerpt of the document's root element is below:
@Root
@Order( elements = {
"providerInformation",
"contents",
"constraints",
"dependencies",
"installableComponents",
"configurationInformation",
"maintenanceInformation",
"modificationInformation",
"uninstallInformation"
})
public class SolutionPackageDeploymentType
extends UniversallyIdentifiedType
{
...
@Element(name = "Contents", required = true)
protected ContentsType contents;
...
}
The ContentsType class with an ElementList is below:
@Root
public class ContentsType {
@ElementList(name = "Content", required = true)
protected List<ContentType> content;
public List<ContentType> getContent() {
if (content == null) {
content = new ArrayList<ContentType>();
}
return this.content;
}
}
An excerpt of the Content class for the element contained in the list is
below:
@Root
public class ContentType {
@Attribute(required = true)
protected String uuid;
@Attribute(required = true)
protected String pathName;
@Attribute(required = true)
protected String purpose;
@Attribute(required = false)
protected BigInteger length;
@Attribute(required = false)
protected String digestMethod;
@Attribute(required = false)
protected String digestValue;
...
}
An excerpt of the example XML is below:
<spd:SolutionPackageDeployment ...
xsi:schemaLocation="http://www.sra.com/rtapp/spdd
SolutionPackageDeploymentV0.xsd"
xmlns:spd="http://www.sra.com/rtapp/spdd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
<spd:Contents>
<spd:Content
uuid="34d00b71-ba29-11e0-962b-0800200c9a66" purpose="DATA_FILE"
pathName="F1"/>
<spd:Content
uuid="34d00b72-ba29-11e0-962b-0800200c9a66" purpose="DATA_FILE"
pathName="F2"/>
</spd:Contents>
...
</spd:SolutionPackageDeployment>
When I attempt to read the XML document, I get the following error
message:
Element 'Content' declared twice at line 10
Any suggestions on how to resolve the error would be greatly
appreciated.
Phil
|