| Nic Miloslav Example 14 | KEYWORDS EXAMPLES AUTHORS |
|---|
Stylesheet 1 sorts in text and Stylesheet 2 in numeric mode. Notice the important difference. 2 is after 1 in alphabet so 2 goes after 10 in text mode.
| XML | HOME XSL 1 XSL 2 |
|---|
| <xslTutorial > |
| <car id="11"/> |
| <car id="6"/> |
| <car id="105"/> |
| <car id="28"/> |
| <car id="9"/> |
| </xslTutorial> |
| XSL 1 | HOME XML HTML 1 OUTPUT 1 |
|---|
| <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' > |
| <xsl:template match="/"> |
| <TABLE> |
| <xsl:for-each select="//car"> |
| <xsl:sort data-type="text" select="@id"/> |
| <TR><TH><xsl:text> Car-</xsl:text> <xsl:value-of |
| select="@id"/></TH></TR> |
| </xsl:for-each> |
| </TABLE> |
| </xsl:template> |
| </xsl:stylesheet> |
| HTML 1 | HOME XML XSL 1 OUTPUT 1 |
|---|
| <HTML> |
| <HEAD> </HEAD> |
| <BODY> |
| <TABLE> |
| <TR> |
| <TH>Car-105</TH></TR> |
| <TR> |
| <TH>Car-11</TH></TR> |
| <TR> |
| <TH>Car-28</TH></TR> |
| <TR> |
| <TH>Car-6</TH></TR> |
| <TR> |
| <TH>Car-9</TH></TR></TABLE> </BODY> </HTML> |
| OUTPUT 1 | HOME XML XSL 1 HTML 1 |
|---|
| Car-105 |
|---|
| Car-11 |
| Car-28 |
| Car-6 |
| Car-9 |
| XSL 2 | HOME XML HTML 2 OUTPUT 2 |
|---|
| <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' > |
| <xsl:template match="/"> |
| <TABLE> |
| <xsl:for-each select="//car"> |
| <xsl:sort data-type="number" select="@id"/> |
| <TR><TH><xsl:text> Car-</xsl:text> <xsl:value-of |
| select="@id"/></TH></TR> |
| </xsl:for-each> |
| </TABLE> |
| </xsl:template> |
| </xsl:stylesheet> |
| HTML 2 | HOME XML XSL 2 OUTPUT 2 |
|---|
| <HTML> |
| <HEAD> </HEAD> |
| <BODY> |
| <TABLE> |
| <TR> |
| <TH>Car-6</TH></TR> |
| <TR> |
| <TH>Car-9</TH></TR> |
| <TR> |
| <TH>Car-11</TH></TR> |
| <TR> |
| <TH>Car-28</TH></TR> |
| <TR> |
| <TH>Car-105</TH></TR></TABLE> </BODY> </HTML> |
| OUTPUT 2 | HOME XML XSL 2 HTML 2 |
|---|
| Car-6 |
|---|
| Car-9 |
| Car-11 |
| Car-28 |
| Car-105 |