count the number of words in a xml node using xsl

前端 未结 3 1532
青春惊慌失措
青春惊慌失措 2021-01-12 19:36

Here is the sample xml document.


   count the number of words 

For this example I want

3条回答
  •  不知归路
    2021-01-12 20:24

    in xslt i think you would need to process to remove any double spacing and then count the remaining spaces to find an answer. although im sure there are better ways!

    
    
    
    
    
            
                    
                            
                            
                    
            
    
    
        
                
                
                
                                
    
                
                        
                                
                                        
                                        
                                
                        
                        
                                no words...
                        
                        
                                
                        
                                
        
    
    
    

    this example code works, ammended it from a stylesheet i had which was processing some legacy code into usefull html output!

    updated code to improve against errors, catches duplicate whitespace and also catches empty nodes :>

    Updated to solve additional problem!

     
            
    
            
            
                    
                            
                            
                            
                            
                    
            
    
    
    
            
            
            
            
            
            
                    
                            
                                      
                            
                            
                                    
                            
                    
             
            
            
                    
                            
                                    
                            
                            
                                    
                            
                    
                    
            
                    
                            
                                    
                            
                            
                                    
                            
                    
            
    
            
                    
                                                    
                                    
                                    
                                    
                                    
                            
                    
                    
                            it was empty
                    
                    
                            
                            wordcount:
                            pass:
                            fail:

提交回复
热议问题