XML - Zero output count

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
myukassign
Premium Member
Premium Member
Posts: 238
Joined: Fri Jul 25, 2008 8:55 am

XML - Zero output count

Post by myukassign »

I have a requirement. I am using an XML input stage and using xslt to get some specific data from the xml and push to a flat file. Incase my xml don't have any tag which i want then the xml output link will give '0' recods and the remaining part of the job will pass through.

To handle this situvation what i did is, I wrote a after job subroutine in the transformer to check the number of records coming from the xml and if it is zero, the job will abort.

My routine will look like this

$INCLUDE DSINCLUDE JOBCONTROL.H

Result = DSGetLinkInfo (DSJ.ME, 'XML_Input_10', 'ABC', DSJ.LINKROWCOUNT)

ErrorCode=0

if Result =0 then
Call DSLogInfo('Job Failed as no valid record in source' : Result , "MyTransform")

ErrorCode = 1

end

.

Someone told me that, this method will impact the perfomance of the job. To work my idea the perfomance statistics should be always on or something liek that.

What is the truth here? Can I use this idea to abort a job incase my XML out put me zero records? Is there a better idea?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: XML - Zero output count

Post by chulett »

myukassign wrote:Someone told me that, this method will impact the perfomance of the job. To work my idea the perfomance statistics should be always on or something liek that.
No & No. There's no "performance impact" to checking a link count after job, if that is what you mean by "this method". And you don't need anything turned on for it to work.
-craig

"You can never have too many knives" -- Logan Nine Fingers
myukassign
Premium Member
Premium Member
Posts: 238
Joined: Fri Jul 25, 2008 8:55 am

Post by myukassign »

Thanks a Lot.

Let me add something to it.

What should be the best way to abort a job, incase the output link bring Zero record to me?

What is happening is incase the output link give me Zero records, everything go for a toss... No check is working with that link.

I would liek to get an easy way to abort a job incase the output link count is zero from an XMl stage.

My design is like this

Folder Stage -> XML input (with xslt) -> Transformer -> Flat file

I want the job abort when the output link from xml produce Zero count
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Do what you are doing, but in the after job routine check the Transformer and the link that writes to the Sequential stage rather than the XML stage.
-craig

"You can never have too many knives" -- Logan Nine Fingers
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post by throbinson »

Could you explain what function against the data is being performed in the XSLT that cannot be done in the Transformer against parsed XML fields? I'm curious.
myukassign
Premium Member
Premium Member
Posts: 238
Joined: Fri Jul 25, 2008 8:55 am

Post by myukassign »

Alrt... Here you go...

my XML look like this
------------------------
<ROOT>
<FILEINFO>
<NAME>MODELFILE</NAME>
<TYPE>XMLPLAIN</TYPE>
<REGION>EUROPE</REGION>
</FILEINFO>
<ADDS>
<ADD>
<PLACE> UK</PLACE>
</ADD>

</ADDS>
</ROOT>

my XSLT look like this
----------------------------

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<table>
<xsl:apply-templates select="/ROOT/FILEINFO"/>
</table>
</xsl:template>
<xsl:template match="/ROOT/FILEINFO">
<row>
<column name="NAME">
<xsl:value-of select="NAME/text()"/>
</column>
<column name="TYPE">
<xsl:value-of select="TYPE/text()"/>
</column>
<column name="REGION">
<xsl:value-of select="REGION/text()"/>
</column>
</row>
</xsl:template>
</xsl:stylesheet>

-------------------------------------------------

Imagine incase my input XML coming with out <FILEINFO> tag, what will happen is, the job will just pass with out aborting because, there is no valid data in xml. It won't do anything.
Post Reply