2019-12-25 seo達(dá)人
重分組介紹
語法:<?for-each-group: BASE-GROUP;GROUPING-ELEMENT?>
用法:重分組可以把XML數(shù)據(jù)做重新分組,這樣數(shù)據(jù)的展示就不一定必須按照XML數(shù)據(jù)的結(jié)構(gòu)顯示。例如原來的XML數(shù)據(jù)結(jié)構(gòu)是CD類別->CD信息(名稱,年份,國家,價(jià)格),我們可以用重分組功能按CD年份->CD國家來顯示.
重分組應(yīng)用
1 按照和XML數(shù)據(jù)不同的結(jié)構(gòu)顯示數(shù)據(jù)
XML數(shù)據(jù)格式如下:
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
。。。。。
</CATALOG>
報(bào)表打算按照國家和年份重新分組,用到的重分組如下:
<?for-each-group:CD;COUNTRY?>
<?for-each:current-group();YEAR?>
1
2
這里的current-group()表示當(dāng)前COUNTRY組下的子分組
2 顯示PIVOT報(bào)表
XML數(shù)據(jù)如下:
<ROWSET>
<RESULTS>
<INDUSTRY>Motor Vehicle Dealers</INDUSTRY>
<YEAR>2005</YEAR>
<QUARTER>Q1</QUARTER>
<SALES>1000</SALES>
</RESULTS>
<RESULTS>
<INDUSTRY>Motor Vehicle Dealers</INDUSTRY>
<YEAR>2005</YEAR>
<QUARTER>Q2</QUARTER>
<SALES>2000</SALES>
</RESULTS>
<RESULTS>
<INDUSTRY>Motor Vehicle Dealers</INDUSTRY>
<YEAR>2004</YEAR>
<QUARTER>Q1</QUARTER>
<SALES>3000</SALES>
</RESULTS>
。。。。
</ROWSET>
如果想按年份生成PIVOT表,可以用如下TAG實(shí)現(xiàn):
<?for-each-group@column:RESULTS;YEAR?>
<?YEAR?>
<?end for-each-group?>
<?for-each-group:RESULTS;INDUSTRY?>
<?for-each-group@cell:current-group();YEAR?>
<?sum(current-group()//SALES)?>
<?end for-each-group?>
<?end for-each-group?>
這里的@cell是給每個(gè)組生成一個(gè)CELL
藍(lán)藍(lán)設(shè)計(jì)的小編 http://www.teruid.com