How does apply-templates work?

前端 未结 3 513
囚心锁ツ
囚心锁ツ 2021-02-14 12:18

I have just started learning XSL(T) and I wonder how apply-templates work? I do not understand the recursively applies templates part of it as it is written in my b

3条回答
  •  无人及你
    2021-02-14 12:22

    You use to invoke the :s you have defined.

    calls a matching template for each node in the set.

    You can control processing order by specifying a select attribute on apply-templates.

    See this example from w3schools:

    
    
    
    
      
      
      

    My CD Collection

    Title:
    Artist:
    • The first apply-templates calls the cd template each time an element named "cd" is encountered.

    • The cd template, in turn calls the title and artist templates to process the children elements of .

    • title is processed before artist. Note, that the order of artist and title elements in the source XML makes no difference.

    You could think of apply-templates as analoguous to a subroutine call in procedural languages.

提交回复
热议问题