Having problems creating a xsl:when condition

Here should go questions about transforming XML with XSLT and FOP.
jmjarrett
Posts: 2
Joined: Thu Mar 30, 2006 6:51 pm

Having problems creating a xsl:when condition

Post 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?
jmjarrett
Posts: 2
Joined: Thu Mar 30, 2006 6:51 pm

Please ignore the error message.

Post 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.
Radu
Posts: 9053
Joined: Fri Jul 09, 2004 5:18 pm

Post 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.
jkmyoung
Posts: 89
Joined: Mon Mar 06, 2006 10:13 pm

Post 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)">
Post Reply