README
Path: README
Modified: Thu Jun 13 02:09:14 MDT 2002

XMLProof/Ruby - An Implementation of xml:Proof for Ruby

<a schema for the rest of us/>

Introduction

XMLProof/Ruby is a 100% Ruby API for using xml:Proof, an alternate XML schema. It was born out of a need to typecast data taken from an XML Document. Imagine! All this just for that one simple need. But it seemed the right way to go about it, and the outcome has produced many additional fruits. xml:Proof has prooved to be quite a sophisticated XML schema, rivaling all others in capability and ease of use.

Installation

To install XMLProof simply unpack the gzipped tarball into your local site_ruby path. This path is usually +/usr/local/lib/site_ruby/1.6/+. An install script is not provided as installation does not require any special files or settings.

Requirements

XMLProof/Ruby requires:

Usage

First read the documentation for xml:Proof at "www.transami.net/files/ruby/xmlproof/xmlproof.html". For greater comprehension read the xml:Proof specification at "www.transami.net/files/ruby/xmlproof/xmlproof-spec.html".

Example of using the proofreader:

  require 'xmlproof/proofreader'

  def validate(xml_filename)
    #create a proofreader
    prover = XMLProof::Proofreader.new

    # validate using document's internal schema instructions
    valid = proofreader.proofread_document_internal(xml_filename)
    # return results
    if valid
      puts "GOOD DOCUMENT"
    else
      puts "BAD DOCUMENT"
      prover.errors.each do |e|
        puts "namespace->#{e[0]} \t xpath->#{e[1]} \t error->#{e[2]}"
      end
    end

  end

Another using external proofsheets:

  require 'xmlproof/proofreader'

  def validate_with(xml_filename, *proofsheet_files)
    # create a proof
    proofsheets = XMLProof::Proofsheets.new
    proofsheets.load_proofsheets(*proofsheet_files)
    proof = XMLProof::Proof.new(proofsheets)

    # create a proofreader using the proof
    proofreader = XMLProof::Proofreader.new
    proofreader.use_proof(proof)
    # validate
    valid = proofreader.proofread_document(xml)

    # return results
    if valid
      puts "GOOD DOCUMENT"
    else
      puts "BAD DOCUMENT"
      prover.errors.each do |e|
        puts "namespace->#{e[0]} \t xpath->#{e[1]} \t error->#{e[2]}"
      end
    end
  end

Until a more detailed tutorial can be written, please refer to prooftool.rb for more concise examples, and refer to the API RDocs for further details.

Authentication

Package:XMLProof/Ruby
Author:Thomas Sawyer
Requires:Ruby 1.6.5+
License:Copyright (c) 2002 Thomas Sawyer, transami@transami.net under the Ruby License