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

omvjsjqw  于 2023-01-27  发布在  Windows
关注(0)|答案(2)|浏览(143)

当我运行Saxon命令行来验证多个DITA文件时:
a)对文件夹使用-s选项无效。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

在本例中,所有主题都验证无误,但主题未被识别。我正在使用DITA-OT/Oxygen garage DITA示例测试命令行。验证单个DITA文件不会产生任何问题。只有在同一文件夹中混合了DITA主题类型时才会出现这种情况。
使用的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">...

注意:如果有数千个文件,就不需要列出要验证的文件。

elcex8rz

elcex8rz1#

所有的DITA XML Schema都不在命名空间中,如果Saxon有某种模式缓存,一旦它为第一个验证的任务加载了“urn:oasis:names:tc:dita:xsd:task.xsd:1.3”模式,它就认为对于没有命名空间,它已经有了一个模式,所以它可能会重用“task.xsd”的模式来验证概念文件。我没有看到避免在命令行中使用此模式缓存的设置。也许您可以尝试在Windows bat文件中使用“for”循环来迭代文件夹中的所有文件,并为每个文件运行验证过程,而不是在整个文件夹上运行验证。您还可以直接在Saxonica用户列表中询问有关此缓存的建议。

mznpcxlj

mznpcxlj2#

我不是DITA方面的Maven,但我认为所有DITA模式模块都是相互兼容的,因为您可以将任何选择的模块组合到单个模式中。例如,您可以编写一个模式文档,其中包含您要使用的DITA模块的任何子集的xs:include。我建议在Saxon validate命令的-xsd选项中使用这样的复合模式。
或者,尝试使用选项--multipleSchemaImports:on --这应该会导致Saxon为特定的名称空间(或空名称空间)加载模式模块,即使它已经为该名称空间加载了模式模块(但请注意,如果两个模式模块具有重叠的定义,这可能会导致失败--我不知道这是否适用于DITA)。
但是,如果您编写一个小的Java应用程序来反复调用Saxon,而不是尝试在命令行的单个命令中完成所有任务,您将对这样的任务获得更多的控制。

相关问题