[cvs-annodex] commit (/annodex): +scripts/trunk/cmml2html.xsl

conrad nobody at lists.annodex.net
Tue Feb 1 12:29:52 EST 2005


Update of /annodex (new revision 802)

Added files:
   scripts/trunk/cmml2html.xsl

Log Message:
add Claudia's cmml2html.xsl script


Added: scripts/trunk/cmml2html.xsl
===================================================================
--- scripts/trunk/cmml2html.xsl	2005-02-01 00:37:14 UTC (rev 801)
+++ scripts/trunk/cmml2html.xsl	2005-02-01 01:29:51 UTC (rev 802)
@@ -0,0 +1,551 @@
+<!--?xml version="1.0" encoding="UTF-8"?-->
+
+<!-- 
+     CSIRO Australia
+     ICT Center
+     North Ryde, NSW 1670
+     Claudia Schremmer, claudia.schremmer at csiro.au
+     February 2004
+
+     This XSLT stylesheet converts a cmml file as specified 
+     in the Internet Draft "The Continuous Media Markup Language 
+     (CMML), Version 2.0" into a HTML file.
+
+     Please call this stylesheet as follows:
+     xsltproc cmml2html.xsl myfile.cmml > myfile.html
+
+     The following requirements apply:
+     -/ The html stylesheet cmml2html.css is required to be in 
+        the same directory as the cmml2html.xsl file.
+     -/ The media files (audio and video) for the CMML file have 
+        to be stored in the subdirectory "media_files".
+     -/ The keyframes for a video have to be stored in the subdirectory 
+        "media_images".
+     Otherwise, the resulting HTML page might not find the corresponding 
+     stylesheet, media files, and images. Or simply adjust this XSTL 
+     stylesheet acordingly.
+
+     !!! Please note that the line <!DOCTYPE cmml SYSTEM "cmml.dtd"> needs 
+     !!! to be deleted from the CMML files for the running of this XSLT. 
+     !!! It should be re-inserted after the processing.
+-->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+  <xsl:output indent="yes" method="html" version="4.0" encoding="UTF-8"/> 
+  <xsl:strip-space elements="*"/>
+  <!--xsl:preserve-space elements="head stream"/-->
+
+  <xsl:template match="cmml"><xsl:text>
+</xsl:text>
+<html><xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+
+<!-- begin construction of head tags -->
+<head><xsl:text>
+</xsl:text>
+<!-- begin inserting meta elements -->
+<xsl:apply-templates select="head/meta"/><xsl:text>
+</xsl:text>
+<meta>
+  <xsl:attribute name="name">
+    <xsl:text>author</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="content">
+    <xsl:text>CSIRO Australia; Claudia Schremmer</xsl:text>
+  </xsl:attribute>
+</meta>
+<meta>
+  <xsl:attribute name="name">
+    <xsl:text>date</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="content">
+    <xsl:text>2004-02-12</xsl:text>
+  </xsl:attribute>
+</meta>
+<meta>
+  <xsl:attribute name="http-equiv">
+    <xsl:text>content-style-type</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="content">
+    <xsl:text>text/css</xsl:text>
+  </xsl:attribute>
+</meta>
+<link>
+  <xsl:attribute name="rel">
+    <xsl:text>stylesheet</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="type">
+    <xsl:text>text/css</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="href">
+    <xsl:text>cmml2html.css</xsl:text>
+  </xsl:attribute>
+</link>
+<!-- end inserting meta elements -->
+
+<title>
+  <xsl:value-of select="head/title"/>
+</title><xsl:text>
+</xsl:text>
+
+</head><xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+<!-- end construction of head tags -->
+
+<!-- begin construction of body tags -->
+<body><xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+
+<table> 
+<xsl:attribute name="width">
+  <xsl:text>100%</xsl:text>
+</xsl:attribute>
+<xsl:attribute name="cellpadding">
+  <xsl:text>0</xsl:text>
+</xsl:attribute>
+<xsl:attribute name="cellspacing">
+  <xsl:text>0</xsl:text>
+</xsl:attribute>
+<xsl:attribute name="border">
+  <xsl:text>0</xsl:text>
+</xsl:attribute>
+<xsl:attribute name="summary">
+  <xsl:text>Main content area and meta data information</xsl:text>
+</xsl:attribute><xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+
+<colgroup>
+  <col></col>
+  <col>
+    <xsl:attribute name="width">
+      <xsl:text>190</xsl:text>
+    </xsl:attribute>
+  </col>
+</colgroup><xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+
+<tr><xsl:text>
+</xsl:text>
+<td>
+  <xsl:attribute name="colspan">
+    <xsl:text>2</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="class">
+    <xsl:text>currentarea</xsl:text>
+  </xsl:attribute>
+  <xsl:text>&#xa0;</xsl:text><xsl:text>
+</xsl:text>
+</td><xsl:text>
+</xsl:text>
+</tr><xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+
+<tr><xsl:text>
+</xsl:text>
+  <td>
+    <xsl:attribute name="class">
+      <xsl:text>content</xsl:text>
+    </xsl:attribute>
+    <h1><xsl:value-of select="head/title"/></h1>
+
+<h2>This HTML page hase been automatically created from its respective CMML file.</h2><xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+
+<!-- start table with CMML clip representation -->
+<table>
+  <xsl:attribute name="border">
+    <xsl:text>0</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="cellspacing">
+    <xsl:text>0</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="cellpadding">
+    <xsl:text>0</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="summary">
+    <xsl:text>Border for next table</xsl:text>
+  </xsl:attribute><xsl:text>
+</xsl:text>
+<tr>
+<td>
+  <xsl:attribute name="style">
+    <xsl:text>background:#FC0;</xsl:text>
+  </xsl:attribute><xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+  
+
+<table> 
+  <xsl:attribute name="border">
+    <xsl:text>0</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="width">
+    <xsl:text>100%</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="cellpadding">
+    <xsl:text>3</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="cellspacing">
+    <xsl:text>1</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="summary">
+    <xsl:text>Clip representation of media file</xsl:text>
+  </xsl:attribute><xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+
+<colgroup>
+  <col>
+    <xsl:attribute name="width">
+      <xsl:text>166</xsl:text>
+    </xsl:attribute>
+  </col>
+  <col>
+  </col>
+</colgroup><xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+<tr>
+  <th>Preview / Link</th>
+  <th>Meta Information</th>
+</tr>
+
+<!-- begin for-each loop over all the clips in CMML -->
+<xsl:for-each select="child::clip">
+<tr><xsl:text>
+</xsl:text>
+<td>
+  <xsl:attribute name="colspan">
+    <xsl:text>2</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="class">
+    <xsl:text>cliphead</xsl:text>
+  </xsl:attribute><xsl:text>
+</xsl:text>
+<strong>Clip <xsl:number/> </strong><xsl:text>
+</xsl:text>
+</td><xsl:text>
+</xsl:text>
+</tr>
+
+<tr>
+  <td> 
+  <xsl:attribute name="class">
+    <xsl:text>keyframepreview</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="rowspan">
+    <xsl:choose>
+      <xsl:when test="a">
+        <xsl:text>3</xsl:text>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:text>2</xsl:text>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:attribute><xsl:text>
+</xsl:text>
+<a>
+  <xsl:attribute name="href">
+    <xsl:value-of select="concat('media_files/',substring-before(../stream/import/@src,'.'),'.anx?t=', at start)"/>
+  </xsl:attribute>
+
+<!--xsl:choose>
+  <xsl:when test="(substring-after(../stream/import/@src,'.')='wav') or (substring-after(../stream/import/@src,'.')='ogg')"></xsl:when>
+  <xsl:otherwise>
+    IMAGE NAME=<xsl:value-of select="substring(img/@src,2)"/>
+</xsl:otherwise>
+</xsl:choose-->
+
+<xsl:choose>
+  <xsl:when test="img">
+    <img>
+      <xsl:attribute name="src">
+        <xsl:value-of select="substring(img/@src,2)"/>
+      </xsl:attribute>
+      <xsl:attribute name="width">
+        <xsl:value-of select="160"/>
+      </xsl:attribute>
+      <xsl:attribute name="height">
+        <xsl:value-of select="120"/>
+      </xsl:attribute>
+      <xsl:attribute name="alt">
+        <xsl:value-of select="substring(img/@src,2)"/>
+      </xsl:attribute>
+    </img>
+  </xsl:when>
+  <xsl:otherwise>
+    <xsl:text>&lt;Link to Clip - No Image&gt;</xsl:text>
+  </xsl:otherwise>
+</xsl:choose><xsl:text>
+</xsl:text>
+
+</a><br></br>
+Clip targets: <xsl:value-of select="concat(substring-before(../stream/import/@src,'.'),'.anx')"/> <xsl:text> at offset </xsl:text> <xsl:value-of select="@start"/><br></br>
+
+<xsl:text>
+</xsl:text>
+</td>
+
+<td>
+<strong>Metadata </strong><br></br><xsl:text>
+</xsl:text>ID=<xsl:value-of select="@id"/><br></br><xsl:text>
+</xsl:text>START=<xsl:value-of select="@start"/><br></br><xsl:text>
+</xsl:text>FILE FORMAT=<xsl:value-of select="substring-after(../stream/import/@src,'.')"/><br></br><xsl:text>
+</xsl:text>
+
+
+<xsl:if test="img">
+  IMAGE NAME=<xsl:value-of select="substring(img/@src,2)"/>
+</xsl:if>
+
+
+
+<!-- The choose statement below referes to a distintion whether we
+have a video or an audio file; This has been replaced by a test
+whether we have an img tag yes or no -->
+
+<!--xsl:choose>
+  <xsl:when test="(substring-after(../stream/import/@src,'.')='wav') or (substring-after(../stream/import/@src,'.')='ogg')"></xsl:when>
+  <xsl:otherwise>
+    IMAGE NAME=<xsl:value-of select="substring(img/@src,2)"/>
+</xsl:otherwise>
+</xsl:choose-->
+
+</td><xsl:text>
+</xsl:text>
+</tr>
+
+<tr><xsl:text>
+</xsl:text>
+<td><xsl:text>
+</xsl:text>
+
+<xsl:choose>
+  <xsl:when test="desc">
+    <strong>Description </strong><br></br> <xsl:value-of select="desc"/>
+  </xsl:when>
+  <xsl:otherwise>
+    &lt;No Description of this Clip Available&gt;   
+  </xsl:otherwise>
+</xsl:choose>
+
+<xsl:text>
+</xsl:text>
+</td><xsl:text>
+</xsl:text>
+</tr>
+
+<xsl:if test="a">
+  <tr><xsl:text>
+</xsl:text>
+<td><xsl:text>
+</xsl:text>
+<xsl:apply-templates select="a"/>
+<xsl:text>
+</xsl:text>
+</td><xsl:text>
+</xsl:text>
+</tr>
+</xsl:if>
+
+</xsl:for-each>
+<!-- end for-each loop over all the clips in CMML -->
+
+<xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+</table><xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+
+</td><xsl:text>
+</xsl:text>
+</tr><xsl:text>
+</xsl:text>
+</table>
+
+<!-- end table with CMML clip representation -->
+
+</td>
+<td>
+  <xsl:attribute name="class">
+    <xsl:text>fileinfo</xsl:text>
+  </xsl:attribute>
+  <h3>File Information</h3>
+  <p>The table on the left has been automatically created from the following time-continuous media, annotated in CMML:</p>
+  <xsl:apply-templates select="stream/import"/><xsl:text>
+</xsl:text>    
+</td>
+
+
+
+</tr>
+  
+
+<!--h1>***XXXX*** Title of Annodex File in CMML ***XXXX***</h1-->
+<tr><xsl:text>
+</xsl:text>
+<td>
+  <xsl:attribute name="colspan">
+    <xsl:text>2</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="class">
+    <xsl:text>currentarea</xsl:text>
+  </xsl:attribute>
+  <xsl:text>&#xa0;</xsl:text><xsl:text>
+</xsl:text>
+</td><xsl:text>
+</xsl:text>
+</tr><xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+
+
+<xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+</table>
+
+<xsl:text>
+</xsl:text><xsl:text>
+</xsl:text></body><xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+<!-- end construction of body tags -->
+
+</html>
+</xsl:template> <!-- end of match="cmml-->
+  
+<xsl:template match="head/meta">
+  <xsl:if test="(@name='DESCRIPTION') or (@name='KEYWORDS')">
+    <meta>
+      <xsl:attribute name="name">
+        <xsl:apply-templates select="@name"/>
+      </xsl:attribute>
+      <xsl:attribute name="content">
+        <xsl:apply-templates select="@content"/>
+      </xsl:attribute>
+    </meta>
+  </xsl:if>
+</xsl:template>
+
+
+<xsl:template match="stream/import">
+<table>
+  <xsl:attribute name="border">
+    <xsl:text>0</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="cellspacing">
+    <xsl:text>0</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="cellpadding">
+    <xsl:text>0</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="summary">
+    <xsl:text>Border for next table</xsl:text>
+  </xsl:attribute>
+<tr>
+<td>
+  <xsl:attribute name="style">
+    <xsl:text>background:#FC0;</xsl:text>
+  </xsl:attribute><xsl:text>
+</xsl:text><xsl:text>
+</xsl:text>
+
+<table> 
+  <xsl:attribute name="border">
+    <xsl:text>0</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="width">
+    <xsl:text>100%</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="cellpadding">
+    <xsl:text>3</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="cellspacing">
+    <xsl:text>1</xsl:text>
+  </xsl:attribute>
+  <xsl:attribute name="summary">
+    <xsl:text>File Information</xsl:text>
+  </xsl:attribute>
+<colgroup>
+  <col>
+    <xsl:attribute name="width">
+      <xsl:text>90</xsl:text>
+    </xsl:attribute>
+  </col>
+  <col>
+    <xsl:attribute name="width">
+      <xsl:text>90</xsl:text>
+    </xsl:attribute>
+  </col>
+</colgroup>
+<tr>
+  <td>
+    <xsl:attribute name="class">
+      <xsl:text>cliphead</xsl:text>
+    </xsl:attribute>
+    File type:
+  </td>
+  <td><xsl:apply-templates select="@contenttype"/></td>
+</tr>
+<tr>
+  <td>
+    <xsl:attribute name="class">
+      <xsl:text>cliphead</xsl:text>
+    </xsl:attribute>
+    Source file:
+  </td>
+  <td><xsl:apply-templates select="@src"/></td>
+</tr>
+<tr>
+  <td>
+    <xsl:attribute name="class">
+      <xsl:text>cliphead</xsl:text>
+    </xsl:attribute>
+    Timebase:
+  </td>
+  <td><xsl:apply-templates select="../@timebase"/></td>
+</tr>
+<tr>
+  <td>
+    <xsl:attribute name="class">
+      <xsl:text>cliphead</xsl:text>
+    </xsl:attribute>
+    Start time:
+  </td>
+  <td><xsl:apply-templates select="@start"/></td>
+</tr>
+</table>
+
+</td>
+</tr>
+</table>
+
+</xsl:template>
+
+<xsl:template match="a">
+  <strong>
+  External link
+  </strong><br></br>
+  <a>
+    <xsl:attribute name="href">
+      <xsl:apply-templates select="@href"/>
+    </xsl:attribute>
+    <xsl:apply-templates/>
+  </a>
+</xsl:template>
+
+
+</xsl:stylesheet>
+       
+
+


-- 
conrad



More information about the cvs-annodex mailing list