Introduction to XML - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Introduction to XML

Description:

eXtensible Markup Language the universal format for structured documents ... Represent database schema as a set of DOM objects. Write the schema out as XML. ... – PowerPoint PPT presentation

Number of Views:12
Avg rating:3.0/5.0
Slides: 15
Provided by: youwen
Category:
Tags: xml | dom | introduction

less

Transcript and Presenter's Notes

Title: Introduction to XML


1
Introduction to XML
  • eXtensible Markup Language the universal format
    for structured documents and data on the Web.
  • A simplified subset of the Standard Generalized
    Markup Language (SGML).
  • It enables the separation of the meaning or
    semantics of the data from the way it is used by
    an application or rendered on the screen or
    output device.
  • XML is case-sensitive, the opening and closing
    tags both must be consistent.
  • Spaces are not allowed in elements names

2
(No Transcript)
3
(No Transcript)
4
XML Tags
  • XML allows us to create our own set of
    self-describing tags to identify our data.
  • Start tags must have corresponding end tags. A
    pair of start and end tags is called an element.
    An empty tag is essentially a start and end tag
    in one, and is identified by a trailing slash
    after the tag name (e.g. ltBR/gt).
  • XML is case-sensitive, the opening and closing
    tags both must be consistent.
  • Spaces are not allowed in elements names

5
Declare an XML Document
lt?xml version"1.0" standalone"yes"
encoding"ISO-8859-1"?gt
6
Build an XML Document
  • XML documents require a root element. The root
    element appears only once and encapsulates the
    entire XML elements and data in the document
  • In a well-formed XML document, all start tags
    need to be properly closed.
  • A well-formed XML structures your data in a
    relational hierarchical tree.
  • All attribute values must be within single or
    double quotes.

7
An Example of XML Document
lt?xml version"1.0" standalone"yes"?gt ltlibrarygt
ltbook call_no"PZ3.S8195Gr6"gt ltcover
href"grapes.gif" alt"Grapes of Wrath"/gt
lttitlegtThe Grapes of Wrathlt/titlegt ltauthorgt
ltlast_namegtSteinbecklt/last_namegt
ltfirst_namegtJohnlt/first_namegt lt/authorgt
ltpublishergtViking Presslt/publishergt
ltpub_yeargt1939lt/pub_yeargt lt/bookgt lt/librarygt
8
(No Transcript)
9
View XML Document
  • A well-formed XML document by itself simply
    provides a way to structure data.
  • To set the rules that govern the valid ways those
    tags must be used, we can use a DTD, or a
    document type definition.
  • XML can be viewed by incorporating HTML tags
    and/or along with style sheet.

10
Document Type Definition (DTD) File
  • Define which elements are available, in what
    sequence they must appear, how often they may be
    used, the possible nesting structure of the
    elements, and the attributes they may contain as
    well.
  • XML is really a formal specification language
    which processors use first to parse the DTD and
    then to read the document to identify where every
    element type comes and how each relates to the
    other.

11
XSL
  • XSL is XML-based, so it has to adhere to the same
    XML rules for well-formedness.
  • An XSL style sheet contains templates, each of
    which dictates rules and is specified with a
    matching pattern.
  • When the XSL processor finds XML data that
    matches a template pattern, it extracts XML data,
    filters out unwanted sections, and manipulates
    the data into some presentable layout.

12
Use XSL with XML
  • XSL style sheets are saved as files with an .xsl
    extension.
  • We need to specify the style sheet in an XML
    document
  • lt?xml-stylesheet type"text/xsl"
    href"library.xsl"?gt

13
An Example
  • ltxsltemplate match"/Recipe"gt indicates that
    this template is to be applied when a ltRecipegt
    element is encountered at the input.
  • ltxslvalue-of select"Name"/gt instructs the XSL
    processor to go get the text contained in the sub
    element ltNamegt.
  • ltxslapply-templatesgt command, which tells the
    XSL processor to apply all the other templates in
    the file to the input.

14
Applications to Database
  • Represent database schema as a set of DOM
    objects.
  • Write the schema out as XML.
  • Use XSL to format the XML as HTML and you've got
    a complete, browseable schema reference that's
    always up to date.
Write a Comment
User Comments (0)
About PowerShow.com