This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
handling media, xsl:variable problem
- From: Nathan Shaw <n8_shaw at yahoo dot com>
- To: XSL-List at lists dot mulberrytech dot com
- Date: Wed, 1 May 2002 12:18:58 -0700 (PDT)
- Subject: [xsl] handling media, xsl:variable problem
- Reply-to: xsl-list at lists dot mulberrytech dot com
(I would appreciate a direct reply as I am a digester
and am working with a tight deadline! Please remember
to cc the list as well though!)
I am trying to setup a template to handle MEDIA
elements, which can be images, video or audio. I am
trying to use a variable to store the actual img or
embed tag to use later on in placement of the media
file, but for some reason, the variable is coming out
empty. If I add some basic text in the variable, it is
captured and output as expected. So, it is just the
img or embed tags that are being ignored/omitted for
some reason...
I am using Saxon and outputting as XHTML. Here is an
exmaple media element and the media template.
Suggestions and/or comments welcome. TIA --Nate
<!-- media element -->
<Media type="image" id="issrail"
file="http://www.nasa.gov/images/031902_issrail.jpg"
align="left" width="110" height="83" border="0"
alt="Space Railroad">
<Caption align="bottom">Space Railroad</Caption>
<Link type="internal"
url="http://spacerailroad.nasa.gov/" />
</Media>
<!-- media template -->
<xsl:template match="Media">
<xsl:variable name="media1">
<xsl:choose>
<xsl:when test="@type='image'">
<img id="{@id}" src="{@file}" width="{@width}"
height="{@height}" align="{@align}" border="{@border}"
alt="{@alt}" />
</xsl:when>
<xsl:when test="@type='audio'">
<embed id="{@id}" src="{@file}" height="{@height}"
width="{@width}" autostart="false" loop="false" />
</xsl:when>
<xsl:when test="@type='video'">
<embed id="{@id}" src="{@file}" height="{@height}"
width="{@width}" autostart="false" loop="false" />
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="media2">
<xsl:choose>
<xsl:when test="Link and Link!=''">
<a>
<xsl:attribute name="href">
<xsl:value-of select="@url" />
</xsl:attribute>
<xsl:if test="@type='external'">
<xsl:attribute name="target">
<xsl:value-of select="'_blank'" />
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$media1" />
</a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$media1" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="Caption and Caption!=''">
<table cellspacing="0" cellpadding="3" border="0">
<xsl:choose>
<xsl:when test="Caption/@align='top'">
<tr><td valign="top"
class="piccaption"><xsl:value-of select="Caption"
/></td></tr>
<tr><td><xsl:value-of select="$media2"
/></td></tr>
</xsl:when>
<xsl:when test="Caption/@align='left'">
<tr><td valign="top"
class="piccaption"><xsl:value-of select="Caption"
/></td>
<td><xsl:value-of select="$media2" /></td></tr>
</xsl:when>
<xsl:when test="Caption/@align='right'">
<tr><td><xsl:value-of select="$media2" /></td>
<td valign="top" class="piccaption"><xsl:value-of
select="Caption" /></td></tr>
</xsl:when>
<xsl:when test="Caption/@align='bottom'">
<tr><td><xsl:value-of select="$media2"
/></td></tr>
<tr><td valign="top"
class="piccaption"><xsl:value-of select="Caption"
/></td></tr>
</xsl:when>
</xsl:choose>
</table>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$media2" />
</xsl:otherwise>
</xsl:choose>
<xsl:if test="@width > 600">
<br clear="all" />
</xsl:if>
</xsl:template>
__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list