xsl-list
[Top] [All Lists]

Re: Change text on given node at runtime

2003-07-23 09:53:45
Hi Jeff ,
  You can try a XSL something like below. This will
replace the contents of tag <A> with 'Some new text'
and copy other things to output as it is. But you want
to provide the tag name and the new text, *at run
time*. If you can tell what is your XSLT processor and
*how you would like to supply the 2 parameters at run
time*, i can try modifying the stylesheet accordingly.

 i don't know if Jeni's XSL is meeting your
requirement(it looks quite complicated to me for your
problem).

Regards,
Mukul

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml" version="1.0"
encoding="UTF-8" indent="yes"/>
 <xsl:template match="@* | node()">
   <xsl:copy>
     <xsl:apply-templates />
   </xsl:copy>      
 </xsl:template>        
        
 <xsl:template match="A">
   <A>Some new text</A>
 </xsl:template>
        
</xsl:stylesheet>


--- jeff(_dot_)day(_at_)bt(_dot_)com wrote:
Hi

Can you please give some guidance on this...

I would like to be able, at runtime, to parse an XML
file and change 

<A>Original text</A>

to

<A>Some new text</A>


On the next occasion I might want to do this...

<F>Old text</F>

change to

<F>New text</F>

So at runtime I need to pass in two parameters that
specify the required
node and the new text for it.

There are two issues: Either change the text in
every node called <A>
throughout the document or else only change <A>
along a particular path. A
solution to either (or both?) option will do for me.

Of course the rest of the document must remain in
its entirety, e.g.
attributes, children etc.

Many thanks for any help given.

Regards

Jeff 


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



__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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