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

RE: How to substitute a portion of the text value of a

Subject: RE: How to substitute a portion of the text value of an element
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 7 Oct 2008 21:53:42 +0100
RE:  How to substitute a portion of the text value of a
Apply it to $old and $new at the time you declare the variables, then

    <xsl:variable name="f" select="translate(., '/', '\')"/>
    <xsl:value-of select="substring-before($f,$old)"/>
    <xsl:value-of select="$new"/>
    <xsl:value-of select="substring-after($f,$old)"/>

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Paul [mailto:pflists@xxxxxxxxx] 
> Sent: 07 October 2008 21:43
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  How to substitute a portion of the text 
> value of an element
> 
> The difficulty I guess is knowing when to apply the translate.
> 
> Ken's code above in the thread:
> 
>  <xsl:copy>
>    <xsl:value-of select="substring-before(.,$old)"/>
>    <xsl:value-of select="$new"/>
>    <xsl:value-of select="substring-after(.,$old)"/>
> </xsl:copy>
> 
> needs to have the substring-before work if the slashes in 
> $old and the slashes in the . are different. Perhaps I need 
> to first translate all occurrences to some canonical form 
> before I do the substring-before or substring-after test if 
> that is possible.
> 
> Paul
> 
> 
> On Tue, Oct 7, 2008 at 4:13 PM, Syd Bauman 
> <Syd_Bauman@xxxxxxxxx> wrote:
> >> Is there a function I can call to first convert the slashes to one 
> >> unified format before applying the substring?
> >
> > translate(.,'\','/')

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.