Xml學習(3)--XSL(可擴展樣式語言)

 

  1. xsl <xsl : value-of > 元素,使用其中的select屬性來選擇xml元素的值,然後把它添加到輸出流中。
  2. xsl <xsl:for-each>元素可以在xsl中作循環操作。可以用來選擇指定節點集中的每一個元素。
  3. 例如:<xsl:for-each select="catalog/book">

                          <tr>
                                    <td><xsl:value-of   select="title"></td>
                                                    ................
                                    <td><xsl:value-of   select="year"></td>
                         </tr>
                      </xsl: for-each>

  1.    過濾輸出 1. = 等於 2. != 不等 3.&lt 小於 4.  &gt 大於

              可以把:<xsl:for-each select="catalog/book">改爲

             <xsl:for-each select="catalog/book[ year = "2002"]"> 

  1. xsl <xsl:sort>元素用來對xml文檔輸出進行排序;

               <xsl:for-each select="catalog/book">          

                       <xsl:sort select="year"/>

              </xsl: for-each>

  1. xsl<xsl:if>包含一個模板,當滿足指定條件就使用它。

          <xsl:if test="price.&gt;'10' ">

             ..................

         </xsl:if>

  1. xsl<xsl:choose> 元素用來聯結<xsl:when>和<xsl:otherwise>;來表示多重條件測試。

       <xsl:choose>
          <xsl :when test="price.&gt;'10' ">
              ..........................................
            </xsl:when><xsl :otherwise>
               ...........................................
            </xsl:otherwise>
        </xsl:choose>

  1.    xsl <xsl:apply-taemplates>元素把模板規則用到當前的元素或節點。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章