libxslt 是否具有将文档拆分为多个文档的功能? [英] Does libxslt have a feature for splitting a document into multiple documents?

查看:18
本文介绍了libxslt 是否具有将文档拆分为多个文档的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来 libxslt 不支持 XSLT 2.0 和 xsl:result-document.有没有办法使用 libxsltxsltproc 来模拟 xsl:result-document?

Looks like libxslt does not support XSLT 2.0, and xsl:result-document. Is there a way to mimic xsl:result-document using libxslt, or xsltproc?

推荐答案

是的,有,使用 exsl:document.一个简单的例子:

Yes, there is, using exsl:document. A simple example:

==== 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>

以此为输入:

==== foo.html ====
<html>
  <body>
    <h1>Hello, world!</h1>
    <p>Some longwinded text follows.</p>
  </body>
</html>

当这样运行时:

xsltproc foo.xsl foo.html

将把它产生给标准输出:

will yield this to stdout:

<html>
  <body>
    <h1>Hello, world!</h1>
    <p>Some longwinded text follows.</p>
  </body>
</html>

同时将其写入toc.html:

<html><body><h1>Hello, world!</h1></body></html>

这篇关于libxslt 是否具有将文档拆分为多个文档的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆