# Listings “cannot load requested language” after newly-defined dialect

[Note that this is not a duplicate of ajeh's question]

I have defined a new XSLT2 dialect of XML for the listings package which includes some extra keywords beyond XSLT, but I can't get it to recognise this: I get the error message

! Package Listings Error: Couldn't load requested language.

See the Listings package documentation for explanation.
Type  H <return>  for immediate help.
...

l.10 \begin{lstlisting}[language=XSLT2]

! Package Listings Error: language xslt2 undefined.


(also weird is that it quotes xslt2 in lowercase, but that's probably a different matter).

Here is the MWE (extra keywords cut):

\documentclass{article}
\usepackage{listings}
\lstdefinelanguage[XSLT2]{XML}% copied from lstlang1.sty
{morekeywords={xsl:for-each-group},%
alsodigit={-},%
}%
\begin{document}
This is a test
\begin{lstlisting}[language=XSLT2]
<xsl:for-each-group select="db:biblioentry">
...
</xsl:for-each-group>
\end{lstlisting}
\end{document}


What am I doing wrong?

 I am aware that I can use [language={[XSLT2]XML}], but if I use the existing XSLT language I don't have to do {[XSLT]XML}...how do I implement it so that it works in the same way? I have tried using \lstset{defaultdialect=[XSLT2]XML} but it has no effect.

You don't want to define a dialect but a new language based on xml, so your syntax is wrong. It should be

\documentclass{article}
\usepackage{listings}
\lstdefinelanguage{XSLT2}[]{XML}% changed
{morekeywords={xsl:for-each-group},%
alsodigit={-},%
}%