英文:
How to get multiple files name using xslt
问题
如何使用XSLT获取多个文件名
我正在使用集合函数
<xsl:for-each select="collection('file:///D:/Xlst/Session 06/05-collection/?select=*.xml;recurse=yes')">
英文:
How to get multiple files name using xslt
I am using collection function
<xsl:for-each select="collection('file:///D:/Xlst/Session 06/05-collection/?select=*.xml;recurse=yes')">
答案1
得分: 1
鉴于您使用的collection
查询参数是Saxon特定的,我假设您使用的是某个版本的Saxon。自从Saxon 9.8/2017版本以来,它支持带有XPath 3.1函数的XSLT 3.0,此外还有一个名为uri-collection
的函数,因此在这里可能更容易使用:
<xsl:for-each select="uri-collection('file:///D:/Xlst/Session 06/05-collection/?select=*.xml;recurse=yes')">
<xsl:message expand-text="yes">当前URI:{.};文件名:{tokenize(., '/')[last()]}</xsl:message>
..
<xsl:apply-templates select="doc(.)"/>
..
</xsl:for-each>
但您尚未详细解释您要查找哪些文件名,以及您发布的代码如何失败或使用集合。
英文:
Given that the query parameters to collection
you use are Saxon specific I assume you use some version of Saxon. Saxon since 9.8/2017 supports XSLT 3.0 with XPath 3.1 functions where you additionally have a function uri-collection
so there it might be easier to use
<xsl:for-each select="uri-collection('file:///D:/Xlst/Session 06/05-collection/?select=*.xml;recurse=yes')">
<xsl:message expand-text="yes">Current URI: {.}; file name: {tokenize(., '/')[last()]}</xsl:message>
..
<xsl:apply-templates select="doc(.)"/>
..
</xsl:for-each>
But you haven't explained in detail which file names you are looking for and how your posted code fails or uses the collection.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论