[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

Subject: How to retain subtree elements while using sub-string
From: Karl <call14@xxxxxxxxx>
Date: Fri, 3 Nov 2006 12:22:33 +0000 (GMT)
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 

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.