ph-schematron icon indicating copy to clipboard operation
ph-schematron copied to clipboard

Rule not fired when context is a comment node

Open dmj opened this issue 4 years ago • 2 comments

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.

dmj avatar Aug 06 '19 09:08 dmj

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[bot] avatar Nov 04 '19 10:11 stale[bot]

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

phax avatar Dec 29 '21 19:12 phax