XQuery IF THEN ELSE in CSS oxy_xpath
Issues related to W3C XQuery.
-
- Posts: 12
- Joined: Wed Sep 23, 2020 1:42 am
XQuery IF THEN ELSE in CSS oxy_xpath
Post by dsmith1690 »
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>
-
- Posts: 12
- Joined: Wed Sep 23, 2020 1:42 am
Re: XQuery IF THEN ELSE in CSS oxy_xpath
Post by dsmith1690 »
Here's the answer:
Code: Select all
INTXREF[DEST = "LST-ITM"]{
font-weight:bold;
content: oxy_xpath("let\
$targetID := @REFID,\
$myTargetList-Item := /descendant::LIST/LST-ITM[@ID = $targetID]/@ID,\
$myTargetList-Type := /descendant::LIST[LST-ITM[@ID = $targetID]]/@ENUMTYPE\
return\
if (contains($myTargetList-Type, 'LOWERALPHA'))\
then format-integer(index-of(/descendant::LIST[LST-ITM/@ID = $targetID]/LST-ITM/@ID, $myTargetList-Item), 'a')\
else if (contains($myTargetList-Type, 'UPPERALPHA'))\
then format-integer(index-of(/descendant::LIST[LST-ITM/@ID = $targetID]/LST-ITM/@ID, $myTargetList-Item), 'A')\
else if (contains($myTargetList-Type, 'LOWERROMAN'))\
then format-integer(index-of(/descendant::LIST[LST-ITM/@ID = $targetID]/LST-ITM/@ID, $myTargetList-Item), 'i')\
else if (contains($myTargetList-Type, 'UPPERROMAN'))\
then format-integer(index-of(/descendant::LIST[LST-ITM/@ID = $targetID]/LST-ITM/@ID, $myTargetList-Item), 'I')\
else index-of(/descendant::LIST[LST-ITM/@ID = $targetID]/LST-ITM/@ID, $myTargetList-Item) ");
}
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service