World: r3wp
[XML] xml related conversations
older newer | first last |
Graham 24-Jun-2009 [737x3] | well, output is first, reading is the next task :) |
it's all in a DB. | |
this is part of the xsd .. found an example http://stackoverflow.com/questions/790118/jaxb-types-problem | |
Maxim 24-Jun-2009 [740x2] | what I can suggest is that you build your objects like so: xml-attribute: context [ name: "someattr" value: "somevalue" ] xml-tag: context [ name: "FileID" content: [] ; a block of inner xml-tag objects attributes: [] ; a block of xml-attribute names ] then all you do is nest objects in objects, filling them up item by item recursively using DB data. |
the downside is that access either needs a wrapper func, or is done via indexes... actually attributes could be an object, since their names are mutually exclusive within an element. | |
Graham 24-Jun-2009 [742] | Let me understand this .. if I have an object that needs other objects more than 1 deep .. I can't use that to clone other objects without creating references instead of copies. |
Maxim 24-Jun-2009 [743] | you can just do a mold/all load, that will in effect copy the whole tree along with all the series too. |
Graham 24-Jun-2009 [744] | I was just thinking that. |
Maxim 24-Jun-2009 [745x2] | ex: load mold/all make object! [ a: make object! [ b: make object! [ c: "tadam!" ] ] ] will effectively create a complete duplicate of the whole object tree. |
but remember to use mold/ALL cause otherwise you end up with gibberish... | |
Graham 24-Jun-2009 [747x2] | So, I can continue to make the objects as I have been doing. But just before I use it ... I load mold/all on it to ensure I have unique objects |
ie. I load a serialized form of the object | |
Maxim 24-Jun-2009 [749] | yes. |
Graham 24-Jun-2009 [750x2] | ahh ... well problem solved :) |
seems not :( >> pharmacy: make object! [ [ name: none [ init: func [ n ][ [ self/name: n [ ] [ ] >> a: load mold/all make pharmacy [] >> probe a make object! [ name: none init: func [n][ self/name: n ] ] >> a/init "testing" ** Script Error: self has no value ** Where: init ** Near: self/name: n | |
Maxim 24-Jun-2009 [752x2] | if you have a function inside, I think you have to do it instead of load it. |
functions cannot be serialized... so they have to be bound somehow. | |
Sunanda 24-Jun-2009 [754] | Why not remove the self ? [not a metaphysical question in this context] ph: make object! [ name: none init: func [n][ name: n ] ] |
Maxim 24-Jun-2009 [755] | seems functions can be serialized, but I don't understand why the self isn't being bound to the object..that is strange. |
Graham 24-Jun-2009 [756] | because it won't work? |
Maxim 24-Jun-2009 [757] | ok, to use do, you must forget the /all. so the above, minus the /all should work with self... (it does in my tests) |
Sunanda 24-Jun-2009 [758] | It worked for me, when i tried it. |
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! |
older newer | first last |