【问题标题】:Eclipse producing empty xml output from xsl TransformationEclipse 从 xsl 转换生成空 xml 输出
【发布时间】:2017-02-06 06:09:54
【问题描述】:

我正在使用一本已知书籍的例子。

xml 输入:

<?xml version="1.0" encoding="UTF-8"?>
<reference>
<body>
<title>xsl:stylesheet</title>
<purpose>
<p>The root element of a stylesheet.</p>
</purpose>
<usage>
<p>The <element>stylesheet</element> is always the root element, even if
a stylesheet is included in, or imported into, another. It must have a
<attr>version</attr> attribute, indicating the version of XSLT that the
stylesheet requires.</p>
<p>For this version of XSLT, the value should normally be "2.0". For a
stylesheet designed to execute under either XSLT 1.0 or XSLT 2.0, create a core
module for each version number; then use <element>xsl:include</element> or
<element>xsl:import</element> to incorporate common code, which should specify
<code>version="2.0"</code> if it uses XSLT 2.0 features, or
<code>version="1.0"</code> otherwise.</p>
<p>The <element>xsl:transform</element> element is allowed as a synonym.</p>
<p>The namespace declaration <code>xmlns:xsl="http//www.w3.org/1999/XSL/
Transform</code> by convention uses the prefix <code>xsl</code>.</p>
<p>An element occurring as a child of the <element>stylesheet</element>
element is called a declaration. These top-level elements are all optional, and
may occur zero or more times.</p>
</usage>
</body>
</reference>

用于转换的简单、空 xsl 文件:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
</xsl:stylesheet>

在 Eclipse Neon 上运行上述程序时,(通过选择两个文件并选择 Run As -&gt; XSL Transformation 我得到一个空的 xml 文件(虽然很明显它应该输出所有文本节点(例如 @987654321 的输出) @)

怎么了?

【问题讨论】:

  • 您想知道为什么您的样式表没有评估内置规则以仅输出文本而没有定义模板吗? Build-in Template Rules 或者您想以更合适的方式获取文本输出吗?
  • 在您的&lt;xsl:stylesheet&gt; 中添加&lt;xsl:output method="text" /&gt; 并通过Eclipse Neon 执行。
  • 您显然在使用不符合标准的 XSLT 处理器。你能更准确地识别它吗? stackoverflow.com/questions/25244370/…
  • Apache 软件基金会 (Xalan XSLTC)1.0

标签: xml eclipse xslt xslt-1.0


【解决方案1】:

事实证明,整个事情都与我在同一目录中还有另一个 xslt 文件有关。

Eclipse 显然使用了所谓的转换管道,因此这两个文件都用于转换。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-12
    • 1970-01-01
    • 1970-01-01
    • 2014-07-16
    相关资源
    最近更新 更多