从xml标记中追加变量值,并使用xslt输入xml文件名
我将下面的XML作为输出,并希望动态地将XML中的值连接到XML文件名。XML包含单个ID值,并希望在运行时使用XSLT以XML文件名传递该值 输出1 XMl: 文件名:Output.xml从xml标记中追加变量值,并使用xslt输入xml文件名,xml,xslt,Xml,Xslt,我将下面的XML作为输出,并希望动态地将XML中的值连接到XML文件名。XML包含单个ID值,并希望在运行时使用XSLT以XML文件名传递该值 输出1 XMl: 文件名:Output.xml <Accounts> <customer> <ID>1234</ID> </customer> </Accounts> <Accounts> <customer> <ID>4096<
<Accounts>
<customer>
<ID>1234</ID>
</customer>
</Accounts>
<Accounts>
<customer>
<ID>4096</ID>
</customer>
</Accounts>
1234
输出2 XMl:
文件名:Output.xml
<Accounts>
<customer>
<ID>1234</ID>
</customer>
</Accounts>
<Accounts>
<customer>
<ID>4096</ID>
</customer>
</Accounts>
4096
预期输出文件名:Output_1234.xml
<Accounts>
<customer>
<ID>1234</ID>
</customer>
</Accounts>
1234
预期文件名:Output_4096.xml
<Accounts>
<customer>
<ID>4096</ID>
</customer>
</Accounts>
4096
使用此代码实现所需的输出:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="/">
<xsl:result-document href="{concat(substring-before(tokenize(base-uri(.),'/')[last()], '.xml'),'_', /Accounts/customer/ID,'.xml')}">
<xsl:copy-of select="Accounts"/>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>