Skip to content

Commit

Permalink
ASCIIDoc: Copy namespaces to root element
Browse files Browse the repository at this point in the history
During the postprocess step, the stylesheets copy some often used
namespaces (XLink, XInclude, ITS) to the root element of the result
tree.

This makes it easier to add, for example, its:translate attribute
into the docinfo file.
  • Loading branch information
tomschr committed Aug 1, 2024
1 parent 96bd88b commit 6b98ed4
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion daps-xslt/asciidoc/postprocess.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,34 @@
<xsl:stylesheet version="1.0"
xmlns="&db5ns;"
xmlns:d="&db5ns;"
xmlns:exsl="http://exslt.org/common"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:its="http://www.w3.org/2005/11/its"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="d">
exclude-result-prefixes="d exsl">

<xsl:import href="../common/copy.xsl"/>
<xsl:output indent="yes"/>

<xsl:variable name="namespaces">
<its:foo/>
<xlink:foo/>
<xi:foo/>
</xsl:variable>
<xsl:variable name="namespace-nodes" select="exsl:node-set($namespaces)"/>

<!-- This rule is only necessary to copy the namespaces into the root element -->
<xsl:template match="/*">
<xsl:copy>
<!-- Copy the namespaces -->
<xsl:for-each select="$namespace-nodes//*/namespace::*">
<xsl:copy-of select="."/>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<xsl:template match="d:authorinitials"/>
<!-- othername & lineage arguably out to be supported by GeekoDoc but aren't currently. -->
<xsl:template match="d:othername|d:lineage"/>
Expand Down

0 comments on commit 6b98ed4

Please sign in to comment.