Re: [Simple-support] Does not understand this ElementException
Brought to you by:
niallg
|
From: Niall G. - Y. <Nia...@yi...> - 2012-09-19 23:02:46
|
Hi,
>From this I can tell one of your XML elements named "SignedDataObject" does not have an "id" attribute. Look in your XML file at line 43, I think you will see there is no "Id" element, set the @Attribute(name="Id", required=false) this should fix it. Also, without seeing the class DigestAlgAndValueType I cannot tell if it has an @Element matching "DigestMethod", though Ill bet there is no such element. A good option for you might be.
Persister.read(MyClass.class, mySourceStream, false) // false means ignore elements and attributes not matched by your annotations
Niall
-----Original Message-----
From: Thomas [mailto:tho...@gm...]
Sent: Wednesday, 19 September 2012 11:05 PM
To: sim...@li...
Subject: [Simple-support] Does not understand this ElementException
Hello,
I have a little problem with Simple. First, here is a part of my XSD file:
<xs:complexType name="SignedDataObjectType">
<xs:sequence>
<xs:element name="Encapsulated" type="xs:boolean"/>
<xs:element name="MimeType" type="xs:string"/>
<xs:element name="Name" type="xs:string" minOccurs="0"/>
<xs:element name="Description" type="xs:string" minOccurs="0"/>
<xs:element name="Size" type="xs:long" minOccurs="0"/>
<xs:element name="DigestAlgAndValue" type="xad:DigestAlgAndValueType" minOccurs="0"/>
<xs:element name="Revisions" type="vt:RevisionsType" minOccurs="0"/>
<xs:element name="Errors" type="vt:ErrorsType" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:ID" use="required"/>
</xs:complexType>
Then, here is my targetted Java class:
public class SignedDataObjectType {
@Attribute(name = "Id")
protected String id;
@Element(name = "Encapsulated")
protected boolean encapsulated;
@Element(name = "MimeType")
public String mimeType;
@Element(name = "Name", required = false)
protected String name;
@Element(name = "Description", required = false)
protected String description;
@Element(name = "Size", required = false)
protected Long size;
@Element(name = "DigestAlgAndValue", required = false)
protected DigestAlgAndValueType digestAlgAndValue;
@Element(name = "Revisions", required = false)
protected RevisionsType revisions;
@Element(name = "Errors", required = false)
protected ErrorsType errors;
... setters and getters here...
And to finish, a the part of my XML file:
... other datas here...
<vt:SignedDataObject Id="signeddata-1">
<vt:Encapsulated>true</vt:Encapsulated>
<vt:MimeType>application/pdf</vt:MimeType>
<vt:Name>signeddata-1.pdf</vt:Name>
<vt:Size>131323</vt:Size>
<vt:DigestAlgAndValue>
<ds:DigestMethod Algorithm="1.3.14.3.2.26"></ds:DigestMethod>
<ds:DigestValue>KuWqL3YVcSMZeHRov5nE90PZSeY=</ds:DigestValue>
</vt:DigestAlgAndValue>
</vt:SignedDataObject>
... other datas here...
And I have this exception:
org.simpleframework.xml.core.ValueRequiredException: Unable to satisfy @org.simpleframework.xml.Attribute(empty=, name=Id, required=true) on field 'id' protected java.lang.String com.lexpersona.lp7verifybox.entities.SignedDataObjectType.id for class com.lexpersona.lp7verifybox.entities.SignedDataObjectType at line 43 at org.simpleframework.xml.core.Composite.validate(Composite.java:644)
at org.simpleframework.xml.core.Composite.readAttributes(Composite.java:416)
...blah blah blah...
As you can see, the datas exists. So, I tried to use the required false (which is very bad because my class attributes are mandatory) in the annotation but I have another exception with the DigestAlgAndValue tag:
org.simpleframework.xml.core.ElementException: Element 'DigestMethod' does not have a match in class com.lexpersona.lp7verifybox.entities.SignedDataObjectType at line 48 at org.simpleframework.xml.core.Composite.readElement(Composite.java:527)
... blah blah blah...
I do not understand why Simple is against me at this level :s And you can note the I already use the DigestAlgAndValue element before and that works... I realy do not understand why Exception are thrown in this level :(
Have you any ideas? Do I need to send you more informations?
Thomas
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|