Download the PHP package mmnewmedia/schematron-parser without Composer
On this page you can find all versions of the php package mmnewmedia/schematron-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mmnewmedia/schematron-parser
More information about mmnewmedia/schematron-parser
Files in mmnewmedia/schematron-parser
Package schematron-parser
Short Description XPath expression parser and compiler for Schematron rule files
License BSD-3-Clause
Informations about the package schematron-parser
mmnewmedia/schematron-parser
XPath expression parser and compiler for Schematron rule files in PHP.
The library tokenizes and parses XPath 1.0 expressions into an AST, compiles them into executable
PHP code, and can generate one PHP rule class per sch:assert / sch:report from a .sch
file. It powers the pure-PHP EN 16931 / Factur-X / ZUGFeRD Schematron validation
(no Java required at runtime).
Requirements
- PHP ^8.4
ext-dom,ext-mbstring
Installation
Overview
Parsing and compiling XPath expressions
XPathAstCompiler also accepts the AST directly ($parser->parse(...) + $compiler->compile(...)),
and individual XPath functions can be compiled with a plain new XPathAstCompiler([]) if no
function library is needed.
The compiler ships implementations for the XPath 1.0 core functions plus the extensions used by
EN 16931 schematron (upper-case, lower-case, matches, tokenize, distinct-values,
starts-with, ends-with, exists, empty, xs:date, xs:decimal, …) under
Compiler/Functions/. Custom functions implement XPathFunctionInterface (or
NodeSetAwareFunctionInterface) and are picked up by FunctionLoader.
The discovered class list is cached per directory/namespace, so repeated load() calls do not
rescan the filesystem. Call FunctionLoader::clearCache() if the functions directory changes
at runtime.
Generating rule classes from a .sch file
Each sch:assert / sch:report becomes a final class with:
CLI
Compiles a single Schematron file: every sch:assert / sch:report is written as a PHP rule
class into <outputDir>, using <namespace> as the generated class namespace.
Codedb lookups
Some Factur-X rules resolve codelist entries at runtime via CodedbCodeList::has(), which scans
codedb XML files. Point it at your files before evaluating generated rules:
Without configuration it looks in <base>/data/zugferd/{_generated,_preprocessed,_XSLT}.
Tests
Static analysis
Psalm runs with errorLevel="5" (mirroring the original project configuration).
License
This project is licensed under the BSD 3-Clause License. See the LICENSE file for the full text.
All versions of schematron-parser with dependencies
ext-dom Version *
ext-mbstring Version *
symfony/console Version ^7.3 || ^8.0