Subject: Re: [xsl] Efficiency, use param in key? From: "Robert S. Koberg" <rob@xxxxxxxxxx> Date: Sat, 03 Aug 2002 04:25:34 -0700 |
Hi Chris, [name sounds familiar, Authorware? Director?]
On working a stylesheet that processes a multimedia-course storyboard and returns text, CRLF-delimited, sorted, lowercase, no-duplicates filenames I have several questions:
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.
3. Or perhaps I should actually ask, is there a way to rework my approach so I can parameterize it?
Stylesheet:
<xsl:output method="text" encoding="ISO-8859-1" indent="no"/>
<xsl:param name="ele">file_audio</xsl:param>
<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>
<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">
</xsl:text> </xsl:template>
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> . .
[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>
<!-- 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>
best, -Rob Koberg http://livestoryboard.com
.
TIA Chris
Christopher Dant Technology Director Jack Morton Worldwide Christopher_Dant@xxxxxxxxxxxxxx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Efficiency, use param in key?, Christopher_Dant | Thread | Re: [xsl] Efficiency, use param in , Marrow |
Re: [xsl] Efficiency, use param in , Marrow | Date | Re: [xsl] Efficiency, use param in , Christopher_Dant |
Month |