/[drupal]/contributions/modules/export_docbook/h2db.xsl
ViewVC logotype

Diff of /contributions/modules/export_docbook/h2db.xsl

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.4.43, Sun Sep 21 20:46:03 2008 UTC revision 1.1.4.44, Mon Sep 22 15:58:41 2008 UTC
# Line 1  Line 1 
1  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
2  <!-- $Id: h2db.xsl,v 1.1.4.42 2008/09/21 16:52:52 robertDouglass Exp $ -->  <!-- $Id: h2db.xsl,v 1.1.4.43 2008/09/21 20:46:03 robertDouglass Exp $ -->
3  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4   xmlns:html="http://www.w3.org/1999/xhtml" exclude-result-prefixes="xsl html">   xmlns:html="http://www.w3.org/1999/xhtml" exclude-result-prefixes="xsl html">
5    
# Line 23  Line 23 
23    <xsl:apply-templates select="* | text()"/>    <xsl:apply-templates select="* | text()"/>
24   </xsl:template>   </xsl:template>
25    
   
26   <!-- This template matches on all HTML header items and makes them into   <!-- This template matches on all HTML header items and makes them into
27       bridgeheads. It attempts to assign an ID to each bridgehead by looking    bridgeheads. It attempts to assign an ID to each bridgehead by looking
28       for a named anchor as a child of the header or as the immediate preceding    for a named anchor as a child of the header or as the immediate preceding
29       or following sibling -->    or following sibling -->
30   <xsl:template   <xsl:template match="html:h1
31    match="html:h1    |html:h2
32                |html:h2    |html:h3
33                |html:h3    |html:h4
34                |html:h4    |html:h5
35                |html:h5    |html:h6">
36                |html:h6">    <xsl:choose>
37    <bridgehead>     <xsl:when test="ancestor::html:ol[contains(@class, 'docbook-procedure')]"/>
38     <xsl:choose>     <xsl:otherwise>
39      <xsl:when test="count(html:a/@name)">      <bridgehead>
40       <xsl:attribute name="id">       <xsl:choose>
41        <xsl:value-of select="html:a/@name"/>        <xsl:when test="count(html:a/@name)">
42       </xsl:attribute>         <xsl:attribute name="id">
43      </xsl:when>          <xsl:value-of select="html:a/@name"/>
44      <xsl:when test="preceding-sibling::* = preceding-sibling::html:a[@name != '']">         </xsl:attribute>
45       <xsl:attribute name="id">        </xsl:when>
46        <xsl:value-of select="concat($prefix,preceding-sibling::html:a[1]/@name)"/>        <xsl:when test="preceding-sibling::* = preceding-sibling::html:a[@name != '']">
47       </xsl:attribute>         <xsl:attribute name="id">
48      </xsl:when>          <xsl:value-of select="concat($prefix,preceding-sibling::html:a[1]/@name)"/>
49      <xsl:when test="following-sibling::* = following-sibling::html:a[@name != '']">         </xsl:attribute>
50       <xsl:attribute name="id">        </xsl:when>
51        <xsl:value-of select="concat($prefix,following-sibling::html:a[1]/@name)"/>        <xsl:when test="following-sibling::* = following-sibling::html:a[@name != '']">
52       </xsl:attribute>         <xsl:attribute name="id">
53      </xsl:when>          <xsl:value-of select="concat($prefix,following-sibling::html:a[1]/@name)"/>
54     </xsl:choose>         </xsl:attribute>
55     <xsl:apply-templates/>        </xsl:when>
56    </bridgehead>       </xsl:choose>
57         <xsl:apply-templates/>
58        </bridgehead>
59       </xsl:otherwise>
60      </xsl:choose>
61   </xsl:template>   </xsl:template>
62    
63    
64   <!-- These templates perform one-to-one conversions of HTML elements into   <!-- These templates perform one-to-one conversions of HTML elements into
65       DocBook elements -->       DocBook elements -->
66   <xsl:template match="html:p">   <xsl:template match="html:p">
# Line 418  Line 422 
422    </itemizedlist>    </itemizedlist>
423   </xsl:template>   </xsl:template>
424    
425     <!-- Some ol elements are meant to be index indicators. These have the class docbook-index. -->
426     <xsl:template match="html:ol[contains(@class, 'docbook-index')]">
427      <xsl:call-template name="indexterm">
428       <xsl:with-param name="primary">
429        <xsl:if test="html:li[1]">
430         <xsl:value-of select="html:li[1]"/>
431        </xsl:if>
432       </xsl:with-param>
433       <xsl:with-param name="secondary">
434        <xsl:if test="html:li[2]">
435         <xsl:value-of select="html:li[2]"/>
436        </xsl:if>
437       </xsl:with-param>
438       <xsl:with-param name="tertiary">
439        <xsl:if test="html:li[3]">
440         <xsl:value-of select="html:li[3]"/>
441        </xsl:if>
442       </xsl:with-param>
443      </xsl:call-template>
444     </xsl:template>
445    
446     <xsl:template match="html:ol[contains(@class, 'docbook-procedure')]">
447      <procedure>
448       <xsl:apply-templates/>
449      </procedure>
450     </xsl:template>
451    
452   <xsl:template match="html:ol">   <xsl:template match="html:ol">
453    <xsl:choose>    <orderedlist>
454     <xsl:when test="contains(@class, 'docbook-index')">     <xsl:apply-templates/>
455      <xsl:call-template name="indexterm">    </orderedlist>
      <xsl:with-param name="primary">  
       <xsl:if test="html:li[1]">  
        <xsl:value-of select="html:li[1]"/>  
       </xsl:if>  
      </xsl:with-param>  
      <xsl:with-param name="secondary">  
       <xsl:if test="html:li[2]">  
        <xsl:value-of select="html:li[2]"/>  
       </xsl:if>  
      </xsl:with-param>  
      <xsl:with-param name="tertiary">  
       <xsl:if test="html:li[3]">  
        <xsl:value-of select="html:li[3]"/>  
       </xsl:if>  
      </xsl:with-param>  
     </xsl:call-template>  
    </xsl:when>  
    <xsl:otherwise>  
     <orderedlist>  
      <xsl:apply-templates/>  
     </orderedlist>  
    </xsl:otherwise>  
   </xsl:choose>  
456   </xsl:template>   </xsl:template>
457    
458   <xsl:template name="indexterm">   <xsl:template name="indexterm">
# Line 560  Line 568 
568   </xsl:template>   </xsl:template>
569    
570   <xsl:template match="html:li">   <xsl:template match="html:li">
571    <listitem>    <!-- <li> elements that contain a heading (h2 - h6) are <step> elements and the <h*> becomes
572     <xsl:apply-templates/>         a <title> element. -->
573    </listitem>    <xsl:choose>
574       <xsl:when test="./parent::html:ol[contains(@class, 'docbook-procedure')]">
575        <step>
576         <xsl:if test="./html:h2 or ./html:h3 or ./html:h4 or ./html:h5 or ./html:h6">
577          <title>
578           <xsl:value-of
579            select="html:h2[text()] | html:h3[text()] | ./html:h4[text()] | ./html:h5[text()] | ./html:h6[text()]"
580           />
581          </title>
582         </xsl:if>
583         <xsl:apply-templates/>
584        </step>
585       </xsl:when>
586       <xsl:otherwise>
587        <listitem>
588         <xsl:apply-templates/>
589        </listitem>
590       </xsl:otherwise>
591      </xsl:choose>
592   </xsl:template>   </xsl:template>
593    
594   <xsl:template match="*">   <xsl:template match="*">

Legend:
Removed from v.1.1.4.43  
changed lines
  Added in v.1.1.4.44

  ViewVC Help
Powered by ViewVC 1.1.2