lout-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DocBook XML to Lout


From: Michael Piotrowski
Subject: Re: DocBook XML to Lout
Date: Wed, 22 Aug 2001 23:31:33 +0200
User-agent: Gnus/5.090004 (Oort Gnus v0.04) XEmacs/21.1 (Bryce Canyon)

Ok, here's a minimal XSLT stylesheet to convert a DocBook XML article
into a Lout report:

------------------------------------------------------------------------
<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version='1.0'>
<xsl:output method="text" encoding="ISO-8859-1"/>

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

<!-- article -->
<xsl:template match="article">
@SysInclude {report}

@Report
  @InitialSpace  {tex}
  @Title         {<xsl:value-of select="articleinfo/title"/>}
  @Author        {<xsl:value-of select="articleinfo/author/firstname"/>
                  <xsl:text> </xsl:text>
                  <xsl:value-of select="articleinfo/author/surname"/>}
  @Abstract      {<xsl:apply-templates select="//abstract"/>}
//

  <xsl:apply-templates select="//sect1"/>
</xsl:template>

<!-- abstract -->
<xsl:template match="abstract">
  <xsl:apply-templates/>
</xsl:template>

<!-- sect1 -->
<xsl:template match="sect1">
  @Section
     @Title {<xsl:value-of select="title"/>}
  @Begin
     <xsl:apply-templates/>
  @End @Section
</xsl:template>

<xsl:template match="sect1/title"></xsl:template>

<!-- para -->
<xsl:template match="para[1]">
  @LP <xsl:apply-templates/>
</xsl:template>

<xsl:template match="abstract/para[1]">
   <xsl:apply-templates/>
</xsl:template>

<xsl:template match="para">
   @PP <xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet>
------------------------------------------------------------------------

Only a _very_ limited number of elements are considered, but it would
be sufficient for converting an XML document like this one:

------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
          "http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd";>

<article class="techreport">
  <articleinfo>
    <title>Report title</title>
    <author>
      <firstname>Michael</firstname>
      <surname>Piotrowski</surname>
    </author>
  </articleinfo>

  <abstract>
    <para>This is the executive summary.</para>
  </abstract>

  <sect1>
    <title>General</title>

    <para>Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
    sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna
    aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud
    exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea
    commodo consequat.</para>

    <para>Duis autem vel eum iriure dolor in hendrerit in vulputate
    velit esse molestie consequat, vel illum dolore eu feugiat nulla
    facilisis at vero eros et accumsan et iusto odio dignissim qui
    blandit praesent luptatum zzril delenit augue duis dolore te
    feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer
    adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
    laoreet dolore magna aliquam erat volutpat.</para>
  </sect1>
</article>
------------------------------------------------------------------------

One does need a little preprocessing, though, to escape the Lout special
characters:

   " # & / @ \ ^ { | } ~

There are several ways to do this.  If there's some interest, I'm
willing to expand on this, but right now it's getting late...

-- 
Michael Piotrowski, M.A.                                  <address@hidden>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]