在流媒体中使用fn:path

问题描述

我有一个累加器,用于XSLT3流样式表中。我想在累加器规则中使用fn:path,但是,出现以下错误

PATH = '/Volumes/gopro8/DCIM/100gopro/' NEW_FILENAME = '/folder/new-file.mp4' video_list = '/folder/ffmpeg-list.txt' # create the text file File.delete(video_list) if File.exist?(video_list) i = 1 Dir.entries(PATH).each do |f| d = File.mtime(PATH + f) size = File.size(PATH + f) if f.match(/GH0.*.MP4/) && d.to_s.match(/2020-07-30/) && size.to_i < 1000000000 puts "#{i}\t#{f}\t#{d}\t#{size}" File.write(video_list,"file #{PATH + f}\n",mode: "a") i= i+1 end end command = "ffmpeg -f concat -safe 0 -i #{video_list} -c copy #{NEW_FILENAME}" puts "executing concatenate..." puts command system(command)

我不明白为什么在这种情况下不能使用path(),因为XSLT流可以访问匹配节点的所有祖先。

The xsl:accumulator-rule/@select expression (or contained sequence constructor) for a streaming accumulator must be grounded and motionless. Operand {.} of {fn:path(...)} selects streamed nodes in a context that allows arbitrary navigation (line XX)

在Saxon EE 9.9.1.7(氧气)上

解决方法

fn:path无法计算位置谓词(例如Q{}foo[2]),因为仅存储祖先而不存储兄弟姐妹。因此fn:path不可流式传输,https://www.w3.org/TR/xslt-30/#classifying-built-in-functionsfn:path() – Equivalent to fn:path(.)fn:path(N)归为“导航”。

https://github.com/martin-honnen/schxslt/blob/release-1.4.6-xslt3-streaming-test/src/main/resources/xslt/3.0-streamable/streaming-utilities/position-accumulator.xsl中,我试图用一些可流动的函数来代替fn:path,这些函数将“位置”存储在累加器中。该代码看起来有些糟糕,需要一些改进,但是在fn:path不起作用的流传输中确实提供了一些有用的结果。

https://xsltfiddle.liberty-development.net/pNmCztr,这是一个简单的测试,它比较fn:path() = mf:path(.)而不进行流传输,因此至少可以获得可比的结果。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...