Page 1 of 1

generate-id function and preceding axis in Schematron

Posted: Wed Feb 03, 2021 10:46 pm
by david_himself
We have a large collection of mixed text TEI/XML files.
  • 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.
I'm trying to flag redundant <handShift>s in our project schema.

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

Re: generate-id function and preceding axis in Schematron

Posted: Fri Feb 05, 2021 10:04 am
by tavy
Hello David,

I will try to analyze this situation and give you some hints, but it will be more easy for me if you can send me some sample files. You can send them on our "support at oxygenxml dot com" email address.

Best Regards,
Octavian

Re: generate-id function and preceding axis in Schematron

Posted: Fri Feb 05, 2021 11:06 am
by david_himself
Thanks. Will do.

D