conditional.rb

Group A

This group has only one data: "only_one".

Group B

Here's the list of this group's data.

Group C

This group has no data.
hello.rb

hello world

Amrita is a html template libraly for Ruby

list.rb table.rb
name author
Ruby matz
perl Larry Wall
python Guido van Rossum
filelist.rb drwxr-xr-x Sat Dec 28 15:51:57 JST 2002 Sat Dec 28 15:51:57 JST 2002 Mon Jan 06 16:48:20 JST 2003 3091461 2397 -rw-rw-r-- Mon Jan 06 13:26:55 JST 2003 Mon Jan 06 13:26:55 JST 2003 Mon Jan 06 13:28:18 JST 2003 82715 474 -rw-r--r-- Tue Aug 06 10:36:18 JST 2002 Tue Aug 06 10:36:18 JST 2002 Mon Jan 06 13:28:18 JST 2003 82694 628 -rw-r--r-- Sat Aug 24 16:31:40 JST 2002 Sat Aug 24 16:31:40 JST 2002 Mon Jan 06 13:28:18 JST 2003 82695 626 -rw-r--r-- Thu Aug 22 15:29:36 JST 2002 Thu Aug 22 15:29:36 JST 2002 Mon Jan 06 13:28:18 JST 2003 82696 389 -rw-r--r-- Wed Aug 21 16:11:56 JST 2002 Wed Aug 21 16:11:56 JST 2002 Mon Jan 06 13:28:18 JST 2003 82697 1178 -rw-r--r-- Thu Sep 05 16:03:49 JST 2002 Thu Sep 05 16:03:49 JST 2002 Mon Jan 06 16:48:47 JST 2003 82698 1241 -rw-r--r-- Thu Sep 05 22:12:16 JST 2002 Thu Sep 05 22:12:16 JST 2002 Mon Jan 06 13:28:18 JST 2003 82699 801 -rw-r--r-- Mon Oct 21 11:35:29 JST 2002 Mon Oct 21 11:35:29 JST 2002 Mon Jan 06 13:28:18 JST 2003 82700 856 -rw-r--r-- Wed Sep 18 10:19:07 JST 2002 Wed Sep 18 10:19:07 JST 2002 Mon Jan 06 13:28:18 JST 2003 82701 964 -rw-r--r-- Thu Sep 05 16:03:49 JST 2002 Thu Sep 05 16:03:49 JST 2002 Mon Jan 06 13:28:18 JST 2003 82702 1029 -rw-r--r-- Thu Sep 05 16:03:49 JST 2002 Thu Sep 05 16:03:49 JST 2002 Mon Jan 06 13:28:18 JST 2003 82703 1352 -rw-r--r-- Thu Oct 24 16:48:43 JST 2002 Thu Oct 24 16:48:43 JST 2002 Mon Jan 06 13:28:18 JST 2003 82704 1417 -rw-r--r-- Thu Oct 24 16:48:43 JST 2002 Thu Oct 24 16:48:43 JST 2002 Mon Jan 06 13:28:18 JST 2003 82705 2596 -rw-r--r-- Fri Aug 02 16:27:34 JST 2002 Fri Aug 02 16:27:34 JST 2002 Mon Jan 06 13:28:18 JST 2003 82706 820 -rw-r--r-- Thu Jul 18 11:28:46 JST 2002 Thu Jul 18 11:28:46 JST 2002 Mon Jan 06 13:28:18 JST 2003 82707 38922 -rw-r--r-- Thu Jul 25 16:34:07 JST 2002 Thu Jul 25 16:34:07 JST 2002 Mon Jan 06 13:28:18 JST 2003 82708 995 -rw-r--r-- Thu Aug 01 15:59:36 JST 2002 Thu Aug 01 15:59:36 JST 2002 Mon Jan 06 13:28:18 JST 2003 82709 295 -rw-r--r-- Wed Jul 17 16:19:53 JST 2002 Wed Jul 17 16:19:53 JST 2002 Mon Jan 06 13:28:18 JST 2003 82710 637 -rw-r--r-- Wed Jul 24 17:06:46 JST 2002 Wed Jul 24 17:06:46 JST 2002 Mon Jan 06 13:28:18 JST 2003 82711 1354 -rw-r--r-- Wed Sep 18 14:53:51 JST 2002 Wed Sep 18 14:53:51 JST 2002 Mon Jan 06 13:28:18 JST 2003 82712 1277 -rw-r--r-- Thu Jul 25 10:11:37 JST 2002 Thu Jul 25 10:11:37 JST 2002 Mon Jan 06 13:28:18 JST 2003 82713 3617 -rw-r--r-- Fri Aug 02 16:27:34 JST 2002 Fri Aug 02 16:27:34 JST 2002 Mon Jan 06 13:28:18 JST 2003 82714 filelist2.rb nil makeurl.rb
name author webpage
Ruby matz Ruby Home Page
perl Larry Wall Perl.com
python Guido van Rossum Python Language Website
makeurl2.rb
nameauthorwebpage
Ruby matz Ruby Home Page
perl Larry Wall Perl.com
python Guido van Rossum Python Language Website
merge_template.rb Insertion MockUp This comes from a template fragment: Hello World! merge_template2.rb Insertion MockUp This comes from a template fragment: Hello World parts1.rb

Scripting Languages

Ruby matz http://www.ruby-lang.org/
perl Larry Wall http://www.perl.com/
python Guido van Rossum http://www.python.org/
parts2.rb
name author url
perl Larry Wall http://www.perl.com/(no need to visit)
Ruby matz http://www.ruby-lang.org/
python Guido van Rossum http://www.python.org/(no need to visit)
....It's only a joke! Don't be angry.
precompile.rb
nameauthorwebpage
Ruby matz Ruby Home Page
perl Larry Wall Perl.com
python Guido van Rossum Python Language Website
nameauthorwebpage
Ruby matz Ruby Home Page
perl Larry Wall Perl.com
python Guido van Rossum Python Language Website
----code generated by Amrita(debug mode)----- include Amrita extend Amrita::HtmlCompiler::RuntimeRoutines def self::expand(_formatter, _data, _context) __d2 = _data # Amrita::HtmlCompiler::HashData # with_dictionary __d2 # put_static_element # Amrita::HtmlCompiler::HashData __d2 _formatter << "\n " # put_static_element # Amrita::HtmlCompiler::HashData __d2 _formatter << "" # put_static_element # Amrita::HtmlCompiler::HashData __d2 _formatter << "" # put_static_element # Amrita::HtmlCompiler::HashData __d2 _formatter << "" # put_static_element # Amrita::HtmlCompiler::HashData __d2 _formatter << "\n " __d3 = __d2[:table1] # Amrita::HtmlCompiler::HashData _context.do_copy do __d5 = __d3 # Amrita::HtmlCompiler::ArrayData __d5.each do |__d7| # with_dictionary __d7 # put_static_element # Amrita::HtmlCompiler::HashData __d7 if _context.do_delete_id _formatter << "" else _formatter << "" end _formatter << "\n " __d8 = __d7[:name] # Amrita::HtmlCompiler::HashData if __d8 # put_static_element # Amrita::HtmlCompiler::ScalarData __d7 if _context.do_delete_id _formatter << "" end _formatter << "\n " __d9 = __d7[:author] # Amrita::HtmlCompiler::HashData if __d9 # put_static_element # Amrita::HtmlCompiler::ScalarData __d7 if _context.do_delete_id _formatter << "" end _formatter << "\n " # put_static_element # Amrita::HtmlCompiler::HashData __d7 _formatter << "\n " end end _formatter << "\n
nameauthorwebpage
" else _formatter << "" end _formatter.format_text(__d8.to_s) _formatter << "" else _formatter << "" end _formatter.format_text(__d9.to_s) _formatter << "" __d10 = __d7[:webpage] # Amrita::HtmlCompiler::HashData __d11 = e(:a,a(:id, "webpage")) .clone if _context.delete_id __d11.delete_attr!(:id) end __d11.hide_hid! __d10.each { |a| __d11[a.key_symbol] = a.value } # put_dynamic_element e = __d11 if _context.do_delete_id e = e.clone e.delete_attr!(:id) end if e.no_child? and _formatter.can_be_single?(e) _formatter << _formatter.format_single_tag(e) else _formatter.format_element(e) do __d12 = __d10.body # Amrita::HtmlCompiler::AttrData _formatter.format_text(__d10.body.to_s) end end _formatter << "
\n" end ----code generated by Amrita end ------------ ----start benchmark ------- 3.366772 seconds for 100 times without compiling 2.186922 seconds for 100 times with pre_format 0.931382 seconds for 100 times with pre-compiled code 0.538006 seconds for 100 times with pre-compiled code(optimized using sample data) proc.rb sanitizer.rb

I want to insert new line.<br>But I can't

I can insert new line
with escape { ... }
But it may be dangerous

But amrita sanitize it!

href is treated in a special way time.rb 2003/1/6 xhtml.rb xhtml sample

SAMPLE1

members of this HASH will be inserted here and title


xml1.rb ------------HTML output ----------------------
name author ISBN
Ruby In A Nutshell Yukihiro Matsumoto, David L. Reynolds 0596002149
Programming Ruby David Thomas, Andrew Hunt 0201710897
The Ruby Way Hal Fulton 0672320835
------------XML output ---------------------- Ruby In A Nutshell Yukihiro Matsumoto, David L. Reynolds 0596002149 Programming Ruby David Thomas, Andrew Hunt 0201710897 The Ruby Way Hal Fulton 0672320835 ------------XML output(pretty-printed) ---------------------- Ruby In A Nutshell Yukihiro Matsumoto, David L. Reynolds 0596002149 Programming Ruby David Thomas, Andrew Hunt 0201710897 The Ruby Way Hal Fulton 0672320835 xml2.rb
title author ISBN
Ruby In A Nutshell Yukihiro Matsumoto
David L. Reynolds
0596002149
Programming Ruby David Thomas
Andrew Hunt
0201710897
The Ruby Way Hal Fulton
0672320835
xml3.rb REXML

REXML

1. overview

1. 1 purpose

REXML is an XML processor for the language Ruby. REXML is conformant (passes 100% of the Oasis non-validating tests), and includes full XPath support. It is reasonably fast, and is implemented in pure Ruby. Best of all, it has a clean, intuitive API.

This software is distribute under the Ruby license.

1. 2 general

Why REXML? There, at the time of this writing, already two XML parsers for Ruby. The first is a Ruby binding to a native XML parser. This is a fast parser, using proven technology. However, it isn't very portable. The second is a native Ruby implementation, and as useful as it is, it has (IMO) a difficult API.

I have this problem: I dislike obfuscated APIs. There are several XML parser APIs for Java. Most of them follow DOM or SAX, and are very similar in philosophy with an increasing number of Java APIs. Namely, they look like they were designed by theorists who never had to use their own APIs. The extant XML APIs, in general, suck. They take a markup language which was specifically designed to be very simple, elegant, and powerful, and wrap an obnoxious, bloated, and large API around it. I was always having to refer to the API documentation to do even the most basic XML tree manipulations; nothing was intuitive, and almost every operation was complex.

Then along came Electric XML.

Ah, bliss. Look at the Electric XML API. First, the library is small; less than 500K. Next, the API is intuitive. You want to parse a document? doc = new Document( some_file ). Create and add a new element? element = parent.addElement( tag_name ). Write out a subtree?? element.write( writer ). Now how about DOM? To parse some file:

parser = new DOMParser(); parser.parse( new InputSource( new FileInputStream( some_file ) ) )
Create a new element? First you have to know the owning document of the to-be-created node (can anyone say "global variables, or obtuse, multi-argument methods"?) and call
element = doc.createElement( tag_name ) parent.appendChild( element )
"appendChild"? Where did they get that from? How many different methods do we have in Java in how many different classes for adding children to parents? addElement()? add()? put()? appendChild()? Heaven forbid that you want to create an Element elsewhere in the code without having access to the owning document. I'm not even going to go into what travesty of code you have to go through to write out an XML sub-tree in DOM.

So, I use Electric XML extensively. It is small, fast, and intuitive. IE, the API doesn't add a bunch of work to the task of writing software. When I started to write more software in Ruby, I needed an XML parser. I wasn't keen on the native library binding, "XMLParser", because I try to avoid complex library dependancies in my software, when I can. For a long time, I used NQXML, because it was the only other parser out there. However, the NQXML API can be even more painful than the Java DOM API. Almost all element operations requires accessing some indirect node access... you had to do something like element.node.attr['key'], and it is never obvious to me when you access the element directly, or the node.. or, really, why they're two different objects, anyway. This is even more unfortunate since Ruby is so elegent and intuitive, and bad APIs really stand out. I'm not, by the way, trying to insult NQXML; I just don't like the API.

I wrote the people at TheMind (Electric XML... get it?) and asked them if I could do a translation to Ruby. They said yes. After a few weeks of hacking on it for a couple of hours each week, and after having gone down a few blind alleys in the translation, I had a working beta. IE, it parsed, but hadn't gone through a lot of strenuous testing. Along the way, I had made a few changes to the API, and a lot of changes to the code. First off, Ruby does iterators differently than Java. Java uses a lot of helper classes. Helper classes are exactly the kinds of things that theorists come up with... they look good on paper, but using them is like chewing glass. You find that you spend 50% of your time writing helper classes just to support the other 50% of the code that actually does the job you were trying to solve in the first place. In this case, the Java helper classes are either Enumerations or Iterators. Ruby, on the other hand, uses blocks, which is much more elegant. Rather than:

for (Enumeration e=parent.getChildren(); e.hasMoreElements(); ) {
   Element child = (Element)e.nextElement();
   // Do something with child
}

you get:

parent.each_child{ |child| # Do something with child }

Can't you feel the peace and contentment in this block of code? Ruby is the language Buddha would have programmed in.

Anyhoo, I chose to use blocks in REXML directly, since this is more common to Ruby code than for x in y ... end, which is as orthoganal to the original Java as possible.

Also, I changed the naming conventions to more Ruby-esque method names. For example, the Java method getAttributeValue() becomes in Ruby get_attribute_value(). This is a toss-up. I actually like the Java naming convention moreThis is no longer true. I'm a convert to the Ruby naming scheme, for Ruby. The reason being that Ruby does a superb job of hiding the difference between attributes and methods; in fact, for all intents and purposes, you can't access attributes directly; all attribute accessors are methods. What this means in the long run is that there is no reason to have different naming conventions for attributes and methods., but the latter is more common in Ruby code, and I'm trying to make things easy for Ruby programmers, not Java programmers.

The biggest change was in the code. The Java version of Electric XML did a lot of efficient String-array parsing, character by character. Ruby, however, has ubiquitous, efficient, and powerful regular expression support. All regex functions are done in native code, so it is very fast, and the power of Ruby regex rivals that of Perl. Therefore, a direct conversion of the Java code to Ruby would have been more difficult, and much slower, than using Ruby regexps. I therefore used regexs. In doing so, I cut the number of lines of sourcecode by half.

Finally, by this point the API looks almost nothing like the original Electric XML API, and practically none of the code is even vaguely similar. However, even though the actual code is completely different, I did borrow the same process of processing XML as Electric, and am deeply indebted to the Electric XML code for inspiration.

One last thing. If you use and like this software, and you feel compelled to make some contribution to the author by way of saying "thanks", and you happen to know what a tea cozy is and where to get them, then you can send me one. Send those puppies to:

Sean Russell 60252 Rimfire Rd. Bend, OR 97702 USA
If you're outside of the US, make sure you write "gift" on it to avoid the taxes. If you don't want to send a tea cozy, you can also send money. Or don't send anything. Offer me a job I can't refuse, in Western Europe somewhere.

1. 3 features

  • Four intuitive parsing APIs.
  • Intuitive, powerful, and reasonably fast tree parsing API (a-la DOMBe aware, however, that REXML does not have a DOM API.
  • Fast stream parsing API (a-la SAX)This is not a SAX API.
  • SAX2-based APIIn addition to the native REXML streaming API. This is slower than the native REXML API, but does a lot more work for you.
  • Pull parsing API.
  • Small
  • Reasonably fast
  • Native Ruby
  • Full XPath supportCurrently only available for the tree API
  • XML 1.0 conformantREXML passes all of the non-validating OASIS tests. There are probably places where REXML isn't conformant, but I try to fix them as they're reported.
  • ISO-8859-1, UNILE, UTF-16 and UTF-8 input and output
  • Documentation
  • 2. operation

    2. 1 Installation

    Run ruby bin/install.rb. By the way, you really should look at these sorts of files before you run them as root. They could contain anything, and since (in Ruby, at least) they tend to be mercifully short, it doesn't hurt to glance over them. If you want to uninstall REXML, run ruby bin/install.rb -u.

    2. 2 Unit tests

    If you have Test::Unit installed, you can run the unit test cases. You can run both installed and not installed tests; to run the tests before installing REXML, run ruby -I. bin/suite.rb. To run them with an installed REXML, use ruby bin/suite.rb.

    2. 3 Benchmarks

    There is a benchmark suite in benchmarks/. To run the benchmarks, change into that directory and run ruby comparison.rb. If you have nothing else installed, only the benchmarks for REXML will be run. However, if you have any of the following installed, benchmarks for those tools will also be run:

    The results will be written to index.html.

    2. 4 General Usage

    Please see the Tutorial.

    The API documentation is available on-line, or it can be downloaded as an archive in tbz2 format (~40Kb), in tgz format (~70Kb), or (if you're a masochist) in zip format (~280Kb). The best solution is to download and install Dave Thomas' most excellent rdoc and generate the API docs yourself; then you'll be sure to have the latest API docs and won't have to keep downloading the doc archive.

    The unit tests in test/ and the benchmarking code in benchmark/ provide additional examples of using REXML. The Tutorial provides examples with commentary. The documentation unpacks into .

    Kouhei Sutou maintains a Japanese version of the REXML 2.2.2 API docs. The Japanese API documentation is also available for download as a gzipped tarball, a bzipped tarball (smallest), or a zip file (largest).

    3. status

    3. 1 Speed and Completeness

    Unfortunately, NQXML is the only package REXML can be compared against; XMLParser uses expat, which is a native library, and really is a different beast altogether. So in comparing NQXML and REXML you can look at four things: speed, size, completeness, and API.

    Benchmarks

    REXML is faster than NQXML in some things, and slower than NQXML in a couple of things. You can see this for yourself by running the supplied benchmarks. Most of the places where REXML are slower are because of the convenience methodsFor example, element.elements[index] isn't really an array operation; index can be an Integer or an XPath, and this feature is relatively time expensive.. On the positive side, most of the convenience methods can be bypassed if you know what you are doing. Check the benchmark comparison page for a general comparison. You can look at the benchmark code yourself to decide how much salt to take with them.

    The sizes of the XML parsers are closeAs measured with ruby -nle 'print unless /^\s*(#.*|)$/' *.rb | wc -l . NQXML 1.1.3 has 1580 non-blank, non-comment lines of code; REXML 2.0 has 2340REXML started out with about 1200, but that number has been steadily increasing as features are added. XPath accounts for 541 lines of that code, so the core REXML has about 1800 LOC..

    REXML is a conformant XML 1.0 parser. It supports multiple language encodings, and internal processing uses the required UTF-8 and UTF-16 encodings. It passes 100% of the Oasis non-validating tests. Furthermore, it provides a full implementation of XPath, a SAX2 and a PullParser API.

    The last thing is the API, and this is where I think REXML wins. The core API is clean and intuitive, and things work the way you would expect them to. Convenience methods abound, and you can code for either convenience or speed. REXML code is terse, and readable, like Ruby code should be. The best way to decide which you like more is to write a couple of small applications in each, then use the one you're more comfortable with.

    3. 2 XPath

    As of release 2.0, XPath 1.0 is fully implemented.

    I fully expect bugs to crop up from time to time, so if you see any bogus XPath results, please let me know. That said, since I'm now following the XPath grammar and spec fairly closely, I suspect that you won't be surprised by REXML's XPath very often, and it should become rock solid fairly quickly.

    Check the "bugs" section for known problems; there are little bits of XPath here and there that are not yet implemented, but I'll get to them soon.

    Namespace support is rather odd, but it isn't my fault. I can only do so much and still conform to the specs. In particular, XPath attempts to help as much as possible. Therefore, in the trivial cases, you can pass namespace prefixes to Element.elements[...] and so on -- in these cases, XPath will use the namespace environment of the base element you're starting your XPath search from. However, if you want to do something more complex, like pass in your own namespace environment, you have to use the XPath first(), each(), and match() methods. Also, default namespaces force you to use the XPath methods, rather than the convenience methods, because there is no way for XPath to know what the mappings for the default namespaces should be. This is exactly why I loath namespaces -- a pox on the person(s) who thought them up!

    3. 3 Namespaces

    Namespace support is now fairly stable. One thing to be aware of is that REXML is not (yet) a validating parser. This means that some invalid namespace declarations are not caught.

    3. 4 Mailing list

    There is a low-volume mailing list dedicated to REXML. To subscribe, send an empty email to ser-rexml-subscribe@germane-software.com. This list is more or less spam proof. To unsubscribe, similarly send a message to ser-rexml-unsubscribe@germane-software.com.

    3. 5 RSS

    An RSS file for REXML is now being generated from the change log. This allows you to be alerted of upgrades via 'pull' as they become available, if you have an RSS browser. This is an abuse of the RSS mechanism, which was intended to be a distribution system for headlines linked back to full articles, but it works. The headline for REXML is the version number, and the description is the change log. The links all link back to the REXML home page. The URL for the RSS itself is http://www.germane-software.com/software/rexml/rss.xml

    For those who are interested, there's a SLOCCount (by David A. Wheeler) file with stats on the REXML sourcecode. Note that the SLOCCount output includes the files in the test/, benchmarks/, and bin/ directories, as well as the main sourcecode for REXML itself.

    3. 6 Applications that use REXML

    3. 7 changelog

    • Internal entities weren't being (recursively) expanded.
    • PullParser text() method now returns two arguments; normalized text, and unnormalized text. That means that users have access to the raw text, without entity replacement, and processed text, with entities replaced. Existing applications using PullParser don't need to be changed; the behavior is backwards compatible. I can't do it for SAX2 yet, because I don't know whether text should be passed to SAX2 listeners normalized or not.
    • Hannes Wyss noticed a bug involving whitespace before the root document element.
  • This is also the 2.4.0 FRC release.
    • REXML is now in the RPKG database, and is a Gentoo package as well.
    • The root node of an XML document is the document, not the document element. Make sense? Well, it's true. '/' of "<a/>" in XPath gives you the parent of 'a', which is a Document object, not 'a'. REXML's XPath has been correct in this for a while. However, REXML always gave that Document node a name: "UNDEFINED". This was not correct. Document::name and Document::expanded_name now return an empty string, which is more in line with the XPath spec.
    • Mike fixed up Functions::tr to handle Unicode better.
    • Fixed a bug in Functions::number.
    • Added some more good diffs from Mike, cleaning up some Ruby 1.7 warnings. Mike also pointed me to a regexp optimization and sent me the most awesome tea cozy -- pictures will be posted.
    • Changed the behaviour of XPath. Please notice this, because it is important. By popular demand, the XPath axe attribute:: (and the shortcut @) now return an Attribute node, not the attribute value. This means that you have to specifically fetch the attribute value if that is what you want. Additionally, to do this without incurring a massive speed penalty, I had to change the behavior of Attribute::to_s(). It now returns just the attribute value, not the key='value' attribute string. If you want that formatted string, you have to use Attribute::to_string(), which is a new method.
    • The distribution mechanism that I use to make releasing versions of REXML easy has been completely revamped, and now seems to have most of the bugs worked out. One of the hard drives on the server died, and we took the opportunity to install a new version of Linux; the sourcecode repository seems to have settled down, and jitterbug is back to working. Sorry for any inconveniences during the changeover.
    • Kouhei found a bug in XPath WRT processing instructions. I've fixed it.
    • Kouhei also found a bug in XPath numeric comparisons. Fixed.
    • attribute::* and @* now works
    • If node()[@x] matched a non-Element node, XPath would throw an exception.
    • Upgraded the install.rb file; fixed a couple of bugs, added redirection and a --noop mode. This was for Portage support.
    • Fixed a bug that caused text containing > to be split into two text nodes. This incurred a speed penalty, but I'll try to improve that later.
    • Added a bug tracking system.
    • Fixed a comment parsing bug.
    • Mike Stok fixed Functions#translate and cleaned up some cruft that slipped through in Functions#substring.
    • Fixed a bug in Element#prefixes, and fixed Attributes#prefixes to use DOCTYPE declared namespaces. Added DocType#attributes_of(Element).
    • Fixed a bug in writing Attlist declarations.
    • Added AttlistDecl#each; AttlistDecl now includes Enumerable
    • Fixed Functions#name and Functions#local_name; fixed unit test.
    • Fixed a bug re. functions w/in predicates in XPath
    • Fixes for Child#parent=()
    • Fixes and speed improvement for creating Text nodes
    • SAX2Parser bug fixes
    • Added dist.xml and an ant build file
    • Tom sent a new version of his pretty printer
    • Kouhei has a new version of his Japanese API documentation translation online
  • Fixed a bug in XPath that kept non-Element nodes from being returned from recursive paths. This had a side effect of speeding up XPath recursions. Fixed a bug in Document WRT text outside of the document. Added peek and unshift methods to the PullParser API. XPath methods now accept an array of nodes in addition to a single node. Fixed a bug in Functions::string(). Changed the unit tests to the Test::Unit platform. This allows the unit tests to be run under a GUI. More Function fixes (substring) by Mike Stok. There was a major bug in XPath handling of math operations, which is fixed. Strings pulled from IO streams are now tainted. Lots of bug fixes in PullParser -- it now passes 100% of the Oasis tests. Bug fix for stream parsing in Entity. Bug fixes in DocType -- SAX2Parser now passes 100% of Oasis tests. REXML now processes internal ATTLIST declarations in the doctype. This includes processing of XML namespaces in the doctype. Changed pretty printing. Whitespace is now never added around Text nodes, and there's a new context property, :ignore_whitespace_nodes. There's also a new transitive pretty printer, obtained by passing 'true' as the third argument to write().
  • Added an alternate pretty printer by Thomas Sawyer; it is in the contrib/ directory. Speed optimizations; REXML is noticably faster now. In particular, PullParser is now just as fast as Stream parsing (10x speed increase over first version). Fixed a bug in Element.add_namespace. Fixed a problem that occurred on some systems with Entities. News: Kouhei Sutou has done a Japanese translation of the REXML API docs. See the section in the main REXML page about the API documentation for links. Mike Stock fixed a bug in the starts_with XPath function. Added, on request, methods to Element to filter children on type. cdatas(), instructions(), comments(), and texts() now return immutable arrays of only those child nodes.
  • Added a (more or less) SAX2 conforming parser. Really, this and the pull parser are just a thin layer over the legacy REXML stream parser, and you'll get better results with the original API. The best thing about this (and the primary reason I did it this way) is that REXML maintains backward compatibility with the old Stream API. After I play with pure pull parsing some more, I may decide to reimplement stream parsing on top of pull parsing, but it shouldn't affect SAX2 in any way. The SAX2 parser is slower primarily because SAX2 requires the parser to do a lot more work -- resolving namespaces and so on -- so while I know I can improve the speed some, SAX2 will never be as fast as REXML vanilla stream parsing. That said, the SAX2 API is pretty nice, and includes all of those stream API changes I wanted to get in, except for filter parsing. Check out the tutorial for usage information.
  • Added a pull parser. This is VERY experimental, and the API is likely to change.
  • Internal entities are now handledPlease note that entity handling complicates text manipulation. See the note in the tutorial. Speed has been further improved for most operations, but especially for stream parsing, writing, and large document parsing.
  • Fixed a bug in benchmark/bench.rb that kept it from running. Added stand_alone?() to XMLDecl as an alias for the standalone accessor. Improvements to the streaming API; in particular, pulling data from non-closing streams doesn't require passing a block size of 1 to the IOSource class any longer; in fact, the block size is ignored. Added a user-supplied patch to fix the fact that not all of the DTD events were getting passed to the listener. Improved entity parsing. Better test suite; you can now pass --help to the main test suite to get a list of the new options, which include listing the available suites and listing methods in the suites, as well as instructions on how to run only certain suites or methods in suites.
  • Fixed broken links in documentation. Added new documentation layout; the old format -- everything on one page -- was getting a bit overwhelming. Added RSS for changelog. Bugfix for element cloning namespace loss. The Streaming API wasn't normalizing input strings; this has been fixed. Added support for deep cloning via Parent.deep_clone(). Fixed some streaming issues for SOAP4RUBY. In particular, text normalization is now also done for the Streaming API. '\r' handling is now correct, as per the XML spec, and entities are handled better. &#13; is now converted to '\r' internally, and then translated back to '\r' on output. All other numeric entities (&#nnn; and &#xnnn;) are now converted to unicode on input, but are only converted back to entities if they don't fit in the requested encoding.
  • Fixed a bug with reading ISO-8859-1 encoded documents, and Document now includes Output, which it always should have.
  • Forgot to add output.rb to the repository.
  • IO optimizations, and support for ISO-8859-1 output. Fixed up pretty-printing a little. Now, if pretty-printing is turned on, text nodes are stripped before printing. This, obviously, can mess up what you'd expect from :respect_whitespace, but pretty printing, by definition, must change your formatting. Updated the tutorial a bit. Please see the section on adding text for a warning, if you're using a non-UTF-8 compatable encoding. Changed behavior of Element.attributes.each. It now itterates over key, value pairs, rather than attributes. This was a feature request. Expanded the unit tests and subsequently fixed a number of obscure bugs. I'm distributing the API documentation seperately from the main distribution now, because the API docs constitute nearly 50% of the total distribution size. FIxed a bug in namespace handling in attributes. Completely updated the API documentation for Element, Element.Elements, and Element.Attributes; the rest of the classes to follow. I'm seriously contemplating removing the examples from the API documentation, because most of them are practically duplicates of the unit tests in test/.
  • 2.0 munged the encoding value in output. This is fixed. I left debugging turned on in XPath in 2.0.2 :-/
  • Added grouping '(...)' and preceding:: and following:: axis. This means that, aside from functional bugs, XPath should have no missing functionality bugs. Keep in mind that not all Functions are tested, though.
  • Added some unit tests, and fixed a namespace XPath bug WRT attribute default NS's. Unicode support was screwing up the upper end of ASCII support; chars between 0xF0 and 0xFD were getting munged. This has been fixed, at the cost of a small amount of speed. Optimized the descendant axes of XPath; it should be significantly faster for '//' and other descendant operations. Added several user contributed unit tests. Re-added QuickPath, the old, non-fully-XPath compliant, yet much faster, XPath processor. Everything is being converted to UTF8 now, and the XML declaration reflects this. See the bugs for more information.
  • True XPath support. Finally. XPath is fully implemented now, and passes all of the tests I can throw at it, including complex XPaths such as '*[* and not(*/node()) and not(*[not(@style)]) and not(*/@style != */@style)]'. It may be slower than it was, but it should be reasonably efficient for what it is doing. The XPath spec doesn't help, and thwarts most attempts at optimization. Please see the notes on XPath for more information. Oh, and some minor bugs were fixed in the XML parser.
  • Fixed a bug pointed out by Peter Verhage where the element names weren't being properly parsed if a namespace was involved.
  • Fixing problems with the 1.2.6 distribution :-/. Added an "applications using REXML" section in this document -- send me those links! Added rdoc documentation. I'm not using API2XML anymore. I think API2XML was the right model, generating XML rather than HTML (which is what rdoc does), but rdoc does a much better job at parsing Ruby source, and I really didn't want to go there in the first place. Also, I had forgotten to generate the Tutorial HTML.
  • Documentation fix (TR). Fixed a bug in Element.add (and, therefore, Element.add_element). Added Robert Feldt's terse xml constructor to contrib/ (check it out; it's handy). Tobias discovered a terrible bug, whereby ENTITY wasn't printing out a final '>'. After a long discussion with a couple of users, and some review of the XML spec, I decided to reverse the default handling of whitespace and pretty printing. REXML now no longer defaults to pretty printing, and preserves whitespace unless otherwise directed. Added provisional namespace support to XPath. XPath is going to require another rewrite.
  • Bug fixes: doctypes that had spaces between the closing ] and > generated errors. There was a small bug that caused too many newlines to be generated in some output. Eelis van der Weegen (what a great name!) pointed out one of the numerous API errors. Julian requested that add_attributes take both Hash (original) and array of arrays (as produced by StreamListener). I killed the mailing list, accidentally, and fixed it again. Fixed a bug in next_sibling, caused by a combination of mixing overriding <=>() and using Array.index().
  • Changes since 1.1b: 100% OASIS valid tests passed. UTF-8/16 support. Many bug fixes. to_a() added to Parent and Element.elements. Updated tutorial. Added variable IOSource buffer size, for stream parsing. delete() now fails silently rather than throwing an exception if it can't find the elemnt to delete. Added a patch to support REXMLBuilder. Reorganized file layout in distribution; added a repackaging program; added the logo.
  • Changes since 1.1a: Stream parsing added. Bug fixes in entity parsing. New XPath implementation, fixing many bugs and making feature complete. Completed whitespace handling, adding much functionality and fixing several bugs. Added convenience methods for inserting elememnts. Improved error reporting. Fixed attribute content to correctly handle quotes and apostrophes. Added mechanisms for handling raw text. Cleaned up utility programs (profile.rb, comparison.rb, etc.). Improved speed a little. Brought REXML up to 98.9% OASIS valid source compliance.
  • 3. 8 bugs

    You can submit bug reports and feature requests, and view the list of known bugs, at the REXML bug report page. Please do submit bug reports. If you really want your bug fixed fast, include an runit or Test::Unit method (or methods) that illustrates the problem. At the very least, send me some XML that REXML doesn't process properly.

    You don't have to send an entire test suite -- just the unit test methods. If you don't send me a unit test, I'll have to write one myself, which will mean that your bug will take longer to fix.

    When submitting bug reports, please include the version of Ruby and of REXML that you're using, and the operating system you're running on. Just run: ruby -vrrexml/rexml -e 'p REXML::Version,PLATFORM' and paste the results in your bug report.

  • Attributes are not handled internally as nodes, so you can't perform node functions on them. This will have to change. It'll also probably mean that, rather than returning attribute values, XPath will return the Attribute nodes.
  • Some of the XPath functions are untestedMike Stok has been testing, debugging, and implementing some of these Functions (and he's been doing a good job) so there's steady improvement in this area.. Any XPath functions that don't work are also bugs... please report them. If you send a unit test that illustrates the problem, I'll try to fix the problem within a couple of days (if I can) and send you a patch, personally.
  • Accessing prefixes for which there is no defined namespace in an XPath should throw an exception. It currently doesn't -- it just fails to match.
  • 3. 9 todo

  • True XML character support
  • RelaxNG support
  • XPath optimizations
  • Japanese encoding support for REXML
  • Add XPath support for streaming APIs
  • XQuery support
  • XUpdate support
  • Make sure namespaces are supported in pull parser
  • Namespace support in SAX2
  • Add document start and entity replacement events in pull parser
  • Better stream parsing exception handling
  • I'd like to hack XMLRPC4R to use REXML, for my own purposes.
  • RPM-ify REXML. Someone has already done this.
  • True DTD handling (in progress). I've given up on this. DTDs suck. I'm going straight to RelaxNG support.
  • I had a dream the other night about how to speed up XPath considerably; I'll have to do some testing to see if it would actually work, but I have high hopes. (depends on absolute XPaths). My dream lied. This had some interesting possibilities as an optimization for some cases, but was basically unworkable.
  • Absolute XPaths attribute for nodes. NOTE: This idea bombed. There is no way (AFAICS) to simplify XPath parsing.
  • It looks like people want XPath to return attribute nodes rather than attribute values. Since I haven't had anyone strongly voting for keeping it the way it is, this will probably change to the requested method.
  • Bug report submission mechanism
  • RFC/RCR on the REXML page
  • Allow the user to add entity conversions
  • Support internal DocType ATTLIST processing (required)
  • Run the streaming and pull parsing APIs against the OASIS tests
  • Link to Kouhei's translated documentation.
  • Extend pretty printing. First, make transitive pretty printing an option. Second, make sure that whitespace isn't added around/to Text nodes. Third, add :ignore_whitespace_nodes.
  • Taint the strings pulled from files.
  • Process entity declarations in DocType.
  • hello world

    Amrita is a html template libraly for Ruby


    Mon Jan 06 16:49:04 JST 2003/ last-modified Tue Aug 06 10:36:18 JST 2002 amx sample

    amx is a XML document. It contains model data as well-formed XML, HTML template and a small Ruby code map both.

    This is a sample AMX document.


    Mon Jan 06 16:49:05 JST 2003 amrita home page Japanese/English/amrita-Wiki/amrita-bbs(Japanese)/amrita-bbs(English)/

    amrita home page

    Amrita is a a html/xhtml template library for Ruby. It makes html documents from a template and a model data.

    What is amrita ?

    Key feature

    Amrita mixes a template and model data up to a html document naturally matching the id attribute of HTML element to model data.

    For detail see documents


    download


    demo

    You can see the samples running here


    amrita-users mailing list

    amrita-users@walrus-ruby.org is set up for a purpose to talk about amrita in English. To subscribe this list, please send the following phrase

    
                    subscribe Your-First-Name Your-Last-Name
    
    in the mail body (not subject) to the address amrita-users-ctl@walrus-ruby.org .


    status

    amrita is stable now. The main features and API are fixed.

    But the archive has many experimental features. These features are not so tested and may change or deleted later.

    I mean "main features" the features described in docs/Tour or these source files.

    I mean "experimental feature" the features described in docs/Tour2 or these source files.


    unstable branch

    The unstable version was forked from V1.0.1 . In this branch, some of next features will be developed.

    The priority of thease feature is not fixed. Requests are welcome .


    ChangeLog

    amrita before V1.0.1 has a XSS vunerability . If you are using pre_format option, update it to V1.0.2 or later .

    V1.0.2

    • fixed XSS vunerability of sanitizing with pre_format
    • fixed a bug of amrita_sanitize_xxx for Fixnum
    • fixed a bug (using MergeTemplate with compiler)
    • fixed a bug (using PartsTemplate with compiler)

    V1.0.1

    • tested under ruby-1.6.8 and ruby-1.8.0-preview1
    • now archive includes RDoc documents
    • fixed bug of merge.rb
    • I followed API changes of cgikit 1.0b5 except Examples/SourcePage
    • fixed bug of compiler(AttrData)

    V1.0.0

    • fixed the problem that the 0.9.6 template compiler doesn't consider attr_filter on attribute expansion.

    V0.9.6

    This version is RC1 for V1.0 . If no problem was found, this archive will be V1.0.

    • fixed bug of expand_attr with compiler
    • added Japanese Documents

    V0.9.5

    I refactored the implematation of compiler much so this release can not be RC

    • add -w for test and removed warning messages
    • added new experimental feature "parts-template"

      For detail see Tour2.

    • added bbs script to sample
    • fixed minor bugs

    V0.9.4

    The parser of V 0.9.3 can't parse comment correctry. This release has only fix of it.

    V0.9.3

    the third beta release. I think next release will be RC1

    • make parser do well with StringScanner_R(ruby version of strscan)

      Now, amrita can be used without any extention library installed. (You only have to put Ruby version of strscan)

    • move tag information of parser.rb to tag.rb and make it customizable
    • make compiler's output to sanitize correctly
    • fixed SingleLineFormatter#initialize: added tagdict parameter
    • fixed bug of AttrArray ( which did not use the context for expanding body )

    V0.9.2

    the second beta release

    • expand_attr can be used with compiler
    • brush up sanitizer
    • fixed minor bugs

    V0.9.1

    the first beta release

    • cgikit interface

      cgikit is a nice framework for cgi programming. An interface for it is included in this release. For detail see Tour2.

    • MergeTemplate

      You can use two or more templates to generate one output. For detail see Tour2.

    • aded yaml feature to AmritaScript

      You can put a yaml format data in AmritaScript. For detail see sample/tour/amsyaml.ams in the archive.

    V0.8.5

    • added amx: Amrita XML extention feature

      amx(AMrita eXtention for XML) is a style-sheet for XML. It converts an XML document to HTML. You can use amrita template for specifing the output format.

    • added handler and sample for mod_ruby
    • added ams: AmritaScript feature ( idea by Mr.Beyond )

      ams(AmritaScript) is an experimental feature that packs a template with the model data for it.

    see ChangeLog for detail


    amrita ホームページ English/amrita-Wiki/amrita-bbs(Japanese)/amrita-bbs(English)/

    amrita ホームページ

    amrita とはなにか?

    amrita(アムリタ)は Ruby用のhtml/xhtmlテンプレートライブラリーです。 テンプレートとモデルデータをかけあわせてHTMLドキュメントを出力します。

    特色


    ダウンロード

    amrita V1.0.1以前にはXSS脆弱性があります。pre_formatオプションを使用している場合には、至急 V1.0.2以降にアップデートしてください。


    ドキュメント

    メーリングリスト

    こちらを参照してください。