简体   繁体   English

使用命令行验证多个 DITA XSD 1.1 文件(文件夹)使用 Saxon

[英]Using the command line to validate multiple DITA XSD 1.1 files (folder) using Saxon

When I run the Saxon command line to validate multiple DITA files:当我运行 Saxon 命令行来验证多个 DITA 文件时:

a) using the -s option for a folder does not work. a) 对文件夹使用 -s 选项不起作用。 b) using a wildcard for the files does, but is limited to a single topic type: b) 对文件使用通配符可以,但仅限于单一主题类型:

C:\Users\542470>java -cp C:\Tools\SaxonEE11-3J\saxon-ee-11.3.jar com.saxonica.Validate -catalog:C:\Tools\dita-schemas\catalog-dita.xml -xi:on -xsiloc:on -xsdversion:1.1 "C:\Tools\SaxonEE11-3J\garage\tasks\*"
Saxon license expires in 25 days
Warning at xs:import on line 42 column 73 of softwareDomain.xsd:
  SXWN9018  The schema document at urn:oasis:names:tc:dita:xsd:xml.xsd:1.3 is not being read
  because schema components for this namespace are already available
Warning at xs:import on line 42 column 73 of uiDomain.xsd:
  SXWN9018  The schema document at urn:oasis:names:tc:dita:xsd:xml.xsd:1.3 is not being read
  because schema components for this namespace are already available
Warning at xs:import on line 63 column 73 of commonElementMod.xsd:
  SXWN9018  The schema document at urn:oasis:names:tc:dita:xsd:xml.xsd:1.3 is not being read
  because schema components for this namespace are already available
Warning at xs:import on line 31 column 78 of topicMod.xsd:
  SXWN9018  The schema document at urn:oasis:names:tc:dita:xsd:ditaarch.xsd:1.3 is not being
  read because schema components for this namespace are already available. To force the
  schema document to be read, set --multipleSchemaImports:on
Error on line 13 column 11 of garagetaskoverview.dita:
  XQDY0084  One validation error was reported: Cannot validate <Q{}**concept**>: no element
  declaration available

In this case, all the topics validated with no errors, but the topic was not recognized.在这种情况下,所有主题都经过验证没有错误,但主题未被识别。 I am using the DITA-OT/Oxygen garage DITA samples to test the command line.我正在使用 DITA-OT/Oxygen garage DITA 示例来测试命令行。 Validating a single DITA file causes no problems.验证单个 DITA 文件不会出现问题。 This only occurs when mixing the DITA topic types in the same folder.只有在同一文件夹中混合 DITA 主题类型时才会发生这种情况。

DITA topic types used:使用的 DITA 主题类型:

<concept id="taskconcept" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:oasis:names:tc:dita:xsd:concept.xsd:1.3"
    xml:lang="en-US">...

<task id="changeoil" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:oasis:names:tc:dita:xsd:task.xsd:1.3"
    xml:lang="en-US">...

Note: Having thousands of files eliminates the option of listing the files to validate.注意:拥有数千个文件会消除列出要验证的文件的选项。

All the DITA XML Schemas are in no namespace, if Saxon has some kind of schema caching, once it loads the "urn:oasis:names:tc:dita:xsd:task.xsd:1.3" schema for the first validated task, it considers that for no namespace it already has a schema so it might re-use the schema for "task.xsd" to also validate the concept file.所有 DITA XML 模式都没有命名空间,如果 Saxon 有某种模式缓存,一旦它为第一个验证任务加载“urn:oasis:names:tc:dita:xsd:task.xsd:1.3”模式,它考虑到没有命名空间它已经有一个架构,因此它可能会重新使用“task.xsd”的架构来验证概念文件。 I do not see a setting to avoid using this schema cache in the command line.我没有看到避免在命令行中使用此架构缓存的设置。 Maybe you can try to iterate all files in the folder using a "for" loop in a Windows bat file and for each file run the validation process instead of running the validation on the entire folder.也许您可以尝试在 Windows bat 文件中使用“for”循环迭代文件夹中的所有文件,并为每个文件运行验证过程,而不是对整个文件夹运行验证。 You could also ask directly on the Saxonica users list for advice about this cache.您也可以直接在 Saxonica 用户列表上询问有关此缓存的建议。

I'm not an expert on DITA, but I think that all the DITA schema modules are compatible with each other in the sense that you can combine any selection of modules into a single schema.我不是 DITA 专家,但我认为所有 DITA 模式模块都相互兼容,因为您可以将任何选择的模块组合到一个模式中。 For example, you could write a schema document that has xs:include 's for any subset of DITA modules that you want to use.例如,您可以为要使用的 DITA 模块的任何子集编写一个包含xs:include的模式文档。 I would suggest using such a composite schema in the -xsd option to the Saxon validate command.我建议在 Saxon validate 命令的 -xsd 选项中使用这样的复合模式。

Alternatively, try using the option --multipleSchemaImports:on - this should cause Saxon to load a schema module for a particular namespace (or for the null namespace) even if it already has a schema module for that namespace loaded.或者,尝试使用选项 --multipleSchemaImports:on - 这应该会导致 Saxon 为特定命名空间(或 null 命名空间)加载模式模块,即使它已经加载了该命名空间的模式模块。 (But note this can cause failures if two schema modules have overlapping definitions - I don't know if this applies to DITA.) (但请注意,如果两个模式模块具有重叠定义,这可能会导致失败——我不知道这是否适用于 DITA。)

However, you're going to get more control over a task like this if you write a little Java application to invoke Saxon repeatedly, rather than trying to do everything in a single command from the command line.但是,如果您编写一个小的 Java 应用程序来重复调用 Saxon,而不是尝试从命令行在单个命令中执行所有操作,那么您将对这样的任务有更多的控制权。

I finally did a "for loop" in a batch file.我终于在批处理文件中做了一个“for 循环”。

command-line: batch-validate C:\XML-WORK\repair\DITA-xsd\topics > testlog.txt 2> testerrors.txt命令行:batch-validate C:\XML-WORK\repair\DITA-xsd\topics > testlog.txt 2> testerrors.txt

batch file command: for %%i in (*) do java com.saxonica.Validate -catalog:C:\Tools\dita-schemas\catalog-dita.xml -xi:on -xsiloc:on -xsdversion:1.1 %%i批处理文件命令:对于 (*) 中的 %%i,执行 java com.saxonica.Validate -catalog:C:\Tools\dita-schemas\catalog-dita.xml -xi:on -xsiloc:on -xsdversion:1.1 %%我

Note: Set the classpath to Saxon and change Dir (CD) to the folder to be validated before running the batch file注意:将类路径设置为 Saxon,并将 Dir (CD) 更改为要在运行批处理文件之前验证的文件夹

It took over 3 hours to validate some 4,000 files.验证大约 4,000 个文件花费了 3 个多小时。 I was using a trial version of Saxon.我使用的是 Saxon 的试用版。 If this is always the expected result, using a batch file is not feasible.如果这始终是预期的结果,则使用批处理文件是不可行的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用命令行列出文件的多种模式 - Multiple patterns for listing files using command line 复制包含文件的文件夹和子文件夹,但使用Windows命令行跳过根文件夹中的文件 - Copy folder and sub folders with files but skip files in root folder using windows command line C ++通过命令行使用*字符传递多个文件 - C++ Passing multiple files using * character via command line 使用命令行在Windows中的zip文件夹 - zip folder in windows using command line 如何使用Windows命令行将NUL写入文件夹中的所有日志文件 - How to write NUL to all log files in a folder using windows command line 从文件夹内的文件中搜索字符串,然后使用命令行窗口返回文件路径 - Search a string from files inside folder and return the file path using command line windows 使用 C++ 针对 xsd 验证 xml - Validate xml against xsd using c++ 如何在 windows 命令行上使用单个命令创建多个文件? - How can I create multiple files using a single command on windows command line? 我可以使用单个“复制”命令在Windows命令行上复制多个命名文件吗? - Can I copy multiple named files on the Windows command line using a single “copy” command? 在Windows命令行中使用批处理文件中的参数 - Using parameters in batch files at Windows command line
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM