Search Posts

Visits: 254

欧州規格のスキーマトロン検証環境

次の記事にも記載しましたが、欧州規格のスキーマトロンファイルEN16931-UBL-validation.schを前処理して生成されたファイルが、EN16931-UBL-validation-preprocessed.schです。
現在公開中のPeppol BIS Billing JP 0.9.3でもDownload resourcesに含まれているスキーマトロンファイルのファイル名が`*-preprocessed.sch`で、どちらもOpen PeppolのOriolさんが作成されていますので、同様の生成方法かなと思います。
2021年12月記事 欧州規格電子インボイスのスキーマトロン検証環境

JP PINT 0.9.3

画面左下の「Download resources」ボタンをクリックするとzipファイルがダウンロードできます。
このzipファイルを解凍すると、次のようなファイルがあります。


.
├── common
│   └── docs
│       ├── bis.pdf
│       ├── compliance.pdf
│       └── release-notes.pdf
└── trn-invoice
    ├── codelist
    │   ├── Aligned-TaxCategoryCodes.gc
    │   ├── Aligned-TaxCategoryCodes.yaml
...
    │   ├── eas.gc
    │   └── eas.yaml
    ├── schematron
    │   ├── PINT-UBL-validation-preprocessed.sch
    │   └── PINT-jurisdiction-aligned-rules.sch
    ├── semantic-model.yaml
    └── syntax-binding.yaml

ここでは、次の3段階の処理を行います。
1. Javaのmavenを使用して*-preprocessed.schファイル生成
2. スキーマトロンファイルからXSLTスタイルシートファイル生成
3. デジタルインボイスにXSLTスタイルシートファイルを適用して検証を実行

XSLTスタイルシートファイル生成

前提 mvn環境

先述した2021年12月記事 欧州規格電子インボイスのスキーマトロン検証環境 を参考にMaven環境を準備してください。

mvnでpom-xslt.xml実行

pom-xslt.xmlの次のXPath /project/build/plugins/plugin/executions/execution/configuration/schematronDirectory の要素の値に入力となる *-preprocessed.sch ファイルを格納しているディレクトリを指定します。
${basedir}/ubl/schematron/JP-PINT

pom-xslt.xmlの次のXPath /project/build/plugins/plugin/executions/execution/configuration/xsltDirectory の要素の値に出力となる *-preprocessed.xslt ファイルを格納するディレクトリを指定します。
${basedir}/ubl/xslt

実行後のディレクトリは次の内容です。

{basedir}
├── ubl
│   ├── schematron
│   │   └── JP-PINT
│   │       ├── PINT-UBL-validation-preprocessed.sch
│   │       └── PINT-jurisdiction-aligned-rules.sch
│   └── xslt
│       ├── PINT-UBL-validation-preprocessed.xslt
│       └── PINT-jurisdiction-aligned-rules.xslt
└── pom-xslt.xml
pom-xslt.xml




  4.0.0
  
    com.helger
    parent-pom
    1.10.8
  
  centc434-validation-rules
  1.0.0
  centc434-validation-rules
  EN16931 - CEN/TC 434 validation rules
  https://github.com/CenPC434/validation
  2016
  
    
      Apache 2
      http://www.apache.org/licenses/LICENSE-2.0
      repo
    
  
  
    
      
        com.helger.maven
        ph-schematron-maven-plugin
        5.2.0
        
          
            ubl
            
              convert
            
            
              ${basedir}/ubl/schematron/JP-PINT
              ${basedir}/ubl/xslt
            
          
        
        
          *.sch
        
      
    
  
pom-xslt.xml実行
$ mvn -f pom-xslt.xml process-resources 2>&1
[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 '/Users/ 省略 /validation/ubl/schematron/JP-PINT/PINT-jurisdiction-aligned-rules.sch' to XSLT file '/Users/ 省略 /validation/ubl/xslt/PINT-jurisdiction-aligned-rules.xslt'
[WARNING] /Users/ 省略 /validation/ubl/schematron/JP-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 '/Users/ 省略 /validation/ubl/schematron/JP-PINT/PINT-UBL-validation-preprocessed.sch' to XSLT file '/Users/ 省略 /validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt'
[WARNING] /Users/ 省略 /validation/ubl/schematron/JP-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
[WARNING] /Users/ 省略 /validation/ubl/schematron/JP-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 /Users/ 省略 /validation/src/main/resources
[INFO] Copying 1 resource to META-INF
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.375 s
[INFO] Finished at: 2022-08-14T13:25:27+09:00
[INFO] ------------------------------------------------------------------------
$

XSLTスタイルシートファイルを適用して検証を実行

JP PINT 0.9.3サイトのダウンロードボタンから取得した次のファイルを対象にスキーマトロンでデータチェックする。

$ ls -l examples
total 360
-rw-r--r--@ 1 pontsoleil  staff  29603 Jul 19 01:12 Japan PINT Invoice UBL Example.xml
-rw-r--r--@ 1 pontsoleil  staff   9817 Jul 19 01:12 Japan PINT Invoice UBL Example1-minimum.xml
-rw-r--r--@ 1 pontsoleil  staff   9210 Jul 19 01:12 Japan PINT Invoice UBL Example2-TaxAcctCur.xml
-rw-r--r--@ 1 pontsoleil  staff  19305 Jul 19 01:12 Japan PINT Invoice UBL Example3-SumInv1.xml
-rw-r--r--@ 1 pontsoleil  staff  16042 Jul 19 01:12 Japan PINT Invoice UBL Example4-SumInv2.xml
-rw-r--r--@ 1 pontsoleil  staff  21151 Jul 19 01:12 Japan PINT Invoice UBL Example5-AllowanceCharge.xml
-rw-r--r--@ 1 pontsoleil  staff  20945 Jul 19 01:12 Japan PINT Invoice UBL Example6-CorrInv.xml
-rw-r--r--@ 1 pontsoleil  staff  12551 Jul 19 01:12 Japan PINT Invoice UBL Example7-Return.Quan.ItPr.xml
-rw-r--r--@ 1 pontsoleil  staff  21655 Jul 19 01:12 Japan PINT Invoice UBL Example9-SumInv1 and O.xml
$
pom-validate.xml



  4.0.0
  
    com.helger
    parent-pom
    1.10.8
  
  JP-PINT-validation-rules
  1.0.0
  JP-PINT-validation-rules
  Peppol Specifications for Japan Implementation of PINT validation rules
  https://github.com/CenPC434/validation
  2016
  
    
      Apache 2
      http://www.apache.org/licenses/LICENSE-2.0
      repo
    
  
  
    
      
        com.helger.maven
        ph-schematron-maven-plugin
        5.2.0
        
          
            shared-rules
            validate
            
              validate
            
            
              examples
              XSLT
              ubl/xslt/PINT-UBL-validation-preprocessed.xslt
            
          
          
            aligned-rules
            validate
            
              validate
            
            
              examples
              XSLT
              ubl/xslt/PINT-jurisdiction-aligned-rules.xslt
            
          
        
      
    
  
pom-validate.xml実行
$ mvn -f pom-validate.xml process-resources 2>&1
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< com.helger:JP-PINT-validation-rules >-----------------
[INFO] Building JP-PINT-validation-rules 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- ph-schematron-maven-plugin:5.2.0:validate (shared-rules) @ JP-PINT-validation-rules ---
[INFO] Compiling XSLT instance [file=/Users/ 省略 /validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt]
[WARNING] /Users/ 省略 /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] /Users/ 省略 /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 '/Users/ 省略 /validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt'
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example9-SumInv1 and O.xml' against Schematron rules from '/Users/ 省略 /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 '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example5-AllowanceCharge.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt' expecting success
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example4-SumInv2.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt' expecting success
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example7-Return.Quan.ItPr.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt' expecting success
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example6-CorrInv.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt' expecting success
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt' expecting success
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example1-minimum.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt' expecting success
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example2-TaxAcctCur.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt' expecting success
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example3-SumInv1.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-UBL-validation-preprocessed.xslt' expecting success
[INFO]
[INFO] --- ph-schematron-maven-plugin:5.2.0:validate (aligned-rules) @ JP-PINT-validation-rules ---
[INFO] Compiling XSLT instance [file=/Users/ 省略 /validation/ubl/xslt/PINT-jurisdiction-aligned-rules.xslt]
[WARNING] /Users/ 省略 /validation/ubl/xslt/PINT-jurisdiction-aligned-rules.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 '/Users/ 省略 /validation/ubl/xslt/PINT-jurisdiction-aligned-rules.xslt'
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example9-SumInv1 and O.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-jurisdiction-aligned-rules.xslt' expecting success
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example5-AllowanceCharge.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-jurisdiction-aligned-rules.xslt' expecting success
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example4-SumInv2.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-jurisdiction-aligned-rules.xslt' expecting success
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example7-Return.Quan.ItPr.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-jurisdiction-aligned-rules.xslt' expecting success
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example6-CorrInv.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-jurisdiction-aligned-rules.xslt' expecting success
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-jurisdiction-aligned-rules.xslt' expecting success
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example1-minimum.xml' against Schematron rules from '/Users/ 省略validation/ubl/xslt/PINT-jurisdiction-aligned-rules.xslt' expecting success
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example2-TaxAcctCur.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-jurisdiction-aligned-rules.xslt' expecting success
[INFO] Validating XML file '/Users/ 省略 /validation/examples/Japan PINT Invoice UBL Example3-SumInv1.xml' against Schematron rules from '/Users/ 省略 /validation/ubl/xslt/PINT-jurisdiction-aligned-rules.xslt' expecting success
[INFO]
[INFO] --- ph-buildinfo-maven-plugin:3.0.0:generate-buildinfo (default) @ JP-PINT-validation-rules ---
[INFO] Successfully created temp directory buildinfo-maven-plugin
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ JP-PINT-validation-rules ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/ 省略 /validation/src/main/resources
[INFO] Copying 1 resource to META-INF
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.406 s
[INFO] Finished at: 2022-08-14T14:22:02+09:00
[INFO] ------------------------------------------------------------------------
$