Home > database >  Using the command line to validate multiple DITA XSD 1.1 files (folder) using Saxon
Using the command line to validate multiple DITA XSD 1.1 files (folder) using Saxon

Time:01-26

When I run the Saxon command line to validate multiple DITA files:

a) using the -s option for a folder does not work. b) using a wildcard for the files does, but is limited to a single topic type:

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. Validating a single DITA file causes no problems. This only occurs when mixing the DITA topic types in the same folder.

DITA topic types used:

<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.

CodePudding user response:

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. 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. You could also ask directly on the Saxonica users list for advice about this cache.

CodePudding user response:

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. For example, you could write a schema document that has xs:include's for any subset of DITA modules that you want to use. I would suggest using such a composite schema in the -xsd option to the Saxon validate command.

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. (But note this can cause failures if two schema modules have overlapping definitions - I don't know if this applies to 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.

  • Related