This is a problem I came across. To prevent h1 to be duplicated, in xml every h1 tag will have a radom number after h1. And the source xml and the wanted html are shown below:
source xml:
<h1_JW1XRT>Hello1</h1_JW1XRT>
<h1_JXZRIE>Hello2</h1_JXZRIE>
convert into html
<h1 id="h1_JW1XRT">Hello1</h1>
<h1 id="h1_JXZRIE">Hello2</h1>
how can i write this template?
This transformation:
when applied on the following XML document (the provided XML fragment, wrapped in a single top element — to become a well-formed XML document):
produces the wanted, correct result:
Explanation: Proper use of the standard XPath function
starts-with()