Re: [xsl] XSL If Statement - repost with code

Subject: Re: [xsl] XSL If Statement - repost with code
From: "Sumit Patki" <sumitpatki@xxxxxxxxx>
Date: Sun, 24 Aug 2008 18:28:53 -0400
Ok. Changing from WD-XSL to XSLT is one issue I have to deal with.
But more than that, I am confused about the below piece of code.

      <xsl:for-each select="topic/detail">
      <!-- <xsl:if test="matrix &gt; 0">       -->
      <xsl:if match=".[matrix=1]">
      <table border="2">
      <tr>
          <td align="center" STYLE="font-weight: bold;">
<xsl:value-of select="topic/detail/tableheading1" /> </td>
          <td align="center" STYLE="font-weight: bold;">
<xsl:value-of select="topic/detail/tableheading2" /> </td>
      </tr>
      <xsl:for-each select="topic/detail/table/state" >
      <tr>
          <td STYLE="font-weight: bold;vertical-align: top;">
<xsl:value-of select="statename" /> </td>
          <td STYLE="vertical-align: top;"> <xsl:apply-templates
select="statedesc" /> </td>
      </tr>
      </xsl:for-each>

      </table>
      </xsl:if>
      </xsl:for-each>

Given the structure of the xml below, will this display the state
matrix table if matrix element is having 1?
Since Matrix element is only present once in the xml, is there any
other alternative to refer to matrix element other than
"for-each select="topic/detail"
Please note that I have to execute another for-each "for-each
select="topic/detail/table/state" once it is inside the "topic/detail"
to display the state matrix html table. This is what is confusing me -
executing a for-each loop inside another for-each loop.
Is there any way I can avoid the outer for-each select = "topic/detail"
I did try <xsl:if match=".[topic/detail/matrix=1]"> but it gave me
error saying document not well formed.


On Sun, Aug 24, 2008 at 5:13 PM, David Carlisle <davidc@xxxxxxxxx> wrote:
>
>> I think I can change namespace to
>> "http://www.w3.org/1999/XSL/Transform"; instead of
>> "http://www.w3.org/TR/WD-xsl"; since the xsl file doesn't have any
>> other WD-XSL specific tags.
>
> The code you posted is _full_ of microsoft- wd-xsl spcifuc syntax  that
> won't work with an xslt processor.
>
>> Even though I change the namespace, it doesn't work.
> If you are using msxml2, then it knows nothing of xslt, so an xslt
> stylesheet obviously won't work, but the solution is to use a system
> that isn't so old, not to write in wd-xsl.
>
> just to point out the main places you need to change.
>
>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl";>
>
> wrong namespace, missing version attribute.
>
>       <xsl:if match=".[matrix=1]">
>
> xsl:if does not have a match attribute
> [ can not be used after .
>
>
> Once those are fixed so you have xslt then probably you need to change
>
> <xsl:value-of select="topic/detail/tableheading1" />
>
> to
>
> <xsl:value-of select="tableheading1" />
>
> as the current element is already the detail element because of the
>       <xsl:for-each select="topic/detail">
>
> David
>
> ________________________________________________________________________
> The Numerical Algorithms Group Ltd is a company registered in England
> and Wales with company number 1249803. The registered office is:
> Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
>
> This e-mail has been scanned for all viruses by Star. The service is
> powered by MessageLabs.
> ________________________________________________________________________

Current Thread