Page 1 of 1

Help with XML Output Stage

Posted: Tue Sep 06, 2011 6:59 am
by mac4rfree85
Hi Guys,

This is my first attempt at creating an XML file, though i have worked in parsing an XML file earlier.

My input file is as below

Code: Select all

TransactionID,TransactionLineNumber,StoreID,ScanType,PLUID
1030104,1,625,2,21155269
1030105,1,626,1,21155270
I want to convert it to XML stage as below.

Code: Select all

<Transaction>
 <TransactionID>1030104</TransactionID>
	<LineItemDetail>
                <TransactionLineNumber>1</TransactionLineNumber>
                <StoreID>625</StoreID>
                <ScanType>2</ScanType>
                <PLUID>21155269</PLUID>
	</LineItemDetail>
	<TransactionID>1030105</TransactionID>
	<LineItemDetail>
                <TransactionLineNumber>1</TransactionLineNumber>
                <StoreID>626</StoreID>
                <ScanType>1</ScanType>
                <PLUID>21155270</PLUID>
	</LineItemDetail>
</Transaction>
I am reading sequential file and passing it to XML output stage. In the derivation of Sequential stage, i am giving the XPATH expressions.
I have given TransactionID as trigger column. In output tab, i have defined a single column as Varchar(999999).
But it is throwing an error as

Code: Select all

The input rule does not map to any output rule
Can somebody help me with this.

Cheers!!!!

Posted: Tue Sep 06, 2011 7:05 am
by eostic
Import the document you have below via the xml metadata importer. Click only the inner most boxes (with the "T"). There should be five of them. Indicate TransactionLineNumber as a key. Load that tabledef into your input link.

Spend time searching thru other threads here concerning additional details of the stage, but that's the basics.

Ernie

Posted: Tue Sep 06, 2011 7:23 am
by mac4rfree85
I have saved the metadata using the XML Metadata Importer and marked TransactionLineNumber as key.
The Metadata had 5 columns with the same XPATH which i used before.
So, i used it in Output stage. But it is still getting aborted.

Posted: Tue Sep 06, 2011 7:34 am
by chulett
Why are you using a trigger column? Do you understand what that does?

Posted: Tue Sep 06, 2011 9:21 am
by eostic
For testing purposes, remove your output link. Put the xml document to a file.

Ernie

Posted: Tue Sep 06, 2011 11:58 pm
by mac4rfree85
@chulett,, yeah that did the trick... i made it as Aggregate into one column.
Now i am able to create the file for testing as told.
But i am not able to route it as Output.
In output, i have used the same metadata definition as defined in Input.

Also the file being created by XML Output stage is having CTRL+M in each of lines. how to rectify it. Below is my XML created by Output stage.

Code: Select all

<!--^M
  - Generated by Ascential Software Corporation, DataStage - XMLOutput stage - ^M
  - Wed Sep  7 04:17:37 2011^M
  -->^M
<Transaction>^M
  <TransactionID>^M
1030104^M
  </TransactionID>^M
  <LineItemDetail>^M
    <TransactionLineNumber>^M
1^M
    </TransactionLineNumber>^M
    <StoreID>^M
625^M
    </StoreID>^M
    <ScanType>^M
2^M
    </ScanType>^M
    <PLUID>^M
21155269^M
    </PLUID>^M
  </LineItemDetail>^M
</Transaction>^M
<Transaction>^M
  <TransactionID>^M
1030105^M
  </TransactionID>^M
  <LineItemDetail>^M
    <TransactionLineNumber>^M
1^M
    </TransactionLineNumber>^M
    <StoreID>^M
626^M
    </StoreID>^M
    <ScanType>^M
1^M
    </ScanType>^M
    <PLUID>^M
21155270^M
    </PLUID>^M
  </LineItemDetail>^M
</Transaction>^M

Posted: Wed Sep 07, 2011 5:54 am
by eostic
Not sure what you mean "unable to route it as output"...do you mean on an output link to a downstream stage? If so, just have a single column like "myXMLdocument" on the output link, with a long varchar as datatype and a single '/' in the Description property.

As for the formatting....unselect any/all formatting so that it goes out as a big long string...then open it in IE or other tool that knows XML.

Ernie

Posted: Wed Sep 07, 2011 7:15 am
by chulett
You get ^M characters on UNIX when you create a DOS output file.