Hi Leigh,
On the DITA Awareness Group on LinkedIn there was a discussion where I
posted a script that takes a topic with nested topics and generates a
map and places each topic to a file:
https://www.linkedin.com/grp/post/162465-5999652510074159104
***
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
xmlns:xs="
http://www.w3.org/2001/XMLSchema"
xmlns:xd="
http://www.oxygenxml.com/ns/doc/xsl"
exclude-result-prefixes="xs xd" version="2.0">
<xsl:output name="topic" doctype-public="-//OASIS//DTD DITA Topic//EN"
doctype-system="topic.dtd"/>
<xsl:output name="map" doctype-public="-//OASIS//DTD DITA Map//EN"
doctype-system="map.dtd"/>
<xsl:template match="/">
<xsl:text>Done, look in the extracted folder for the result
topic files</xsl:text>
<xsl:for-each select="//topic">
<xsl:variable name="actualTitle">
<xsl:call-template name="getTopicName"/>
</xsl:variable>
<xsl:result-document
href="extracted/topics/{$actualTitle}.dita" format="topic">
<xsl:copy>
<xsl:apply-templates select="@*" mode="copy"/>
<xsl:apply-templates mode="copy"/>
</xsl:copy>
</xsl:result-document>
</xsl:for-each>
<xsl:result-document href="extracted/map.ditamap" format="map">
<map>
<title>Generated DITA Map</title>
<xsl:apply-templates select="." mode="map"/>
</map>
</xsl:result-document>
</xsl:template>
<xsl:template match="node() | @*" mode="copy">
<xsl:copy>
<xsl:apply-templates select="node() | @*" mode="copy"/>
</xsl:copy>
</xsl:template>
<xsl:template match="topic" mode="copy"/>
<xsl:template match="topic" mode="map">
<xsl:variable name="actualTitle">
<xsl:call-template name="getTopicName"/>
</xsl:variable>
<topicref href="topics/{$actualTitle}.dita" format="dita">
<xsl:apply-templates mode="map"/>
</topicref>
</xsl:template>
<xsl:template mode="map" match="text()"/>
<xsl:template name="getTopicName">
<xsl:variable name="title" select="translate(title, ' ?', '_')"/>
<xsl:variable name="similarTitles"
select="count(preceding::topic[translate(title, ' ?', '_')
= $title])"/>
<xsl:value-of
select="
concat($title, if ($similarTitles = 0) then
''
else
$similarTitles)"
/>
</xsl:template>
</xsl:stylesheet>
***
Best Regards,
George
--
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
> --
> You received this message because you are subscribed to the Google
> Groups "DITA-OT Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
dita-ot-user...@googlegroups.com
> <mailto:
dita-ot-user...@googlegroups.com>.