Use object.id in boostbook to docbook conversion

Will generate more consistent ids if generate.consistent.ids is set to 1.
This commit is contained in:
Daniel James 2017-10-25 01:14:54 +01:00
parent 6740d35836
commit 1b8441c17c
3 changed files with 10 additions and 5 deletions

View File

@ -9,12 +9,16 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xi="http://www.w3.org/2001/XInclude"
version="1.0">
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/common/common.xsl"/>
<xsl:include href="reference.xsl"/>
<xsl:output method="xml"
doctype-public="-//OASIS//DTD DocBook XML V4.2//EN"
doctype-system="http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"/>
<!-- Generate consistent id values if document is unchanged -->
<xsl:param name="generate.consistent.ids" select="0"/>
<!-- The maximum number of columns allowed in preformatted text -->
<xsl:param name="max-columns" select="78"/>

View File

@ -22,7 +22,7 @@
</xsl:template>
<xsl:template match="*" mode="generate.id">
<xsl:value-of select="generate-id(.)"/>
<xsl:call-template name="object.id"/>
<xsl:text>-bb</xsl:text>
</xsl:template>
@ -185,7 +185,7 @@
<xsl:template match="*" mode="preprocess-ids">
<element>
<xsl:attribute name="id">
<xsl:value-of select="generate-id()"/>
<xsl:call-template name="object.id"/>
</xsl:attribute>
<xsl:attribute name="part-id">
<xsl:call-template name="print-id-part"/>
@ -234,10 +234,11 @@
translate($part, '.&lt;&gt;;\:*?&quot;| ', '') != $part
)">
<xsl:variable name="normalized" select="translate(normalize-space(translate($part, '.&lt;&gt;;\:*?&quot;|_', ' ')), ' ', '_')"/>
<xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
<xsl:value-of select =
"concat(
substring($normalized, 1, $boost.max.id.part.length - string-length(generate-id(.)) - 1),
concat('_', generate-id(.)))"/>
substring($normalized, 1, $boost.max.id.part.length - string-length($id) - 1),
concat('_', $id))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$part"/>

View File

@ -115,7 +115,7 @@
<xsl:if test="count(key('named-entities',
translate(@name, $uppercase-letters, $lowercase-letters)))!=1">
<xsl:text>_</xsl:text>
<xsl:value-of select="generate-id(.)"/>
<xsl:call-template name="object.id"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>