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

More clues to where the error is located would be nice #52

Open
jkiddo opened this issue Sep 26, 2017 · 10 comments
Open

More clues to where the error is located would be nice #52

jkiddo opened this issue Sep 26, 2017 · 10 comments

Comments

@jkiddo
Copy link

jkiddo commented Sep 26, 2017

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

@phax
Copy link
Owner

phax commented Sep 26, 2017

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

@jkiddo-dxc
Copy link

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

@phax phax self-assigned this Sep 29, 2017
@stale
Copy link

stale bot commented May 14, 2019

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 stale bot added the wontfix label May 14, 2019
@phax phax added pinned and removed wontfix labels May 15, 2019
phax added a commit that referenced this issue Dec 4, 2020
@phax
Copy link
Owner

phax commented Dec 4, 2020

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

@phax phax added the Saxon label Dec 4, 2020
@BBE78
Copy link

BBE78 commented Jan 12, 2023

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

@phax
Copy link
Owner

phax commented Jan 12, 2023

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

@BBE78
Copy link

BBE78 commented Jan 13, 2023

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.

@phax
Copy link
Owner

phax commented Jan 15, 2023

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

@BBE78
Copy link

BBE78 commented Jan 17, 2023

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

@phax
Copy link
Owner

phax commented Jan 17, 2023

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

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

No branches or pull requests

4 participants