How to use attribute values from another XML file as an element value selection in the current XML

前端 未结 3 1168
北恋
北恋 2021-01-07 08:40

I have two XML files. One is the main XML file and the other one is used as a lookup table. Here is the main XML:


      
                   


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-07 09:17

    This is the way I would do it (although I like Martin's use of xsl:key):

    I modified main.xml and lookup.xml to show the dynamic name lookup.

    main.xml

    
    
      
        test1
        test2
        test3
        testing new element
      
      
        test4
        test5
        test6
        testing new element again
      
    
    

    lookup.xml

    
    
      fieldA
      fieldB
      fieldC
      fieldD
    
    

    XSLT 1.0 stylesheet

    
    
      
    
      
    
      
        
          
        
      
    
      
        
          
        
      
    
      
        
          
            
      
    
      
        
        
          
        
      
    
    
    

    output

    
    
      
          test1
          test2
          test3
          testing new element
      
      
          test4
          test5
          test6
          testing new element again
      
    
    

提交回复
热议问题