2017-07-15 103 views
0

刪除命名空間喜HEVE從我的輸出中刪除的命名空間 我的XSLT輸入 `XSLT從輸出

<?xml version="1.0" encoding="utf-8"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://webservice.sbi.com" exclude-result-prefixes="xsl xsd xsi xs " > 
    <xsl:output method="xml" indent="yes"/> 

    <xsl:template match="@* | node()"> 
    <xsl:copy > 
     <xsl:apply-templates select="@* | node()"/> 
    </xsl:copy> 
    </xsl:template> 

    <xsl:template match="@SomeAttribute"> 
    <SomeAttributeTransformedToElement> 
     <xsl:value-of select="." disable-output-escaping="yes"/> 
    </SomeAttributeTransformedToElement> 
    </xsl:template> 

</xsl:stylesheet> 

and my output xml is

<FIXML xsi:schemaLocation="http://www.finacle.com/fixml getLastNTransactionsWithPagination.xsd" xmlns="http://www.finacle.com/fixml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<Header> 
<ResponseHeader> 
<RequestMessageKey> 
<RequestUUID>Req_14999064961</RequestUUID> 
<ServiceRequestId>getLastNTransactionsWithPagination</ServiceRequestId> 
<ServiceRequestVersion>10.2</ServiceRequestVersion> 
<ChannelId>COR</ChannelId> 
</RequestMessageKey> 
<ResponseMessageInfo> 
<BankId>MV</BankId> 
<TimeZone></TimeZone> 
<MessageDateTime>2017-07-14T12:02:29.187</MessageDateTime> 
</ResponseMessageInfo><UBUSTransaction> 
<Id/> 
<Status/> 
</UBUSTransaction> 
<HostTransaction> 
<Id/> 
<Status>SUCCESS</Status> 
</HostTransaction> 
<HostParentTransaction> 
<Id/> 
<Status/> 
</HostParentTransaction> 
<CustomInfo/> 
</ResponseHeader> 
</Header> 
<Body> 
<getLastNTransactionsWithPaginationResponse> 
<PaginatedAccountStatement> 
<accountBalances> 
<acid>12600262320201</acid> 
<availableBalance> 
<amountValue>680.1</amountValue> 
<currencyCode>MVR</currencyCode> 
</availableBalance> 
<branchId>126</branchId> 
<currencyCode>MVR</currencyCode> 
<fFDBalance> 
<amountValue>0.0</amountValue> 
<currencyCode>MVR</currencyCode> 
</fFDBalance> 
<floatingBalance> 
<amountValue>0.0</amountValue> 
<currencyCode>MVR</currencyCode> 
</floatingBalance> 
<ledgerBalance> 
<amountValue>680.1</amountValue> 
<currencyCode>MVR</currencyCode> 
</ledgerBalance> 
<userDefinedBalance> 
<amountValue>680.1</amountValue> 
<currencyCode>MVR</currencyCode> 
</userDefinedBalance> 
</accountBalances> 
<field125></field125> 
<field126></field126> 
<field127></field127> 
<hasMoreData>Y</hasMoreData> 
<transactionDetails> 
<pstdDate>2017-06-17T16:19:43.000</pstdDate> 
<transactionSummary> 
<instrumentId>    </instrumentId> 
<txnAmt> 
<amountValue>1000.0</amountValue> 
<currencyCode>MVR</currencyCode> 
</txnAmt> 
<txnDate>2017-06-28T00:00:00.000</txnDate> 
<txnDesc>Dormancy Charges as on 30-06-2017     </txnDesc> 
<txnType>D</txnType> 
</transactionSummary> 
<txnBalance> 
<amountValue>680.1</amountValue> 
<currencyCode>MVR</currencyCode> 
</txnBalance> 
<txnCat>TBI</txnCat> 
<txnId> DC360</txnId> 
<txnSrlNo> 1</txnSrlNo> 
<valueDate>2017-06-28T00:00:00.000</valueDate> 
</transactionDetails> 
<transactionDetails> 
<pstdDate>2016-12-26T19:52:51.000</pstdDate> 
<transactionSummary> 
<instrumentId>    </instrumentId> 
<txnAmt> 
<amountValue>1000.0</amountValue> 
<currencyCode>MVR</currencyCode> 
</txnAmt> 
<txnDate>2016-12-26T00:00:00.000</txnDate> 
<txnDesc>Dormancy Charges as on 31-12-2016     </txnDesc> 
<txnType>D</txnType> 
</transactionSummary> 
<txnBalance> 
<amountValue>1680.1</amountValue> 
<currencyCode>MVR</currencyCode> 
</txnBalance> 
<txnCat>TBI</txnCat> 
<txnId> DC1401</txnId> 
<txnSrlNo> 1</txnSrlNo> 
<valueDate>2016-12-26T00:00:00.000</valueDate> 
</transactionDetails> 
</PaginatedAccountStatement><getLastNTransactionsWithPagination_CustomData> 
<THB>49</THB></getLastNTransactionsWithPagination_CustomData> 
</getLastNTransactionsWithPaginationResponse></Body></FIXML> 

`

和我得到的輸出爲`

<?xml version="1.0" encoding="utf-8"?> 
<FIXML xsi:schemaLocation="http://www.finacle.com/fixml getLastNTransactionsWithPagination.xsd" xmlns="http://www.finacle.com/fixml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<Header> 
<ResponseHeader> 
<RequestMessageKey> 
<RequestUUID>Req_14999064961</RequestUUID> 
<ServiceRequestId>getLastNTransactionsWithPagination</ServiceRequestId> 
<ServiceRequestVersion>10.2</ServiceRequestVersion> 
<ChannelId>COR</ChannelId> 
</RequestMessageKey> 
<ResponseMessageInfo> 
<BankId>MV</BankId> 
<TimeZone /> 
<MessageDateTime>2017-07-14T12:02:29.187</MessageDateTime> 
</ResponseMessageInfo><UBUSTransaction> 
<Id /> 
<Status /> 
</UBUSTransaction> 
<HostTransaction> 
<Id /> 
<Status>SUCCESS</Status> 
</HostTransaction> 
<HostParentTransaction> 
<Id /> 
<Status /> 
</HostParentTransaction> 
<CustomInfo /> 
</ResponseHeader> 
</Header> 
<Body> 
<getLastNTransactionsWithPaginationResponse> 
<PaginatedAccountStatement> 
<accountBalances> 
<acid>12600262320201</acid> 
<availableBalance> 
<amountValue>680.1</amountValue> 
<currencyCode>MVR</currencyCode> 
</availableBalance> 
<branchId>126</branchId> 
<currencyCode>MVR</currencyCode> 
<fFDBalance> 
<amountValue>0.0</amountValue> 
<currencyCode>MVR</currencyCode> 
</fFDBalance> 
<floatingBalance> 
<amountValue>0.0</amountValue> 
<currencyCode>MVR</currencyCode> 
</floatingBalance> 
<ledgerBalance> 
<amountValue>680.1</amountValue> 
<currencyCode>MVR</currencyCode> 
</ledgerBalance> 
<userDefinedBalance> 
<amountValue>680.1</amountValue> 
<currencyCode>MVR</currencyCode> 
</userDefinedBalance> 
</accountBalances> 
<field125 /> 
<field126 /> 
<field127 /> 
<hasMoreData>Y</hasMoreData> 
<transactionDetails> 
<pstdDate>2017-06-17T16:19:43.000</pstdDate> 
<transactionSummary> 
<instrumentId>    </instrumentId> 
<txnAmt> 
<amountValue>1000.0</amountValue> 
<currencyCode>MVR</currencyCode> 
</txnAmt> 
<txnDate>2017-06-28T00:00:00.000</txnDate> 
<txnDesc>Dormancy Charges as on 30-06-2017     </txnDesc> 
<txnType>D</txnType> 
</transactionSummary> 
<txnBalance> 
<amountValue>680.1</amountValue> 
<currencyCode>MVR</currencyCode> 
</txnBalance> 
<txnCat>TBI</txnCat> 
<txnId> DC360</txnId> 
<txnSrlNo> 1</txnSrlNo> 
<valueDate>2017-06-28T00:00:00.000</valueDate> 
</transactionDetails> 
<transactionDetails> 
<pstdDate>2016-12-26T19:52:51.000</pstdDate> 
<transactionSummary> 
<instrumentId>    </instrumentId> 
<txnAmt> 
<amountValue>1000.0</amountValue> 
<currencyCode>MVR</currencyCode> 
</txnAmt> 
<txnDate>2016-12-26T00:00:00.000</txnDate> 
<txnDesc>Dormancy Charges as on 31-12-2016     </txnDesc> 
<txnType>D</txnType> 
</transactionSummary> 
<txnBalance> 
<amountValue>1680.1</amountValue> 
<currencyCode>MVR</currencyCode> 
</txnBalance> 
<txnCat>TBI</txnCat> 
<txnId> DC1401</txnId> 
<txnSrlNo> 1</txnSrlNo> 
<valueDate>2016-12-26T00:00:00.000</valueDate> 
</transactionDetails> 
</PaginatedAccountStatement><getLastNTransactionsWithPagination_CustomData> 
<THB>49</THB></getLastNTransactionsWithPagination_CustomData> 
</getLastNTransactionsWithPaginationResponse></Body></FIXML> 

` 我想刪除從FIXML標籤的命名空間我放棄嘗試了一些建議輸出,但似乎沒有任何幫助work.please

回答

0

我想向您推薦以下解決方案:

<?xml version="1.0" encoding="utf-8"?> 
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
        xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://webservice.sbi.com" 
        exclude-result-prefixes="xsl xsd xsi xs"> 
     <xsl:output method="xml" indent="yes"/> 
     <xsl:template match="*"> 
     <xsl:element name="{local-name()}"> 
      <xsl:for-each select="@*"> 
      <xsl:attribute name="{local-name()}"> 
       <xsl:value-of select="."/> 
      </xsl:attribute> 
      </xsl:for-each> 
      <xsl:apply-templates/> 
     </xsl:element> 
     </xsl:template> 
    </xsl:stylesheet> 

也許它是最好在你的情況下使用這個:

<?xml version="1.0" encoding="utf-8"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
       xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://webservice.sbi.com" 
       exclude-result-prefixes="xsl xsd xsi xs"> 
    <xsl:output method="xml" indent="yes"/> 
    <xsl:template match="*"> 
    <xsl:element name="{local-name(.)}"> 
     <xsl:apply-templates/> 
    </xsl:element> 
    </xsl:template> 
    <xsl:template match="@*"> 
    <xsl:copy/> 
    </xsl:template> 
</xsl:stylesheet> 
+0

nope Schemalocation is still there –

+0

Yea!嗯,它通常工作,但不是在這種情況下。 –

+0

我附上了適用於您的案例的變換。 –