xml - XSLT 2.0 sorting with key position and zero values -



xml - XSLT 2.0 sorting with key position and zero values -

im stuck xslt sorting problem:

i'd able sort list of elements according key (weight). key position in sorted list result. problem input list has key-position values 0 , result should maintain these order when no position assigned.

example: input list:

<document> <html weight="7"><data>aaa</data></html> <news weight="5"><data>bbb</data></news> <news weight="2"><data>ccc</data></news> <asset weight="0"><data>ddd</data></asset> <news weight="0"><data>eee</data></news> <news weight="0"><data>fff</data></news> <news weight="0"><data>ggg</data></news> <news weight="0"><data>hhh</data></news> <asset weight="0"><data>iii</data></news> <html weight="0"><data>jjj</data></news> </document>

goal:

<document> <asset weight="0"><data>ddd</data></asset> <news weight="2"><data>ccc</data></news> <news weight="0"><data>eee</data></news> <news weight="0"><data>fff</data></news> <news weight="5"><data>bbb</data></news> <news weight="0"><data>ggg</data></news> <html weight="7"><data>aaa</data></html> <news weight="0"><data>hhh</data></news> <asset weight="0"><data>iii</data></news> <html weight="0"><data>jjj</data></news> </document>

data node content no matter in sorting algorithm.

<asset weight="0"><data>ddd</data></asset> must first "zero" weight item because there isn't weight=1 in input list. <news weight="2"><data>ccc</data></news> sec element because weight=2=position in result list. <news weight="0"><data>eee</data></news> must sec "zero" because there isn't weight=3 in input list. , on

thanks

xml sorting xslt xslt-2.0

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -