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

World: r3wp

[Core] Discuss core issues

Graham
17-Nov-2006
[6249x2]
Is there a  way to build a rebol object with these tools?
So, I can then identify elements using path notation?
Geomol
17-Nov-2006
[6251x8]
No, not with RebXML as it is now.
Maybe we need rebxml2obj.r and obj2rebxml.r scripts!?
There is a problem with attributes. What if an attribute to a tag 
has the same name as another element within the content of the tag?
A rule could be made, that attributes are placed within a block named 
"attributes" within the object. But that you can't have a tag with 
the name "attributes".
But that = But then
Another solution could be, that attributes and content are treated 
the same, but then something like:
<tag type="mytag"><type>mycontent</type></tag>
will produce:
tab: make object! [type: "mycontent"]
and the attribute is lost.
tab: = tag:
(It's late here. Sorry about misspell.)
Graham
17-Nov-2006
[6259]
perhaps the content should be made an attribute of the tag.
Geomol
17-Nov-2006
[6260x3]
That's a solution, but it can't cope with all XML. What should you 
call the content attribute? You might call it something, that another 
attribute is called already.
Another problem is, that this is valid XML:
<tag1>string 1<tag2>content</tag2>string 2</tag1>


If you made that to an object, how would to refer to "string 1" and 
"string 2"? So of course it's possible to make XML to REBOL objects, 
but then you have to make restrictions to what kind of XML, you can 
handle.
It's hard (maybe impossible) to come up with a solution, that can 
handle all XML.
Graham
17-Nov-2006
[6263]
is there a difference between valid xml and that which is in common 
use?
Geomol
17-Nov-2006
[6264]
I don't know. My last example is probably not seen that often, but 
it's valid according to the XML specs.
Graham
17-Nov-2006
[6265]
as long as something covers 80% of the use cases ...
Geomol
17-Nov-2006
[6266]
Maybe something can be made from the builtin REBOL parse-xml and 
xml-language?
Graham
17-Nov-2006
[6267]
rebelxml.r looks as though it will do what I need.
Geomol
17-Nov-2006
[6268]
cool
Graham
17-Nov-2006
[6269]
http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=rebelxml.r&sid=jp963yh
Pekr
18-Nov-2006
[6270]
Graham - I found Gavain's Mckenzie's scripts usefull some two years 
ago. I had also some chat with him, and it seems his work covers 
80% of usual programmer needs. You could build object with his code 
...
Sunanda
18-Nov-2006
[6271]
I've used Graham's code a lot --especially for hefting RSS files 
into REBOL format. It works well.
Gregg
18-Nov-2006
[6272]
There's a HUGE difference between dealing with simple, well formed, 
XML, and trying to implement the XML specification. A good deal of 
XML our there is just well formed; no namespaces, no attributes; 
easy to deal with. I did a loading (XML to blocks) that just makes 
a minor change to parse-xml; it reverses the content and attribute 
values--since attributes are often NONE--so you can use path notation 
on the resulting block.
Graham
18-Nov-2006
[6273x3]
rebelxml seems to be working so far .. if it doesn't do, I'll look 
at Gavin's stuff again.
>> test: make object! [ a: b: none  c: make object! [ d: none]]
>>
>> obj: make test [ c/d: "testing"]
>> h: make test [ a: 1 ]
>> probe h
make object! [
    a: 1
    b: none
    c: make object! [
        d: "testing"
    ]
]
how come when I create a new test object, it has the same c object 
?  Shouldn't that be a new object as well?
Anton
19-Nov-2006
[6276x2]
No, when using MAKE, sub-objects are shared (functions are cloned). 
This is how sharing of feel objects is implemented when faces are 
cloned.
So, if you want to be sure to clone your object and every field, 
you will have to check every field to see if it is an object and 
clone it too.
Graham
19-Nov-2006
[6278]
that's a bit painful ... guess why I never used objects much before.
Anton
19-Nov-2006
[6279]
Yes, sharing is handy but not when you don't want it. :)
Sunanda
20-Nov-2006
[6280]
Quick hack, Graham:
test: make object! [ a: b: none  c: make object! [ d: none]]
obj: make first reduce load mold test [ c/d: "testing"]
[unknown: 10]
20-Nov-2006
[6281]
x: [ 2 4 6 ]
y: [  x/1 ]

how do i get the value from y/1 ? I know this is perhpas very newbe 
but once every year I always run into this and can figure it out...

reduce y/1 gives me x/1 but I want 2.. Im missing somekind of  'eval 
y/1 ...
Henrik
20-Nov-2006
[6282]
do y/1
[unknown: 10]
20-Nov-2006
[6283]
no that gives me also x/1
Henrik
20-Nov-2006
[6284]
it works fine here?
[unknown: 10]
20-Nov-2006
[6285x3]
not here..
>> x: [ 1 2 3 ]
== [1 2 3]
>> y: [ x/1 ]
== [x/1]
>> do y/1
== x/1
>> x: [ 1 2 3 ]
== [1 2 3]
>> y: [ x/1 ]
== [x/1]
>> do y/1
== x/1
odd ...
Henrik
20-Nov-2006
[6288x2]
>> x: [2 4 6]
== [2 4 6]
>> y: [ x/1 ]
== [x/1]
>> y/1
== x/1
>> do y/1
== 2
try a fresh console, I've done it successfully on mac with view 1.3.2 
and winXP with view 2.7.0
[unknown: 10]
20-Nov-2006
[6290]
your kidding me... Could that be a problem ?
Henrik
20-Nov-2006
[6291]
well, if some variable has been changed.
Gabriele
20-Nov-2006
[6292]
do on paths was added in 1.3.1 or something i think.
Henrik
20-Nov-2006
[6293]
hmm... it could be that it evaluates as a path
[unknown: 10]
20-Nov-2006
[6294]
mmm nope no effect ->
>> x: [ 2 4 6 ]
== [2 4 6]
>> y: [ x/1 ]
== [x/1]
>> y/1
== x/1
>> do y/1
== x/1
>>
Henrik
20-Nov-2006
[6295]
rebolinth, system/version ?
[unknown: 10]
20-Nov-2006
[6296]
REBOL/Core 2.5.6.4.2
Gabriele
20-Nov-2006
[6297x2]
use 2.6 :)
otherwise you need to  do y   or  do reduce [y/1]