The Caboteria / Tech Web / TechNotes > ProgrammingNotes > XmlNotes / XsltNotes (revision 3)

Reverse Order

Sometimes you want to display a list of items in the reverse order than they appear in the document. http://www.biglist.com/lists/xsl-list/archives/200105/msg00236.html shows how:

    <xsl:apply-templates select="item">
      <xsl:sort select="position()" data-type="number" order="descending" />
    </xsl:apply-templates>

Non-breaking Space

Short answer: use &#160; instead of &nbsp;

Long answer: http://www.dpawson.co.uk/xsl/sect2/nbsp.html

Passthrough

This transform (which I learned from the guys that wrote the Maverick MVC framework) passes everything through unmolested.

        <xsl:template match="@*|node()">
                <xsl:copy>
                        <xsl:apply-templates select="@*|node()"/>
                </xsl:copy>
        </xsl:template>

Links

http://www.jenitennison.com/xslt/ - lots of good XSLT tips
http://www.jenitennison.com/xslt/grouping/index.xml - how to group items in XSLT (can be used to emulate sql's "select distinct" functionality)

Edit | Attach | Print version | History: r9 | r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions...
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding The Caboteria? Send feedback