on 05-22-2012 1:44 PM
Hi All,
I have been working on ABAP-XSLT mapping and facing an issue. First 2 lines of my input file look like this,
<?xml version="1.0" ?>
<Invoice xmlns="http://schema.test.com/TEST/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schema.infor.com/TEST/2 http://schema.test.com/2.6.3/TEST/Developer/Invoice.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" releaseID="9.2" versionID="2.6.3">
When I test mapping without all the namespace definitions, the mapping works. But when I test with all namespaces as shown above, then mapping program cannot locate the field values in source XML.
I am using <xsl:template match="/"> to match root node (Invoice)
What could be wrong? I don't want to remove the namespaces from source file. What can be done?
- Netrey
Yes, you dont need to make changes in the source file. You can ignore the namespaces that you don't need using the XML Anonymizer bean. In addition to Greg's link if you need any screenshot for how to apply this bean you can see this link
http://www.saptechnical.com/Tutorials/XI/XMLPayload/Index.htm
Remember this bean module is not for adding the namespace. This is only used for removing the namespace or namespace prefix or changing the namespace prefix.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Greg and Baskar,
Thanks for your inputs. Those are really helpful. However, I have a little problem here. I have JDBC adapter at sender side which reads table entry in VARBINARY format. Then Java mapping program converts this VARBINARY and then only I get the data in XML format. Now, if I use XML Anonymizer Bean in sender JDBC adapter, it's of no use. So, do I have to change this XML data in Java mapping only to remove namespace definitions or still there is some other way to do it, without manually modifying source XML ?
Thanks,
Netrey
Dear Netrey,
You're right, any adapter module is of no use in this case. Furtunately there is an alternative: you can use an additional XSLT mapping (after Java mapping and before the "main" graphical mapping) that will remove the namespaces from the XML payload. Here is the XSLT code that should do this for you:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- attributes, commments, processing instructions, text: copy as is -->
<xsl:template match="@*|comment()|processing-instruction()|text()">
<xsl:copy-of select="."/>
</xsl:template>
<!-- elements: create a new element with the same name, but no namespace -->
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
More XSLT variants for removing namespaces are included in this thread: . You could also remove the namespaces while parsing the input in the Java mapping, but this might require some more complex coding.
Regards,
Greg
Hi Netrey,
>>> What could be wrong?
It's just that you cannot ignore the namespaces when working with XML. Namespace is an integral part of the tag name and you cannot simply omit it (otherwise the solution won't work as expected, just like in your case). <abc:xyz> is not the same tag as <def:xyz>, just like <xyz> is not the same as <jkl>.
>>> I don't want to remove the namespaces from source file.
Luckily there is also another solution. You can use the XML Anonymizer Bean in the sender channel to make PI remove the unwanted namespaces from the payload read from the file, before the mapping. Thanks to that, you will not have to modify the source files, nor the mapping itself. Read more about the bean here:
http://help.sap.com/saphelp_nw04/helpdata/en/45/d169186a29570ae10000000a114a6b/content.htm
Regards,
Greg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.