在我的一个xml有效内容中我需要在下面一行之后添加一个名称空间。使用XSLT添加名称空间
<?xml version="1.0" encoding="UTF-8"?>
<ep:Document xmlns:ep="namespace here"
xmlns:gk="namespace here"
xmlns:sh="namespace here" schemaVersion="" creationDate="">
在此之后我NEDD添加的命名空间的xmlns:XSI = “http://www.w3.org/2001/XMLSchema-instance”>
预期的输出应该
<?xml version="1.0" encoding="UTF-8"?>
<ep:Document xmlns:ep="namespace here"
xmlns:gk="namespace here"
xmlns:sh="namespace here" schemaVersion="" creationDate=""xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
请问您可以帮忙。 让我详细说明我的要求。在实际的输入消息中,我正在获取没有任何名称空间的有效内容。它看起来像下面。
<?xml version="1.0" encoding="UTF-8"?>
<document>
</document>
在b/w文件中我们有剩余的有效载荷。
之后,我已经使用XSLT代码在有效负载中添加名称空间和前缀。下面的 是我的XSLT代码。
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ep="namespace here"
xmlns:sh="namespace here"
xmlns:gk="namespace here">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Document">
<ep:Document>
<xsl:apply-templates select="node()|@*"/>
</ep:Document>
</xsl:template>
<xsl:template match="Extension|Extension//*">
<xsl:element name="gk:{name()}">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>
<xsl:template match="Header|Header//*">
<xsl:element name="sh:{name()}">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:stylesheet>
使用此代码我收到看起来像下面的输出后。
<?xml version="1.0" encoding="UTF-8"?>
<ep:Document xmlns:ep="namespace here"
xmlns:gk="namespace here"
xmlns:sh="namespace here" schemaVersion="" creationDate="">
和其余payload.so我需要在现有的代码中的架构版本和creationdate后面多一个命名空间,如后面提到的。
我们需要查看您现有的XSLT - 至少是处理'ep:Document'元素的部分。请注意,这是(另一个)多余的要求:如果您的输出需要绑定xsi前缀,那么您的处理器会自动包含它(或发生错误)。 –
让我详细说明我的要求。在实际的输入有效载荷中,我得到没有任何命名空间的消息。 –
我编辑了我的问题。请找到详细信息。 –