Saturday 17 December 2011

How can an XML document be best presented?

XML itself does not specify lay-out of a document. It is just used to represent the data and structure them. Therefore XML does not present well. Hence a stylesheet is needed which attaches lay-out instructions to elements. There are two stylesheet languanges: Cascading Style Sheets (CSS) and eXtensible Style Language (XSL).

CSS pre-dates XML which is used for HTML, in fact developed alongside HTML. It supports enhanced presentation and easier editing.

h1{font-family:helvetica;font-size:16pt};
p{font-style:italic};

It is not formulated in XML so there is not much direct support for XML yet. However, all major browser directly displays XML + CSS, to some extent.

XSL is an XML application and in fact combination of three standards:
  • XSLT Transformation language
  • Xpath - used to identify parts of an XML document
  • XSL-FO - Formatting language
We can use either CSS or XSL with our XML document to be best presented.

No comments:

Post a Comment