|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: text nodes
Hi,
> Suggestions? Solutions?
Don't know if this approach is generic enough for your purposes, but seems to work
<xsl:template match="/">
<div>
<xsl:apply-templates />
</div>
</xsl:template>
<xsl:template match="b"/>
<xsl:template match="c">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="d">
<d>
<xsl:apply-templates/>
</d>
</xsl:template>
<xsl:template match="a">
<l>
<xsl:variable name="text" select="descendant::text()[1]"/>
<xsl:if test="not(string(number(substring($text, 1, 1))) = 'NaN')">
<xsl:attribute name="n">
<xsl:value-of select="substring-before(concat($text, ' '), ' ')"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates/>
</l>
</xsl:template>
<xsl:template match="a//text()" >
<xsl:choose>
<xsl:when test="not(preceding::text()[generate-id(ancestor::a[1]) = generate-id(current()/ancestor::a[1])])">
<xsl:choose>
<xsl:when test="string(number(substring(., 1, 1))) = 'NaN'">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring(., string-length(substring-before(concat(., ' '), ' ')) + 1)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Cheers,
Jarno - Massiv in Mensch: Kunstmutter
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








