XML in the Real World perl, xml and oakley'com - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

XML in the Real World perl, xml and oakley'com

Description:

Balance between power' and ease of use' suitable for business ... etymology friend of the wild boar /etymology /last /name XML / Database Alternative ... – PowerPoint PPT presentation

Number of Views:102
Avg rating:3.0/5.0
Slides: 24
Provided by: ryane9
Category:
Tags: xml | boar | com | oakley | perl | real | world | xml

less

Transcript and Presenter's Notes

Title: XML in the Real World perl, xml and oakley'com


1
XML in the Real Worldperl, xml and oakley.com
  • by Ryan Erwin

2
Overview
  • Perl
  • XML
  • XPath
  • XML Schema
  • XSLT
  • XML Indexes
  • AxKit, SAWA

3
Perl in Business Applications
  • Flexible - TIMTOWTDI
  • Fast Development
  • Versatile
  • Dictionary capable of doing many things
    competently
  • Easy things Easy - Hard things possible
  • Balance between power and ease of use
    suitable for business applications
  • Fun
  • I enjoy solving problems with Perl
  • Efficient
  • Others really enjoy their work with Perl

4
XML / Use Cases
  • Standardized Data Interchange
  • EDI Replacements
  • Web Services - Remote Function Calls
  • XML-RPC and SOAP
  • Document File Formats
  • OpenOffice Word Processor
  • SVG (for Flash and Illustrator some day?)
  • Configuration Files
  • Database Alternative
  • XML-RDBMS
  • Xindice (Zeen-dee-chay)
  • ECommerce Product Catalog

5
XML / Overview
  • XML stands for eXtensible Markup Language
  • XML is a markup language much like HTML
  • XML was designed to describe data
  • XML tags are not predefined in XML - youre free
    to define your own tags
  • Remember XML does NOT do anything
  • XML was created as a way to structure, store, and
    send information

6
XML / File Types
  • XML Data Files
  • Data Oriented
  • Element Nodes are usually not nested inside Text
    Nodes
  • Can be visualized as a Spread Sheet (via XML Spy)
  • Higher correlation with Entity-Relationship Model
  • XML Document Files
  • Presentation Oriented
  • More like HTML
  • Formatting Information (bold, italic, underline,
    color, etc)
  • Stylesheets
  • Difficult to visualize as a Spread Sheet

7
XML / Attributes and Elements
  • Use Elements whenever Possible
  • Attributes are best used for Data Type
    Information attached to Elements
  • Exampleltname firstryan lasterwin/gt-or-ltn
    amegt ltfirstgtryanlt/firstgt ltlastgterwinlt/lastgtlt/
    namegt

8
XML / Attribute and Elements (cont)
  • ltnamegt ltfirstgtryan ltetymologygtlittle
    kinglt/etymologygt lt/firstgt ltlastgterwin
    ltetymologygtfriend of the wild boarlt/etymologygt
    lt/lastgtlt/namegt

9
XML / Database Alternative
  • Low Cost
  • Easy to Create
  • No database server required
  • Neither does Berkley DB or Embedded MySQL
  • Easy to Change
  • Easy to Make a Mess

10
XML - DB - Change
  • XML is just a text file
  • exceptions can apply to a single file
  • databases require schema changes when one special
    case breaks the previously established rules
  • this is power - it can be well used or well
    abused
  • Additions can easily be made to a schema without
    breaking existing code
  • recall XML Attribute and Element Example

11
XPath
  • Query Language for XML
  • Locate Information inside an XML Document
  • XPath querys the data in a loaded nodeset - it
    cant find data that isnt yet loaded
  • If you had an XML document containing a Map of
    the world, an XPath expression might look like
  • US/CA/Foothill Ranch/Icon/One/Building/Auditorium
  • XPath specifies a route rather than pointing to a
    specific set or sequence of characters, words, or
    other elements

12
W3 XML Schema
  • XML Based Data Validation Tool
  • Alternative to XML DTD - Document Type Definition
  • XML Spy Integration
  • Not widely accepted / implemented
  • Much more powerful than DTD
  • RegEx validation against element content

13
W3 XML Schema Example
  • lt?xml version"1.0" encoding"UTF-8" ?gt
  • ltxsdschema xmlnsxsd"http//www.w3.org/2001/XMLS
    chema"gt
  • ltxsdsimpleType name"path_absolute_type"gt lt
    xsdrestriction base"xsdstring"gt
  • ltxsdpattern value
  • (/xml/product/)1(_a-z0-9_\./)1,index.xml
    " /gt
  • lt/xsdrestrictiongt
  • lt/xsdsimpleTypegt
  • lt/xsdschemagt

14
XSLT
  • Separate Content from Presentation
  • One Document - Many Purposes
  • The LA Times presents News Stories and
    Advertisements
  • These are presented in the Newspaper and Website
  • If all of the content is well organized in XML
    the Times would
  • use Newspaper.xsl and send the output to the
    printing press
  • use Website.xsl and send the output to the screen

15
XSLT (cont)
  • XML Language for Transforming XML Documents
  • Many Implementations
  • Very Fast, if using LibXSLT from RedHat
  • Limited set of functions and power by design

16
XSLT (cont)
  • Programming without Assignments
  • Useless for XSL with Pull Method
  • PurposeDownload entire XSL File but start
    displaying an XML file when only a portion of the
    file has been downloaded

17
XSLT / Models
  • Push
  • Event Driven by Template Matching Rules and Apply
    Templates
  • More Similar to SAX
  • XML DocBook
  • Little Control over XSL output
  • Pull
  • More Similar to DOM
  • Grab specific items of interest out of an XML
    document
  • Very useful when multiple rules may be needed for
    one element
  • Lots of Control over XSL output

18
XSLT Example
  • /Desktop/Presentation/XSLT

19
XML Product Database
  • Business Requirements always Change
  • at least they do here )
  • XML allows flexibility to grow
  • Data Administration with XML Spy
  • often able to avoid tools required to bootstrap
    your tools with data these tools also need to
    be changed as your application changes
  • Flexibility to Make Exceptions
  • Most eyewear is defined by a product name, lens
    color and frame color
  • Oakley M-Frame and Why-3 also have a lens shape
  • XML allows us to avoid complicating all of the
    normal products just to accommodate exceptions
  • More Efficient way to solve many problems

20
XML Product Database (cont)
  • If resources were infinite and requirements never
    changed I would recommend using an RDBMS over XML
    any day
  • If you live in such a world, Im happy for you -
    never leave )
  • If you dont, then dont worry about building the
    perfect schema that will inevitably break, take
    a swing at defining a good enough XML Schema
    and let it grow with your needs

21
MySQL XML Index
  • Huge XML Drawback
  • XML isnt automatically indexed
  • Workaround
  • Build a database schema that represents the
    required parts of your XML
  • Build a tool to dump your XML into that database
    for searching
  • Dont bother trying to generically convert your
    XML into an RDBMS and back
  • you will loose everything that XML gives you
  • Think of the relationship of your XML to your
    Database like a Photoshop file is to a JPEG
  • Xindice and other projects will fix this in the
    future

22
XML and Friends
  • XML is just another tool...
  • Java, EJBs, JDBC, etc
  • Perl, DBI, Data Access Modules
  • Perl, XML, XSLT, Schema, XmlSpy
  • Microsoft Access

23
The End
  • Questions
  • Comments
  • Tips )
Write a Comment
User Comments (0)
About PowerShow.com