0

我有五个来自表单的值;像 state1、state2、state3、state4 和 state5。每个值都可以是“新”或“已关闭”。将根据这些值显示报告。因此,我创建了 5 个表格,每个表格显示在报告中。如果值为“新”,则显示相应的表格,否则无需显示。因此,我创建了如下所示的 XSLT(这只是我代码中的一个片段)。

  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="html" omit-xml-declaration="yes" standalone="yes" indent="yes"cdata-section-elements="script msxsl:script"></xsl:output>
   <xsl:template match="/">
   <html>
     <head><title>Report</title></head>
      <body>
       <table class="row1">
        <tr>
         <td align="left" colspan="2">
         <img src="../images/Logos/logo.gif" height="80"></img>
         </td>
        </tr>
       </table>
   <xsl:if test="(state1='New') and (state2='Closed') and (state3='Closed') and (state4='Closed') and (state5='Closed')">
    <table class="row2">
     <tr>
      <td class="section" uniqueID="ms__id17">
       <b>Details(S1)</b>
      </td>
     </tr>
      <!--some rows -->
    </table>
    </xsl:if>
   <xsl:if test="(state1='New') and (state2='New') and (state3='Closed') and   (state4='Closed') and (state5='Closed')">
    <table class="row2">
     <tr>
      <td class="section" uniqueID="ms__id18">
       <b>Details(S1)</b>
      </td>
     </tr>
      <!--some rows -->
    </table> 
    <table class="row3">
     <tr>
      <td class="section" uniqueID="ms__id19">
       <b>Details(S2)</b>
      </td>
     </tr>
      <!--some rows -->
    </table> 
   </xsl:if>
   <!--more conditions-->
         </body>
       </html>
    </xsl:template>
   </xsl:stylesheet>

如果我继续给这样的条件,我应该给5!条件。

有没有更好的方法来做到这一点。

4

1 回答 1

0

这是你想要的(使用或代替and)吗?

<xsl:if test="(state1='New') or (state2='New') or (state3='New') or (state4='New') or (state5='New')">
<table class="row2">
 <tr>
  <td class="section" uniqueID="ms__id17">
   <b>Details(S1)</b>
  </td>
 </tr>
  <!--some rows -->
</table>
</xsl:if>
于 2013-08-02T13:56:51.667 回答