我有一个看起来像这样的 xml 文档:
<units>
<unit>
<year></year>
<month></month>
<qty></qty>
</unit>
</units>
我想在 html 中创建此数据的交叉表视图,其中每一行由一年表示,每一列由一个月表示,每个值包含特定年/月的数量总和。有点像这样:
Jan Feb Mar Apr.... etc
2010 345 0 12 0
2011 1 23 344 0
2012 99 1 23 0.... etc
我的主要问题是:交叉表甚至可以使用 xslt 吗?
我的后续问题是,您能否为 xslt 新手(例如我自己)指明正确的方向,开始尝试完成这项工作?
样本数据:
<units>
<unit>
<year>2010</year>
<month>9</month>
<qty>13320</qty>
</unit>
<unit>
<year>2010</year>
<month>9</month>
<qty>2445</qty>
</unit>
<unit>
<year>2010</year>
<month>10</month>
<qty>8949</qty>
</unit>
<unit>
<year>2010</year>
<month>10</month>
<qty>13650</qty>
</unit>
<unit>
<year>2010</year>
<month>11</month>
<qty>4091</qty>
</unit>
<unit>
<year>2010</year>
<month>11</month>
<qty>6600</qty>
</unit>
<unit>
<year>2010</year>
<month>12</month>
<qty>686</qty>
</unit>
<unit>
<year>2010</year>
<month>12</month>
<qty>678</qty>
</unit>
<unit>
<year>2011</year>
<month>1</month>
<qty>1234</qty>
</unit>
<unit>
<year>2011</year>
<month>1</month>
<qty>12345</qty>
</unit>
<unit>
<year>2011</year>
<month>2</month>
<qty>4500</qty>
</unit>
<unit>
<year>2011</year>
<month>2</month>
<qty>999</qty>
</unit>
<unit>
<year>2011</year>
<month>3</month>
<qty>166</qty>
</unit>
<unit>
<year>2011</year>
<month>3</month>
<qty>456666</qty>
</unit>
<unit>
<year>2011</year>
<month>4</month>
<qty>41113</qty>
</unit>
<unit>
<year>2011</year>
<month>4</month>
<qty>1150</qty>
</unit>
<unit>
<year>2011</year>
<month>5</month>
<qty>4150</qty>
</unit>
<unit>
<year>2011</year>
<month>5</month>
<qty>491</qty>
</unit>
<unit>
<year>2011</year>
<month>6</month>
<qty>11250</qty>
</unit>
<unit>
<year>2011</year>
<month>6</month>
<qty>3400</qty>
</unit>
<unit>
<year>2011</year>
<month>7</month>
<qty>485</qty>
</unit>
<unit>
<year>2011</year>
<month>7</month>
<qty>90</qty>
</unit>
<unit>
<year>2011</year>
<month>8</month>
<qty>1606</qty>
</unit>
<unit>
<year>2011</year>
<month>8</month>
<qty>202000</qty>
</unit>
<unit>
<year>2011</year>
<month>9</month>
<qty>45333</qty>
</unit>
<unit>
<year>2011</year>
<month>9</month>
<qty>13650</qty>
</unit>
<unit>
<year>2011</year>
<month>10</month>
<qty>4050</qty>
</unit>
<unit>
<year>2011</year>
<month>10</month>
<qty>431</qty>
</unit>
<unit>
<year>2011</year>
<month>11</month>
<qty>45713</qty>
</unit>
<unit>
<year>2011</year>
<month>11</month>
<qty>13690</qty>
</unit>
<unit>
<year>2011</year>
<month>12</month>
<qty>4050</qty>
</unit>
<unit>
<year>2011</year>
<month>12</month>
<qty>431</qty>
</unit>
<unit>
<year>2012</year>
<month>1</month>
<qty>2500</qty>
</unit>
<unit>
<year>2012</year>
<month>1</month>
<qty>34100</qty>
</unit>
<unit>
<year>2012</year>
<month>2</month>
<qty>400</qty>
</unit>
<unit>
<year>2012</year>
<month>2</month>
<qty>99</qty>
</unit>
<unit>
<year>2012</year>
<month>3</month>
<qty>1606</qty>
</unit>
<unit>
<year>2012</year>
<month>3</month>
<qty>202000</qty>
</unit>
<unit>
<year>2012</year>
<month>4</month>
<qty>53773</qty>
</unit>
<unit>
<year>2012</year>
<month>4</month>
<qty>13650</qty>
</unit>
<unit>
<year>2012</year>
<month>5</month>
<qty>4150</qty>
</unit>
<unit>
<year>2012</year>
<month>5</month>
<qty>4231</qty>
</unit>
<unit>
<year>2012</year>
<month>6</month>
<qty>278</qty>
</unit>
<unit>
<year>2012</year>
<month>6</month>
<qty>6100</qty>
</unit>
<unit>
<year>2012</year>
<month>7</month>
<qty>406</qty>
</unit>
<unit>
<year>2012</year>
<month>7</month>
<qty>95</qty>
</unit>
</units>