2

[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={-},%
  }%
\lstloadlanguages{[XSLT2]XML}
\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?

[edit] 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.

2

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={-},%
  }%
\lstloadlanguages{XSLT2}
\begin{document}
This is a test
\begin{lstlisting}[language=XSLT]
<xsl:for-each-group select="db:biblioentry">
  ...
</xsl:for-each-group>
\end{lstlisting}
\end{document}
1
  • Thanks for that...I had completely misunderstood the arguments: I thought it was the other way round... – Peter Flynn May 9 '15 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.