Search Posts

Visits: 417

[2022−05−30] jp-pint-validate.xmlファイルについて記述を追加。
昨年末の記事を忘れないようにに再確認した。
公開されている*-preprocessed.schファイルで検証。

ConnectingEurope/eInvoicing-EN16931の次の EN16931 Validation artefacts v.1.3.2 ページから Source code (zip)をダウンロードして、update-xslt-and-validate.cmdのmvnコマンドを実行して確認した。

その他の関連記事は、こちらから。

mvnインストール

Amazon Web Service EC2
Last login: Sun Sep 13 04:47:03 2020 from .....

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2018.03-release-notes/
[ec2-user@ip-xx-x-x-xxx ~]$ mvn -version
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T16:58:13+09:00)
Maven home: /usr/share/apache-maven
Java version: 1.8.0_252, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.51.amzn1.x86_64/jre
Default locale: ja_JP, platform encoding: UTF-8
OS name: "linux", version: "4.14.171-105.231.amzn1.x86_64", arch: "amd64", family: "unix"

wget validation-1.3.2.zip

[ec2-user@ip-xx-x-x-xxx ~]$ cd tmp
[ec2-user@ip-xx-x-x-xxx tmp]$ 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に問いあわせています... 13.114.40.48
github.com (github.com)|13.114.40.48|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 302 Found
場所: https://codeload.github.com/ConnectingEurope/eInvoicing-EN16931/zip/validation-1.3.2 [続く]
--2020-09-14 07:15:08--  https://codeload.github.com/ConnectingEurope/eInvoicing-EN16931/zip/validation-1.3.2
codeload.github.com (codeload.github.com) をDNSに問いあわせています... 52.193.111.178
codeload.github.com (codeload.github.com)|52.193.111.178|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 特定できません [application/zip]
`validation-1.3.2.zip' に保存中

validation-1.3.2.zip                [ <=>                                                  ]   1.15M  --.-KB/s    in 0.1s    

2020-09-14 07:15:08 (7.81 MB/s) - `validation-1.3.2.zip' へ保存終了 [1206511]

unzip

[ec2-user@ip-xx-x-x-xxx tmp]$ unzip validation-1.3.2.zip
Archive:  validation-1.3.2.zip
b6762416a714fa78633af72966f130bddbeee568
   creating: eInvoicing-EN16931-validation-1.3.2/
  inflating: eInvoicing-EN16931-validation-1.3.2/.gitattributes  
  inflating: eInvoicing-EN16931-validation-1.3.2/.gitignore  
...

作業ディレクトリに移動

[ec2-user@ip-xx-x-x-xxx tmp]$ cd eInvoicing-EN16931-validation-1.3.2
[ec2-user@ip-xx-x-x-xxx eInvoicing-EN16931-validation-1.3.2]$

1 preprocess

ConnectingEurope/eInvoicing-EN16931では、schematronのabstract定義を前処理して展開してスキーマトロンファイルを生成している。
J PINT 0.9.nでは、*-preprocessed.schファイルが配布されているのでこのステップは不要。

mvn -f pom-preprocess.xml generate-resources

[ec2-user@ip-xx-x-x-xxx eInvoicing-EN16931-validation-1.3.2]$ mvn -f pom-preprocess.xml generate-resources
[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 25 kB/s)
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building centc434-validation-rules 1.0.0
[INFO] ------------------------------------------------------------------------
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
Downloaded 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 (4.9 kB at 11 kB/s)
...

[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/apache/maven/maven-plugin-api/3.0/maven-plugin-api-3.0.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/3.0/maven-plugin-api-3.0.pom (2.3 kB at 6.0 kB/s)
...

[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
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/3.5.3/maven-plugin-api-3.5.3.pom (2.9 kB at 9.7 kB/s)
...

[INFO] Successfully wrote preprocessed Schematron file '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 '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 'ubl/schematron/preprocessed/EN16931-UBL-validation-preprocessed.sch'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:03 min
[INFO] Finished at: 2020-09-14T07:20:15+09:00
[INFO] Final Memory: 15M/36M
[INFO] ------------------------------------------------------------------------
[ec2-user@ip-xx-x-x-xxx eInvoicing-EN16931-validation-1.3.2]$

2 XSLTスタイルシートファイル変換

スキーマトロンファイルをXSLTスタイルシートに変換する。

mvn -f pom-xslt.xml process-resources 

MVNリポジトリーのPH Schematron Maven Pluginを使用してschematronを変換している。 Maven plugin to apply Schematron rules to XML files on build time

[ec2-user@ip-xx-x-x-xxx eInvoicing-EN16931-validation-1.3.2]$ mvn -f pom-xslt.xml process-resources
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building centc434-validation-rules 1.0.0
[INFO] ------------------------------------------------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/3.1.0/maven-resources-plugin-3.1.0.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/3.1.0/maven-resources-plugin-3.1.0.pom (7.2 kB at 6.1 kB/s)
...

[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 'cii/schematron/EN16931-CII-validation.sch' to XSLT file 'cii/xslt/EN16931-CII-validation.xslt'
[INFO] 
[INFO] --- ph-schematron-maven-plugin:5.2.0:convert (edifact) @ centc434-validation-rules ---
[INFO] Converting Schematron file 'edifact/schematron/EN16931-EDIFACT-validation.sch' to XSLT file 'edifact/xslt/EN16931-EDIFACT-validation.xslt'
[INFO] 
[INFO] --- ph-schematron-maven-plugin:5.2.0:convert (ubl) @ centc434-validation-rules ---
[INFO] Converting Schematron file 'ubl/schematron/EN16931-UBL-validation.sch' to XSLT file 'ubl/xslt/EN16931-UBL-validation.xslt'
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ centc434-validation-rules ---
Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-component-annotations/1.7.1/plexus-component-annotations-1.7.1.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-component-annotations/1.7.1/plexus-component-annotations-1.7.1.pom (770 B at 1.3 kB/s)
...

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory src/main/resources
[INFO] Copying 1 resource to META-INF
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23:26 min
[INFO] Finished at: 2020-09-14T07:44:29+09:00
[INFO] Final Memory: 21M/146M
[INFO] ------------------------------------------------------------------------
[ec2-user@ip-xx-x-x-xxx eInvoicing-EN16931-validation-1.3.2]$ 

3 Add license headers to all relevant files

ライセンス情報追加

mvn -f pom-license.xml license:format

[ec2-user@ip-xx-x-x-xxx eInvoicing-EN16931-validation-1.3.2]$ mvn -f pom-license.xml license:format
[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
Downloaded 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 (12 kB at 10 kB/s)
...

[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building centc434-validation-rules 1.3.0
[INFO] ------------------------------------------------------------------------
[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
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/3.1.0/maven-plugin-api-3.1.0.pom (3.0 kB at 12 kB/s)
...

[INFO] Updating license headers...
[INFO] Updating license header in: ubl/schematron/preprocessed/EN16931-UBL-validation-preprocessed.sch
[INFO] Updating license header in: ubl/xslt/EN16931-UBL-validation.xslt
[INFO] Updating license header in: cii/schematron/preprocessed/EN16931-CII-validation-preprocessed.sch
[INFO] Updating license header in: cii/xslt/EN16931-CII-validation.xslt
[INFO] Updating license header in: edifact/schematron/preprocessed/EN16931-EDIFACT-validation-preprocessed.sch
[INFO] Updating license header in: edifact/xslt/EN16931-EDIFACT-validation.xslt
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.528 s
[INFO] Finished at: 2020-09-14T07:46:33+09:00
[INFO] Final Memory: 12M/32M
[INFO] ------------------------------------------------------------------------
[ec2-user@ip-xx-x-x-xxx eInvoicing-EN16931-validation-1.3.2]$

4 スキーマトロン検証

スタイルシートを入力にして検証実行する。
JP PINT 0.9.1のテストは、これからpom-validate.xmlファイルの定義および関連ファイルをXSLTスタイルシートに変換して実行予定。
下記は、CEFのeInvoiceでのテスト。

mvn -f pom-validate.xml validate

[ec2-user@ip-xx-x-x-xxx eInvoicing-EN16931-validation-1.3.2]$ mvn -f pom-validate.xml validate
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building centc434-validation-rules 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- ph-schematron-maven-plugin:5.2.0:validate (cii) @ centc434-validation-rules ---
[INFO] Compiling XSLT instance [file=cii/xslt/EN16931-CII-validation.xslt]
[INFO] Successfully parsed Schematron file 'cii/xslt/EN16931-CII-validation.xslt'
[INFO] Validating XML file 'cii/examples/CII_example1.xml' against Schematron rules from '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: sun.misc.Launcher$AppClassLoader@7852e922]
[INFO] Validating XML file 'cii/examples/CII_business_example_02.xml' against Schematron rules from 'cii/xslt/EN16931-CII-validation.xslt' expecting success
[INFO] Validating XML file 'cii/examples/CII_example6.xml' against Schematron rules from 'cii/xslt/EN16931-CII-validation.xslt' expecting success
[INFO] Validating XML file 'cii/examples/CII_example4.xml' against Schematron rules from 'cii/xslt/EN16931-CII-validation.xslt' expecting success
[INFO] Validating XML file 'cii/examples/CII_example3.xml' against Schematron rules from 'cii/xslt/EN16931-CII-validation.xslt' expecting success
[INFO] Validating XML file 'cii/examples/CII_example2.xml' against Schematron rules from 'cii/xslt/EN16931-CII-validation.xslt' expecting success
[INFO] Validating XML file 'cii/examples/CII_business_example_01.xml' against Schematron rules from 'cii/xslt/EN16931-CII-validation.xslt' expecting success
[INFO] Validating XML file 'cii/examples/CII_example7.xml' against Schematron rules from 'cii/xslt/EN16931-CII-validation.xslt' expecting success
[INFO] Validating XML file 'cii/examples/CII_example5.xml' against Schematron rules from 'cii/xslt/EN16931-CII-validation.xslt' expecting success
[INFO] Validating XML file 'cii/examples/CII_example9.xml' against Schematron rules from 'cii/xslt/EN16931-CII-validation.xslt' expecting success
[INFO] Validating XML file 'cii/examples/CII_example8.xml' against Schematron rules from '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=edifact/xslt/EN16931-EDIFACT-validation.xslt]
[INFO] Successfully parsed Schematron file 'edifact/xslt/EN16931-EDIFACT-validation.xslt'
[INFO] Validating XML file 'edifact/examples/EDIFACT_EXAMPLE4.xml' against Schematron rules from 'edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success
[INFO] Validating XML file 'edifact/examples/EDIFACT_EXAMPLE8.xml' against Schematron rules from 'edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success
[INFO] Validating XML file 'edifact/examples/EDIFACT_EXAMPLE9.xml' against Schematron rules from 'edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success
[INFO] Validating XML file 'edifact/examples/EDIFACT_EXAMPLE2.xml' against Schematron rules from 'edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success
[INFO] Validating XML file 'edifact/examples/EDIFACT_EXAMPLE3.xml' against Schematron rules from 'edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success
[INFO] Validating XML file 'edifact/examples/EDIFACT_EXAMPLE7.xml' against Schematron rules from 'edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success
[INFO] Validating XML file 'edifact/examples/EDIFACT_EXAMPLE1.xml' against Schematron rules from 'edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success
[INFO] Validating XML file 'edifact/examples/EDIFACT_EXAMPLE5.xml' against Schematron rules from 'edifact/xslt/EN16931-EDIFACT-validation.xslt' expecting success
[INFO] Validating XML file 'edifact/examples/EDIFACT_EXAMPLE6.xml' against Schematron rules from '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=ubl/xslt/EN16931-UBL-validation.xslt]
[INFO] Successfully parsed Schematron file 'ubl/xslt/EN16931-UBL-validation.xslt'
[INFO] Validating XML file 'ubl/examples/ubl-tc434-creditnote1.xml' against Schematron rules from 'ubl/xslt/EN16931-UBL-validation.xslt' expecting success
[INFO] Validating XML file 'ubl/examples/ubl-tc434-example2.xml' against Schematron rules from 'ubl/xslt/EN16931-UBL-validation.xslt' expecting success
[INFO] Validating XML file 'ubl/examples/ubl-tc434-example3.xml' against Schematron rules from 'ubl/xslt/EN16931-UBL-validation.xslt' expecting success
[INFO] Validating XML file 'ubl/examples/ubl-tc434-example1.xml' against Schematron rules from 'ubl/xslt/EN16931-UBL-validation.xslt' expecting success
[INFO] Validating XML file 'ubl/examples/ubl-tc434-example7.xml' against Schematron rules from 'ubl/xslt/EN16931-UBL-validation.xslt' expecting success
[INFO] Validating XML file 'ubl/examples/ubl-tc434-example5.xml' against Schematron rules from 'ubl/xslt/EN16931-UBL-validation.xslt' expecting success
[INFO] Validating XML file 'ubl/examples/ubl-tc434-example6.xml' against Schematron rules from 'ubl/xslt/EN16931-UBL-validation.xslt' expecting success
[INFO] Validating XML file 'ubl/examples/ubl-tc434-example4.xml' against Schematron rules from 'ubl/xslt/EN16931-UBL-validation.xslt' expecting success
[INFO] Validating XML file 'ubl/examples/ubl-tc434-example9.xml' against Schematron rules from 'ubl/xslt/EN16931-UBL-validation.xslt' expecting success
[INFO] Validating XML file 'ubl/examples/ubl-tc434-example8.xml' against Schematron rules from 'ubl/xslt/EN16931-UBL-validation.xslt' expecting success
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.456 s
[INFO] Finished at: 2020-09-14T07:47:03+09:00
[INFO] Final Memory: 70M/167M
[INFO] ------------------------------------------------------------------------
[ec2-user@ip-xx-x-x-xxx eInvoicing-EN16931-validation-1.3.2]$ 

JP PINT 0.9.1スキーマトロン検証

5 XSLTスタイルシート生成

5.1 pom-xslt.xmlファイル変更

${basedir}/ubl/schematron/PINTをschematronDirectoryに指定し、
xsltDirectoryを${basedir}/ubl/xslとした。

<?xml version="1.0" encoding="UTF-8"?>
<!--

    Licensed under European Union Public Licence (EUPL) version 1.2.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.helger</groupId>
    <artifactId>parent-pom</artifactId>
    <version>1.10.8</version>
  </parent>
  <artifactId>centc434-validation-rules</artifactId>
  <version>1.0.0</version>
  <name>centc434-validation-rules</name>
  <description>EN16931 - CEN/TC 434 validation rules</description>
  <url>https://github.com/CenPC434/validation</url>
  <inceptionYear>2016</inceptionYear>
  <licenses>
    <license>
      <name>Apache 2</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <build>
    <plugins>
      <plugin>
        <groupId>com.helger.maven</groupId>
        <artifactId>ph-schematron-maven-plugin</artifactId>
        <version>5.2.0</version>
        <executions>
          <execution>
            <id>ubl</id>
            <goals>
              <goal>convert</goal>
            </goals>
            <configuration>
              <schematronDirectory>${basedir}/ubl/schematron/PINT</schematronDirectory>
              <xsltDirectory>${basedir}/ubl/xslt</xsltDirectory>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <schematronPattern>*.sch</schematronPattern>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

5.2 XSLTスタイル生成

上記で変更したファイルを指定して

mvn -f pom-xslt.xml process-resources

注:ログに残っているcentc434関連の記述は、元のソースのままとしているためです。

$ mvn -f pom-xslt.xml process-resources 
[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 (ubl) @ centc434-validation-rules ---
[INFO] Converting Schematron file 'validation/ubl/schematron/PINT/PINT-jurisdiction-aligned-rules.sch' to XSLT file 'validation/ubl/xslt/PINT-jurisdiction-aligned-rules.xslt'
[WARNING] validation/ubl/schematron/PINT/PINT-jurisdiction-aligned-rules.sch [0:0]: Transformation warning - A function that computes atomic values should use xsl:sequence rather than xsl:value-of
[INFO] Converting Schematron file 'validation/ubl/schematron/PINT/PINT-UBL-validation-preprocessed.sch' to XSLT file 'validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt'
[WARNING] validation/ubl/schematron/PINT/PINT-UBL-validation-preprocessed.sch [0:0]: Transformation warning - A function that computes atomic values should use xsl:sequence rather than xsl:value-of
[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 validation/src/main/resources
[INFO] Copying 1 resource to META-INF
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.276 s
[INFO] Finished at: 2022-05-29T16:46:44+09:00
[INFO] ------------------------------------------------------------------------
$ 

検証実行
mvn -f jp-pint-validate.xml validate

検証した結果セマンティックモデルの仕様に従って記載されていない箇所がエラーとして報告された。
[ibr-co-12]-Sum of charges on document level (ibt-108) = Σ Document level charge amount (ibt-099).


[ERROR] [fatal_error] in /*:Invoice[namespace-uri()='urn:oasis:names:specification:ubl:schema:xsd:Invoice-2'][1]/*:LegalMonetaryTotal[namespace-uri()='urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2'][1] @ examples/JP_PINT_Invoice_Example1.xml [ibr-co-12]-Sum of charges on document level (ibt-108) = Σ Document level charge amount (ibt-099). Test=xs:decimal(cbc:ChargeTotalAmount) = (round(sum(../cac:AllowanceCharge[cbc:ChargeIndicator=true()]/xs:decimal(cbc:Amount)) * 10 * 10) div 100) or (not(cbc:ChargeTotalAmount) and not(../cac:AllowanceCharge[cbc:ChargeIndicator=true()]))

エラー発生箇所のXPathは、
/*:Invoice[namespace-uri()=’urn:oasis:names:specification:ubl:schema:xsd:Invoice-2′][1]/*:LegalMonetaryTotal[namespace-uri()=’urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2′][1]
該当するファイルは、
examples/JP_PINT_Invoice_Example1.xml
testスクリプトは、
xs:decimal(cbc:ChargeTotalAmount) = (
 round(
sum(../cac:AllowanceCharge[cbc:ChargeIndicator=true()]/xs:decimal(cbc:Amount)) * 10 * 10
) div 100
) or
(not(cbc:ChargeTotalAmount) and
not(../cac:AllowanceCharge[cbc:ChargeIndicator=true()]))
海外通貨は、小数点以下2桁表示のため合計金額を100倍した金額にround()関数で丸めた計算を求め、その金額を100で割る計算を行っている。日本円で小数点以下の端数がないときに同じ計算でも問題はない。

ドキュメントレベルの追加料金の合計金額が総額表示の追加料金の金額と不一致であるとエラー報告されているので、具体的な内容を調査できる。
このように、スキーマトロンのチェックでは、セマンティックモデルで定義している項目の記載条件と金額計算ルールが検証されるとともにシンタックスバインディングで定義されたUBLの要素への対応条件がもれなく確認されているので、受け取った買い手は、自社業務システムにそのままつなげて自動的なワークフロー処理が可能となる。

$ mvn -f jp-pint-validate.xml validate
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< com.helger:pint-validation-rules >------------------
[INFO] Building pint-validation-rules 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- ph-schematron-maven-plugin:5.2.0:validate (PINT) @ pint-validation-rules ---
[INFO] Compiling XSLT instance [file=validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt]
[WARNING] validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt [0:0]: Transformation warning - A function that computes atomic values should use xsl:sequence rather than xsl:value-of
[WARNING] validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt [0:0]: Transformation warning - A function that computes atomic values should use xsl:sequence rather than xsl:value-of
[INFO] Successfully parsed Schematron file 'validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt'
[INFO] Validating XML file 'examples/Invoice_Example.xml' against Schematron rules from 'validation/ubl/xslt/PINT-UBL-validation-preprocessed.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 'examples/Invoice_Example.xml' against Schematron rules from 'validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt' expecting success
[ERROR] 2 failed Schematron assertions for XML file 'examples/Invoice_Example.xml'
[ERROR] [fatal_error] in /*:Invoice[namespace-uri()='urn:oasis:names:specification:ubl:schema:xsd:Invoice-2'][1]/*:LegalMonetaryTotal[namespace-uri()='urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2'][1] @ examples/Invoice_Example.xml [ibr-co-11]-Sum of allowances on document level (ibt-107) = Σ Document level allowance amount (ibt-092). Test=xs:decimal(cbc:AllowanceTotalAmount) = (round(sum(../cac:AllowanceCharge[cbc:ChargeIndicator=false()]/xs:decimal(cbc:Amount)) * 10 * 10) div 100) or (not(cbc:AllowanceTotalAmount) and not(../cac:AllowanceCharge[cbc:ChargeIndicator=false()]))
[ERROR] [fatal_error] in /*:Invoice[namespace-uri()='urn:oasis:names:specification:ubl:schema:xsd:Invoice-2'][1]/*:LegalMonetaryTotal[namespace-uri()='urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2'][1] @ examples/Invoice_Example.xml [ibr-co-12]-Sum of charges on document level (ibt-108) = Σ Document level charge amount (ibt-099). Test=xs:decimal(cbc:ChargeTotalAmount) = (round(sum(../cac:AllowanceCharge[cbc:ChargeIndicator=true()]/xs:decimal(cbc:Amount)) * 10 * 10) div 100) or (not(cbc:ChargeTotalAmount) and not(../cac:AllowanceCharge[cbc:ChargeIndicator=true()]))
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.307 s
[INFO] Finished at: 2022-05-29T16:48:12+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.helger.maven:ph-schematron-maven-plugin:5.2.0:validate (PINT) on project pint-validation-rules: 2 failed Schematron assertions for XML file 'examples/Invoice_Example.xml' -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
$ 

検証用パラメタファイル

コマンド実行用のjp-pint-validate.xmlファイルを次に示します。

$ mvn -f jp-pint-validate.xml validate

<?xml version="1.0" encoding="UTF-8"?>
<!--

    Licensed under European Union Public Licence (EUPL) version 1.2.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.helger</groupId>
    <artifactId>parent-pom</artifactId>
    <version>1.10.8</version>
  </parent>
  <artifactId>pint-validation-rules</artifactId>
  <version>1.0.0</version>
  <name>pint-validation-rules</name>
  <description>PINT validation rules</description>
  <url>https://github.com/CenPC434/validation</url>
  <inceptionYear>2016</inceptionYear>
  <licenses>
    <license>
      <name>Apache 2</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <build>
    <plugins>
      <plugin>
        <groupId>com.helger.maven</groupId>
        <artifactId>ph-schematron-maven-plugin</artifactId>
        <version>5.2.0</version>
        <executions>
<!--          <execution>
            <id>Basic</id>
            <phase>validate</phase>
            <goals>
              <goal>validate</goal>
            </goals>
            <configuration>
              <xmlDirectory>../examples</xmlDirectory>
              <schematronProcessingEngine>XSLT</schematronProcessingEngine>
              <schematronFile>ubl/xslt/Basic-UBL-validation-preprocessed.xslt</schematronFile>
            </configuration>
          </execution>-->
          <execution>
            <id>PINT Shared</id>
            <phase>validate</phase>
            <goals>
              <goal>validate</goal>
            </goals>
            <configuration>
              <xmlDirectory>../examples</xmlDirectory>
              <schematronProcessingEngine>XSLT</schematronProcessingEngine>
              <schematronFile>ubl/xslt/PINT-UBL-validation-preprocessed.xslt</schematronFile>
            </configuration>
          </execution>
          <execution>
            <id>Japan Aligned</id>
            <phase>validate</phase>
            <goals>
              <goal>validate</goal>
            </goals>
            <configuration>
              <xmlDirectory>../examples</xmlDirectory>
              <schematronProcessingEngine>XSLT</schematronProcessingEngine>
              <!-- <schematronFile>ubl/xslt/PINT-jurisdiction-aligned-rules.xslt</schematronFile> -->
              <schematronFile>ubl/xslt/PINT-UBL-validation-aligned-japan-preprocessed.xslt</schematronFile>
            </configuration>
          </execution>
          <execution>
            <id>Japan Aligned Nobu</id>
            <phase>validate</phase>
            <goals>
              <goal>validate</goal>
            </goals>
            <configuration>
              <xmlDirectory>../examples</xmlDirectory>
              <schematronProcessingEngine>XSLT</schematronProcessingEngine>
              <schematronFile>ubl/xslt/PINT-UBL-validation-aligned-japan-preprocessed_Nobu.xslt</schematronFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>