XSLT xsl:sequence. What is it good for..?

后端 未结 4 622
北恋
北恋 2020-12-24 05:28

I know the following question is a little bit of beginners but I need your help to understand a basic concept.

I would like to say first that I\'m a XSLT programmer

4条回答
  •  无人及你
    2020-12-24 06:01

    on an atomic value (or sequence of atomic values) is the same as both just return a copy of their input. The difference comes when you consider nodes.

    If $n is a single element node, eg as defined by something like

    
    

    Then

    
    

    Returns a copy of the node, it has the same name and child structure but it is a new node with a new identity (and no parent).

    
    

    Returns the node $n, The node returned has the same parent as $n and is equal to it by the is Xpath operator.

    The difference is almost entirely masked in traditional (XSLT 1 style) template usage as you never get access to the result of either operation the result of the constructor is implicitly copied to the output tree so the fact that xsl:sequence doesn't make a copy is masked.

    
       
       
       
    
    

    is the same as

    
        
        
        
    
    

    Both make a new element node and copy the result of the content as children of the new node x.

    However the difference is quickly seen if you use functions.

    
    
        
            hello
        
    
        
            ::
            :: 
            :: 
            ::
            :: 
            :: 
            ::
        
    
        
            
            
        
    
        
            
            
        
    
    
    

    Produces

    $ saxon9 -it main seq.xsl
    
    ::
    :: true
    :: false
    ::
    :: 1
    :: 0
    ::
    

    Here the results of xsl:sequence and xsl:copy-of are radically different.

提交回复
热议问题