如何获取具有命名空间的子节点值?
How to get child node value which has namespace on it?
我完全不熟悉 XSLT,我的目标是从其上具有名称空间的节点检索值。我的 XML 如下所示。
<WBIFNMsg>
<AppData>
<AppName>INFM</AppName>
<MsgType>Notification</MsgType>
<MsgStatus>Success</MsgStatus>
</AppData>
<AppMsg>
<Document xmlns="urn:swift:xsd:setr.010.001.03">
<SbcptOrdrV03>
<MsgId>
<Id>29331095XXXXML</Id>
<CreDtTm>2019-06-07T10:30:43.681+02:00</CreDtTm>
</MsgId>
</SbcptOrdrV03>
</Document>
</AppMsg>
</WBIFNMsg>
我正在尝试通过 xslt 获取 document/SbcptOrdrV03/MsgId/ 下的 Id 标记的值。由于文档标签具有命名空间,我已将其包含在我的 xslt 中,但我仍然无法检索到该值。
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:b="urn:swift:xsd:setr.010.001.03" exclude-result-prefixes="b">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<data>
<messageDataApps>
<field>
<fieldName>SENDER.STP</fieldName>
<value>
<xsl:value-of select="b:WBIFNMsg/b:AppMsg/b:Document/b:SbcptOrdrV03/b:MsgId/b:id"/>
</value>
</field>
</messageDataApps>
</data>
</xsl:template>
</xsl:stylesheet>
如果有人可以提供帮助,我们将不胜感激。提前致谢。
只有 Document
及其后代在命名空间中,并且在寻址时需要使用前缀。而不是:
<xsl:value-of select="b:WBIFNMsg/b:AppMsg/b:Document/b:SbcptOrdrV03/b:MsgId/b:id"/>
尝试:
<xsl:value-of select="WBIFNMsg/AppMsg/b:Document/b:SbcptOrdrV03/b:MsgId/b:Id"/>
另请注意 XML 区分大小写:b:id
与 b:Id
不同。
我完全不熟悉 XSLT,我的目标是从其上具有名称空间的节点检索值。我的 XML 如下所示。
<WBIFNMsg>
<AppData>
<AppName>INFM</AppName>
<MsgType>Notification</MsgType>
<MsgStatus>Success</MsgStatus>
</AppData>
<AppMsg>
<Document xmlns="urn:swift:xsd:setr.010.001.03">
<SbcptOrdrV03>
<MsgId>
<Id>29331095XXXXML</Id>
<CreDtTm>2019-06-07T10:30:43.681+02:00</CreDtTm>
</MsgId>
</SbcptOrdrV03>
</Document>
</AppMsg>
</WBIFNMsg>
我正在尝试通过 xslt 获取 document/SbcptOrdrV03/MsgId/ 下的 Id 标记的值。由于文档标签具有命名空间,我已将其包含在我的 xslt 中,但我仍然无法检索到该值。
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:b="urn:swift:xsd:setr.010.001.03" exclude-result-prefixes="b">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<data>
<messageDataApps>
<field>
<fieldName>SENDER.STP</fieldName>
<value>
<xsl:value-of select="b:WBIFNMsg/b:AppMsg/b:Document/b:SbcptOrdrV03/b:MsgId/b:id"/>
</value>
</field>
</messageDataApps>
</data>
</xsl:template>
</xsl:stylesheet>
如果有人可以提供帮助,我们将不胜感激。提前致谢。
只有 Document
及其后代在命名空间中,并且在寻址时需要使用前缀。而不是:
<xsl:value-of select="b:WBIFNMsg/b:AppMsg/b:Document/b:SbcptOrdrV03/b:MsgId/b:id"/>
尝试:
<xsl:value-of select="WBIFNMsg/AppMsg/b:Document/b:SbcptOrdrV03/b:MsgId/b:Id"/>
另请注意 XML 区分大小写:b:id
与 b:Id
不同。