CliftonLib

This is a collection of useful functionality that I require for various projects that I'm working on.

In version 0.0.1, I've implemented several XML helper classes, similar to .NET's XmlDocument, to facilitate the creation and serialization of XML. In this version, the support is bare bones but sufficient for what I need done.

Why do this?

All the implementations for XML support that I've seen in Ruby utilize the "method missing" feature, so that markup is written in a DSL manner. For example:

doc.product = 'Apples'

will yield something like:

Apples

I have several issues with this:

  1. It isn't object oriented.
  2. It assumes you know the element and attribute names, which isn't convenient when generating XML dynamically from other data sources
  3. It leverages "method missing", which affects performance and creates an internal DSL which isn't necessary.
  4. Frequently, the parameters are passed as hashes, which I find particularly evil in Ruby as they don't document what the valid parameter-hashes are via function parameters.

Instead, I want to base XML document generation (and eventually parsing) on Microsoft's implementation of the XmlDocument class in .NET:

http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx

This implementation:

  1. Is a decent object-oriented solution for creating XML documents
  2. Inherently supports dynamic XML generation
  3. Isn't DSL-ish.

Revisions

Published 0.0.10 - Fixed issue with child nodes and inner text, also XmlDocument instance references itself since it's derived from XmlNode. Published 0.0.9 - Must remember to push commits before pushing gem Published 0.0.8 - Fixed indentation issues with XmlFragments, Bad Push Published 0.0.7 - Added XmlFragment 0.0.6 - Published 0.0.5 - Added support to disallow a closing tag for HTML5 compatibility. For example, is valid, is seen as a stray ending tag. 0.0.4 - Added support to disallow self-closing tags for HTML5 compatibility. For example,

...
is valid,
is not. 0.0.3 - Added support for valueless attributes. Example: