Advertisement
Guest User

Untitled

a guest
Nov 28th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 6.76 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ntw="Number2Word.uri" exclude-result-prefixes="ntw">
  3.     <xsl:output method="html"/>
  4.     <xsl:variable name="ThisDocument" select="document('')"/>
  5.  
  6. <xsl:variable name="chapn">
  7. <xsl:value-of select="toc-div/toc-item/toc-title"/>
  8. </xsl:variable>
  9.    
  10.     <xsl:template match="/">
  11.         <xsl:text disable-output-escaping="yes"><![CDATA[<!DOCTYPE html>]]></xsl:text>
  12.         <html>
  13.             <head>
  14.                 <xsl:text disable-output-escaping="yes"><![CDATA[</meta>]]></xsl:text>
  15.                 <title>
  16.                 <!--TABLE OF Contents-->
  17.                     <xsl:value-of select="toc/title"/>
  18.                 </title>
  19.                 <link rel="stylesheet" href="C:\Users\u0138039\Desktop\Proview\HK\Business Law in Hong Kong\Source\XSLT\main.css" type="text/css"/><xsl:text disable-output-escaping="yes"><![CDATA[</link>]]></xsl:text>
  20.             </head>
  21.             <body>
  22.                 <section class="tr_toc">
  23.                 <xsl:apply-templates/>
  24.                 </section>
  25.             </body>
  26.         </html>
  27.     </xsl:template>
  28.    
  29.    
  30.     <xsl:template match="toc">
  31.           <div class="toc">
  32.                 <a name="BLHK_TOC_01"></a>
  33.                 <div class="toc-title">
  34.                     <xsl:value-of select="title" />
  35.                 </div>
  36.                 <xsl:for-each select="toc-part/toc-div[1]/toc-item">
  37.             <table>
  38.                 <tbody class="toc-frontitem">
  39.                     <tr>
  40.                         <td class="toc-title">
  41.                             <span class="content-style font-style-italic">
  42.                                 <xsl:value-of select="./toc-title"/>
  43.                             </span>
  44.                         </td>
  45.                         <td class="toc-pg">
  46.                         <span class="content-style font-style-italic">
  47.                                 <xsl:value-of select="./toc-pg"/>
  48.                                 </span>
  49.                         </td>
  50.                     </tr>
  51.                 </tbody>
  52.             </table>
  53.                 </xsl:for-each>
  54.                 <xsl:apply-templates select="toc-part/toc-div/title"/>
  55.           </div>
  56.       </xsl:template>
  57.  
  58.  
  59.      
  60. <xsl:template match="toc-part/toc-div/title">
  61.  
  62.       <table class="toc-div">
  63.                 <tbody>
  64.                 <tr>
  65.                 <td>
  66.                     <xsl:apply-templates select="../toc-item"/>
  67.                     </td>
  68.  
  69. </tr>
  70.                 </tbody>
  71.             </table>
  72.  
  73. </xsl:template>
  74.  
  75. <xsl:template match="chapter" mode="x">
  76. <xsl:if test="$chapn=toc-part/toc-div/toc-item/toc-title">
  77. <xsl:value-of select="toc-part/toc-div/toc-item/toc-title"/>
  78. </xsl:if>
  79.  
  80. </xsl:template>
  81.  
  82. <xsl:template match="toc-item">
  83. <xsl:variable name="prent">
  84. <xsl:value-of select="substring-before(substring-after(../title,' '),' ')"/>
  85. </xsl:variable>
  86. <xsl:variable name="tex">
  87. <xsl:value-of select="./toc-title/text()"/>
  88. </xsl:variable>
  89.  
  90. <xsl:variable name="cha">
  91. <xsl:value-of select="$prent"/>
  92. </xsl:variable>
  93. <xsl:variable name="get_tit">
  94. <xsl:value-of select="document(concat('C:\Documents and Settings\u0138039\Desktop\Proview\HK\Business Law in Hong Kong\Source\Business Law in Hong Kong/Chapter ',$cha,'.xml'))/chapter/toc/toc-part/toc-div/toc-item/toc-title/text()"/>
  95.  
  96. </xsl:variable>
  97.  
  98.  
  99.  
  100. <xsl:variable name="match">
  101.  
  102. <xsl:if test="document(concat('C:\Documents and Settings\u0138039\Desktop\Proview\HK\Business Law in Hong Kong\Source\Business Law in Hong Kong/Chapter ',$cha,'.xml'))/chapter/toc/toc-part/toc-div/toc-item/toc-title/text() = ./toc-title/text()">
  103.  
  104.  
  105. <xsl:apply-templates select="document(concat('C:\Documents and Settings\u0138039\Desktop\Proview\HK\Business Law in Hong Kong\Source\Business Law in Hong Kong/Chapter ',$cha,'.xml'))/chapter" mode="x"/>
  106. </xsl:if>
  107.  
  108. </xsl:variable>
  109.  
  110. <div class="a">
  111. <xsl:value-of select="$get_tit"/>
  112. </div>
  113. <div class="b">
  114. <xsl:value-of select="$match"/>
  115. </div>
  116. <!--
  117. <xsl:value-of select="."/>
  118. -->
  119.  
  120.  
  121.  
  122.  
  123.  
  124. <xsl:value-of select="$prent"/>
  125. <table class="toc-item">
  126.                         <tbody>
  127.                             <tr>
  128.                                
  129.                                     <xsl:choose>
  130.                                                                                                                                                     <xsl:when test="contains(./toc-title,'CHAPTER')">
  131. <td class="toc-title">
  132.                                     <xsl:value-of select="concat('CHAPTER ',substring-before(substring-after(./toc-title,' '),' '))" />
  133.                                  <xsl:text>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</xsl:text>
  134.                                     <xsl:value-of select="substring-after(substring-after(./toc-title,' '),' ')"/>
  135.                                    
  136.                                     </td>                                                                                                                  
  137.                                                                                                                                                     </xsl:when>
  138.                                                                                                                                 <xsl:when test="contains(./toc-title,'Chapter')">
  139. <td class="toc-title">
  140.                                     <xsl:value-of select="concat('CHAPTER ',substring-before(substring-after(./toc-title,' '),' '))" />
  141.                                   <xsl:text>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</xsl:text>
  142.                                     <xsl:value-of select="substring-after(substring-after(./toc-title,' '),' ')"/>
  143.                                    
  144.                                     </td>                                                                                                                                                   </xsl:when>            
  145.                                             <xsl:otherwise>
  146.                          <td class="toc-title">
  147.                                     <xsl:value-of select="normalize-space(current()/toc-title)" />
  148.                                     </td>
  149.                         </xsl:otherwise>
  150.                     </xsl:choose>
  151.                    
  152.                                    
  153.                                     <xsl:choose>
  154.                         <xsl:when test="(contains(current()/toc-subitem[1]/toc-title,'Appendix '))">
  155.                                 <td class="toc-pg">
  156.                                 <span class="font-style-italic">
  157. <xsl:value-of select="current()/toc-subitem[1]/toc-title"/></span>
  158. </td>       </xsl:when>
  159. <xsl:otherwise>
  160. </xsl:otherwise>
  161.                                 </xsl:choose>
  162.                          
  163.                             </tr>
  164.                        
  165.                         </tbody>
  166.                     </table>
  167.                
  168.                    
  169.                 <xsl:apply-templates select="toc-subitem"/>
  170.                
  171. </xsl:template>
  172. <xsl:template match="toc-subitem">
  173. <xsl:variable name="prent">
  174. <xsl:value-of select="substring-before(substring-after(../../title,' '),' ')"/>
  175. </xsl:variable>
  176. <xsl:value-of select="$prent"/>
  177. <table class="toc-third-level">
  178. <td><xsl:value-of select="./toc-title"/></td>
  179. </table>
  180. </xsl:template>
  181. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement