Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rmove xmlns attribute

I am trying to remove the attribute xmlns="http://webdev2003.test.com" from the following xml using xsl/xslt, a requirement of the XML Task in SSIS. What is a proper methodology considering a large file size. ~40mb

<?xml version="1.0" encoding="utf-16"?>
<ArrayOfAccount xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">    
<Account>  
    <FirstName xmlns="http://webdev2003.test.com/">John</FirstName>  
    <LastName xmlns="http://webdev2003.test.com/">Smith</LastName>  
</Account>  
</ArrayOfAccount>
like image 520
decompiled Avatar asked Oct 14 '22 12:10

decompiled


2 Answers

I hate when I answer my own questions, but the credit goes to - http://blogs.msdn.com/kaevans/archive/2003/06/13/8679.aspx

The first part of the example lists how to remove all attributes which in my scenario works. Perhaps there is a better solution?

like image 190
decompiled Avatar answered Oct 18 '22 23:10

decompiled


I think you can remove the namespace declarations as described in this article. It looks like you might have to declare a prefix for the namespace in your stylesheet before adding it to the exclude-result-prefixes attribute.

You can prevent this from happening with the xsl:stylesheet element's exclude-result-prefixes attribute. This attribute's name can be confusing, because the namespace prefixes will still show up in the result tree. It doesn't mean "exclude the prefixes in the result"; it means "exclude the namespaces with these prefixes".

like image 44
Don Kirkby Avatar answered Oct 18 '22 23:10

Don Kirkby