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

Re: String replace special case

Subject: Re: String replace special case
From: António Mota <amsmota@xxxxxxxxx>
Date: Mon, 13 Feb 2006 16:51:02 +0000
xsl replace substring
Here4s the full case test:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
	<xsl:template name="replace-values">
		<xsl:param name="textfrom"/>
		<xsl:param name="textwhere"/>
		<!--xsl:variable name="textfrom" select="concat($textfrom0,'&amp;')"/-->
		<xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable>
		<xsl:variable name="upper">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
		<xsl:choose>
			<xsl:when test="contains($textfrom, '{')">
				<xsl:variable name="lookfor"
select="substring-before(substring-after($textfrom,'{'),'}')"/>
				<xsl:variable name="before" select="substring-before($textfrom,
concat('{',$lookfor,'}'))"/>
				<xsl:variable name="after" select="substring-after($textfrom,
concat('{',$lookfor,'}'))"/>
				<xsl:variable name="value">
					<xsl:variable name="ulookfor" select="translate($lookfor, $lower,
$upper)"/>
					<xsl:variable name="llookfor" select="translate($lookfor, $upper,
$lower)"/>
					<xsl:variable name="utextwhere" select="translate($textwhere,
$lower, $upper)"/>
					<xsl:variable name="ltextwhere" select="translate($textwhere,
$upper, $lower)"/>
					<xsl:choose>
						<xsl:when
test="substring-before(substring-after($utextwhere,concat($ulookfor,'=')),'&a
mp;')">
							<xsl:value-of
select="substring-before(substring-after($utextwhere,
concat($ulookfor,'=')),'&amp;')"/>
						</xsl:when>
						<xsl:when
test="substring-before(substring-after($ltextwhere,concat($llookfor,'=')),'&a
mp;')">
							<xsl:value-of
select="substring-before(substring-after($ltextwhere,
concat($llookfor,'=')),'&amp;')"/>
						</xsl:when>
						<xsl:when test="substring-after($utextwhere, concat($ulookfor,'='))">
							<xsl:variable name="stest" select="substring-after($utextwhere,
concat($ulookfor,'='))"/>
							<xsl:if test="not(starts-with($stest,'&amp;'))">
								<xsl:value-of select="substring-after($utextwhere,
concat($ulookfor,'='))"/>
							</xsl:if>
						</xsl:when>
						<xsl:when test="substring-after($ltextwhere, concat($llookfor,'='))">
							<xsl:variable name="stest" select="substring-after($ltextwhere,
concat($llookfor,'='))"/>
							<xsl:if test="not(starts-with($stest,'&amp;'))">
								<xsl:value-of select="substring-after($ltextwhere,
concat($llookfor,'='))"/>
							</xsl:if>
						</xsl:when>
					</xsl:choose>
				</xsl:variable>
				<xsl:value-of select="$before"/>
				<xsl:value-of select="$value"/>
				<xsl:call-template name="replace-values">
					<xsl:with-param name="textfrom" select="$after"/>
					<xsl:with-param name="textwhere" select="$textwhere"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$textfrom"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>


	<xsl:template match="/">
		<xsl:call-template name="replace-values">
			<xsl:with-param name="textfrom"
					select="'list_entidadeprocessos.aspx?k=PAI&amp;entidade_k={ENTIDADE_K}&a
mp;processo_k={PROCESSO_K}'"/>
			<xsl:with-param name="textwhere"
select="'?businessclass=PROCESSO&amp;ENTIDADE_K=&amp;processo_k=xx0001'"/>
		</xsl:call-template>
	</xsl:template>
</xsl:stylesheet>

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.