[REBOL] Re: Rebol & XML
From: brett:codeconscious at: 5-Aug-2003 23:50
Hi Andrew,
> I've discovered that Gavin's parse-xml is based on SAX or the event model
of
> processing XML. At the moment, my thoughts are going towards a DOM model,
> because Rebol is oriented that way, I feel, in reading and writing all of
a
> file at once. The DOM model builds a tree in memory. I want to access the
> ...
It has been a while since I looked at it, but I thought that the xml-object
that Gavin wrote did build a tree of objects. However I seem to recall that
the parser was not entirely complete.
> I'd like to processs the above and then access the author's name with
Rebol
> script like:
>
> XML/Workbook/DocumentProperties/Author
>
> And set it with Rebol script like:
>
> XML/Workbook/DocumentProperties/Author: "Andrew Martin"
It certainly looks neat, even if your underlying XML structure doesn't
support it, maybe a dialect can do the translation of your request. A
question to ponder though. How many instances of these would be literally in
your code, or would you need to build them up in other code?
> Also we should think about several tags at the same level of nesting, like
> in table:
>
> row
> cell
> cell
> cell
My XML is very limited. If we write a program to access a cell from the row
in this example are we implicitly encoding the structure of XML (DTD) into a
program?
> Unfortunately, there's a problem with accessing the attributes of a tag!
For
> example, what's the path! value for accessing the value of the "xmlns"
> attribute in the "DocumentProperties" tag?
>
> XML/Workbook/DocumentProperties/________
>
> Or perhaps I could use:
>
> XML/Workbook/DocumentProperties/_Attribute/xmlns
>
> Where "_Attribute" is the magic word for accessing attributes of a tag?
>
Perhaps the attributes of each element can be held seperately from the
element structures, and the same for namespaces.
The path notation then becomes a key to each of these three storage
structures. Therefore different aspects of a node could be:
Content XML/Workbook/DocumentProperties
Attributes XML/Workbook/DocumentProperties
Namespace XML/Workbook/DocumentProperties
etc. This is not well thought through - just throwing some ideas out.
By the way does namespaces represent contracts for behaviour, or are they
like rebol objects - a way to provide seperate contexts, or are they both?
> What do people think? Is there a better or more simpler way that I've
> overlooked?
I wish :^)
I think that if you consider the different ways you might want to process
the XML you will find different representations that can be useful. Also if
a DTD (are these obsolete yet?) is available - the extra information might
have an impact. E.g using a DTD maybe a program could be generated that
knows how to traverse the XML implicitly (because it was generated to do
so).
Not being much help am I? :^)
Regards,
Brett.