Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

XML Schemas: Definition, Features, and Data Types, Slides of Semantics of Programming Languages

An overview of xml schemas, their role as successors to dtds, and their features such as support for data types, extensibility, and use of xml syntax. It also covers the structure of xml schemas and the definition of element and attribute types, as well as data types and their extensions.

Typology: Slides

2011/2012

Uploaded on 07/11/2012

dharuna
dharuna 🇮🇳

4.7

(6)

87 documents

1 / 87

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 4
DTD Review
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57

Partial preview of the text

Download XML Schemas: Definition, Features, and Data Types and more Slides Semantics of Programming Languages in PDF only on Docsity!

Lecture 4

 DTD Review

Review DTD

****

A head element

contains (in that order):

a from element

at least one to element

zero or more cc

elements

a subject element

Review DTD

****

A body element contains

a text element, possibly

followed by a number

of attachment elements.

Review DTD

The encoding attribute

of an attachment

element must have

either the

value “mime” or

“binhex”,

the former being the

default value.

7

XML Schemas

 XML Schemas are the Successors of DTDs

 XML Schemas will be used in most Web applications

as a replacement for DTDs. Here are some reasons:

 XML Schemas are extensible to future additions

 XML Schemas are richer and more powerful than DTDs

 XML Schemas are written in XML

 XML Schemas support data types

 XML Schemas support namespaces

8

XML Schema?

 The purpose of an XML Schema is to define the legal

building blocks of an XML document, just like a DTD.

 An XML Schema:

 defines elements that can appear in a document

 defines attributes that can appear in a document

 defines which elements are child elements

 defines the order of child elements

 defines the number of child elements

 defines whether an element is empty or can include text

 defines data types for elements and attributes

 defines default and fixed values for elements and attributes

10

XML Schemas

XML Schemas use XML Syntax

 Schemas are XML documents

 Benefits of Schemas as XML docs

 You don't have to learn a new language

 You can use your XML editor to edit your Schema files

 You can use your XML parser to parse your Schema files

 You can manipulate your Schema with the XML DOM

 You can transform your Schema with XSLT

11

XML Schemas

XML Schemas are Extensible

 XML Schemas are extensible, because XML is

extensible

 With an extensible Schema definition you can:

 Reuse your Schema in other Schemas

 Create your own data types derived from the standard

types

 Reference multiple schemas in the same document

13

XML Schemas

 Even if documents are well-formed they can

still contain errors, and those errors can have

serious consequences.

 Think of the following situation: you order 5

gross of laser printers, instead of 5 laser printers. With XML Schemas, most of these

errors can be caught by your validating

software.

14

XML Schemas

 Simple XML Document "note.xml":

Tove

Jani

Reminder

Don't forget me this

weekend!

16

XML Schemas



<xs:element name="note"> <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>

<element name="firstname" type="string“ minOccurs="0“ maxOccurs="unbounded"/>

Another Example

19

XML Schemas

 This XML document has a reference to a

Schema:

<note xmlns= “http://www.w3schools.com” xmlns:xsi="http://www.w3.org/2001/XMLSchema instance“ xsi:schemaLocation="http://www.w3schools.com note.xsd">

Tove Jani Reminder

Don'tforget me this weekend!

20

XML Schemas

The Element

 The element is the root element of

every XML Schema:

<xs:schema>

</xs:schema>