Report generation is controlled by a set of reports options, read from an XML file. Here is an example: <ReportOptions xmlns="http://www.teradp.com/schemas/GN4/1/ReportOptions.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" NavOptions="None"> <Xslt xmlns="http://www.teradp.com/schemas/GN4/1/XmlExportOptions.xsd"> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:gn4="urn:schemas-teradp-com:gn4tera" xmlns:fn="http://www.teradp.com/schemas/GN4/1/Xslt" xmlns="" version="1.0"> <!-- Common parameters --> <xsl:param name="context" /> <xsl:param name="pars" /> <!-- Report column value template --> <xsl:template name="c"> <xsl:param name="name"/> <!-- Column name --> <xsl:param name="value"/> <!-- Column value --> <xsl:if test="$value"> <xsl:element name="{$name}"> <xsl:value-of select="$value"/> </xsl:element> </xsl:if> </xsl:template> <!-- Template matching any object--> <xsl:template match="gn4:*"> <r> <xsl:call-template name="c"> <xsl:with-param name="name" select="'id'"/> <xsl:with-param name="value" select="fn:objectIdFromString(@id)"/> </xsl:call-template> <xsl:call-template name="c"> <xsl:with-param name="name" select="'type'"/> <xsl:with-param name="value" select="local-name()"/> </xsl:call-template> <xsl:call-template name="c"> <xsl:with-param name="name" select="'size'"/> <xsl:with-param name="value" select="@size"/> </xsl:call-template> </r> </xsl:template> <!-- Template matching a list of objects --> <xsl:template match="gn4:objects"> <xsl:apply-templates/> </xsl:template> <!-- Root template --> <xsl:template match="/"> <root> <xsl:apply-templates/> </root> </xsl:template> </xsl:stylesheet> </Xslt> <Conditions xmlns="http://www.teradp.com/schemas/GN4/1/SearchConditions.xsd" ObjectTypeName="archiveObject"> <SearchNode xsi:type="ConditionSearchNode" Op="Equal"> <Left xsi:type="AttributeSearchNode" Path="archiveObject.folderRef.path" /> <Right xsi:type="VariableSearchNode" Name="folderPath" Type="String" /> </SearchNode> </Conditions> <Columns> <Column Name="Id" Type="Integer"/> <Column Name="Type" Type="String" Length="80"/> <Column Name="Size" Type="Long"/> </Columns> </ReportOptions> It contains an XSL transformation (in blue above), search conditions (red) and a list of columns definitions (green). The search conditions can contain variable parameters - in this example the search will find all objects in the folder specified by the 'folderPath' parameter. Assuming that the above options are stored in the file 'report_FolderObjectSize.xml', to create the report execute: srv4 report -opt report_FolderObjectSize.xml -out c:\temp\fo.xml -pars folderPath:/system/users/administrator this will produce an output file fo.xml with the data of all the objects in the '/system/users/administrator' folder - something like this: <root> <r> <id>6827</id> <type>audio</type> <size>3942414</size> </r> <r> <id>6826</id> <type>image</type> <size>38966</size> </r> <r> <id>6825</id> <type>story</type> <size>69</size> </r> <r> <id>6809</id> <type>audio</type> <size>35296982</size> </r> . . . </root> The output is the result of applying the XSLT to all the objects matching the search condition. The internal report code takes care of retrieving all the matching objects in groups, applying the XSLT and merge the results - so that the system never has to load too many object in memory at the same time.
|
A ReportOptions has a structure like this: <ReportOptions TableName="myTableName"> <Xslt> <xsl:stylesheet> . . . </xsl:stylesheet> </Xslt> <Conditions> . . . </Conditions> <Columns> . . . </Columns> </ReportOptions> It contains: •The list of columns (<Columns>) •The query to perform into the GN4 database (<Conditions>). It can be a SearchConditions or a XQuery. •The xslt stylesheet which transforms the xml returned by the query (<Xslt>) into a fixed format. The xslt stylesheet written into the <Xslt> tag generates the report output xml to have always the following structure: <root> <r> <myColumn1>myValue1</myColumn1> <myColumn2>myValue2</myColumn2> <myColumn3>myValue3</myColumn3> . . . </r> <r> . . . </r> . . . </root>
Note that inside the root tag there is one <r> tag for each row of the report. Inside the <r> tag there are the columns tags containing the actual statistics data. Here is a real sample of the xml returned by GN4 report: <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <r> <Id>31156</Id> <Edition>Globe 04/04/2013 new edition today</Edition> <Total>5</Total> <Complete>0</Complete> <Late>5</Late> <Warning>0</Warning> <Normal>0</Normal> </r> <r> <Id>4813</Id> <Edition>Globe 06/06/2012 test ads 1</Edition> <Total>15</Total> <Complete>0</Complete> <Late>15</Late> <Warning>0</Warning> <Normal>0</Normal> </r> </root>
The report output xml is displayed as table in GNPortal and client applications. Moreover, it can be saved as xml file (or as Excel document) or stored into the reports database.
|