Failure in validating XML via XSLT Schematron #162
Replies: 1 comment 1 reply
-
Hi, I don't have the time to dig into it in detail, but here are my observations:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I need to validate an XML report using an XSLT Schematron file. To achieve this, I've opted for ph-schematron (com.helger:ph-schematron:5.6.5) and created the following simple application (in Java 11) to test its functionality:
`
import com.helger.schematron.ISchematronResource;
import com.helger.schematron.xslt.SchematronResourceSCH;
import javax.annotation.Nonnull;
import javax.xml.transform.stream.StreamSource;
import java.io.File;
import java.net.URL;
public class ValidationTest {
}
`
But it leads to the following exception:
2024-01-12 17:51:39,572 ERROR [com.helger.xml.transform.LoggingTransformErrorListener] [fatal_error] Transformation fatal error (net.sf.saxon.trans.XPathException: org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.) 2024-01-12 17:51:39,575 ERROR [com.helger.schematron.xslt.SchematronProviderXSLTFromSCH] Schematron preprocessor error net.sf.saxon.trans.XPathException: org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted. at net.sf.saxon.dom.DOMWriter.characters(DOMWriter.java:232) at net.sf.saxon.event.ProxyReceiver.characters(ProxyReceiver.java:157) at net.sf.saxon.event.SequenceNormalizer.characters(SequenceNormalizer.java:98) at net.sf.saxon.event.ComplexContentOutputter.characters(ComplexContentOutputter.java:270) at net.sf.saxon.trans.rules.TextOnlyCopyRuleSet.process(TextOnlyCopyRuleSet.java:81) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:530) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:625) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:478) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:625) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:478) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:625) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:478) at net.sf.saxon.trans.rules.TextOnlyCopyRuleSet.process(TextOnlyCopyRuleSet.java:72) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:530) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:625) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:478) at net.sf.saxon.trans.XsltController.applyTemplates(XsltController.java:661) at net.sf.saxon.s9api.AbstractXsltTransformer.applyTemplatesToSource(AbstractXsltTransformer.java:360) at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:349) at net.sf.saxon.jaxp.TransformerImpl.transform(TransformerImpl.java:74) at com.helger.schematron.xslt.SchematronProviderXSLTFromSCH.<init>(SchematronProviderXSLTFromSCH.java:155) at com.helger.schematron.xslt.SchematronResourceSCHCache.createSchematronXSLTProvider(SchematronResourceSCHCache.java:69) at com.helger.schematron.xslt.SchematronResourceSCHCache.lambda$getSchematronXSLTProvider$1(SchematronResourceSCHCache.java:146) at com.helger.commons.concurrent.SimpleReadWriteLock.writeLockedGet(SimpleReadWriteLock.java:404) at com.helger.schematron.xslt.SchematronResourceSCHCache.getSchematronXSLTProvider(SchematronResourceSCHCache.java:140) at com.helger.schematron.xslt.SchematronResourceSCH.getXSLTProvider(SchematronResourceSCH.java:118) at com.helger.schematron.xslt.AbstractSchematronXSLTBasedResource.isValidSchematron(AbstractSchematronXSLTBasedResource.java:188) at com.test.peppol.reporting.ValidationTest.validateXMLViaXSLTSchematron(ValidationTest.java:35) at com.test.peppol.reporting.ValidationTest.main(ValidationTest.java:20) Caused by: org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted. at java.xml/com.sun.org.apache.xerces.internal.dom.ParentNode.internalInsertBefore(ParentNode.java:359) at java.xml/com.sun.org.apache.xerces.internal.dom.ParentNode.insertBefore(ParentNode.java:286) at java.xml/com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.insertBefore(CoreDocumentImpl.java:447) at java.xml/com.sun.org.apache.xerces.internal.dom.NodeImpl.appendChild(NodeImpl.java:230) at net.sf.saxon.dom.DOMWriter.characters(DOMWriter.java:229) ... 28 common frames omitted 2024-01-12 17:51:39,577 WARN [com.helger.schematron.xslt.SchematronResourceSCHCache] The Schematron resource 'D:\test\codebases\internal-codebases\java\comp-send-oxalis-peppol-report-generator-app\target\classes\schematron\peppol-end-user-statistics-reporting-1.1.4.xslt' is invalid! Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: Invalid Schematron! at com.test.peppol.reporting.ValidationTest.main(ValidationTest.java:22) Caused by: java.lang.IllegalArgumentException: Invalid Schematron! at com.test.peppol.reporting.ValidationTest.validateXMLViaXSLTSchematron(ValidationTest.java:36) at com.test.peppol.reporting.ValidationTest.main(ValidationTest.java:20)
Could someone please assist me in sorting this out?
Thank you!
I've attached a zipped file containing the sample XML and the XSLT that I used to test the functionality:
schematron.zip
Beta Was this translation helpful? Give feedback.
All reactions