|
XML.HTMLTeacher.Com
[Search] [Contact] [Sitemap] |
XML
[Main] [XPath] |
|
[Classes]
[XHTML] [XML] [CSS] [Design] [Programming] [Marketing] |
|
| Table of Contents |
|
1. Overview
2. Match Patterns 3. Path Expressions 4. Tutorial/Lab |
Please note:
<xsl:template match="library"> XSL file View result
The following 3 examples will all match the author element: <xsl:template match="author"> XSL file View result <xsl:template match="library/book/bookcataloginfo/author"> XSL file View result <xsl:template match="bookcataloginfo/author"> XSL file View result
Example 1 <xsl:template match="chapter"> XSL file View result Example 2 <xsl:template match="topic"> XSL file View result Example 3 <xsl:template match="chapter/topic"> XSL file View result Example 4 <xsl:template match="subtopic/topic"> XSL file View result
The following has been added to the XML document used for these examples. Note that this content is NOT accessed. <bookcataloginfo> <title>NO ATTRIBUTE</title> <author>NO ATTRIBUTE</author> </bookcataloginfo> Example 1 <xsl:template match="bookcataloginfo"> <xsl:apply-templates select="@isbn"/> XSL file View result Example 2A 1. This example tells the processor to look for all the chapter elements and access them only if they contain the attribute named number. 2. Since the processor is told to format only the number attribute's value by using the select attribute within the <xsl:apply-templates/> element, the values for the number attribute are each displayed within a paragraph element. 3. Note the formatting of the values for the number attribute and compare it with the next example. <xsl:template match="chapter"> <xsl:apply-templates select="@number"/> XSL file View result Example 2B 1. This example tells the processor to look for all the bookchapters elements and access them only if they contain the element of chapter if chpater also contains the attribute named number. 2. The processor is told to format only the number attribute's value by using the select attribute within the <xsl:apply-templates/> element. 3. Since the chapter element was also requested within the select attribute of <apply-template/> element, the values for the number attribute are all displayed on one line. <xsl:template match="bookchapters"> <xsl:apply-templates select="chapter/@number"/> XSL file View result |
| All materials, tutorials and content are copyrighted by HTMLTeacher.Com.
Any use of any material, tutorials and/or content provided by this site is prohibited without expressed written consent of the author. Copyright ©2003 HTMLTeacher.Com and Sonia Weimann
|