Docsity

Structured Web Documents in XML-Bioinformatics Using Semantic Computing-Lecture Slides, Slides of Semantics of Programming Languages

Partial preview of the text

Download Structured Web Documents in XML-Bioinformatics Using Semantic Computing-Lecture Slides and more Slides Semantics of Programming Languages in PDF only on Docsity!

Structured Web Documents

in XML

2

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

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

5

 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

7

 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

8

Well-Formed is not Enough

 A well-formed XML document is a document that conforms to the XML syntax rules, like:  it must begin with the XML declaration  it must have one unique root element  start-tags must have matching end-tags  elements are case sensitive  all elements must be closed  all elements must be properly nested  all attribute values must be quoted  entities must be used for special characters

10

Simple XML Document "note.xml":

Tove

Jani

Reminder

Don't forget me this weekend!

11

An XML Schema

 XML Schema file called "note.xsd" that

defines the elements of the XML document

above ("note.xml"):

 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.

13

 This XML document has a reference to a

Schema:

Tove Jani Reminder Don'tforget me this weekend!

14

 The Element

 The element is the root element of every XML Schema:

... ...

16

 The following fragment:

xmlns:xs= “http://www.w3.org/2001/XMLSchema”

 Indicates that the elements and data types used in the

schema come from the “http://www.w3.org/2001/XMLSchema" namespace.

 It also specifies that the elements and data types that come

from the “http://www.w3.org/2001/XMLSchema" namespace should be prefixed with xs:

17

targetNamespace="http://www.w3schools.com"

 Indicates that the elements defined by this schema

(note, to, from, heading, body.) come from the

target namespace.

For example, target namespaces would enable us to

distinguish between the declaration for element in the

XML Schema language vocabulary, and a declaration

for element in a hypothetical chemistry language

vocabulary.

The former is part of the

http://www.w3.org/2001/XMLSchema target

namespace, and the latter is part of another target

namespace.

20

xmlns=“http://www.w3schools.com”

 Indicates the default namespace