[Home] [By Thread] [By Date] [Recent Entries]
At 2010-05-10 16:08 -0700, Red Light wrote:
i have a a table with fixed column and sometime the text overload on some adjancent column, An example I have from my classroom materials inserts a zero-width space after URI punctuation characters so that long URIs wrap in narrow columns without any visible spaces at the break points, where the input URI is the current node: replace(.,'([\[(.:/{\\])','$1​') But in your situation you could do something like the following (untested) for those text nodes that are descendants of the table construct: <xsl:variable name="length" select="10"/> <xsl:template match="table-thingy//text()" name="chop-it-up">
<xsl:param name="text" select="."/>
<xsl:choose>
<xsl:when test="string-length($text) <= $length">
<!--short enough-->
<xsl:value-of select="$text"/>
</xsl:when>
<xsl:otherwise>
<!--too long-->
<xsl:value-of select="substring( $text, 1, $length )"/>
<!--add a zero-width breaking space-->
<xsl:text>​</xsl:text>
<xsl:call-template name="chop-it-up">
<xsl:with-param name="text" select="substring($text,$length+1)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>Note that when it is matched, the entire node is bound to $text, then when it is called, only what hasn't been processed is bound to $text. I hope this helps. . . . . . . . . . . . . . Ken -- XSLT/XQuery training: after http://XMLPrague.cz 2011-03-28/04-01 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|

Cart



