home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / fix-imagelinks.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  1.9 KB  |  60 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17.  
  18. <!-- A small stylesheet to make image links in *.fo files absolute.  This is
  19. currently necessary because FOP doesn't know the 'context' in which it is
  20. operating, and so cannot resolve relative URLs.  This hack will go away once the
  21. Cocoon<->FOP link improves (it's fixed for CVS trunk FOP, but that isn't too
  22. usable yet).  -->
  23.  
  24. <xsl:stylesheet
  25.   version="1.0"
  26.   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  27.   xmlns:fo="http://www.w3.org/1999/XSL/Format">
  28.  
  29.   <!-- Absolute path to context root -->
  30.   <xsl:param name="ctxroot" select="'[ctxroot]'"/>
  31.  
  32.   <!-- context-relative path of current directory -->
  33.   <xsl:param name="dir" select="'[dir]'"/>
  34.  
  35.   <xsl:template match="fo:external-graphic/@src">
  36.     <xsl:attribute name="src">
  37.       <xsl:value-of select="$ctxroot"/>
  38.       <xsl:choose>
  39.         <xsl:when test="starts-with(., '/')">
  40.           <xsl:value-of select="."/>
  41.         </xsl:when>
  42.         <xsl:otherwise>
  43.           <xsl:value-of select="$dir"/>
  44.           <xsl:value-of select="."/>
  45.         </xsl:otherwise>
  46.       </xsl:choose>
  47.     </xsl:attribute>
  48.   </xsl:template>
  49.  
  50.  
  51.   <!-- Copy across everything else unchanged. -->
  52.   <xsl:template match="node()|@*" priority="-1">
  53.     <xsl:copy>
  54.       <xsl:apply-templates select="@*"/>
  55.       <xsl:apply-templates/>
  56.     </xsl:copy>
  57.   </xsl:template>
  58.  
  59. </xsl:stylesheet>
  60.