r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[XML] xml related conversations

Maxim
23-Jun-2009
[658x3]
my engine does support embedded types, but ignored it by default... 
it was also byte reversible... a loaded xml block loaded through 
the engine was saved back exactly, byte for byte, checksum proofed.
oops.. embedded text I mean.
but all of that is not open source.
BrianH
23-Jun-2009
[661]
And mine is lost :(
Maxim
23-Jun-2009
[662x2]
my newer version doesn't have the schema validation process.... that 
is a very complex engine to build.   schemas and Parse traversal 
do not follow the same algorythm... so its a bitch to implement.
anyhow... the xml tools I currently have are not yet tested enough 
to be release ready.
Graham
23-Jun-2009
[664]
Ok, so we have established that everyone does it their own way :)
Maxim
23-Jun-2009
[665]
but the rebxml tools (on rebol.org) as-is are very usefull, so some 
utf-8 support and are less buggy than rebelXML in my previous tests.
Graham
23-Jun-2009
[666x4]
rebelxml gets confused if there is more than one path with the same 
name
it accepts the first one it finds
even if the full path is specified.
I suspect the author is no longer reboling
Maxim
23-Jun-2009
[670]
I remeber it also tripping on some of the XML files I gave it... 
don't remember the problems... but its error handling /recovery was 
very shaky IIRC.
Graham
23-Jun-2009
[671x2]
You should add a comment to the discussion page if you remember.
as should i.
Maxim
23-Jun-2009
[673]
read above,  I don't  ;-)
Graham
23-Jun-2009
[674x3]
at this time .. it may come back to you
that's why I said "if" ...
Using objects means i can store the functions that initialize it 
inside the object.
BrianH
23-Jun-2009
[677]
Not a good idea for data objects, which could number in the thousands, 
each with their own bound copy of the functions.
Maxim
23-Jun-2009
[678]
yes, the best method is to have some form of dtd or schema, and use 
class-based objects.
BrianH
23-Jun-2009
[679]
Class-based objects are emulated in REBOL.
Maxim
23-Jun-2009
[680x2]
the init is a context with one function, to which you supply the 
outer (instance) which holds the data:

my-tag: context [
	data: "tototo"
	attribute-1: "red"
	class: context [
		init: func [instance][
			instance/data: copy ""
			instance/attribute-1:  copy "blue"
		]
	]
]

to init the an instance of my-tag:

new-tag: make my-tag [class/init self]
class is shared amongst all my-tag instances, and is never bound 
to any of them, so its both very fast and very RAM efficient..  exponentially 
so with large classes.
Graham
24-Jun-2009
[682x2]
That's what i was going to do initially, but I thought it would be 
easier to maintain if I kept the init methods inside the objects
Perhaps I'm not clear on this ....  
If I create a pharmacy object like this


pharmacy: make object! [
	name: none
	init: func [ n ][
		self/name: n
	]
]


is the init function shared by all the subsequent pharmacy instances?
Maxim
24-Jun-2009
[684]
it is bound each time, so if you have 2000 instances, you actually 
have 2000 times that function in ram, it adds up quickly for larger 
objects... for such a simple object, it might not be all that bad...
Graham
24-Jun-2009
[685]
what's the diff between yours and mine?
Maxim
24-Jun-2009
[686x2]
my example above, will share the init function amongst all the 2000 
objects... and its going to be faster since no binding occurs... 
well only the CLASS word is bound but its content is the same in 
all instances.
with liquid the difference is staggering when over 10000 objects.
Graham
24-Jun-2009
[688x2]
well, I doubt that I would have more than a few hundred objects... 
but ...
unclear as to why yours is shared and mine isn't
Maxim
24-Jun-2009
[690x2]
but its a large object.  still using the class system, I can allocate 
1000000 nodes using about 400MB.  with instances, 10000 obects take 
much more than that.
R2 shares objects within objects. the class is not re-created at 
each make [].
Graham
24-Jun-2009
[692x2]
Oh ....
is it objects within objects within objects?
BrianH
24-Jun-2009
[694]
But then the class functions are accessed through obj/class/method 
obj, insstead of obj/method.
Graham
24-Jun-2009
[695]
so if I have

pharmacy: make object! [
	address: make addressobj [ ]
]


and the address object has objects in it ... they will be shared??
BrianH
24-Jun-2009
[696]
Yeah.
Graham
24-Jun-2009
[697x3]
Ouch
So, how does one create nested unique objects?
Create them using the init function ??
BrianH
24-Jun-2009
[700x2]
With explicit construction in the spec block, like this:
a: make proto [
    b: make inner-proto [...]
]
Every MAKE object! takes a spec block that is an init function, in 
effect.
Graham
24-Jun-2009
[702x3]
so , instead of 

a: make pharmacy []

I have to 

a: make pharmacy [ address: make addressobj []]
If that is the case, perhaps I need a 'create function with each 
object, and at init time, iterate thru all the objects calling their 
create function ?
As you can see, I've never played with rebol objects before ...
BrianH
24-Jun-2009
[705]
If you like. The standard way of doing things in REBOL is to have 
functions that create objects, rather than constructor methods.
Graham
24-Jun-2009
[706x2]
which is the more robust method?
In terms of maintenance?