cancel
Showing results for 
Search instead for 
Did you mean: 

Transform XML to CSV

Former Member
0 Kudos

I have transform WDP parent-node into XML form.

And I have a requirement that I need to transform the XML file to CSV too.

I am having problem to transform this 2-level depth node into CSV by writting XSLT function.

Here is the sample of my XML file:


<Output>
	<Invoices_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>115.35</Amount>
		<Desc>Claim order Invoice</Desc>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>210.00</Amount>
		<Desc>Spare part Invoice</Desc>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>1210.75</Amount>
		<Desc>Services Invoice</Desc>
	</Invoices_T>
	
	<Pymts_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>11.35</Amount>
		<Item_Desc>Payment 1 of 3</Item_Desc>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>110.00</Amount>
		<Item_Desc>Payment 2 of 3</Item_Desc>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>800.75</Amount>
		<Item_Desc>Payment 3 of 3</Item_Desc>
	</Pymts_T>
	
	<Parts_Msgs_T>
		<Status>PO-pending</Status>
		<Part_Nr>13N5511-1</Part_Nr>
		<Message>This part will be available after one month</Message>
		<Timestamp>20070122132530</Timestamp>
		<Status>On Order</Status>
		<Part_Nr>13N5511-2</Part_Nr>
		<Message>This part is currently on order, status will be updated once available</Message>
		<Timestamp>20070122132610</Timestamp>
		<Status>Sent To Warehouse</Status>
		<Part_Nr>13N5511-3</Part_Nr>
		<Message>Order sent to Warehouse</Message>
		<Timestamp>20070122132610</Timestamp>
		<Status>Shipped</Status>
		<Part_Nr>13N5511-4</Part_Nr>
		<Message>This part has been shipped</Message>
		<Timestamp>20070122132700</Timestamp>
	</Parts_Msgs_T>
	
	<Parts_Info_T>
		<Status>Completed</Status>
		<Service>false</Service>
		<Shipped_Part_Desc>Base Assembly</Shipped_Part_Desc>
		<Line_Nr>0010</Line_Nr>
		<Part_Shipped>13N5512-1</Part_Shipped>
		<Part_Ordered>13N5511-1</Part_Ordered>
		<Scrap_Return>Scrap</Scrap_Return>
		<Part_Refid>Baseno2347</Part_Refid>
		<Fail_Code>F571</Fail_Code>
		<Cru_Tier_Value>CRU TIER V</Cru_Tier_Value>
		<Status>Completed</Status>
		<Service>false</Service>
		<Shipped_Part_Desc>Disk 3 read head</Shipped_Part_Desc>
		<Line_Nr>0020</Line_Nr>
		<Part_Shipped>13N5512-1</Part_Shipped>
		<Part_Ordered>13N5511-2</Part_Ordered>
		<Scrap_Return>Scrap</Scrap_Return>
		<Part_Refid>HD546784</Part_Refid>
		<Fail_Code>F573</Fail_Code>
		<Cru_Tier_Value>CRU TIER V</Cru_Tier_Value>
		<Status>Completed</Status>
		<Service>false</Service>
		<Shipped_Part_Desc>Disk 6 read head</Shipped_Part_Desc>
		<Line_Nr>0030</Line_Nr>
		<Part_Shipped>13N5512-1</Part_Shipped>
		<Part_Ordered>13N5511-3</Part_Ordered>
		<Scrap_Return>Return</Scrap_Return>
		<Part_Refid>ReadHead47944</Part_Refid>
		<Fail_Code>F256</Fail_Code>
		<Cru_Tier_Value>CRU TIER V</Cru_Tier_Value>
		<Status>Completed</Status>
		<Service>false</Service>
		<Shipped_Part_Desc>converter circuit board</Shipped_Part_Desc>
		<Line_Nr>0040</Line_Nr>
		<Part_Shipped>13N5512-1</Part_Shipped>
		<Part_Ordered>13N5511-4</Part_Ordered>
		<Scrap_Return>Return</Scrap_Return>
		<Part_Refid>Ckt879564</Part_Refid>
		<Fail_Code>F740</Fail_Code>
		<Cru_Tier_Value>CRU TIER V</Cru_Tier_Value>
	</Parts_Info_T>
	
	<Claim_Fields>
		<Basew_Type>Base</Basew_Type>
		<Incident_Nr>I456789</Incident_Nr>
		<Part_Comments>The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.</Part_Comments>
		<Basew_Desc>6 months Base Warranty</Basew_Desc>
		<Brand_Auth>Y</Brand_Auth>
		<Tecnhician_Email>Anthny@emailsrv.com</Tecnhician_Email>
		<Upgradew_Start_Date>2006-12-24</Upgradew_Start_Date>
		<Phone_Nr>919-456-7890</Phone_Nr>
		<Submitter_Name>Dhiraj Bhavsar</Submitter_Name>
		<Endcust_Postalcode>08813</Endcust_Postalcode>
		<Submitter_Phone>848-203-5184</Submitter_Phone>
		<Submitter_Id>DHIRAJB</Submitter_Id>
		<Endcust_City>Trenton</Endcust_City>
		<Pop_Date>2006-06-23</Pop_Date>
		<Rma_Nr>RMA9876543</Rma_Nr>
		<Shipto_City>Durham</Shipto_City>
		<Endcust_Addr3>
		</Endcust_Addr3>
		<Shipto_Addr1>597 Green Street</Shipto_Addr1>
		<Basew_Start_Date>2006-06-23</Basew_Start_Date>
		<Part_Failure_Desc>Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.</Part_Failure_Desc>
		<Shipto_Company>Terragear Inc</Shipto_Company>
		<Invoice_Date>2006-06-24</Invoice_Date>
		<Shipto_Addr3>
		</Shipto_Addr3>
		<Pymt_Date>2006-06-24</Pymt_Date>
		<Endcust_Country>USA</Endcust_Country>
		<Claim_Nr>100040</Claim_Nr>
		<Claim_Status>In Process</Claim_Status>
		<Shipto_Postalcode>27709</Shipto_Postalcode>
		<Shipto_Country>USA</Shipto_Country>
		<Endcust_Company>BearingPoint Inc.</Endcust_Company>
		<Serial_Nr>GS9546234754</Serial_Nr>
		<Company_Name>Wal-mart / Durham NC 28213</Company_Name>
		<Upgradew_Type>Upgr</Upgradew_Type>
		<Endcust_Type>Commercial</Endcust_Type>
		<Basew_Authorized>Y</Basew_Authorized>
		<Submitter_Email>DhirajBhavsar@yahoo.com</Submitter_Email>
		<Endcust_State>NJ</Endcust_State>
		<Endcust_Addr1>586 Market Street</Endcust_Addr1>
		<Basew_End_Date>2006-12-23</Basew_End_Date>
		<Bp_Claim_Refid>C7634572</Bp_Claim_Refid>
		<Endcust_Contact_Name>John Smith</Endcust_Contact_Name>
		<Shipto_Contact_Name>Caroline Smith</Shipto_Contact_Name>
		<Shipto_Addr2>Suite xxx</Shipto_Addr2>
		<Service_Site>Trenton, NJ</Service_Site>
		<Tech_Qualified>Y</Tech_Qualified>
		<Endcust_Addr2>Suite xxx</Endcust_Addr2>
		<Shipto_State>NC</Shipto_State>
		<Pymt_Paidto>XXX Inc, XXX Street, Edison, NJ</Pymt_Paidto>
		<Upgradew_Authorized>Y</Upgradew_Authorized>
		<Upgradew_End_Date>2007-12-23</Upgradew_End_Date>
		<Technitian_Name>Anthony Gonz</Technitian_Name>
		<Contact_Date>2006-12-29</Contact_Date>
		<Technitian_Phone>609-111-111</Technitian_Phone>
		<Loc_Id>1000040</Loc_Id>
		<Tecnhician_Id>   100247</Tecnhician_Id>
		<Upgradew_Desc>12 months upgrade warranty</Upgradew_Desc>
		<Product_Desc>Hard drive 80gb assembly</Product_Desc>
		<Service_Dt>2006-12-29</Service_Dt>
		<Prodct_Id>13N112</Prodct_Id>
		<Part_Ship_Type>Fedex Ground</Part_Ship_Type>
	</Claim_Fields>
</Output>

I tried to import the data into Excel and SAve It as CSV, but the display of XML file data in the Excel just don't really make sense to me.

Here is some analysis:

The <Claim_Fields> is cominf from a singleton node, and <Invoices_T>, <Parts_Msgs_T>, and <Parts_Info_T> are coming from non-singleton nodes.

And the parent node for them are <Output>.

I am doing the transformation through this function method:


 public java.lang.String iterateAndDisplay( com.sap.tc.webdynpro.progmodel.context.NodeInfo nodeInfo, com.sap.tc.webdynpro.progmodel.api.IWDNode actualNode )
  {
    //@@begin iterateAndDisplay()

	Iterator iterChild = nodeInfo.iterateChildren();
		Iterator iterAttributes = nodeInfo.iterateAttributes();
		ArrayList arrListAttrib = new ArrayList();
		//storing attribute names in an Arraylist 
		while (iterAttributes.hasNext()) {
			arrListAttrib.add(((AttributeInfo) iterAttributes.next()).getName());
		}

		xmlString.append("<" + nodeInfo.getName() + ">n");
		//if multiple objects present for the node 
		for (int i = 0; i < actualNode.size(); i++) {
			for (int j = 0; j < arrListAttrib.size(); j++) {
				String attrName = (String) arrListAttrib.get(j);
				//append attribute name 
				xmlString.append("<" + attrName + ">");
				//obtain IWDNodeElement object to obtain Attribute object
				//IWDNode childNode = wdContext.getChildNode(node.getPathDescription(), 0);
				IWDNodeElement actualNodeElement = actualNode.getElementAt(i);
				String strAttrValue = actualNodeElement.getAttributeValue(attrName) + "";
				xmlString.append(strAttrValue);
				xmlString.append("</" + attrName + ">n");
				//			}
			}
		}
		while (iterChild.hasNext()) {
			NodeInfo iwdNode = (NodeInfo) iterChild.next();
			iterateAndDisplay(iwdNode,actualNode.getChildNode(iwdNode.getName(), 0));
		}
		xmlString.append("</" +  nodeInfo.getName() + ">n");
		return xmlString.toString();
    //@@end
  }

I personal feel that there is something wrong in the non-singleton xml tag. like:


<Pymts_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>11.35</Amount>
		<Item_Desc>Payment 1 of 3</Item_Desc>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>110.00</Amount>
		<Item_Desc>Payment 2 of 3</Item_Desc>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>800.75</Amount>
		<Item_Desc>Payment 3 of 3</Item_Desc>
	</Pymts_T>

Shouldn't this be:


        <Pymts_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>11.35</Amount>
		<Item_Desc>Payment 1 of 3</Item_Desc>
	</Pymts_T>

         <Pymts_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>110.00</Amount>
		<Item_Desc>Payment 2 of 3</Item_Desc>
	</Pymts_T>

       <Pymts_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>800.75</Amount>
		<Item_Desc>Payment 3 of 3</Item_Desc>
	</Pymts_T>

Please advise.

Thanks.

Kent

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

This message was moderated.

former_member182372
Active Contributor
0 Kudos

for (int i = 0; i < actualNode.size(); i++) {
	xmlString.append("<" + nodeInfo.getName() + ">n");
	IWDNodeElement actualNodeElement = actualNode.getElementAt(i);
	for (int j = 0; j < arrListAttrib.size(); j++) {
		String attrName = (String) arrListAttrib.get(j);
		//append attribute name 
		xmlString.append("<" + attrName + ">");
		//obtain IWDNodeElement object to obtain Attribute object
		//IWDNode childNode = wdContext.getChildNode(node.getPathDescription(), 0);
		
		String strAttrValue = actualNodeElement.getAttributeValue(attrName) + "";
		xmlString.append(strAttrValue);
		xmlString.append("</" + attrName + ">n");
		//			}
	}

	while (iterChild.hasNext()) {
		NodeInfo iwdNode = (NodeInfo) iterChild.next();
		iterateAndDisplay(iwdNode, actualNode.getChildNode(iwdNode.getName(), actualNodeElement.index()));
	}
	
	xmlString.append("</" +  nodeInfo.getName() + ">n");
}

Former Member
0 Kudos

Hi, Maksim.

I am able to generate the right XML file which able to open with Excel 2003 now.

As I mentioned, my requirement changed that I need to generate the CSV format and open with Excel now.

For next step, how can I transform this XML file to the right CSV format?

I know I need to write a xslt to transform that. Can you provide some guide on this?

My current XML file look like this:


<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<Output>
	<Invoices_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>115.35</Amount>
		<Desc>Claim order Invoice</Desc>
	</Invoices_T>
	<Invoices_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>210.00</Amount>
		<Desc>Spare part Invoice</Desc>
	</Invoices_T>
	<Invoices_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>1210.75</Amount>
		<Desc>Services Invoice</Desc>
	</Invoices_T>
	<Pymts_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>11.35</Amount>
		<Item_Desc>Payment 1 of 3</Item_Desc>
	</Pymts_T>
	<Pymts_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>110.00</Amount>
		<Item_Desc>Payment 2 of 3</Item_Desc>
	</Pymts_T>
	<Pymts_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>800.75</Amount>
		<Item_Desc>Payment 3 of 3</Item_Desc>
	</Pymts_T>
	<Parts_Msgs_T>
		<Status>PO-pending</Status>
		<Part_Nr>13N5511-1</Part_Nr>
		<Message>This part will be available after one month</Message>
		<Timestamp>20070122132530</Timestamp>
	</Parts_Msgs_T>
	<Parts_Msgs_T>
		<Status>On Order</Status>
		<Part_Nr>13N5511-2</Part_Nr>
		<Message>This part is currently on order, status will be updated once available</Message>
		<Timestamp>20070122132610</Timestamp>
	</Parts_Msgs_T>
	<Parts_Msgs_T>
		<Status>Sent To Warehouse</Status>
		<Part_Nr>13N5511-3</Part_Nr>
		<Message>Order sent to Warehouse</Message>
		<Timestamp>20070122132610</Timestamp>
	</Parts_Msgs_T>
	<Parts_Msgs_T>
		<Status>Shipped</Status>
		<Part_Nr>13N5511-4</Part_Nr>
		<Message>This part has been shipped</Message>
		<Timestamp>20070122132700</Timestamp>
	</Parts_Msgs_T>
	<Parts_Info_T>
		<Status>Completed</Status>
		<Service>false</Service>
		<Shipped_Part_Desc>Base Assembly</Shipped_Part_Desc>
		<Line_Nr>0010</Line_Nr>
		<Part_Shipped>13N5512-1</Part_Shipped>
		<Part_Ordered>13N5511-1</Part_Ordered>
		<Scrap_Return>Scrap</Scrap_Return>
		<Part_Refid>Baseno2347</Part_Refid>
		<Fail_Code>F571</Fail_Code>
		<Cru_Tier_Value>CRU TIER V</Cru_Tier_Value>
	</Parts_Info_T>
	<Parts_Info_T>
		<Status>Completed</Status>
		<Service>false</Service>
		<Shipped_Part_Desc>Disk 3 read head</Shipped_Part_Desc>
		<Line_Nr>0020</Line_Nr>
		<Part_Shipped>13N5512-1</Part_Shipped>
		<Part_Ordered>13N5511-2</Part_Ordered>
		<Scrap_Return>Scrap</Scrap_Return>
		<Part_Refid>HD546784</Part_Refid>
		<Fail_Code>F573</Fail_Code>
		<Cru_Tier_Value>CRU TIER V</Cru_Tier_Value>
	</Parts_Info_T>
	<Parts_Info_T>
		<Status>Completed</Status>
		<Service>false</Service>
		<Shipped_Part_Desc>Disk 6 read head</Shipped_Part_Desc>
		<Line_Nr>0030</Line_Nr>
		<Part_Shipped>13N5512-1</Part_Shipped>
		<Part_Ordered>13N5511-3</Part_Ordered>
		<Scrap_Return>Return</Scrap_Return>
		<Part_Refid>ReadHead47944</Part_Refid>
		<Fail_Code>F256</Fail_Code>
		<Cru_Tier_Value>CRU TIER V</Cru_Tier_Value>
	</Parts_Info_T>
	<Parts_Info_T>
		<Status>Completed</Status>
		<Service>false</Service>
		<Shipped_Part_Desc>converter circuit board</Shipped_Part_Desc>
		<Line_Nr>0040</Line_Nr>
		<Part_Shipped>13N5512-1</Part_Shipped>
		<Part_Ordered>13N5511-4</Part_Ordered>
		<Scrap_Return>Return</Scrap_Return>
		<Part_Refid>Ckt879564</Part_Refid>
		<Fail_Code>F740</Fail_Code>
		<Cru_Tier_Value>CRU TIER V</Cru_Tier_Value>
	</Parts_Info_T>
	<Claim_Fields>
		<Basew_Type>Base</Basew_Type>
		<Incident_Nr>I456789</Incident_Nr>
		<Part_Comments>The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.</Part_Comments>
		<Basew_Desc>6 months Base Warranty</Basew_Desc>
		<Brand_Auth>Y</Brand_Auth>
		<Tecnhician_Email>Anthny@emailsrv.com</Tecnhician_Email>
		<Upgradew_Start_Date>2006-12-24</Upgradew_Start_Date>
		<Phone_Nr>919-456-7890</Phone_Nr>
		<Submitter_Name>Dhiraj Bhavsar</Submitter_Name>
		<Endcust_Postalcode>08813</Endcust_Postalcode>
		<Submitter_Phone>848-203-5184</Submitter_Phone>
		<Submitter_Id>DHIRAJB</Submitter_Id>
		<Endcust_City>Trenton</Endcust_City>
		<Pop_Date>2006-06-23</Pop_Date>
		<Rma_Nr>RMA9876543</Rma_Nr>
		<Shipto_City>Durham</Shipto_City>
		<Endcust_Addr3>
		</Endcust_Addr3>
		<Shipto_Addr1>597 Green Street</Shipto_Addr1>
		<Basew_Start_Date>2006-06-23</Basew_Start_Date>
		<Part_Failure_Desc>Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.</Part_Failure_Desc>
		<Shipto_Company>Terragear Inc</Shipto_Company>
		<Invoice_Date>2006-06-24</Invoice_Date>
		<Shipto_Addr3>
		</Shipto_Addr3>
		<Pymt_Date>2006-06-24</Pymt_Date>
		<Endcust_Country>USA</Endcust_Country>
		<Claim_Nr>100040</Claim_Nr>
		<Claim_Status>In Process</Claim_Status>
		<Shipto_Postalcode>27709</Shipto_Postalcode>
		<Shipto_Country>USA</Shipto_Country>
		<Endcust_Company>BearingPoint Inc.</Endcust_Company>
		<Serial_Nr>GS9546234754</Serial_Nr>
		<Company_Name>Wal-mart / Durham NC 28213</Company_Name>
		<Upgradew_Type>Upgr</Upgradew_Type>
		<Endcust_Type>Commercial</Endcust_Type>
		<Basew_Authorized>Y</Basew_Authorized>
		<Submitter_Email>DhirajBhavsar@yahoo.com</Submitter_Email>
		<Endcust_State>NJ</Endcust_State>
		<Endcust_Addr1>586 Market Street</Endcust_Addr1>
		<Basew_End_Date>2006-12-23</Basew_End_Date>
		<Bp_Claim_Refid>C7634572</Bp_Claim_Refid>
		<Endcust_Contact_Name>John Smith</Endcust_Contact_Name>
		<Shipto_Contact_Name>Caroline Smith</Shipto_Contact_Name>
		<Shipto_Addr2>Suite xxx</Shipto_Addr2>
		<Service_Site>Trenton, NJ</Service_Site>
		<Tech_Qualified>Y</Tech_Qualified>
		<Endcust_Addr2>Suite xxx</Endcust_Addr2>
		<Shipto_State>NC</Shipto_State>
		<Pymt_Paidto>Pits Financial Services Inc, 428 Green Street, Edison, NJ</Pymt_Paidto>
		<Upgradew_Authorized>Y</Upgradew_Authorized>
		<Upgradew_End_Date>2007-12-23</Upgradew_End_Date>
		<Technitian_Name>Anthony Gonzalez</Technitian_Name>
		<Contact_Date>2006-12-29</Contact_Date>
		<Technitian_Phone>609-000-0000</Technitian_Phone>
		<Loc_Id>1000040</Loc_Id>
		<Tecnhician_Id>   100247</Tecnhician_Id>
		<Upgradew_Desc>12 months upgrade warranty</Upgradew_Desc>
		<Product_Desc>Hard drive 80gb assembly</Product_Desc>
		<Service_Dt>2006-12-29</Service_Dt>
		<Prodct_Id>13N112</Prodct_Id>
		<Part_Ship_Type>Fedex Ground</Part_Ship_Type>
	</Claim_Fields>
</Output>

Thanks.

Kent

former_member182372
Active Contributor
0 Kudos

Kent, what is your question? How to perform xslt transformation in Java? Or how to create XSLT?


<?xml version="1.0"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="Invoices_T">
<xsl:value-of select="Amount_Currency"/>,<xsl:value-of select="Amount"/>,<xsl:value-of select="Desc"/>
</xsl:template>
</xsl:stylesheet>

Former Member
0 Kudos

Hi, Maksim.

I am looking for xsl like you shown as example.

I wonder can I make more generic XSL Style Sheet with a transformation template that able to transform XML file with unknown xml tags?

The reason is the structure of my context node may change, that cause the xml tags changed. If I have static XSL file, I will need to make the change on that too.

But the below example should help me to get started.

I will update you on how I progress from here.

Thanks

Kent

Former Member
0 Kudos

HI, Maksim.

(The result below is generated from the xml source I provided when I open the XML source with Excel, then SAVE AS cvs format. My goal is to transform it to csv format directly without manual SAVE to csv format)

Result :

Amount_Currency,Amount,Desc,Amount_Currency2,Amount3,Item_Desc,Status,Part_Nr,Message,Timestamp,Status4,Service,Shipped_Part_Desc,Line_Nr,Part_Shipped,Part_Ordered,Scrap_Return,Part_Refid,Fail_Code,Cru_Tier_Value,Basew_Type,Incident_Nr,Part_Comments,Basew_Desc,Brand_Auth,Tecnhician_Email,Upgradew_Start_Date,Phone_Nr,Submitter_Name,Endcust_Postalcode,Submitter_Phone,Submitter_Id,Endcust_City,Pop_Date,Rma_Nr,Shipto_City,Endcust_Addr3,Shipto_Addr1,Basew_Start_Date,Part_Failure_Desc,Shipto_Company,Invoice_Date,Shipto_Addr3,Pymt_Date,Endcust_Country,Claim_Nr,Claim_Status,Shipto_Postalcode,Shipto_Country,Endcust_Company,Serial_Nr,Company_Name,Upgradew_Type,Endcust_Type,Basew_Authorized,Submitter_Email,Endcust_State,Endcust_Addr1,Basew_End_Date,Bp_Claim_Refid,Endcust_Contact_Name,Shipto_Contact_Name,Shipto_Addr2,Service_Site,Tech_Qualified,Endcust_Addr2,Shipto_State,Pymt_Paidto,Upgradew_Authorized,Upgradew_End_Date,Technitian_Name,Contact_Date,Technitian_Phone,Loc_Id,Tecnhician_Id,Upgradew_Desc,Product_Desc,Service_Dt,Prodct_Id,Part_Ship_Type

USD,115.35,Claim order Invoice,,,,,,,,,,,,,,,,,,Base,I456789,"The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.",6 months Base Warranty,Y,Anthny@emailsrv.com,12/24/2006,919-456-7890,Dhiraj Bhavsar,8813,848-203-5184,DHIRAJB,Trenton,6/23/2006,RMA9876543,Durham,,597 Green Street,6/23/2006,"Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.",Terragear Inc,6/24/2006,,6/24/2006,USA,100040,In Process,27709,USA,BearingPoint Inc.,GS9546234754,Wal-mart / Durham NC 28213,Upgr,Commercial,Y,DhirajBhavsar@yahoo.com,NJ,586 Market Street,12/23/2006,C7634572,John Smith,Caroline Smith,Suite 101,"Trenton, NJ",Y,Suite 302,NC,"Pits Financial Services Inc, 428 Green Street, Edison, NJ",Y,12/23/2007,Anthony Gonzalez,12/29/2006,609-445-2525,1000040,100247,12 months upgrade warranty,Hard drive 80gb assembly,12/29/2006,13N112,Fedex Ground

USD,210,Spare part Invoice,,,,,,,,,,,,,,,,,,Base,I456789,"The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.",6 months Base Warranty,Y,Anthny@emailsrv.com,12/24/2006,919-456-7890,Dhiraj Bhavsar,8813,848-203-5184,DHIRAJB,Trenton,6/23/2006,RMA9876543,Durham,,597 Green Street,6/23/2006,"Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.",Terragear Inc,6/24/2006,,6/24/2006,USA,100040,In Process,27709,USA,BearingPoint Inc.,GS9546234754,Wal-mart / Durham NC 28213,Upgr,Commercial,Y,DhirajBhavsar@yahoo.com,NJ,586 Market Street,12/23/2006,C7634572,John Smith,Caroline Smith,Suite 101,"Trenton, NJ",Y,Suite 302,NC,"Pits Financial Services Inc, 428 Green Street, Edison, NJ",Y,12/23/2007,Anthony Gonzalez,12/29/2006,609-445-2525,1000040,100247,12 months upgrade warranty,Hard drive 80gb assembly,12/29/2006,13N112,Fedex Ground

USD,1210.75,Services Invoice,,,,,,,,,,,,,,,,,,Base,I456789,"The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.",6 months Base Warranty,Y,Anthny@emailsrv.com,12/24/2006,919-456-7890,Dhiraj Bhavsar,8813,848-203-5184,DHIRAJB,Trenton,6/23/2006,RMA9876543,Durham,,597 Green Street,6/23/2006,"Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.",Terragear Inc,6/24/2006,,6/24/2006,USA,100040,In Process,27709,USA,BearingPoint Inc.,GS9546234754,Wal-mart / Durham NC 28213,Upgr,Commercial,Y,DhirajBhavsar@yahoo.com,NJ,586 Market Street,12/23/2006,C7634572,John Smith,Caroline Smith,Suite 101,"Trenton, NJ",Y,Suite 302,NC,"Pits Financial Services Inc, 428 Green Street, Edison, NJ",Y,12/23/2007,Anthony Gonzalez,12/29/2006,609-445-2525,1000040,100247,12 months upgrade warranty,Hard drive 80gb assembly,12/29/2006,13N112,Fedex Ground

,,,USD,11.35,Payment 1 of 3,,,,,,,,,,,,,,,Base,I456789,"The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.",6 months Base Warranty,Y,Anthny@emailsrv.com,12/24/2006,919-456-7890,Dhiraj Bhavsar,8813,848-203-5184,DHIRAJB,Trenton,6/23/2006,RMA9876543,Durham,,597 Green Street,6/23/2006,"Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.",Terragear Inc,6/24/2006,,6/24/2006,USA,100040,In Process,27709,USA,BearingPoint Inc.,GS9546234754,Wal-mart / Durham NC 28213,Upgr,Commercial,Y,DhirajBhavsar@yahoo.com,NJ,586 Market Street,12/23/2006,C7634572,John Smith,Caroline Smith,Suite 101,"Trenton, NJ",Y,Suite 302,NC,"Pits Financial Services Inc, 428 Green Street, Edison, NJ",Y,12/23/2007,Anthony Gonzalez,12/29/2006,609-445-2525,1000040,100247,12 months upgrade warranty,Hard drive 80gb assembly,12/29/2006,13N112,Fedex Ground

,,,USD,110,Payment 2 of 3,,,,,,,,,,,,,,,Base,I456789,"The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.",6 months Base Warranty,Y,Anthny@emailsrv.com,12/24/2006,919-456-7890,Dhiraj Bhavsar,8813,848-203-5184,DHIRAJB,Trenton,6/23/2006,RMA9876543,Durham,,597 Green Street,6/23/2006,"Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.",Terragear Inc,6/24/2006,,6/24/2006,USA,100040,In Process,27709,USA,BearingPoint Inc.,GS9546234754,Wal-mart / Durham NC 28213,Upgr,Commercial,Y,DhirajBhavsar@yahoo.com,NJ,586 Market Street,12/23/2006,C7634572,John Smith,Caroline Smith,Suite 101,"Trenton, NJ",Y,Suite 302,NC,"Pits Financial Services Inc, 428 Green Street, Edison, NJ",Y,12/23/2007,Anthony Gonzalez,12/29/2006,609-445-2525,1000040,100247,12 months upgrade warranty,Hard drive 80gb assembly,12/29/2006,13N112,Fedex Ground

,,,USD,800.75,Payment 3 of 3,,,,,,,,,,,,,,,Base,I456789,"The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.",6 months Base Warranty,Y,Anthny@emailsrv.com,12/24/2006,919-456-7890,Dhiraj Bhavsar,8813,848-203-5184,DHIRAJB,Trenton,6/23/2006,RMA9876543,Durham,,597 Green Street,6/23/2006,"Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.",Terragear Inc,6/24/2006,,6/24/2006,USA,100040,In Process,27709,USA,BearingPoint Inc.,GS9546234754,Wal-mart / Durham NC 28213,Upgr,Commercial,Y,DhirajBhavsar@yahoo.com,NJ,586 Market Street,12/23/2006,C7634572,John Smith,Caroline Smith,Suite 101,"Trenton, NJ",Y,Suite 302,NC,"Pits Financial Services Inc, 428 Green Street, Edison, NJ",Y,12/23/2007,Anthony Gonzalez,12/29/2006,609-445-2525,1000040,100247,12 months upgrade warranty,Hard drive 80gb assembly,12/29/2006,13N112,Fedex Ground

,,,,,,PO-pending,13N5511-1,This part will be available after one month,2.00701E+13,,,,,,,,,,,Base,I456789,"The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.",6 months Base Warranty,Y,Anthny@emailsrv.com,12/24/2006,919-456-7890,Dhiraj Bhavsar,8813,848-203-5184,DHIRAJB,Trenton,6/23/2006,RMA9876543,Durham,,597 Green Street,6/23/2006,"Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.",Terragear Inc,6/24/2006,,6/24/2006,USA,100040,In Process,27709,USA,BearingPoint Inc.,GS9546234754,Wal-mart / Durham NC 28213,Upgr,Commercial,Y,DhirajBhavsar@yahoo.com,NJ,586 Market Street,12/23/2006,C7634572,John Smith,Caroline Smith,Suite 101,"Trenton, NJ",Y,Suite 302,NC,"Pits Financial Services Inc, 428 Green Street, Edison, NJ",Y,12/23/2007,Anthony Gonzalez,12/29/2006,609-445-2525,1000040,100247,12 months upgrade warranty,Hard drive 80gb assembly,12/29/2006,13N112,Fedex Ground

,,,,,,On Order,13N5511-2,"This part is currently on order, status will be updated once available",2.00701E+13,,,,,,,,,,,Base,I456789,"The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.",6 months Base Warranty,Y,Anthny@emailsrv.com,12/24/2006,919-456-7890,Dhiraj Bhavsar,8813,848-203-5184,DHIRAJB,Trenton,6/23/2006,RMA9876543,Durham,,597 Green Street,6/23/2006,"Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.",Terragear Inc,6/24/2006,,6/24/2006,USA,100040,In Process,27709,USA,BearingPoint Inc.,GS9546234754,Wal-mart / Durham NC 28213,Upgr,Commercial,Y,DhirajBhavsar@yahoo.com,NJ,586 Market Street,12/23/2006,C7634572,John Smith,Caroline Smith,Suite 101,"Trenton, NJ",Y,Suite 302,NC,"Pits Financial Services Inc, 428 Green Street, Edison, NJ",Y,12/23/2007,Anthony Gonzalez,12/29/2006,609-445-2525,1000040,100247,12 months upgrade warranty,Hard drive 80gb assembly,12/29/2006,13N112,Fedex Ground

,,,,,,Sent To Warehouse,13N5511-3,Order sent to Warehouse,2.00701E+13,,,,,,,,,,,Base,I456789,"The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.",6 months Base Warranty,Y,Anthny@emailsrv.com,12/24/2006,919-456-7890,Dhiraj Bhavsar,8813,848-203-5184,DHIRAJB,Trenton,6/23/2006,RMA9876543,Durham,,597 Green Street,6/23/2006,"Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.",Terragear Inc,6/24/2006,,6/24/2006,USA,100040,In Process,27709,USA,BearingPoint Inc.,GS9546234754,Wal-mart / Durham NC 28213,Upgr,Commercial,Y,DhirajBhavsar@yahoo.com,NJ,586 Market Street,12/23/2006,C7634572,John Smith,Caroline Smith,Suite 101,"Trenton, NJ",Y,Suite 302,NC,"Pits Financial Services Inc, 428 Green Street, Edison, NJ",Y,12/23/2007,Anthony Gonzalez,12/29/2006,609-445-2525,1000040,100247,12 months upgrade warranty,Hard drive 80gb assembly,12/29/2006,13N112,Fedex Ground

,,,,,,Shipped,13N5511-4,This part has been shipped,2.00701E+13,,,,,,,,,,,Base,I456789,"The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.",6 months Base Warranty,Y,Anthny@emailsrv.com,12/24/2006,919-456-7890,Dhiraj Bhavsar,8813,848-203-5184,DHIRAJB,Trenton,6/23/2006,RMA9876543,Durham,,597 Green Street,6/23/2006,"Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.",Terragear Inc,6/24/2006,,6/24/2006,USA,100040,In Process,27709,USA,BearingPoint Inc.,GS9546234754,Wal-mart / Durham NC 28213,Upgr,Commercial,Y,DhirajBhavsar@yahoo.com,NJ,586 Market Street,12/23/2006,C7634572,John Smith,Caroline Smith,Suite 101,"Trenton, NJ",Y,Suite 302,NC,"Pits Financial Services Inc, 428 Green Street, Edison, NJ",Y,12/23/2007,Anthony Gonzalez,12/29/2006,609-445-2525,1000040,100247,12 months upgrade warranty,Hard drive 80gb assembly,12/29/2006,13N112,Fedex Ground

,,,,,,,,,,Completed,FALSE,Base Assembly,10,13N5512-1,13N5511-1,Scrap,Baseno2347,F571,CRU TIER V,Base,I456789,"The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.",6 months Base Warranty,Y,Anthny@emailsrv.com,12/24/2006,919-456-7890,Dhiraj Bhavsar,8813,848-203-5184,DHIRAJB,Trenton,6/23/2006,RMA9876543,Durham,,597 Green Street,6/23/2006,"Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.",Terragear Inc,6/24/2006,,6/24/2006,USA,100040,In Process,27709,USA,BearingPoint Inc.,GS9546234754,Wal-mart / Durham NC 28213,Upgr,Commercial,Y,DhirajBhavsar@yahoo.com,NJ,586 Market Street,12/23/2006,C7634572,John Smith,Caroline Smith,Suite 101,"Trenton, NJ",Y,Suite 302,NC,"Pits Financial Services Inc, 428 Green Street, Edison, NJ",Y,12/23/2007,Anthony Gonzalez,12/29/2006,609-445-2525,1000040,100247,12 months upgrade warranty,Hard drive 80gb assembly,12/29/2006,13N112,Fedex Ground

,,,,,,,,,,Completed,FALSE,Disk 3 read head,20,13N5512-1,13N5511-2,Scrap,HD546784,F573,CRU TIER V,Base,I456789,"The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.",6 months Base Warranty,Y,Anthny@emailsrv.com,12/24/2006,919-456-7890,Dhiraj Bhavsar,8813,848-203-5184,DHIRAJB,Trenton,6/23/2006,RMA9876543,Durham,,597 Green Street,6/23/2006,"Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.",Terragear Inc,6/24/2006,,6/24/2006,USA,100040,In Process,27709,USA,BearingPoint Inc.,GS9546234754,Wal-mart / Durham NC 28213,Upgr,Commercial,Y,DhirajBhavsar@yahoo.com,NJ,586 Market Street,12/23/2006,C7634572,John Smith,Caroline Smith,Suite 101,"Trenton, NJ",Y,Suite 302,NC,"Pits Financial Services Inc, 428 Green Street, Edison, NJ",Y,12/23/2007,Anthony Gonzalez,12/29/2006,609-445-2525,1000040,100247,12 months upgrade warranty,Hard drive 80gb assembly,12/29/2006,13N112,Fedex Ground

,,,,,,,,,,Completed,FALSE,Disk 6 read head,30,13N5512-1,13N5511-3,Return,ReadHead47944,F256,CRU TIER V,Base,I456789,"The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.",6 months Base Warranty,Y,Anthny@emailsrv.com,12/24/2006,919-456-7890,Dhiraj Bhavsar,8813,848-203-5184,DHIRAJB,Trenton,6/23/2006,RMA9876543,Durham,,597 Green Street,6/23/2006,"Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.",Terragear Inc,6/24/2006,,6/24/2006,USA,100040,In Process,27709,USA,BearingPoint Inc.,GS9546234754,Wal-mart / Durham NC 28213,Upgr,Commercial,Y,DhirajBhavsar@yahoo.com,NJ,586 Market Street,12/23/2006,C7634572,John Smith,Caroline Smith,Suite 101,"Trenton, NJ",Y,Suite 302,NC,"Pits Financial Services Inc, 428 Green Street, Edison, NJ",Y,12/23/2007,Anthony Gonzalez,12/29/2006,609-445-2525,1000040,100247,12 months upgrade warranty,Hard drive 80gb assembly,12/29/2006,13N112,Fedex Ground

,,,,,,,,,,Completed,FALSE,converter circuit board,40,13N5512-1,13N5511-4,Return,Ckt879564,F740,CRU TIER V,Base,I456789,"The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.",6 months Base Warranty,Y,Anthny@emailsrv.com,12/24/2006,919-456-7890,Dhiraj Bhavsar,8813,848-203-5184,DHIRAJB,Trenton,6/23/2006,RMA9876543,Durham,,597 Green Street,6/23/2006,"Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.",Terragear Inc,6/24/2006,,6/24/2006,USA,100040,In Process,27709,USA,BearingPoint Inc.,GS9546234754,Wal-mart / Durham NC 28213,Upgr,Commercial,Y,DhirajBhavsar@yahoo.com,NJ,586 Market Street,12/23/2006,C7634572,John Smith,Caroline Smith,Suite 101,"Trenton, NJ",Y,Suite 302,NC,"Pits Financial Services Inc, 428 Green Street, Edison, NJ",Y,12/23/2007,Anthony Gonzalez,12/29/2006,609-445-2525,1000040,100247,12 months upgrade warranty,Hard drive 80gb assembly,12/29/2006,13N112,Fedex Ground

NOTE: The singleton <Claim_Fields> actually repeated itself every time, while the other attributes repeated only once in their according columns.

In this case, how should I write the xsl class?

Thanks for advise.

Kent

former_member182372
Active Contributor
0 Kudos

>>The result below is generated from the xml source I provided when I open the >>XML source with Excel, then SAVE AS cvs format. My goal is to transform it to >>csv format directly without manual SAVE to csv format)

Sorry, I don`t understand you. What is the question? You have context structure, you generate XML from context, transforming it applying XSLT. What is you requirement? Save csv file to the disk? Or present it to the user?

Former Member
0 Kudos

Maksim.

Sorry to confuse you.

My optimal goal is to save the CSV format file (from the context node) to the disk.

Thanks.

Kent

former_member182372
Active Contributor
0 Kudos

What code (Java) did you use to produce result from above?

Former Member
0 Kudos

I did not write any code to generate the CSV format. All I do now is open the XML file with Excel, then SAVE it into CSV format, then reopen it with TextPad. But my goal is to generate this CSV file through XSLT/Java programming.

Again, here is the XML source I open with Excel:


<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<Output>
	<Invoices_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>115.35</Amount>
		<Desc>Claim order Invoice</Desc>
	</Invoices_T>
	<Invoices_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>210.00</Amount>
		<Desc>Spare part Invoice</Desc>
	</Invoices_T>
	<Invoices_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>1210.75</Amount>
		<Desc>Services Invoice</Desc>
	</Invoices_T>
	<Pymts_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>11.35</Amount>
		<Item_Desc>Payment 1 of 3</Item_Desc>
	</Pymts_T>
	<Pymts_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>110.00</Amount>
		<Item_Desc>Payment 2 of 3</Item_Desc>
	</Pymts_T>
	<Pymts_T>
		<Amount_Currency>USD</Amount_Currency>
		<Amount>800.75</Amount>
		<Item_Desc>Payment 3 of 3</Item_Desc>
	</Pymts_T>
	<Parts_Msgs_T>
		<Status>PO-pending</Status>
		<Part_Nr>13N5511-1</Part_Nr>
		<Message>This part will be available after one month</Message>
		<Timestamp>20070122132530</Timestamp>
	</Parts_Msgs_T>
	<Parts_Msgs_T>
		<Status>On Order</Status>
		<Part_Nr>13N5511-2</Part_Nr>
		<Message>This part is currently on order, status will be updated once available</Message>
		<Timestamp>20070122132610</Timestamp>
	</Parts_Msgs_T>
	<Parts_Msgs_T>
		<Status>Sent To Warehouse</Status>
		<Part_Nr>13N5511-3</Part_Nr>
		<Message>Order sent to Warehouse</Message>
		<Timestamp>20070122132610</Timestamp>
	</Parts_Msgs_T>
	<Parts_Msgs_T>
		<Status>Shipped</Status>
		<Part_Nr>13N5511-4</Part_Nr>
		<Message>This part has been shipped</Message>
		<Timestamp>20070122132700</Timestamp>
	</Parts_Msgs_T>
	<Parts_Info_T>
		<Status>Completed</Status>
		<Service>false</Service>
		<Shipped_Part_Desc>Base Assembly</Shipped_Part_Desc>
		<Line_Nr>0010</Line_Nr>
		<Part_Shipped>13N5512-1</Part_Shipped>
		<Part_Ordered>13N5511-1</Part_Ordered>
		<Scrap_Return>Scrap</Scrap_Return>
		<Part_Refid>Baseno2347</Part_Refid>
		<Fail_Code>F571</Fail_Code>
		<Cru_Tier_Value>CRU TIER V</Cru_Tier_Value>
	</Parts_Info_T>
	<Parts_Info_T>
		<Status>Completed</Status>
		<Service>false</Service>
		<Shipped_Part_Desc>Disk 3 read head</Shipped_Part_Desc>
		<Line_Nr>0020</Line_Nr>
		<Part_Shipped>13N5512-1</Part_Shipped>
		<Part_Ordered>13N5511-2</Part_Ordered>
		<Scrap_Return>Scrap</Scrap_Return>
		<Part_Refid>HD546784</Part_Refid>
		<Fail_Code>F573</Fail_Code>
		<Cru_Tier_Value>CRU TIER V</Cru_Tier_Value>
	</Parts_Info_T>
	<Parts_Info_T>
		<Status>Completed</Status>
		<Service>false</Service>
		<Shipped_Part_Desc>Disk 6 read head</Shipped_Part_Desc>
		<Line_Nr>0030</Line_Nr>
		<Part_Shipped>13N5512-1</Part_Shipped>
		<Part_Ordered>13N5511-3</Part_Ordered>
		<Scrap_Return>Return</Scrap_Return>
		<Part_Refid>ReadHead47944</Part_Refid>
		<Fail_Code>F256</Fail_Code>
		<Cru_Tier_Value>CRU TIER V</Cru_Tier_Value>
	</Parts_Info_T>
	<Parts_Info_T>
		<Status>Completed</Status>
		<Service>false</Service>
		<Shipped_Part_Desc>converter circuit board</Shipped_Part_Desc>
		<Line_Nr>0040</Line_Nr>
		<Part_Shipped>13N5512-1</Part_Shipped>
		<Part_Ordered>13N5511-4</Part_Ordered>
		<Scrap_Return>Return</Scrap_Return>
		<Part_Refid>Ckt879564</Part_Refid>
		<Fail_Code>F740</Fail_Code>
		<Cru_Tier_Value>CRU TIER V</Cru_Tier_Value>
	</Parts_Info_T>
	<Claim_Fields>
		<Basew_Type>Base</Basew_Type>
		<Incident_Nr>I456789</Incident_Nr>
		<Part_Comments>The Hard drive worked smoothly for first day. Only second day of purchase the drive refused to start, but again started next day and was okay for 3 months.</Part_Comments>
		<Basew_Desc>6 months Base Warranty</Basew_Desc>
		<Brand_Auth>Y</Brand_Auth>
		<Tecnhician_Email>Anthny@emailsrv.com</Tecnhician_Email>
		<Upgradew_Start_Date>2006-12-24</Upgradew_Start_Date>
		<Phone_Nr>919-456-7890</Phone_Nr>
		<Submitter_Name>Dhiraj Bhavsar</Submitter_Name>
		<Endcust_Postalcode>08813</Endcust_Postalcode>
		<Submitter_Phone>848-203-5184</Submitter_Phone>
		<Submitter_Id>DHIRAJB</Submitter_Id>
		<Endcust_City>Trenton</Endcust_City>
		<Pop_Date>2006-06-23</Pop_Date>
		<Rma_Nr>RMA9876543</Rma_Nr>
		<Shipto_City>Durham</Shipto_City>
		<Endcust_Addr3>
		</Endcust_Addr3>
		<Shipto_Addr1>597 Green Street</Shipto_Addr1>
		<Basew_Start_Date>2006-06-23</Basew_Start_Date>
		<Part_Failure_Desc>Everytime during the start, Hard disk is not detected for 2 to 3 minutes and then detected okay.</Part_Failure_Desc>
		<Shipto_Company>Terragear Inc</Shipto_Company>
		<Invoice_Date>2006-06-24</Invoice_Date>
		<Shipto_Addr3>
		</Shipto_Addr3>
		<Pymt_Date>2006-06-24</Pymt_Date>
		<Endcust_Country>USA</Endcust_Country>
		<Claim_Nr>100040</Claim_Nr>
		<Claim_Status>In Process</Claim_Status>
		<Shipto_Postalcode>27709</Shipto_Postalcode>
		<Shipto_Country>USA</Shipto_Country>
		<Endcust_Company>BearingPoint Inc.</Endcust_Company>
		<Serial_Nr>GS9546234754</Serial_Nr>
		<Company_Name>Wal-mart / Durham NC 28213</Company_Name>
		<Upgradew_Type>Upgr</Upgradew_Type>
		<Endcust_Type>Commercial</Endcust_Type>
		<Basew_Authorized>Y</Basew_Authorized>
		<Submitter_Email>DhirajBhavsar@yahoo.com</Submitter_Email>
		<Endcust_State>NJ</Endcust_State>
		<Endcust_Addr1>586 Market Street</Endcust_Addr1>
		<Basew_End_Date>2006-12-23</Basew_End_Date>
		<Bp_Claim_Refid>C7634572</Bp_Claim_Refid>
		<Endcust_Contact_Name>John Smith</Endcust_Contact_Name>
		<Shipto_Contact_Name>Caroline Smith</Shipto_Contact_Name>
		<Shipto_Addr2>Suite 101</Shipto_Addr2>
		<Service_Site>Trenton, NJ</Service_Site>
		<Tech_Qualified>Y</Tech_Qualified>
		<Endcust_Addr2>Suite 302</Endcust_Addr2>
		<Shipto_State>NC</Shipto_State>
		<Pymt_Paidto>Pits Financial Services Inc, 428 Green Street, Edison, NJ</Pymt_Paidto>
		<Upgradew_Authorized>Y</Upgradew_Authorized>
		<Upgradew_End_Date>2007-12-23</Upgradew_End_Date>
		<Technitian_Name>Anthony Gonzalez</Technitian_Name>
		<Contact_Date>2006-12-29</Contact_Date>
		<Technitian_Phone>609-445-2525</Technitian_Phone>
		<Loc_Id>1000040</Loc_Id>
		<Tecnhician_Id>   100247</Tecnhician_Id>
		<Upgradew_Desc>12 months upgrade warranty</Upgradew_Desc>
		<Product_Desc>Hard drive 80gb assembly</Product_Desc>
		<Service_Dt>2006-12-29</Service_Dt>
		<Prodct_Id>13N112</Prodct_Id>
		<Part_Ship_Type>Fedex Ground</Part_Ship_Type>
	</Claim_Fields>
</Output>

former_member182372
Active Contributor
0 Kudos

Gotcha!

5 minutes of protoyping result


import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;


	try {
		SAXParserFactory factory = SAXParserFactory.newInstance();
		SAXParser parser = factory.newSAXParser();
		
		StringReader sr = new StringReader(XI_DOCUMENT.trim());
		Source xmlSource = new StreamSource(sr);
		StringReader srxslt = new StringReader(XSLT_DOCUMENT.trim());
		Source xsltSource = new StreamSource(srxslt);
		Result result = new StreamResult(System.out);
		TransformerFactory tf = TransformerFactory.newInstance();
		Templates templates = tf.newTemplates(xsltSource);
		Transformer transformer = templates.newTransformer();
		transformer.transform(xmlSource, result);
	} catch (Exception e) {
		final StringWriter sw = new StringWriter(); 
		final PrintWriter pw = new PrintWriter(sw); 
		e.printStackTrace(pw);
	}

public static final String XI_DOCUMENT = //XML from your post;
public static final String XSLT_DOCUMENT  = //XSLT file;

Former Member
0 Kudos

Hi, Maksim.

Sorry for the late reply, I was busy with other implementation lately.

I am actually looking for the xsl file that do the transformation from the XML file above to CSV format.

Something like this:


<?xml version="1.0"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>

<xsl:template match="/">
     <xsl:apply-templates select="//Invoices_T"></xsl:apply-templates>
     <xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text>
     <xsl:apply-templates select="//Pymts_T"></xsl:apply-templates>
     <xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text>,<xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text>
     <xsl:apply-templates select="//Parts_Msgs_T"></xsl:apply-templates>
     <xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text>,<xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text>,<xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text>
     <xsl:apply-templates select="//Parts_Info_T"></xsl:apply-templates>
</xsl:template>


<xsl:template match="Invoices_T">
<xsl:value-of select="Amount_Currency"/>,<xsl:value-of select="Amount"/>,<xsl:value-of select="Desc"/>
</xsl:template>



<xsl:template match="Pymts_T">
<xsl:value-of select="Amount_Currency"/>,<xsl:value-of select="Amount"/>,<xsl:value-of select="Item_Desc"/>
</xsl:template>


<xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text><xsl:text>,</xsl:text>
<xsl:template match="Parts_Msgs_T">
<xsl:value-of select="Status"/>,<xsl:value-of select="Part_Nr"/>,<xsl:value-of select="Message"/>,<xsl:value-of select="Timestamp"/>
</xsl:template>

<xsl:template match="Parts_Info_T">
<xsl:value-of select="Status"/>,<xsl:value-of select="Service"/>,<xsl:value-of select="Shipped_Part_Desc"/>,<xsl:value-of select="Line_Nr"/>,<xsl:value-of select="Part_Shipped"/>,<xsl:value-of select="Part_Ordered"/>,<xsl:value-of select="Scrap_Return"/>,<xsl:value-of select="Part_Refid"/>,<xsl:value-of select="Fail_Code"/>,<xsl:value-of select="Cru_Tier_Value"/>
</xsl:template>

<xsl:template match="Parts_Info_T">
<xsl:value-of select="Status"/>,<xsl:value-of select="Service"/>,<xsl:value-of select="Shipped_Part_Desc"/>,<xsl:value-of select="Line_Nr"/>,<xsl:value-of select="Part_Shipped"/>,<xsl:value-of select="Part_Ordered"/>,<xsl:value-of select="Scrap_Return"/>,<xsl:value-of select="Part_Refid"/>,<xsl:value-of select="Fail_Code"/>,<xsl:value-of select="Cru_Tier_Value"/>
</xsl:template>


</xsl:stylesheet>

I couldn't get the right CSV output from the above code so far.

Thanks for advise.

Kent