Customizing Narrowcast XSL

In Narrowcast Server, when you use report in EXCEL document, instead of normal report output; you can customize the output result based on your own design by modifying default Narrowcast XSLT.

In order to design Narrowcast XSLT, first we need to understand the Report XML and its content present in XML file.

How to get the get the report xml:

  1. Run the corresponding report in the WEB.
  2. In the Address Bar, enter ‘&XML=1’ at the end of the URL as shown below.
  3. Right click in Browser and Select the ‘ViewSource’ option.
  4. Search for ‘<mi’ in the Source and starting from the ‘<mi’ tag copy till end tag (i.e) ‘mi>’.
  5. Paste the copied text in notepad and save it in ‘.xml’ file.

Note: Report data Tag starts with <RH>

Narrowcast XSLT’s and Tags specific to spreadsheet

Note: All aspects of this XML specification, including element (tag) names, attribute names, and attribute values are case sensitive. •

  • The pt-container is the root level of every Excel XML document element that contains the table tag. This tag is required.
  • The table tag contains both content and formatting tags for turning data into a well-formatted grid. The resulting grid overwrites a contiguous rectangle of cells in an Excel workbook when an Excel document is rendered. An Excel XML document element can contain only one table tag.
  • The fonts tag contains the set font definitions that control the font characteristics of cells written into the Excel workbook. Font definitions include font type, color, size, weight, and modifiers like italic. An Excel XML document element can contain only one fonts tag.
  • The font tag contains the definition of a specific font used for this document element. Zero or more font tags are required.
  • The styles tag contains the set style definitions that control cell formatting for cells written into the Excel workbook. Style definitions include all font characteristics as well as background color, orientation, alignment, and borders. An Excel XML document element can contain only one styles tag.
  • The style tag contains the definition of a specific style that is used for this document element. Zero or more style tags are required.
  • The formats tag contains the set of format strings that are used to format date, time, and numeric cell contents. An Excel XML document element can contain only one formats tag.
  • The format tag contains the definition of a specific format string that is used for this document element. Zero or more format tags are required.
  • Each row in a table contains cells. A blank row can be represented by the inclusion of a row containing an empty cell. One or more row tags are required.
  • Each cell in a row contains the data that should be placed into the corresponding cell in the resulting grid. One or more cell tags are required.

Sample Report output and used to design the XSL

Country Region Revenue
USA Northeast

$2,334,864

Mid-Atlantic

$3,413,340

Southeast

$2,016,186

Central

$1,773,270

South

$1,380,991

Northwest

$1,485,182

Southwest

$2,816,334

Web Web

$1,716,267

Sample XSL created for the above Report (you can take default Narrowcast XSL and Modify the content except parent tags)

[sourcecode language=”xml”]
<?xml version="1.0"?>;
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">;
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes" />;
<xsl:template match="/">;

<pt-container>;

<table row-count="3" column-count="12">;

<fonts>;
<font name="ObjectName1" family="Arial" size="10" weight="bold" style="italic" />;
<font name="ObjectName2" family="Arial" size="10" weight="bold" style="italic" />;
<font name="ObjectName3" family="Arial" size="10" weight="bold" style="italic" />;
<font name="ObjectValue1" family="Coronet" size="11" weight="bold" color="12" />;
<font name="ObjectValue2" family="Coronet" size="11" weight="bold" color="12" />;
<font name="ObjectValue3" family="Coronet" size="11" weight="bold" color="12" />;
</fonts>;

<styles>;
<style name="SObjectName1" background-color="47" align="center" border-top="style:medium" border-right="style:medium" border-left="style:medium" border-bottom="style:medium" font="ObjectName1" />;
<style name="SObjectName2" background-color="44" align="center" border-top="style:medium" border-right="style:medium" border-left="style:medium" border-bottom="style:medium" font="ObjectName2" />;
<style name="SObjectName3" background-color="34" align="center" border-top="style:medium" border-right="style:medium" border-left="style:medium" border-bottom="style:medium" font="ObjectName3" />;
<style name="SObjectValue1" background-color="47" align="center" border-top="style:medium" border-right="style:medium" border-left="style:medium" border-bottom="style:medium" font="ObjectValue1" />;
<style name="SObjectValue2" background-color="44" align="center" border-top="style:medium" border-right="style:medium" border-left="style:medium" border-bottom="style:medium" font="ObjectValue2" />;
<style name="SObjectValue3" background-color="34" align="center" border-top="style:medium" border-right="style:medium" border-left="style:medium" border-bottom="style:medium" font="ObjectValue3" />;
</styles>;

<formats/>;
<row>;
<cell style="SObjectName2" type="8">;Region</cell>;
<xsl:for-each select="/mi/rit/vw/gr/rh/rw">;
<xsl:if test="./h[1][@rfd=’4′]“>;
<cell style="SObjectValue2">;<xsl:value-of select="./h[2]/fv"/>;</cell>;
</xsl:if>;
<xsl:if test="./h[1][@rfd!=’4′]“>;
<cell style="SObjectValue2">;<xsl:value-of select="./h[1]/fv"/>;</cell>;
</xsl:if>;
</xsl:for-each>;
</row>;

<row>;
<cell style="SObjectName3" type="8">;Revenue</cell>;
<xsl:for-each select="/mi/rit/vw/gr/rh/rw">;
<xsl:if test="./h[1][@rfd=’4′]“>;
<cell style="SObjectValue3">;<xsl:value-of select="./mv"/>;</cell>;
</xsl:if>;
<xsl:if test="./h[1][@rfd!=’4′]“>;
<cell style="SObjectValue3">;<xsl:value-of select="./mv"/>;</cell>;
</xsl:if>;
</xsl:for-each>;
</row>;

</table>;

</pt-container>;
</xsl:template>;
</xsl:stylesheet>;
[/sourcecode]

Output for the above Report along with the XSL

1) Save the above XSLT

2) Insert the XSLT as XSL file in Narrowcast Server

3) In the documents, while mapping report in EXCEL document; Map this XSLT for the particular report

4) complete the service (as we do normally)

5) Run the service, you will get the customized output

Narrowcast XLST output

Narrowcast XLST output

About Senthilraj

DW BI Architect and BI Project Management (Specialized in MicroStrategy). Hobbies/Passion about photography, tennis, music, travel-trekking. Website: www.b-diamonds.com www.facebook.com/SENRAJ81 www.linkedin.com/in/senraj


Notice: compact(): Undefined variable: limits in /home1/microoat/public_html/blog/wp-includes/class-wp-comment-query.php on line 821

Notice: compact(): Undefined variable: groupby in /home1/microoat/public_html/blog/wp-includes/class-wp-comment-query.php on line 821

Notice: compact(): Undefined variable: groupby in /home1/microoat/public_html/blog/wp-includes/class-wp-comment-query.php on line 821

Warning: count(): Parameter must be an array or an object that implements Countable in /home1/microoat/public_html/blog/wp-includes/class-wp-comment-query.php on line 399