Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

XSLT When condition for multiple OR condition

Currently, I have a working version of below code which check if first or second entry from input payload meets the condition. How can I make changes if I need to check for multiple entries instead of adding many OR conditions (i.e: [3], [4], [5]….etc) ?

<xsl:choose>
    <xsl:when test="(wd:Entry[1]/wd:Item = 'ABC' or wd:Entry[2]/wd:Item/@wd:Descriptor = 'ABC')">
        <wd:Type_Reference>
            <wd:ID wd:type="Type_ID">DEF</wd:ID>
        </wd:Type_Reference>
    </xsl:when>
</xsl:choose>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

If you use e.g. wd:Entry/wd:Item = 'ABC' you are checking that at least one wd:Entry/wd:Item is equal to 'ABC'.

Similarly wd:Entry/wd:Item/@wd:Descriptor = 'ABC' would check that at least one wd:Entry/wd:Item/@wd:Descriptor attribute is equal to 'ABC'.

If you want to check a certain range, then, in XPath 2 and later, you can use e.g. wd:Entry[position() = (1 to 5)]/wd:Item = 'ABC'.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading