I feel I am so close to getting this worked out but am still having a few problems. I didn’t realise how hard it would be to convert text into bold and italics through XSL. At the moment I feel my code is almost there but there’s just something that’s stopping it from working correctly. This is my current code:
<xsl:template match="para/text() | para//b/text() | para//em/text()">
<span>
<xsl:attribute name="font-weight">
<xsl:choose>
<xsl:when test="//em">italic</xsl:when>
<xsl:when test="//b">bold</xsl:when>
<xsl:when test="/">normal</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="."/>
</span>
</xsl:template>
It seems to me that it would logically work but the problem at the moment is that it puts everything in <span font-weight=“italic”> tags. For example, this is my xml:
<para>The only significant remaining piece of the 6-metre thick wall that in
colonial times surrounded the <b>Old Town</b>, and protected the city against its many invaders, is the ornamental gate at the entrance of the Old Town (Ciudad Vieja in Spanish). The district – a finger of land jutting out into the River Plate – is a curious and fascinating mixture of financial centre, working port, restaurant hub and low-rent housing laid out on a precise grid
plan.</para>
<para>The pedestrianised calle Sarandí leads from the ornamental gate to the
<em>Plaza Matriz</em>, the heart of the Old Town. Don’t miss the wonderful
art deco Ferrando building, constructed in 1917, as you walk down the first
block of Sarandí. The ground floor is given over to a bookshop; take a look at
the beautiful stained glass above the stairway at the back of the store (there
is a café upstairs). </para>
And this is the outputted html:
<span font-weight="italic">The only significant remaining piece of the 6-metre thick wall that in colonial times surrounded the </span><span font-weight="italic">Old Town</span><span font-weight="italic">, and protected the city against its many invaders, is the ornamental gate at the entrance of the Old Town (Ciudad Vieja in Spanish). The district – a finger of land jutting out into the River Plate – is a curious and fascinating mixture of financial centre, working port, restaurant hub and low-rent housing laid out on a precise grid plan.</span><span font-weight="italic">The pedestrianised calle Sarandí leads from the ornamental gate to the </span><span font-weight="italic">Plaza Matriz</span><span font-weight="italic">, the heart of the Old Town. Don’t miss the wonderful art deco Ferrando building, constructed in 1917, as you walk down the first block of Sarandí. The ground floor is given over to a bookshop; take a look at the beautiful stained glass above the stairway at the back of the store (there is a café upstairs).
If I were to change the order of the font-weight’s so that bold was above italic in the XSL sheet then all the font-weight’s become bold in my HTML. Why is this? What am I doing wrong???
Thanks for any help on this at all!
Russ