XSLT: Sorting based on sum of values from other nodes

后端 未结 2 654
抹茶落季
抹茶落季 2021-01-20 03:27

I\'m rather new to coding xslt and have got rather stuck trying to do the following.

I have an xml file that has breeding info for horses broken into two main sectio

2条回答
  •  情歌与酒
    2021-01-20 03:53

    You need to use current():

    
        
    

    current() gives you the context node as it is outside of the current XPath expression; in this case, the current element selected by xsl:apply-templates. Inside the predicate, the context node is the element that's being tested against the predicate expression.

    Notes:

    • You had a @ in there that you don't want; @ID refers to an ID attribute.
    • I replaced descendant::/ with //
    • As @Dimitre noted, your stylesheet will scale better to large input if you use keys instead of //foo[barID = current()/ID].

提交回复
热议问题