[英]Transform SOAP to XML using XSLT
我真的很想將SOAP請求轉換為可用的XML文件,然后將其上傳到Filemaker數據庫中。 我一直在尋找幾天,但是找不到有效的解決方案。 我在下面復制了SOAP請求的示例,並在下面復制了所需的輸出。 任何幫助將不勝感激!!
到目前為止,我所能做的就是使用以下XSL生成內容:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns ="http://www.somedomainename.com">
<xsl:template match="@*|comment()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
SOAP請求:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<ns0:course_application_list xmlns:ns0="http://au.edu.sydney/schemas/studentcoursemanagement/courseppplication/courseapplicationdetails/1.0">
<ns0:course_application>
<ns0:application_form_seqno>01</ns0:application_form_seqno>
<ns0:course_application_seqno>01</ns0:course_application_seqno>
<ns0:application_course>MAEDUCAT-03</ns0:application_course>
<ns0:commence_year>2014</ns0:commence_year>
<ns0:sid>11223344</ns0:sid>
<ns0:application_type>I</ns0:application_type>
<ns0:application_status>AF</ns0:application_status>
<ns0:decision1>U</ns0:decision1>
</ns0:course_application>
</ns0:course_application_list>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
所需的輸出XML:
<course_application_list>
<course_application>
<application_form_seqno>01</application_form_seqno>
<course_application_seqno>01</course_application_seqno>
<application_course>MAEDUCAT-03</application_course>
<commence_year>2014</commence_year>
<sid>11223344</sid>
<application_type>I</application_type>
<application_status>AF</application_status>
<decision1>U</decision1>
</course_application>
</course_application_list>
您需要適當地管理名稱空間,您可能可以執行以下操作:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:somedo ="http://au.edu.sydney/schemas/studentcoursemanagement/courseppplication/courseapplicationdetails/1.0"
exclude-result-prefixes="somedo">
<!-- This will skip all SOAP-env related elements -->
<xsl:template match="soap:*">
<xsl:apply-templates select="*" />
</xsl:template>
<!-- this will copy all elements without the namespace declaration -->
<xsl:template match="somedo:*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*|comment()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
到目前為止,我得到的結果是:
<?xml version="1.0" encoding="UTF-8"?>
<course_application_list>
<course_application>
<application_form_seqno>01</application_form_seqno>
<course_application_seqno>01</course_application_seqno>
<application_course>MAEDUCAT-03</application_course>
<commence_year>2014</commence_year>
<sid>11223344</sid>
<application_type>I</application_type>
<application_status>AF</application_status>
<decision1>U</decision1>
</course_application>
</course_application_list>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.