嗨我要从输出中删除命名空间 我的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标签中删除命名空间我尝试了一些建议的输出,但似乎没有任何工作。请帮助
答案 0 :(得分: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>