How to parse this list of users using XSLT 1
Hi. I'm using XSLT 1.
I'm giving the following input:
<Addressees>BILLY, GROUPA (EXCLUDE BOB, JANE), JANE DOE, SMITH FAMILY (EXCLUDE TIMMY), HEIDI,</Addressees>
I need to parse that input into these fields:
<User>BILLY</User>
<User Exclude='(EXCLUDE BOB, JANE)'>GROUPA</User>
<User>JANE DOE</User>
<User Exclude='(EXCLUDE TIMMY)'>SMITH FAMILY</User>
<User>HEIDI</User>
My XSLT code so far:
<xsl:template name='parse'>
<xsl:param name='str'/>
<xsl:variable name='user' select='substring-before($str, ',')/>
<User>
<xsl:value-of select="$user"/>
</User>
<!-- Recursively call to process the remaining users -->
<xsl:call-template name='parse'>
<xsl:with-param name='str' select='normalize-space(substring-after($str, ','))/>
</xsl:call-template>
</xsl:template>
My output so far (which is wrong):
<User>BILLY</User>
<User>GROUPA (EXCLUDE BOB</User>
<User>JANE)</User>
<User>JANE DOE</User>
<User>SMITH FAMILY (EXCLUDE TIMMY)</User>
<User>HEIDI</User>
Please help. Appreciate any help.
|