Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] handling media, xsl:variable problem

From: Nathan Shaw <n8_shaw@--------->
To:
Date: 5/1/2002 11:13:00 AM
(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


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent