Output element in comments

前端 未结 4 1219
谎友^
谎友^ 2020-12-20 12:51

I need to display HTML-element in comments (for example)


I use th

4条回答
  •  感动是毒
    2020-12-20 13:28

    From http://www.w3.org/TR/xslt#section-Creating-Comments:

    The xsl:comment element is instantiated to create a comment node in the result tree. The content of the xsl:comment element is a template for the string-value of the comment node.

    For example, this

    This file is automatically generated. Do not edit!

    would create the comment

    It is an error if instantiating the content of xsl:comment creates nodes other than text nodes. An XSLT processor may signal the error; if it does not signal the error, it must recover by ignoring the offending nodes together with their content.

    It is an error if the result of instantiating the content of the xsl:comment contains the string -- or ends with -. An XSLT processor may signal the error; if it does not signal the error, it must recover by inserting a space after any occurrence of - that is followed by another - or that ends the comment.

    So, in order to do what you want you need to use DOE mechanism.

    As example, this stylesheet:

    
        
        
            
        
        
            
                
            
            
                
                
                    
                
            
        
        
            
            
            >
            
            
        
        
            
            
            />
        
        
            
        
    
    

    With this input:

    
        http://example.org/image1.jpg
        http://example.org/image2.jpg
        http://example.org/image3.jpg
    
    

    Output:

    
        
        
        
        
    
    

    Note: node-set extension function for two pass transformation. disable-output-escaping attribute for xsl:value-of instruction.

提交回复
热议问题