How to match this OR that in an xsl template?

前端 未结 1 1533
陌清茗
陌清茗 2020-12-21 18:56

In my Sharepoint fldtypes_custom.xsl file, I have this code, which works perfectly. However, I want to use the same code on three or four similar fields.

相关标签:
1条回答
  • 2020-12-21 19:31

    Is there a way I can match fields named status1 OR status2, OR status3 in the same template?

    Use:

    <xsl:template match="status1 | status2 | status3">
      <!-- Your processing here -->
    </xsl:template>
    

    However, I see from the provided code, that the strings "status1", "status2" and "status3" aren't element names -- they are just possible values of the Name attribute of the FieldRef element.

    In this case, your template could be:

    <xsl:template match="FieldRef
         [@Name = 'status1' or @Name = 'status2' or @Name = 'status3']">
      <!-- Your processing here -->
    </xsl:template>
    

    In case there are many possible values for the Name attribute, one can use the following abbreviation:

    <xsl:template match="FieldRef
         [contains('|status1|status2|staus3|', concat('|',@Name, '|'))]">
      <!-- Your processing here -->
    </xsl:template>
    
    0 讨论(0)
提交回复
热议问题