Wednesday 15 June 2011

xslt - How to generate empty space in a fo:block if there is no valued in the extracted element? -



xslt - How to generate empty space in a fo:block if there is no valued in the extracted element? -

i using xsl-fo , fop .95, whenever write code in xsl-fo have utilize statement generate empty space:

<fo:block> <xsl:choose> <xsl:when test="normalize-space(seller_name)!=''"> <xsl:value-of select="normalize-space(seller_name)"/> </xsl:when> <xsl:otherwise><xsl:text>&#160;</xsl:text></xsl:otherwise> </xsl:choose> </fo:block>

i dont want utilize these take when conditions generate empty space save block collapse. there function or property can used here? have tried line-feed-treatment , white-space-collapse didnt work. please advise something.

if happy have above, why not template it. cut down phone call 3 lines:

<xsl:template name="blockwithblank"> <xsl:param name="field"/> <fo:block> <xsl:choose> <xsl:when test="normalize-space($field)!=''"> <xsl:value-of select="$field"/> </xsl:when> <xsl:otherwise><xsl:text>&#160;</xsl:text></xsl:otherwise> </xsl:choose> </fo:block> </xsl:template>

that above 1 time in whole stylesheet, each of calls 3 lines:

<xsl:call-template name="blockwithblank"> <xsl:with-param name="field" select="seller_name"/> </xsl:call-template>

i not sure can shorten more 3 lines each call.

xslt xsl-fo

No comments:

Post a Comment