[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

solved: Generating <col> or <fo:table-column> tags wit

Subject: 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
fo table column
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.