用XSL格式化XML输出,双列,分组,遇到难题了,高手请进!
这段时间在研究XML,遇到了一个极其头痛的问题。我在尝试用XML做一个新闻模块的分组显示模板的时候,遇到了XML格式化的问题。发在这里,希望能碰上高手指点一下。
XML文件内容如下:
<?xml version= "1.0 " encoding= "gb2312 "?>
<?xml-stylesheet type= "text/xsl " href= "list.xsl "?>
<newsinfo>
<clslist>
<cls cls_id= "01 " cls_name= "新闻类别01 " lvl= "0 " parentid= "0 "/>
<cls cls_id= "11 " cls_name= "新闻类别11 " lvl= "1 " parentid= "01 "/>
<cls cls_id= "12 " cls_name= "新闻类别12 " lvl= "1 " parentid= "01 "/>
<cls cls_id= "13 " cls_name= "新闻类别13 " lvl= "1 " parentid= "01 "/>
<cls cls_id= "111 " cls_name= "新闻类别111 " lvl= "2 " parentid= "11 "/>
<cls cls_id= "112 " cls_name= "新闻类别112 " lvl= "2 " parentid= "11 "/>
<cls cls_id= "113 " cls_name= "新闻类别113 " lvl= "2 " parentid= "11 "/>
<cls cls_id= "121 " cls_name= "新闻类别121 " lvl= "2 " parentid= "12 "/>
<cls cls_id= "122 " cls_name= "新闻类别122 " lvl= "2 " parentid= "12 "/>
<cls cls_id= "131 " cls_name= "新闻类别131 " lvl= "2 " parentid= "13 "/>
</clslist>
<newslist>
<news news_id= "1 " news_title= "新闻标题1 " create_date= "2007-3-27 9:53:22 " head_count= "0 " cls_id= "01 "/>
<news news_id= "2 " news_title= "新闻标题2 " create_date= "2007-5-23 14:41:38 " head_count= "30 " cls_id= "01 "/>
<news news_id= "5 " news_title= "新闻标题5 " create_date= "2007-5-23 14:58:00 " head_count= "11 " cls_id= "01 "/>
<news news_id= "6 " news_title= "新闻标题6 " create_date= "2007-5-23 15:00:06 " head_count= "1 " cls_id= "01 "/>
<news news_id= "7 " news_title= "新闻标题7 " create_date= "2007-5-23 15:15:46 " head_count= "1 " cls_id= "11 "/>
<news news_id= "15 " news_title= "新闻标题15 " create_date= "2007-5-23 15:57:05 " head_count= "1 " cls_id= "13 "/>
<news news_id= "9 " news_title= "新闻标题9 " create_date= "2007-5-23 15:34:25 " head_count= "1 " cls_id= "12 "/>
<news news_id= "10 " news_title= "新闻标题10 " create_date= "2007-5-23 15:39:49 " head_count= "2 " cls_id= "12 "/>
<news news_id= "11 " news_title= "新闻标题11 " create_date= "2007-5-23 15:47:57 " head_count= "1 " cls_id= "12 "/>
<news news_id= "12 " news_title= "新闻标题12 " create_date= "2007-5-23 15:55:08 " head_count= "21 " cls_id= "12 "/>
<news news_id= "4 " news_title= "新闻标题4 " create_date= "2007-5-23 14:52:04 " head_count= "1 " cls_id= "01 "/>
<news news_id= "13 " news_title= "新闻标题13 " create_date= "2007-5-23 16:05:04 " head_count= "1 " cls_id= "13 "/>
<news news_id= "42 " news_title= "新闻标题42 " create_date= "2007-5-23 14:55:41 " head_count= "2 " cls_id= "122 "/>
<news news_id= "14 " news_title= "新闻标题14 " create_date= "2007-5-23 16:06:27 " head_count= "6 " cls_id= "13 "/>
<news news_id= "3 " news_title= "新闻标题3 " create_date= "2007-5-23 14:49:22 " head_count= "1 " cls_id= "01 "/>
<news news_id= "16 " news_title= "新闻标题16 " create_date= "2007-5-23 16:09:23 " head_count= "1 " cls_id= "13 "/>
<news news_id= "8 " news_title= "新闻标题8 " create_date= "2007-5-23 15:29:10 " head_count= "1 " cls_id= "11 "/>
<news news_id= "17 " news_title= "新闻标题17 " create_date= "2007-5-23 15:48:58 " head_count= "1 " cls_id= "13 "/>
<news news_id= "18 " news_title= "新闻标题18 " create_date= "2007-5-23 15:41:17 " head_count= "6 " cls_id= "13 "/>
<news news_id= "19 " news_title= "新闻标题19 " create_date= "2007-5-23 15:36:36 " head_count= "2 " cls_id= "111 "/>
<news news_id= "21 " news_title= "新闻标题21 " create_date= "2007-5-23 15:16:53 " head_count= "1 " cls_id= "111 "/>
<news news_id= "22 " news_title= "新闻标题22 " create_date= "2007-5-23 15:01:02 " head_count= "1 " cls_id= "111 "/>
<news news_id= "23 " news_title= "新闻标题23 " create_date= "2007-5-23 14:53:12 " head_count= "1 " cls_id= "111 "/>
<news news_id= "24 " news_title= "新闻标题24 " create_date= "2007-3-27 9:57:14 " head_count= "0 " cls_id= "111 "/>
<news news_id= "25 " news_title= "新闻标题25 " create_date= "2007-3-27 9:51:05 " head_count= "0 " cls_id= "112 "/>
<news news_id= "26 " news_title= "新闻标题26 " create_date= "2007-3-27 9:49:49 " head_count= "0 " cls_id= "112 "/>
<news news_id= "27 " news_title= "新闻标题27 " create_date= "2007-5-23 14:54:38 " head_count= "1 " cls_id= "113 "/>
<news news_id= "28 " news_title= "新闻标题28 " create_date= "2007-5-23 15:02:35 " head_count= "1 " cls_id= "113 "/>
<news news_id= "29 " news_title= "新闻标题29 " create_date= "2007-5-23 15:17:53 " head_count= "1 " cls_id= "113 "/>
<news news_id= "20 " news_title= "新闻标题20 " create_date= "2007-5-23 15:30:37 " head_count= "2 " cls_id= "111 "/>
<news news_id= "30 " news_title= "新闻标题30 " create_date= "2007-5-23 15:32:01 " head_count= "1 " cls_id= "113 "/>
<news news_id= "32 " news_title= "新闻标题32 " create_date= "2007-5-23 15:42:11 " head_count= "2 " cls_id= "113 "/>
<news news_id= "33 " news_title= "新闻标题33 " create_date= "2007-5-23 15:50:39 " head_count= "1 " cls_id= "121 "/>
<news news_id= "34 " news_title= "新闻标题34 " create_date= "2007-5-23 15:58:16 " head_count= "2 " cls_id= "121 "/>
<news news_id= "35 " news_title= "新闻标题35 " create_date= "2007-5-23 16:07:12 " head_count= "3 " cls_id= "121 "/>
<news news_id= "36 " news_title= "新闻标题36 " create_date= "2007-5-23 16:08:00 " head_count= "1 " cls_id= "121 "/>
<news news_id= "31 " news_title= "新闻标题31 " create_date= "2007-5-23 15:38:09 " head_count= "1 " cls_id= "113 "/>
<news news_id= "37 " news_title= "新闻标题37 " create_date= "2007-5-23 15:59:42 " head_count= "5 " cls_id= "121 "/>
<news news_id= "38 " news_title= "新闻标题38 " create_date= "2007-5-23 15:51:23 " head_count= "1 " cls_id= "121 "/>
<news news_id= "39 " news_title= "新闻标题39 " create_date= "2007-5-23 15:43:11 " head_count= "1 " cls_id= "121 "/>
<news news_id= "40 " news_title= "新闻标题40 " create_date= "2007-5-23 15:20:12 " head_count= "1 " cls_id= "121 "/>
<news news_id= "41 " news_title= "新闻标题41 " create_date= "2007-5-23 15:03:39 " head_count= "1 " cls_id= "122 "/>
<news news_id= "43 " news_title= "新闻标题43 " create_date= "2007-5-23 15:04:57 " head_count= "1 " cls_id= "131 "/>
<news news_id= "44 " news_title= "新闻标题44 " create_date= "2007-5-23 15:22:14 " head_count= "1 " cls_id= "131 "/>
<news news_id= "45 " news_title= "新闻标题45 " create_date= "2007-5-23 15:44:17 " head_count= "2 " cls_id= "131 "/>
<news news_id= "46 " news_title= "新闻标题46 " create_date= "2007-5-23 15:52:35 " head_count= "1 " cls_id= "131 "/>
<news news_id= "47 " news_title= "新闻标题47 " create_date= "2007-5-23 15:53:48 " head_count= "1 " cls_id= "131 "/>
<news news_id= "31 " news_title= "新闻标题31 " create_date= "2007-5-23 15:38:09 " head_count= "1 " cls_id= "113 "/>
<news news_id= "48 " news_title= "新闻标题48 " create_date= "2007-5-23 15:45:14 " head_count= "1 " cls_id= "131 "/>
<news news_id= "49 " news_title= "新闻标题49 " create_date= "2007-5-23 15:23:41 " head_count= "1 " cls_id= "131 "/>
<news news_id= "50 " news_title= "新闻标题50 " create_date= "2007-5-23 15:06:07 " head_count= "1 " cls_id= "131 "/>
<news news_id= "51 " news_title= "新闻标题51 " create_date= "2007-5-23 15:08:54 " head_count= "1 " cls_id= "131 "/>
<news news_id= "52 " news_title= "新闻标题52 " create_date= "2007-5-23 15:46:35 " head_count= "2 " cls_id= "131 "/>
<news news_id= "42 " news_title= "新闻标题42 " create_date= "2007-5-23 14:55:41 " head_count= "2 " cls_id= "122 "/>
<news news_id= "53 " news_title= "新闻标题53 " create_date= "2007-5-23 15:10:15 " head_count= "1 " cls_id= "131 "/>
<news news_id= "54 " news_title= "新闻标题54 " create_date= "2007-5-23 15:11:18 " head_count= "1 " cls_id= "131 "/>
<news news_id= "55 " news_title= "新闻标题55 " create_date= "2007-5-23 15:13:06 " head_count= "1 " cls_id= "131 "/>
</newslist>
</newsinfo>
[解决办法]
建议先将XML做线性转树形,否则上面XML失去意义。
转换的文章参考这里:http://blog.csdn.net/cds27/archive/2006/06/08/780942.aspx