Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/phivePublic

Generic business document validation engine

License

NotificationsYou must be signed in to change notification settings

phax/phive

Repository files navigation

javadocMaven Central

A generic business document validation engine originally developed for Peppol but now also supporting many other document types.

"phive" is an abbreviation of "Philip Helger Integrative Validation Engine" and is pronounced exactly like the digit 5:[ˈfaɪv].

This project only contains the validationengine - all the preconfigured rules are available in a separate repository athttps://github.com/phax/phive-rules

This project is part of my Peppol solution stack. Seehttps://github.com/phax/peppol for other components and libraries in that area.

This project is licensed under the Apache 2 license.

A live version of this engine can be found onPeppol Practical and atecosio.

This project has the following sub-modules:

  • phive-api - a generic API that is independent of the effective validation logic. It contains the interfaces for validation sources, validation artefacts, validation execution and validation results.
  • phive-ves-model - contains the XML representation of aVES, a Validation Execution Set.
  • phive-xml (previouslyphive-engine) - contains the support for validating XML source document via XML Schema and Schematron
  • phive-ves-engine - the validation engine that takes the data structures fromphive-ves-model, loads external resources viaph-diver and validates business documents viaphive-xml.
  • phive-result (previouslyphive-json) - library to support converting validation results to different output formats (e.g. JSON)

Note: this library does NOT include an EDIFACT validation. It's a placeholder for local implementations.

Note: please seeREADME v5,README v6 andREADME v7/v8 for previous documentation.

Usage guide

Basically this library wraps different XML Schemas and Schematrons in a certain order and under certain constraints and offers the possibility to validate XML documents based on the rules.

The underlying model is the so called "Validation Pyramid":Validation Pyramid

Each layer of the Validation Pyramid reflects a single set of rules.Each rule set is identified by a VESID, and the resulting pyramid is also identified by a single ID.

Validation executor set identification

Every set of validation artefacts is uniquely identified with aVESID which is aDVR Coordinate.E.g. the "Peppol BIS Billing UBL Invoice release May 2023" is identified with the group IDeu.peppol.bis3, the artefact ID isinvoice and the version number is2023.5 (representing "May 2023") (without a classifier).Another example is "SimplerInvoicing 1.2 invoice" which has the group IDorg.simplerinvoicing, the artifact IDinvoice and the version number1.2 (also without a classifier).

Additional Pseudo Versions

Additional to the pseudo versions defined byph-diver this library adds the following additional pseudo versions:

  • latest-active - always refer to the latest version of an artefact which is currently valid. This includes snapshot and non-snapshot versions.
  • latest-release-active - always refer to the latest version of an artefact which is currently valid. This includes snapshot and non-snapshot versions.

Note: These pseudo versions are defined in classPhivePseudoVersionRegistrarSPIImpl.

How to validate documents with programmatic rules

At least thephive-xml project and one library with rule sets (like e.g.phive-rules-peppol fromhttps://github.com/phax/phive-rules)is needed in your application. See the section on usage in a Maven project below.All available VES must be registered in an instance of classValidationExecutorSetRegistry (which can simply created vianew).Depending on the used domain specific libraries, initialization calls for registration into the registry must be performed.Example for registering (only) Peppol validation artefacts:

finalValidationExecutorSetRegistry <IValidationSourceXML>aVESRegistry =newValidationExecutorSetRegistry<> ();PeppolValidation.initStandard (aVESRegistry);

The instance of classValidationExecutorSetRegistry can be kept as a (static) singleton - it is thread-safe.Therefore the registration process need to be performed only once.

Validating a business document requires a few more steps.

  1. Access to the registry is needed.
  2. A specificVESID instance (e.g.PeppolValidation2024_05.VID_OPENPEPPOL_INVOICE_UBL_V3 - fromphive-rules) - there are constants available for all VES identifiers defined in this project.
  3. TheValidationExecutionManager is an in-between class that can be used to customize the execution. But it is created very quickly, so there is no harm on creating it on the fly every time.
  4. An instance of classValidationSourceXML to identify the document to be validate. ClassValidationSourceXML has factory methods for the default cases (having anorg.w3c.dom.Node or having ancom.helger.commons.io.resource.IReadableResource).
  5. The validation results are stored in an instance of classValidationResultList. This class is a list ofValidationResult instances - eachValidationResult represents the result of a single level of validation.
  6. Your application logic than needs to define what to do with the results.

A basic example can be found in the tests athttps://github.com/phax/phive/blob/master/phive-xml/src/test/java/com/helger/phive/api/execute/ValidationExecutionManagerFuncTest.java

How to validate documents with declarative rules

TODO The description of this section needs to be written. Please have patience until everything is ready and setup.

Maven usage

Add the following to yourpom.xml to use this artifact, replacingx.y.z with the latest version:

<dependency>  <groupId>com.helger.phive</groupId>  <artifactId>phive-xml</artifactId>  <version>x.y.z</version></dependency>

If you are interested in the validation result transformation you need to also include this artefact.

<dependency>  <groupId>com.helger.phive</groupId>  <artifactId>phive-result</artifactId>  <version>x.y.z</version></dependency>

Alternate usage as a Maven BOM:

<dependency>  <groupId>com.helger.phive</groupId>  <artifactId>phive-parent-pom</artifactId>  <version>x.y.z</version>  <type>pom</type>  <scope>import</scope></dependency>

Potential issues

Please ensure that your stack size is at least 1MB (for Saxon). Using the Oracle runtime, this can be achieved by passing-Xss1m on the command line. This only seems to be a problem when running 32bit Java. With 64bit Java, the default stack size of the Oracle JVM is already 1MB.

News and noteworthy

  • v10.1.1 - 2025-03-03
    • Added new classesIGenericPseudoVersionResolver andDefaultGenericPseudoVersionResolver
    • Fixed invalid return codes forValidationResultList.containsNo(Failure|Error) for empty lists
  • v10.1.0 - 2024-12-05
    • Requires ph-commons 11.1.11
    • Added new interfaceIValidationExecutorSetMutable
    • Added new classValidationExecutorSetAlias to be able to proxy existing VES with different coordinates
    • Added new classValidityDeterminatorRegistry to support validity determination processes
    • Added optionalIValidationSource toValidationResultList
    • Changed parameter types inPhiveJsonHelper andPhiveXMLHelper fromList <? extends ValidationResult> toValidationResultList
    • Added new classValidationSourceXMLReadableResource
    • ExtendedIValidationSource interface to make content serializable
    • Added the duration in milliseconds perValidationResult
    • Updated the default JSON and XML validation result list serialization to contain the new elements
  • v10.0.3 - 2024-12-01
    • Added default XML serialization of validation results
    • Added newEValidationBaseType entries
  • v10.0.2 - 2024-09-16
    • Re-release due to Maven Central issue
  • v10.0.1 - 2024-09-16
    • Fixed the validation types inValidationExecutorXSDPartial.create
  • v10.0.0 - 2024-09-16
    • Updated to ph-diver 3.0.1
    • The outcome of a validation can now bevalid,invalid orunclear (new)
      • Added new classesEExtendedValidity andIValidityDeterminator
      • EachIValidationExecutorManager now has anIValidityDeterminator
      • By usingIValidityDeterminator.getDefault() the previous state can be re-created
    • Renamed methodIValidationArtefact.getValidationArtefactType togetValidationType
    • Moved classes(Abstract|I)ValidationExecutor to its own.executor package
    • Renamed classTestFile toPhiveTestFile
  • v9.2.2 - 2024-07-29
    • Switched from custom error level toCustomErrorDetails
  • v9.2.1 - 2024-04-25
    • Updated to ph-diver 1.2.0
    • Added support for the pseudo version resolution inVESLoader.loadVESFromRepo
    • TheVESLoader now requires aIRepoStorageWithToc instead of aIRepoStorageBase in the constructor
    • Added support for new pseudo versionslatest-active andlatest-release-active
  • v9.2.0 - 2024-03-29
    • Updated to ph-commons 11.1.5
    • Ensured Java 21 compatibility
    • Extended the VES status XSD with new optional elements
    • Introducing[I]ValidationExecutorSetStatus representing the status of a single Validation Executor Set
  • v9.1.0 - 2024-03-09
    • Updated to ph-schematron 8.0.0 using Saxon 12.x
    • Updated to ph-diver 1.1.0
    • Improved dynamic VES loading heavily
  • v9.0.0 - 2023-09-14
    • Moved classPhiveRestoredException into a separate package
    • Using the classVESID etc. fromph-diver-api instead
    • Replaced thephive-repo withph-diver-repo instead
    • Moved classes[I]ValidationSourceBinary fromphive-xml tophive-api
    • Renamed classMockFile toTestFile
  • v9.0.0-beta2 - 2023-09-06 [don't use in production]
    • Reworked the version handling inside classVESID so that a strict ordering by version is possible
    • Added specific support for theSNAPSHOT version, so that1.0.0-SNAPSHOT is lower then1.0.0
  • v9.0.0-beta1 - 2023-08-30 [don't use in production]
    • RemovedVOM* in favour ofVES*
    • Added new submodule "phive-repo" to be able to retrieve artefacts from remote storage locations
    • Added new submodule "phive-ves-model" that contain the VES data structures
    • Added new submodule "phive-ves-engine" that contain the VES execution engine
    • Renamed the submodule "phive-engine" to "phive-xml" to indicate, that this is the part dealing with XML validation only. This also lead to new package names.
    • Renamed the submodule "phive-json" to "phive-result" to indicate, that this is deals with validation results in general. The JSON stuff got its own package in there.
    • Initial version for declaration VES rules for XSD and Schematron
  • v8.0.1 - 2023-03-17
    • Added support for resolving the pseudo versionlatest inValidationExecutorSetRegistry. Seeissue #16 - thx @adammscisz
  • v8.0.0 - 2023-02-19
    • Using Java 11 as the baseline
    • Updated to ph-commons 11
    • Updated to JAXB 4.0
  • v7.2.4 - 2022-08-17
    • Updated to ph-commons 10.1.7
    • Added support for the error date time serialization to JSON and back
  • v7.2.3 - 2022-02-24
    • Increased the flexibility of the Json output providers
  • v7.2.2 - 2021-11-05
    • Stopping further validations, if an error occurs on XSD level
  • v7.2.1 - 2021-06-09
    • Started introduction of the new VOM - Validation Object Model - an XML based approach for validation configuration
  • v7.2.0 - 2021-03-22
    • Updated to ph-commons 10
    • Added new classValidationSourceBinary
  • v7.1.1 - 2021-01-28
    • Extended the internal API to ensure validation artifacts are in cache
  • v7.1.0 - 2021-01-26
    • Extracted the interfaceIValidationType fromEValidationType and using it where applicable
  • v7.0.1 - 2020-12-04
    • Updated to ph-schematron 6.0.1
    • The failed assertion ID is now part of the created errors (if present)
    • Add the possibility to change the error levels of occurred Schematron errors
  • v7.0.0 - 2020-11-25
    • The Maven group ID changed fromcom.helger.bdve tocom.helger.phive
    • The Java package names changed fromcom.helger.bdve.* tocom.helger.phive.*
    • The class nameBDVEJsonHelper changed toPhiveJsonHelper
    • The class nameBDVERestoredException changed toPhiveRestoredException
    • Updated to ph-schematron 6.0.0
    • Added support for using "SchXslt" as a Schematron engine
  • v6.0.4 - 2020-11-11
    • Added new overloads forValidationExecutorXSD.create
    • AddedIValidationArtefact.getRuleResourcePath () to customize the file path
    • AddedValidationExecutorXSDPartial.create factory methods
    • AddedXSDPartialContext.create factory methods
    • AddedValidationExecutorSchematron.create factory methods
  • v6.0.3 - 2020-09-17
    • Updated to Jakarta JAXB 2.3.3
  • v6.0.2 - 2020-06-16
    • Fixed a typo in the JSON propertyerrorLocationObj
  • v6.0.1 - 2020-06-16
    • ExtendedValidationExecutorSetRegistry API to allow for unregistration
  • v6.0.0 - 2020-06-08
    • Separated all the rules into a separate project -https://github.com/phax/ph-bdve-rules - this repository only contains the engine
    • Extracted the JSON binding into a separate submodule "ph-bdve-json"
    • Extracted the generic API project into a separate submodule "ph-bdve-api"
    • Made the validation source type a generics parameter to the executor set etc. So an executor needs to know, whether it can accept XML sources or other kind of source syntaxes.
    • ExtractedIValidationSourceXML fromIValidationSource
    • RenamedValidationSource fromValidationSourceXML
  • v5.3.1 - 2020-05-28
    • Added possibility to stop further validation on failed Schematrons as well
  • v5.3.0 - 2020-05-26
    • Changed the Maven groupId tocom.helger.bdve
    • Renamed the submoduleph-bdve toph-bdve-engine
    • Updated to ph-commons 9.4.4
    • Removed the class loader member fromIValidationArtifact
    • Deprecated Peppol 3.9.0 and 3.9.1 artefacts - 3.10.0 is the right one
    • Added support for EN 16931 1.3.2 format (deprecated version 1.3.1)
  • v5.2.11 - 2020-05-01
    • Updated to ph-commons 9.4.0
    • Added support for ebInterface 6.0
    • Added support for OpenPeppol validation artifacts, Spring 2020 release
  • v5.2.10 - 2020-03-20
    • The Peppol AU-NZ rules were updated to v1.0.2. v1.0.1 is now deprecated.
  • v5.2.9 - 2020-03-18
    • Fixed usage of wrong Peppol AU-NZ Schematrons for v1.0.1. Seeissue #12
  • v5.2.8 - 2020-03-12
    • Added support for UBL.BE 1.2 (version 2020-03)
    • Deprecated OpenPeppol 3.7.0 rules (for BIS v2)
  • v5.2.7 - 2020-03-08
    • Deprecatedeu.cen.en16931:edifact:1.0.0 as it is not maintained anymore
    • Extended validation API
    • Added support for EN 16931 1.3.1 format (deprecated version 1.3.0)
  • v5.2.6 - 2020-02-10
    • Updated the UBL 2.3 identifiers from "csprd01" to "csprd02"
    • Added Peppol BIS 3 billing Hotfix from 2020-02-10 (BR-S-08 for standard VAT, BR-IG-08 for Canary Islands tax, BR-IP-08 for Ceuta and Melilla tax) as Peppol rules 3.9.1
    • Updated to the EHF G2 rules from 2019-12
  • v5.2.5 - 2020-02-06
    • Added a default JSON representation for validation results - see classBDVEJsonHelper
    • Added support for UBL.BE 1.1 (version 2019-11)
    • Deprecated UBL.BE 1.0, e-FFF Invoice and e-FFF Credit Note validations
    • Updated to UBL 2.3 CSPRD 02 (without changing the ID :( )
  • v5.2.4 - 2020-01-13
    • Added support for XRechnung 1.2.2 format (deprecated version 1.2.1)
  • v5.2.3 - 2019-12-18
    • Added Singapore (SG) Peppol Billing BIS3 rules version 1.0.2
  • v5.2.2 - 2019-12-12
    • Added SimplerInvoicing 2.0.2 and deprecated version 2.0.1
  • v5.2.1 - 2019-12-09
    • Added SimplerInvoicing 2.0.1 and deprecated version 2.0
  • v5.2.0 - 2019-11-29
    • The Peppol AU-NZ rules were updated. The old version is now the official "1.0.0" whereas the new rules are "1.0.1". Confusing, I know :-|
    • Updated to ph-schematron 5.4.0 (incompatible change)
  • v5.1.15 - 2019-11-15
    • Added support for UBL 2.3 CSPRD01
    • Updated Peppol-SG rules to the latest version
    • Deprecated OpenPeppol 3.8.1 rules
  • v5.1.14 - 2019-11-01
    • Added support for A-NZ Peppol 1.0.1 validations
    • Added OpenPEPPOL 3.9.0 (Fall release 2019) artefacts
  • v5.1.13 - 2019-10-14
    • Added support for EN 16931 1.3.0 format (deprecated version 1.2.3)
    • Updated Singapore (SG) Peppol Billing BIS3 rules to version 2019-06-12
  • v5.1.12 - 2019-09-09
    • Deprecated OpenPEPPOL 3.8.0 artefacts
    • XRechnung 1.2.1 is now based on EN16931 1.2.1 release
  • v5.1.11 - 2019-07-21
    • Added OpenPEPPOL 3.8.1 (Spring release 2019 bug fix release) artefacts
    • Updated SimplerInvoicing artefacts to the latest versions. This lead to "SI 1.1 strict" to be removed.
  • v5.1.10 - 2019-07-10
    • Added new EHF validation artefacts (incl. Invoice and Credit Note 2.0.16)
    • Deprecatedeu.peppol.bis3.ubl:invoice:1 in favour ofeu.peppol.bis3:invoice:3.8.0
    • Deprecatedeu.peppol.bis3.ubl:creditnote:1 in favour ofeu.peppol.bis3:creditnote:3.8.0
    • Added support for XRechnung 1.2.1 format (deprecated version 1.2.0)
    • Added support for EN 16931 1.2.3 format (deprecated version 1.2.1)
  • v5.1.9 - 2019-06-10
    • Fixed an error inEHF-UBL-COMMON.sch of November 2018 release
    • Fixed an error inEHF-UBL-T19.sch of November 2018 release
    • Added support for XRechnung 1.2.0 format
  • v5.1.8 - 2019-05-15
    • Added Peppol 3.8.0 (Spring 2019 release) validation artefacts (BIS v3 only)
  • v5.1.7 - 2019-05-14
    • Added EN 16931 validation artefacts version 1.2.1, deprecated the old 1.2.0 version
    • Internally restructured EHF layout for future extension
  • v5.1.6 - 2019-04-26
    • Added EN 16931 validation artefacts version 1.2.0, deprecated the old 1.1.0 version
  • v5.1.5 - 2019-04-19
    • Updated OIOUBL validation rules to the latest version
    • Updated SimplerInvoicing 2.0 RC1 to 2.0 final release
    • Added support for Dutch Energie eFactuur 3.0.0 (based on SimplerInvoicing 2.0)
  • v5.1.4 - 2019-03-21
    • EHF validation without "OPENPEPPOL CORE" rules
    • Fixed an error in the created XSLTs for ATNAT/ATGOV T10 and T14 because of variable order as well as a spelling error
  • v5.1.3 - 2019-03-08
    • Updated to latest EHF releases (Invoice and Credit Note 2.0.15 etc.)
    • EHF validation now directly depends on the Peppol Validation artefacts
  • v5.1.2 - 2019-02-04
    • Added SimplerInvoicing 2.0 RC1 support#3
    • Added Singapore (SG) Peppol Billing BIS3 support#4
  • v5.1.1 - 2019-01-16
    • Added UBL.BE 1.0.0 Schematrons
  • v5.1.0 - 2018-11-23
    • Requires ph-commons 9.2.0
    • Added support for OpenPEPPOL 3.7.0 (Fall 2018) rules (incl. Billing BIS3)
    • Removed support for OpenPEPPOL 3.4.0 rules
  • v5.0.6 - 2018-11-09
    • Fixed an error in the UBL.BE document types. In reality those are e-FFF 3.0 document types. VESID changed therefore.
  • v5.0.5 - 2018-11-07
    • Requires at least ph-commons 9.1.8
    • Added support for UBL.BE document types
    • Added support for OpenPEPPOL 3.7.0.RC1 (Fall 2018) rules (incl. Billing BIS3)
  • v5.0.4 - 2018-08-14
    • Added support for UBL 2.0 XSD validation
    • Added support for UBL 2.2 XSD validation
  • v5.0.3 - 2018-07-11
    • Updated EHF rules to 2018-02-20
  • v5.0.2 - 2018-06-26
    • Added EN 16931 validation artefacts version 1.1.0, deprecated the old 1.0.0 version
  • v5.0.1 - 2018-06-15
    • Fixed marking of OpenPEPPOL 3.5.0 artefatcs as "deprecated"
    • Added support for Peppol Billing BIS 3 document types
    • Added support for EN 16931 UBL CreditNote validation
  • v5.0.0 - 2018-06-01
    • Added Tieto TEAPPSXML support
    • Added Austrian ebInterface support
    • Simplified internal API backwards incompatible (removed all the bloat overhead where possible)
  • v4.0.5 - 2018-05-14
    • Support for OpenPEPPOL rules 3.3.0 was removed - too old
    • Updated to OpenPEPPOL 3.6.0 (Spring 2018) rules
  • v4.0.4 - 2018-02-22
    • Updated to EN 16931 rules 1.0.0
    • Added support for Dutch Energie eFactuur 1.0.0 (based on SimplerInvoicing 1.1)
    • Added support for Dutch Energie eFactuur 1.0.1 (based on SimplerInvoicing 1.1)
  • v4.0.3 - 2018-02-07
    • Added OIOUBL 2.0.2 support (new artefactph-bdve-oioubl)
    • EN 16031 rules were updated
  • v4.0.2 - 2018-02-03
    • Added support for Dutch Energie eFactuur 2.0.0 (new artefactph-bdve-energieefactuur) - based on SimplerInvoicing 1.2
    • Updated to ph-commons 9.0.1 (Locale specific XSD error messages)
    • Schematron error messages are more easily readable
    • EN 16031 rules were updated
    • CII validation was heavily improved
  • v4.0.1 - 2018-01-23
    • Added support for EHF document formats (new artefactph-bdve-ehf) - based onhttps://vefa.difi.no/ehf/standard/
    • Added support to validate UBL documents only (without Schematron) (new artefactph-bdve-ubl)
    • Added support to validate CII documents only (without Schematron) (new artefactph-bdve-cii)
    • Extended API to support better cleanup
  • v4.0.0 - 2018-01-15
    • Updated to ph-commons 9.0.0
    • Updated to the latest official EN-16931 rules
    • Updated to the Peppol Autumn 2017 release (3.5.0)
  • v3.2.0 - 2017-07-27
    • Improved ClassLoader handling, so that each validation artefact has a defined class loader.
  • v3.1.4 - 2017-07-12
    • Fixed an error where warnings in Schematron validation lead to not evaluating the SVRL
  • v3.1.3 - 2017-06-07
    • Re-release because v3.1.2 had issues with Maven Central deployment
  • v3.1.2 - 2017-06-06
    • Fixed a problem with XSLT based validation when using anything different from a DOM Document as the validation source
  • v3.1.1 - 2017-06-01
    • Re-added SimplerInvoicing 1.1 rules
    • Enabled Schematron caching by default
    • Improved caching API
  • v3.1.0 - 2017-05-15
    • Added EN 16931 rules
    • Update to OpenPEPPOL 3.4.0 rules
    • Update to SimplerInvoicing 1.2 rules
    • Updated to ph-schematron 4.3.0
  • v3.0.0 - 2017-01-26
    • Is a complete rewrite with different structure etc.
    • Binds to ph-commons 8.6.x
    • Requires at least ph-schematron 4.2.1
  • v2.0.1 - 2016-09-12
    • Binds to ph-commons 8.5.x
  • v2.0.0 - 2016-08-22
    • Requires JDK 8

My personalCoding Styleguide |It is appreciated if you star the GitHub project if you like it.


[8]ページ先頭

©2009-2025 Movatter.jp