This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Efficiency, use param in key?


Hi Chris,
[name sounds familiar, Authorware? Director?]

First, people who storyboard their projects are some of the smartest people :-D


Christopher_Dant@jackmorton.com wrote:
On working a stylesheet that processes a multimedia-course storyboard and
returns text, CRLF-delimited, sorted, lowercase, no-duplicates filenames I
have several questions:
Second, I am not too clear on the desired outcome.

1. is there anything I should do to improve it (make it more efficient)?

2. is it possible to use the param "ele" in key, apply-templates and
template? This would make it possible for a single stylesheet to look for
file_audio, file_video or file_graphic tags.
No you can't do that.

If you are making a storyboard, why do you need to get all of these at once? in sorted order?

3. Or perhaps I should actually ask, is there a way to rework my approach
so I can parameterize it?
Can you show the output you are trying to achieve?

Stylesheet:

<xsl:output method="text" encoding="ISO-8859-1" indent="no"/>

<xsl:param name="ele">file_audio</xsl:param>
Here you could pass in the param from the server (or a client-side app). So all you need at the top level is:

<xsl:param name="ele"/>

<xsl:variable name="lc" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="uc" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>

<xsl:key name="fn" match="file_audio" use="@fileref"/>

<xsl:template match="/">
    <xsl:apply-templates select="//file_audio">
        <xsl:sort select="@fileref"/>
    </xsl:apply-templates>
</xsl:template>

You almost never want to use '//' to find things. This is a big slowdown. Are you trying to create a report of all your media assets? If so, it might not matter that the performance is bad.


<xsl:template match="file_audio[generate-id() = generate-id(key('fn',
@fileref)[1])]">
    <xsl:value-of select="translate(@fileref, $uc, $lc)"/>
    <xsl:text disable-output-escaping="yes">&#xD;&#xA;</xsl:text>
</xsl:template>
Ah.. you just want a list of assets and to ensure all the names are lowercase

You don't need the elaborate match. In your match="/" you set up everything to be fed to the template directly above. So all you need is:

<xsl:template match="file_audio">

I am not sure what you are trying to do here:

<xsl:text disable-output-escaping="yes">&#xD;&#xA;</xsl:text>


Excerpts of sample input:

<frame id="01" type="a" parms="a">
<txt_scr lang="ENG"/>
<txt_aud>Click on a button in front of the module you wish to begin
and...</txt_aud>
<file_audio fileref="coursemenu.mp3"/>
</frame>
.
.
.
<frame id="01">
<txt_scr lang="ENG">Welcome to the Intercom Plus training!</txt_scr>
<txt_avi>{Zelda} Hi, welcome to the Intercom Plus Training! I am Zelda
Morales...</txt_avi>
<file_avi start_frame="1" end_frame="359" fileref="__A_.0010.001.avi" />
</frame>
.
.

Chris, you can contact me offlist if you want more specific stuff as it relates to a MACR product.

I don't understand why you need to get the media assets all at once. For a storyboard that I have in mind you would want to keep the asset with the frame. Can you elaborate on what you need.

You might want to keep your assets in different files and refer to them by ID. So you might have:

[movies.xml]
<movies>
<movie start_frame="1" label="jkhjh" end_frame="359" id="amovie.avi">
<text id="text1.xml"/>
</movie>
<movie start_frame="1" label="jkhjh" end_frame="359" id="amovie2.avi">
<text id="text2.xml"/>
</movie>
<movie start_frame="1" label="jkhjh" end_frame="359" id="amovie_n.avi">
<text id="text_n.xml"/>
</movie>
</movies>

[audio_clips.xml]
<clips>
<clip id="amp3.mp3" label="jkhjh" more_meta_data="whatever"/>
<clip id="amp3_n.mp3" label="jkhjh" more_meta_data="whatever"/>
</clips>

[screen_text.xml]
<screen_texts>
<screen_text id="screen1.xml" label="jkhjh"/>
<screen_text id="screen2.xml" label="jkhjh"/>
</screen_texts>


[cbt.xml]
<cbt>
<chapter id="chap1" title="blah blah">
<frame id="f1" etc="etc" blah="blah">
<screen_text id="screen1.xml"/>
<movie id="amovie.avi"/>
</frame>
<frame id="f2" etc="etc" blah="blah">
<screen_text id="screen2.xml"/>
<clip id="amp3.mp3"/>
</frame>
</chapter>
</cbt>

Here, your main source document is cbt.xml. In your primary XSL you can define a key to account for all XML documents you bring into the transformation, like:

<xsl:key name="main_key" match="chapter | frame | screen_text | clip | movie | clip" use="@id"/>

As you go through you main source XML (cbt.xml) you come across your different assets you can access their specific info by doing something like:
<!-- top-level variable -->
<xsl:variable name="movies_nodeset" select="document('movies.xml')/movies"/>

<!-- perhaps you need to get all of the particular movie's info -->
<xsl:template match="movie">
<xsl:variable name="movie_id" select="@id"/>
<!-- change the XML context to the movies.xml so you can use key() -->
<xsl:for-each select="$movies_nodeset/movie">
<xsl:apply-templates select="key('main_key', $movie_id)" mode="info"/>
</xsl:for-each>
</xsl:template>

<xsl:template match="movie" mode="info">
<!-- now you are in movies.xml at the node specified by the key above -->

<xsl:value-of select="@id"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="@label"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="@start_frame"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="@end_frame"/>
<xsl:text>, </xsl:text>

</xsl:template>


best,
-Rob Koberg
http://livestoryboard.com



.

TIA
Chris

Christopher Dant
Technology Director
Jack Morton Worldwide
Christopher_Dant@jackmorton.com



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list





XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]