Share via


isXPS 一致性工具

更新:2007 年 11 月

isXPS 一致性工具 (isXPS.exe) 會測試檔案符合 XML Paper Specification (XPS) 和開放式封裝慣例 (OPC) 規格的程度。

您可以從 XPS:規格與授權下載 (英文) 下載 XPS 和 OPC 規格。

功能

  • 產生所執行測試的詳細報告。

  • 可以分批測試多個檔案。

  • 提供每個測試檔案中每個失敗的描述。

  • 智慧地建議找到的每個失敗可能違反的規則。

  • 支援可啟用自訂測試的參數,例如,只測試 OPC 符合性。

語法

isXPS/f=file_name_or_pattern [options]
注意事項:

在所有參數中,都可以使用連字號 ("-") 取代正斜線 ("/"),而使用冒號 (":") 取代等號 ("=")。

參數

參數

描述

/?

工具說明會顯示在 cmd.exe 視窗中。這個參數會封鎖所有測試,使其無法執行 (這個參數也會導致工具報告失敗。這是為了確保在 Windows Driver Kit (英文) 的測試基礎結構中執行測試時,不會出現意外「通過」的報告)。

/BadDir=path

指定目錄,在其中會複製或移動導致符合性測試失敗的檔案。如果使用 /DelBad 參數,會移動檔案。否則,會複製檔案。

/DelBad

指定導致符合性測試失敗的檔案會從它們目前的目錄中刪除 (如果與 /BadDir 參數搭配使用,則會將檔案移至後面參數指定的目錄中。如果未使用 /BadDir 參數,則會刪除檔案)。

/device="device_string"

指定與 Windows Test Technologies (WTT) 記錄器搭配使用的自訂裝置字串,這個記錄器可以從 Windows Driver Kit (英文) 取得 (請參閱/logger)。

/doc=Doc_XSD_file

指定自訂 XML 結構描述定義檔 (XSD) 檔案,用以驗證 XPS 檔案的 <DocumentStructure> 部分。建議您讓此工具使用它自己內建的預設 XSD 檔案,而非自訂的檔案。

/f

強制。指定要測試的檔案。標準命令列萬用字元 "?"和 "*" 可以用於 file_name_or_pattern 中。如果路徑或檔名包含任何空白,請使用引號括住整個路徑或檔名。XPS 檔案的副檔名通常是 'xps',但是不一定要是這個副檔名。

/logfile=file_name

指定記錄檔的路徑和檔名。除非 /logger 參數設定為 File,否則會忽略這個參數。如果未使用 /logfile 參數,而且 /logger 參數設定為 File,則記錄檔是位在目前目錄中的 isXPSLog.txt。如果使用的 /logsplit 參數值大於 0,則使用 /logfile 指定的記錄檔只會包含安裝程式測試。其他測試則會在一個或多個其他記錄檔中。如需詳細資訊,請參閱這個表格稍後的 /logprefix/logsplit,而如需所有測試的描述,則請參閱本主 題稍後的內容。

/logger=log_type

指定要產生的輸出種類。這可以是下列任意值:

  • Console (預設值) - 輸出會導向至 cmd.exe 視窗。

  • File - 除非使用 /logfile 參數指定另一個路徑或檔名,否則輸出會儲存至目前目錄中名稱為 isXPSLog.txt 的文字檔。

  • WTT - 輸出會儲存至目前目錄中名稱為 isXPSLog.wtl 的 Windows Test Technologies 記錄檔。這個選項只適用於在 Windows Driver Kit (英文) 的測試基礎結構中執行測試時。

/logprefix=prefix

指定要加入至記錄檔檔名開頭的前置字元,而記錄檔檔名是在使用 /logsplit 參數時產生。

使用的這個參數沒有明確 /logsplit 參數 (或明確 /logsplit=0) 時,工具的行為就像 /logsplit=1 (請參閱這個表格稍後的 /logsplit)。

/logsplit=number

指定是否將記錄檔分割成多個檔案,以及分割方式。

如果缺少這個參數,或這個參數存在但設定為預設值 0,則不會進行分割 (除非仍然使用 /logprefix,在這個情況下,即使具有明確 /logsplit=0 參數,還是會進行分割,而且工具的行為就像 /logsplit=1)。

如果這個參數設定為 1,則 isXPSlog.txt 檔案 (或使用 /logfile 參數指定的任何檔案) 中只會報告安裝程式測試。每個檔案測試 (請參閱本主題稍後的「II. <file_name> 測試」) 都會報告在命名為 _file_name.log 的不同記錄檔中,其中 file_name 是正在測試之 XPS 檔案的名稱。如果使用 /logprefix 參數,則在底線前面會有前置字元。

當這個參數設定為大於 1 的任意值時,會表示每個記錄檔中包含的檔案測試數目。而 isXPSlog.txt 檔案 (或使用 /logfile 參數指定的任何檔案) 中只會報告安裝程式測試。其他測試則會報告在命名為 _NtoM.log 的不同記錄檔中,其中 NtoM 指定記錄檔中包含的某範圍檔案。例如,如果五個檔案符合使用 /f 參數指定的模式,而且 /logsplit 設定為 2,則工具會產生命名為 _1to2.log、_3to4.log 和 _5to5.log 的檔案。如果使用 /logprefix 參數,則在底線前面會有前置字元。

除非 /logger 參數設定為 File,否則會忽略這個參數。如需所有測試的描述,請參閱本主題稍後的內容。

/NoInterleave

這個參數會封鎖交錯測試。 如需所有測試的描述,請參閱本主題稍後的內容。

/OnlyOPC

指定只要測試輸入檔的 OPC 符合性,而不測試 XPS 符合性。會測試 OPC 特定部分的內部標記。這個參數會封鎖 XPS 套件結構測試,使其無法執行。如需所有測試的描述,請參閱本主題稍後的內容。

/OnlyPkg

指定只測試檔案的各個部分,以確定它們是正確地儲存在套件中、具有正確的內容類型,以及它們之間具有正確的關聯性。但不會測試各個部分的內部標記 (包含 OPC 特定部分)。這個參數會封鎖 OPC 驗證測試的關聯性標記測試部分,使其無法執行。也會封鎖 XPS 套件結構測試的固定格式文件序列測試、固定格式文件測試或固定頁面測試部分,使其無法執行。最後,會封鎖獨立資源驗證測試,使其無法執行。如需所有測試的描述,請參閱本主題稍後的內容。

/r=Rsc_XSD_file

指定自訂 XML 結構描述定義檔 (XSD) 檔案,用以驗證 XPS 檔案的 <ResourceDictionary> 部分。建議您讓此工具使用它自己內建的預設 XSD 檔案,而非自訂的檔案。

/s

指定搜尋中要包含子目錄,以找出符合利用 /f 參數指定之模式的檔案。如果未使用這個參數,則不會包含子目錄。除非使用 /f 變數指定不同的父目錄,否則父目錄就是目前目錄。

/SkipResParts

指定不要測試獨立資源 (字型和影像)。這個參數會封鎖獨立資源驗證測試,使其無法執行。如需所有測試的描述,請參閱本主題稍後的內容。

/x=S0_XSD_file

指定自訂 XML 結構描述定義檔 (XSD) 檔案,用以驗證 XPS 檔案的 <FixedDocumentSequence>、<FixedDocument> 和 <FixedPage> 部分。建議您讓此工具使用它自己內建的預設 XSD 檔案,而非自訂的檔案。

記錄檔解譯

輸出是一系列的巢狀測試結果。每個測試的開頭都會標上 "+Start Test" 行,而每個測試的結尾都會標上 "-End Test" 行。根測試是針對所有使用 /f 參數指定之檔案的整組測試。例如,如果 /f 參數指定 "s*.xps",則在下列範例中會顯示根測試。

Beginning Test ******************************************
+Start Test: isXPS s*.xps

       … matter omitted … 

-End Test: isXPS s*.xps Result: Fail

Log Rollup***************************** TestName: isXPS s*.xps PassRate: 77% Pass: 63 Warn: 0 Fail: 18 Block: 0 ******************************************************* Result: Fail

請注意,"-End Test" 行會提供整體結果。如果任何檔案失敗,則會將整個測試標示為 "Fail"。

"Log Rollup" 區段摘要整個測試。"PassRate" 是通過的測試百分比。而 "Pass"、"Warning" 和 "Fail" 則分別提供通過、通過但發生警告和失敗的測試數目 ("Block" 是未與目前工作版本搭配使用的特殊失敗狀態)。

最後一行會重複整體結果。

根測試有兩種類型的子測試:

  • 安裝程式 - 每個記錄檔中都只會有一個安裝程式測試。

  • <file_name> - 每個符合使用 /f 參數指定之模式的檔案都會有測試。

安裝程式測試

安裝程式測試是用來判斷工具是否可以執行、剖析它的命令列,以及載入和編譯 XSD 檔案。它有五種類型的子測試:

  1. 記錄器初始設定 - 這實際上只有一項。因為失敗時,也不會產生記錄,所以這一律會記錄為 "Pass"。

  2. 命令列剖析 - 這實際上只有一項。失敗時,不會報告任何詳細資料,但是工具語法的說明會導向主控台。

  3. 載入和註冊自訂 XSD 檔案 - 這類子測試會有零到三種,而每個分別使用下列其中一個參數:/doc/r/x。載入 XSD 檔案之後,工具會註冊該檔案。如果與 XSD 相關聯的命名空間套用至 XPS 標記的多個部分,則會分別註冊套用的每個部分。例如,會針對 <DocumentStructure> 和 <StoryFragments> 部分註冊 <DocumentStructure>XSD。請參閱下列範例。

    注意事項:

    如果無法載入自訂 XSD 檔案,則工具不會載入其餘任何 XSD。這些包含所有內建 XSD。因此,不會執行大部分後續測試。

  4. 載入和註冊內建 XSD 檔案 - 除非無法載入自訂 XSD,否則這些測試至少有九種。而針對未使用的每個 /doc/r/x 參數都還會有一種這類額外測試。前一個項目符號中針對註冊自訂 XSD 所做的說明,也適用於內建 XSD。

  5. XSD 編譯 - 假設已載入所有 XSD 檔案,則會有一個編譯測試,而且會在無法編譯任一 XSD 檔案時失敗。如果無法載入任意 XSD 檔案,則不會執行這個測試。

下列是安裝程式測試結果的範例。在這個範例中,/x 參數是用來指定替代 S0 結構描述。

+Start Test: Setup
  Pass: Logger Initialized successfully
  Pass: Command line parameters parsed successfully
  Info: Reading stream for S0 schema from .\alternatexsds\s0schema.xsd
  Info: Registering Schema for namespace https://schemas.microsoft.com/xps/2005/06 
    and ContentType application/vnd.ms-package.xps-fixedpage+xml from provided stream
  Info: Registering Schema for namespace https://schemas.microsoft.com/xps/2005/06 
    and ContentType application/vnd.ms-package.xps-fixeddocument+xml from provided stream
  Info: Registering Schema for namespace https://schemas.microsoft.com/xps/2005/06 
    and ContentType application/vnd.ms-package.xps-fixeddocumentsequence+xml from provided stream
  Info: Registering Schema for namespace https://schemas.microsoft.com/xps/2005/06 
    and ContentType application/vnd.ms-package.xps-resourcedictionary+xml from provided stream
  Info: No filename specified for Resource Dictionary Key schema. Using default
  Info: No filename specified for Document Structure schema. Using default
  Info: Loading default Schema for Resource Dictionary key. (rdkey.xsd)
  Info: Registering Schema for namespace https://schemas.microsoft.com/xps/2005/06/resourcedictionary-key 
    and ContentType application/vnd.ms-package.xps-fixedpage+xml from provided stream
  Info: Registering Schema for namespace https://schemas.microsoft.com/xps/2005/06/resourcedictionary-key 
    and ContentType application/vnd.ms-package.xps-fixeddocument+xml from provided stream
  Info: Registering Schema for namespace https://schemas.microsoft.com/xps/2005/06/resourcedictionary-key 
    and ContentType application/vnd.ms-package.xps-fixeddocumentsequence+xml from provided stream
  Info: Registering Schema for namespace https://schemas.microsoft.com/xps/2005/06/resourcedictionary-key 
    and ContentType application/vnd.ms-package.xps-resourcedictionary+xml from provided stream
  Info: Loading default Schema for Document structure (DocStructure.xsd)
  Info: Registering Schema for namespace https://schemas.microsoft.com/xps/2005/06/documentstructure 
    and ContentType application/vnd.ms-package.xps-documentstructure+xml from provided stream
  Info: Registering Schema for namespace https://schemas.microsoft.com/xps/2005/06/documentstructure 
    and ContentType application/vnd.ms-package.xps-storyfragments+xml from provided stream
  Info: Loading default Schema for Relationship markup (Relationships.xsd)
  Info: Registering Schema for namespace https://schemas.openxmlformats.org/package/2006/relationships 
    and ContentType application/vnd.openxmlformats-package.relationships+xml from provided stream
  Info: Loading default Schema for Package properties (CoreProperties.xsd)
  Info: Registering Schema for namespace https://schemas.openxmlformats.org/package/2006/metadata/core-properties 
    and ContentType application/vnd.openxmlformats-package.core-properties+xml from provided stream
  Info: Loading default Dublin Schema for Package properties (dc.xsd)
  Info: Registering Schema for namespace http://purl.org/dc/elements/1.1/ 
    and ContentType application/vnd.openxmlformats-package.core-properties+xml 
    from provided stream
  Info: Loading default Dublin terms Schema for Package properties (dcterms.xsd)
  Info: Registering Schema for namespace http://purl.org/dc/terms/ 
    and ContentType application/vnd.openxmlformats-package.core-properties+xml 
    from provided stream
  Info: Loading default Dublin type Schema for Package properties (dcmitype.xsd)
  Info: Registering Schema for namespace http://purl.org/dc/dcmitype/ 
    and ContentType application/vnd.openxmlformats-package.core-properties+xml 
    from provided stream
  Info: Loading the OPC Digital Signature Schema (OPC_DigSig.xsd)
  Info: Registering Schema for namespace https://schemas.openxmlformats.org/package/2006/digital-signature 
    and ContentType application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml 
    from provided stream
  Info: Loading the XML Digital Signature Core Schema (xmldsig-core-schema.xsd)
  Info: Registering Schema for namespace http://www.w3.org/2000/09/xmldsig# 
    and ContentType application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml 
    from provided stream
  Info: Loading default Schema for Digital Signature Definitions (SignatureDefinitions.xsd)
  Info: Registering Schema for namespace https://schemas.microsoft.com/xps/2005/06/signature-definitions 
    and ContentType CustomSignatureDefinitionTag from provided stream
  Info: Loading default Schema for the Discard Control part (DiscardControl.xsd)
  Info: Registering Schema for namespace https://schemas.microsoft.com/xps/2005/06/discard-control 
    and ContentType application/vnd.ms-package.xps-discard-control+xml from provided stream
  Info: Compiling schemas
-End Test: Setup Result: Pass

如需範例中所參照之 Dublin 結構描述的詳細資訊,請參閱 Dublin Core Metadata Initiative

<file_name> 測試

特定檔案的每個測試都是由下列子測試組成:

  • 交錯測試。

  • 獨立資源驗證測試。

  • OPC 驗證測試。

  • XPS 套件結構測試。

交錯測試

這個工具會報告是否交錯檔案,以及如果已交錯,則是否交錯正確 (如果使用 /NoInterleave 參數,則不會執行這個測試)。這有兩種子測試:

  1. 收集項目測試 - 這個工具會收集檔案的所有內嵌項目。 這些包含每個字型和影像檔、關聯性檔案,以及每個 *.fpage、*.fdoc、*.fdseq 和 *.frag 檔案。下面是這個測試之記錄項目的範例。正在測試之 XPS 套件具有單一固定格式文件,內含單一固定頁面、單一字型和單一影像。

    +Start Test: Collecting pieces from .\MyFile.xps
      Info: _rels/.rels, collected
      Info: Documents/FixedDocument_1.fdoc, collected
      Info: Pages/_rels/FixedPage_1.fpage.rels, collected
      Info: Pages/FixedPage_1.fpage, collected
      Info: Resources/Fonts/33c063c8-1259-4322-acc8-8fc1964cc064.ODTTF, collected
      Info: Resources/Images/Image_1.png, collected
      Info: [Content_Types].xml, collected
      Info: FixedDocumentSequence.fdseq, collected
    -End Test: Collecting pieces from .\MyFile.xps Result: Pass
    
  2. 排序部分測試 - 這個測試會判斷 Zip 中央目錄與 Zip 本機檔案標頭中的檔案部分順序是否相同。如果順序不同,則測試會提供 "Warn",因為 Microsoft Windows XP Shell 不允許編輯順序不同的 Zip 檔案。

獨立資源驗證測試

獨立資源驗證測試會搜尋整個檔案,以找出指向字型或影像內容類型的 XPS 部分,而且測試會確認每個資源的內容類型都正確。例如,會確認透過字型內容類型指向的資源確實是字型 (如果使用 /SkipResParts 參數或 /OnlyPkg 參數,則不會執行這些測試)。

OPC 驗證測試

OPC 驗證測試會檢查 XPS 檔案是否符合 OPC 規格。

這個測試有兩種子測試:

  1. 關聯性標記測試 - 這個工具會驗證套件中的每個 <Relationships> 部分,但不含來自套件根的關聯性。而每個這類部分都會有一個子測試。例如,假設有一個 <Relationships> 部分稱為 1.fpage.rels (如下所示)。

    <?xml version="1.0" encoding="utf-8"?>
    <Relationships xmlns="https://schemas.openxmlformats.org/package/2006/relationships">
      <Relationship 
        Type="https://schemas.microsoft.com/xps/2005/06/required-resource" 
        Target="../../../Resources/7c1549d5-8780-4db6-8831-19bfe6d8f88d.ttf" 
        Id="Rf50d8565978247c5" />
      <Relationship 
        Type="https://schemas.microsoft.com/xps/2005/06/required-resource" 
        Target="../../../Resources/2884eaa8-9d38-4506-adf8-977a24ff9faa.jpg" 
        Id="R3643335530274b5f" />
    </Relationships>
    

    這個工具會傳回下列記錄項目。

    +Start Test: /Documents/1/Pages/_rels/1.fpage.rels Markup
      Info: Validating Markup of Part /Documents/1/Pages/_rels/1.fpage.rels 
        using target namespace "https://schemas.openxmlformats.org/package/2006/relationships"
      Pass: Markup of Part is Compliant according to the XSD supplied
    -End Test: /Documents/1/Pages/_rels/1.fpage.rels Markup Result: Pass
    

    如果使用 /OnlyPkg 參數,則關聯性標記測試的記錄項目只會警告未完成任何驗證。

  2. 套件關聯性標記測試 - 這個工具會驗證 XML Paper Specification (XPS) 套件根的 <Relationships> 部分 (如果有的話)。例如,假設有一個 <Relationships> 部分稱為 .rels (如下所示)。

    <?xml version="1.0" encoding="utf-8"?>
    <Relationships xmlns="https://schemas.openxmlformats.org/package/2006/relationships">
      <Relationship Type="https://schemas.microsoft.com/xps/2005/06/fixedrepresentation"
        Target="/FixedDocumentSequence.fdseq" Id="Ra1bd31ccb7f04267" />
      <Relationship 
        Type="https://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin"
        Target="/package/services/digital-signature/origin.psdsor" Id="R290472945f4248d7" />
    </Relationships>
    

    這個工具會傳回下列記錄項目。

    Info: Found a https://schemas.microsoft.com/xps/2005/06/fixedrepresentation 
      relationship, validating...
    Pass: Valid Relationship to /FixedDocumentSequence.fdseq from a PackageRoot part. 
      RelationshipType: https://schemas.microsoft.com/xps/2005/06/fixedrepresentation
    Info: Found a https://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin
      relationship, validating...
    Info: Digital Signature Origin part /package/services/digital-signature/origin.psdsor 
      found, validating...
    
        … matter omitted … 
    
    Pass: Valid Relationship to /package/services/digital-signature/origin.psdsor 
      from a PackageRoot part. RelationshipType: 
      https://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin
    

    如果來自根的關聯性是針對具有內部標記的物件 (如 <DigitalSignature> 部分),則驗證該 <Relationship> 部分 (做為子測試) 會包含驗證目標的標記。而後面的測試會有它自己的子測試。例如,在前一個範例中,"Digital Signature Origin part" 測試實際上是將下列測試樹狀結構項目以 "… matter omitted …" 代替。

    +Start Test: Digital Signature Valdiation
      Info: Found a https://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature 
        relationship, validating...
      Info: Found Digital Signature part 
        /package/services/digital-signature/xml-signature/c613c04b58cb4d619c92bab230c4b0c6.psdsxs, 
        validating...
      +Start Test: /package/services/digital-signature/xml-signature/c613c04b58cb4d619c92bab230c4b0c6.psdsxs Markup
        Info: Validating Markup of Part 
          /package/services/digital-signature/xml-signature/c613c04b58cb4d619c92bab230c4b0c6.psdsxs 
          using target namespace "http://www.w3.org/2000/09/xmldsig#"
        Pass: Markup of Part is Compliant according to the XSD supplied
      -End Test: /package/services/digital-signature/xml-signature/c613c04b58cb4d619c92bab230c4b0c6.psdsxs 
        Markup Result: Pass
      Info: Found a https://schemas.openxmlformats.org/package/2006/relationships/digital-signature/certificate
        relationship, validating...
      Pass: Valid Relationship to 
        /package/services/digital-signature/certificate/715364A10002007DBA0C.cer from a
        application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml part. 
        RelationshipType: https://schemas.openxmlformats.org/package/2006/relationships/digital-signature/certificate
      Pass: Valid Relationship to 
        /package/services/digital-signature/xml-signature/c613c04b58cb4d619c92bab230c4b0c6.psdsxs from a 
        application/vnd.openxmlformats-package.digital-signature-origin part. 
        RelationshipType: https://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature
    -End Test: Digital Signature Valdiation Result: Pass
    

XPS 套件結構測試

XPS 套件結構測試會以遞迴方式逐步執行 XPS 套件的樹狀結構。這樣做會驗證每個部分的標記,以及確認標記中參考的每個資源都有一個 <Relationship> 部分 (如果使用 /OnlyOPC,則不會執行這個測試)。

下列是包含的子測試。

  1. 固定格式文件序列測試 - 會驗證 *.fdseq 檔案中的 <FixedDocumentSequence> 標記。下列範例顯示通過測試時的記錄報告。

    +Start Test: /FixedDocumentSequence.fdseq Markup
      Info: Validating Markup of Part /FixedDocumentSequence.fdseq using 
        target namespace "https://schemas.microsoft.com/xps/2005/06"
      Pass: Markup of Part is Compliant according to the XSD supplied
    -End Test: /FixedDocumentSequence.fdseq Markup Result: Pass
    

    下列範例顯示測試失敗時的記錄報告,在這種情況下,原因是 XPS 產生者誤在 <FixedDocumentSequence> 開始與結束標記之間加入文字。

    +Start Test: /FixedDocumentSequence.fdseq Markup
      Info: Validating Markup of Part /FixedDocumentSequence.fdseq using 
        target namespace https://schemas.microsoft.com/xps/2005/06
      Fail: Markup is not Compliant:  Number of errors: 1
      Info: XPSRule: M2.72
      Info: Error #1: At position (1,134) Message: The element 'FixedDocumentSequence' 
        in namespace 'https://schemas.microsoft.com/xps/2005/06' 
        cannot contain text. List of possible elements expected: 
        'DocumentReference' in namespace 'https://schemas.microsoft.com/xps/2005/06'.
    -End Test: /FixedDocumentSequence.fdseq Markup Result: Fail
    

    如果使用 /OnlyPkg 參數,則固定格式文件序列測試的記錄項目只會警告未完成任何驗證。

  2. 固定格式文件測試 - 會驗證 *.fdoc 檔案中的 <FixedDocument> 標記。下列範例顯示通過測試時的記錄報告。

    +Start Test: /Documents/FixedDocument_1.fdoc Markup
      Info: Validating Markup of Part /Documents/FixedDocument_1.fdoc 
        using target namespace "https://schemas.microsoft.com/xps/2005/06"
      Pass: Markup of Part is Compliant according to the XSD supplied
    -End Test: /Documents/FixedDocument_1.fdoc Markup Result: Pass
    

    下列範例顯示測試失敗時的記錄報告,在這種情況下,原因是 <FixedDocument> 部分包含不在套件中的頁面 (<PageContent Source="../Pages/FixedPage_3.fpage" />) 參考。請注意,記錄會提供可能違反的規則清單。您可以查閱 XPS 規格中的錯誤,這個規格可以從 XPS:規格與授權下載 (英文) 下載。

    Fail: Error getting part: /Pages/FixedPage_3.fpage Message: 
      Specified part does not exist in the package.
    Fail: Reference to non-existant or corrupted part: 
      /Pages/FixedPage_3.fpage from /Documents/FixedDocument_1.fdoc
    Info: Possible violation of OPC rules M1.1, M1.2, M1.5, M1.6, M1.7,
      M1.8, M1.10, MB.2 
    

    如果使用 /OnlyPkg 參數,則固定格式文件測試的記錄項目只會警告未完成任何驗證。

  3. 固定頁面測試 - 會驗證 *.fpage 檔案中的 <FixedPage> 標記。下列範例顯示通過測試時的記錄報告。

    +Start Test: /Pages/FixedPage_1.fpage Markup
      Info: Validating Markup of Part /Pages/FixedPage_1.fpage using 
        target namespace "https://schemas.microsoft.com/xps/2005/06"
      Pass: Markup of Part is Compliant according to the XSD supplied
    -End Test: /Pages/FixedPage_1.fpage Markup Result: Pass
    

    下列範例顯示測試失敗時的記錄報告,在這種情況下,原因是 <FixedPage> 部分包含 XPS 結構描述中未宣告的屬性。記錄會識別違反的規則,而且會指定錯誤標記開始的確切字元位置。

    +Start Test: /Pages/FixedPage_2.fpage Markup
      Info: Validating Markup of Part /Pages/FixedPage_2.fpage using 
        target namespace "https://schemas.microsoft.com/xps/2005/06"
      Fail: Markup is not Compliant:  Number of errors: 1
      Info: XPSRule: M2.72
      Info: Error #1: At position (4,55) Message: The 'Stretch' 
        attribute is not declared.
    -End Test: /Pages/FixedPage_2.fpage Markup Result: Fail 
    

    如果使用 /OnlyPkg 參數,則固定頁面測試的記錄項目只會警告未完成任何驗證。

  4. 自訂標記測試 - 這個測試會測試 XSD 檔案本身未賦予的規則符合性 (如 M2.74、M3.7 到 M3.14 和 M4.3)。您可以尋找 XPS 規格中的這些規則,這個規格可以從 XPS:規格與授權下載 (英文) 下載。

  5. 頁面關聯性測試 - 這個測試會檢查 <FixedPage> 標記 (XPS 套件的 page_name.fpage 元件) 中資源部分 (字型、影像、遠端資源字典或 International Color Consortium [ICC] 設定檔) 的每個參考,以及確認具有與該資源 (在 page_name.fpage.rels 元件中) 的對應必要資源關聯性,而且該關聯性指向正確的部分類型。而每個資源都會有一個子測試。下列範例顯示字型關聯性的記錄項目。

    +Start Test: /Documents/1/Pages/3.fpage Relationships
      Info: Validating Relationships of Part /Documents/1/Pages/3.fpage
      Info: Validating Font part: /Resources/86e01f8d-dfc9-438e-9d02-830e7076a3f8.ODTTF 
        ContentType: application/vnd.ms-package.obfuscated-opentype
      Info: Name:Verdana, Embedding rights:Installable, Glyphs count:62
      Pass: Found relationship to resource Part: 
        /Resources/86e01f8d-dfc9-438e-9d02-830e7076a3f8.ODTTF
    -End Test: /Documents/1/Pages/3.fpage Relationships Result: Pass
    
  6. 未參考部分測試 - 如果在套件中找到任何未參考的部分,則記錄會顯示警告。

XPS 套件結構測試中的子測試順序如下。

  1. 測試 <FixedDocumentSequence> 部分。

  2. 測試 <FixedDocumentSequence> 部分中參考的第一個 (或下一個) <FixedDocument> 部分。

  3. 測試 <FixedDocument> 部分中參考的第一個 (或下一個) <FixedPage> 部分。

  4. 測試 <FixedPage> 部分中的自訂標記 (如果有的話)。

  5. 測試 <FixedPage> 部分的 <Relationships> 部分 (如果有的話)。這個測試具有下列子測試。

    1. 測試 <Relationships> 部分中的第一個 (或下一個) <Relationship> 部分。關聯性可以是關聯至字型、影像、遠端資源字典和 International Color Consortium (ICC) 設定檔。

    2. 針對每個關聯性,重複執行步驟 a。

  6. 針對文件中的每個頁面,重複執行步驟 3 到 5。

  7. 針對序列中的每個文件,重複執行步驟 2 到 6。

  8. 測試未參考的部分。

下列範例顯示套件的完整 XPS 套件結構測試結果,這個套件具有一份 (兩頁) 文件、每個頁面上都有一種字型,而在第二頁上有一個影像。請注意,在第二份文件的第二頁上,<FixedPage> 部分參考的 "Stretch" 屬性不是以 XPS 規格進行宣告。因此,工具會讓這個頁面和套件失敗。

+Start Test: Validating XPS Package structure: .\Spec.xps
  Info: Validating XPSRule M2.14
  Info: Found a https://schemas.microsoft.com/xps/2005/06/fixedrepresentation 
    relationship, validating...
  Pass: Valid Relationship to /FixedDocumentSequence.fdseq 
    from a PackageRoot part. RelationshipType: 
    https://schemas.microsoft.com/xps/2005/06/fixedrepresentation
  Pass: Found a Valid StartPart with ContentType: 
    application/vnd.ms-package.xps-fixeddocumentsequence+xml
  +Start Test: /FixedDocumentSequence.fdseq Markup
    Info: Validating Markup of Part /FixedDocumentSequence.fdseq using 
      target namespace "https://schemas.microsoft.com/xps/2005/06"
    Pass: Markup of Part is Compliant according to the XSD supplied
  -End Test: /FixedDocumentSequence.fdseq Markup Result: Pass
  Pass: Found markup reference to Valid Part with expected ContentType. 
    TargetURI: /Documents/FixedDocument_1.fdoc ContentType: 
    application/vnd.ms-package.xps-fixeddocument+xml
  +Start Test: /Documents/FixedDocument_1.fdoc Markup
    Info: Validating Markup of Part /Documents/FixedDocument_1.fdoc 
      using target namespace "https://schemas.microsoft.com/xps/2005/06"
    Pass: Markup of Part is Compliant according to the XSD supplied
  -End Test: /Documents/FixedDocument_1.fdoc Markup Result: Pass
  Pass: Found markup reference to Valid Part with expected ContentType. 
    TargetURI: /Pages/FixedPage_1.fpage ContentType: 
    application/vnd.ms-package.xps-fixedpage+xml
  +Start Test: /Pages/FixedPage_1.fpage Markup
    Info: Validating Markup of Part /Pages/FixedPage_1.fpage using 
      target namespace "https://schemas.microsoft.com/xps/2005/06"
    Pass: Markup of Part is Compliant according to the XSD supplied
  -End Test: /Pages/FixedPage_1.fpage Markup Result: Pass
  +Start Test: /Pages/FixedPage_1.fpage Custom Markup validation
  -End Test: /Pages/FixedPage_1.fpage Custom Markup validation Result: Pass
  +Start Test: /Pages/FixedPage_1.fpage Relationships
    Info: Validating Relationships of Part /Pages/FixedPage_1.fpage
    Info: Validating Font part: 
      /Resources/Fonts/9aa4ea89-755c-4331-be84-0cd43ff87195.ODTTF 
      ContentType: application/vnd.ms-package.obfuscated-opentype
    Info: Name:Verdana, Embedding rights:Installable, Glyphs count:35
    Pass: Found relationship to resource Part: 
      /Resources/Fonts/9aa4ea89-755c-4331-be84-0cd43ff87195.ODTTF
  -End Test: /Pages/FixedPage_1.fpage Relationships Result: Pass
  Pass: Found markup reference to Valid Part with expected ContentType. 
    TargetURI: /Pages/FixedPage_2.fpage 
    ContentType: application/vnd.ms-package.xps-fixedpage+xml
  +Start Test: /Pages/FixedPage_2.fpage Markup
    Info: Validating Markup of Part /Pages/FixedPage_2.fpage using 
      target namespace "https://schemas.microsoft.com/xps/2005/06"
    Fail: Markup is not Compliant:  Number of errors: 1
    Info: XPSRule: M2.72
    Info: Error #1: At position (4,55) Message: The 'Stretch' attribute 
      is not declared.
  -End Test: /Pages/FixedPage_2.fpage Markup Result: Fail
  +Start Test: /Pages/FixedPage_2.fpage Custom Markup validation
  -End Test: /Pages/FixedPage_2.fpage Custom Markup validation Result: Pass
  +Start Test: /Pages/FixedPage_2.fpage Relationships
    Info: Validating Relationships of Part /Pages/FixedPage_2.fpage
    Pass: Found relationship to resource Part: /Resources/Images/Image_1.png
    Info: Validating Font part: 
      /Resources/Fonts/3b85141b-0969-4d9e-b9c8-e705bb7e6543.ODTTF 
      ContentType: application/vnd.ms-package.obfuscated-opentype
    Info: Name:Times New Roman, Embedding rights:Installable, Glyphs count:4
    Pass: Found relationship to resource Part: 
      /Resources/Fonts/3b85141b-0969-4d9e-b9c8-e705bb7e6543.ODTTF
  -End Test: /Pages/FixedPage_2.fpage Relationships Result: Pass
  Pass: No un-referenced parts found
-End Test: Validating XPS Package structure: .\Spec.xps Result: Fail

需求

.NET Framework 3.0

請參閱

其他資源

XPS:規格與授權下載

XPS 和 Windows Vista

程式設計 XPS 文件實驗室和擴充 XPS 文件檢視體驗實驗室