1 / 19

XML and Ruby on Rails

XML and Ruby on Rails. Jennifer Andrews LIS 531F April 25,2007. Strengths of databases. Effective searching Efficient data storage (no redundancy) Scalable Reliable Good security features Been around a long time Part of the business structure. Strengths of XML. Human readable

Download Presentation

XML and Ruby on Rails

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML and Ruby on Rails Jennifer Andrews LIS 531F April 25,2007

  2. Strengths of databases • Effective searching • Efficient data storage (no redundancy) • Scalable • Reliable • Good security features • Been around a long time • Part of the business structure

  3. Strengths of XML • Human readable • Open standard, not tied to a platform • Structure part of document facilitates transfer and sharing of information • Flexible • Becoming more important with increase of information sharing across businesses and applications

  4. Relational Database • Stores data in tables made up of rows and columns • Each row represents a record • Order of records irrelevant • Many tables connected by “keys” • Can express complex relationships between tables

  5. XML • Hierarchical • Harder to express complex relationships • Order of data important • Preservation of order?

  6. Ruby on Rails • Based on Ruby • Web based database applications • Basic structure built into Rails • All pieces of the application interact in standard way • Advantage? Easy and speedy development of applications • OPEN SOURCE

  7. Architecture • MVC or Model, View, Controller • Controller = conductor • Model = data handling, enforces “rules” • Views = HTML, interface for interaction with user, but only displays, never handles data

  8. Step 1 – create database and tables using SQL

  9. New material Fiber Weight Brand Color Back

  10. Table in SQL

  11. Now what? • Create an XML document • Create view or “template” saved as .rxml • One small piece of code in the controller • Point browser to that view • And …..

  12. Code to generate XML resides in template xml.instruct! :xml, :version=>"1.0" xml.channel { for m in @materials xml.material do xml.title(m.fiber) xml.description(m.weight) xml.brand(m.brand) xml.color(m.color) end end }

  13. Material Controller

  14. How does it happen? • MAGIC! • A piece ofRuby code called Builder • Takes what is after the xml. and turns it into a tag • xml.description becomes <description> • can include attibutes, too • xml.price(p.price, currency => “USD”) becomes <price currency=”USD”>50.00</price>.

  15. Real Life Application • Rails app collecting orders for books • Part of that process – collecting names, addresses • Marketing department wants names of all who bought a certain book (in XML) to feed into a another program they have.

  16. Another way • Autogenerate through command called to_xml • Dumps everything • No control over order of elements • Possible to add code so if a request comes for HTML – that is what’s returned, if the request is for XML, that is what is returned

  17. Bits and pieces • Can you use XML to input data into RonR? • Installing RonR on computer • Locomotive • 2 tutorials • Put your XML knowledge to use • Start simple, ride the rails, and be amazed

More Related