在我的场景中,我希望使用xslt在主xml (insert.xml)中插入或追加(source.xml)。命名空间是这里的关键约束之一,source.xml包含insert.xml拥有的所有名称空间。
我的源文件如下所示(见下文)
source.xml :
我的插入文件如下所示(见下文)
Insert.xml
我想要这样的输出(见下面)
预期输出:
我的xsl文件如下所示(见下文)
Xsl文件:
我得到的输出如下xslt输出:
发布于 2022-02-09 20:17:47
我想你想
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"
xpath-default-namespace="http://mynamespace.com/request/wrapper/2022"
xmlns:tns1="http://mynamespace.com/request/2022"
xmlns:tns2="http://mynamespace.com/clientresponse/2022"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs">
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="Requests/Request/Data">
<xsl:next-match/>
<xsl:apply-templates select="document('insert.xml')/tns1:ServiceResponse/tns1:ClientList"/>
</xsl:template>
<xsl:template match="tns1:*">
<xsl:element name="tns1:{local-name()}" namespace="{namespace-uri()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="tns2:*">
<xsl:element name="tns2:{local-name()}" namespace="{namespace-uri()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>https://stackoverflow.com/questions/71055491
复制相似问题