relaxng / jing-trang

Schema validation and conversion based on RELAX NG
http://www.thaiopensource.com/relaxng/
Other
227 stars 69 forks source link

Schematron validation erroneously fails with missing namespace exception #257

Open ujay68 opened 4 years ago

ujay68 commented 4 years ago

Strange effect: When I use the runnable jing.jar v20181222 or the runnable jing.jar built with Ant from the current head (commit 12275d1) on the attached Schematron schema and test.xml, I get this exception:

ERROR:  'Namespace for prefix 't' has not been declared.'
fatal: exception "java.lang.RuntimeException" thrown: Namespace for prefix 't' has not been declared.

To me, the schema looks ok. I've tried to hunt this down with a development setup in an IDE (IntelliJ IDEA), but when I run the current head code from within the IDE, the xml file validates just fine.

Maybe something to do with a resource missing from the jar but found by the IDE? Any idea what might be wrong here?

test.sch.txt test.xml.txt

ujay68 commented 4 years ago

The difference seems to be in the XSLT implementation, depending on whether Saxon is in the classpath or not. The method com.thaiopensource.validate.schematron.ISOSchemaReaderImpl#createSchema uses these implementations (AdoptOpenJDK build 1.8.0_242-b08 on macOS):

With Saxon in the classpath:

Without Saxon in the classpath:

The Xalan XSLT compiler runs into an ER_NAMESPACE_PREFIX exception somewhere deep in its stack (GregorSamsa in between). So, one of these countless bugs in JDK's repackaged Xalan probably.