Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schematron validation erroneously fails with missing namespace exception #257

Open
ujay68 opened this issue Apr 9, 2020 · 1 comment
Open

Comments

@ujay68
Copy link

ujay68 commented Apr 9, 2020

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
Copy link
Author

ujay68 commented Apr 9, 2020

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:

  • XMLReader: com.icl.saxon.aelfred.SAXDriver
  • TemplatesHandler: com.icl.saxon.TemplatesHandlerImpl

Without Saxon in the classpath:

  • XMLReader: com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
  • TemplatesHandler: com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesHandlerImpl

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant