如何解决在流媒体中使用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-functions将fn: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(.)
而不进行流传输,因此至少可以获得可比的结果。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。