Subject: Elements to attributes From: Peter Sparkes <peter@xxxxxxxxxx> Date: Thu, 26 Oct 2000 20:24:32 +0100 |
Hi I want to transform a list of attributes (NMTOKENS) into element. I.e. from: <foo N="PU US UK"/> to: <foo><St>PU</St><St>US</St><St>UK</St></foo> The following: <xsl:template match="foo"> <foo <xsl:variable name="wlista" select="@N"/> <xsl:variable name="st"> <xsl:call-template name="lists"> <xsl:with-param name="wlist" select="$wlista"/> <xsl:with-param name="tag" select="'St'"/> </xsl:call-template> </xsl:variable> <xsl:value-of select="$st"/> </foo > </xsl:template> <xsl:template name="lists"> <xsl:param name="wlist"/> <xsl:param name="tag"/> <xsl:variable name="wlistb" select="concat(normalize-space($wlist),' ')"/> <xsl:choose> <xsl:when test="$wlistb!=' '"> <xsl:variable name="first" select="substring-before($wlistb,' ')"/> <xsl:variable name="rest" select="substring-after($wlistb,' ')"/> <xsl:call-template name="lists"> <xsl:with-param name="wlist" select="$rest"/> <xsl:with-param name="tag" select="$tag"/> </xsl:call-template> <xsl:value-of select="concat('<',$tag,'>',$first,'</',$tag,'>')"/> </xsl:when> </xsl:choose> </xsl:template> Converts it to: <foo><St>UK</St><St>US</St><St>PU</St></ foo> Please, 1. How can I replace < and < with < and > in the ouput. Peter Sparkes XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: html to xml, Sebastian Rahtz | Thread | Re: Elements to attributes, Alex Albu |
Re: Saxon and MSXML3 differences, Lee Goddard | Date | Re: Castor -> XSLT, Gary L Peskin |
Month |