ph-schematron icon indicating copy to clipboard operation
ph-schematron copied to clipboard

More clues to where the error is located would be nice

Open jkiddo opened this issue 7 years ago • 10 comments

[main] ERROR com.helger.xml.transform.LoggingTransformErrorListener - [fatal_error] Transformation fatal error (net.sf.saxon.trans.XPathException: Unexpected token ")" at start of expression)
[main] ERROR com.helger.xml.transform.XMLTransformerFactory - Failed to parse javax.xml.transform.dom.DOMSource@383864d5
javax.xml.transform.TransformerConfigurationException: net.sf.saxon.s9api.SaxonApiException: Errors were reported during stylesheet compilation
	at net.sf.saxon.jaxp.SaxonTransformerFactory.newTemplates(SaxonTransformerFactory.java:157)
	at com.helger.xml.transform.XMLTransformerFactory.newTemplates(XMLTransformerFactory.java:263)
	at com.helger.schematron.xslt.SchematronProviderXSLTFromSCH.<init>(SchematronProviderXSLTFromSCH.java:220)
	at com.helger.schematron.xslt.SchematronResourceSCHCache.createSchematronXSLTProvider(SchematronResourceSCHCache.java:69)
	at com.helger.schematron.xslt.SchematronResourceSCHCache.getSchematronXSLTProvider(SchematronResourceSCHCache.java:145)
	at com.helger.schematron.xslt.SchematronResourceSCH.getXSLTProvider(SchematronResourceSCH.java:92)
	at com.helger.schematron.xslt.AbstractSchematronXSLTBasedResource.isValidSchematron(AbstractSchematronXSLTBasedResource.java:187)
	at com.helger.schematron.AbstractSchematronResource.applySchematronValidationToSVRL(AbstractSchematronResource.java:255)
	at cda.schematronvalidator.SchematronValidator.runValidation(SchematronValidator.java:143)
	at cda.schematronvalidator.SchematronValidator.validate(SchematronValidator.java:114)
	at cda.schematronvalidator.SchematronValidator.main(SchematronValidator.java:96)
Caused by: net.sf.saxon.s9api.SaxonApiException: Errors were reported during stylesheet compilation
	at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:746)
	at net.sf.saxon.jaxp.SaxonTransformerFactory.newTemplates(SaxonTransformerFactory.java:154)
	... 10 more
Caused by: net.sf.saxon.trans.XPathException: Errors were reported during stylesheet compilation
	at net.sf.saxon.style.StylesheetModule.loadStylesheet(StylesheetModule.java:259)
	at net.sf.saxon.style.Compilation.compileSingletonPackage(Compilation.java:106)
	at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:743)
	... 11 more
---------
net.sf.saxon.s9api.SaxonApiException: Errors were reported during stylesheet compilation
	at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:746)
	at net.sf.saxon.jaxp.SaxonTransformerFactory.newTemplates(SaxonTransformerFactory.java:154)
	at com.helger.xml.transform.XMLTransformerFactory.newTemplates(XMLTransformerFactory.java:263)
	at com.helger.schematron.xslt.SchematronProviderXSLTFromSCH.<init>(SchematronProviderXSLTFromSCH.java:220)
	at com.helger.schematron.xslt.SchematronResourceSCHCache.createSchematronXSLTProvider(SchematronResourceSCHCache.java:69)
	at com.helger.schematron.xslt.SchematronResourceSCHCache.getSchematronXSLTProvider(SchematronResourceSCHCache.java:145)
	at com.helger.schematron.xslt.SchematronResourceSCH.getXSLTProvider(SchematronResourceSCH.java:92)
	at com.helger.schematron.xslt.AbstractSchematronXSLTBasedResource.isValidSchematron(AbstractSchematronXSLTBasedResource.java:187)
	at com.helger.schematron.AbstractSchematronResource.applySchematronValidationToSVRL(AbstractSchematronResource.java:255)
	at cda.schematronvalidator.SchematronValidator.runValidation(SchematronValidator.java:143)
	at cda.schematronvalidator.SchematronValidator.validate(SchematronValidator.java:114)
	at cda.schematronvalidator.SchematronValidator.main(SchematronValidator.java:96)
Caused by: net.sf.saxon.trans.XPathException: Errors were reported during stylesheet compilation
	at net.sf.saxon.style.StylesheetModule.loadStylesheet(StylesheetModule.java:259)
	at net.sf.saxon.style.Compilation.compileSingletonPackage(Compilation.java:106)
	at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:743)
	... 11 more
[main] WARN com.helger.schematron.xslt.SchematronResourceSCHCache - The Schematron resource 'schema.sch' is invalid!

If the name of the file in question could be part of the stacktrace or the failed expression could be part of the trace it would be great. (The file 'schema.sch' is only the container for a lot of other files).

jkiddo avatar Sep 26 '17 12:09 jkiddo

Currently on vacation so only a quick answer.please try v5.0.0-b1 and give me feedback please. Thx

phax avatar Sep 26 '17 18:09 phax

Looks like the same to me using v5.0.0-b1

jkiddo-dxc avatar Sep 28 '17 11:09 jkiddo-dxc

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 14 '19 22:05 stale[bot]

I enabled a flag in the Saxon runtime - maybe the makes things a bit better.

phax avatar Dec 04 '20 20:12 phax

Hi ! I'm also interested in this feature (ie at least line number) on errors. But I'm not sure to understand what we (ph-schematron users) should code to have this information?

I'm using the following code to collect schematron errors:

StreamSource source = new StreamSource(new StringInputStream(xml, StandardCharsets.UTF_8));
SchematronOutputType ouput = sch.applySchematronValidationToSVRL(source);
final ICommonsList<SVRLFailedAssert> failedAssertions = SVRLHelper.getAllFailedAssertions(ouput);

Could you please provide an explanation or code snippet on how to read the "location" information ? Thanks

BBE78 avatar Jan 12 '23 15:01 BBE78

Hi, the problem with the line numbers is mainly for the internal conversion of SCH to XSLT.

In what exact context to do you expect line numbers?

  • SCH to XSLT
  • XSLT on XML

In the created SVRL there is no option to get the line number of the respective XML - that's why you have the XPath expression.

Please elaborate a bit more - thx

phax avatar Jan 12 '23 18:01 phax

Hi, here is what I want: I want the error lines number when I validate a XML content against a schematron. Maybe I'm not using the correct API to do this.

BBE78 avatar Jan 13 '23 17:01 BBE78

Unfortunately SVRL, the output language for Schematron validation, does not foresee the provision of line and column numbers for matching elements. So unfortunately there is no standard way to provide this - sorry

phax avatar Jan 15 '23 20:01 phax

Do we have another ways to have these line/column information ?

BBE78 avatar Jan 17 '23 07:01 BBE78

Well I am not aware of a simple solution to do it. Evtl. you can use this method with some value-of assertion elements, but I never used it...

phax avatar Jan 17 '23 11:01 phax