[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Remapping image paths

Subject: Re: Remapping image paths
From: Josh Canfield <joshcanfield@xxxxxxxxx>
Date: Tue, 22 Jun 2004 09:48:47 -0700
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>
> --+--
> 
>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.