Umbraco/Various useful XSLT methods in Umbraco

The basics of using XSLT in Umbraco
Creating a variable:  Variables a after this referenced using $myVarName (prefix with $)

Outputting a value: 

Expressions:

Converting to string: string($myVarName) Converting to number: number($myVarName)

If test:  

Choose test:        

Loop all nodes from root and down of a certain doc-type (this example includes sorting on a field in this doc-type):   

Get a node name from the first parent node of a certain doc-type: 

(Since the Umbraco 4.5 Schema, @nodeTypeAlias is no longer used) - for versions 4.5 and above, use: <xsl:variable name="myVarName" select="$currentPage/ancestor-or-self::doc-type-alias-goes-here/@nodeName"></xsl:variable>

Details of the change from using @nodeTypeAlias are here: http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/no-more-@nodetypealias

Get an attribute value from the first parent node that has a certain doc-type: <xsl:variable name="myVarName" select="ancestor-or-self::node [@nodeTypeAlias = 'myDocType']/data [@alias = 'myAttributeAlias']"/>

Limit a for-each loop to run only five times (if position <= 5) (REMEMBER in XSLT the '<' sign must be written as '&amp;lt;'  !) : <xsl:for-each select="$currentPage/descendant::node"> <xsl:if test="position &amp;lt;= 5"> </xsl:if> </xsl:for-each> Loops first five descendents of current node.

Get attribute value from a current node in a loop: <xsl:value-of select="data [@alias = 'myAttributeAlias']"/>

Creating a template with two parameters: <xsl:template name="myTemplate"> <xsl:param name="startnode"/> <xsl:param name="endnode"/> </xsl:template>

Calling a template: <xsl:call-template name="myTemplate"> <xsl:with-param name="startnode" select="23"/> <xsl:with-param name="endnode" select="49"/> </xsl:call-template>

Get a parameter from a macro <xsl:variable name="myParam" select="/macro/parameterAlias"/>