generate-id function and preceding axis in Schematron

This should cover W3C XML Schema, Relax NG and DTD related problems.
david_himself
Posts: 27
Joined: Mon Oct 01, 2018 7:29 pm

generate-id function and preceding axis in Schematron

Post by david_himself » Wed Feb 03, 2021 10:46 pm

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

tavy
Posts: 273
Joined: Thu Jul 01, 2004 12:29 pm

Re: generate-id function and preceding axis in Schematron

Post by tavy » Fri Feb 05, 2021 10:04 am

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
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

david_himself
Posts: 27
Joined: Mon Oct 01, 2018 7:29 pm

Re: generate-id function and preceding axis in Schematron

Post by david_himself » Fri Feb 05, 2021 11:06 am

Thanks. Will do.

D

Post Reply