Web technologies/2014-2015/Laboratory 3

XML
XML is derived from SGML (Standard Generalized Markup Language - ISO 8879) and has a plain text format designed to be human readable (although a binary version is under consideration by W3C). There are two versions 1.0 (5th edition) and 1.1 (2nd edition). The former one is widely used and still recommended for usage.

In the last years it has started to play an important role in the exchange of data on the Web (Web services, SOAP protocol).

The W3C specifies both the lexical grammar and the parsing prerequisites for it. An XML document needs to have two main characteristics:
 * well-formed: in general every XML document can be represented as a tree with only one root element (or document element), and each start-tag must have a corresponding end-tag. Additionally, the root element can be proceeded by an XML declaration which specifies the version of XML being used, the character encoding and optional external dependencies. Each element can contain several attributes with values enclosed in quotes (either double or single).


 * valid: it must be compliant with a particular XML schema or DTD (Document Type Definition).

Example of an XML:

Example of DTD (for the previous XML):

Supposing we call this DTD queue.dtd we validate an XML against it by placing:

under:

Example of XML Schema (for the previous XML):

Supposing we call this XML Schema file queue.xsd we validate the XML document by placing:

under:

Links:


 * XML specification -- W3C
 * XML tutorial -- W3Schools
 * XML Schema -- Wikipedia
 * DTD -- Wikipedia

XSL
XSL (Extensible Stylesheet Language) is used to refer to a family of languages used for transforming and rendering XML documents.

It is nowadays used to express many things including:


 * XSLT: language for transforming of the XML document
 * XSL-PO: language for visually editing the document (generating PDFs)
 * XPath: non-XML language used to address XML elements (or parts of it). Used mainly from inside XSLT.

For example given the previous XML the following XPath query:

selects all the links in the document.

Links:


 * XSL -- Wikipedia
 * Xpath -- Wikipedia

XSLT
XSLT (XSL Transformations) is used for transforming XML documents. As far as we are concerned it can be used to produce HTML documents out of XML ones

Example:

Supposing we call this XSLT file queue.xsl we transform the previous XML document by placing:

under:

We obtain the following HTML document:

Links:


 * XSLT -- Wikipedia
 * XSL -- W3C

Exercises
Create a database like XML (like the one in the example from above) file with:
 * at least 10 record like elements (for example the link element);
 * each record should have at least 4 attributes (for example the name or uri);
 * each record should have at least 3 sub-records (for example I could extend the link elements to also contain multiple comment elements);

Create an XSLT file -- that is used by the previous XML file -- to transform the database into a HTML file. Each information available in the XML file should be presented in the generated HTML. Online editor

The XML should be validated against both a DTD and XML Schema (they need to be created). For easy verification you can try this Online Schema validator.

Gabriel Iuhasz, 2018-10-08, [mailto:iuhasz.gabriel@e-uvt.ro iuhasz.gabriel@e-uvt.ro]