simple-support Mailing List for Simple (Page 12)
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: Nhat N. <phu...@gm...> - 2012-10-31 06:30:15
|
Hi all,
Let's say I got the following objects:
*Sector.java*
@Root
public class Sector {
@Attribute
String name;
@Element
Int value;
@ElementList(entry="neighbor")
List<Sector> neighbours;
public Sector(@Attribute name,
@Element value) {
...
}
public addNeighbour(sector) {
...
}
}
*Sectors.java*
public class Sectors {
@ElementList
List<Sector> sectors;
...
}
How would I serialize and deserialize the above objects into the following
sample xml:
<Sectors>
<Sector name = "one">
<value>5</value>
<neighbours class=...>
<neighbour name="two" />
</neighbours>
</Sector>
<Sector name = "two">
<value>2</value>
<neighbours class=...>
<neighbour name="one" />
<neighbour name="three" />
</neighbours>
</Sector>
...
</Sectors>
Where the Neighbours are referred by designated name and not referring to
the whole object. I've tried CycleStrategy but it seems to refer to every
element in object and not simply a specific one I needed.
Nhat
|
|
From: Niall G. <gal...@ya...> - 2012-10-27 14:12:42
|
It should not matter what collection you use, but you must make sure the serialization runtime knows the type. The easiest is to declare it in the field with the full class name.
@ElementList(name="Positions")
private PositionSet<Position> positions;
If you do not declare the full type, then you must use the "class=" attribute in your XML.
<Positions class="my.package.PositionSet">
<Position>A</Position>
<Position>B</Position>
</Positions>
Niall
--- On Sat, 27/10/12, Nhat Ngo <phu...@gm...> wrote:
> From: Nhat Ngo <phu...@gm...>
> Subject: [Simple-support] Serialise/Deserialise collections
> To: sim...@li...
> Received: Saturday, 27 October, 2012, 6:57 AM
> Hi all,
> I am using SimpleXML to read/write data to XML
> from a part of a wider package of air traffic management and
> would like to ask for details on how to serialise and
> deserialise an odd setup on collections type. I got the
> following 2 classes:
>
> Position.java
>
>
>
>
>
>
>
>
> @Root(name="Position")
> public class Position {
> @Text
> private String name;
>
> public Position(@Text String name) {
> this.name=name
> }
>
> }PositionSet.java
> (used system-wide and should not be modified in
> functionality)import
> com.google.common.collect.ForwardingSortedSet;
>
> public class PositionSet extends
> ForwardingSortedSet<Position> {
> private final SortedSet<Position>
> delegate;
> public PositionSet() {
> this.delegate = new
> TreeSet<Position>();
>
> }
>
> public PositionSet(Collection<Position>
> delegate) {
> this.delegate = new
> TreeSet<Position>(delegate);
> }
>
> @Override
> protected SortedSet<Position> delegate() {
>
> return delegate;
> }
> }
> I want to produce the following
> XML:<Positions>
> <Position>A</Position>
>
> <Position>B</Position></Positions>
> The easiest option is to create another class
> called Positions.java, load the positions and then add it to
> PositionSet. However, I do not want to pollute the models
> with redundant codes and would like to use PositionSet and
> Position only.
>
> Further from that, there are other similar
> collections construction in the code bases that use
> SortedSet interface. Would it be possible to write a good
> Converter for SortedSet that handle different child elements
> (given they have respective annotated classes).
>
> Thanks,Nhat
>
> -----Inline Attachment Follows-----
>
> ------------------------------------------------------------------------------
> WINDOWS 8 is here.
> Millions of people. Your app in 30 days.
> Visit The Windows 8 Center at Sourceforge for all your go to
> resources.
> http://windows8center.sourceforge.net/
> join-generation-app-and-make-money-coding-fast/
> -----Inline Attachment Follows-----
>
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|
|
From: Nhat N. <phu...@gm...> - 2012-10-27 13:58:02
|
Hi all,
I am using SimpleXML to read/write data to XML from a part of a wider
package of air traffic management and would like to ask for details on how
to serialise and deserialise an odd setup on collections type. I got the
following 2 classes:
*Position.java*
@Root(name="Position")
public class Position {
@Text
private String name;
public Position(@Text String name) {
this.name=name
}
}
*PositionSet.java *(used system-wide and should not be modified in
functionality)
import com.google.common.collect.ForwardingSortedSet;
public class PositionSet extends ForwardingSortedSet<Position> {
private final SortedSet<Position> delegate;
public PositionSet() {
this.delegate = new TreeSet<Position>();
}
public PositionSet(Collection<Position> delegate) {
this.delegate = new TreeSet<Position>(delegate);
}
@Override
protected SortedSet<Position> delegate() {
return delegate;
}
}
I want to produce the following XML:
<Positions>
<Position>A</Position>
<Position>B</Position>
</Positions>
The easiest option is to create another class called Positions.java, load
the positions and then add it to PositionSet. However, I do not want to
pollute the models with redundant codes and would like to use PositionSet
and Position only.
Further from that, there are other similar collections construction in the
code bases that use SortedSet interface. Would it be possible to write a
good Converter for SortedSet that handle different child elements (given
they have respective annotated classes).
Thanks,
Nhat
|
|
From: Niall G. <gal...@ya...> - 2012-10-21 02:20:54
|
The list needs to be in a serializable type, try
@Root
public class MyList {
@ElementList(inline=true)
List<MyClass> list;
}
This should work.
--- On Sat, 20/10/12, Tyrel Alastair Hunter <ial...@gm...> wrote:
> From: Tyrel Alastair Hunter <ial...@gm...>
> Subject: [Simple-support] Serializing List
> To: sim...@li...
> Received: Saturday, 20 October, 2012, 7:21 AM
> I am unable to serialize a list of Annotated
> objects is this possible
>
> I have a Class that is annotated and I can
> serialize them individually however if I put the items in
> a list and then try to serialize the list it does not
> serialize anything
>
>
> Sample:@rootpublic
> MyClass{
> @Attribute(name="name") public
> string name;
> @Attribute(name="id")
> public int id; public
> MyClass(@Attribute(name="name") String name,
> @Attribute(name="id") int id)
> { this.name= name;
> this.id = id;
> }}
> List<MyClass> list = new
> ArrayList<MyClass>();list.add(new
> MyClass("name 1", 1);
> list.add(new MyClass("name
> 2",2);serializer.write(list,output);
>
> -----Inline Attachment Follows-----
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
> -----Inline Attachment Follows-----
>
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|
|
From: Tyrel A. H. <ial...@gm...> - 2012-10-20 14:21:48
|
I am unable to serialize a list of Annotated objects is this possible
I have a Class that is annotated and I can serialize
them individually however if I put the items in a list and then try to
serialize the list it does not serialize anything
Sample:
@root
public MyClass{
@Attribute(name="name")
public string name;
@Attribute(name="id")
public int id;
public MyClass(@Attribute(name="name") String name,
@Attribute(name="id") int id)
{
this.name= name;
this.id = id;
}
}
List<MyClass> list = new ArrayList<MyClass>();
list.add(new MyClass("name 1", 1);
list.add(new MyClass("name 2",2);
serializer.write(list,output);
|
|
From: Lars C. <lar...@na...> - 2012-10-15 10:36:17
|
Hi! Thanks for your answer. To me it looks like StAX behaves as I would expect (or as I understand the xml spec), i.e. looks for the external entity in the same directory where the file containing the entity reference are. SimpleXML (or the underlying used API’s) looks in the path where the program was started and expects the file to be there. The problems arise when the external entity does not have an absolute path, just referenced as “file.xml”. If I add an absolute path to the entity reference it works fine in both SimpleXML and StAX. I can’t put an absolute path in the external reference because the file will be moved around in different paths, and that will not be flexible enough. The directory where the XML files are located is not a part of the classpath. Best regards, Lars From: Niall Gallagher [mailto:gal...@ya...] Sent: den 14 oktober 2012 12:48 To: 'sim...@li...'; Lars Carlsson Subject: Re: [Simple-support] External entity reference problems Hi, I think this is a problem with the StAX configuration you are using or perhaps your classpath. Simple does not directly deal with the XML, it only wraps various APIs like StAX, DOM, and XmlPull. Thanks, Niall --- On Wed, 10/10/12, Lars Carlsson <lar...@na...<mailto:lar...@na...>> wrote: From: Lars Carlsson <lar...@na...<mailto:lar...@na...>> Subject: [Simple-support] External entity reference problems To: "'sim...@li...'" <sim...@li...<mailto:sim...@li...>> Received: Wednesday, 10 October, 2012, 9:39 AM Hello! I am using simpleXml and I really like it a lot. I have a special case though where I am referring a xml file that contains an external entity referencing to another xml file. The reference looks like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE run [ <!ENTITY e SYSTEM "file.xml"> ]> <run><iMessageList class="java.util.ArrayList">&e;</iMessageList></run> I run a program from path A and reference the 2 xml files that are located in path B. When I load the xml file and parse it with Java streaming API for Xml (StAX) it works fine. When I do the same with SimpleXml I get an error indicating it cannot find the path of the file. The path that simpleXml expects is the path A, where I started the program and not path B where I have the xml files. I checked the XML spec (http://www.w3.org/TR/REC-xml/#dt-extent) and I can find some info about this: “Unless otherwise provided by information outside the scope of this specification (e.g. a special XML element type defined by a particular DTD, or a processing instruction defined by a particular application specification), relative URIs are relative to the location of the resource within which the entity declaration occurs.” Anyone knows if this is a bug? Best regards and thanks for a great XML api! Lars -----Inline Attachment Follows----- ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev -----Inline Attachment Follows----- _______________________________________________ Simple-support mailing list Sim...@li...</mc/compose?to=...@li...> https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Niall G. <gal...@ya...> - 2012-10-14 10:48:07
|
Hi, I think this is a problem with the StAX configuration you are using or perhaps your classpath. Simple does not directly deal with the XML, it only wraps various APIs like StAX, DOM, and XmlPull. Thanks,Niall --- On Wed, 10/10/12, Lars Carlsson <lar...@na...> wrote: From: Lars Carlsson <lar...@na...> Subject: [Simple-support] External entity reference problems To: "'sim...@li...'" <sim...@li...> Received: Wednesday, 10 October, 2012, 9:39 AM Hello! I am using simpleXml and I really like it a lot. I have a special case though where I am referring a xml file that contains an external entity referencing to another xml file. The reference looks like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE run [ <!ENTITY e SYSTEM "file.xml"> ]> <run><iMessageList class="java.util.ArrayList">&e;</iMessageList></run> I run a program from path A and reference the 2 xml files that are located in path B. When I load the xml file and parse it with Java streaming API for Xml (StAX) it works fine. When I do the same with SimpleXml I get an error indicating it cannot find the path of the file. The path that simpleXml expects is the path A, where I started the program and not path B where I have the xml files. I checked the XML spec (http://www.w3.org/TR/REC-xml/#dt-extent) and I can find some info about this: “Unless otherwise provided by information outside the scope of this specification (e.g. a special XML element type defined by a particular DTD, or a processing instruction defined by a particular application specification), relative URIs are relative to the location of the resource within which the entity declaration occurs.” Anyone knows if this is a bug? Best regards and thanks for a great XML api! Lars -----Inline Attachment Follows----- ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev -----Inline Attachment Follows----- _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Niall G. <gal...@ya...> - 2012-10-14 10:44:36
|
Hi, The XPath parser uses only a subset of expressions, you can only select by element depth. In future I hope to extend the number of supported expressions further. Thanks,Niall --- On Mon, 8/10/12, BRANDON J GRESHAM <Bra...@ut...> wrote: From: BRANDON J GRESHAM <Bra...@ut...> Subject: [Simple-support] Selection using XPath based on value of sibling To: "sim...@li..." <sim...@li...> Received: Monday, 8 October, 2012, 3:00 PM New to Simple as well as complex xpath queries… hoping someone can help me out here… I initially posted this question on SO: http://stackoverflow.com/questions/12648363/xpath-simplexml-selection-of-child-based-on-value-of-childs-sibling Please review my question there for more detail, but essentially I want to do something like this: <xml> <metadata> <resources> <resource> <ittype>Service_Links</> <links> <link>…</> … </links> … @ElementList(entry=”link”, inline=true) @Path( “metadata/resources/resource[ittype=’Service_Links’]/links” ) public List<Link> links; That is, I’m hoping I can use annotations to target a collection (ie: ‘links’) based on the value of the collection’s sibling (ie: ‘ittype’) I would really appreciate any guidance on this. ~Brandon -----Inline Attachment Follows----- ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev -----Inline Attachment Follows----- _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Lars C. <lar...@na...> - 2012-10-10 17:15:00
|
Hello! I am using simpleXml and I really like it a lot. I have a special case though where I am referring a xml file that contains an external entity referencing to another xml file. The reference looks like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE run [ <!ENTITY e SYSTEM "file.xml"> ]> <run><iMessageList class="java.util.ArrayList">&e;</iMessageList></run> I run a program from path A and reference the 2 xml files that are located in path B. When I load the xml file and parse it with Java streaming API for Xml (StAX) it works fine. When I do the same with SimpleXml I get an error indicating it cannot find the path of the file. The path that simpleXml expects is the path A, where I started the program and not path B where I have the xml files. I checked the XML spec (http://www.w3.org/TR/REC-xml/#dt-extent) and I can find some info about this: "Unless otherwise provided by information outside the scope of this specification (e.g. a special XML element type defined by a particular DTD, or a processing instruction defined by a particular application specification), relative URIs are relative to the location of the resource within which the entity declaration occurs." Anyone knows if this is a bug? Best regards and thanks for a great XML api! Lars |
|
From: BRANDON J G. <Bra...@ut...> - 2012-10-08 22:00:59
|
New to Simple as well as complex xpath queries... hoping someone can help me out here... I initially posted this question on SO: http://stackoverflow.com/questions/12648363/xpath-simplexml-selection-of-child-based-on-value-of-childs-sibling Please review my question there for more detail, but essentially I want to do something like this: <xml> <metadata> <resources> <resource> <ittype>Service_Links</> <links> <link>...</> ... </links> ... @ElementList(entry="link", inline=true) @Path( "metadata/resources/resource[ittype='Service_Links']/links" ) public List<Link> links; That is, I'm hoping I can use annotations to target a collection (ie: 'links') based on the value of the collection's sibling (ie: 'ittype') I would really appreciate any guidance on this. ~Brandon |
|
From: Thomas <tho...@gm...> - 2012-09-20 08:12:12
|
Yes ;)
On Sep 20, 2012, at 10:10 AM, Niall Gallagher - Yieldbroker wrote:
> So I take it that the test is in TestLP7VerifyBoxTokenParser
>
> From: Thomas [mailto:tho...@gm...]
> Sent: Thursday, 20 September 2012 6:08 PM
> To: Niall Gallagher - Yieldbroker
> Cc: sim...@li...
> Subject: Re: [Simple-support] Does not understand this ElementException
>
> Of course !
>
> I joined an archive with Simple entities, the unit test, the xml file and xsd schemas.
>
>
>
> On Sep 20, 2012, at 9:47 AM, Niall Gallagher - Yieldbroker wrote:
>
> > Could you send me a JUnit test case, if I can run it and break then I can tell you what is wrong. Its difficult to say from just the snippets here.
> >
> > -----Original Message-----
> > From: Thomas [mailto:tho...@gm...]
> > Sent: Thursday, 20 September 2012 5:38 PM
> > To: Niall Gallagher - Yieldbroker
> > Cc: sim...@li...
> > Subject: Re: [Simple-support] Does not understand this ElementException
> >
> > Hello,
> >
> > First, thank you for your reply.
> >
> > In the previous mail, I extracted the piece of XML code where the line 43 is. Here is with line numbers:
> >
> > ...other datas...
> > 42: <vt:SignedDataObject Id="signeddata1">
> > 43: <vt:Encapsulated>true</vt:Encapsulated>
> > 44: <vt:MimeType>application/pdf</vt:MimeType>
> > 45: <vt:Name>signeddata-1.pdf</vt:Name>
> > 46: <vt:Size>131323</vt:Size>
> > 47: <vt:DigestAlgAndValue>
> > 48: <ds:DigestMethod Algorithm="1.3.14.3.2.26"></ds:DigestMethod>
> > 49: <ds:DigestValue>KuWqL3YVcSMZeHRov5nE90PZSeY=</ds:DigestValue>
> > 50: </vt:DigestAlgAndValue>
> > 51: </vt:SignedDataObject>
> > ...other datas...
> >
> > As you can see, the Id attribute is set.
> >
> > And here is the Java class which modelize the DigestAlgAndValueType XML type:
> >
> > public class DigestAlgAndValueType {
> >
> > @Element(name = "DigestMethod", required = true)
> > protected DigestMethodType digestMethod;
> >
> > @Element(name = "DigestValue", required = true)
> > protected String encodedDigestValue;
> >
> > protected byte[] digestValue;
> >
> > @Commit
> > public void commit() {
> > digestValue = Base64.decode(encodedDigestValue);
> > encodedDigestValue = null;
> > }
> >
> > @Persist
> > public void prepare() {
> > encodedDigestValue = new String(Base64.encode(digestValue));
> > }
> >
> > @Complete
> > public void release() {
> > encodedDigestValue = null;
> > }
> >
> > ... getters and setters...
> > }
> >
> > I don't understand about the DigestAlgAndValueType because it is already used in the XML and the mapping works. Here is the piece of XML file which work and which use DigestAlgAndValueType:
> >
> > 16: <vt:BeforeVerification>
> > 17: <vt:Size>131323</vt:Size>
> > 18: <vt:DigestAlgAndValue>
> > 19: <ds:DigestMethod Algorithm="2.16.840.1.101.3.4.2.1"></ds:DigestMethod>
> > 20: <ds:DigestValue>E8re2OFo7sUq0C78R6ueaC8M56xQjvy97OFU9sgaw1U=</ds:DigestValue>
> > 21: </vt:DigestAlgAndValue>
> > 22: </vt:BeforeVerification>
> >
> >
> > On Sep 20, 2012, at 1:02 AM, Niall Gallagher - Yieldbroker wrote:
> >
> >> 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
> >
>
|
|
From: Niall G. - Y. <Nia...@yi...> - 2012-09-20 08:11:04
|
So I take it that the test is in TestLP7VerifyBoxTokenParser
From: Thomas [mailto:tho...@gm...]
Sent: Thursday, 20 September 2012 6:08 PM
To: Niall Gallagher - Yieldbroker
Cc: sim...@li...
Subject: Re: [Simple-support] Does not understand this ElementException
Of course !
I joined an archive with Simple entities, the unit test, the xml file and xsd schemas.
On Sep 20, 2012, at 9:47 AM, Niall Gallagher - Yieldbroker wrote:
> Could you send me a JUnit test case, if I can run it and break then I can tell you what is wrong. Its difficult to say from just the snippets here.
>
> -----Original Message-----
> From: Thomas [mailto:tho...@gm...]
> Sent: Thursday, 20 September 2012 5:38 PM
> To: Niall Gallagher - Yieldbroker
> Cc: sim...@li...<mailto:sim...@li...>
> Subject: Re: [Simple-support] Does not understand this ElementException
>
> Hello,
>
> First, thank you for your reply.
>
> In the previous mail, I extracted the piece of XML code where the line 43 is. Here is with line numbers:
>
> ...other datas...
> 42: <vt:SignedDataObject Id="signeddata1">
> 43: <vt:Encapsulated>true</vt:Encapsulated>
> 44: <vt:MimeType>application/pdf</vt:MimeType>
> 45: <vt:Name>signeddata-1.pdf</vt:Name>
> 46: <vt:Size>131323</vt:Size>
> 47: <vt:DigestAlgAndValue>
> 48: <ds:DigestMethod Algorithm="1.3.14.3.2.26"></ds:DigestMethod>
> 49: <ds:DigestValue>KuWqL3YVcSMZeHRov5nE90PZSeY=</ds:DigestValue>
> 50: </vt:DigestAlgAndValue>
> 51: </vt:SignedDataObject>
> ...other datas...
>
> As you can see, the Id attribute is set.
>
> And here is the Java class which modelize the DigestAlgAndValueType XML type:
>
> public class DigestAlgAndValueType {
>
> @Element(name = "DigestMethod", required = true)
> protected DigestMethodType digestMethod;
>
> @Element(name = "DigestValue", required = true)
> protected String encodedDigestValue;
>
> protected byte[] digestValue;
>
> @Commit
> public void commit() {
> digestValue = Base64.decode(encodedDigestValue);
> encodedDigestValue = null;
> }
>
> @Persist
> public void prepare() {
> encodedDigestValue = new String(Base64.encode(digestValue));
> }
>
> @Complete
> public void release() {
> encodedDigestValue = null;
> }
>
> ... getters and setters...
> }
>
> I don't understand about the DigestAlgAndValueType because it is already used in the XML and the mapping works. Here is the piece of XML file which work and which use DigestAlgAndValueType:
>
> 16: <vt:BeforeVerification>
> 17: <vt:Size>131323</vt:Size>
> 18: <vt:DigestAlgAndValue>
> 19: <ds:DigestMethod Algorithm="2.16.840.1.101.3.4.2.1"></ds:DigestMethod>
> 20: <ds:DigestValue>E8re2OFo7sUq0C78R6ueaC8M56xQjvy97OFU9sgaw1U=</ds:DigestValue>
> 21: </vt:DigestAlgAndValue>
> 22: </vt:BeforeVerification>
>
>
> On Sep 20, 2012, at 1:02 AM, Niall Gallagher - Yieldbroker wrote:
>
>> 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...<mailto: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...<mailto:Sim...@li...>
>> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|
|
From: Niall G. - Y. <Nia...@yi...> - 2012-09-20 07:47:56
|
Could you send me a JUnit test case, if I can run it and break then I can tell you what is wrong. Its difficult to say from just the snippets here.
-----Original Message-----
From: Thomas [mailto:tho...@gm...]
Sent: Thursday, 20 September 2012 5:38 PM
To: Niall Gallagher - Yieldbroker
Cc: sim...@li...
Subject: Re: [Simple-support] Does not understand this ElementException
Hello,
First, thank you for your reply.
In the previous mail, I extracted the piece of XML code where the line 43 is. Here is with line numbers:
...other datas...
42: <vt:SignedDataObject Id="signeddata1">
43: <vt:Encapsulated>true</vt:Encapsulated>
44: <vt:MimeType>application/pdf</vt:MimeType>
45: <vt:Name>signeddata-1.pdf</vt:Name>
46: <vt:Size>131323</vt:Size>
47: <vt:DigestAlgAndValue>
48: <ds:DigestMethod Algorithm="1.3.14.3.2.26"></ds:DigestMethod>
49: <ds:DigestValue>KuWqL3YVcSMZeHRov5nE90PZSeY=</ds:DigestValue>
50: </vt:DigestAlgAndValue>
51: </vt:SignedDataObject>
...other datas...
As you can see, the Id attribute is set.
And here is the Java class which modelize the DigestAlgAndValueType XML type:
public class DigestAlgAndValueType {
@Element(name = "DigestMethod", required = true)
protected DigestMethodType digestMethod;
@Element(name = "DigestValue", required = true)
protected String encodedDigestValue;
protected byte[] digestValue;
@Commit
public void commit() {
digestValue = Base64.decode(encodedDigestValue);
encodedDigestValue = null;
}
@Persist
public void prepare() {
encodedDigestValue = new String(Base64.encode(digestValue));
}
@Complete
public void release() {
encodedDigestValue = null;
}
... getters and setters...
}
I don't understand about the DigestAlgAndValueType because it is already used in the XML and the mapping works. Here is the piece of XML file which work and which use DigestAlgAndValueType:
16: <vt:BeforeVerification>
17: <vt:Size>131323</vt:Size>
18: <vt:DigestAlgAndValue>
19: <ds:DigestMethod Algorithm="2.16.840.1.101.3.4.2.1"></ds:DigestMethod>
20: <ds:DigestValue>E8re2OFo7sUq0C78R6ueaC8M56xQjvy97OFU9sgaw1U=</ds:DigestValue>
21: </vt:DigestAlgAndValue>
22: </vt:BeforeVerification>
On Sep 20, 2012, at 1:02 AM, Niall Gallagher - Yieldbroker wrote:
> 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
|
|
From: Thomas <tho...@gm...> - 2012-09-20 07:38:26
|
Hello,
First, thank you for your reply.
In the previous mail, I extracted the piece of XML code where the line 43 is. Here is with line numbers:
...other datas...
42: <vt:SignedDataObject Id="signeddata1">
43: <vt:Encapsulated>true</vt:Encapsulated>
44: <vt:MimeType>application/pdf</vt:MimeType>
45: <vt:Name>signeddata-1.pdf</vt:Name>
46: <vt:Size>131323</vt:Size>
47: <vt:DigestAlgAndValue>
48: <ds:DigestMethod Algorithm="1.3.14.3.2.26"></ds:DigestMethod>
49: <ds:DigestValue>KuWqL3YVcSMZeHRov5nE90PZSeY=</ds:DigestValue>
50: </vt:DigestAlgAndValue>
51: </vt:SignedDataObject>
...other datas...
As you can see, the Id attribute is set.
And here is the Java class which modelize the DigestAlgAndValueType XML type:
public class DigestAlgAndValueType {
@Element(name = "DigestMethod", required = true)
protected DigestMethodType digestMethod;
@Element(name = "DigestValue", required = true)
protected String encodedDigestValue;
protected byte[] digestValue;
@Commit
public void commit() {
digestValue = Base64.decode(encodedDigestValue);
encodedDigestValue = null;
}
@Persist
public void prepare() {
encodedDigestValue = new String(Base64.encode(digestValue));
}
@Complete
public void release() {
encodedDigestValue = null;
}
... getters and setters...
}
I don't understand about the DigestAlgAndValueType because it is already used in the XML and the mapping works. Here is the piece of XML file which work and which use DigestAlgAndValueType:
16: <vt:BeforeVerification>
17: <vt:Size>131323</vt:Size>
18: <vt:DigestAlgAndValue>
19: <ds:DigestMethod Algorithm="2.16.840.1.101.3.4.2.1"></ds:DigestMethod>
20: <ds:DigestValue>E8re2OFo7sUq0C78R6ueaC8M56xQjvy97OFU9sgaw1U=</ds:DigestValue>
21: </vt:DigestAlgAndValue>
22: </vt:BeforeVerification>
On Sep 20, 2012, at 1:02 AM, Niall Gallagher - Yieldbroker wrote:
> 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
|
|
From: Dawid W. <daw...@gm...> - 2012-09-20 07:07:04
|
I'm not pressing on you to do it asap, I realize it's a borderline use case (most people will not be affected by this if they know their Strings contain valid unicode text, not some junk). I think the patch to Formatter could be based on the workaround I did with the transformer: http://goo.gl/8tYjR what happens is every "text" to be emitted is first checked (isMappableXmlText) and if it's conforming to the spec is passed through. If it's not valid XML text the offending characters are replaced with a "replacement character" from Unicode (it's the boxed question mark typically). Now, for the Formatter it'd probably need to take a configurable logic. Structural XML elements (element names, attribute names, namespaces etc.) should throw exceptions if they're declared with invalid characters inside. As for attribute and text blocks perhaps this should be configurable -- either an encoding exception (IOException) or a quiet replacement of offending characters much like in my code above. This would be somewhat consistent with Java's built-in charencoders. Again, this is by no means a critical feature -- like you see it can be hacked around in a pretty simple way -- just something to thing about and consider. Dawid On Thu, Sep 20, 2012 at 1:12 AM, Niall Gallagher - Yieldbroker <Nia...@yi...> wrote: > Hi Dawid, > > If you can suggest a simple fix perhaps in the Formatter that you think will be 100% XML compliant and make the Persister more resilient then let me know. Ill add it in to the next release. I think a full on strategy would be great, however it is something that I probably will not get time to do for a while. > > Thanks, > Niall > > -----Original Message----- > From: Dawid Weiss [mailto:daw...@gm...] > Sent: Wednesday, 19 September 2012 4:51 PM > To: sim...@li... > Subject: [Simple-support] Invalid unicode characters in XML stream > > Niall, you asked if this is a problem in practice -- see this build log, for example: > > http://jenkins.sd-datasolutions.de/job/Lucene-Solr-4.x-Linux/1199/consoleText > > it failed for exactly the reasons I mentioned -- invalid unicode character in a throwable's message, serialized via simple-xml's model for ANT's junit files. I think it should be fixed at some point and I think it should be the default behavior to always produce valid XML, no matter what the performance penalty might be. > > Perhaps Formatter should be a replaceable strategy? Doesn't seem like there are that many options there, but it could be fun too -- think of a binary-XML formatter :) Just a thought. > > Dawid > > ------------------------------------------------------------------------------ > 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 |
|
From: Niall G. - Y. <Nia...@yi...> - 2012-09-19 23:12:55
|
Hi Dawid, If you can suggest a simple fix perhaps in the Formatter that you think will be 100% XML compliant and make the Persister more resilient then let me know. Ill add it in to the next release. I think a full on strategy would be great, however it is something that I probably will not get time to do for a while. Thanks, Niall -----Original Message----- From: Dawid Weiss [mailto:daw...@gm...] Sent: Wednesday, 19 September 2012 4:51 PM To: sim...@li... Subject: [Simple-support] Invalid unicode characters in XML stream Niall, you asked if this is a problem in practice -- see this build log, for example: http://jenkins.sd-datasolutions.de/job/Lucene-Solr-4.x-Linux/1199/consoleText it failed for exactly the reasons I mentioned -- invalid unicode character in a throwable's message, serialized via simple-xml's model for ANT's junit files. I think it should be fixed at some point and I think it should be the default behavior to always produce valid XML, no matter what the performance penalty might be. Perhaps Formatter should be a replaceable strategy? Doesn't seem like there are that many options there, but it could be fun too -- think of a binary-XML formatter :) Just a thought. Dawid ------------------------------------------------------------------------------ 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 |
|
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
|
|
From: Thomas <tho...@gm...> - 2012-09-19 13:05:17
|
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
|
|
From: Dawid W. <daw...@gm...> - 2012-09-19 06:51:23
|
Niall, you asked if this is a problem in practice -- see this build log, for example: http://jenkins.sd-datasolutions.de/job/Lucene-Solr-4.x-Linux/1199/consoleText it failed for exactly the reasons I mentioned -- invalid unicode character in a throwable's message, serialized via simple-xml's model for ANT's junit files. I think it should be fixed at some point and I think it should be the default behavior to always produce valid XML, no matter what the performance penalty might be. Perhaps Formatter should be a replaceable strategy? Doesn't seem like there are that many options there, but it could be fun too -- think of a binary-XML formatter :) Just a thought. Dawid |
|
From: Dawid W. <daw...@gm...> - 2012-09-13 10:06:02
|
> Are you suggesting there is a bug?
Depends how you look at it. It's a confluence of different things --
the fact that Java Strings can be invalid unicode, the fact that XML
does not allow all unicode characters to appear in the stream, etc. I
think it would be nicer by default if the framework had an invariant
of _always_ producing valid XML and from this point of view it is a
bug. Try to serialize:
@Root("abc")
public class Abc {
@Attribute
public String s = new String("\u0000");
}
and you'll see this produces an XML that won't parse with any
(conforming) parser. It's an invalid XML.
> I think for faster processing something could be done in the org.simpleframework.xml.stream.Formatter object
Yes, from a quick look at it, it could also be used for this purpose.
> You could also write your own java.io.Writer object. If these are not suitable then I think your Transform<String> is probably best.
I don't think a custom Writer would be a better solution. It is a
derivative of XML specification so if simple-xml would want to be
strictly conformant it should, for example, reject attribute and
element names that contain unmappable XML characters, remap or reject
unmappable characters inside attribute values and text blocks, etc.
The attached patch solves the problem for me, I'm just pointing out
the issue if you wanted to tackle it in a more general way. A
randomized test case trying out if it work is also here:
http://goo.gl/GyDWm
Dawid
|
|
From: Niall G. <gal...@ya...> - 2012-09-13 09:53:40
|
Hi, Are you suggesting there is a bug? I think for faster processing something could be done in the org.simpleframework.xml.stream.Formatter object, however I am not sure there is a problem here though that needs to be fixed. You could also write your own java.io.Writer object. If these are not suitable then I think your Transform<String> is probably best. Thanks, Niall --- On Thu, 13/9/12, Dawid Weiss <daw...@gm...> wrote: > From: Dawid Weiss <daw...@gm...> > Subject: [Simple-support] Valid XML characters and String recoding > To: sim...@li... > Received: Thursday, 13 September, 2012, 1:46 AM > Hi Niall, everyone. > > I'd like to bring up the issue that occurred to me in > practice. We > have input data which we serialize via simple-xml to > external XML > files. Everything works like a charm except when there are > String > objects with unmappable XML characters in the data model. We > don't > have any control over these strings and need to make sure > the produced > XML is always valid (parseable). > > The spec (and wikipedia) say the following: > > Unicode code points in the following ranges are valid in XML > 1.0 documents:[10] > - U+0009, U+000A, U+000D: these are the only C0 controls > accepted in XML 1.0; > - U+0020–U+D7FF, U+E000–U+FFFD: this excludes some (not > all) > non-characters in the BMP (all surrogates, U+FFFE and U+FFFF > are > forbidden); > - U+10000–U+10FFFF: this includes all code points in > supplementary > planes, including non-characters. > > Unfortunately at the moment characters outside of these > ranges are > passed to the XML stream writer and in effect produce > invalid XML. > > There are no "simple" solutions but there are workarounds. I > used a > Transform<String> to recode all the strings that had > invalid > characters before serialization. This seems like a sensible > solution > to use by default (although it does come with a performance > penalty). > > Looking forward to hearing your thoughts about this, > Dawid > > ------------------------------------------------------------------------------ > 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 > |
|
From: Dawid W. <daw...@gm...> - 2012-09-13 08:46:50
|
Hi Niall, everyone. I'd like to bring up the issue that occurred to me in practice. We have input data which we serialize via simple-xml to external XML files. Everything works like a charm except when there are String objects with unmappable XML characters in the data model. We don't have any control over these strings and need to make sure the produced XML is always valid (parseable). The spec (and wikipedia) say the following: Unicode code points in the following ranges are valid in XML 1.0 documents:[10] - U+0009, U+000A, U+000D: these are the only C0 controls accepted in XML 1.0; - U+0020–U+D7FF, U+E000–U+FFFD: this excludes some (not all) non-characters in the BMP (all surrogates, U+FFFE and U+FFFF are forbidden); - U+10000–U+10FFFF: this includes all code points in supplementary planes, including non-characters. Unfortunately at the moment characters outside of these ranges are passed to the XML stream writer and in effect produce invalid XML. There are no "simple" solutions but there are workarounds. I used a Transform<String> to recode all the strings that had invalid characters before serialization. This seems like a sensible solution to use by default (although it does come with a performance penalty). Looking forward to hearing your thoughts about this, Dawid |
|
From: Arthur E. <ar...@bl...> - 2012-09-07 08:41:35
|
Thanks Niall that works great.
On Fri, Sep 7, 2012 at 12:11 AM, Niall Gallagher - Yieldbroker <
Nia...@yi...> wrote:
> I have fixed this in the SVN trunk, but have not released it. You can
> check it out, then it should work for you if you do ‘ant build’.****
>
> ** **
>
> *From:* Arthur Embleton [mailto:ar...@bl...]
> *Sent:* Friday, 7 September 2012 2:57 AM
> *To:* sim...@li...
> *Subject:* [Simple-support] Error when all elements have the same name****
>
> ** **
>
> I have some XML such as the following:****
>
> <rdr>
> <details>
>
> ****
>
> ** **
>
> ** **
>
> <detail>****
>
> <name>version</name>
> <value>15.0</value>****
>
> </detail>
> <detail>
> <name>resolution</name>****
>
> <value>1080X1920</value>
> </detail>
> <detail>
>
> ****
>
> ** **
>
> ** **
>
> <name>browser</name>****
>
> <value>Firefox</value>
> </detail>****
>
> </details>
> </rdr>****
>
>
> and I would like to map this to a bean so I have the following properties:
> ****
>
> @Path("details/detail[1]")
> @Element(name = "value")****
>
> private String version;
>
> @Path("details/detail[2]")
> @Element(name = "value")****
>
> private String resolution;
>
> @Path("details/detail[4]")
> @Element(name = "value")****
>
> private String browser;
>
> This results in a null pointer exception because they all have the same element names. InstantiatorBuilder.register(Label, Map) is putting a null as the value against any keys that are repeated.
>
> ****
>
> ** **
>
>
> What is the reasoning behind this?
>
> I commented this out and my code runs fine, but UnionWithSameNamesAndDifferentPathsTest.testErrorInParametersExample failed because "Ambiguous parameter should cause a failure". I can't understand what this test is trying to test!
>
> ****
>
> ** **
>
>
> ~
> Arthur****
>
>
|
|
From: Niall G. - Y. <Nia...@yi...> - 2012-09-06 23:11:53
|
I have fixed this in the SVN trunk, but have not released it. You can check it out, then it should work for you if you do 'ant build'.
From: Arthur Embleton [mailto:ar...@bl...]
Sent: Friday, 7 September 2012 2:57 AM
To: sim...@li...
Subject: [Simple-support] Error when all elements have the same name
I have some XML such as the following:
<rdr>
<details>
<detail>
<name>version</name>
<value>15.0</value>
</detail>
<detail>
<name>resolution</name>
<value>1080X1920</value>
</detail>
<detail>
<name>browser</name>
<value>Firefox</value>
</detail>
</details>
</rdr>
and I would like to map this to a bean so I have the following properties:
@Path("details/detail[1]")
@Element(name = "value")
private String version;
@Path("details/detail[2]")
@Element(name = "value")
private String resolution;
@Path("details/detail[4]")
@Element(name = "value")
private String browser;
This results in a null pointer exception because they all have the same element names. InstantiatorBuilder.register(Label, Map) is putting a null as the value against any keys that are repeated.
What is the reasoning behind this?
I commented this out and my code runs fine, but UnionWithSameNamesAndDifferentPathsTest.testErrorInParametersExample failed because "Ambiguous parameter should cause a failure". I can't understand what this test is trying to test!
~
Arthur
|
|
From: Arthur E. <ar...@bl...> - 2012-09-06 16:57:00
|
I have some XML such as the following:
<rdr>
<details>
<detail>
<name>version</name>
<value>15.0</value>
</detail>
<detail>
<name>resolution</name>
<value>1080X1920</value>
</detail>
<detail>
<name>browser</name>
<value>Firefox</value>
</detail>
</details>
</rdr>
and I would like to map this to a bean so I have the following properties:
@Path("details/detail[1]")
@Element(name = "value")private String version;
@Path("details/detail[2]")
@Element(name = "value")private String resolution;
@Path("details/detail[4]")
@Element(name = "value")private String browser;
This results in a null pointer exception because they all have the
same element names. InstantiatorBuilder.register(Label, Map) is
putting a null as the value against any keys that are repeated.
What is the reasoning behind this?
I commented this out and my code runs fine, but
UnionWithSameNamesAndDifferentPathsTest.testErrorInParametersExample
failed because "Ambiguous parameter should cause a failure". I can't
understand what this test is trying to test!
~
Arthur
|