XML Schemas: Understanding XML Data Types and Structure, Slides of Semantics of Programming Languages

An overview of xml schemas, their purpose, and the benefits they offer in defining elements, attributes, and data types for xml documents. It covers the syntax and structure of xml schemas, their support for data types, and their extensibility. The document also includes examples of xml schema files and their corresponding xml instance documents.

Typology: Slides

2011/2012

Uploaded on 07/11/2012

dharuna
dharuna 🇮🇳

4.7

(6)

85 documents

1 / 92

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
XML Schema
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
pf58
pf59
pf5a
pf5b
pf5c

Partial preview of the text

Download XML Schemas: Understanding XML Data Types and Structure and more Slides Semantics of Programming Languages in PDF only on Docsity!

 XML Schema

DTD Problems

 Attribute Value

 It is possible to specify all the values an attribute can

have or allow it to have any value.

 It is not possible to perform type checking on an

attribute’s value so you cannot specify an attributes

value is a integer or float…

 Does not follow xml syntax

DTD Problems

 DTDs are written in their own peculiar

syntax

 In contrast, XML Schemas use regular XML

syntax.

 As a result, any tool that can read or

process an XML document, can read and

process an XML Schema.

 Schemas have a notion of named types,

which are akin to classes; and element

declarations, which are akin to object

instances.

 Schemas also support basic inheritance

concepts, which enable you to derive new

types from existing base types.

 Schemas provide full support for XML

Namespaces.

 This is critically important, as it enables a

single instance document to reference two

or more schemas, each of which is defined

in a separate namespace.

8

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

10

XML Schemas

 XML Schemas Support Data Types

 One of their greatest strengths

 With support for data types:

 It is easier to describe allowable document content  It is easier to validate the correctness of data  It is easier to work with data from a database  It is easier to define data facets (restrictions on data)  It is easier to define data patterns (data formats)  It is easier to convert data between different data types

11

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

13

XML Schemas

Well-Formed is not Enough

 A well-formed XML document is a document that conforms to the XML syntax rules, like:

  1. it must begin with the XML declaration
  2. it must have one unique root element
  3. start-tags must have matching end-tags
  4. elements are case sensitive
  5. all elements must be closed
  6. all elements must be properly nested
  7. all attribute values must be quoted
  8. entities must be used for special characters

14

XML Schemas

 Even if documents are well-formed they can still

contain errors, and those errors can have serious

consequences.

 The purpose of a schema is to define a class of XML documents

 and so the term "instance document" is often used to describe an XML document that conforms to a particular schema

17

XML Schemas

Simple XML Document "note.xml":

Tove Jani Reminder Don't forget me this weekend!

Start with the standard XML declaration followed by the xs:schema element that defines a schema

**

In the schema above we use the standard namespace (xs), and the URI associated with this namespace is the Schema language definition, which has the standard value of http://www.w3.org/2001/XMLSchema.

The note element is a complex type because it contains other elements. The other elements (to, from,

heading, body) are simple types because they do not contain other elements.

Tove Jani Reminder Don't forget me this weekend!