KSH - help needed for creating a script to generate xml file from text file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting KSH - help needed for creating a script to generate xml file from text file
# 1  
Old 06-21-2011
KSH - help needed for creating a script to generate xml file from text file


Dear Members,

I have a table in Oracle DB and one of its column name is INFO which has data in text format which we need to fetch in a script and create an xml file of a new table from the input.

The contents of a single cell of INFO column is like:
Code:
Area:app - aam
Clean Up Criteria:
Description:Dummy table for Automation scripts
Expected Num:Less then hundred rows
Life Cycle:Life Cycle - Undecided
Purpose:
Table Name:DUMMY_TABLE
Update Frequency:
------
Column Name:PK_REC_1
Comments:
Default Value:
Description:PK_REC_1
Domain Id:JOBREC
Life Cycle:
New Domain Ind:No
Not Null:Yes
Pk:Yes
Sub Action:New Attribute
------
Column Name:NOT_NULL_REC_1
Comments:
Default Value:
Description:NOT_NULL_REC_1
Domain Id:CUSTOMERID
Life Cycle:
New Domain Ind:No
Not Null:Yes
Pk:No
Sub Action:New Attribute
------
Column Name:NEW_COL_NO_CONST
Comments:
Default Value:
Description:NEW_COL_NO_CONST
Domain Id:GNYESNO
Life Cycle:
New Domain Ind:No
Not Null:No
Pk:No
Sub Action:New Attribute

So, we have to take the contents of this cell as input to the script and create an xml file from it in the following format:

Code:
<?xml version="1.0"?>
	<Table TabName="DUMMY_TABLE" TabAlias="dumtab" TabStructLastUpdDate="2011-06-21 08:18:13" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
		<TabMetaData>
			<TabBasics>
				<ExtendableInd>Yes</ExtendableInd>
				<TabArea>app/aam</TabArea>
				<TabStorageProfile>Medium</TabStorageProfile>
			</TabBasics>
			<TabDocs>
				<TabDescrip>Dummy table for Automation scripts</TabDescrip>
				<TabLifeCycle>Life Cycle - Undecided</TabLifeCycle>
			</TabDocs>
		</TabMetaData>
		<TabColumns>
			<Column ColName="PK_REC_1">
				<ColBasics>
					<ColType>
						<DmidRef RefName="JOBREC"/>
					</ColType>
					<Mandatory>true</Mandatory>
				</ColBasics>
				<ColDocs>
					<ColDescrip>PK_REC_1</ColDescrip>
				</ColDocs>
				<ColAuditData>
					<ColCreDate>2011-06-21</ColCreDate>
					<ColCreTime>08:16:46</ColCreTime>
					<CreatedByBB>cdom2foxgdd</CreatedByBB>
					<CreatedInVersion>88_0</CreatedInVersion>
					<ColSeqOrder>1</ColSeqOrder>
				</ColAuditData>
			</Column>
			<Column ColName="NOT_NULL_REC_1">
				<ColBasics>
					<ColType>
						<DmidRef RefName="CUSTOMERID"/>
					</ColType>
					<Mandatory>true</Mandatory>
				</ColBasics>
				<ColDocs>
					<ColDescrip>NOT_NULL_REC_1</ColDescrip>
				</ColDocs>
				<ColAuditData>
					<ColCreDate>2011-06-21</ColCreDate>
					<ColCreTime>08:17:45</ColCreTime>
					<CreatedByBB>cdom2foxgdd</CreatedByBB>
					<CreatedInVersion>88_0</CreatedInVersion>
					<ColSeqOrder>5</ColSeqOrder>
				</ColAuditData>
			</Column>
			<Column ColName="NEW_COL_NO_CONST">
				<ColBasics>
					<ColType>
						<DmidRef RefName="GNYESNO"/>
					</ColType>
				</ColBasics>
				<ColAuditData>
					<ColCreDate>2011-06-21</ColCreDate>
					<ColCreTime>08:18:02</ColCreTime>
					<CreatedByBB>cdom2foxgdd</CreatedByBB>
					<CreatedInVersion>88_0</CreatedInVersion>
					<ColSeqOrder>5</ColSeqOrder>
				</ColAuditData>
			</Column>
		</TabColumns>
		<TabConstraints>
			<TabPk PkName="DUMMY_TABLE_PK">
				<PkDeferStatus>Not Deferred</PkDeferStatus>
				<ColinPk ColRef="PK_REC_1"/>
			</TabPk>
		</TabConstraints>
		<TabUpgrd LastUpdDate="2011-06-21 08:18:12">
			<Upgrd CreDate="2011-06-21 08:18:07" UpdDate="2011-06-21 08:18:12" ModVer="88_0">
				<UpgrdCol ColRef="PK_REC_1" UpdDate="2011-06-21 08:18:07">
					<Type>Constant</Type>
					<Value>&apos;NULL&apos;</Value>
				</UpgrdCol>
				<UpgrdCol ColRef="NOT_NULL_REC_1" UpdDate="2011-06-21 08:18:12">
					<Type>Constant</Type>
					<Value>NULL</Value>
				</UpgrdCol>
			</Upgrd>
		</TabUpgrd>
	</Table>
<!--checkSum:3707227330-->

I see that in the above xml many tags are constant (like ColAuditData) and such a format can be repeated, but how are we supposed to add new column values for table and the subsequent values within tags.

Also, if we already have such an XML file created, how can we parse till the end of the file and add a new column if the need arises?

I am an amateur in scripting and will require a lot of help from you talented members.

Please help me understand the script too so that I can tweak it as and when the need arises.

Thank you!
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Programming

How to write in other language in text/xml file by reading english text/xml file using C++?

Hello Team, I have 2 files.one contains english text and another contains Japanese. so i have to read english text and replace the text with Japanesh text in third file. Basically, I need a help to write japanese language in text/xml file.I heard wstring does this.Not sure how do i write... (2 Replies)
Discussion started by: SA_Palani
2 Replies

2. Shell Programming and Scripting

Needed script to generate versions for a file and maintian them in a folder

need a shell script for the following requirement how to generate 5 versions of a file in a folder after generating them in a folder i want to maintian the past 2 versions of the file in the folder and i have to delete the the remaining. for example if i ran the script today and tommorow... (3 Replies)
Discussion started by: hemanthsaikumar
3 Replies

3. Shell Programming and Scripting

Needed script to FTP a File and generate a quality checksum file

hi all i want a script to FTP a file and should generate a quality checksum file means when I FTP a file from one server to another server it should generate a QC file which should contain timestamp,no.of records in that file Thanks in advance saikumar (3 Replies)
Discussion started by: hemanthsaikumar
3 Replies

4. Shell Programming and Scripting

KSH - XML file from Text file

Hello Members, I have to create a script to parse a text file in the following format: Increment By:1 Max Value:999999 Related Table: Dummy_table Related Table Column: dummy_id Sequence Name: dummy_table_1SQ Start With:1 and create an xml file from the above text file using KSH... (4 Replies)
Discussion started by: Yoodit
4 Replies

5. Shell Programming and Scripting

Generate a XML file from a text file

FILE-1 USER username@foo.com TOOLIN tool-a TOOL2 tool-b TOOL3 tool-c TOOL4 tool-d TOOL5 tool-e USER username_2@foo.com TOOLIN tool-e TOOL2 tool-f TOOL3 tool-c TOOL4 tool-d .... I need to take this file and generate a target XML file - <access> <managed> ... (3 Replies)
Discussion started by: jacki
3 Replies

6. Shell Programming and Scripting

Need help in creating a Unix Script to parse xml file

Hi All, My requirement is create an unix script to parse the xml file and display the values of the Elements/value between the tags on console. Like say, I would like to fetch the value of errorCode from the below xml which is 'U007' and display it. Can we use SED command for this? I have tried... (10 Replies)
Discussion started by: Anil.Wmg
10 Replies

7. UNIX for Dummies Questions & Answers

Script to generate text file from excel file

Hello, I have a excel file which has almost ten columns on the shared drive. I have to write a shell script to ftp that daily to unix server and then extract some columns from there and generate oracle standard text file. The columns should be in proper order and aligned properly, otherwise... (1 Reply)
Discussion started by: isingh786
1 Replies
Login or Register to Ask a Question