<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <!-- Convert kdenlive guide markers into Bombono parts
      that can be pasted into bombono xml project files.

      This works with kdenlive 16.12.
      Earlier versions of kdenlive were different;
      they had mlt/kdenlivedoc/guides/guide tags
      which are not generated anymore
 -->
 <xsl:output indent="yes"/>

 <xsl:template match="/">
  <Parts>
    <xsl:for-each select="mlt/playlist/property[substring(@name, 0, 16) = 'kdenlive:guide.']">
      <!-- we need to sort manually, they can appear in any order -->
      <xsl:sort data-type="number" select="translate(substring(@name, 16),',','.')"/>

      <xsl:variable name="timeorig" select="substring(@name, 16)"/>
      <!-- support german files with comma as decimal separator-->
      <xsl:variable name="time" select="translate($timeorig,',','.')"/>

      <Part>
        <xsl:attribute name="Name"><xsl:value-of select="."/></xsl:attribute>
        <xsl:value-of select="$time"/>
      </Part>
    </xsl:for-each>
  </Parts>
 </xsl:template>

</xsl:stylesheet> 