[Xerte] Re: Converting an object to xml

Kemp Johnathan johnathan.kemp at ntlworld.com
Wed Mar 7 15:26:50 GMT 2012


 "Can you write recursive functions to dive an object?"

I've got a snorkel and some flippers - will that help :-)

This sounds like a fun project for when I have got the current release out
of the way. I would like to have a save and restore facility for the
scenario connector page. I think I have only used recursion once in all the
time I've been programming so the current answer to your question would be
no - but things change.

If we release the current version of the page in 2.18 it should be a simple
swap out of the rlm file at a later date if I can get it working.

Kind regards

Johnathan

On 7 March 2012 15:18, Julian Tenney <Julian.Tenney at nottingham.ac.uk> wrote:

> Perfectly feasible, but xerte hasn’t got one.
>
>
>
> Can you write recursive functions to dive an object?
>
>
>
> Look at the code behind inspect() in the engine. You could modify that.
>
>
>
>
>
> *From:* xerte-bounces at lists.nottingham.ac.uk [mailto:
> xerte-bounces at lists.nottingham.ac.uk] *On Behalf Of *Kemp Johnathan
> *Sent:* 07 March 2012 15:17
>
> *To:* Xerte discussion list
> *Subject:* [Xerte] Re: Converting an object to xml
>
>
>
> The problem I was trying to solve was one of having an object in a page,
> being able to dump that object as xml data to a file and then being able to
> recreate that object from the xml data by reloading the file at a later
> date.
>
>
>
> So if you started with the object
>
> node[0].att
>
>
>
> When it was converted to xml would it matter if it was generated as
>
>
>
> <node att="value">
>
> or
>
> <node><att>value</att></node>
>
>
>
> since either approach would recreate as an object as
>
>
>
> node[0].att
>
>
>
> I can understand that if you were starting with the xml you would not know
> which format of xml to create when converting back from the object you
> created and that therefore you could end up with a different XML structure
> to that which you started with. But if you were starting off from the
> object, would it not be feasible to have a conversion routine that always
> adopted the same approach when converting from an object to the xml data.
> Thus making it possible to consistently convert from the object to the xml
> and back again? (I know I am talking theoretically here - how you would
> achieve it I am not currently sure).
>
>
>
> Is there something fundamental about xml that I am failing to grasp here?
>
>
>
> Kind regards
>
>
>
> Johnathan
>
>
>
> On 7 March 2012 12:05, Julian Tenney <Julian.Tenney at nottingham.ac.uk>
> wrote:
>
> I don’t think you’re going to get bi-directional because
>
>
>
> <node att=”value”> is node[0].att and <node><att>value</att></node> is
> node[0].att
>
>
>
> *From:* xerte-bounces at lists.nottingham.ac.uk [mailto:
> xerte-bounces at lists.nottingham.ac.uk] *On Behalf Of *Kemp Johnathan
>
>
> *Sent:* 07 March 2012 11:21
> *To:* Xerte discussion list
>
> *Subject:* [Xerte] Re: Converting an object to xml
>
>
>
> What I was hoping to achieve was a bi-directional capability i.e.
>
>
>
> you could go back and forth, perhaps creating your initial object from xml
> data, then modify the object in a page, then save it out as xml again. Then
> the next time you load the page you have the option of restoring a your
> previously saved data.
>
>
>
> Kind regards
>
>
>
> Johnathan
>
>
>
> On 7 March 2012 11:03, Julian Tenney <Julian.Tenney at nottingham.ac.uk>
> wrote:
>
> Good question. No, not currently. Have a look for a prototype extension
> and I can build it in if it does what you want: it would probably not
> create attributes, rather full nodes for each value, and it would have to
> make some assumptions when naming things I think:
>
>
>
> <object>
>
>   <property>value</property>
>
>   <array>
>
>     <item>value</item>
>
>     ….
>
>   </array>
>
>>
> </object>
>
>
>
> *From:* xerte-bounces at lists.nottingham.ac.uk [mailto:
> xerte-bounces at lists.nottingham.ac.uk] *On Behalf Of *Kemp Johnathan
> *Sent:* 07 March 2012 10:40
> *To:* Xerte discussion list
> *Subject:* [Xerte] Converting an object to xml
>
>
>
> Xerte has the myXML.toObject() method that will construct an object from
> xml data.
>
>
>
> Is there an easy way to go in the other direction and convert an object
> into XML data?
>
>
>
> Kind regards
>
>
>
> Johnathan
>
>
>
> This message and any attachment are intended solely for the addressee and
> may contain confidential information. If you have received this message in
> error, please send it back to me, and immediately delete it. Please do not
> use, copy or disclose the information contained in this message or in any
> attachment. Any views or opinions expressed by the author of this email do
> not necessarily reflect the views of the University of Nottingham.
>
> This message has been checked for viruses but the contents of an
> attachment may still contain software viruses which could damage your
> computer system: you are advised to perform your own checks. Email
> communications with the University of Nottingham may be monitored as
> permitted by UK legislation.
>
>
> _______________________________________________
> Xerte mailing list
> Xerte at lists.nottingham.ac.uk
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte
>
> This message and any attachment are intended solely for the addressee and
> may contain confidential information. If you have received this message in
> error, please send it back to me, and immediately delete it.   Please do
> not use, copy or disclose the information contained in this message or in
> any attachment.  Any views or opinions expressed by the author of this
> email do not necessarily reflect the views of the University of Nottingham.
>
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses which could damage your computer system:
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
>
>
>
>
> _______________________________________________
> Xerte mailing list
> Xerte at lists.nottingham.ac.uk
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte
>
> This message and any attachment are intended solely for the addressee and
> may contain confidential information. If you have received this message in
> error, please send it back to me, and immediately delete it.   Please do
> not use, copy or disclose the information contained in this message or in
> any attachment.  Any views or opinions expressed by the author of this
> email do not necessarily reflect the views of the University of Nottingham.
>
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses which could damage your computer system:
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
>
>
>
> _______________________________________________
> Xerte mailing list
> Xerte at lists.nottingham.ac.uk
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte
>
> This message and any attachment are intended solely for the addressee and
> may contain confidential information. If you have received this message in
> error, please send it back to me, and immediately delete it.   Please do
> not use, copy or disclose the information contained in this message or in
> any attachment.  Any views or opinions expressed by the author of this
> email do not necessarily reflect the views of the University of Nottingham.
>
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses which could damage your computer system:
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20120307/dcc96e04/attachment-0001.html>


More information about the Xerte mailing list