[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: xml + ruby

Zach Dennis

10/3/2003 2:51:00 PM



From: Austin Ziegler Wrote:

>I think it's more than that. There's a deep division in the XML camp
>itself as to whether things should be expressed as attributes or
>child elements:
>
> <foo bar="baz" />
> <foo><bar>baz</bar></foo>
>
>The moment you have to deal with an attribute, the x.y notation
>becomes nearly useless. How do you deal with attributes in that
>form[1]?

You deal with by accessing foo.attributes["bar"], which will equal baz.
You shouldn't access childNodes by saying "foo.bar" This can lead to
ambiguity in many cases. Instead each XML object should support something
like:

If you want to write <foo><bar>baz</bar></foo> then write something like:

foo.childNodes[0] = bar xml object
foo.childNodes[0].nodeValue = "baz"


>There's further confusion if you had:
>
> <list><item>1</item><item>2</item><item>3</item></list>
>
>How would I refer to each individual item: list.item[0] through
>list.item[2]?

The structure for the XML object should look something like:

list.childNodes[0].nodeValue = "1"
list.childNodes[1].nodeValue = "2"
list.childNodes[2].nodeValue = "3"


For Ruby to have a well structured and defined( and accessible )
XML object is not that far out there. I have a feeling that
this XML object may improve from a little bit of XP
style thinking. We( or whomever ends up writing it ) should start
with a basic XML object that can be expanded upon to add
stylesheets, CDATA tags, etc..etc..People only need to use
the equivalent of what they have now and a little bit more. And
since the XML we have know lacks alot it and alot the ease it shouldn't
be this hard to come out with a new or revised XML Object.

-Zach


2 Answers

James Britt

10/3/2003 5:45:00 PM

0

Zach Dennis wrote:
>
>
> For Ruby to have a well structured and defined( and accessible )
> XML object is not that far out there.

True enough; in fact, you need only do this:

require 'rexml/document'


James




James Britt

10/3/2003 5:59:00 PM

0

James Britt wrote:

> Zach Dennis wrote:
>
>>
>>
>> For Ruby to have a well structured and defined( and accessible )
>> XML object is not that far out there.
>
>
> True enough; in fact, you need only do this:
>
> require 'rexml/document'
>


If REXML doesn't float your boat, this article may offer food for
thought (though I'm thinking this whole thread might be better off on
the rexml mailing list ...)

http://www.sys-con.com/xml/article....


James