Hi, I have an xml that looks something like this
<para>
text text text
<b>text</b> text text <i>text</i>
</para>
the objective is to convert this to mediaWiki formatting with ''' for a bold font and so on.
when I write a transformation for this the template match ignores all the text inside the <para>
tag and only the the <b>
s and the <i>
s are converted. i need help.
update: here is what i have tried so far:
this is what i have tried so far.
<xsl:template match="para">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="b">
<xsl:text>'''</xsl:text><xsl:value-of select="replace(replace(.,'\s+$',''),'^\s+','')" disable-output-escaping="no"/><xsl:text>'''</xsl:text>
</xsl:template>
<xsl:template match="i">
<xsl:text>''</xsl:text><xsl:value-of select="replace(replace(.,'\s+$',''),'^\s+','')" disable-output-escaping="no"/><xsl:text>''</xsl:text>
</xsl:template>
this is what I used when i tried the text() function.
<xsl:template match="text()">
<xsl:value-of select="." disable-output-escaping="no"/>
</xsl:template>
--update-- in order to not lose the spaces before and after the text block and the bold and italics flags we can also check for spaces before and after the text.
<xsl:template match="text()">
<xsl:variable name="originalText" select="."/>
<xsl:if test="starts-with($originalText,' ')">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:value-of select="normalize-space(.)" disable-output-escaping="no"/>
<xsl:if test="ends-with($originalText,' ')">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>