[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

handling media, xsl:variable problem

Subject: handling media, xsl:variable problem
From: Nathan Shaw <n8_shaw@xxxxxxxxx>
Date: Wed, 1 May 2002 12:18:58 -0700 (PDT)
xsl variable xsl when
(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 &gt; 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.