[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xslt 2 when test multiple conditions
Hi Phil, The <xsl:value-of> inside your bwhenb conditions do not consider whatever test might have preceded them; they are simply evaluated as-is when their bwhenb branch is followed. In your case, I suggest separating the selection of the record and the acquisition of the data from that record: <!-- get all records, with most preferred response first --> <xsl:variable name="sorted-records" as="element(records)*"> <xsl:perform-sort select="//records"> <xsl:sort select="contains(QuestionnaireQuestion/Questionnaire/QuestionnaireIdentifier, 'Safety_MedicalAE')" order="descending"/> </xsl:perform-sort> </xsl:variable> <!-- return first response (or empty value if no match) --> <xsl:value-of select="$sorted-records[1]/Response"/> The sort is a descending Boolean sort, which puts the true() evaluations first. Also, you are using <records> for the root element and for your data records. In my testing, I changed the root element to <root>. Depending on the granularity of your full data, you might change obtain and sort on a different element than <records>, adjusting the tests accordingly. * Chris From: LEGAULT, PHILLIP plegault@xxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: Saturday, August 19, 2023 10:41 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: xslt 2 when test multiple conditions Simple as I can get it <?xml version="1.0" encoding="UTF-8"?> <records> <Case_Responses> <records> <QuestionnaireQuestion> <DSMapping>Indication</DSMapping_GCC__c> <Questionnaire> <QuestionnaireIdentifier>Safety_MedicalAE Questionnaire</QuestionnaireIdentifier> </Questionnaire_GCC__r> </QuestionnaireQuestion> <Response>rash</Response> </records> <records> <QuestionnaireQuestion> <DSMapping>Indication</DSMapping> <Questionnaire> <QuestionnaireIdentifier>Safety_Medical_FULL Questionnaire</QuestionnaireIdentifier> </Questionnaire> </QuestionnaireQuestion> <Response>cough</Response> </records> </Case_Responses> </records> expected output: rash From: Chris Papademetrious chrispitude@xxxxxxxxx<mailto:chrispitude@xxxxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list-service@xxxxxxxxxxxx rytech.com>> Sent: Saturday, August 19, 2023 9:36 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: [EXTERNAL] Re: xslt 2 when test multiple conditions Hi Phil, What is the simplest input XML and expected output XML that describes your question, without using domain-specific elements (or at least not long complicated ones)? - Chris EasyUnsubscribe<https://urldefense.com/v3/__http:/lists.mulberrytech.com/unsu b/xsl-list/3514465__;!!A4F2R9G_pg!aWhAfS8HN45QUHeMMEL6jbvyohvELfGzTXI8zdboJOQ NOJC7Jk9ZYH1MNZqomu5u8fNNa5w7MFOxsEeUVmU2V_rZ-W1INpMdMiStI9_ZC3YSn6SKKyHo$> (by email) XSL-List info and archive<https://urldefense.com/v3/__http:/www.mulberrytech.com/xsl/xsl-list__ ;!!A4F2R9G_pg!aWhAfS8HN45QUHeMMEL6jbvyohvELfGzTXI8zdboJOQNOJC7Jk9ZYH1MNZqomu5 u8fNNa5w7MFOxsEeUVmU2V_rZ-W1INpMdMiStI9_ZC3YSnxHNCJE1$> EasyUnsubscribe<https://urldefense.com/v3/__http:/lists.mulberrytech.com/unsu b/xsl-list/3380743__;!!A4F2R9G_pg!aWhAfS8HN45QUHeMMEL6jbvyohvELfGzTXI8zdboJOQ NOJC7Jk9ZYH1MNZqomu5u8fNNa5w7MFOxsEeUVmU2V_rZ-W1INpMdMiStI9_ZC3YSn2J0KWQM$> (by email<>)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|