XSLT Syntax

All XSLT documents need to be well-formed and valid XML documents, so you need to follow the same syntax rules that apply to any other XML document.

As well as ensuring that your XSLT documents are valid XML, you need to ensure they are valid XSLT documents. Here's what you need to remember when creating XSLT documents.

XML Version

XSL documents are also XML documents and so we should include the XML version in the document's prolog. We should also set the standalone attribute to no as we now rely on an external resource (i.e. the external XSL file).

XSL Root Element

Then we open the root element — xsl:stylesheet. The root element needs to include the XSL version as well as the XSL namespace (hence the xsl prefix and the xmlns... part).

XSL Namespace Prefix

All XSL elements in your XSLT document must include the XSL prefix.