Sponsored Content
Top Forums Shell Programming and Scripting Generating XML from a flatfile Post 302665815 by ianmrid on Tuesday 3rd of July 2012 08:19:57 AM
Old 07-03-2012
Generating XML from a flatfile

Hi all,

I am trying to generate an XML file from a flatfile in ksh/bash (could also use perl at a pinch, but out of my depth there!).

I have found several good solutions on this very forum for cases where the header line in the file forms the XML tags, however my flatfile is as follows:
Code:
Object,Type
Table1,Tables
Table2,Tables
Table3,Tables
View1,Views
View2,Views
Proc1,Procs
Proc2,Procs

And I want to create the following:

Code:
<Whatever>
 <Tables>
    Table1
    Table2
    Table3
 </Tables>
 <Views>
    View1
    View2
 </Views>
 <Procs>
    Proc1
    Proc2
 </Procs>
</Whatever>

So I essentially want the data to be segregated by one of the data columns in the flatfile, rather than just a more straightforward 'header becomes a tag' scenario.

All pointers much appreciated!

*Edit*


Although the data should always be in sequence of the different types, I would be interested to see if it could handle:

Code:
Object,Type
Table1,Tables
Proc1,Procs
View1,Views
Table2,Tables
Table3,Tables
View2,Views
Proc2,Procs

Thanks,
Ian

Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by ianmrid; 07-03-2012 at 09:41 AM.. Reason: Please use code tags for data and code samples, thank you
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Finding a column in a flatfile

I have a file which is fixed width columns. This is an offset buffer - rather than space or tab delimited. There are upto about 8 columns and I need to get all of the column 5's values into another file. The problem is that because the delimiter is a space - and some fields are blank - the 5th... (3 Replies)
Discussion started by: peter.herlihy
3 Replies

2. UNIX for Dummies Questions & Answers

encrypting Unix flatfile

Hi, I am new to unix. I have a flat file that needs to be pgp encyrpted in ASCII format and ftped in Ascii format to remote location. Can any one tell me the steps involved in the pgp encryption of the unix file. I will really appreciate if any one can help me with the pgp encryption shell... (1 Reply)
Discussion started by: rkumar28
1 Replies

3. Shell Programming and Scripting

Traverse a flatfile and check for errors

Hi, I need to check a flatfile for various parameters like length of the record, format of record, any tab character present in the record etc., for checking presence of tab character, i'm trying to use the following code and i'm not sure if the same is right. Pls Help. nawk '{print... (1 Reply)
Discussion started by: aravindc
1 Replies

4. Shell Programming and Scripting

Deleting column from a flatfile with delimiter

I have a set of flatfiles which have columns delimited by #. How can a particular column be deleted in all the flatfiles. All flatfiles have same number of columns. (5 Replies)
Discussion started by: rsprabha
5 Replies

5. UNIX for Advanced & Expert Users

Generating XML from XSD

Hi all, Am looking for a way to generate XML based on XSDs so that the final XML need not be validated against the XSDs again. Here is the part of the XSD <xsd:element name="first_element"> <xsd:complexType> <xsd:sequence> <xsd:element name="val"/> </xsd:sequence> ... (0 Replies)
Discussion started by: matrixmadhan
0 Replies

6. Shell Programming and Scripting

Generating an xml having information related to files in the directory

Hi all, Have to generate an xml having information related to files in the directory Suppose i have file file1.xml (datafile) file2.xml (datafile) file3.xml (metafile) Now i need to generate an xml in the format >> <?xml version="1.0" encoding="UTF-8"?> <AuditFile Version="2.0">... (8 Replies)
Discussion started by: abhinav192
8 Replies

7. UNIX for Advanced & Expert Users

Delimeters Count in a FlatFile

Hi, I have the below script to check the count of delimeters for a file (here is File : test.csv Delimeter is ",") awk '{gsub(/"*"/,x);print gsub(/,/,x)}' test.csv And it return the output for each line as: 2 2 cat test.csv: abc,xyz "abc,zxyz",1 I need help one the below things: - IS... (8 Replies)
Discussion started by: venkatajay_18
8 Replies

8. Shell Programming and Scripting

sending output to flatfile

Hi, I am writing one unix script to get row count of few tables into one sequential file my script is like this $ORACLE_HOME/bin/sqlplus -s <<EOF >output.txt userid/password@databasename set verify off set heading off set feedback off select count(*) count from tablel where ; select... (4 Replies)
Discussion started by: spmsarada
4 Replies

9. Shell Programming and Scripting

Parsing a mixed format (flatfile+xml) logfile

I am trying to parse a file that looks like the below: There are thousands of lines like the above and the file is expected to run into hundreds of thousands. The issue i have is the mixed format of the file. If it was just an xmlfile, i would use an xmllint to parse the file. Now, i am... (11 Replies)
Discussion started by: goddevil
11 Replies

10. Shell Programming and Scripting

Generating xml file from UNIX

i have a unix script which generates the csv file. the data in csv file is dynamic. how can i convert/move the data from csv file to xml. please suggest (1 Reply)
Discussion started by: archana25
1 Replies
docb_gen(3erl)						     Erlang Module Definition						    docb_gen(3erl)

NAME
docb_gen - Generate XML from EDoc comments in Erlang source code. DESCRIPTION
docb_gen contains functions for generating XML documentation source code according to the erlref or chapter DTD from EDoc comments in Erlang source code or an overview.edoc file, using EDoc. EXPORTS
module(File) -> ok | {error, Reason} module(File, Options) -> ok | {error, Reason} Types File = string() Options = [Opt] Opt = {def,Defs} | {includes,Dirs} | {preprocess,Bool} | {sort_functions,Bool} Defs = [{atom(),string()}] Dirs = [string()] Bool = bool() Reason = badfile | {badopt,term()} | term() Generates XML documentation source code according to the erlref DTD from EDoc comments File , using the EDoc application. File is an Erlang source file, given with or without the .erl extension as Name.erl or Name . The resulting XML file is created in the current working directory and named Name.xml . Options is a list of options, see below. Returns ok if successful, and an error tuple otherwise. users_guide(File) -> ok | {error, Reason} users_guide(File, Options) -> ok | {error, Reason} Types File -- see module/1,2 Options -- see module/1,2 Reason -- see module/1,2 Like module/1,2 but generates XML source code according to the chapter DTD from an overview.edoc or similar file. The resulting file is named chapter.xml . OPTIONS
{def, [{Name,Text}]} : Specifies EDoc macro definitions. See edoc:get_doc/2 . {includes, [Dir]} : Specifies directories where EDoc should search for include files. See edoc:read_source/2 . {preprocess, true|false} : Specifies if EDoc should read the source file via the Erlang preprocessor. Default is false . See edoc:read_source/2 . {sort_functions, true|false} : Specifies if the functions in the resulting XML file should be sorted alphabetically. Default is true . LIMITATIONS
The mapping from the EDoc XHTML output to valid Erlang/OTP XML is not complete. An attempt has been made to cover the most commonly used XHTML constructs, but there will still be cases where XML generation fails or where the resulting XML is inadequate. This is especially true for users_guide/1,2 . Known limitations for some XHTML tags: <a> : All attributes except the first href or name attribute are ignored. A href attribute means the <a> tag will be transformed to a <seealso> or <url> tag and an attempt is made to resolve the reference if necessary. A name attribute means the <a> tag will be transformed to a <marker> tag. <b>, <em>, <pre> : Cannot contain other tags in Erlang/OTP XML, content is converted to plain text. <center> : No corresponding Erlang/OTP XML tag, converted to plain text. <font> : No corresponding Erlang/OTP XML tag, converted to plain text. <h1>, <h2>, ... : There is no tag corresponding to a header in Erlang/OTP XML, so these are converted to plain text instead, with the exception of <h3> and <h4> tags within overview.edoc , see part about " chapter DTD" below. <sup> : There is no tag corresponding to superscript in Erlang/OTP XML, so this is converted to plain text within brackets "(..)". References : The markers automatically inserted by EDoc at each heading and function will override the markers automatically inserted by DocBuilder, with the unfortunate result that the links in the left-hand frame of the User's Guide will not work, and also that cross referencing a function in a module the usual Erlang/OTP way " <seealso marker="edoc:edoc#run/3...> " does not work. (But " <seealso marker="edoc:edoc#run-3...> " does.) erlref DTD Tables : Tables are not allowed. The contents of a table is converted to text instead, each row corresponding to one line of text. chapter DTD Sections : Only two levels of sections. <h3> (equivalent to EDoc headings " == Heading == ") is interpreted as start of top-level section, or if there is no <h3> tag, the entire document is made into one top-level section. <h4> (equivalent to EDoc sub-headings (" === Sub-heading === ") is interpreted as start of second-level section. Tables : Tables without borders are converted to text in the same manner as for the erlref DTD. Ericsson AB docbuilder 0.9.8.9 docb_gen(3erl)
All times are GMT -4. The time now is 02:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy