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

World: r3wp

[XML] xml related conversations

BrianH
23-Jun-2009
[644]
My positional version handles multiple subelements of the same type, 
and using strings rather than words lets you use tags that don't 
match word syntax or are case=sensitive.
Maxim
23-Jun-2009
[645x2]
its just that in my tests, either you can create, read or set some 
of the datatypes via path notation.  so only string based types allow 
full XML qualification.
hahaha
Graham
23-Jun-2009
[647]
XML can be case sensitive??
Maxim
23-Jun-2009
[648]
but brian, how do you acess it?
Graham
23-Jun-2009
[649]
by position!
BrianH
23-Jun-2009
[650x2]
XML *is* case-sensitive. Your paths can't access multiple subelements 
of the same type, or embedded text.
I wrote a simple xpath compiler too (but don't know where it is now).
Maxim
23-Jun-2009
[652]
I wanted direct access to all elements within rebol.
Graham
23-Jun-2009
[653]
Looks like we need an article on best practices here ...
Maxim
23-Jun-2009
[654]
a later version, using schema validation, understands multiple subelements 
and automatically converts them to blocks IIRC.

so you do document/element/3/subelement/#attribute.
BrianH
23-Jun-2009
[655]
Your paths can't access multiple subelements of the same type, or 
embedded text. It might have worked for that customer but not the 
general case. No namespace support either.
Maxim
23-Jun-2009
[656]
my paths.. namespace works... for sure.  did you know you can have 
colon in word names in R2 !   but i didn;t use that, I just used 
tags directly.  more obvious than strings, and the exact same effort 
and speed.
BrianH
23-Jun-2009
[657]
I was parsing xhtml and other XML of the like. Subelements of mixed 
types in order with text between them than mattered.
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?