|
Xml Conversion Patterns 2 Describes high-level conversion of XML documents to HopObject structures and back. Implemented. Conversion between XML documents and HopObjects can be achieved in two ways:
Please note that java-properties regard not only a '=' but also a ':' as the separator. So in a properties file name=test is the same as name:test. As the ':' character is used to separate namespace and localname, we need to mask these characters if they appear in the properties file. namespace\:localname = something
item._prototype = testobject
A certain attribute is converted to a property of a different name. item._attribute.about = info <item about="xyz"></item>results in item.info = "xzy"
item._text = info <item>some text</item>results in item.info = "some text"(the default would be item.text = "some text")
item.description._text = desc <item> <description>some text</description> <description>more text</description> </item>results in item.desc = "some text"If there is more than one element of that name, the rest will be ignored.
Defines which childelements are converted as children of the corresponding Hopobject. _all will mount all childelements as children (nevertheless they might get a virtual mounting too, see below). _all can lead to a children-array containing different prototypes. item._children = _all <item> <description>some text</description> <description>some text</description> <image>imagedata</image> </item>results in item.get(0) = Hopobject description item.get(1) = Hopobject description item.get(2) = Hopobject imagedataor item._children = description <item> <description>some text</description> <description>some text</description> <image>imagedata</image> </item>results in item.get(0) = Hopobject description item.get(1) = Hopobject description
By default a virtual collection of children is created for every type of element that is found in the document. With this directive you can change the name of this collection. item.testimage = images <item> <testimage>firstimage</testimage> <testimage>secondimage</testimage> <testimage>thirdimage</testimage> </item>results in item.images.get(0) = Hopobject firstimage item.images.get(1) = Hopobject secondimage item.images.get(2) = Hopobject thirdimagethe default would be item.testimage.get(0) = Hopobject firstimage item.testimage.get(1) = Hopobject secondimage item.testimage.get(2) = Hopobject thirdimage
... comment
tobi,
Wednesday, 5. June 2002, 19:49
Change note
As of June 5, save(), load() and create() have been renamed to write(), read(), writeToString() and readFromString() as discussed on the mailing list http://helma.org/archives/hop/2002-June/001247.html
... link ... comment
hns,
Thursday, 6. June 2002, 15:26
Change note
Reversed argument order in Xml.write() from
void Xml.write(filename,hopobject); to void Xml.write(hopobject,filename); because this seemed more consistent to me. This is still pending Stefan's approval. ... link ... comment
stefanp,
Thursday, 26. September 2002, 17:16
Re: Xml Conversion Patterns 2
be careful: If the assigned property name is the same as a predefined hopobject-function like add, remove, href, link (!) the property is not accessible.
the rss-examples have that problem when is converted to a property "link" as link() is an undocumented function of every hopobject. ... link
hns,
Friday, 27. September 2002, 10:11
Re: Re: Xml Conversion Patterns 2
This sucks... We have to do something about this, at some point.
BTW, I think hopObject.link() is obsolete and should be removed. ... link ... comment |
navigation
Download
Community
Weblog
Mailing Lists
IRC Channel
Documentation
Introductions
Tools
Reference
Project
Roadmap
Bug Reporting
Source
Wiki
Tags
Updates
Related Projects
search
|
|||||||||||