XML 2 - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

XML 2

Description:

Document model defines the vocabulary and grammar rules ... Critical If you wish to share your document with other people. 5. Overview of DTD. Internal DTD ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 17
Provided by: Horn82
Category:
Tags: xml

less

Transcript and Presenter's Notes

Title: XML 2


1
XML 2
  • Document Type Definition
  • 12/01/2004

2
Using a Document Model
  • Correct syntax rules ? well-formed doc
  • Add rules to XML document to enforce structure
  • DTD document type definition
  • XML schema
  • Document model defines the vocabulary and grammar
    rules
  • Docs that correctly follow the rules are said to
    be valid.

3
Document Model
  • Define the elements your document can contain
  • Define the order in which the elements appear
  • Require that certain elements appear
  • Define the allowed number of occurrences of a
    given element
  • Define the type of data an element can contain
  • Define child elements for a given element
  • Define the attributes for each of your elements
  • Assign constraints to the attribute values

4
Document Model
  • Are not required by XML and may not be needed
  • Critical If you wish to share your document with
    other people

5
Overview of DTD
  • Internal DTD
  • Provided as part of the document
  • External DTD
  • Provided as an external file
  • Syntax and rules for defining the pieces of a DTD
    are the same

6
Element Declarations
  • The DTD must declare all elements used in the
    document
  • Element declaration
  • lt!Element element_name (content model)gt
  • lt?xml version 1.0 standaloneyes?gt
  • lt!DOCTYPE email
  • lt!ELEMENT email (PCDTA)gt
  • gt
  • ltemailgt
  • This is my e-mail message
  • lt/emailgt

7
Content Types for Elements
  • Text
  • lt!ELMENT invoice (PCDATA) gt
  • Elements
  • lt!ELMENT invoice (element_name) gt
  • Mixed Content
  • lt!ELEMENT invoice (PCDATA, element_name) gt
  • Empty
  • lt!ELMENT invoice empty gt
  • Any
  • lt!ELMENT invoice ANY gt
  • See next page

8
Special Character Notation
  • message?
  • The element occurs no more than once
  • message
  • The element can occur zero or more times
  • message
  • The element must occur at least once
  • (xyz)
  • Or operator, must take on a value listed

9
Attribute Declarations
  • Give you control over the values of attributes
  • lt!ATTLIST element_name
  • Attribute_name1 data_type default_value
  • Attribute_name2 data_type default_value
  • Default Values
  • FIXED must match the value supplied
  • REQUIRED value must be supplied
  • IMPLIED optional

10
Data Types for Attributes
  • CDATA character data
  • ID Unique identifier
  • Enumerated List list of all possible values
    (separated by the pipe char)
  • See next page

11
External DTD
  • Reference to an external file
  • lt?xml version1.0 standaloneno ?gt
  • lt!DOCTYPE emails SYSTEM emails.dtd gt
  • lt!DOCTYPE emails SYSTEM http//www.acme.com/emails
    .dtd gt
  • Syntax is exactly the same as before
  • Public DTD
  • lt!DOCTYPE emails PUBLIC //W3C//DTD XHTML 1.0
    STRICT//EN DTD/HTTP/www.w3c.org/DTD/xhtmll-stric
    t.dtdgt
  • DTD for xhmtl.

12
XML Schemas
  • An alternative to DTD that offers a more powerful
    way to describe XML components
  • Allows you to match string patterns within the
    content
  • Provides more data types
  • Boolean, numbers, dates, times
  • Allows you to define your own data type
  • Supports namespaces

13
Creating the Presentation
  • Separating the content allows you to change the
    presentation without changing the content
  • You can use this method to format for different
    clients
  • Use a different style sheet for each client

14
Cascading Style Sheets
  • They work the same way in XML as HTML
  • Contains rules that tell the browser how do
    display certain elements
  • Style information resides in an external file
    that usually ends with .css
  • See next page

15
Problems with CSS
  • Not a programming language
  • When displayed, elements must appear in the same
    order in which they appear in the XML document
  • Cant perform mathematical computations
  • Cant make logical decisions
  • Doesnt support relationships between siblings

16
XSL Extensible Stylesheet Language
  • Addresses the limitations of CSS
  • XSL stylesheets will provide presentation options
    for a much wider range of output formats
    including voice and print
  • Provides much greater control and flexibility
  • Has a built in programming language
  • Much harder to learn than CSS
Write a Comment
User Comments (0)
About PowerShow.com