simple-support Mailing List for Simple (Page 70)
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: Mirza A. R. <abb...@ya...> - 2008-12-10 23:54:45
|
Thanks for the suggestion! I have to switch gears to take up an urgent thing that has come up at work. I will be back to this project next Monday. However, I will be thinking about this issue during this week. I may have to brainstorm with a colleague later this week. I will keep you posted.
________________________________
From: Niall Gallagher <gal...@ya...>
To: Niall Gallagher <gal...@ya...>; Mirza Abbas Raza <abb...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 3:10:56 PM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
Sorry, where I said "This is not detached from your object model" I meant "This is not atttached from your object model".
Niall
________________________________
From: Niall Gallagher <gal...@ya...>
To: Mirza Abbas Raza <abb...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 11:09:04 PM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
Hi,
Well here is what I am thinking. Are you going to be writing more or less code to add static data to the document. I mean if I were to write a decorator that would match the element name or class to complement the attributes and elements like so.
public void decorate(OutputNode node) {
if(x) {
node.addSomething();
} else {
node.addSomethingElse();
}
}
This is not detached from your object model, ant it will be much harder to maintain. Take XStream where the XML structure is not attached to the object. You have to bind by somethiing else, things become difficult to trace. In what way is it associated and how to you know it is. Do you follow the call hierarchies, do you trace the types matched, is it obvious to someone that is new to this code. I would imagine not. It is scattered code, not fundamentally associated with your object model. You just end up writing more code. I realise adding redundant fields or methods is not ideal for your code. But is there any way that involves less coding and is more obvious? I can't think of any simple way to do this that requires less effort and is more obvious than annotating a field. I you can I am very interested.
Look forward to hearing your suggestions,
Niall
________________________________
From: Mirza Abbas Raza <abb...@ya...>
To: Niall Gallagher <gal...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 10:19:37 PM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
First off, thanks for the quick reply. The elements typeId, templateId, id, code etc. sprayed around in the document are static. They do not change. Rest of the other elements like custodian, participant etc. are dynamic. The static content has to be be just sticked in. I have not thought in detail about how I would inject in those static elements. Probably I will have objects that read the text literals from a configuration file and have them as instance variables. This is just a thought at this point. Suggestions?
Thanks!
________________________________
From: Niall Gallagher <gal...@ya...>
To: Mirza Abbas Raza <abb...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 11:48:12 AM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
Hi,
Took a look at the document, it looks pretty easy to parse. However, I
am not sure what you mean by static content? What difference has this
to the dynamic content, that it does not change? If so what do you need
to achieve, and how do you envision handling static content and how would it differ from dynamic content?
Regards,
Niall
________________________________
From: Mirza Abbas Raza <abb...@ya...>
To: sim...@li...
Sent: Wednesday, December 10, 2008 7:23:18 PM
Subject: [Simple-support] Any suggestion for static and dynamic xml content serialization
Hi,
In the XML that I have to serialize, the content is roughly 20% static (Standardized IDs and such) and 80% dynamic. The document in question is the Continuity of Care Document (http://www.himssehrva.org/ASP/CCD_QSG_20071112.asp). I am debating using XSLT/XSD based serializers or annotation based libraries. With XSLT based serializers, the nice thing is that the static content can easily be extracted out in the XSLT. However, the performance takes the hit with the process of creating the XML in the first place and doing the transformation. Also, one would have to maintain the XSLT. On the other hand, with Simple, we would not have to maintain any XMLs/XSLTs and the performance would be better on the premise that there are fewer steps involved in serialization. The only downside I see is to produce static content in Java. Is there any mechanism that Simple can provide to handle this issue? At this point, from the tutorial, I did not find one. Appreciate
any help.
Thanks,
Abbas |
|
From: Niall G. <gal...@ya...> - 2008-12-10 23:10:59
|
Sorry, where I said "This is not detached from your object model" I meant "This is not atttached from your object model".
Niall
________________________________
From: Niall Gallagher <gal...@ya...>
To: Mirza Abbas Raza <abb...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 11:09:04 PM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
Hi,
Well here is what I am thinking. Are you going to be writing more or less code to add static data to the document. I mean if I were to write a decorator that would match the element name or class to complement the attributes and elements like so.
public void decorate(OutputNode node) {
if(x) {
node.addSomething();
} else {
node.addSomethingElse();
}
}
This is not detached from your object model, ant it will be much harder to maintain. Take XStream where the XML structure is not attached to the object. You have to bind by somethiing else, things become difficult to trace. In what way is it associated and how to you know it is. Do you follow the call hierarchies, do you trace the types matched, is it obvious to someone that is new to this code. I would imagine not. It is scattered code, not fundamentally associated with your object model. You just end up writing more code. I realise adding redundant fields or methods is not ideal for your code. But is there any way that involves less coding and is more obvious? I can't think of any simple way to do this that requires less effort and is more obvious than annotating a field. I you can I am very interested.
Look forward to hearing your suggestions,
Niall
________________________________
From: Mirza Abbas Raza <abb...@ya...>
To: Niall Gallagher <gal...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 10:19:37 PM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
First off, thanks for the quick reply. The elements typeId, templateId, id, code etc. sprayed around in the document are static. They do not change. Rest of the other elements like custodian, participant etc. are dynamic. The static content has to be be just sticked in. I have not thought in detail about how I would inject in those static elements. Probably I will have objects that read the text literals from a configuration file and have them as instance variables. This is just a thought at this point. Suggestions?
Thanks!
________________________________
From: Niall Gallagher <gal...@ya...>
To: Mirza Abbas Raza <abb...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 11:48:12 AM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
Hi,
Took a look at the document, it looks pretty easy to parse. However, I
am not sure what you mean by static content? What difference has this
to the dynamic content, that it does not change? If so what do you need
to achieve, and how do you envision handling static content and how would it differ from dynamic content?
Regards,
Niall
________________________________
From: Mirza Abbas Raza <abb...@ya...>
To: sim...@li...
Sent: Wednesday, December 10, 2008 7:23:18 PM
Subject: [Simple-support] Any suggestion for static and dynamic xml content serialization
Hi,
In the XML that I have to serialize, the content is roughly 20% static (Standardized IDs and such) and 80% dynamic. The document in question is the Continuity of Care Document (http://www.himssehrva.org/ASP/CCD_QSG_20071112.asp). I am debating using XSLT/XSD based serializers or annotation based libraries. With XSLT based serializers, the nice thing is that the static content can easily be extracted out in the XSLT. However, the performance takes the hit with the process of creating the XML in the first place and doing the transformation. Also, one would have to maintain the XSLT. On the other hand, with Simple, we would not have to maintain any XMLs/XSLTs and the performance would be better on the premise that there are fewer steps involved in serialization. The only downside I see is to produce static content in Java. Is there any mechanism that Simple can provide to handle this issue? At this point, from the tutorial, I did not find one. Appreciate
any help.
Thanks,
Abbas
|
|
From: Niall G. <gal...@ya...> - 2008-12-10 23:09:07
|
Hi,
Well here is what I am thinking. Are you going to be writing more or less code to add static data to the document. I mean if I were to write a decorator that would match the element name or class to complement the attributes and elements like so.
public void decorate(OutputNode node) {
if(x) {
node.addSomething();
} else {
node.addSomethingElse();
}
}
This is not detached from your object model, ant it will be much harder to maintain. Take XStream where the XML structure is not attached to the object. You have to bind by somethiing else, things become difficult to trace. In what way is it associated and how to you know it is. Do you follow the call hierarchies, do you trace the types matched, is it obvious to someone that is new to this code. I would imagine not. It is scattered code, not fundamentally associated with your object model. You just end up writing more code. I realise adding redundant fields or methods is not ideal for your code. But is there any way that involves less coding and is more obvious? I can't think of any simple way to do this that requires less effort and is more obvious than annotating a field. I you can I am very interested.
Look forward to hearing your suggestions,
Niall
________________________________
From: Mirza Abbas Raza <abb...@ya...>
To: Niall Gallagher <gal...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 10:19:37 PM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
First off, thanks for the quick reply. The elements typeId, templateId, id, code etc. sprayed around in the document are static. They do not change. Rest of the other elements like custodian, participant etc. are dynamic. The static content has to be be just sticked in. I have not thought in detail about how I would inject in those static elements. Probably I will have objects that read the text literals from a configuration file and have them as instance variables. This is just a thought at this point. Suggestions?
Thanks!
________________________________
From: Niall Gallagher <gal...@ya...>
To: Mirza Abbas Raza <abb...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 11:48:12 AM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
Hi,
Took a look at the document, it looks pretty easy to parse. However, I
am not sure what you mean by static content? What difference has this
to the dynamic content, that it does not change? If so what do you need
to achieve, and how do you envision handling static content and how would it differ from dynamic content?
Regards,
Niall
________________________________
From: Mirza Abbas Raza <abb...@ya...>
To: sim...@li...
Sent: Wednesday, December 10, 2008 7:23:18 PM
Subject: [Simple-support] Any suggestion for static and dynamic xml content serialization
Hi,
In the XML that I have to serialize, the content is roughly 20% static (Standardized IDs and such) and 80% dynamic. The document in question is the Continuity of Care Document (http://www.himssehrva.org/ASP/CCD_QSG_20071112.asp). I am debating using XSLT/XSD based serializers or annotation based libraries. With XSLT based serializers, the nice thing is that the static content can easily be extracted out in the XSLT. However, the performance takes the hit with the process of creating the XML in the first place and doing the transformation. Also, one would have to maintain the XSLT. On the other hand, with Simple, we would not have to maintain any XMLs/XSLTs and the performance would be better on the premise that there are fewer steps involved in serialization. The only downside I see is to produce static content in Java. Is there any mechanism that Simple can provide to handle this issue? At this point, from the tutorial, I did not find one. Appreciate
any help.
Thanks,
Abbas
|
|
From: Mirza A. R. <abb...@ya...> - 2008-12-10 22:19:42
|
First off, thanks for the quick reply. The elements typeId, templateId, id, code etc. sprayed around in the document are static. They do not change. Rest of the other elements like custodian, participant etc. are dynamic. The static content has to be be just sticked in. I have not thought in detail about how I would inject in those static elements. Probably I will have objects that read the text literals from a configuration file and have them as instance variables. This is just a thought at this point. Suggestions? Thanks! ________________________________ From: Niall Gallagher <gal...@ya...> To: Mirza Abbas Raza <abb...@ya...>; sim...@li... Sent: Wednesday, December 10, 2008 11:48:12 AM Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization Hi, Took a look at the document, it looks pretty easy to parse. However, I am not sure what you mean by static content? What difference has this to the dynamic content, that it does not change? If so what do you need to achieve, and how do you envision handling static content and how would it differ from dynamic content? Regards, Niall ________________________________ From: Mirza Abbas Raza <abb...@ya...> To: sim...@li... Sent: Wednesday, December 10, 2008 7:23:18 PM Subject: [Simple-support] Any suggestion for static and dynamic xml content serialization Hi, In the XML that I have to serialize, the content is roughly 20% static (Standardized IDs and such) and 80% dynamic. The document in question is the Continuity of Care Document (http://www.himssehrva.org/ASP/CCD_QSG_20071112.asp). I am debating using XSLT/XSD based serializers or annotation based libraries. With XSLT based serializers, the nice thing is that the static content can easily be extracted out in the XSLT. However, the performance takes the hit with the process of creating the XML in the first place and doing the transformation. Also, one would have to maintain the XSLT. On the other hand, with Simple, we would not have to maintain any XMLs/XSLTs and the performance would be better on the premise that there are fewer steps involved in serialization. The only downside I see is to produce static content in Java. Is there any mechanism that Simple can provide to handle this issue? At this point, from the tutorial, I did not find one. Appreciate any help. Thanks, Abbas |
|
From: Niall G. <gal...@ya...> - 2008-12-10 19:48:17
|
Hi, Took a look at the document, it looks pretty easy to parse. However, I am not sure what you mean by static content? What difference has this to the dynamic content, that it does not change? If so what do you need to achieve, and how do you envision handling static content and how would it differ from dynamic content? Regards, Niall ________________________________ From: Mirza Abbas Raza <abb...@ya...> To: sim...@li... Sent: Wednesday, December 10, 2008 7:23:18 PM Subject: [Simple-support] Any suggestion for static and dynamic xml content serialization Hi, In the XML that I have to serialize, the content is roughly 20% static (Standardized IDs and such) and 80% dynamic. The document in question is the Continuity of Care Document (http://www.himssehrva.org/ASP/CCD_QSG_20071112.asp). I am debating using XSLT/XSD based serializers or annotation based libraries. With XSLT based serializers, the nice thing is that the static content can easily be extracted out in the XSLT. However, the performance takes the hit with the process of creating the XML in the first place and doing the transformation. Also, one would have to maintain the XSLT. On the other hand, with Simple, we would not have to maintain any XMLs/XSLTs and the performance would be better on the premise that there are fewer steps involved in serialization. The only downside I see is to produce static content in Java. Is there any mechanism that Simple can provide to handle this issue? At this point, from the tutorial, I did not find one. Appreciate any help. Thanks, Abbas |
|
From: Mirza A. R. <abb...@ya...> - 2008-12-10 19:23:23
|
Hi, In the XML that I have to serialize, the content is roughly 20% static (Standardized IDs and such) and 80% dynamic. The document in question is the Continuity of Care Document (http://www.himssehrva.org/ASP/CCD_QSG_20071112.asp). I am debating using XSLT/XSD based serializers or annotation based libraries. With XSLT based serializers, the nice thing is that the static content can easily be extracted out in the XSLT. However, the performance takes the hit with the process of creating the XML in the first place and doing the transformation. Also, one would have to maintain the XSLT. On the other hand, with Simple, we would not have to maintain any XMLs/XSLTs and the performance would be better on the premise that there are fewer steps involved in serialization. The only downside I see is to produce static content in Java. Is there any mechanism that Simple can provide to handle this issue? At this point, from the tutorial, I did not find one. Appreciate any help. Thanks, Abbas |
|
From: Niall G. <gal...@ya...> - 2008-12-07 20:21:56
|
Hi, Simple 2.0 has been released with namespace support, versioning capabilities introduced, and customizable transformations (e.g transformation of a java.util.Date, java.util.Calendar, or other such types that can be converted to an from a string). Also, I have moved the org.simpleframework.xml.load package to org.simpleframework.xml.core, however everything else remains fully backward compatible. All that is needed is to change your imports and everything will work as before. Thanks for your assistance with namespaces Saurabh, very much appreciated. Niall ----- Original Message ---- From: "Nia...@ub..." <Nia...@ub...> To: sau...@ya...; sim...@li... Sent: Friday, November 28, 2008 6:12:05 PM Subject: Re: [Simple-support] Support for namespaces and comment in SimpleXML Hi, Cool any suggestions would be appreciated. Although I am familiar with namespaces and how they work I am not sure how to apply them to an XML serialization framework through annotations. Ill look forward to any suggestions you might have on how to apply them. Thanks, Niall -----Original Message----- From: saurabh sule [mailto:sau...@ya...] Sent: 28 November 2008 16:54 To: Gallagher, Niall-N; sim...@li... Subject: Re: [Simple-support] Support for namespaces and comment in SimpleXML Hi Niall I presume you might have gone through this link, but if you haven't then you can quickly scan through this link and you might get some idea of as to how the namespaces work and get inherited: http://www.w3.org/TR/REC-xml-names/ To make it quick just go through the section : 6 Applying Namespaces to Elements and Attributes I will return back with more on how to apply namespaces and will try to provide certain suggestions as to how we can do that using SimpleXML. Hopefully the above link will get you thinking. Regards, Saurabh. ----- Original Message ---- From: "Nia...@ub..." <Nia...@ub...> To: sau...@ya...; sim...@li... Sent: Friday, 28 November, 2008 3:54:41 PM Subject: RE: [Simple-support] Support for namespaces and comment in SimpleXML Hi, I have been working on 1.8 recently, which should be ready for release shortly enough. The only problem I have with namespaces is how to do it properly. By this I mean how are namespaces inherited? And if they are inherited does this mean that your XML class components are coupled by namespace? An annotation such as @Namespace(prefix='prefix', location='http://domain.com/location') @Root public class Example { @Attribute priavte String name; @Element private Component value; } Resulting in the following XML. <example name='name' xmlns:prefix='http://domain.com/location'> <component attribute='value'> // does this inherit the namespace....? </component> </example> The last thing I want to do is implement namespaces badly, and then have to refactor it breaking backward compatibility. If anyone has experience on how JAXB or C# XML serialization tackles the issue of namespaces I would love to see some examples of how they have done it. Without a clear idea on how to do this it will take me some time to look in to it, and this is why its taking so long, as time is very difficult to get. If there are any good ideas or examples of how to do this, in particular with reference to a successful scheme used by another project. Then I am sure I could progress with this sooner rather than later (perhaps in the 1.8 release)? Niall -----Original Message----- From: saurabh sule [mailto:sau...@ya...] Sent: 28 November 2008 07:45 To: sim...@li... Subject: [Simple-support] Support for namespaces and comment in SimpleXML Hi Niall, Wonderful project you have got there. I have just started to use SimpleXML and I need some support from the APIs. I already see a request for the namespace support in SimpleXML and have seen a reply from you dated: 2008-07-31, stating that it will be done and released by end of August. I have started working with the latest download: Simple 1.7.3, dated: 18 October 2008. But I still don't see proper support for namespaces. As suggested by Patrick Strum, I have tried using @Attribute(name="xmlns:p") kind of annotations but it doesn't seem to work. Can you suggest an alternative way of supporting namespaces? When can we expect the namespace support? Support for comments is also not there. But comments are not that greater an issue as namespaces are. Between, just for the information, we have selected SimpleXML over XStream from codehaus. With namespace support in place, SimpleXML will do the trick for us. Regards, Saurabh. Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/ ------------------------------------------------------------------------ - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company registered in England & Wales under company number 2035362, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS AG (London Branch) is registered as a branch of a foreign company under number BR004507, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS Clearing and Execution Services Limited is a company registered in England & Wales under company number 03123037, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. Be the first one to try the new Messenger 9 Beta! Go to http://in.messenger.yahoo.com/win/ Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company registered in England & Wales under company number 2035362, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS AG (London Branch) is registered as a branch of a foreign company under number BR004507, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS Clearing and Execution Services Limited is a company registered in England & Wales under company number 03123037, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Niall G. <gal...@ya...> - 2008-11-30 00:15:09
|
Hi,
This issue has now been resolved in release 1.8. You can now read objects from collections that may be primitives or other annotated types. See MixTest.java in the tests to see how it can be used. This will work transparently with your current code.
Regards,
Niall
________________________________
From: "Nia...@ub..." <Nia...@ub...>
To: gre...@qu...; sim...@li...
Sent: Monday, October 20, 2008 11:05:11 AM
Subject: Re: [Simple-support] Element values not stored
Hi,
This is a known issue, the fix for this will be available
in the next release. Which should be very soon.
Thanks,
Niall
________________________________
From: Greg Cottman
[mailto:gre...@qu...]
Sent: 20 October 2008
09:14
To: sim...@li...
Subject: [Simple-support] Element values not stored
Hi
Niall,
I have an issue where
the values of elements are not being stored for Java types if they are declared
as an Object. The class
attribute is always set correctly, so I’m presuming this is a value conversion
problem caused by the actual type differing from the declared
type.
User-defined classes
don’t seem to suffer from the same problem, as illustrated by the Name class
shown below.
This
XML:
<test>
<string>ABC</string>
<object class="java.lang.String"/>
<map class="java.util.HashMap">
<entry string="INTEGER">
<object class="java.lang.Integer"/>
</entry>
<entry string="DATE">
<object class="java.util.Date"/>
</entry>
<entry string="STRING">
<object class="java.lang.String"/>
</entry>
<entry string="NAME">
<object class="test.xml.Simple.Name" firstName="Greg"
lastName="Cottman"/>
</entry>
</map>
</test>
is generated by this
test program:
@Root(name = "test")
publicclassMapTest
{
@Element
privateString string= "ABC";
@Element
privateObject object= "ABC";
@ElementMap(keyType =
String.class, valueType =
Object.class, attribute = true)
privateMap<String,Object> map= newHashMap<String,Object>();
publicstaticvoidmain(String[] args)
{
try
{
MapTest test = newMapTest();
test.map.put("STRING", "THX1138");
test.map.put("INTEGER",
Integer.valueOf(42));
test.map.put("DATE", newDate(System.currentTimeMillis()));
test.map.put("NAME", newName("Greg", "Cottman"));
Serializer serializer = newPersister();
serializer.write(test, System.out);
}
catch(Exception
e)
{
e.printStackTrace();
}
}
}
Thanks,
Greg.
|
|
From: <Nia...@ub...> - 2008-11-28 18:12:33
|
Hi, Cool any suggestions would be appreciated. Although I am familiar with namespaces and how they work I am not sure how to apply them to an XML serialization framework through annotations. Ill look forward to any suggestions you might have on how to apply them. Thanks, Niall -----Original Message----- From: saurabh sule [mailto:sau...@ya...] Sent: 28 November 2008 16:54 To: Gallagher, Niall-N; sim...@li... Subject: Re: [Simple-support] Support for namespaces and comment in SimpleXML Hi Niall I presume you might have gone through this link, but if you haven't then you can quickly scan through this link and you might get some idea of as to how the namespaces work and get inherited: http://www.w3.org/TR/REC-xml-names/ To make it quick just go through the section : 6 Applying Namespaces to Elements and Attributes I will return back with more on how to apply namespaces and will try to provide certain suggestions as to how we can do that using SimpleXML. Hopefully the above link will get you thinking. Regards, Saurabh. ----- Original Message ---- From: "Nia...@ub..." <Nia...@ub...> To: sau...@ya...; sim...@li... Sent: Friday, 28 November, 2008 3:54:41 PM Subject: RE: [Simple-support] Support for namespaces and comment in SimpleXML Hi, I have been working on 1.8 recently, which should be ready for release shortly enough. The only problem I have with namespaces is how to do it properly. By this I mean how are namespaces inherited? And if they are inherited does this mean that your XML class components are coupled by namespace? An annotation such as @Namespace(prefix='prefix', location='http://domain.com/location') @Root public class Example { @Attribute priavte String name; @Element private Component value; } Resulting in the following XML. <example name='name' xmlns:prefix='http://domain.com/location'> <component attribute='value'> // does this inherit the namespace....? </component> </example> The last thing I want to do is implement namespaces badly, and then have to refactor it breaking backward compatibility. If anyone has experience on how JAXB or C# XML serialization tackles the issue of namespaces I would love to see some examples of how they have done it. Without a clear idea on how to do this it will take me some time to look in to it, and this is why its taking so long, as time is very difficult to get. If there are any good ideas or examples of how to do this, in particular with reference to a successful scheme used by another project. Then I am sure I could progress with this sooner rather than later (perhaps in the 1.8 release)? Niall -----Original Message----- From: saurabh sule [mailto:sau...@ya...] Sent: 28 November 2008 07:45 To: sim...@li... Subject: [Simple-support] Support for namespaces and comment in SimpleXML Hi Niall, Wonderful project you have got there. I have just started to use SimpleXML and I need some support from the APIs. I already see a request for the namespace support in SimpleXML and have seen a reply from you dated: 2008-07-31, stating that it will be done and released by end of August. I have started working with the latest download: Simple 1.7.3, dated: 18 October 2008. But I still don't see proper support for namespaces. As suggested by Patrick Strum, I have tried using @Attribute(name="xmlns:p") kind of annotations but it doesn't seem to work. Can you suggest an alternative way of supporting namespaces? When can we expect the namespace support? Support for comments is also not there. But comments are not that greater an issue as namespaces are. Between, just for the information, we have selected SimpleXML over XStream from codehaus. With namespace support in place, SimpleXML will do the trick for us. Regards, Saurabh. Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/ ------------------------------------------------------------------------ - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company registered in England & Wales under company number 2035362, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS AG (London Branch) is registered as a branch of a foreign company under number BR004507, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS Clearing and Execution Services Limited is a company registered in England & Wales under company number 03123037, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. Be the first one to try the new Messenger 9 Beta! Go to http://in.messenger.yahoo.com/win/ Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company registered in England & Wales under company number 2035362, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS AG (London Branch) is registered as a branch of a foreign company under number BR004507, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS Clearing and Execution Services Limited is a company registered in England & Wales under company number 03123037, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. |
|
From: saurabh s. <sau...@ya...> - 2008-11-28 16:54:38
|
Hi Niall I presume you might have gone through this link, but if you haven't then you can quickly scan through this link and you might get some idea of as to how the namespaces work and get inherited: http://www.w3.org/TR/REC-xml-names/ To make it quick just go through the section : 6 Applying Namespaces to Elements and Attributes I will return back with more on how to apply namespaces and will try to provide certain suggestions as to how we can do that using SimpleXML. Hopefully the above link will get you thinking. Regards, Saurabh. ----- Original Message ---- From: "Nia...@ub..." <Nia...@ub...> To: sau...@ya...; sim...@li... Sent: Friday, 28 November, 2008 3:54:41 PM Subject: RE: [Simple-support] Support for namespaces and comment in SimpleXML Hi, I have been working on 1.8 recently, which should be ready for release shortly enough. The only problem I have with namespaces is how to do it properly. By this I mean how are namespaces inherited? And if they are inherited does this mean that your XML class components are coupled by namespace? An annotation such as @Namespace(prefix='prefix', location='http://domain.com/location') @Root public class Example { @Attribute priavte String name; @Element private Component value; } Resulting in the following XML. <example name='name' xmlns:prefix='http://domain.com/location'> <component attribute='value'> // does this inherit the namespace....? </component> </example> The last thing I want to do is implement namespaces badly, and then have to refactor it breaking backward compatibility. If anyone has experience on how JAXB or C# XML serialization tackles the issue of namespaces I would love to see some examples of how they have done it. Without a clear idea on how to do this it will take me some time to look in to it, and this is why its taking so long, as time is very difficult to get. If there are any good ideas or examples of how to do this, in particular with reference to a successful scheme used by another project. Then I am sure I could progress with this sooner rather than later (perhaps in the 1.8 release)? Niall -----Original Message----- From: saurabh sule [mailto:sau...@ya...] Sent: 28 November 2008 07:45 To: sim...@li... Subject: [Simple-support] Support for namespaces and comment in SimpleXML Hi Niall, Wonderful project you have got there. I have just started to use SimpleXML and I need some support from the APIs. I already see a request for the namespace support in SimpleXML and have seen a reply from you dated: 2008-07-31, stating that it will be done and released by end of August. I have started working with the latest download: Simple 1.7.3, dated: 18 October 2008. But I still don't see proper support for namespaces. As suggested by Patrick Strum, I have tried using @Attribute(name="xmlns:p") kind of annotations but it doesn't seem to work. Can you suggest an alternative way of supporting namespaces? When can we expect the namespace support? Support for comments is also not there. But comments are not that greater an issue as namespaces are. Between, just for the information, we have selected SimpleXML over XStream from codehaus. With namespace support in place, SimpleXML will do the trick for us. Regards, Saurabh. Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/ ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company registered in England & Wales under company number 2035362, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS AG (London Branch) is registered as a branch of a foreign company under number BR004507, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS Clearing and Execution Services Limited is a company registered in England & Wales under company number 03123037, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. Be the first one to try the new Messenger 9 Beta! Go to http://in.messenger.yahoo.com/win/ |
|
From: <Nia...@ub...> - 2008-11-28 10:24:41
|
Hi, I have been working on 1.8 recently, which should be ready for release shortly enough. The only problem I have with namespaces is how to do it properly. By this I mean how are namespaces inherited? And if they are inherited does this mean that your XML class components are coupled by namespace? An annotation such as @Namespace(prefix='prefix', location='http://domain.com/location') @Root public class Example { @Attribute priavte String name; @Element private Component value; } Resulting in the following XML. <example name='name' xmlns:prefix='http://domain.com/location'> <component attribute='value'> // does this inherit the namespace....? </component> </example> The last thing I want to do is implement namespaces badly, and then have to refactor it breaking backward compatibility. If anyone has experience on how JAXB or C# XML serialization tackles the issue of namespaces I would love to see some examples of how they have done it. Without a clear idea on how to do this it will take me some time to look in to it, and this is why its taking so long, as time is very difficult to get. If there are any good ideas or examples of how to do this, in particular with reference to a successful scheme used by another project. Then I am sure I could progress with this sooner rather than later (perhaps in the 1.8 release)? Niall -----Original Message----- From: saurabh sule [mailto:sau...@ya...] Sent: 28 November 2008 07:45 To: sim...@li... Subject: [Simple-support] Support for namespaces and comment in SimpleXML Hi Niall, Wonderful project you have got there. I have just started to use SimpleXML and I need some support from the APIs. I already see a request for the namespace support in SimpleXML and have seen a reply from you dated: 2008-07-31, stating that it will be done and released by end of August. I have started working with the latest download: Simple 1.7.3, dated: 18 October 2008. But I still don't see proper support for namespaces. As suggested by Patrick Strum, I have tried using @Attribute(name="xmlns:p") kind of annotations but it doesn't seem to work. Can you suggest an alternative way of supporting namespaces? When can we expect the namespace support? Support for comments is also not there. But comments are not that greater an issue as namespaces are. Between, just for the information, we have selected SimpleXML over XStream from codehaus. With namespace support in place, SimpleXML will do the trick for us. Regards, Saurabh. Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/ ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company registered in England & Wales under company number 2035362, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS AG (London Branch) is registered as a branch of a foreign company under number BR004507, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS Clearing and Execution Services Limited is a company registered in England & Wales under company number 03123037, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. |
|
From: saurabh s. <sau...@ya...> - 2008-11-28 08:11:39
|
Hi Niall,
Wonderful project you have got there.
I have just started to use SimpleXML and I need some support from the APIs.
I already see a request for the namespace support in SimpleXML and have seen a reply from you
dated: 2008-07-31, stating that it will be done and released by end of August.
I have started working with the latest download: Simple 1.7.3, dated: 18 October 2008.
But I still don't see proper support for namespaces. As suggested by Patrick Strum, I have tried using
@Attribute(name="xmlns:p") kind of annotations but it doesn't seem to work.
Can you suggest an alternative way of supporting namespaces? When can we expect the namespace support?
Support for comments is also not there. But comments are not that greater an issue as namespaces are.
Between, just for the information, we have selected SimpleXML over XStream from codehaus.
With namespace support in place, SimpleXML will do the trick for us.
Regards,
Saurabh.
Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/
|
|
From: Niall G. <gal...@ya...> - 2008-11-23 09:40:57
|
Hi,
The only way to do it currently would be to use an @Commit annotation and pass it from a Map to an EnumMap.
@Commit
public void commit() {
enumMap.putAll(normalMap);
}
Support for EnumMap objects will be added in an upcoming release.
Niall
________________________________
From: Rob Gilson <rob...@ar...>
To: sim...@li...
Cc: Arise <ar...@si...>
Sent: Saturday, November 22, 2008 8:04:39 PM
Subject: [Simple-support] Simple1.7.3 EnumMap deserialization bug
Hi all,
I've been working on a project which is heavily reliant on the Simple xml serialization library and I seem to have come across a problem in it's instantiation of EnumMaps. As many of you undoubtedly know EnumMaps do not have a zero parameter constructor rather they can only be constructed by passing the Class of the enum you wish to use due to the limitation of java Generics, my problem comes about as it seems Simple Xml is trying to use that non-existant EnumMap() constructor and is throwing a NoSuchMethodException. The stack trace (for deserialization, serialization works fine), if i allow java to step forward into the exception is as follows:
Exception in thread "main" java.lang.NoSuchMethodException: java.util.EnumMap.<init>()
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getDeclaredConstructor(Unknown Source)
at org.simpleframework.xml.load.ClassType.getInstance(ClassType.java:88)
at org.simpleframework.xml.load.ClassType.getInstance(ClassType.java:72)
at org.simpleframework.xml.load.CompositeMap.read(CompositeMap.java:109)
at org.simpleframework.xml.load.Composite.read(Composite.java:354)
at org.simpleframework.xml.load.Composite.readElement(Composite.java:334)
at org.simpleframework.xml.load.Composite.readElements(Composite.java:250)
at org.simpleframework.xml.load.Composite.read(Composite.java:194)
Any help would be greatly appreciated. Also I just wanted to say thanks to the Simple team, you guys have done an awsome job with Simple, its very intuitive and very powerfull, the combination of which has saved me massive amounts of time on this project!
Cheers,
Rob
My source code:
/**
*
*/
package simpleXmlSandpit;
import java.io.File;
import java.util.EnumMap;
import org.simpleframework.xml.ElementMap;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.load.Persister;
/**
* @author Rob Gilson, University of Ottawa CEG Student
*/
@Root
public class EnumTestSerialization {
@ElementMap (required=false) public EnumMap<TestEnum, String> map = new EnumMap<TestEnum, String>(TestEnum.class);
public static enum TestEnum
{
enumTest,
otherTest
}
public EnumTestSerialization()
{
map.put(TestEnum.enumTest, "hello world this is the test #1");
map.put(TestEnum.otherTest, "hello world this is the other test #2");
}
/**
* serializes and subsiquently deserializes a object containing a enum map
* to illustrate a potential bug in Simple 1.7.3
* @param args unused.
* @throws Exception if the serialization or deserialization fail.
*/
public static void main(String[] args) throws Exception {
java.io.File file = new File("example.xml");
Serializer serializer = new Persister();
EnumTestSerialization example;
//Serialization
example = new EnumTestSerialization();
serializer.write(example, file);
example = null;
//Deserialization
if (file.exists() == false) System.err.println("File does not exist!");
//Exception is thrown here \/
example = serializer.read(EnumTestSerialization.class, file);
//Exception is thrown here /\
System.out.println(example.map.get(TestEnum.enumTest));
System.exit(1);
}
}
|
|
From: Rob G. <rob...@ar...> - 2008-11-22 20:04:45
|
Hi all,
I've been working on a project which is heavily reliant on the Simple xml
serialization library and I seem to have come across a problem in it's
instantiation of EnumMaps. As many of you undoubtedly know EnumMaps do not
have a zero parameter constructor rather they can only be constructed by
passing the Class of the enum you wish to use due to the limitation of java
Generics, my problem comes about as it seems Simple Xml is trying to use
that non-existant EnumMap() constructor and is throwing a
NoSuchMethodException. The stack trace (for deserialization, serialization
works fine), if i allow java to step forward into the exception is as
follows:
Exception in thread "main" java.lang.NoSuchMethodException:
java.util.EnumMap.<init>()
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getDeclaredConstructor(Unknown Source)
at org.simpleframework.xml.load.ClassType.getInstance(ClassType.java:88)
at org.simpleframework.xml.load.ClassType.getInstance(ClassType.java:72)
at org.simpleframework.xml.load.CompositeMap.read(CompositeMap.java:109)
at org.simpleframework.xml.load.Composite.read(Composite.java:354)
at
org.simpleframework.xml.load.Composite.readElement(Composite.java:334)
at
org.simpleframework.xml.load.Composite.readElements(Composite.java:250)
at org.simpleframework.xml.load.Composite.read(Composite.java:194)
Any help would be greatly appreciated. Also I just wanted to say thanks to
the Simple team, you guys have done an awsome job with Simple, its very
intuitive and very powerfull, the combination of which has saved me massive
amounts of time on this project!
Cheers,
Rob
*My source code:
*
/**
*
*/
package simpleXmlSandpit;
import java.io.File;
import java.util.EnumMap;
import org.simpleframework.xml.ElementMap;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.load.Persister;
/**
* @author Rob Gilson, University of Ottawa CEG Student
*/
@Root
public class EnumTestSerialization {
@ElementMap (required=false) public EnumMap<TestEnum, String> map = new
EnumMap<TestEnum, String>(TestEnum.class);
public static enum TestEnum
{
enumTest,
otherTest
}
public EnumTestSerialization()
{
map.put(TestEnum.enumTest, "hello world this is the test #1");
map.put(TestEnum.otherTest, "hello world this is the other test
#2");
}
/**
* serializes and subsiquently deserializes a object containing a enum
map
* to illustrate a potential bug in Simple 1.7.3
* @param args unused.
* @throws Exception if the serialization or deserialization fail.
*/
public static void main(String[] args) throws Exception {
java.io.File file = new File("example.xml");
Serializer serializer = new Persister();
EnumTestSerialization example;
//Serialization
example = new EnumTestSerialization();
serializer.write(example, file);
example = null;
//Deserialization
if (file.exists() == false) System.err.println("File does not
exist!");
//Exception is thrown here \/
example = serializer.read(EnumTestSerialization.class, file);
//Exception is thrown here /\
System.out.println(example.map.get(TestEnum.enumTest));
System.exit(1);
}
}
|
|
From: Zdenek M. <zde...@he...> - 2008-11-03 12:07:36
|
Hi Niall and Quirino,
Thanks for your help.
Indeed, it looks like the whole file gets eaten when calling first read().
As for adding a wrapper class, this is not really feasible for me since
I need to append object by object into the file. The only thing which
comes to my mind is to add artificially wrapper tags just before reading.
Thanks again for your responses.
Zdenek
-------- Original Message --------
Subject: Re: [Simple-support] reading a list of objects from XML
From: <Nia...@ub...>
To: the...@gm..., zde...@he...
Cc: sim...@li...
Date: Mon Nov 03 2008 11:32:58 GMT+0100 (CET)
> Hi,
>
> Also, just to mention. Simple does not directly interact with the
> underlying stream. It simply uses StAX as an interface to it. Perhaps
> XERCES is consuming the whole file. If so then try something like
> Woodstox. I am pretty sure I have done this before with that StAX
> parser. Also the SUN StAX (found in Java 1.6 and available separately
> for Java 1.5) parser might give you better results.
>
> Niall
>
> ------------------------------------------------------------------------
> *From:* Quirino Zagarese [mailto:the...@gm...]
> *Sent:* 03 November 2008 10:30
> *To:* Zdenek Maxa
> *Cc:* Gallagher, Niall-N; sim...@li...
> *Subject:* Re: [Simple-support] reading a list of objects from XML
>
> If your document only contains a list of <textMessage/>, it's not a
> valid xml doc: there should be a root tag.
> Maybe refactoring it like this:
>
> <wrapper>
> <textMessage>
> <message>message, index: 0</message>
> <timeStamp>2008-11-03 10:39:36.770 CET</timeStamp>
> <toAcknowledge>false</toAcknowledge>
> </textMessage><textMessage>
> <message>message, index: 1</message>
> <timeStamp>2008-11-03 10:39:36.770 CET</timeStamp>
> <toAcknowledge>false</
> toAcknowledge>
> </textMessage>
> </wrapper>
>
> and adding this class to your code:
>
> @Root(name="wrapper")
> public class Wrapper{
>
> @ElementList(type=TextMessage.class,inline=true)
> private ArrayList<TextMessage> messages = new ArrayList<TextMessage>();
>
> public ArrayList<TextMessage> getMessages(){
> return messages;
> }
>
> public void setMessages( ArrayList<TextMessage> messages){
> this.messages = messages;
> }
>
> }
>
> and deserializing it:
>
> Wrapper wrapper = persister.read(Wrapper.
> class, fis);
>
> I guess it should work.
>
> Regards
>
>
>
> 2008/11/3 Zdenek Maxa <zde...@he...
> <mailto:zde...@he...>>
>
> Hi,
>
> I have tried without
>
> fw.write("\n");
>
> already.
>
> That results is having XML like this:
>
> ------- paste ----------
> <textMessage>
> <message>message, index: 0</message>
> <timeStamp>2008-11-03 10:39:36.770 CET</timeStamp>
> <toAcknowledge>false</toAcknowledge>
> </textMessage><textMessage>
> <message>message, index: 1</message>
> <timeStamp>2008-11-03 10:39:36.770 CET</timeStamp>
> <toAcknowledge>false</toAcknowledge>
> </textMessage>
> ------- end of paste -------
>
> i.e. the opening tag of the second object is right after closing
> tag of
> the previous, however, I get identical behaviour and identical error
> message when trying to deserialize the second object.
>
> However, if I do following:
>
> while(true)
> {
> TextMessage tm = persister.read(TextMessage.class, fis);
> System.out.println("loaded from XML file: " + tm.toString());
> System.out.println("char: \"" + fis.read() + "\"");
> }
>
> a single character reading returns -1, so the end of file is already
> reached after the first reading loading the first object. I guess that
> persister.read() is likely no good for reading multiple objects
> from a file?
>
> Thanks for your help.
>
> Zdenek
>
>
>
> -------- Original Message --------
> Subject: Re: [Simple-support] reading a list of objects from XML
> From: <Nia...@ub... <mailto:Nia...@ub...>>
> To: zde...@he... <mailto:zde...@he...>,
> sim...@li...
> <mailto:sim...@li...>
> Date: Mon Nov 03 2008 10:37:24 GMT+0100 (CET)
> > Hi,
> >
> > This looks like the issue, try without it.
> >
> > fw.write("\n");
> >
> > Or if this is not good, then read a line after you deserialize
> to remove
> > the \n before the next read. An XML file must start with a valid XML
> > prolog or a root XML element.
> >
> > Niall
> >
> > -----Original Message-----
> > From: Zdenek Maxa [mailto:zde...@he...
> <mailto:zde...@he...>]
> > Sent: 03 November 2008 09:06
> > To: Gallagher, Niall-N; sim...@li...
> <mailto:sim...@li...>
> > Subject: Re: [Simple-support] reading a list of objects from XML
> >
> > Hi,
> >
> > writing XML - each object is appended independently into the XML
> file:
> >
> > Serializer serializer = new Persister();
> > // true flag - open for appending (writing to the end)
> > FileWriter fw = new FileWriter("file.xml", true);
> > serializer.write(textMessageToStore, fw);
> > fw.write("\n");
> > fw.close();
> > XML for first two objects looks like this:
> > ----------- paste ------------
> > <textMessage>
> > <message> ... </message>
> > <timeStamp>2008-11-03 10:02:17.201 CET</timeStamp>
> > <toAcknowledge>false</toAcknowledge>
> > </textMessage>
> > <textMessage>
> > <message> ... </message>
> > <timeStamp>2008-11-03 10:02:17.201 CET</timeStamp>
> > <toAcknowledge>false</toAcknowledge>
> > </textMessage>
> > ---------- end of paste -------
> >
> >
> > First message gets read fine.
> >
> > Zdenek
> >
> >
> >> -------- Original Message --------
> >> Subject: Re: [Simple-support] reading a list of objects from XML
> >> From: <Nia...@ub...
> <mailto:Nia...@ub...>>
> >> To: zde...@he... <mailto:zde...@he...>
> >> Cc: sim...@li...
> <mailto:sim...@li...>
> >> Date: Mon Nov 03 2008 09:58:55 GMT+0100 (CET)
> >>
> >>> Hi,
> >>>
> >>> How are you writing the XML? Also, what does the XML look like
> here:
> >>>
> >>> [row,col]:[1,1]
> >>>
> >>> Niall
> >>>
> >>>
> >>>
> >>> -----Original Message-----
> >>> From: Zdenek Maxa [mailto:zde...@he...
> <mailto:zde...@he...>] Sent: 03
> >>> November 2008 08:57
> >>> To: Gallagher, Niall-N
> >>> Cc: sim...@li...
> <mailto:sim...@li...>
> >>> Subject: Re: [Simple-support] reading a list of objects from XML
> >>>
> >>> Hi,
> >>>
> >>> This is exactly what I am doing:
> >>>
> >>> FileInputStream fis = new FileInputStream("file.xml");
> >>> Persister persister = new Persister();
> >>> ArrayList<TextMessage> fromFile = new
> >>>
> > ArrayList<TextMessage>();
> >
> >>> try
> >>> {
> >>> while(true)
> >>> {
> >>> TextMessage tm = persister.read(TextMessage.class,
> >>>
> > fis);
> >
> >>> System.out.println("loaded from XML file: " +
> >>> tm.toString());
> >>> fromFile.add(tm);
> >>> } }
> >>> catch(EOFException ex)
> >>> {
> >>> System.out.println("end of file reached.");
> >>> fis.close();
> >>> }
> >>>
> >>>
> >>> First object gets loaded fine but reading fails on the second
> object
> >>> / iteration:
> >>>
> >>> Exception occured in simple serialisation example: ParseError at
> >>> [row,col]:[1,1]
> >>> Message: Premature end of file.
> >>> javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
> >>> Message: Premature end of file.
> >>> at
> >>>
> com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLS
> >>> tre
> >>> amReaderImpl.java:588)
> >>> at
> >>>
> com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventRead
> >>> erI
> >>> mpl.java:85)
> >>> at
> >>>
> org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java
> >>> :11
> >>> 7)
> >>> at
> >>>
> >>>
> >
> org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:74)
> >
> >>> at
> >>>
> org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:74)
> >>> at
> >>>
> org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:61)
> >>> at
> >>>
> > org.simpleframework.xml.load.Persister.read(Persister.java:337)
> >
> >>> at
> >>>
> > org.simpleframework.xml.load.Persister.read(Persister.java:319)
> >
> >>> at
> >>>
> > org.simpleframework.xml.load.Persister.read(Persister.java:300)
> >
> >>> at
> >>>
> JavaToXMLSerialisation.simpleSerialisationExample(JavaToXMLSerialisat
> >>> ion
> >>> .java:148)
> >>> at
> JavaToXMLSerialisation.main(JavaToXMLSerialisation.java:183)
> >>>
> >>>
> >>> Thanks again,
> >>> Zdenek
> >>>
> >>>
> >>> -------- Original Message --------
> >>> Subject: Re: [Simple-support] reading a list of objects from XML
> >>> From: <Nia...@ub...
> <mailto:Nia...@ub...>>
> >>> To: zde...@he...
> <mailto:zde...@he...>,
> sim...@li...
> <mailto:sim...@li...>
> >>> Date: Mon Nov 03 2008 08:37:46 GMT+0100 (CET)
> >>>
> >>>
> >>>> Hi,
> >>>>
> >>>> If you do the following.
> >>>>
> >>>> InputStream source = new FileInputStream(fileName); Persister
> >>>> persister = new Persister(); List list = new ArrayList();
> >>>>
> >>>> While(....){
> >>>> list.add(persister.read(ClassName.class, source)); }
> >>>>
> >>>> This should work fine. As long as you re-use the same input
> stream.
> >>>>
> >>>> Niall
> >>>>
> >>>>
> >>>> -----Original Message-----
> >>>> From: Zdenek Maxa [mailto:zde...@he...
> <mailto:zde...@he...>] Sent: 02
> >>>> November 2008 20:47
> >>>> To: sim...@li...
> <mailto:sim...@li...>
> >>>> Subject: Re: [Simple-support] reading a list of objects from XML
> >>>>
> >>>> hello,
> >>>>
> >>>> I am using Simple 1.7.3, serializing number of objects so
> that I am
> >>>> -appending- each object to a single file. The result is
> something
> >>>>
> >>>>
> >>> like
> >>>
> >>>
> >>>> this:
> >>>>
> >>>> <textMessage>
> >>>> <message> ... </message>
> >>>> <timeStamp>2008-11-02 20:15:28.254 CET</timeStamp>
> >>>> <toAcknowledge>false</toAcknowledge>
> >>>> </textMessage>
> >>>>
> >>>> <textMessage>
> >>>> <message> ... </message>
> >>>> <timeStamp>2008-11-02 20:15:28.254 CET</timeStamp>
> >>>> <toAcknowledge>false</toAcknowledge>
> >>>> </textMessage>
> >>>>
> >>>> I was wondering whether Simple provides some easy way of
> performing
> >>>>
> >>>> ArrayList<TextMessage> msgList =
> serializer.read(TextMessage.class,
> >>>> reader)
> >>>>
> >>>> which would load the whole file in one go.
> >>>>
> >>>> I was experimenting with
> >>>>
> >>>> TextMessage tm = serializer.read(TextMessage.class, read)
> >>>>
> >>>> placed in a loop, but that only reads fine the first objects and
> >>>> then fails with
> >>>>
> >>>> Message: Premature end of file.
> >>>> javax.xml.stream.XMLStreamException: ParseError at
> [row,col]:[1,1]
> >>>> Message: Premature end of file.
> >>>> at
> >>>>
> >>>>
> >>>>
> >>>
> com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLS
> >>> tre
> >>>
> >>>
> >>>> amReaderImpl.java:588)
> >>>> at
> >>>>
> >>>>
> >>>>
> >>>
> com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventRead
> >>> erI
> >>>
> >>>
> >>>> mpl.java:85)
> >>>> at
> >>>>
> >>>>
> >>>>
> >>>
> org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java
> >>> :11
> >>>
> >>>
> >>>> 7)
> >>>> at
> >>>>
> org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:7
> >>>> 4)
> >>>>
> >>>> ....
> >>>>
> >>>>
> >>>> I shall add that storing all objects in a container is no good
> >>>>
> >>>>
> >>> solution
> >>>
> >>>
> >>>> for me since I need to be appending objects and I would be
> >>>> potentially dealing with many objects.
> >>>>
> >>>> Thanks very much for your advise. I have just started with your
> >>>>
> >>>>
> >>> library
> >>>
> >>>
> >>>> and find it very very useful for my purpose! Thanks a lot!
> >>>>
> >>>> Zdenek
> >>>>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win
> great prizes
> Grand prize is a trip for two to an Open Source event anywhere in
> the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> <http://moblin-contest.org/redirect.php?banner_id=100&url=/>
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> <mailto:Sim...@li...>
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
>
>
>
> --
> Quirino Zagarese
>
> LaszloItalia Founder (www.laszloitalia.org <http://www.laszloitalia.org>)
> Software Development Manager - Galilaeus s.r.l.
|
|
From: <Nia...@ub...> - 2008-11-03 10:33:05
|
Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company registered in England & Wales under company number 2035362, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS AG (London Branch) is registered as a branch of a foreign company under number BR004507, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS Clearing and Execution Services Limited is a company registered in England & Wales under company number 03123037, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. |
|
From: Zdenek M. <zde...@he...> - 2008-11-03 10:05:44
|
Hi,
I have tried without
fw.write("\n");
already.
That results is having XML like this:
------- paste ----------
<textMessage>
<message>message, index: 0</message>
<timeStamp>2008-11-03 10:39:36.770 CET</timeStamp>
<toAcknowledge>false</toAcknowledge>
</textMessage><textMessage>
<message>message, index: 1</message>
<timeStamp>2008-11-03 10:39:36.770 CET</timeStamp>
<toAcknowledge>false</toAcknowledge>
</textMessage>
------- end of paste -------
i.e. the opening tag of the second object is right after closing tag of
the previous, however, I get identical behaviour and identical error
message when trying to deserialize the second object.
However, if I do following:
while(true)
{
TextMessage tm = persister.read(TextMessage.class, fis);
System.out.println("loaded from XML file: " + tm.toString());
System.out.println("char: \"" + fis.read() + "\"");
}
a single character reading returns -1, so the end of file is already
reached after the first reading loading the first object. I guess that
persister.read() is likely no good for reading multiple objects from a file?
Thanks for your help.
Zdenek
-------- Original Message --------
Subject: Re: [Simple-support] reading a list of objects from XML
From: <Nia...@ub...>
To: zde...@he..., sim...@li...
Date: Mon Nov 03 2008 10:37:24 GMT+0100 (CET)
> Hi,
>
> This looks like the issue, try without it.
>
> fw.write("\n");
>
> Or if this is not good, then read a line after you deserialize to remove
> the \n before the next read. An XML file must start with a valid XML
> prolog or a root XML element.
>
> Niall
>
> -----Original Message-----
> From: Zdenek Maxa [mailto:zde...@he...]
> Sent: 03 November 2008 09:06
> To: Gallagher, Niall-N; sim...@li...
> Subject: Re: [Simple-support] reading a list of objects from XML
>
> Hi,
>
> writing XML - each object is appended independently into the XML file:
>
> Serializer serializer = new Persister();
> // true flag - open for appending (writing to the end)
> FileWriter fw = new FileWriter("file.xml", true);
> serializer.write(textMessageToStore, fw);
> fw.write("\n");
> fw.close();
> XML for first two objects looks like this:
> ----------- paste ------------
> <textMessage>
> <message> ... </message>
> <timeStamp>2008-11-03 10:02:17.201 CET</timeStamp>
> <toAcknowledge>false</toAcknowledge>
> </textMessage>
> <textMessage>
> <message> ... </message>
> <timeStamp>2008-11-03 10:02:17.201 CET</timeStamp>
> <toAcknowledge>false</toAcknowledge>
> </textMessage>
> ---------- end of paste -------
>
>
> First message gets read fine.
>
> Zdenek
>
>
>> -------- Original Message --------
>> Subject: Re: [Simple-support] reading a list of objects from XML
>> From: <Nia...@ub...>
>> To: zde...@he...
>> Cc: sim...@li...
>> Date: Mon Nov 03 2008 09:58:55 GMT+0100 (CET)
>>
>>> Hi,
>>>
>>> How are you writing the XML? Also, what does the XML look like here:
>>>
>>> [row,col]:[1,1]
>>>
>>> Niall
>>>
>>>
>>>
>>> -----Original Message-----
>>> From: Zdenek Maxa [mailto:zde...@he...] Sent: 03
>>> November 2008 08:57
>>> To: Gallagher, Niall-N
>>> Cc: sim...@li...
>>> Subject: Re: [Simple-support] reading a list of objects from XML
>>>
>>> Hi,
>>>
>>> This is exactly what I am doing:
>>>
>>> FileInputStream fis = new FileInputStream("file.xml");
>>> Persister persister = new Persister();
>>> ArrayList<TextMessage> fromFile = new
>>>
> ArrayList<TextMessage>();
>
>>> try
>>> {
>>> while(true)
>>> {
>>> TextMessage tm = persister.read(TextMessage.class,
>>>
> fis);
>
>>> System.out.println("loaded from XML file: " +
>>> tm.toString());
>>> fromFile.add(tm);
>>> } }
>>> catch(EOFException ex)
>>> {
>>> System.out.println("end of file reached.");
>>> fis.close();
>>> }
>>>
>>>
>>> First object gets loaded fine but reading fails on the second object
>>> / iteration:
>>>
>>> Exception occured in simple serialisation example: ParseError at
>>> [row,col]:[1,1]
>>> Message: Premature end of file.
>>> javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
>>> Message: Premature end of file.
>>> at
>>> com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLS
>>> tre
>>> amReaderImpl.java:588)
>>> at
>>> com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventRead
>>> erI
>>> mpl.java:85)
>>> at
>>> org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java
>>> :11
>>> 7)
>>> at
>>>
>>>
> org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:74)
>
>>> at
>>> org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:74)
>>> at
>>> org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:61)
>>> at
>>>
> org.simpleframework.xml.load.Persister.read(Persister.java:337)
>
>>> at
>>>
> org.simpleframework.xml.load.Persister.read(Persister.java:319)
>
>>> at
>>>
> org.simpleframework.xml.load.Persister.read(Persister.java:300)
>
>>> at
>>> JavaToXMLSerialisation.simpleSerialisationExample(JavaToXMLSerialisat
>>> ion
>>> .java:148)
>>> at JavaToXMLSerialisation.main(JavaToXMLSerialisation.java:183)
>>>
>>>
>>> Thanks again,
>>> Zdenek
>>>
>>>
>>> -------- Original Message --------
>>> Subject: Re: [Simple-support] reading a list of objects from XML
>>> From: <Nia...@ub...>
>>> To: zde...@he..., sim...@li...
>>> Date: Mon Nov 03 2008 08:37:46 GMT+0100 (CET)
>>>
>>>
>>>> Hi,
>>>>
>>>> If you do the following.
>>>>
>>>> InputStream source = new FileInputStream(fileName); Persister
>>>> persister = new Persister(); List list = new ArrayList();
>>>>
>>>> While(....){
>>>> list.add(persister.read(ClassName.class, source)); }
>>>>
>>>> This should work fine. As long as you re-use the same input stream.
>>>>
>>>> Niall
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: Zdenek Maxa [mailto:zde...@he...] Sent: 02
>>>> November 2008 20:47
>>>> To: sim...@li...
>>>> Subject: Re: [Simple-support] reading a list of objects from XML
>>>>
>>>> hello,
>>>>
>>>> I am using Simple 1.7.3, serializing number of objects so that I am
>>>> -appending- each object to a single file. The result is something
>>>>
>>>>
>>> like
>>>
>>>
>>>> this:
>>>>
>>>> <textMessage>
>>>> <message> ... </message>
>>>> <timeStamp>2008-11-02 20:15:28.254 CET</timeStamp>
>>>> <toAcknowledge>false</toAcknowledge>
>>>> </textMessage>
>>>>
>>>> <textMessage>
>>>> <message> ... </message>
>>>> <timeStamp>2008-11-02 20:15:28.254 CET</timeStamp>
>>>> <toAcknowledge>false</toAcknowledge>
>>>> </textMessage>
>>>>
>>>> I was wondering whether Simple provides some easy way of performing
>>>>
>>>> ArrayList<TextMessage> msgList = serializer.read(TextMessage.class,
>>>> reader)
>>>>
>>>> which would load the whole file in one go.
>>>>
>>>> I was experimenting with
>>>>
>>>> TextMessage tm = serializer.read(TextMessage.class, read)
>>>>
>>>> placed in a loop, but that only reads fine the first objects and
>>>> then fails with
>>>>
>>>> Message: Premature end of file.
>>>> javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
>>>> Message: Premature end of file.
>>>> at
>>>>
>>>>
>>>>
>>> com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLS
>>> tre
>>>
>>>
>>>> amReaderImpl.java:588)
>>>> at
>>>>
>>>>
>>>>
>>> com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventRead
>>> erI
>>>
>>>
>>>> mpl.java:85)
>>>> at
>>>>
>>>>
>>>>
>>> org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java
>>> :11
>>>
>>>
>>>> 7)
>>>> at
>>>> org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:7
>>>> 4)
>>>>
>>>> ....
>>>>
>>>>
>>>> I shall add that storing all objects in a container is no good
>>>>
>>>>
>>> solution
>>>
>>>
>>>> for me since I need to be appending objects and I would be
>>>> potentially dealing with many objects.
>>>>
>>>> Thanks very much for your advise. I have just started with your
>>>>
>>>>
>>> library
>>>
>>>
>>>> and find it very very useful for my purpose! Thanks a lot!
>>>>
>>>> Zdenek
>>>>
|
|
From: <Nia...@ub...> - 2008-11-03 09:37:36
|
Hi,
This looks like the issue, try without it.
fw.write("\n");
Or if this is not good, then read a line after you deserialize to remove
the \n before the next read. An XML file must start with a valid XML
prolog or a root XML element.
Niall
-----Original Message-----
From: Zdenek Maxa [mailto:zde...@he...]
Sent: 03 November 2008 09:06
To: Gallagher, Niall-N; sim...@li...
Subject: Re: [Simple-support] reading a list of objects from XML
Hi,
writing XML - each object is appended independently into the XML file:
Serializer serializer = new Persister();
// true flag - open for appending (writing to the end)
FileWriter fw = new FileWriter("file.xml", true);
serializer.write(textMessageToStore, fw);
fw.write("\n");
fw.close();
XML for first two objects looks like this:
----------- paste ------------
<textMessage>
<message> ... </message>
<timeStamp>2008-11-03 10:02:17.201 CET</timeStamp>
<toAcknowledge>false</toAcknowledge>
</textMessage>
<textMessage>
<message> ... </message>
<timeStamp>2008-11-03 10:02:17.201 CET</timeStamp>
<toAcknowledge>false</toAcknowledge>
</textMessage>
---------- end of paste -------
First message gets read fine.
Zdenek
>
>
> -------- Original Message --------
> Subject: Re: [Simple-support] reading a list of objects from XML
> From: <Nia...@ub...>
> To: zde...@he...
> Cc: sim...@li...
> Date: Mon Nov 03 2008 09:58:55 GMT+0100 (CET)
>> Hi,
>>
>> How are you writing the XML? Also, what does the XML look like here:
>>
>> [row,col]:[1,1]
>>
>> Niall
>>
>>
>>
>> -----Original Message-----
>> From: Zdenek Maxa [mailto:zde...@he...] Sent: 03
>> November 2008 08:57
>> To: Gallagher, Niall-N
>> Cc: sim...@li...
>> Subject: Re: [Simple-support] reading a list of objects from XML
>>
>> Hi,
>>
>> This is exactly what I am doing:
>>
>> FileInputStream fis = new FileInputStream("file.xml");
>> Persister persister = new Persister();
>> ArrayList<TextMessage> fromFile = new
ArrayList<TextMessage>();
>> try
>> {
>> while(true)
>> {
>> TextMessage tm = persister.read(TextMessage.class,
fis);
>> System.out.println("loaded from XML file: " +
>> tm.toString());
>> fromFile.add(tm);
>> } }
>> catch(EOFException ex)
>> {
>> System.out.println("end of file reached.");
>> fis.close();
>> }
>>
>>
>> First object gets loaded fine but reading fails on the second object
>> / iteration:
>>
>> Exception occured in simple serialisation example: ParseError at
>> [row,col]:[1,1]
>> Message: Premature end of file.
>> javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
>> Message: Premature end of file.
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLS
>> tre
>> amReaderImpl.java:588)
>> at
>> com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventRead
>> erI
>> mpl.java:85)
>> at
>> org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java
>> :11
>> 7)
>> at
>>
org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:74)
>> at
>> org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:74)
>> at
>> org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:61)
>> at
org.simpleframework.xml.load.Persister.read(Persister.java:337)
>> at
org.simpleframework.xml.load.Persister.read(Persister.java:319)
>> at
org.simpleframework.xml.load.Persister.read(Persister.java:300)
>> at
>> JavaToXMLSerialisation.simpleSerialisationExample(JavaToXMLSerialisat
>> ion
>> .java:148)
>> at JavaToXMLSerialisation.main(JavaToXMLSerialisation.java:183)
>>
>>
>> Thanks again,
>> Zdenek
>>
>>
>> -------- Original Message --------
>> Subject: Re: [Simple-support] reading a list of objects from XML
>> From: <Nia...@ub...>
>> To: zde...@he..., sim...@li...
>> Date: Mon Nov 03 2008 08:37:46 GMT+0100 (CET)
>>
>>> Hi,
>>>
>>> If you do the following.
>>>
>>> InputStream source = new FileInputStream(fileName); Persister
>>> persister = new Persister(); List list = new ArrayList();
>>>
>>> While(....){
>>> list.add(persister.read(ClassName.class, source)); }
>>>
>>> This should work fine. As long as you re-use the same input stream.
>>>
>>> Niall
>>>
>>>
>>> -----Original Message-----
>>> From: Zdenek Maxa [mailto:zde...@he...] Sent: 02
>>> November 2008 20:47
>>> To: sim...@li...
>>> Subject: Re: [Simple-support] reading a list of objects from XML
>>>
>>> hello,
>>>
>>> I am using Simple 1.7.3, serializing number of objects so that I am
>>> -appending- each object to a single file. The result is something
>>>
>> like
>>
>>> this:
>>>
>>> <textMessage>
>>> <message> ... </message>
>>> <timeStamp>2008-11-02 20:15:28.254 CET</timeStamp>
>>> <toAcknowledge>false</toAcknowledge>
>>> </textMessage>
>>>
>>> <textMessage>
>>> <message> ... </message>
>>> <timeStamp>2008-11-02 20:15:28.254 CET</timeStamp>
>>> <toAcknowledge>false</toAcknowledge>
>>> </textMessage>
>>>
>>> I was wondering whether Simple provides some easy way of performing
>>>
>>> ArrayList<TextMessage> msgList = serializer.read(TextMessage.class,
>>> reader)
>>>
>>> which would load the whole file in one go.
>>>
>>> I was experimenting with
>>>
>>> TextMessage tm = serializer.read(TextMessage.class, read)
>>>
>>> placed in a loop, but that only reads fine the first objects and
>>> then fails with
>>>
>>> Message: Premature end of file.
>>> javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
>>> Message: Premature end of file.
>>> at
>>>
>>>
>> com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLS
>> tre
>>
>>> amReaderImpl.java:588)
>>> at
>>>
>>>
>> com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventRead
>> erI
>>
>>> mpl.java:85)
>>> at
>>>
>>>
>> org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java
>> :11
>>
>>> 7)
>>> at
>>> org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:7
>>> 4)
>>>
>>> ....
>>>
>>>
>>> I shall add that storing all objects in a container is no good
>>>
>> solution
>>
>>> for me since I need to be appending objects and I would be
>>> potentially dealing with many objects.
>>>
>>> Thanks very much for your advise. I have just started with your
>>>
>> library
>>
>>> and find it very very useful for my purpose! Thanks a lot!
>>>
>>> Zdenek
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> ---
>>
>>> -
>>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>>> challenge Build the coolest Linux based applications with Moblin SDK
>>> & win great prizes Grand prize is a trip for two to an Open Source
>>> event anywhere in the world
>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>>> _______________________________________________
>>> Simple-support mailing list
>>> Sim...@li...
>>> https://lists.sourceforge.net/lists/listinfo/simple-support
>>> Visit our website at http://www.ubs.com
>>>
>>> This message contains confidential information and is intended only
>>> for the individual named. If you are not the named addressee you
>>> should not disseminate, distribute or copy this e-mail. Please
>>> notify the sender immediately by e-mail if you have received this
>>> e-mail by mistake and delete this e-mail from your system.
>>>
>>> E-mails are not encrypted and cannot be guaranteed to be secure or
>>> error-free as information could be intercepted, corrupted, lost,
>>> destroyed, arrive late or incomplete, or contain viruses. The
>>> sender therefore does not accept liability for any errors or
>>> omissions in the
>>>
>>
>>
>>> contents of this message which arise as a result of e-mail
>>>
>> transmission.
>>> If verification is required please request a hard-copy version.
>>> This message is provided for informational purposes and should not
>>> be construed as a solicitation or offer to buy or sell any
>>> securities or related financial instruments.
>>>
>>> UBS Limited is a company registered in England & Wales under company
>>> number 2035362, whose registered office is at 1 Finsbury Avenue,
>>> London, EC2M 2PP, United Kingdom.
>>>
>>> UBS AG (London Branch) is registered as a branch of a foreign
>>> company under number BR004507, whose registered office is at
>>> 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
>>>
>>> UBS Clearing and Execution Services Limited is a company registered
>>> in England & Wales under company number 03123037, whose registered
>>> office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
>>>
>>
>>
>> Visit our website at http://www.ubs.com
>>
>> This message contains confidential information and is intended only
>> for the individual named. If you are not the named addressee you
>> should not disseminate, distribute or copy this e-mail. Please
>> notify the sender immediately by e-mail if you have received this
>> e-mail by mistake and delete this e-mail from your system.
>>
>> E-mails are not encrypted and cannot be guaranteed to be secure or
>> error-free as information could be intercepted, corrupted, lost,
>> destroyed, arrive late or incomplete, or contain viruses. The sender
>> therefore does not accept liability for any errors or omissions in
>> the contents of this message which arise as a result of e-mail
>> transmission. If verification is required please request a hard-copy
>> version. This message is provided for informational purposes and
>> should not be construed as a solicitation or offer to buy or sell any
>> securities or related financial instruments.
>>
>> UBS Limited is a company registered in England & Wales under company
>> number 2035362, whose registered office is at 1 Finsbury Avenue,
>> London, EC2M 2PP, United Kingdom.
>>
>> UBS AG (London Branch) is registered as a branch of a foreign company
>> under number BR004507, whose registered office is at
>> 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
>>
>> UBS Clearing and Execution Services Limited is a company registered
>> in England & Wales under company number 03123037, whose registered
>> office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
>>
>
>
>
Visit our website at http://www.ubs.com
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mails are not encrypted and cannot be guaranteed to be secure or
error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The sender
therefore does not accept liability for any errors or omissions in the
contents of this message which arise as a result of e-mail transmission.
If verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities
or related financial instruments.
UBS Limited is a company registered in England & Wales under company
number 2035362, whose registered office is at 1 Finsbury Avenue,
London, EC2M 2PP, United Kingdom.
UBS AG (London Branch) is registered as a branch of a foreign company
under number BR004507, whose registered office is at
1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
UBS Clearing and Execution Services Limited is a company registered
in England & Wales under company number 03123037, whose registered
office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
|
|
From: Zdenek M. <zde...@he...> - 2008-11-03 09:07:00
|
Hi,
writing XML - each object is appended independently into the XML file:
Serializer serializer = new Persister();
// true flag - open for appending (writing to the end)
FileWriter fw = new FileWriter("file.xml", true);
serializer.write(textMessageToStore, fw);
fw.write("\n");
fw.close();
XML for first two objects looks like this:
----------- paste ------------
<textMessage>
<message> ... </message>
<timeStamp>2008-11-03 10:02:17.201 CET</timeStamp>
<toAcknowledge>false</toAcknowledge>
</textMessage>
<textMessage>
<message> ... </message>
<timeStamp>2008-11-03 10:02:17.201 CET</timeStamp>
<toAcknowledge>false</toAcknowledge>
</textMessage>
---------- end of paste -------
First message gets read fine.
Zdenek
>
>
> -------- Original Message --------
> Subject: Re: [Simple-support] reading a list of objects from XML
> From: <Nia...@ub...>
> To: zde...@he...
> Cc: sim...@li...
> Date: Mon Nov 03 2008 09:58:55 GMT+0100 (CET)
>> Hi,
>>
>> How are you writing the XML? Also, what does the XML look like here:
>>
>> [row,col]:[1,1]
>>
>> Niall
>>
>>
>>
>> -----Original Message-----
>> From: Zdenek Maxa [mailto:zde...@he...] Sent: 03
>> November 2008 08:57
>> To: Gallagher, Niall-N
>> Cc: sim...@li...
>> Subject: Re: [Simple-support] reading a list of objects from XML
>>
>> Hi,
>>
>> This is exactly what I am doing:
>>
>> FileInputStream fis = new FileInputStream("file.xml");
>> Persister persister = new Persister();
>> ArrayList<TextMessage> fromFile = new ArrayList<TextMessage>();
>> try
>> {
>> while(true)
>> {
>> TextMessage tm = persister.read(TextMessage.class, fis);
>> System.out.println("loaded from XML file: " +
>> tm.toString());
>> fromFile.add(tm);
>> } }
>> catch(EOFException ex)
>> {
>> System.out.println("end of file reached.");
>> fis.close();
>> }
>>
>>
>> First object gets loaded fine but reading fails on the second object
>> / iteration:
>>
>> Exception occured in simple serialisation example: ParseError at
>> [row,col]:[1,1]
>> Message: Premature end of file.
>> javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
>> Message: Premature end of file.
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStre
>> amReaderImpl.java:588)
>> at
>> com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderI
>> mpl.java:85)
>> at
>> org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java:11
>> 7)
>> at
>> org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:74)
>> at
>> org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:74)
>> at
>> org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:61)
>> at org.simpleframework.xml.load.Persister.read(Persister.java:337)
>> at org.simpleframework.xml.load.Persister.read(Persister.java:319)
>> at org.simpleframework.xml.load.Persister.read(Persister.java:300)
>> at
>> JavaToXMLSerialisation.simpleSerialisationExample(JavaToXMLSerialisation
>> .java:148)
>> at JavaToXMLSerialisation.main(JavaToXMLSerialisation.java:183)
>>
>>
>> Thanks again,
>> Zdenek
>>
>>
>> -------- Original Message --------
>> Subject: Re: [Simple-support] reading a list of objects from XML
>> From: <Nia...@ub...>
>> To: zde...@he..., sim...@li...
>> Date: Mon Nov 03 2008 08:37:46 GMT+0100 (CET)
>>
>>> Hi,
>>>
>>> If you do the following.
>>>
>>> InputStream source = new FileInputStream(fileName);
>>> Persister persister = new Persister();
>>> List list = new ArrayList();
>>>
>>> While(....){
>>> list.add(persister.read(ClassName.class, source));
>>> }
>>>
>>> This should work fine. As long as you re-use the same input stream.
>>>
>>> Niall
>>>
>>>
>>> -----Original Message-----
>>> From: Zdenek Maxa [mailto:zde...@he...] Sent: 02
>>> November 2008 20:47
>>> To: sim...@li...
>>> Subject: Re: [Simple-support] reading a list of objects from XML
>>>
>>> hello,
>>>
>>> I am using Simple 1.7.3, serializing number of objects so that I am
>>> -appending- each object to a single file. The result is something
>>>
>> like
>>
>>> this:
>>>
>>> <textMessage>
>>> <message> ... </message>
>>> <timeStamp>2008-11-02 20:15:28.254 CET</timeStamp>
>>> <toAcknowledge>false</toAcknowledge>
>>> </textMessage>
>>>
>>> <textMessage>
>>> <message> ... </message>
>>> <timeStamp>2008-11-02 20:15:28.254 CET</timeStamp>
>>> <toAcknowledge>false</toAcknowledge>
>>> </textMessage>
>>>
>>> I was wondering whether Simple provides some easy way of performing
>>>
>>> ArrayList<TextMessage> msgList = serializer.read(TextMessage.class,
>>> reader)
>>>
>>> which would load the whole file in one go.
>>>
>>> I was experimenting with
>>>
>>> TextMessage tm = serializer.read(TextMessage.class, read)
>>>
>>> placed in a loop, but that only reads fine the first objects and then
>>> fails with
>>>
>>> Message: Premature end of file.
>>> javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
>>> Message: Premature end of file.
>>> at
>>>
>>>
>> com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStre
>>
>>> amReaderImpl.java:588)
>>> at
>>>
>>>
>> com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderI
>>
>>> mpl.java:85)
>>> at
>>>
>>>
>> org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java:11
>>
>>> 7)
>>> at
>>> org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:74)
>>>
>>> ....
>>>
>>>
>>> I shall add that storing all objects in a container is no good
>>>
>> solution
>>
>>> for me since I need to be appending objects and I would be potentially
>>> dealing with many objects.
>>>
>>> Thanks very much for your advise. I have just started with your
>>>
>> library
>>
>>> and find it very very useful for my purpose! Thanks a lot!
>>>
>>> Zdenek
>>>
>>>
>>>
>> ------------------------------------------------------------------------
>>
>>> -
>>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>>> challenge Build the coolest Linux based applications with Moblin SDK &
>>> win great prizes Grand prize is a trip for two to an Open Source event
>>> anywhere in the world
>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>>> _______________________________________________
>>> Simple-support mailing list
>>> Sim...@li...
>>> https://lists.sourceforge.net/lists/listinfo/simple-support
>>> Visit our website at http://www.ubs.com
>>>
>>> This message contains confidential information and is intended only
>>> for the individual named. If you are not the named addressee you
>>> should not disseminate, distribute or copy this e-mail. Please
>>> notify the sender immediately by e-mail if you have received this
>>> e-mail by mistake and delete this e-mail from your system.
>>>
>>> E-mails are not encrypted and cannot be guaranteed to be secure or
>>> error-free as information could be intercepted, corrupted, lost,
>>> destroyed, arrive late or incomplete, or contain viruses. The
>>> sender therefore does not accept liability for any errors or
>>> omissions in the
>>>
>>
>>
>>> contents of this message which arise as a result of e-mail
>>>
>> transmission.
>>> If verification is required please request a hard-copy version.
>>> This message is provided for informational purposes and should not
>>> be construed as a solicitation or offer to buy or sell any
>>> securities or related financial instruments.
>>>
>>> UBS Limited is a company registered in England & Wales under company
>>> number 2035362, whose registered office is at 1 Finsbury Avenue,
>>> London, EC2M 2PP, United Kingdom.
>>>
>>> UBS AG (London Branch) is registered as a branch of a foreign company
>>> under number BR004507, whose registered office is at
>>> 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
>>>
>>> UBS Clearing and Execution Services Limited is a company registered
>>> in England & Wales under company number 03123037, whose registered
>>> office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
>>>
>>
>>
>> Visit our website at http://www.ubs.com
>>
>> This message contains confidential information and is intended only
>> for the individual named. If you are not the named addressee you
>> should not disseminate, distribute or copy this e-mail. Please
>> notify the sender immediately by e-mail if you have received this
>> e-mail by mistake and delete this e-mail from your system.
>>
>> E-mails are not encrypted and cannot be guaranteed to be secure or
>> error-free as information could be intercepted, corrupted, lost,
>> destroyed, arrive late or incomplete, or contain viruses. The sender
>> therefore does not accept liability for any errors or omissions in
>> the contents of this message which arise as a result of e-mail
>> transmission. If verification is required please request a hard-copy
>> version. This message is provided for informational purposes and
>> should not be construed as a solicitation or offer to buy or sell any
>> securities or related financial instruments.
>>
>> UBS Limited is a company registered in England & Wales under company
>> number 2035362, whose registered office is at 1 Finsbury Avenue,
>> London, EC2M 2PP, United Kingdom.
>>
>> UBS AG (London Branch) is registered as a branch of a foreign company
>> under number BR004507, whose registered office is at
>> 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
>>
>> UBS Clearing and Execution Services Limited is a company registered
>> in England & Wales under company number 03123037, whose registered
>> office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
>>
>
>
>
|
|
From: <Nia...@ub...> - 2008-11-03 08:59:06
|
Hi,
How are you writing the XML? Also, what does the XML look like here:
[row,col]:[1,1]
Niall
-----Original Message-----
From: Zdenek Maxa [mailto:zde...@he...]
Sent: 03 November 2008 08:57
To: Gallagher, Niall-N
Cc: sim...@li...
Subject: Re: [Simple-support] reading a list of objects from XML
Hi,
This is exactly what I am doing:
FileInputStream fis = new FileInputStream("file.xml");
Persister persister = new Persister();
ArrayList<TextMessage> fromFile = new ArrayList<TextMessage>();
try
{
while(true)
{
TextMessage tm = persister.read(TextMessage.class, fis);
System.out.println("loaded from XML file: " +
tm.toString());
fromFile.add(tm);
}
}
catch(EOFException ex)
{
System.out.println("end of file reached.");
fis.close();
}
First object gets loaded fine but reading fails on the second object /
iteration:
Exception occured in simple serialisation example: ParseError at
[row,col]:[1,1]
Message: Premature end of file.
javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Premature end of file.
at
com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStre
amReaderImpl.java:588)
at
com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderI
mpl.java:85)
at
org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java:11
7)
at
org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:74)
at
org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:74)
at
org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:61)
at org.simpleframework.xml.load.Persister.read(Persister.java:337)
at org.simpleframework.xml.load.Persister.read(Persister.java:319)
at org.simpleframework.xml.load.Persister.read(Persister.java:300)
at
JavaToXMLSerialisation.simpleSerialisationExample(JavaToXMLSerialisation
.java:148)
at JavaToXMLSerialisation.main(JavaToXMLSerialisation.java:183)
Thanks again,
Zdenek
-------- Original Message --------
Subject: Re: [Simple-support] reading a list of objects from XML
From: <Nia...@ub...>
To: zde...@he..., sim...@li...
Date: Mon Nov 03 2008 08:37:46 GMT+0100 (CET)
> Hi,
>
> If you do the following.
>
> InputStream source = new FileInputStream(fileName);
> Persister persister = new Persister();
> List list = new ArrayList();
>
> While(....){
> list.add(persister.read(ClassName.class, source));
> }
>
> This should work fine. As long as you re-use the same input stream.
>
> Niall
>
>
> -----Original Message-----
> From: Zdenek Maxa [mailto:zde...@he...]
> Sent: 02 November 2008 20:47
> To: sim...@li...
> Subject: Re: [Simple-support] reading a list of objects from XML
>
> hello,
>
> I am using Simple 1.7.3, serializing number of objects so that I am
> -appending- each object to a single file. The result is something
like
> this:
>
> <textMessage>
> <message> ... </message>
> <timeStamp>2008-11-02 20:15:28.254 CET</timeStamp>
> <toAcknowledge>false</toAcknowledge>
> </textMessage>
>
> <textMessage>
> <message> ... </message>
> <timeStamp>2008-11-02 20:15:28.254 CET</timeStamp>
> <toAcknowledge>false</toAcknowledge>
> </textMessage>
>
> I was wondering whether Simple provides some easy way of performing
>
> ArrayList<TextMessage> msgList = serializer.read(TextMessage.class,
> reader)
>
> which would load the whole file in one go.
>
> I was experimenting with
>
> TextMessage tm = serializer.read(TextMessage.class, read)
>
> placed in a loop, but that only reads fine the first objects and then
> fails with
>
> Message: Premature end of file.
> javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
> Message: Premature end of file.
> at
>
com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStre
> amReaderImpl.java:588)
>
> at
>
com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderI
> mpl.java:85)
>
> at
>
org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java:11
> 7)
> at
> org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:74)
>
> ....
>
>
> I shall add that storing all objects in a container is no good
solution
> for me since I need to be appending objects and I would be potentially
> dealing with many objects.
>
> Thanks very much for your advise. I have just started with your
library
> and find it very very useful for my purpose! Thanks a lot!
>
> Zdenek
>
>
------------------------------------------------------------------------
> -
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge Build the coolest Linux based applications with Moblin SDK &
> win great prizes Grand prize is a trip for two to an Open Source event
> anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
> Visit our website at http://www.ubs.com
>
> This message contains confidential information and is intended only
> for the individual named. If you are not the named addressee you
> should not disseminate, distribute or copy this e-mail. Please
> notify the sender immediately by e-mail if you have received this
> e-mail by mistake and delete this e-mail from your system.
>
> E-mails are not encrypted and cannot be guaranteed to be secure or
> error-free as information could be intercepted, corrupted, lost,
> destroyed, arrive late or incomplete, or contain viruses. The sender
> therefore does not accept liability for any errors or omissions in the
> contents of this message which arise as a result of e-mail
transmission.
> If verification is required please request a hard-copy version. This
> message is provided for informational purposes and should not be
> construed as a solicitation or offer to buy or sell any securities
> or related financial instruments.
>
> UBS Limited is a company registered in England & Wales under company
> number 2035362, whose registered office is at 1 Finsbury Avenue,
> London, EC2M 2PP, United Kingdom.
>
> UBS AG (London Branch) is registered as a branch of a foreign company
> under number BR004507, whose registered office is at
> 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
>
> UBS Clearing and Execution Services Limited is a company registered
> in England & Wales under company number 03123037, whose registered
> office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
>
Visit our website at http://www.ubs.com
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mails are not encrypted and cannot be guaranteed to be secure or
error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The sender
therefore does not accept liability for any errors or omissions in the
contents of this message which arise as a result of e-mail transmission.
If verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities
or related financial instruments.
UBS Limited is a company registered in England & Wales under company
number 2035362, whose registered office is at 1 Finsbury Avenue,
London, EC2M 2PP, United Kingdom.
UBS AG (London Branch) is registered as a branch of a foreign company
under number BR004507, whose registered office is at
1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
UBS Clearing and Execution Services Limited is a company registered
in England & Wales under company number 03123037, whose registered
office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
|
|
From: Zdenek M. <zde...@he...> - 2008-11-03 08:57:30
|
Hi,
This is exactly what I am doing:
FileInputStream fis = new FileInputStream("file.xml");
Persister persister = new Persister();
ArrayList<TextMessage> fromFile = new ArrayList<TextMessage>();
try
{
while(true)
{
TextMessage tm = persister.read(TextMessage.class, fis);
System.out.println("loaded from XML file: " +
tm.toString());
fromFile.add(tm);
}
}
catch(EOFException ex)
{
System.out.println("end of file reached.");
fis.close();
}
First object gets loaded fine but reading fails on the second object /
iteration:
Exception occured in simple serialisation example: ParseError at
[row,col]:[1,1]
Message: Premature end of file.
javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Premature end of file.
at
com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:588)
at
com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderImpl.java:85)
at
org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java:117)
at
org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:74)
at org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:74)
at org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:61)
at org.simpleframework.xml.load.Persister.read(Persister.java:337)
at org.simpleframework.xml.load.Persister.read(Persister.java:319)
at org.simpleframework.xml.load.Persister.read(Persister.java:300)
at
JavaToXMLSerialisation.simpleSerialisationExample(JavaToXMLSerialisation.java:148)
at JavaToXMLSerialisation.main(JavaToXMLSerialisation.java:183)
Thanks again,
Zdenek
-------- Original Message --------
Subject: Re: [Simple-support] reading a list of objects from XML
From: <Nia...@ub...>
To: zde...@he..., sim...@li...
Date: Mon Nov 03 2008 08:37:46 GMT+0100 (CET)
> Hi,
>
> If you do the following.
>
> InputStream source = new FileInputStream(fileName);
> Persister persister = new Persister();
> List list = new ArrayList();
>
> While(....){
> list.add(persister.read(ClassName.class, source));
> }
>
> This should work fine. As long as you re-use the same input stream.
>
> Niall
>
>
> -----Original Message-----
> From: Zdenek Maxa [mailto:zde...@he...]
> Sent: 02 November 2008 20:47
> To: sim...@li...
> Subject: Re: [Simple-support] reading a list of objects from XML
>
> hello,
>
> I am using Simple 1.7.3, serializing number of objects so that I am
> -appending- each object to a single file. The result is something like
> this:
>
> <textMessage>
> <message> ... </message>
> <timeStamp>2008-11-02 20:15:28.254 CET</timeStamp>
> <toAcknowledge>false</toAcknowledge>
> </textMessage>
>
> <textMessage>
> <message> ... </message>
> <timeStamp>2008-11-02 20:15:28.254 CET</timeStamp>
> <toAcknowledge>false</toAcknowledge>
> </textMessage>
>
> I was wondering whether Simple provides some easy way of performing
>
> ArrayList<TextMessage> msgList = serializer.read(TextMessage.class,
> reader)
>
> which would load the whole file in one go.
>
> I was experimenting with
>
> TextMessage tm = serializer.read(TextMessage.class, read)
>
> placed in a loop, but that only reads fine the first objects and then
> fails with
>
> Message: Premature end of file.
> javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
> Message: Premature end of file.
> at
> com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStre
> amReaderImpl.java:588)
>
> at
> com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderI
> mpl.java:85)
>
> at
> org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java:11
> 7)
> at
> org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:74)
>
> ....
>
>
> I shall add that storing all objects in a container is no good solution
> for me since I need to be appending objects and I would be potentially
> dealing with many objects.
>
> Thanks very much for your advise. I have just started with your library
> and find it very very useful for my purpose! Thanks a lot!
>
> Zdenek
>
> ------------------------------------------------------------------------
> -
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge Build the coolest Linux based applications with Moblin SDK &
> win great prizes Grand prize is a trip for two to an Open Source event
> anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
> Visit our website at http://www.ubs.com
>
> This message contains confidential information and is intended only
> for the individual named. If you are not the named addressee you
> should not disseminate, distribute or copy this e-mail. Please
> notify the sender immediately by e-mail if you have received this
> e-mail by mistake and delete this e-mail from your system.
>
> E-mails are not encrypted and cannot be guaranteed to be secure or
> error-free as information could be intercepted, corrupted, lost,
> destroyed, arrive late or incomplete, or contain viruses. The sender
> therefore does not accept liability for any errors or omissions in the
> contents of this message which arise as a result of e-mail transmission.
> If verification is required please request a hard-copy version. This
> message is provided for informational purposes and should not be
> construed as a solicitation or offer to buy or sell any securities
> or related financial instruments.
>
> UBS Limited is a company registered in England & Wales under company
> number 2035362, whose registered office is at 1 Finsbury Avenue,
> London, EC2M 2PP, United Kingdom.
>
> UBS AG (London Branch) is registered as a branch of a foreign company
> under number BR004507, whose registered office is at
> 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
>
> UBS Clearing and Execution Services Limited is a company registered
> in England & Wales under company number 03123037, whose registered
> office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
>
|
|
From: <Nia...@ub...> - 2008-11-03 07:38:03
|
Hi,
If you do the following.
InputStream source = new FileInputStream(fileName);
Persister persister = new Persister();
List list = new ArrayList();
While(....){
list.add(persister.read(ClassName.class, source));
}
This should work fine. As long as you re-use the same input stream.
Niall
-----Original Message-----
From: Zdenek Maxa [mailto:zde...@he...]
Sent: 02 November 2008 20:47
To: sim...@li...
Subject: Re: [Simple-support] reading a list of objects from XML
hello,
I am using Simple 1.7.3, serializing number of objects so that I am
-appending- each object to a single file. The result is something like
this:
<textMessage>
<message> ... </message>
<timeStamp>2008-11-02 20:15:28.254 CET</timeStamp>
<toAcknowledge>false</toAcknowledge>
</textMessage>
<textMessage>
<message> ... </message>
<timeStamp>2008-11-02 20:15:28.254 CET</timeStamp>
<toAcknowledge>false</toAcknowledge>
</textMessage>
I was wondering whether Simple provides some easy way of performing
ArrayList<TextMessage> msgList = serializer.read(TextMessage.class,
reader)
which would load the whole file in one go.
I was experimenting with
TextMessage tm = serializer.read(TextMessage.class, read)
placed in a loop, but that only reads fine the first objects and then
fails with
Message: Premature end of file.
javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Premature end of file.
at
com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStre
amReaderImpl.java:588)
at
com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderI
mpl.java:85)
at
org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java:11
7)
at
org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:74)
....
I shall add that storing all objects in a container is no good solution
for me since I need to be appending objects and I would be potentially
dealing with many objects.
Thanks very much for your advise. I have just started with your library
and find it very very useful for my purpose! Thanks a lot!
Zdenek
------------------------------------------------------------------------
-
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge Build the coolest Linux based applications with Moblin SDK &
win great prizes Grand prize is a trip for two to an Open Source event
anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
Visit our website at http://www.ubs.com
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mails are not encrypted and cannot be guaranteed to be secure or
error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The sender
therefore does not accept liability for any errors or omissions in the
contents of this message which arise as a result of e-mail transmission.
If verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities
or related financial instruments.
UBS Limited is a company registered in England & Wales under company
number 2035362, whose registered office is at 1 Finsbury Avenue,
London, EC2M 2PP, United Kingdom.
UBS AG (London Branch) is registered as a branch of a foreign company
under number BR004507, whose registered office is at
1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
UBS Clearing and Execution Services Limited is a company registered
in England & Wales under company number 03123037, whose registered
office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
|
|
From: Zdenek M. <zde...@he...> - 2008-11-02 20:47:39
|
hello, I am using Simple 1.7.3, serializing number of objects so that I am -appending- each object to a single file. The result is something like this: <textMessage> <message> ... </message> <timeStamp>2008-11-02 20:15:28.254 CET</timeStamp> <toAcknowledge>false</toAcknowledge> </textMessage> <textMessage> <message> ... </message> <timeStamp>2008-11-02 20:15:28.254 CET</timeStamp> <toAcknowledge>false</toAcknowledge> </textMessage> I was wondering whether Simple provides some easy way of performing ArrayList<TextMessage> msgList = serializer.read(TextMessage.class, reader) which would load the whole file in one go. I was experimenting with TextMessage tm = serializer.read(TextMessage.class, read) placed in a loop, but that only reads fine the first objects and then fails with Message: Premature end of file. javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1] Message: Premature end of file. at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:588) at com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderImpl.java:85) at org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java:117) at org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:74) .... I shall add that storing all objects in a container is no good solution for me since I need to be appending objects and I would be potentially dealing with many objects. Thanks very much for your advise. I have just started with your library and find it very very useful for my purpose! Thanks a lot! Zdenek |
|
From: <Nia...@ub...> - 2008-10-20 10:06:01
|
Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company registered in England & Wales under company number 2035362, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS AG (London Branch) is registered as a branch of a foreign company under number BR004507, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS Clearing and Execution Services Limited is a company registered in England & Wales under company number 03123037, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. |
|
From: Greg C. <gre...@qu...> - 2008-10-20 08:18:41
|
Hi Niall,
I have an issue where the values of elements are not being stored for Java types if they are declared as an Object. The class attribute is always set correctly, so I'm presuming this is a value conversion problem caused by the actual type differing from the declared type.
User-defined classes don't seem to suffer from the same problem, as illustrated by the Name class shown below.
This XML:
<test>
<string>ABC</string>
<object class="java.lang.String"/>
<map class="java.util.HashMap">
<entry string="INTEGER">
<object class="java.lang.Integer"/>
</entry>
<entry string="DATE">
<object class="java.util.Date"/>
</entry>
<entry string="STRING">
<object class="java.lang.String"/>
</entry>
<entry string="NAME">
<object class="test.xml.Simple.Name" firstName="Greg" lastName="Cottman"/>
</entry>
</map>
</test>
is generated by this test program:
@Root(name = "test")
public class MapTest
{
@Element
private String string = "ABC";
@Element
private Object object = "ABC";
@ElementMap(keyType = String.class, valueType = Object.class, attribute = true)
private Map<String,Object> map = new HashMap<String,Object>();
public static void main(String[] args)
{
try
{
MapTest test = new MapTest();
test.map.put("STRING", "THX1138");
test.map.put("INTEGER", Integer.valueOf(42));
test.map.put("DATE", new Date(System.currentTimeMillis()));
test.map.put("NAME", new Name("Greg", "Cottman"));
Serializer serializer = new Persister();
serializer.write(test, System.out);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
Thanks,
Greg.
|