strip leading whitespace for sorting
XSLT 1.0, Firefox 3.0 & other recent browsers.
I've got a problem with nodes that contain leading whitespace that I want to strip, because it's affecting my sorts.
I've had a look at the list archives & dpawson's faq. Is it true that the only way to strip leading whitespace is as shown here: < http://www.dpawson.co.uk/xsl/sect2/N8321.html#d12429e833 >? It looks like a lot of hard work.
FWIW, below is my current xsl stylesheet, which gets called from within php... which is processing some pretty basic xml sent from a wsdl/soap thing-a-mejig (a list of countries & currencies).
As you can see, I've tried to use <xsl:strip-space elements="*" /> & <xsl:copy>, but may, in my ignorance, simply be misusing those tools.
TIA for any pointers. Cheers!
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- This is required so that   is correctly rendered --> <xsl:output encoding="iso-8859-1" /> <!-- Doesn't fix the problem with spaces affecting sort order --> <xsl:strip-space elements="*" />
<table border='2'><tr><th>Currency Name</th><th>Currency Code</th><th>Country Name</th><th>Country Code</th></tr>
<!-- Is this achieving anything? -->
<xsl:sort select="Currency" order="ascending" />
<xsl:sort select="Name" order="ascending" />
<xsl:call-template name="displayCurrency" />
<xsl:variable name="theCurrencyName" select="Currency" />
<xsl:variable name="theCurrencyCode" select="CurrencyCode" />
<tr><td><xsl:value-of select="$theCurrencyName" /> </td><td><xsl:value-of select="$theCurrencyCode" /> </td><td><xsl:value-of select="Name" /></td><td><xsl:value-of select="CountryCode" /></td></tr>\n
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format