Nested for-each loops, accessing outer element with variable from the inner loop

后端 未结 1 636
北海茫月
北海茫月 2021-01-01 22:53

I\'m trying to write an XSL that will output a certain subset of fields from the source XML. This subset will be determined at transformation time, by using an external XML

1条回答
  •  鱼传尺愫
    2021-01-01 23:05

    Your stylesheet looks almost fine. Just the expression $rec/$field doesn't make sense because you can't combine two node sets/sequences this way. Instead, you should compare the names of the elements using the name() function. If I understood your problem correctly, something like this should work:

    
    
        
        
            
            ...
            
            ...    
        
        
    
    

    Variable field is not required in this example. You can also use function current() to access the current context node of the inner loop:

    
    

    0 讨论(0)
提交回复
热议问题