local-name 函式
傳回節點 (位於文件順序首位的節點集引數中) 之展開名稱的本機部分。
string local-name(node-set?)
備註
展開的名稱通常是由命名空間 URI (或關聯的前置詞)、冒號 (:) 和本機部分組成。例如,b:author
是擴充名稱,其中,b
是命名空間 URI 前置詞,author
是本機部分。因此,將 local-name()
函式套用至此節點會傳回 author
。當節點沒有擴充名稱 (如 author
) 時,將 local-name()
函式套用至此節點則會傳回原始的節點名稱,亦即 author
。
如果省略節點集引數,它就會預設為只有內容節點做為唯一成員的節點集。
範例
XML 檔 (data.xml)
XSLT 檔 (sample.xsl)
輔助 XSLT 檔 (book-schema.xml)
格式化輸出
local-name() Function
catalog =
book =
author = Gambardella, Matthew
title = XML Developer's Guide
genre = Computer
price = 44.95
publish_date = 2000-10-01
description = An in-depth look at creating applications with XML.
book =
author = Ralls, Kim
title = Midnight Rain
genre = Fantasy
price = 5.95
publish_date = 2000-12-16
description = A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.
處理器輸出
<html>
<body>
<h3>local-name() Function</h3>catalog = <br>book = <br>author = Gambardella, Matthew<br>title = XML Developer's Guide<br>genre = Computer<br>price = 44.95<br>publish_date = 2000-10-01<br>description = An in-depth look at creating applications with XML.<br>book = <br>author = Ralls, Kim<br>title = Midnight Rain<br>genre = Fantasy<br>price = 5.95<br>publish_date = 2000-12-16<br>description = A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.<br></body>
</html>