Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 17th, 2007, 06:20 AM
Registered User
 
Join Date: Jul 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default modifying a node in xslt

Hi all,

Would it be possible to gain a little guidance on this problem i have.

Basically i have a node that contains a URL. I basically want to modify the URL so it automatically adds two further strings. for example user types in www.google.com. Then i want the xslt to add strings onto it automatically, like /search for example. resulting in the URL to be www.google.com/search?

can anyone help?

Thanks in advance

 
Old July 17th, 2007, 07:25 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I can't see why you're finding this difficult. You just need something like

<xsl:template match="url">
  <xsl:value-of select="concat(.,'/search')"/>
</xsl:template>

Mind you, building URLs by concatenating strings has many pitfalls if you're going to make it robust.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 17th, 2007, 08:25 AM
Registered User
 
Join Date: Jul 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Would it be more difficult like this;

www.google.com/images/image.jpg

*i want to change it through xslt by doing this

www.google.com/images/_t/image_jpg.jpg?

i basically want to add a subdomain to the route and a simple extention to the name of the image file?

its all because of thumb nails you see

could you please help on this final stage of my project?

many thanks again

 
Old July 17th, 2007, 09:15 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

XSLT 1.0 provides a fairly limited range of operators for string manipulation: concat(), substring(), substring-before(), and a few others. But you can do surprisingly complex things if you learn how to write recursive templates. XSLT 2.0 has a much richer repertoire including full regular expressions - matches(), tokenize(), and replace().

If you have a specific problem achieving a specific transformation with these functions then I can help you. However, you must first specify the problem precisely, and you then need to make your best efforts to solve it for yourself. I'm not going to write the code for you.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT Help to get value from Upper Node by compare pixelheart XSLT 10 May 1st, 2008 12:25 PM
changing output for one node in XSLT shane_carty XSLT 3 February 27th, 2008 05:28 AM
XSLT Going up a level from current node. lafilip XSLT 4 February 23rd, 2007 03:06 PM
Problem regarding finding the node in xslt. rohitjain13 XSLT 1 October 6th, 2005 03:26 AM
Modifying time with XSLT bigdog-yahoo XSLT 3 March 30th, 2005 11:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.