[Home] [By Thread] [By Date] [Recent Entries]
Mathieu Malaterre wrote:
On 9/27/07, Abel Braaksma <abel.online@xxxxxxxxx> wrote: Thanks for the shorter samples, that sure helps a lot. But I still prefer them in the mail, though (link vanish with time). I don't see how you applied my changes.. This is your stylesheet: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="@*">
<xsl:attribute name="{name()}" select="normalize-space(.)"/>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="normalize-space(.)"/>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="table">
<table>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="entry/para">
<entry ie="{.}"/>
</xsl:template>
</xsl:stylesheet>I suggested to use a variable, like so: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes" encoding="UTF-8"/> <!-- whitespace correction templates -->
<xsl:template match="@*" mode="correct-ws">
<xsl:attribute name="{name()}" select="normalize-space(.)"/>
</xsl:template><xsl:template match="text()" mode="correct-ws"> <xsl:value-of select="normalize-space(.)"/> </xsl:template> <xsl:template match="/" mode="correct-ws">
<xsl:variable name="output">
<xsl:apply-templates select="*"/>
</xsl:variable>
<xsl:apply-templates select="$output/*" mode="correct-ws" />
</xsl:template> <!-- normal templates -->
<xsl:template match="table">
<table>
<xsl:apply-templates/>
</table>
</xsl:template> <xsl:template match="entry/para">
<entry ie="{.}"/>
</xsl:template></xsl:stylesheet> That should do it. I didn't test it though ;) Cheers, -- Abel Braaksma
|

Cart



