on 08-20-2015 12:09 PM
Hi Experts,
i am new to XSLT mapping , but i used few xslt codes which were found in few blogs, and those are running fine..but need to keep both codintions in single code..below are codes
Code1: this is doing removing the all namespaces in payload
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="*">
<xsl:element name="{local-name(.)}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name(.)}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
<xsl:template match="@*[local-name(.)='noNamespaceSchemaLocation']"/>
</xsl:stylesheet>
Code2: its doing adding my required Message type and namespace with tacking header and body from payload
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="ns0 ns1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://Softel.com/xi/Softel_SC_PLANNING/GPEO/TransactionalData" xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge" >
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:template match="/">
<ns0:Envelope xmlns:ns0="http:Business.com" >
<xsl:copy>
<xsl:apply-templates select="//Header"/>
</xsl:copy>
<xsl:copy>
<xsl:apply-templates select="//Body"/>
</xsl:copy>
</ns0:Envelope>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
please help me if both condition are possible to merge in single code and achieve.
Thanks,
Maheswarareddy
Hi Mahesh,
I assume your query is on handling namespaces.
If yes, then can you look out the possibility of using XML anonymiser bean at the channel level for the same.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vishu,
actually i am getting so many namespaces from receiver third party system such as xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> and more in between also. with different prefixes.
so i want to remove all namespaces and put my msgmapping namespace with prefix ns0
like xmlns:ns0="http:Business.com"( need in output)
however i tried as per blog which u shared
and getting error like below
20.08.2015 12:28:50.112 | Information | MP: processing local module localejbs/AF_Modules/XMLAnonymizerBean |
20.08.2015 12:28:50.436 | Error | Anonymizer: unmatched value pairs in anonymizer.acceptNamespaces |
20.08.2015 12:28:50.437 | Error | MP: exception caught with cause java.util.NoSuchElementException |
20.08.2015 12:28:50.442 | Error | Exception caught by adapter framework: {0} |
20.08.2015 12:28:50.443 | Error | Transmitting the message using connection AFW failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.util.NoSuchElementException |
BR,
Maheswarareddy
Hi Vishnu,
i added as you suggested(http:Business.com ns0) its running fine but output is below
- <Envelope>
Hi Vishnu,
i am using this bean at receiver channel to convert response msg.
response is coming like below from receiver.
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<u:Timestamp u:Id="_0">
<u:Created>2015-08-20T12:18:33.970Z</u:Created>
<u:Expires>2015-08-20T12:23:33.970Z</u:Expires>
</u:Timestamp>
</o:Security>
</s:Header>
<s:Body>
..
...
..
</s:Body>
</s:Envelope>
and when i use bean below is the output.here namespace is missing
<Envelope>
<Header>
<Security mustUnderstand="1">
<Timestamp Id="_0">
<Created>2015-08-20T14:00:46.331Z</Created>
<Expires>2015-08-20T14:05:46.331Z</Expires>
</Timestamp>
</Security>
</Header>
<Body>
..
...
...
</Body>
</Envelope>
and i am expecting like below.
<ns0:Envelope xmlns:ns0="http:Business.com">
<Header>
<Security s:mustUnderstand="1">
<Timestamp Id="_0">
<Created>2015-08-20T12:18:33.970Z</Created>
<Expires>2015-08-20T12:23:33.970Z</Expires>
</Timestamp>
</Security>
</Header>
<Body>
..
...
..
</Body>
</ns0:Envelope>
HI Mahesh,
I guess you need to handle this in the mapping level itself, as using xml anonymiser bean only removes the unwanted namespaces and keeps only the mentioned namespaces in the payload. It doesn't alter the namespaces as we wish.
So, let me check the xslt mapping code for this requirement involving both the conditions as you mentioned.
I am just curious to know, I assume you have shared the wsdl to the webservice team and are they sending the response including soap header data?
codes were missed in post,
Code1:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="*">
<xsl:element name="{local-name(.)}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name(.)}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
<xsl:template match="@*[local-name(.)='noNamespaceSchemaLocation']"/>
</xsl:stylesheet>
Code2:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="ns0 ns1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://Softel.com/xi/Softel_SC_PLANNING/GPEO/TransactionalData" xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge" >
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:template match="/">
<ns0:Envelope xmlns:ns0="http:Business.com" >
<xsl:copy>
<xsl:apply-templates select="//Header"/>
</xsl:copy>
<xsl:copy>
<xsl:apply-templates select="//Body"/>
</xsl:copy>
</ns0:Envelope>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.