Skip to content

Commit

Permalink
Implement prefix for find-empty-inlines.xsl
Browse files Browse the repository at this point in the history
Parameter "prefix" is by default set to "d"
  • Loading branch information
tomschr committed Aug 3, 2023
1 parent d9572b2 commit c01449e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 9 additions & 1 deletion contrib/check-source/find-empty-inlines.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
Find empty inline elements in our sources.
These elements cause layout issues in HTML.
Parameters:
prefix: the prefix to use for the output XPath (default "d")
(without the colon)
Input:
DocBook 5 document
Expand All @@ -29,6 +33,8 @@
<xsl:strip-space elements="*"/>
<xsl:preserve-space elements="d:screen d:programlisting"/>

<!-- <xsl:param name="prefix">d</xsl:param>-->


<xsl:template name="error">
<xsl:param name="node" select="."/>
Expand All @@ -48,7 +54,9 @@
select="concat('[', $level, '] ', $msg, ' Element &lt;', local-name($node), '>')"
/> located near id=<xsl:value-of
select="$id"/>, title=<xsl:value-of select="normalize-space($title)"/>
XPath=<xsl:call-template name="xpath.location"/>
XPath=<xsl:call-template name="xpath.location">
<xsl:with-param name="prefix" select="$prefix"/>
</xsl:call-template>
</xsl:message>
</xsl:template>

Expand Down
8 changes: 7 additions & 1 deletion daps-xslt/common/xpath.location.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
Returns the XPath of a node, including predicates if needed
Parameters:
None
prefix: the prefix to use for the output XPath (default "d")
(without the colon)
Dependencies:
None
Expand All @@ -28,7 +29,10 @@
Original template from http://docbook.sourceforge.net/release/xsl/current/lib/lib.xsl
-->

<xsl:param name="prefix">d</xsl:param>

<xsl:template name="xpath.location">
<xsl:param name="prefix" select="$prefix"/>
<xsl:param name="node" select="."/>
<xsl:param name="path" select="''"/>

Expand All @@ -38,6 +42,7 @@
select="count($node/preceding-sibling::*[name(.) = name($node)])"/>

<xsl:variable name="next.path">
<xsl:if test="$prefix != ''"><xsl:value-of select="concat($prefix, ':')"/></xsl:if>
<xsl:value-of select="local-name($node)"/>
<xsl:if test="$path != ''">
<xsl:if test="$prec-sib >0">
Expand All @@ -51,6 +56,7 @@
<xsl:choose>
<xsl:when test="$node/parent::*">
<xsl:call-template name="xpath.location">
<xsl:with-param name="prefix" select="$prefix"/>
<xsl:with-param name="node" select="$node/parent::*"/>
<xsl:with-param name="path" select="$next.path"/>
</xsl:call-template>
Expand Down

0 comments on commit c01449e

Please sign in to comment.