example script and XSLT for topic bursting

138 views
Skip to first unread message

Leigh White

unread,
May 29, 2015, 5:13:49 PM5/29/15
to dita-o...@googlegroups.com
Hi all,

Would anyone be willing to share a basic example of a script and XSLT they have used to burst one large DITA topic into multiple smaller ones? Not finding anything online, unfortunately, and I need something to jump-start me. Many thanks!

Leigh

Kristen James Eberlein

unread,
May 29, 2015, 6:01:52 PM5/29/15
to dita-o...@googlegroups.com
I use some code that Eliot initially developed to burst a composite topic into the following:
  • A DITA map
  • An individual topic for each topic previously in the single composite topic

Let me know offline if you want what I have. It's not ready for primetime.

Best,
Kris

Kristen James Eberlein
Chair, OASIS DITA Technical Committee
Principal consultant, Eberlein Consulting
www.eberleinconsulting.com
+1 919 682-2290; kriseberlein (skype)

--
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.
For more options, visit https://groups.google.com/d/optout.

George Bina

unread,
May 29, 2015, 6:31:40 PM5/29/15
to Leigh White, dita-o...@googlegroups.com
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>.

Eliot Kimber

unread,
Jun 1, 2015, 9:39:22 AM6/1/15
to Leigh White, dita-o...@googlegroups.com
This project in the GitHub DITA Community organization has some bursting code:


Cheers,

E.

--
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.

For more options, visit https://groups.google.com/d/optout.



--
Eliot Kimber
Reply all
Reply to author
Forward
0 new messages