Displaying XML

XSL (eXtensible Stylesheet Language)

HTML pages uses predefined tags, and the meaning of these tags is well understood: <p> means a paragraph and <h1> means a header, and the browser knows how to display these pages.

With XML we can use any tags we want, and the meaning of these tags are not automatically understood by the browser: <table> could mean a HTML table or maybe a piece of furniture. Because of the nature of XML, there is no standard way to display an XML document.

In order to display XML documents, it is necessary to have a mechanism to describe how the document should be displayed. One of these mechanisms is Cascading Style Sheets (CSS), but XSL (eXtensible Stylesheet Language) is the preferred style sheet language of XML, and XSL is far more sophisticated than the CSS  used by HTML.

XSL - What can it do?

XSL can be used to define how an XML file should be displayed by transforming the XML file into a format that is recognizable to a browser. One such format is HTML. Normally XSL does this by transforming each XML element into an HTML element.

XSL can also add completely new elements into the output file, or remove elements. It can rearrange and sort the elements, test and make decisions about which elements to display, and a lot more.

Below is a fraction of the XML file, with an added XSL reference.
The second line, <?xml-stylesheet type="text/xsl" href="simple.xsl"?>, links the XML file to the XSL file:
CSS (Cascading Style Sheets)

Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.

Below is a fraction of the XML file, with an added CSS style sheet reference. The second line,
<?xml-stylesheet type="text/css" href="cd_catalog.css"?>, links the XML file to the CSS file:
CSS & XSL

 
 CSSXSL
  Can be used with HTMLYesNo
  Can be used with XML?YesYes
  Transformation language?NoYes
  SyntaxCSSXML

Top