[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

Austin Ziegler

10/3/2003 12:59:00 PM

On Fri, 3 Oct 2003 16:11:46 +0900, paul vudmaska wrote:
> As for the conflict with characters in ruby names, unfortunately I
> can suggest no obvious solution - maybe use xpath where the easy
> way is not acceptable. Also someone mentions 'just getting to the
> element he wants' without using a long path. Again, xpath, would
> be the direct/best approach perhaps.

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]? The e4x stuff as you've presented it here is also very
DOM-oriented, which is fine for smaller XML documents, but assuredly
not fine for many other documents -- unless you plan on doing lazy
loading.

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]? If the <list> tag also allowed for CDATA values,
there's nothing in the XML spec that would prevent:

<list>cdata<item>1</item>cdata<item>2</item>cdata</list>

What you've suggested offers no easy way around this. You're far
better off not treating XML as pseudo-objects. It's a poor fit,
ultimately, and the moment you get anything reasonably complex (like
RSS) or having namespace support, or you need a larger document that
won't fit into memory entirely as DOM requires, it breaks and you
need the more complex API again.

-austin
[1] I have not looked at the e4x stufff, and I don't intend to; I
have too much else on my plate right now. I'm asking practical
problems regarding the suggestion made here.
--
austin ziegler * austin@halostatue.ca * Toronto, ON, Canada
software designer * pragmatic programmer * 2003.10.03
* 08.50.00


1 Answer

Eric Hodel

10/3/2003 3:17:00 PM

0

Austin Ziegler (austin@halostatue.ca) wrote:

> 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]? If the <list> tag also allowed for CDATA values,
> there's nothing in the XML spec that would prevent:
>
> <list>cdata<item>1</item>cdata<item>2</item>cdata</list>

Ruby <--> XML seems to be a poor fit, it seems XML will quickly
become too verbose with all the exceptions and having to resort to
XPath (I've seen several posts that say "oh, we'll have to use XPath for
that", and that wouldn't make me very happy). Ruby <--> RDF would
be a better fit, especially if used as a serialization format.

--
Eric Hodel - drbrain@segment7.net - http://se...
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04