DSXchange: DataStage and IBM Websphere Data Integration Forum
View next topic
View previous topic
Add To Favorites
Author Message
adarsh shrinagesh



Group memberships:
Premium Members

Joined: 05 Feb 2005
Posts: 68
Location: India
Points: 611

Post Posted: Wed May 19, 2010 7:20 am Reply with quote    Back to top    

DataStage® Release: 7x
Job Type: Server
OS: Windows
Hello

While I am able to create a valid xml file sourced from a database table - i am not able to get the xml in the exact format required.

For ex: if the following are source records


Code:

Name   Age
Ad   1
Ak   2


I would like the output xml source code as

<student>
<Name> Ad</Name>
<Age>1</Age>
<Name> Ak</Name>
<Age>2</Age>
</student>

I would like the closing tags of the repeating elements in one single line as opposed to the output format I am currently being able to create using the xml output


<student>
<Name>
Ad
</Name>
<Age>
</Age>
<Name>
Ak
</Name>
<Age>
2
</Age>
</student>

Please advise.



[/code]
chulett

Premium Poster


since January 2006

Group memberships:
Premium Members, Inner Circle, Server to Parallel Transition Group

Joined: 12 Nov 2002
Posts: 43085
Location: Denver, CO
Points: 222463

Post Posted: Wed May 19, 2010 7:41 am Reply with quote    Back to top    

Why? Formatting is for peoples, no process you create this for will care. And you can always "pretty print" it yourself afterwards simply (one way) by opening it in something like IE. That's how the formatted output option in the stage works and looks - "turn it off" is my best advice here.

_________________
-craig

"You can never have too many knives" -- Logan Nine Fingers
Rate this response:  
Not yet rated
adarsh shrinagesh



Group memberships:
Premium Members

Joined: 05 Feb 2005
Posts: 68
Location: India
Points: 611

Post Posted: Wed May 19, 2010 7:56 am Reply with quote    Back to top    

chulett wrote:
Why? Formatting is for peoples, no process you create this for will care. And you can always "pretty print" it yourself afterwards simply (one way) by opening it in something like IE. That's how the formatted output option in the stage works and looks - "turn it off" is my best advice here.


Hello

Yes, I agree ... I am told however, that there is a downstream application designed to read this data based on the closing tags for a single field ( this is tool migration activity and the earlier product was able to create such a format).

The only other alternative albeit a "dirty" approach -I could think of is to create the tags ourselves in a transformer:
Ex:

Code:


"<":Extract columname:">":ColValue:"</":Extract columname:">"

Defeats the purpose of the XML stage though.

I tried turning the "formatting" off - however the output is freeform text - no line feeds whatsoever.
Rate this response:  
Not yet rated
chulett

Premium Poster


since January 2006

Group memberships:
Premium Members, Inner Circle, Server to Parallel Transition Group

Joined: 12 Nov 2002
Posts: 43085
Location: Denver, CO
Points: 222463

Post Posted: Wed May 19, 2010 10:48 am Reply with quote    Back to top    

That's not "free form" that's proper "xml form"... one big string. I'd be curious what Ernie thinks when he gets a chance to drop by but any process that requires specific XML formatting to work is a poorly designed one. IMHO, of course.

Yes, you can go all Old Skool and do all the tags yourself. Make sure you also account for anything in the data that would need to made "safe" as well like angle brackets or ampersands. My advice still stands: turn off formatting, generate it without any formatting and then use another process (i.e. not DataStage, some command line utility that DataStage runs after job... there are typically plenty to choose from or you can 'roll yer own' should you so desire) post-creation to "pretty print" it... if that's really what you need.

_________________
-craig

"You can never have too many knives" -- Logan Nine Fingers
Rate this response:  
Not yet rated
eostic

Premium Poster



Group memberships:
Premium Members

Joined: 17 Oct 2005
Posts: 3836

Points: 30974

Post Posted: Thu May 20, 2010 12:33 am Reply with quote    Back to top    

Yeah.....you still see this sort of thing every once in awhile.....usually it's with tools that were written when XML was new --- someone insisted back then on having xml in the "model", but formal xml api's weren't used in the code, or the skills weren't there, etc.

....if the xml node is small, then I'd just do it in the Transformer and build it however I need it......if the xml is many more columns, consider building it as an unformatted document (less space) and then pass it right back into xml output and parse it however you need......

....for example, wrap your name and age with another element, such as "person"..... .../person/name/text() and .../person/age/text() ....and then, in a followup downstream xmlInput Stage, just have a single column called Person (varchar, length of say, 20), and use this: .../person/ (don't put in the text() ).........

...now you will have columns whose value is the full tag of name and age <name>fred</name><age>24</age> and can do whatever you want with it.....send it to a sequential file, etc.

Might take further massaging after that, but you get the idea....

Ernie

_________________
Ernie Ostic

blogit!
Open IGC is Here!
Rate this response:  
Not yet rated
frolen
Participant



Joined: 22 Feb 2020
Posts: 11

Points: 93

Post Posted: Thu Aug 20, 2020 8:05 am Reply with quote    Back to top    

Why?
Rate this response:  
Not yet rated
ray.wurlod

Premium Poster
Participant

Group memberships:
Premium Members, Inner Circle, Australia Usergroup, Server to Parallel Transition Group

Joined: 23 Oct 2002
Posts: 54595
Location: Sydney, Australia
Points: 296053

Post Posted: Thu Oct 08, 2020 10:48 am Reply with quote    Back to top    

frolen wrote:
Why?
Because.

_________________
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Rate this response:  
Not yet rated
Display posts from previous:       

Add To Favorites
View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2002 phpBB Group
Theme & Graphics by Daz :: Portal by Smartor
All times are GMT - 6 Hours