I found the answers of kipelovets and GuruM useful and developed this solution that combines their advice.
.ctags:
--langdef=xslt
--langmap=xslt:.xsl
--regex-xslt=/<xsl:template[^>]+name=\"([-a-zA-Z0-9_:]+)\"( +mode="([^"]+)")?/\1 \2/n,namedtemplate/i
--regex-xslt=/<xsl:template[^>]+match=\"([^"]+)\"( +mode="([^"]+)")?/\1 \2/m,matchedtemplate/i
--regex-xslt=/<xsl:apply-templates +select="([^"]{2,})"( +mode="([^"]+)")?/\1 \2/a,applytemplate/i
--regex-xslt=/<xsl:call-template +select="([^"]+)"( +mode="([^"]+)")?/\1 \2/c,calltemplate/i
--regex-xslt=/<xsl:variable[^>]+name=\"([-a-zA-Z0-9_]+)\"/\1/v,variable/i
--regex-xslt=/<xsl:function[^>]+name=\"([-a-zA-Z0-9_:]+)\"/\1/f,function/i
--regex-xslt=/<xsl:param[^>]+name=\"([-a-zA-Z0-9_:]+)\"/\1/p,parameter/i
Vim tag settings (which some people may find useful):
let g:tagbar_type_xslt = {
\ 'ctagstype' : 'xslt',
\ 'kinds' : [
\ 'n:templates (named)',
\ 'm:templates (matched)',
\ 'a:applied templates',
\ 'c:called templates',
\ 'f:functions',
\ 'p:parameters',
\ 'v:variables'
\ ]
\ }
This is better, but some issues that I still have include:
- grouping patterns by their modes
- spaces such as newlines between attributes for a template / variable, etc.
- defining variables and parameters and applying call patterns and patterns
- So, if you have several variables with the same name, but in different templates, the scope of which they are located is not fixed.
- commented patterns, functions, variables and parameters
Best approach to future search: