Remapping image paths

Subject: Remapping image paths
From: Max Romantschuk <max@xxxxxxxxxx>
Date: Tue, 22 Jun 2004 09:14:10 +0300
I'm working on a system where I have an XHTML based data storage, an I'm using XSLT to extract the relevant bits and pieces into the page framework. I'm keeping my individual pages paths following this pattern: /content/name_of_page/

I'd like to use XSLT to take the paths of img elements referring to image files and make them relative to the root of the site, where my actual site engine resides.

Thus <img src="an_image_file.jpeg" /> would become <img src="content/name_of_page/an_image_file.jpeg" />

I'm using PHP and Sablotron, and I can pass the path of the current page's path into the stylesheet.

This should be rather trivial, but the XSLT references I've ran into so far aren't very detailed on string manipulation.

An additional requirement would be to leave src attribute values pointing to other sites (starting with 'http://') alone. I guess I can do this with xsl:if and a substring match?

Could someone give me an example, or (even better) point me to a decent reference on XSLT string manipulation?

Thanks in advance!

.max


-- Max Romantschuk http://max.nma.fi/

Current Thread