<?xml version="1.0" encoding="UTF-8"?>
<sch:pattern id="ISM-ID-00156" xmlns:sch="http://purl.oclc.org/dsdl/schematron">
    <sch:p id="ruleText">
        [ISM-ID-00156][Error] If ISM-CAPCO-RESOURCE and:
        1. The attribute notice contains on of the [DoD-Dist-B], [DoD-Dist-C], [DoD-Dist-D], [DoD-Dist-E],
           [DoD-Dist-F], or [DoD-Dist-X]
        AND
        2. One of the attributes noticeDate and noticePOC is not specified.
        
        Human Readable: DoD distribution statements B, C, D ,E ,F, and X all require a Date and a POC.
    </sch:p>
    <sch:p id="codeDesc">
        If CAPCO rules do not apply to the document then the rule does not apply
        and we return true. If the current element has attribute notice specified 
        with a value containing [DoD-Dist-B], [DoD-Dist-C], [DoD-Dist-D], [DoD-Dist-E], [DoD-Dist-F], 
        or [DoD-Dist-X], then we make sure that attributes noticeDate and noticePOC are also specified 
        on the resourceElement.
    </sch:p>
    <sch:rule context="//*[@ism:notice]">
        <!-- tokenize the element's notice attribute -->
        <sch:let name="noticeTok" value="tokenize(./@ism:notice, ' ')"/>
        
        <sch:assert id="ISM-00156"
            test="
            if(not($ISM_CAPCO_RESOURCE)) then true() else 
            if(index-of($noticeTok, 'DoD-Dist-B')>0 or
               index-of($noticeTok, 'DoD-Dist-C')>0 or
               index-of($noticeTok, 'DoD-Dist-D')>0 or
               index-of($noticeTok, 'DoD-Dist-E')>0 or
               index-of($noticeTok, 'DoD-Dist-F')>0 or
               index-of($noticeTok, 'DoD-Dist-X')>0) 
                then (./@ism:noticeDate and ./@ism:noticePOC)
                else true()
            "
            flag="error"> 
            [ISM-ID-00156][Error] DoD distribution statements B, C, D ,E ,F, and X all require a Date and a POC.
        </sch:assert>
    </sch:rule>
</sch:pattern>
