phax / ph-schematron

Java Schematron library that supports XSLT and native application
Apache License 2.0
110 stars 36 forks source link

SAXParseException: cvc-complex-type.2.4.a #140

Closed cemo closed 1 year ago

cemo commented 1 year ago

I have a sch file including some other sch files. When I use with another project, it runs fine but with ph-schematron I have some issues. Can you help me please about this error?

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://purl.oclc.org/dsdl/svrl":ns-prefix-in-attribute-values}'. One of '{"http://purl.oclc.org/dsdl/svrl":active-pattern, "http://purl.oclc.org/dsdl/svrl":fired-rule}' is expected.
    at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204)
phax commented 1 year ago

Which module are you using? Pure, Xslt or Schxslt?

cemo commented 1 year ago

I am using

<dependency>
  <groupId>com.helger.schematron</groupId>
  <artifactId>ph-schematron-xslt</artifactId>
  <version>7.0.0</version>
</dependency>
cemo commented 1 year ago

My usage is:

  @Test
  void sampl2e() throws Exception {

    ClassPathResource classPathResource = new ClassPathResource("/fixtures/1_TEMEL_FATURA.xml");
    InputStream inputStream = classPathResource.getInputStream();

    final ISchematronResource aResSCH = SchematronResourceSCH.fromClassPath("/schematron/TR_Schematron_EInvoice.xml");

    if (!aResSCH.isValidSchematron ())
      throw new IllegalArgumentException ("Invalid Schematron!");
    SchematronOutputType schematronOutputType = aResSCH.applySchematronValidationToSVRL(new StreamSource(inputStream));
phax commented 1 year ago

The problem is somewhere else. The "URI Resolver" is set by default (using method SchematronResourceSCH.setURIResolver).

The problem is in the created SVRL out. Your output uses an element ns-prefix-in-attribute-values in the wrong order. Can you by any chance append the SCH and the example invoice to this issue, so that I can have a look?

cemo commented 1 year ago

I created a gist:

https://gist.github.com/cemo/83cd1064f20838cc6cbb053946e64c89

sample.xml is the scm schema which is including UBL-TR_Common_Schematron.xml and UBL-TR_Codelist.xml. data.xml is valid sample.

By the way I tried as you suggested by changing locations of the definitions blocks and it seems it is working. But I wanted to share you again maybe it can help you for future problems.