Learning Center
Plans & pricing Sign in
Sign Out




A web enabled data description language


          By Mark Lawson &
        Edward Ryan L’Herault
                      XML HISTORY

• Developed by work group, under authority
  of the W3C
• First seen in 1996, and standardized by the
  W3C in 1998
• Simplified dialect of the SGML
  SGML "Standard Generalized
           Markup Language"
• A method for creating interchangeable,
  structured documents
• Standardized in 1986 (ISO8879:1986)
• Can assemble a single document from
  many sources
• Defines a document structure using a
  special grammar called a Document Type
• Adds markup to show the structural units in
  a document
         HTML vs XML vs SGML

• HTML is an SGML application (a DTD and
  set of processing conventions)
  – As such it’s much more limited than SGML and
  – It’s easy to learn
• SGML is the mother of XML and HTML
  – It’s complicated – hundreds of pages in it’s
  – It has many extraneous features that aren’t
    needed on the web
      HTML vs XML vs SGML II

• XML is a subset of SGML

  –   Valid SGML
  –   Only uses the parts that are useful on the web
  –   Requires more syntax checking than HTML
  –   Is extendable like SGML
  –   Has a small definition (25 pages)
  –   Easy to learn
How do I execute or run
           an XML file?
• You can't and you don't.

• XML is not a programming language,
  so XML files don't ‘run’ or ‘execute’.

• XML is a markup specification
  language and XML files are data.
Constructing your own XML

You must supply a Document Type Definition

What is a Document Type Definition (DTD)?

• A context-free grammar like Extended BNF
• Provides the rules that define the elements
  and structure of your new language
• Thousands of SGML DTDs already in
• SGML DTDs need to be converted to XML
      for use with XML systems
How is a DTD implemented?

• A DTD is a file (or several files to be used
  together), written in XML's Declaration
• It contains a formal description of a
  particular type of document
• It sets out what names can be used for
  element types, where they may occur, and
  how they all fit together
• Any browser (or application) with an XML
  parser could interpret an XML document
  instance by "learning" the rules defined by
  the DTD.
      Defining the structure &
             Semantics of XML
XML structure is defined in a schema

• Defines shared markup vocabularies
• Provide a means for defining the structure,
  content and semantics of XML
• Introduces new levels of flexibility that may
  accelerate the adoption of XML for
  significant industrial use

• Schemas support inheritance and
  overriding old values
• Schemas are not yet a formal
  Recommendation, but a number of
  sites are starting to serve useful
  applications as both DTDs and
                        An XML example
• Example: Elements and Attributes
  This group of elements, attributes describe the
  contents of an address book. It includes a DTD
  which describes how all of the pieces work as XML.
      <?xml version=‘1.0’ ?>
      <!DOCTYPE address-book SYSTEM ‘address-book.dtd’>
      <!--loosely inspired by vCard 3.0 -->

1. The XML Declaration
   • <?xml version="1.0"
     •   This is what tells an XML parser that
         the document is XML

2.    XML Declaration w/ character set
     • <?xml version="1.0"
                        Basic Syntax

• All tags must be closed
• The exception is an empty tag
  (i.e. <line-break/> )
• All nested tags must close before the tag
  they are nested in
• All attributes must have quotes
• Case sensitive
                      Tags and DTD

The DTD describes every object that can
  appear in the document
An example section of a DTD is:

     <!ELEMENT address-book (entry+)>

  This is an entry that says the element
  <address-book> is composed of one or
  more <entry> elements.
          Optional modifiers
             for the entries:

1. No modifier: Object appears once
   and only once in the element
2. +: Object appears at least once
   and can be repeated
3. *: Object appears zero or more
4. ?: Object appears zero or one
              Elements composed of
                   multiple entries
An element can be composed of multiple entries, for
  example an entry in the address book has: a
  name, phone number, and email
<!ELEMENT entry (name,tel*,fax*,email*)>
Inside the parentheses are the elements that make
  up entry these can take the forms:
• (e1 , e2): These elements will appear once each in
  order e1 e2
• (e1 | e2): One of these elements will appear (either or)
• These can be combined as in:
   – (e1, (e2 | e3) )
      Attributes of Elements

Some elements have attributes, which are
part of their data description. An attribute

– The attribute tag opening: <!ATTLIST
– The name of the element it belongs to:
– The attribute name: href
– The attribute type: CDATA
– Optionally a default value: #REQUIRED
– The close bracket: >
  Attributes of Elements II

There can be more than one attribute listed
in one attribute tag:
   preferred (true |false) 'false'>
            Referencing the DTD

A DTD is referenced in the document using it
  with the tag:

  <!DOCTYPE address-book SYSTEM "address-book.dtd">
   Referencing the DTD II

The section of the tag:SYSTEM "address-

Can be replaced with or followed by a [ and
  the actual DTD as in:
   <!DOCTYPE name [
      <!ELEMENT name (#PCDATA |fname |lname)*>
      <!ELEMENT fname (#PCDATA)>
      <!ELEMENT lname (#PCDATA)>
           Viewing the XML: XSL

Because XML is just for describing data it isn’t
  inherently displayed in a particular way by
  a browser. XSL allows how things are
  displayed to be specified

• XSLT transforms the data into new forms
• XSLFO allows the style of the objects to be set
• A similar thing to XLSO which is more
  supported is CSS
                          Uses of XML

1. intelligent agents - content
   personalization via smart pull/push
   (possibly with a date-stamped XML
2. structured records (purchase order)
   object with methods and data (Java, and
   potentially JavaScript)
3. meta-content about your web site
   (improves searches) query results
4. graphical user interface of an application
5. persistent storage format (e.g. ODBMS-
   powered XML repository)
                  Uses of XML II

6. electronic service manuals
7. online process/procedures
8. EDI (electronic data interchange) -
   mapping data between purchasing
   and inventory departments of same
   or different companies

most informative site:


XML for Dummies
XML by Example by Que

To top