XSLT - Stylesheet Reference
This lesson will teach you how to link your XML document to your XSLT stylesheet. This is the magic step that connects your XML to a XSLT file! If you do not follow the steps in this lesson to link your files, XSLT will not work properly.
XSLT - xml-stylesheet
xml-stylesheet is a special declaration in XML for linking XML with stylesheets. Place this after your XML declaration to link your XML file to your XSLT code.
xml-stylesheet has two attributes:
- type: the type of file being linked to. We will be using the value text/xsl to specify XSLT.
- href: the location of the file. If you saved your XSLT and XML file in the same directory, you can simply use the XSLT filename.
If you have been following along with this tutorial, your XSLT file should be named class.xsl. Make sure that both your XSLT and XML file are in the same directory.
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="class.xsl"?>
Save this XML file as class.xml, and your XML file will be linked to your XSLT file. After you have finished this step, you can continue learning XSLT!
Download Tizag.com's XML Book
If you would rather download the PDF of this tutorial, check out our
XML eBook from the Tizag.com store.
Found Something Wrong in this Lesson?
Report a Bug or Comment on This Lesson - Your input is what keeps Tizag improving with time!