Convert XML to JSON using XSLT and remove namespaces -


I'm new to XSLT.

I have to convert the XML to JSON using XSLT.

I have the following XML:

  & amp; Lt; getEndUserCriteriaListForRangeResponse xmlns = "http://xxxx.xxxx.xx.com/" & gt; & Lt; endUserCriteriaList & gt; & Lt; ns0: endUserCriteria xmlns: ns0 = "http://xxxx.xxxx.xx.com" & gt; & Lt; ns0: DefaultValue & gt; & Lt; ns0: customValue & gt; Parameters & lt; / ns0: customValue & gt; & Lt; ns0: eucValue & gt; Parameters & lt; / ns0: eucValue & gt; & Lt; Ns0: eucValueId & gt; Parameters & lt; / Ns0: eucValueId> & Lt; / ns0: DefaultValue & gt; & Lt; ns0: eucId & gt; Parameters & lt; / ns0: eucId> & Lt; Ns0: label & gt; Parameters & lt; / Ns0: Labels & gt; & Lt; ns0: ranges & gt; & Lt; Ns0: id & gt; Parameters & lt; / Ns0: ID & gt; & Lt; ns0: rangeName & gt; Parameters & lt; / ns0: rangeName & gt; & Lt; / ns0: Ranges & gt; & Lt; Ns0: Status & gt; Parameters & lt; / Ns0: Status & gt; & Lt; Ns0: unit & gt; Parameters & lt; / Ns0: unit & gt; & Lt; Ns0: value & gt; & Lt; ns0: customValue & gt; Parameters & lt; / ns0: customValue & gt; & Lt; ns0: eucValue & gt; Parameters & lt; / ns0: eucValue & gt; & Lt; Ns0: eucValueId & gt; Parameters & lt; / Ns0: eucValueId> & Lt; / Ns0: value & gt; & Lt; Ns0: weight & gt; Parameters & lt; / Ns0: weight & gt; & Lt; / Ns0: endUserCriteria & gt; & Lt; / EndUserCriteriaList & gt; & Lt; / GetEndUserCriteriaListForRangeResponse & gt;   

This is XSLT:

  & lt; Xsl: stylesheet xmlns: xsl = "http://www.w3.org/1999/XSL/conversion" version = "1.0" & gt; & Lt; Xsl: output method = "xml" /> & Lt; Xsl: template match = "/" & gt; & Lt; Xsl: copy-of select = "/ *" / & gt; & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt;   

and generated is JSON:

  {"@xmlns": "http://xxxx.xxxx.xx.com/", "End User Sequential list ": {" Ns0: endUserCriteria ": {" @xmlns: ns0 ":" http://xxxx.xxxx.xx.com "," ns0: defaultValue ": {" ns0: customValue ":" parameter ", "Ns0: eucId": "parameter", "ns0: label": "parameter", "ns0: eucValue": "parameter", "ns0: eucValueId": "parameter"}, "ns0: eucId": {" "Ns0: value": {"ns0: id": "parameter", "ns0: rangeName": "parameter"}, "ns0: status": "parameter", "ns0: unit": "parameter" CustomValue ":" Parameter "," NS0: Luke Value ":" Parameter "," NS 0: EUC Hieliaidi "" parameter "}," NS 0: Wet ":" Parameters "}}}   

generates JSON, I need to remove the" ns0: ". How do I do that? Here is a common XSLT, which is a source document to all namespaces:

 

& lt; Xsl: stylesheet version = "1.0" xmlns: xsl = "http://www.w3.org/1999/XSL/Transform" & gt; & Lt; Xsl: output method = "xml" indent = "yes" omit-xml-declaration = "yes" /> & Lt; Xsl: template match = "@ * | node () [no (auto :: *)]" & gt; & Lt; XSL: Copy & gt; & Lt; xsl: apply-select template = "@ * | node ()" /> & Lt; / XSL: Copy & gt; & Lt; / XSL: Templates & gt; & Lt; xsl: template match = "*" & gt; & Lt; Xsl: element name = "{local-name ()}" & gt; & Lt; xsl: apply-select template = "@ * | node ()" /> & Lt; / XSL: element & gt; & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt;

When you run on your input, the result is:

  & amp; GetEndUserCriteriaListForRangeResponse & gt; & Lt; EndUserCriteriaList & gt; & Lt; EndUserCriteria & gt; & Lt; DefaultValue & gt; & Lt; CustomValue & gt; Parameters & lt; / CustomValue & gt; & Lt; EucValue & gt; Parameters & lt; / EucValue & gt; & Lt; EucValueId & gt; Parameters & lt; / EucValueId> & Lt; / DefaultValue & gt; & Lt; EucId & gt; Parameters & lt; / EucId> & Lt; Label & gt; Parameters & lt; / Labels & gt; & Lt; Ranges & gt; & Lt; ID & gt; Parameters & lt; / Id & gt; & Lt; RangeName & gt; Parameters & lt; / RangeName & gt; & Lt; / Ranges & gt; & Lt; Status & gt; Parameters & lt; / Status & gt; & Lt; Unit & gt; Parameters & lt; / Unit & gt; & Lt; Values ​​& gt; & Lt; CustomValue & gt; Parameters & lt; / CustomValue & gt; & Lt; EucValue & gt; Parameters & lt; / EucValue & gt; & Lt; EucValueId & gt; Parameters & lt; / EucValueId> & Lt; / Values ​​& gt; & Lt; Weight & gt; Parameters & lt; / Weight> & Lt; / EndUserCriteria & gt; & Lt; / EndUserCriteriaList & gt; & Lt; / GetEndUserCriteriaListForRangeResponse & gt;   

And I think your process is some step in the pipeline that you are searching for in JSON.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -