How can you deal with embedded XML tags in XSLT?

前端 未结 4 819
鱼传尺愫
鱼传尺愫 2020-12-31 09:25

I am using XSLT to convert XML to HTML. I am having trouble figuring out how to deal with embedded XML nodes for formatting. For example, let\'s say I have the XML element:<

4条回答
  •  天命终不由人
    2020-12-31 09:56

    However, during XLST, the tag gets ignored, so "Star Wars" is not italicized in the HTML output. Is there a relatively simple way to fix this?

    Your problem is here:

    The instruction is used to create a text node. In doing so it copies to the output the string value of the XPath expression specified in the select attribute of this XSLT instruction. The string value of an element is the concatenation of all its text-node descendents.

    So this is how you get the reported output.

    Solution:

    Use the instruction, which copies all the nodes that are specified in its select attribute:

    Another solution, more alligned with the principles of XSLT avoids using at all:

    
     
    
     
      
        
        
         
        
      
     
    
     
      
  • When any of the two solutions defined above are applied to the provided XML document:

    
        the 
            Star Wars saga
        
    
    

    the wanted, correct result is produced:

    
        
        
            
    • the Star Wars saga

提交回复
热议问题