home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / building / xmlspy / xmlspyentcomplete5.exe / Data1.cab / _E44CF4D4EC2B47D8B98E71B70643F612 < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-04  |  7.4 KB  |  199 lines

  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
  4.                 xmlns:sverb="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Verbatim"
  5.                 xmlns:xverb="com.nwalsh.xalan.Verbatim"
  6.                 xmlns:lxslt="http://xml.apache.org/xslt"
  7.                 exclude-result-prefixes="sverb xverb lxslt"
  8.                 version='1.0'>
  9.  
  10. <!-- ********************************************************************
  11.      $Id: callout.xsl,v 1.1.2.1 2002/09/04 14:24:58 jdj Exp $
  12.      ********************************************************************
  13.  
  14.      This file is part of the XSL DocBook Stylesheet distribution.
  15.      See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  16.      and other information.
  17.  
  18.      ******************************************************************** -->
  19.  
  20. <lxslt:component prefix="xverb"
  21.                  functions="insertCallouts"/>
  22.  
  23. <xsl:template match="programlistingco|screenco">
  24.   <xsl:variable name="verbatim" select="programlisting|screen"/>
  25.   <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
  26.  
  27.   <xsl:choose>
  28.     <xsl:when test="$use.extensions != '0'
  29.                     and $callouts.extension != '0'">
  30.       <xsl:variable name="rtf">
  31.         <xsl:apply-templates select="$verbatim">
  32.           <xsl:with-param name="suppress-numbers" select="'1'"/>
  33.         </xsl:apply-templates>
  34.       </xsl:variable>
  35.  
  36.       <xsl:variable name="rtf-with-callouts">
  37.         <xsl:choose>
  38.           <xsl:when test="contains($vendor, 'SAXON ')">
  39.             <xsl:copy-of select="sverb:insertCallouts(areaspec,$rtf)"/>
  40.           </xsl:when>
  41.           <xsl:when test="contains($vendor, 'Apache Software Foundation')">
  42.             <xsl:copy-of select="xverb:insertCallouts(areaspec,$rtf)"/>
  43.           </xsl:when>
  44.           <xsl:otherwise>
  45.             <xsl:message terminate="yes">
  46.               <xsl:text>Don't know how to do callouts with </xsl:text>
  47.               <xsl:value-of select="$vendor"/>
  48.             </xsl:message>
  49.           </xsl:otherwise>
  50.         </xsl:choose>
  51.       </xsl:variable>
  52.  
  53.       <xsl:choose>
  54.         <xsl:when test="$verbatim/@linenumbering = 'numbered'
  55.                         and $linenumbering.extension != '0'">
  56.           <xsl:call-template name="number.rtf.lines">
  57.             <xsl:with-param name="rtf" select="$rtf-with-callouts"/>
  58.             <xsl:with-param name="pi.context"
  59.                             select="programlisting|screen"/>
  60.           </xsl:call-template>
  61.           <xsl:apply-templates select="calloutlist"/>
  62.         </xsl:when>
  63.         <xsl:otherwise>
  64.           <xsl:copy-of select="$rtf-with-callouts"/>
  65.           <xsl:apply-templates select="calloutlist"/>
  66.         </xsl:otherwise>
  67.       </xsl:choose>
  68.     </xsl:when>
  69.     <xsl:otherwise>
  70.       <xsl:apply-templates/>
  71.     </xsl:otherwise>
  72.   </xsl:choose>
  73. </xsl:template>
  74.  
  75. <xsl:template match="areaspec|areaset|area">
  76. </xsl:template>
  77.  
  78. <xsl:template match="areaset" mode="conumber">
  79.   <xsl:number count="area|areaset" format="1"/>
  80. </xsl:template>
  81.  
  82. <xsl:template match="area" mode="conumber">
  83.   <xsl:number count="area|areaset" format="1"/>
  84. </xsl:template>
  85.  
  86. <xsl:template match="co">
  87.   <fo:inline id="{@id}">
  88.     <xsl:apply-templates select="." mode="callout-bug"/>
  89.   </fo:inline>
  90. </xsl:template>
  91.  
  92. <xsl:template match="co" mode="callout-bug">
  93.   <xsl:call-template name="callout-bug">
  94.     <xsl:with-param name="conum">
  95.       <xsl:number count="co" format="1"/>
  96.     </xsl:with-param>
  97.   </xsl:call-template>
  98. </xsl:template>
  99.  
  100. <xsl:template name="callout-bug">
  101.   <xsl:param name="conum" select='1'/>
  102.  
  103.   <xsl:choose>
  104.     <!-- Draw callouts as images -->
  105.     <xsl:when test="$callout.graphics != '0'
  106.                     and $conum <= $callout.graphics.number.limit">
  107.       <xsl:variable name="filename"
  108.                     select="concat($callout.graphics.path,$conum,$callout.graphics.extension)"/>
  109.  
  110.       <fo:external-graphic>
  111.         <xsl:attribute name="src">
  112.           <xsl:choose>
  113.             <xsl:when test="$passivetex.extensions != 0
  114.                             or $fop.extensions != 0
  115.                             or $arbortext.extensions != 0">
  116.               <xsl:value-of select="$filename"/>
  117.             </xsl:when>
  118.             <xsl:otherwise>
  119.               <xsl:text>url(</xsl:text>
  120.               <xsl:value-of select="$filename"/>
  121.               <xsl:text>)</xsl:text>
  122.             </xsl:otherwise>
  123.           </xsl:choose>
  124.         </xsl:attribute>
  125.       </fo:external-graphic>
  126.     </xsl:when>
  127.  
  128.     <xsl:when test="$callout.unicode != 0
  129.                     and $conum <= $callout.unicode.number.limit">
  130.       <xsl:variable name="comarkup">
  131.         <xsl:choose>
  132.           <xsl:when test="$callout.unicode.start.character = 10102">
  133.             <xsl:choose>
  134.               <xsl:when test="$conum = 1">❶</xsl:when>
  135.               <xsl:when test="$conum = 2">❷</xsl:when>
  136.               <xsl:when test="$conum = 3">❸</xsl:when>
  137.               <xsl:when test="$conum = 4">❹</xsl:when>
  138.               <xsl:when test="$conum = 5">❺</xsl:when>
  139.               <xsl:when test="$conum = 6">❻</xsl:when>
  140.               <xsl:when test="$conum = 7">❼</xsl:when>
  141.               <xsl:when test="$conum = 8">❽</xsl:when>
  142.               <xsl:when test="$conum = 9">❾</xsl:when>
  143.               <xsl:when test="$conum = 10">❿</xsl:when>
  144.             </xsl:choose>
  145.           </xsl:when>
  146.           <xsl:otherwise>
  147.             <xsl:message>
  148.               <xsl:text>Don't know how to generate Unicode callouts </xsl:text>
  149.               <xsl:text>when $callout.unicode.start.character is </xsl:text>
  150.               <xsl:value-of select="$callout.unicode.start.character"/>
  151.             </xsl:message>
  152.             <fo:inline background-color="#404040"
  153.                        color="white"
  154.                        padding-top="0.1em"
  155.                        padding-bottom="0.1em"
  156.                        padding-start="0.2em"
  157.                        padding-end="0.2em"
  158.                        baseline-shift="0.1em"
  159.                        font-family="{$body.font.family}"
  160.                        font-weight="bold"
  161.                        font-size="75%">
  162.               <xsl:value-of select="$conum"/>
  163.             </fo:inline>
  164.           </xsl:otherwise>
  165.         </xsl:choose>
  166.       </xsl:variable>
  167.  
  168.       <xsl:choose>
  169.         <xsl:when test="$callout.unicode.font != ''">
  170.           <fo:inline font-family="{$callout.unicode.font}">
  171.             <xsl:copy-of select="$comarkup"/>
  172.           </fo:inline>
  173.         </xsl:when>
  174.         <xsl:otherwise>
  175.           <xsl:copy-of select="$comarkup"/>
  176.         </xsl:otherwise>
  177.       </xsl:choose>
  178.     </xsl:when>
  179.  
  180.     <!-- Most safe: draw a dark gray square with a white number inside -->
  181.     <xsl:otherwise>
  182.       <fo:inline background-color="#404040"
  183.                  color="white"
  184.                  padding-top="0.1em"
  185.                  padding-bottom="0.1em"
  186.                  padding-start="0.2em"
  187.                  padding-end="0.2em"
  188.                  baseline-shift="0.1em"
  189.                  font-family="{$body.font.family}"
  190.                  font-weight="bold"
  191.                  font-size="75%">
  192.         <xsl:value-of select="$conum"/>
  193.       </fo:inline>
  194.     </xsl:otherwise>
  195.   </xsl:choose>
  196. </xsl:template>
  197.  
  198. </xsl:stylesheet>
  199.