Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why curely braces in does not evaluate

Status
Not open for further replies.

fabed

Programmer
Dec 4, 2006
4
PS
<xsl:choose>
<xsl:when test="$has_pic='1'">
<xsl:variable name="href_preview">
<xsl:for-each select="NewsItem/NewsComponent/NewsComponent/NewsComponent">
<xsl:variable name="index" select="position()" />
<xsl:choose>
<xsl:when test="Role/@FormalName='Preview'">
<xsl:value-of select="ContentItem/@Href"/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="width">
<xsl:for-each select="NewsItem/NewsComponent/NewsComponent/NewsComponent">
<xsl:choose>
<xsl:when test="Role/@FormalName='Preview'">
<xsl:for-each select="ContentItem/Characteristics/Property">
<xsl:choose>
<xsl:when test="@FormalName='Width'">
<xsl:value-of select="@Value"/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="height">
<xsl:for-each select="NewsItem/NewsComponent/NewsComponent/NewsComponent">
<xsl:choose>
<xsl:when test="Role/@FormalName='Preview'">
<xsl:for-each select="ContentItem/Characteristics/Property">
<xsl:choose>
<xsl:when test="@FormalName='Height'">
<xsl:value-of select="@Value"/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="image_href_thumbnail">
<xsl:for-each select="NewsItem/NewsComponent/NewsComponent/NewsComponent">
<xsl:choose>
<xsl:when test="Role/@FormalName='Thumbnail'">
<xsl:value-of select="ContentItem/@Href"/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:variable>
<xsl:choose>
<xsl:when test="$pos = '1'">
<xsl:variable name="image_thumb">
<xsl:value-of select="concat('/imgbs/arabic/journal/sport/', substring-before($href_preview, '.jpg'), '.jpg')" />
</xsl:variable>
<xsl:variable name="image_thumb_new">
<xsl:value-of select="concat('files/afp/', substring-before($href_preview, '.jpg'), '.jpg')" />
</xsl:variable>
<xsl:variable name="newWidth">
<xsl:choose>
<xsl:when test="$width > 420">
<xsl:value-of select="420"></xsl:value-of>
</xsl:when>
<xsl:when test="420 > $width">
<xsl:choose>
<xsl:when test="$height > 300">
<xsl:value-of select="$width div ($height div 300)" />
</xsl:when>
<xsl:when test="300 > $height">
<xsl:value-of select="$width" />
</xsl:when>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="newHeight" >
<xsl:choose>
<xsl:when test="$height > 300">
<xsl:choose>
<xsl:when test="$width > 420">
<xsl:value-of select="$height div ($width div 420)" />
</xsl:when>
<xsl:when test="420 > $width">
<xsl:value-of select="300" />
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="300 > $height">
<xsl:value-of select="$height" />
</xsl:when>
</xsl:choose>
</xsl:variable>
<table dir="rtl">
<tr>
<td align="center" width="420">
<a href="{$image_thumb}">
<img align="right" src="{$image_thumb}" height="{$newHeight}" width="{$newWidth}"/>
</a>
</td>
</tr>
<tr>
<td align="right">
<p class="title-right">
<xsl:value-of select="NewsItem/NewsComponent/NewsLines/HeadLine" />
</p>
<p>
<xsl:value-of select="NewsItem/NewsComponent/NewsComponent/NewsComponent/ContentItem/DataContent/p"/>
</p>
</td>
</tr>
<tr>
<td align="left">
<a href="?XML={$xml_file}"><img src="files/more.gif" alt="??????" /></a>
</td>
</tr>
</table>
</xsl:when>
 
Maybe it is evaluated to empty?! How do you know it does not evaluate?

By just superficial reading of the script, I wonder why do you do all the for-each and choose elements to define a variable. Is it that you want the last one to prevail?... For instance, the first variable.

<xsl:variable name="href_preview">
<xsl:for-each select="NewsItem/NewsComponent/NewsComponent/NewsComponent">
<xsl:variable name="index" select="position()" />
<xsl:choose>
<xsl:when test="Role/@FormalName='Preview'">
<xsl:value-of select="ContentItem/@Href"/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:variable>

Why not simply do roughly this?

[tt] <xsl:variable name="href_preview">
<xsl:value-of select="NewsItem/NewsComponent/NewsComponent/NewsComponent/ContentItem[../Role/@FormalName='Preview']/@Href">
</xsl:variable>
[/tt]
May be I miss something or exactitude... but that's the idea.
 
the problem is in the height and width values when i select their values using <xsl:value of>, their values are shown.
All other code is work well...

thanks alot for your replying
 
What if width equal to 420 and height equal to 300?
 
i want to know if my code has an error or must work well and the problem is not in the height and width variables...
 
Replace > inside test by &gt; and < by &lt;.
 
fabed,

My response to this thread is, "If you ask an inspecific question, don't complain about the answer."

Also, you might take Tsuji's advice (in his initial response) and try a different technique. Your stylesheet appears to be far more complex than it needs to be, because you are thinking in terms of a C programming paradigm. XPath expressions are much more powerful, if you take some time to think inside the XPath paradigm.

Finally, you definitely owe Tsuji a
star.gif
for his willingness to determine the problem in your original submission.

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top