XML Input Stage

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
vick
Participant
Posts: 88
Joined: Sun Oct 30, 2005 2:06 am

XML Input Stage

Post by vick »

Hello

I have job design with Seq File stage (4 Columns) that reads an xml file and passes it to XML Inout stage.

[b]Source XML File: -
<artist> Bee Gees
<company>COLUMBIA</company>
<price>10</price>
<year>1985</year>
</artist>
<country>USA</country> [/b]

The target is Seq file stage with "|" demiliter.

I get an output that looks like this

[i][b]Bee Gees
|COLUMBIA|10|1985|USA|[/b][/i]

Any pointers on how I can organize this row in a single line.

TIA

vick
bchau
Charter Member
Charter Member
Posts: 46
Joined: Tue Jan 18, 2005 7:39 am
Location: Japan
Contact:

Post by bchau »

In your XML Input stage, what is your XPath Derivation in the Column propoerties? XPath Derivation is in last (right-most) item in the Column Properties.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Also known as the 'Description' field. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
gsym
Charter Member
Charter Member
Posts: 118
Joined: Thu Feb 02, 2006 3:05 pm

Post by gsym »

The XPath on the output/columns tab has the following

artist/text()

artist/company/text()

artist/company/price/text()

so on so forth...


I assume that the input/columns tab does'nt require an Xpath. Pl correct me.


The xml file file format is making the output format go awry.

I 'm using the TFR TRIM function but to no avail.

Appreciate responses
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

gsym wrote:I 'm using the TFR TRIM function but to no avail.
You might want to explain what this means. It looks like you may be picking up a <CR> in the artist element - do that mean you are trying to remove it? Post your derivation.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vick
Participant
Posts: 88
Joined: Sun Oct 30, 2005 2:06 am

Post by vick »

Craig

You got it. <CR> it is. But not able to fig out a eliminate the <CR>

The derivation of the source xml file
<artist>Bee Gees
<company>COLUMBIA</company>
<price>10</price>
<year>1985</year>
</artist>
<country>USA</country>


If I modify the derivation it works perfect. But I expect to get the file in above mentioned format and obviously I cant modify a mil of those.

TIA
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You might need to translate this into PX, but EReplace or Convert can do that for you:

Code: Select all

EReplace(YourField,CHAR(13),"")
Would replace each CR with an empty string, in essence removing it.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Curious... does this file come from a Windows system? If you view the file in vi and ":set list" does a ^M show up at the end of each line? If so, ensure the file is transferred to your UNIX server via an ASCII transfer to eliminate those as an issue.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vick
Participant
Posts: 88
Joined: Sun Oct 30, 2005 2:06 am

Post by vick »

Nope. This was not created from a windows system. A $ shows up @ the end and ^I @ the start.

I used the Convert fucntion [Convert (DSLink.artist, CHAR (13), "")but it removes the 1st line frm the record.

Original Output Record
Bee Gees
|COLUMBIA|10|1985|USA|

After the use of Convert Function

|COLUMBIA|10|1985|USA|
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That was EReplace syntax, the syntax for Convert is different:

Code: Select all

Convert(CHAR(13),"",DSLink.artist)
Try it that way and see if it helps.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vick
Participant
Posts: 88
Joined: Sun Oct 30, 2005 2:06 am

Post by vick »

Nope Craig. It does'nt. I tried CompactWhiteSpace and TrimLeadingTrailing functions but the result is same.

<CR> comes into picture coz of the XML input file derivation and needs to be eliminated.

Just thinking aloud if there's something else that could be used other than TFR.

Any pointers.

Thanks a bunch for the previous responses.
Post Reply