on 09-30-2009 7:07 PM
Hi Experts!
How to remove xmlns in node level in response xml file. I tried to use AF_Modules/XMLAnonymizerBean, but it did not work.
Can you please help me out on this.
I want to remvoe xmlns tag in LEVICOM
Eg:
- <Addenda>
- <LEVICOM xmlns="">
Thanks,
Hari
Hi Experts!
How to remove xmlns tag in xml file, where only xmlns="".
I am using below xslt mapping, but it is removing all xmlns tags in a xml file. I want to remove only xmlns="" .
Here is the code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.arconw.com/XI/XSLT_Library/XmlNamespacePrefixRemoval"
version="1.0">
<xsl:output method = "xml" />
<xsl:template match="/">
<xsl:apply-templates select="*" mode="remprefix"/>
</xsl:template>
<xsl:template match="*" mode="remprefix">
<xsl:variable name="newname" select="local-name(.)"/>
<xsl:element name="{$newname}" namespace ="{namespace-uri()}">
<xsl:apply-templates mode="copyall" select="@*|comment()|processing-instruction()|text()"/>
<xsl:apply-templates select="*" mode="remprefix"/>
</xsl:element>
</xsl:template>
<xsl:template mode="copyall" match="@*|comment()|processing-instruction()|text()">
<xsl:copy>
<xsl:apply-templates mode="copyall" select="@*|comment()|processing-instruction()|text()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Thanks,
Hari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks SuraJ!
Its very helpful answer. I have given point to you.
Thanks,
Hari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Expers!
Please help me out on this. The below xslt mapping working only to remove xmlns prefix in xml file, if parent having only one child. This code is not working if parent having multiple childs.
Eg: <parent>
<phild xmlns="">
test1
</phild>
</parent>
The above example working fine with below xslt mapping to remove xmlns tag.
Second scenarion not working
Eg: <parent>
<child1 xmlns="">
test1
</child1>
<child2 xmlns="">
test2
</child2>
</parent>
The above example is not working.
Here is the code:
You can remove the namespace prefixes using an XSLT mapping if they are causing problems with applications outside of XI.
Try the following code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.arconw.com/XI/XSLT_Library/XmlNamespacePrefixRemoval"
version="1.0">
<xsl:output method = "xml" />
<xsl:template match="/">
<xsl:apply-templates select="*" mode="remprefix"/>
</xsl:template>
<xsl:template match="*" mode="remprefix">
<xsl:variable name="newname" select="local-name(.)"/>
<xsl:element name="{$newname}" namespace ="{namespace-uri()}">
<xsl:apply-templates mode="copyall" select="@*|comment()|processing-instruction()|text()"/>
<xsl:apply-templates select="*" mode="remprefix"/>
</xsl:element>
</xsl:template>
<xsl:template mode="copyall" match="@*|comment()|processing-instruction()|text()">
<xsl:copy>
<xsl:apply-templates mode="copyall" select="@*|comment()|processing-instruction()|text()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Thanks,
Hari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Hari,
Use this XSLT:
<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>
<!-- go process children (applies to root node only) -->
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<!-- go process attributes and children -->
<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>
Regards
Suraj
Thanks Vijay and Raj.
Raj,
if you are using JAVA Mapng use regex to remove the XMLNS...
Can you send sample code , how to regex in JAVA mapping?
Vijay,
Here is the ouput xml file,
<Parent>
<child xmlns="">
</child>
<parent>
I want to remove xmlns tag in child node.
Thanks,
Hari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
My scenario:
IDOC --> Java Mapping --> XML file.
In response xml file I am getting xmlns tag. How to remove that tag in Java mapping.
Thanks,
Hari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry , It did not help to my scenario.
Can you please help me on this.
Thanks,
Hari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can you please explain me how to remove xmlns by using JAVA mapping. Currenly I am using java mapping.
Thanks,
Hari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Try with the following links
Hari,
You can write a Java / XSLT mapping to handle this.
regards,
Neetesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.