File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes xsl template question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xsl template question" Watch "xsl template question" New topic
Author

xsl template question

Angelo Bonaparte
Greenhorn

Joined: Aug 02, 2006
Posts: 19
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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

You call it in your main template in exactly the same way you called it recursively in itself:
Angelo Bonaparte
Greenhorn

Joined: Aug 02, 2006
Posts: 19
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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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

Joined: Aug 02, 2006
Posts: 19
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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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

Joined: Aug 02, 2006
Posts: 19
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: xsl template question