我正在尝试开始使用EXSLT。
这是我的基本 XSL。
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
version="1.0">
<xsl:import href="exsl.xsl" />
<xsl:output method="html" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="yes"/>
<xsl:variable name="main" select="/data"/>
<xsl:template match="/data">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
HTML STARTS
<br/>
<xsl:variable name="metadata" select="document('metadata.xml')"/>
Straight Value of<br/>
<xsl:value-of select="$metadata"/>
Node-set value of <br/>
<xsl:value-of select="exsl:node-set($metadata)/email"/>
<xsl:for-each select="$metadata/Data">
<xsl:variable name="node" select="."/>
<xsl:value-of select="$node"/>
Test<br/>
</xsl:for-each>
</html>
</xsl:template>
</xsl:stylesheet>
我已经从EXSLT网站下载了通用模块。(http://www.exslt.org/exsl/index.html)
该模块的结构为:
基地.cssexsl.xsl/functions/node-set/base.css/functions/node-set/exsl.node-set.xml/functions/object-type/base.css/functions/object-type/exsl.object-type.xml/elements/document/base.css/elements/document/exsl.document.xml(+ 每个文件夹中的一些 html)。
我提取它并将其放在与我的基本 XSL 相同的目录中,以便 exsl.xsl 和我的基本 xsl 位于同一文件夹中。
exsl.xsl 说
<?xml version="1.0" encoding="utf-8"?>
<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/exsl" version="1.1" extension-element-prefixes="exsl" exsl:doc="http://www.exslt.org/exsl">
<import href="node-set/exsl.node-set.xsl"/>
<import href="object-type/exsl.object-type.xsl"/>
</stylesheet>
现在这本身似乎是错误的,因为它没有首先指向函数文件夹。但是,即使我添加了功能:
<import href="functions/node-set/exsl.node-set.xsl"/>
<import href="functions/object-type/exsl.object-type.xsl"/>
我在 XMLSpy 上收到"找不到本地文件"错误。
知道我是如何开始的吗?
如上所述:
引用 EXSLT 命名空间是全部。它们包括在内。
如果你有
<xsl:variable name="metadata" select="document('metadata.xml')"/>
那么根本不需要使用exsl:node-set函数,因为文档函数给你一个节点集。