Page 1 of 1

Map transformation that runs XSLT transformation on the topi

Posted: Thu Oct 16, 2014 3:33 pm
by Frank Ralf
Hi,

I want to create a map transformation which runs a normal XSLT transformation on every topic. The use case is a software block (map) with each function described in a separate topic. The XSLT transformation shall generate a header file from all the topics referenced in the map. The output shall be one header file containing all functions for the software block.

Any pointers welcome

TIA
Frank

Re: Map transformation that runs XSLT transformation on the

Posted: Fri Oct 17, 2014 9:14 am
by Radu
Hi Frank,

You may want to take a look at the XSL George wrote which gets applied on a DITA Map and generates a report for content loaded from all referenced topics:

OXYGEN_INSTALL_DIR\frameworks\dita\report\report.xsl

When applied on the root map element the template gets all the content of the DITA Map expanded in a single variable:

Code: Select all

        <xsl:variable name="resolved">
<oxyd:mapref xml:base="{document-uri(.)}">
<xsl:apply-templates select="/" mode="resolve"/>
</oxyd:mapref>
</xsl:variable>
That merged content is obtained by calling templates from the XSLT module:

OXYGEN_INSTALL_DIR\frameworks\dita\report\modules\resolve.xsl

which you could probably re-use completely in your XSLT stylesheet.

After you have the content with all topicrefs expanded in a single variable, you can do anything you want with it.

Regards,
Radu

Re: Map transformation that runs XSLT transformation on the

Posted: Fri Oct 17, 2014 12:06 pm
by Frank Ralf
Hi Radu,

Many thanks, that looks great! I will give it a try and report back.

Kind regards,
Frank

Re: Map transformation that runs XSLT transformation on the

Posted: Mon Oct 20, 2014 6:24 pm
by Frank Ralf
Hi Radu,

I got this working in principle, using the code-snippet from report.xsl. Some hints for others who want to give it a try:
  • 1. For instructions on multiple transformations (pipelining) in one stylesheet see http://www.oxygenxml.com/archives/xsl-l ... 00406.html.
    2. Because resolve.xsl uses some XSLT 2.0 features you have to make sure to choose a XSLT 2 capable engine in your transformation scenario.
Thanks again
Frank