XML Output format help

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
reachsam11
Participant
Posts: 26
Joined: Wed Mar 17, 2010 11:05 am

XML Output format help

Post by reachsam11 »

The XML output when opened in a notepad has new line charactes in between the open and close tags as below.

<?xml version="1.0" encoding="UTF-8"?>
<customers xmlns="http://www.cust.org/Customers" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<customer id="0">
<name>
Porsche
</name>
<order number="1">
<product_code>
1
</product_code>
<quantity>
10
</quantity>
<unit_price>
10000
</unit_price>
</order>
</customer>
</customers>


I like the output to be as below - data in the same line as open and close tags.
<?xml version="1.0" encoding="UTF-8"?>
<customers xmlns="http://www.cust.org/Customers" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<customer id="0">
<name> Porsche</name>
<order number="1">
<product_code>1</product_code>
<quantity>10</quantity>
<unit_price>1000</unit_price>
</order>
</customer>
</customers>
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Code: Select all

sed -e "/<name>/{N;N;/<\/name>/s/\n//g;}" -e "/<product_code>/{N;N;/<\/product_code>/s/\n//g;}" -e "/<quantity>/{N;N;/<\/quantity>/s/\n//g;}" -e "/<unit_price>/{N;N;/<\/unit_price>/s/\n//g;}" file
You are the creator of your destiny - Swami Vivekananda
reachsam11
Participant
Posts: 26
Joined: Wed Mar 17, 2010 11:05 am

Post by reachsam11 »

Is it possible to acheive it with in Datastage XML output stage?
anbu wrote:

Code: Select all

sed -e "/<name>/{N;N;/<\/name>/s/\n//g;}" -e "/<product_code>/{N;N;/<\/product_code>/s/\n//g;}" -e "/<quantity>/{N;N;/<\/quantity>/s/\n//g;}" -e "/<unit_price>/{N;N;/<\/unit_price>/s/\n//g;}" file
ReachSam
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No. You've seen what DataStage considers "formatted" output and if that's not what you want you should not enable that option. Keep in mind that formatting like that is only for peoples and no XML reader will care or need any formatting, so most applications don't bother with it.

If somehow you think you really "need" that formatted or "pretty printed" output, that will need to be a separate step done post-generation outside of DataStage using 3rd party utilities.
Last edited by chulett on Fri Apr 30, 2010 7:25 am, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

...it wastes space. Open the document with a tool that understands XML. Generate formatted output ought to be removed or at least not be the default.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Post Reply