[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: preserving html tags

Subject: Re: preserving html tags
From: Karl <call14@xxxxxxxxx>
Date: Wed, 1 Nov 2006 16:50:45 +0000 (GMT)
substring before html tags
My problem is related to rendering html content like
"content<b>bold</b>...contents" as it in xml into the output html. I
am using <apply-templates> to select content but later use <value-of>
to trim it. Suspect <value-of> removing the html tags (not sure), but
are there any other way to get proper results?
 
Basically my xml looks something like

		<Introduction>
			<Title>Introduction</Title>
			<Paragraph>In this session we <sub>this</sub><b>Bold</b> take a
closer look at what is meant by strategy. The classical approach to
strategic management  ... big para content
 			</Paragraph>
 			<Paragraph/>
		</Introduction>
		<Section/>

I am trying to output 1st para of certain elements & limit the para
content to certain char limit. so, in my xsl 

		<xsl:for-each select="//Introduction | 
//Session/Section/SubSection | //References | //Acknowledgements">
			<xsl:variable name="titleContent">				
				<xsl:value-of select="name()"/>
			</xsl:variable>
			<xsl:variable name="paraContent">
				<xsl:if test=".//Paragraph[1] and (name() = 'SubSection' or
name() = 'Introduction')">
					<xsl:apply-templates select=".//Paragraph[1]"/>
				</xsl:if>
			</xsl:variable>
			<p class="paradefault">
				<xsl:call-template name="trimPara">
					<xsl:with-param 

name="stringLenRequired">200</xsl:with-param>
					<xsl:with-param name="stringInput" 

select="$paraContent"/>
				</xsl:call-template>
			</p>
		</xsl:for-each>

and then ...

	<xsl:template name="trimPara">
		<!-- pass the string to be cropped with required string length -->
		<xsl:param name="stringLenRequired"/>
		<xsl:param name="stringInput"/>
		<xsl:value-of 

select="substring($stringInput,1,number($stringLenRequired))"/>
		<xsl:value-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>


This results in an html output having no <b>, <sup> or any other html
tags - while the content within them gets thro. I dont know where
those html tags gets striped. Pls let me know how can this be fixed.

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-2013 All Rights Reserved.