RD2REXML - RDTool Visitor Library for REXML

Introduction

To create a REXML::Element instance from a RD formatted document, RD2REXML was developed as RD::Visitor of RDTool. In RD2REXML, it is concentrating RD format on translating into an XML format, with the structure of original of a document maintained.

Unlike some visitors included in the RDTool distribution, in RD2REXML, there is no high-level function like a solving reference. Instead, a conversion result is an instance of REXML::Element, so you can operate document structure using the function of REXML.

RD2REXML may be helpful when processing RD document as parts of XML/XHTML.

Requirements

download

<URL:http://www.fobj.com/rd2rexml/files/>

Installation

$ ruby install.rb                 # Install into the sitelibdir

If you want to install it into other place:

$ ruby install.rb -d {anywhere}

How To Use

as library

require 'rd2rexml/xml_visitor'
visitor = RD2REXML::XMLVisitor.new
source = File.open('data.rd').read
element = visitor.translate( source )
p elment       # => REXML::Element
p element.name # => "document"
element.to_s   # => "<document>...</document>"

require 'rd2rexml/html_visitor'
visitor = RD2REXML::HTMLVisitor.new
element = visitor.translate( source )
p element.name # => "div"
element.to_s   # => "<div>...</div>"

You can define derived class of XMLVisitor,HTMLVisitor or Visitor for your purpose.

use with rd2 as command line tool

$ rd2 -r rd2rexml-lib  DOC.rd > DOC.xml
$ rd2 -r rd2rehtml-lib DOC.rd > DOC.html

License

RD2REXML is copyright (c) 2003 FUJIMOTO Hisakuni. It is free software, and is distributed under the Ruby license. See the COPYING file in the standard Ruby distribution for details.

Warranty

This software is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantibility and fitness for a particular purpose.

Author

FUJIMOTO Hisakuni, <hisa at fobj.com>