问题标签 [xslt-3.0]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
2665 浏览

xml - XSLT 3.0 流式传输(撒克逊)

我有一个带有这种树的大 XML 文件(6 GB):

如果我在其上应用 XSLT 样式表,则会出现以下错误:

线程“主”java.lang.OutOfMemoryError 中的异常:Java 堆空间

所以我想尝试新的 XSLT 3.0 功能:流式传输,以及 Saxon 9.6 EE。我不想在文档中有一次流式约束。我认为,我想要做的,非常接近这里描述的“突发模式”:http: //saxonica.com/documentation/html/sourcedocs/streaming/burst-mode-streaming.html

这是我的撒克逊命令行:

java -cp saxon9ee.jar net.sf.saxon.Transform -t -s:input.xml -xsl:stylesheet.xsl -o:output/output.html

这是我的 XSLT 样式表:

但我仍然有同样的内存不足错误。

谢谢您的帮助!

0 投票
1 回答
1520 浏览

xml - XSLT 3.0 部分流式传输 (Saxon)

我有一个带有这种树的大 XML 文件(6 GB):

所以我使用了新的 XSLT 3.0 流功能和 Saxon 9.6 EE。我不想在文档中有一次流式约束。这就是我尝试使用copy-of(). 我认为,我想要做的,非常接近这里描述的“突发模式”:http: //saxonica.com/documentation/html/sourcedocs/streaming/burst-mode-streaming.html

这是我的 XSLT 样式表:

从某种意义上说,它之所以有效,是因为copy-of()我可以xsl:value-of直接在 for-each 中使用几个(就像在这个问题中一样)。(否则我有这个错误 * There are at least two consuming operands: {xsl:value-of} on line 8, and {xsl:value-of} on line 9

但我仍然有流媒体限制,因为<xsl:call-template name="fnc1"/>会产生这个错误:

所以我的问题是:如何进行部分流式传输(文档被一个一个加载但完全加载)以便能够在文档中使用call-template(和其他apply-templates)?

谢谢您的帮助!

0 投票
2 回答
437 浏览

xml - XSLT 3.0 流有哪些实际用例?

这项技术能否有效地用于股票行情、社交媒体流等?XSLT 当前是否用于这些目的中的任何一个?

0 投票
1 回答
267 浏览

xslt - 的孩子不支持“扩展文本”

我在 XSLT3 样式表中使用“扩展文本”。以下 w3.org 注释说“如果 expand-text='yes' 属性在范围内,文本值模板应该应用于 xsl:text 的文本节点子节点”。

http://lists.w3.org/Archives/Public/public-qt-comments/2014Aug/0059.html

这似乎不适用于 Saxon-EE 9.5.1.7。例如:

输出:

也就是说,表达式在外部<xsl:text>而不是内部被正确评估。

Michael Kay 随后回复了上述 w3.org 注释,并评论说“更改已应用”表明它已在 Saxon 的某些版本中得到修复。任何人都可以确认吗?任何提示我需要查看什么版本?

谢谢,乔希。

0 投票
0 回答
253 浏览

xslt - XSLT 3.0: Conditional setting of

I would ordinarily like to set different <xsl:accumulator>s in response to the results of <xsl:if test="foo">.

Problem: <xsl:accumulator> must be a child of <xsl:stylesheet> or <xsl:transform>.

Said another way, the accumulator cannot be in a template where condition tests could be performed.

Question: Is there a way to change accumulator specs at run time, based on what is found in the source document?

The accumulator is similar to:

What I'd like to change at run time based on the source document is the @match="".

Update (response to comments): If the document tests to have a article/div structure, I would like the accumulator @match to be article/div, if the document tests to have section/div structure, I'd want the accumulator @match to be section/div.

Sometimes my documents vary, and like like to adjust on the fly.

0 投票
1 回答
916 浏览

xml - Using xsl:accumulator with xsl:try/xsl:catch

I have very large input document (thousands of Records) that has a structure something like this (Data represents many child elements):

I'm processing it with a stylesheet that performs a complex transform on each Record which could run into many dynamic errors. In this application if a few records have bad data I would prefer not to halt the transform but I would like to know about the errors so I can fix them later. I'm using an xsl:try/xsl:catch to allow the processing to continue:

This works fine, but it's a pain to dig through the large input documents to find the few records that failed. What I'd like to do is write the source of the Record elements that fail to a new Input document using xsl:result-document. I'm trying to add an xsl:accumulator something like this:

However, I can't figure out what the predicate in the xsl:accumulator-rule should be, or if it's even possible to use this pattern. Can a single result document be created without restructuring the stylesheet?

NB: I'm aware of the following solution, but it wasn't my first choice because it seems like it could potentially have much higher memory requirements, but perhaps that isn't true. I could also write all the Records out to individual files but I consider this dangerous because one source document might generate thousands of failures.

0 投票
2 回答
347 浏览

xml - disable-output-escaping="yes" 在 try/catch 中失败

可能是撒克逊人的一个错误,但只是想澄清一下-

结果 -

现在试试——

结果-

关于为什么会发生这种情况的任何想法?

0 投票
1 回答
707 浏览

saxon - XSL-T 3.0 中的 XPath 3.1 如何像 java.text.SimpleDateFormat 一样将自由格式的字符串解析为 DateTime?

我想在 XSL-T 3.0 中将几乎自由格式的字符串解析为 DateTime,因为可以使用 java.text.SimpleDateFormat 在 Java 中完成。可能吗?

我正在使用最新的 Saxon HE 9.7.0.1 for Java 并使用 W3C CR 3.1“XPath and XQuery Functions and Operators 3.1”咨询它。W3C CR 3.1 中有函数“fn:parse-ietf-date”,但它看起来不能像“6.1.94 7:29”那样解析字符串 - 例外:

tr.xsl 的第 20 行第 47 行的 xsl:value-of/@select 中的字符 17 处出错:FORG0010:内置模板规则中的无效 IETF 日期值 6.1.94 7:29(缺少日期分隔符)无效的 IETF 日期值6.1.94 7:29(缺少日期分隔符)

我是否在我的 XSL-T 中犯了任何错误,或者“fn:parse-ietf-date”不支持更多格式的字符串被解析为 DateTime?

如果问题不在我这边,是否可以将 fn:parseTime 之类的函数添加到 W3C CR 3.1 作为 Java 8 java.text.SimpleDateFormat 类的“副本”,并支持其所有日期和时间模式?它可以解决 String 到 DateTime 的解析(我希望永远)。它也已经在 J​​ava 中被发明并被广泛使用。我非常感谢在 Saxon-HE 中实现它,尽管我知道,在我的 XSL-T 脚本中在 Saxon-PE 或 Saxon-EE 中调用 java.text.SimpleDateFormat 应该很容易。

问候, 斯捷潘

我的用例:

壳:

在.xml:

tr.xsl:

0 投票
1 回答
694 浏览

xml - 即使我正在使用流式传输,XSLT 内存不足

我有以下样式表:

我在命令行中运行以下命令:

即使我在样式表中指定了流,我也会收到内存不足错误。

我的 korpus.xml 文件有 3.61 GB 大。

我做错了什么?

0 投票
1 回答
121 浏览

xml - 可能的循环包依赖性 - XSLT 3.0

我第一次尝试 xsl:package 但在命令行上出现错误-

xml(未真正使用)-

package.xsl-

包使用.xsl

在命令行上(使用 saxon 9.7)

返回-

可能的循环包依赖

我尝试使用 Saxon 9.6 对 Oxygen XML 进行类似的转换并得到 java.lang.NullPointerException。