Thursday, 22 May 2014

Variable Declaration in XML Publisher

Define Constant Variable

This variable remains constant for entire file
(xsl:variable name="no_of_lines_per_page" select="number(15)"/)

Assigning Group/Repeating Frame to Variable

(xsl:variable xdofo:ctx="incontext" name="inner_group" select=".//DocumentPayable"/)
Here DocumentPayable is a Group which is assigned to variable inner_group. So we can
loop through this variable as below
(?for-each:$inner_group?)
Here you can also get total records in a group anytime using count($inner_group)

Incrementing Variable in Loop

Declare variable before loop and increment it inside loop as below
(?xdoxslt:set_variable($_XDOCTX, 'counter', 0)?)
(?for-each:G_LINES?)
(?xdoxslt:set_variable($_XDOCTX, 'counter', xdoxslt:get_variable($_XDOCTX, 'counter') +
1)?)
(?xdoxslt:get_variable($_XDOCTX, 'counter')?)
(?end for-each?)

Printing Variable Value

The "xsl:value-of" element can be used to select the value of an XML element and add it to
the output
(xsl:value-of select="$var1"/)

No comments:

Post a Comment