XSL函数介绍(1)

来源:互联网 发布:安卓软件源码是什么 编辑:程序博客网 时间:2024/05/01 13:18
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
对于VBScript、JScript增加的方法、属性,以充分发挥XML的优势,用于< XSL:script >、< XSL:eval >标记内表达式的编写或< XSL:if >、< XSL:when >的expr属性。

一、absoluteChildNumber

含义:返回结点相对于它所有的兄弟(不论名字是否相同)的序号

语法:absoluteChildNumber(node)

参数:node ── 对象,欲返回编号的结点。

示例:

1、假定文档结构为:< document >< head/ >< body/ >< /document >,其中document为顶层结点,下述表达式将输出

< XSL:eval >

absoluteChildNumber(this.selectNodes("/document/body").item(0))

< /XSL:eval >

2、确定当前结点相对于其所有兄弟的序号

< XSL:eval >absoluteChildNumber(this)< /XSL:eval >

二、ancestorChildNumber

含义:从给定结点出发根据给定祖先结点名返回最近的祖先结点的序号(相对于同名结点)。如果找不祖先,则返回0。

语法:ancestorChildNumber(bstrNodeName, pNode)

参数:

bstrNodeName ── 字符串。被搜索的祖先结点的名字。

pNode ── 对象。搜索开始位置的结点。

示例:

查找当前结点最近的名为report祖先结点。

ancestorChildNumber("report",this)

三、attributes

含义:返回结点属性的集合

语法:object.attributes

参数:object ── 结点对象

示例:

当前结点属性的个数

this.attributes.length

当前结点第三个属性的值

this.attributs.item(2).value

或this.attributes.item(2).text

或this.attributes(2).text

注意:如果给定的下标大于属性总和减1将出错,第一个属性的下标是0。

四、baseName

含义:返回有名字空间限制的基本名,即不包括名字前缀

语法:object.baseName

参数:object ── 结点对象

示例:当前结点的基本名:this.baseName

五、childNumber

含义:返回结点相对于同名同胞的序号

语法:childNumber(object)

参数:object ─? 岬愣韵?/p>

示例:假定XML文档结构如下

< x >< y >< z >< z/ >< y/ >< /x >

如果当前结点是z ,则childNumber(this)返回1,而absoluteChildNumber(this)返回3。

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击