Environmental Information eXchange Network by dbmMp7v

VIEWS: 4 PAGES: 16

									  Practical XML
      Representing Data
        The New Way

 Bill Rensmith, Windsor Solutions, Inc.
Exchange Network National Conference
               4/22/2010
                                          1
      What is XML?


• Nothing more than a text file
• A format for representing data in a flexible,
  structured way
• Consider a list of permits:

    PermitNumber   IssuedDate     PermitStatusText
    WA000111       6/23/2003      Expired
    WA000222       1/23/2009      In Effect
    WA000333       5/12/2010      Pending




                                                     2
      What is XML? (cont’d)


• Same list of permits as XML:




                                 3
      Basic Syntax


• Tags wrap data:
  <PermitNumber>WA0000111</PermitNumber>
• Tags can be empty:
  <PermitNumber/>
• Tags can wrap other tags to create a group:
  <PermitList>
    <PermitNumber>WA0000111</PermitNumber>
    <PermitNumber>WA0000111</PermitNumber>
    <PermitNumber>WA0000111</PermitNumber>
  </PermitList>
                                                4
      Why is XML So Useful?


• Human readable!
  – Compared to flat files:
     WA000011120030623EXP
     WA000022220090123EFF
     WA000033320100512PND
  – Compared to binary files:
    0010110111011011010101011
    1101101110101010101101010



                                5
       Why is XML So Useful? (cont’d)

• XML can be used to represent hierarchal data:




                                                  6
      Why is XML So Useful? (cont’d)


• Most programs today can read and
  manipulate XML
• XML structure and syntax can be validated
  using XML Schema
• XML is compatible with the Web




                                              7
      XML in Action


• Opening an XML file in Internet Explorer
• Manipulating XML in Excel 2007




                                             8
      XML in Action (cont’d)


• RSS News Feed
  – https://www.windsorsolutions.biz/on2rss/Feed.aspx
  DEMO – Examining an RSS Feed
• Google Earth KML files
  – http://www.epa.gov/airexplorer/monitor_kml.htm
  DEMO – Viewing an EPA KML File in Google Earth
• All Office 2007 documents are really just XML
  files!
   DEMO – Dissecting a Word Document

          My Goodness, XML is EVERYWHERE!

                                                        9
      XML Schema


• A schema describes the structure of an XML
  file
• Can be used to prove an XML file is valid
• Enforces element data types (string, date,
  integer, boolean, etc.)
• Can limit an element to a list of allowable
  values (lookups)
• Cannot do cross-field validation!
   – Other technologies needed.
        DEMO – Creating a Schema and
               Validating an XML File         10
      XML Schema


• “Well formed” vs. “Valid” XML files
   – Well Formed
     • Every element has an opening and closing tag
     • Do not need a schema to check that an XML
       file is well formed
  – Valid
     • Means an XML file conforms to the structure
       prescribed in the schema




                                                      11
      XML on the Exchange Network


• XML is almost exclusively used on the EN to
  copy data between partner databases




       …but how does that DB-to-XML
           data translation occur?

                                                12
      Translating Data To/From XML


• A multitude of ways to translate between a
  database and XML:
   – Gazillion programming frameworks
   – Directly from database using SQL
     DEMO – XML Output from SQL Server Query
  – XML Mapping Utilities
     DEMO – Altova MapForce 2009




                                               13
Translating Data To/From XML




                               14
      XML Stylesheets (XSLT)


• A stylesheet contains instructions for
  translating an XML file into some other format
  including HTML, flat file, or even XML
• An XSLT processor is needed to apply the
  transformation




       DEMO – Transforming XML to HTML         15
      Summary


• XML is ubiquitous
• XML is really made for machines, but is
  human-friendly too
• XML is easily viewed and manipulated
• XML schemas are used to enforce the
  structure and integrity of XML documents
• XML stylesheets are used to transform an
  XML document into something new
• XML really isn’t that scary, is it?

                                             16

								
To top