Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从xml标记中追加变量值,并使用xslt输入xml文件名_Xml_Xslt - Fatal编程技术网

从xml标记中追加变量值,并使用xslt输入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<

我将下面的XML作为输出,并希望动态地将XML中的值连接到XML文件名。XML包含单个ID值,并希望在运行时使用XSLT以XML文件名传递该值

输出1 XMl:

文件名:Output.xml

<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>