Why replace one attribute by element is valid, and two attributes not?

后端 未结 3 1713
攒了一身酷
攒了一身酷 2021-01-17 05:29

In a identity transform we can delete an attribute by


this works for any input... And we can \"r

3条回答
  •  误落风尘
    2021-01-17 05:55

    It's difficult to answer your questions because some of your assumptions are wrong. For example:

    my new element
    

    works for any number of elements. When applied (together with an identity transform template) to the following input:

    
        
             
        
        
    
    

    the result will be:

    
    
       
          my new element
          
             my new element
          
       
       
          my new element
       
    
    

    So clearly your assertion that "it works only when input have only one element" is not true.

    With regard to:

    newValue
    

    This does not replace the value of myAttrib because the template matches the attribute - not its value (as an aside: the value of an attribute is not a node and cannot be matched). So just like before, the attribute is matched and another node is output in its place; first it was an element, now it's a text node. That's the only difference.


    Edit:

    The "replace procedure" is one attribute-node per one element-node.

    No, that's not true either. Consider, for example, the following input:

    
        
             
        
        
    
    

    and the following template:

    
        
    
    

    or:

    
        
    
    

    --
    BTW, none of these examples will work with Saxon - but that's another story.

提交回复
热议问题