World: r3wp
[XML] xml related conversations
older newer | first last |
Graham 24-Jun-2009 [759] | so, I have to now do a: do load mold make pharmacy [ ] ? |
Maxim 24-Jun-2009 [760] | a: do mold pharmacy [ ] |
Graham 24-Jun-2009 [761] | a: do mold pharmacy ; |
Maxim 24-Jun-2009 [762] | yes since I removed the make. |
Graham 24-Jun-2009 [763] | This solution seems a little tortued :) |
Maxim 24-Jun-2009 [764] | not really, the way I see it is that we are taking advantage of rebol's features. |
Sunanda 24-Jun-2009 [765] | Do has some dangers if you do not trust the code involved. This works for me, and keeps the load/all (but not the self).....Even more tortured: a: first reduce load/all mold pharmacy |
Maxim 24-Jun-2009 [766] | but note that your object's structure has to remain pretty static for any type of deep copy like this to be usefull. |
Graham 24-Jun-2009 [767] | what do you mean? |
Maxim 24-Jun-2009 [768] | talking to who? |
Graham 24-Jun-2009 [769x2] | deep copy |
what do you nean by structure has to remain pretty static? | |
Maxim 24-Jun-2009 [771x2] | well if the pharmacy object can have 1 or 5 addresses, some people 3 different ways to refer to patients, etc... then the copy still has to be meddled with. |
if the db returns lists of varying length and types... you're better off creating a structured approach to a recursive initialisation. | |
Graham 24-Jun-2009 [773] | I'll be creating an empty object and then populating it once created |
Maxim 24-Jun-2009 [774] | ok. |
Sunanda 24-Jun-2009 [775] | You may have some other issues to consider as part of building/loading the data structures. For example, Version2 of the application adds some fields not present in V1. To avoid a one-off bulk conversion exercise, the load process needs to check each object and add missing fields with default values. |
Graham 24-Jun-2009 [776x3] | I'll just change the object templates |
What I need to do is to create the object, create the xml from the object, and then submit it via ssl to the gateway server | |
and then I can discard it ... | |
Sunanda 24-Jun-2009 [779] | That makes life a bit simpler.....Objects with year-long lifespans can be harder to manage :) |
Graham 24-Jun-2009 [780x2] | I have configs that are saved in the db as objects ... and those i have to check each time :( |
And when my app crashes as it does often enough, I save state as an object .. and that has to be checked as well when reloaded. | |
Sunanda 24-Jun-2009 [782] | We have similar issues at REBOL.org where just about everything [scripts, Ml posts, internal data structures, etc] is objects, or blocks of objects. Data sanitisation and object upgrading is a major part of the gig. |
Graham 24-Jun-2009 [783x3] | Interesting... |
and these are stored where? In the filing system? | |
I'm pretty sure rebol.org doesn't use a db backend. | |
Sunanda 24-Jun-2009 [786] | [we're off topic for XML -- please continue in Library if you want more details]. Stored in text files and binary files (which are generally just compressed text files. No database! |
BrianH 24-Jun-2009 [787x3] | Functions can be serialized, but the only word contexts that get restored are the global and thee function local context. Any intermediate contexts, like object contexts, don't get restored. |
That's because the "intermediate" contexts don't really indermediate - they get applied in order by DO. | |
indermediate -> intermediate | |
Geomol 24-Jun-2009 [790] | In case, it's needed, RebXML spec: http://www.fys.ku.dk/~niclasen/rebxml/rebxml-spec.html |
Graham 28-Jun-2009 [791] | has anyone got a working copy of parse-xml.r from the library? |
Sunanda 28-Jun-2009 [792] | Don't remember if I tried parse-xml. I do use xml-object wich works well for me: http://www.rebol.org/view-script.r?script=xml-object.r |
Graham 28-Jun-2009 [793] | that's the complementary script ... |
Sunanda 28-Jun-2009 [794] | Both parse XML. The main difference is: -- xml-object.r uses REBOL's built-in mezzanine, parse-xml -- parse-xml.r is an improvement for parse-xml In theory, you could use both together. In my experience, xml-object.r is all I need to parse XML ..... the XML I encounter just does not need the extra oomph supplied by parse-xml.r |
Graham 28-Jun-2009 [795x2] | Got a working example of their use? |
I keep getting errors | |
Sunanda 28-Jun-2009 [797] | This works for me: do %xml-object.r xml-file: read %my-xml-file.xml xml-object: first reduce xml-to-object parse-xml xml-file Though the resulting object does need some tidying up |
Graham 28-Jun-2009 [798x5] | Hmm. There is no 'xml-object function |
oh ...sorry | |
cool .. | |
creates a value element for each value :( | |
value?: | |
Sunanda 28-Jun-2009 [803] | As I said, you may need to tidy things up.....I wrote some code to do that, but it is hardwired for the particular dataset i was using. |
Graham 28-Jun-2009 [804x5] | Looks good ... I can cope :) |
fix-object: func [ obj [object!] /local prev ][ foreach element next first obj [ if object? o: get in obj element [ ; is object, so check to see if has value? either "value?" = form next first o [ set in obj element trim/head/tail get in o 'value? ][ fix-object o ] ] ] ] this fixes up the object created by xml-to-object | |
ooops ... doesn't need the /loca | |
ie. should be /local o | |
or not | |
older newer | first last |