xslt - Get distinct node values in XML with XSL -


How do I get all the specific names in my XML using XSL?

  & lt; NewDataSet & gt; & Lt; SearchResult & gt; & Lt; Name & gt; HAREDIN & lt; / Name & gt; & Lt; Surname & gt; FEIMI & lt; / Nickname & gt; & Lt; FathersName & gt; QAMIL & lt; / FathersName & gt; & Lt; Date of birth & gt; 1949-06-13T00 00: 00 + 02: 00 & lt; / Birthdate & gt; & Lt; Customer Segment & gt; Individ Standart & lt; / Customer Segment & gt; & Lt; / SearchResult & gt; & Lt; SearchResult & gt; & Lt; Name & gt; HARMENAK & lt; / Name & gt; & Lt; Surname & gt; BADEJAN & lt; / Nickname & gt; & Lt; Father's Name & gt; VARAHAN & lt; / Father name & gt; & Lt; Date of birth & gt; 1943-10-02T00: 00: 00 + 02: 00 & lt; / Birthdate & gt; & Lt; Customer Segment & gt; Individ Standart & lt; / Customer Segment & gt; & Lt; / SearchResult & gt; & Lt; SearchResult & gt; & Lt; Name & gt; HARMENAK & lt; / Name & gt; & Lt; Surname & gt; BADEJAN & lt; / Nickname & gt; & Lt; Father's Name & gt; VARAHAN & lt; / Father name & gt; & Lt; Date of birth & gt; 1943-10-02T00: 00: 00 + 02: 00 & lt; / Birthdate & gt; & Lt; Customer Segment & gt; Individ Standart & lt; / Customer Segment & gt; & Lt; / SearchResult & gt; & Lt; / NewDataSet & gt;  

I use all the specific name nodes, such as th output:

   

This XSLT 1.0 changes :

< Previous> & lt; Xsl: stylesheet version = "1.0" xmlns: xsl = "http://www.w3.org/1999/XSL/Transform" & gt; & Lt; Xsl: output omit-xml-declaration = "yes" indent = "yes" /> & Lt; Xsl: key name = "match =" name = "name" usage = "." / & Gt; & Lt; Xsl: template match = "/" & gt; & Lt; T & gt; & Lt; Xsl: copy-of select = "* / * / name [genera-id () = generate-id (key ('kNamesByVal',) [1])" /> & Lt; / T & gt; & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt;

When applied to the provided XML document, produces the desired, correct result :

  & lt; T & gt; & Lt; Name & gt; HAREDIN & lt; / Name & gt; & Lt; Name & gt; HARMENAK & lt; / Name & gt; & Lt; / T & gt;  

An XSLT 2.0 solution that does not use the key:

  & lt; Xsl: stylesheet version = "2.0" xmlns: XSL = "http://www.w3.org/1999/XSL/Transform" & gt; & Lt; Xsl: output omit-xml-declaration = "yes" indent = "yes" /> & Lt; Xsl: template match = "/" & gt; & Lt; T & gt; & Lt; Xsl: Selecting each group = "* / * / name" group-rate = "." & Gt; & Lt; Xsl: copy-of select = "." / & Gt; & Lt; / XSL: for each group & gt; & Lt; / T & gt; & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt;  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -