XSL是一種用來轉換XML文檔的樣式表,包含了三種語言:XSL轉換(XSLT),XML路徑語言(XPath)和 XSL格式化對象(XSL-FO)
聲明XSL模板 <xsl:template match="pattern"> 不帶match默認爲/
調用模板 <xsl:apply-templates select="*"/> 不帶select(同*) 調用後面的所有
循環:<xsl:for-each select="student" order-by="-score"> order-by +升序 -降序
節點取值: <xsl:value-of select="pattern"> 不帶select或*輸出當前節點及其所有後繼節點的值.
條件判斷:<xsl:if match="元素名稱">
<xsl:if match="元素名稱[.='元素內容']">
<xsl:if test=".[@id='105']"> <xsl: if test="./@id[value()='105']">
多條件判斷 <xsl:choose>
<xsl:when match=".[score $lt$ 80]">一般</xsl:when></xsl:choose>
路徑匹配符號
/ // * |
位置匹配
/student[1] /student[last()] /studen[position()>1
屬性和屬性值匹配
//student[@ID] //student[@ID="103"]
親屬關係匹配
//skill/parent::* //skill/ancestor::* 所有祖先結點 //skill/child::* //student/self::*
條件匹配
常用函數有四大類:節點函數,字符串函數,數值函數,布爾函數.
用XSL轉換XML文檔
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.