I have to remove the xsi:schemaLocation but I don't get it to work, I think I do something wrong in wt:Envelope/wt:Body/wt:MessageParts/*[not(name() ='xsi:schemaLocation')] definition, but don't know how to solve this
xml source:
<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">
<Header>
<MessageId>{AAE4C191-6D18-4823-A29D-9C6CA68113C2}</MessageId>
<Action>http://tempuri.org/VendPaymentsService/find</Action>
</Header>
<Body>
<MessageParts xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">
<Document xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03 pain.001.001.03.xsd"
xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CstmrCdtTrfInitn>
....
</CstmrCdtTrfInitn>
</Document>
</MessageParts>
</Body>
</Envelope>
My xslt
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wt="http://schemas.microsoft.com/dynamics/2011/01/documents/Message"
xmlns:s1="http://schemas.microsoft.com/dynamics/2008/01/documents/VendPayments"
version="1.0">
<xsl:output method="xml" encoding="iso-8859-1" />
<xsl:template match="/">
<xsl:text disable-output-escaping="yes"><?xml version="1.0" encoding="utf-8"?></xsl:text>
<xsl:copy-of select="wt:Envelope/wt:Body/wt:MessageParts/*[not(name() ='xsi:schemaLocation')]" />
</xsl:template>
</xsl:stylesheet>
result
<?xml version="1.0" encoding="utf-8"?>
<Document
xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03 pain.001.001.03.xsd" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CstmrCdtTrfInitn>
..
</CstmrCdtTrfInitn>
</Document>
what am I doing wrong?
<xsl:copy-of>
performs a deep copy; you cannot exclude individual nodes. Note also that xsi:schemaLocation
is an attribute, not an element.
Try it this way, perhaps?
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wt="http://schemas.microsoft.com/dynamics/2011/01/documents/Message"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<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="/">
<xsl:apply-templates select="wt:Envelope/wt:Body/wt:MessageParts/*" />
</xsl:template>
<xsl:template match="@xsi:schemaLocation"/>
</xsl:stylesheet>
Note:
You should never be required to use a hack like this:
<xsl:text disable-output-escaping="yes"><?xml version="1.0" encoding="utf-8"?></xsl:text>
If you want your output to have utf-8 encoding, say so in the <output>
element.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다