1 users online. Create an account or sign in to join them.Users
how to concatenate string with two different delimiters with xsl?
This is an open discussion with 1 reply, filed under XSLT.
Search
Can you show us what you've tried so far? What are the results/errors you're seeing?
Create an account or sign in to comment.
I have a XML 100120014001102202234383163
I would like to use xsl to parse into another XML. The output would be
where the componentsids belonged to different groupid are separated by "|" . The component_sids belonged to the same group id should be concatenated with ",". I used the following xsl
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <xsl:element name="comp"> <xsl:attribute name="value"> <xsl:call-template name="join"> <xsl:with-param name="list" select="//DATA_RECORD[GROUP_ID=1]/COMPONENT_SID" /> <xsl:with-param name="separator" select="','" /> </xsl:call-template> </xsl:attribute> </xsl:element> </xsl:template> <xsl:template name="join"> <xsl:param name="list" /> <xsl:param name="separator"/> <xsl:for-each select="$list"> <xsl:value-of select="." /> <xsl:if test="position() != last()"> <xsl:value-of select="$separator" /> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet>The result is
. But I could not figure out how to separate other groups of component_sid with "|". Can someone help me?
Thanks in advance