请建议XSLT中的'Collection'函数从'main.xml'中从子目录名称中获取信息,名称以9000系列开头,即 D:/Author-Index/9001/main.xml,D:/Author-Index/9002/main.xml,D:/Author-Index/9003/main.xml,D:/ Author-Index/9009/main。 xml,D:/Author-Index/90nn/main.xml(第n个数字)XSLT:使用xslt从名称9000系列的所有文件夹中收集xml文件Collection
但不是从D:/Author-Index/939/main.xml(因为三位数字文件夹)。
我正在使用collection('file:///D:/AuthorIndex/9[0-9][0-9][0-9]?select=*main.xml;recurse=yes')
找到文件夹名称错误始于9[n][n][n]/main.xml
XML1:d:/Author-Index/9001/main.xml
<article>
<fm>
<title>Journey to Galaxy</title>
<author><snm>Kishan</snm><fnm>TR</fnm></author>
</fm>
<body>
<p>This article explian about Galaxy Journey</p>
</body>
</article>
XML2:d:/作者指数/9002/main.xml
<article>
<fm>
<title>Journey to Mars</title>
<author><snm>Rudramuni</snm><fnm>TP</fnm></author>
</fm>
<body>
<p>This article explian about Mars Journey</p>
</body>
</article>
XSLT:XSLT版本2
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:variable name="varCollection">
<xsl:copy-of select="collection('file:///D:/AuthorIndex/9[0-9][0-9][0-9]?select=*main.xml;recurse=yes')"/>
</xsl:variable>
<xsl:template match="root">
<xsl:for-each select="$varCollection//article">
<xsl:element name="title1"><xsl:value-of select="//fm//title"/></xsl:element>
<xsl:element name="aug">
<xsl:for-each select="//fm//author">
<xsl:element name="au"><xsl:element name="snm"><xsl:value-of select="snm"/></xsl:element><xsl:text> </xsl:text>
<xsl:element name="fnm"><xsl:value-of select="fnm"/></xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
所需的结果:
<article>
<aug>
<au><snm>Kishan</snm><fnm>TR</fnm></au>
<title1>Journey to Galaxy</title1>
<au><snm>Rudramuni</snm><fnm>TP</fnm></au>
<title1>Journey to Mars</title1>
</aug>
</article>
@Mads Hansen先生,非常感谢您的建议。它按要求完美地工作。 –