This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Reformatting


> That said, I transform the XML into HTML by simply using:
>
>     <xsl:template match="ch">
>       <xsl:apply-templates/>,
>     </xsl:template>
>
> to produce:
>
>      1,2,3,4,10,11,12,13,24
>
> I am trying to use XSLT format the output abbreviating ranges
> of channels.
> The above would ideally be formatted as:
>
>       1-4,10-13,24
>
Suggestion: write a set of template rules with different priorities that
compare the value with preceding or following siblings, eg.

<xsl:template match="ch[.=preceding-sibling::ch[1]+1]" priority="2">

if value is one more than previous and one less than next, do nothing
if value is one more than previous and not one less than next, output "-x,"
if value is not one more than previous and not one less than next, output
"x,"
otherwise output "x".

Not tested, may need refining.

Or you could do the same logic in xsl:choose, of course.

Mike Kay
Software AG


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]