Subject: Re: [xsl] Group by Element based on Attribute inside container using 1.0|
From: Michael Ludwig <mlu@xxxxxxxxxxxxx>
Date: Fri, 07 Nov 2008 16:43:27 +0100
Now for the syntax, please describe why you did this and what it does. If you can break down the statement 'substring' and what 6,4 1,2 4,2 does that would be very helpful.
Well, you want to sort by date, but your dates don't sort naturally when compared as strings, because they don't read like year-month-day from left to right, which they have to do in order to be sortable as strings.
The substring() function is just the usual substring function which takes a part out of a string. The only thing this in XSLT in which this is unusual is that this function is 1-based, as opposed to 0-based, as in all languages I'd learnt before. So in "substring('abcde', 2, 3)", the second argument says where to start extracting the substring and the third one says how many characters to extract, and this returns "bcd".
And for this comment, '<!-- Extend this to display more information. -->', do you mean I can add the following statement in order to show more Inspection details on the output?
Add? <xsl:value-of select="ObjectClassField[ @name = 'Inspected By']"/> <xsl:value-of select="ObjectClassField[ @name = 'Repairs Made']"/>
<xsl:template match="ObjectClassRow"> <!-- Extend this to display more information. --> <xsl:value-of select="ObjectClassField[ @name = 'Date Inspected']"/> <xsl:text> </xsl:text> </xsl:template>
By the way, the is a newline. If you want more lines, add more of that. But i guess you want HTML, given that your clients are IE6. In that case, you should change the output method to "html" and add HTML elements instead of the plain text newlines.
And my final question, how can I turn a value in the XML into another value shown in the XSL output. For "Repairs Made" we store it is an integer, but I want to show it as Yes or No based on 0 or 1.
<xsl:choose> <xsl:when test="$repairs-mode = 0">No</xsl:when> <xsl:otherwise>Yes</xsl:otherwise> <xsl:choose>
|<- Previous||Index||Next ->|
|Re: [xsl] Group by Element based on, Friend, Darris E||Thread||Re: [xsl] Group by Element based on, Friend, Darris E|
|Re: [xsl] Group by Element based on, Friend, Darris E||Date||Re: [xsl] XPATH problem, Sam Byland|