有没有在Schematron中使用循环的方法?

Is there a way to use loops in Schematron?

I am new to Schematron, however I have searched and am coming up empty handed.

I have an external file that identifies the required content sections. I can retrieve them and get a count on how many there are, however I have not figured out how to check if they are present in the source document. My thinking was to get the collection of sections in the document and then walk trough the required from 1 to the # required and for each check if it's in the document, this would allow me to write very detailed error messages.

However I have not found any way to do this, I have no problems comparing the file to the external reference as I get one node at a time, below is an example of how I check the file against an external reference, probably not optimal but it works.

<!-- Check if the section should be included -->
<sch:let name="oid_sections" value="(document(concat($oid_loc,$toc_oid)))/gc:CodeList/SimpleCodeList/Row[./Value[@ColumnRef=(concat($doc_type,'-included'))]/SimpleValue='T']/Value[@ColumnRef='code']/SimpleValue"/>
<sch:let name="current_section" value="code/@code"/>
<!-- failed assert to say section not to be included if included-section = F -->
<sch:assert test="$current_section=$oid_sections">DT Rule 36</sch:assert>
<sch:assert test="$current_section=$oid_sections">Details: The section labeled with code: <sch:value-of select="$current_section"/> is not permitted for this doctype</sch:assert>

But sadly I am searching for missing nodes, suggestions and ideas or tell me where to look :)