0
這是我的XSLT代碼來獲取CDATA段值和發送到目的地XSLT代碼迴路CDATA段在我的地圖
<?xml version="1.0" encoding="UTF-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0 s1" version="1.0" xmlns:ns0="http://AIS/IL/ES/QueryROCNoResp/JIM/v1.0" xmlns:s0="http://ws.myimm.htp.com/" xmlns:s1="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" indent="yes"/>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="s1:Envelope">
<ns0:response>
<item>
<result>
<xsl:value-of select="substring-before(substring-after(., '<result>'), '</result>')"/>
</result>
<name>
<xsl:value-of select="substring-before(substring-after(., '<name>'), '</name>')"/>
</name>
<ppt_no>
<xsl:value-of select="substring-before(substring-after(., '<ppt_no>'), '</ppt_no>')"/>
</ppt_no>
<nat_cd>
<xsl:value-of select="substring-before(substring-after(., '<nat_cd>'), '</nat_cd>')"/>
</nat_cd>
<dob>
<xsl:value-of select="substring-before(substring-after(., '<dob>'), '</dob>')"/>
</dob>
<sex_cd>
<xsl:value-of select="substring-before(substring-after(., '<sex_cd>'), '</sex_cd>')"/>
</sex_cd>
<ppt_exp_dt>
<xsl:value-of select="substring-before(substring-after(., '<ppt_exp_dt>'), '</ppt_exp_dt>')"/>
</ppt_exp_dt>
<pas_apprv_dt>
<xsl:value-of select="substring-before(substring-after(., '<pas_apprv_dt>'), '</pas_apprv_dt>')"/>
</pas_apprv_dt>
<pas_expry_dt>
<xsl:value-of select="substring-before(substring-after(., '<pas_expry_dt>'), '</pas_expry_dt>')"/>
</pas_expry_dt>
<vp_no>
<xsl:value-of select="substring-before(substring-after(., '<vp_no>'), '</vp_no>')"/>
</vp_no>
<sector>
<xsl:value-of select="substring-before(substring-after(., '<sector>'), '</sector>')"/>
</sector>
<ref_no>
<xsl:value-of select="substring-before(substring-after(., '<ref_no>'), '</ref_no>')"/>
</ref_no>
</item>
</ns0:response>
</xsl:template>
</xsl:stylesheet>
輸入文件:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:incomingResponse xmlns:ns2="http://ws.myimm.htp.com/">
<return>
<![CDATA[
<response>
<item>
<result>1</result>
<name>PINOKIO</name>
<ppt_no>001FILIPINA</ppt_no>
<nat_cd>PHL</nat_cd>
<dob>19800101</dob>
<sex_cd>2</sex_cd>
<ppt_exp_dt>20150116</ppt_exp_dt>
<pas_apprv_dt>20130619</pas_apprv_dt>
<pas_expry_dt>20160718</pas_expry_dt>
<vp_no>P1401219062013110321374</vp_no>
<sector>PA</sector>
<ref_no>BPR/14012/CFATL0449374</ref_no>
</item>
<item>
<result>1</result>
<name>LIN SHU YUAN</name>
<ppt_no>210139660</ppt_no>
<nat_cd>TWN</nat_cd>
<dob>19631001</dob>
<sex_cd>2</sex_cd>
<ppt_exp_dt>20130930</ppt_exp_dt>
<pas_apprv_dt>20031203</pas_apprv_dt>
<pas_expry_dt>20160718</pas_expry_dt>
<vp_no>150406</vp_no>
<sector>PA</sector>
<ref_no>150406</ref_no>
</item>
</response>
]]>
</return>
</ns2:incomingResponse>
</S:Body>
</S:Envelope>
輸出:
我的輸出應該像
<ns0:records xmlns:ns0="http://AIS/IL/ES/QueryROCNoReq/JIM/v1.0">
<item>
<result>1</result>
<name>PINOKIO</name>
<ppt_no>001FILIPINA</ppt_no>
<nat_cd>PHL</nat_cd>
<dob>19800101</dob>
<sex_cd>2</sex_cd>
<ppt_exp_dt>20150116</ppt_exp_dt>
<pas_apprv_dt>20130619</pas_apprv_dt>
<pas_expry_dt>20160718</pas_expry_dt>
<vp_no>P1401219062013110321374</vp_no>
<sector>PA</sector>
<ref_no>BPR/14012/CFATL0449374</ref_no>
</item>
<item>
<result>1</result>
<name>LIN SHU YUAN</name>
<ppt_no>210139660</ppt_no>
<nat_cd>TWN</nat_cd>
<dob>19631001</dob>
<sex_cd>2</sex_cd>
<ppt_exp_dt>20130930</ppt_exp_dt>
<pas_apprv_dt>20031203</pas_apprv_dt>
<pas_expry_dt>20160718</pas_expry_dt>
<vp_no>150406</vp_no>
<sector>PA</sector>
<ref_no>150406</ref_no>
</item>
</ns0:records>
我試過每個,但它無法提供正確的輸出。如何實現這一點使用xslt.Can有人請幫助我
感謝邁克爾它工作正常。 – Chitra