私はムネチアンのグループ化に関するすべての例を調べましたが、アイデアを理解できないように見えるので、かなり厚いに違いありません。出力例の各列の合計を計算しようとしています。
Mike S.
Manager
Region 1
ID Last Quarter ID This Quarter ID Last Month ID This Month ID Last Week ID This Week
Client 1 $ $745,866 $ 745,866 $526,927 $209,624
Client 2 $1,070,345 $2,107,518 $178,800 $1,370,890 $221,381 $40,563
Totals
Region 2
ID Last Quarter ID This Quarter ID Last Month ID This Month ID Last Week ID This Week
Client 1 $ $745,866 $ $745,866 $526,927 $209,624
Client 3 $8,551,014 $9,620,100 $3,133,717 $3,237,586 $847,511 $1,471
Totals
私の入力XMLは次のとおりです。
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="main.xsl"?>
<Person Person_NM="Mike S." Title="Manager">
<AuditGroup AuditGroup_NM="Region 1">
<Audit audit_NM="Client 1" LogoPath="\images\CL1.jpg">
<KPI kpi_NM="IDLastQT" kpi_DESC="ID Last Quarter">
<KPIValue strValue="0.00">
<Display ordinal="1" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDThisQT" kpi_DESC="ID This Quarter">
<KPIValue strValue="745866.05">
<Display ordinal="2" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDLastMN" kpi_DESC="ID Last Month">
<KPIValue strValue="0.00">
<Display ordinal="3" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDThisMN" kpi_DESC="ID This Month">
<KPIValue strValue="745866.05">
<Display ordinal="4" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDLastWK" kpi_DESC="ID Last Week">
<KPIValue strValue="526927.13">
<Display ordinal="5" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDThisWK" kpi_DESC="ID This Week" URLToOpen="http://www.google.com">
<KPIValue strValue="209623.54">
<Display ordinal="6" />
</KPIValue>
</KPI>
</Audit>
<Audit audit_NM="Client 2" LogoPath="\images\CL2.jpg">
<KPI kpi_NM="IDLastQT" kpi_DESC="ID Last Quarter">
<KPIValue strValue="1070345.17">
<Display ordinal="1" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDThisQT" kpi_DESC="ID This Quarter">
<KPIValue strValue="2107517.62">
<Display ordinal="2" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDLastMN" kpi_DESC="ID Last Month">
<KPIValue strValue="178800.08">
<Display ordinal="3" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDThisMN" kpi_DESC="ID This Month">
<KPIValue strValue="1370889.90">
<Display ordinal="4" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDLastWK" kpi_DESC="ID Last Week">
<KPIValue strValue="221380.65">
<Display ordinal="5" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDThisWK" kpi_DESC="ID This Week" URLToOpen="http://www.google.com">
<KPIValue strValue="40563.25">
<Display ordinal="6" />
</KPIValue>
</KPI>
</Audit>
</AuditGroup>
<AuditGroup AuditGroup_NM="Region 2">
<Audit audit_NM="Client 1" LogoPath="\images\CL1.jpg">
<KPI kpi_NM="IDLastQT" kpi_DESC="ID Last Quarter">
<KPIValue strValue="0.00">
<Display ordinal="1" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDThisQT" kpi_DESC="ID This Quarter">
<KPIValue strValue="745866.05">
<Display ordinal="2" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDLastMN" kpi_DESC="ID Last Month">
<KPIValue strValue="0.00">
<Display ordinal="3" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDThisMN" kpi_DESC="ID This Month">
<KPIValue strValue="745866.05">
<Display ordinal="4" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDLastWK" kpi_DESC="ID Last Week">
<KPIValue strValue="526927.13">
<Display ordinal="5" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDThisWK" kpi_DESC="ID This Week" URLToOpen="http://www.google.com">
<KPIValue strValue="209623.54">
<Display ordinal="6" />
</KPIValue>
</KPI>
</Audit>
<Audit audit_NM="Client 3" LogoPath="\images\CL3.jpg">
<KPI kpi_NM="IDLastQT" kpi_DESC="ID Last Quarter">
<KPIValue strValue="8551014.09">
<Display ordinal="1" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDThisQT" kpi_DESC="ID This Quarter">
<KPIValue strValue="9620100.47">
<Display ordinal="2" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDLastMN" kpi_DESC="ID Last Month">
<KPIValue strValue="3133717.02">
<Display ordinal="3" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDThisMN" kpi_DESC="ID This Month">
<KPIValue strValue="3237586.46">
<Display ordinal="4" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDLastWK" kpi_DESC="ID Last Week">
<KPIValue strValue="847510.78">
<Display ordinal="5" />
</KPIValue>
</KPI>
<KPI kpi_NM="IDThisWK" kpi_DESC="ID This Week" URLToOpen="http://www.google.com">
<KPIValue strValue="1471.12">
<Display ordinal="6" />
</KPIValue>
</KPI>
</Audit>
</AuditGroup>
</Person>
私の現在のXSLTは次のとおりです。
<?xml version="1.0"?>
<!--Main.xsl -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<xsl:apply-templates select="Person"/>
</xsl:template>
<xsl:template match="Person">
<html>
<body>
<h2><xsl:value-of select="@Person_NM"/></h2>
<h3><xsl:value-of select="@Title"/></h3>
<xsl:apply-templates select="AuditGroup"/>
</body>
</html>
</xsl:template>
<xsl:template match="AuditGroup">
<table>
<tr>
<td><b><xsl:value-of select="@AuditGroup_NM"/></b></td>
</tr>
<tr>
<td></td>
<td></td>
<xsl:for-each select="Audit">
<xsl:if test="position()=1">
<xsl:for-each select="KPI">
<td><b><xsl:value-of select="@kpi_DESC"/></b></td>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</tr>
<xsl:apply-templates select="Audit"/>
<tr>
<td></td>
<td align="right"><i><b>Totals</b></i></td>
</tr>
</table>
</xsl:template>
<xsl:template match="Audit">
<tr>
<td></td>
<td><xsl:value-of select="@audit_NM"/></td>
<xsl:for-each select="KPI/KPIValue">
<td align="right"><xsl:value-of select="format-number(@strValue, '$###,###')"/></td>
</xsl:for-each>
</tr>
</xsl:template>
</xsl:stylesheet>
値を計算するにはどうすればよいですか?最初にAudit / @ Audit_IDでグループ化し、次にKPI / @ kpi_NMでグループ化する必要があると思います。これには、2つのキーが必要ですが、その後は途方に暮れます。答えをいただければ幸いですが、わかりやすい説明をいただければ幸いです。ありがとう...
マイク
ここではMuenchianのグループ化は必要ありません。キーだけです。ただし、キーには、使用パラメーターとして「複合」値が必要です。この方法で試してください。
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:key name="val" match="KPI" use="concat(../../@AuditGroup_NM, '|', @kpi_NM)" />
<xsl:template match="/Person">
<html>
<body>
<h2><xsl:value-of select="@Person_NM"/></h2>
<h3><xsl:value-of select="@Title"/></h3>
<table border="1">
<xsl:apply-templates select="AuditGroup"/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="AuditGroup">
<xsl:variable name="col" select="Audit[1]/KPI" />
<tr>
<th colspan="{count($col) + 1}"><xsl:value-of select="@AuditGroup_NM"/></th>
</tr>
<tr>
<td></td>
<xsl:for-each select="$col">
<th><xsl:value-of select="@kpi_DESC"/></th>
</xsl:for-each>
</tr>
<xsl:apply-templates select="Audit"/>
<tr>
<td align="right"><i><b>Totals</b></i></td>
<xsl:for-each select="$col">
<td align="right"><xsl:value-of select="format-number(sum(key('val', concat(../../@AuditGroup_NM, '|', @kpi_NM))/KPIValue/@strValue), '$#,###')"/></td>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template match="Audit">
<tr>
<td><xsl:value-of select="@audit_NM"/></td>
<xsl:for-each select="KPI">
<td align="right"><xsl:value-of select="format-number(KPIValue/@strValue, '$#,###')"/></td>
</xsl:for-each>
</tr>
</xsl:template>
</xsl:stylesheet>
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加