Process oXygen XPath with regex
Posted by gregster on 15 May 2015 in Announcements
This entry is to help me next time I need to do the same thing.
I frequently run XPath in oXygen to find stuff. For example, I just wanted to find all the non-conformant xml:id attributes in a file. So, I used this XPath expression to find them:
//person[matches(@xml:id,'[a-z]{5}')
and it responded with output like this:
System ID: /path/to/my/file/FILENAME.xml Description: xml:id="feefifofum_3" XPath location: /TEI[1]/text[1]/body[1]/div[1]/listPerson[2]/person[166] Start location: 1703:21 End location: 1708:30
ad nauseam
I'm only interested in the actual xml:id value (feefifofum_3) so I ran this regex:
^System.*\nDescription: xml:id="(.*)?".*\n.*\n(^Start.*\n)?(^End.*\n)?
and replaced the match with the first group \1 (or $1 in oXygen)
This entry was posted by Greg and filed under Announcements.