XML Introduction




XML, Extensible Markup Language, is a simlified subset of SGML, Standard Generalized Markup Language. XML coded files are extensively used to transport information between applications on he Internet.

The project.xml file contains a high level 'hierachical structure' describing of a project.

'Project' contains 'Site(s)' contains 'Building(s)' contains 'Storey(s)' contains 'Space(s).

The XML files must be well-formed (e.g. always start and end-tags). A valid document should also have a Document Type Definition, DTD, and follow the grammar established by the DTD.

We can now display the project.xml file by adding information about how the different elements in the file shall be presented in the Internet-browser. This can be done in two ways

We now create two new 'project.xml' files where we in the headers add a link to a CSS file <?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="project_overall.css" ?>
thus enabling two views to the same project.xml information


By using XSL documents (which by the way are XML documents) it is possible to format the output, add new elements and choose what elements that are to be included in the generated document.

In this short example the 'project.xml' file has the header

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="a_project_overall.xsl" ?>
and is thus referencing the file a_project_overall.xsl to give the output you find when calling a_project_overall_xsl.xml


The DTD forms the vocabulary of the XML document can be used to control that a XML document contains defined elements, and the structure of them (including e.g. if they can be repeated such as the Space element in our 'project.xml' file).

The XSL document can except format output to any desired document type also be used to transform XML documents to any desired structure (and thus eventually also defining new DTDs). Looking at the figure above we can envision how different applications within or between companies can use XML documents to exchange structured and valid data.

Further reading




©Per Christiansson, 6.4.2001 [5.4.2001]