Table of Contents

Class OdfExternalValidator

Namespace
OdfKit.Compliance
Assembly
OdfKit.dll

Provides the OdfExternalValidator API. 提供呼叫外部 ODF 驗證器的輔助方法。

public static class OdfExternalValidator
Inheritance
OdfExternalValidator
Inherited Members

Fields

OdfValidatorJarEnvironmentVariable

取得 ODF Validator JAR 路徑的環境變數名稱。

public const string OdfValidatorJarEnvironmentVariable = "ODFKIT_ODFVALIDATOR_JAR"

Field Value

string

Methods

ValidateWithCommand(string, string)

Short overload of ValidateWithCommand that accepts commandPath and filePath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 commandPath 與 filePath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithCommand 多載。

public static OdfExternalValidatorResult ValidateWithCommand(string commandPath, string filePath)

Parameters

commandPath string
filePath string

Returns

OdfExternalValidatorResult

ValidateWithCommand(string, string, int)

Validates with command. 執行可選外部驗證命令並以結束碼判定 valid / invalid。

public static OdfExternalValidatorResult ValidateWithCommand(string commandPath, string filePath, int timeoutMilliseconds)

Parameters

commandPath string

外部命令路徑

filePath string

要驗證的 ODF 文件路徑

timeoutMilliseconds int

外部程序逾時毫秒數

Returns

OdfExternalValidatorResult

外部驗證器執行結果

Remarks

Prefer ValidateWithCommandAsync(string, string, int, CancellationToken) in server environments to avoid blocking request threads. 在 ASP.NET Core 等伺服器環境中,請優先使用 ValidateWithCommandAsync(string, string, int, CancellationToken) 以避免阻塞要求執行緒。

ValidateWithCommandAsync(string, string)

Short overload of ValidateWithCommandAsync that accepts commandPath and filePath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 commandPath 與 filePath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithCommandAsync 多載。

public static Task<OdfExternalValidatorResult> ValidateWithCommandAsync(string commandPath, string filePath)

Parameters

commandPath string
filePath string

Returns

Task<OdfExternalValidatorResult>

ValidateWithCommandAsync(string, string, int)

Short overload of ValidateWithCommandAsync that accepts commandPath, filePath, and timeoutMilliseconds; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 commandPath、filePath 與 timeoutMilliseconds;其餘可選參數使用預設值並轉呼叫最長 ValidateWithCommandAsync 多載。

public static Task<OdfExternalValidatorResult> ValidateWithCommandAsync(string commandPath, string filePath, int timeoutMilliseconds)

Parameters

commandPath string
filePath string
timeoutMilliseconds int

Returns

Task<OdfExternalValidatorResult>

ValidateWithCommandAsync(string, string, int, CancellationToken)

Validates with command async. 非同步執行可選外部驗證命令並以結束碼判定 valid / invalid。

public static Task<OdfExternalValidatorResult> ValidateWithCommandAsync(string commandPath, string filePath, int timeoutMilliseconds, CancellationToken cancellationToken)

Parameters

commandPath string

外部命令路徑

filePath string

要驗證的 ODF 文件路徑

timeoutMilliseconds int

外部程序逾時毫秒數

cancellationToken CancellationToken

取消語彙基元

Returns

Task<OdfExternalValidatorResult>

代表非同步驗證作業的工作,其結果為外部驗證器執行結果

Remarks

cancellationToken 已請求取消,作業會立即以 OperationCanceledException 結束; 否則會在外部子程序等待與 stdout/stderr 讀取期間協作檢查取消語彙。

ValidateWithOdfValidator(string)

Short overload of ValidateWithOdfValidator that accepts filePath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 filePath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithOdfValidator 多載。

public static OdfExternalValidatorResult ValidateWithOdfValidator(string filePath)

Parameters

filePath string

Returns

OdfExternalValidatorResult

ValidateWithOdfValidator(string, string?)

Short overload of ValidateWithOdfValidator that accepts filePath and jarPath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 filePath 與 jarPath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithOdfValidator 多載。

public static OdfExternalValidatorResult ValidateWithOdfValidator(string filePath, string? jarPath)

Parameters

filePath string
jarPath string

Returns

OdfExternalValidatorResult

ValidateWithOdfValidator(string, string?, string?)

Short overload of ValidateWithOdfValidator that accepts filePath, jarPath, and javaPath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 filePath、jarPath 與 javaPath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithOdfValidator 多載。

public static OdfExternalValidatorResult ValidateWithOdfValidator(string filePath, string? jarPath, string? javaPath)

Parameters

filePath string
jarPath string
javaPath string

Returns

OdfExternalValidatorResult

ValidateWithOdfValidator(string, string?, string?, int)

Validates with odf validator. 使用 ODF Toolkit 的 ODF Validator JAR 驗證指定文件。

public static OdfExternalValidatorResult ValidateWithOdfValidator(string filePath, string? jarPath, string? javaPath, int timeoutMilliseconds)

Parameters

filePath string

要驗證的 ODF 文件路徑

jarPath string

ODF Validator JAR 路徑。若未提供,會讀取 ODFKIT_ODFVALIDATOR_JAR

javaPath string

Java 執行檔路徑。預設使用 java

timeoutMilliseconds int

外部程序逾時毫秒數

Returns

OdfExternalValidatorResult

外部驗證器執行結果

Remarks

Prefer ValidateWithOdfValidatorAsync(string, string?, string?, int, CancellationToken) in server environments to avoid blocking request threads. 在 ASP.NET Core 等伺服器環境中,請優先使用 ValidateWithOdfValidatorAsync(string, string?, string?, int, CancellationToken) 以避免阻塞要求執行緒。

Exceptions

ArgumentException

當文件路徑或 JAR 路徑未提供時擲出

FileNotFoundException

當文件或 JAR 不存在時擲出

TimeoutException

當外部程序逾時時擲出

ValidateWithOdfValidatorAsync(string)

Short overload of ValidateWithOdfValidatorAsync that accepts filePath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 filePath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithOdfValidatorAsync 多載。

public static Task<OdfExternalValidatorResult> ValidateWithOdfValidatorAsync(string filePath)

Parameters

filePath string

Returns

Task<OdfExternalValidatorResult>

ValidateWithOdfValidatorAsync(string, string?)

Short overload of ValidateWithOdfValidatorAsync that accepts filePath and jarPath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 filePath 與 jarPath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithOdfValidatorAsync 多載。

public static Task<OdfExternalValidatorResult> ValidateWithOdfValidatorAsync(string filePath, string? jarPath)

Parameters

filePath string
jarPath string

Returns

Task<OdfExternalValidatorResult>

ValidateWithOdfValidatorAsync(string, string?, string?)

Short overload of ValidateWithOdfValidatorAsync that accepts filePath, jarPath, and javaPath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 filePath、jarPath 與 javaPath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithOdfValidatorAsync 多載。

public static Task<OdfExternalValidatorResult> ValidateWithOdfValidatorAsync(string filePath, string? jarPath, string? javaPath)

Parameters

filePath string
jarPath string
javaPath string

Returns

Task<OdfExternalValidatorResult>

ValidateWithOdfValidatorAsync(string, string?, string?, int)

Short overload of ValidateWithOdfValidatorAsync that accepts filePath, jarPath, javaPath, and timeoutMilliseconds; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 filePath、jarPath、javaPath 與 timeoutMilliseconds;其餘可選參數使用預設值並轉呼叫最長 ValidateWithOdfValidatorAsync 多載。

public static Task<OdfExternalValidatorResult> ValidateWithOdfValidatorAsync(string filePath, string? jarPath, string? javaPath, int timeoutMilliseconds)

Parameters

filePath string
jarPath string
javaPath string
timeoutMilliseconds int

Returns

Task<OdfExternalValidatorResult>

ValidateWithOdfValidatorAsync(string, string?, string?, int, CancellationToken)

Validates with odf validator async. 非同步使用 ODF Toolkit 的 ODF Validator JAR 驗證指定文件。

public static Task<OdfExternalValidatorResult> ValidateWithOdfValidatorAsync(string filePath, string? jarPath, string? javaPath, int timeoutMilliseconds, CancellationToken cancellationToken)

Parameters

filePath string

要驗證的 ODF 文件路徑

jarPath string

ODF Validator JAR 路徑。若未提供,會讀取 ODFKIT_ODFVALIDATOR_JAR

javaPath string

Java 執行檔路徑。預設使用 java

timeoutMilliseconds int

外部程序逾時毫秒數

cancellationToken CancellationToken

取消語彙基元

Returns

Task<OdfExternalValidatorResult>

代表非同步驗證作業的工作,其結果為外部驗證器執行結果

Remarks

cancellationToken 已請求取消,作業會立即以 OperationCanceledException 結束; 否則會在外部子程序等待與 stdout/stderr 讀取期間協作檢查取消語彙。

Exceptions

ArgumentException

當文件路徑或 JAR 路徑未提供時擲出

FileNotFoundException

當文件或 JAR 不存在時擲出

TimeoutException

當外部程序逾時時擲出