View Single Post
  #6 (permalink)  
Old December 25th, 2003, 09:33 AM
armmarti armmarti is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: Nor Hachin, Kotayk, Armenia.
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to armmarti
Default

Quote:
quote:Originally posted by Birger
 Hi armmati!
That's a lot of code for a Search/Replace. Wouldn't it be possible to have such a function available in another file to be called when needed?

Thanks in advance
If you want to search the whole XML document, this code is quite small :). If you know where your text can be found exactly (that is, the parent node of the text node containing the text you want to replace; it's the element "seller" in your example), then you can avoid walking through the whole document and perform replacements. Instead, you can get the content of the text node and call the "replace" template.
Or if you don't want XSLT, you have to write recursive method, in Java for example, (if you still want to search the whole XML doc) which again will walk through the whole tree and perform appropriate replacements.
About keeping the "replace" template in a separate file: it's a good idea of course, since the template is general; you can freely move the template into separate file, say replace-string.xsl, then include it in the main stylesheet.

Regards,
Armen
Reply With Quote