Skip to Content
0

Updating Namespace Using XSLT Not working after Simple Transformation

Dec 02, 2016 at 02:57 AM

67

avatar image
Former Member

Hi All, I am trying to remove existing namespaces and add another namespace to my XML Document. When i didnt added the attribute, it was working. Now, when i added an attribute "id" the removal code is not working. My XML Document is:

I used XSLT_TOOL to create a simple transformation(z_add_attribute_xslt) that gave the following output:

<?xml version="1.0" encoding="UTF-8"?>
 <n0:eCPR xmlns:prx="urn:sap.com:proxy:DV4:/1SAI/TAS1F59A417878D36573F1D:700:2013/05/24" xmlns:n0="http://www.dir.ca.gov/dlse/CPR-Prod-Test/CPR.xsd"> 

<n0:employees> <n0:employee> <n0:name id="20019768">Paul John</n0:name> </n0:employee> </n0:employees> </n0:eCPR>



But, What i want it to be is:

 <CPR:eCPR xmlns:CPR="http://www.dir.ca.gov/dlse/CPR-Prod-Test/CPR.xsd"> 

<CPR:employees> <CPR:employee> <CPR:name id="12345">JOHN SMITH</CPR:name> </CPR:employee> </CPR:employees> </CPR:eCPR>

The XSLT Code(XSLT_TOOL) which i applied was: z_remove_namespacee_xslt
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:CPR="http://www.dir.ca.gov/dlse/CPR-Prod-Test/CPR.xsd"> 
 <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 
 <xsl:strip-space elements="*"/> 

 <xsl:template match="*"> 
 <xsl:element name="CPR:{local-name()}"> 
 <xsl:apply-templates/> 
 </xsl:element> 
 </xsl:template> 
 </xsl:stylesheet>


But, the above code is not working and it is not removing the namespaces.

ABAP Code:

call transformation z_add_attribute_xslt
  source cpr = ls_abap_data
  result xml xml_result  .

call transformation z_remove_namespacee_xslt
source xml xml_result
result xml xml_result.
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers