# The Functional XML Parser

## Contents

| About fxp
| fxp Versions and Changes
| Where to get fxp
| How to install fxp
| Example Applications: fxp, fxcanon, fxcopy, fxesis, and fxviz.

### What is fxp?

fxp is a validating XML parser written completely in the functional programming language SML. fxp can validate both XML 1.0 and XML 1.1 documents. It has a programming interface allowing for production of XML applications based on fxp. It comes with four example applications:

| fxp, the pure parser. It parses a document and finds well-formedness errors, validity errors and other problems;
| fxcanon produces an equivalent canonical XML document. Canonical XML was invented by James Clark for testing XML parsers. It contains only the information a processor is required to pass to the application;
| fxcopy reproduces the document parsed by fxp. The copy can be generated in a different encoding than the input, and can be normalized in different ways concerning, e.g., expansion of entity references;
| fxesis adds a backend to fxp, producing an output similar to nsgmls's ESIS (Element Structure Information Set) output;
| fxviz is an XML tree visualizer. It produces a graph description suitable as input to Georg Sander's vcg.

More features of fxp are here.

### fxp Versions and Changes

The current version of fxp is 2.0. Changes from the previous versions are described here.

### Downloading fxp

The source code for fxp can be downloaded by http. The Copyright note is here.

### Installation instructions

In order to install fxp, you need an SML compiler. It has been tested with the stable versions 110.0.7 and 110.0.6 of SML of New Jersey. (If you need to use a working version of the SML compiler look here.) The compiler must have the compilation manager (CM) built in, which is the default when installing SML-NJ. We successfully compiled fxp on Linux. For other unices we expect no problems. An installation using the Windows version of SML-NJ is documented here.

These are the steps for installing fxp under Unix:

1. Download the latest version of fxp;
2. Unpack the sources, and change to the fxp directory, e.g.:

        gunzip -c fxp-2.0.tar.gz | tar xf -
        cd fxp-2.0

3. Read the `COPYRIGHT`;
4. Edit the `Makefile` according to your needs. Probably you will only have to change the following:

- `INSTALL_PROGS` is the list of programs to be installed. fxlib is required if you want to develop applications with fxp. The fxgrep XML query language and the fxt XML transformation language also need fxlib being installed.
- `FXP_BINDIR` is where the executables are installed;
- `FXP_LIBDIR` is where other files needed by fxp - the heap images and the library -- are installed;
- `SML_BINDIR` is the directory where the SML executables are found. It must contain the `.arch-n-opsys` script from the SML-NJ distribution, so make sure that this is where SML-NJ is physically installed;
- `SML_EXEC` is the name of the SML executable. This is the program that is called for generating the heap image and at execution of fxp. If `sml` will be in your `PATH` at execution time, you don't need the full path here.
- `SML_MAKEDEF` is for defining the `make` command in SML. After version 110.0.3, SML-NJ changed the type of `CM.make'`. Therefore it is wrapped into the `make` defined by this variable. For working versions of SML-NJ, use the second variant of this definition.

5. Edit the file `src/config.sml` according to your needs. Currently only a single value can be configured here:

- `retrieveCommand` is the command to be used by fxp for retrieving a remote URI from the internet and storing it in a temporary file on the local file system. It is a string value and should contain the strings `%1` and `%2`, where

- `%1` is replaced by the URI;
- `%2` is replaced by the local filename.

It is recommended that the command exits with failure in case the URI cannot be retrieved. If the command generates a HTML error message instead (like, e.g., `"lynx -source %1 > %2"`), this HTML file is considered to be XML and will probably cause a mess of parsing errors. If you don't need URI retrieval, use `"exit 1"` which always fails on Unix. Sensible values are, e.g:

- `"wget -qO %2 %1"`
- `"got_it -o %2 %1"`
- `"urlget -s -o %2 %1"`

6. Compile fxp by typing `make`;
7. Install fxp by typing `make install`.
8. If you want to use fxviz, you should also install vcg.

### fxp's Programming Interface

Here is a document describinng the programming interface

### fxp's feedback address

Any feedback related to fxp is welcome to:

### Credits:

The author of fxp is Andreas Neumann. fxp is maintained and updated by Alexandru Berlea.