XSL - 从网络上的目录生成文件列表
XSL - Generating list of files from directory on network
我正在尝试使用 collection
函数列出带有 xsl 的目录文件。它似乎适用于正常用例(在本地目录中搜索),但在网络上搜索路径时失败:例如。 \\name_of_machine\the\path\to\folder
日志错误为:
FODC0002: The file or directory
file:/D:/the/current/location/of/the/executing/xsl/%5C%5Cname_of_machine2%5Cthe%5Cpath%5Cto%5Cfolder does not exist
还有我的代码片段:
<xsl:variable name="docList" select="for $f in collection($dir) return lower-case($f)"/>
所以,基本上,collection
函数是在执行代码的 XSL 文件的当前位置前添加,然后转义所有 \(反斜杠)字符。
如何使用收集功能通过网络检索文件?
编辑:
我正在使用 Saxon-HE 9.8.0-15
我想你可以使用例如<xsl:variable name="doc-list" select="uri-collection('file:////name_of_machine/the/path/to/folder?select=*.xml')"/>
获取 Saxon 9 目录中文件的 URI 列表。我认为表示此类路径的 URI 语法是 file:////name_of_machine/the/path/to/folder
.
此处使用 Saxon 9.8 在 Windows 10 机器上进行的测试给出
java -cp 'C:\Program Files\Saxonica\Saxon9.8HE\saxon9he.jar' net.sf.saxon.Query -t -qs:"uri-collection('file:////machine-name/Users/marti/SomeFolder/xml?select=*.xml')"
Saxon-HE 9.8.0.15J from Saxonica
Java version 1.8.0_252
Analyzing query from {uri-collection('file:////machine-name/Users/marti/SomeFolder/xml?select=*.xml')}
Analysis time: 194.6869 milliseconds
<?xml version="1.0" encoding="UTF-8"?>file:////machine-name/Users/marti/SomeFolder/xml/sample1.xml file:////machine-name/Us
ers/marti/SomeFolder/xml/sample2.xml
我正在尝试使用 collection
函数列出带有 xsl 的目录文件。它似乎适用于正常用例(在本地目录中搜索),但在网络上搜索路径时失败:例如。 \\name_of_machine\the\path\to\folder
日志错误为:
FODC0002: The file or directory
file:/D:/the/current/location/of/the/executing/xsl/%5C%5Cname_of_machine2%5Cthe%5Cpath%5Cto%5Cfolder does not exist
还有我的代码片段:
<xsl:variable name="docList" select="for $f in collection($dir) return lower-case($f)"/>
所以,基本上,collection
函数是在执行代码的 XSL 文件的当前位置前添加,然后转义所有 \(反斜杠)字符。
如何使用收集功能通过网络检索文件?
编辑: 我正在使用 Saxon-HE 9.8.0-15
我想你可以使用例如<xsl:variable name="doc-list" select="uri-collection('file:////name_of_machine/the/path/to/folder?select=*.xml')"/>
获取 Saxon 9 目录中文件的 URI 列表。我认为表示此类路径的 URI 语法是 file:////name_of_machine/the/path/to/folder
.
此处使用 Saxon 9.8 在 Windows 10 机器上进行的测试给出
java -cp 'C:\Program Files\Saxonica\Saxon9.8HE\saxon9he.jar' net.sf.saxon.Query -t -qs:"uri-collection('file:////machine-name/Users/marti/SomeFolder/xml?select=*.xml')"
Saxon-HE 9.8.0.15J from Saxonica
Java version 1.8.0_252
Analyzing query from {uri-collection('file:////machine-name/Users/marti/SomeFolder/xml?select=*.xml')}
Analysis time: 194.6869 milliseconds
<?xml version="1.0" encoding="UTF-8"?>file:////machine-name/Users/marti/SomeFolder/xml/sample1.xml file:////machine-name/Us
ers/marti/SomeFolder/xml/sample2.xml