generate-id function and preceding axis in Schematron
Posted: Wed Feb 03, 2021 10:46 pm
We have a large collection of mixed text TEI/XML files.
My Schematron rules work OK both for files which have <div>s without @hand and for files without any <div>s at all. My problem is with files containing div/@hand, i.e. whose <body> portion is a sequence of elements of the form <div type="ABC" hand="#XYZ"> ... </div>. I need to be able to identify (i) the <handShift> in one such <div>, if any, which precedes a given <handShift> in the same <div>, and (ii) the first <handShift> in such a <div>, if any. For testing (non)identity of div or handShift elements, I've been using the generate-id function. If I use paths containing tei:handShift[1], certain configurations trigger an error message of the type 'A sequence of more than one item is not allowed as the first argument of fn:generate-id() (<handShift>, <handShift>)'. I don't understand how this could arise, but to avoid the error, I've replaced tei:handShift[1] by tei:handShift[not(preceding::tei:handShift)]. Unfortunately, the preceding axis can move outside the <div>, in which case the rule doesn't fire when it should.
I've tried to use a rule context either of <handShift> or of the ancestor <div>, but no luck yet with either. Any pointers on how to proceed? Thanks.
best
David
- If a file has <div> elements, either all the <div>s have @hand, or none.
- <handShift new="#XYZ"/> is always a milestone element.
- Consecutive <handShift>s are not necessarily siblings, as they can be embedded in almost any element where text is allowed.
My Schematron rules work OK both for files which have <div>s without @hand and for files without any <div>s at all. My problem is with files containing div/@hand, i.e. whose <body> portion is a sequence of elements of the form <div type="ABC" hand="#XYZ"> ... </div>. I need to be able to identify (i) the <handShift> in one such <div>, if any, which precedes a given <handShift> in the same <div>, and (ii) the first <handShift> in such a <div>, if any. For testing (non)identity of div or handShift elements, I've been using the generate-id function. If I use paths containing tei:handShift[1], certain configurations trigger an error message of the type 'A sequence of more than one item is not allowed as the first argument of fn:generate-id() (<handShift>, <handShift>)'. I don't understand how this could arise, but to avoid the error, I've replaced tei:handShift[1] by tei:handShift[not(preceding::tei:handShift)]. Unfortunately, the preceding axis can move outside the <div>, in which case the rule doesn't fire when it should.
I've tried to use a rule context either of <handShift> or of the ancestor <div>, but no luck yet with either. Any pointers on how to proceed? Thanks.
best
David