[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Converting CSV to XML without hardcoding schema d

Subject: RE: Converting CSV to XML without hardcoding schema details in xsl
From: "Pantvaidya, Vishwajit" <vpantvai@xxxxxxxxxxxxx>
Date: Wed, 21 Jun 2006 13:26:09 -0700
xml hard coding
You are correct, Wendell. I am using XSLT2.0.

Other than breaking up the strings, my issue is how to generate the output
xml with the element names generated at runtime from the field names in the
csv.

I was using xsl:element - but I was trying to achieve the above using
item-at and was not sure if I can use that function within the xsl:element
name AVT.

Thanks a lot,

Vish.
>-----Original Message-----
>From: Wendell Piez [mailto:wapiez@xxxxxxxxxxxxxxxx]
>Sent: Wednesday, June 21, 2006 1:02 PM
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>Subject: RE:  Converting CSV to XML without hardcoding schema details
>in xsl
>
>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(., ',')">
>>&lt;<xsl:value-of select="item-at($elementNames,index-of(?parent of
>current
>>node?,.))"/>&gt;
>><xsl:value-of select="."/>
>>&lt;/<xsl:value-of select="item-at($elementNames,index-of(?parent of
>current
>>node?,.))"/>&gt;
>></xsl:for-each>
>>
>>where elementNames is a tokenized list of the fieldnames - but I am unable
>>to get it to work.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.