home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / retrograde.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  2.5 KB  |  66 lines

  1. <?xml version="1.0"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17. <xsl:stylesheet version="1.0" 
  18.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  19.  
  20.   <xsl:template match="MTrk">
  21.       <xsl:copy>
  22.           <xsl:apply-templates select="@*"/>
  23.           <xsl:variable name="deltas" select="DELTA[descendant::NOTE_ON]"/>
  24.         <xsl:variable name="deltaCount" select="count($deltas)"/>
  25.         <xsl:comment>Count: <xsl:value-of select="$deltaCount"/></xsl:comment>
  26.           <xsl:for-each select="DELTA">
  27.             <xsl:choose>
  28.               <xsl:when test="descendant::NOTE_ON">
  29.                   <xsl:variable name="position" select="count(preceding-sibling::DELTA[descendant::NOTE_ON]) + 1"/>
  30.                 <xsl:variable name="newPosition" select="($deltaCount - $position) + 1"/>
  31.                 <xsl:comment>Position: <xsl:value-of select="$position"/>, New: <xsl:value-of select="$newPosition"/></xsl:comment>
  32.                 <xsl:copy>
  33.                     <xsl:variable name="followingDelta" select="following-sibling::DELTA[descendant::NOTE_ON]"/>
  34.                   <xsl:attribute name="DTIME">
  35.                     <xsl:choose>
  36.                       <xsl:when test="$position = 1">00000000</xsl:when>
  37.                       <xsl:when test="$followingDelta">
  38.                         <xsl:value-of select="$followingDelta/@DTIME"/>
  39.                       </xsl:when>
  40.                       <xsl:otherwise>00000000</xsl:otherwise>
  41.                     </xsl:choose>
  42.                   </xsl:attribute>
  43.                   <xsl:comment>The DTIME was <xsl:value-of select="@DTIME"/>, and is <xsl:value-of select="$followingDelta/@DTIME"/></xsl:comment>
  44.                   <xsl:copy-of select="$deltas[$newPosition]/*"/>
  45.                 </xsl:copy>
  46.               </xsl:when>
  47.               <xsl:otherwise>
  48.                 <xsl:copy>
  49.                   <xsl:apply-templates select="@*"/>
  50.                   <xsl:apply-templates/>
  51.                 </xsl:copy>
  52.               </xsl:otherwise>
  53.             </xsl:choose>
  54.           </xsl:for-each>
  55.       </xsl:copy>
  56.   </xsl:template>
  57.  
  58.   <xsl:template match="node()|@*">
  59.     <xsl:copy>
  60.       <xsl:apply-templates select="node()|@*"/>
  61.     </xsl:copy>
  62.   </xsl:template>
  63.  
  64. </xsl:stylesheet>
  65.  
  66.