♣
初学xml的小题,,答对就有分哟!!!!
///////////////
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test2.xsl"?>
<test>
<x a="1">
<x a="2" b="b">
<x>
<y>y31</y>
<y>y32</y>
</x>
</x>
</x>
</test>
/////////////////////
test2.xsl
<?xml version=1.0?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/xsl/transform">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<!-- suppress text nodes not covered in subsequent template rule. -->
<xsl:template match="text()"/>
<!-- handles a generic element node. -->
<xsl:template match="*">
<xsl:element name="{name()}">
<xsl:apply-templates select="*|@*" />
<xsl:if test="text()">
<xsl:value-of select="."/>
</xsl:if>
</xsl:element>
</xsl:template>
<!-- handles a generic attribute node. -->
<xsl:template match="@*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
结果为:y31 y32
去掉<!-- handles a generic attribute node. -->
<xsl:template match="@*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
时结果为:12by31 y32 有谁能解释上面这一段的起什么作用吗,?/
2:
| 为 union的意思 ,相当于和的意思了,对不对,与其它语言的意思不同了?
eg:
expression: first-name | last-name
refers to : a node set containing <first-name> and <last-name>
elements in the current context.
////////////////
3::::
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test2.xsl"?>
<test>
<x a="1">
<x a="2">
<x>
<y>y31</y>
<y>y32</y>
</x>
</x>
</x>
<x a="1">
<x a="2">
<y>y21</y>
<y>y22</y>
</x>
</x>
<x a="1">
<y>y11</y>
<y>y12</y>
</x>
<x>
<y>y03</y>
<y>y04</y>
</x>
</test>
<?xml version=1.0?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/xsl/transform">
<xsl:output method="text" />
<xsl:template match="/">
<xsl:value-of select="count(//x)"/>
<xsl:value-of select="count(//x[1])"/>
<xsl:value-of select="count(//x/y)"/>
<xsl:value-of select="count(//x/y[1])"/>
<xsl:value-of select="count(//x[1]/y[1])"/>
</xsl:template>
</xsl:stylesheet>
谁能解释一下这为什么是74842
· 网友精彩回答:
首先,你要先了解一下那段xsl的功能,它其实只是将xml再复制一遍。
<xsl:template match="@*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
该模板匹配所有属性节点,功能是添加该属性。换句话说,就是复制属性。也就是
<x a="1">
的
a="1"
| 为 union的意思 ? 对。
上例中的意思为,当前节点下的所有的子元素节点和属性节点。
count是计数的意思,count(//x)就是统计所有的x个数。
count(//x[1])是所有x位置为1的节点个数。
count(//x/y)是所有x下的y的个数。
其他类似。详细参考xpath。
- 更多问题:
- · 帮忙指点一下 在线等结果 先谢谢了~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
- · xsl页面中的javascript 函数的调用问题,急啊!!!!!!!!!!!!!!!!!!
- · VB 中怎么把JPG文件转化成BMP文件
- · 关于DLL与EXE之间的通信问题
- · 指针悬挂问题 谢谢大家帮忙
- · 和delphi以及C++ builder相比,VC的socket接口的不同,救急!!!
- · -1的16进制?
- · 求《UNIX网络编程.卷1〉的中文pdf电子版!!!!!!!!!
- · 如何让出现<单击此处填加标题>啊...
- · 100 分。。错误的过程?谁帮我看看?
- · 急!!!有哪位大哥教我如何实现JPEG2000的ROI编码啊
- · 关于新闻搜索的网站,望大家多多指教
- · 怎么向oracle数据库中添加大于4000字节的数据?
- · 今天搭车回家,公车上碰到两个成熟美少妇一起,坐我旁边,有说有笑,好诱惑啊,身材真好,唉.....两个都167高的样子
- · 应用程序
- · 关于数据输入的问题~~~高手指点一下
- · Tomcat技术文档
- · 汇编相关 | 汇编
- · explorer相关问题
- · sco专题
- · soa专题 | soa
- · Solaris专题
- · ntfs文件
- · 入侵xp
- · 改mac
- · dns服务
- · mac mini
- · pdf转换工具
- · borland starteam
- · bios升级
- · php后门
- · 龙域
- · flash播放器下载
- · 漂亮的qq空间透明flash大放送
- · flash特效
- · flash.ocx删不了?
- · 如何制作flash
- · 在vc6.0 or .net里面使用ado功能
- · auto病毒,怎么清除
- · 瑞星病毒库

