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

Re: csv data to xml

Subject: Re: csv data to xml
From: henry human <henry_human@xxxxxxxx>
Date: Thu, 27 Jun 2013 16:28:51 +0100 (BST)
Re:  csv data to xml
Hi guys 
I was able to convert the data from csv to xml. Now I want to build
groups of the elements such as the sample bellow.
Each 5 elements should be
assigned to a clfPackage element: 
  
This is the CSV as xml:
<?xml
version="1.0" encoding="UTF-8"?>
<xmlData>
 <element>EN</element>
 <element>01</element>
 <element>text</element>
 <element>U</element>
 <element>2013028074426</element>
 
 <element>SE</element>
 <element>06</element>
 <element>text</element>
 <element>M</element>
 <element>2013011234457</element>
 
 .......
 
</xmlData>  
  
This is what
must be created:
 <clfPackage>  
  <Country><xsl:value-of
select="xmlData/element"/></CountryCode>           //must be the first element
  <number><xsl:value-of select="xmlData/element"/></ClearingNumber>        
//must be the secound element
  <Description1><xsl:value-of
select="xmlData/element"/></Description>
  <ChangeMode><xsl:value-of
select="xmlData/element"/></ChangeMode>
  <Modification><xsl:value-of
select="xmlData/element"/></Modification>
 </clfPackage>

Best regards
Henry
----- Urspr|ngliche Message -----
Von: Michael Kay <mike@xxxxxxxxxxxx>
An:
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
CC: 
Gesendet: 16:47 Mittwoch, 26.Juni 2013
Betreff: Re:  csv data to xml


On 26 Jun 2013, at 15:21, henry human
wrote:

> Hi I was not able to run get this xslt sample runing! When I try it
with Saxon 9.1.0  and (call it in Stylus Studio) I got the known
>
error:ontent is not allowed in prolog.

That means you're doing it wrong;
you're somehow putting the CSV file through an XML parser. Probably because
you are supplying it as the main input to the transformation, rather than
merely a secondary file to be read with unparsed-text().

Michael Kay
Saxonica
> ?
> This was my csv file test.csv
> USA,AA,Comp. 1,U,012345,L987
>
USA,BB,Comp.2,Z,034567888888,F098
> USA,CC,Comp 3,M,034847474747,F098
> 
> 
>
----- Urspr|ngliche Message -----
> Von: Andrew Welch
<andrew.j.welch@xxxxxxxxx>
> An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> CC: 
>
Gesendet: 15:15 Dienstag, 25.Juni 2013
> Betreff: Re:  csv data to xml
>
>> Use unparsed-text() to read the csv, then use tokenize() to split it
>>
into lines, iterate over each line outputting a <Segment>, then
>> tokenize()
the $line into $tokens, and use fill-in-the-blanks style to
>> populate the
elements.
> 
> Basically this:
> 
>
http://andrewjwelch.com/code/xslt/csv/csv-to-xml_v2.html
> 
> 
> -- 
> Andrew
Welch
> http://andrewjwelch.com/
> 
>
--~------------------------------------------------------------------
>
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@xxxxxxxxxxxxxxxxxxxxxx>
> --~--
> 
>
--~------------------------------------------------------------------
>
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@xxxxxxxxxxxxxxxxxxxxxx>
> --~--

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.