How to Write an XSL Style Sheet for XML Online
An XSL -- eXtensible Stylesheet Language -- file is a class layout file for your XML -- eXtensible Markup Language -- data stored on your website. You use the XML file to retrieve data to display online, and the XSL file formats the data in the XHTML -- eXtended HyperText Markup Language -- format that your users can view. For instance, you can transform a list of items into an XHTML table. An XSL file makes it more convenient to display XML data in an XHTML layout without manually programming the layout.
Instructions
-
-
1
Right-click the XSL file you want to edit and select "Open With." Click "Notepad" to create the layout in the Notepad editor. If you have a third-party XSL editor or another text editor you prefer, choose this program shortcut instead.
-
2
Add the heading for the XML data. For instance, if you have a list of customers to display, the following code sets up two headings for the first and last name:
<table border="1">
<tr bgcolor="#000000">
<th>First Name</th>
<th>Last Name</th>
</tr>
</table> -
-
3
Add the XSL transformation style. The following code uses a list of customers to display in an XHTML table:
<xsl:for-each select="customers">
<tr>
<td><xsl:value-of select="first"/></td>
<td><xsl:value-of select="last"/></td>
</tr>
</xsl:for-each>In this example, the XML tags with the data are "first" and "last." Change these two values to your own XML data tags.
-
4
Click the "Save" button to save your file. Open the XSL file in your browser to review the data and layout.
-
1