当前位置:编程学习 > XML/UML >>

关于XSL函数详细介绍(中)

 十四、nodeName

含义:返回元素、属性、入口的名字或其他类型结点的一个特定字符串

语法:pNode.nodeName

示例:当前结点的名字

this.nodeName

十五、nodeType、NodeTypeString

含义:返回结点的类型的数值形式(或字符串形式)

语法:pNode.nodeType或pNode.nodeTypeString

返回值:

结点类型
结点类型编号 结点类型字符串

元素
1
"element"

元素属性
2
"attribute"

Markup-Delimited Region of Text 
3
"text"

Processing Instruction 
7
"processing_instruction"

Comment 
8
"comment"

Document Entity 
9
"document"


十六、nodeTypedvalue

含义:以结点预定义的数据类型返回结点的值

语法:pNode.nodeTypedvalue

示例:假定当前结点的数据类型是fixed.14.4,下例将以数值返回结点的值,而不是文本一个字符串

this.nodeTypedvalue

十七、nodevalue

含义:返回结点的文本

语法:pNode.nodevalue

注意:该方法不用于元素类结点,可用于属性、CDATA、注释、文本等结点

示例:当前元素第一个属性的值

this.attributes(0).nodevalue

当前元素内的文本(假定该元素内只有文本,无其它元素,即< mark >text< /mark >,建议多尝几次掌握其确切的用法)

this.firstChild.nodevalue

十八、ownerDocument

含义:返回包含该结点的文档的根

语法:pNode.ownerDocument

注意:该方法用于文档的根结点将出错

十九、selectNodes

含义:给定的样式匹配应用于当前结点并返回匹配的结点集合

语法:pNode.selectNodes("pattern")

提示:pattern的编写与< xsl:for-each >的select属性的值类似,其中以“/”开头表示

从文档的根出发搜索;以“//”开头表遍历文档的所有结点;以“..”开头

表示从当前结点的父结点开始;如果欲从当前结点向下搜索则不能有以上特殊字符打头。

    示例:与当前结点同名的元素在其父元素内的个数

childNumber(this.selectNodes("../"+this.nodeName+"[end()]").item(0))

当前元素内名字为“skill”的元素的个数

childNumber(this.selectNodes("skill[end()]").item(0))

二十、selectSingleNode

含义:与selectNodes类似,不同的只返回匹配的第一个结点、而不是结点集合

语法:pNode.selectSingleNode("pattern")

示例:与当前结点同名的元素在其父元素内的个数

childNumber(this.selectSingleNode("../"+this.nodeName+"[end()]"))

当前元素内名字为“skill”的元素的个数

childNumber(this.selectSingleNode("skill[end()]"))

二十一、text

含义:返回结点与它的子树内的文字内容

语法:pNode.text

示例:整个文档内的文字内容

this.ownerDocument.text

当前元素及其子树的文字内容

this.text

二十二、xml

含义:返回结点及其后代的XML表示

语法:pNode.xml

示例:当前文档的XML内容

this.ownerDocument.xml

另有几个函数不作介绍,列于其下以供参考,如感兴趣,请访问http://msdn.microsoft.com获取详细说明。

formatTime(varTime, bstrFormat,varDestLocale) 

formatDate(varDate, bstrFormat,varDestLocale)

apendChild(newChild)

definition

CloneNode

insertBefore(newChild, refChild)

parsed

removeChild(oldChild)

replaceChild(newChild, oldChild)

specified

transformNode(stylesheet)

transformNodeToObject(stylesheet,outputObject) 

uniqueID(pNode)

办公软件知识学习,尽在www.zzzyk.com 电脑知识网

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,