Sponsored Content
Top Forums Shell Programming and Scripting KSH - XML file from Text file Post 302535588 by aigles on Friday 1st of July 2011 07:50:44 AM
Old 07-01-2011
You can do something like that :
Code:
nawk -F': *' '
$1=="Increment By"          { Inc = $2; next }
$1=="Max Value"             { Max = $2; next }
$1=="Related Table"         { Tbl = $2; next }
$1=="Related Table Column"  { Col = $2; next }
$1=="Sequence Name"         { Seq = $2; next }
$1=="Start With"            { Sta = $2; next }
END {
    fmt =     "<?xml version=\"1.0\"?>\n";
    fmt = fmt "\t<Sequence SeqName=\"%s\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
    fmt = fmt "\t\t<SeqArea>appl/misc</SeqArea>\n";
    fmt = fmt "\t\t<SeqData>\n";
    fmt = fmt "\t\t\t<IncrementValue>%s</IncrementValue>\n";
    fmt = fmt "\t\t\t<MaximumValue>%s</MaximumValue>\n";
    fmt = fmt "\t\t\t<StartValue>%s</StartValue>\n";
    fmt = fmt "\t\t</SeqData>\n";
    fmt = fmt "\t\t<SeqDocs>\n";
    fmt = fmt "\t\t\t<SeqDesc>some description.</SeqDesc>\n"
    fmt = fmt "\t\t</SeqDocs>\n";
    fmt = fmt "\t\t<UseColumn TabName=\"%s\" ColName=\"%s\"/>\n";
    fmt = fmt "\t</Sequence>\n";
    printf fmt, Seq, Inc, Max, Sta, toupper(Tbl), toupper(Col);
}

' inputfile

Inputfile:
Code:
#Begin
Increment By:1
Max Value:999999
Related Table: Dummy_table
Related Table Column: dummy_id
Sequence Name: dummy_table_1SQ
Start With:1
#End

Output:
Code:
<?xml version="1.0"?>
        <Sequence SeqName="dummy_table_1SQ" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <SeqArea>appl/misc</SeqArea>
                <SeqData>
                        <IncrementValue>1</IncrementValue>
                        <MaximumValue>999999</MaximumValue>
                        <StartValue>1</StartValue>
                </SeqData>
                <SeqDocs>
                        <SeqDesc>some description.</SeqDesc>
                </SeqDocs>
                <UseColumn TabName="DUMMY_TABLE" ColName="DUMMY_ID"/>
        </Sequence>

Jean-Pierre.
This User Gave Thanks to aigles For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

convert XML file into Text file(fixed length)

If someone out there could help me out with this problem. I would really appreciate it. I am trying to convert xml into text file(fixed length) using Unix Borne shell scripts. My xml file: <root> <header_rec recordtype="00"> <record_id>00</record_id> ... (0 Replies)
Discussion started by: ram2s2001
0 Replies

2. Shell Programming and Scripting

Plz Help To convert xml file to text file using bourn shell scripts

If someone out there could help me out with this problem. I would really appreciate it. I am trying to convert xml into text file(fixed length) using Unix Borne shell scripts. My xml file: <root> <header_rec recordtype="00"> <record_id>00</record_id> <country_code>AK></country_code>... (0 Replies)
Discussion started by: ram2s2001
0 Replies

3. Shell Programming and Scripting

Convert XML file into TEXT file using PERL seript

Dear Yogesh..."Convert XML file into TEXT file using PERL seript"... can u help me regarding this issue...plz Thanks Rudro (0 Replies)
Discussion started by: Rudro
0 Replies

4. Shell Programming and Scripting

KSH Script to Get the <TAG Values> from an XML file

Hi All, I am new to Unix I need a KSH script to get the values from XML file to write to a temp file. Like the requirement is from the below TAG <MAPPING DESCRIPTION ="Test Mapping" ISVALID ="YES" NAME ="m_test_xml" OBJECTVERSION ="1" VERSIONNUMBER ="1"> I need the MAPPING DESCRIPTION... (3 Replies)
Discussion started by: perlamohan
3 Replies

5. Shell Programming and Scripting

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: Area:app - aam Clean Up Criteria:... (0 Replies)
Discussion started by: Yoodit
0 Replies

6. Shell Programming and Scripting

Filter a .kml file (xml) with data set from text file

I have a .kml file. So I want filter the .kml to get only the tags that have this numeric codes that they are in a text file 11951 11952 74014 11964 11965 11969 11970 11971 11972 60149 74018 74023 86378 11976 11980 11983 11984 11987 (5 Replies)
Discussion started by: pcoj33
5 Replies

7. UNIX for Dummies Questions & Answers

Reading XML file and print the values in the text file using Linux shell script

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (1 Reply)
Discussion started by: sravanreddy
1 Replies

8. UNIX for Dummies Questions & Answers

Reading Xml file and print the values into the text file in columnwise?

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (4 Replies)
Discussion started by: sravanreddy
4 Replies

9. 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
NUMFMT_GET_ERROR_MESSAGE(3)						 1					       NUMFMT_GET_ERROR_MESSAGE(3)

NumberFormatter::getErrorMessage - Get formatter's last error message.

	Object oriented style

SYNOPSIS
public string NumberFormatter::getErrorMessage (void ) DESCRIPTION
Procedural style string numfmt_get_error_message (NumberFormatter $fmt) Get error message from the last function performed by the formatter. PARAMETERS
o $fmt -NumberFormatter object. RETURN VALUES
Returns error message from last formatter call. EXAMPLES
Example #1 numfmt_get_error_message(3) example <?php $fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL ); $data = numfmt_format($fmt, 1234567.891234567890000); if(intl_is_failure(numfmt_get_error_code($fmt))) { report_error("Formatter error"); } ?> Example #2 OO example <?php $fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL ); $fmt->format(1234567.891234567890000); if(intl_is_failure($fmt->getErrorCode())) { report_error("Formatter error"); } ?> SEE ALSO
numfmt_get_error_code(3), intl_get_error_code(3), intl_is_failure(3). PHP Documentation Group NUMFMT_GET_ERROR_MESSAGE(3)
All times are GMT -4. The time now is 11:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy