我正试图提出一个描述性的标题...大声笑...
无论如何;这可能很简单,但是我在这里有些挣扎。我有一个需要处理的输入。我需要这样做:
输入文件
<TOTALRequest-Response-Keys xmlns="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard">
<fha_case_number>2812883060</fha_case_number>
<loan_number>1000006611</loan_number>
<score_dt>2019/01/31 16:23:55</score_dt>
<aus>ZFWF</aus>
<times_enqueued>1</times_enqueued>
<TOTALRequest-Response xmlns:client="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard">
<client:process>
<client:monthly_income/>
<!-- many elements -->
<client:loanapp>
<client:loanapptype>MISMOAUS2.4</client:loanapptype>
<ns1:loanappdata xmlns="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard" xmlns:ns2="http://mismo.org/aus/" xmlns:ns1="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard">
<ns2:LOAN_APPLICATION MISMOVersionID="2.4"/>
<!-- many elements ns1:whatever -->
</ns1:loanappdata>
</client:loanapp>
</client:process>
<client:processResponse/>
</TOTALRequest-Response>
</TOTALRequest-Response-Keys>
所需的输出
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:f17="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard">
<soapenv:Body>
<fha:process xmlns:fha="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard">
<fha:monthly_income>
<fha:loanapp>
<fha:loanapptype>MISMOAUS2.4</fha:loanapptype>
<ns1:loanappdata xmlns="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard" xmlns:ns2="http://mismo.org/aus/" xmlns:ns1="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard">
<ns2:LOAN_APPLICATION MISMOVersionID="2.4">
</ns1:loanappdata>
</fha:loanapp>
</fha:process>
</soapenv:Body>
</soapenv:Envelope>
我当前所拥有的;您拥有的
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fha="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard"
xmlns:client="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard"
xmlns:ns1="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard">
xmlns:ns2="http://mismo.org/aus/">
<xsl:output method="xml" version="1.0" omit-xml-declaration="yes" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:f17="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard">
<soapenv:Body>
<fha:process xmlns:fha="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard">
<xsl:copy>
<xsl:copy-of select="/*/*/*:process/child::*"/>
</xsl:copy>
</fha:process>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
<!--
<xsl:template match="client:*" name="change_prefix">
<xsl:element name="fha:{local-name()}">
<xsl:apply-templates select="."/>
</xsl:element>
</xsl:template>
<xsl:template match="/">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:f17="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard">
<soapenv:Body>
<xsl:copy>
<xsl:copy-of select="/*/*/child::*"/>
</xsl:copy>
<xsl:apply-templates select="change_prefix" />
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
-->
</xsl:stylesheet>
我尝试了很多事情,但感觉就像是在向墙上扔面条。 :(
答案 0 :(得分:1)
这对您有用吗?
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fha="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard"
xmlns:client="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/fha:TOTALRequest-Response-Keys">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:f17="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard">
<soapenv:Body>
<xsl:apply-templates select="fha:TOTALRequest-Response/client:process"/>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
<xsl:template match="client:*">
<xsl:element name="fha:{local-name()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
答案 1 :(得分:0)
事实证明,我不需要对嵌入式片段做任何事情。端点能够掌握嵌入式文档的默认名称空间(但是,如果有人想对此做出回应,我不会反对。)
我唯一需要对Michael做出的更改是在“ envelope”标签上添加一个名称空间声明。 (Micheal不可能知道最终流程需要另一个名称空间。)
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fha="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard"
xmlns:client="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard"
xmlns:ns2="http://mismo.org/aus/"
xmlns:ns1="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/fha:TOTALRequest-Response-Keys">
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:f17="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard"
xmlns:fha="http://xmlns.oracle.com/F17CTOTALScorecard/F17CTOTALScorecard/F17CTOTALScorecard">
<soapenv:Body>
<xsl:apply-templates select="fha:TOTALRequest-Response/client:process"/>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
<xsl:template match="client:*">
<xsl:element name="fha:{local-name()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>