Open your own online store and grow your sales with BigCommerce. Try it Free!

What Is a Variable?

What Is a Variable?
A variable is a handy little gadget used in nearly every programming language. Not to be left out, XSLT has variables as well, but they’re quite different from those you find in Visual Basic, JavaScript, C++, or Java. They are truly their own breed.

In XSLT, a variable is used to represent something—perhaps a chunk of text, a numeric value, boilerplate HyperText Markup Language (HTML), or even a collection of XML tree nodes. But, in a manner quite different from its cousins in other languages, an XSLT variable can’t change its value after you declare it. Actually, if you want to draw any comparisons, an XSLT variable is perhaps closest to a constant in a traditional programming language. XSLT is quite powerful by using template rules and XPath expressions to transform XML into pretty much any output that you can imagine. Variables help to augment these tools by enabling you to make what techies call run-time changes (or for the rest of us, changes that happen at the time the XSLT is processed).

Run-time changes enable your transformation to adapt to a condition that exists at the time of execution rather than having all the “canned” answers prepared beforehand. Admittedly, XSLT variables are limited in their ability to do many things on the fly because you can’t modify them after they’re defined.

This entry was posted in Technology. Bookmark the permalink.

Leave a Reply