Definitely I will never find success thinking in XSLT…
Here is what I have:
<par font="Arial" size="24">text 24</par>
<par font="Arial" size="12">text 12</par>
<par font="Times New Roman" size="12">text times 12</par>
And here is what I want:
<font style="font-family:Arial"><font style="font-size:24">text 24</font></font>
<font style="font-family:Arial"><font style="font-size:12">text 12</font></font>
<font style="font-family:Times New Roman"><font style="font-size:12">text times 12</font></font>
Of course, something like this is good as well, but for me this solution seems more complicated:
<font style="font-family:Arial;font-size:24">text 24</font>
<font style="font-family:Arial;font-size:12">text 12</font>
<font style="font-family:Times New Roman;font-size:12">text times 12</font>
I think (but I may be wrong) I will have to specify some code for each size and each font. This is not a problem because there are only few sizes and fonts available in my xml.
Many many thanks for your help, I start loosing my hair trying to do it by myself…
You could do something like this:
XML Input (modified to be well-formed)
XSLT 1.0
Output
Also, you can change the
match="par"tomatch="par[@font or @size]"if you only want to output<font>if it has afontorsizeattribute.