[xsl] Re: replacing parts of a string

Subject: [xsl] Re: replacing parts of a string
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Thu, 15 Jan 2004 20:37:30 +0100
"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