Hi Vish,
I take it you're using XSLT 2.0 from the construct for-each
select="tokenize(.,',')"?
If not, let's not get on the wrong track.
Even if so, look up the instruction <xsl:element/>, since it'll allow
you to create elements named with values from your data -- better
than trying to write tags. Thus their names don't have to be hard-coded.
As for how to break your values out, that depends on whether you're
using XSLT 2.0, which has better facilities for this, or 1.0, which
requires you to break up the strings recursively (or use extension functions).
Answer the 1.0/2.0 question and someone can help further. (I think I
may be done for the day, sorry.)
Cheers,
Wendell
At 03:17 PM 6/21/2006, you wrote:
Can anybody suggest how to convert CSV data in the format
Field1,Field2
Value11,Value12
to xml like
<Field1>Value11</Field1>
<Field2>Value12</Field2>
without hardcoding the fieldnames in the xsl?
I was thinking of something like
<xsl:for-each select="tokenize(., ',')">
<<xsl:value-of select="item-at($elementNames,index-of(?parent of current
node?,.))"/>>
<xsl:value-of select="."/>
</<xsl:value-of select="item-at($elementNames,index-of(?parent of current
node?,.))"/>>
</xsl:for-each>
where elementNames is a tokenized list of the fieldnames - but I am unable
to get it to work.
--~------------------------------------------------------------------
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>
--~--