Subject: [xsl] solved: Generating <col> or <fo:table-column> tags with widths look ed up from a comma separated string - recursive From: "SANWAL, ABHISHEK (HP-Houston)" <abhishek.sanwal@xxxxxx> Date: Thu, 23 Oct 2003 11:38:07 -0500 |
I was able to solve the issues and problems that I described in the following thread topics, with a different approach: (adding them so that keyword searches made on google will help others with this issue). - whats the best way to create and use values for lookup (key-value) such that you can loop through it with limits - to convert XSLs from HTML to FO: approach, ideas, thoughts ? - Converting nested XSL-HTMLs made for complex technical spec documents into FO, design approach, current layouts, other thoughts - advise - TOUGH ONE: All Grandmasters - how- iteratable key-value pair/array/lookup table that has only local scope with the xsl template - Implementing an Array or Lookup List type of structure in XSL It uses a comma (or any other char) separated string) to separate the elements of the so called array or list structure. Of course it currently does not feature all the possible operations traditionally available with arrays. But, it's a start in being able to retrieve values. It uses a recursive call. It is particularly good for generating <fo:table-column> for FO using WIDTHS defined in the XSL and not from XML Data (where it would be easier to model). Solution XSL: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template name ="MatrixColumns" > <xsl:param name ="MatrixColumnWidths"></xsl:param> <xsl:choose> <xsl:when test ="contains($MatrixColumnWidths,',')" > <fo:table-column> <xsl:attribute name="column-width"><xsl:value-of select="substring-before($MatrixColumnWidths,',')"></xsl:value-of></xsl: attribute> </fo:table-column> <!-- <col> <xsl:attribute name="width"><xsl:value-of select="substring-before($MatrixColumnWidths,',')"></xsl:value-of></xsl: attribute> </col> --> <xsl:call-template name ="MatrixColumns" > <xsl:with-param name ="MatrixColumnWidths" > <xsl:value-of select ="substring-after($MatrixColumnWidths,',')" /> </xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <!-- <fo:table-column> <xsl:attribute name="column-width"><xsl:value-of select="$MatrixColumnWidths"></xsl:value-of></xsl:attribute> </fo:table-column> --> <col> <xsl:attribute name="width"><xsl:value-of select="substring-before($MatrixColumnWidths,',')"></xsl:value-of></xsl: attribute> </col> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="/"> <xsl:variable name="WidthsString" select="'10,20,30,40,50'"/> <xsl:call-template name="MatrixColumns"> <xsl:with-param name="MatrixColumnWidths" select="$WidthsString"/> </xsl:call-template> </xsl:template> </xsl:stylesheet> XML: <root> </root> Abhishek Sanwal HP - Houston Campus abhishek.sanwal@xxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] cdata-section-elements, Abie Hamaoui | Thread | [xsl] Special characters in xsl, Archana Rao |
[xsl] cdata-section-elements, Abie Hamaoui | Date | [xsl] Special characters in xsl, Archana Rao |
Month |