Monday, 28 January 2019

xsl, xslt : Using in BI Publisher

Sample Data:

<?xml version = '1.0' encoding = 'utf-8'?>
<G_MAIN>
<PAYMENT_ID>45003</PAYMENT_ID><PAYMENT_AMOUNT>2221000</PAYMENT_AMOUNT><PAYMENT_CURRENCY_CODE>USD</PAYMENT_CURRENCY_CODE>
<G_INV>
<CHECK_NUMBER>1</CHECK_NUMBER><INVOICE_ID>17007</INVOICE_ID><INVOICE_NUM>8888</INVOICE_NUM>
</G_INV>
<G_INV>
<CHECK_NUMBER>1</CHECK_NUMBER><INVOICE_ID>17008</INVOICE_ID><INVOICE_NUM>9999</INVOICE_NUM>
</G_INV>
<G_INV>
<CHECK_NUMBER>1</CHECK_NUMBER><INVOICE_ID>17009</INVOICE_ID><INVOICE_NUM>1111</INVOICE_NUM>
</G_INV>
</G_MAIN>
</DATA_DS>


Always use xsl syntax in rtf tags, writing directly in rtf will not work.

xsl:value-of

<xsl:value-of select="//G_MAIN/G_INV/INVOICE_NUM"/>

It will search for node //G_MAIN/G_INV/ in xml, and will print all occurrences of INVOICE_NUM



<xsl: if>
XSL_IF
XSL Tags
Output
<xsl:if test="count(//G_MAIN/G_INV)>1">
true statement
</xsl:if>
<xsl:if test="count(//G_MAIN/G_INV) > 10">
<?count(//G_MAIN/G_INV)?>
</xsl:if>
true statement
20


<xsl:choose>
XSL_CHOOSE

XSL Tags
Output
<xsl:choose>
<xsl:when test="count(//G_MAIN/G_INV)>10">
COUNT IS MORE THAN 10
</xsl:when>
<xsl:otherwise>
COUNT IS LESS THAN 10
</xsl:otherwise>
</xsl:choose
COUNT IS MORE THAN 10

 <xsl:text> 
<xsl:text>text to be displayed</xsl:text>


Define Variables


<xsl:variable name="x"/> --BLANK VAR

<xsl:variable name="favouriteColour" select="'blue'"/>  --STATIC VAL VARIABLE

<xsl:variable name="favouriteColour" select="blue"/>  -- FETCH <blue> element into var


Define a Variable
<xsl:variable name="no_of_lines_per_page" select="number(15)"/>

<?$ no_of_lines_per_page?>


Define a variable to contain Data Nodes

Define a group on the fly. With context
<xsl:variable xdofo:ctx="incontext" name="INV_GRP" select=".//G_INV"/>

<?for-each:$INV_GRP?>
<?position()?> <?INVOICE_NUM?>
<?end for-each?>



Define and Calling a Template

Define Template
<xsl:template name="calcuateArea">
<xsl:param name="width"/>
<xsl:param name="height"/>
<xsl:value-of select="$width * $height"/>
</xsl:template>

Call Template
<xsl:call-template name="calcuateArea">
<xsl:with-param name="width" select="10"/>
<xsl:with-param name="height" select="50"/>
</xsl:call-template>













1 comment:

  1. Oracle Apps R12 and Fusion Cloud Self Paced Training Videos Published on Udemy with Live Meeting Support. Please Check https://www.oracleappstechnical.com

    ReplyDelete