Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

xsl template question

 
Angelo Bonaparte
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm trying to get familiar with XSL and got the following code from the web that replaces a string withing a string with a selected string. Ie. let's says I have george@mysite.com I would like to replace it with george_REMOVE_AT_mysite.com. So here is the template....




and here is how i try to access it. I can't seem to find the correct way to call it. I get Could not find function: replace-string. The code works if I just display text but it crashes when I try to use the replace-string template.



Thanks for any guidance.
 
Paul Clapham
Sheriff
Posts: 21149
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You call it in your main template in exactly the same way you called it recursively in itself:
 
Angelo Bonaparte
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That did the trick. I just gotta figure out how to display the result of calling that template. I tried a few ways already but without success.
 
Paul Clapham
Sheriff
Posts: 21149
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That depends on what you mean by "display". Normally an XSLT stylesheet produces a result (which can be XML or HTML or text). So by "display" do you mean you want the xsl:call-template element to include something in the result? It doesn't return a value itself, so whatever it is you want included in the result, the template has to do that.

But if you wrap that in an xsl:variable element, then that variable becomes the output destination for the time being.
[ April 04, 2007: Message edited by: Paul Clapham ]
 
Angelo Bonaparte
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response it's appreciated. Before I added a template to replace the @ to AT in an email address I had the following wich rendered the html to display Email Address: then the email address.

Here is the code:



Now with the code below my html renders, no errors occur but I only get the label, the actual email with the @ removed doesn't show. Here is the code.
Again, thanks for all your help.
 
Paul Clapham
Sheriff
Posts: 21149
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You passed the constant string "text" to the template. Based on what you posted earlier, I would expect to see that same string appearing in the output. (I do that all the time too.)
 
Angelo Bonaparte
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I will try again but so far I only get the label Contact Email:
but the email address doesn't appear. I will try different things to see what happens.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic