Skip to content

Commit

Permalink
Remove key artefacts
Browse files Browse the repository at this point in the history
  • Loading branch information
jelovirt committed Mar 3, 2023
1 parent 4e1bc1b commit 292907d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
15 changes: 15 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,26 @@
depends="build-init,
preprocess">
<makeurl property="output.dir.uri" file="${output.dir}"/>
<local name="_normalize-strip-keyref"/>
<condition property="_normalize-strip-keyref" value="true" else="false">
<and>
<not>
<isset property="keyref.skip"/>
</not>
<or>
<istrue value="${normalize-strip-keyref}"/>
<not>
<isset property="normalize-strip-keyref"/>
</not>
</or>
</and>
</condition>
<!--pipeline message="Normalize DITA files" taskname="normalize"-->
<xslt in="${dita.temp.dir}/.job.xml" out="${dita.temp.dir}/.job.xml.temp"
style="${dita.plugin.org.dita.normalize.dir}/xsl/normalize.xsl"
taskname="normalize">
<param name="output.dir.uri" expression="${output.dir.uri}"/>
<param name="normalize-strip-keyref" expression="${_normalize-strip-keyref}"/>
<xmlcatalog refid="dita.catalog"/>
</xslt>
<!--/pipeline-->
Expand Down
7 changes: 6 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
See the accompanying license.txt file for applicable licenses.
-->
<plugin id="org.dita.normalize">
<transtype name="dita" desc="Normalized DITA"/>
<transtype name="dita" desc="Normalized DITA">
<param name="normalize-strip-keyref" desc="Remove key artefacts after key resolution." type="enum">
<val default="true">yes</val>
<val>no</val>
</param>
</transtype>
<feature extension="dita.conductor.target.relative" file="conductor.xml"/>
</plugin>
10 changes: 9 additions & 1 deletion xsl/normalize.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

<xsl:import href="plugin:org.dita.base:xsl/common/uri-utils.xsl"/>

<xsl:param name="output.dir.uri"/>
<xsl:param name="output.dir.uri" as="xs:string"/>
<xsl:param name="normalize-strip-keyref" as="xs:string"/>

<xsl:function name="dita-ot:get-fragment" as="xs:string">
<xsl:param name="input" as="xs:string"/>
Expand Down Expand Up @@ -157,6 +158,13 @@
</xsl:element>
</xsl:template>

<xsl:template match="*[contains(@class, ' map/topicref ')]
[exists(@keys) and @processing-role = 'resource-only']
[$normalize-strip-keyref = 'true']"/>

<xsl:template match="@keyref[$normalize-strip-keyref = 'true'] |
@keys[$normalize-strip-keyref = 'true']"/>

<xsl:template match="*[contains(@class, ' topic/xref ') or
contains(@class, ' topic/xref ') or
contains(@class, ' map/topicref ')]
Expand Down

0 comments on commit 292907d

Please sign in to comment.