phax / ph-schematron

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

Attribute 'document' is not allowed to appear in element 'svrl:active-pattern' #149

Closed pigelvy closed 7 months ago

pigelvy commented 1 year ago

Using SchematronResourceSCH (r7.0.1), the SVRL mashalling fails. It seems that the active-pattern contains the attribute document instead of documents.

Here's a simple JUnit test showing the problem.

@Test
  void simple_test() throws Exception {
    String xml = "<xml id='1'/>";

    String sch = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                 "<schema xmlns=\"http://purl.oclc.org/dsdl/schematron\" queryBinding=\"xslt2\">\n" +
                 "  <pattern>\n" +
                 "    <rule context=\"xml\"><assert test=\"exists(@id)\">No id</assert></rule>\n" +
                 "  </pattern>\n" +
                 "</schema>\n";

    final SchematronResourceSCH schResource = SchematronResourceSCH.fromString(sch, UTF_8);
    final SchematronOutputType schematronOutputType = schResource.applySchematronValidationToSVRL(new StringStreamSource(xml));

    final SVRLMarshaller svrlMarshaller = new SVRLMarshaller();
    svrlMarshaller.getAsString(schematronOutputType); // This throws an exception
  }
phax commented 1 year ago

I cannot reproduce this Exception on my side.

Looking at my (self-built) XSD, I can see this comment:

      <!-- [ph] Schematron 2016 adds this in favor of "document" -->
      <xs:attribute name="documents" type="xs:string"/>
...
      <xs:attribute name="document" type="xs:string"/>

So this is kind of Schematron-specification dependent.

The RNC of the 2006 specification contains this snippet: grafik

The RNC of the 2016 specification contains the "documents" attribute: grafik

Edit: for Schematron 2020 is identical to 2016 for this field

And ISO Schematron emits the document attribute: grafik

And finally SchXslt 1.9.5 does it according to Schematron 2016: grafik

It is all very messy....

stale[bot] commented 9 months ago

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.

phax commented 8 months ago

Bascially by chosing an implementation you can decide what attribute you will get. Hope this works. Or shall we modify the ISO Schematron XSLT to produce documents instead?