RE: [xsl] fun with fo tab formatting

Subject: RE: [xsl] fun with fo tab formatting
From: "Kyle Partridge" <kpartridge@xxxxxxxxxxxx>
Date: Thu, 11 Dec 2003 15:51:25 -0500
Hi List Members,

Eliot and Ken - thanks for pointing me in the right direction...  This
is as far as I have gotten:

<xsl:template match="ws:tab">
	
	<xsl:if test="position()=1">
		<fo:table>
			<fo:table-body>
				<fo:table-row>
	</xsl:if>
				
	<xsl:element name="fo:table-cell">
		<xsl:attribute name="width">
			<xsl:call-template name="get-width">
				<xsl:with-param name="list">
				  <xsl:choose>
					<xsl:when test="parent::tabs">
						<xsl:value-of
select="parent::tabs"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:variable
name="styleName" select="parent::style"/>
						<xsl:value-of
select="//ws:textStyle[@name=$styleName]/ws:blockAttr/@tabs"/>
					</xsl:otherwise>
				  </xsl:choose>
				</xsl:with-param>
				<xsl:with-param name="curpos">
				  <xsl:choose>
					<xsl:when
test="preceding-sibling::br">
						<xsl:value-of
select="count(preceding-sibling::tab)-position()"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of
select="position()"/>
					</xsl:otherwise>
				  </xsl:choose>
				</xsl:with-param>
			</xsl:call-template>
		</xsl:attribute>
	</xsl:element>
	<fo:block/>
	<xsl:element name="fo:table-cell">
		<xsl:apply-templates/>
	</xsl:element>
				
	<xsl:if test="position()=parent::ws:tab[last()]">
				</fo:table-row>
			</fo:table-body>
		</fo:table>
	</xsl:if>	
	
</xsl:template>

First, it won't let me save this, because it doesn't like me opening
tags in one statement and closing them in another...any way I can get
around this?

Second...I've reached a wall with my new "get-width" template:

<xsl:template name="get-width">
	<xsl:param name="list"/>
	<xsl:param name="curpos"/>
	<xsl:variable name="nlist"
select="concat(normalize-space($list), ' ')"/>
	<xsl:variable name="first" select="substring-before($nlist, '
')"/>
	<xsl:choose>
		<xsl:when test="$curpos=1">
			<xsl:value-of select="$first"/>
		</xsl:when>
		<xsl:otherwise>
			<!--want list[curpos] - list[curpos-1]...I
think.  But how???-->
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

If the curpos(tab) is 1, then I can just output the first string.
However, I can't come up with an algorithm that works for the rest of
the items.  If curpos is 2 or 3, or 4 or whatever, I want the tab width
output to be list[curpos] - list[curpos-1] but I don't know how to
express that here.  It's driving me batty!

Thanks for all your help/advice with this stuff - in case you couldn't
already tell, I find this very!! confusing.

KP



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


Current Thread