[xsl] Splitting Node Output

Subject: [xsl] Splitting Node Output
From: "HEATH ALLISON" <HEATH.ALLISON@xxxxxxxxxxxxxxx>
Date: Fri, 24 Jan 2003 10:36:30 -0600
I want to take this form element:
<BlAH>a brown dog jumped over a lazy fox who cares</BLAH>

and put into a table that's aligned like this:

<TR><TD colspan="2">a brown dog jumped over a</TD></TR>
<TR><TD>lazy fox who cares</TD><TD></TD></TR>

On my own I figured out how to do something like this:

NOTE: the -400 and 150 numbers in this code represent the actual numbers fo the geometry of a much larger table.
Here the numbers would be smaller since the actual content of <BLAH> is much smaller. 400 represents the total number of chracters to appear in the bottom row's first TD column. And 

<xsl:variable name="getTotalChars">
                <xsl:value-of select="string-length(.)" />
</xsl:variable>

<xsl:variable name="getLeftChars">
		<xsl:value-of select="($getTotalChars)-20" />
</xsl:variable>

<xsl:variable name="getCharDivision">
                <xsl:value-of select="($getLeftChars mod 25)" />
</xsl:variable>

<xsl:variable name="getLineDifference">
                <xsl:value-of select="(25 - $getCharDivision)" />
</xsl:variable>

<xsl:variable name="getNewAbove">
                <xsl:value-of select="($getLeftChars + $getLineDifference)" />
</xsl:variable>

<xsl:variable name="getWhatNew">
                <xsl:value-of select="substring(.,$getNewAbove,1)" />
</xsl:variable>

<TR><TD colspan="2"><xsl:value-of select="substring(.,0,$getNewAbove)" /></TD></TR>
<TR><TD><xsl:value-of select="substring(.,$getNewAbove)" /></TD><TD></TD></TR>

This is MOSTLY working. I'm not sure if it's the effecient right way to do it, but it was the best I could manage without outside assitance. Here's the problem, it returns this:

<TR><TD colspan="2">a brown dog jumped over a l</TD></TR>
<TR><TD>azy fox who cares</TD><TD></TD></TR>

So I need some way to test the character at the position $getNewAbove. If it's an empty space, then life is good. However if it is a character, I need to reduce the value of $getNewAbove by one, so that the word we've landed in the middle of will rag down into the next row.

Does this make sense? Do you have any suggestions?



heath deforrest allison
"Arrowed!"




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


Current Thread