So I’ve never used XSLT before, so this is probably a very simple problem. Basically, my job is to chapter videos, and the program we use generates an XML document containing pairs of timecodes (where the chapter starts, in milliseconds) and a title (the name of the chapter). What I want to do is rearrange it into a format that Final Cut Pro understands.
The program generates data in the following format:
<marker time="27">
<label>Introduction</label>
</marker>
and Final Cut needs it in this format (with the timecode converted into frames, aka divided by 33.3):
<marker>
<name>Introduction</name>
<comment> <CHAPTER>
</comment>
<color>
<alpha>0</alpha>
<red>127</red>
<green>0</green>
<blue>255</blue>
</color>
<in>27</in>
<out>-1</out>
</marker>
The code I’ve written is:
<xsl:template match="/">
<xsl:for-each select="captionate/markers/marker">
<marker>
<name><xsl:value-of select="label"/></name>
<comment> <CHAPTER>
</comment>
<color>
<alpha>0</alpha>
<red>127</red>
<green>0</green>
<blue>255</blue>
</color>
<in><xsl:value-of select="@time"/></in>
<out>-1</out>
</marker>
</xsl:for-each>
</xsl:template>
but it’s not working (I’m not even entirely sure how to implement it). Any help would be greatly appreciated!
I have completed your sample data (perhaps it now matches yours exactly?):
Here is the code again, only minimal changes (shows the division):
Running this through xsltproc gives the expected results.