我正在尝试将此SOAP响应转换为简单的HTML:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<Players xmlns="http://ws.wso2.org/dataservice">
<Player>
<name>ATP</name>
<ranking>1</ranking>
<first_name>Novak</first_name>
<last_name>Djokovic</last_name>
<country>RS</country>
<email>novak@aaa.net</email>
</Player>
<Player>
<name>ATP</name>
<ranking>2</ranking>
<first_name>Andy</first_name>
<last_name>Murray</last_name>
<country>GB</country>
<email>andy@bbb.net</email>
</Player>
<Player>
<name>ATP</name>
<ranking>3</ranking>
<first_name>Viktor</first_name>
<last_name>Troicki</last_name>
<country>US</country>
<email>viktor@ccc.com</email>
</Player>
</Players>
</soapenv:Body>
</soapenv: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://ws.wso2.org/dataservice"
exclude-result-prefixes="p">
<xsl:template match="/">
<html>
<body>
<h2>PLAYER RANKINGS</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">Ranking</th>
<th style="text-align:left">First Name</th>
<th style="text-align:left">Last Name</th>
<th style="text-align:left">Country</th>
</tr>
<xsl:for-each select="//p:Players/Player">
<tr>
<td><xsl:value-of select="p:ranking"/></td>
<td><xsl:value-of select="p:first_name"/></td>
<td><xsl:value-of select="p:last_name"/></td>
<td><xsl:value-of select="p:country"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我正在“玩”这个简单的任务很长一段时间,但不能使它与for循环中的select表达式匹配。
我尝试使用和不使用命名空间,但没有运气。
答案 0 :(得分:1)
你错过了命名空间。尝试
<xsl:for-each select="//p:Players/p:Player">