Hello,
I have a template where i am trying to restrict the string length
using sub-string. My string has subtree elements (mostly html tags
like <b>, <sup> etc) and i want to retain them as it is. I use
copy-of but found i loose the subtree elements when using sub-string
- i mean this results in an html output having no <b>, <sup> or any
other subtree elements - while the content within them gets thro!. I
retain subtree elements if i just use copy-of WITHOUT sub-string.
sample string:
In this session we <sub>this</sub><b>Bold</b> take a closer look at
what is meant by strategy. ... big para content
I get:
In this session we thisBold take a closer look at what is meant by
strategy...
What i want (same as input string):
In this session we <sub>this</sub><b>Bold</b> take a closer look at
what is meant by strategy...
In my xsl i pass my content to a trimPara template whenever i have to
restrict the length like:
<xsl:template name="trimPara">
<!-- pass the string to be cropped with required string length
-->
<xsl:param name="stringLenRequired"/>
<xsl:param name="stringInput"/>
<xsl:copy-of select="$stringInput"/> <!-- this retains subtree
elements here, while i lose them in below
statemments where i use sub-string, which i have to do -->
<xsl:copy-of
select="substring($stringInput,1,number($stringLenRequired))"/>
<xsl:copy-of
select="substring-before(concat(substring($stringInput,number($stringLenRequired)+1,number($stringLenRequired)
+20),' ' ),'
')"/> <!-- to make it a full word -->
<xsl:if test="string-length($stringInput) >
number($stringLenRequired)">...</xsl:if>
</xsl:template>
Pls suggest me how can i retain the subtree elements while using
sub-string. Are there any other method i can acheive this? Thanks in
adv
karl
Send instant messages to your online friends http://uk.messenger.yahoo.com
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--