Page 1 of 1

XML - Zero output count

Posted: Mon Oct 13, 2008 9:38 am
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?

Re: XML - Zero output count

Posted: Mon Oct 13, 2008 10:00 am
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.

Posted: Mon Oct 13, 2008 10:10 am
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

Posted: Mon Oct 13, 2008 10:19 am
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.

Posted: Mon Oct 13, 2008 1:44 pm
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.

Posted: Tue Oct 14, 2008 3:15 am
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.