diff options
author | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-07-20 16:48:06 +0100 |
---|---|---|
committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-07-20 16:48:06 +0100 |
commit | 8e8edc70b402e69953fb9135a58d7faee12dc088 (patch) | |
tree | e8815e7ef185ccaba26bcd616eace378572b922e /xhtml5 | |
download | docbook-xsl-8e8edc70b402e69953fb9135a58d7faee12dc088.tar.gz |
Tarball conversion
Diffstat (limited to 'xhtml5')
-rw-r--r-- | xhtml5/README | 61 | ||||
-rw-r--r-- | xhtml5/chunk.xsl | 29 | ||||
-rw-r--r-- | xhtml5/chunkfast.xsl | 69 | ||||
-rw-r--r-- | xhtml5/docbook.css.xml | 104 | ||||
-rw-r--r-- | xhtml5/docbook.xsl | 21 | ||||
-rw-r--r-- | xhtml5/html5-chunk-mods.xsl | 111 | ||||
-rw-r--r-- | xhtml5/html5-element-mods.xsl | 773 | ||||
-rw-r--r-- | xhtml5/onechunk.xsl | 36 | ||||
-rw-r--r-- | xhtml5/profile-chunk.xsl | 52 | ||||
-rw-r--r-- | xhtml5/profile-docbook.xsl | 23 | ||||
-rw-r--r-- | xhtml5/xhtml-docbook.xsl | 495 | ||||
-rw-r--r-- | xhtml5/xhtml-profile-docbook.xsl | 408 | ||||
-rw-r--r-- | xhtml5/xhtml2xhtml5.xsl | 49 |
13 files changed, 2231 insertions, 0 deletions
diff --git a/xhtml5/README b/xhtml5/README new file mode 100644 index 0000000..c0db6b7 --- /dev/null +++ b/xhtml5/README @@ -0,0 +1,61 @@ +DocBook stylesheets for HTML5 output +============================================= + +This directory contains XSL stylesheets +for generating HTML5 output from DocBook content. +For information on HTML5, see: + +http://dev.w3.org/html5/spec/Overview.html + +Note that there is no schema available for HTML5, by design. + +The output of these stylesheets is the XML serialization of +HTML5. There is no provision for generating the HTML +serialization of HTML5 with these stylesheets. + +These HTML5 stylesheets are also used by the EPUB3 +stylesheets included in this distribution. + +These stylesheets are customizations of the +existing stylesheets in the "xhtml/" directory. +Using a customization layer enables the HTML5 +stylesheets to inherit all the features of the +XHTML stylesheets while making the minimum changes +for them to produce valid HTML5. + +If you are processing DocBook 5 document, you should use +the namespaced version of the stylesheets, with "-ns-" +in the directory name. + + +Usage +----------- +You should be able to apply any of these stylesheet files +to a DocBook document as with any other DocBook stylesheet: + +xhtml5/docbook.xsl - Single file output. +xhtml5/chunk.xsl - Chunked output. +xhtml5/profile-docbook.xsl - Profiled single file output. +xhtml5/profile-chunk.xsl - Profiled chunk output. +xhtml5/chunkfast.xsl - Chunked output with precomputed chunks. + +Do not attempt to directly use the following two stylesheet files: + +xhtml-docbook.xsl +xhtml-profile-docbook.xsl + +Those are copies of the corresponding files in the +xhtml/ directory, modified to remove the doctype +declarations in the xsl:output elements. They were also +modified to import from the original xhtml/ directory. +They will produce xhtml output, not HTML5 output. +They are imported by the xhtml5 stylesheet files. + +Testing +-------------- + +The HTML5 output of these stylesheets should pass the +W3C online validator, available here: + +http://validator.w3.org/ + diff --git a/xhtml5/chunk.xsl b/xhtml5/chunk.xsl new file mode 100644 index 0000000..e3fc396 --- /dev/null +++ b/xhtml5/chunk.xsl @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsl:stylesheet + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:exsl="http://exslt.org/common" + xmlns="http://www.w3.org/1999/xhtml" + exclude-result-prefixes="exsl" + version="1.0"> + +<!-- $Id: chunk.xsl,v 1.1 2011-09-16 21:43:59 bobs Exp $ --> + +<!-- This is the main driver stylesheet file. It imports or +includes all the components that it needs. --> + +<!-- Import the module that customizes docbook elements --> +<!-- Put any customizations of element content in this module. --> +<xsl:import href="docbook.xsl"/> + +<xsl:import href="../xhtml/chunk-common.xsl"/> + +<xsl:include href="../xhtml/chunk-code.xsl"/> + +<!-- The following module has templates that override the stock + xhtml templates for HTML5 output. + It contains match templates with priority="1" attributes, + and named templates. These override any templates that + handle chunking behavior --> +<xsl:include href="html5-chunk-mods.xsl"/> + +</xsl:stylesheet> diff --git a/xhtml5/chunkfast.xsl b/xhtml5/chunkfast.xsl new file mode 100644 index 0000000..fd1be4d --- /dev/null +++ b/xhtml5/chunkfast.xsl @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="ASCII"?> +<!--This file was created automatically by html2xhtml--> +<!--from the HTML stylesheets.--> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0" xmlns="http://www.w3.org/1999/xhtml" version="1.0" exclude-result-prefixes="cf exsl"> + +<!-- ******************************************************************** + $Id: chunkfast.xsl,v 1.1 2011-09-16 21:44:00 bobs Exp $ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://docbook.sf.net/release/xsl/current/ for + copyright and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:import href="chunk.xsl"/> +<xsl:param name="chunk.fast" select="1"/> + +<xsl:variable name="chunks" select="exsl:node-set($chunk.hierarchy)//cf:div"/> + +<!-- ==================================================================== --> + +<xsl:template name="process-chunk-element"> + <xsl:choose> + <xsl:when test="$chunk.fast != 0 and $exsl.node.set.available != 0"> + <xsl:variable name="genid" select="generate-id()"/> + + <xsl:variable name="div" select="$chunks[@id=$genid or @xml:id=$genid]"/> + + <xsl:variable name="prevdiv" select="($div/preceding-sibling::cf:div|$div/preceding::cf:div|$div/parent::cf:div)[last()]"/> + <xsl:variable name="prev" select="key('genid', ($prevdiv/@id|$prevdiv/@xml:id)[1])"/> + + <xsl:variable name="nextdiv" select="($div/following-sibling::cf:div|$div/following::cf:div|$div/cf:div)[1]"/> + <xsl:variable name="next" select="key('genid', ($nextdiv/@id|$nextdiv/@xml:id)[1])"/> + + <xsl:choose> + <xsl:when test="$onechunk != 0 and parent::*"> + <xsl:apply-imports/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="process-chunk"> + <xsl:with-param name="prev" select="$prev"/> + <xsl:with-param name="next" select="$next"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:choose> + <xsl:when test="$onechunk != 0 and not(parent::*)"> + <xsl:call-template name="chunk-all-sections"/> + </xsl:when> + <xsl:when test="$onechunk != 0"> + <xsl:apply-imports/> + </xsl:when> + <xsl:when test="$chunk.first.sections = 0"> + <xsl:call-template name="chunk-first-section-with-parent"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="chunk-all-sections"/> + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +</xsl:stylesheet> diff --git a/xhtml5/docbook.css.xml b/xhtml5/docbook.css.xml new file mode 100644 index 0000000..9587979 --- /dev/null +++ b/xhtml5/docbook.css.xml @@ -0,0 +1,104 @@ +<?xml version="1.0"?> +<style> + +/********************************/ +/* start of styles in block.xsl */ + +.formalpara-title { + font-weight: bold; +} + +div.blockquote-title { + font-weight: bold; + margin-top: 1em; + margin-bottom: 1em; +} + +span.msgmain-title { + font-weight: bold; +} + +span.msgsub-title { + font-weight: bold; +} + +span.msgrel-title { + font-weight: bold; +} + +div.msglevel, div.msgorig, div.msgaud { + margin-top: 1em; + margin-bottom: 1em; +} + +span.msglevel-title, span.msgorig-title, span.msgaud-title { + font-weight: bold; +} + +div.msgexplan { + margin-top: 1em; + margin-bottom: 1em; +} + +span.msgexplan-title { + font-weight: bold; +} + +/* end of styles in block.xsl */ +/********************************/ + +/********************************/ +/* start of styles in autotoc.xsl */ + + +/* end of styles in autotoc.xsl */ +/********************************/ + +/********************************/ +/* start of styles in formal.xsl */ + +div.figure-title { + font-weight: bold; +} + +div.example-title { + font-weight: bold; +} + +div.equation-title { + font-weight: bold; +} + +div.table-title { + font-weight: bold; +} + +div.sidebar-title { + font-weight: bold; +} + + +/* end of styles in formal.xsl */ +/********************************/ + +/********************************/ +/* start of styles in verbatim.xsl */ + +div.programlisting { + white-space: pre; + font-family: monospace; +} + +div.screen { + white-space: pre; + font-family: monospace; +} + +div.synopsis { + white-space: pre; + font-family: monospace; +} + +/* end of styles in verbatim.xsl */ +/********************************/ +</style> diff --git a/xhtml5/docbook.xsl b/xhtml5/docbook.xsl new file mode 100644 index 0000000..421fbb5 --- /dev/null +++ b/xhtml5/docbook.xsl @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE xsl:stylesheet [ +]> +<xsl:stylesheet + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:exsl="http://exslt.org/common" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:stbl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Table" + xmlns:xtbl="xalan://com.nwalsh.xalan.Table" + xmlns:lxslt="http://xml.apache.org/xslt" + xmlns:ptbl="http://nwalsh.com/xslt/ext/xsltproc/python/Table" + exclude-result-prefixes="exsl stbl xtbl lxslt ptbl" + version="1.0"> + +<!-- $Id: docbook.xsl,v 1.2 2011-09-18 17:47:28 bobs Exp $ --> +<xsl:import href="xhtml-docbook.xsl"/> +<xsl:include href="html5-element-mods.xsl"/> + +<xsl:output method="xml" encoding="UTF-8" /> + +</xsl:stylesheet> diff --git a/xhtml5/html5-chunk-mods.xsl b/xhtml5/html5-chunk-mods.xsl new file mode 100644 index 0000000..27426ac --- /dev/null +++ b/xhtml5/html5-chunk-mods.xsl @@ -0,0 +1,111 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsl:stylesheet + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:exsl="http://exslt.org/common" + xmlns="http://www.w3.org/1999/xhtml" + exclude-result-prefixes="exsl" + version="1.0"> + +<!-- $Id: html5-chunk-mods.xsl,v 1.1 2011-09-16 21:44:00 bobs Exp $ --> + +<!-- call HTML5 header and footer templates for navigation --> +<xsl:template name="chunk-element-content"> + <xsl:param name="prev"/> + <xsl:param name="next"/> + <xsl:param name="nav.context"/> + <xsl:param name="content"> + <xsl:apply-imports/> + </xsl:param> + + <xsl:call-template name="user.preroot"/> + + <html> + <xsl:call-template name="root.attributes"/> + <xsl:call-template name="html.head"> + <xsl:with-param name="prev" select="$prev"/> + <xsl:with-param name="next" select="$next"/> + </xsl:call-template> + + <body> + <xsl:call-template name="body.attributes"/> + + <xsl:call-template name="html5.header.navigation"> + <xsl:with-param name="prev" select="$prev"/> + <xsl:with-param name="next" select="$next"/> + <xsl:with-param name="nav.context" select="$nav.context"/> + </xsl:call-template> + + <xsl:call-template name="user.header.content"/> + + <xsl:copy-of select="$content"/> + + <xsl:call-template name="user.footer.content"/> + + <xsl:call-template name="html5.footer.navigation"> + <xsl:with-param name="prev" select="$prev"/> + <xsl:with-param name="next" select="$next"/> + <xsl:with-param name="nav.context" select="$nav.context"/> + </xsl:call-template> + + </body> + </html> + <xsl:value-of select="$chunk.append"/> +</xsl:template> + +<!-- Add HTML5 <header> wrapper, and convert some attributes to styles --> +<xsl:template name="html5.header.navigation"> + <xsl:param name="prev" select="/foo"/> + <xsl:param name="next" select="/foo"/> + <xsl:param name="nav.context"/> + + <xsl:variable name="content"> + <header> + <xsl:call-template name="user.header.navigation"> + <xsl:with-param name="prev" select="$prev"/> + <xsl:with-param name="next" select="$next"/> + <xsl:with-param name="nav.context" select="$nav.context"/> + </xsl:call-template> + + <xsl:call-template name="header.navigation"> + <xsl:with-param name="prev" select="$prev"/> + <xsl:with-param name="next" select="$next"/> + <xsl:with-param name="nav.context" select="$nav.context"/> + </xsl:call-template> + </header> + </xsl:variable> + + <!-- And fix up any style atts --> + <xsl:call-template name="convert.styles"> + <xsl:with-param name="content" select="$content"/> + </xsl:call-template> +</xsl:template> + +<!-- Add HTML5 <footer> wrapper, and convert some attributes to styles --> +<xsl:template name="html5.footer.navigation"> + <xsl:param name="prev" select="/foo"/> + <xsl:param name="next" select="/foo"/> + <xsl:param name="nav.context"/> + + <xsl:variable name="content"> + <footer> + <xsl:call-template name="user.footer.navigation"> + <xsl:with-param name="prev" select="$prev"/> + <xsl:with-param name="next" select="$next"/> + <xsl:with-param name="nav.context" select="$nav.context"/> + </xsl:call-template> + + <xsl:call-template name="footer.navigation"> + <xsl:with-param name="prev" select="$prev"/> + <xsl:with-param name="next" select="$next"/> + <xsl:with-param name="nav.context" select="$nav.context"/> + </xsl:call-template> + </footer> + </xsl:variable> + + <!-- And fix up any style atts --> + <xsl:call-template name="convert.styles"> + <xsl:with-param name="content" select="$content"/> + </xsl:call-template> +</xsl:template> + +</xsl:stylesheet> diff --git a/xhtml5/html5-element-mods.xsl b/xhtml5/html5-element-mods.xsl new file mode 100644 index 0000000..9aae285 --- /dev/null +++ b/xhtml5/html5-element-mods.xsl @@ -0,0 +1,773 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE xsl:stylesheet [ +<!ENTITY % common.entities SYSTEM "../common/entities.ent"> +%common.entities; +]> +<xsl:stylesheet + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:exsl="http://exslt.org/common" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:stbl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Table" + xmlns:xtbl="xalan://com.nwalsh.xalan.Table" + xmlns:lxslt="http://xml.apache.org/xslt" + xmlns:ptbl="http://nwalsh.com/xslt/ext/xsltproc/python/Table" + exclude-result-prefixes="exsl stbl xtbl lxslt ptbl" + version="1.0"> + +<!-- $Id: html5-element-mods.xsl,v 1.2 2011-09-18 17:47:28 bobs Exp $ --> + +<!--==============================================================--> +<!-- DocBook XSL Parameter settings --> +<!--==============================================================--> +<!-- Set these to blank so can output special HTML5 empty DOCTYPE --> +<xsl:param name="chunker.output.doctype-system" select="''"/> +<xsl:param name="chunker.output.doctype-public" select="''"/> + +<xsl:param name="table.borders.with.css" select="1"/> +<xsl:param name="html.ext">.xhtml</xsl:param> +<xsl:param name="toc.list.type">ul</xsl:param> +<xsl:param name="css.decoration" select="1"/> +<xsl:param name="make.clean.html" select="1"/> +<xsl:param name="generate.id.attributes" select="1"/> +<xsl:variable name="div.element">section</xsl:variable> + +<!--==============================================================--> +<!-- Customized templates --> +<!--==============================================================--> + +<!-- HTML5: needs special doctype --> +<xsl:template name="user.preroot"> + <xsl:text disable-output-escaping="yes"><!DOCTYPE html></xsl:text> +</xsl:template> + +<!-- HTML5: Replace HTML acronum with abbr for HTML 5 --> +<xsl:template match="acronym"> + <xsl:call-template name="inline.charseq"> + <xsl:with-param name="wrapper-name">abbr</xsl:with-param> + </xsl:call-template> +</xsl:template> + +<!-- HTML5: replace border="0" with border="" --> +<!-- HTML5: No @summary allowed --> +<!-- HTML5: replace many table atts with CSS styles --> +<xsl:template match="tgroup" name="tgroup"> + <xsl:if test="not(@cols) or @cols = '' or string(number(@cols)) = 'NaN'"> + <xsl:message terminate="yes"> + <xsl:text>Error: CALS tables must specify the number of columns.</xsl:text> + </xsl:message> + </xsl:if> + + <xsl:variable name="summary"> + <xsl:call-template name="pi.dbhtml_table-summary"/> + </xsl:variable> + + <xsl:variable name="cellspacing"> + <xsl:call-template name="pi.dbhtml_cellspacing"/> + </xsl:variable> + + <xsl:variable name="cellpadding"> + <xsl:call-template name="pi.dbhtml_cellpadding"/> + </xsl:variable> + + <!-- First generate colgroup with attributes --> + <xsl:variable name="colgroup.with.attributes"> + <colgroup> + <xsl:call-template name="generate.colgroup"> + <xsl:with-param name="cols" select="@cols"/> + </xsl:call-template> + </colgroup> + </xsl:variable> + + <!-- then modify colgroup attributes with extension --> + <xsl:variable name="colgroup.with.extension"> + <xsl:choose> + <xsl:when test="$use.extensions != 0 + and $tablecolumns.extension != 0"> + <xsl:choose> + <xsl:when test="function-available('stbl:adjustColumnWidths')"> + <xsl:copy-of select="stbl:adjustColumnWidths($colgroup.with.attributes)"/> + </xsl:when> + <xsl:when test="function-available('xtbl:adjustColumnWidths')"> + <xsl:copy-of select="xtbl:adjustColumnWidths($colgroup.with.attributes)"/> + </xsl:when> + <xsl:when test="function-available('ptbl:adjustColumnWidths')"> + <xsl:copy-of select="ptbl:adjustColumnWidths($colgroup.with.attributes)"/> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>No adjustColumnWidths function available.</xsl:text> + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:copy-of select="$colgroup.with.attributes"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <!-- Now convert to @style --> + <xsl:variable name="colgroup"> + <xsl:call-template name="colgroup.with.style"> + <xsl:with-param name="colgroup" select="$colgroup.with.extension"/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="explicit.table.width"> + <xsl:call-template name="pi.dbhtml_table-width"> + <xsl:with-param name="node" select=".."/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="table.width.candidate"> + <xsl:choose> + <xsl:when test="$explicit.table.width != ''"> + <xsl:value-of select="$explicit.table.width"/> + </xsl:when> + <xsl:when test="$default.table.width = ''"> + <xsl:text>100%</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$default.table.width"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + + <xsl:variable name="table.width"> + <xsl:if test="$default.table.width != '' + or $explicit.table.width != ''"> + <xsl:choose> + <xsl:when test="contains($table.width.candidate, '%')"> + <xsl:value-of select="$table.width.candidate"/> + </xsl:when> + <xsl:when test="$use.extensions != 0 + and $tablecolumns.extension != 0"> + <xsl:choose> + <xsl:when test="function-available('stbl:convertLength')"> + <xsl:value-of select="stbl:convertLength($table.width.candidate)"/> + </xsl:when> + <xsl:when test="function-available('xtbl:convertLength')"> + <xsl:value-of select="xtbl:convertLength($table.width.candidate)"/> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>No convertLength function available.</xsl:text> + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$table.width.candidate"/> + </xsl:otherwise> + </xsl:choose> + </xsl:if> + </xsl:variable> + + <!-- assemble a table @style --> + <xsl:variable name="table.style"> + + <xsl:if test="$cellspacing != '' or $html.cellspacing != ''"> + <xsl:text>cellspacing: </xsl:text> + <xsl:choose> + <xsl:when test="$cellspacing != ''"> + <xsl:value-of select="$cellspacing"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$html.cellspacing"/> + </xsl:otherwise> + </xsl:choose> + <xsl:text>; </xsl:text> + </xsl:if> + + <xsl:if test="$cellpadding != '' or $html.cellpadding != ''"> + <xsl:text>cellpadding: </xsl:text> + <xsl:choose> + <xsl:when test="$cellpadding != ''"> + <xsl:value-of select="$cellpadding"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$html.cellpadding"/> + </xsl:otherwise> + </xsl:choose> + <xsl:text>; </xsl:text> + </xsl:if> + + <xsl:choose> + <xsl:when test="string-length($table.width) != 0"> + <xsl:text>width: </xsl:text> + <xsl:value-of select="$table.width"/> + <xsl:text>; </xsl:text> + </xsl:when> + <xsl:when test="../@pgwide=1 or local-name(.) = 'entrytbl'"> + <xsl:text>width: 100%; </xsl:text> + </xsl:when> + <xsl:otherwise> + </xsl:otherwise> + </xsl:choose> + + <xsl:choose> + <xsl:when test="../@frame='all' or (not(../@frame) and $default.table.frame='all')"> + <xsl:text>border-collapse: collapse; </xsl:text> + <xsl:call-template name="border"> + <xsl:with-param name="side" select="'top'"/> + <xsl:with-param name="style" select="$table.frame.border.style"/> + <xsl:with-param name="color" select="$table.frame.border.color"/> + <xsl:with-param name="thickness" select="$table.frame.border.thickness"/> + </xsl:call-template> + <xsl:call-template name="border"> + <xsl:with-param name="side" select="'bottom'"/> + <xsl:with-param name="style" select="$table.frame.border.style"/> + <xsl:with-param name="color" select="$table.frame.border.color"/> + <xsl:with-param name="thickness" select="$table.frame.border.thickness"/> + </xsl:call-template> + <xsl:call-template name="border"> + <xsl:with-param name="side" select="'left'"/> + <xsl:with-param name="style" select="$table.frame.border.style"/> + <xsl:with-param name="color" select="$table.frame.border.color"/> + <xsl:with-param name="thickness" select="$table.frame.border.thickness"/> + </xsl:call-template> + <xsl:call-template name="border"> + <xsl:with-param name="side" select="'right'"/> + <xsl:with-param name="style" select="$table.frame.border.style"/> + <xsl:with-param name="color" select="$table.frame.border.color"/> + <xsl:with-param name="thickness" select="$table.frame.border.thickness"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="../@frame='topbot' or (not(../@frame) and $default.table.frame='topbot')"> + <xsl:text>border-collapse: collapse;</xsl:text> + <xsl:call-template name="border"> + <xsl:with-param name="side" select="'top'"/> + <xsl:with-param name="style" select="$table.frame.border.style"/> + <xsl:with-param name="color" select="$table.frame.border.color"/> + <xsl:with-param name="thickness" select="$table.frame.border.thickness"/> + </xsl:call-template> + <xsl:call-template name="border"> + <xsl:with-param name="side" select="'bottom'"/> + <xsl:with-param name="style" select="$table.frame.border.style"/> + <xsl:with-param name="color" select="$table.frame.border.color"/> + <xsl:with-param name="thickness" select="$table.frame.border.thickness"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="../@frame='top' or (not(../@frame) and $default.table.frame='top')"> + <xsl:text>border-collapse: collapse;</xsl:text> + <xsl:call-template name="border"> + <xsl:with-param name="side" select="'top'"/> + <xsl:with-param name="style" select="$table.frame.border.style"/> + <xsl:with-param name="color" select="$table.frame.border.color"/> + <xsl:with-param name="thickness" select="$table.frame.border.thickness"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="../@frame='bottom' or (not(../@frame) and $default.table.frame='bottom')"> + <xsl:text>border-collapse: collapse;</xsl:text> + <xsl:call-template name="border"> + <xsl:with-param name="side" select="'bottom'"/> + <xsl:with-param name="style" select="$table.frame.border.style"/> + <xsl:with-param name="color" select="$table.frame.border.color"/> + <xsl:with-param name="thickness" select="$table.frame.border.thickness"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="../@frame='sides' or (not(../@frame) and $default.table.frame='sides')"> + <xsl:text>border-collapse: collapse;</xsl:text> + <xsl:call-template name="border"> + <xsl:with-param name="side" select="'left'"/> + <xsl:with-param name="style" select="$table.frame.border.style"/> + <xsl:with-param name="color" select="$table.frame.border.color"/> + <xsl:with-param name="thickness" select="$table.frame.border.thickness"/> + </xsl:call-template> + <xsl:call-template name="border"> + <xsl:with-param name="side" select="'right'"/> + <xsl:with-param name="style" select="$table.frame.border.style"/> + <xsl:with-param name="color" select="$table.frame.border.color"/> + <xsl:with-param name="thickness" select="$table.frame.border.thickness"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="../@frame='none'"> + <xsl:text>border: none;</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>border-collapse: collapse;</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <table> + <!-- HTML5: no table summary allowed --> + <xsl:if test="string-length($table.style) != 0"> + <xsl:attribute name="style"> + <xsl:value-of select="$table.style"/> + </xsl:attribute> + </xsl:if> + + + <xsl:copy-of select="$colgroup"/> + + <xsl:apply-templates select="thead"/> + <xsl:apply-templates select="tfoot"/> + <xsl:apply-templates select="tbody"/> + + <xsl:if test=".//footnote|../title//footnote"> + <tbody class="footnotes"> + <tr> + <td colspan="{@cols}"> + <xsl:apply-templates select=".//footnote|../title//footnote" mode="table.footnote.mode"/> + </td> + </tr> + </tbody> + </xsl:if> + </table> +</xsl:template> + +<!-- HTML5: convert col attributes to col CSS styles --> +<xsl:template name="colgroup.with.style"> + <xsl:param name="colgroup"/> + + <xsl:variable name="colgroup.nodeset" select="exsl:node-set($colgroup)"/> + <xsl:apply-templates select="$colgroup.nodeset" mode="convert.to.style"/> +</xsl:template> + +<xsl:template match="colgroup" mode="convert.to.style"> + <xsl:copy> + <xsl:copy-of select="@*"/> + <xsl:apply-templates mode="convert.to.style"/> + </xsl:copy> +</xsl:template> + +<!-- HTML5: converts obsolete HTML attributes to CSS styles --> +<xsl:template match="*" mode="convert.to.style"> + + <xsl:variable name="style.from.atts"> + <xsl:for-each select="@*"> + + <xsl:choose> + <xsl:when test="local-name() = 'width'"> + <xsl:text>width: </xsl:text> + <xsl:value-of select="."/> + <xsl:text>; </xsl:text> + </xsl:when> + + <xsl:when test="local-name() = 'align'"> + <xsl:text>text-align: </xsl:text> + <xsl:value-of select="."/> + <xsl:text>; </xsl:text> + </xsl:when> + + <xsl:when test="local-name() = 'valign'"> + <xsl:text>vertical-align: </xsl:text> + <xsl:value-of select="."/> + <xsl:text>; </xsl:text> + </xsl:when> + + <xsl:when test="local-name() = 'border'"> + <xsl:text>border: </xsl:text> + <xsl:value-of select="."/> + <xsl:text>; </xsl:text> + </xsl:when> + + <xsl:when test="local-name() = 'cellspacing'"> + <xsl:text>border-spacing: </xsl:text> + <xsl:value-of select="."/> + <xsl:text>; </xsl:text> + </xsl:when> + + <xsl:when test="local-name() = 'cellpadding'"> + <xsl:text>padding: </xsl:text> + <xsl:value-of select="."/> + <xsl:text>; </xsl:text> + </xsl:when> + </xsl:choose> + </xsl:for-each> + </xsl:variable> + + <!-- merge existing styles with these new styles --> + <xsl:variable name="style"> + <xsl:value-of select="concat($style.from.atts, @style)"/> + </xsl:variable> + + <!-- HTML5: reserved for element name conversion if needed --> + <xsl:variable name="element.name"> + <xsl:value-of select="local-name(.)"/> + </xsl:variable> + + <xsl:element name="{$element.name}"> + <xsl:if test="string-length($style) != 0"> + <xsl:attribute name="style"> + <xsl:value-of select="$style"/> + </xsl:attribute> + </xsl:if> + <!-- Also skip disallowed summary attributes --> + <xsl:copy-of select="@*[local-name(.) != 'width' and + local-name(.) != 'summary' and + local-name(.) != 'border' and + local-name(.) != 'cellspacing' and + local-name(.) != 'cellpadding' and + local-name(.) != 'style' and + local-name(.) != 'align' and + local-name(.) != 'valign']"/> + <xsl:apply-templates mode="convert.to.style"/> + </xsl:element> +</xsl:template> + +<!-- HTML5: convert some attributes to CSS style attribute --> +<xsl:template match="entry|entrytbl"> + <xsl:param name="col"> + <xsl:choose> + <xsl:when test="@revisionflag"> + <xsl:number from="row"/> + </xsl:when> + <xsl:otherwise>1</xsl:otherwise> + </xsl:choose> + </xsl:param> + + <xsl:param name="spans"/> + + + <!-- Process with stock template --> + <xsl:variable name="cell"> + <xsl:call-template name="entry"> + <xsl:with-param name="col" select="$col"/> + <xsl:with-param name="spans" select="$spans"/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="cell.nodes" select="exsl:node-set($cell)"/> + + <xsl:apply-templates select="$cell.nodes" mode="convert.to.style"/> + +</xsl:template> + +<xsl:template match="mediaobject|inlinemediaobject"> + <xsl:call-template name="convert.styles"/> +</xsl:template> + +<xsl:template match="qandaset"> + <xsl:call-template name="convert.styles"/> +</xsl:template> + +<xsl:template match="calloutlist|revhistory|footnote|figure|co"> + <xsl:call-template name="convert.styles"/> +</xsl:template> + +<xsl:template match="revhistory" mode="titlepage.mode"> + <xsl:call-template name="convert.styles"/> +</xsl:template> + +<xsl:template match="variablelist"> + <xsl:call-template name="convert.styles"/> +</xsl:template> + +<xsl:template match="orderedlist[@inheritnum = 'inherit']"> + <xsl:call-template name="convert.styles"/> +</xsl:template> + +<xsl:template match="simplelist"> + <xsl:call-template name="convert.styles"/> +</xsl:template> + +<xsl:template match="blockquote"> + <xsl:call-template name="convert.styles"/> +</xsl:template> + +<xsl:template match="note|important|warning|caution|tip"> + <xsl:call-template name="convert.styles"/> +</xsl:template> + +<xsl:template match="funcprototype" mode="ansi-tabular"> + <xsl:call-template name="convert.styles"/> +</xsl:template> + +<xsl:template match="funcprototype" mode="kr-tabular"> + <xsl:call-template name="convert.styles"/> +</xsl:template> + +<xsl:template name="convert.styles"> + <xsl:param name="content"> + <xsl:apply-imports/> + </xsl:param> + <xsl:variable name="nodes" select="exsl:node-set($content)"/> + + <xsl:apply-templates mode="convert.to.style" select="$nodes"/> +</xsl:template> + +<!-- HTML5: link rel="home" is not permitted --> +<!-- Add support for attributes on <html> element --> +<xsl:template match="*" mode="process.root"> + <xsl:variable name="doc" select="self::*"/> + + <xsl:call-template name="user.preroot"/> + <xsl:call-template name="root.messages"/> + + <html> + <xsl:call-template name="root.attributes"/> + <head> + <xsl:call-template name="system.head.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + <xsl:call-template name="head.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + <xsl:call-template name="user.head.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + </head> + <body> + <xsl:call-template name="body.attributes"/> + <xsl:call-template name="user.header.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + <xsl:apply-templates select="."/> + <xsl:call-template name="user.footer.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + </body> + </html> + <xsl:value-of select="$html.append"/> + + <!-- Generate any css files only once, not once per chunk --> + <xsl:call-template name="generate.css.files"/> +</xsl:template> + +<xsl:template name="root.attributes"> +</xsl:template> + +<!-- HTML5: uses <ul> instead of <dl> for TOC --> +<xsl:template match="question" mode="qandatoc.mode"> + <xsl:variable name="firstch"> + <!-- Use a titleabbrev or title if available --> + <xsl:choose> + <xsl:when test="../blockinfo/titleabbrev"> + <xsl:apply-templates select="../blockinfo/titleabbrev[1]/node()"/> + </xsl:when> + <xsl:when test="../blockinfo/title"> + <xsl:apply-templates select="../blockinfo/title[1]/node()"/> + </xsl:when> + <xsl:when test="../info/titleabbrev"> + <xsl:apply-templates select="../info/titleabbrev[1]/node()"/> + </xsl:when> + <xsl:when test="../titleabbrev"> + <xsl:apply-templates select="../titleabbrev[1]/node()"/> + </xsl:when> + <xsl:when test="../info/title"> + <xsl:apply-templates select="../info/title[1]/node()"/> + </xsl:when> + <xsl:when test="../title"> + <xsl:apply-templates select="../title[1]/node()"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="(*[local-name(.)!='label'])[1]/node()"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="deflabel"> + <xsl:choose> + <xsl:when test="ancestor-or-self::*[@defaultlabel]"> + <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()] + /@defaultlabel"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$qanda.defaultlabel"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <li> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:attribute> + <xsl:apply-templates select="." mode="label.markup"/> + <xsl:if test="contains($deflabel,'number') and not(label)"> + <xsl:apply-templates select="." mode="intralabel.punctuation"/> + </xsl:if> + <xsl:text> </xsl:text> + <xsl:value-of select="$firstch"/> + </a> + <!-- * include nested qandaset/qandaentry in TOC if user wants it --> + + <xsl:if test="not($qanda.nested.in.toc = 0)"> + <xsl:apply-templates select="following-sibling::answer" mode="qandatoc.mode"/> + </xsl:if> + </li> +</xsl:template> + +<xsl:template match="answer" mode="qandatoc.mode"> + <xsl:if test="descendant::question"> + <xsl:call-template name="process.qanda.toc"/> + </xsl:if> +</xsl:template> + +<!-- html5 uses <ul> instead of <dl> for toc --> +<xsl:template name="process.qanda.toc"> + <ul> + <xsl:apply-templates select="qandadiv" mode="qandatoc.mode"/> + <xsl:apply-templates select="qandaset|qandaentry" mode="qandatoc.mode"/> + </ul> +</xsl:template> + +<xsl:template match="qandadiv" mode="qandatoc.mode"> + <!-- + <dt><xsl:apply-templates select="title" mode="qandatoc.mode"/></dt> + <dd><xsl:call-template name="process.qanda.toc"/></dd> + --> + <li> + <xsl:apply-templates select="title" mode="qandatoc.mode"/> + <xsl:call-template name="process.qanda.toc"/> + </li> +</xsl:template> + +<xsl:template match="audiodata"> + <xsl:variable name="filename"> + <xsl:call-template name="mediaobject.filename"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:variable> + + <audio> + <xsl:call-template name="common.html.attributes"/> + + <xsl:attribute name="src"> + <xsl:value-of select="$filename"/> + </xsl:attribute> + + <xsl:apply-templates select="@*"/> + <xsl:apply-templates select="../multimediaparam"/> + + <!-- add any fallback content --> + <xsl:call-template name="audio.fallback"/> + </audio> +</xsl:template> + +<!-- generate <video> element for html5 --> +<xsl:template match="videodata"> + <xsl:variable name="filename"> + <xsl:call-template name="mediaobject.filename"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:variable> + + <video> + <xsl:call-template name="common.html.attributes"/> + + <xsl:attribute name="src"> + <xsl:value-of select="$filename"/> + </xsl:attribute> + + <xsl:call-template name="video.poster"/> + + <xsl:apply-templates select="@*[local-name() != 'fileref']"/> + <xsl:apply-templates select="../multimediaparam"/> + + <!-- add any fallback content --> + <xsl:call-template name="video.fallback"/> + </video> +</xsl:template> + +<!-- use only an imageobject with @role = 'poster' --> +<xsl:template name="video.poster"> + <xsl:variable name="imageobject" select="../../imageobject[@role = 'poster'][1]"/> + <xsl:if test="$imageobject"> + <xsl:attribute name="poster"> + <xsl:value-of select="$imageobject/imagedata/@fileref"/> + </xsl:attribute> + </xsl:if> +</xsl:template> + +<xsl:template match="videodata/@fileref"> + <!-- already handled by videodata template --> +</xsl:template> + +<xsl:template match="audiodata/@fileref"> + <!-- already handled by audiodata template --> +</xsl:template> + +<xsl:template match="videodata/@contentwidth"> + <xsl:attribute name="width"> + <xsl:value-of select="."/> + </xsl:attribute> +</xsl:template> + +<xsl:template match="videodata/@contentdepth"> + <xsl:attribute name="height"> + <xsl:value-of select="."/> + </xsl:attribute> +</xsl:template> + +<xsl:template match="videodata/@depth"> + <xsl:attribute name="height"> + <xsl:value-of select="."/> + </xsl:attribute> +</xsl:template> + +<!-- pass through these attributes --> +<xsl:template match="videodata/@autoplay | + videodata/@controls | + audiodata/@autoplay | + audiodata/@controls"> + <xsl:copy-of select="."/> +</xsl:template> + +<xsl:template match="videodata/@*" priority="-1"> + <!-- Do nothing with the rest of the attributes --> +</xsl:template> + +<xsl:template match="audiodata/@*" priority="-1"> + <!-- Do nothing with the rest of the attributes --> +</xsl:template> + +<xsl:template match="multimediaparam"> + <xsl:call-template name="process.multimediaparam"> + <xsl:with-param name="object" select=".."/> + <xsl:with-param name="param.name" select="@name"/> + <xsl:with-param name="param.value" select="@value"/> + </xsl:call-template> +</xsl:template> + +<!-- Determines the best value of a media attribute from the + attributes and multimediaparam elements --> +<xsl:template name="process.multimediaparam"> + <xsl:param name="object" select="NOTANELEMENT"/> + <xsl:param name="param.name"/> + <xsl:param name="param.value"/> + + <xsl:choose> + <xsl:when test="$object/*/@*[local-name(.) = $param.name]"> + <!-- explicit attribute with that name takes precedence --> + <xsl:attribute name="{$param.name}"> + <xsl:value-of select="$object/*/@*[local-name(.) = $param.name]"/> + </xsl:attribute> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="{$param.name}"> + <xsl:value-of select="$param.value"/> + </xsl:attribute> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="video.fallback"> + <xsl:param name="videodata" select="."/> + <xsl:variable name="textobject" select="$videodata/../../textobject"/> + + <xsl:apply-templates select="$textobject" mode="fallback"/> +</xsl:template> + +<xsl:template name="audio.fallback"> + <xsl:param name="audiodata" select="."/> + <xsl:variable name="textobject" select="$audiodata/../../textobject"/> + + <xsl:apply-templates select="$textobject" mode="fallback"/> +</xsl:template> + +<xsl:template match="textobject" mode="fallback"> + <div> + <xsl:apply-templates select="." mode="class.attribute"/> + <xsl:apply-templates/> + </div> +</xsl:template> + +<!-- HTML5: no body attributes --> +<xsl:template name="body.attributes"/> + +</xsl:stylesheet> diff --git a/xhtml5/onechunk.xsl b/xhtml5/onechunk.xsl new file mode 100644 index 0000000..92e8874 --- /dev/null +++ b/xhtml5/onechunk.xsl @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="ASCII"?> +<!--This file was created automatically by html2xhtml--> +<!--from the HTML stylesheets.--> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" xmlns="http://www.w3.org/1999/xhtml" version="1.0" exclude-result-prefixes="doc"> + +<!-- ******************************************************************** + $Id: onechunk.xsl,v 1.1 2011-09-16 21:44:00 bobs Exp $ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://docbook.sf.net/release/xsl/current/ for + copyright and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:import href="chunk.xsl"/> + +<!-- Ok, using the onechunk parameter makes this all work again. --> +<!-- It does have the disadvantage that it only works for documents that have --> +<!-- a root element that is considered a chunk by the chunk.xsl stylesheet. --> +<!-- Ideally, onechunk would let anything be a chunk. But not today. --> + +<xsl:param name="onechunk" select="1"/> +<xsl:param name="suppress.navigation">1</xsl:param> + +<xsl:template name="href.target.uri"> + <xsl:param name="object" select="."/> + <xsl:text>#</xsl:text> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select="$object"/> + </xsl:call-template> +</xsl:template> + +</xsl:stylesheet> diff --git a/xhtml5/profile-chunk.xsl b/xhtml5/profile-chunk.xsl new file mode 100644 index 0000000..5c04c31 --- /dev/null +++ b/xhtml5/profile-chunk.xsl @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="ASCII"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" version="1.0" exclude-result-prefixes="exsl"> + +<!-- ******************************************************************** + $Id: profile-chunk.xsl,v 1.1 2011-09-16 21:44:00 bobs Exp $ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://docbook.sf.net/release/xsl/current/ for + copyright and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<!-- First import the non-chunking templates that format elements + within each chunk file. In a customization, you should + create a separate non-chunking customization layer such + as mydocbook.xsl that imports the original docbook.xsl and + customizes any presentation templates. Then your chunking + customization should import mydocbook.xsl instead of + docbook.xsl. --> +<xsl:import href="docbook.xsl"/> + +<!-- chunk-common.xsl contains all the named templates for chunking. + In a customization file, you import chunk-common.xsl, then + add any customized chunking templates of the same name. + They will have import precedence over the original + chunking templates in chunk-common.xsl. --> +<xsl:import href="../xhtml/chunk-common.xsl"/> + +<!-- The manifest.xsl module is no longer imported because its + templates were moved into chunk-common and chunk-code --> + +<!-- chunk-code.xsl contains all the chunking templates that use + a match attribute. In a customization it should be referenced + using <xsl:include> instead of <xsl:import>, and then add + any customized chunking templates with match attributes. But be sure + to add a priority="1" to such customized templates to resolve + its conflict with the original, since they have the + same import precedence. + + Using xsl:include prevents adding another layer + of import precedence, which would cause any + customizations that use xsl:apply-imports to wrongly + apply the chunking version instead of the original + non-chunking version to format an element. --> +<xsl:include href="../xhtml/profile-chunk-code.xsl"/> + +<xsl:include href="html5-chunk-mods.xsl"/> + +</xsl:stylesheet> diff --git a/xhtml5/profile-docbook.xsl b/xhtml5/profile-docbook.xsl new file mode 100644 index 0000000..47f8236 --- /dev/null +++ b/xhtml5/profile-docbook.xsl @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="ASCII"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ng="http://docbook.org/docbook-ng" xmlns:db="http://docbook.org/ns/docbook" xmlns:exsl="http://exslt.org/common" xmlns:exslt="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" exslt:dummy="dummy" ng:dummy="dummy" db:dummy="dummy" extension-element-prefixes="exslt" exclude-result-prefixes="db ng exsl exslt exslt" version="1.0"> + + +<!-- ******************************************************************** + $Id: profile-docbook.xsl,v 1.2 2011-09-18 17:47:28 bobs Exp $ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://docbook.sf.net/release/xsl/current/ for + copyright and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:import href="xhtml-profile-docbook.xsl"/> + +<xsl:include href="html5-element-mods.xsl"/> + +<xsl:output method="xml" encoding="UTF-8" indent="no"/> + +</xsl:stylesheet> diff --git a/xhtml5/xhtml-docbook.xsl b/xhtml5/xhtml-docbook.xsl new file mode 100644 index 0000000..e14f054 --- /dev/null +++ b/xhtml5/xhtml-docbook.xsl @@ -0,0 +1,495 @@ +<?xml version="1.0"?> + +<!--This file was created automatically by xhtml2xhtml5.xsl from the xhtml stylesheet.--> + +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ng="http://docbook.org/docbook-ng" xmlns:db="http://docbook.org/ns/docbook" xmlns:exsl="http://exslt.org/common" xmlns:exslt="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="db ng exsl exslt" version="1.0"> + +<!--Same as xhtml but with doctypes removed from xsl:output --> +<!--and including from ../xhtml directory --> +<xslo:output xmlns:xslo="http://www.w3.org/1999/XSL/Transform" method="xml" encoding="UTF-8" indent="no"/> + +<!-- ******************************************************************** + $Id: docbook.xsl 9396 2012-06-02 21:56:19Z bobstayton $ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://docbook.sf.net/release/xsl/current/ for + copyright and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:include href="../VERSION.xsl"/> +<xsl:include href="../xhtml/param.xsl"/> +<xsl:include href="../lib/lib.xsl"/> +<xsl:include href="../common/l10n.xsl"/> +<xsl:include href="../common/common.xsl"/> +<xsl:include href="../common/utility.xsl"/> +<xsl:include href="../common/labels.xsl"/> +<xsl:include href="../common/titles.xsl"/> +<xsl:include href="../common/subtitles.xsl"/> +<xsl:include href="../common/gentext.xsl"/> +<xsl:include href="../common/targets.xsl"/> +<xsl:include href="../common/olink.xsl"/> +<xsl:include href="../common/pi.xsl"/> +<xsl:include href="../xhtml/autotoc.xsl"/> +<xsl:include href="../xhtml/autoidx.xsl"/> +<xsl:include href="../xhtml/lists.xsl"/> +<xsl:include href="../xhtml/callout.xsl"/> +<xsl:include href="../xhtml/verbatim.xsl"/> +<xsl:include href="../xhtml/graphics.xsl"/> +<xsl:include href="../xhtml/xref.xsl"/> +<xsl:include href="../xhtml/formal.xsl"/> +<xsl:include href="../xhtml/table.xsl"/> +<xsl:include href="../xhtml/htmltbl.xsl"/> +<xsl:include href="../xhtml/sections.xsl"/> +<xsl:include href="../xhtml/inline.xsl"/> +<xsl:include href="../xhtml/footnote.xsl"/> +<xsl:include href="../xhtml/html.xsl"/> +<xsl:include href="../xhtml/info.xsl"/> +<xsl:include href="../xhtml/keywords.xsl"/> +<xsl:include href="../xhtml/division.xsl"/> +<xsl:include href="../xhtml/toc.xsl"/> +<xsl:include href="../xhtml/index.xsl"/> +<xsl:include href="../xhtml/refentry.xsl"/> +<xsl:include href="../xhtml/math.xsl"/> +<xsl:include href="../xhtml/admon.xsl"/> +<xsl:include href="../xhtml/component.xsl"/> +<xsl:include href="../xhtml/biblio.xsl"/> +<xsl:include href="../xhtml/biblio-iso690.xsl"/> +<xsl:include href="../xhtml/glossary.xsl"/> +<xsl:include href="../xhtml/block.xsl"/> +<xsl:include href="../xhtml/task.xsl"/> +<xsl:include href="../xhtml/qandaset.xsl"/> +<xsl:include href="../xhtml/synop.xsl"/> +<xsl:include href="../xhtml/titlepage.xsl"/> +<xsl:include href="../xhtml/titlepage.templates.xsl"/> +<xsl:include href="../xhtml/pi.xsl"/> +<xsl:include href="../xhtml/ebnf.xsl"/> +<xsl:include href="../xhtml/chunker.xsl"/> +<xsl:include href="../xhtml/html-rtf.xsl"/> +<xsl:include href="../xhtml/annotations.xsl"/> +<xsl:include href="../common/stripns.xsl"/> + +<xsl:param name="stylesheet.result.type" select="'xhtml'"/> +<xsl:param name="htmlhelp.output" select="0"/> + +<!-- ==================================================================== --> + +<xsl:key name="id" match="*" use="@id|@xml:id"/> +<xsl:key name="gid" match="*" use="generate-id()"/> + +<!-- ==================================================================== --> + +<xsl:template match="*"> + <xsl:message> + <xsl:text>Element </xsl:text> + <xsl:value-of select="local-name(.)"/> + <xsl:text> in namespace '</xsl:text> + <xsl:value-of select="namespace-uri(.)"/> + <xsl:text>' encountered</xsl:text> + <xsl:if test="parent::*"> + <xsl:text> in </xsl:text> + <xsl:value-of select="name(parent::*)"/> + </xsl:if> + <xsl:text>, but no template matches.</xsl:text> + </xsl:message> + + <span style="color: red"> + <xsl:text><</xsl:text> + <xsl:value-of select="name(.)"/> + <xsl:text>></xsl:text> + <xsl:apply-templates/> + <xsl:text></</xsl:text> + <xsl:value-of select="name(.)"/> + <xsl:text>></xsl:text> + </span> +</xsl:template> + +<xsl:template match="text()"> + <xsl:value-of select="."/> +</xsl:template> + +<xsl:template name="body.attributes"><xslo:if xmlns:xslo="http://www.w3.org/1999/XSL/Transform" test="starts-with($writing.mode, 'rl')"><xslo:attribute name="dir">rtl</xslo:attribute></xslo:if> +<!-- no apply-templates; make it empty except for dir for rtl--> +</xsl:template> + +<xsl:template name="head.content"> + <xsl:param name="node" select="."/> + <xsl:param name="title"> + <xsl:apply-templates select="$node" mode="object.title.markup.textonly"/> + </xsl:param> + + <title> + <xsl:copy-of select="$title"/> + </title> + + <xsl:if test="$html.base != ''"> + <base href="{$html.base}"/> + </xsl:if> + + <!-- Insert links to CSS files or insert literal style elements --> + <xsl:call-template name="generate.css"/> + + <xsl:if test="$html.stylesheet != ''"> + <xsl:call-template name="output.html.stylesheets"> + <xsl:with-param name="stylesheets" select="normalize-space($html.stylesheet)"/> + </xsl:call-template> + </xsl:if> + + <xsl:if test="$html.script != ''"> + <xsl:call-template name="output.html.scripts"> + <xsl:with-param name="scripts" select="normalize-space($html.script)"/> + </xsl:call-template> + </xsl:if> + + <xsl:if test="$link.mailto.url != ''"> + <link rev="made" href="{$link.mailto.url}"/> + </xsl:if> + + <meta name="generator" content="DocBook {$DistroTitle} V{$VERSION}"/> + + <xsl:if test="$generate.meta.abstract != 0"> + <xsl:variable name="info" select="(articleinfo |bookinfo |prefaceinfo |chapterinfo |appendixinfo |sectioninfo |sect1info |sect2info |sect3info |sect4info |sect5info |referenceinfo |refentryinfo |partinfo |info |docinfo)[1]"/> + <xsl:if test="$info and $info/abstract"> + <meta name="description"> + <xsl:attribute name="content"> + <xsl:for-each select="$info/abstract[1]/*"> + <xsl:value-of select="normalize-space(.)"/> + <xsl:if test="position() < last()"> + <xsl:text> </xsl:text> + </xsl:if> + </xsl:for-each> + </xsl:attribute> + </meta> + </xsl:if> + </xsl:if> + + <xsl:if test="($draft.mode = 'yes' or ($draft.mode = 'maybe' and ancestor-or-self::*[@status][1]/@status = 'draft')) and $draft.watermark.image != ''"> + <style type="text/css"><xsl:text> +body { background-image: url('</xsl:text> +<xsl:value-of select="$draft.watermark.image"/><xsl:text>'); + background-repeat: no-repeat; + background-position: top left; + /* The following properties make the watermark "fixed" on the page. */ + /* I think that's just a bit too distracting for the reader... */ + /* background-attachment: fixed; */ + /* background-position: center center; */ + }</xsl:text> + </style> + </xsl:if> + <xsl:apply-templates select="." mode="head.keywords.content"/> +</xsl:template> + +<xsl:template name="output.html.stylesheets"> + <xsl:param name="stylesheets" select="''"/> + + <xsl:choose> + <xsl:when test="contains($stylesheets, ' ')"> + <xsl:variable name="css.filename" select="substring-before($stylesheets, ' ')"/> + + <xsl:call-template name="make.css.link"> + <xsl:with-param name="css.filename" select="$css.filename"/> + </xsl:call-template> + + <xsl:call-template name="output.html.stylesheets"> + <xsl:with-param name="stylesheets" select="substring-after($stylesheets, ' ')"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="$stylesheets != ''"> + <xsl:call-template name="make.css.link"> + <xsl:with-param name="css.filename" select="$stylesheets"/> + </xsl:call-template> + </xsl:when> + </xsl:choose> +</xsl:template> + +<xsl:template name="output.html.scripts"> + <xsl:param name="scripts" select="''"/> + + <xsl:choose> + <xsl:when test="contains($scripts, ' ')"> + <xsl:variable name="script.filename" select="substring-before($scripts, ' ')"/> + + <xsl:call-template name="make.script.link"> + <xsl:with-param name="script.filename" select="$script.filename"/> + </xsl:call-template> + + <xsl:call-template name="output.html.scripts"> + <xsl:with-param name="scripts" select="substring-after($scripts, ' ')"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="$scripts != ''"> + <xsl:call-template name="make.script.link"> + <xsl:with-param name="script.filename" select="$scripts"/> + </xsl:call-template> + </xsl:when> + </xsl:choose> +</xsl:template> + +<!-- ============================================================ --> + +<xsl:template match="*" mode="head.keywords.content"> + <xsl:apply-templates select="chapterinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="appendixinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="prefaceinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="bookinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="setinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="articleinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="artheader/keywordset" mode="html.header"/> + <xsl:apply-templates select="sect1info/keywordset" mode="html.header"/> + <xsl:apply-templates select="sect2info/keywordset" mode="html.header"/> + <xsl:apply-templates select="sect3info/keywordset" mode="html.header"/> + <xsl:apply-templates select="sect4info/keywordset" mode="html.header"/> + <xsl:apply-templates select="sect5info/keywordset" mode="html.header"/> + <xsl:apply-templates select="sectioninfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="refsect1info/keywordset" mode="html.header"/> + <xsl:apply-templates select="refsect2info/keywordset" mode="html.header"/> + <xsl:apply-templates select="refsect3info/keywordset" mode="html.header"/> + <xsl:apply-templates select="bibliographyinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="glossaryinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="indexinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="refentryinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="partinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="referenceinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="docinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="info/keywordset" mode="html.header"/> + + <xsl:if test="$inherit.keywords != 0 and parent::*"> + <xsl:apply-templates select="parent::*" mode="head.keywords.content"/> + </xsl:if> +</xsl:template> + +<!-- ============================================================ --> + +<xsl:template name="system.head.content"> + <xsl:param name="node" select="."/> + + <!-- FIXME: When chunking, only the annotations actually used + in this chunk should be referenced. I don't think it + does any harm to reference them all, but it adds + unnecessary bloat to each chunk. --> + <xsl:if test="$annotation.support != 0 and //annotation"> + <xsl:call-template name="add.annotation.links"/> + <script type="text/javascript"> + <xsl:text> +// Create PopupWindow objects</xsl:text> + <xsl:for-each select="//annotation"> + <xsl:text> +var popup_</xsl:text> + <xsl:value-of select="generate-id(.)"/> + <xsl:text> = new PopupWindow("popup-</xsl:text> + <xsl:value-of select="generate-id(.)"/> + <xsl:text>"); +</xsl:text> + <xsl:text>popup_</xsl:text> + <xsl:value-of select="generate-id(.)"/> + <xsl:text>.offsetY = 15; +</xsl:text> + <xsl:text>popup_</xsl:text> + <xsl:value-of select="generate-id(.)"/> + <xsl:text>.autoHide(); +</xsl:text> + </xsl:for-each> + </script> + + <style type="text/css"> + <xsl:value-of select="$annotation.css"/> + </style> + </xsl:if> + + <!-- system.head.content is like user.head.content, except that + it is called before head.content. This is important because it + means, for example, that <style> elements output by system.head.content + have a lower CSS precedence than the users stylesheet. --> +</xsl:template> + +<!-- ============================================================ --> + +<xsl:template name="user.preroot"> + <!-- Pre-root output, can be used to output comments and PIs. --> + <!-- This must not output any element content! --> +</xsl:template> + +<xsl:template name="user.head.content"> + <xsl:param name="node" select="."/> +</xsl:template> + +<xsl:template name="user.header.navigation"> + <xsl:param name="node" select="."/> + <xsl:param name="prev" select="/foo"/> + <xsl:param name="next" select="/foo"/> + <xsl:param name="nav.context"/> +</xsl:template> + +<xsl:template name="user.header.content"> + <xsl:param name="node" select="."/> +</xsl:template> + +<xsl:template name="user.footer.content"> + <xsl:param name="node" select="."/> +</xsl:template> + +<xsl:template name="user.footer.navigation"> + <xsl:param name="node" select="."/> + <xsl:param name="prev" select="/foo"/> + <xsl:param name="next" select="/foo"/> + <xsl:param name="nav.context"/> +</xsl:template> + +<!-- To use the same stripped nodeset everywhere, it should +be created as a global variable here. +Used by docbook.xsl, chunk-code.xsl and chunkfast.xsl --> +<xsl:variable name="no.namespace"> + <xsl:if test="$exsl.node.set.available != 0 and (*/self::ng:* or */self::db:*)"> + <xsl:apply-templates select="/*" mode="stripNS"/> + </xsl:if> +</xsl:variable> + +<xsl:template match="/"> + <!-- * Get a title for current doc so that we let the user --> + <!-- * know what document we are processing at this point. --> + <xsl:variable name="doc.title"> + <xsl:call-template name="get.doc.title"/> + </xsl:variable> + <xsl:choose> + <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document, + toss the namespace and continue. Use the docbook5 namespaced + stylesheets for DocBook5 if you don't want to use this feature.--> + <!-- include extra test for Xalan quirk --> + <xsl:when test="$exsl.node.set.available != 0 and (*/self::ng:* or */self::db:*)"> + <xsl:call-template name="log.message"> + <xsl:with-param name="level">Note</xsl:with-param> + <xsl:with-param name="source" select="$doc.title"/> + <xsl:with-param name="context-desc"> + <xsl:text>namesp. cut</xsl:text> + </xsl:with-param> + <xsl:with-param name="message"> + <xsl:text>stripped namespace before processing</xsl:text> + </xsl:with-param> + </xsl:call-template> + <!-- DEBUG: to save stripped document. + <xsl:message>Saving stripped document.</xsl:message> + <xsl:call-template name="write.chunk"> + <xsl:with-param name="filename" select="'/tmp/stripped.xml'"/> + <xsl:with-param name="method" select="'xml'"/> + <xsl:with-param name="content"> + <xsl:copy-of select="exsl:node-set($no.namespace)"/> + </xsl:with-param> + </xsl:call-template> + --> + <xsl:call-template name="log.message"> + <xsl:with-param name="level">Note</xsl:with-param> + <xsl:with-param name="source" select="$doc.title"/> + <xsl:with-param name="context-desc"> + <xsl:text>namesp. cut</xsl:text> + </xsl:with-param> + <xsl:with-param name="message"> + <xsl:text>processing stripped document</xsl:text> + </xsl:with-param> + </xsl:call-template> + <xsl:apply-templates select="exsl:node-set($no.namespace)"/> + </xsl:when> + <!-- Can't process unless namespace removed --> + <xsl:when test="*/self::ng:* or */self::db:*"> + <xsl:message terminate="yes"> + <xsl:text>Unable to strip the namespace from DB5 document,</xsl:text> + <xsl:text> cannot proceed.</xsl:text> + </xsl:message> + </xsl:when> + <xsl:otherwise> + <xsl:choose> + <xsl:when test="$rootid != ''"> + <xsl:choose> + <xsl:when test="count(key('id',$rootid)) = 0"> + <xsl:message terminate="yes"> + <xsl:text>ID '</xsl:text> + <xsl:value-of select="$rootid"/> + <xsl:text>' not found in document.</xsl:text> + </xsl:message> + </xsl:when> + <xsl:otherwise> + <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'"> + <xsl:apply-templates select="key('id', $rootid)" mode="collect.targets"/> + </xsl:if> + <xsl:if test="$collect.xref.targets != 'only'"> + <xsl:apply-templates select="key('id',$rootid)" mode="process.root"/> + <xsl:if test="$tex.math.in.alt != ''"> + <xsl:apply-templates select="key('id',$rootid)" mode="collect.tex.math"/> + </xsl:if> + </xsl:if> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'"> + <xsl:apply-templates select="/" mode="collect.targets"/> + </xsl:if> + <xsl:if test="$collect.xref.targets != 'only'"> + <xsl:apply-templates select="/" mode="process.root"/> + <xsl:if test="$tex.math.in.alt != ''"> + <xsl:apply-templates select="/" mode="collect.tex.math"/> + </xsl:if> + </xsl:if> + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="*" mode="process.root"> + <xsl:variable name="doc" select="self::*"/> + + <xsl:call-template name="user.preroot"/> + <xsl:call-template name="root.messages"/> + + <html> + <xsl:call-template name="root.attributes"/> + <head> + <xsl:call-template name="system.head.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + <xsl:call-template name="head.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + <xsl:call-template name="user.head.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + </head> + <body> + <xsl:call-template name="body.attributes"/> + <xsl:call-template name="user.header.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + <xsl:apply-templates select="."/> + <xsl:call-template name="user.footer.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + </body> + </html> + <xsl:value-of select="$html.append"/> + + <!-- Generate any css files only once, not once per chunk --> + <xsl:call-template name="generate.css.files"/> +</xsl:template> + +<xsl:template name="root.attributes"> + <!-- customize to add attributes to <html> element --> +</xsl:template> + +<xsl:template name="root.messages"> + <!-- redefine this any way you'd like to output messages --> + <!-- DO NOT OUTPUT ANYTHING FROM THIS TEMPLATE --> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="chunk"> + <xsl:param name="node" select="."/> + + <!-- The default is that we are not chunking... --> + <xsl:text>0</xsl:text> +</xsl:template> + +</xsl:stylesheet> diff --git a/xhtml5/xhtml-profile-docbook.xsl b/xhtml5/xhtml-profile-docbook.xsl new file mode 100644 index 0000000..dc0d979 --- /dev/null +++ b/xhtml5/xhtml-profile-docbook.xsl @@ -0,0 +1,408 @@ +<?xml version="1.0" encoding="ASCII"?> +<!--This file was created automatically by html2xhtml--> +<!--from the HTML stylesheets.--> +<!--This file was created automatically by xsl2profile--> +<!--from the DocBook XSL stylesheets.--> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ng="http://docbook.org/docbook-ng" xmlns:db="http://docbook.org/ns/docbook" xmlns:exsl="http://exslt.org/common" xmlns:exslt="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" exslt:dummy="dummy" ng:dummy="dummy" db:dummy="dummy" extension-element-prefixes="exslt" exclude-result-prefixes="db ng exsl exslt exslt" version="1.0"> + +<xsl:output method="xml" encoding="UTF-8" indent="no"/> + +<!-- ******************************************************************** + $Id: xhtml-profile-docbook.xsl,v 1.1 2011-09-16 21:44:00 bobs Exp $ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://docbook.sf.net/release/xsl/current/ for + copyright and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:include href="../VERSION.xsl"/> +<xsl:include href="../xhtml/param.xsl"/> +<xsl:include href="../lib/lib.xsl"/> +<xsl:include href="../common/l10n.xsl"/> +<xsl:include href="../common/common.xsl"/> +<xsl:include href="../common/utility.xsl"/> +<xsl:include href="../common/labels.xsl"/> +<xsl:include href="../common/titles.xsl"/> +<xsl:include href="../common/subtitles.xsl"/> +<xsl:include href="../common/gentext.xsl"/> +<xsl:include href="../common/targets.xsl"/> +<xsl:include href="../common/olink.xsl"/> +<xsl:include href="../common/pi.xsl"/> +<xsl:include href="../xhtml/autotoc.xsl"/> +<xsl:include href="../xhtml/autoidx.xsl"/> +<xsl:include href="../xhtml/lists.xsl"/> +<xsl:include href="../xhtml/callout.xsl"/> +<xsl:include href="../xhtml/verbatim.xsl"/> +<xsl:include href="../xhtml/graphics.xsl"/> +<xsl:include href="../xhtml/xref.xsl"/> +<xsl:include href="../xhtml/formal.xsl"/> +<xsl:include href="../xhtml/table.xsl"/> +<xsl:include href="../xhtml/htmltbl.xsl"/> +<xsl:include href="../xhtml/sections.xsl"/> +<xsl:include href="../xhtml/inline.xsl"/> +<xsl:include href="../xhtml/footnote.xsl"/> +<xsl:include href="../xhtml/html.xsl"/> +<xsl:include href="../xhtml/info.xsl"/> +<xsl:include href="../xhtml/keywords.xsl"/> +<xsl:include href="../xhtml/division.xsl"/> +<xsl:include href="../xhtml/toc.xsl"/> +<xsl:include href="../xhtml/index.xsl"/> +<xsl:include href="../xhtml/refentry.xsl"/> +<xsl:include href="../xhtml/math.xsl"/> +<xsl:include href="../xhtml/admon.xsl"/> +<xsl:include href="../xhtml/component.xsl"/> +<xsl:include href="../xhtml/biblio.xsl"/> +<xsl:include href="../xhtml/biblio-iso690.xsl"/> +<xsl:include href="../xhtml/glossary.xsl"/> +<xsl:include href="../xhtml/block.xsl"/> +<xsl:include href="../xhtml/task.xsl"/> +<xsl:include href="../xhtml/qandaset.xsl"/> +<xsl:include href="../xhtml/synop.xsl"/> +<xsl:include href="../xhtml/titlepage.xsl"/> +<xsl:include href="../xhtml/titlepage.templates.xsl"/> +<xsl:include href="../xhtml/pi.xsl"/> +<xsl:include href="../xhtml/ebnf.xsl"/> +<xsl:include href="../xhtml/chunker.xsl"/> +<xsl:include href="../xhtml/html-rtf.xsl"/> +<xsl:include href="../xhtml/annotations.xsl"/> +<xsl:include href="../common/stripns.xsl"/> + +<xsl:param name="stylesheet.result.type" select="'xhtml'"/> +<xsl:param name="htmlhelp.output" select="0"/> + +<!-- ==================================================================== --> + +<xsl:key name="id" match="*" use="@id|@xml:id"/> +<xsl:key name="gid" match="*" use="generate-id()"/> + +<!-- ==================================================================== --> + +<xsl:template match="*"> + <xsl:message> + <xsl:text>Element </xsl:text> + <xsl:value-of select="local-name(.)"/> + <xsl:text> in namespace '</xsl:text> + <xsl:value-of select="namespace-uri(.)"/> + <xsl:text>' encountered</xsl:text> + <xsl:if test="parent::*"> + <xsl:text> in </xsl:text> + <xsl:value-of select="name(parent::*)"/> + </xsl:if> + <xsl:text>, but no template matches.</xsl:text> + </xsl:message> + + <span style="color: red"> + <xsl:text><</xsl:text> + <xsl:value-of select="name(.)"/> + <xsl:text>></xsl:text> + <xsl:apply-templates/> + <xsl:text></</xsl:text> + <xsl:value-of select="name(.)"/> + <xsl:text>></xsl:text> + </span> +</xsl:template> + +<xsl:template match="text()"> + <xsl:value-of select="."/> +</xsl:template> + +<xsl:template name="body.attributes"><xslo:if xmlns:xslo="http://www.w3.org/1999/XSL/Transform" test="starts-with($writing.mode, 'rl')"><xslo:attribute name="dir">rtl</xslo:attribute></xslo:if> +<!-- no apply-templates; make it empty except for dir for rtl--> +</xsl:template> + +<xsl:template name="head.content"> + <xsl:param name="node" select="."/> + <xsl:param name="title"> + <xsl:apply-templates select="$node" mode="object.title.markup.textonly"/> + </xsl:param> + + <title> + <xsl:copy-of select="$title"/> + </title> + + <xsl:if test="$html.base != ''"> + <base href="{$html.base}"/> + </xsl:if> + + <!-- Insert links to CSS files or insert literal style elements --> + <xsl:call-template name="generate.css"/> + + <xsl:if test="$html.stylesheet != ''"> + <xsl:call-template name="output.html.stylesheets"> + <xsl:with-param name="stylesheets" select="normalize-space($html.stylesheet)"/> + </xsl:call-template> + </xsl:if> + + <xsl:if test="$link.mailto.url != ''"> + <link rev="made" href="{$link.mailto.url}"/> + </xsl:if> + + <meta name="generator" content="DocBook {$DistroTitle} V{$VERSION}"/> + + <xsl:if test="$generate.meta.abstract != 0"> + <xsl:variable name="info" select="(articleinfo |bookinfo |prefaceinfo |chapterinfo |appendixinfo |sectioninfo |sect1info |sect2info |sect3info |sect4info |sect5info |referenceinfo |refentryinfo |partinfo |info |docinfo)[1]"/> + <xsl:if test="$info and $info/abstract"> + <meta name="description"> + <xsl:attribute name="content"> + <xsl:for-each select="$info/abstract[1]/*"> + <xsl:value-of select="normalize-space(.)"/> + <xsl:if test="position() < last()"> + <xsl:text> </xsl:text> + </xsl:if> + </xsl:for-each> + </xsl:attribute> + </meta> + </xsl:if> + </xsl:if> + + <xsl:if test="($draft.mode = 'yes' or ($draft.mode = 'maybe' and ancestor-or-self::*[@status][1]/@status = 'draft')) and $draft.watermark.image != ''"> + <style type="text/css"><xsl:text> +body { background-image: url('</xsl:text> +<xsl:value-of select="$draft.watermark.image"/><xsl:text>'); + background-repeat: no-repeat; + background-position: top left; + /* The following properties make the watermark "fixed" on the page. */ + /* I think that's just a bit too distracting for the reader... */ + /* background-attachment: fixed; */ + /* background-position: center center; */ + }</xsl:text> + </style> + </xsl:if> + <xsl:apply-templates select="." mode="head.keywords.content"/> +</xsl:template> + +<xsl:template name="output.html.stylesheets"> + <xsl:param name="stylesheets" select="''"/> + + <xsl:choose> + <xsl:when test="contains($stylesheets, ' ')"> + <xsl:variable name="css.filename" select="substring-before($stylesheets, ' ')"/> + + <xsl:call-template name="make.css.link"> + <xsl:with-param name="css.filename" select="$css.filename"/> + </xsl:call-template> + + <xsl:call-template name="output.html.stylesheets"> + <xsl:with-param name="stylesheets" select="substring-after($stylesheets, ' ')"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="$stylesheets != ''"> + <xsl:call-template name="make.css.link"> + <xsl:with-param name="css.filename" select="$stylesheets"/> + </xsl:call-template> + </xsl:when> + </xsl:choose> +</xsl:template> + +<!-- ============================================================ --> + +<xsl:template match="*" mode="head.keywords.content"> + <xsl:apply-templates select="chapterinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="appendixinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="prefaceinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="bookinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="setinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="articleinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="artheader/keywordset" mode="html.header"/> + <xsl:apply-templates select="sect1info/keywordset" mode="html.header"/> + <xsl:apply-templates select="sect2info/keywordset" mode="html.header"/> + <xsl:apply-templates select="sect3info/keywordset" mode="html.header"/> + <xsl:apply-templates select="sect4info/keywordset" mode="html.header"/> + <xsl:apply-templates select="sect5info/keywordset" mode="html.header"/> + <xsl:apply-templates select="sectioninfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="refsect1info/keywordset" mode="html.header"/> + <xsl:apply-templates select="refsect2info/keywordset" mode="html.header"/> + <xsl:apply-templates select="refsect3info/keywordset" mode="html.header"/> + <xsl:apply-templates select="bibliographyinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="glossaryinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="indexinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="refentryinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="partinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="referenceinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="docinfo/keywordset" mode="html.header"/> + <xsl:apply-templates select="info/keywordset" mode="html.header"/> + + <xsl:if test="$inherit.keywords != 0 and parent::*"> + <xsl:apply-templates select="parent::*" mode="head.keywords.content"/> + </xsl:if> +</xsl:template> + +<!-- ============================================================ --> + +<xsl:template name="system.head.content"> + <xsl:param name="node" select="."/> + + <!-- FIXME: When chunking, only the annotations actually used + in this chunk should be referenced. I don't think it + does any harm to reference them all, but it adds + unnecessary bloat to each chunk. --> + <xsl:if test="$annotation.support != 0 and //annotation"> + <xsl:call-template name="add.annotation.links"/> + <script type="text/javascript"> + <xsl:text> +// Create PopupWindow objects</xsl:text> + <xsl:for-each select="//annotation"> + <xsl:text> +var popup_</xsl:text> + <xsl:value-of select="generate-id(.)"/> + <xsl:text> = new PopupWindow("popup-</xsl:text> + <xsl:value-of select="generate-id(.)"/> + <xsl:text>"); +</xsl:text> + <xsl:text>popup_</xsl:text> + <xsl:value-of select="generate-id(.)"/> + <xsl:text>.offsetY = 15; +</xsl:text> + <xsl:text>popup_</xsl:text> + <xsl:value-of select="generate-id(.)"/> + <xsl:text>.autoHide(); +</xsl:text> + </xsl:for-each> + </script> + + <style type="text/css"> + <xsl:value-of select="$annotation.css"/> + </style> + </xsl:if> + + <!-- system.head.content is like user.head.content, except that + it is called before head.content. This is important because it + means, for example, that <style> elements output by system.head.content + have a lower CSS precedence than the users stylesheet. --> +</xsl:template> + +<!-- ============================================================ --> + +<xsl:template name="user.preroot"> + <!-- Pre-root output, can be used to output comments and PIs. --> + <!-- This must not output any element content! --> +</xsl:template> + +<xsl:template name="user.head.content"> + <xsl:param name="node" select="."/> +</xsl:template> + +<xsl:template name="user.header.navigation"> + <xsl:param name="node" select="."/> +</xsl:template> + +<xsl:template name="user.header.content"> + <xsl:param name="node" select="."/> +</xsl:template> + +<xsl:template name="user.footer.content"> + <xsl:param name="node" select="."/> +</xsl:template> + +<xsl:template name="user.footer.navigation"> + <xsl:param name="node" select="."/> +</xsl:template> + +<xslo:include xmlns:xslo="http://www.w3.org/1999/XSL/Transform" href="../profiling/profile-mode.xsl"/><xslo:variable xmlns:xslo="http://www.w3.org/1999/XSL/Transform" name="profiled-content"><xslo:choose><xslo:when test="*/self::ng:* or */self::db:*"><xslo:message>Note: namesp. cut : stripped namespace before processing</xslo:message><xslo:variable name="stripped-content"><xslo:apply-templates select="/" mode="stripNS"/></xslo:variable><xslo:message>Note: namesp. cut : processing stripped document</xslo:message><xslo:apply-templates select="exslt:node-set($stripped-content)" mode="profile"/></xslo:when><xslo:otherwise><xslo:apply-templates select="/" mode="profile"/></xslo:otherwise></xslo:choose></xslo:variable><xslo:variable xmlns:xslo="http://www.w3.org/1999/XSL/Transform" name="profiled-nodes" select="exslt:node-set($profiled-content)"/><xsl:template match="/"> + <!-- * Get a title for current doc so that we let the user --> + <!-- * know what document we are processing at this point. --> + <xsl:variable name="doc.title"> + <xsl:call-template name="get.doc.title"/> + </xsl:variable> + <xsl:choose> + <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document, + toss the namespace and continue. Use the docbook5 namespaced + stylesheets for DocBook5 if you don't want to use this feature.--> + <!-- include extra test for Xalan quirk --> + <xsl:when test="false()"/> + <!-- Can't process unless namespace removed --> + <xsl:when test="false()"/> + <xsl:otherwise> + <xsl:choose> + <xsl:when test="$rootid != ''"> + <xsl:choose> + <xsl:when test="count($profiled-nodes//*[@id=$rootid]) = 0"> + <xsl:message terminate="yes"> + <xsl:text>ID '</xsl:text> + <xsl:value-of select="$rootid"/> + <xsl:text>' not found in document.</xsl:text> + </xsl:message> + </xsl:when> + <xsl:otherwise> + <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'"> + <xsl:apply-templates select="key('id', $rootid)" mode="collect.targets"/> + </xsl:if> + <xsl:if test="$collect.xref.targets != 'only'"> + <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="process.root"/> + <xsl:if test="$tex.math.in.alt != ''"> + <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="collect.tex.math"/> + </xsl:if> + </xsl:if> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'"> + <xsl:apply-templates select="$profiled-nodes" mode="collect.targets"/> + </xsl:if> + <xsl:if test="$collect.xref.targets != 'only'"> + <xsl:apply-templates select="$profiled-nodes" mode="process.root"/> + <xsl:if test="$tex.math.in.alt != ''"> + <xsl:apply-templates select="$profiled-nodes" mode="collect.tex.math"/> + </xsl:if> + </xsl:if> + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="*" mode="process.root"> + <xsl:variable name="doc" select="self::*"/> + + <xsl:call-template name="user.preroot"/> + <xsl:call-template name="root.messages"/> + + <html> + <head> + <xsl:call-template name="system.head.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + <xsl:call-template name="head.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + <xsl:call-template name="user.head.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + </head> + <body> + <xsl:call-template name="body.attributes"/> + <xsl:call-template name="user.header.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + <xsl:apply-templates select="."/> + <xsl:call-template name="user.footer.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + </body> + </html> + <xsl:value-of select="$html.append"/> + + <!-- Generate any css files only once, not once per chunk --> + <xsl:call-template name="generate.css.files"/> +</xsl:template> + +<xsl:template name="root.messages"> + <!-- redefine this any way you'd like to output messages --> + <!-- DO NOT OUTPUT ANYTHING FROM THIS TEMPLATE --> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="chunk"> + <xsl:param name="node" select="."/> + + <!-- The default is that we are not chunking... --> + <xsl:text>0</xsl:text> +</xsl:template> + +</xsl:stylesheet> diff --git a/xhtml5/xhtml2xhtml5.xsl b/xhtml5/xhtml2xhtml5.xsl new file mode 100644 index 0000000..05fe68d --- /dev/null +++ b/xhtml5/xhtml2xhtml5.xsl @@ -0,0 +1,49 @@ +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xslo="http://www.w3.org/1999/XSL/TransformAlias" + version="1.0"> + +<xsl:output indent="no" method="xml"/> + +<xsl:namespace-alias stylesheet-prefix="xslo" result-prefix="xsl"/> + +<xsl:template match="node()|@*"> + <xsl:copy> + <xsl:apply-templates select="@*"/> + <xsl:apply-templates/> + </xsl:copy> +</xsl:template> + +<xsl:template match="xsl:output"> + <xsl:comment>Same as xhtml but with doctypes removed from xsl:output </xsl:comment> + <xsl:text> </xsl:text> + <xsl:comment>and including from ../xhtml directory </xsl:comment> + <xsl:text> </xsl:text> + <xslo:output method="xml" encoding="UTF-8" indent="no"/> +</xsl:template> + +<xsl:template match="xsl:include/@href"> + <xsl:choose> + <xsl:when test="starts-with(., '../')"> + <xsl:copy-of select="."/> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="href"> + <xsl:value-of select="concat('../xhtml/', .)"/> + </xsl:attribute> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="comment() + [starts-with(string(.), 'This file was created automatically')]"> + <xsl:text> </xsl:text> + <xsl:comment>This file was created automatically by xhtml2xhtml5.xsl from the xhtml stylesheet.</xsl:comment> + <xsl:text> </xsl:text> +</xsl:template> + +<xsl:template match="comment() + [starts-with(string(.), 'from the HTML stylesheets')]"/> + +<xsl:include href="../common/subtitles.xsl"/> +</xsl:stylesheet> + |