Page 1 of 1

Having problems creating a xsl:when condition

Posted: Thu Mar 30, 2006 11:49 pm
by jmjarrett
What I am trying to accomplish is determine that the copiedItemRecKey is not empty and also determine whether the value in copiedItemRecKey exists in any other items by checking the value in the primaryKey of all the other items. If the node count is greater than zero then one of the items has the same key as the copiedItemRecKey.

The context when this is called is /SendRfqDto/scenariosToBeShopped/SpecialInquiryScenarioDto/itemDtos/SpecialItemDto/specialItem

<xsl:when test="(not(normalize-space(copiedItemRecKey) = '')) and (count(/SendRfqDto/scenariosToBeShopped//SpecialInquiryScenarioDto/itemDtos/SpecialItemDto/specialItem[primaryKey] = copiedItemRecKey) > 0)">

do something...

</xsl:when>

It is not working however...obviously I'm new to xsl and could be doing this completely wrong without knowing it.

Oxygen reports when I run the transform:

SystemID: /Users/mjarrett/Desktop/PreviewSpecialInquiryRFQ-new.xsl
Location: 465:0
Description: Can not convert #BOOLEAN to a NodeList!

Does anyone have any suggestions to accomplish what I'm trying to do?

Please ignore the error message.

Posted: Mon Apr 03, 2006 11:54 pm
by jmjarrett
Please ignore the error message. I probably shouldn't have put it in the original post. I have gotten at least a dozen different errors while trying out different combinations of xpath expressions.

What I am really wanting is someone to tell me if what I am trying to do is impossible using XSL. One of the people I talked to here at work said he didn't think XSL could be used for this level of evaluation and I should be doing everything in Java. Is he right?

I'll be happy to post more info if it is needed. I'd hate to give up at this point when I'm so close to finishing. This is the only evaluation which isn't working the way I need it to.

Thanks in advance.

Posted: Tue Apr 04, 2006 8:25 am
by Radu
Hi,

Sorry for the delay.
I think the best you could do would be to post a small, cut-down, sample of the XML file you are trying to process and then describe in your own words what you are trying to achieve with the stylesheet.

Regards, Radu.

Posted: Thu Apr 06, 2006 9:29 pm
by jkmyoung
Entire condition should be in the brackets..
otherwise you're only taking one node, comparing to copiedItemRecKey, and then trying to count if it matched or not.

moved the ']'

<xsl:when test="(not(normalize-space(copiedItemRecKey) = '')) and (count(/SendRfqDto/scenariosToBeShopped//SpecialInquiryScenarioDto/itemDtos/SpecialItemDto/specialItem[primaryKey = copiedItemRecKey]) > 0)">