Example: [http://www.adivaconsulting.com/adiva-blog/item/38-working-with-xpath-in-rtf-template.html]
Here is the example of an institute which has one department and a few students in it.
<INSTITUTE>
<DEPARTMENT>
<DEPARTMENT_NAME>COMPUTER SCIENCE ENGINEERING</DEPARTMENT_NAME>
<SECTION>
<STUDENT>
<ROLL_NO>1201</ROLL_NO>
<MARKS>
<SUBJECT1>45</SUBJECT1>
<SUBJECT2>55</SUBJECT2>
<SUBJECT3>65</SUBJECT3>
</MARKS>
</STUDENT>
<STUDENT>
<ROLL_NO>1205</ROLL_NO>
<MARKS>
<SUBJECT1>56</SUBJECT1>
<SUBJECT2>48</SUBJECT2>
<SUBJECT3>58</SUBJECT3>
</MARKS>
</STUDENT>
<STUDENT>
<ROLL_NO>1257</ROLL_NO>
<MARKS>
<SUBJECT1>51</SUBJECT1>
<SUBJECT2>49</SUBJECT2>
<SUBJECT3>53</SUBJECT3>
</MARKS>
</STUDENT>
</SECTION>
</DEPARTMENT>
</INSTITUTE>
Now let’s display all the student details using a table with department name, roll number and marks.
Output:
Why is the department name missing?
When we say <?for-each:STUDENT?> the control is at <STUDENT> , (as you can see in the below diagram) but department name is not the child of student so we have to move the cursor to appropriate tag using xpath.
Output:
Here we used <?../../DEPARTMENT_NAME?> instead of <?DEPARTMENT_NAME?> so that the control jumps to two levels up in hierarchy and displays the DEPARTMENT NAME.
Now, let’s calculate totals marks secured by each student. To do so, add a column for Total and use <?sum(./MARKS/*)?> syntax to calculate TOTAL.
<?sum(./MARKS/*)?> syntax implies that we are using sum function and calculating all the children in marks
Output:
Oracle Apps R12 and Fusion Cloud Self Paced Training Videos Published on Udemy with Live Meeting Support. Please Check https://www.oracleappstechnical.com
ReplyDelete