<div style="font-family: Arial, sans-serif; font-size: 14px;">Hello,</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">Consider the following XML:</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><span><?xml version="1.0"?></span><div><span><root></span></div><div><span>  <relevant></span></div><div><span>    <element relevant-attribute="this attribute exists only on elements under relevant"/></span></div><div><span>  </relevant></span></div><div><span>  <irrelevant></span></div><div><span>    <element/></span></div><div><span>  </irrelevant></span></div><div><span></root></span></div><div><span><br></span></div><span></span></div><div style="font-family: Arial, sans-serif; font-size: 14px;">And the following Schematron:</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><span><?xml version="1.0" encoding="UTF-8"?></span><div><span><schema xmlns="<a target="_blank" rel="noreferrer nofollow noopener" href="http://purl.oclc.org/dsdl/schematron">http://purl.oclc.org/dsdl/schematron</a>" queryBinding="xslt3" xmlns:xsl="<a target="_blank" rel="noreferrer nofollow noopener" href="http://www.w3.org/1999/XSL/Transform">http://www.w3.org/1999/XSL/Transform</a>" xmlns:map="<a target="_blank" rel="noreferrer nofollow noopener" href="http://www.w3.org/2005/xpath-functions/map">http://www.w3.org/2005/xpath-functions/map</a>"></span></div><div><span>  <ns prefix="map" uri="<a target="_blank" rel="noreferrer nofollow noopener" href="http://www.w3.org/2005/xpath-functions/map">http://www.w3.org/2005/xpath-functions/map</a>"/></span></div><div><span>  <let name="some-map" value="map {}"/></span></div><div><span>  <pattern></span></div><div><span>    <rule context="/*/relevant/element[map:contains($some-map, @relevant-attribute)]"></span></div><div><span>      <assert test="true()">Impossible</assert></span></div><div><span>    </rule></span></div><div><span>  </pattern></span></div><div><span></schema></span></div><span></span></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">When I validate the XML with the Schematron, Oxygen prints a warning that an empty sequence is not allowed as the second argument to map:contains, which I've determined is because it is testing the "element" elements under "irrelevant". I know this because if I add a second such element, the error prints twice. If I have 9, the error prints 9 times. But why is it testing that element? I deliberately used xpath that navigates via the parent because I want to include only elements under that parent, but it seems that it's looking at all elements, anywhere in the document, named 'element'. Is this expected?</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">I can silence the warning if I explicitly check for the presence of the attribute:</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><span></span></div><span><?xml version="1.0" encoding="UTF-8"?></span><div><span><schema xmlns="<a target="_blank" rel="noreferrer nofollow noopener" href="http://purl.oclc.org/dsdl/schematron">http://purl.oclc.org/dsdl/schematron</a>" queryBinding="xslt3" xmlns:xsl="<a target="_blank" rel="noreferrer nofollow noopener" href="http://www.w3.org/1999/XSL/Transform">http://www.w3.org/1999/XSL/Transform</a>" xmlns:map="<a target="_blank" rel="noreferrer nofollow noopener" href="http://www.w3.org/2005/xpath-functions/map">http://www.w3.org/2005/xpath-functions/map</a>"></span></div><div><span>  <ns prefix="map" uri="<a target="_blank" rel="noreferrer nofollow noopener" href="http://www.w3.org/2005/xpath-functions/map">http://www.w3.org/2005/xpath-functions/map</a>"/></span></div><div><span>  <let name="some-map" value="map {}"/></span></div><div><span>  <pattern></span></div><div><span>    <rule context="/*/relevant/element[@relevant-attribute and map:contains($some-map, @relevant-attribute)]"></span></div><div><span>      <assert test="true()">Impossible</assert></span></div><div><span>    </rule></span></div><div><span>  </pattern></span></div><div><span></schema></span></div><div><span><br></span></div><span></span><div style="font-family: Arial, sans-serif; font-size: 14px;">But not if I precede the broken rule with a rule that should equivalently prevent the broken rule from firing on those elements:</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><span></span><span><?xml version="1.0" encoding="UTF-8"?></span><div><span><schema xmlns="<a target="_blank" rel="noreferrer nofollow noopener" href="http://purl.oclc.org/dsdl/schematron">http://purl.oclc.org/dsdl/schematron</a>" queryBinding="xslt3" xmlns:xsl="<a target="_blank" rel="noreferrer nofollow noopener" href="http://www.w3.org/1999/XSL/Transform">http://www.w3.org/1999/XSL/Transform</a>" xmlns:map="<a target="_blank" rel="noreferrer nofollow noopener" href="http://www.w3.org/2005/xpath-functions/map">http://www.w3.org/2005/xpath-functions/map</a>"></span></div><div><span>  <ns prefix="map" uri="<a target="_blank" rel="noreferrer nofollow noopener" href="http://www.w3.org/2005/xpath-functions/map">http://www.w3.org/2005/xpath-functions/map</a>"/></span></div><div><span>  <let name="some-map" value="map {}"/></span></div><div><span>  <pattern></span></div><div><span>    <rule context="/*/relevant/element[not(@relevant-attribute)]"></span></div><div><span>      <assert test="true()">Impossible</assert></span></div><div><span>    </rule></span></div><div><span>    <rule context="/*/relevant/element[map:contains($some-map, @relevant-attribute)]"></span></div><div><span>      <assert test="true()">Impossible</assert></span></div><div><span>    </rule></span></div><div><span>  </pattern></span></div><div><span></schema></span></div><span></span><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">Thanks,</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">-- <br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">Danny MacMillan<br></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div>
<div class="protonmail_signature_block " style="font-family: Arial, sans-serif; font-size: 14px;">
    <div class="protonmail_signature_block-user protonmail_signature_block-empty"></div>
    
            <div class="protonmail_signature_block-proton">
        Sent with <a target="_blank" href="https://proton.me/" rel="noopener noreferrer">Proton Mail</a> secure email.
    </div>
</div>