CM322: Advanced Web Technologies - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

CM322: Advanced Web Technologies

Description:

... (name, email, phone) person name ... prefix name by '%' in declaration !ENTITY % common 'name | address | phone' ... Namespace is referred to by a prefix ... – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 28
Provided by: Lesli72
Category:

less

Transcript and Presenter's Notes

Title: CM322: Advanced Web Technologies


1
CM322 Advanced Web Technologies
Verifying XML with DTDs Les Carr IAM Research
University of Southampton
2
Session 2
  • XML Verification
  • DTDs and Valid XML
  • XML Namespaces
  • Example XML Vocabulary SMIL

3
XML Verification
  • Well-formed XML document
  • conforms to basic XML syntax
  • contains only built-in character entities
  • Validated XML document
  • conforms to the grammar of a specific data type
  • uses any predeclared entities
  • specified by Document Type Declaration

4
XML Type Declaration
  • A DTD specifies the grammar for a simple data
    structure
  • ordering
  • repeatability
  • labelling
  • vocabulary / schema / ontology
  • DTD defined in an external entity
  • overridden by local definitions

5
XML Type Declaration
  • Element declarations
  • lt!ELEMENT para contents of paragt
  • just text
  • lt!ELEMENT para (PCDATA)gt
  • ltparagtHere is some text. No italics
  • allowed.lt/paragt

6
XML Type Declaration
  • just a sequence of elements
  • lt!ELEMENT person (name, email, phone)gt
  • ...
  • ltpersongt
  • ltnamegtLeslt/namegt
  • ltemailgtlac_at_ecs.soton.ac.uklt/emailgt
  • ltphonegt44 23 8067 5145lt/phonegt
  • lt/persongt

7
XML Type Declaration
  • just a choice of elements
  • lt!ELEMENT person (name email staffno)gt
  • ...
  • ltpersongt
  • ltnamegtLeslt/namegt
  • lt/persongt

8
XML Type Declaration
  • element repetition can be controlled
  • ? optional
  • required and repeatable
  • optional and repeatable
  • element can be grouped with ( )
  • lt!ELEMENT customer (
  • ((surname, initials) custid),
  • purchases , visits )gt

9
XML Type Declaration
  • mixed content (text interspersed with elements)
  • lt!ELEMENT para
  • (PCDATA italic bold
  • link image)
  • -- optional repeatable choice group
  • with PCDATA as first item --
  • gt

10
XML Type Declaration
  • no content
  • lt!ELEMENT image EMPTY gt
  • any content
  • lt!ELEMENT buffer ANY gt

11
XML Type Declaration
  • Attribute declarations
  • lt!ATTLIST para
  • security security attribute info
  • author author attribute info
  • id id attribute info gt
  • Each attribute has a type and default
  • lt!ATTLIST para
  • security (privatepublic) "public"
  • author CDATA IMPLIED
  • id ID REQUIRED gt

12
XML Type Declaration
  • Attribute types
  • CDATA, NMTOKEN(S), ENTITY(-IES), ID, IDREF(S),
    enumeration
  • Default values
  • string
  • token
  • IMPLIED
  • REQUIRED
  • FIXED (must precede default)

13
XML Entities
  • Entities can be strings
  • lt!ENTITY cc "Clifford Chance"gt
  • Entities can be external files
  • Entities can be binary data formats
  • lt!ENTITY pic1 SYSTEM "me.gif" NDATA gifgt
  • lt!NOTATION gif SYSTEM "gifviewer.exe"gt

lt!ENTITY chap1 SYSTEM "../src/ch1.xml"gt lt!ENTITY
disc PUBLIC "-//CC//Standard Disclaimer//EN"
"/lib/stddisc.xml"gt
14
XML Entities
  • Entities must be declared in a DTD
  • lt!DOCTYPE Book
  • lt!ENTITY chap1 SYSTEM "ch1.xml"gt
  • gt
  • Entities can be used in text or attributes
  • ltbookgtchap1 chap2 chap3lt/bookgt
  • ltpara title"This amp That"/gt
  • ltimage src"pic1" alignleft/gt

15
XML Entities
  • Parameter entities provide macro expansion within
    a DTD
  • use '' instead of ''
  • prefix name by '' in declaration
  • lt!ENTITY common "name address phone"gt
  • lt!ELEMENT stuff ( common email )

16
XML Namespaces
  • Namespaces allow different designers to create
    different elements and attribute names for
    different purposes.
  • e.g. MS catalogue
  • lttablegt element for screen layout
  • lttablegt element for describing furniture

17
XML Namespaces
  • Namespace is identified with a URL
  • Namespace is referred to by a prefix
  • Any name from that namespace is referred to by a
    qualified name
  • prefixname
  • e.g. lthtmltablegt
  • or ltpara MoDclassificationrestrictedgt

18
XML Namespaces
  • Namespace is defined
  • at the document root
  • by the xmlns attribute prefix
  • ltcatalog xmlnshtml"http//www.w3c.org/TR/REC-htm
    l40"gt
  • lthtmltablegt
  • lttable materialpinegtltpricegt120lt/pricegtlt/tablegt
  • ltchair materialpinegtltpricegt34lt/pricegtlt/chairgt
  • lt/htmltablegt
  • lt/cataloggt

19
SMIL
  • W3C Standard for Synchronised Multimedia
  • XML format
  • regions
  • sequences
  • parallels
  • audio, video
  • pictures

20
SMIL
  • ltsmilgt
  • ltbodygt
  • ltseq id"Herengracht_Stroll"gt
  • ltimg id"map" src"map.gif" dur"3s"/gt
  • ltimg id"hg168" src"h168.gif" dur"3s"/gt
  • ltimg id"hg218" src"h218.gif" dur"3s"/gt
  • ltimg id"hg284" src"h284.gif" dur"3s"/gt
  • lttext type"text/plain" id"Credits"
  • src"dataThanks20to..." dur"indefinite"/gt
  • lt/seqgt
  • lt/bodygt
  • lt/smilgt

21
SMIL
  • Vocabulary
  • regions are spaces on the display device
  • seqs are sequential orderings of
  • pictures, sounds, videos, text
  • all of which appear one after the other
  • pars are parallel orderings of
  • pictures, sounds, videos, text
  • all of which appear at the same time

22
SMIL
  • Constraints
  • each content item must appear in a region
  • each picture, video etc is assigned a duration
  • seq duration is sum of media durations
  • finishes when last element has completed
  • par duration is max of media durations
  • finishes when longest element has completed

23
SMIL
  • Vocabulary gets quite complex!
  • DTD has to reflect this

24
References
  • XML Applicationshttp//www.oasis-open.org/cover/
    xml.htmlapplications
  • XML Namespaces by Examplehttp//www.xml.com/xml/p
    ub/1999/01/namespaces.html
  • SMILhttp//www.w3.org/AudioVideo

25
Exercise 1
  • The simple XML file book.xml has a DTD in
    books.dtd
  • Use the validator and the DTD to help correct the
    errors in badbooks.xml

26
Exercise 2
  • Write a DTD for the well-formed XML document you
    created in the previous session.
  • Use validate.html to check it in Explorer as
  • an external entity
  • an internal subset

27
Exercise 3
  • The files day1.xml, day2.xml and day3.xml
    describe three days out, giving various
    activities and breaks from an E-travel-agency.
  • Construct a DTD that can be used to validate all
    three files.
Write a Comment
User Comments (0)
About PowerShow.com