Tuesday, April 5, 2011

LaTeX code listing definition for Manchester OWL Syntax and UML Profiles

The listings package is a source code printer for LaTeX. It can be used to typeset stand alone files as well as listings with an environment as well as you can print code snippets. Many parameters control the output and if your preferred programming language isn’t already supported, you can make your own definition.

The presently supported languages don't include the following syntaxes:

  • Manchester OWL syntax: The Manchester OWL Syntax, is a new syntax that has been designed for writing OWL class expressions. Although the syntax borrows ideas from the OWL Abstract Syntax, it is much less verbose, meaning that it is quicker to write and easier to read.
  • UML Profile XML format: A profile in the UML (Unified Modeling Language) provides a generic extension mechanism for customizing UML models for particular domains and platforms. Profiles are defined using stereotypes, tag definitions, and constraints that are applied to specific model elements (such as Classes, Attributes, Operations, and Activities).
I implemented both of them, the results can be downloaded from the links below (Please note, the keywords section may be completed depending on your need.):

The following code snippet points out usage examples:

...
\usepackage{listings}


\usepackage{xcolor}      
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{light-gray}{rgb}{0.97,0.97,0.97}


...
\lstinputlisting[language=owlms]{<filename>} 
\lstinputlisting[language=umlprofile]{<filename2>}
...