Introduction To XML

Document Sample
Introduction To XML Powered By Docstoc
					Introduction To XML
                  By Abdul Habra
                  October 30, 2002




 www.tek271.com/articles/articles.html



         Introduction To XML By Abdul Habra   1
Topics
                   Expectations
                   What is XML
                   Acronyms
                   History
                   Motivation
                   Where/Who uses XML
                   When to use/not use
                   Technologies
                   What’s next
                   Feedback
 Introduction To XML By Abdul Habra       2
Expectations
   Understand what XML is, even
    if you are not a programmer
   Tell you what are some of the
    acronyms and technologies
   What to do to learn more
   Will NOT learn API or
    programming



    Introduction To XML By Abdul Habra   3
What Is XML
    Data formatted in a way that
     is easy for humans and
     machines to read
    eXtensible Markup Language
    Text data, i.e. not binary
         When stored in a file, one can
          view it with Notepad
    Not a proprietary language
    Fast becoming a universal
     data translation language

    Introduction To XML By Abdul Habra   4
              Example
<?xml version="1.0"?>

<CustomerList>
  <customer id="1">
    <fname> Jen </fname>
    <lname> Lo </lname>
    <title> CEO </title>
    <company> Blue Moon Enterprises </company>
  </customer>
  <customer id="2">
    <fname> Austin </fname>
    <lname> Powers </lname>
    <title> Gold Member </title>
    <company> MiniEvil </company>
  </customer>
</CustomerList>
                Introduction To XML By Abdul Habra   5
Acronyms
   DOM, SAX, DTD, XSL, XSLT,
    SOAP, UDDI, …
   X: eXtensible
   D: Document
   L: Language
   O: Object
   P: Protocol

See:
www.tek271.com/articles/acroStats/
  AcroStat.html
    Introduction To XML By Abdul Habra   6
XML’s History
   Derived from SGML (Standard
    Generalized Markup Language),
    that started in the 1960s
   Specs published in Feb 1998
   Began to get popular in 2000
   Supported by most vendors and
    platforms
       MS, IBM, Sun, Borland, …
   I.E. >= 5.0 can display XML data



    Introduction To XML By Abdul Habra   7
Motivation
   Businesses needed to communicate
    over the Internet. (B2B)
       Send documents and complex data
        that have different formats
            Word, PDF, Excel, Access, comma
             separated, …
       E.g. think how many ways a
        person’s name can be formatted
   Different Internet clients
    capabilities.
       Desktops with different browsers
       PDAs, Mobile phones, …


    Introduction To XML By Abdul Habra         8
Where/Who Uses XML
      In databases to store or move data
      In configuration files
      In communication between systems
      MS: .NET, IE, SQL Server, …
      IBM: donated their Java XML
       technologies to Apache
      Sun: Supports XML, Web Services, …
      I started using it at R+R in 1998



        Introduction To XML By Abdul Habra   9
To Use Or Not To Use
    Use when you want to:
       Communicate between different
        programs and systems
       Store complex configuration data

       Display output by different clients,
        e.g. desktops and PDAs. Use XSLT
    Do not use when:
       You need a relational database
        model, XML is less efficient than
        RDBs



        Introduction To XML By Abdul Habra     10
XML Technologies

   The following slides will
    introduce some XML related
    terms and technologies
   This a high level definition
   Some definitions are
    approximated for the sake of
    simplicity



    Introduction To XML By Abdul Habra   11
Tags And Elements
Consider the following XML snippet:

<customer id="2">
  <fname> Austin </fname>
  <lname> Powers </lname>
  <title> Gold Member </title>
  <company> MiniEvil </company>
</customer>

   <fname> is a start tag
   </fname> is an end tag
   <fname>Austin</fname> is an
    element
   id (in customer tag) is an attribute

    Introduction To XML By Abdul Habra     12
Well-Formed/Valid Documents
          Well-Formed document:
              Follows XML syntax
              Every start tag must have an end tag
              If a document is not well-formed,
               then it is NOT an XML document
          Valid document:
              Must be well-formed
              Must follow a template (DTD) that
               specifies what elements and
               attributes can/must exist in the
               document


           Introduction To XML By Abdul Habra      13
      Documents Templates
Consider the following XML snippet:

            <customer id="2">
              <fname> Austin </fname>
              <lname> Powers </lname>
              <company> MiniEvil </company>
              <balance> 1009 </balance>
            </customer>

A template will specify that customer element:
 Must have an id attribute that is an integer

 Must contain an fname element that is a string

 Can contain a balance element that is an integer

 …


                Introduction To XML By Abdul Habra   14
DTD And Schema
   A standard was created for
    defining document templates;
    Document Type Definition (DTD)
   DTD has a confusing syntax and
    is not XML
   In 2001 a new standard was
    created; XML Schema
   XML Schemas are well-formed
    XML documents
   Schemas provide better control
    of the data types

    Introduction To XML By Abdul Habra   15
        XML Parsers
           To parse is “to classify a word or
            analyze a sentence in terms of
            grammar”
COOK
           A Parser is a program that reads
BOO         source code of a language and
    K
            recognizes each element of it
           An XML parser reads the XML
            source, breaks it down into its
            elements, and allows another
            program to act on these elements


            Introduction To XML By Abdul Habra   16
Processing XML
To process an XML document,
   you have several options:
1. Write a program to parse and
   process (do it yourself)
2. Write a program using some
   libraries (DOM or SAX)
3. Write processing rules using
   XSLT


  Introduction To XML By Abdul Habra   17
DOM Or SAX
   Libraries to parse XML data
   A Document Object Model (DOM)
    parser reads the whole source and
    converts it into a tree-like data
    structure
   A Simple API for XML (SAX) parser
    reads the source and allows the
    programmer to act on each element
    as soon as it is recognized
   DOM is easy to use, slow, and
    consumes memory
   SAX is harder to use, fast, and
    consumes less memory

    Introduction To XML By Abdul Habra   18
XSL And XSLT
   Process XML data using rules.
   The eXtensible Stylesheet
    Language (XSL) is used to
    format XML documents for
    display (e.g. in a browser)
   The eXtensible Stylesheet
    Language Transformation
    (XSLT) allows converting XML
    documents into any other
    format including XML, HTML

    Introduction To XML By Abdul Habra   19
    SOAP
   SOAP: Simple Object Access Protocol
   XML based standard
   Allows calling methods, functions, or
    procedures on a remote computer
   It works over the Internet
       Uses HTTP
       Can pass through a firewall
   Allows inter-operability between
    different platforms, operating systems,
    and languages


        Introduction To XML By Abdul Habra   20
    Web Services
   A standard for locating SOAP methods
    and determining how to use them
    automatically
   Web Service Description Language
    (WSDL): A way to describe the remote
    method’s name and parameters
   Universal Description, Discovery and
    Integration Protocol (UDDI): A directory
    listing of different services (like yellow
    pages)

Web Service = SOAP + WSDL + UDDI

     Introduction To XML By Abdul Habra     21
That’s It with XML Technologies




           Introduction To XML By Abdul Habra   22
What’s Next
   To learn more about XML:
      www.xml.com
      www.ibm.com/developer/xml/

      www.xmlsoftware.com

      msdn.microsoft.com/xml/

      Book: CodeNotes for XML

   Start using it. You can use:
      VB, Java, .NET, C++, …
      MS, IBM, and Sun provide
       free XML parsers and libraries

    Introduction To XML By Abdul Habra   23
Examples
   RTRErrorLog.xml: Error log
    file.
   RTRConfClient.xml: A
    configuration file.
   XSLT: On-line example.




    Introduction To XML By Abdul Habra   24
Feedback
   Did this satisfy your expectations?

   Any suggestions or comments?

   What topics do you like to see in a
    next or advanced class? (e.g.
    XSLT, SOAP, …)




    Introduction To XML By Abdul Habra   25

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:163
posted:11/21/2008
language:English
pages:25