Hello i need to sperate datas with comma and add new data.
<fields>
<field name="example"><value>example,i,am,new,to,xslt</value></field>
<fields>
i need to transform this xml to
<fields>
<field name="example"><value>example</value><value>i</value>am</value><value>new</value><value>to</value><value>xslt</value></field>
<fields>
can any one explain how can i do that using XSLT
I. XSLT 2.0 solution:
when this transformation is applied on the provided XML document (Corrected!!!! for well-formedness):
the wanted, correct result is produced:
II. XSLT 1.0 solution:
when this transformation is applied on the same XML document (above), the same correct result is produced:
Explanation:
Use of the identity rule to copy everything “as-is”.
Overriding (of the identity template) template that matches
value.In Solution I — appropriate use of the standard XPath 2.0 function
tokenize().In Solution II — implementing something loke the
tokenize()function using a named template — because there is notokenize()defined in XPath 1.0/XSLT 1.0.In Solution II for convenience we have merged the template matching
valuewith the named template that performs comma-tokenization.