[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] How to retain subtree elements while using sub-string
Subject: [xsl] How to retain subtree elements while using sub-string From: Karl <call14@xxxxxxxxx> Date: Fri, 3 Nov 2006 12:22:33 +0000 (GMT) |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Count of unique attribute, Michael Kay | Thread | [xsl] Quotes in expression, Ed Yau |
SV: [xsl] Help needed to transform , Per Osnes | Date | Re: [xsl] Count of unique attribute, Andrew Welch |
Month |
Keywords