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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with xsl:if

Status
Not open for further replies.

Crovax2000

Programmer
Jul 30, 2004
1
US
I keep getting this message from IE:Keyword xsl:stylesheet may not contain xsl:if.

Is there only certain places that xsl:if can be placed??

Thank you for you help, code listed below.

Crovax

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="<xsl:template match="/">
<html><head><title>Comedy Movies</title></head>

<body>
<xsl:for-each select="/">
<div styles="width:275px; margin-bottom:10px; border:5px double black; color:black; background-color:yellow;
test-align:center">

<xsl:apply-templates select="Movie"/>
<xsl:apply-templates select="ReleaseYear"/>
<xsl:apply-templates select="Genre"/>

</div>
</xsl:for-each>
</body>
</html>

</xsl:template>
<xsl:if test="IsItComedy = 1">
<xsl:template match="Movie">
<div style="fontfamily:Times, serif; fontsize:13pt; font-weight:bold">
<xsl:value-of select="."/>
</div>
</xsl:template>

<xsl:template match="Year">
<div style="fontfamily:Times, serif; fontsize:13pt">
<xsl:value-of select="."/>
</div>
</xsl:template>

<xsl:template match="Genre">
<div style="fontfamily:Times, serif; fontsize:13pt">
<xsl:value-of select="."/>
</div>
</xsl:template>
</xsl:if>
</xsl:stylesheet>
 
Only within <xsl:template...>
In your example maybe:

Code:
<xsl:template match="/">
...
  <xsl:if test="IsItComedy = 1">
    <xsl:apply-templates select="Movie"/>
    <xsl:apply-templates select="ReleaseYear"/>
    <xsl:apply-templates select="Genre"/>
  </xsl:if>
...
</xsl:template>

By the way, <xsl:for-each select="/"> is a bit strange:it means for each root-node, and there is always only one.
 
yes he needs to use

Code:
<xsl:for-each select="*">
..
..
</xsl:for-each>

instead, as hes already in the root context specified by the <xsl:template match="/">.

:)

matt

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top