| Article: |
Exploring E4X with Ruby | |
| Subject: | Nice Idea | |
| Date: | 2004-10-15 12:22:16 | |
| From: | HotFusionMan | |
|
Response to: Nice Idea
|
||
I was so happy to see the easy-to-use syntax in this article that I turned the inline code into a library file and a Test::Unit test case. In the course of running the tests, I may have uncovered the bug reported here: the readxml method was not using the document's root to create the NodeWrapper, as the xml method was. Once I added ".root" to the end of the argument to NodeWrapper.new, I had no more test failures. |
||
Showing messages 1 through 3 of 3.
-
Nice Idea
2004-10-15 12:41:03 Jack Herrington |
[View]
-
Nice Idea
2004-10-15 21:36:12 HotFusionMan [View]
And many thanks to you for the code and article!
The dash-in-name remark reminds me of something -- I think the same issue arises in the cLabs Internet Explorer Controller (mentioned in one of the files in its distribution if I remember correctly, not directly on its Web pages).
At least for this case, if the Ruby interpreter required whitespace around the "-" method in calls, that might disambiguate this type of name from the minus operator/method. But I guess that would break the (admittedly rarely seen) syntaxfoo.-barorfoo.-(bar). -
Nice Idea
2004-10-15 21:50:43 Jack Herrington |
[View]
Thanks. My pleasure.
My guess is that outside of a string literal it would be difficult to get Ruby to look at any operator symbol as anything other than just the operator.
I haven't tried something like this though: foo."-bar"
I'd try it out but I need some sleep.
I actually talked with the guys that did the E4X work in Javascript. They did a LOT of work in the tokenizer and lexical analyzer to support the entire XML standard in Javascript.



Be advised. I was informed by another reader that because of the operand ordering in Ruby that not all XML structures are available with this code. For example, attributes in namespaces, or attributes which include special characters, like a dash, are not available. Though you can use the standard accessors to get to these.