home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 March / maximum-cd-2011-03.iso / DiscContents / LibO_3.3.0rc1_Win_x86_install_multi.exe / libreoffice33.msi / print.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2010-12-01  |  5.9 KB  |  190 lines

  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.     version="1.0">
  4.     <!-- XSLT stylesheet to pretty print grammar.xml
  5.         
  6.         usage:
  7.         
  8.         java -jar saxon8.jar grammar.xml print.xsl
  9.         
  10.     -->
  11.     <xsl:output method="html" encoding="UTF-8" indent="no" />
  12.  
  13.     <xsl:template match="text()" />
  14.  
  15.     <xsl:template match="*">    
  16.             <xsl:apply-templates select="*">
  17.                 <xsl:sort select="@name"/>
  18.             </xsl:apply-templates>
  19.     </xsl:template>
  20.     
  21.     <xsl:template match="//category">        
  22.         <xsl:variable name="category_name" select="@name"/>
  23.         <xsl:variable name="cat_id" select="generate-id()"/>
  24.         <xsl:element name="div">
  25.         <xsl:attribute name="id"><xsl:copy-of select="$cat_id"/></xsl:attribute>
  26.         <xsl:attribute name="style">display:none</xsl:attribute>            
  27.         <h4>        
  28.         <xsl:element name="a">
  29.         <xsl:attribute name="href">javascript:;</xsl:attribute>
  30.         <xsl:attribute name="onmousedown">toggleDiv('<xsl:copy-of select="$cat_id"/>');</xsl:attribute>
  31.         <xsl:value-of select="$category_name"/>
  32.         </xsl:element>
  33.         (<xsl:value-of select="count(rule[@id!=''])+count(rulegroup[@id!=''])"/>)
  34.         </h4>
  35.         <ol>            
  36.             <xsl:apply-templates select="*">
  37.                 <xsl:sort select="@name"/>
  38.             </xsl:apply-templates>
  39.         </ol>
  40.         </xsl:element>
  41.         <h4>        
  42.         <xsl:element name="a">
  43.         <xsl:attribute name="href">javascript:;</xsl:attribute>
  44.         <xsl:attribute name="onmousedown">toggleDiv('<xsl:copy-of select="$cat_id"/>');</xsl:attribute>
  45.         <xsl:value-of select="$category_name"/>
  46.         </xsl:element>
  47.         (<xsl:value-of select="count(rule[@id!=''])+count(rulegroup[@id!=''])"/>)
  48.         </h4>
  49.     </xsl:template>
  50.  
  51.  
  52.     <xsl:template match="//rule[@id!='']">
  53.         <li>
  54.             <xsl:value-of select="@name" />            
  55.         </li>
  56.         <ul>
  57.             <xsl:apply-templates select="*" />
  58.         </ul>
  59.     </xsl:template>
  60.  
  61.     <xsl:template match="//rulegroup">
  62.         <li>
  63.             <xsl:value-of select="@name" />
  64.         </li>
  65.         <ul>
  66.             <xsl:apply-templates select="*" />
  67.         </ul>
  68.     </xsl:template>
  69.  
  70.  
  71.     <xsl:template match="//rule/example[@type='incorrect']">
  72.         <li>
  73.             <xsl:apply-templates select="*|text()" /> <br/>
  74.             <xsl:if test="@correction !=''">
  75.             <xsl:choose>
  76.             <xsl:when test="not(contains(@correction, '|')) and not(contains(../message/text(), '\')) and count(../message/text()) < 3">
  77.             <xsl:copy-of select="../message/text()[1]"/>
  78.             <strong style="color: #339900;"><xsl:value-of select="@correction"/></strong>
  79.             <xsl:copy-of select="../message/text()[2]"/>
  80.             </xsl:when>
  81.             <xsl:otherwise>
  82.             <!--  two problems: parse correction, i.e., split it on "|" 
  83.             and replace \1 with ../pattern/token[1]/text() 
  84.             <xsl:copy-of select="../pattern/token[2]/text()"/>
  85.             for now, we simply print "Correction", and skip the message                        
  86.             <xsl:variable name="cor_text" select="substring-before(@correction, '|')"/>
  87.             <strong style="color: #339900;">
  88.                 <xsl:value-of select="$cor_text"/>
  89.             </strong>
  90.             <xsl:variable name="cor_text" select="substring-after($cor_text,'|')"/>
  91.             aaaa <xsl:value-of select="$cor_text"/>
  92.             <xsl:if test="contains($cor_text, '|')">
  93.                 <xsl:variable name="message_cnt" select="$message_cnt + 1"/>
  94.                 aas
  95.                 <xsl:copy-of select="../message/text()[$message_cnt]"/>
  96.                 <xsl:variable name="cor_text" select="substring-before(@correction, '|')"/>
  97.                 <strong style="color: #339900;">
  98.                     <xsl:value-of select="$cor_text"/>
  99.                 </strong>
  100.                 <xsl:variable name="message_cnt" select="$message_cnt + 1"/>
  101.                 <xsl:copy-of select="../message/text()[$message_cnt]"/>
  102.             </xsl:if>            
  103.             </xsl:when>
  104.             <xsl:otherwise>
  105.             <xsl:copy-of select="../message/text()[1]"/>
  106.             </xsl:otherwise>
  107.             </xsl:choose>
  108.                         -->
  109.             <xsl:choose>
  110.             <xsl:when test="//rules[@lang='pl']">Poprawnie: </xsl:when>
  111.             <xsl:when test="//rules[@lang='en']">Correctly: </xsl:when>
  112.             <xsl:when test="//rules[@lang='de']">Korrekt: </xsl:when>
  113.             <xsl:when test="//rules[@lang='fr']">Correctement : </xsl:when>
  114.             <xsl:when test="//rules[@lang='nl']">Correct: </xsl:when>
  115.             <xsl:when test="//rules[@lang='es']">Correctamente: </xsl:when>
  116.             </xsl:choose>
  117.                 <strong style="color: #339900;">
  118.                     <xsl:value-of select="@correction"/>
  119.                 </strong>
  120.             <!-- 
  121.             <xsl:variable name="text_count" select="count(../message/text())"/>
  122.             <xsl:value-of select="../message/text()[$text_count]"/>            
  123.              -->
  124.              </xsl:otherwise>
  125.              </xsl:choose>
  126.             </xsl:if>
  127.         </li>
  128.     </xsl:template>
  129.  
  130.     <xsl:template match="//rule/example[@type='incorrect']/text()">
  131.         <xsl:copy-of select="." />
  132.     </xsl:template>
  133.  
  134.     <xsl:template match="//rule/example[@type='incorrect']/marker">
  135.         <strong style="color: rgb(255, 0, 0);">
  136.             <xsl:value-of select="./text()" />
  137.         </strong>
  138.     </xsl:template>
  139.     
  140.     <xsl:template match="//rules">    
  141.     <html>
  142.     <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
  143.     <head>
  144.     <script language="javascript">
  145.     <xsl:text>
  146.       function toggleDiv(divid){
  147.         if(document.getElementById(divid).style.display == 'none'){
  148.           document.getElementById(divid).style.display = 'block';
  149.         }else{
  150.           document.getElementById(divid).style.display = 'none';
  151.         }
  152.       }
  153.      </xsl:text>
  154.     </script>
  155.     </head>
  156.     <body>
  157.         <noscript><p><strong>Note:</strong> this page requires Javascript to work</p></noscript>
  158.         <xsl:choose>
  159.         <xsl:when test="//rules[@lang='pl']">┼ü─àczna liczba regu┼é: </xsl:when>
  160.         <xsl:otherwise>Total number of rules: </xsl:otherwise>
  161.         </xsl:choose>
  162.         <strong>
  163.             <xsl:value-of select="count(//rule)"/>
  164.         </strong>        
  165.         <br/>
  166.         <xsl:choose>
  167.         <xsl:when test="//rules[@lang='pl']">W tym z podpowiedziami: </xsl:when>
  168.         <xsl:otherwise>Rules with suggestions: </xsl:otherwise>
  169.         </xsl:choose>
  170.         <strong>
  171.             <xsl:value-of select="count(//message[suggestion!=''])"/>
  172.         </strong>
  173.         <br/>
  174.         <xsl:choose>
  175.         <xsl:when test="//rules[@lang='pl']">Liczba widocznych typ├│w regu┼é: </xsl:when>
  176.         <xsl:otherwise>Total number of visible rule types: </xsl:otherwise>
  177.         </xsl:choose>
  178.         <strong>
  179.             <xsl:value-of select="count(//rule[@id!=''])+count(//rulegroup[@id!=''])"/>
  180.         </strong>        
  181.         <br/>
  182.     
  183.             <xsl:apply-templates select="*">
  184.                 <xsl:sort select="@name"/>
  185.             </xsl:apply-templates>
  186.     </body>
  187.     </html>
  188.     </xsl:template>    
  189.     
  190. </xsl:stylesheet>