extensible Markup Language

eXtensible Markup Language Jesús Ibáñez, Toni Navarrete, Rocío García, Josep Blat Universitat Pompeu Fabra eXtensible Markup Language ? New Internet...
Author: Ashlee Morgan
6 downloads 0 Views 2MB Size
eXtensible Markup Language Jesús Ibáñez, Toni Navarrete, Rocío García, Josep Blat Universitat Pompeu Fabra

eXtensible Markup Language ? New

Internet mark-up metalanguage ? Previously: SGML, HTML ? Extensibility, structure and validation ? SGML adaptation for WWW

1

eXtensible Markup Language ? Defined

as standard by W3C (Generic SGML Editorial Review Board XML Working Group) ? XML != HTML++ ; XML == SGML-? XML, DTD (Document Type Definition) and XSL (eXtensible Style Language)

Main Characteristics ? ? ?

Describing semantically document content Uncoupling semantic description from presentation Allowing each user community to define its own labels, for instance:

, , , ,

2

XML Example (without DTD) Hello world! Stop it, I’m getting off!

Example with DTD (1) ]>

3

Example with DTD (2) My Life and Times Paul McCartney July, 1998 94303-1202143892 McMillan Publishing

DTDs ? ?

Allow to create new sets of labels Examples: ? ? ? ? ?

(1 or more) (0 or more) ? (0 or 1) , (sequence) | (option) Attributes: • (CDATA means Character Data) • (optional) • (required)

4

DTDs ]>

DTDs


< Disk> < Title>Brother in arms < Group>Dire Straits < Song> < titleS>Money for nothing < Duration>5:20 < Song> So far away 4:10 ... On every street Dire Straits ...

5

DTDs ]>

DTDs Brother in arms Dire Straits Money for nothing 5:20 ... Cien años de soledad Gabriel García Márquez ... La ciudad de los prodigios Eduardo Mendoza ...

6

DTDs ]> Toni Navarrete Terrasa Rambla 32

Well formed versus valid ? Well

formed: XML syntax compliant ? Valid: the content conforms to the rules of the associated DTD. ? Completeness,

good format and attribute values of the XML data is ensured. ? An XML document without DTD can be well formed but, of course, cannot be valid.

7

DTD limitations; Schemas and Namespaces Difficult to read (and parse) ? Not extensible ? No support for datatypes and inheritance ? Solution: namespaces and schemas can integrate different sources ? Re-use and better structure are supported ? XML syntax: improved readability and processing ?

XML Schemas XML Schemas to define the structure of XML documents (same as DTDs BUT in XML syntax) ? Same parser to validate, tools for dynamic creation ? Use of Namespaces ? Improved data type definition (41 instead of 10, plus user-defined) ? Object orientation allows new types by extension or restriction of previous ones ? Validation (a document wrt a scheme, a scheme wrt scheme of schemes)

?

8

Schema definition ?

An XML document whose root is “schema” and within it elements and attributes are defined:

?

A DTD would be like:

?

In the cardinality definition we replace the DTD symbols ?, *, +

Building blocks: Complex types ?

The element book is composite, thus we define it as a complex type:



11

Alternative: naming complex types ? We

could also define a complex type with a name:



12

Building blocks: empty elements ?

Elements such as HTML tags or are empty

?

Empty has to be declared as an implicit complex type

A level upwards ... ? Let us define “bookshop”: ...

15

Namespaces ? ? ?

An XML Namespace is a collection of names (of elements and attributes) identified by an URI Namespaces are a very flexible tool. The re-use of schemas, names, mixing them is promoted. For instance we could use elements from two name spaces

< BOOKS>

Example (and 4) ? In

the instantiated document: