How can I select nodes from a tree whose markup is stored in a variable?

前端 未结 2 1014
北荒
北荒 2021-01-06 19:38

Consider the following XSLT script:




        
2条回答
  •  爱一瞬间的悲伤
    2021-01-06 20:07

    A posting by M. David Peterson just taught me how to make this work:

    It's not necessary to have an for this case. Instead, I can embed the data document directly into the XSL stylesheet (putting it into a namespace for sanity) and then select elements from that. Here's the result:

    
    
    
    
    
    
    redrot
    greengruen
    blueblau
    
    
    
    
        
    
    
    
    
    

    This generates the expected output redgreenblue.

    The trick is to use document('') to get a handle to the XSLT document itself, then * to get into the toplevel xsl:stylesheet element and from there I can access the color map.

提交回复
热议问题