|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Remapping image paths
Something like this?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:variable name="path-start" select="'content/name_of_page/'"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="img[not(starts-with(@src, 'http://'))]">
<img src="{$path-start}{@src}">
<xsl:copy-of select="@*[name() != 'src']"/>
</img>
</xsl:template>
<xsl:template match="img">
<xsl:copy>
<xsl:copy-of select="@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Josh
On Tue, 22 Jun 2004 09:14:10 +0300, Max Romantschuk <max@xxxxxxxxxx> wrote:
>
> 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/
>
> --+------------------------------------------------------------------
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
> --+--
>
>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








