[iNote]XSLT Quick Reference

<?xml version=”1.0”?> <!—   pi    —>
<xsl:stylesheet version=”1.0” xmlns:xsl=”http://www.w3.org/1999/XSL/Transform“> <!—   identify this is an xsl:stylesheet    —>

<xsl:template match=”/”> <!—  <xsl:template> use to define a style for the element choose by “match=’xPath’ “  —> <!— here “/” indicate xmlDoc —>
F
oreach node: <xsl:for-each select=”catalog/cd”>
<!— “catalog/cd” -> XPath. XML file has structure: <catalog><cd><title>……… —>

Value of node: <xsl:value-of select=”title”/>
Value of attribute <xsl:value-of select=”@attributeName”/>
Link form XML: <?xml-stylesheet type=”text/xsl” href=”cdcatalog.xsl”?>
Sort <xsl:sort select=”title” /> Condition: <xsl:if test=”price &gt; 10”> Switch: <xsl:choose> <xsl:when test=”price &gt; 10”>Something</xsl:when> <xsl:when test=”price &gt; 20”>Something</xsl:when> <xsl:otherwise>otherthing </xsl:otherwise></xsl:choose> Apply template: <xsl:apply-templates select= “title” />
Use javascript in client - side (browser) to TRANSFORM XML to XHTML http://w3schools.com/xsl/xsl_client.asp
Learn XPath

This was posted 2 years ago. It has 0 notes.