Skip to content

Handling and Storage of XML Documents

Goals
  • Recognize the need for converting XML documents.
  • Determine the areas of application.
  • Analyse the involved technologies and how they work.
  • Explain the specific syntax used in converting and adapting XML documents.
  • Create conversion specifications.
  • Identify and characterize specific tools related to converting XML documents.
  • Perform conversions in different output formats.
  • Document and debug conversion specifications.
  • Identify the main methods for storing information in XML documents.
  • Recognize the disadvantages of storing information in XML format.
  • Use relational database management systems for storing XML-formatted information.
  • Use specific techniques to create XML documents from information stored in relational databases.
  • Identify the characteristics of native XML database management systems.
  • Use techniques to manage information stored in native XML databases.
  • Identify languages and tools for processing and storing information and incorporating it into XML documents.
  • Identify the main methods of storing information used in XML documents.
  • Identify the drawbacks of storing information in XML format.
  • Use relational database management systems in the storage of information in XML format.
  • Use specific techniques to create XML documents from information stored in relational databases.
  • Identify the characteristics of native XML database management systems.
  • Use techniques to manage information stored in native XML databases.
  • Identify languages and tools for processing and storing information and including it in XML documents.
Assessment criteria
  1. The need for converting XML documents has been recognized.
  2. The areas of application have been established.
  3. The involved technologies have been analysed and their mode of operation has been understood.
  4. The specific syntax used in converting and adapting XML documents has been described.
  5. Conversion specifications have been created.
  6. Specific tools related to converting XML documents have been identified and characterized.
  7. Conversions have been performed in different output formats.
  8. Conversion specifications have been documented and debugged.
  9. The main methods for storing information in XML documents have been identified.
  10. The disadvantages of storing information in XML format have been recognized.
  11. Efficient storage technologies for information have been established based on their characteristics.
  12. Relational database management systems have been used for storing XML-formatted information.
  13. Specific techniques have been used to create XML documents from information stored in relational databases.
  14. The characteristics of native XML database management systems have been identified.
  15. Analysed systems and native XML database systems have been installed.
  16. Techniques have been used to manage information stored in native XML databases.
  17. Languages and tools for processing and storing information and incorporating it into XML documents have been identified.

In this lesson, we will learn how to handle XML documents. We will learn how to change XML documents into different kinds of documents or how to rearrange them. We will also learn how to store XML data in databases, like in a relational database system or a native database.

XML is mainly used for storing and exchanging information, but sometimes it needs to be transformed so that it can be read by people or specific programs more easily. There are 3 ways to do this:

  1. Create a program that converts the XML into a more readable format,
  2. Use CSS to change the way the document is displayed,
  3. Change the document into a format that is designed for viewing, like PDF, HTML, XHTML, etc.

In the following example an CSS file are applied in order to change the way an XML document is shown in a browser:

<?xml version="1.0" ?>
<?xml-stylesheet href="sample.css"?>
<professor>
  <nom>Marcel</nom>
  <cognom>Garcia</cognom>
  <departament>Departament d'Informàtica</departament>
  <carrecs>
    <carrec>Cap de Departament</carrec>
    <carrec>Tutor</carrec>
  </carrecs>
</professor>
professor { 
  padding: 30px;
  margin: 30px;
  border: 4px black solid;
  width: 40%; 
}

nom,cognom { 
  font-size: 30px; 
}

departament { 
  padding-top: 20px; 
  display:block;
  font-weight:bold;
}

carrec { 
  font-style: italic;
  padding-left:10px; 
}

carrec:after { 
  content:","; 
}

The resulting page will be similar to:

To make XML more readable for humans, CSS can be used. But CSS has some limitations:

  • We can't change the order of information
  • It's difficult to show some attributes
  • Can't do any new calculations or data processing
  • Can't format data for printing easily.

CSS only changes how the document looks, not what the document is. If we want to change the document, CSS is not helpful.

Conversion and adaptation of XML documents

The W3C created a generalization of CSS style sheets called XSL (eXtensible Stylesheet Language). XSL is a language used to format and transform XML documents into other formats, like HTML or PDF, to make them easier to read. XSL is like a set of instructions for the computer to follow to change an XML document into a new, readable format. The W3C has developed three languages:

  • XPath: A language for referring to parts of an XML document.
  • XSLT (XSL Transformation, ie XSL Transformations): a language for transforming XML documents.
  • XSL-FO (XSL Formatting Objects): a language for specifying the format of an XML document and converting it to PDF or PostScript.

bg 90%

Bibliography, webography and credits