I'd like to implement some XML code in my document. However, the syntax of my listings doesn't seem to be acknowledged. So my output looks like this right now:
Obviously, that doesn't make any sense. I tried to redefine the keywords, using "more keywords" but that didn't cause the desired effect. I'm using the listings package. Could anyone help me with a correct syntax definition for my XML Listings? (It's SAPUI5 identifiers, that's why some of them are not "common")
Here's the necessary code to reproduce my document:
\documentclass[11pt, a4paper, toc = bibliography, toc = listof,twoside,table,titlepage]{scrartcl}
\usepackage{listings}
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstdefinelanguage{JavaScript}{
keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break},
keywordstyle=\color{blue}\bfseries,
ndkeywords={class, export, boolean, throw, implements, import, this},
ndkeywordstyle=\color{blue}\bfseries,
identifierstyle=\color{black},
sensitive=false,
comment=[l]{//},
morecomment=[s]{/*}{*/},
stringstyle=\color{red}\ttfamily,
morestring=[b]',
morestring=[b]"
}
\lstset{frame=tb,
language=JavaScript,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle={\small\ttfamily},
numbers=left,
numberstyle=\tiny\color{gray},
keywordstyle=\color{blue},
commentstyle=\color{dkgreen},
stringstyle=\color{mauve},
breaklines=true,
breakatwhitespace=true,
tabsize=3
}
\begin{document}
\begin{lstlisting}[caption={Aggregation Binding über die View} ,captionpos=b, language=XML, label=lst:aggregationBinding]
<Table id="table" items="{Students}>
<columns>
<Column id="matrikelnummer">
<header>
<Text text="Matrikelnummer:"/>
</header>
</Column>
<Column id="name">
<header>
<Text text="Name:"/>
</header>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<ObjectIdentifier text="{Matrikelnummer}"/>
<ObjectIdentifier text="{Name}"/>
</cells>
</ColumnListItem>
</items>
</Table>
\end{lstlisting}
\end{document}


mintedpackage. Because it uses Python and not TeX its highlighting capabilities can be more advanced in some areas (and may be easier to tweak). Possibly related: https://tex.stackexchange.com/q/10255/35864 – moewe Dec 07 '18 at 10:57\documentclass. Ideally we can just paste and run the example without adding any additional code (see the link I gave above). You may also want to remove the excessive indent of the lines (probably introduced by the code highlighting). I'm a bit confused that all your\lst...settings are forJavaScript, but your question is about XML. Do you have a specific setup for XML already? (And I'm still not sure on the expected/desired output.) – moewe Dec 07 '18 at 11:13"initems="{Students}, that should probably readitems="{Students}". With that quotation mark back in all strings have the same colour and the rest is black. You now need to manually add all keywords/code words (liketext) that need a different colour. – moewe Dec 07 '18 at 13:56