本文概述
- 参数说明
- XSLT < xsl:import> 元素示例
<
xsl:import href = "http://www.srcmini.com/uri">
<
/xsl:import>
参数说明 href:用于提供要导入的xslt样式表的路径。
XSLT < xsl:import> 元素示例 让我们以创建一个< employee> 元素的列表为例, 该元素的属性为” id” , 其子元素< firstname> , < lastname> , < nickname> 和< salary> 遍历每个员工。在此示例中, 我们创建了两个xsl样式表, 其中employee_import.xsl样式表导入employee.xsl, 而employee.xml链接到employee_import.xsl。
employee.xml
<
?xml version = "1.0"?>
<
?xml-stylesheet type = "text/xsl" href = "http://www.srcmini.com/employee_import.xsl"?>
<
class>
<
employee id = "001">
<
firstname>
Aryan<
/firstname>
<
lastname>
Gupta<
/lastname>
<
nickname>
Raju<
/nickname>
<
salary>
30000<
/salary>
<
/employee>
<
employee id = "024">
<
firstname>
Sara<
/firstname>
<
lastname>
Khan<
/lastname>
<
nickname>
Zoya<
/nickname>
<
salary>
25000<
/salary>
<
/employee>
<
employee id = "056">
<
firstname>
Peter<
/firstname>
<
lastname>
Symon<
/lastname>
<
nickname>
John<
/nickname>
<
salary>
10000<
/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>
<
table border = "1">
<
tr bgcolor = "pink">
<
th>
ID<
/th>
<
th>
First Name<
/th>
<
th>
Last Name<
/th>
<
th>
Nick Name<
/th>
<
th>
Salary<
/th>
<
/tr>
<
xsl:for-each select = "class/employee">
<
tr>
<
td>
<
xsl:value-of select = "@id"/>
<
/td>
<
td>
<
xsl:value-of select = "firstname"/>
<
/td>
<
td>
<
xsl:value-of select = "lastname"/>
<
/td>
<
td>
<
xsl:value-of select = "nickname"/>
<
/td>
<
td>
<
xsl:value-of select = "salary"/>
<
/td>
<
/tr>
<
/xsl:for-each>
<
/table>
<
/body>
<
/html>
<
/xsl:template>
<
/xsl:stylesheet>
Employee_import.xsl:
<
?xml version = "1.0" encoding = "UTF-8"?>
<
xsl:stylesheet version = "1.0"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<
xsl:import href = "http://www.srcmini.com/employee.xsl"/>
<
xsl:template match = "/">
<
xsl:apply-imports/>
<
/xsl:template>
<
/xsl:stylesheet>
【XSLT xsl(import元素)】输出
文章图片
推荐阅读
- XSLT xsl(message元素)
- XSLT xsl(key元素)
- poj 2385 Apple Catching(记录结果再利用的动态规划)
- react-native Android 全面屏手机 底部留有一大块黑屏
- 专题(“今日校园” App 用户体验分析)
- 社交电商模式商城APP开发分析
- 解决在Android设备播放音频与其他应用重音的问题,并监听耳机的控制按钮
- Mapper与Reducer浅析
- Android使用https与服务器交互的正确姿势