diff --git a/ws/Docbook/Extensions/Xsl/common.xsl b/ws/Docbook/Extensions/Xsl/common.xsl new file mode 100644 index 0000000000000000000000000000000000000000..17dc33e36205a3466543c00f6b71cb482f3fedef --- /dev/null +++ b/ws/Docbook/Extensions/Xsl/common.xsl @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + exclude-result-prefixes="xs" + version="2.0"> + + <xsl:template name="hdm.get.leftmost.of.seperator"> + <xsl:param name="path"/> + <xsl:param name="seperator"/> + <xsl:param name="start">1</xsl:param> + <xsl:if test="contains($path, $seperator )"> + <xsl:if test="$start='0'"> + <xsl:value-of select="$seperator"/> + </xsl:if> + <xsl:value-of select="substring-before($path, $seperator)"/> + <xsl:call-template name="hdm.get.leftmost.of.seperator"> + <xsl:with-param name="path" select="substring-after($path, $seperator)"/> + <xsl:with-param name="seperator" select="$seperator"/> + <xsl:with-param name="start">0</xsl:with-param> + </xsl:call-template> + </xsl:if> + </xsl:template> + +</xsl:stylesheet> \ No newline at end of file diff --git a/ws/Docbook/Extensions/Xsl/docbook2docbook.xsl b/ws/Docbook/Extensions/Xsl/docbook2docbook.xsl index d30f899f31eb90ee8403e25855bafd8568544dbb..d008d406ef3c2f8057a8e54fc27b5eb0330263a5 100644 --- a/ws/Docbook/Extensions/Xsl/docbook2docbook.xsl +++ b/ws/Docbook/Extensions/Xsl/docbook2docbook.xsl @@ -3,6 +3,8 @@ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" xmlns:db="http://docbook.org/ns/docbook"> + <xsl:include href="common.xsl"/> + <xsl:param name="generateIdPrefix">__sdwordm4342cs__</xsl:param> <xsl:output indent="yes"/> <xsl:param name="lastAnswerId" select="document('lastAnswerId.xml',/)/lastAnswer/@id" /> @@ -146,23 +148,6 @@ </link> </xsl:template> - <xsl:template name="hdm.get.leftmost.of.seperator"> - <xsl:param name="path"/> - <xsl:param name="seperator"/> - <xsl:param name="start">1</xsl:param> - <xsl:if test="contains($path, $seperator )"> - <xsl:if test="$start='0'"> - <xsl:value-of select="$seperator"/> - </xsl:if> - <xsl:value-of select="substring-before($path, $seperator)"/> - <xsl:call-template name="hdm.get.leftmost.of.seperator"> - <xsl:with-param name="path" select="substring-after($path, $seperator)"/> - <xsl:with-param name="seperator" select="$seperator"/> - <xsl:with-param name="start">0</xsl:with-param> - </xsl:call-template> - </xsl:if> - </xsl:template> - <!-- Excluding non-referenced <bibliography> and <glossary> elements --> <xsl:template match="db:bibliography/db:biblioentry[not(key('internRef', @xml:id))]"> @@ -175,6 +160,24 @@ </xsl:comment> </xsl:template> + <xsl:template match="db:glossary//db:glosslist"> + + <xsl:choose> + <xsl:when test=".//db:glossentry[key('internRef', @xml:id) or key('internRef', .//*/@xml:id)]"> + <xsl:comment>Non-empty glosslist</xsl:comment> + <xsl:copy> + <xsl:apply-templates select="@* | node()"/> + </xsl:copy> + </xsl:when> + <xsl:otherwise> + <xsl:comment> + <xsl:text>No @xml:id or all glosslist entries are not being referenced, excluding whole list.</xsl:text> + </xsl:comment> + <xsl:apply-templates select="db:glossentry"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + <xsl:template match="db:glossary/db:glosslist//db:glossentry[not(key('internRef', @xml:id)) and not(key('internRef', .//*/@xml:id))]"> <xsl:comment> <xsl:text>Excluding non referenced glossary entry '</xsl:text> diff --git a/ws/Docbook/Extensions/Xsl/docbookExtractFig.xsl b/ws/Docbook/Extensions/Xsl/docbookExtractFig.xsl index 4e5cb309e36ea27f4a845b73557505cfeef8b87f..68663ec55cf48fe7595dff90b72827c464fe64a0 100644 --- a/ws/Docbook/Extensions/Xsl/docbookExtractFig.xsl +++ b/ws/Docbook/Extensions/Xsl/docbookExtractFig.xsl @@ -3,7 +3,7 @@ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" xmlns:d="http://docbook.org/ns/docbook"> - + <xsl:include href="common.xsl"/> <xsl:template match="/"> <xsl:apply-templates select="//d:imagedata[ends-with(@fileref, '.fig') ]" mode="goik"/> @@ -64,25 +64,7 @@ </xsl:text> </xsl:result-document> </xsl:template> - - - <xsl:template name="hdm.get.leftmost.of.seperator"> - <xsl:param name="path"/> - <xsl:param name="seperator"/> - <xsl:param name="start">1</xsl:param> - <xsl:if test="contains($path, $seperator )"> - <xsl:if test="$start='0'"> - <xsl:value-of select="$seperator"/> - </xsl:if> - <xsl:value-of select="substring-before($path, $seperator)"/> - <xsl:call-template name="hdm.get.leftmost.of.seperator"> - <xsl:with-param name="path" select="substring-after($path, $seperator)"/> - <xsl:with-param name="seperator" select="$seperator"/> - <xsl:with-param name="start">0</xsl:with-param> - </xsl:call-template> - </xsl:if> - </xsl:template> - + <xsl:template name="hdm.get.pure.filename"> <xsl:param name="path"/> <xsl:choose>