Giter Site home page Giter Site logo

rxsd's Introduction

RXSD - XSD / Ruby Translator

Copyright © 2010 Mohammed Morsi <[email protected]>

RXSD is made available under the GNU LESSER GENERAL PUBLIC LICENSE as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Info

RXSD is a library that translates XSD XML Schema Definitions into Ruby Classes on the fly. It is able to read XSD resources and use them to define Ruby classes in memory or string class definitions to be written to the filesystem

RXSD implements a full XSD parser that not only defines the various xsd schema classes, parsing them out of a XSD file, but translates them into a meta-class heirarchy, for use in subsequent transformations. The builder interface can easily be extended to output any format one could want including classes in other languages (Python, C++, Java, etc), other XML formats, etc.

RXSD also parses XML conforming to a XSD schema, and instantiates objects corresponding to the XSD classes created. Furthermore, RXSD will work with existing class definitions resulting in a quick way to map XSD to Ruby constructs, letting you define the schema features that you need, and autogenerting handlers to the others.

Installation

To install rxsd simply run:

gem install rxsd

Source code is available via:

git clone http://github.com/movitto/rxsd

Usage

require 'lib/rxsd'

xsd_uri = "file:///home/user/schema.xsd"
xml_uri = "file:///home/user/data.xml"

schema = RXSD::Parser.parse_xsd :uri => xsd_uri

puts "=======Classes======="
classes = schema.to :ruby_classes
puts classes.collect{ |cl| !cl.nil? ? (cl.to_s + " < " + cl.superclass.to_s) : ""}.sort.join("\n")

puts "=======Tags======="
puts schema.tags.collect { |n,cb| n + ": " + cb.to_s + ": " + (cb.nil? ? "ncb" : cb.klass_name.to_s + "-" + cb.klass.to_s) }.sort.join("\n")

puts "=======Objects======="
data = RXSD::Parser.parse_xml :uri => xml_uri
objs = data.to :ruby_objects, :schema => schema
objs.each {  |obj|
  puts "#{obj}"
}

rxsd's People

Contributors

movitto avatar

Stargazers

Dan Freeman avatar Anton Sozontov avatar

Watchers

Anton Sozontov avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.