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 :

  & 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;   

Here is my .xsl file :

   & 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):   

view, value

  XYZ, xyz1, xyz2, Xyz3, xyz4, ABC, ABC1, ABC2, ABC3, ABC4,   

Expected Result (CSV):

 < Code> rowview, value xyz abc xyz1, abc1 xyz2, abc2 xyz3, abc3 xyz4, abc4, 
< P> Assume that there are only 2 columns (i.e. 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: ​​(  

Edit

> & 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 "> ; & Lt; / xsl: Call-template & gt; & lt; xsl: text & gt;; & #xA; & lt; / xsl: text & gt; & lt; / xsl: each-one & gt; ; & Lt; / xsl: Templates & gt; & lt; Xsl: template name = "scrap column" & gt; & Lt; Xsl: Ultimate Name = "Status" & gt; & Lt; / Xsl: param & gt; & Lt; Xsl: each selection = "// rouf value [condition () & gt; 1] // line volume [position () = $ pos]" & gt; & Lt; xsl: Select the value = "concat (',', normal-location (.))" / / Gt; & Lt; / Xsl: for- each & gt; & Lt; / Xsl: Templates & gt; & Lt; / Xsl: stylesheet & gt;

There is undoubtedly a more elegant solution.

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 -