XML - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

XML

Description:

Well Formed Documents. Attributes must be placed in the start tag ... title Well Formed Documents /TITLE ... to ensure that your document is well formed ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 23
Provided by: Horn82
Category:
Tags: xml | wellformed

less

Transcript and Presenter's Notes

Title: XML


1
XML
  • Extensible Markup Language
  • 11/29/2004

2
What is XML?
  • Not a markup language
  • Set of tools used to create new markup languages
  • Metalanguage
  • Open standard
  • Plain text file

3
Fundamentals of Markup Languages
  • A set of rules that define the layout, format or
    structure of text within a document
  • Apply markup instructions
  • Document is formed (processed)
  • SGML
  • Tex
  • HTML

4
HTML Limitations
  • Elements are used primarily for defining
    presentation and formatting styles
  • Has a limited number of elements
  • Lacks flexibly and extensibility
  • Searching the content of HTML documents produces
    poor results

5
Benefits of XML
  • Allows the data to be self-describing, as opposed
    to being limited by a predefined set of elements
  • You can provide rules for XML elements that limit
    the type of data than an element can contain
  • Legs you create custom data structures for
    industry specific needs

6
Benefits of XML
  • Because XML describes data, the data can be
    displayed in any number of ways by applying
    different presentation styles
  • Can be used to interchange data between
    proprietary formats and between different
    databases
  • Has robust and reliable data searching
    capabilities

7
Separating Data from Presentation
  • XML elements are used to describe the data, not
    the format
  • ltphone numgt245 5585lt/phone numgt
  • Style sheet to describe now to display phone
    numbers

8
XML vs. HTML
  • XML is not dependent on a single document type or
    set of markup elements, HTML is
  • HTML specification defines a finite set of
    elements, XML allows you to define elements that
    best fit your document or data
  • XML separates presentation from data

9
XML vs. HTML
  • Browsers are fairly forgiving of HTML. XML is
    extremely strict about correct syntax
  • HTML tags are not case-sensitive. XML is.
  • HTML is web oriented. XML can be used for any
    kind of data

10
XHTML
  • The best of both worlds
  • Merges XML with HTML
  • Allows a quick transition to XML syntax for
    existing HTML documents
  • XHTML tags are all lower case
  • All tags have a start and end tag

11
XML Example 1
  • Difference between HTML and XML
  • Expand/collapse
  • Hierarchical structure
  • Parent/child
  • Nesting of elements
  • Root Element
  • Job-Posting
  • Create a set of tags to define the data for a job
    posting

12
Components of XML Documents
  • Declaration tells the browser it is a XML
    document
  • lt?xml version1.0 ?gt
  • XML elements
  • Start tag ltelement namegt
  • Content
  • End tag lt/element namegt

13
XML Elements
  • Root element topmost or outermost node
  • Type of object you wish to represent
  • Parent/child/sibling elements
  • Empty elements
  • ltbr /gt ltimg /gt ltp /gt

14
XML Attributes
  • Pieces of information that help to describe or
    label XML elements
  • Name-value pairs
  • ltmovie sourcehttp//whatevergtlt/moviegt
  • ltmoviegt
  • ltsourcegthttp//whatever lt/sourcegt
  • lt/moviegt
  • Elements vs Attributes
  • Use elements when the data contains children
  • Attributes cannot have child elements
  • When the data contain a large amount of text use
    elements

15
XML Entities
  • Used as placeholders for content in an XML
    document
  • General entities
  • Character special characters
  • Content common block of content
  • Unparsed binary or other nontext data
  • Parameter entities
  • Cover later

16
Character Entities
  • lt?xml version1.0 ?gt
  • ltequationgt 50 lt 100 lt/equationgt
  • ltequationgt 50 lt 100 lt/equationgt
  • Others
  • -- apos
  • -- quote
  • gt -- gt

17
Content Entities
  • Are defined within the internal subset of a DTD
    (document type definition)
  • Are defined within a document after the XML
    declaration and before the start of the root
    element
  • lt!ENTITY state New Yorkgt
  • ltaddressgt
  • ltstategt state lt/stategt
  • lt/addressgt

18
External Entities
  • Used when information will be used in multiple
    XML files
  • See business.xml description.xml

19
Unparsed Entities
  • Data that is not text
  • lt!ENTITY picture SYSTEM sunset.gif NDATA GIFgt
  • XML Comments
  • lt!-- this is a comment --gt

20
Well Formed Documents
  • XML document that adheres to XML syntax is said
    to be well formed
  • All XML Documents must contain one and only one
    root element
  • All elements must have a start and end tag
  • Elements must be nested properly and cannot
    overlap
  • All attributes must have a value and it must be
    enclosed in quotes

21
Well Formed Documents
  • Attributes must be placed in the start tag
  • No attribute can appear more than once
  • Element names are case sensitive
  • lttitlegt Well Formed Documents lt/TITLEgt
  • Element names can start with letters or an
    underscore and can contain only letters, numbers,
    hyphens, periods and underscores

22
XML Parsers
  • program that checks your XML document to ensure
    that your document is well formed
  • Nonvalidating looks for syntax errors
  • Validating checks your document against a DTD
    or schema
  • Think of it as a complier
Write a Comment
User Comments (0)
About PowerShow.com