|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] How to retain subtree elements while using sub-string
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






