Somewhat simplified, my XML looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<dict>
<entry>
<form>word</form>
<gram>noun</gram>
<span style="bold">1.</span>
<def>this is a definition in the first sense.</def> – <cit type="example">
<quote>This is a <span style="bold">quote</span> for the first sense. </quote>
</cit>
<span style="bold">2.</span>
<def>This is a definition for the second sense</def> – <cit type="example">
<quote>This is a quote for the second sense.</quote>
</cit>
</entry>
</dict>
I need to transform this using XSLT 2.0 or 3.0 to get the following:
<?xml version="1.0" encoding="UTF-8"?>
<dict>
<entry>
<form>word</form>
<gram>noun</gram>
<sense n="1">
<def>this is a definition in the first sense.</def> – <cit type="example">
<quote>This is a <span style="bold">quote</span> for the first sense. </quote>
</cit>
</sense>
<sense n="2">
<def>This is a definition for the second sense</def> – <cit type="example">
<quote>This is a quote for the second sense.</quote>
</cit>
</sense>
</entry>
</dict>
Тhere can be more than two senses, and span style bold can occur elsewhere, so we need to identify specifically something like tei:span[@style='bold'][matches(text(), '^\d\.')]
for this.
I'm having a hard time putting this together in a stylesheet that would also extract the number for the span's text node and use it as the attribute value of the new element <sense>
.
I'll be most grateful for your tips.x