converting omf files



Folks -

I've made an xsl stylesheet to convert old OMF files to the form
required by ScrollKeeper's new dtd. This is tested against some of my
old files, and also against Dan's "Complete OMF File" example (which
is of the old type):

http://scrollkeeper.sourceforge.net/documentation/writing_scrollkeeper_omf_files/ar01s06.html

Run this using xsltproc at the command line:

[jfleck jelloiii omfexamples]$ xsltproc omftransform.xsl complete.omf > testout.omf

Then by all means, you should validate the resulting output:

[jfleck jelloiii omfexamples]$ xmllint --noout --dtdvalid /usr/share/xml/scrollkeeper/dtds/scrollkeeper-omf.dtd testout.omf 

Suggestions welcome, as my xslt skills are modest at best.

Cheers,
John

-- 
John Fleck
jfleck inkstain net (h) jfleck abqjournal com (w)
http://www.inkstain.net http://www.abqjournal.com

"You don't want to die with the music still in you."
 - John Gardner
<?xml version="1.0"?>
<xsl:stylesheet id="omf"
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
   <xsl:strip-space elements="*"/>
   
   <xsl:template match="omf">
     <xsl:element name="omf">
       <xsl:text>
       </xsl:text>
       <xsl:apply-templates/>
     </xsl:element>
   </xsl:template>

 
   <xsl:template match="resource">
     <xsl:element name="resource">
       <xsl:text>
       </xsl:text>
       <xsl:apply-templates/>
     </xsl:element>
     <xsl:text>
     </xsl:text>
   </xsl:template>
   
   <xsl:template match="creator">
     <xsl:element name="creator">
       <xsl:apply-templates/>
     </xsl:element>
     <xsl:text>
     </xsl:text>
   </xsl:template>

   <xsl:template match="maintainer">
     <xsl:element name="maintainer">
       <xsl:apply-templates/>
     </xsl:element>
     <xsl:text>
     </xsl:text>
   </xsl:template>

   <xsl:template match="contributor">
     <xsl:element name="contributor">
       <xsl:apply-templates/>
     </xsl:element>
     <xsl:text>
     </xsl:text>
   </xsl:template>

   <xsl:template match="type">
     <xsl:element name="type">
       <xsl:apply-templates/>
     </xsl:element>
     <xsl:text>
     </xsl:text>
   </xsl:template>

   <xsl:template match="title">
     <xsl:element name="title">
       <xsl:apply-templates/>
     </xsl:element>
     <xsl:text>
     </xsl:text>
   </xsl:template>

   <xsl:template match="date">
     <xsl:element name="date">
       <xsl:apply-templates/>
     </xsl:element>
     <xsl:text>
     </xsl:text>
   </xsl:template>

   <xsl:template match="version">
     <version xsl:use-attribute-sets="version-atts">
       
     </version>
     <xsl:text>
     </xsl:text>
   </xsl:template>

   <xsl:attribute-set name="version-atts">
     <xsl:attribute name="identifier"><xsl:value-of select="normalize-space(identifier)"/></xsl:attribute>
     <xsl:attribute name="date"><xsl:value-of select="normalize-space(date)"/></xsl:attribute>
     <xsl:attribute name="description"><xsl:value-of select="normalize-space(description)"/></xsl:attribute>
   </xsl:attribute-set>

   <xsl:template match="subject">
     <subject xsl:use-attribute-sets="subject-atts">
     
     </subject>
     <xsl:text>
     </xsl:text>
   </xsl:template>
  
   <xsl:attribute-set name="subject-atts">
     <xsl:attribute name="category"><xsl:value-of select="normalize-space(category)"/></xsl:attribute>

   </xsl:attribute-set>

   <xsl:template match="description">
     <xsl:element name="description">
       <xsl:apply-templates/>
     </xsl:element>
     <xsl:text>
     </xsl:text>
   </xsl:template>

   <xsl:template match="format">
     <format xsl:use-attribute-sets="format-atts">
       
     </format>
     <xsl:text>
     </xsl:text>
   </xsl:template>
  
   <xsl:attribute-set name="format-atts">
     <xsl:attribute name="mime"><xsl:value-of select="@mime"/></xsl:attribute>
     <xsl:attribute name="dtd"><xsl:value-of select="@dtd"/></xsl:attribute>
   </xsl:attribute-set>

   <xsl:template match="identifier">
     <identifier xsl:use-attribute-sets="identifier-atts">
     
     </identifier>
     <xsl:text>
     </xsl:text>
   </xsl:template>
   
   <xsl:attribute-set name="identifier-atts">
     <xsl:attribute name="url"><xsl:value-of select="@url"/></xsl:attribute>
   </xsl:attribute-set>

   <xsl:template match="relation">
     <relation xsl:use-attribute-sets="relation-atts">
       
     </relation>
     <xsl:text>
     </xsl:text>
   </xsl:template>
   
   <xsl:attribute-set name="relation-atts">
     <xsl:attribute name="seriesid"><xsl:value-of select="@seriesid"/></xsl:attribute>
   </xsl:attribute-set>

   <xsl:template match="language">
     <language xsl:use-attribute-sets="language-atts">
     
     </language>
     <xsl:text>
     </xsl:text>
   </xsl:template>
  
   <xsl:attribute-set name="language-atts">
     <xsl:attribute name="code"><xsl:value-of select="@code"/></xsl:attribute>
   </xsl:attribute-set>

   <xsl:template match="rights">
     <rights xsl:use-attribute-sets="rights-atts">
     
     </rights>
     <xsl:text>
     </xsl:text>
   </xsl:template>

   <xsl:attribute-set name="rights-atts">
     <xsl:attribute name="type"><xsl:value-of select="normalize-space(type)"/></xsl:attribute>
     <xsl:attribute name="license.version"><xsl:value-of select="normalize-space(license.version)"/></xsl:attribute>
     <xsl:attribute name="holder"><xsl:value-of select="normalize-space(holder)"/></xsl:attribute>
   </xsl:attribute-set>
   
 </xsl:stylesheet>


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