与XPath表达式一起使用的XPath通配符列表。
Index | Wildcard | Expression |
---|---|---|
1) | * | 它用于匹配任何节点。 |
2) | . | 它用于匹配上下文中的当前节点。 |
3) | @* | 它用于匹配任何属性。 |
4) | node() | 它用于匹配任何类型的节点。 |
【XPath通配符】employee.xml
<
?xml version = "1.0"?>
<
?xml-stylesheet type = "text/xsl" href = "http://www.srcmini.com/employee.xsl"?>
<
class>
<
employee id = "001">
<
firstname>
Abhiram<
/firstname>
<
lastname>
Kushwaha<
/lastname>
<
nickname>
Manoj<
/nickname>
<
salary>
15000<
/salary>
<
/employee>
<
employee id = "002">
<
firstname>
Akash<
/firstname>
<
lastname>
Singh<
/lastname>
<
nickname>
Bunty<
/nickname>
<
salary>
25000<
/salary>
<
/employee>
<
employee id = "003">
<
firstname>
Brijesh<
/firstname>
<
lastname>
Kaushik<
/lastname>
<
nickname>
Ballu<
/nickname>
<
salary>
20000<
/salary>
<
/employee>
<
employee id = "004">
<
firstname>
Zoya<
/firstname>
<
lastname>
Mansoori<
/lastname>
<
nickname>
Sonam<
/nickname>
<
salary>
30000<
/salary>
<
/employee>
<
/class>
员工.xsl
<
?xml version = "1.0" encoding = "UTF-8"?>
<
xsl:stylesheet version = "1.0">
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<
xsl:template match = "/">
<
html>
<
body>
<
h2>
Employee <
/h2>
<
xsl:apply-templates select = "class/*" />
<
/body>
<
/html>
<
/xsl:template>
<
xsl:template match = "class/*">
<
xsl:apply-templates select = "@id" />
<
xsl:apply-templates select = "firstname" />
<
xsl:apply-templates select = "lastname" />
<
xsl:apply-templates select = "nickname" />
<
xsl:apply-templates select = "salary" />
<
br />
<
/xsl:template>
<
xsl:template match = "@id">
<
span style = "font-size = 22px;
">
<
xsl:value-of select = "." />
<
/span>
<
br />
<
/xsl:template>
<
xsl:template match = "firstname">
First Name: <
span style = "color:blue;
">
<
xsl:value-of select = "." />
<
/span>
<
br />
<
/xsl:template>
<
xsl:template match = "lastname">
Last Name: <
span style = "color:green;
">
<
xsl:value-of select = "." />
<
/span>
<
br />
<
/xsl:template>
<
xsl:template match = "nickname">
Nick Name: <
span style = "color:red;
">
<
xsl:value-of select = "." />
<
/span>
<
br />
<
/xsl:template>
<
xsl:template match = "salary">
Salary: <
span style = "color:brown;
">
<
xsl:value-of select = "." />
<
/span>
<
br />
<
/xsl:template>
<
/xsl:stylesheet>
输出
文章图片
推荐阅读
- XPath谓词
- XPath绝对路径
- XPath字符串函数
- XPath节点函数
- XPath数字运算符/函数
- XPath布尔运算符
- XPath运算符
- XPath比较运算符
- android uboot config nor flash