nizarhandal
Programmer
Can anyone tell me why in the following code the variable href_preview is always empty?
The XSL file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" xmlns:fo=" <xsl:template match="/">
<html>
<head>
<title>
<xsl:value-of select="NewsML/NewsItem/NewsComponent/NewsLines/HeadLine"/>
</title>
</head>
<body dir="rtl">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"><div align="center"><strong><xsl:value-of select="NewsML/NewsItem/NewsComponent/NewsLines/HeadLine"/></strong></div></td>
</tr>
<tr>
<td width="70%">
<div align="justify">
<xsl:for-each select="NewsML/NewsItem/NewsComponent">
<xsl:value-of select="NewsComponent"/>
</xsl:for-each>
</div>
</td>
<td valign="top" width="30%">
<div align="center">
<xsl:for-each select="NewsML/NewsItem/NewsComponent/NewsComponent/NewsComponent">
<xsl:variable name="href_preview">
<xsl:choose>
<xsl:when test="Role/@FormalName='Preview'">
<xsl:value-of select="ContentItem/@Href"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="href_quicklook">
<xsl:choose>
<xsl:when test="Role/@FormalName='Quicklook'">
<xsl:value-of select="ContentItem/@Href"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="width">
<xsl:choose>
<xsl:when test="Role/@FormalName='Quicklook'">
<xsl:choose>
<xsl:when test="ContentItem/Characteristics/Property/@FormalName='Width'">
<xsl:value-of select="ContentItem/Characteristics/Property/@Value"/>
</xsl:when>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="height">
<xsl:choose>
<xsl:when test="Role/@FormalName='Quicklook'">
<xsl:choose>
<xsl:when test="ContentItem/Characteristics/Property/@FormalName='Height'">
<xsl:value-of select="ContentItem/Characteristics/Property/@Value"/>
</xsl:when>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:if test="$width != '' and $height != '' and $href_preview != '' and $href_quicklook != ''">
<a href="images/{$href_preview}"><img src="images/{$href_quicklook}" width="{$width}" height="{$height}"/></a>
</xsl:if>
</xsl:for-each>
</div>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The XML file:
<?xml version="1.0"?>
<NewsML>
<Catalog Href=" <NewsEnvelope>
<DateAndTime>20060603T061859Z</DateAndTime>
</NewsEnvelope>
<NewsItem>
<Identification>
<NewsIdentifier>
<ProviderId>afp.com</ProviderId>
<DateId>20060603</DateId>
<NewsItemId>060603061851.sff41n7v</NewsItemId>
<RevisionId PreviousRevision="0" Update="N">1</RevisionId>
<PublicIdentifier>urn:newsml:afp.com:20060603:060603061851.sff41n7v:1</PublicIdentifier>
</NewsIdentifier>
<NameLabel>???/???????</NameLabel>
</Identification>
<NewsManagement>
<NewsItemType FormalName="News"/>
<FirstCreated>20060603T061851Z</FirstCreated>
<ThisRevisionCreated>20060603T061851Z</ThisRevisionCreated>
<Status FormalName="Usable"/>
</NewsManagement>
<NewsComponent>
<NewsLines>
<HeadLine>??????? 2006: ??? ??????? ??? ???????? 3-??? ???? ??? ???????? ???????</HeadLine>
<CopyrightLine>????? ????? ??? © 2006</CopyrightLine>
<SlugLine>???/??????? ????</SlugLine>
</NewsLines>
<AdministrativeMetadata>
<Provider>
<Party FormalName="AFP"/>
</Provider>
</AdministrativeMetadata>
<DescriptiveMetadata>
<Language FormalName="ar"/>
<OfInterestTo FormalName="mmd--arabic--journal--sport"/>
</DescriptiveMetadata>
<NewsComponent>
<ContentItem>
<MediaType FormalName="Text"/>
<Format FormalName="bcNITF2.5"/>
<DataContent>
<media media-type="image" style="rightSide">
<media-reference mime-type="" data-location="#photo0"/>
</media>
<p>???????????? (???????) (? ? ?)- ??? ????? ???????? ???? ????? ??? ????? ????????? 3-??? ?????? ?? ???????????? (???) ?? ???? ????????? ????? ???????? ??????? 2006 ?? 9 ??????/????? ??? 9 ????/????? ?? ???????.</p>
<p>???? ?????? ????? (20) ???????? ??????????? (37) ???? ???????? (69) ???????.</p>
<p>????? ??????? ?? ????????? ??? ????????? ?????? ??? ???? ????????? ??????? ??????????.</p>
<p>??? ???? ????? ??? ????? ?? ???? ????? ??? ?????? ????? ???????? ??????? ???? ?????????? ???? ????? ???? ???????? ????????? ????? ??? ??????? ?????? ?? ??? ?????? ??? ?????? ?? ??? ?????? ??? ??? ??? ?????? ?? ????? ????? ?? ???????????? "??? ?? ???? ???????? ??????? ??? ??????? ??? ????? ????? ????? ???? ?? ???? ????? ??????? ????? ?????? ?????? ????? ????? ?? ?? ??????".</p>
<p>????? "????? ?????? ?????? ??? ??? ??? ????? ?? ??????? (2-2) ????? ???? ?????? ?? ????????? ???? ????? ?? ???? ??? ??????. ??? ?? ???? ?????? ?????? ?? ????????? ?? ????? ????? ???? ????????? ?????????? ???????".</p>
<p>???? "???? ?????? ???? ????? ???? ????? ???? ??? ???????? ??? ??????? ?? ????? ???? ?? ?????? ???? ???? ???????? ????????? ????????".</p>
<p>???? ???????? ???? ????? ?? ??/????? 2004 ??? ????? ??????? ?? ???? ?????? ?????? ?? ????? ????? ???? ????? ????????? ??? 2004 ?? ????????.</p>
<p>????? ???????? ?? ??? ?????? ???????? ????? ????? ?? ?????? ???????? ?????????? ?? ????????? ?? 9 ?????? ??? ?????? ???????? ?? ?????? ??????? ??? ???????? ??? ???? ????? ??? ????? ???? ??? ??? ???? ???????? ???? ???? ??? ????? ??? ??????? ?????????.</p>
<p>???? ??????????? ????? ??????? ?? ??????? ??????? ??? ???? ????? ??????? ???? ?????? ?? ??? ????? ??????? ???? ???? ??? ????? ?????? ??? ?????? ???????? ?? ????????? 9 ?12 ?????? ????? ?????? ????????? ?????.</p>
<p>???? ??????????? ???? ???? ??? ?????? ?????? ????? ???? ???? ?????? ????????? ??? ????? ????? ????? ???? ?????? ?????? ????????? ?? 65 ?????? (21).</p>
<p>???? ????? ????? ???? ???? ??????? ??????? ????? ?????? ??????? (28) ???? ???? ?????? ????? ??? ????? ????????? ????? ???? ????? ???? ????? ?????? ???????? (34) ??? ?? ????? ??????????? ???? ??????? ???????? ??????? ???? ??? ?? ???? ??? ?????? ???? ??? 25 ???? (37).</p>
<p>??? ??????? 41 ???? ????? ???? ?? ???? ??? ?? ???? ??? ?????? ?? ????? ???????? ??? ?????? ?????? ??????? ?????? ?? ?????? ???? ???????.</p>
<p>????? ???? ??????? ???????? ???? ??? ??? 45 ??? ????? ????? ?? ???? ????? ??? ????? ????? ?? ????????? ?????? ???? (62) ?? ???? ????? ?????? ??? ????? (65) ??? ?? ???? ??? ???????? ??????? ???? ??? ?????? ??????? ???????? ????????? ??????? ????????.</p>
<p>?????? ???????? ?????? ????? ????? ?? ??? ?????? ????????? ???? ???? ??????? ???? ???? (69) ????? ??? ?????? ???? ????? ??????? ??? ?????? ?????????.</p>
</DataContent>
</ContentItem>
</NewsComponent>
<NewsComponent Duid="photo0">
<NewsLines>
<HeadLine>????? ??????? ???????? ??????? ?????? ??? ???????? </HeadLine>
</NewsLines>
<AdministrativeMetadata>
<Provider>
<Party FormalName="?? ?/?? ?? ?? "/>
</Provider>
<Creator>
<Party FormalName="?????? ???? "/>
</Creator>
</AdministrativeMetadata>
<NewsComponent>
<Role FormalName="Caption"/>
<ContentItem>
<MediaType FormalName="Text"/>
<Format FormalName="bcNITF2.5"/>
<DataContent>
<p>??? ????? ???????? ???? ????? ??? ????? ????????? 3-??? ?????? ?? ???????????? (???) ?? ???? ????????? ????? ???????? ??????? 2006 ?? 9 ??????/????? ??? 9 ????/????? ?? ???????.</p>
</DataContent>
</ContentItem>
</NewsComponent>
<NewsComponent>
<Role FormalName="Thumbnail"/>
<ContentItem Href="SGE.CXV92.030606061846.photo00.thumbnail.default-65x100.jpg">
<MediaType FormalName="Photo"/>
<Characteristics>
<Property FormalName="Width" Value="65"/>
<Property FormalName="Height" Value="100"/>
</Characteristics>
</ContentItem>
</NewsComponent>
<NewsComponent>
<Role FormalName="Quicklook"/>
<ContentItem Href="SGE.CXV92.030606061846.photo00.quicklook.default-161x245.jpg">
<MediaType FormalName="Photo"/>
<Characteristics>
<Property FormalName="Width" Value="161"/>
<Property FormalName="Height" Value="245"/>
</Characteristics>
</ContentItem>
</NewsComponent>
<NewsComponent>
<Role FormalName="Preview"/>
<ContentItem Href="SGE.CXV92.030606061846.photo00.photo.default-337x512.jpg">
<MediaType FormalName="Photo"/>
<Characteristics>
<Property FormalName="Width" Value="337"/>
<Property FormalName="Height" Value="512"/>
</Characteristics>
</ContentItem>
</NewsComponent>
</NewsComponent>
</NewsComponent>
</NewsItem>
</NewsML>
The XSL file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" xmlns:fo=" <xsl:template match="/">
<html>
<head>
<title>
<xsl:value-of select="NewsML/NewsItem/NewsComponent/NewsLines/HeadLine"/>
</title>
</head>
<body dir="rtl">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"><div align="center"><strong><xsl:value-of select="NewsML/NewsItem/NewsComponent/NewsLines/HeadLine"/></strong></div></td>
</tr>
<tr>
<td width="70%">
<div align="justify">
<xsl:for-each select="NewsML/NewsItem/NewsComponent">
<xsl:value-of select="NewsComponent"/>
</xsl:for-each>
</div>
</td>
<td valign="top" width="30%">
<div align="center">
<xsl:for-each select="NewsML/NewsItem/NewsComponent/NewsComponent/NewsComponent">
<xsl:variable name="href_preview">
<xsl:choose>
<xsl:when test="Role/@FormalName='Preview'">
<xsl:value-of select="ContentItem/@Href"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="href_quicklook">
<xsl:choose>
<xsl:when test="Role/@FormalName='Quicklook'">
<xsl:value-of select="ContentItem/@Href"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="width">
<xsl:choose>
<xsl:when test="Role/@FormalName='Quicklook'">
<xsl:choose>
<xsl:when test="ContentItem/Characteristics/Property/@FormalName='Width'">
<xsl:value-of select="ContentItem/Characteristics/Property/@Value"/>
</xsl:when>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="height">
<xsl:choose>
<xsl:when test="Role/@FormalName='Quicklook'">
<xsl:choose>
<xsl:when test="ContentItem/Characteristics/Property/@FormalName='Height'">
<xsl:value-of select="ContentItem/Characteristics/Property/@Value"/>
</xsl:when>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:if test="$width != '' and $height != '' and $href_preview != '' and $href_quicklook != ''">
<a href="images/{$href_preview}"><img src="images/{$href_quicklook}" width="{$width}" height="{$height}"/></a>
</xsl:if>
</xsl:for-each>
</div>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The XML file:
<?xml version="1.0"?>
<NewsML>
<Catalog Href=" <NewsEnvelope>
<DateAndTime>20060603T061859Z</DateAndTime>
</NewsEnvelope>
<NewsItem>
<Identification>
<NewsIdentifier>
<ProviderId>afp.com</ProviderId>
<DateId>20060603</DateId>
<NewsItemId>060603061851.sff41n7v</NewsItemId>
<RevisionId PreviousRevision="0" Update="N">1</RevisionId>
<PublicIdentifier>urn:newsml:afp.com:20060603:060603061851.sff41n7v:1</PublicIdentifier>
</NewsIdentifier>
<NameLabel>???/???????</NameLabel>
</Identification>
<NewsManagement>
<NewsItemType FormalName="News"/>
<FirstCreated>20060603T061851Z</FirstCreated>
<ThisRevisionCreated>20060603T061851Z</ThisRevisionCreated>
<Status FormalName="Usable"/>
</NewsManagement>
<NewsComponent>
<NewsLines>
<HeadLine>??????? 2006: ??? ??????? ??? ???????? 3-??? ???? ??? ???????? ???????</HeadLine>
<CopyrightLine>????? ????? ??? © 2006</CopyrightLine>
<SlugLine>???/??????? ????</SlugLine>
</NewsLines>
<AdministrativeMetadata>
<Provider>
<Party FormalName="AFP"/>
</Provider>
</AdministrativeMetadata>
<DescriptiveMetadata>
<Language FormalName="ar"/>
<OfInterestTo FormalName="mmd--arabic--journal--sport"/>
</DescriptiveMetadata>
<NewsComponent>
<ContentItem>
<MediaType FormalName="Text"/>
<Format FormalName="bcNITF2.5"/>
<DataContent>
<media media-type="image" style="rightSide">
<media-reference mime-type="" data-location="#photo0"/>
</media>
<p>???????????? (???????) (? ? ?)- ??? ????? ???????? ???? ????? ??? ????? ????????? 3-??? ?????? ?? ???????????? (???) ?? ???? ????????? ????? ???????? ??????? 2006 ?? 9 ??????/????? ??? 9 ????/????? ?? ???????.</p>
<p>???? ?????? ????? (20) ???????? ??????????? (37) ???? ???????? (69) ???????.</p>
<p>????? ??????? ?? ????????? ??? ????????? ?????? ??? ???? ????????? ??????? ??????????.</p>
<p>??? ???? ????? ??? ????? ?? ???? ????? ??? ?????? ????? ???????? ??????? ???? ?????????? ???? ????? ???? ???????? ????????? ????? ??? ??????? ?????? ?? ??? ?????? ??? ?????? ?? ??? ?????? ??? ??? ??? ?????? ?? ????? ????? ?? ???????????? "??? ?? ???? ???????? ??????? ??? ??????? ??? ????? ????? ????? ???? ?? ???? ????? ??????? ????? ?????? ?????? ????? ????? ?? ?? ??????".</p>
<p>????? "????? ?????? ?????? ??? ??? ??? ????? ?? ??????? (2-2) ????? ???? ?????? ?? ????????? ???? ????? ?? ???? ??? ??????. ??? ?? ???? ?????? ?????? ?? ????????? ?? ????? ????? ???? ????????? ?????????? ???????".</p>
<p>???? "???? ?????? ???? ????? ???? ????? ???? ??? ???????? ??? ??????? ?? ????? ???? ?? ?????? ???? ???? ???????? ????????? ????????".</p>
<p>???? ???????? ???? ????? ?? ??/????? 2004 ??? ????? ??????? ?? ???? ?????? ?????? ?? ????? ????? ???? ????? ????????? ??? 2004 ?? ????????.</p>
<p>????? ???????? ?? ??? ?????? ???????? ????? ????? ?? ?????? ???????? ?????????? ?? ????????? ?? 9 ?????? ??? ?????? ???????? ?? ?????? ??????? ??? ???????? ??? ???? ????? ??? ????? ???? ??? ??? ???? ???????? ???? ???? ??? ????? ??? ??????? ?????????.</p>
<p>???? ??????????? ????? ??????? ?? ??????? ??????? ??? ???? ????? ??????? ???? ?????? ?? ??? ????? ??????? ???? ???? ??? ????? ?????? ??? ?????? ???????? ?? ????????? 9 ?12 ?????? ????? ?????? ????????? ?????.</p>
<p>???? ??????????? ???? ???? ??? ?????? ?????? ????? ???? ???? ?????? ????????? ??? ????? ????? ????? ???? ?????? ?????? ????????? ?? 65 ?????? (21).</p>
<p>???? ????? ????? ???? ???? ??????? ??????? ????? ?????? ??????? (28) ???? ???? ?????? ????? ??? ????? ????????? ????? ???? ????? ???? ????? ?????? ???????? (34) ??? ?? ????? ??????????? ???? ??????? ???????? ??????? ???? ??? ?? ???? ??? ?????? ???? ??? 25 ???? (37).</p>
<p>??? ??????? 41 ???? ????? ???? ?? ???? ??? ?? ???? ??? ?????? ?? ????? ???????? ??? ?????? ?????? ??????? ?????? ?? ?????? ???? ???????.</p>
<p>????? ???? ??????? ???????? ???? ??? ??? 45 ??? ????? ????? ?? ???? ????? ??? ????? ????? ?? ????????? ?????? ???? (62) ?? ???? ????? ?????? ??? ????? (65) ??? ?? ???? ??? ???????? ??????? ???? ??? ?????? ??????? ???????? ????????? ??????? ????????.</p>
<p>?????? ???????? ?????? ????? ????? ?? ??? ?????? ????????? ???? ???? ??????? ???? ???? (69) ????? ??? ?????? ???? ????? ??????? ??? ?????? ?????????.</p>
</DataContent>
</ContentItem>
</NewsComponent>
<NewsComponent Duid="photo0">
<NewsLines>
<HeadLine>????? ??????? ???????? ??????? ?????? ??? ???????? </HeadLine>
</NewsLines>
<AdministrativeMetadata>
<Provider>
<Party FormalName="?? ?/?? ?? ?? "/>
</Provider>
<Creator>
<Party FormalName="?????? ???? "/>
</Creator>
</AdministrativeMetadata>
<NewsComponent>
<Role FormalName="Caption"/>
<ContentItem>
<MediaType FormalName="Text"/>
<Format FormalName="bcNITF2.5"/>
<DataContent>
<p>??? ????? ???????? ???? ????? ??? ????? ????????? 3-??? ?????? ?? ???????????? (???) ?? ???? ????????? ????? ???????? ??????? 2006 ?? 9 ??????/????? ??? 9 ????/????? ?? ???????.</p>
</DataContent>
</ContentItem>
</NewsComponent>
<NewsComponent>
<Role FormalName="Thumbnail"/>
<ContentItem Href="SGE.CXV92.030606061846.photo00.thumbnail.default-65x100.jpg">
<MediaType FormalName="Photo"/>
<Characteristics>
<Property FormalName="Width" Value="65"/>
<Property FormalName="Height" Value="100"/>
</Characteristics>
</ContentItem>
</NewsComponent>
<NewsComponent>
<Role FormalName="Quicklook"/>
<ContentItem Href="SGE.CXV92.030606061846.photo00.quicklook.default-161x245.jpg">
<MediaType FormalName="Photo"/>
<Characteristics>
<Property FormalName="Width" Value="161"/>
<Property FormalName="Height" Value="245"/>
</Characteristics>
</ContentItem>
</NewsComponent>
<NewsComponent>
<Role FormalName="Preview"/>
<ContentItem Href="SGE.CXV92.030606061846.photo00.photo.default-337x512.jpg">
<MediaType FormalName="Photo"/>
<Characteristics>
<Property FormalName="Width" Value="337"/>
<Property FormalName="Height" Value="512"/>
</Characteristics>
</ContentItem>
</NewsComponent>
</NewsComponent>
</NewsComponent>
</NewsItem>
</NewsML>