XML to CSV
Hi,
My main problem statement is to convert and XML file into a CSV file.
That I can do if someone can help me how to read a file in adobe flex line by line?
I would have then read the XML file line by line and pulled up the values between the tags.
Somehow I couldnt find a method to do so. Most of the file methods are bytes based which dont suit me.
Thanks.
http://www.adobe.com/livedocs/flex/3/html/help.html?content=Filesystem_16.html
Also check this out:
http://www.adobe.com/devnet/flex/quickstart/httpservice/
Similar Messages
-
Conversion from xml to csv using xsl
hi i am converting from xml to csv using xsl i am getting the extra junk character(space) in the csv file.below i written the xml file and xsl file
xml file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl"?>
<DOCUMENTS>
<FILE>
<DOCUMENT>
<BUSINESS>finance</BUSINESS>
<PROGRAM>CM</PROGRAM>
<PROJECT>Testing Area</PROJECT>
<NAME>121940~1.doc</NAME>
<TEXT>SQL</TEXT>
<LINK>http://www.sql.org/</LINK>
</DOCUMENT>
<DOCUMENT>
<BUSINESS>finance</BUSINESS>
<PROGRAM>CM</PROGRAM>
<PROJECT>Testing Area</PROJECT>
<NAME>121940~1.doc</NAME>
<TEXT>Information</TEXT>
<LINK>http://google.com/</LINK>
</DOCUMENT>
<DOCUMENT>
<BUSINESS>finance</BUSINESS>
<PROGRAM>CM</PROGRAM>
<PROJECT>Testing Area</PROJECT>
<NAME>121940~1.doc</NAME>
<TEXT>Configuration</TEXT>
<LINK>http://msdn.microsoft.com/</LINK>
</DOCUMENT>
</FILE>
</DOCUMENTS>
xsl file
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" indent="yes"/>
<xsl:template match="DOCUMENTS">
<xsl:text>Business,Program,Project,DocumentName,Textforlink,Hyperlink</xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="FILE">
<xsl:value-of select="DOCUMENT/BUSINESS"/>
<xsl:value-of select="','"/>
<xsl:value-of select="DOCUMENT/PROGRAM"/>
<xsl:value-of select="','"/>
<xsl:value-of select="DOCUMENT/PROJECT"/>
<xsl:value-of select="','"/>
<xsl:value-of select="DOCUMENT/NAME"/>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="DOCUMENT">
<xsl:value-of select="','"/>
<xsl:value-of select="','"/>
<xsl:value-of select="','"/>
<xsl:value-of select="','"/>
<xsl:value-of select="TEXT"/>
<xsl:value-of select="','"/>
<xsl:value-of select="LINK"/>
</xsl:template>
</xsl:stylesheet>
for converting to csv i am using java program.
please go through it.<xsl:value-of select="','"/>That's not the correct way to output a literal comma. Just write the comma directly, or use xsl:text. And don't put in those line breaks either. You can reduce the rule for FILE to something like this:
xsl:template match="FILE">
<xsl:value-of select="DOCUMENT/BUSINESS"/>, <xsl:value-of select="DOCUMENT/PROGRAM"/>, <xsl:value-of select="DOCUMENT/PROJECT"/>, <xsl:value-of select="DOCUMENT/NAME"/>
<xsl:apply-templates/>
</xsl:template> -
Hi,
I am facing some problem in FCC for Receiver adapter. It has to convert from XML to CSV File.
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:PaymentFull_Target xmlns:ns0="http://sdn.com/Payment">
- <RECORDSET>
- <Header>
<LineItem>1</LineItem>
<SaleNumber>102</SaleNumber>
<TransNumber>105</TransNumber>
<Store>1326</Store>
<variant>Z6</variant>
<TransType>NEW</TransType>
<Adjustm_Type />
</Header>
- <Header>
<LineItem>2</LineItem>
<SaleNumber>102</SaleNumber>
<TransNumber>105</TransNumber>
<Store>1326</Store>
<variant>Z6</variant>
<TransType>NEW</TransType>
<Adjustm_Type />
</Header>
- <Header>
<LineItem>3</LineItem>
<SaleNumber>102</SaleNumber>
<TransNumber>105</TransNumber>
<Store>1326</Store>
<variant>Z6</variant>
<TransType>NEW</TransType>
<Adjustm_Type />
</Header>
</RECORDSET>
</ns0:PaymentFull_Target>
Output File is coming only with lineitem values , remaining fields are not coming.
*1,2,3*
FCC Used...
RecordSet Structure -- Header
Header.fieldNames -
LineItem,SaleNumber,TransNumber,Store,variant,TransType,Adjustm_Type
Header.fieldSeparator----- ,
Header.endSeparator----- 'nl'
Did I miss anything.. any idea whats going wrong?
Thanks
DeepthiHi Deepthi,
Mention the occurrence of header in Recordset
You specify like this:
Recordset: Header, *
Header.fieldSeparator : u2018Field Separatoru2019
-->For FCC on Receiver side you donu2019t have to mention the field names.
-->The u2018endSeparatoru2019 parameter needs to given for substructure only
Check this links:
http://help.sap.com/saphelp_nw04/helpdata/en/d2/bab440c97f3716e10000000a155106/content.htm
/people/shabarish.vijayakumar/blog/2007/08/03/file-adapter-receiver--are-we-really-sure-about-the-concepts
/people/arpit.seth/blog/2005/06/02/file-receiver-with-content-conversion
Rgds,
Akhila -
Hi,
I would like to know as to how can I add links to open xml and csv files stored in another location? Please advice how to place links in my frame maker document?
Kindly advice.
Thanks
PriyaSpecial > Hypertext > Command "open document" will do its best to open the target document inside FrameMaker, which may not be much help; Special > Hypertext > Command "message …" will use the application you specify. The user guide for 7.0 says this about absolute links, and I don't think anything has changed since:
For example, to start PaintBrush and open the Ship.pcx file on drive C you would use the command message system pbrush.exe C:/Ship.pcx
I've not often used a relative link, and not recently: the same source says
folder levels are separated by a slash / even in Windows and Mac
[relative links] FrameMaker searches for a relative pathname beginning in the folder that contains the current document
[absolute links] FrameMaker searches for an absolute pathname beginning at the top of the file system. In Windows, the absolute pathname begins with the drive specifier, a colon and a slash. -
Generating XMLs from CSVs using DOM parser......
Hi,
I am trying to generate XMLs from CSV files using DOM parser. XMLs are getting generated but the problem is that i am using Encoding "ISO-8859-1" but XMLs are getting generated in UTF-8 encoding.
Please refer to the code below and advice. (where are the code tags gone ????? )
Source domSource = new DOMSource(document);
ByteArrayOutputStream xmlStream = new ByteArrayOutputStream();
Result result = new StreamResult(xmlStream);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(domSource, result);
xmlStream.close();
generatedXml = new String(xmlStream.toByteArray(), "*ISO-8859-1*");Use transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1") to specify the character set.
-
How to convert org hierarchy XML to CSV/Excel format using PI/XI
Hi All,
I am working with SAP PI/XI for the first time and need some help file conversion of complex hierarchy XML to CSV file using PI. I have done plenty of research on SDN and could find much related to what I want to do.
Here is the example of how my input XML would look like:
<?xml version="1.0" encoding="UTF-8"?>
<PartyMaster type="OrgHierarchy" name="Compass Group Owned">
<PartyMasterHierarchy>
<Hierarchy level="3" nodeName="Bon Appetit Sector" type="Sector" ID="A00000" refID="A00000">
<Hierarchy level="4" nodeName="BA Division" type="Division" ID="AB0000" refID="AB0000" >
<Hierarchy level="5" nodeName="BA East Coast Region" type="Region" ID="ABE000" refID="ABE000">
<Hierarchy level="6" nodeName="Engstrom, John RVP" type="District" ID="ABE01" refID="ABE01" >
</Hierarchy>
</Hierarchy>
</Hierarchy>
</Hierarchy>
<Hierarchy level="3" nodeName="Levy Sector" type="Sector" ID="K00000" refID="K00000".
<Hierarchy level="4" nodeName="Levy Sector Division" type="Division" ID="K90000" refID="K90000">
<Hierarchy level="5" nodeName="Levy Sector Region" type="Region" ID="K99000" refID="K99000">
<Hierarchy level="6" nodeName="TBA Total" type="District" ID="K9901" refID="K9901"> </Hierarchy>
</Hierarchy>
</Hierarchy>
</Hierarchy>
</PartyMasterHierarchy>
</PartyMaster>
I would like to get CSV output in the format below
DISPLAY_NAME, DOCUMENT_DESCRIPTION, PARENT, EXTERNAL_ID, ORG_UNIT_TYPE
Bon Appetit Sector, Bon Appetit Sector,constant value, A00000, constant value
Levy Sector, Levy Sector, constant value, K00000, constant value
BA Division, BA Division, A00000, AB0000, constant value
Levy Sector Division, Levy Sector Division, K00000, K90000, constant value
BA East Coast Region, BA East Coast Region, AB0000, ABE000, constant value
Levy Sector Region, Levy Sector Region, K90000, K99000, constant value
Engstrom John RVP, Engstrom John RVP, ABE000, ABE01, constant value
TBA Total ,TBA Total ,K99000, K9901, constant value
1) How do I go about this? I think I have to configure an adapter but which adapter would give me the desired result?
2) How do I tell PI when to pick the file from and where to place it after conversion? Could this be done in adapter configuration?
Any help will be greatly appreciated.
Thanks.
--Mithun>>> 1) How do I go about this? I think I have to configure an adapter but which adapter would give me the desired result?
Use File adapter at the sender side to pick up the xml and use file adapter at the receiver side (message protocol file content conversion) to convert xml format to csv.
Basically you have to configure in the file adapter (FCC) on the receiver side to get desired csv structure from XML.
>>> 2) How do I tell PI when to pick the file from and where to place it after conversion? Could this be done in adapter configuration?
Configure sender file adapter to pick up the file from the specified directory. Configure receiver file (fcc adapter) to drop the csv file after conversion.
For sender adapter
http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm
For receiver adapter in our case FCC (FILE content Conversion) follow the link
http://help.sap.com/saphelp_NW04/helpdata/en/d2/bab440c97f3716e10000000a155106/content.htm
Hope answered your question.
Mapping area: simple suggestion. Keep input and output message same structure and do one to one mapping. In the receiver fcc adapter configure for csv structure following instruction given in the above second link
Note: FCC adapter does not support nested structure more than 2. So in your case you can achieve using conversion agent tool. Otherwise you might have to achieve through some graphical mapping. -
How to convert hierarchy XML to CSV/Excel format using PI/XI
posted in PI forum but not many replies, please bear with me as I am in crunch time*
Hi All,
I am working with SAP PI/XI for the first time and need some help file conversion of complex hierarchy XML to CSV file using PI. I have done plenty of research on SDN and could find much related to what I want to do.
Here is the example of how my input XML would look like:
<?xml version="1.0" encoding="UTF-8"?>
<PartyMaster type="OrgHierarchy" name="Compass Group Owned">
<PartyMasterHierarchy>
<Hierarchy level="3" nodeName="Bon Appetit Sector" type="Sector" ID="A00000" refID="A00000">
<Hierarchy level="4" nodeName="BA Division" type="Division" ID="AB0000" refID="AB0000" >
<Hierarchy level="5" nodeName="BA East Coast Region" type="Region" ID="ABE000" refID="ABE000">
<Hierarchy level="6" nodeName="Engstrom, John RVP" type="District" ID="ABE01" refID="ABE01" >
</Hierarchy>
</Hierarchy>
</Hierarchy>
</Hierarchy>
<Hierarchy level="3" nodeName="Levy Sector" type="Sector" ID="K00000" refID="K00000".
<Hierarchy level="4" nodeName="Levy Sector Division" type="Division" ID="K90000" refID="K90000">
<Hierarchy level="5" nodeName="Levy Sector Region" type="Region" ID="K99000" refID="K99000">
<Hierarchy level="6" nodeName="TBA Total" type="District" ID="K9901" refID="K9901"> </Hierarchy>
</Hierarchy>
</Hierarchy>
</Hierarchy>
</PartyMasterHierarchy>
</PartyMaster>
I would like to get CSV output in the format below
DISPLAY_NAME, DOCUMENT_DESCRIPTION, PARENT, EXTERNAL_ID, ORG_UNIT_TYPE
Bon Appetit Sector, Bon Appetit Sector,constant value, A00000, constant value
Levy Sector, Levy Sector, constant value, K00000, constant value
BA Division, BA Division, A00000, AB0000, constant value
Levy Sector Division, Levy Sector Division, K00000, K90000, constant value
BA East Coast Region, BA East Coast Region, AB0000, ABE000, constant value
Levy Sector Region, Levy Sector Region, K90000, K99000, constant value
Engstrom John RVP, Engstrom John RVP, ABE000, ABE01, constant value
TBA Total ,TBA Total ,K99000, K9901, constant value
1) How do I go about this? I think I have to configure an adapter but which adapter would give me the desired result?
2) How do I tell PI when to pick the file from and where to place it after conversion? Could this be done in adapter configuration?
Any help will be greatly appreciated.
Thanks.
--MithunHi Mithun,
You might try this step below :
1. As for xsd schema fo the xml or create xsd schema base on the sample xml file using tools like xmlspy or others free tools.
2. import you xsd schema as outbound Data type
3. apply mapping from source to target (csv).
Configuration
Sender file adapter (without content conversion)
Receiver file adapter (with content conversion).
so the sender adapter will be monitoring inbound directory and write the result to another directory.
Thank You and Best Regards
Fernand. -
Hi
I have a pdf which contains a table, I click a submit button and the data is posted to a url. The response is a csv file from the xml. Is there anyway in which reader 9 will be able to open the resulting csv in a native application without reader being opened in the broswer. This functionality did exist in reader 8, but is now gone in reader 9.
Is there anyway I can achive this?
Thanks in advance.
DylanWhen the httpservices completes isn't the result bound to an arrayCollection (or array) so you could essesntially accomplish anything you want, sort search etc..
Is the XML result directly bound to a datagrid or is it bound to arrayCollection first and then bind the arrayCollection to the data grid?
From the network layer comparison, say you have 100 rows with 10 columns, the file size of XML vs CSV makes a big difference. Do you think this warrants bringing the file as CSV instead of XML? You also have to consider the server side doing the extra formating. You will notice a big difference in an enterprise database if its doing extra work and file I/O.
Being so used to ODBC-RAW data, I'm finding some apps are slow because of the XML format and I'm looking for an alternative similar to the ODBC-RAW data format. I do agree that you can do more with XML but if it's just use for say in drop down list, data grid and not so much for formatting, I think CSV will do just fine. I would however, bring in a single row as XML.
Thanks for replying back so quickly.
-nobody- -
How to convert hierarchy XML to CSV format using PI/XI
Hi All,
I am working with SAP PI/XI for the first time and need some help file conversion of complex hierarchy XML to CSV file using PI. I have done plenty of research on SDN and could find much related to what I want to do.
Here is the example of how my input XML would look like:
<?xml version="1.0" encoding="UTF-8"?>
<PartyMaster type="OrgHierarchy" name="Compass Group Owned">
<PartyMasterHierarchy>
<Hierarchy level="3" nodeName="Bon Appetit Sector" type="Sector" ID="A00000" refID="A00000">
<Hierarchy level="4" nodeName="BA Division" type="Division" ID="AB0000" refID="AB0000" > <Hierarchy level="5" nodeName="BA East Coast Region" type="Region" ID="ABE000" refID="ABE000">
<Hierarchy level="6" nodeName="Engstrom, John RVP" type="District" ID="ABE01" refID="ABE01" >
</Hierarchy>
</Hierarchy>
</Hierarchy>
</Hierarchy>
<Hierarchy level="3" nodeName="Levy Sector" type="Sector" ID="K00000" refID="K00000". <Hierarchy level="4" nodeName="Levy Sector Division" type="Division" ID="K90000" refID="K90000"> <Hierarchy level="5" nodeName="Levy Sector Region" type="Region" ID="K99000" refID="K99000"> <Hierarchy level="6" nodeName="TBA Total" type="District" ID="K9901" refID="K9901"> </Hierarchy>
</Hierarchy>
</Hierarchy>
</Hierarchy>
</PartyMasterHierarchy>
</PartyMaster>
I would like to get CSV output in the format below
*DISPLAY_NAME DOCUMENT_DESCRIPTION PARENT EXTERNAL_ID ORG_UNIT_TYPE*
Bon Appetit Sector Bon Appetit Sector constant value A00000 constant value
Levy Sector Levy Sector constant value K00000 constant value
BA Division BA Division A00000 AB0000 constant value
Levy Sector Division Levy Sector Division K00000 K90000 constant value
BA East Coast Region BA East Coast Region AB0000 ABE000 constant value
Levy Sector Region Levy Sector Region K90000 K99000 constant value
Engstrom, John RVP Engstrom, John RVP ABE000 ABE01 constant value
TBA Total TBA Total K99000 K9901 constant value
1) How do I go about this? I think I have to configure an adapter but which adapter would give me the desired result?
2) How do I tell PI when to pick the file from and where to place it after conversion? Could this be done in adapter configuration?
Any help will be greatly appreciated.
Thanks.
--MithunMithun,
you would get lot of answers if you looking in the PI (process integration forum)... There is something calles File content coversion in XI file adapter (which can convert the xml to csv and viceversa) -
How to ignore prefix from XML while converting XML to csv using XSLT
Hi All,
I am trying to convert XML to csv file.
the XML i have is like....
<?xml version="1.0"?>
<bulkCmConfigDataFile xmlns:es="SpecificAttributes.3.0.xsd" xmlns:un="utranNrm.xsd" xmlns:xn="genericNrm.xsd" xmlns:gn="geranNrm.xsd" xmlns="configData.xsd">
<configData dnPrefix="Undefined">
<xn:SubNetwork id="AU_R">
<xn:SubNetwork id="H5RG_0501">
<xn:MeContext id="Firle_5070020">
<xn:ManagedElement id="1">
<un:RncFunction id="1">
<un:UtranCell id="50390303">
<un:attributes>
<un:userLabel>UtranCell 50390303</un:userLabel>
<un:cId>52383</un:cId>
<un:localCellId>50390303</un:localCellId>
<un:uarfcnUl>9613</un:uarfcnUl>
<un:uarfcnDl>10563</un:uarfcnDl>
<un:primaryScramblingCode>502</un:primaryScramblingCode>
<un:primaryCpichPower>287</un:primaryCpichPower>
<un:maximumTransmissionPower>403</un:maximumTransmissionPower>
<un:primarySchPower>-18</un:primarySchPower>
<un:secondarySchPower>-20</un:secondarySchPower>
<un:bchPower>-20</un:bchPower>
<un:lac>50301</un:lac>
<un:rac>1</un:rac>
<un:sac>52383</un:sac>
<un:utranCellIubLink>SubNetwork=AU_R,SubNetwork=H5RG_0501,MeContext=H5RG_0501,ManagedElement=1,RncFunction=1,IubLink=5039030</un:utranCellIubLink>
</un:attributes>
</un:UtranCell>
</un:RncFunction>
</xn:ManagedElement>
</xn:MeContext>
</xn:SubNetwork>
</xn:SubNetwork>
</configData>
</bulkCmConfigDataFile>now when i am using XSLT functionality to convert this XML into a csv i want ignore all the prefix from this xml like "un" , "xn" etc....
can anybody has idea how i can ignore all this value using XSLTI just dont understand why factory.setIgnoringElementContentWhitespace(true) did not work.That only does something if the XML has a DTD that enables it to know what whitespace can be ignored and what is significant. The API documentation for the method refers you to this document:
http://www.w3.org/TR/REC-xml#sec-white-space -
Problem in file content conversion from XML to CSV
Hi Experts,
I am finding problem in file content conversion. I need to convert the following XML file into CSV file:
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:MT_CROSS_REF xmlns:ns0="urn:dabur:idoc2file:pos">
<Update_type>2</Update_type>
<PLU>00000000</PLU>
<Cross_ref_PLU>7777777</Cross_ref_PLU>
<Capture_PLU />
<Package_size />
<Package_desc />
</ns0:MT_CROSS_REF>
The output file data has to be like:
2,00000000,7777777,,,,
The problem I am facing is while specifying the content conversion parameters in communication channel i dont know what recordset structure i should mention as all the records are directly under root. If I mention recordset structure as "ns0:MT_CROSS_REF" and parameters as
ns0:MT_CROSS_REF.fieldSeparator ,
ns0:MT_CROSS_REF.endSeparator 'nl'
i get error in communication channel monitoring and no file is posted.
Please help me as to what correct parameter i should mention in my case.
Thanks,
Regards,
YashHi Chirag,
I cannot change the xml file as it comes after mapping idoc to a message type. How can I add ROOT in the xml? My message type is like MT_CROSS_REF and it has those 6 fields as in the XML (Update_type, PLU etc.). I do the mapping of these fields from a IDOC and get the XML.
I hope you got my point.
Thanks,
Yash -
Problem while populating XML using CSV data
Hi,
We are trying to populate a XML file of nested structure from a CSV file. The performance is found to be degrading much.
While debugging, we found that the issue is because BODS is generating certain nodes in the XML multiple times. This has increased the number of rows that are processed by many fold. This in turn is hitting the performance.
The structure of our target XSD schema is something like this
CreateUpdateNode
|
|
Production
|
|
Asset
|
|
Budget
CreateUpdateNode is the outer root element which is nested with inner elements as shown. Each of these nodes has their own child elements like
production name,Asset name,Budget name e.t.c
The source is a CSV file containing multiple rows. While executing the job, the ideal case should be:
one CreateUpdateNode block for each input row. But here the nodes are generated multiple times in target XML.
We tried the below approach:
Generate a column for row number in the source, and during mapping, put a WHERE clause for each node such as WHERE row number=1.
Then the nodes are generated as we expect, but in this approach we will get only the data in first row (as row number=1).
Please suggest a suitable solution
Thanks ,
Prateek
Edited by: Prateek_Naidu on Mar 9, 2012 6:20 AM
Edited by: Prateek_Naidu on Mar 9, 2012 6:31 AMDear Mr. Prateek
have you already solved this problem?
i got same problem with you.
i have xml schema with alot of nested attribute.
BODS generating my attribute data multiple times as much as data row.
can you give me advice to solved this problem? -
XML to CSV routine using XSLT. Oracle bugs?
I'm trying to write some XSLT so that I can apply it to any given XML using XMLTransform to generate a flattened CSV structure. My input can be any XML document, with any number of nested levels so the structure isn't known to the XSLT. I'm fairly new to XSLT but am having problem with Oracle's version of it. I've tested on both 10gR2 and 11gR2.
CSV Rules :
Adjacent fields must be separated by a comma
Embedded commas in fields are escaped e.g. 15, Maple Street => "15, Maple Street"
Embedded quotes in fields are escaped. e.g. O'Brien => "O'Brien" or John "Jonner" McNabb => "John ""Jonner"" McNabb"
Embedded CR / LF or CRLF in fields are escaped with quotes.
Records are separated with CRLF pairs
Flattening Rules :
The text of leaf elements (elements without children) are output even if they are empty
Any element with text is output
A new line occurs whenever the nesting level changes. i.e. If an element has children.
When I run the following XML and my XSLT through Oracle I get results inconsistent with results I get when I run the XML and XSLT through online XSLT utils (including W3C's test pages).
with qryXML as (
select xmltype(q'[
<email>
<to>Steve O'Brien</to>
<cc/>
<from>Jane "The Smiler" Griff</from>
<heading>Reminder</heading>
<body>Hey, don't forget me this weekend! I've enclosed some pics from last weekend
Love Jane
</body>
<attachments>
<attachment>
<filename>Dance.jpg</filename>
<encoding>MIME</encoding>
</attachment>
<attachment>
<filename>Signature.txt</filename>
<encoding/>
</attachment>
</attachments>
</email>
]') as XMLDATA from dual)
select
XMLTransform(q.XMLDATA,
xmltype(q'[
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:strip-space elements="*"/>
<xsl:template match="*[text() or not(*)]">
<xsl:if test="position() > 1">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:call-template name="display_csv_field">
<xsl:with-param name="field" select="."/>
</xsl:call-template>
<xsl:if test="not(following-sibling::*[text() or not(*)])">
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="display_csv_field">
<xsl:param name="field"/>
<xsl:variable name="CRLF">
<xsl:text> </xsl:text>
</xsl:variable>
<xsl:variable name="CR">
<xsl:text> </xsl:text>
</xsl:variable>
<xsl:variable name="LF">
<xsl:text> </xsl:text>
</xsl:variable>
<xsl:variable name="apos">'</xsl:variable>
<xsl:choose>
<xsl:when test="contains( $field, '"' )">
<!-- Field contains a quote. So escape -->
<xsl:text>"</xsl:text>
<xsl:call-template name="escape_quotes">
<xsl:with-param name="string" select="$field" />
</xsl:call-template>
<xsl:text>"</xsl:text>
</xsl:when>
<xsl:when test="contains( $field, ',' ) or
contains( $field, $apos ) or
contains( $field, $CRLF ) or
contains( $field, $CR ) or
contains( $field, $LF )" >
<!-- Field contains a comma, apostrophe and/or a linefeed, so quote -->
<xsl:text>"</xsl:text>
<xsl:value-of select="$field" />
<xsl:text>"</xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- No need to enclose this field in quotes. -->
<xsl:value-of select="$field" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="escape_quotes">
<xsl:param name="string" />
<xsl:value-of select="substring-before( $string, '"' )" />
<xsl:text>""</xsl:text>
<xsl:variable name="substring_after_first_quote"
select="substring-after( $string, '"' )" />
<xsl:choose>
<xsl:when test="not( contains( $substring_after_first_quote, '"' ) )">
<xsl:value-of select="$substring_after_first_quote" />
</xsl:when>
<xsl:otherwise>
<!-- The substring after the first quote contains a quote.
So, we call ourself recursively to escape the quotes
in the substring after the first quote. -->
<xsl:call-template name="escape_quotes">
<xsl:with-param name="string" select="$substring_after_first_quote" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
)) from qryXML q
Output from Oracle (which appears incorrect)
"Steve O'Brien""Jane ""The Smiler"" Griff"Reminder"Hey, don't forget me this weekend! I've enclosed some pics from last weekend
Love Jane
"
Dance.jpgMIME
Signature.txt
Output from most other XSLT test environments (which appears correct):
"Steve O'Brien",,"Jane ""The Smiler"" Griff",Reminder,"Hey, don't forget me this weekend! I've enclosed some pics from last weekend
Love Jane
Dance.jpg,MIME
Signature.txt,
Oracle's XSLT handling appears incorrect in several ways:
1. There is no comma delimiter separating fields and on investigation, position() is always returning 1, which is incorrect. From XSLT reference "The position function returns a number equal to the context position from the expression evaluation context." ...."the position, or index number, of the node, relative to all the selected nodes in the node list." Therefore any node in a node list should be indexable with position. I am selecting a node list *[text() or not(*)] => Any nodes with text or with no children, yet position of each node in this list is always 1.
2. My XSLT says the output is text, yet Oracle is still using HTML character escaping which is not text! " instead of " and ' instead of '. I could search and replace, but I shouldn't have to.
Can anyone explain why Oracle's XSLT differs from other XSLT processors and offer suggestions to solve these issues. Are these bugs?Here's an example tested on 11.2.0.2 :
SQL> set scan off
SQL> set long 5000
SQL> set lines 200
SQL> var doc clob
SQL> begin
2 :doc := '<email>
3 <to>Steve O''Brien</to>
4 <cc/>
5 <from>Jane "The Smiler" Griff</from>
6 <heading>Reminder</heading>
7 <body>Hey, don''t forget me this weekend! I''ve enclosed some pics from last weekend
8 Love Jane
9 </body>
10 <attachments>
11 <attachment>
12 <filename>Dance.jpg</filename>
13 <encoding>MIME</encoding>
14 </attachment>
15 <attachment>
16 <filename>Signature.txt</filename>
17 <encoding/>
18 </attachment>
19 </attachments>
20 </email>';
21 end;
22 /
PL/SQL procedure successfully completed.
SQL> select xmlcast(
2 xmlquery(
3 'declare function local:formatField ($e as element()) as xs:string
4 {
5 let $t := ora:replace($e, """, """")
6 return if ( contains($t, """)
7 or contains($t, ",")
8 or contains($t, "'")
9 or contains($t, " ")
10 or contains($t, " ") )
11 then concat(""", $t, """)
12 else $e
13 }; (::)
14 string-join(
15 for $i in //*[*[text() or not(node())]]
16 return
17 string-join(
18 for $j in $i/*[text() or not(node())]
19 return local:formatField($j)
20 , ","
21 )
22 , " "
23 )'
24 passing xmltype(:doc)
25 returning content
26 )
27 as clob
28 ) as result
29 from dual ;
RESULT
"Steve O'Brien",,"Jane ""The Smiler"" Griff",Reminder,"Hey, don't forget me this
weekend! I've enclosed some pics from last weekend
Love Jane
Dance.jpg,MIME
Signature.txt,
We could also use a single ora:matches function in place of the OR'ed contains but it doesn't appear to work on 11.2.0.3, got an internal error :
ORA-00600: code d'erreur interne, arguments : [qmxqrs_xvm_popLastFuncArgAsStr:1], [], [], [], [], [], [], [], [], [], [], [] -
Hi,
I have customized incident form and added few fields as per our requirement.
All customized fields are in a separate class extension "ClassExtension_9cd2b3e6_25ea_4385_9a94_fc08e0cf6172"
Now we are planing to import incident data from our legacy ticketing tool (Manageengine Servicedesk).
Here is my XML code
<CSVImportFormat>
<Projection Type="System.WorkItem.Incident.ProjectionType">
<Seed>
<Class Type="ClassExtension_9cd2b3e6_25ea_4385_9a94_fc08e0cf6172">
<Property ID="Id"/>
<Property ID="Source"/>
<Property ID="TierQueue"/>
<Property ID="Classification"/>
<Property ID="Title"/>
<Property ID="Urgency"/>
<Property ID="Impact"/>
<Property ID="Description"/>
<Property ID="Priority"/>
<Property ID="Status"/>
<Property ID="CreatedDate"/>
<Property ID="ActualEndDate"/>
<Property ID="ClosedDate"/>
<Property ID="ResolutionDescription"/>
<Property ID="Prod" />
<Property ID="ParentAccount" />
<Property ID="CustomerSupportAccount" />
<Property ID="Hardware" />
<Property ID="OperatingSystem" />
<Property ID="Browser" />
<Property ID="InternetConnection" />
<Property ID="ProblemAffectsOthers" />
<Property ID="SalesforceCase" />
<Property ID="TFS" />
<Property ID="CustomerSupportAgent" />
</Class>
</Seed>
<Component Alias="AffectedUser" Count="1">
<Seed>
<Class Type="System.Domain.User">
<Property ID="UserName" />
<Property ID="Domain" />
</Class>
</Seed>
</Component>
<Component Alias="AssignedUser" Count="1">
<Seed>
<Class Type="System.Domain.User">
<Property ID="UserName" />
<Property ID="Domain" />
</Class>
</Seed>
</Component>
</Projection>
</CSVImportFormat>
I am getting below error while importing CSV
Could not import the row on line 2 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. It contains too few fields (number of fields expected 29 , found: 27).
Could not import the row on line 3 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. It contains too few fields (number of fields expected 29 , found: 27).
Could not import the row on line 4 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. It contains too few fields (number of fields expected 29 , found: 27).
Could not import the row on line 5 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. It contains too few fields (number of fields expected 29 , found: 27).
Could not import the row on line 6 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. It contains too few fields (number of fields expected 29 , found: 27).
Could not import the row on line 7 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. It contains too few fields (number of fields expected 29 , found: 27).
Could not import the row on line 8 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. It contains too few fields (number of fields expected 29 , found: 27).
Could not import the row on line 9 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. It contains too few fields (number of fields expected 29 , found: 27).
Could not import the row on line 10 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. It contains too few fields (number of fields expected 29 , found: 27).
Could not import the row on line 11 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. It contains too few fields (number of fields expected 29 , found: 27).
Could not import the row on line 12 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. It contains too few fields (number of fields expected 29 , found: 27).
Could not import the row on line 13 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. It contains too few fields (number of fields expected 29 , found: 27).
CSV Import Summary Statistics for file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv
Instances created in memory: 0
Instances failed in memory: 12
Instances committed to database: 0
Instances rejected by database: 0
Note:I have 27 Fields in my CSV file.
Regards, H@riThanks Andreas,
I have made changes as suggested by you.But i am getting below error while importing the data.
============
Creating new CSVImporter
Data Filename: C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv
Format Filename: C:\Users\administrator.TEST\Desktop\Incident1.xml
Validating against XSD schema...
Validation completed.
Warning: possible error in row on line 1 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. The following message was logged:
--> Could not find cached enumeration value Source for property Source, class System.WorkItem.Incident in enumeration cache. You must specify either the Name or Guid of an enumeration of type IncidentSourceEnum.
Error: Could not import the row on line 1 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. Object creation failed with the following error:
--> Exception of type 'Microsoft.EnterpriseManagement.CSVImport.CSVInstanceException' was thrown.
Warning: possible error in row on line 2 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. The following message was logged:
--> Matched enum value E-Mail for property Source of class System.WorkItem.Incident in data file with enum display name: E-Mail. Display names may not be unique. Consider using actual property name IncidentSourceEnum.Email.
Warning: possible error in row on line 2 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. The following message was logged:
--> Matched enum value SaaS IT NOC for property TierQueue of class System.WorkItem.Incident in data file with enum display name: SaaS IT NOC. Display names may not be unique. Consider using actual property name Enum.e5d90c8dd3074cf2a241968f3d676cde.
Warning: possible error in row on line 2 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. The following message was logged:
--> Matched enum value EMR for property Classification of class System.WorkItem.Incident in data file with enum display name: EMR. Display names may not be unique. Consider using actual property name Enum.f9c3dc992c584534b420b0fff7d3d426.
Warning: possible error in row on line 2 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. The following message was logged:
--> Matched enum value Medium for property Urgency of class System.WorkItem.TroubleTicket in data file with enum display name: Medium. Display names may not be unique. Consider using actual property name System.WorkItem.TroubleTicket.UrgencyEnum.Medium.
Warning: possible error in row on line 2 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. The following message was logged:
--> Matched enum value Medium for property Impact of class System.WorkItem.TroubleTicket in data file with enum display name: Medium. Display names may not be unique. Consider using actual property name System.WorkItem.TroubleTicket.ImpactEnum.Medium.
Warning: possible error in row on line 2 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. The following message was logged:
--> Matched enum value Closed for property Status of class System.WorkItem.Incident in data file with enum display name: Closed. Display names may not be unique. Consider using actual property name IncidentStatusEnum.Closed.
Warning: possible error in row on line 2 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. The following message was logged:
--> Could not find cached enumeration value Prod1 for property Prod, class ClassExtension_9cd2b3e6_25ea_4385_9a94_fc08e0cf6172 in enumeration cache. You must specify either the Name or Guid of an enumeration of type Prod.
Error: Could not import the row on line 2 of CSV file C:\Users\administrator.TEST\Desktop\New folder (2)\New folder\Incident1.csv. Object creation failed with the following error:
--> Exception of type 'Microsoft.EnterpriseManagement.CSVImport.CSVInstanceException' was thrown.
=======================
Regards, H@ri -
Hello
I need to convert xml files to csv format using SAX Parser. The following code & outputs are as below:
XML file:
<Library>
<Book>
<Title>Professional JINI</Title>
<Author>bs</Author>
<Publisher>Oreilly Publications</Publisher>
</Book>
<Book>
<Title>XML Programming</Title>
<Author>java</Author>
<Publisher>Mann Publications</Publisher>
</Book>
</Library>
public class BooksLibrary extends DefaultHandler
protected static final String XML_FILE_NAME = "C:\\library1.xml";
public static void main (String argv [])
// Use the default (non-validating) parser
SAXParserFactory factory = SAXParserFactory.newInstance();
try {
FileOutputStream fos=new FileOutputStream("C:/test.txt");
// Set up output stream
out = new OutputStreamWriter (fos, "UTF8");
// Parse the input
SAXParser saxParser = factory.newSAXParser();
saxParser.parse( new File(XML_FILE_NAME), new BooksLibrary() );
} catch (Throwable t) {
t.printStackTrace ();
System.exit (0);
static private Writer out;
//===========================================================
// Methods in SAX DocumentHandler
//===========================================================
public void startDocument ()
throws SAXException
showData ("<?xml version='1.0' encoding='UTF-8'?>");
newLine();
public void endDocument ()
throws SAXException
try {
newLine();
out.flush ();
} catch (IOException e) {
throw new SAXException ("I/O error", e);
public void startElement (String name, Attributes attrs)
throws SAXException
showData ("<"+name);
if (attrs != null) {
for (int i = 0; i < attrs.getLength (); i++) {
showData (" ");
showData (attrs.getLocalName(i)+"=\""+attrs.getValue (i)+"\"");
showData (">");
public void endElement (String name)
throws SAXException
showData ("</"+name+">");
public void characters (char buf [], int offset, int len)
throws SAXException
String s = new String(buf, offset, len);
showData (s);
//===========================================================
// Helpers Methods
//===========================================================
// Wrap I/O exceptions in SAX exceptions, to
// suit handler signature requirements
private void showData (String s)
throws SAXException
try {
out.write (s);
out.flush ();
} catch (IOException e) {
throw new SAXException ("I/O error", e);
// Start a new line
private void newLine ()
throws SAXException
//String lineEnd = System.getProperty("line.separator");
try {
out.write (", ");
} catch (IOException e) {
throw new SAXException ("I/O error", e);
--------------------------------------------------------------------------------------------------output is as follows:
<?xml version='1.0' encoding='UTF-8'?>,
Professional JINI
bs
Oreilly Publications
XML Programming
java
Mann Publications
Can anyone please tell me how to remove that indentation space & get the output as :
<?xml version='1.0' encoding='UTF-8'?>, Professional JINI, bs, Oreilly Publications, XML Programming, java, Mann Publications
ThanksBy the way, there is a new feature in Java 5.0 (Tiger) called "Annotations."
Since your code extneds DefaultHandler, you could specify a line with
@Override
before the definition of each of your methods. If you had used these, the compiler would have given an error since your methods did not override the methods of DefaultHandler.
(If your code implemented ContentHandler, by contrast, using @Override is invalid because you need to implement all of the methods defined in the interface definition.)
The other comment is that the safest way to handle characters() data is to use a StringBuilder/Buffer (StringBuilder is only valid in 5.0, StringBuffer has been around since Release 1.0) that you define in the startElement method. Use the append method to gather data presented to you in the characters() method and use toString() to harvest the data in the endElement method.
Dave Patterson -
XML TO .CSV Conversion issue
Hi All,
I Developed an MDM to 3rd Party FTPscenario with FCC . The data from MDM comes as XML and i placed it at the FTP succesfully with .CSV format.
But the issue is with tirmming of before Zeros in excel file,
eg: The value of a field GTIN_No is 076895464 from source, but its getting placed in the excel file as 76895464.
The before zero is mandatory as of the client requirement.
Please suggest
Regards,
RaghavHello Raghavendra,
Can you include a quote ' before and after the numerical value. The Excel will then interpret this number as string from the CSV file you are creating and should solve your problem.
Let me know if you still have issues after this solution.
Regards,
Nipun
Maybe you are looking for
-
USER EXIT FOR VF02! While completing the Billing Doc.
Hi, While cancelling the proforma invoice, i require to check some conditions.like whether excise invoice is made or not. i have find the include RV60AFZZ , i hv written the logic its work when VF02->biling doc ->cancle. but if it is performa invoi
-
Color calibrating comp. monitor
hello, does anyone know hoe to calibrate a monitor using the color bars? how the colrs should be and so forth? i do a little editing and some cs3. thx
-
How to compile the customization form in oracle ERP R12
hi i'm newbie.. plzz gimme the procedure line by line and what is command behind then and where i apply on linux or windows.. there is no DBA available soi have the responsibility to perform this task..! Regards Zafar Habib
-
Regarding marking and releasing in CK24.
The customer has a direct delivery process as in they purchase finished goods and just sell them. Such a material is newly created under a plant. In this case there is no in house production of that material and the price needs to be maintained manu
-
I selected Edit Document Text under Tools | Content | Edit Text & Objects. I place my cursor on the pdf and nothing happens. I then thought that the problem might be that Acrobat does not recognize the text. So I enabled OCR. I then placed my cursor