Re: [xsl] Filemaker Pro XSL Question! Help!!

Subject: Re: [xsl] Filemaker Pro XSL Question! Help!!
From: Brandon Ibach <brandon.ibach@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 22 Jan 2011 16:34:39 -0500
This solution would only output a single ROW for each track, where the
requirement appears to be a ROW for each clipitem.  Something like
this should give the desired result:

<xsl:for-each select="/xmeml/sequence/media/video/track/clipitem">
  <ROW MODID="" RECORDID="">
    <COL>
      <DATA>
        <xsl:value-of select="count(../preceding-sibling::track) + 1"/>
      </DATA>
    </COL>
    <COL>
      <DATA>
        <xsl:value-of select="name"/>
      </DATA>
    </COL>
    <COL>
      <DATA>
        <xsl:value-of select="in"/>
      </DATA>
    </COL>
    <COL>
      <DATA>
        <xsl:value-of select="out"/>
      </DATA>
    </COL>
  </ROW>
</xsl:for-each>

Even better:

<xsl:for-each select="/xmeml/sequence/media/video/track/clipitem">
  <ROW MODID="" RECORDID="">
    <COL>
      <DATA>
        <xsl:value-of select="count(../preceding-sibling::track) + 1"/>
      </DATA>
    </COL>
    <xsl:for-each select="name | in | out">
      <COL>
        <DATA>
          <xsl:value-of select="."/>
        </DATA>
      </COL>
    </xsl:for-each>
  </ROW>
</xsl:for-each>

I should note, however, that good XSLT practice would suggest breaking
the contents of these <xsl:for-each> elements into separate templates
and using <xsl:apply-templates> to dispatch them.

-Brandon :)


On Fri, Jan 21, 2011 at 5:46 PM, Michael M|ller-Hillebrand
<mmh@xxxxxxxxxxxxx> wrote:
> Hi Josh,
>
> I have never used XSL with FileMaker Pro, but I use that program a lot. Try
this, using XSLT magic:
>
> <!-- loop through all tracks -->
> <xsl:for-each select="/xmeml/sequence/media/video/track">
> <ROW MODID="" RECORDID="">
>      <COL>
>       <DATA>
>   <!-- calculate the track number -->
>        <xsl:value-of select="count(preceding-sibling::track) + 1"/>
>       </DATA>
>      </COL>
>      <COL>
>       <DATA>
>   <!-- finds the clip name as child of clipitem -->
>        <xsl:value-of select="clipitem/name"/>
>       </DATA>
>      </COL>
>      <COL>
>       <DATA>
>       <!-- finds the in point of the source clip in frames -->
>        <xsl:value-of select="clipitem/in"/>
>       </DATA>
>      </COL>
>      <COL>
>       <DATA>
>       <!-- finds the out point of the clip in frames -->
>        <xsl:value-of select="clipitem/out"/>
>       </DATA>
>      </COL>
> </ROW>
> </xsl:for-each>
>
> Am 21.01.2011 um 21:20 schrieb Josh Kirschenbaum:
>
>> Hello all - I'm new to XML / XSLT, so go easy on me!
>> I am trying to get an XML file from Final Cut Pro to Filemaker Pro
>> using an XSLT template.
>> The original XML has a basic structure like this (simplified for this
question)
>> <video>
>>    <track>
>>      <clipitem id="This Is The First Clip">
>>            <name>The First Clip has a Name</name>
>>            <in>140</in>
>>            <out>240</out>
>>            <...etc..>
>>      </clipitem>
>>      <clipitem id="And The Second Clip">
>>            <name>Number Two</name>
>>            <in>360</in>
>>            <out>520</out>
>>            <...etc..>
>>      </clipitem>
>>      <clipitem id="Finally The Third Clip">
>>            <name>Three Is Not Company</name>
>>            <in>140</in>
>>            <out>240</out>
>>            <...etc..>
>>      </clipitem>
>>    </track>
>>    <track>
>>      <clipitem id="First Clip on Another Track">
>>            <name>Track Two's First Clip</name>
>>            <in>140</in>
>>            <out>240</out>
>>            <...etc..>
>>      </clipitem>
>>      <clipitem id="Second Clip Second Track">
>>            <name>Number Two Track Two</name>
>>            <in>460</in>
>>            <out>820</out>
>>            <...etc..>
>>      </clipitem>
>>      <clipitem id="Second Track Third Clip">
>>            <name>Three Is Not Company On This Track Either</name>
>>            <in>158</in>
>>            <out>655</out>
>>            <...etc..>
>>      </clipitem>
>>    </track>
>> </video>
>>
>> Obviously there are many other leaves inside of the <clipitem> tag.
>> And there are more <track> levels as well - once again, this is just
>> for illustration.
>> This is FileMaker Pro's XSLT template format (once again, slimmed
>> down) to pull out the three <clipitem> from the first <track> level.
>> This makes sense to me - it's very straightforward.
>> The issue is that I don't want to manually indicate which <track> to
>> "pick" by changing track[1] to track[2]. I want to traverse the entire
>> XML file - even when I don't know how many <track> occurences there
>> are.
>> <xsl:for-each select="/xmeml/sequence/media/video/track[1]/clipitem">
>> <ROW MODID="" RECORDID="">
>>       <COL>
>>        <DATA>
>>    <!-- finds the clip name -->
>>         <xsl:value-of select="./name"/>
>>        </DATA>
>>       </COL>
>>
>>
>>       <COL>
>>        <DATA>
>>        <!-- finds the in point of the source clip in frames -->
>>         <xsl:value-of select="./in"/>
>>        </DATA>
>>       </COL>
>>
>>       <COL>
>>        <DATA>
>>        <!-- finds the out point of the clip in frames -->
>>         <xsl:value-of select="./out"/>
>>        </DATA>
>>       </COL>
>>
>> </ROW>
>> </xsl:for-each>
>>
>>
>> I also want to add another <COL> set - one that outputs the number of
>> the <track> I'm on - kind of like this:
>>
>>
>> <COL>
>> <DATA>
>> <!-- finds the track number -->
>> <xsl:value-of select="count(/xmeml/sequence/media/video/track)"/>
>> </DATA>
>> </COL>
>>
>> The problem is that this line of code just returns the TOTAL number of
>> <track> levels - in this case it would return "2". I want it to return
>> 1, then all the clipitems on that level, then 2, then the clipitems on
>> that level, etc.
>> This is probably something that is SUPER straightforward, but as I
>> said, I'm a newbie to this stuff!!
>> Thanks in advance!!!
>> --
>>
>> -. --- -- .- - - . .-. .-- .... . .-. . -.-- --- ..- --. --- - .... .
>> .-. . -.-- --- ..- .- .-. .
>>
>> Josh Kirschenbaum
>> Visual Effects Director / Design
>> www.zeroperimeter.com

Current Thread