2011-12-03 111 views
0

我有這樣的XSLT分組碼的另一部分:訂購的<xsl:when>結果頁面

<xsl:template match="zootier"> 
    <xsl:choose> 
     <xsl:when test="not(@flugfaeghig) or (@flugfaeghig='true')"> 
     <xsl:value-of select="name/text()"/> 
     (<xsl:value-of select="@id"/>) 
     </xsl:when> 

     <xsl:otherwise> 
     <xsl:if test="@flugfaeghig='false'"> 
      <xsl:value-of select="name/text()"/> 
      (<xsl:value-of select="@id"/>) 
     </xsl:if> 
     </xsl:otherwise> 
    </xsl:choose> 
    </xsl:template> 

我希望顯示的<xsl:when>結果在另一部分我的網頁的一個組成部分,<xsl:otherwise> 。例如iwant表現出對一個 FRNT和TH B的前<xsl:otherwise> resault

<xsl:template match="zoo"> 
    <html> 
     <title> 
     <xsl:text>ZOO</xsl:text> 
     </title> 
     <head> 
     <h1>Behausung im Zoo "Zoogarten"</h1> 
     </head> 

     <table> 
     <tr> 
      <td> 
      <xsl:text>A </xsl:text> 
      </td> 
     </tr> 
     <tr> 
      <td> 
      <xsl:text>B</xsl:text> 
      </td> 

     </tr> 
     <xsl:apply-templates select="zootier" /> 
     </table> 
    </html> 

請你告訴我,我怎樣才能做到這一點的<xsl:when>的resualt?

回答

0

如果我理解得很好,這個XSLT應該可以工作。如果仍然存在問題,您能否提供一個XML示例和期望的結果。我無法測試這個。

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version="1.0"> 
    <xsl:template match="zoo"> 
     <html> 
      <title> 
       <xsl:text>ZOO</xsl:text> 
      </title> 
      <head> 
       <h1>Behausung im Zoo "Zoogarten"</h1> 
      </head> 

      <table> 
       <tr> 
        <th> 
         <xsl:apply-templates select="zootier[not(@flugfaeghig) or (@flugfaeghig='true')]"/> 
        </th> 
        <td> 
         <xsl:text>A </xsl:text> 
        </td> 
       </tr> 
       <tr> 
        <th> 
         <xsl:apply-templates select="zootier[@flugfaeghig='false']"/> 
        </th> 
        <td> 
         <xsl:text>B</xsl:text> 
        </td> 

       </tr> 
      </table> 
     </html> 
    </xsl:template> 
    <xsl:template match="zootier"> 
     <xsl:value-of select="concat(name,' (',@id,')')"/>   
    </xsl:template> 
</xsl:stylesheet> 

的想法是濾除在你需要它的右zootier元素。