Search code examples
xmlschematronoxygenxml

Schematron to check if metadata element has been updated


I am trying to create a schematron that checks if the metadata element with keywords exists and if it has been updated. I have the code to check if the metadata exists but I am unsure of what to add to check if the metadata has been updated.

This is the code I have so far:

<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
  <sch:pattern>
    <sch:rule context="/*">
      <sch:assert test="prolog/metadata/keywords" role="warn">
        It is recommended to add metadata in the current '<sch:name/>' topic.
      </sch:assert>
     </sch:rule>
    </sch:pattern>
</sch:schema>

I have tested this and it does work for checking if metadata keywords were created.


Solution

  • Change prolog/metadata/keywords to prolog/metadata/keywords/keyword. The XPath is true if any keyword is present.