Latest web development tutorials

XSLT <xsl: template> element

XSL stylesheets are called by one or more sets of template (template) of the rules.

Each template contains a rule when a specified node is matched applied.

<Xsl: template> element

<Xsl: template> element is used to build templates.

The match attribute is used to associate XML elements and templates.match attribute can also be used to define a template for the entire XML document. Value match attribute is an XPath expression (for example, match = "/" defines the entire document).

Well, let's look at a simplified version of the last chapter of the XSL file:


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"

<xsl:template match="/">
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">


try it"

Examples explained

Since the XSL stylesheet is itself an XML document, so it is always starting from the XMLdeclaration: <xml version = "1.0" encoding = "ISO-8859-1"??>.

The nextelement, <xsl: stylesheet>, Define this document is an XSLT style sheet document (along with the version number and XSLT namespace attributes).

<xsl: template> element defines a template.Thematch = "/" attribute put the template with the root of the XML source document linked.

<Xsl: template> defines the content of the element inside the HTML code is written to the output.

The last two lines define the end of the template and the end of the style sheet.

The results of this example there is a little flawed, because the data is not copied from the XML document to the output. In the next chapter, you will learn how to use the<xsl: value-of> element to select values from the XML elements.