ndw / xmlcalabash1

XML Calabash, an XProc processor
http://xmlcalabash.com/
108 stars 41 forks source link

NVDL validation #283

Closed raghnysh closed 4 years ago

raghnysh commented 5 years ago

I am unable to validate documents with NVDL. I am working with XML Calabash 1.1.22-98, and DocBook 5.1. This is the pipeline nvdl.xpl that I am using:

<?xml version="1.0" encoding="utf-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:pxp="http://exproc.org/proposed/steps"
                version="1.0">
  <p:input port="source" />
  <p:output port="result" />
  <p:import href="http://xmlcalabash.com/extension/steps/library-1.0.xpl" />

  <pxp:nvdl name="validate-nvdl">
    <p:input port="nvdl">
      <p:document href="/pkg/docbook/docbook.nvdl" />
    </p:input>
    <p:input port="schemas">
      <p:empty />
    </p:input>
  </pxp:nvdl>
</p:declare-step>

This is the test file test.xml that I am using:

<?xml version="1.0" encoding="utf-8"?>
<section xmlns="http://docbook.org/ns/docbook">
  <title>Test</title>
  <para>This document is valid with respect to the RNG schema.</para>
  <annotation>
    <annotation>
      <para>However, this annotation inside an annotation violates a
      Schematron rule.</para>
    </annotation>
  </annotation>
</section>

The command

java -cp /pkg/xmlcalabash/xmlcalabash-1.1.22-98.jar com.xmlcalabash.drivers.Main -i source=test.xml nvdl.xpl

produces the error

ERROR: SAX Exception
ERROR:     cause: no implementation available for schema language with namespace URI "http://purl.oclc.org/dsdl/schematron"
ERROR: SAX Exception
ERROR: Underlying exception: no implementation available for schema language with namespace URI "http://purl.oclc.org/dsdl/schematron"

I am able to validate the document using validate-with-relax-ng, and am getting the expected error using validate-with-schematron.

raghnysh commented 5 years ago

The problem seems to be related to this thread on the Oxygen XML Forum. According to it, the version of jing current in 2010 did not support ISO Schematron validation. The version of jing packaged by my OS (Linux Mint 18.1) is able to validate the file properly:

$ jing /pkg/docbook/docbook.nvdl test.xml 
/home/raghu/xml-sandbox/xproc-nvdl/test.xml:5: error: assertion failed:
  annotation must not occur among the children or descendants of annotation

$ jing | grep -i 'version'
Jing version 20131210

The version in the XML Calabash lib directory is jing-20091111.jar. Is it possible to replace it with a more recent version?

raghnysh commented 5 years ago

Using jing built from its GitHub source works better:

$ java -cp /home/raghu/Downloads/jing-trang/build/jing.jar:/pkg/xmlcalabash/xmlcalabash-1.1.22-98.jar com.xmlcalabash.drivers.Main -i source=test.xml nvdl.xpl

Warning at char 3 in xsl:param/@select on line 459 column 43 
  SXWN9000: The parent axis starting at a document node will never select anything

error: assertion failed:
  annotation must not occur among the children or descendants of annotation
ERROR: err:XC0053:XC0053
ERROR: It is a dynamic error if the assert-valid option is true and the input document is not valid.

$ java -jar /home/raghu/Downloads/jing-trang/build/jing.jar | grep -i version
Jing version 20151127

I don't know what the SXWN9000 warning means. The response is as expected modulo that warning.

ndw commented 5 years ago

Ok. Thanks for doing the research. I noticed just this week that a recent version of jing/trang don’t seem to be in any of the common repositories. I’ll see about bundling it with the next XML Calabash release.

raghnysh commented 5 years ago

The one at https://github.com/relaxng/jing-trang has version 20151127 which seems recent enough for this problem.

ndw commented 5 years ago

Yes, but it's not on a public Maven repo, for example.

ndw commented 5 years ago

We now have Jing in Maven, so 1.1.23 should work. Please reopen if I'm mistaken.

raghnysh commented 5 years ago

Thank you very much. It works now, except for the SXWN9000 warning.

$ java -cp /pkg/xmlcalabash/xmlcalabash-1.1.23-98.jar com.xmlcalabash.drivers.Main -i source=test.xml nvdl.xpl
Warning at char 3 in xsl:param/@select on line 459 column 43 
  SXWN9000: The parent axis starting at a document node will never select anything
error: assertion failed:
  annotation must not occur among the children or descendants of annotation
ERROR: err:XC0053:XC0053
ERROR: It is a dynamic error if the assert-valid option is true and the input document is not valid.

I don't know where the warning is coming from.

raghnysh commented 5 years ago

Just in case it is relevant, according to https://github.com/w3c/epubcheck/issues/859#issuecomment-437801722 the warning is coming from the jing-trang iso-schematron.xsl file. There is also a followup at w3c/epubcheck#910.

ndw commented 5 years ago

In progress, https://github.com/relaxng/jing-trang/issues/240