Exploiting FrameMaker MIF as XML, Back into MIF
[Read this for an introduction to what I'm talking about].
The first step of doing anything useful with MX is the ability to get back out into MIF. Thankfully, this is an entirely trivial job in XSLT.
[This code thanks to my boss, Andrew Savikas.]
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- author: Andrew Savikas, O'Reilly Media -->
<xsl:output method="text" encoding="ascii"/>
<xsl:strip-space elements="_facet"/>
<xsl:template match="/|MIF_ROOT">
<xsl:apply-templates/>
</xsl:template>
<!-- This template needs to remain flush left for correct output -->
<xsl:template match="_facet">
<xsl:text>
</xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="*">
<xsl:text><</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text> </xsl:text>
<xsl:apply-templates/>
<xsl:text>></xsl:text>
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>
The code is also available here or darcs get http://kfahlgren.com/code/mx/.