You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by je...@apache.org on 2003/06/22 08:47:40 UTC

cvs commit: cocoon-2.1/src/blocks/fop/samples/misc fix-imagelinks.xsl minimal.fo.xml

jefft       2003/06/21 23:47:40

  Modified:    src/blocks/fop/samples sitemap.xmap
               src/blocks/fop/samples/misc minimal.fo.xml
  Added:       src/blocks/fop/samples/misc fix-imagelinks.xsl
  Log:
  Add an image to the PDF, to show one way of doing it.
  
  Revision  Changes    Path
  1.7       +8 -1      cocoon-2.1/src/blocks/fop/samples/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/fop/samples/sitemap.xmap,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- sitemap.xmap	10 Jun 2003 23:58:43 -0000	1.6
  +++ sitemap.xmap	22 Jun 2003 06:47:40 -0000	1.7
  @@ -52,6 +52,13 @@
               <!-- xsl-fo document access -->
               <map:match pattern="**/*.fo.xml">
                   <map:generate src="{1}/{2}.fo.xml"/>
  +                <!-- This stylesheet makes image URLs absolute, so that FOP can
  +                display images. {realpath:/} returns the absolute path of the
  +                context root. -->
  +                <map:transform src="misc/fix-imagelinks.xsl">
  +                  <map:parameter name="ctxroot" value="{realpath:/}"/>
  +                  <map:parameter name="dir" value="samples/fop/{1}/"/>
  +                </map:transform>
                   <map:serialize type="xml"/>
               </map:match>
   
  
  
  
  1.2       +4 -1      cocoon-2.1/src/blocks/fop/samples/misc/minimal.fo.xml
  
  Index: minimal.fo.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/fop/samples/misc/minimal.fo.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- minimal.fo.xml	1 May 2003 11:23:27 -0000	1.1
  +++ minimal.fo.xml	22 Jun 2003 06:47:40 -0000	1.2
  @@ -24,6 +24,9 @@
       <fo:page-sequence master-reference="main">
   
           <fo:flow flow-name="xsl-region-body">
  +            <fo:block padding="24pt">
  +                <fo:external-graphic src="/resources/images/cocoon.gif"/>
  +            </fo:block>
               <fo:block font-size="18pt">
                   Congratulations!
               </fo:block>
  @@ -33,4 +36,4 @@
               </fo:block>
           </fo:flow>
       </fo:page-sequence>
  -</fo:root>
  \ No newline at end of file
  +</fo:root>
  
  
  
  1.1                  cocoon-2.1/src/blocks/fop/samples/misc/fix-imagelinks.xsl
  
  Index: fix-imagelinks.xsl
  ===================================================================
  <?xml version="1.0" encoding="utf-8"?>
  
  <!-- A small stylesheet to make image links in *.fo files absolute.  This is
  currently necessary because FOP doesn't know the 'context' in which it is
  operating, and so cannot resolve relative URLs.  This hack will go away once the
  Cocoon<->FOP link improves (it's fixed for CVS trunk FOP, but that isn't too
  usable yet).  -->
  
  <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format">
  
    <!-- Absolute path to context root -->
    <xsl:param name="ctxroot" select="'[ctxroot]'"/>
  
    <!-- context-relative path of current directory -->
    <xsl:param name="dir" select="'[dir]'"/>
  
    <xsl:template match="fo:external-graphic/@src">
      <xsl:attribute name="src">
        <xsl:value-of select="$ctxroot"/>
        <xsl:choose>
          <xsl:when test="starts-with(., '/')">
            <xsl:value-of select="substring(., 2)"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$dir"/>
            <xsl:value-of select="."/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:attribute>
    </xsl:template>
  
  
    <!-- Copy across everything else unchanged. -->
    <xsl:template match="node()|@*" priority="-1">
      <xsl:copy>
        <xsl:apply-templates select="@*"/>
        <xsl:apply-templates/>
      </xsl:copy>
    </xsl:template>
  
  </xsl:stylesheet>