XSLT in batch
Posted: Mon Jun 06, 2016 8:02 am
Hello,
We'd like to perform some cleanup on our DITA files using XSLT. Here is the code that we'd like to run across all files in the database:
Fortunately, in Oxygen we can create a project and then run a transform on all files in a folder pretty easily. I set the XML URL to ${currentFileURL} and it shows the results fine in the resources tab. The issue is that the files are not actually being modified.
So, to run the XSLT code and actually modify the files, what setting or coded content are we missing??
Thanks for your time.
Take care,
- Nick
We'd like to perform some cleanup on our DITA files using XSLT. Here is the code that we'd like to run across all files in the database:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<!-- Remove certain topicref attributes -->
<xsl:template match="topicref/@type[.='concept' or .='reference' or .='task']"/>
<xsl:template match="topicref/@format[.='ditamap' or .='dita']"/>
<xsl:template match="@scope[.='local']"/>
<xsl:template match="topicref/@navtitle"/>
<xsl:template match="@class"/>
<!-- Remove certain mapref attributes -->
<xsl:template match="mapref/@format[.='ditamap']"/>
<xsl:template match="mapref/@type[.='map']"/>
<xsl:template match="mapref/@navtitle"/>
<!-- Remove certain keydef attributes -->
<xsl:template match="keydef/@type[.='concept' or .='reference' or .='task']"/>
<xsl:template match="keydef/@format[.='ditamap' or .='dita']"/>
<xsl:template match="keydef/@processing-role[.='resource-only']"/>
<!-- Add image alt text element using the imate alt attribute -->
<xsl:template match="image">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<alt>
<xsl:value-of select="@alt"/>
</alt>
</xsl:copy>
</xsl:template>
<!-- Remove image alt attribute -->
<xsl:template match="image/@alt"/>
</xsl:stylesheet>
So, to run the XSLT code and actually modify the files, what setting or coded content are we missing??
Thanks for your time.
Take care,
- Nick