# Can you apply XSLT transforms using Sublime Text 2

sublime-text-2xslt

Scenario:
I have a project with a number of XML files and I would like to apply a XSLT transform on these and then use that output for other purposes.

There is a variety of tools to do this, but it would be nice to be be able to stay in the editor while debugging/using the transform.

If you have 3 different files you need, you can use first-line (or second if you need utf8 stuff) comments. I use it to compile the main TeX file from one of the children.

%!../main_file.tex
\documentclass[12pt,a4paper]{scrartcl}

\usepackage[czech,english]{babel}


I have a script, which looks at the first line:

match=head -n1 $1 | grep %! if [[$match ]]
then
# do stuff with the parent's name, which is ${match:2:100} else # no match :/ fi  and a simple build file aiming at my custom script: { "cmd": ["/path/to/build/script.sh", "$file"],
"selector": "whatever"
}


This way, you can have as many "references" in your files as you want. Just switch the value of head -n1.

In XML, you would probably use <!--%somefilename --> with head -n1 $1 | grep '<!--%' and ${match:5:100}.

To end with, I present to you my XeLaTeX build script ;)

#!/bin/bash
file="$1" flag="-halt-on-error" match=head -n1$file | grep %!

if [[ $match ]] then if [${match:2:3} = ../ ]
then
cd .. &&
target=${match:5:100} else target=${match:2:100}
fi
else
target=$file fi rubber -c 'set arguments -shell-escape' -f -m xelatex -W all$target

exit 0