Expand | Collapse

◀ 5. HTML document7. Text elements ▶

6. Structuring elements

Implements the XHTML Structural Module.

xsl:stylesheet id="stylesheet" exclude-result-prefixes="x2 lit xs" version="1.0" xml:lang="en"

address
blockcode
blockquote
div
h
p
pre
section
separator

title-text: format a title

xsl:template match="x2:address"
  xsl:call-template name="copy-xhtml1"
xsl:template match="x2:blockcode"
  xsl:call-template name="copy-xhtml1"
    xsl:with-param name="tag-name" select="'pre'"
  
xsl:template match="x2:blockquote"
  xsl:call-template name="copy-xhtml1"
xsl:template match="x2:div"
  xsl:call-template name="copy-xhtml1"
xsl:template match="x2:pre"
  xsl:call-template name="copy-xhtml1"
xsl:template match="x2:section"
  xsl:call-template name="copy-xhtml1"
    xsl:with-param name="tag-name" select="'div'"
    xsl:with-param name="content"
      xsl:apply-templates select="child::x2:h" mode="heading"
      <div>
        xsl:attribute name="id"
          xsl:call-template name="id"
            xsl:with-param name="suffix" select="'.content'"
          
        

        xsl:apply-templates
      </div>
    
  
xsl:template match="x2:separator"
  xsl:call-template name="copy-xhtml1"
    xsl:with-param name="tag-name" select="'hr'"
  
xsl:template match="x2:p"
  xsl:call-template name="copy-xhtml1"

xsl:template match="x2:h"


xsl:template match="x2:h" mode="heading"
  xsl:variable name="level" select="count(ancestor::x2:section)+1"
  xsl:variable name="level-capped"
    xsl:choose
      xsl:when test="$level > 6"6
      xsl:otherwisexsl:value-of select="$level"
    
  
  xsl:element name="{concat('h', $level-capped)}" namespace="http://www.w3.org/1999/xhtml"

    xsl:variable name="content-id"
      xsl:call-template name="id"
        xsl:with-param name="target" select=".."
        xsl:with-param name="suffix" select="'.content'"
      
    

    <a href="{concat('#', $content-id)}">
      xsl:attribute name="class"_collapse-toggle
      xsl:attribute name="onclick"
        xsl:textreturn xhtml2to1_collapse_toggle('
        xsl:value-of select="$content-id"
        xsl:text', event)
      
      xsl:text▼
    </a>

    xsl:call-template name="number"
      xsl:with-param name="target" select=".."
    

    xsl:text 
    xsl:apply-templates
  

6.1. title-text: format a title

The title-text mode formats a piece of markup as a title on output.

Presently, it merely applies normal (inline) stylesheet templates to the piece of markup.

xsl:template match="xs:title" mode="title-text"
        xsl:apply-templates
      
xsl:template match="x2:h" mode="title-text"
        xsl:apply-templates
      

Formatted using xhtml2to1 by Steve Cheng.