搏软狂歌
拼搏之中,我歌我狂!
博客园
首页
新随笔
联系
订阅
管理
随笔 - 124 文章 - 0 评论 - 511 trackbacks - 9
<
2004年8月
>
日
一
二
三
四
五
六
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
与我联系
发短消息
搜索
常用链接
我的随笔
我的空间
我的短信
我的评论
更多链接
我的参与
我的新闻
最新评论
我的标签
留言簿
(10)
给我留言
查看留言
我参加的小组
博皮小组
我参与的团队
Ajax&Atlas技术团队(0/1138)
随笔分类
Ajax(3)
DataBase(4)
DotNet(34)
Visual Basic(8)
Visual C++(1)
WEB开发(31)
不用墨水的作品(9)
我来说两句儿(38)
随笔档案
2008年2月 (2)
2007年9月 (1)
2007年8月 (2)
2007年6月 (1)
2006年9月 (8)
2006年8月 (1)
2006年7月 (1)
2006年5月 (3)
2006年4月 (2)
2006年3月 (2)
2006年2月 (3)
2006年1月 (1)
2005年12月 (2)
2005年9月 (1)
2005年8月 (4)
2005年7月 (3)
2005年6月 (1)
2005年5月 (10)
2005年4月 (2)
2005年3月 (1)
2005年2月 (5)
2005年1月 (2)
2004年12月 (5)
2004年10月 (2)
2004年9月 (2)
2004年8月 (20)
2004年7月 (16)
2004年6月 (21)
相册
天津程序员[聚]照
收藏夹
Desktop 开发技巧(3)
WEB 开发技巧(13)
杂项收集(2)
博客链接
ceocio
Realize .NET Potential
ScottGu's Blog
ScottGu博客中文版
Think Different and Think More
宝玉
蝈蝈俊
孔曰成仁,孟曰取E
灵感之源
迷失网络
木野狐的 Web Log
思归呓语
技术站点
Ajaxian
C# Corner
CodeGuru
CSS Reboot
DotNetJunkies
Got Dot Net
JavaScript Kit
MVPs.org
Planet Source Code
Regular Expression Library
TechNet 中文站点
The Code Project
The Programmer's File Format Collection
TheServerSide.NET
TopXML
vbAccelerator.com
VC学习教程
VC知识库
W3schools
WebFX
动网新闻系统 → 技术文章
符合W3C标准的CSS布局站点集
孟宪会之精彩世界
面向Mozilla开发
社区推荐
ASP.NET Forums
ASP.NET Forums
Code Comments
CSDN社区
kbAlertz!
Microsoft Search Engine for Microsoft Server Content
Sourceforge.net
博客堂
微软中国社区
问专家
积分与排名
积分 - 172372
排名 - 209
最新评论
1. re: FCKeditor2.2+ASP.NET2.0不完全攻略
请问下出现说:error loarding /FCKeditor/fckstyles.xml是什么问题啊~
--424
阅读排行榜
1. 最新BT网站网址大全
2. FCKeditor2.2+ASP.NET2.0不完全攻略(10667)
3. 西城男孩(Westlife)全集(10624)
4. 激动不已的IIS7.0!(7454)
5. SHTML - SSI技术[收藏](6748)
评论排行榜
1. FCKeditor2.2+ASP.NET2.0不完全攻略(66)
2. 西城男孩(Westlife)全集(42)
3. C#利用CDOSYS组件发邮件的一些小结(39)
4. 很难受(36)
5. 激动不已的IIS7.0!(27)
2004年8月16日
XSLT实现XML无极限树(精简版)[二] 解决没有递归出节点属性值总和的问题(JS实现)
XML数据源文件和第一版的一样!
这个XSLT解决没有递归出节点属性值总和的问题
不过是借助JS实现的
不管怎么样,问题算是解决了!
<
xsl:stylesheet
version
="1.0"
xmlns:xsl
="http://www.w3.org/1999/XSL/Transform"
>
<!--
这个名称空间可以使用output,但是IE5不可解析
-->
<!--
推荐使用环境,MSIE6,MSXML4.0
-->
<
xsl:output
method
="html"
version
="4.0"
encoding
="GB2312"
/>
<
xsl:template
match
="/"
>
<
html
>
<
head
>
<
title
>
XMLTREE
</
title
>
<
style
>
<
xsl:comment
>
<![CDATA[
h1
{
display:list-item;
padding:2px;
list-style:none;
}
span.clsP
{
list-style-type:square;
color:#222;
}
span.clsC
{
list-style-type:disc;
color: #00b;
}
span
{
padding: 2px;
font: 9pt;
cursor: default;
text-decoration:none;
margin: 0px;
margin-left: 16px;
}
div
{
margin-left: 18px;
border-left: 1px solid #ddd;
border-bottom:1px solid;
border-bottom-color:expression(document.bgColor);
display:block;
}
]]>
</
xsl:comment
>
</
style
>
</
head
>
<
body
onselectstart
="return false;"
>
<
xsl:call-template
name
="NextPID"
>
<
xsl:with-param
name
="mPID"
>
-1
</
xsl:with-param
>
<
xsl:with-param
name
="mNum"
>
0
</
xsl:with-param
>
</
xsl:call-template
>
</
body
>
<
script
language
="javascript"
>
<
xsl:comment
>
<![CDATA[
//************************************************
//
// 解决没有递归出节点属性值总和的问题
//
//************************************************
var i, j, nodesum;
//因为提前把一个根下的所有孩子都方在一个DIV内
//所以把这些DIV都找出来就可以找到一个根下的所有孩子了
var objs = document.body.getElementsByTagName("DIV");
for(i = 0; i < objs.length; i++)
{
var obj = objs[i];
// 找到这些孩子的父亲
var nobj = document.getElementById("snode" + obj.id.replace("node",""));
// 初始根节点下孩子总和的值为此节点附有的同属性的值
nodesum = parseInt(nobj.mc, 10);
// 所有带有目标属性的同宗的孩子
var spanobjs = obj.getElementsByTagName("SPAN");
for(j in spanobjs)
{
if(spanobjs[j].mc) // 去除一些干扰
nodesum += parseInt(spanobjs[j].mc, 10); // 累加
}
// 可以写祖宗的innerText了!成功!
nobj.innerText += "(" + (nodesum) + ")";
}
// 就这样,把所有需要计算的东西都放到Client去做
// 服务器应该尽可能闲下来休息一下的
]]>
</
xsl:comment
>
</
script
>
</
html
>
</
xsl:template
>
<
xsl:template
name
="NextPID"
>
<
xsl:param
name
="mPID"
/>
<
xsl:param
name
="mNum"
/>
<
xsl:for-each
select
="//Troot/Item[@pid = $mPID]"
>
<
xsl:sort
select
="count(//Troot/Item[@pid = current()/@id])"
order
="descending"
data-type
="number"
/>
<!--
首先按拥有孩子的数量来排序
-->
<
xsl:sort
select
="@id"
order
="ascending"
/>
<
xsl:choose
>
<
xsl:when
test
="count(//Troot/Item[@pid = current()/@id]) > 0"
>
<!--
有孩子的节点
-->
<
h1
>
<
span
class
="clsP"
>
<
xsl:attribute
name
="id"
>
snode
<
xsl:value-of
select
="@id"
/></
xsl:attribute
>
<
xsl:attribute
name
="mc"
>
<
xsl:value-of
select
="@c"
/>
</
xsl:attribute
>
<
xsl:value-of
select
="."
/>
<!--
[下属节点数:<xsl:value-of select="format-number(count(//Troot/Item[@pid = current()/@id]),'00')" />]
-->
</
span
>
</
h1
>
<
div
>
<
xsl:attribute
name
="id"
>
node
<
xsl:value-of
select
="@id"
/></
xsl:attribute
>
<
xsl:call-template
name
="NextPID"
>
<
xsl:with-param
name
="mPID"
>
<
xsl:value-of
select
="@id"
/>
</
xsl:with-param
>
<
xsl:with-param
name
="mNum"
>
<
xsl:value-of
select
="$mNum + @c"
/>
</
xsl:with-param
>
</
xsl:call-template
>
</
div
>
</
xsl:when
>
<
xsl:otherwise
>
<!--
孤单的节点
-->
<
h1
>
<
span
class
="clsC"
>
<
xsl:attribute
name
="snode"
>
<
xsl:value-of
select
="@id"
/>
</
xsl:attribute
><
xsl:attribute
name
="mc"
>
<
xsl:value-of
select
="@c"
/>
</
xsl:attribute
>
<
xsl:value-of
select
="."
/>
(
<
xsl:value-of
select
="@c"
/>
)
</
span
>
</
h1
>
</
xsl:otherwise
>
</
xsl:choose
>
</
xsl:for-each
>
</
xsl:template
>
</
xsl:stylesheet
>
<!--
最终版权归 DSclub(任兀)拥有,您可以在未授权的情况下使用,但请保留此信息
-->
<!--
EMail:dsclub@hotmail.com
QQ:9967030
Nick Name: DSclub(兀儿-干部)
姓名:任兀
性别:男生(未婚哦)
-->
posted @
2004-08-16 23:56
搏软狂歌 阅读(804) |
评论 (0)
|
编辑
XSLT实现XML无极限树(精简版)[一]代码少,传输好!
摘要: 数据文件:xmltree.xml<?xmlversion="1.0"encoding="GB2312"?><?xml-stylesheettype="text/xsl"href="style.xsl"?><Troot><Itemid="1"pid="0"c="1">大学</Item><Itemid="2"pid="0"c="3"&g...
阅读全文
posted @
2004-08-16 18:48
搏软狂歌 阅读(1520) |
评论 (7)
|
编辑
用XSLT实现的“斐波那契数列”
数据源XML,data.xml
<?
xml version="1.0" encoding="GB2312"
?>
<?
xml-stylesheet type="text/xsl" href="style.xslt"
?>
<
Root
>
<
Troot
>
0
</
Troot
>
<
Troot
>
1
</
Troot
>
<
Troot
>
2
</
Troot
>
<
Troot
>
3
</
Troot
>
<
Troot
>
4
</
Troot
>
<
Troot
>
5
</
Troot
>
<
Troot
>
6
</
Troot
>
<
Troot
>
7
</
Troot
>
<
Troot
>
8
</
Troot
>
<
Troot
>
9
</
Troot
>
<
Troot
>
10
</
Troot
>
<
Troot
>
11
</
Troot
>
<
Troot
>
12
</
Troot
>
<
Troot
>
13
</
Troot
>
<
Troot
>
14
</
Troot
>
<
Troot
>
15
</
Troot
>
<
Troot
>
16
</
Troot
>
<
Troot
>
17
</
Troot
>
<
Troot
>
18
</
Troot
>
<
Troot
>
19
</
Troot
>
<
Troot
>
20
</
Troot
>
</
Root
>
以下是XSLT的实现,style.xslt
<?
xml version="1.0" encoding="GB2312"
?>
<
xsl:stylesheet
version
="1.0"
xmlns:xsl
="http://www.w3.org/1999/XSL/Transform"
>
<
xsl:output
method
="html"
version
="4.0"
encoding
="GB2312"
/>
<
xsl:template
match
="/"
>
<
html
>
<
head
>
<
title
>
XSLT版本斐波那契数列
</
title
>
<
style
type
="text/css"
>
<
xsl:comment
>
<![CDATA[
span
{
font:9pt;
color:#999;
display:list-item;
list-style:none;
}
]]>
</
xsl:comment
>
</
style
>
</
head
>
<
body
>
<
span
>
斐波那契数列:
</
span
>
<
xsl:for-each
select
="Root/Troot"
>
<
span
>
当n =
<
xsl:value-of
select
="."
disable-output-escaping
="no"
/>
时,结果:
<
xsl:call-template
name
="fun"
>
<
xsl:with-param
name
="n"
select
="."
/>
</
xsl:call-template
>
</
span
>
</
xsl:for-each
>
</
body
>
</
html
>
</
xsl:template
>
<
xsl:template
name
="fun"
>
<
xsl:param
name
="n"
/>
<
xsl:choose
>
<
xsl:when
test
="$n <= 1"
>
<
xsl:value-of
select
="1"
disable-output-escaping
="no"
/>
</
xsl:when
>
<
xsl:otherwise
>
<
xsl:variable
name
="ni"
>
<
xsl:call-template
name
="fun"
>
<
xsl:with-param
name
="n"
select
="$n - 1"
/>
</
xsl:call-template
>
</
xsl:variable
>
<
xsl:variable
name
="nii"
>
<
xsl:call-template
name
="fun"
>
<
xsl:with-param
name
="n"
select
="$n - 2"
/>
</
xsl:call-template
>
</
xsl:variable
>
<
xsl:value-of
select
="number($nii) + number($ni)"
/>
</
xsl:otherwise
>
</
xsl:choose
>
</
xsl:template
>
</
xsl:stylesheet
>
主要是为了验证XSLT中的template是可递归的,也可以类似一般函数一样有“返回值”,通过Variable。
不过,这个Variable实在是有些不通人情的,只能赋值一次,不可再做改动了!
posted @
2004-08-16 09:44
搏软狂歌 阅读(657) |
评论 (3)
|
编辑