XQuery IF THEN ELSE in CSS oxy_xpath
Posted: Tue Aug 15, 2023 11:57 pm
I'm attempting to use the "oxy_xpath" functionality in CSS with an XQuery that retrieves the list item target of a cross-reference and outputs the list item number in a format that reflects the list type. I have everything working as desired except for the series of IF THEN ELSE statements and I can't get even one of those to work. So this is basically what I want in the CSS rule xpath:
Somewhere in that there's a syntax error that I can't identify (not experienced in XQuery). Apart from that the three variables ($targetID, $myTargetList-Item, and $myTargetList-Type all work as expected; the formatting of the calculated integer works correctly. But I can't get the IF THEN ELSE correct, must less the additional ones I'll need to additional list types.
Any help pointing me in the right direction will be greatly appreciated. I'm pasting a sample XML doc below for reference.
Code: Select all
INTXREF[DEST = "LST-ITM"]{
content: oxy_xpath("let\
$targetID := @REFID,\
$myTargetList-Item := /descendant::LIST/LST-ITM[@ID = $targetID]/@ID,\
$myTargetList-Type := /descendant::LIST[LST-ITM[@ID = $targetID]]/@ENUMTYPE,\
if(contains($myTargetList-Type, 'LOWERALPHA')),\
then format-integer(index-of(/descendant::LIST[LST-ITM/@ID = $targetID]/LST-ITM/@ID, $myTargetList-Item), 'a'),\
else concat('List type ', $myTargetList-Type, 'not supported')");
}
Any help pointing me in the right direction will be greatly appreciated. I'm pasting a sample XML doc below for reference.
Code: Select all
<ROOT>
<LIST ENUMTYPE="LOWERALPHA" TYPE="ORDERED">
<LST-ITM ID="L1I1">
<PTXT>List 1 - List item 1</PTXT>
</LST-ITM>
<LST-ITM ID="L1I2">
<PTXT>List 1 - List item 2</PTXT>
</LST-ITM>
<LST-ITM ID="L1I3">
<PTXT>List 1 - List item 3</PTXT>
</LST-ITM>
</LIST>
<P>Paragraph</P>
<LIST ENUMTYPE="ARABICNUM" TYPE="ORDERED">
<LST-ITM ID="L2I1">
<PTXT>List 2 - List item 1</PTXT>
</LST-ITM>
<LST-ITM ID="L2I2">
<PTXT>List 2 - List item 2</PTXT>
</LST-ITM>
<LST-ITM ID="L2I3">
<PTXT>List 2 - List item 3</PTXT>
</LST-ITM>
</LIST>
<P>This reference is to List 1 Item 2: <INTXREF DEST="LST-ITM" REFID="L1I2"/></P>
<P>This reference is to List 2 Item 3: <INTXREF DEST="LST-ITM" REFID="L2I3"/></P>
</ROOT>