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

  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <xsl:stylesheet 
  4.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  5.     xmlns:html="http://www.w3.org/TR/html4/loose.dtd"
  6.     exclude-result-prefixes="html"
  7.     version="1.0">
  8.  
  9.   <xsl:output method="html" encoding="UTF-8"/>
  10.  
  11.   <xsl:template match="firstparagraph">
  12.     <xsl:apply-templates select="body | class"/>
  13.   </xsl:template>
  14.  
  15.  
  16.   <!-- don't need to output title since title is in title tag -->
  17.   <xsl:template match="title">
  18.   </xsl:template>
  19.  
  20.   <xsl:template match="titlsub">
  21.   </xsl:template>
  22.  
  23.   <xsl:template match="tabbrev|chemsym">
  24.   </xsl:template>
  25.  
  26.   <xsl:template match="firstart">
  27.   </xsl:template>
  28.  
  29.  
  30.   <xsl:template match="asset">
  31.   </xsl:template>
  32.  
  33.   <xsl:template match="class">
  34.         <xsl:variable name="parseBody">
  35.         <xsl:apply-templates select="label"/> <xsl:apply-templates select="commonname"/> 
  36.         <xsl:apply-templates select="desc"/>
  37.         </xsl:variable>
  38.         <xsl:choose>
  39.             <xsl:when test="string-length($parseBody) > 300">
  40.                 <xsl:call-template name="gist">
  41.                     <xsl:with-param name="gistbody" select="$parseBody"/>
  42.                 </xsl:call-template>...
  43.             </xsl:when>
  44.             <xsl:otherwise>
  45.                 <xsl:value-of select="$parseBody"/>
  46.             </xsl:otherwise>
  47.         </xsl:choose>
  48.   </xsl:template>
  49.     
  50.     <xsl:template match="body">
  51.         <xsl:variable name="parseBody">
  52.             <xsl:apply-templates/>
  53.         </xsl:variable>
  54.         <xsl:choose>
  55.             <xsl:when test="string-length($parseBody) > 300">
  56.                 <xsl:call-template name="gist">
  57.                     <xsl:with-param name="gistbody" select="$parseBody"/>
  58.                 </xsl:call-template>...
  59.             </xsl:when>
  60.             <xsl:otherwise>
  61.                 <xsl:value-of select="$parseBody"/>
  62.             </xsl:otherwise>
  63.         </xsl:choose>
  64.     </xsl:template>
  65.     
  66.     <xsl:template name="gist">
  67.         <xsl:param name="charposition" select="300"/>
  68.         <xsl:param name="gistbody"/>
  69.         <xsl:choose>
  70.             <xsl:when test="substring($gistbody,$charposition,1) = ' '">
  71.                 <xsl:value-of select="substring($gistbody,1,$charposition)" disable-output-escaping="no"/>
  72.             </xsl:when>
  73.             <xsl:otherwise>
  74.                 <xsl:call-template name="gist">
  75.                      <xsl:with-param name="charposition" select="$charposition - 1"/>
  76.                     <xsl:with-param name="gistbody" select="$gistbody"/>
  77.                 </xsl:call-template>
  78.          </xsl:otherwise>
  79.      </xsl:choose>
  80.  </xsl:template>
  81. </xsl:stylesheet>  
  82.