I’m trying to flatten an element’s text nodes and nested inlined elements
<e>something <inline>rather</inline> else</e>
into
<text>something </text>
<text-inline>rather</text-inline>
<text> else</text>
Using e/text()
would return both text nodes but how do I flatten all nodes in order for arbitrarily inlined elements (even nested)?
I am not sure "flatten" is the right term for this. It seems all you want to do is change some text nodes into elements containing the same text. This can be done by a template matching these text nodes:
Demo: https://xsltfiddle.liberty-development.net/ncdD7n4
Of course, if you also want to rename
inline
totext-inline
, you will need another template for that: