Views: 52
Open Peppolは、EUのConnected Europe FacilityプロジェクトのCEF DIGITALが提供するコンポーネントの中にあるe-Invoiceの実証実験、PEPPOLに起源があります。
電子インボイスについての欧州規格 EN 16931-1は、UN/CEFACT CII, 及びUBL 2.1の形式での電子インボイスをサポートしており、それぞれの形式のXMLファイルの検証のためにスキーマトロンでの検証環境を提供しています。この検証環境は、GitHub上のeInvoicing-EN16931-validation-1.3.2で提供されています。
schematronの検証ルールは、abstractディレクトリにあるものとUBLファイルにあるものを参照する形で、EN16931-UBL-validation.schファイルに定義されています。
これらのファイルを前処理して生成されたファイルが、EN16931-UBL-validation-preprocessed.schです。
現在公開中のPeppol BIS Billing JP 0.9のDownload resourcesに含まれているスキーマトロンファイルもファイル名が-preprocessed.schで、どちらもOpen PeppolのOriolさんが作成されていますので、同様の生成方法かなと思います。
ダウンロードして、テストを実行したディレクトリ構造を次に示します。
. ├── LICENSE.txt ├── README.md ├── codelist │ └── iso6523 │ ├── ICD-list.pdf │ └── README.md ├── pom-license.xml ├── pom-preprocess.xml ├── pom-validate.xml ├── pom-xslt.xml ├── target │ ├── buildinfo-maven-plugin │ │ └── buildinfo.xml │ └── classes │ └── META-INF │ └── buildinfo.xml ├── templates │ ├── current │ │ ├── abstract-template.sch │ │ ├── codes-template.sch │ │ ├── main-schematron-template.sch │ │ └── syntax-binding-template.sch │ ├── license-template.txt │ └── original │ └── Template_Schematron.sch ├── ubl │ ├── examples │ │ ├── ubl-tc434-creditnote1.xml │ │ ├── ubl-tc434-example1.xml │ │ ├── ubl-tc434-example2.xml │ │ ├── ubl-tc434-example3.xml │ │ ├── ubl-tc434-example4.xml │ │ ├── ubl-tc434-example5.xml │ │ ├── ubl-tc434-example6.xml │ │ ├── ubl-tc434-example7.xml │ │ ├── ubl-tc434-example8.xml │ │ └── ubl-tc434-example9.xml │ ├── schema │ │ └── README.md │ ├── schematron │ │ ├── EN16931-UBL-validation.sch │ │ ├── UBL │ │ │ ├── EN16931-UBL-model.sch │ │ │ └── EN16931-UBL-syntax.sch │ │ ├── abstract │ │ │ ├── EN16931-model.sch │ │ │ └── EN16931-syntax.sch │ │ ├── codelist │ │ │ └── EN16931-UBL-codes.sch │ │ └── preprocessed │ │ └── EN16931-UBL-validation-preprocessed.sch │ └── xslt │ └── EN16931-UBL-validation.xslt ├── update-xslt-and-validate.cmd ├── update-xslt-and-validate.sh └── validate.sh
update-xslt-and-validate.sh実行
このシェルスクリプトは、ダウンロードしたファイルをExtensible Stylesheet Language Transformations (XSLT) スクリプトファイルに変換し、XSL変換で検証結果を表示するものです。
スクリプトの内容を次に示します。
# !/bin/sh # === Initialize shell environment =================================== set -eux # -e Exit immediately if a command exits with a non-zero status. # -u Treat unset variables as an error when substituting. # -v Print shell input lines as they are read. # -x Print commands and their arguments as they are executed. export LC_ALL=C Tmp=/tmp/${0##*/}.$$ # === Log ============================================================ exec 2>$Tmp.log result=0 echo 'preprocess first - catches errors quickers' mvn -f pom-preprocess.xml generate-resources 2>&1 || result=$? if [ ! "$result" = "0" ]; then echo >&2 'ERROR preprocess' exit 1 fi echo 'convert to XSLT - takes forever' mvn -f pom-xslt.xml process-resources 2>&1 || result=$? if [ ! "$result" = "0" ]; then echo >&2 'ERROR convert' exit 1 fi echo 'Add license headers to all relevant files' mvn -f pom-license.xml license:format 2>&1 || result=$? if [ ! "$result" = "0" ]; then echo >&2 'ERROR add license' exit 1 fi echo 'validate afterwards' mvn -f pom-validate.xml validate 2>&1 || result=$? if [ ! "$result" = "0" ]; then echo >&2 'ERROR validate' exit 1 fi rm $Tmp* exit 0
>$ ./update-xslt-and-validate.sh を実行した結果です。
$ ./update-xslt-and-validate.sh ++ export LC_ALL=C ++ LC_ALL=C ++ Tmp=/tmp/update-xslt-and-validate.sh.33899 ++ exec preprocess first - catches errors quickers [INFO] Scanning for projects... Downloading from central: https://repo.maven.apache.org/maven2/com/helger/parent-pom/1.10.8/parent-pom-1.10.8.pom Downloaded from central: https://repo.maven.apache.org/maven2/com/helger/parent-pom/1.10.8/parent-pom-1.10.8.pom (44 kB at 31 kB/s) [INFO] [INFO] ----------------< com.helger:centc434-validation-rules >---------------- [INFO] Building centc434-validation-rules 1.0.0 [INFO] --------------------------------[ jar ]--------------------------------- Downloading from central: https://repo.maven.apache.org/maven2/com/helger/maven/ph-buildinfo-maven-plugin/3.0.0/ph-buildinfo-maven-plugin-3.0.0.pom .... [INFO] [INFO] --- ph-buildinfo-maven-plugin:3.0.0:generate-buildinfo (default) @ centc434-validation-rules --- Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-component-annotations/1.5.4/plexus-component-annotations-1.5.4.pom .... [INFO] Successfully created temp directory buildinfo-maven-plugin [INFO] [INFO] --- ph-schematron-maven-plugin:5.2.0:preprocess (cii) @ centc434-validation-rules --- Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/3.5.3/maven-plugin-api-3.5.3.pom .... [INFO] Successfully wrote preprocessed Schematron file '?????/eInvoicing-EN16931-validation-1.3.2/cii/schematron/preprocessed/EN16931-CII-validation-preprocessed.sch' [INFO] [INFO] --- ph-schematron-maven-plugin:5.2.0:preprocess (edifact) @ centc434-validation-rules --- [INFO] Successfully wrote preprocessed Schematron file '?????/eInvoicing-EN16931-validation-1.3.2/edifact/schematron/preprocessed/EN16931-EDIFACT-validation-preprocessed.sch' [INFO] [INFO] --- ph-schematron-maven-plugin:5.2.0:preprocess (ubl) @ centc434-validation-rules --- [INFO] Successfully wrote preprocessed Schematron file '?????/eInvoicing-EN16931-validation-1.3.2/ubl/schematron/preprocessed/EN16931-UBL-validation-preprocessed.sch' [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 30.868 s [INFO] Finished at: 2021-12-25T13:29:56+09:00 [INFO] ------------------------------------------------------------------------ convert to XSLT - takes forever [INFO] Scanning for projects... [INFO] [INFO] ----------------< com.helger:centc434-validation-rules >---------------- [INFO] Building centc434-validation-rules 1.0.0 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- ph-buildinfo-maven-plugin:3.0.0:generate-buildinfo (default) @ centc434-validation-rules --- [INFO] Successfully created temp directory buildinfo-maven-plugin [INFO] [INFO] --- ph-schematron-maven-plugin:5.2.0:convert (cii) @ centc434-validation-rules --- [INFO] Converting Schematron file '?????/eInvoicing-EN16931-validation-1.3.2/cii/schematron/EN16931-CII-validation.sch' to XSLT file '?????/eInvoicing-EN16931-validation-1.3.2/cii/xslt/EN16931-CII-validation.xslt' [INFO] [INFO] --- ph-schematron-maven-plugin:5.2.0:convert (edifact) @ centc434-validation-rules --- [INFO] Converting Schematron file '?????/eInvoicing-EN16931-validation-1.3.2/edifact/schematron/EN16931-EDIFACT-validation.sch' to XSLT file '?????/eInvoicing-EN16931-validation-1.3.2/edifact/xslt/EN16931-EDIFACT-validation.xslt' [INFO] [INFO] --- ph-schematron-maven-plugin:5.2.0:convert (ubl) @ centc434-validation-rules --- [INFO] Converting Schematron file '?????/eInvoicing-EN16931-validation-1.3.2/ubl/schematron/EN16931-UBL-validation.sch' to XSLT file '?????/eInvoicing-EN16931-validation-1.3.2/ubl/xslt/EN16931-UBL-validation.xslt' [INFO] [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ centc434-validation-rules --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory ?????/eInvoicing-EN16931-validation-1.3.2/src/main/resources [INFO] Copying 1 resource to META-INF [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 26:31 min [INFO] Finished at: 2021-12-25T13:56:30+09:00 [INFO] ------------------------------------------------------------------------ Add license headers to all relevant files [INFO] Scanning for projects... Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.8.0/maven-compiler-plugin-3.8.0.pom .... [INFO] [INFO] ----------------< com.helger:centc434-validation-rules >---------------- [INFO] Building centc434-validation-rules 1.3.0 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- license-maven-plugin:3.0:format (default-cli) @ centc434-validation-rules --- Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/3.1.0/maven-plugin-api-3.1.0.pom .... [INFO] Updating license headers... [INFO] Updating license header in: ?????/eInvoicing-EN16931-validation-1.3.2/edifact/xslt/EN16931-EDIFACT-validation.xslt [INFO] Updating license header in: ?????/eInvoicing-EN16931-validation-1.3.2/edifact/schematron/preprocessed/EN16931-EDIFACT-validation-preprocessed.sch [INFO] Updating license header in: ?????/eInvoicing-EN16931-validation-1.3.2/ubl/schematron/preprocessed/EN16931-UBL-validation-preprocessed.sch [INFO] Updating license header in: ?????/eInvoicing-EN16931-validation-1.3.2/cii/schematron/preprocessed/EN16931-CII-validation-preprocessed.sch [INFO] Updating license header in: ?????/eInvoicing-EN16931-validation-1.3.2/ubl/xslt/EN16931-UBL-validation.xslt [INFO] Updating license header in: ?????/eInvoicing-EN16931-validation-1.3.2/cii/xslt/EN16931-CII-validation.xslt [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 31.633 s [INFO] Finished at: 2021-12-25T13:57:05+09:00 [INFO] ------------------------------------------------------------------------ validate afterwards [INFO] Scanning for projects... [INFO] [INFO] ----------------< com.helger:centc434-validation-rules >---------------- [INFO] Building centc434-validation-rules 1.0.0 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- ph-schematron-maven-plugin:5.2.0:validate (cii) @ centc434-validation-rules --- [INFO] Compiling XSLT instance [file=?????/eInvoicing-EN16931-validation-1.3.2/cii/xslt/EN16931-CII-validation.xslt] [INFO] Successfully parsed Schematron file '?????/eInvoicing-EN16931-validation-1.3.2/cii/xslt/EN16931-CII-validation.xslt' [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/cii/examples/CII_example9.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/cii/xslt/EN16931-CII-validation.xslt' expecting success [INFO] Creating JAXB context for package org.oclc.purl.dsdl.svrl using ClassLoader ClassRealm[plugin>com.helger.maven:ph-schematron-maven-plugin:5.2.0, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@42110406] [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/cii/examples/CII_example8.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/cii/xslt/EN16931-CII-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/cii/examples/CII_example1.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/cii/xslt/EN16931-CII-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/cii/examples/CII_example3.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/cii/xslt/EN16931-CII-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/cii/examples/CII_example2.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/cii/xslt/EN16931-CII-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/cii/examples/CII_example6.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/cii/xslt/EN16931-CII-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/cii/examples/CII_example7.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/cii/xslt/EN16931-CII-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/cii/examples/CII_example5.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/cii/xslt/EN16931-CII-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/cii/examples/CII_example4.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/cii/xslt/EN16931-CII-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/cii/examples/CII_business_example_02.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/cii/xslt/EN16931-CII-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/cii/examples/CII_business_example_01.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/cii/xslt/EN16931-CII-validation.xslt' expecting success [INFO] [INFO] --- ph-schematron-maven-plugin:5.2.0:validate (edifact) @ centc434-validation-rules --- [INFO] Compiling XSLT instance [file=?????/eInvoicing-EN16931-validation-1.3.2/edifact/xslt/EN16931-EDIFACT-validation.xslt] [INFO] Successfully parsed Schematron file '?????/eInvoicing-EN16931-validation-1.3.2/edifact/xslt/EN16931-EDIFACT-validation.xslt' [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/edifact/examples/EDIFACT_EXAMPLE3.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/edifact/examples/EDIFACT_EXAMPLE2.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/edifact/examples/EDIFACT_EXAMPLE1.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/edifact/examples/EDIFACT_EXAMPLE5.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/edifact/examples/EDIFACT_EXAMPLE4.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/edifact/examples/EDIFACT_EXAMPLE6.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/edifact/examples/EDIFACT_EXAMPLE7.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/edifact/examples/EDIFACT_EXAMPLE9.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/edifact/examples/EDIFACT_EXAMPLE8.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success [INFO] [INFO] --- ph-schematron-maven-plugin:5.2.0:validate (ubl) @ centc434-validation-rules --- [INFO] Compiling XSLT instance [file=?????/eInvoicing-EN16931-validation-1.3.2/ubl/xslt/EN16931-UBL-validation.xslt] [INFO] Successfully parsed Schematron file '?????/eInvoicing-EN16931-validation-1.3.2/ubl/xslt/EN16931-UBL-validation.xslt' [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/ubl/examples/ubl-tc434-creditnote1.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/ubl/xslt/EN16931-UBL-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/ubl/examples/ubl-tc434-example8.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/ubl/xslt/EN16931-UBL-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/ubl/examples/ubl-tc434-example9.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/ubl/xslt/EN16931-UBL-validation.xslt' expecting success [INFO] Validating XML file '?????/eInvoicing-EN16931-validation-1.3.2/ubl/examples/ubl-tc434-example1_Error.xml' against Schematron rules from '?????/eInvoicing-EN16931-validation-1.3.2/ubl/xslt/EN16931-UBL-validation.xslt' expecting success [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 17.879 s [INFO] Finished at: 2021-12-25T13:57:25+09:00 [INFO] ------------------------------------------------------------------------ $
準備作業
Mavenインストール
MacOS CatalinaでeInvoicing-EN16931-validation-1.3.2環境を確認しました。
macOs catalinaで再現し、確認しました。
スキーマトロン環境では、Mavenを使用して、スキーマトロンファイルをXSLファイルに変換して検証を行なっていますので、まずMavenをbrewコマンドでインストールしました。
$ brew install maven
$ brew install maven Updating Homebrew... ==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:0cb1cc7af109437fe0e020c9f3b7b95c3c709b140bde9f991ad2c1433496dd42 ################################################################################################################# 100.0% ==> Pouring portable-ruby-2.6.8.yosemite.bottle.tar.gz ==> Auto-updated Homebrew! Updated 2 taps (homebrew/core and homebrew/services). ==> New Formulae abi-compliance-checker fcp ... ==> Updated Formulae Updated 5309 formulae. ==> Renamed Formulae badtouch -> authoscope ... ==> Deleted Formulae amap ... ==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/manifests/17.0.1_1 ######################################################################## 100.0% ==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/blobs/sha256:43ed8d59b409bed727b11254eeb6758a7ad40fc88daf3124ab ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:43ed8d59b409bed727b11254eeb6758a7ad ######################################################################## 100.0% ==> Downloading https://ghcr.io/v2/homebrew/core/maven/manifests/3.8.4 ######################################################################## 100.0% ==> Downloading https://ghcr.io/v2/homebrew/core/maven/blobs/sha256:ff38bb52b93216582dbd13fb00be5679090ac4b66f7e7c5c8cae ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:ff38bb52b93216582dbd13fb00be5679090 ######################################################################## 100.0% ==> Installing dependencies for maven: openjdk ==> Installing maven dependency: openjdk ==> Pouring openjdk--17.0.1_1.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/openjdk/17.0.1_1: 639 files, 305.3MB ==> Installing maven ==> Pouring maven--3.8.4.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/maven/3.8.4: 79 files, 10MB ==> `brew cleanup` has not been run in the last 30 days, running now... Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). Removing: /Users/.. ../Library/Caches/Homebrew/gdbm--1.18.1_1.catalina.bottle.tar.gz... (203.8KB) ... Pruned 1 symbolic links and 6 directories from /usr/local $ mvn -v Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: /usr/local/Cellar/maven/3.8.4/libexec Java version: 17.0.1, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/17.0.1_1/libexec/openjdk.jdk/Contents/Home Default locale: ja_JP, platform encoding: UTF-8 OS name: "mac os x", version: "10.15.7", arch: "x86_64", family: "mac"
eInvoicing-EN16931-validation-1.3.2をダウンロード
wgetでGitHubから環境を取得しました。
wget https://github.com/ConnectingEurope/eInvoicing-EN16931/archive/validation-1.3.2.zip --2020-09-14 07:15:08-- https://github.com/ConnectingEurope/eInvoicing-EN16931/archive/validation-1.3.2.zip github.com (github.com) をDNSに問いあわせています...