Git Product home page Git Product logo

schxslt's Introduction

SchXslt [ʃˈɛksl̩t] – An XSLT-based Schematron processor

SchXslt is copyright (c) 2018–2020 by David Maus <[email protected]> and released under the terms of the MIT license.

DOI Build Status

SchXslt is a Schematron processor implemented entirely in XSLT. It transforms a Schemtron schema document to an XSLT stylesheet that you apply to the document(s) to be validated.

Limitations

As of date SchXslt does not properly implement the scoping rules of pattern and phase variables (see #315 and #316).

Schema, pattern, and phase variables are all implemented as global XSLT variables. As a consequence the name of a schema, pattern, or phase variable must be unique in the entire schema.

Due to the constrains of XSLT 1.0 and the way rules are implemented it is not possible to use a variable inside a rule context expression of a Schematron using the XSLT 1.0 query binding (see #318).

Installation

Depending on your environment there are several ways to install SchXslt.

  • Starting with version 1.5 every release on this repository's release page provides a ZIP file with just the XSLT stylesheets. This page also provides a ZIP file with the XSLT stylesheets and two XProc 1.0 steps. Just download and unzip.

  • A Java package is published to Maven Central. Use it with Maven or the Java dependency management tool of your choice.

  • If you use BaseX or eXist you can download installable XQuery modulesq from this repository's release page as well.

Using SchXslt

XSLT Stylesheets

The simplest way to use SchXslt is to download the ZIP file with just the stylesheets from the releaes page. To validate documents with your Schematron you first transform it with the pipeline-for-svrl.xsl stylesheet. This creates the XSL transformation that creates a validation report when applied to a document.

Java applications

To use SchXslt in your Java application define the following Maven dependency:

<dependency>
  <groupId>name.dmaus.schxslt</groupId>
  <artifactId>schxslt</artifactId>
  <version>{VERSION}</version>
</dependency>

Where {VERSION} is replaced with the current SchXslt version.

Also take a look at SchXslt Java, a set of Java classes for Schematron validation with SchXslt.

XQuery

The XQuery module provides a function schxslt:validate() that validates a document and returns a validation report expressed in the Schematron Validation Report Language (SVRL). You import the module using its namespace URI.

import module namespace schxslt = "https://doi.org/10.5281/zenodo.1495494";

let $document := <ex:example xmlns:ex="https://example.com/ns"/>
let $schema :=
  <sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
    <sch:pattern>
      <sch:rule context="/">
        <sch:assert test="true()">Always true</sch:assert>
      </sch:rule>
    </sch:pattern>
  </sch:schema>

return
  schxslt:validate($document, $schema)

Ant

TBD

Command line

TBD

Building

SchXslt uses the Maven build tool to create installable packages. To create the packages for yourself clone this repository, install Maven and run it with the package phase.

dmaus@carbon ~ % git clone --recursive https://github.com/schxslt/schxslt.git
Cloning into 'schxslt'...
remote: Enumerating objects: 450, done.
remote: Counting objects: 100% (450/450), done.
remote: Compressing objects: 100% (298/298), done.
remote: Total 3789 (delta 172), reused 374 (delta 111), pack-reused 3339
Receiving objects: 100% (3789/3789), 470.87 KiB | 1.05 MiB/s, done.
Resolving deltas: 100% (1607/1607), done.

dmaus@carbon ~ % mvn package

This runs the unit tests and creates the following files:

  • core/target/schxslt-{VERSION}.jar (Java archive)
  • core/target/schxslt-{VERSION}-xslt-only.zip (ZIP file with stylesheets)
  • exist/target/schxslt-exist-{VERSION}.xar (XQuery package for eXist)
  • basex/target/schxslt-basex-{VERSION}.xar (XQuery package for BaseX)

Where {VERSION} is replaced with the current SchXslt version.

schxslt's People

Contributors

dependabot-preview[bot] avatar dmj avatar duncdrum avatar

Watchers

 avatar

schxslt's Issues

Handling of duplicate bursting rules

Suppose we have two rules like

<rule context="book" str:streaming="copy-of">

and

<rule context="book[@price > 0]" str:streaming="copy-of">

While the top level templates won't both get run, because their generated grounded templates have the same mode, the wrong one might get run (next-match should take care of multiple rules getting run).

Test shadowing

It is unclear if the shadowing avoidance actually works.

Streamable rules run without access to ancestors.

Suppose we have a sch:rule whose str:streamable="on", and another sch:rule that is set to str:streamable="copy-of". The first rule can be applied to grounded nodes from the second rule. However, in this context, the rule asserts won't have access to ancestors. This might be confusing, as vanilla streaming always provides ancestor access.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.