cancel
Showing results for 
Search instead for 
Did you mean: 

Global Variable or Container

Former Member
0 Kudos

Hi Gurus,

For me there is a requirement that is in XSLT mapping, I have to count the number of records based on certain conditions in a for loop .

I think using varibales in XSLT it cant be achevied,

I thought of calling a java function using GlobalContainer but not able to count the records .

I am able to see examples using UDF in forums But not by using XSLT

Please can any one help to solve this issue

Rams

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I also think you should be able to achieve your goal in a UDF function, but in any case the xslt element that you could investigate is

<xslt:number count="xpath">

where <i>xpath</i> is an XPath expression that specifies what nodes are to be counted.

You can find more information <a href="http://www.w3schools.com/xsl/el_number.asp">here</a>.

best,

Daniele

Former Member
0 Kudos

hi Daniele,

I can use count if it direct but I need to compare 2 nodes in that the records those satisify the condition should be counted

say example

<xsl:value-of select="count(ns0:Source/row/Age[text() = ns0:Source/row/Name[text()]])"/>

but not able to get the result

if i hard code i am able to

<xsl:value-of select="count(ns0:Source/row/Age[text() = 10)"/>

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

>>>I thought of calling a java function using GlobalContainer but not able to count the records .

don't use GlobalContainer - just use globa variable and you'll be able to do it easily

BTW

you're function needs to be type - queue if you want to cound all lines etc

Regards,

michal

-


<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

Former Member
0 Kudos

hi michal ,

Please can you brief it, see i am using XSLT mapping.

the way I tried is I try to call the java function like this from XSLT ....

-


XSLT----


<xsl:if test="function-available('ChkCounter:addCounter')">

<xsl:value-of select="ChkCounter:addCounter()" />

</xsl:if>

-


JAVA----


public static String addCounter()

{

GlobalContainer gc = container.getGlobalContainer();

Object o =gc.getParameter("counter");

try{

Integer i;

if(o==null) i = new Integer(0);

else

i = (Integer)o;

i = new Integer(i.intValue() + 1);

gc.setParameter("counter",i);

-


another way I tried was in XSLT itself

<xsl:value-of select="count(ns0:Source/row/field1[text() = ns0:Source/row/field2[text()]])"/>

-


Can u please guide me in specific

thanks

rams