看起来像libxslt不支持XSLT 2.0,和xsl:result-document.有没有办法模仿xsl:result-document使用libxslt,或xsltproc?
Owe*_* S. 14
是的,有使用exsl:document.一个简单的例子:
==== foo.xsl ====
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl">
<xsl:output method="html"/>
<xsl:template match="/">
<exsl:document href="toc.html" method="html">
<html>
<body>
<xsl:apply-templates select=".//h1"/>
</body>
</html>
</exsl:document>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
以此为输入:
==== foo.html ====
<html>
<body>
<h1>Hello, world!</h1>
<p>Some longwinded text follows.</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当像这样运行时:
xsltproc foo.xsl foo.html
Run Code Online (Sandbox Code Playgroud)
将这个产生给stdout:
<html>
<body>
<h1>Hello, world!</h1>
<p>Some longwinded text follows.</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
同时写这个toc.html:
<html><body><h1>Hello, world!</h1></body></html>
Run Code Online (Sandbox Code Playgroud)