ValidateInvoiceBusinessRulesWithTools

發票、合規性

需要 Small Business 版本。在 Delphi、C++Builder 與 Lazarus 程式碼中,請以 TPDFlibSmallBusiness(PDFlibSmallBusiness 單元)或 TPDFlibEnterprise 建立程式庫;Small Business 與 Enterprise DLL 及 ActiveX 組建原樣提供。Single 版本保留此方法,方法會傳回 0、空字串或 False,並將 LastErrorCode 設為 901(PDFLIB_ERROR_SMALLBUSINESS_REQUIRED)

描述

對內嵌發票執行 XML schema 與 Schematron 驗證

語法

Delphi

Function TPDFlib.ValidateInvoiceBusinessRulesWithTools(Const EmbeddedFileName, Standard, RulesVersion, RulesProfile, SchemaFile, SchematronStylesheetFile, XMLLintExecutable, JavaExecutable, SaxonClassPath: WideString;
  TimeoutMS: Integer): WideString; Virtual;

DLL

const wchar_t* DLValidateInvoiceBusinessRulesWithTools(int InstanceID, const wchar_t* EmbeddedFileName, const wchar_t* Standard, const wchar_t* RulesVersion, const wchar_t* RulesProfile, const wchar_t* SchemaFile, const wchar_t* SchematronStylesheetFile, const wchar_t* XMLLintExecutable, const wchar_t* JavaExecutable, const wchar_t* SaxonClassPath, int TimeoutMS);
const char* DLValidateInvoiceBusinessRulesWithToolsA(int InstanceID, const char* EmbeddedFileName, const char* Standard, const char* RulesVersion, const char* RulesProfile, const char* SchemaFile, const char* SchematronStylesheetFile, const char* XMLLintExecutable, const char* JavaExecutable, const char* SaxonClassPath, int TimeoutMS);

ActiveX

Function PDFlib::ValidateInvoiceBusinessRulesWithTools(EmbeddedFileName As String, Standard As String, RulesVersion As String, RulesProfile As String, SchemaFile As String, SchematronStylesheetFile As String, XMLLintExecutable As String, JavaExecutable As String, SaxonClassPath As String, TimeoutMS As Long) As String

參數

EmbeddedFileName要驗證的內嵌發票名稱;空值會選用偵測到的 Factur-X 或 ZUGFeRD 附件
Standard規則所針對的發票標準,例如 EN 16931、Factur-X 或 ZUGFeRD
RulesVersion規則套件的版次識別碼
RulesProfile規則預期的發票設定檔,例如 MINIMUM、BASIC WL、BASIC、EN 16931、EXTENDED 或 XRECHNUNG
SchemaFile結構描述階段讀取的 XSD 套件;其匯入的文件必須能在同目錄解析
SchematronStylesheetFile編譯後的 .xsl 或 .xslt 樣式表;未編譯的 .sch 檔案會被拒絕
XMLLintExecutablexmllint 執行檔的路徑;空值會執行內建的 XML Schema 驗證器,回報引擎為 BuiltIn XSD
JavaExecutableSaxonJ 轉換所用 Java 執行檔的路徑
SaxonClassPath以分號分隔的類別路徑,內含 SaxonJ 及其相依項目
TimeoutMS套用於每個外部工具的逾時(毫秒);零或負值選用 30000 毫秒

傳回值

以 JSON 傳回驗證報告,內含所選的 standard、version 與 profile、complete 與 valid 判定,以及分開的 schema 與 schematron 階段物件。無法產生報告時傳回空字串。Single 版會傳回空字串,並將 LastErrorCode 設為 901(PDFLIB_ERROR_SMALLBUSINESS_REQUIRED)

備註

用版本化的 XSD 封裝與編譯過的 Schematron XSLT 樣式表,為所選內嵌 XML 傳回 JSON;這個便利方法一律要求兩個階段

XMLLintExecutable 留空時,schema 階段改用內建的 XML Schema 驗證器,它會讀取 SchemaFile 及其 import 的文件,並在所有平台回報引擎 BuiltIn XSD

請傳入 xmllint 與 Java 的執行檔路徑,以及包含 SaxonJ 及其相依項的分號分隔 SaxonClassPath;請使用編譯過的 .xsl 或 .xslt,而不是未編譯的 .sch 檔

RulesVersion 識別規則封裝版本,RulesProfile 識別目標發票設定檔;請明確挑選相符的規則,因為 schema 與通用 EN16931 規則不會自動涵蓋每個國家或產業設定檔

兩個工具都在沒有 shell、沒有可見視窗的情況下執行,停用 DTD 處理,輸出大小有界,並遵守要求的逾時;TimeoutMS<=0 表示 30000 ms

JSON 包含 standard、version、profile、complete、valid,以及分開的 schema 與 schematron 階段;階段內容包括狀態、完成度、引擎、執行計數、診斷,以及帶有規則 ID、欄位路徑、嚴重性、行號與訊息的問題

階段狀態為 passed、failed、error、unavailable 或 not_checked;規則失敗時仍可能 complete=true,但相依項遺漏、逾時、輸出超限、SVRL 無效與未執行的規則都不可能產生有效結果

內建工具配接器只在 Windows 上提供;可攜式應用程式可以透過具型別 API 自行提供 IPDFInvoiceValidationProvider

PDF 容器檢查與發票業務驗證是兩回事;需要檢查 PDF/A-3 與混合附件慣例時,請一併呼叫 ValidateFacturXInvoice

DLL 結果由實例持有,必須在下一次字串結果呼叫前複製;A 結果為 UTF-8 JSON,A 輸入字串使用實例的 ANSI 設定

另請參閱

ValidateFacturXInvoice, ValidateInvoiceBusinessRules, ValidateInvoiceBusinessRulesWithPackage, ExtractFacturXXMLToString