XSLT 元素參考
W 3C 推薦标準所定義的XSLT元素(XSLT 1.0)。
XSLT元素
“元素”列中的連結指向每個特定元素的屬性和更多有用的資訊。
N: 指明最早版本的Netscape浏覽器所支援的标簽
IE: 指明最早版本的IE浏覽器所支援的标簽
注意: IE5支援的元素可能含有非标準的行為,因為在XSLT成為W 3C 的官方推薦标準之前,IE5就已經釋出了。
Element 元素 | Description 描述 | IE | N |
apply-imports | Applies a template rule from an imported style sheet 在輸入樣式表中應用模版規則 | 6.0 | |
apply-templates | Applies a template rule to the current element or to the current element's child nodes 把模版規則應用到目前元素或目前元素的子節點 | 5.0 | 6.0 |
attribute | Adds an attribute 添加一個屬性 | 5.0 | 6.0 |
attribute-set | Defines a named set of attributes 定義指定屬性集 | 6.0 | 6.0 |
call-template | Calls a named template 調用一個指定模版 | 6.0 | 6.0 |
choose | Used in conjunction with <when> and <otherwise> to express multiple conditional tests 通過與<when> 和<otherwise>配合使用來表達多種條件語句 | 5.0 | 6.0 |
comment | Creates a comment node in the result tree 在結果樹中建立一個注釋節點 | 5.0 | 6.0 |
copy | Creates a copy of the current node (without child nodes and attributes) 複制目前節點(不包括子節點和屬性) | 5.0 | 6.0 |
copy-of | Creates a copy of the current node (with child nodes and attributes) 複制目前節點(包括子節點和屬性) | 6.0 | 6.0 |
decimal-format | Defines the characters and symbols to be used when converting numbers into strings, with the format-number() function 當使用format-number()函數将數字轉換成字元串時,定義字元和符号 | 6.0 | |
element | Creates an element node in the output document 在輸出文檔中建立一個元素節點 | 5.0 | 6.0 |
fallback | Specifies an alternate code to run if the processor does not support an XSLT element 如果處理器不支援XSLT元素,指定所需執行的替換代碼 | 6.0 | |
for-each | Loops through each node in a specified node set 在指定的節點集循環每個節點 | 5.0 | 6.0 |
if | Contains a template that will be applied only if a specified condition is true 條件語句:如果指定的條件為真,則執行對應的模版 | 5.0 | 6.0 |
import | Imports the contents of one style sheet into another. Note: An imported style sheet has lower precedence than the importing style sheet 将一張樣式表中的内容導入至另一張樣式表中。 注意:與導入的樣式表相比,被導入的樣式表優先級較低。 | 6.0 | 6.0 |
include | Includes the contents of one style sheet into another. Note: An included style sheet has the same precedence as the including style sheet 把一張樣式表的内容嵌套到另一張樣式表中 。 注意:這兩份樣式表的優先級相同。 | 6.0 | 6.0 |
key | Declares a named key that can be used in the style sheet with the key() function 使用key() 函數聲明一個可以用于樣式表的特定鍵值 | 6.0 | 6.0 |
message | Writes a message to the output (used to report errors) 将資訊寫進結果中(用于報告錯誤資訊) | 6.0 | 6.0 |
namespace-alias | Replaces a namespace in the style sheet to a different namespace in the output 把結果中的命名空間用樣式表中的命名空間替換 | 6.0 | |
number | Determines the integer position of the current node and formats a number 确定目前節點的整數位置并定義一個數字格式 | 6.0 | 6.0 |
otherwise | Specifies a default action for the <choose> element 指定<choose>元素的預設行為 | 5.0 | 6.0 |
output | Defines the format of the output document 定義結果文檔的格式 | 6.0 | 6.0 |
param | Declares a local or global parameter 聲明一個本地參數或是通用參數 | 6.0 | 6.0 |
preserve-space | Defines the elements for which white space should be preserved 定義需要保留白白的元素 | 6.0 | 6.0 |
processing-instruction | Writes a processing instruction to the output 在結果中寫入一條處理指令 | 5.0 | 6.0 |
sort | Sorts the output 對結果分類 | 6.0 | 6.0 |
strip-space | Defines the elements for which white space should be removed 定義需要删除空白的元素 | 6.0 | 6.0 |
stylesheet | Defines the root element of a style sheet 定義樣式表的根元素 | 5.0 | 6.0 |
template | Rules to apply when a specified node is matched 當指定節點比對時應用的規則 | 5.0 | 6.0 |
text | Writes literal text to the output 編寫文字文本到輸出 | 5.0 | 6.0 |
transform | Defines the root element of a style sheet 定義樣式表的根元素 | 6.0 | 6.0 |
value-of | Extracts the value of a selected node 摘取一個標明的節點值 | 5.0 | 6.0 |
variable | Declares a local or global variable 聲明本地變量或通用變量 | 6.0 | 6.0 |
when | Specifies an action for the <choose> element 指定<choose>元素的行為 | 5.0 | 6.0 |
with-param | Defines the value of a parameter to be passed into a template 定義一個傳遞到模版内的參數值 | 6.0 | 6.0 |
XSLT 函數
XQuery 1.0, XPath 2.0, 和XSLT 2.0共享一個函數庫。
XSLT包含了超過100個内置函數,包括字元串函數、數值函數、日期時間函數、節點、QName處理函數、序列處理函數、邏輯函數等等。
XSLT函數命名空間的URI是:http://www.w3.org/2005/02/xpath-functions
函數命名空間的預設字首是“fn”:
提示: 函數的聲明通常以“fn” 為字首,如:“fn:string()”;然而,由于“fn:”是命名空間的預設字首,是以,當聲明函數時,函數名稱不需要書寫字首名。
請在我們的XPath教程中查找全部内置的XSLT2.0函數的參數
作為補充,我們還例舉了下面這些内置XSLT函數:
Name 名稱 | Description 描述 |
current() | Returns the current node 傳回目前節點 |
document() | Used to access the nodes in an external XML document 用于通路一個外部XML文檔内的節點 |
element-available() | Tests whether the element specified is supported by the XSLT processor 測試指定的元素是否被XSLT處理器支援 |
format-number() | Converts a number into a string 将某個數字轉化為對應的字元串 |
function-available() | Tests whether the function specified is supported by the XSLT processor 測試指定的函數是否被XSLT處理器支援 |
generate-id() | Returns a string value that uniquely identifies a specified node 傳回一個獨立定義指定節點的字元串值 |
key() | Returns a node-set using the index specified by an <xsl:key> element 使用由<XSL:key>元素指定的索引來傳回一個節點集 |
system-property() | Returns the value of the system properties 傳回系統屬性值 |
unparsed-entity-uri() | Returns the URI of an unparsed entity 傳回一個未被解析的實體元素的URI |