on 10-05-2006 6:17 PM
Hi Everyone,
I am implementing a scenario wherein I have to perform XSLT mapping. After implementing XSLT mapping, the output I get is shown below. The issue I am facing is to remove <b>ns1:</b> from the output.
<<b>ns1:</b>batch>
<<b>ns1:</b>DataBatch schemaVersion="1.0" enterpriseSystemId="826" receiptType="OnDemand" batchId="xyz123">
<<b>ns1:</b>DataUnits>
<<b>ns1:</b>DataUnit participantId="09088149987" completed="completed" sendersReference="1111eee"><<b>ns1:</b>Skjema skjemanummer="669" blankettnummer="RF-1037" spesifikasjonsnummer="4578"/>
</<b>ns1:</b>DataUnit>
</<b>ns1:</b>DataUnits>
</<b>ns1:</b>DataBatch>
</<b>ns1:</b>batch>
However the required output is:
<batch>
<?xml version="1.0" encoding="utf-8"?>
<DataBatch batchId="8e8d6e34-60b3-4c42-89f8-dce662913d2f" enterpriseSystemId="512"
schemaVersion="1.0" receiptType="OnDemand">
<DataUnits>
<DataUnit participantId="980407047" sendersReference="fd1fc4b6-ffee-47dd-aeee-
d3d57b1d6b2e" parentReference="" completed="0" locked="0">
</DataUnit>
</DataUnits>
</DataBatch>
</batch>
The XSLT mapping program I have used is:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:
ns1="urn:TestingAltinn">
<xsl:template match="/">
<ns1:Batch>
<xsl:text disable-output-escaping="yes">
<![CDATA[<![CDATA[]]></xsl:text>
<xsl:copy-of select="//ns1:DataBatch"/>
<xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text>
<xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>
</ns1:Batch>
</xsl:template>
</xsl:stylesheet>
Please advice.
Regards,
Ashish
Hi,
copy the following XSLT and save it as RemName.xsl
Then zip it and import it under Imported Archive. In your Interface mapping add one more mappinf by clicking "+" button and add the imported new XSL mapping.
<?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="no"/>
<xsl:template match="/|comment()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</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>
Thanks,
Prakash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your reply Prakash,
I would like to tell you my scenario in detail. I perform two mappings in my scenario.
In the first one I transfer XML structure in one <b>DataBatch</b> element.
The output I get is:
<ns1:DataBatch schemaVersion="1.0" enterpriseSystemId="826" receiptType="OnDemand" batchId="xyz123">
<ns1:DataUnits>
<ns1:DataUnit participantId="09088149987" completed="completed" sendersReference="1111eee"><ns1:Skjema skjemanummer="669" blankettnummer="RF-1037" spesifikasjonsnummer="4578"/>
</ns1:DataUnit>
</ns1:DataUnits>
</ns1:DataBatch>
The XSLT mapping program I have used is:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:
ns1="urn:TestingAltinn">
<xsl:template match="/">
<ns1:DataBatch>
<xsl:text disable-output-escaping="yes">
<![CDATA[<![CDATA[]]></xsl:text>
<xsl:copy-of select="//ns1:DataBatch"/>
<xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text>
<xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>
</ns1:DataBatch>
</xsl:template>
</xsl:stylesheet>
In the second mapping I transfer the above output to a new field called <b>Batch</b>
<i>I concat the previous output + '<?xml version="1.0" encoding="UTF-8"?>' = Batch </i>
To get the final output:
<b><ns1:batch>
<?xml version="1.0" encoding="UTF-8"?></b>
<ns1:DataBatch schemaVersion="1.0" enterpriseSystemId="826" receiptType="OnDemand" batchId="xyz123">
<ns1:DataUnits>
<ns1:DataUnit participantId="09088149987" completed="completed" sendersReference="1111eee"><ns1:Skjema skjemanummer="669" blankettnummer="RF-1037" spesifikasjonsnummer="4578"/>
</ns1:DataUnit>
</ns1:DataUnits>
</ns1:DataBatch>
</ns1:batch>
Now how do i get rid of <b>ns1:</b> in the above output.
Appreciate your patience.
Regards,
Ashish
Hi,
Instead of doing in two steps you could have done in one step.
Directly adding <?xml version="1.0" encoding="UTF-8"?> and DataBatch under the Batch tag. So you will need only one XSLT mapping. Then use the RemName.xsl to do it. If you are confirtable with it you can anyways go and add one more XSLT mapping I mean the 3rd one, but again performance comes into picture.
Please post Source XML and expected final target XML
Thanks,
Prakash
Hi Prakash,
The final required XML structure is:
<batch>
<?xml version="1.0" encoding="utf-8"?>
<DataBatch batchId="8e8d6e34-60b3-4c42-89f8-dce662913d2f" enterpriseSystemId="512"
schemaVersion="1.0" receiptType="OnDemand">
<DataUnits>
<DataUnit participantId="980407047" sendersReference="fd1fc4b6-ffee-47dd-aeee-
d3d57b1d6b2e" parentReference="" completed="0" locked="0">
</DataUnit>
</DataUnits>
</DataBatch>
</batch>
and i have to perform the two mappings i have mentioned as it is part of the business requirment.
and if i have got you right, then i complete my final mapping to get the structure:
<ns1:batch>
<?xml version="1.0" encoding="UTF-8"?>
<ns1:DataBatch schemaVersion="1.0" enterpriseSystemId="826" receiptType="OnDemand" batchId="xyz123">
<ns1:DataUnits>
<ns1:DataUnit participantId="09088149987" completed="completed" sendersReference="1111eee"><ns1:Skjema skjemanummer="669" blankettnummer="RF-1037" spesifikasjonsnummer="4578"/>
</ns1:DataUnit>
</ns1:DataUnits>
</ns1:DataBatch>
</ns1:batch>
Then i have to add another xslt mapping at the interface mapping level with exactly the code given by you:
<?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="no"/>
<xsl:template match="/|comment()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</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>
Pls advice.
Regards,
Ashish
Hi,
<i>>>>Then i have to add another xslt mapping at the interface mapping level with exactly the code given by you:</i>
Yes this will remove all the namespaces and will give you just the elements and the attributes.
Just save it, import it and add it as 3rd mapping. You will have to expected output.
I noted a problem <?xml version="1.0" encoding="UTF-8"?> tag should always be in the first line otherwise you will have a error saying not a well formed XML. If you need that try to put all those under a CDATA
Also one more observiation <ns1:batch> the ns:1 is not declared anywhere. While creating the Batch you can do this way <ns1:batch xmlns:ns1="http://sap.com/test"> something like this to avoid syntax error of the XML
Thanks,
Prakash
Message was edited by: Prakash Arunachalam
Message was edited by: Prakash Arunachalam
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.