[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: concat string
Subject: RE: concat string From: "Jon Payne" <Jon.Payne@xxxxxxxxxx> Date: Thu, 30 Nov 2000 17:07:34 -0000 |
Hi YueMa, I'm an XSLT newbie myself, but I think these should work. Below are two slightly different ways of achieving the output: > <META http-equiv="Keywords" name="Keywords" content="key1, > key2, key3"> from your source: > .. > <keys>key1</keys> > <keys>key2</keys> > <keys>key3</keys> > .. 'method1' uses a template to match on 'keys' and uses xsl:attribute . 'method2' uses xsl:for-each and xsl:variable. Note: both methods match on ALL 'keys' which may not be what you want. Regards, Jon. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:call-template name="method1"/> <xsl:call-template name="method2"/> </xsl:template> <xsl:template name="method2"> <xsl:variable name="keys"> <xsl:for-each select="//keys"> <xsl:value-of select="."/> <xsl:call-template name="comma"/> </xsl:for-each> </xsl:variable> <META http-equiv="Keywords" name="Keywords" content="{$keys}"/> </xsl:template> <xsl:template name="method1"> <xsl:element name="META"> <xsl:attribute name="http-equiv">Keywords</xsl:attribute> <xsl:attribute name="name">Keywords</xsl:attribute> <xsl:attribute name="content"> <xsl:apply-templates mode="keys"/> </xsl:attribute> </xsl:element> </xsl:template> <xsl:template match="keys" mode="keys"> <xsl:value-of select="."/> <xsl:call-template name="comma"/> </xsl:template> <xsl:template name="comma"> <xsl:if test="name(following-sibling::node()) = name(self::node())"> <xsl:text>, </xsl:text> </xsl:if> </xsl:template> </xsl:stylesheet> > > How can I do that ? > > Thanks! > > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
<- Previous | Index | Next -> |
---|---|---|
concat string, YueMa | Thread | Re: concat string, Ian Davis |
sum() of nodeset, Shimon Pozin | Date | RE: switching from xalan (J) to sax, Kay Michael |
Month |
Keywords