当前位置: 首页 > 网络学院 > XML相关教程 > XSL/XSLT > XSLT <xsl:import> 元素

XSL/XSLT
XSL 语言
XSLT 介绍
XSLT 浏览器
XSLT 转换
<xsl:template>
<xsl:value-of>
<xsl:for-each>
<xsl:sort>
<xsl:if>
<xsl:choose>
<xsl:apply-templates>
XSLT - 客户端
XSLT - 服务器端
XSLT - 编辑XML
XSLT 摘要
XSLT 元素参考
XSLT 函数
XSL 编辑器

XSL/XSLT 中的 XSLT <xsl:import> 元素


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 264 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The <xsl:import> element is a top-level element that is used to import the contents of one style sheet into another.
<xsl:import>元素是顶级元素,它的作用是将一张样式表中的内容导入到另一张样式表中。

Note: An imported style sheet has lower precedence than the importing style sheet.
注意:一张导入的样式表比主样式表优先级低。

Note: This element must appear as the first child node of <xsl:stylesheet> or <xsl:transform>.
注意:这个元素必须以<xsl:stylesheet>元素或<xsl:transform>元素的第一个子节点形式出现。

Note: Netscape 6 does not support import precedence, so this element will behave equivalent to <xsl:include>.
注意:Netscape 6 不支持“导入优先级”,所以在这个浏览器下,<xsl:import>元素和<xsl:include>完全相同。


Syntax
语法

<xsl:import href="URI"/>

Attributes
属性

属性 描述
href URI Required. Specifies the URI of the style sheet to import
必要参数。指定导入样式表的URl

Example 1
案例1

Suppose you have a style sheet called "cdcatalog_ex3.xsl":
假设你有一张名为"cdcatalog_ex3.xsl"的样式表,具体如下:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Title</th> <th>Artist</th> </tr> <tr> <td><xsl:value-of select="catalog/cd/title"/></td> <td><xsl:value-of select="catalog/cd/artist"/></td> </tr> </table> </body> </html>
</xsl:template>
</xsl:stylesheet>

A second style sheet called "cdcatalog_import.xsl" imports "cdcatalog_ex3.xsl":
第二张样式表为"cdcatalog_import.xsl",并将"cdcatalog_ex3.xsl"导入其中:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="cdcatalog_ex3.xsl"/>
<xsl:template match="/"> <xsl:apply-imports/>
</xsl:template>
</xsl:stylesheet>

查看XML 文件XSL 文件以及结果

Note: This example will not work in Netscape 6 because it does not support the <xsl:apply-imports> element!
注意:Netscape 6不支持该案例,因为它不支持其中的 <xsl:apply-imports> 元素。

评论 (0) All

登陆 | 还没注册?