in reply to Replace MathML content using Twig

Using XML::XSH2:
open 903926.xml ; map :i {s/(.*)/[$1]/} //mml:mi[text()!="s"] ; # wrap non-s in square b +rackets map "..." //mml:mi[text()="s"] ; # replace s with ...