XPATH or XSL to match two node-sets using custom comparison

前端 未结 4 1067
鱼传尺愫
鱼传尺愫 2021-01-01 06:22

EDIT: I also have access to ESXLT functions.

I have two node sets of string tokens. One set contains values like these:

/Geography/N         


        
4条回答
  •  南笙
    南笙 (楼主)
    2021-01-01 07:04

    I guess I couldn't make the XPath above work. I started with the following XML doc to initialize the two nodesets:

    
    
      
        /Geography/North America/California/San Francisco
        /Geography/Asia/Japan/Tokyo/Shinjuku
      
      
        /Geography/North America/
        /Geography/Asia/Japan/
      
    
    

    I think this stylesheet ought to implement Robert's solution, but I only get a count of '1':

    
    
    
      
    
      
        
        
        
        
    
      
    
    
    

    I did write a stylesheet that uses a recursive template and does produce the correct count of '2' with the given input doc, but it's far less elegant than Robert's answer. If only I could get the XPath to work--always wanting to learn.

提交回复
热议问题