home *** CD-ROM | disk | FTP | other *** search
/ Encyclopaedia Britannica …oncise Encyclopedia 2007 / bcd_concise07.iso / data / jars / oec2-lib.jar / xsl / shared / ArtAssembly.xsl next >
Encoding:
Extensible Markup Language  |  2006-08-25  |  8.9 KB  |  295 lines

  1. <xsl:stylesheet 
  2.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.     xmlns:html="http://www.w3.org/TR/html4/loose.dtd"
  4.     exclude-result-prefixes="html"
  5.     version="1.0">
  6.  
  7.   <xsl:import href="ContentTags.xsl"/>
  8.   <xsl:import href="RefLinks.xsl"/>
  9.   <xsl:import href="Variables.xsl"/>
  10.  
  11.   <xsl:output method="html"/>
  12.  
  13.   <xsl:template match="/">
  14.         <html>
  15.       <head>
  16.         <title><xsl:value-of select="assemblyXml/assemblyTitle"/></title>
  17.       </head>
  18.       <body><xsl:apply-templates select="assemblyXml/asmbly"/></body>
  19.       </html>
  20.    </xsl:template>
  21.  
  22.  
  23.   <xsl:template match="asmbly">
  24.     <center><div>   
  25.     <xsl:apply-templates select="imgmap | asset"/>
  26.     <xsl:apply-templates select="caption"/>
  27.     <br/>
  28.     <xsl:apply-templates select="credit"/>
  29.     </div></center>
  30.   </xsl:template>
  31.  
  32.  
  33.   <xsl:template match="imgmap">
  34.     <xsl:apply-templates/>    
  35.   </xsl:template>
  36.  
  37.   <xsl:template match="mapcap">
  38.     <xsl:param name="xcnt">
  39.      <xsl:value-of select="count(xref)"/>
  40.    </xsl:param>
  41.  
  42.  <!-- imglink tag will be deleted and replaced by assetlink once we publish new data -->
  43.  <!-- we parse both tags in order to make it backward compatible -->
  44.  
  45.    <xsl:param name="icnt">
  46.         <xsl:value-of select="count(assetlink)"/>
  47.    </xsl:param> 
  48.  
  49.  <!-- artlink tag will be deleted and replaced by assemblylink once we publish new data -->
  50.  <!-- we parse both tags in order to make it backward compatible -->
  51.  
  52.   <xsl:param name="acnt">
  53.       <xsl:value-of select="count(assemblylink)"/>
  54.   </xsl:param>
  55.   
  56.    <xsl:choose>         
  57.         <!-- combination of imglink and xref -->
  58.     <xsl:when test="$xcnt > 1 and $icnt > 1">
  59.       <table>
  60.         <tr>
  61.           <td width="300" valign="top"><div align="center">
  62.              <xsl:for-each select="assetlink">
  63.                 <xsl:apply-templates select="."/><br/>
  64.              </xsl:for-each></div>
  65.           </td>
  66.           <td width="300" valign="top"><div align="center">
  67.               <xsl:for-each select="xref">
  68.                 <xsl:apply-templates select="."/><br/>
  69.               </xsl:for-each></div>
  70.           </td>
  71.         </tr>
  72.       </table>
  73.     </xsl:when>
  74.     <xsl:when test="$xcnt >= 1 and $acnt >= 1"><!-- fixed bug from nigeria article's map. -->
  75.       <table>
  76.         <tr>
  77.           <td width="300" valign="top"><div align="center">
  78.              <xsl:for-each select="assemblylink">
  79.                 <xsl:apply-templates select="."/><br/>
  80.              </xsl:for-each></div>
  81.           </td>
  82.           <td width="300" valign="top"><div align="center">
  83.               <xsl:for-each select="xref">
  84.                 <xsl:apply-templates select="."/><br/>
  85.               </xsl:for-each></div>
  86.           </td>
  87.         </tr>
  88.       </table>
  89.     </xsl:when>
  90.      <!-- xref only -->
  91.     <xsl:when test="$xcnt > 1">
  92.      <xsl:value-of select="text()[position() = 1]"/><p/>
  93.       <xsl:call-template name="linksUnderMap">
  94.         <xsl:with-param name="cnt"><xsl:value-of select="$xcnt"/></xsl:with-param>
  95.         <xsl:with-param name="linktype">xref</xsl:with-param>
  96.       </xsl:call-template>
  97.     </xsl:when>
  98.          <!-- imglink only -->
  99.         <xsl:when test="$icnt > 1">
  100.       <xsl:call-template name="linksUnderMap">
  101.         <xsl:with-param name="cnt"><xsl:value-of select="$icnt"/></xsl:with-param>
  102.         <xsl:with-param name="linktype">imglink</xsl:with-param>
  103.       </xsl:call-template>
  104.     </xsl:when>
  105.      <!-- artlink only -->
  106.     <xsl:when test="$acnt > 1">
  107.       <xsl:call-template name="linksUnderMap">
  108.         <xsl:with-param name="cnt"><xsl:value-of select="$acnt"/></xsl:with-param>
  109.         <xsl:with-param name="linktype">artlink</xsl:with-param>
  110.       </xsl:call-template>
  111.     </xsl:when>
  112.     <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
  113.  
  114.    </xsl:choose>
  115.   </xsl:template>
  116.  
  117. <xsl:template name="linksUnderMap">
  118.     <xsl:param name="cnt">0</xsl:param>
  119.     <xsl:param name="linktype"></xsl:param>
  120.     <xsl:param name="avecnt" select="round($cnt div 2)"/>
  121.  
  122.      <table>
  123.         <tr>
  124.           <td width="250">
  125.           <xsl:choose>
  126.            <xsl:when test="$linktype = 'xref'">
  127.              <xsl:for-each select="xref">
  128.             <xsl:if test="position() <= $avecnt">
  129.                   <xsl:apply-templates select="."/><br/>
  130.                   <xsl:value-of select="following-sibling::text()"/><p/>
  131.             </xsl:if>
  132.              </xsl:for-each>
  133.            </xsl:when>
  134.            <xsl:when test="$linktype = 'imglink'">
  135.              <xsl:for-each select="assetlink">
  136.             <xsl:if test="position() <= $avecnt">
  137.                   <xsl:apply-templates select="."/><br/>
  138.             </xsl:if>
  139.              </xsl:for-each>
  140.            </xsl:when>
  141.            <xsl:when test="$linktype = 'artlink'">
  142.              <xsl:for-each select="assemblylink">
  143.             <xsl:if test="position() <= $avecnt">
  144.                   <xsl:apply-templates select="."/><br/>
  145.             </xsl:if>
  146.             </xsl:for-each>
  147.            </xsl:when>
  148.            </xsl:choose>
  149.           </td>
  150.           <td width="40"/>
  151.           <td valign="top" width="250">
  152.            <xsl:choose>
  153.               <xsl:when test="$linktype = 'xref'">
  154.             <xsl:for-each select="xref">
  155.               <xsl:if test="position() > $avecnt">
  156.                <xsl:apply-templates select="."/><br/>
  157.                <xsl:value-of select="following-sibling::text()"/><p/>
  158.               </xsl:if>
  159.             </xsl:for-each>
  160.             </xsl:when>
  161.             <xsl:when test="$linktype = 'imglink'">    
  162.               <xsl:if test="position() > $avecnt">
  163.                   <xsl:apply-templates select="."/><br/>
  164.               </xsl:if>
  165.             </xsl:when>
  166.             <xsl:when test="$linktype = 'artlink'">
  167.                 <xsl:for-each select="assemblylink">
  168.               <xsl:if test="position() > $avecnt">
  169.                   <xsl:apply-templates select="."/><br/>
  170.               </xsl:if>
  171.                 </xsl:for-each>
  172.             </xsl:when>
  173.            </xsl:choose>
  174.           </td>
  175.         </tr>
  176.     </table>
  177. </xsl:template>
  178.  
  179.   <xsl:template match="caphead">
  180.     <p><xsl:apply-templates/></p>
  181.   </xsl:template>
  182.     
  183.   <xsl:template match="p">
  184.     <p><xsl:apply-templates/></p>
  185.   </xsl:template>
  186.  
  187.     <xsl:template match="frac">
  188.         <xsl:apply-templates select="num"/>/<xsl:apply-templates select="den"/>
  189.     </xsl:template>
  190.  
  191.  
  192.   <xsl:template match="credit">
  193.     <i><xsl:apply-templates/></i>
  194.   </xsl:template>
  195.   
  196.   <xsl:template name="new_multimedia">
  197.    <xsl:variable name="filename" select="@filename"/>
  198.    <xsl:variable name="subdir" select="substring-after($filename,'.')"/>
  199.    <xsl:variable name="mediaDir" select="concat('/new-multimedia/',$subdir,'/',$filename)"/>
  200.  
  201.    <xsl:choose>
  202.       <xsl:when test="@bintype='8'">
  203.         <xsl:if test="not(preceding-sibling::*/@bintype='9') and not(following-sibling::*/@bintype='9')">
  204.     <embed src="{$mediaDir}" width="{@wdth}" height="{@hgt}"/>
  205.         </xsl:if>
  206.       </xsl:when>
  207.       <xsl:when test="@bintype='5'">
  208.         <xsl:if test="not(preceding-sibling::*/@bintype='4') and not(following-sibling::*/@bintype='4')">
  209.     <embed src="{$mediaDir}" width="{@wdth}" height="{@hgt}"/>
  210.         </xsl:if>
  211.  
  212.       </xsl:when>
  213.       <xsl:when test="@bintype='20'"> <!-- audio type assembly xml data has width and height=0 -->
  214.         <embed src="{$mediaDir}"/>
  215.       </xsl:when>
  216.       <xsl:otherwise>
  217.     <embed src="{$mediaDir}" width="{@wdth}" height="{@hgt}"/>
  218.       </xsl:otherwise>
  219.    </xsl:choose>
  220.   </xsl:template>
  221.  
  222.   <xsl:template name="img">
  223.     <img vspace="6">
  224.       <xsl:attribute name="height"><xsl:value-of select="@hgt"/></xsl:attribute>
  225.       <xsl:attribute name="width"><xsl:value-of select="@wdth"/></xsl:attribute>
  226.  
  227.       <!-- temporary hack until "name" attribute of the map element is fixed -->
  228.       <xsl:if test="@imgmap = 'y'">
  229.         <xsl:attribute name="usemap">#<xsl:value-of select="following-sibling::imgmap/map/@name"/></xsl:attribute>
  230.       </xsl:if>
  231.  
  232.       <xsl:attribute name="src"><xsl:value-of select="$imageURL"/>?id=<xsl:value-of select="@id"/></xsl:attribute>
  233.       <xsl:attribute name="alt"><xsl:value-of select="/asmbly/caption"/></xsl:attribute>
  234.  
  235.     </img>
  236.   </xsl:template>
  237.  
  238.  
  239. <xsl:template match="asset">
  240.     <xsl:choose>
  241.       <xsl:when test="@bintype > 2">
  242.         <xsl:call-template name="new_multimedia"/>
  243.       </xsl:when>
  244.       <xsl:otherwise>
  245.         <xsl:call-template name="img"/>
  246.       </xsl:otherwise>
  247.     </xsl:choose>  
  248.     <br/>
  249. </xsl:template>
  250.  
  251.   <xsl:template match="map">
  252.     <map name="{@name}"><xsl:apply-templates/></map>
  253.   </xsl:template>
  254.   
  255.   <xsl:template match="area">
  256.     <xsl:choose>
  257.  
  258.     <xsl:when test="@reftype='toc'">
  259.       <xsl:call-template name="area">
  260.         <xsl:with-param name="URL"><xsl:value-of select="$articleURL"/>?tocId=<xsl:value-of select="@refid"/></xsl:with-param>
  261.       </xsl:call-template>
  262.     </xsl:when>
  263.  
  264.     <xsl:when test="@reftype='bin'">
  265.       <xsl:call-template name="area">
  266.         <xsl:with-param name="URL"><xsl:value-of select="$assemblyURL"/>?id=<xsl:value-of select="@refid"/></xsl:with-param>
  267.       </xsl:call-template>
  268.     </xsl:when>
  269.  
  270.     <xsl:when test="@reftype='asm'">
  271.       <xsl:call-template name="area">
  272.         <xsl:with-param name="URL"><xsl:value-of select="$assemblyURL"/>?id=<xsl:value-of select="@refid"/></xsl:with-param>
  273.       </xsl:call-template>
  274.     </xsl:when>
  275.  
  276.     </xsl:choose>
  277.   </xsl:template>
  278.  
  279.   <xsl:template name="area">
  280.     <xsl:param name="URL"></xsl:param>
  281.     <area coords="{@coords}" shape="{@shape}" href="{$URL}"/> 
  282.   </xsl:template>
  283.  
  284.   
  285.   <xsl:template match="assetlink">
  286.     <a class="artcopybold" href="{$assemblyURL}?id={@binid}&type=I"><xsl:apply-templates/></a>
  287.   </xsl:template>
  288.  
  289.  
  290.   <xsl:template match="assemblylink">
  291.     <a class="artcopybold" href="{$assemblyURL}?id={@asmid}&type=A"><xsl:apply-templates/></a>
  292.   </xsl:template>
  293.  
  294. </xsl:stylesheet>  
  295.