How to divide the xml value in Datastage without xml input

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
pradeep_nov18
Participant
Posts: 92
Joined: Wed Mar 05, 2008 4:09 am
Location: chennai
Contact:

How to divide the xml value in Datastage without xml input

Post by pradeep_nov18 »

Hi,

My source record is as below:

<POLICY_COVERAGE_ROW><REPORT_DT>201302</REPORT_DT><POLICY_NO>130201LD01</POLICY_NO></POLICY_COVERAGE_ROW>

How do i generate pieline delimiter file only with tag value as shown below using datastage.

201302|130201LD01

Noted:I dont want to use Xml input stage to do that and tag can grow on demand

Thanks
pradeep.v
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Then you are firmly in the Camp Substring. You can use Index() to find the information that Substring() will need. What does "grow on demand" mean?
-craig

"You can never have too many knives" -- Logan Nine Fingers
pradeep_nov18
Participant
Posts: 92
Joined: Wed Mar 05, 2008 4:09 am
Location: chennai
Contact:

Xml

Post by pradeep_nov18 »

Hi Chulett,

It will cumbersome to write derivation for each tag,because we have more tags.

Noted:The only reason i opted to perform above because xml input stage requires XSD stored some where and results the warning stating "The primary document entity could not be opened".

Can u suggest what need to done for the below requirement to pick up tag values for below example.

<Head>
<Body><Value>a<Value></Body>
<Body><Value>a<Value></Body>
</Head>

if u can explain me the design and properties that should be followed will be a great help to achieve.

By the way "Can grow in demand" --Tags can be added in future in the same layout

Thanks
pradeep.v
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Xml

Post by chulett »

pradeep_nov18 wrote:Noted:The only reason i opted to perform above because xml input stage requires XSD stored some where and results the warning stating "The primary document entity could not be opened".
No, it doesn't. The new XML stage does but the older ones certainly do not require them. Leverage, yes, require... no.
pradeep_nov18 also wrote:It will cumbersome to write derivation for each tag,because we have more tags.
Then use the right tool for the job. Parsing XML? Use the XML stages.
pradeep_nov18 lastly wrote:By the way "Can grow in demand" --Tags can be added in future in the same layout
Meaning more of the same? Different elements? Not sure it really matters as the vendor adding new data elements would need to be coordinated. Perhaps Ernie can provide some specifics as to how something 'generic' could be done, perhaps via schema files? I'm not sure. You can certainly do all of this manually by locating and substring'ing out the parts you need but it does sound like a bit of a PITA. However, you can look for patterns that indicate the beginning of an element, then find the next end pattern and pull out whatever is between them. You can do this for both the element name and value then (I suppose) figure out what to do with it based on the name found - directig it to the proper field in the output link comes to mind.

Me, I'd still attempt to stick with the XML stages.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pradeep_nov18
Participant
Posts: 92
Joined: Wed Mar 05, 2008 4:09 am
Location: chennai
Contact:

Re: Xml

Post by pradeep_nov18 »

Hi Chulett,

Yeah your are right ,So going with experts words i have designed job ExternalSource--->Xmlinput---->Peak ,The job is succesful and providing me the acrute results.

Before i mark this post a resolved, Can you please share me how to handle rejected record in Xml Input stage to peek stage ,i have used all the option where we need to set for rejection but not happening

Noted : i have removed the open tag for validating the reject in the source file

Thanks
pradeep.v
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

For the first question, not much you can do if a new tag is entered...the code (which is one of the wonderful values of xml) will just continue to work, perfectly ignoring any new tags.

...or....you "could" create an xsd, and as Craig says, "leverage it" and have the Job abort or reject the content if a new tag arrives.

In order to just have it pipe delimit the new tag, you'd need another approach. The xml Stage lives on the metadata that you give it. A new tag is either (a) wrong or (b) should be ignored. Usually the Reject or Abort idea above with xsd validation is the way to go --- but beware...xsd validation in ANY tooling can be a costly process. Consider your volume.

As for reject, you declare an output link to be a "reject link". If the xml rejects based on a xsd violation, you can send the content and the message down the output link.

Ernie
Ernie Ostic

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