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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Plz Help To convert xml file to text file using bourn shell scripts
# 1  
Old 11-09-2005
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>
</header_rec>

<detail_rec recordtype="01">
<record_id_01>01</drecord_id>
<country_code_01>AK</country_code>
</detail_rec>

<detail_rec rectyp_2="10">
<record_id>10</record_id>
<country_code>AK</country_code>
<fax>4567677</fax>
</detail_rec>

<trailer_rec recordtype="99">
<record_id>99</record_id>
</trailer_rec>

</root>





My File Test.txt


00AK112005-08-15 (record type=00)(fixed lengths -->recordid:1-2 -->countrycode:5-7


012005-65AK2005-08-15 (record type=01)
012005-65AK2005-08-15 (record type=01)
012005-65AK2005-08-15 (record type=02)
012005-65AK2005-08-15 (record type=02)

99AK11392005-08-+0000424 (record type=99))




I can't use whitespace as a delimiter.


Thanks you guys very much,
I really appreciate it.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 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

Read csv file, convert the data and make one text file in UNIX shell scripting

I have input data looks like this which is a part of a csv file 7,1265,76548,"0102:04" 8,1266,76545,"0112:04" I need to make the output data should look like this and the output data will be part of text file: 7|1265000 |7654899 |A| 8|12660000 |76545999 |B| The logic behind the... (6 Replies)
Discussion started by: RJG
6 Replies

3. Shell Programming and Scripting

Need help to write a shell script to convert text file to excel file.

Hi Everyone, I want your help to write a script which will take text file as input and on the basis of delimiter ":"script will create excel sheet. Example input: IpAdress:InstanceName:Port:ServerName 10.255.255.1:abc:2232:xyz_abc Output should be an excel sheet like below: Column... (8 Replies)
Discussion started by: akabhinav18
8 Replies

4. 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

5. Shell Programming and Scripting

How to convert xml file to text file?

Hi Everyone, I want to convert 1 xml file to text file.... Please help in the xml file i have 4 columns.... Thanks a lot in advance. Nilesh (6 Replies)
Discussion started by: nileshbhawsar
6 Replies

6. Shell Programming and Scripting

Convert XML to Data File in Shell Script

Hi All, I will be getting a huge XML file with a lot of records in it. I need to convert it into multiple data files. SAMPLE XML FILE <ABSProductCatalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <ProductSalesHierachy> - <Portfolios> - <Portfolio productCode="P1"> ... (8 Replies)
Discussion started by: ragha81
8 Replies

7. 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

8. 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

9. Shell Programming and Scripting

Converting Text File into XML using Unix Shell Scripts

Hi everyone, If someone out there could help me out with this problem. I would really appreciate it. I am trying to convert a file into xml format using Unix shell scripts. The file has fields with each field having a certain number of bytes, but the fields are not delimited by anything... (10 Replies)
Discussion started by: Laud12345
10 Replies
Login or Register to Ask a Question
XMLTO(1)							       xmlto								  XMLTO(1)

NAME
xmlto - apply an XSL stylesheet to an XML document SYNOPSIS
xmlto [-o output_dir] [-x custom_xsl] [-m xsl_fragment] [-v] [-p postprocessor_opts] [--extensions] [--searchpath path] [--skip-validation] {format} {file} xmlto {--help | --version} DESCRIPTION
The purpose of xmlto is to convert an XML file to the desired format using whatever means necessary. This may involve two steps: 1. The application of an appropriate XSL stylesheet using an XSL-T processor. 2. Further processing with other tools. This step may not be necessary. To decide which stylesheet to use and what, if any, needs to be done to post-process the output, xmlto makes use of format scripts, which are simple shell scripts that xmlto calls during the conversion. The appropriate format script is selected based on the type of XML file and the desired output format. xmlto comes with some format scripts for converting DocBook XML files to a variety of formats. You may specify your own format script by using an absolute filename for format on the command line. Firstly, if xmlto has not been told explicitly which stylesheet to use (with the -x option), the format script will be called with $1 set to stylesheet. The environment variable XSLT_PROCESSOR contains the base name of the executable that will be used to perform the XSL-T transformation (for example xsltproc), and the environment variable XSL_DIR contains the path to the directory containing some useful stylesheets that come with xmlto. The format script should write the name of the stylesheet to use to standard output and exit success- fully, or exit with a non-zero return code if there is no appropriate stylesheet to use (for example, if the only available stylesheet is known not to work with the XSL-T processor that will be used). If nothing is written to standard output but the script exits successfully, no XSL-T transformation will be performed. Secondly, after an XSL-T processor has been run using the stylesheet, the format script will be called again, this time with $1 set to post-process. The format script should perform any necessary steps to translate the XSL-T processed output into the desired output format, including copying the output to the desired output directory. For post-processing, the format script is run in a temporary directory con- taining just the processed output (whose name is stored in XSLT_PROCESSED and whose basename is that of the original XML file with any filename extension replaced with .proc). INPUT_FILE is set to the name of the original XML file, OUTPUT_DIR is set to the name of the directory that the output (and only the output) must end up in, and SEARCHPATH is set to a colon-separate list of fallback directories in which to look for input (for images, for example). If this step is unsuccessful the format script should exit with a non-zero return code. -v Be verbose (-vv for very verbose). -x stylesheet Use stylesheet instead of asking the format script to choose one. -m fragment Use the provided XSL fragment to modify the stylesheet. -o directory Put output in the specified directory instead of the current working directory. -p postprocessor_opts Pass postprocessor_opts to processing stages after stylesheet application (e.g. lynx or links when going through HTML to text, or xmltex when going from through TeX to DVI). If -p is specified a second time, the options specified will be passed to second-stage postprocessing; presently this is only applicable when going through xmltex and dvips to PostScript. --extensions Turn on stylesheet extensions for the tool chain in use (for example, this might turn on passivetex.extensions and use.extensions if PassiveTeX is being used). The variables turned on are the ones used by Norman Walsh's DocBook XSL stylesheets. --searchpath path Add the colon-separated list of directories in path as fallback directories for including input. --skip-validation Skip the validation step that is normally performed. --help Display a short usage message. It will describe xmlto's options, and the available output formats. --version Display the version number of xmlto. EXAMPLES
To convert a DocBook XML document to PDF, use: xmlto pdf mydoc.xml To convert a DocBook XML document to HTML and store the resulting HTML files in a separate directory use: xmlto -o html-dir html mydoc.xml To convert a DocBook XML document to a single HTML file use: xmlto html-nochunks mydoc.xml To modify the output using an XSL fragment use: xmlto -m ulink.xsl pdf mydoc.xml To specify which stylesheet to use (overriding the one that the format script would choose) use: xmlto -x mystylesheet.xsl pdf mydoc.xml AUTHOR
Tim Waugh <twaugh@redhat.com>. Linux October 2002 XMLTO(1)