[Home] [By Thread] [By Date] [Recent Entries]
On 08/06/2010 23:24, Lynn Murdock wrote:
hi- basically whenever doing string operations like thi son mixed content, the trick is to apply the operation to th etext nodes rather than al the content, so instead of <xsl:template match="title-group/article-title" mode="none"> have <xsl:template match="title-group/article-title/node()[last()][self::text()]" mode="none"> so you just apply this to the last node, if it's text. and you want to remove trailing white space if you are using xslt2 could use a regxep, but possibly if you also want to collapse space, the xslt1 way with normalise-space is easiest. <xsl:value-of select="substring(normalize-space(concat('x',.)),2)"/> </xsl:template> then one for the first node: <xsl:template match="title-group/article-title/node()[1][self::text()]" mode="none"> nt to collapse space, the xslt1 way with normalise-space is easiest. <xsl:variable name="x" select="normalize-space(concat(.,'x'))"/> <xsl:value-of select="substring($x,1,string-length($x)-1)"/> </xsl:template> and one for the simple case (which you need otherwise you will get an error about both the above matching the same node) <xsl:template match="title-group/article-title[not(*)]" mode="none"> <xsl:value-of select="normailze-space(.)"/> </xsl:template> David
|

Cart



