这是我的回复信息:
<?xml version="1.0" encoding="UTF-16"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<QueryMXCPISResponse baseLanguage="EN"
creationDateTime="2014-11-25T11:56:09+01:00"
maximoVersion="7 5 20130829-1209 V7510--1"
messageID="1416912970550686680" rsCount="3" rsStart="0"
rsTotal="3" transLanguage="EN"
xmlns="http://www.ibm.com/maximo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MXCPISSet>
<CPIS>
<AK>D</AK>
<CPISID>630124</CPISID>
<ORGID>01</ORGID>
<S1>0</S1>
<S2>0</S2>
<S3>0</S3>
<S4>0</S4>
<S5>0</S5>
<S6>1</S6>
<SHIFT>3</SHIFT>
<SHIFTDATE>2014-09-30T00:00:00+02:00</SHIFTDATE>
<SITEID>0030</SITEID>
<STATUS>NEW</STATUS>
<TEAM>C</TEAM>
<WP>LC11</WP>
<ASSET>
<ASSETNUM>LC11</ASSETNUM>
<LOCATION>FACILITY-1</LOCATION>
<SITEID>0030</SITEID>
</ASSET>
</CPIS>
<CPIS>
<AK>D</AK>
<CPISID>630121</CPISID>
<ORGID>01</ORGID>
<S1>0</S1>
<S2>0</S2>
<S3>1</S3>
<S4>0</S4>
<S5>0</S5>
<S6>1</S6>
<SHIFT>1</SHIFT>
<SHIFTDATE>2014-09-30T00:00:00+02:00</SHIFTDATE>
<SITEID>0030</SITEID>
<STATUS>CHECKED</STATUS>
<TEAM>B</TEAM>
<WP>LC11</WP>
<ASSET>
<ASSETNUM>LC11</ASSETNUM>
<LOCATION>FACILITY-1</LOCATION>
<SITEID>0030</SITEID>
</ASSET>
</CPIS>
<CPIS>
<AK>D</AK>
<CPISID>630122</CPISID>
<ORGID>01</ORGID>
<S1>1</S1>
<S2>1</S2>
<S3>0</S3>
<S4>0</S4>
<S5>0</S5>
<S6>1</S6>
<SHIFT>2</SHIFT>
<SHIFTDATE>2014-09-30T00:00:00+02:00</SHIFTDATE>
<SITEID>0030</SITEID>
<STATUS>APPLIED</STATUS>
<TEAM>B</TEAM>
<WP>LC11</WP>
<ASSET>
<ASSETNUM>LC11</ASSETNUM>
<LOCATION>FACILITY-1</LOCATION>
<SITEID>0030</SITEID>
</ASSET>
</CPIS>
</MXCPISSet>
</QueryMXCPISResponse>
</soapenv:Body>
这是我的xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="MXCPISSet">
<html>
<body>
<table>
<tbody>
<tr>
<th>WP</th>
<th>Site</th>
<th>Shift</th>
</tr>
<xsl:for-each select="CPIS">
<tr>
<td><xsl:value-of select="WP"/></td>
<td><xsl:value-of select="ASSET/SITEID"/></td>
<td><xsl:value-of select="SHIFT"/></td>
</tr>
</xsl:for-each>
</tbody>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
结果如下:
D 630124 01 0 0 0 0 0 1 3 2014-09-30T00:00:00+02:00 0030 NEW C LC11 LC11 FACILITY-1 0030 D 630121 01 0 0 1 0 0 1 1 2014-09-30T00:00:00+02:00 0030 CHECKED B LC11 LC11 FACILITY-1 0030 D 630122 01 1 1 0 0 0 1 2 2014-09-30T00:00:00+02:00 0030 APPLIED B LC11 LC11 FACILITY-1 0030
如果我从响应消息中删除xmlns =“http://www.ibm.com/maximo”,我会得到正确的输出
WP Site Shift
LC11 0030 3
LC11 0030 1
LC11 0030 2
我的XSL文件中有什么问题我没有得到HTML输出?
答案 0 :(得分:2)
元素QueryMXCPISResponse
,MXCPISSet
等位于命名空间xmlns="http://www.ibm.com/maximo"
中。如果没有命名空间,处理器就不会匹配任何元素,而是应用default processing rules而不是应用样式表。您需要在模板中容纳此命名空间,如下所示(请注意xmlns
和别名,m
表示maximo):
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:m="http://www.ibm.com/maximo"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
exclude-result-prefixes="soapenv m">
<xsl:output method="html"/>
<xsl:template match="/" >
<xsl:apply-templates select="m:QueryMXCPISResponse/m:MXCPISSet" />
</xsl:template>
<xsl:template match="m:MXCPISSet">
<html>
<body>
<table>
<tbody>
<tr>
<th>WP</th>
<th>Site</th>
<th>Shift</th>
</tr>
<xsl:for-each select="m:CPIS">
... etc.
其他信息:
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
<xsl:output method="html"/>
。xsl:for-each