If you want to overwrite the way one stylesheet process some node (@xml:id
i.e.), import the stylesheet and declare your own rule:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="docbook2dita.xsl"/>
<xsl:template match="@xml:id">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
EDIT: If it's garanteed a one-to-one transformation (i.e. section
to reference
), then this stylesheet:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:import href="test2.xsl"/>
<xsl:template match="*[@xml:id]">
<xsl:variable name="vResult">
<xsl:apply-imports/>
</xsl:variable>
<xsl:apply-templates select="msxsl:node-set($vResult)/*" mode="copy">
<xsl:with-param name="pId" select="@xml:id"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="/*/@id" mode="copy"/>
<xsl:template match="node()|@*" mode="copy">
<xsl:param name="pId" select="/.."/>
<xsl:copy>
<xsl:apply-templates select="@*" mode="copy"/>
<xsl:apply-templates select="$pId" mode="copy"/>
<xsl:apply-templates select="node()" mode="copy"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
It should preserve @xml:id
and strip any calculate @id
.
As proof, this input:
<root>
<section xml:id="555" xmlns="http://docbook.org/ns/docbook"/>
<section id="111" xmlns="http://docbook.org/ns/docbook"/>
</root>
With this imported stylesheet test2.xsl
:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:db="http://docbook.org/ns/docbook"
exclude-result-prefixes="db">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="db:section">
<reference id="{(@id|@xml:id)[1]}-sufix"/>
</xsl:template>
</xsl:stylesheet>
Output:
<root>
<reference xml:id="555"></reference>
<reference id="111-sufix" />
</root>
Note: If this doesn't help you, you should post a question in DITA forum