Dear Liam (cc public-ixml),

Thanks, Liam, for pointing this out. Yes, ixml will be available in XPath 4, making it easy to apply it to isolated parts of a document. It can already be used that way inside Saxon with the help of CoffeeSacks. 

This leaves me still wondering whether there are rules of thumb for choosing between using regex (e.g., analyze-string()) and using ixml when both are available. I approached this task in both ways and I find my regex-in-XSLT solution more legible and easier to understand, but I don’t know how much my perception of legibility or ease of understanding is about differences between the technologies vs differences in my experience and familiarity with them. “Use what you know” might get the particular job done more quickly, but sometimes learning something new pays off over time. 

As for the course exercise you mention, I used to do a regex up-conversion activity with students where they would tag every line as a line and then retag the title lines as a titles, all with regex. Overgeneralizing and then fixing the misses made for simpler match patterns than trying to tag all lines except titles.

Best,

David 

On Jan 28, 2025, at 12:07 AM, Liam R. E. Quin <liam@fromoldbooks.org> wrote:


On Mon, 2025-01-27 at 23:56 -0500, David Birnbaum wrote:

Your observation that the task might be better suited to regex, whether with a sed pre-processing step, as you suggest, or within XSLT, helps me think more generally about which tasks are well-suited to ixml and which might be handled more effectively in other ways.

In principle at least there is, or should be, also the possibility of using ixml from within XSLT, applying it as a function directly. In this case you can write a template - maybe with a predicate pattern - to match putative titles.

I’m contemplating a similar course exercise (although we won’t use ixml in an XSLT 3 course, i’ll mention it) for the upcoming course, matching paragraphs in a minimally-marked-up TEI document to turn them into headings, replacing a somewhat unsuccessful exercise i had before that replaced acronyms with expansions.

liam

-- 
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org