xslt to skip already “visited” nodes

后端 未结 3 1619
故里飘歌
故里飘歌 2021-01-05 05:16

not sure if this is possible without having to go through several passes, but I\'ll ask anyway (my XSL is a little rusty)

I have an XML document, which contains node

3条回答
  •  一个人的身影
    2021-01-05 05:50

    This transformation:

    
     
    
     
    
     
      
       
      
    
     
    
     
       
    
    struct 
    {
      
    };
      
      
       
      
     
    
     
      
     
    
    

    when applied on the provided XML document:

    
     
       
       
       
     
    
     
       
       
     
    
     
       
       
       
     
    
    

    produces the wanted, correct result:

    struct STRUCT_C
    {
       FIELD_E e;
       FIELD_F f;
       FIELD_G g;
    };
    
    
    struct STRUCT_B
    {
       STRUCT_C c;
       FIELD_E e;
    };
    
    
    struct STRUCT_A
    {
       STRUCT_B b;
       STRUCT_C c;
       FIELD_D d;
    };
    

    Explanation: structure elements are processed strictly one by one. At any time we process the first structure element whose id isn't yet registered in the pVisited parameter and that has no field/@idref value that isn't already in the pVisited parameter and refers to an existing structure element.

提交回复
热议问题