Hi All,
I m stuck in between to some issue, please help me out....
Input xml:
<test>
<a>
<b name ='1'></b>
<b name ='2'></b>
<b name ='3'>
<c>aaa</c>
</b>
<b name ='4'>
<c>bbb</c>
<c>ccc</c>
</b>
<b name ='4'>
<c>dddd</c>
<c>eeee</c>
</b>
</a>
<a>
<b name ='1'></b>
<b name ='2'>
<c>fffff</c>
</b>
<b name ='3'></b>
<b name ='4'>
<c>gggg</c>
</b>
</a>
</test>
Xsl used:
<xsl:template match="/">
<html>
<body>
<table>
<tbody>
<tr>
<th>
<xsl:value-of
select="$CustomSelect"/>
</th>
<th>
</th>
</tr>
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:variable name="CustomSelect">
<xsl:text>position: </xsl:text>
<xsl:call-template name="test">
</xsl:call-template>
</xsl:variable>
<xsl:template name="test">
<xsl:call-template name="test2">
<xsl:with-param name="node" select="//b[c][not(@name
=preceding::b[child::c]/@name)]/@name"/>
</xsl:call-template>
<xsl:template name="test2" match="*" mode="test2">
<xsl:param name="node"/>
<xsl:for-each select="//b[c][not(@name
=preceding::b[child::c]/@name)]/@name">
<xsl:variable
name="InitialList">
<xsl:for-each
select="//c[1][ancestor::b/@name=$node]">
<xsl:text
disable-output-escaping="no">'</xsl:text>
<xsl:value-of
select="./text()"/>
<xsl:text
disable-output-escaping="no">', </xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:value-of
select="concat('[',substring($InitialList, 1,
string-length($InitialList)-2), ']')"/>
</xsl:for-each>
</xsl:template>
output i m getting:
<th>position: ['aaa', 'bbb', 'ccc', 'dddd', 'eeee', 'fffff',
'gggg']['aaa', 'bbb', 'ccc', 'dddd', 'eeee', 'fffff', 'gggg']['aaa',
'bbb', 'ccc', 'dddd', 'eeee', 'fffff', 'gggg']</th>
Desired output:
<th>position: ['aaa'],['bbb', 'ccc', 'dddd', 'eeee', 'gggg'], ['ffff']</th>
That is for b(@name='3'), there is only one 'c' in the complete xml,
so the first square bracket contains 'aaa'. Similarly, for
b[(_at_)name='4'], there are four c elements in the complete xml, i.e. bbb,
ccc; dddd, eeee and gggg, so it was listed in second sq brackets.
Please let me know is this possible........please help me out..........
Thanks....
--
Rashi Bhardwaj
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--