使用XSLT(错误解析)将SOAP转换为HTML

时间:2019-05-27 10:19:04

标签: xslt soap

我尝试使用XSLT将SOAP响应消息转换为HTML,但不起作用。

'instance'标签具有一些属性,当我检索它们时,我的代码可以正常工作。

我的SOAP响应消息:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
        <RetrieveIncidentListResponse 
            message="Success" 
            returnCode="0" 
            schemaRevisionDate="2018-12-19" 
            schemaRevisionLevel="0" 
            status="SUCCESS" 
            xmlns="http://schemas.hp.com/SM/7" 
            xmlns:cmn="http://schemas.hp.com/SM/7/Common" 
            xmlns:xmime="http://www.w3.org/2005/05/xmlmime" 
            xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xsi:schemaLocation="http://schemas.hp.com/SM/7/Incident.xsd">
            <instance query="" recordid="I003988322 - incident chatBot" uniquequery="number=&quot;I003988322&quot;">
                <TicketID type="String">I003988322</TicketID>
            </instance>
            <instance query="" recordid="I003988323 - incident chatBot" uniquequery="number=&quot;I003988323&quot;">
                <TicketID type="String">I003988323</TicketID>
            </instance>
        </RetrieveIncidentListResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

我的XSLT代码:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:p="http://schemas.hp.com/SM/7"
    exclude-result-prefixes="p">
<xsl:template match="/">
<html>
    <body>
        <table>
            <xsl:for-each select="//p:RetrieveIncidentListResponse/p:instance">
            <tr>
                <td>TicketID : </td><td><xsl:value-of select="p:TicketID"/></td>
            </tr>
            </xsl:for-each>
        </table>
        Nb tickets: <xsl:value-of select="count(//p:RetrieveIncidentListResponse/p:instance)"/>
    </body>
</html>
</xsl:template>
</xsl:stylesheet>

实际结果:

Nb tickets: 0

预期结果:

TicketID :  I003988322
TicketID :  I003988323
Nb tickets: 2

0 个答案:

没有答案