XML quick References - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

XML quick References

Description:

Title: Chapter 8 Author: cheng-chia chen Last modified by: chengchia Created Date: 11/30/1998 8:11:49 AM Document presentation format: A4 (210x297 ) – PowerPoint PPT presentation

Number of Views:66
Avg rating:3.0/5.0
Slides: 23
Provided by: ChengCh8
Category:
Tags: xml | quick | references

less

Transcript and Presenter's Notes

Title: XML quick References


1
XML quick References
2
XML Declaration
  • lt?xml version1.0 encodingBig5
    standaloneno ?gt

Version of the XML specification
no parsing affected by external DTD
subset yes not affected .
character encoding of the document, expressed
in Latin characters, e.g., UTF-8,
UTF-16, iso-8859-1,
3
Processing Instruction and comment
  • lt?PItarget other staff ?gt
  • lt!-- ??????? --gt

may contain any characters except the string --
4
Start tag with attribute ( in document) and end
tag
  • lttag attributeName attrbute-value gt
  • lt/taggt

name of the attribute
value or values of the attribute
Each element may contain zero or more attributes
name(or type) of the element
single or double quotes, or must match
start tag and end tag must match
5
EMPTY Element and CDATA Section
  • lttag name1value1 /gt
  • lttag name1value1 gtlt/taggt
  • ltCDATA any characters except CDATA-end
    gt

may contains any characters except the string
gt, characters in CDATA section will not be
parsed (preserve their literal meaning).
6
DOCTYPE Declaration
  • lt!DOCTYPE name External-ID
    declaration gt

name of the document type
the internal subset of the DTD (optional)
pointer to another file
Keyword DOCTYPE
DSO DSC Declaration
Declaration Subset Open
Subset Close
7
Internal Subset
  • lt?xml version1.0 ?gt
  • lt!DOCTYPE root
  • gt

DOCTYPE declaration include other declarations in
this internal subset
ltroot gt lt/rootgt
tags and text the document
8
External Subset
DOCTYPE declaration refers to a DTD in an
external subset. the other form PUBLIC
publicLiteral root.dtd
  • lt?xml version1.0 ?gt
  • lt!DOCTYPE root
  • SYSTEM rootURI.dtd
  • gt

ltroot gt lt/rootgt
a file named rootURI.dtd
tags and text the document
9
Internal and external Subsets
  • lt?xml version1.0 ?gt
  • lt!DOCTYPE root
  • SYSTEM root.dtd
  • gt

DOCTYPE declaration refers to an external subset
and includes an internal subset. DTD is sum of
both parts with internal subset taking
precedence when conflict.
an external file
ltroot gt lt/rootgt
tags and text the document
10
Conditional Section (DTD only) and External-ID
  • Include
  • lt!INCLUDE declarations gt
  • not-include
  • lt!IGNORE declarations gt
  • External-ID
  • SYSTEM URI or
  • PUBILC publicID URI

11
Parameter Entity(PE) Declarations
  • Internal Parameter Entity
  • lt!ENTITY name whatever Text gt

name of the entity
Keyword ENTITY
entity value (any literal)
percent sign show this is a PE.
single or double quotes, or must match
12
Parameter Entity Declarations
  • External Parameter Entity
  • lt!ENTITY name External-ID gt

name of the entity
Keyword ENTITY
pointer to a file, whose content is the entity
value
percent sign show this is a PE.
13
Notation declaration
  • lt!NOTATION1 name2 External-ID3 gt
  • Notes
  • keyword NOTATION
  • name of the notation (GIF, JPEG, PNG, etc) must
    be unique in DTD.
  • SYSTEM or PUBLIC identifer (PUBLIC does not
    require URI). EXs
  • SYSTEM my-gif.def
  • PUBLIC -//W3c PNG//PNGs public id //EN
    pngLoc.def

14
general Entity Declarations
  • Internal general Entity
  • lt!ENTITY name whatever Text
    gt

name of the entity
Keyword ENTITY
entity value (any literal)
single or double quotes, or must match
15
General Entity Declarations
  • External Unparsed General Entity
  • lt!ENTITY name External-ID NDATA name gt

Keyword ENTITY
name of the entity
SYSTEM or PUBLIC identifier, pointer to a
file, whose content is the entity value and will
not be parsed.
Keyword NDATA followed by notation name, which
must be defined
16
Predefined general entities
ENTITY Display As Character value
amp 3838
lt lt 3860
gt gt 62
apos 39
quot 34
17
Element Declaration
  • lt!ELEMENT name (content-model) gt
  • ANY Element keyword
  • lt!ELEMENT name ANY gt
  • may contain zero or more elements and text data
  • EMPTY ELEMENT keyword
  • lt!ELEMENT name EMPTYgt
  • must not contain any content

name of the element type (tag name)
keyword ELEMENT
formal definition of the elements allowed content
18
Special symbols used in content-model
  • Connectors
  • , gt then Follow with (in sequence)
  • gt Or Select (only) one from the group
  • Only one connector type per group -- no mixing!
  • Groupings
  • ( gt start c.m or grouping
  • ) gt end c.m. or grouping
  • Ex (A , B, C) (A (B,C) (C,D)) (A,B C)
    (A B, C)
  • Occurrence Indicators
  • ? gt optional, zero or one
  • gt zero or more
  • gt one or more
  • (no indicator) gt one and only one

19
PCDATA in content-model
  • pure text content
  • (PCDATA)
  • mixed (mode) with other elements
  • (PCDATA element-1 element-n )
  • Notes
  • PCDATA must be placed first
  • must always include the

20
Attribute Declaration
  • lt!ATTLIST1 element2 name3 declValue4
    default5 gt
  • Keyword ATTLIST
  • name of the associated element
  • name of the attribute
  • type of the attribute
  • keyword or default value
  • Reserved attributes
  • xmlspace (default preserve), preserve white
    space or use default
  • xmllang indicate langugae of element and that
    elements attributes and children.

21
Types of XML Attributes
  • CDATA Data character string (default if
    well-formed)
  • NMTOKEN Name Token
  • NMTOKENS one or more name tokens (spaces between)
  • ID Unique identifier for element
  • IDREF reference to ID on another element
  • IDREFS one or more IDREFs ( spaces between)
  • ENTITY Name of an unparsed entity
  • ENTITIES one or more names of entities
  • Enumerations
  • ( a b c ) list attribute values a,b,c (
    Or between)
  • NOTATION ( x y z) names of notation (
    Requires a list of values as well as the keyword.
    x,y,z must be declared elsewhere with NOTATION) .

22
Attribute Defaults
  • value
  • if omitted in document, assume this value.
  • REQUIRED
  • cannot be omitted in document for validity.
  • IMPLIED
  • optional. no default can be inferred application
    is free to handle as appropriate.
  • FIXED value
  • fixed value. if a different value appears in
    document, it is not valid.
Write a Comment
User Comments (0)
About PowerShow.com