
<?xml version = "1.0" encoding = "ISO-8859-1"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
<?xml version = "1.0" encoding = "ISO-8859-1"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:template match = "/">
<html>
<body>
<h2>My CD Colletion</h2>
<table border = "1">
<tr bgcolor = "blue">
<th align = "left>Title</th>
<th align = "left>Artist</th>
<tr>
<xsl:for-each select = "catalog/cd">
<tr>
<td><xsl:value-of select = "title" /></td>
<td><xsl:value-of select = "artist" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<?xml version = "1.0" encoding = "ISO-8859-1"?>
<?xml-stylesheet type = "text/xsl" href = "cdcatalog.xsl"
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
<?xml version = "1.0" encoding = "ISO-8859-1"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:template match = "/">
<html>
<body>
<h2>My CD Colletion</h2>
<table border = "1">
<tr bgcolor = "blue">
<th align = "left>Title</th>
<th align = "left>Artist</th>
<tr>
<xsl:for-each select = "catalog/cd">
<tr>
<td><xsl:value-of select = "title" /></td>
<td><xsl:value-of select = "artist" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<?xml version = "1.0" encoding = "ISO-8859-1"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:template match = "/">
<html>
<body>
<h2>My CD Colletion</h2>
<table border = "1">
<tr bgcolor = "blue">
<th align = "left>Title</th>
<th align = "left>Artist</th>
<tr>
<tr>
<td><xsl:value-of select = "catalog/cd/title" /></td>
<td><xsl:value-of select = "catalog/cd/artist" /></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<?xml version = "1.0" encoding = "ISO-8859-1"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:template match = "/">
<html>
<body>
<h2>My CD Colletion</h2>
<table border = "1">
<tr bgcolor = "blue">
<th align = "left>Title</th>
<th align = "left>Artist</th>
<tr>
<xsl:for-each select = "catalog/cd">
<tr>
<td><xsl:value-of select = "title" /></td>
<td><xsl:value-of select = "artist" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<?xml version = "1.0" encoding = "ISO-8859-1"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:template match = "/">
<html>
<body>
<h2>My CD Colletion</h2>
<table border = "1">
<tr bgcolor = "blue">
<th align = "left>Title</th>
<th align = "left>Artist</th>
<tr>
<xsl:for-each select = "catalog/cd">
<xsl:sort select = "artist" />
<tr>
<td><xsl:value-of select = "title" /></td>
<td><xsl:value-of select = "artist" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<?xml version = "1.0" encoding = "ISO-8859-1"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:template match = "/">
<html>
<body>
<h2>My CD Colletion</h2>
<table border = "1">
<tr bgcolor = "blue">
<th align = "left>Title</th>
<th align = "left>Artist</th>
<tr>
<xsl:for-each select = "catalog/cd">
<xsl:if test = "price &gt; 10">
<tr>
<td><xsl:value-of select = "title" /></td>
<td><xsl:value-of select = "artist" /></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<?xml version = "1.0" encoding = "ISO-8859-1"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:template match = "/">
<html>
<body>
<h2>My CD Colletion</h2>
<table border = "1">
<tr bgcolor = "blue">
<th align = "left>Title</th>
<th align = "left>Artist</th>
<tr>
<xsl:for-each select = "catalog/cd">
<tr>
<td><xsl:value-of select = "title" /></td>
<xsl:choose>
<xsl:when test = "price &gt; 10">
<td bgcolor = "pink"><xsl:value-of select = "artist" /></td>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of select = "artist" /></td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<?xml version = "1.0" encoding = "ISO-8859-1"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:template match = "/">
<html>
<body>
<h2>My CD Colletion</h2>
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match = "cd">
<p>
<xsl:apply-templates select = "title" />
<xsl:apply-templates select = "artist" />
</p>
</xsl:template>
<xsl:template match = "title">
Title: <span style = "color:red"><xsl:value-of select = "," /></span><br />
</xsl:template>
<xsl:template match = "artist">
Artist: <span style = "color:blue"><xsl:value-of select = "," /></span><br />
</xsl:template>
</xsl:stylesheet>
<html>
<body>
<script type = "text/javascript">
// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("filename.xml")
// Load XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("filenae.xsl")
// Transform
document.write(xml.transformNode(xsl))
</script>
</body>
</html>
<$
' Load XML
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
xml.load(Server.MapPath("filename.xml"))
' Load XSL
set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load(Server.MapPath("filename.xsl"))
' Transform
Response.Write(xml.transformNode(xsl))
%>
| Element | Description |
|---|---|
| xsl:apply-imports | Applies a template rule from an imported style sheet |
| xsl:apply-templates | Applies a template rule to the current element
or to the current element's childNodes |
| xsl:attribute | Adds an attribute |
| xsl:attribute-set | Defines a named set of Attributes |
| xsl:call-template | Calls a Named Template |
| xsl:choose | Expresses multiple condition tests |
| xsl:comment | Creates a comment node in the result tree |
| xsl:copy | Creates a copy of the current node
with childNodes and attributes |
| xsl:copy-of | Creates a copy of the current node
with childNodes and attributes |
| xsl:decimal-format | Defines the characters and symbols
to be used when converting numbers into strings with the format-number() function |
| xsl:element | Creates an element node in the output document |
| xsl:fallback | Specifies an alternate code to run
if the XSL processor doesn't support an element |
| xsl:for-each | for loop |
| xsl:if | If statement |
| xsl:import | Imports the contents of one style sheet into another |
| xsl:include | Includes the contents of one style sheet into another |
| xsl:key | Declares a Named Key that can be used in the style sheet
with the key() function |
| xsl:message | Writes a message to the output (error reporting) |
| xsl:namespace-alias | Replaces a namespace in the style sheet
to a different NameSpace in the output |
| xsl:number | Determines the integer position of the current node
and formats a number |
| xsl:otherwise | The otherwise part of choose |
| xsl:output | Defines the format of the output document |
| xsl:param | Declares a local or global parameter |
| xsl:preserve-space | Defines the elements for which white space
should be preserved |
| xsl:processing-instruction | Writes a processing instruction to the output |
| xsl:sort | Sort Statement |
| xsl:strip-space | Defines the elements for which white space
should be removed |
| xsl:stylesheet | Defines the root element of a style sheet |
| xsl:template | Rules to apply when a specified node is matched |
| xsl:text | Writes literal text to the output |
| xsl:transform | Defines the root element of a style sheet |
| xsl:value-of | Extracts the value of a selected node |
| xsl:variable | Declares a local or global variable |
| xsl:when | Specifies an action for the choose element |
| xsl:with-param | Defines the value of a parameter to be passed
to a template |
| Name | Description |
|---|---|
| current() | Returns the current Node |
| document() | Used to access the nodes in an external XML document |
| element-available() | Tests whether the element specified is supported by
the XSLT processor |
| format-number() | Converts a number into a string |
| function-available() | Tests whether the Function Specified is supported
by the XSLT Processor |
| generate-id() | Returns a String Identifier of a Specified Node |
| system-property() | Returns the value of the system properties |
| unparsed-entity-uri() | Returns the URI of an Unparsed Entity |
| key() | Returns a Node-Set using the Index Specified
by an <xsl:key> element |
| Name | Description | |
|---|---|---|
| count() | Returns the number of nodes in a node-set | number = count(node-set) |
| id() | Selects Elements by Unique Id | node-set = id(value) |
| local-name() | Returns the local part of a node
A Node usually consists of a prefix, a colon, and the local name |
string = local-name(node) |
| name() | returns the name of a node | string = name(node) |
| position() | Returns the position of a Node in the Node-List | number = position() |
| last() | Returns the position of the last node in a node-list | number = last() |
| namespace-uri | Returns the namespaace URI of a specified node | uri = namespace-uri(node) |
| Name | Description | |
|---|---|---|
| concat() | string concatenation | string = concat(val1, val2,...) |
| contains() | Returns true or false if the second string is
found in the first |
bool = contains(string,substr) |
| normalize-space() | Removes leading/traline spcaes from a string | string = normalize-space(string) |
| starts-with() | Returns tre if the first string starts with
the second |
bool = starts-with(string,substr) |
| string() | Converts the value to a string | string(value) |
| string-length() | Number of characters in a string | number = string-length(string) |
| substring() | Returns a part of the string
in the string argument |
string = substring(string, start, length) |
| substring-after() | Returns the part of the string in string argument
that occurs after the substring in the substr argument |
string = substring-after(string, substr) |
| substring-before() | Returns the part of the string in the string argument
that occurs before the substring in the substr argument |
string = substring-before(string, substr) |
| translate() | Takes the value arguemtn and replaces
all occurances of string1 with string2 and returns the modified string |
string = translate(value, string1, string2) |
| Name | Description | |
|---|---|---|
| ceiling() | Returns the smallest integer that is not
less than the number argument |
number = ceiling(number) |
| floor() | Returns the largest integer that is not
greater than the number argument |
number = floor(number) |
| number() | converts to a number | number = number(value) |
| round() | rounds to the nearest integer | integer = round(number) |
| sum() | total of a set of numeric values in a node-set | number = sum(nodeset) |
| Name | Description | |
|---|---|---|
| boolean() | Converts the value to Boolean
and returns true or false |
bool = boolean(value) |
| false() | Returns false | false() |
| lang() | Returns true if the language argument matches
the language of the <xsl:lang> element, otherwise false |
bool = lang(language) |
| not() | Returns true if the condition argument is false
and false if the condition is true |
bool = not(condition) |
| true() | Returns true | true() |
|
|
|