我有来自 web 服务的这个 xml 输出:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<FLNewIndividualID xmlns="http://www.test.com/wsdl/TTypes">
<ObjectType>C1</ObjectType>
<ObjectReference>101000216193</ObjectReference>
<ObjectReference xsi:nil="true"/>
<ObjectReference xsi:nil="true"/>
</FLNewIndividualID>
</soapenv:Body>
</soapenv:Envelope>
我正在尝试提取 ObjectType 和 ObjectReference 所以我有这个 XSLT
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:nsl="http://www.test.com/wsdl/TTypes"
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/env:Envelope/env:Body/nsl:FLNewIndividualID">
<xsl:value-of select="ObjectType"/>-<xsl:value-of select="ObjectReference"/>
</xsl:template>
</xsl:stylesheet>
我只是得到
<?xml version="1.0" encoding="utf-8"?>
结果如果我在结果中添加一个空白属性 xmlns="" 例如。
<ObjectType xmlns="">C1</ObjectType>
<ObjectReference xmlns="">101000216193</ObjectReference>
然后它起作用了,我得到:
<?xml version="1.0" encoding="utf-8"?>
C1-101000216193
有任何想法吗?我无法更改 XML 输出。