Strip Namesspaces

Post Reply
Rookie
Newbie
Posts: 4
Joined: Mon Aug 13, 2012 11:47 am

Strip Namesspaces

Post by Rookie »

Hello all,



is it possible to strip all namespaces in an xml file when using an switchscript?



Or which namespace must i register when there are namespace definitions like this:







thanks in advance and best regards


freddyp
Advanced member
Posts: 413
Joined: Thu Feb 09, 2012 3:53 pm

Strip Namesspaces

Post by freddyp »

var xmlFile = new Document( path to XML file );

var defaultMap = xmlFile.createDefaultMap();



Be sure to look it up in the online help for more explanation: Scripting module - Scripting reference - XML module - Document class and Metadata module - Map class.



Freddy
Rookie
Newbie
Posts: 4
Joined: Mon Aug 13, 2012 11:47 am

Strip Namesspaces

Post by Rookie »

Thanks for your reply.



Actually i am using this after test all avaible namespaces in the xml, and this works.



var dataset = job.getDataset("Xml");

var theXML = new Document( dataset.getPath( ) );

var ns = theXML.createEmptyMap();

ns.put("i" ,"http://url.to/schemas/orderexport");



ok ... i guess i must use the one in xmlns field :) deleteng all namespaces from an xml seems to be impossible with switchscripter :(
tz8
Member
Posts: 84
Joined: Mon Aug 13, 2012 12:56 pm

Strip Namesspaces

Post by tz8 »

it's impossible because you have to enable the namespaces in order to target the element! You could simply open it as a file instead of as a document and perform a line by line string search for "", closing the file and reopening as document then, but that would be a _very_ crude hack!
Post Reply