XML Functions For Template
XML Functions For Template
<NAME>Vision</NAME>
<DEPT>
<DEPT_NAME>IT</DEPT_NAME>
<EMPLOYEE>
<EMPNO>6</EMPNO>
<ENAME>Rich Walker</ENAME>
<JOB>CLERK</JOB>
<SAL>100</SAL>
</<EMPLOYEE>>
<EMPLOYEE>
<EMPNO>5</EMPNO>
<ENAME>Russ Kepel</ENAME>
<JOB>CLERK</JOB>
<SAL>100</SAL>
</EMPLOYEE>
<EMPLOYEE>
<EMPNO>8</EMPNO>
<ENAME>Helbe Korth</ENAME>
<JOB>CLERK</JOB>
<SAL>100</SAL>
</EMPLOYEE>
</DEPT>
<DEPT>
<DEPT_NAME>Accounting</DEPT_NAME>
<EMPLOYEE>
<EMPNO>1</EMPNO>
<ENAME>Ike Wiggins</ENAME>
<JOB>CLERK</JOB>
<SAL>100</SAL>
</<EMPLOYEE>
<EMPLOYEE>
<EMPNO>2</EMPNO>
<ENAME>Heike Elder</ENAME>
<JOB>CLERK</JOB>
<SAL>100</SAL>
</EMPLOYEE>
</DEPT>
</CORPORATION>
Overview of for-each
<?for-each:DEPT?><?DEPT_NAME?><?end for-each?>
DEPT
For-Each DEPT_NAME End-For-Each
DEPT
IT
Accounting
Example 2: Get dept/employee
Now this is where were going to reference the vocabulary above. Employees are available in the
context of the current element or node dept. So you can access those elements but it will be in the
context of the current node, which only has two elements to loop through.
<?for-each:DEPT?><?DEPT_NAME?><?ENAME?><?end for-each?>
If we wanted to drill down in employee’s we would need to make sure were in the right context and
to tell the parser there’s more elements there. In order to do this, we need to do another for-each
loop. This tells xml parser the following. For each dept, get each dept and for each employee get
there name too and in that order.
<?for-each:DEPT?>
<?DEPT_NAME?>
<?for-each: EMPLOYEE?>
<?ENAME?>
<?end for-each?>
<?end for-each?>
<?for-each:DEPT?>
<?../DEPT_NAME?>
<?for-each: EMPLOYEE?>
<?ENAME?>
<?end for-each?>
<?end for-each?>
Note: // this is not in-context command, it will find the first element in the document that
matches. This isn’t a problem if there is only one element. We will be doing that in this
example. Also, if you wanted to find the first element in the current context you could do .//
For example : If we want to display main group elements in the sub group like “ENAME” in “DEPT”
group. We have to place the ../../ before the tag (../../ENAME)
<?for-each:DEPT?>
<?//NAME?>
<?../DEPT_NAME?>
<?for-each: EMPLOYEE?>
<?ENAME?>
<?end for-each?>
<?end for-each?>
Example 6:
<?split-by-page-break:?>
Example 7:
<?xdoxslt:sysdate()?>
<?xdoxslt:sysdate('DD/MM/YY HH:MI:SS')?>
To get the Date in RTF Report, For Displaying Current System Date in Layout we have to use above
Tag.
Example 8:
<?for-each@section:G_DEPTNO?>
Example 8:
url:{concat('${OA_MEDIA}','/',IMAGE_FILE)}
Example 9:
If you want to display the total in last page use this command.
Example 10:
Example 11:
If you want to hide the Rows use this command in Group level
<?init-page-total: pst?>
<?add-page-total:pst;'SAL'?>
<?show-page-total:pst;'C9G990D00';'(C9G990D00)'?>
If you are using sum(SAL) function in the any rtf file, if at least one SAL field contains salary null, the
output will not generated & it will give an error.
To get a correct result you have to handle null columns like below:
sum(SAL[.!=’’])
Example 13:
Create a variable
<?xdoxslt:set_variable($_XDOCTX, 'V_NUM', 0)?>
Display variable
<?xdoxslt:get_variable($_XDOCTX, 'V_NUM')?>
<?for-each-group:CD;COUNTRY?>
<?for-each-group:current-group();YEAR?>
<?for-each:current-group()?>
<?end for-each?>
<?end for-each-group?>
<?end for-each-group?>
Number Formatting
<?xdoxslt:xdo_format_number_l(100000,'999G999D99','EN-us')?>
Output:- 100,000.00
<?xdoxslt:xdo_format_number_l(100000,'999G999D99','DE-de')?>
Output:- 100.000,00