<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Keith's Blog &#187; FrameMaker</title>
	<atom:link href="http://kfahlgren.com/blog/category/framemaker/feed/" rel="self" type="application/rss+xml" />
	<link>http://kfahlgren.com/blog</link>
	<description>Keith on XML, Publishing, Ruby, Birds, &#038; San Francisco</description>
	<lastBuildDate>Fri, 09 Apr 2010 15:59:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Exploiting FrameMaker MIF as XML, Reading Bookfiles</title>
		<link>http://kfahlgren.com/blog/2007/02/25/exploiting-framemaker-mif-as-xml-reading-bookfiles/</link>
		<comments>http://kfahlgren.com/blog/2007/02/25/exploiting-framemaker-mif-as-xml-reading-bookfiles/#comments</comments>
		<pubDate>Sun, 25 Feb 2007 16:38:49 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[FrameMaker]]></category>
		<category><![CDATA[MX]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XSLT]]></category>

		<guid isPermaLink="false">http://kfahlgren.com/blog/2007/02/25/exploiting-framemaker-mif-as-xml-reading-bookfiles/</guid>
		<description><![CDATA[[Read this for an introduction to what I'm talking about]. Now that we&#8217;ve got our FrameMaker documents in XML, how can we exploit their new format? One of the first things I did was to create new ways of reading (eventually changing) the simple data stored within them. This isn&#8217;t all that earth-shattering, but when [...]]]></description>
			<content:encoded><![CDATA[<p>[Read <a href="http://kfahlgren.com/blog/2007/02/03/exploiting-framemaker-mif-as-xml-introduction/">this</a> for an introduction to what I'm talking about].</p>
<p>Now that we&#8217;ve got our FrameMaker documents in XML, how can we exploit their new format? One of the first things I did was to create new ways of reading (eventually changing) the simple data stored within them. This isn&#8217;t all that earth-shattering, but when you consider how difficult it is to find and change some values in the FrameMaker UI this is a big win. Where to start? Bookfiles.</p>
<p>To be able to apply stylesheets or data-collection tools to books (rather than individual files), I need to be able to collect a books components. So, convert your bookfile to MX (yeah, it works on bookfiles as well as chapter files), and search through it for one of the filenames you know is a part of the book (you&#8217;ll probably want to pretty-print the XML first). I get something like this:</p>
<pre>  &lt;BookComponent&gt;
    &lt;FileName&gt;`&amp;lt;c\&amp;gt;ch01'&lt;/FileName&gt;
    &lt;Unique&gt;27107&lt;/Unique&gt;
    &lt;StartPageSide&gt;StartRightSide&lt;/StartPageSide&gt;
    &lt;PageNumbering&gt;Restart&lt;/PageNumbering&gt;
    &lt;PgfNumbering&gt;Continue&lt;/PgfNumbering&gt;
    &lt;PageNumPrefix&gt;`'&lt;/PageNumPrefix&gt;
    &lt;PageNumSuffix&gt;`'&lt;/PageNumSuffix&gt;
    &lt;DefaultPrint&gt;Yes&lt;/DefaultPrint&gt;
    &lt;DefaultApply&gt;Yes&lt;/DefaultApply&gt;
  &lt;/BookComponent&gt;</pre>
<p>MX in this case has a pretty comprehensible structure, so we&#8217;ll need to grab a <tt>BookComponent/FileName</tt>, do a little text processing to remove the funky characters, and potentially append our MX file extension (I chose &#8220;.mx&#8221;). Here&#8217;s a very simple stylesheet to do just that:</p>
<pre>&lt;?xml version="1.0"?&gt;
&lt;xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:output method="xml" indent="yes"/&gt;

  &lt;xsl:template match="@*|node()"&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/xsl:template&gt;  

  &lt;xsl:template match="/"&gt;
    &lt;xsl:element name="components"&gt;
      &lt;xsl:apply-templates/&gt;
    &lt;/xsl:element&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="//BookComponent/FileName"&gt;
    &lt;xsl:param name="extension" select="'.mx'"/&gt;
    &lt;xsl:variable name="str-after"&gt;
      &lt;xsl:value-of select="substring-after(., '&gt;')"/&gt;
    &lt;/xsl:variable&gt;
    &lt;xsl:element name="component"&gt;
      &lt;xsl:value-of select="substring($str-after,
                                      1,
                                      string-length($str-after) - 1)"/&gt;
      &lt;xsl:value-of select="$extension"/&gt;
    &lt;/xsl:element&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;</pre>
<p>When you run that on a MX bookfile, you should see an output like this (note that the file extension is customizable above):</p>
<pre>&lt;?xml version="1.0"?&gt;
&lt;components&gt;
  &lt;component&gt;svcTOC.fm.mx&lt;/component&gt;
  &lt;component&gt;foreword.mx&lt;/component&gt;
  &lt;component&gt;ch00.mx&lt;/component&gt;
  &lt;component&gt;ch01.mx&lt;/component&gt;
  &lt;component&gt;ch02.mx&lt;/component&gt;
  &lt;component&gt;ch03.mx&lt;/component&gt;
  &lt;component&gt;ch04.mx&lt;/component&gt;
  &lt;component&gt;ch05.mx&lt;/component&gt;
  &lt;component&gt;ch06.mx&lt;/component&gt;
  &lt;component&gt;ch07.mx&lt;/component&gt;
  &lt;component&gt;ch08.mx&lt;/component&gt;
  &lt;component&gt;ch09.mx&lt;/component&gt;
  &lt;component&gt;appa.mx&lt;/component&gt;
  &lt;component&gt;appb.mx&lt;/component&gt;
  &lt;component&gt;appc.mx&lt;/component&gt;
  &lt;component&gt;appd.mx&lt;/component&gt;
  &lt;component&gt;appe.mx&lt;/component&gt;
  &lt;component&gt;svcIX.fm.mx&lt;/component&gt;
  &lt;component&gt;svcAPL.fm.mx&lt;/component&gt;
  &lt;component&gt;svcLOR.fm.mx&lt;/component&gt;
&lt;/components&gt;</pre>
<p>That&#8217;ll give us a nice structure to direct other processes to the individual component files.</p>
<p>The code is also available <a href="http://kfahlgren.com/code/mx/xslt/mxgetbookcomponents.xsl">here</a> or <tt>darcs get http://kfahlgren.com/code/mx/</tt>.</p>
]]></content:encoded>
			<wfw:commentRss>http://kfahlgren.com/blog/2007/02/25/exploiting-framemaker-mif-as-xml-reading-bookfiles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exploiting FrameMaker MIF as XML, Back into MIF</title>
		<link>http://kfahlgren.com/blog/2007/02/03/exploiting-framemaker-mif-as-xml-back-into-mif/</link>
		<comments>http://kfahlgren.com/blog/2007/02/03/exploiting-framemaker-mif-as-xml-back-into-mif/#comments</comments>
		<pubDate>Sat, 03 Feb 2007 20:24:31 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[FrameMaker]]></category>
		<category><![CDATA[MX]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XSLT]]></category>

		<guid isPermaLink="false">http://kfahlgren.com/blog/?p=35</guid>
		<description><![CDATA[[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.] &#60;?xml version="1.0"?&#62; &#60;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&#62; &#60;!-- author: Andrew Savikas, O'Reilly [...]]]></description>
			<content:encoded><![CDATA[<p>[Read <a href="http://kfahlgren.com/blog/2007/02/03/exploiting-framemaker-mif-as-xml-introduction/">this</a> for an introduction to what I'm talking about].</p>
<p>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.</p>
<p>[This code thanks to my boss, <a href="http://www.oreillynet.com/pub/au/1848">Andrew Savikas</a>.]</p>
<pre>
&lt;?xml version="1.0"?&gt;
&lt;xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;!-- author: Andrew Savikas, O'Reilly Media --&gt;

  &lt;xsl:output method="text" encoding="ascii"/&gt;
  &lt;xsl:strip-space elements="_facet"/&gt;

  &lt;xsl:template match="/|MIF_ROOT"&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/xsl:template&gt;

&lt;!-- This template needs to remain flush left for correct output --&gt;
&lt;xsl:template match="_facet"&gt;
&lt;xsl:text&gt;
&lt;/xsl:text&gt;
&lt;xsl:apply-templates/&gt;
&lt;/xsl:template&gt;

  &lt;xsl:template match="*"&gt;
    &lt;xsl:text&gt;&amp;lt;&lt;/xsl:text&gt;
      &lt;xsl:value-of select="name()"/&gt;
    &lt;xsl:text&gt; &lt;/xsl:text&gt;
    &lt;xsl:apply-templates/&gt;
    &lt;xsl:text&gt;&amp;gt;&lt;/xsl:text&gt;
    &lt;xsl:text&gt; &lt;/xsl:text&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;
</pre>
<p>The code is also available <a href="http://kfahlgren.com/code/mx/xslt/mx2mif.xsl">here</a> or <tt>darcs get http://kfahlgren.com/code/mx/</tt>.</p>
]]></content:encoded>
			<wfw:commentRss>http://kfahlgren.com/blog/2007/02/03/exploiting-framemaker-mif-as-xml-back-into-mif/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exploiting FrameMaker MIF as XML, Introduction</title>
		<link>http://kfahlgren.com/blog/2007/02/03/exploiting-framemaker-mif-as-xml-introduction/</link>
		<comments>http://kfahlgren.com/blog/2007/02/03/exploiting-framemaker-mif-as-xml-introduction/#comments</comments>
		<pubDate>Sat, 03 Feb 2007 19:32:26 +0000</pubDate>
		<dc:creator>Keith</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[DocBook]]></category>
		<category><![CDATA[FrameMaker]]></category>
		<category><![CDATA[MX]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://kfahlgren.com/blog/?p=34</guid>
		<description><![CDATA[My O&#8217;Reilly colleague Andy Bruno has just written a pair of posts on converting FrameMaker&#8217;s MIF (link may be old/die) format into XML (henceforth &#8216;MX&#8217;). I&#8217;ll be writing a few posts outlining the ways in which we&#8217;ve leveraged MX at O&#8217;Reilly. [Update: Series continues here with getting back into MIF, and reading bookfiles.] Background After [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://oreilly.com">O&#8217;Reilly</a> colleague <a href="http://left.subtree.org">Andy Bruno</a> has just written a <a href="http://left.subtree.org/2007/01/25/converting-mif-to-xml/">pair</a> of <a href="http://left.subtree.org/2007/01/31/converting-mif-to-xml-java-version/">posts</a> on converting <a href="http://www.adobe.com/products/framemaker/">FrameMaker&#8217;s</a> <a href="http://partners.adobe.com/public/developer/en/framemaker/MIF_Reference.pdf">MIF</a> (link may be old/die) format into XML (henceforth &#8216;MX&#8217;). I&#8217;ll be writing a few posts outlining the ways in which we&#8217;ve leveraged MX at O&#8217;Reilly.</p>
<p>[Update: Series continues here with <a href="http://kfahlgren.com/blog/2007/02/03/exploiting-framemaker-mif-as-xml-back-into-mif/">getting back into MIF</a>, and <a href="http://kfahlgren.com/blog/2007/02/25/exploiting-framemaker-mif-as-xml-reading-bookfiles/">reading bookfiles</a>.]</p>
<p><span id="more-34"></span></p>
<h3>Background</h3>
<p>After helping to get <a href="http://www.docbook.org/tdg/en/html/docbook.html">DocBook</a> <a href="http://tim.oreilly.com/articles/longview.html">off the ground</a> in the early 90s, the company moved away from DocBook toward FrameMaker in the late 90s. FrameMaker continues to be our standard page layout program today for the core series: Cookbooks, Animal books, and Hacks books. InDesign controls our <a href="http://www.oreilly.com/store/series/headfirst.html">graphically rich series</a> and we&#8217;ve recently started pushing DocBook heavily again thanks to the <a href="http://www.sagehill.net/docbookxsl/">DocBook-XSL</a> project (see the <a href="http://www.oreilly.com/catalog/9780596527310/"><em>Rails Cookbook</em></a>, <a href="http://www.oreilly.com/catalog/unicode/index.html"><em>Unicode Explained</em></a>, or future <a href="http://www.oreilly.com/store/series/sc.csp">Short Cuts</a> for examples using DocBook-XSL).</p>
<p>Getting our corpus of hundreds of past and present FrameMaker titles into a round-trippable XML format was the basis for a huge technological breakthrough in all of O&#8217;Reilly&#8217;s underlying book production software. Andy was not the first O&#8217;Reilly employee to work on two-way converters, but his work came at a time when the entire XML toolchain was finally reaching maturity.</p>
<h3>Uses</h3>
<p>Some examples of what we did with MX (some of which I&#8217;ll try to highlight in future posts):</p>
<dl>
<dt>Conversions</dt>
<dd>We rewrote every single conversion path (both into FrameMaker and out of it) around MX over the course of a year:</p>
<ul>
<li>Word to Frame (Word 2003 XML)</li>
<li>Frame to DocBook (using XSLT2)</li>
<li>Frame to Word (for new revisions)</li>
<li>DocBook to Frame [partway] (but this was scrapped in favor of DocBook-XSL)</li>
</ul>
</dd>
<dt>Templates</dt>
<dd>MX allowed us to transform our templates into spec documents describing in detail all of our default styles (this was invaluable writing our DocBook-XSL customization layer)</dd>
<dt>Data Queries</dt>
<dd>We built some proof-of-concept data gatherers (much like <a href="http://labs.oreilly.com">labs.oreilly.com</a>).</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://kfahlgren.com/blog/2007/02/03/exploiting-framemaker-mif-as-xml-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

