Library tutorials & articles
Extensible Markup Language (XML) Tutorial
XSL Transformations
Basic Transformations
The value-of keyword is used to match a pattern and generates an element in the result tree containing the matched text.
<xsl:value-of select="/collection/cd/band" />
Element attributes are accessed using @. The following example matches the attribute year of the title element.
<xsl:value-of select="/collection/cd/title/@year" />
Selection
The if keyword is used for decision making. Conditions are placed in square brackets. The following example tests the paid attribute. If the paid attribute has a value of yes, then Fully Paid Member is displayed.
<xsl:if test=".[membership/@paid='yes']">Fully Paid Member</xsl:if>
Multiple conditions are performed using the choose keyword.
<xsl:choose>
<xsl:when test=".[membership/@paid='yes']">Fully
Paid Member</xsl:when>
<xsl:when test=".[membership/@paid='no']">Unpaid Member</xsl:when>
<xsl:otherwise>Unknown Payment Status</xsl:otherwise>
</xsl:choose>
Iteration
Iteration is achieved using the for-each keyword. The following example iterates through each cd in the collection and displays the band.
<xsl:for-each select="/collection/cd">
<xsl:value-of select="band" />
< /xsl:for-each>m
With iteration, the sort keyword may be used to sort elements selected by the select attribute. The following example displays the bands in ascending order.
<xsl:for-each select="/collection/cd">
<xsl:sort select="band" order="ascending" />
<xsl:value-of select="band" />
</xsl:for-each>
Related articles
Related discussion
-
vb6 generated help file not working in Window 7 and Vista
by Thushan Fernando (1 replies)
-
doctype in xml using c#.net
by madarapurajesh (0 replies)
-
Like statement in Xpath
by madarapurajesh (3 replies)
-
Problem looping through xml file to play a flv video file
by Bozmeister (0 replies)
-
Creating a Windows Service in VB.NET
by davidvanr (108 replies)
Related podcasts
-
LINQ to XML
Scott's been poking around with LINQ to XML and reports his findings to Carl about life with XDocuments and XElements. They also talk about the bridge classes that link (no pun intended) System.Xml and System.Xml.Linq.
Beutiful article. Takes a user from a beginner level to an intermediate level very nicely. Certainly a treat for beginers and an expert alike.
Good article for starters
This thread is for discussions of Extensible Markup Language (XML) Tutorial.