xslt - Using XSL transformation for XML to CSV conversion -
I am working on XML using CSV Transformation and method. However my .xsl file can not produce expected .csv results
How can I move forward? How do I change my .xsl file?
Here's my .xml file : Here is my .xsl file : view, value Expected Result (CSV): Edit > There is undoubtedly a more elegant solution.
& lt; RAVVALUUGS & gt; & Lt; RowValue & gt; & Lt; VALUE & gt; XYZ & lt; / Pricing & gt; & Lt; / RowValue & gt; & Lt; RowValue & gt; & Lt; VALUE & gt; Xyz1 & lt; / Pricing & gt; & Lt; / RowValue & gt; & Lt; RowValue & gt; & Lt; VALUE & gt; Xyz2 & lt; / Pricing & gt; & Lt; / RowValue & gt; & Lt; RowValue & gt; & Lt; VALUE & gt; Xyz3 & lt; / Pricing & gt; & Lt; / RowValue & gt; & Lt; RowValue & gt; & Lt; VALUE & gt; Xyz4 & lt; / Pricing & gt; & Lt; / RowValue & gt; & Lt; / RowOfValues & gt; & Lt; RowOfValues & gt; & Lt; RowValue & gt; & Lt; VALUE & gt; ABC & lt; / Pricing & gt; & Lt; / RowValue & gt; & Lt; RowValue & gt; & Lt; VALUE & gt; ABC1 & lt; / Pricing & gt; & Lt; / RowValue & gt; & Lt; RowValue & gt; & Lt; VALUE & gt; ABC2 & lt; / Pricing & gt; & Lt; / RowValue & gt; & Lt; RowValue & gt; & Lt; VALUE & gt; abc3 & lt; / Pricing & gt; & Lt; / RowValue & gt; & Lt; RowValue & gt; & Lt; VALUE & gt; Abc4 & lt; / Pricing & gt; & Lt; / RowValue & gt; & Lt; / RowOfValues & gt;
& Lt; Xsl: template match = "/" & gt; RoW value, value & lieutenant; Xsl: each-select = "// rouvices" & gt; & Lt; Xsl: Select for each = "// Rowview" & gt; & Lt; xsl: Select the value = "concat (value, ',', '& amp; #xA;')" /> & Lt; / XSL: for-each & gt; & Lt; / XSL: for-each & gt; & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt; Current result (CSV):
XYZ, xyz1, xyz2, Xyz3, xyz4, ABC, ABC1, ABC2, ABC3, ABC4,
< Code> rowview, value xyz abc xyz1, abc1 xyz2, abc2 xyz3, abc3 xyz4, abc4,
rouge value ), and assume that both columns are of the same length:
& lt ;? Xml version = "1.0"? & Gt; & Lt; Xsl: stylesheet version = "1.0" xmlns: xsl = "http://www.w3.org/1999/XSL/Transform" xmlns: fo = "http://www.w3.org/1999/XSL/ format" & Gt; & Lt; xsl: output method = "text" indistinguishable-xml-declaration = "yes" indent = "no" /> & Lt; Xsl: template match = "/" & gt; & Lt; Xsl: select value = "concat ('roew, value', '& amp; #xA;')" /> & Lt; xsl: Select each = "// Rouffle Price [1] / Rowview" & gt; & Lt; Xsl: variable name = "pos" Select = "position ()" /> & Lt; Xsl: select value = "concat (normal-space (concat (., ',', // rouge value [2] / rowview [position (= $ pos])), '& amp; #xA; ') "/> & Lt; / XSL: for-each & gt; & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt; Here's a way to contact N column case using call templates, though it is necessary: (
& lt; xml version = "1.0"? Gt; & gt; xsl: stylesheet version = "1.0" xmlns: xsl = "http://www.w3.org/1999/XSL/Transform" Xmlns: Fo = "http://www.w3.org/1999/XSL/Format" & gt; & lt; xsl: Output Method = "Text" Amit-XML-declaration = "Yes" Indent = "No" / > Gt; & lt; xls: Template Match = "/" & gt; & lt; xsl: Select Value = "Context ('RoVe, Value', '& amp; #xA;')" /> & Lt; xsl: Prev Select == Raouf Value [1] / Rowview ">
Comments
Post a Comment