p:label-elements vs p:add-attribute

Dear XProc-dev,

I'm still learning my way around XProc, and to add unique identifier
attributes to specific elements in a document within a pipeline I used
<p:viewport> to match the elements I cared about and <p:add-attribute>
(using p:iteration-position()) to create and add the unique identifiers. I
was pleased with the result until I stumbled today over <p:label-elements>,
which I hadn't noticed / known about earlier, I see that <p:label-elements>
has a "replace" option that <p:add-attribute> lacks, but otherwise it looks
as if the two methods can be used for the same purpose.

Are there situations (other than where I need to control whether to replace
an existing value) where one method should be preferred over the other?
That is, what types of use-cases motivated the decision to make both
methods available in the language? Thanks for any guidance!

Best,

David

Received on Wednesday, 5 February 2025 22:02:07 UTC