<?xml version="1.0" encoding="UTF-8"?>
<sch:pattern id="ISM-ID-00119" xmlns:sch="http://purl.oclc.org/dsdl/schematron">
    <sch:p id="ruleText">
        [ISM-ID-00119][Error] If ISM-CAPCO-RESOURCE and 
        1. attribute classification is not [U]
        AND
        2. ISM-ICD-710Applies
        AND
        3. Attribute disseminationControls does not contain one or more of 
            [DISPLAYONLY], [REL], [RELIDO], [EYES], or [NF]

        
        Human Readable: All classified NSI that claims compliance with ICD 710 must have an appropriate 
        foreign disclosure or release marking.
    </sch:p>
    <sch:p id="codeDesc">
        If CAPCO rules do not apply to the document, or ICD 710 does not apply to the document,
        or the resource is unclassified, then the the rule does not apply and we return true. 
        Otherwise, we make sure that the attribute disseminationControls does not contain 
        one of the values [DISPLAYONLY], [RELIDO], [REL], [EYES], or [NF].
    </sch:p>
    <sch:rule context="//*[@ism:*]">
        <sch:let name="dissemTok" value="tokenize(./@ism:disseminationControls,' ')"/>
        <sch:assert 
            id="ISM-00119" 
            test="
            if(not($ISM_CAPCO_RESOURCE)) then true() else 
            if(not($ISM_ICD_710_APPLIES)) then true() else
            if(./@ism:classification='U') then true() else
            not(
                count(
                    (if(index-of($dissemTok, 'RELIDO')>0) then 1 else null, 
                     if(index-of($dissemTok, 'REL')>0) then 1 else null,
                     if(index-of($dissemTok, 'EYES')>0) then 1 else null,
                     if(index-of($dissemTok, 'DISPLAYONLY')>0) then 1 else null,
                     if(index-of($dissemTok, 'NF')>0) then 1 else null)
                )=0
            )
            " 
            flag="error">
            [ISM-ID-00119][Error] All classified NSI that claims compliance with ICD 710 must have an appropriate 
            foreign disclosure or release marking.
        </sch:assert>
    </sch:rule>
</sch:pattern>