[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Group by Element based on Attribute inside contain
Friend, Darris E schrieb:
Outstanding! I did a little research on the Sort. Your method did sort by year, but not exactly the way I wanted. Partly because I did not mention the most recent year first.
So the last digit of the year wasn't taken into account, which provided a wrong result. I altered your statement removing the concat and two substrings (also note the third argument for substring is dropped) and produced the following:
<xsl:sort select="concat( substring( ObjectClassField[ @name = $inspected], 7, 4), substring( ObjectClassField[ @name = $inspected], 1, 2), substring( ObjectClassField[ @name = $inspected], 4, 2))"/> Or YYYY, then MM, then DD: <xsl:sort select="substring(ObjectClassField[@name = $inspected], 7, 4)"/> <xsl:sort select="substring(ObjectClassField[@name = $inspected], 1, 2)"/> <xsl:sort select="substring(ObjectClassField[@name = $inspected], 4, 2)"/> With a variable $inspected defined outside the xsl:apply-templates or xsl:for-each that is sorted: <xsl:variable name="inspected" select="'Date Inspected'"/> And of course sorting years as strings only works when they all have the same number of digits, so in order to sort years like -44 (44 BC), 0, 800, or 10123, you want: <xsl:sort select="Year" data-type="number"/> But then, you'd also need some more intelligent substring work to parse the dates. Thank you for your help and patience. darris You're very welcome, thanks for reporting back. Michael Ludwig
|
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
|