Two XSL IF Conditions

Hey guys,

having a bit of bother … I want to transform an xml file but only if 2 conditions are true …

so eg.

If my content type is sport and my format is football.

I tried this …


<xsl:variable name="format">
    <xsl:value-of select="format"/>
  </xsl:variable>
  <xsl:variable name="content_type">
    <xsl:value-of select="content_type"/>
  </xsl:variable>

I then tried 2 if statements to check the conditions …


<xsl:if test="$format = 'football''">
    <xsl:if test="$content_type = 'sport'">
         <!-- other stuff here -->
    </xsl:if>
</xsl:if>

I get a blank document once parsed.

regards,

Ronan

  1. You had a typo, 2 apostrophes after “football”.
  2. You can test for two conditions in one statement:

<xsl:if test="$format = 'football' and $content_type='sport'">
         <!-- other stuff here -->
</xsl:if>

Cheers vgarcia … found out my problem …

I had multiple formats and as my 1st format in the xml file did not always = football it failed.

I now cycle through each format and check if it = football …


<xsl:for-each select="List[format='football']"

Thanks for your help …