summaryrefslogtreecommitdiff
path: root/epub3
diff options
context:
space:
mode:
authorKévin THIERRY <kevin.thierry@open.eurogiciel.org>2014-11-06 11:50:51 +0100
committerKévin THIERRY <kevin.thierry@open.eurogiciel.org>2014-11-06 11:50:51 +0100
commit14b660c1b43c74e8db2abb51e38e7a1aa38220a2 (patch)
treef78a8637465b7a4c9624fef03d27eb7aeaa779d4 /epub3
parentb2d73bee5e123c5e69352a447d4bc318132612d9 (diff)
downloaddocbook-xsl-stylesheets-14b660c1b43c74e8db2abb51e38e7a1aa38220a2.tar.gz
docbook-xsl-stylesheets-14b660c1b43c74e8db2abb51e38e7a1aa38220a2.tar.bz2
docbook-xsl-stylesheets-14b660c1b43c74e8db2abb51e38e7a1aa38220a2.zip
Imported Upstream version 1.78.1upstream/1.78.1
Diffstat (limited to 'epub3')
-rw-r--r--epub3/epub3-chunk-mods.xsl13
-rw-r--r--epub3/epub3-element-mods.xsl155
2 files changed, 124 insertions, 44 deletions
diff --git a/epub3/epub3-chunk-mods.xsl b/epub3/epub3-chunk-mods.xsl
index b4ea68d..7aa6901 100644
--- a/epub3/epub3-chunk-mods.xsl
+++ b/epub3/epub3-chunk-mods.xsl
@@ -28,6 +28,7 @@
<!-- EPUB3: customize to generate package files -->
<xsl:template match="*" mode="process.root" priority="2">
+ <xsl:call-template name="check.for.xalan"/>
<xsl:apply-templates select="."/>
<xsl:call-template name="generate.css.files"/>
@@ -35,4 +36,16 @@
</xsl:template>
+<xsl:template name="check.for.xalan">
+ <xsl:if test="contains(system-property('xsl:vendor'), 'Apache Software Foundation')">
+ <xsl:message terminate="yes">
+ <xsl:text>&#10;</xsl:text>
+ <xsl:text>FATAL ERROR: </xsl:text>
+ <xsl:text>Xalan processor not supported by DocBook Epub3 stylesheets. </xsl:text>
+ <xsl:text>Xalan does not properly support XSL output method="text", </xsl:text>
+ <xsl:text>which is required for the various epub support files.</xsl:text>
+ </xsl:message>
+ </xsl:if>
+</xsl:template>
+
</xsl:stylesheet>
diff --git a/epub3/epub3-element-mods.xsl b/epub3/epub3-element-mods.xsl
index 64f2629..8ba786d 100644
--- a/epub3/epub3-element-mods.xsl
+++ b/epub3/epub3-element-mods.xsl
@@ -52,6 +52,9 @@ article toc,title,figure,table,example,equation
<xsl:param name="base.dir" select="'OEBPS/'"/>
<xsl:param name="index.links.to.section" select="0"/>
+<!-- Epub does not yet support external links -->
+<xsl:param name="activate.external.olinks" select="0"/>
+
<!-- Turning this on crashes ADE, which is unbelievably awesome -->
<xsl:param name="formal.object.break.after">0</xsl:param>
@@ -135,17 +138,17 @@ article toc,title,figure,table,example,equation
<xsl:param name="editor.property">contributor</xsl:param>
<!-- Generate full output path -->
-<xsl:param name="epub.package.dir" select="concat($base.dir, '../')"/>
+<xsl:param name="epub.package.dir" select="concat($chunk.base.dir, '../')"/>
<xsl:param name="epub.ncx.pathname"
- select="concat($base.dir, $epub.ncx.filename)"/>
+ select="concat($chunk.base.dir, $epub.ncx.filename)"/>
<xsl:param name="epub.container.pathname"
select="concat($epub.package.dir, $epub.metainf.dir,
$epub.container.filename)"/>
<xsl:param name="epub.package.pathname"
- select="concat($base.dir, $epub.package.filename)"/>
+ select="concat($chunk.base.dir, $epub.package.filename)"/>
<xsl:param name="epub.cover.pathname"
- select="concat($base.dir, $epub.cover.filename)"/>
+ select="concat($chunk.base.dir, $epub.cover.filename)"/>
<xsl:param name="epub.mimetype.pathname"
select="concat($epub.package.dir, $epub.mimetype.filename)"/>
@@ -637,31 +640,41 @@ article toc,title,figure,table,example,equation
YYYY, YYYY-MM or YYYY-MM-DD -->
<xsl:template name="format.meta.date">
<xsl:param name="string" select="''"/>
+ <xsl:param name="node" select="."/>
- <!-- FIXME: this needs further work, so just return the date string for now -->
- <xsl:variable name="date">
+ <!-- FIXME: this needs further work, so just check the
+ string format and return the date string for now -->
+ <xsl:variable name="normalized"
+ select="translate($string, '0123456789', '##########')"/>
+
+ <xsl:variable name="date.ok">
<xsl:choose>
- <xsl:when test="string-length($string) = 0">
- </xsl:when>
- <xsl:otherwise>
- <!-- construct a date one digit at a time until it fails to match format -->
- <xsl:if test="contains('1234567890', substring($string,1,1))">
- <xsl:value-of select="substring($string,1,1)"/>
- </xsl:if>
- <xsl:if test="contains('1234567890', substring($string,2,1))">
- <xsl:value-of select="substring($string,2,1)"/>
- </xsl:if>
- <xsl:if test="contains('1234567890', substring($string,3,1))">
- <xsl:value-of select="substring($string,3,1)"/>
- </xsl:if>
- <xsl:if test="contains('1234567890', substring($string,4,1))">
- <xsl:value-of select="substring($string,4,1)"/>
- </xsl:if>
- <!-- FIXME: continue -->
- </xsl:otherwise>
+ <xsl:when test="string-length($string) = 4 and
+ $normalized = '####'">1</xsl:when>
+ <xsl:when test="string-length($string) = 7 and
+ $normalized = '####-##'">1</xsl:when>
+ <xsl:when test="string-length($string) = 10 and
+ $normalized = '####-##-##'">1</xsl:when>
+ <xsl:when test="string-length($string) = 10 and
+ $normalized = '####-##-##'">1</xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
+ <xsl:if test="$date.ok = 0">
+ <xsl:message>
+ <xsl:text>WARNING: wrong metadata date format: '</xsl:text>
+ <xsl:value-of select="$string"/>
+ <xsl:text>' in element </xsl:text>
+ <xsl:value-of select="local-name($node/..)"/>
+ <xsl:text>/</xsl:text>
+ <xsl:value-of select="local-name($node)"/>
+ <xsl:text>. It must be in one of these forms: </xsl:text>
+ <xsl:text>YYYY, YYYY-MM, or YYYY-MM-DD.</xsl:text>
+ </xsl:message>
+ </xsl:if>
+
+ <!-- return the string anyway -->
<xsl:value-of select="$string"/>
</xsl:template>
@@ -1224,12 +1237,20 @@ article toc,title,figure,table,example,equation
<xsl:variable name="object" select="$olist[position() = $object.index]"/>
- <xsl:variable name="image.filename">
+ <xsl:variable name="output_filename">
<xsl:call-template name="mediaobject.filename">
<xsl:with-param name="object" select="$object"/>
</xsl:call-template>
</xsl:variable>
+ <xsl:variable name="image.filename">
+ <xsl:if test="$img.src.path != '' and
+ not(starts-with($output_filename, '/')) and
+ not(contains($output_filename, '://'))">
+ <xsl:value-of select="$img.src.path"/>
+ </xsl:if>
+ <xsl:value-of select="$output_filename"/>
+ </xsl:variable>
<xsl:variable name="image.extension">
<xsl:call-template name="filename-extension">
<xsl:with-param name="filename" select="$image.filename"/>
@@ -1396,34 +1417,60 @@ article toc,title,figure,table,example,equation
<xsl:choose>
<xsl:when test="$next.chunk">
<xsl:variable name="this.imagedata"
- select="$this.chunk//imagedata"/>
+ select="$this.chunk//mediaobject"/>
<xsl:variable name="before.next"
- select="$next.chunk/preceding::imagedata"/>
+ select="$next.chunk/preceding::mediaobject"/>
<!-- select for an SVG imagedata in the intersection of them -->
- <xsl:variable name="intersection"
+ <xsl:variable name="mediaobject.set"
select="$this.imagedata[count(.|$before.next) = count($before.next)]"/>
+ <xsl:variable name="svg.imagedata">
+ <xsl:for-each select="$mediaobject.set">
+ <xsl:variable name="olist" select="imageobject[not(@role = 'poster')] |
+ imageobjectco"/>
+ <xsl:variable name="mediaobject.index">
+ <xsl:call-template name="select.mediaobject.index">
+ <xsl:with-param name="olist" select="$olist"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="object" select="$olist[position() = $mediaobject.index]"/>
+ <xsl:if test="$object/imagedata[contains(
+ substring(@fileref, string-length(@fileref)-3,4), '.svg')]">
+ <xsl:text>svg</xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
- <xsl:variable name="svg.imagedata"
- select="$intersection[contains(
- substring(@fileref, string-length(@fileref)-3,4), '.svg')]"/>
-
- <xsl:if test="count($svg.imagedata) != 0">
+ <xsl:if test="contains($svg.imagedata, 'svg')">
<xsl:text>svg</xsl:text>
</xsl:if>
</xsl:when>
<xsl:otherwise>
- <xsl:variable name="this.imagedata"
- select="$this.chunk//imagedata"/>
- <xsl:variable name="svg.imagedata"
- select="$this.imagedata[contains(
- substring(@fileref, string-length(@fileref)-3,4), '.svg')]"/>
- <xsl:if test="count($svg.imagedata) != 0">
+ <xsl:variable name="mediaobject.set"
+ select="$this.chunk//mediaobject"/>
+ <xsl:variable name="svg.imagedata">
+ <xsl:for-each select="$mediaobject.set">
+ <xsl:variable name="olist" select="imageobject[not(@role = 'poster')] |
+ imageobjectco"/>
+ <xsl:variable name="mediaobject.index">
+ <xsl:call-template name="select.mediaobject.index">
+ <xsl:with-param name="olist" select="$olist"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="object" select="$olist[position() = $mediaobject.index]"/>
+ <xsl:if test="$object/imagedata[contains(
+ substring(@fileref, string-length(@fileref)-3,4), '.svg')]">
+ <xsl:text>svg</xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <xsl:if test="contains($svg.imagedata, 'svg')">
<xsl:text>svg</xsl:text>
</xsl:if>
-
</xsl:otherwise>
</xsl:choose>
+
</xsl:template>
<xsl:template name="mathml.property">
@@ -1563,12 +1610,21 @@ article toc,title,figure,table,example,equation
<xsl:param name="object" select="."/>
<xsl:if test="$object">
- <xsl:variable name="image.filename">
+ <xsl:variable name="output_filename">
<xsl:call-template name="mediaobject.filename">
<xsl:with-param name="object" select="$object"/>
</xsl:call-template>
</xsl:variable>
+ <xsl:variable name="image.filename">
+ <xsl:if test="$img.src.path != '' and
+ not(starts-with($output_filename, '/')) and
+ not(contains($output_filename, '://'))">
+ <xsl:value-of select="$img.src.path"/>
+ </xsl:if>
+ <xsl:value-of select="$output_filename"/>
+ </xsl:variable>
+
<xsl:variable name="image.extension">
<xsl:call-template name="filename-extension">
<xsl:with-param name="filename" select="$image.filename"/>
@@ -1785,6 +1841,7 @@ article toc,title,figure,table,example,equation
<xsl:choose>
<xsl:when test="$root.is.a.chunk != '0'">
<xsl:apply-templates select="/*" mode="ncx" />
+ <xsl:apply-templates select="/*/*" mode="ncx" />
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="/*/*" mode="ncx" />
@@ -1895,7 +1952,11 @@ article toc,title,figure,table,example,equation
<xsl:value-of select="$href"/>
</xsl:attribute>
</xsl:element>
- <xsl:apply-templates select="book[parent::set]|part|reference|preface|chapter|bibliography|appendix|article|topic|glossary|section|sect1|sect2|sect3|sect4|sect5|refentry|colophon|bibliodiv[title]|setindex|index" mode="ncx"/>
+ <xsl:if test="$depth != 0">
+ <!-- Don't recurse on root element, but treat it as a single point so
+ the progress bar shows all top level children -->
+ <xsl:apply-templates select="book[parent::set]|part|reference|preface|chapter|bibliography|appendix|article|topic|glossary|section|sect1|sect2|sect3|sect4|sect5|refentry|colophon|bibliodiv[title]|setindex|index" mode="ncx"/>
+ </xsl:if>
</xsl:element>
</xsl:template>
@@ -1986,6 +2047,12 @@ article toc,title,figure,table,example,equation
</xsl:template>
<xsl:template name="container">
+ <!-- The path in rootfile does not include all of base.dir, only the last part -->
+ <xsl:variable name="full-path-dir">
+ <xsl:call-template name="filename-basename">
+ <xsl:with-param name="filename" select="$chunk.base.dir"/>
+ </xsl:call-template>
+ </xsl:variable>
<xsl:call-template name="write.chunk">
<xsl:with-param name="filename">
<xsl:value-of select="$epub.container.pathname" />
@@ -2004,7 +2071,7 @@ article toc,title,figure,table,example,equation
<xsl:element namespace="urn:oasis:names:tc:opendocument:xmlns:container" name="rootfile">
<xsl:attribute name="full-path">
<xsl:value-of
- select="concat($epub.oebps.dir, '/', $epub.package.filename)"/>
+ select="concat($full-path-dir, $epub.package.filename)"/>
</xsl:attribute>
<xsl:attribute name="media-type">
<xsl:text>application/oebps-package+xml</xsl:text>
@@ -2016,7 +2083,7 @@ article toc,title,figure,table,example,equation
</xsl:call-template>
</xsl:template>
-<xsl:template name="mimetype">'
+<xsl:template name="mimetype">
<xsl:call-template name="write.text.chunk">
<xsl:with-param name="filename" select="$epub.mimetype.pathname"/>
<xsl:with-param name="content" select="$epub.mimetype.value"/>