VIM Functions and Menu Items for Writing XSL

31 July 2008
by Billy Czajkowska

Add the following lines to a myxsl.vim file and place it in your VIM plugins directory.
The next time you start VIM, you will have a menu called “lf” appear with the following items
listed that allow you to create more xsl code with less typing.
Note that you must also add the VIM utility functions listed in a previous blog article, found here:
http://www.littleforest.co.uk/vim-unix/vim-toolkit-functions/
amenu lf.xsl:template w name :call XslTemplateWithName()<CR><ESC>
amenu lf.xsl:call-template :call XslCallTemplate()<CR><ESC>
amenu lf.xsl:param :call XslParam()<CR><ESC>
amenu lf.xsl:with-param :call XslWithParam()<CR><ESC>
amenu lf.xsl:if :call XslIf()<CR><ESC>
amenu lf.xsl:choose :call XslChoose()<CR><ESC>
amenu lf.xsl:when :call XslWhen()<CR><ESC>
amenu lf.xsl:otherwise :call XslOtherwise()<CR><ESC>
amenu lf.xsl:variable :call XslVariable()<CR><ESC>
amenu lf.xsl:value-of :call XslValueOf()<CR><ESC>
amenu lf.xsl:text :call XslText()<CR><ESC>
amenu lf.xsl:for-each :call XslForEach()<CR><ESC>
amenu lf.xsl:sort :call XslSort()<CR><ESC>
func! XslTemplateWithName()
let n=inputdialog(“Template Name”)
call P(“<xsl:template name=”” . n . “”>”)
call P(“</xsl:template>”)
call Up()
endf
func! XslForEach()
let n=inputdialog(“Select Expression”)
call P(“<xsl:for-each select=”” . n . “”>”)
call P(“</xsl:for-each>”)
call Up()
endf
func! XslCallTemplate()
let n=inputdialog(“Template Name”)
call P(“<xsl:call-template name=”” . n . “”>”)
call P(“</xsl:call-template>”)
call Up()
endf
func! XslSort()
let n=inputdialog(“Sort Select Expression”)
call P(“<xsl:sort select=”” . n . “”/>”)
endf
func! XslParam()
let n=inputdialog(“Param Name”)
call P(“<xsl:param name=”” . n . “”/>”)
endf
func! XslWithParam()
let n=inputdialog(“Param Name”)
let v=inputdialog(“Param Value”)
call P(“<xsl:with-param name=”” . n . “”>” . v . “</xsl:with-param>”)
endf
func! XslIf()
let n=inputdialog(“Test Expression”)
call P(“<xsl:if test=”” . n . “”>”)
call P(“</xsl:if>”)
call Up()
endf
func! XslChoose()
call P(“<xsl:choose>”)
call P(“</xsl:choose>”)
call Up()
endf
func! XslAttribute()
let n=inputdialog(“Attribute Name”)
call P(“<xsl:attribute name=”” . n . “”>”)
call P(“</xsl:attribute>”)
call Up()
endf
func! XslText()
call P(“<xsl:text></xsl:text>”)
endf
func! XslWhen()
let n=inputdialog(“Test Expression”)
call P(“<xsl:when test=”” . n . “”>”)
call P(“</xsl:when>”)
call Up()
endf
func! XslOtherwise()
call P(“<xsl:otherwise>”)
call P(“</xsl:otherwise>”)
call Up()
endf
func! XslVariable()
let n=inputdialog(“Variable Name”)
let v=inputdialog(“Variable Value”)
call P(“<xsl:variable name=”” . n . “”>” . v . “</xsl:variable>”)
call Up()
endf
func! XslValueOf()
let n=inputdialog(“Variable Name”)
call P(“<xsl:value-of select=”” . n . “”/>”)
endf
 

Our Latest News