Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "xsd"

Title:XML Schema validation with Prolog
Rating:Not rated. Create the first rating!
Latest version:0.2.1
SHA1 sum:b777694e81dbc038c19737fefbe2f00add4ac1c9
Author:Falco Nogatz <fnogatz@gmail.com>
Jona Kalkus <jonakalkus@gmail.com>
Maintainer:Falco Nogatz <fnogatz@gmail.com>
Packager:Falco Nogatz <fnogatz@gmail.com>
Home page:https://github.com/jonakalkus/xsd
Download URL:https://github.com/jonakalkus/xsd/releases/*.zip
Requires:regex
tap

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
0.1.0b84df8f5631d0d376be83cf8a570e29ad8148e0b1http://falco.io/xsd-0.1.0.tgz
0.1.2a7cf22ec8a35ea1fb0a8c7ff01a0870a188222a92https://github.com/jonakalkus/xsd/archive/v0.1.2.zip
0.1.4caf4e536ad9506367948c22d0dcc5a103a731cb01https://github.com/jonakalkus/xsd/archive/v0.1.4.zip
0.1.57a8b2e09bc947b8c92f63bd35af5f5a720de64532https://github.com/jonakalkus/xsd/archive/v0.1.5.zip
0.1.6bb8dedb347c0564ccf2ff009bb3df0f6ef98148534https://github.com/jonakalkus/xsd/archive/v0.1.6.zip
0.1.7936d8d8f9e318b6e9ff7ab6d24a6176189b66b1f1https://github.com/jonakalkus/xsd/archive/v0.1.7.zip
0.2.00d6ad6222447981de39617ca4ab3c63a63e289db28https://github.com/jonakalkus/xsd/archive/v0.2.0.zip
b6e4dccd0687138fdc059a2cdbcc161f1fc52b7a13https://github.com/jonakalkus/xsd.git
0.2.1b777694e81dbc038c19737fefbe2f00add4ac1c93https://github.com/jonakalkus/xsd/archive/v0.2.1.zip

XML Validator in SWI-Prolog

Validate an XML Document against an XML Schema in SWI-Prolog.

Installation

First of all, you need SWI-Prolog. Take a look at the official website for installation instructions.

After that, you have to install the latest version of the regex library. Installation instructions for this library can be found with the provided link.

If you are a developer of this project, you must also install the tap library in order to successfully execute our tests.

Pre-Compilation

It is possible to create a pre-compiled file which increases the tool's performance significantly. The command line interface is compiled using swipl's -c option:

swipl -g main -o cli.exe -c cli.pl

The `.exe` suffix is chosen for compatibility with Windows systems.

Usage as CLI

A command line interface is provided, too. You can directly execute it via

swipl -g main cli.pl -- schema.xsd instance.xml

Call with `--help` instead of the filenames to get more options.

After the pre-compilation step mentioned before, the created executable can be called via:

./cli.exe schema.xsd instance.xml

Usage with SWI-Prolog

The library(xsd) exports the following predicates:

  • xsd_validate(+Schema, +Document)
    Validates an XML Document with Identifier `Document` against an XML Schema `Schema`.

    The library(xsd/flatten) exports the following predicates:

  • `xml_flatten(+Input, ?Identifier)`
    Loads an XML file from source `Input` into the prolog database.
    An `Identifier` can be freely chosen, otherwise it will be generated.
  • remove_file(+Identifier)
    Deletes all nodes corresponding to `Identifier` from the prolog database.

Example Call

?- use_module(library(xsd)),
   xsd_validate('path/to/schema.xsd', 'path/to/instance.xml').

XML File Representation

Once an XML file is loaded using xml_flatten/2, it will be represented by the following predicates:

  • node(File_ID, ID, Namespace, Node)
    Each node in the document `File_ID` is represented by a node/4 fact with the unique identifier `ID`. Also, the namespace and the name of the element are stated.
  • node_attribute(File_ID, ID, Attribute, Value)
    For every attribute a `node_attribute/4` fact is generated. It stores the `Attribute` and `Value` of an attribute associated to node `ID` inside document `File_ID`.
  • text_node(File_ID, ID, Node)
    Text inside the document `File_ID` is represented as `text_node/3` facts. These have unique identifiers like regular document nodes and store the text `Node`.

Supported Features

Please see FEATURES.md for the full list of currently supported components of the XML Schema Definition Language.

Environment

Developed and tested in SWI-Prolog, version 7.4.1, 64 bit.

Background

This tool has been developed as part of a practical course at the University of Würzburg, Germany. It contains contributions of:

  • Kevin Jonscher
  • Jona Kalkus
  • Lucas Kinne
  • Falco Nogatz Please cite the work as: Nogatz, F., Kalkus, J.: Declarative XML Schema Validation with SWI-Prolog. In: Seipel, D., Hanus, M., and Abreu, S. (eds.) Declarative Programming and Knowledge Management. pp. 187-197 (2018). In this paper, we present the general idea of the validation process and give some examples.

Contents of pack "xsd"

Pack contains 205 files holding a total of 258K bytes.