Usecase:
Here, we will create a custom fields XML Output BI report using XSL template.
Check my previous blog how to create BI report using xsl template
https://soalicious.blogspot.com/2022/03/create-bi-report-using-xsl-template.html
.xsl template used:
Syntax1:
<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<document>
<xsl:element name="SupplierData">
<xsl:for-each select="DATA_DS/G_1">
<xsl:element name="Supplier">
<xsl:element name="SUPPLIER_NAME">
<xsl:value-of select="SUPPLIER_NAME"/>
</xsl:element>
<xsl:element name="SUPPLIER_NUMBER">
<xsl:value-of select="SUPPLIER_NUMBER"/>
</xsl:element>
<xsl:element name="SUPPLIER_ID">
<xsl:value-of select="SUPPLIER_ID"/>
</xsl:element>
<xsl:element name="COUNTRY">
<xsl:value-of select="COUNTRY"/>
</xsl:element>
<xsl:element name="CITY">
<xsl:value-of select="CITY"/>
</xsl:element>
<xsl:element name="STATUS">
<xsl:value-of select="STATUS"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:element>
</document>
</xsl:template>
</xsl:stylesheet>
Syntax2:
<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<document>
<SupplierData>
<xsl:for-each select="DATA_DS/G_1">
<Supplier>
<SUPPLIER_NAME>
<xsl:value-of select="SUPPLIER_NAME"/>
</SUPPLIER_NAME>
<SUPPLIER_NUMBER>
<xsl:value-of select="SUPPLIER_NUMBER"/>
</SUPPLIER_NUMBER>
<SUPPLIER_ID>
<xsl:value-of select="SUPPLIER_ID"/>
</SUPPLIER_ID>
<COUNTRY>
<xsl:value-of select="COUNTRY"/>
</COUNTRY>
<CITY>
<xsl:value-of select="CITY"/>
</CITY>
<STATUS>
<xsl:value-of select="STATUS"/>
</STATUS>
</Supplier>
</xsl:for-each>
</SupplierData>
</document>
</xsl:template>
</xsl:stylesheet>
Dont forget to change the default format from html to xml.
Output report:
For multi group sample:
No comments:
Post a Comment