sorting - XSLT recursive sort by attribute -


I get a lot of questions and answers about nested / recursive sort using the XSLT, but in my case map it Was not able to.

My status:

  • The "set" element can contain 0 or more "properties" elements
  • In a "set" element, 0 Or more subset
  • The attribute in both sets and property elements is made up of "key"
  • I want to sort "set" according to the "key" attribute and "per set". The "key" of the "properties" elements

    The XML looks like this:

      & lt; Set key = "..." & gt; & Lt; Property Key = "..." /> & Lt; Property Key = "..." /> & Lt; Property Key = "..." /> & Lt; Set = "..." & gt; & Lt; Set key = "... ... gt; property key =" ... "/> property key =" ... "/> & gt; asset key =" ... "/> & Lt; / set & gt; & lt; / set & gt; & lt; / set & gt;   

    suggestions?

    In simple situations it can be obtained like this:

        gt; & lt; / xsl: apply-template & gt; & lt; / xsl: copy & Gt; & lt; / xsl: template & gt; & lt; / xsl: stylesheet & gt;   

    apply to this XML:

      & lt ; Set key = "1" & gt; & lt; multiplier key = "6 property key =" 8 "/> gt; & Gt; Property Key = "1" /> gt; & Gt; Set = "3" & gt; & Lt; Set key = "0" & ​​gt; & Lt; Property Key = "4" /> Property Key = "2" /> gt; & Lt; Property Key = "9" /> gt; & Lt; / Set & gt; & Lt; / Set & gt; & Lt; / Set & gt;   

    The result will be:

      & lt; Set key = "1" & gt; Property key = "1" & gt; & Lt; / Property & gt; & Lt; Set key = property key = "2" & gt; & Lt; / Property & gt; Property key = "4" & gt; & Lt; / Property & gt; Property key = "3" & gt; Set key = "0" & ​​gt; 9 "& gt; Property key =" 8 "& gt; & lt; / property & gt; & lt; / lt; / Property & gt; & lt; / set & gt; Property key =" 6 "& gt;    

    I think the real-life app is more complex, but your example does not show as such .

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -