Oleg Tkachenko [MVP] napisał(a):
Jarek Mielcarek wrote:
in xml file I have some fields which are source for <textarea> element.
I'd like to transform this file using xslt and set the rows property
of <textarea> depend of lines in some source field.
How to do this?
Height is a visual property and as such is really hard to calculate. You
better set rows and cols properties according to number of characters
the textarea contains. Something like
rows = ceiling(string-length($content ) div $cols)
thx for help. it works when I do something like this:
<xsl:template match="/">
...
<textarea id="descr1" cols="40">
<xsl:choose>
<xsl:when test="ceiling(s tring-length(//descr1) div 40) < 4">
<xsl:attribut e name="rows">4</xsl:attribute>
</xsl:when>
<xsl:otherwis e>
<xsl:attribut e name="rows"><xs l:value-of
select="ceiling (string-length(//descr1) div 40)+1" /></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="//descr1" />
</textarea>
....
</xsl:template>
but it doesn't set row property in this sample:
<xsl:template match="/">
...
<textarea id="descr3" cols="40">
<xsl:apply-templates select="/document/descr3"/>
</textarea>
....
</xsl:template>
<xsl:template match="descr1|d escr2|descr3">
<xsl:choose>
<xsl:when test="ceiling(s tring-length(.) div 40) < 4">
<xsl:attribut e name="rows">4</xsl:attribute>
</xsl:when>
<xsl:otherwis e>
<xsl:attribut e name="rows"><xs l:value-of
select="ceiling (string-length(.) div 40)+1" /></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="." />
</xsl:template>
the question is why?
jaro