I'm applying grouping in the XSLT based on the attribute that comes from the XML.But i dont see any grouping done now. Can anyone please help me on this.. Below is my XSLT and XML
I would like to achieve like below, My GroupingColumn will be coming from the XML and I need to match that GroupingColumn value with XSL FO and generate the table like below.
<xsl:key name="Report" match="Report" use="@GroupingColumn1" /><xsl:variable name="GroupingColumn"><xsl:value-of select="/PdfPrinter/Reports/Header/GroupingColumn1" /></xsl:variable>
When i applied $GroupingColumn in the blow XSLT, it is not being reflected. But i'm able to print the correct value for $GroupingColumn.$GroupingColumn will give me the column name so that i can use it in the below grouping logic.How to do this?
XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ext="http://exslt.org/common" xmlns:utilityExtension="pdfprinter:extensions:utility" exclude-result-prefixes="msxsl utilityExtension"><xsl:output method="xml" indent="yes" omit-xml-declaration="yes" encoding="utf-8"/><xsl:key name="Report" match="Report" use="GroupingColumn1" /><xsl:template match="/"><xsl:apply-templates select="Reports/Header"/><xsl:variable name="GroupingColumn"><xsl:value-of select="/PdfPrinter/Reports/Header/GroupingColumn1" /></xsl:variable><xsl:variable name="columnFontSize">12pt</xsl:variable><xsl:variable name="columnFontType">Helvetica</xsl:variable><xsl:variable name="headerOrgName">Pavan</xsl:variable><xsl:variable name="headerPrintedBy">Printed By</xsl:variable><xsl:variable name="headerPrintedDate">Printed Date</xsl:variable><xsl:variable name="headerReportID">Report ID</xsl:variable><xsl:variable name="logo" select="utilityExtension:MapPath('~/App_Data/Resources/IMAGES/logo.jpg')"/><fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"><!-- defines the layout master --><fo:layout-master-set><fo:simple-page-master master-name="all-pages" page-width="1600pt" page-height="1190pt"><fo:region-body region-name="xsl-region-body" column-gap="0.250in" margin="0.7in" margin-left="0.7in"/><fo:region-before region-name="xsl-region-before" display-align="after" extent="0.700in" /><fo:region-after region-name="xsl-region-after" extent="0.700in"/></fo:simple-page-master><fo:page-sequence-master master-name="default-sequence"><fo:repeatable-page-master-reference master-reference="all-pages"/></fo:page-sequence-master></fo:layout-master-set><!-- starts actual layout --><fo:page-sequence master-reference="default-sequence" initial-page-number="1"><fo:static-content border-bottom-width="1pt" border-bottom-style="solid" border-bottom-color="rgb(192,192,192)" flow-name="xsl-region-before" font-size="10pt" font-family="Helvetica"><fo:block color="rgb(105,105,105)" text-align-last="justify"><fo:inline font-size="10pt" font-weight="normal">                                                                                                                                                                                                                                                                                                                                                                                                                                  Page <fo:page-number/> of <fo:page-number-citation ref-id="theEnd"/></fo:inline></fo:block></fo:static-content><fo:static-content border-top-width="1pt" width="1000pt" border-top-style="solid" border-top-color="rgb(192,192,192)" padding-top="2pt" flow-name="xsl-region-after" font-size="10pt" font-family="Helvetica"><fo:table table-layout="fixed" width="500pt"><fo:table-column column-width="proportional-column-width(4)"/><fo:table-column column-width="proportional-column-width(1)"/><fo:table-body><fo:table-row><fo:table-cell><fo:block text-align="right" color="rgb(105,105,105)"> </fo:block></fo:table-cell></fo:table-row></fo:table-body></fo:table></fo:static-content><fo:flow flow-name="xsl-region-body" font-size="10pt" font-family="Helvetica"><fo:block><fo:table border-collapse="collapse" width="1200pt" table-layout="auto" margin-top="-0.002in"><fo:table-column column-width="proportional-column-width(55)" column-number="1"/><fo:table-column column-width="proportional-column-width(45)" column-number="2"/><fo:table-body><fo:table-row><fo:table-cell><fo:block color="rgb(0,0,128)" font-size="16pt" font-weight="bold"> </fo:block><fo:block color="rgb(0,0,128)" font-weight="bold"></fo:block><fo:block color="rgb(0,0,0)" font-weight="bold" font-family="{$columnFontType}" font-size="{$columnFontSize}"><fo:external-graphic src="{$logo}"/>    <fo:block><xsl:value-of select="$GroupingColumn"/></fo:block></fo:block><fo:block color="rgb(0,0,128)" font-weight="bold">    </fo:block><fo:block color="rgb(0,0,0)" font-weight="bold" font-family="{$columnFontType}" font-size="{$columnFontSize}"><xsl:value-of select="$headerReportID"/></fo:block><fo:block><xsl:value-of select="/PdfPrinter/Reports/Header/ReportID" /></fo:block></fo:table-cell><fo:table-cell><fo:block text-align="left"><fo:inline font-weight="bold" font-family="{$columnFontType}" font-size="{$columnFontSize}"><xsl:value-of select="$headerPrintedBy"/> :</fo:inline><fo:block><xsl:value-of select="/PdfPrinter/Reports/Header/PrintedBy" /></fo:block></fo:block><fo:block text-align="left"><fo:inline font-weight="bold" font-family="{$columnFontType}" font-size="{$columnFontSize}"><xsl:value-of select="$GroupingColumn"/> :</fo:inline><fo:block><xsl:value-of select="/PdfPrinter/Reports/Header/PrintedDate" /></fo:block></fo:block></fo:table-cell></fo:table-row></fo:table-body></fo:table><fo:block/></fo:block><fo:block text-align="center"><fo:table border-bottom-width="5pt" font-weight="bold" inline-progression-dimension="auto" width="900pt" border-bottom-color="rgb(51,51,153)" border-collapse="collapse"><fo:table-column column-number="1"/><fo:table-body><fo:table-row border-bottom-color="rgb(0,0,255)" display-align="before"><fo:table-cell border-bottom-width="3pt" border-bottom-style="solid" border-bottom-color="rgb(51,51,153)" padding="2pt" text-align="left"><fo:block text-align="center" font-size="12pt" font-weight="bold" font-family="Helvetica" border-bottom="10pt "></fo:block><fo:block><xsl:value-of select="/PdfPrinter/Reports/Header/ReportTitle" /></fo:block><fo:block border-bottom-width="10pt" text-align="center"/></fo:table-cell></fo:table-row></fo:table-body></fo:table></fo:block><fo:block font-size="18pt" font-family="sans-serif" line-height="24pt" space-after.optimum="15pt" background-color="blue" color="white" text-align="center" padding-top="3pt"> Users Report</fo:block><fo:block text-align="center"><!-- table start --><fo:table role="html:table" width="1200pt" border="2px" border-collapse="collapse" border-spacing="0px" border-style="outset hidden" space-after="1em" space-before="1em"><!--table header--><xsl:for-each select="/PdfPrinter/Reports/Report[1]/*[local-name() != '$GroupingColumn']"><fo:table-column column-width="proportional-column-width(4.77)"/></xsl:for-each><fo:table-header border="1px solid" display-align="before" end-indent="0pt" last-line-end-indent="0pt" role="html:thead" start-indent="0pt" text-align="start" text-indent="0pt"><fo:table-row height="20.81pt" display-align="center" overflow="hidden"><xsl:for-each select="/PdfPrinter/Reports/Report[1]/*[local-name() != '$GroupingColumn']"><fo:table-cell text-align="center" border="rgb(0, 0, 0) solid 1pt" padding="2pt"><fo:block color="rgb(0,0,0)" text-align="center" font-weight="normal" font-family="{$columnFontType}" font-size="{$columnFontSize}"><xsl:value-of select="name()"/></fo:block></fo:table-cell></xsl:for-each></fo:table-row></fo:table-header><!--table body--><fo:table-body><xsl:for-each select="PdfPrinter/Reports/Report[generate-id() = generate-id(key('Report', $GroupingColumn)[1])]"><fo:table-row><fo:table-cell number-columns-spanned="{count(*) - 1}"><fo:block> @GroupingColumn : <xsl:apply-templates select="$GroupingColumn" /></fo:block></fo:table-cell></fo:table-row><xsl:for-each select="key('Report', $GroupingColumn)"><fo:table-row display-align="before"><xsl:for-each select="*[local-name() != '$GroupingColumn']"><fo:table-cell text-align="center" border-top-color="rgb(0, 0, 0)" border-top-style="solid" border-width="1pt" padding="2pt"><fo:block><xsl:value-of select="."/></fo:block></fo:table-cell></xsl:for-each></fo:table-row></xsl:for-each></xsl:for-each></fo:table-body></fo:table><!-- table end --></fo:block></fo:flow></fo:page-sequence></fo:root></xsl:template></xsl:stylesheet>
XML
<Reports><Report><CreatedDate>2015-10-07T17:36:45</CreatedDate><LogType>InvalidPassword</LogType><LoginID>B1ADMIN</LoginID><Name>XYZ</Name><AppVersion></AppVersion><System>OS</System><UserIPAddress>192.168.1.83</UserIPAddress><LoginDate /><LogoutDate /><Remarks></Remarks></Report><Report><CreatedDate>2015-10-07T17:37:06</CreatedDate><LogType>InvalidPassword</LogType><LoginID>B1ADMIN</LoginID><Name>XYZ</Name><AppVersion></AppVersion><System>OS</System><UserIPAddress>192.168.1.83</UserIPAddress><LoginDate /><LogoutDate /><Remarks></Remarks></Report><Report><CreatedDate>2015-10-07T17:41:10</CreatedDate><LogType>FailedLogin</LogType><LoginID>B1ADMIN</LoginID><Name>XYZ</Name><AppVersion></AppVersion><System>OS</System><UserIPAddress>192.168.1.83</UserIPAddress><LoginDate /><LogoutDate /><Remarks></Remarks></Report><Header><ReportID>AUD001</ReportID><GroupingColumn1>LoginID</GroupingColumn1><PrintedBy>DebugTest</PrintedBy><PrintedDate>2016-07-22</PrintedDate></Header></Reports>
If you look the GroupingColumn1 attribute in the XML which is LoginID, I would like to group my table based on this value in the XSL FO. GroupingCOlumn is one of the columns present in the <Report> section of XML which i get it from the frontend. If GroupingColumn is LogType, then i should be able to apply grouping by LogType. I hope i'm clear..
@GroupingColumn is what i'm assigning dynamically in the XSL FO. Please help me on this.
BB 10 Firing on all cylinders!