generating OMF
- From: Martijn van Beers <martijn eekeek org>
- To: gnome-doc-list gnome org, scrollkeeper-devel lists sourceforge net
- Subject: generating OMF
- Date: Mon, 17 Sep 2001 18:18:32 +0200
Hi,
I really didn't like creating a .omf file by hand when half of
the information in it is already in my source docbook file, so
I wrote a little xsl stylesheet to get that info out. To get
the other information at the same time, I put it in the docbook
file using namespaces.
Attached are the stylesheet, an example document and the output
from running xsltproc with those.
Martijn
<?xml version='1.0'?>
<!-- vim:set sts=2 shiftwidth=2 syntax=sgml: -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:omf="http://metalab.unc.edu/osrt/omf/"
version='1.0'>
<xsl:strip-space elements="*"/>
<xsl:output method="xml"
encoding="ISO-8859-1"
indent="yes" />
<xsl:template name="copy">
<xsl:copy>
<xsl:for-each select="./@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="copyright">
<xsl:variable name="fdl" select='/article/appendix[ id="gfdl"]' />
<xsl:element name="rights">
<xsl:element name="holder">
<xsl:attribute name="name">
<xsl:value-of select="./holder" />
</xsl:attribute>
</xsl:element>
<xsl:if test="$fdl">
<xsl:element name="licence">
<xsl:attribute name="name">
<xsl:value-of select="$fdl/title" />
</xsl:attribute>
<xsl:attribute name="version">
<xsl:value-of select="substring ($fdl/para[1], 9, 3)" />
</xsl:attribute>
<xsl:attribute name="url">http://www.gnu.org/copyleft/fdl.txt</xsl:attribute>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:template>
<xsl:template match="author">
<xsl:element name="person">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="firstname">
<xsl:element name="firstName">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
<xsl:template match="surname">
<xsl:element name="lastName">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
<xsl:template match="affiliation/address">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="affiliation/address/email">
<xsl:call-template name="copy" />
</xsl:template>
<xsl:template match="abstract/para[1]">
<xsl:element name="description">
<xsl:value-of select="." />
</xsl:element>
</xsl:template>
<xsl:template match="omf:resource//node()">
<xsl:call-template name="copy"/>
</xsl:template>
<xsl:template match="article">
<omf>
<resource>
<title><xsl:value-of select="articleinfo/title"/></title>
<creator>
<xsl:apply-templates select="articleinfo/author" />
</creator>
<xsl:apply-templates select="articleinfo/copyright" />
<xsl:apply-templates select="articleinfo/abstract" />
<xsl:apply-templates select="omf:resource/*" />
<format dtd="DocBook" mime="text/xml" />
</resource>
</omf>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0"?>
<!-- vim:set sts=2 shiftwidth=2 syntax=sgml: -->
<!DOCTYPE article PUBLIC
"-//OASIS/DTD DocBook XML V4.1,2/EN"
"http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd" [
<!ENTITY gfdl SYSTEM "fdl.sgml">
]>
<article xmlns:omf="http://metalab.unc.edu/osrt/omf/">
<omf:resource>
<omf:subject>
<omf:category>GNOME|Applications</omf:category>
</omf:subject>
<omf:type>manual</omf:type>
<omf:identifier url="kerchief.xml"/>
<omf:language code="C" />
</omf:resource>
<articleinfo>
<title>Kerchief Manual</title>
<copyright>
<year>2001</year>
<holder>Martijn van Beers</holder>
</copyright>
<author>
<firstname>Martijn</firstname>
<surname>van Beers</surname>
<affiliation>
<address>
<email>martijn eekeek org</email>
</address>
</affiliation>
</author>
<abstract>
<para>
This document is intended to help you learn how to use the Kerchief
application
</para>
</abstract>
<legalnotice>
<para>
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
or any later version published by the Free Software Foundation;
with no Invariant Sections, with no Front-Cover Texts, and with no
Back-Cover Texts. A copy of the license is included in the section
entitled <quote>GNU Free Documentation License</quote>.
</para>
</legalnotice>
</articleinfo>
&gfdl;
</article>
<?xml version="1.0" encoding="ISO-8859-1"?>
<omf xmlns:omf="http://metalab.unc.edu/osrt/omf/">
<resource>
<title>Kerchief Manual</title>
<creator>
<person>
<firstName>Martijn</firstName>
<lastName>van Beers</lastName>
<email>martijn eekeek org</email>
</person>
</creator>
<rights>
<holder name="Martijn van Beers"/>
<licence name="GNU Free Documentation License" version="1.1" url="http://www.gnu.org/copyleft/fdl.txt"/>
</rights>
<description>
This document is intended to help you learn how to use the Kerchief
application
</description>
<omf:subject>
<omf:category>GNOME|Applications</omf:category>
</omf:subject>
<omf:type>manual</omf:type>
<omf:identifier url="kerchief.xml"/>
<omf:language code="C"/>
<format dtd="DocBook" mime="text/xml"/>
</resource>
</omf>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]