ModPro Compiler

This page explains how to use the ModPro MPC compiler.

Compiler Overview
Running the Compiler
Compiler Parameters

Compiler Overview

The ModPro compiler takes XML files containing MPML and compiles them into HTML. Your XML documents must be well-formed and valid and the root element must be <mpml> or the compile will fail.

When you compile your files the first thing it does is preprocessing. The preprocessor inserts included files into the main document. Next the XSL transformer starts processing the document using the XSL files specified for the page. Finally, if there are no errors, the result is saved to an HTML file.

The compiler caches included files and XSL files since most of your pages will use the same includes. The compiler also keeps track of dependencies for each MPML file so that it will only be compiled again when it or one of its dependencies has changed.

Running the Compiler

The ModPro compiler is written in Java and can be called using the following command where %mp_path% is the path to where ModPro is installed.

java -cp %mp_path%\lib\mpml.jar com.worldtree.mpml.MPC

However, there is a batch file you should use that makes it easier to run the compiler. You compile by running the batch file called mpc.bat. This starts the Java Virtual Machine and calls the MPML compiler with the compiler parameters you specified. Here's what a typical call to start the compiler will look like.

mpc *.xml -out:../html/*.html

This tells the compiler to compile all files in the current directory that have the extension ".xml" and save them to the html directory with the ".html" extension.

Compiler Parameters

This is a list of the command line parameters that can be used with the compiler. Here is the format of the command line.

mpc [-out:name] [-xsl:name*] [-verbose|quiet] [-rebuild] [-pre] [-project:name] files

  • -out:name = Name of output file or pattern for one or more output files (ex. -out:*.html).
  • -xsl:names = Names of xsl files used to transform the xml, seperated by semicolons (ex. -xsl:mpml.xsl;nav.xsl).
  • -verbose = Show more compiler output.
  • -quiet = Show no compiler output except errors.
  • -rebuild = Force rebuild of all files.
  • -pre = Preprocess only and place xml files in output directory specified by -out.
  • -project:name = Name of a ModPro project file that contains MPC commands.
  • files = List of one or more xml files to compile. May include wildcards (ex. index.xml or *.xml)

-out:name
The -out argument tells the compiler where and what to save the compiled HTML file(s) as. This can be an explicit file name if you only specified one source file, or you can use a wildcard to tell it where to save a set of files. For instance, if you want all compiled HTML files saved to the html directory with the extension .html you would specify html/*.html. The star (*) will be replaced with the name of the source file. If not specified the defualt is -out:*.html, which will put the html files in the same directory as the source files.

Examples

mpc -out:index.html index.xml
mpc -out:*.html index.xml page1.xml
mpc -out:html/*.html src/*.xml

-xsl:name
The -xsl argument tells the compiler what XSL files to use. It is followed by a semi-colon separated list of XSL file names. If you specify the XSL files to use inside your MPML file using <xml-stylesheet> processing instructions you don't need use this argument. This option is equivalent to creating an XSL file that simply includes the specified XSL files.

mpc xsl:../xsl/mpml.xsl index.xml
mpc -xsl:../xsl/mpml.xsl;myComponents.xsl;navigation.xsl *.xml

-verbose|quiet
Use -verbose if you want to see more output from the compiler, such as how long it took to compile each file. Use -quiet if you don't wan to see any output from the compiler except for error messages. These options are mutually exclusive so you can't use them both at the same time.

mpc -quiet -out:*.html *.xml

-rebuild
Forces the compiler to rebuild all files regardless of whether or not they are out of date.

mpc -rebuild -out:*.html *.xml

-pre
Instructs the compiler to preprocess only. When using this parameter no HTML files are generated and the -out parameter is used to tell it where to save the preprocessed files. This is useful for debugging when you want to see what your MPML files look like after the included files have been inserted.

mpc -pre -out:temp/*.xml *.xml

-project:name
Tells the compiler to use a ModPro project file. The project file is an XML file that contains MPC commands. For more complex web sites using a project file makes compiling faster and easier.

mpc -project:myProject.xml

files
Any arguments that don't begin with a dash (-) are considered to be the name of an MPML source file. You can specify files by name explicitly or use wildcards to specify a set of files that match the pattern. All file names can be relative to the current directory or absolute.