It’s just data

xml:base support

The version of REXML included within ruby 1.8.2 does not appear to contain xml:base support.  However, this is not much of a problem in Ruby, as such support can easily be added.

This code checks for the method named defined by DOM3, and if not found, adds it directly to the REXML::Element class.  I also include four unit tests, ones that focus more on different combinations of xml:base usage than on the correct operation of URI.join.

While the tests passed, as I wrote both the code and the tests, this begs the question as to whether or not I have interpreted the spec correctly.  As libxml2 has a reputation for speed, completeness, and correctness, and has a Python interface, I simply ported the test The results don’t disappoint.

I made a similar attempt with JDK 5.0, but with less positive results.  Apparently in one of the tests, getBaseURI returns null.  If anybody has any insight into either the problem or in what I did incorrectly, I would appreciate it.


Interesting.  Actually, this will be quite helpful for the feed parser I’m writing since it uses REXML.

Posted by Bob Aman at

Sam Ruby: xml:base support

[link]...

Excerpt from del.icio.us/tag/ruby at

I think you’re missing a few test cases.  How does this interact with HTTP?  If no xml:base is specified on the root element, the base URI is the base URI of the document.  The base URI of the document could be the document URI, or it could be specified in a Content-Location HTTP header (or Content-Base, but let’s ignore that for now).  The Content-Location header can itself be a relative URI, in which case it is relative to the URI of the document.

References:

Posted by Mark at

Mark, unquestionably, this meager set of tests is just a starter set.  However, two of the four tests do rely on an XML base being externally provided as the href and all the xml:base elements are relative.  I even factored out the externally provided base as a parameter to the parse routine (with a default provided for the purposes of testing).

Actually interacting with HTTP will have to wait until I create a rails version.  From what I have read, rail’s support for testing goes far beyond what I have explored here.  Particularly, when you get to the chapter on testing controllers.

Posted by Sam Ruby at

Veckans Del.icio.us-länkar

Den här veckans intressanta länkar, från del.icio.us/staffanmalmgren Using the Rake Build Language [make programming rake ruby toread] –"Rake is a build language, similar in purpose to make and ant. Like make and ant...

Excerpt from Staffan Malmgrens blogg at

Publishing a Blog From a mod_atom Store

Seth Gordon:  That would certainly cover the front page, but that’s about it. Fortunately, there are bits and pieces that cover the rest.  I’ve contributed heavily to Planet, the Universal Feed Parser,... [more]

Trackback from Sam Ruby

at

Add your comment