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

Re: replacing parts of a string

Subject: Re: replacing parts of a string
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Thu, 15 Jan 2004 20:37:30 +0100
copy part of a string
"Jonny Pony" <jonnypony666@xxxxxxxxxxx> wrote in message
news:Law14-F89Gad6bd89m000009edc@xxxxxxxxxxxxxx
> Hi,
>
> OK. Downloaded your files. Did the things you said.
> Now call me dumb:
> I don't know how to invoke your "template".
>
> Let's say I have:
> <hello>
>
<LongString>12rt,dsfg,dsfg,ewrt,wert,xcvbs,rwete,ehgfh,xxxxxasd,awersdf,dfgx
vxcv</LongString>
>
<LongString>76rt,dsfg,dsfg,ewrt,wert,xcvbs,rwete,ehgfh,xxxxxasd,awersdf,dfgx
vxcv</LongString>
>
<LongString>wert,ds4,dsfg,ewrt,wert,xcvbs,rwete,ehgfh,xxxxxasd,awersdf,dfgxv
xcv</LongString>
>
<LongString>wert,d12,dsfg,ewrt,wert,xcvbs,rwete,ehgfh,xxxxxasd,awersdf,dfgxv
xcv</LongString>
> </hello>
>
> What would I "do" in my xsl to invoke your "function"?
> Sorry, but I have no clue.

Answer: Nothing. Just run the transformation. The result is:

<LongString> 12rt,  dsfg,  dsfg,  ewrt,  wert,  xcvbs,  rwete,  ehgfh,
xxxxxasd,  awersdf,  dfgxvxcv</LongString>
<LongString> 76rt,  dsfg,  dsfg,  ewrt,  wert,  xcvbs,  rwete,  ehgfh,
xxxxxasd,  awersdf,  dfgxvxcv</LongString>
<LongString> wert,  ds4,  dsfg,  ewrt,  wert,  xcvbs,  rwete,  ehgfh,
xxxxxasd,  awersdf,  dfgxvxcv</LongString>
<LongString> wert,  d12,  dsfg,  ewrt,  wert,  xcvbs,  rwete,  ehgfh,
xxxxxasd,  awersdf,  dfgxvxcv</LongString>

If you want to copy all other nodes (unchanged) just put the identity rule
as the first template in the stylesheet:

   <xsl:template match="@*|node()">
     <xsl:copy>
       <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>
   </xsl:template>

Now the output is:

<hello>
  <LongString> 12rt,  dsfg,  dsfg,  ewrt,  wert,  xcvbs,  rwete,  ehgfh,
xxxxxasd,  awersdf,  dfgxvxcv</LongString>
  <LongString> 76rt,  dsfg,  dsfg,  ewrt,  wert,  xcvbs,  rwete,  ehgfh,
xxxxxasd,  awersdf,  dfgxvxcv</LongString>
  <LongString> wert,  ds4,  dsfg,  ewrt,  wert,  xcvbs,  rwete,  ehgfh,
xxxxxasd,  awersdf,  dfgxvxcv</LongString>
  <LongString> wert,  d12,  dsfg,  ewrt,  wert,  xcvbs,  rwete,  ehgfh,
xxxxxasd,  awersdf,  dfgxvxcv</LongString>
</hello>


Dimitre Novatchev.
FXSL developer,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.