我是使用xsl的新手。我需要转换以下SOAP ws响应。我有以下XML输入:
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:NS1="urn:ECGTSIncomingSoapWebServiceIntf-IIncomingWebService" xmlns:NS2="urn:unECGIncomingSoapGlobal">
<NS1:RequestResponse>
<return href="#1"/>
</NS1:RequestResponse>
<NS2:TECGIncomingResponse id="1" xsi:type="NS2:TECGIncomingResponse">
<Error xsi:type="xsd:int">0</Error>
<ErrorMsg xsi:type="xsd:string"></ErrorMsg>
<Output xsi:type="xsd:string">2VKFKup1ZWNs0yCmDMCW/xXNwNHGb1hrVP7MilsECKpUrZWv4UfHJ6Nvi9kun7bdig/YwaOUVmSSVq1syKkdP08zGuZaoGHBBjsmR+zrPt5Ppo/govH7yyynLSfkIbBI/tNzwW6BtND+Dz0750ybm0pI6TQbyN2aKzTUB0Zj8FGXE/sAllTD19xeFIhqOBT5s5/zMZXWoaBoi5yhnsAFSqHhdTmZ2urFUc2m2t7nPNAmZze48+1b/xItDTZoybus+ZXDMRivr5ZxkjkaCGhcIvBoqHc0APYPMNg3YnwEhdw1DxDqilFx1FFR/6O0ntcKRN4luR7vzxnB/WH5gRXCT7WAhxIZn6Aa2Mfjf+FWMrr/Kr9jpeSiLlRsogA/83Cvv9xSzNHepRpKLNYXQfvW+ps8O7paPcPpA3Hp6Ajob3E3T3l6t2olGLfvwINlDgSQiV2+XdDrCONxSESboCuZUzxN1dVKWNdWl3rOwKK1xDazORX2sOtHnofp7exTH9e3/tqEUHBC4CVeYns6He4mm1+gilHYlLSDwn6NUrA1O0Hk8QRVUOoF5Symz62/DAHlr7GUbrC30AchGFB6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k3u2M3SbOQPT929rQZxtu9yQPw1Dy1xeCr/KzaYofgAMOlIfAznfY4XJi1XuK5A+3DC/kGVORLEme/eiplY5R36BZlcMt5G3xrYjk7t1wmwVD5B7KLzTkADyUYU+m7zk+MXbsb9GScetFELf2ENp93JZ7alnVXR0yYJ77R9KKvvg59owAAml68eCY3rJGZ8RYyfta3YfzUTczCnUoi3nA2MBIkhyAmZ7UhOasCiXxks+36cMk/J+iOc1dcfEXxbNbv8m2h8uGhL3YxR39W776ReiRYF9tETJXSAxo1scwfDK8mOoz5ytrpXsop5c2c+4LtvP09EP/tGUcDrSo7W54TFRJ4Vg0juDj0Q9WLg8PTP+5Fkk/VYXmPQflv9jWpTzDvDKymgqMiZiXNQvZvfu1+6sGLGppDCpyYPD1+Mv/vJq9WBf51V/trnEQHFNfHoHPODz/GQJP16DilPOAB1AiHHpRMZz+U3h4RDBX1I/O1gWogBverRTXHm62OaUDGErO0XUwsldBrn4E2QFdFszN5Gk5r9m/duI/2q2/hNWUWC7pQigfq2ED+lP0UoB1+qYte0OLGwJKrZSY3qNJj0O95xMyGqCkklluvNmiN4LA4KxuDCI7AUzlGI6fwgJYGxzQjIzeyY8Uzr16qB8vvtA=</Output>
<OutputHash xsi:type="xsd:string">877C40EB46C09F7C2066CADF3EEF4E12D2D5CE15</OutputHash>
<OutputKey xsi:type="xsd:string"></OutputKey>
<OutputKeyHash xsi:type="xsd:string"></OutputKeyHash>
<OutputSecuence xsi:type="xsd:string">20170102112384225</OutputSecuence>
</NS2:TECGIncomingResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我尝试使用XSL模板提取<Output>
和<Error>
标记值。
我试过了:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<xsl:template match="/">
<xsl:value-of select="SOAP-ENV:Envelope/SOAP-ENV:Body/NS2:TECGIncomingResponse/Output"/>
<xsl:value-of select="SOAP-ENV:Envelope/SOAP-ENV:Body/NS2:TECGIncomingResponse/Output"/>
</xsl:template>
</xsl:stylesheet>
但它会引发错误。我觉得不是很复杂!我怎样才能得到这个结果?非常感谢!
答案 0 :(得分:1)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:NS2="urn:unECGIncomingSoapGlobal">
<xsl:template match="/">
<xsl:value-of select="SOAP-ENV:Envelope/SOAP-ENV:Body/NS2:TECGIncomingResponse/Error"/>
<xsl:value-of select="SOAP-ENV:Envelope/SOAP-ENV:Body/NS2:TECGIncomingResponse/Output"/>
</xsl:template>
</xsl:stylesheet>
那为我工作!!我忘了为NS2定义前缀映射:xmlns:NS2="urn:unECGIncomingSoapGlobal