Subject: Re: [xsl] Text output line width setting technique From: Senthilukvelaan <skumaravelan@xxxxxxxxxxxxxx> Date: Wed, 8 Apr 2009 10:48:04 +0100 |
Hi All, I have found a solution for the same. <xsl:template name="wrap-string"> <xsl:param name="str" /> <xsl:param name="wrap-col" /> <xsl:param name="break-mark" /> <xsl:param name="pos" select="0" /> <xsl:choose> <xsl:when test="contains( $str, ' ' )"> <xsl:variable name="before" select="substring-before( $str, ' ' )" /> <xsl:variable name="pos-now" select="$pos + string-length( $before )" /> <xsl:choose> <xsl:when test="$pos = 0" /> <xsl:when test="floor( $pos div $wrap-col ) != floor( $pos-now div $wrap-col )"> <xsl:copy-of select="$break-mark" /> </xsl:when> <xsl:otherwise> <xsl:text> </xsl:text> </xsl:otherwise> </xsl:choose> <xsl:value-of select="$before" /> <xsl:call-template name="wrap-string"> <xsl:with-param name="str" select="substring-after( $str, ' ' )" /> <xsl:with-param name="wrap-col" select="$wrap-col" /> <xsl:with-param name="break-mark" select="$break-mark" /> <xsl:with-param name="pos" select="$pos-now" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:if test="$pos > 0"><xsl:text> </xsl:text></xsl:if> <xsl:value-of select="$str" /> </xsl:otherwise> </xsl:choose> </xsl:template> and it can be invoked by calling <xsl:call-template name="wrap-string"> <xsl:with-param name="str" select="normalize-space(.)"/> <xsl:with-param name="wrap-col" select="80"/> <xsl:with-param name="break-mark" select="'	 '"/> </xsl:call-template> I hope it might help one like me. On Wed, Apr 8, 2009 at 10:39 AM, Michael Ludwig <mlu@xxxxxxxxxxxxx> wrote: > Senthilukvelaan schrieb: >> >> I use XSLT 1.0. >> is there any way to text hard wrapping by line size in XSLT1.0. > > It is possible doing it by hand. But honestly, I wouldn't attempt it, > too much tedium. > > I'd consider postprocessing the transformation output using Perl > and the excellent Text::Autoformat module by Damian Conway. > > http://search.cpan.org/perldoc/Text::Autoformat > > Michael Ludwig
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Text output line width se, Michael Ludwig | Thread | [xsl] doc-available timeout, Emmanuel Bégué |
Re: [xsl] Text output line width se, Michael Ludwig | Date | RE: [xsl] doc-available timeout, Michael Kay |
Month |