About Stylesheets
Page Index
- What is an XSL stylesheet?
- Why do I need stylesheets?
- Do browsers support formatting via XSL stylesheets?
- How can I view an XML document in a web-browser?
- What is XHTML (Extensible Hyper Text Markup Language)?
What is an XSL stylesheet?
An XSL stylesheet contains a set of rules, which specify how a specific element in an XML document is to be presented.
Stylesheets define the layout of the document: they can specify which elements are to be displayed, and in what order. The rules can also specify the font to use, the size of the text, as well as spacing on the page and other display properties.
The use of a stylesheet does not change the original file, and this is one of its great assets. XML tags are typically used to mark the semantics of what is in a file, not its presentation. It is the stylesheet which takes that information and presents it in an appropriate format. Several presentation formats may in fact be used to display a single XML page, depending on the needs or preferences of the user.
XSL is the W3C recommended stylesheet standard. XSL Transformations can be used to transform an XML document into another XML document, into any plain text format, or even PDF and Word formats.
This part of the school is designed to be a Linguist's introduction to the use of stylesheets. For more tools for learning XSL, visit the following sites:
- W3Schools XSL tutorial: http://www.w3schools.com/xsl/default.asp
- Top XML XSL Tutorial: http://www.topxml.com/xsl/
- XSLT.com: http://www.xslt.com/
Why do I need stylesheets?
Stylesheets are helpful tools for displaying your data.
- They provide you with the ability to quickly manipulate and update the presentation of your data.
- One stylesheet can transform a large amount of data.
- Once you create a stylesheet, you can re-use it again and again to output your presentation format. If you add data to your XML file, so long as it remains in the same format your stylesheet will continue to produce the new data in the presentation format you chose.
- You can use stylesheets created by others to produce new formats.
Do browsers support formatting via XSL stylesheets?
Yes, Internet Explorer 6 (on Windows), Netscape 7 (all platforms) and Firefox fully support the official W3C recommendation.
How can I view an XML document in a web-browser?
If there is no associated stylesheet specified in the XML document, you will see the bare tree structure of the XML document.
The XSL transformation engine is automatically invoked when the XML document contains an <?xml-stylesheet?> processing instruction at the beginning, which specifies the stylesheet that should be used. Thus all you need to do to view the file is to open the XML document with the browser.
What is XHTML (Extensible Hyper Text Markup Language)?
XHTML is almost identical to HTML 4.01, but it is a stricter and cleaner version of HTML: XHTML is HTML defined as XML. This means that:
- XHTML elements must be properly nested.
- Tag names must be in lowercase.
- All XHTML elements must be closed.
More information is available from W3C Schools.
Related Links | |
---|---|
About Stylesheets How XSL Works Example Files ![]() How to Use Stylesheets |
User Contributed Notes XSL Stylesheets |
+ Add a comment |
+ View comments |