XSL BI Publisher For-Each 循环打印空行

XSL BI Publisher For-Each Loop print blank lines

我的 BI Publisher RTF 模板中有一个 for-each 循环,用于在 XML 输出中重复组。当没有数据存在时,我仍然需要 for-each 循环来输出空白 table 行。有点像 for-each 循环的异常。可能吗?

XML 输出:

<LIST_G_BOX_18_TO_20> 
 <G_BOX_18_TO_20>
  <SD_CODE></SD_CODE>
  <ASSIGNMENT_ACTION_ID5>2090950796</ASSIGNMENT_ACTION_ID5>
  <PAYROLL_ACTION_ID5>30381586</PAYROLL_ACTION_ID5>
  <TAX_UNIT_ID4>120</TAX_UNIT_ID4>
  <LOCALITY_NAME1>Euclid(OH)</LOCALITY_NAME1>
  <STATE_ABBREV>OH</STATE_ABBREV>
  <W2_LOCAL_WAGES>34.43</W2_LOCAL_WAGES>
  <W2_LOCAL_INCOME_TAX>.98</W2_LOCAL_INCOME_TAX>
 </G_BOX_18_TO_20>
<LIST_G_BOX_18_TO_20> 

FOR-EACH 循环

<?for-each:G_BOX_18_TO_20[W2_LOCAL_WAGES>0]?>
   <?if:position()!=1?><?STATE_ABBREV?>
  <?W2_LOCAL_WAGES?>
  <?W2_LOCAL_INCOME_TAX?>
  <?    xdofx:substr(LOCALITY_NAME1,1,decode(instr(LOCALITY_NAME1,'(',1),'0',length(LOCALITY_NAME1)+1,instr(LOCALITY_NAME1, '(', 1)) - 1)?>
 <?end if?>
 <?end for-each?>

元素不存在数据时的 XML 输出示例 - G_BOX_18_TO_20:

<LIST_G_BOX_18_TO_20>
</LIST_G_BOX_18_TO_20>

选项 1

将第二行添加到您的 table 循环中的行之前。将这些条件之一应用于该新行,以便在满足条件时显示该行。

条件A:检查LIST元素中是否没有记录

<?if:LIST_G_BOX_18_TO_20 and LIST_G_BOX_18_TO_20="?><?end if?> 

条件 B:检查 LIST ITEM 元素是否不存在

<?if:not(G_BOX_18_TO_20)?><?end if?>

选项 2

这在了解一些其他详细信息之前应用,因此可能对其他人了解有所帮助。把条件从for-each中拿出来,当条件不满足时,在你不想出现的所有字段上做一个if语句。

<?for-each:G_BOX_18_TO_20?>
   <?if:position()!=1?><?STATE_ABBREV?>
  <?if:W2_LOCAL_WAGES>0?><?W2_LOCAL_WAGES?><?end if?>
  <?if:W2_LOCAL_WAGES>0?><?W2_LOCAL_INCOME_TAX?><?end if?>
  <?if:W2_LOCAL_WAGES>0?><?xdofx:substr(LOCALITY_NAME1,1,decode(instr(LOCALITY_NAME1,'(',1),'0',length(LOCALITY_NAME1)+1,instr(LOCALITY_NAME1, '(', 1)) - 1)?><?end if?>
 <?end if?>
<?end for-each?>