This is the mail archive of the docbook@lists.oasis-open.org mailing list for the DocBook project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Frame -> DocBook XSLT


Hi,

Here's a quick and dirty Framemaker XML -> DocBook XML XSLT style sheet.
I am not aware of any other XSLT sheet for this conversion, so I wrote
my own. Perhaps it can be of use to someone. Have fun!

-Amos

--
Amos Latteier         mailto:amos@digicool.com
Digital Creations     http://www.digicool.com

--

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version='1.0'>

<!--

  XSLT to convert Framemaker XML to DocBook XML

  Amos Latteier, Digital Creations

  Note: this is a quick hack. It does a reasonable first
  cut at conversion, but is in no way complete. 

-->

<xsl:output method="xml"
            doctype-public="-//Norman Walsh//DTD DocBk XML V3.1.7//EN"/>

<xsl:template match="XML">
  <article>
    <xsl:apply-templates/>
  </article>
</xsl:template>

<xsl:template match="XML">
  <article>
    <xsl:apply-templates/>
  </article>
</xsl:template>

<xsl:template match="TITLE">
  <title>
    <xsl:apply-templates/>
   </title>
</xsl:template>

<xsl:template match="BodyAfterHead|Body">
  <para>
    <xsl:apply-templates/>
  </para>
</xsl:template>

<xsl:template match="DIV[child::Heading1|Heading2|Heading3|Heading4]">
  <section>
    <xsl:apply-templates/>
  </section>
</xsl:template>

<xsl:template match="Heading1|Heading2|Heading3|Heading4">
  <title>
    <xsl:apply-templates/>
  </title>
</xsl:template>

<xsl:template match="Figure">
</xsl:template>

<xsl:template match="DIV[child::IMAGE]">
  <figure>
    <title>
      <xsl:value-of select="following-sibling::DIV/Figure"/>
    </title>
    <mediaobject> 
      <imageobject>
        <imagedata>
          <xsl:attribute name="fileref">
            <xsl:value-of select="IMAGE/attribute::href"/>
          </xsl:attribute>
        </imagedata>
      </imageobject> 
   </mediaobject> 
  </figure>
</xsl:template>

<xsl:template match="BulletedList">
  <itemizedlist>
    <xsl:apply-templates/>
  </itemizedlist>
</xsl:template>

<xsl:template match="Bulleted">
  <listitem>
    <para>
      <xsl:apply-templates/>
    </para>
  </listitem>
</xsl:template>

<xsl:template match="NumberedList">
  <orderedlist>
    <xsl:apply-templates/>
  </orderedlist>
</xsl:template>

<xsl:template match="Numbered|Numbered1">
  <listitem>
    <para>
      <xsl:apply-templates/>
    </para>
  </listitem>
</xsl:template>

<xsl:template match="PRE[not(preceding-sibling::PRE)]">
  <programlisting>
    <xsl:apply-templates/>
    <xsl:for-each select="following-sibling::PRE">
      <xsl:apply-templates/>
    </xsl:for-each>
  </programlisting>
</xsl:template>

<xsl:template match="PRE[preceding-sibling::PRE]">
</xsl:template>

<xsl:template match="Code[not(ancestor::PRE)]">
  <literal>
    <xsl:apply-templates/>
  </literal>
</xsl:template>

<xsl:template match="TableTitle">
</xsl:template>

<xsl:template match="TABLE">
  <table>
    <title>
      <xsl:value-of select="preceding-sibling::TableTitle"/>
    </title>
    <tgroup>
      <xsl:attribute name="cols">
        <xsl:number level="any" count="CELL" from="ROW" format="1"/>
      </xsl:attribute>
      <thead>
        <xsl:for-each select="ROW">
          <row>
            <xsl:for-each select="CELL/CellHeading">
              <entry>
                <xsl:value-of select="."/>
              </entry>
            </xsl:for-each>
          </row>
        </xsl:for-each>      
      </thead>
      <tbody>
        <xsl:for-each select="ROW">
          <row>
            <xsl:for-each select="CELL/CellBody">
              <entry>
                <xsl:value-of select="."/>
              </entry>
            </xsl:for-each>
          </row>
        </xsl:for-each>
      </tbody>
    </tgroup>
  </table>  
</xsl:template>

<xsl:template match="FOOTNOTE">
  <footnote>
    <para>
      <xsl:apply-templates/>
    </para>
  </footnote>
</xsl:template>

</xsl:stylesheet>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]