phax / ph-schematron

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

Rule not fired when context is a comment node #83

Open dmj opened 5 years ago

dmj commented 5 years ago

Using the following Schematron:

<sch:schema>
  <sch:pattern>
    <sch:rule context="comment()">
      <sch:assert test="false()"/>
    </sch:rule>
  </sch:pattern>
</sch:schema>

And the following document:

<?pi Processing instruction ?>
<element attribute="value">
  <!-- Comment -->
  <element>Text content</element>
</element>

I expect the assertion to fail.

But instead I get the following:

<?xml version="1.0" encoding="UTF-8"?>
<schematron-output xmlns="http://purl.oclc.org/dsdl/svrl">
  <active-pattern/>
</schematron-output>

This was discovered with running ph-schematron 5.2.0 against a in-progress schematron testsuite. The complete test results are shown here.

stale[bot] commented 5 years 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 2 years ago

This is a long standing issue, and I tested it with the latest version and here are my results. When using your proposed Schematron

<?xml version="1.0" encoding="utf-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
  <sch:pattern>
    <sch:rule context="comment()">
      <sch:assert test="false()">Found a comment</sch:assert>
    </sch:rule>
  </sch:pattern>
</sch:schema>

and this test XML

<?xml version="1.0" encoding="UTF-8"?>
<?pi Processing instruction ?>
<element attribute="value">
  <!-- Comment -->
  <element>Text content</element>
</element>

I get the following output when using the ISO Schematrons:

<?xml version="1.0" encoding="UTF-8"?>
<ns2:schematron-output xmlns:ns2="http://purl.oclc.org/dsdl/svrl" title="" schemaVersion="">
  <ns2:active-pattern document="C:\dev\git\ph-schematron\ph-schematron-xslt\src\test\resources\issues\github83\test.xml" />
</ns2:schematron-output>

The same error with SchXslt 1.8.5:

<?xml version="1.0" encoding="UTF-8"?>
<ns2:schematron-output xmlns:ns2="http://purl.oclc.org/dsdl/svrl">
  <ns2:active-pattern documents="C:\dev\git\ph-schematron\ph-schematron-schxslt\src\test\resources\issues\github83\test.xml" />
</ns2:schematron-output>

and with the pure version:

<?xml version="1.0" encoding="UTF-8"?>
<ns2:schematron-output xmlns:ns2="http://purl.oclc.org/dsdl/svrl">
  <ns2:active-pattern />
</ns2:schematron-output>

In the meantime you maybe more qualified that question yourself @dmj ???