我现在遇到DataPower的有线问题,它没有处理XML 转型得当。使用以下输入:
当我把它放入Datapower时,<response status="200"><CustomELearningVO><ClassListVO> <CLASS_TAB_OBJ> <CLASS_TAB> <CLASS_OBJ> <ClassId>123456</ClassId> <ClassName>Sample Class1</ClassName> <Status>Not Attempted</Status> <Link>link</Link> <PlayEnable>Y</PlayEnable> </CLASS_OBJ> <CLASS_OBJ> <ClassId>56789</ClassId> <ClassName>Sample Class2</ClassName> <Status>Failed</Status> <Link>link2</Link><PlayEnable>Y</PlayEnable> </CLASS_OBJ> <CLASS_OBJ> <ClassId>56788</ClassId> <ClassName>Sample Class3</ClassName> <Status>Failed</Status> <PlayEnable>N</PlayEnable> <PlayMessage>"Course cannot be played as Certfication subscribed to Course has Expired"</PlayMessage> </CLASS_OBJ> </CLASS_TAB> </CLASS_TAB_OBJ> </ClassListVO><eBSErrorCode>0</eBSErrorCode><eBSErrorMessage>SUCCESS</eBSErrorMessage></CustomELearningVO></response> When I use the below XSL, it process properly and gives me a correct output (output1). But the same gives a different output
(output2)。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
的xmlns:WSDL =&#34; HTTP://api.esr.nhs.uk/v1/ELearning/wsdl" 的xmlns:SOAP =&#34; HTTP://www.w3.org/2003/05/soap-envelope" 的xmlns:DP =&#34; HTTP://www.datapower.com/extensions" 伸长元件前缀=&#34; DP&#34; exclude-result-prefixes =&#34; wsdl soap DP&#34;&GT;
<xsl:template match="/"> <xsl:if test="/response/CustomELearningVO/ClassListVO/CLASS_TAB_OBJ/CLASS_TAB/CLASS_OBJ/ClassId"> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <soap:Header> <callerIds> <userId> <xsl:value-of select="1234"/> </userId> <responsibilityId> <xsl:value-of select="576"/> </responsibilityId> </callerIds> <requestId> <xsl:value-of select="123"/> </requestId> <sessionToken> <xsl:value-of select="8787"/> </sessionToken> </soap:Header> <soap:Body> <wsdl:getELearningClassResponse> <xsl:apply-templates select="/response/CustomELearningVO/ClassListVO/CLASS_TAB_OBJ/CLASS_TAB/CLASS_OBJ[ClassId]"/> </wsdl:getELearningClassResponse> </soap:Body> </soap:Envelope> </xsl:if> <xsl:if test="not(/response/CustomELearningVO/ClassListVO/CLASS_TAB_OBJ/CLASS_TAB/CLASS_OBJ/ClassId)"> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <soap:Body> <soap:Fault> <soap:Code> <soap:Value>soap:Sender</soap:Value> <soap:Subcode> <soap:Value>soap:INT1001</soap:Value> </soap:Subcode> </soap:Code> <soap:Reason> <soap:Text xml:lang="en"> <xsl:value-of select="/response/CustomELearningVO/eBSErrorMessage"/> </soap:Text> </soap:Reason> </soap:Fault> </soap:Body> </soap:Envelope> </xsl:if> </xsl:template> <xsl:template match="/response/CustomELearningVO/ClassListVO/CLASS_TAB_OBJ/CLASS_TAB/CLASS_OBJ"> <learningClass> <classId><xsl:value-of select="ClassId"/></classId> <className><xsl:value-of select="ClassName"/></className> <status><xsl:value-of select="Status"/></status> <link><xsl:value-of select="Link"/></link> <playEnable><xsl:value-of select="PlayEnable"/></playEnable> <playMessage><xsl:value-of select="PlayMessage"/></playMessage> </learningClass> </xsl:template> </xsl:stylesheet>
output1(在Notepad ++中处理)
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <soap:Header> <callerIds> <userId>1234</userId> <responsibilityId>576</responsibilityId> </callerIds> <requestId>123</requestId> <sessionToken>8787</sessionToken> </soap:Header> <soap:Body> <wsdl:getELearningClassResponse xmlns:wsdl="http://api.esr.nhs.uk/v1/ELearning/wsdl"> <learningClass> <classId>123456</classId> <className>Sample Class1</className> <status>Not Attempted</status> <link>link</link> <playEnable>Y</playEnable> <playMessage/> </learningClass> <learningClass> <classId>56789</classId> <className>Sample Class2</className> <status>Failed</status> <link>link2</link> <playEnable>Y</playEnable> <playMessage/> </learningClass> <learningClass> <classId>56788</classId> <className>Sample Class3</className> <status>Failed</status> <link/> <playEnable>N</playEnable> <playMessage>"Course cannot be played as Certfication subscribed to Course has Expired"</playMessage> </learningClass> </wsdl:getELearningClassResponse> </soap:Body> </soap:Envelope>
output2(在DP中处理)
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <soap:Body> <soap:Fault> <soap:Code> <soap:Value>soap:Sender</soap:Value> <soap:Subcode> <soap:Value>soap:INT1001</soap:Value> </soap:Subcode> </soap:Code> <soap:Reason> <soap:Text xml:lang="en">SUCCESS</soap:Text> </soap:Reason> </soap:Fault> </soap:Body> </soap:Envelope>
任何人都可以建议,这里有什么问题?或者我在做什么 错误?
第二部分
稍微更新了XSL:
<xsl:template match="/"> <xsl:if test="(/response/CustomELearningVO/ClassListVO)"> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <soap:Header> <callerIds> <userId> <xsl:value-of select="1234"/> </userId> <responsibilityId> <xsl:value-of select="576"/> </responsibilityId> </callerIds> <requestId> <xsl:value-of select="123"/> </requestId> <sessionToken> <xsl:value-of select="8787"/> </sessionToken> </soap:Header> <soap:Body> <wsdl:getELearningClassResponse> <xsl:apply-templates select="/response/CustomELearningVO/ClassListVO/CLASS_TAB_OBJ/CLASS_TAB/CLASS_OBJ[ClassId]"/> </wsdl:getELearningClassResponse> </soap:Body> </soap:Envelope> </xsl:if> <xsl:if test="not(/response/CustomELearningVO)"> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <soap:Body> <soap:Fault> <soap:Code> <soap:Value>soap:Sender</soap:Value> <soap:Subcode> <soap:Value>soap:INT1001</soap:Value> </soap:Subcode> </soap:Code> <soap:Reason> <soap:Text xml:lang="en"> <xsl:value-of select="/response/CustomELearningVO/eBSErrorMessage"/> </soap:Text> </soap:Reason> </soap:Fault> </soap:Body> </soap:Envelope> </xsl:if> </xsl:template>
但现在打印到应用模板部分:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" > <soap:Header> <callerIds> <userId>1234</userId> <responsibilityId>576</responsibilityId> </callerIds> <requestId>123</requestId> <sessionToken>8787</sessionToken> </soap:Header> <soap:Body> <wsdl:getELearningClassResponse xmlns:wsdl="http://api.esr.nhs.uk/v1/ELearning/wsdl" /> </soap:Body> </soap:Envelope>
这意味着它不理解这一部分:
<xsl:apply-templates select="/response/CustomELearningVO/ClassListVO/CLASS_TAB_OBJ/CLASS_TAB/CLASS_OBJ[ClassId]"/>
任何人都可以帮助我理解如何打印其余部分 消息?