I'm using listings to display my codes. I'm getting some issues. First, the codes when it is too long, it is going out of page as shown here. Secondly, the codes are in SPARQL. It is recognising some of the variables I use as SQL keywords and highlighted them as shown here where Class is inspite being a variable is being highlighted as a keyword. My codes are as follows:
\begin{lstlisting}[captionpos=b, caption=Retrieval of Individuals, label=listing:sparql_getallindividuals,
basicstyle=\ttfamily]
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wo: <http://purl.org/ontology/wo/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?individual ?type ?name
WHERE
{ ?individual rdf:type ?type .
?individual wo:commonName ?name
FILTER ( ?type IN (wo:Kingdom, wo:Phylum, wo:Class, wo:Order, wo:Species, wo:Family, wo:Genus) )
}
\end{lstlisting}
Any help would be greatly appreciated
This is preamble of my report:
\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}
\definecolor{darkblue}{rgb}{0.0,0.0,0.6}
\definecolor{cyan}{rgb}{0.0,0.6,0.6}
\lstset{frame=tb,
language=Java,
showstringspaces=false,
columns=flexible,
numbers=none,
commentstyle=\color{dkgreen},
stringstyle=\color{mauve},
tabsize=3
}
\lstdefinelanguage{XML}
{
morestring=[b]",
morestring=[s]{>}{<},
morecomment=[s]{<?}{?>},
stringstyle=\color{black},
identifierstyle=\color{darkblue},
keywordstyle=\color{cyan},
morekeywords={xmlns,version,type,ma-id}% list your attributes here
}

minteddoesn't wrap long lines unlikelistings, see http://tex.stackexchange.com/questions/23663/minted-truncates-the-code-if-it-doesnt-fit-into-one-page, for sparql highlighting, see http://tex.stackexchange.com/questions/14927/listing-syntax-highlighting-for-sparql-query – ArTourter Aug 06 '13 at 23:10