﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-kapok-随笔分类-个人项目所需资料</title><link>http://www.blogjava.net/kapok/category/900.html</link><description>垃圾桶,嘿嘿，我藏的这么深你们还能找到啊，真牛！</description><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 15:57:44 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 15:57:44 GMT</pubDate><ttl>60</ttl><item><title>简单记录以下。论文用</title><link>http://www.blogjava.net/kapok/archive/2005/04/13/3134.html</link><dc:creator>笨笨</dc:creator><author>笨笨</author><pubDate>Wed, 13 Apr 2005 05:40:00 GMT</pubDate><guid>http://www.blogjava.net/kapok/archive/2005/04/13/3134.html</guid><wfw:comment>http://www.blogjava.net/kapok/comments/3134.html</wfw:comment><comments>http://www.blogjava.net/kapok/archive/2005/04/13/3134.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kapok/comments/commentRss/3134.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kapok/services/trackbacks/3134.html</trackback:ping><description><![CDATA[<A href="http://www.cnblogs.com/William_Fire/articles/125108.html">http://www.cnblogs.com/William_Fire/articles/125108.html</A><BR><BR><A href="http://www.cnblogs.com/William_Fire/articles/125819.html">http://www.cnblogs.com/William_Fire/articles/125819.html</A><BR><BR><BR><BR><A href="http://www.cnblogs.com/william_fire/articles/126665.html">http://www.cnblogs.com/william_fire/articles/126665.html</A><A href="http://www.cnblogs.com/william_fire/articles/126665.html"></A><BR><A href="http://www.cnblogs.com/tintown/archive/2005/03/23/124395.html">http://www.cnblogs.com/tintown/archive/2005/03/23/124395.html</A><BR><BR><BR><A href="http://www.cnblogs.com/tintown/category/12787.html">http://www.cnblogs.com/tintown/category/12787.html</A><BR><A href="http://www.cnblogs.com/tintown/archive/2005/04/04/131784.html">http://www.cnblogs.com/tintown/archive/2005/04/04/131784.html</A><BR><BR><BR><A href="http://www.cnblogs.com/tintown/archive/2005/04/04/131784.html?Pending=true#PostPost">http://www.cnblogs.com/tintown/archive/2005/04/04/131784.html?Pending=true#PostPost</A><BR><BR><BR><A href="http://www.cnblogs.com/tintown/archive/2005/04/07/132876.html">http://www.cnblogs.com/tintown/archive/2005/04/07/132876.html</A><BR><BR><A href="http://blog.sunmast.com/sunmast/articles/816.aspx">http://blog.sunmast.com/sunmast/articles/816.aspx</A><BR><BR>ADO.NET对象模型：<BR><A href="http://www.phome.net/document/net/200504/net111246243813950.html">http://www.phome.net/document/net/200504/net111246243813950.html</A><BR><IMG height=418 src="http://www.phome.net/d/file/document/net/2005-04-02/0442c2b7c534a4e24d69d393bf36bcd5.jpg" width=436><BR><BR><A href="http://www.phome.net/document/net/200504/net111246243713949.html">http://www.phome.net/document/net/200504/net111246243713949.html</A><BR><IMG src="file:///C:/Documents%20and%20Settings/IJ1147/Local%20Settings/Temporary%20Internet%20Files/Content.IE5/GRTB66FP/7a1e5676cdeb55c0b2c250e6cda46d20%5B1%5D.jpg"><BR><BR><IMG height=253 src="http://www.phome.net/d/file/document/net/2005-04-02/bb4502f4244aea539a18c873c1b5366b.jpg" width=378><BR><IMG height=305 src="http://www.phome.net/d/file/document/net/2005-04-02/8137feebd8f8d86e60649e9aae46c7f0.jpg" width=483>&nbsp;<BR><BR><BR>
<DIV align=center><FONT size=3><STRONG>ADO.NET--什么是关系型数据库<BR></STRONG></FONT></DIV><BR><A href="http://www.phome.net/document/net/200504/net111246244913952.html">http://www.phome.net/document/net/200504/net111246244913952.html</A><BR><BR><BR><A href="http://blog.csdn.net/jabby12/archive/2004/08/02/59221.aspx">ADO.NET对象模型</A> <BR><A href="http://blog.csdn.net/jabby12/archive/2004/08/02/59221.aspx">http://blog.csdn.net/jabby12/archive/2004/08/02/59221.aspx</A><BR>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ADO.NET是专门为帮助开发人员开发高效的多层数据库应用程序设计的。ADO.NET对象模型可分为两类：一类为“连接的”，一类为“断开连接的”对象，后者允许将查询结果保存在内存中进行处理。</P>
<P>”连接的“对象模型顾名思义，它是直接与数据库进行连接操作;“断开连接”的对象模型可以说是建立在“连接的”对象模型的基础上进行的，因为它必须先进行一次“连接的”操作，才能得到所需的结果。</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;举个例 ：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P>SqlConnection con=new SqlConnection("server=localhost;database=db,uid=sa,pwd=;");</P>
<P>SqlDataAdapter ad=new SqlDataAdapter("select * from table",con);</P>
<P>DataSet ds=new Dataset();</P>
<P>ad.Fill(ds,"table"); </P>
<P>//注意这里已经将从数据库里查询出来的结果放到一个Dataset对象里，从此刻开始，你就开始使用“断开连接”的对象模型来对数据库进行操作，DataSet对象是一个在内存中的”虚数据表“，你可以对它进行任何操作而不影响数据库，可以对它进行排序，修改，查询，增加，删除。而如果你想更改数据库内容的话，也可以通过DataSet对象来操作，很简单，调用它的update()方法即可完成更新数据库。也可以使用它的GetChanges()方法来获取只更改过的行，它返回一个DataSet，这个Dataset不同于调用GetChanges()方法的那个，返回的这个只是它的一张子表，也就是更改过的数据，利用此方法可以大大地提高多层ADO.NET应用程序的性能。DataSet类还有一个Merge方法用来合并两个DataSet对象的数据，ADO.NET默认覆盖被调用Merge()方法的DataSet中的行。</P>
<P>ADO.NET还提供了一种强类型的DATASET对象：它可以帮助你简化建立数据访问应用程序的过程。例如：有个表叫table,其中有一列叫column你可以这样来访问此列：</P>
<P>vb.net:&nbsp;&nbsp;&nbsp;&nbsp;Dim ds as DataSet </P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(ds.table(0).column);&nbsp;&nbsp;&nbsp;(table(0).表示table表中的第1行）</P>
<P>c#:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DataSet ds;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(ds.table[0].column);&nbsp; (table[0].表示table表中的第1行）</P>
<P>是不是很简洁: ^_^</P>
<P>关于DataSet里面还有好多东西方便用如：DataTable,DataView,DataRow,DataColumn,DataRelation,Constraint一大堆的好东西，在以后的日志中会提到！<BR></P><BR><BR>&nbsp;&nbsp;可见，在分层的时候，我们会增加一个实体层，它的作用如下： <BR>&nbsp;&nbsp;① 将显示数据和实际的存储区域隔离，保证了业务的独立性，提高了可重用性。 <BR>&nbsp;&nbsp;② 在业务层和表现层之间传递数据。（如果没有实体层的话，我们需要把表的每个字段作为一个参数在它们之间传递，如果修改的话，将需要影响到程序的各个层） <BR>&nbsp;&nbsp;③ 提供更大的可收缩性。 <BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;2） 业务实体层的几种选择方案及其优缺点。 <BR>&nbsp;&nbsp;在.NET环境下实现业务实体有下面的几种选择： <BR>&nbsp;&nbsp;① DataReader BE 具有最快的读取速度，用于只读的场合，不具有OO的概念。 <BR>&nbsp;&nbsp;② XML BE 可以与XML Reader和DataSet转换。缺点：性能低，验证、解析、显示、排序等都很复杂。 <BR>&nbsp;&nbsp;③ Generic DataSet BE 优点：数据绑定等。缺点：客户端必须通过集合来获取数据，没有类型，实例化开销大，调度性能低。 <BR>&nbsp;&nbsp;④ Typed DataSet BE 优点：由类型，可以进行类型检查。缺点：只能从DataSet继承，部署不方便，可扩展性差，实例化开销大，调度性能低。 <BR>&nbsp;&nbsp;⑤ Custom BE　优点：性能调优，代码更具有可读性，用自定义实体类定义一个良好的接口，将复杂问题隐藏在其中。缺点：设计开发都很复杂，需要自己去实现CURD操作，自己去实现数据绑定，工作量很大。 <BR>&nbsp;&nbsp;⑥ O/R Mapping的实现 它具有自定义类的所有优点，同时实现了CRUD，数据绑定等操作。 <BR><BR>关于ObjectSpaces 和<U><FONT color=#800080>llblgen </FONT></U><BR><A href="http://www.llblgen.com/defaultgeneric.aspx">http://www.llblgen.com/defaultgeneric.aspx</A><BR><A href="http://www.sinzy.net/blog/Read.asp?ID=44&amp;BID=931">http://www.sinzy.net/blog/Read.asp?ID=44&amp;BID=931</A><BR><BR><BR><A href="http://www.csdn.net/develop/author/NetAuthor/sun2bin/">http://www.csdn.net/develop/author/NetAuthor/sun2bin/</A><A href="http://www.cnblogs.com/william_fire/articles/126665.html"></A><img src ="http://www.blogjava.net/kapok/aggbug/3134.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kapok/" target="_blank">笨笨</a> 2005-04-13 13:40 <a href="http://www.blogjava.net/kapok/archive/2005/04/13/3134.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Implementing Data Transfer Object in .NET with a Typed DataSet</title><link>http://www.blogjava.net/kapok/archive/2005/04/12/3173.html</link><dc:creator>笨笨</dc:creator><author>笨笨</author><pubDate>Tue, 12 Apr 2005 04:49:00 GMT</pubDate><guid>http://www.blogjava.net/kapok/archive/2005/04/12/3173.html</guid><wfw:comment>http://www.blogjava.net/kapok/comments/3173.html</wfw:comment><comments>http://www.blogjava.net/kapok/archive/2005/04/12/3173.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kapok/comments/commentRss/3173.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kapok/services/trackbacks/3173.html</trackback:ping><description><![CDATA[<H1 class=dtH1><A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ImpDTOtypedDataSet.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ImpDTOtypedDataSet.asp</A></H1>
<H1 class=dtH1><A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconworkingwithtypeddataset.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconworkingwithtypeddataset.asp</A></H1>
<H1 class=dtH1>Implementing Data Transfer Object in .NET with a Typed DataSet</H1>
<P>
<TABLE cellSpacing=0 cellPadding=0 bgColor=#eeeeee>
<TBODY>
<TR>
<TD><IMG height=26 alt=? src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_TL.gif" width=26 border=0></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Data Column: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_toptab_D1.gif" width=37 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Application Column: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_toptab_A1-up.gif" width=37 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Deployment Column: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_toptab_D1.gif" width=37 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Infrastructure Column: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_toptab_I1.gif" width=45 border=0></A></TD></TR>
<TR>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Architecture Row: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_sidetab_A.gif" width=26 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Data Architecture: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_1.gif" width=37 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Application Architecture: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_2.gif" width=37 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Deployment Architecture: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_3.gif" width=37 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Infrastructure Architecture: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_4.gif" width=45 border=0></A></TD></TR>
<TR>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/designpatoverview.aspx"><IMG height=26 alt="Design Row: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_sidetab_D.gif" width=26 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Data Design: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_5.gif" width=37 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Application Design: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_6.gif" width=37 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Deployment Design: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_7.gif" width=37 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Infrastructure Design: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_8.gif" width=45 border=0></A></TD></TR>
<TR>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/implpatoverview.aspx"><IMG height=26 alt="Implementation Row" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_sidetab_I-up.gif" width=26 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Data Implementation: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_9.gif" width=37 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Application Implementation: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_10-up.gif" width=37 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Deployment Implementation: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_11.gif" width=37 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MSpatterns.asp"><IMG height=26 alt="Infrastructure Implementation: select for more on pattern organization" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_12.gif" width=45 border=0></A></TD></TR>
<TR>
<TD><IMG height=27 alt=? src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_BL.gif" width=26 border=0></TD>
<TD><A href="http://msdn.microsoft.com/practices"><IMG height=27 alt="Complete List of patterns &amp; practices" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_logo1.gif" width=37 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/practices"><IMG height=27 alt="Complete List of patterns &amp; practices" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_logo2.gif" width=37 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/practices"><IMG height=27 alt="Complete List of patterns &amp; practices" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_logo3.gif" width=37 border=0></A></TD>
<TD><A href="http://msdn.microsoft.com/practices"><IMG height=27 alt="Complete List of patterns &amp; practices" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/MapNav_logo4.gif" width=45 border=0></A></TD></TR></TBODY></TABLE></P>
<P>Version 1.0.0</P>
<P><A href="http://www.gotdotnet.com/Community/Workspaces/workspace.aspx?id=0aac3f2c-53c1-45d1-b79d-81f7c9382cc7"><FONT color=gray>GotDotNet community for collaboration on this pattern</FONT></A></P>
<P><A href="http://msdn.microsoft.com/practices/"><FONT color=gray>Complete List of patterns &amp; practices</FONT></A></P>
<P></P>
<H2 class=dtH1>
<P>Context</P></H2>
<P>You are implementing a distributed application with the .NET Framework. The client application displays a form that requires making multiple calls to an ASP.NET Web service to satisfy a single user request. Based on performance measurements you have found that making multiple calls degrades application performance. To increase performance, you would like to retrieve all the data that the user request requires in a single call to the Web service. </P>
<H2 class=dtH1>
<P>Background </P></H2>
<BLOCKQUOTE class=dtBlock>
<P>
<P><B>Note:</B> The following is the same sample application that is described in <A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/ImpDTODataSet.asp"><I>Implementing Data Transfer Object in .NET with a DataSet</I></A>. </P>
<P></P>
<P>
<P>The following is a simplified Web application that communicates with an ASP.NET Web service to deliver recording and track information to the user. The Web service in turn calls a database to provide the data that the client requests. The following sequence diagram depicts the interaction among the application, the Web service, and the database for a typical page. </P>
<P></P></BLOCKQUOTE>
<P><IMG src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/Imp_DTO_with_DataSet_Fig01.gif"></P>
<P><HEAD3>Figure 1: Behavior of a typical user request</HEAD3></P>
<P>
<P>Figure 1 illustrates the sequence of calls needed to fulfill the entire user request. The first call retrieves the recording information, and the second call retrieves the track information for the specified recording. In addition, the Web service must make separate calls to the database to retrieve the required information. </P>
<P></P>
<H3 class=dtH1>
<P>Database Schema</P></H3>
<P></P>
<P>
<P>The schema that is used in the example shown in Figure 2 depicts a <B>recording</B> record that has a one-to-many relationship with a <B>track</B> record. </P>
<P></P>
<P><IMG src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/Imp_DTO_with_DataSet_Fig02.gif"></P>
<P><HEAD3>Figure 2: Schema for sample application</HEAD3></P>
<H3 class=dtH1>
<P>Implementing a DTO</P></H3>
<P></P>
<P>
<P>One way to improve the performance of this user request is to package all the required data into a data transfer object (DTO) that can be sent with a single call to the Web service. This reduces the overhead associated with two separate calls and allows you to use a single connection with the database to retrieve both the recording and the track information. For a detailed description of how this improves performance, see the <A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/DesDTO.asp"><I>Data Transfer Object</I></A> pattern. </P>
<P></P>
<H2 class=dtH1>
<P>Implementation Strategy</P></H2>
<P>A typed <B>DataSet</B> is a generated subclass of <B>System.Data.DataSet</B>. You provide an XML schema file which is then used to generate a strongly-typed wrapper around the <B>DataSet</B>. The following two code samples illustrate the differences. The first sample is implemented with an ordinary <B>DataSet</B>: </P><PRE class=code> 

DataTable dataTable = dataSet.Tables["recording"];
DataRow row = dataTable.Rows[0];
string artist = (string)row["artist"];
 </PRE>
<P>This sample indicates that you need to know the table and column names to access the tables and fields contained in the <B>DataSet</B>. You also have to know the return type of the Artist field to ensure that the correct cast is done. If you do not use the correct type, you will get a runtime error. The following is the same example implemented with a typed <B>DataSet</B>:</P><PRE class=code> 

   Recording recording = typedDataSet.Recordings[0];
   string artist = recording.Artist; 
 </PRE>
<P>This example demonstrates the benefits that the typed interface provides. You no longer have to refer to table or column by name and you do not have to know that the return type of the Artist column is a string. A typed <B>DataSet</B> defines a much more explicit interface that is verifiable at compile time instead of at runtime. In addition to the strongly-typed interface a typed <B>DataSet</B> also can be used in all places a <B>DataSet</B> can be used; therefore, it also can be used as a DTO. It is loaded in a similar fashion as a <B>DataSet</B> and it can be serialized to and from XML. In comparison to an ordinary <B>DataSet</B> you do have to write and maintain an XML schema that describes the typed interface. The Microsoft Visual Studio .NET development system provides a number of tools that simplify the creation and maintenance of the schema.The rest of this implementation strategy outlines the steps required in creating a typed <B>DataSet</B> for the sample application just described. </P>
<H3 class=dtH1>
<P>Creating a Typed DataSet</P></H3>
<P></P>
<P>
<P>A typed DataSet is generated from an XML schema. Visual Studio .NET provides a drag-and-drop tool which automates the creation of the schema (see Figure 3) and the generation of the typed DataSet classes. If you do not use Visual Studio.NET, you can write the XML schema and use a command-line tool called XSD.exe to generate the typed DataSet. For detailed instructions on both of these methods, see "Typed DataSets in ADO.NET" from the May 2001 issue of <I>.NET Developer</I> [Wildermuth02]. </P>
<P></P>
<P><IMG src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/Imp_DTO_with_Typed_DataSet_Fig03.gif"></P>
<P><HEAD3>Figure 3: Visual Studio .NET DataSet file type</HEAD3></P>
<H4 class=dtH1>
<P>RecordingDto.xsd</P></H4>
<P></P>
<P>
<P>The following is the XML schema for the DTO to be used in this example. It combines both the recording table along with its associated track records in a single typed DataSet named <B>RecordingDto</B>:</P>
<P></P><PRE class=code> 

&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;xs:schema id="RecordingDto" targetNamespace="http://msdn.microsoft.com/practices/RecordingDto.xsd"
   elementFormDefault="qualified" attributeFormDefault="qualified" xmlns="http://tempuri.org/RecordingDTO.xsd"
   xmlns:mstns="http://msdn.microsoft.com/practices/RecordingDto.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:codegen="urn:schemas-microsoft-com:xml-msprop"&gt;
   &lt;xs:element name="RecordingDto" msdata:IsDataSet="true"&gt;
      &lt;xs:complexType&gt;
         &lt;xs:choice maxOccurs="unbounded"&gt;
            &lt;xs:element name="recording" codegen:typedName="Recording" codegen:typedPlural="Recordings"
               codegen:typedChildren="Track"&gt;
               &lt;xs:complexType&gt;
                  &lt;xs:sequence&gt;
                     &lt;xs:element name="id" type="xs:long" codegen:typedName="Id" /&gt;
                     &lt;xs:element name="title" type="xs:string" codegen:typedName="Title" /&gt;
                     &lt;xs:element name="artist" type="xs:string" codegen:typedName="Artist" /&gt;
                  &lt;/xs:sequence&gt;
               &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="track" codegen:typedName="Track" codegen:typedPlural="Tracks" codegen:typedParent="Recording"&gt;
               &lt;xs:complexType&gt;
                  &lt;xs:sequence&gt;
                     &lt;xs:element name="id" type="xs:long" codegen:typedName="Id" /&gt;
                     &lt;xs:element name="title" type="xs:string" codegen:typedName="Title" /&gt;
                     &lt;xs:element name="duration" type="xs:string" codegen:typedName="Duration" /&gt;
                     &lt;xs:element name="recordingId" type="xs:long" codegen:typedName="RecordingId" /&gt;
                  &lt;/xs:sequence&gt;
               &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;
         &lt;/xs:choice&gt;
      &lt;/xs:complexType&gt;
      &lt;xs:unique name="RecordingDTOKey1" msdata:PrimaryKey="true"&gt;
         &lt;xs:selector xpath=".//mstns:recording" /&gt;
         &lt;xs:field xpath="mstns:id" /&gt;
      &lt;/xs:unique&gt;
      &lt;xs:unique name="RecordingDTOKey2" msdata:PrimaryKey="true"&gt;
         &lt;xs:selector xpath=".//mstns:track" /&gt;
         &lt;xs:field xpath="mstns:id" /&gt;
      &lt;/xs:unique&gt;
      &lt;xs:keyref name="recordingtrack" refer="mstns:RecordingDTOKey1"&gt;
         &lt;xs:selector xpath=".//mstns:track" /&gt;
         &lt;xs:field xpath="mstns:recordingId" /&gt;
      &lt;/xs:keyref&gt;
   &lt;/xs:element&gt;
&lt;/xs:schema&gt;
 </PRE>
<P>This schema is not the exact file produced by Visual Studio .NET. It is annotated with a number of attributes that are prefixed from the <B>codegen</B> namespace. This modification is desirable because the code that is generated does not adhere to the .NET naming conventions. For example, without the modification, Visual Studio .NET would generate a <B>track</B> class that corresponds to the track table, whereas according to conventions used in the .NET Framework the class should be named <B>Track</B>. To change the name of the class that is generated, you must add the codegen:typedName attribute to the element definition in the XML schema:</P><PRE class=code> 

&lt;xs:element name="track" codegen:typedName="Track"&gt;
   
&lt;/element&gt;
 </PRE>
<P>There are a number of other attributes besides codegen:typedName. For a detailed description of all the attributes, see "Typed DataSets in ADO.NET" from the May 2001 issue of <I>.NET Developer</I> [Wildermuth02].</P>
<H3 class=dtH1>
<P>Filling a Typed DataSet from the Database</P></H3>
<P></P>
<P>
<P>The following code example demonstrates how to fill a typed <B>DataSet</B> with the data that the sample application requires. This includes the specific <B>recording</B> record and all of its associated <B>track</B> records. The difference between this code and filling an ordinary <B>DataSet</B> is that you do not need to explicitly define the relationship between the recording and track records. </P>
<P></P>
<H4 class=dtH1>
<P>Assembler.cs</P></H4>
<P></P>
<P>
<P>Just as in <I>Implementing a Data Transfer Object in .NET with a DataSet</I>, an <B>Assembler</B> class maps the actual database calls into the typed <B>DataSet</B>: </P>
<P></P><PRE class=code> 

using System;
using System.Data;
using System.Data.SqlClient;

using Recording;

public class Assembler
{
   public static RecordingDto CreateRecordingDto(long id)
   {
      string selectCmd = 
         String.Format(
         "select * from recording where id = {0}",
         id);

      SqlConnection myConnection = 
         new SqlConnection(
         "server=(local);database=recordings;Trusted_Connection=yes;");
      SqlDataAdapter myCommand = new SqlDataAdapter(selectCmd, 
         myConnection);

      RecordingDto dto = new RecordingDto();
      myCommand.Fill(dto, "recording");

      String trackSelect = 
         String.Format(
         "select * from Track where recordingId = {0} order by Id",
         id);

      SqlDataAdapter trackCommand = 
         new SqlDataAdapter(trackSelect, myConnection);
      trackCommand.Fill(dto, "track");

      return dto;
   }
}
 </PRE>
<BLOCKQUOTE class=dtBlock>
<P>
<P><B>Note:</B> The example shown here is not meant to describe the only way to fill the typed <B>DataSet</B>. There are many ways to retrieve this data from the database. For example, you could use a stored procedure. </P>
<P></P></BLOCKQUOTE>
<H3 class=dtH1>
<P>Using a Typed DataSet in an ASP.NET Page</P></H3>
<P></P>
<P>
<P>As mentioned previously, a typed <B>DataSet</B> inherits from <B>System.Data.DataSet</B>. This means that it can be substituted for a <B>DataSet</B>. For example, when using the .NET user interface controls (Web Forms or Windows Forms) a typed <B>DataSet</B> can be used in all places you could use a <B>DataSet</B>. The sample application page shown in the following code example uses two <B>DataGrid</B> controls, <B>RecordingGrid</B> and <B>TrackGrid</B>. You can use the typed <B>DataSet</B>, <B>RecordingDto</B> when setting the <B>DataSource</B> properties on the controls because a typed <B>DataSet</B> inherits from <B>DataSet</B>. </P>
<P></P><PRE class=code> 

using System;
using System.Data;
using RecordingApplication.localhost;

public class RetrieveForm : System.Web.UI.Page
{
   private RecordingCatalog catalog = new RecordingCatalog();
 
   // 

   protected void Button1_Click(object sender, System.EventArgs e)
   {
      string stringId = TextBox1.Text;
      long id = Convert.ToInt64(stringId);

      RecordingDTO dto = catalog.Get(id);
      RecordingGrid.DataSource = dto.recording;
      RecordingGrid.DataBind();

      TrackGrid.DataSource = dto.track;
      TrackGrid.DataBind();
   }
}
 </PRE>
<H2 class=dtH1>
<P>Tests</P></H2>
<P>Because the typed <B>DataSet</B> is generated by tools in the .NET Framework, you do not need to write tests to verify that it functions correctly. In the following tests, you are testing that the <B>Assembler</B> class loaded the typed <B>DataSet</B> correctly. </P>
<H3 class=dtH1>
<P>AssemblerFixture.cs</P></H3>
<P></P><PRE class=code> 

using NUnit.Framework;
using System.Data;
using Recording;

[TestFixture]
public class AssemblerFixture
{
   private RecordingDto dto;
   private RecordingDto.Recording recording;
   private RecordingDto.Track[] tracks; 
   
   [SetUp]
   public void Init()
   {
      dto = Assembler.CreateRecordingDto(1234);
      recording = dto.Recordings[0];
      tracks = recording.GetTracks();
   }

   [Test]
   public void RecordingCount()
   {
      Assert.Equals(1, dto.Recordings.Rows.Count);
   }

   [Test]
   public void RecordingTitle()
   {
      Assert.Equals("Up", recording.Title.Trim());
   }


   [Test]
   public void RecordingChild()
   {
      Assert.Equals(10, tracks.Length);

      foreach(RecordingDto.Track track in tracks)
      {
         Assert.Equals(recording.Id, track.RecordingId);
      }
   }

   [Test]
   public void TrackParent()
   {
      RecordingDto.Track track = tracks[0];
      RecordingDto.Recording parent = track.Recording;
      Assert.Equals("Up", parent.Title.Trim());
   }

   [Test]
   public void TrackContent()
   {
      RecordingDto.Track track = tracks[0];
      Assert.Equals("Darkness", track.Title.Trim());
   }

   [Test]
   public void InvalidRecording()
   {
      RecordingDto dto = Assembler.CreateRecordingDto(-1);
      Assert.Equals(0, dto.Recordings.Rows.Count);
      Assert.Equals(0, dto.Tracks.Rows.Count);
   }
}
 </PRE>
<P>These tests describe how to access the individual elements of the <B>DataSet</B>. Because of the use of a typed <B>DataSet</B>, the test code does not require the actual column names and does not require the return type to be cast. Comparing these tests with the ones described in <I>Implementing Data Transfer Object in .NET with a DataSet</I> reveals the differences between using a strongly-typed interface and a generic interface. The strongly-typed interface is easier to use and understand. It also provides the added benefit of compile-time checking on return types. 
<H2 class=dtH1>
<P>Resulting Context</P></H2>
<P>Implementing DTO with a typed <B>DataSet</B> shares a number of the same benefits and liabilities as implementing DTO with a <B>DataSet</B>; however, certain benefits and liabilities are unique to a typed-<B>DataSet</B> implementation.</P>
<H3 class=dtH1>
<P>Benefits</P></H3>
<P></P>
<P>
<P>The typed <B>DataSet</B> shares the following benefits with a <B>DataSet</B> when used as a DTO: </P>
<P></P>
<LI>
<P><B>Development tool support</B>. Because the <B>DataSet</B> class is implemented in ADO.NET, there is no need to design and implement the DTO. There is also extensive support in Visual Studio for automating the creation and filling of <B>DataSet</B> and typed-<B>DataSet</B> objects. </P>
<LI>
<P><B>Integration with controls</B>. A <B>DataSet</B> works directly with the built-in controls in Windows Forms and Web Forms, making it a logical choice as a DTO. </P>
<LI>
<P><B>Serialization</B>. The <B>DataSet</B> comes complete with the ability to serialize itself into XML. Not only is the content serialized, but the schema for the content is also present in the serialization. </P>
<LI>
<P><B>Disconnected database model</B>. The <B>DataSet</B> represents a snapshot of the current contents of the database. This means that you can alter the contents of the <B>DataSet</B> and subsequently use the <B>DataSet</B> as the means to update the database. </P>
<LI>
<P>An additional benefit that might persuade you to use a typed <B>DataSet</B> as opposed to an ordinary <B>DataSet</B> is the strongly-typed interface of the typed <B>DataSet</B>. A typed <B>DataSet</B>, as described here, generates classes that can be used to access the contained data. The classes present an interface which defines how the class is to be used in a more explicit manner. This removes the need for casting which was present in the <B>DataSet</B> implementation. </P>
<H3 class=dtH1>
<P>Liabilities</P></H3>
<P></P>
<P>
<P>The typed <B>DataSet</B> shares the following liabilities with a <B>DataSet</B> when used in the context of a DTO: </P>
<P></P>
<LI>
<P><B>Interoperability</B>. Because the <B>DataSet</B> class is part of ADO.NET, it is not the best choice for a DTO in cases requiring interoperability with clients that are not running the .NET Framework.. You can still use <B>DataSet</B>, however, the client will be forced to parse the XML and build its own representation. If interoperability is a requirement, see <I>Implementing Data Transfer Object in .NET with Serialized Objects</I>. </P>
<LI>
<P><B>Stale data</B>. The typed <B>DataSet</B>, like a <B>DataSet</B>, is disconnected from the database. It is filled with a snapshot of the data in the database when it is constructed. This implies that the actual data in the database may be different from what is contained in the typed <B>DataSet</B>. For reading primarily static data, this is not a major issue. If the data is constantly changing, however, using any kind of <B>DataSet</B> is not recommended. </P>
<LI>
<P><B>Potential for performance degradation</B>. Instantiating and filling a <B>DataSet</B> can be an expensive operation. Serializing and deserializing a <B>DataSet</B> can also be very time consuming. A good rule of thumb for using a <B>DataSet</B> is that a <B>DataSet</B> is a good choice when you are using more than one table or relying on the capability of the <B>DataSet</B> to update the database. If you are displaying the results from a single table, then using a <B>DataReader</B> with strongly-typed objects may offer better performance. For more information, see <I>Implementing Data Transfer Object in .NET with Serialized Objects</I>. </P>
<LI>
<P>The following are additional liabilities when using a typed <B>DataSet</B> as opposed to an ordinary <B>DataSet</B>: </P>
<LI>
<P><B>A typed DataSet is still a DataSet. </B>A typed <B>DataSet</B> can be substituted at runtime with a <B>DataSet</B>. This means that even though the strongly-typed interface exists, programmers can still access the data without the typed interface. A possible result of doing this is that there could be parts of the code which couple the application tightly to the <B>DataSet</B> table and column names. </P>
<LI>
<P><B>The need for an XML schema</B>. When using a typed DataSet you have to create and maintain an XML schema to describe the strongly-typed interface. Visual Studio .NET provides a number of tools to assist in this process, but nevertheless you still have to maintain an additional file. </P>
<H2 class=dtH1>
<P>Related Patterns</P></H2>
<P>For more information, see the following related patterns:</P>
<LI>
<P><A href="http://msdn.microsoft.com/library/en-us/dnpatterns/html/ImpDTODataSet.asp"><I>Implementing Data Transfer Object in .NET with a DataSet</I></A>.</P>
<LI>
<P><I>Implementing Data Transfer Object in .NET with Serialized Objects</I>.</P>
<LI>
<P><I>Assembler</I>. In <I>Enterprise Application Architecture Patterns</I>, Fowler defines <I>Assembler</I> as a specialized instance of the <I>Mapper</I> pattern <I>[Fowler03].</I></P>
<H2 class=dtH1>
<P>Acknowledgments</P></H2>
<P>[Beau02] Beauchemin, Bob. <I>Essential ADO.NET</I>. Addison-Wesley, 2002.</P>
<P>[Fowler03] Fowler, Martin. <I>Enterprise Application Architecture Patterns</I>. Addison-Wesley, 2003.</P>
<P>[Wildermuth01] Wildermuth, Shawn. "Typed DataSets in ADO.NET." <I>.NET Developer</I>. May 2001.</P>
<P><IMG alt="Patterns Practices" src="http://msdn.microsoft.com/library/en-us/dnpatterns/html/PATTPRAC.gif"></P><!-- End Content --></LI><img src ="http://www.blogjava.net/kapok/aggbug/3173.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kapok/" target="_blank">笨笨</a> 2005-04-12 12:49 <a href="http://www.blogjava.net/kapok/archive/2005/04/12/3173.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[zt]数据访问接口体系及数据对象模型探讨(Beat 1.0) .3</title><link>http://www.blogjava.net/kapok/archive/2005/04/12/3170.html</link><dc:creator>笨笨</dc:creator><author>笨笨</author><pubDate>Tue, 12 Apr 2005 02:34:00 GMT</pubDate><guid>http://www.blogjava.net/kapok/archive/2005/04/12/3170.html</guid><wfw:comment>http://www.blogjava.net/kapok/comments/3170.html</wfw:comment><comments>http://www.blogjava.net/kapok/archive/2005/04/12/3170.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kapok/comments/commentRss/3170.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kapok/services/trackbacks/3170.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 数据访问接口体系及数据对象模型探讨(Beat 1.0) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n...&nbsp;&nbsp;<a href='http://www.blogjava.net/kapok/archive/2005/04/12/3170.html'>阅读全文</a><img src ="http://www.blogjava.net/kapok/aggbug/3170.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kapok/" target="_blank">笨笨</a> 2005-04-12 10:34 <a href="http://www.blogjava.net/kapok/archive/2005/04/12/3170.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[ZT]数据访问接口体系及数据对象模型探讨(Beat 1.0) 2</title><link>http://www.blogjava.net/kapok/archive/2005/04/12/3169.html</link><dc:creator>笨笨</dc:creator><author>笨笨</author><pubDate>Tue, 12 Apr 2005 02:32:00 GMT</pubDate><guid>http://www.blogjava.net/kapok/archive/2005/04/12/3169.html</guid><wfw:comment>http://www.blogjava.net/kapok/comments/3169.html</wfw:comment><comments>http://www.blogjava.net/kapok/archive/2005/04/12/3169.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kapok/comments/commentRss/3169.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kapok/services/trackbacks/3169.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: http://dev.csdn.net/develop/article/21/21019.shtm数据访问接口体系及数据对象模型探讨(Beat 1.0) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&...&nbsp;&nbsp;<a href='http://www.blogjava.net/kapok/archive/2005/04/12/3169.html'>阅读全文</a><img src ="http://www.blogjava.net/kapok/aggbug/3169.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kapok/" target="_blank">笨笨</a> 2005-04-12 10:32 <a href="http://www.blogjava.net/kapok/archive/2005/04/12/3169.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[ZT]数据访问接口体系及数据对象模型探讨(Beat 1.0)</title><link>http://www.blogjava.net/kapok/archive/2005/04/12/3168.html</link><dc:creator>笨笨</dc:creator><author>笨笨</author><pubDate>Tue, 12 Apr 2005 02:31:00 GMT</pubDate><guid>http://www.blogjava.net/kapok/archive/2005/04/12/3168.html</guid><wfw:comment>http://www.blogjava.net/kapok/comments/3168.html</wfw:comment><comments>http://www.blogjava.net/kapok/archive/2005/04/12/3168.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kapok/comments/commentRss/3168.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kapok/services/trackbacks/3168.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: http://dev.csdn.net/develop/article/21/21018.shtm数据访问接口体系及数据对象模型探讨(Beat 1.0)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n...&nbsp;&nbsp;<a href='http://www.blogjava.net/kapok/archive/2005/04/12/3168.html'>阅读全文</a><img src ="http://www.blogjava.net/kapok/aggbug/3168.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kapok/" target="_blank">笨笨</a> 2005-04-12 10:31 <a href="http://www.blogjava.net/kapok/archive/2005/04/12/3168.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[CMS][ZT]内容管理系统(CMS)的设计和选型</title><link>http://www.blogjava.net/kapok/archive/2005/04/02/2741.html</link><dc:creator>笨笨</dc:creator><author>笨笨</author><pubDate>Sat, 02 Apr 2005 07:07:00 GMT</pubDate><guid>http://www.blogjava.net/kapok/archive/2005/04/02/2741.html</guid><wfw:comment>http://www.blogjava.net/kapok/comments/2741.html</wfw:comment><comments>http://www.blogjava.net/kapok/archive/2005/04/02/2741.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kapok/comments/commentRss/2741.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kapok/services/trackbacks/2741.html</trackback:ping><description><![CDATA[<TABLE style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" cellSpacing=0 cellPadding=0 width="90%" border=0>
<TBODY>
<TR>
<TD class=oblog_t_4><SPAN class=style1><FONT size=3><IMG src="http://www.blog.edu.cn/images/face/1.gif"><A href="http://www.blog.edu.cn/blog.asp?name=yonghui&amp;subjectid=20298">[CMS]<A href="http://www.blog.edu.cn/more.asp?name=yonghui&amp;id=117470">[ZT]内容管理系统(CMS)的设计和选型</A></FONT></SPAN></TD></TR>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD>
<DIV align=right><SPAN class=oblog_text>蒲永辉 发表于 2005-3-30 8:26:00</SPAN></DIV></TD></TR></TBODY></TABLE><SPAN class=oblog_text><BR><A>　作者： 车东 Email: chedongATbigfoot.com/chedongATchedong.com 
<P><!--StartFragment --></P>
<P>版权声明：可以任意转载，转载时请务必以超链接形式标明文章原始出处和作者信息及本声明<BR></A><A href="http://www.chedong.com/tech/cms.html">http://www.chedong.com/tech/cms.html</A><A></P>
<P>关键词："content manage system" cms 内容管理系统<BR></P>
<P>内容摘要：<BR></P>
<UL>
<LI></A><A href="http://www.chedong.com/tech/cms.html#intro">内容管理系统概述</A><A> 
<LI></A><A href="http://www.chedong.com/tech/cms.html#cms">内容管理系统的选型</A><A> 
<LI></A><A href="http://www.chedong.com/tech/cms.html#ads">广告管理系统的选型</A><A> 
<LI></A><A href="http://www.chedong.com/tech/cms.html#bbs">论坛/社区系统的选型</A><A><BR>
<LI></A><A href="http://www.chedong.com/tech/cms.html#wysiwyg">所见即所得编辑器的选型</A><A><BR>
<LI></A><A href="http://www.chedong.com/tech/cms.html#upload">图片上传和文件管理组件</A><A><BR></LI></UL>
<H2></A><A name=intro></A><A>内容管理系统概述</H2>
<P><BR>内容管理系统是一个很泛的概念：从商业门户网站的新闻系统到个人的Weblog都可以称作发布系统。<BR></P>
<UL>
<LI>框架型：本身不包含任何应用实现，只是提供了底层框架，具体应用需要一定的二次开发，比如Cocoon，Vignette； 
<LI>应用型：本身是一个面向具体类型的应用实现，已经包含了新闻/评论管理，投票，论坛，WIKI等一些子系统。比如：</A><A href="http://www.postnuke.com/">postNuke</A><A> </A><A href="http://www.xoops.org/">xoops</A><A>等；<BR></LI></UL>
<P>但无论如何，在发布系统选型之前，首先了解自己的实际需求是最重要的：想根据现成系统将自己的需求硬往上照搬是非常不可取的。访问量，权限控制和各种功能需求。每个模块和功能自己都比较清晰一点以后，再去网上找找类似的实现：你会发现其实每个环节到目前上都有比较成熟的实现了，而且还在不断完善和发展中，如果没有：你的需求太特殊，或者可以尝试分解成更小的系统组合实现。<BR></P>
<P>内容管理系统被分离成以下几个层面：各个层面优先考虑的需求不同<BR></P>
<OL>
<LI>后台业务子系统管理（管理优先：内容管理）：新闻录入系统，BBS论坛子系统，全文检索子系统等，针对不同系统的方便管理者的内容录入：所见即所得的编辑管理界面等，清晰的业务逻辑：各种子系统的权限控制机制等； 
<LI>Portal系统（表现优先：模板管理）：大部分最终的输出页面：网站首页，子频道/专题页，新闻详情页一般就是各种后台子系统模块的各种组合，这种发布组合逻辑是非常丰富的，Portal系统就是负责以上这些后台子系统的组合表现管理； 
<LI>前台发布（效率优先：发布管理）：面向最终用户的缓存发布，和搜索引擎spider的URL设计等……</LI></OL>
<P>内容管理和表现的分离：很多成套的CMS系统没有把后台各种子系统和Portal分离开设计，以至于在Portal层的模板表现管理和新闻子系统的内容管理逻辑混合在一起，甚至和BBS等子系统的管理都耦合的非常高，整个系统会显得非常庞杂。而且这样的系统各个子系统捆绑的比较死，如果后台的模块很难改变。但是如果把后台各种子系统内容管理逻辑和前台的表现/发布分离后，Portal和后台各个子系统之间只是数据传递的关系：Portal只决定后台各个子系统数据的取舍和表现，而后台的各个子系统也都非常容易插拔。<BR><BR>内容管理和数据分发的分离：需要要Portal系统设计的时候注意</A><A href="http://www.chedong.com/tech/cache.html">可缓存性（Cache Friendly）性设计</A><A>：CMS后台管理和发布机制，本身不要过多考虑“效率”问题，只要最终页面输出设计的比较Cacheable，效率问题可通过更前端专门的缓存服务器解决。<BR><BR>此外，就是除了面向最终浏览器用户外，还要注意面向</A><A href="http://www.chedong.com/tech/google_url.html">搜索引擎友好(Search engine Friendly)的URL设计</A><A>：通过URL REWRITE转向或基于PATH_INFO的参数解析使得动态网页在链接（URI）形式上更像静态的目录结构，方便网站内容被搜索引擎收录；<BR><BR></P><PRE>---------------    ---------------     ---------------                    <BR>|新闻管理子系统|   | BBS论坛子系统|    | 商城子系统  |                    <BR>---------------    ---------------     ---------------                    <BR>      |       \     /    |     \           /   内                         <BR>      |        ----------|---   \         /    容   &lt;== 业务子系统（零件生产）<BR>      |           /      |   \   \       /     管                         <BR>    ---------------      |    ---------------  理                         <BR>    |专题制作子系统|     |    |全文检索子系统|                            <BR>    ---------------      |    ---------------                             <BR>                 \       |          /                                     <BR>-------------------------|---------------------------------------------   <BR>                   \     |        /            频                         <BR>                   ---------------             道   &lt;== Portal系统（产品组装）<BR>                   | Portal 系统 |             管                         <BR>                   ---------------             理                         <BR>                         |                                                <BR>-------------------------|---------------------------------------------   <BR>                         |                     前                         <BR>                         |                     台   &lt;== 发布系统（分发代理）  <BR>                  ---------------              发                         <BR>                  |前台发布系统 |              布                         <BR>                  ---------------                                         <BR>                    /        \                                            <BR>                   /          \                                           <BR>      ---------------      ---------------                                <BR>      | 用户浏览器   |     |Search Engine|                                <BR>      ---------------      ---------------                                <BR><BR></PRE>
<P>这里，我把在内容发布系统选型中找到的一些资料总结如下： </P>
<OL></OL>
<P></P>
<H2></A><A name=cms></A><A>内容管理系统的选型</H2>
<P></P>
<P>关键词：CMS Content Manage System<BR></P>
<P>CMS行业研究<BR></A><A href="http://www.cmswatch.com/">http://www.cmswatch.com</A><A><BR></A><A href="http://www.cmsreview.com/">http://www.cmsreview.com</A><A><BR></A><A href="http://www.cmsinfo.org/">http://www.cmsinfo.org</A><A><BR></P>
<P>CMS讨论邮件列表<BR></A><A href="http://www.cms-list.org/">http://www.cms-list.org</A><A> </P>
<P>商业软件和开源项目列表：<BR></A><A href="http://directory.google.com/Top/Computers/Software/Internet/Site_Management/Content_Management/">http://directory.google.com/Top/Computers/Software/Internet/Site_Management/Content_Management/</A><A><BR></P>
<P>推荐：基于XML的发布框架<BR></A><A href="http://cocoon.apache.org/">http://cocoon.apache.org/</A><A><BR></P>
<P>具体实现复杂程度可能会根据需求的不同而不同，但越是大型的系统越是需要分工：将内容（数据），表现（模板）和应用逻辑（程序）尽可能分离和对这3 者的管理。<BR></P>
<P>Portal---门户系统 <BR>Open source Projects: <BR></A><A href="http://jportlet.sourceforge.net/">http://jportlet.sourceforge.net/</A><A> <BR>Apache Software Foundation: Jakarta JetSpeed 1.3<BR>JetSpeed home page: </A><A href="http://jakarta.apache.org/jetspeed/site/index.html">http://jakarta.apache.org/jetspeed/site/index.html</A><A> <BR>JetSpeed Portlet API: </A><A href="http://cvs.apache.org/viewcvs/jakarta-jetspeed/proposals/portletAPI/">http://cvs.apache.org/viewcvs/jakarta-jetspeed/proposals/portletAPI/</A><A><BR></A><A href="http://www.liferay.com/home/index.jsp">http://www.liferay.com/home/index.jsp</A><A> <BR></A><A href="http://basicportal.com/">http://basicPortal.com/</A><A> <BR></A><A href="http://www.jahia.org/">http://www.jahia.org/</A><A> <BR></A><A href="http://jporta.sourceforge.net/">http://jporta.sourceforge.net/</A><A> <BR><BR>商业软件：<BR>BEA WebLogic Portal - </A><A href="http://edocs.bea.com/wlp/docs81/javadoc/com/bea/portal/model/Portlet.html">http://edocs.bea.com/wlp/docs81/javadoc/com/bea/Portal/model/Portlet.html</A><A> <BR>IBM Websphere Portal - </A><A href="http://www.software.ibm.com/wsdd/zones/portal/">http://www.software.ibm.com/wsdd/zones/Portal/</A><A> <BR>Oracle Portal Developer Kit - </A><A href="http://portalstudio.oracle.com/">http://Portalstudio.oracle.com/</A><A> <BR><BR>其它: <BR>P***L - </A><A href="http://jakarta.apache.org/jetspeed/site/psml.html">http://jakarta.apache.org/jetspeed/site/psml.html</A><A><BR>BEA: Web Logic Portal 4.0 </A><A href="http://www.bea.com/products/weblogic/portal/index.shtml">http://www.bea.com/products/weblogic/Portal/index.shtml</A><A><BR>IBM: WebSphere Portal 2.1 </A><A href="http://www-4.ibm.com/software/webservers/portal/">http://www-4.ibm.com/software/webservers/Portal/</A><A> <BR>iPlanet: iPlanet Portal Server 3.0 </A><A href="http://www.iplanet.com/products/iplanet_portal/home_portal.html">http://www.iplanet.com/products/iplanet_Portal/home_Portal.html</A><A><BR>Oracle: Oracle 9i Portal </A><A href="http://www.oracle.com/ip/deploy/ias/portal/index.html">http://www.oracle.com/ip/deploy/ias/Portal/index.html</A><A><BR>SAP Portal: </A><A href="http://www.iviewstudio.com/">http://www.iviewstudio.com</A><A><BR>Epicentric Portal: </A><A href="http://www.epicentric.com/solutions/products/efs/">http://www.epicentric.com/solutions/products/efs/</A><A><BR><BR>参考：<BR></A><A href="http://www.waferproject.org/index.html">Wafer：Java开发框架研究</A><A><BR>http://www.waferproject.org/index.html<BR><BR></A><A href="http://udoo.51.net/mt/archives/000011.html">门户(Portal)系统相关开发框架：</A><A><BR>http://udoo.51.net/mt/archives/000011.html<BR></P>
<H2></A><A name=ads></A><A>广告管理系统 </H2>
<P>关键词：ad server</P>
<P>广告系统和内容的分离，可以大大降低系统之间的关联度。<BR>&nbsp;<BR>专业行业研究网站：<BR></A><A href="http://adres.internet.com/">http://adres.internet.com</A><A><BR><BR>相关厂商和开源项目：<BR></A><A href="http://directory.google.com/Top/Computers/Programming/Languages/PHP/Scripts/Ad_Management/?il=1">http://directory.google.com/Top/Computers/Programming/Languages/PHP/Scripts/Ad_Management/?il=1</A><A><BR></A><A href="http://directory.google.com/Top/Computers/Software/Internet/Servers/Advertising/?tc=1">http://directory.google.com/Top/Computers/Software/Internet/Servers/Advertising/?tc=1</A><A><BR></A><A href="http://www.jspin.com/home/apps/admanage?cob=winedit">http://www.jspin.com/home/apps/admanage?cob=winedit</A><A><BR></A><A href="http://www.scriptdex.com/dex/php_ad_management.shtml">http://www.scriptdex.com/dex/php_ad_management.shtml</A><A><BR></P>
<P>推荐：<BR></A><A href="http://www.phpadsnew.com/">http://www.phpadsnew.com/</A><A> 功能性比较强 <BR></A><A href="http://oasis.sourceforge.net/">http://oasis.sourceforge.net/</A><A> 免费 基于日志记录和定期导入MYSQL统计，可以负载50万请求/每小时 以上<BR><BR>如果看重广告的第3方特性，可以选择第三方服务：<BR></A><A href="http://www.doubleclick.net/">http://www.doubleclick.net/</A><A><BR></A><A href="http://www.allyes.com/">http://www.allyes.com/</A><A><BR></P>
<H2></A><A name=bbs></A><A>论坛/社区系统 </H2>
<P>关键词： BBS FORUM<BR><BR>论坛软件介绍：<BR></A><A href="http://directory.google.com/Top/Computers/Internet/Web_Design_and_Development/Message_Boards/">http://directory.google.com/Top/Computers/Internet/Web_Design_and_Development/Message_Boards/</A><A><BR><BR>推荐：<BR></A><A href="http://www.phpbb.com/">http://www.phpBB.com</A><A> PHP + MySQL open source<BR></A><A href="http://www.vbulletin.com/order/">http://www.vbulletin.com/order/</A><A> PHP + MySQL&nbsp; 有付费的商业支持85－160$<BR><BR></A><A href="http://www.jivesoftware.com/products/pricing.jsp">http://www.jivesoftware.com/products/pricing.jsp</A><A> 商业论坛系统，1000$－2500$ 有知识库扩展应用<BR></A><A href="http://yazd.yasna.com/features.jsp">http://yazd.yasna.com/features.jsp</A><A> 基于 Java<BR></P>
<H2></A><A name=wysiwyg></A><A>所见即所得（WYSIWYG）编辑器</H2>
<P>在内容的录入管理方面，所见即所得是比较重要的，这样可以大大简化对系统中布局排版的需求。<BR>基于浏览器的WYSIWYG（所见即所得）编辑器是CMS设计中，编辑工具的主要考虑方面。目前主要是通过JAVASCRIPT调用IE或其他浏览器的内置方法实现。其中基于IE5.5浏览器的实现最为简洁。这里有一个完整的例子：<BR></A><A href="http://www.devarticles.com/c/a/HTML/Building-a-WYSIWYG-HTML-Editor-Part-1/">Building a WYSIWYG HTML Editor Part 1/2</A><A><BR></A><A href="http://www.devarticles.com/c/a/HTML/Building-a-WYSIWYG-HTML-Editor-Part-2/">Building a WYSIWYG HTML Editor Part 2/2</A><A><BR><BR>主要功能：<BR></P>
<UL>
<LI>能够通过JAVASCRIPT实现的基本功能：加粗，斜体字，居中，添加链接，添加图片，模式切换：HTML和文本模式的切换， 
<LI>Word垃圾代码过滤 
<LI>图片上载接口：图片上载最好通过其他独立模块实现。</LI></UL>
<P>选型指标：<BR></P>
<UL>
<LI>不依赖服务器端代码：只通过JAVASCRIPT或客户端控件实现代码，可以保证以后系统迁移的方便。 
<LI>WORD垃圾代码过滤</LI></UL>
<P>可视化编辑器大全：<BR></A><A href="http://www.bris.ac.uk/is/projects/cms/ttw/ttw.html">http://www.bris.ac.uk/is/projects/cms/ttw/ttw.html</A><A><BR><BR>推荐：<BR></A><A href="http://www.aine.be/aynhtml/">http://www.aine.be/aynhtml/</A><A><BR><BR></P>
<H2></A><A name=upload></A><A>图片/文件上传组建</H2>
<P>图片和文件等非结构化数据还是分别使用另外的服务解决比较好。这样可以大大简化CMS本身的复杂程度。<BR><BR>推荐：<BR>文件上传：<BR></A><A href="http://jakarta.apache.org/commons/">Apache Commons项目</A><A><BR>http://jakarta.apache.org/commons/<BR><BR></A><A href="http://rsb.info.nih.gov/ij/">ImageJ：图片处理缩略图生成和水印等</A><A><BR>http://rsb.info.nih.gov/ij/<BR><BR>关于Blog系统的选型，目前主流的基于PHP的包括：<BR>· Nucleus 3.0 </A><A href="http://www.nucleuscms.org/">www.nucleuscms.org</A><A><BR>· pmachine 2.3 </A><A href="http://www.pmachine.com/">www.pmachine.com</A><A><BR>· b2evolution 0.9.0.3 </A><A href="http://www.b2evolution.net/">www.b2evolution.net</A><A><BR>· Serendipity 0.6 </A><A href="http://www.s9y.org/">www.s9y.org</A><A><BR>· WordPress 1.2 </A><A href="http://www.wordpress.org/">www.wordpress.org</A><A><BR>· bBlog 0.7.3 </A><A href="http://www.bblog.com/">www.bblog.com</A><A><BR>· pLog 0.3.1 </A><A href="http://www.plogworld.org/">www.plogworld.org</A><A><BR>· Simplog .9 </A><A href="http://www.simplog.org/">www.simplog.org</A><A><BR>· Textpattern 1.18a </A><A href="http://www.textpattern.com/">www.textpattern.com</A><A> </P></A></SPAN></TD></TR></TBODY></TABLE><img src ="http://www.blogjava.net/kapok/aggbug/2741.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kapok/" target="_blank">笨笨</a> 2005-04-02 15:07 <a href="http://www.blogjava.net/kapok/archive/2005/04/02/2741.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java Tree</title><link>http://www.blogjava.net/kapok/archive/2005/03/31/2657.html</link><dc:creator>笨笨</dc:creator><author>笨笨</author><pubDate>Thu, 31 Mar 2005 06:08:00 GMT</pubDate><guid>http://www.blogjava.net/kapok/archive/2005/03/31/2657.html</guid><wfw:comment>http://www.blogjava.net/kapok/comments/2657.html</wfw:comment><comments>http://www.blogjava.net/kapok/archive/2005/03/31/2657.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kapok/comments/commentRss/2657.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kapok/services/trackbacks/2657.html</trackback:ping><description><![CDATA[<TABLE class=tf width="98%" align=center border=0>
<TBODY>
<TR>
<TD class=bw width="100%"><FONT class=htd id=font_word style="FONT-SIZE: 14px; FONT-FAMILY: 宋体, Verdana, Arial, Helvetica, sans-serif"><A href="http://www.matrix.org.cn/article/335.html">http://www.matrix.org.cn/article/335.html</A><BR><BR>原创 作者-- joinme<BR><BR>Tree型结构，Tree图不管在哪个领域都是一个比较吃香的东东。在自己的网站或项目中有一个tree型图或tree型结构的权限（或角色，和数据库设计相关），总能有那么一点点成就感。^_^<BR>&nbsp;&nbsp;&nbsp;&nbsp;这篇文章就把我自己在这方面应用的实践整理一下拿出来。为您详细介绍了在Tree有关方面应用的完整实践。<BR>实例如下：<A href="http://www.matrix.org.cn/upload/forum/2003716130558.jpg" target=_blank><IMG height=375 alt="" src="http://www.matrix.org.cn/upload/forum/2003716130558.jpg" width=500 onload="javascript:if(this.width>screen.width-215)this.width=screen.width-215" align=center border=0 dypop="按此在新窗口浏览图片"></A><BR>左边的tree图的实现方式是通过javascript+jsp实现。如果是为了实现逻辑上的tree结构的维护，采用的是xml解决方案。<BR>现在这里说一下,javascript+jsp的表现层的实现。这里的javascript并不是唯一的选择，可以在网上下到类似的javascript(毕竟是共享的嘛。:)&nbsp;).点<A href="http://www.matrix.org.cn/upload/article/a2003716131846.rar" target=_blank>这里</A>可以下载相关代码.<BR>其中的test.htm是javascript例子代码:<BR>&lt;script&nbsp;type="text/javascript"&nbsp;src="include/dtree.js"&gt;&lt;/script&gt;<BR>&lt;div&nbsp;class="dtree"&gt;<BR>&nbsp;&lt;script&nbsp;type="text/javascript"&gt;<BR>&nbsp;&nbsp;&lt;!--<BR>&nbsp;&nbsp;d&nbsp;=&nbsp;new&nbsp;dTree('d');<BR>&nbsp;&nbsp;d.add(0,-1,'文章目录');<BR>d.add(3,0,'技术与方案','admin.php?module=article&amp;action=catelist&amp;cid=3','','_blank');<BR>d.add(5,0,'新闻中心','admin.php?module=article&amp;action=catelist&amp;cid=5');<BR>d.add(34,5,'新闻中心','admin.php?module=article&amp;action=catelist&amp;cid=5');<BR>d.add(35,34,'新闻中心','admin.php?module=article&amp;action=catelist&amp;cid=5');<BR>d.add(36,35,'新闻中心','admin.php?module=article&amp;action=catelist&amp;cid=5');<BR>d.add(37,36,'新闻中心','admin.php?module=article&amp;action=catelist&amp;cid=5');<BR>d.add(38,37,'新闻中心','admin.php?module=article&amp;action=catelist&amp;cid=5');<BR>d.add(7,6,'网络知识','admin.php?module=article&amp;action=catelist&amp;cid=7');<BR>d.add(8,6,'配置手册','admin.php?module=article&amp;action=catelist&amp;cid=8');<BR>d.add(9,6,'网络安全','admin.php?module=article&amp;action=catelist&amp;cid=9');<BR>d.add(10,3,'解决方案','admin.php?module=article&amp;action=catelist&amp;cid=10');<BR>d.add(11,10,'局域网','admin.php?module=article&amp;action=catelist&amp;cid=11');<BR>d.add(12,10,'宽带接入','admin.php?module=article&amp;action=catelist&amp;cid=12');<BR>d.add(6,3,'网络技术','admin.php?module=article&amp;action=catelist&amp;cid=6');<BR>document．write(d);<BR><BR>--&gt;<BR>&lt;/script&gt;<BR>&lt;/div&gt;<BR>"d.add(3,0,'技术与方案','admin.php?module=article&amp;action=catelist&amp;cid=3','','_blank');<BR>"中的"3"是当前节点，"0"是父节点,"技术与方案"是tree上显示的节点名,"admin.php?......"指向的url."_blank"是指向的窗口。<BR>从上可以看出，这个javascript已经把tree图实现的大部分工作已经做好了。只要我们传入对应的数据就可以了。<BR>首先是数据库结构。从上可以看出，有节点名，节点id,父节点id,节点url,节点target,还可以有个节点状态（比如是激活或休眠，很常用用一种用法），当然还可以有其它属性，那就要根据项目的需要了。其实只要抓住一点，有唯一节点id和唯一父节点id就可以了（面向对象）就可以了。<BR>有了数据库结构，然后要实现tree图就是根据一定的限制（比如权限，最后对应为tree结构的子集（当然也必须是完整的tree结构））取出符合条件并且完整的tree结构的数据（我采用的解决方法是把权限对应的节点的上溯父节点都取出来保证tree结构的完整性,具体可以看<A href="http://www.matrix.org.cn/article_view.asp?id=246" target=_blank>java&amp;xml心得(三)</A>）.<BR>假设我们已经完成了上述的工作，那么要实现tree图的代码应该如下:<BR>.........<BR>&lt;html&gt;<BR>&lt;head&gt;<BR>&lt;title&gt;Untitled&nbsp;document．lt;/title&gt;<BR>&lt;meta&nbsp;http-equiv="Content-Type"&nbsp;content="text/html;&nbsp;charset=gb2312"&gt;<BR>&lt;link&nbsp;rel="stylesheet"&nbsp;href="images/cj_styles.css"&nbsp;type="text/css"&gt;<BR>&lt;script&nbsp;type="text/javascript"&nbsp;src="include/dtree.js"&gt;&lt;/script&gt;<BR>&lt;/head&gt;<BR><BR>&lt;body&nbsp;bgcolor="#FFFFFF"&nbsp;text="#000000"&nbsp;leftmargin="2"&nbsp;topmargin="0"&gt;<BR>&lt;div&nbsp;class="dtree"&gt;<BR><BR>&lt;script&nbsp;type="text/javascript"&gt;<BR>&nbsp;&nbsp;&lt;!--<BR><BR>&nbsp;&lt;%<BR>&nbsp;if(!finds){<BR>&nbsp;&nbsp;out.println("document．write('没有权限');");<BR>&nbsp;}else{<BR>&nbsp;Result&nbsp;rsShow=ResultFactory.getResult("Vector");<BR>&nbsp;rsShow.setConnType("jdbc");<BR>&nbsp;rsShow.setSql(tempsqls);<BR>&nbsp;rsShow.Create();<BR>&nbsp;out.println("d=new&nbsp;dTree('d');");<BR>&nbsp;out.println("d.add(0,-1,'权限列表');");<BR>&nbsp;String&nbsp;t_tree_id,t_tree_id_p,t_tree_name,t_tree_address,t_tree_target;<BR>&nbsp;&nbsp;while(rsShow.next()){<BR>&nbsp;&nbsp;&nbsp;t_tree_id=rsShow.getString("tree_id");<BR>&nbsp;&nbsp;&nbsp;t_tree_id_p=rsShow.getString("tree_id_p");<BR>&nbsp;&nbsp;&nbsp;t_tree_name=rsShow.getString("tree_name");<BR>&nbsp;&nbsp;&nbsp;t_tree_address=rsShow.getString("tree_address");<BR>&nbsp;&nbsp;&nbsp;t_tree_address+="?tree_id="+rsShow.getString("tree_id")+"&amp;tree_name="+rsShow.getString("tree_name");&nbsp;//t_tree_address+="edit/list.jsp?tree_id="+rsShow.getString("tree_id")+"&amp;tree_name="+rsShow.getString("tree_name");<BR>&nbsp;&nbsp;&nbsp;t_tree_target=rsShow.getString("tree_target").length()&gt;0?rsShow.getString("tree_target"):"mainFrame";<BR>&nbsp;&nbsp;&nbsp;out.println("d.add("+t_tree_id+","+t_tree_id_p+",'"+t_tree_name+"','"+t_tree_address+"','','"+t_tree_target+"');");<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;out.println("d.add(-2,0,'退出系统','/zdtadmin/content/login.jsp','','_top');");<BR>&nbsp;&nbsp;out.println("document．write(d);");<BR>&nbsp;rsShow.close();<BR>&nbsp;}<BR>&nbsp;%&gt;<BR><BR>&nbsp;&nbsp;--&gt;<BR>&nbsp;&lt;/script&gt;<BR><BR><BR>&lt;/div&gt;<BR><BR><BR>&lt;/body&gt;<BR>&lt;/html&gt;<BR>这样就实现了动态tree图。<BR>上面的这种实现是用jsp+javascript实现。也可以用xml+xsl来实现。不是必要，只是可以让新手也了解一下关于xml的应用。:)<BR>比如我们已经成功把数据库的数据导出成xml格式。代码如下：<BR>&lt;?xml&nbsp;version="1.0"&nbsp;?&gt;<BR>&lt;?xml:stylesheet&nbsp;type="text/xsl"&nbsp;href="ttx2.xsl"&nbsp;?&gt;<BR>&lt;table&nbsp;name="cm_tree"&gt;<BR>&lt;col&nbsp;id="1"&nbsp;label="闆嗗洟鏂伴椈"&nbsp;parentid="29"&nbsp;target="_blank"&nbsp;url="/zdtadmin/default.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="2"&nbsp;label="闆嗗洟瑕侀椈"&nbsp;parentid="1"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=2"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="3"&nbsp;label="缁煎悎淇℃伅"&nbsp;parentid="1"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=3"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="4"&nbsp;label="鏀跨瓥娉曡"&nbsp;parentid="29"&nbsp;target="_blank"&nbsp;url="/zdtadmin/default.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="5"&nbsp;label="娉曞緥娉曡"&nbsp;parentid="4"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=5"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="7"&nbsp;label="鏀跨瓥鐮旂┒"&nbsp;parentid="4"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=7"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="8"&nbsp;label="鐢熶骇缁忚惀"&nbsp;parentid="29"&nbsp;target="_blank"&nbsp;url="/zdtadmin/default.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="9"&nbsp;label="瀹夊叏鐢熶骇"&nbsp;parentid="8"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=9"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="10"&nbsp;label="缁忚惀鍔ㄦ€?&nbsp;parentid="8"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=10"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="11"&nbsp;label="宸ョ▼寤鸿"&nbsp;parentid="29"&nbsp;target="_blank"&nbsp;url="/zdtadmin/default.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="12"&nbsp;label="鐏數宸ョ▼"&nbsp;parentid="11"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=12"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="13"&nbsp;label="姘寸數宸ョ▼"&nbsp;parentid="11"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=13"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="14"&nbsp;label="鏍哥數宸ョ▼"&nbsp;parentid="11"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=14"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="17"&nbsp;label="鍥介檯鍚堜綔"&nbsp;parentid="29"&nbsp;target="_blank"&nbsp;url="/zdtadmin/default.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="19"&nbsp;label="鍚堜綔鍔ㄦ€?&nbsp;parentid="17"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=19"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="20"&nbsp;label="浼佷笟鏂囧寲"&nbsp;parentid="29"&nbsp;target="_blank"&nbsp;url="/zdtadmin/default.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="22"&nbsp;label="绮剧鏂囨槑"&nbsp;parentid="20"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=22"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="24"&nbsp;label="鍏朵粬淇℃伅"&nbsp;parentid="29"&nbsp;target="_blank"&nbsp;url="/zdtadmin/default.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="25"&nbsp;label="澶╂皵棰勬姤"&nbsp;parentid="24"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=25"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="26"&nbsp;label="浼佷笟鏂囧寲鍔ㄦ€?&nbsp;parentid="20"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=26"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="27"&nbsp;label="鏂囧寲娲诲姩"&nbsp;parentid="20"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=27"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="29"&nbsp;label="鍐呭绠＄悊"&nbsp;parentid="0"&nbsp;target="_blank"&nbsp;url="/zdtadmin/default.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="31"&nbsp;label="鏍忕洰缁存姢"&nbsp;parentid="0"&nbsp;target="_blank"&nbsp;url="/zdtadmin/treeadmin/tree_edit.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="32"&nbsp;label="瑙掕壊缁存姢"&nbsp;parentid="0"&nbsp;target="_blank"&nbsp;url="/zdtadmin/default.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="41"&nbsp;label="澶氱浜т笟"&nbsp;parentid="8"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=41"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="42"&nbsp;label="涓婂競鍏徃"&nbsp;parentid="8"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=42"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="44"&nbsp;label="娣诲姞瑙掕壊"&nbsp;parentid="32"&nbsp;target="_blank"&nbsp;url="/zdtadmin/peradmin/role_edit.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="45"&nbsp;label="瑙掕壊-鏍忕洰"&nbsp;parentid="32"&nbsp;target="_blank"&nbsp;url="/zdtadmin/peradmin/role_tree.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="46"&nbsp;label="瑙掕壊-鐢ㄦ埛"&nbsp;parentid="32"&nbsp;target="_blank"&nbsp;url="/zdtadmin/peradmin/role_user.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="47"&nbsp;label="鏂囦欢涓嬭浇"&nbsp;parentid="24"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/down_list.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="48"&nbsp;label="鐢ㄦ埛绠＄悊"&nbsp;parentid="0"&nbsp;target="_blank"&nbsp;url="/zdtadmin/useradmin/user_list.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="51"&nbsp;label="涓撴爮"&nbsp;parentid="29"&nbsp;target="_blank"&nbsp;url="/zdtadmin/default.jsp"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="52"&nbsp;label="鐢靛姏绉戞櫘"&nbsp;parentid="51"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=52"&gt;&lt;/col&gt;<BR>&lt;col&nbsp;id="53"&nbsp;label="鍩虹绠＄悊骞?&nbsp;parentid="51"&nbsp;target="_blank"&nbsp;url="/zdtadmin/newsadmin/list.jsp?tree_id=53"&gt;&lt;/col&gt;&lt;/table&gt;<BR>其中乱码是因为用到了utf8编码。就是节点名。在ie中可以正常显示。<BR>然后我们写一个xsl来表示它，把它转成一个html来显示。<BR>"&lt;?xml:stylesheet&nbsp;type="text/xsl"&nbsp;href="ttx2.xsl"&nbsp;?&gt;"指定了我们要用<BR>ttx2.xsl来表示它。代码如下：<BR><BR>&lt;?xml&nbsp;version='1.0'&nbsp;?&gt;<BR>&lt;xsl:stylesheet&nbsp;version='1.0'&nbsp;xmlns:xsl="<IMG src="http://www.matrix.org.cn/article/images/small/url.gif" align=absMiddle><A href='http://www.w3.org/TR/WD-xsl"' target=_blank>http://www.w3.org/TR/WD-xsl"</A>;&nbsp;&gt;<BR>&lt;xsl:template&nbsp;match="/"&gt;<BR>&lt;html&gt;<BR>&lt;head&gt;<BR>&lt;title&gt;Tree&nbsp;test&lt;/title&gt;<BR>&lt;/head&gt;<BR>&lt;body&gt;<BR>&lt;script&nbsp;type="text/javascript"&nbsp;src="include/dtree.js"&gt;&lt;/script&gt;<BR>&lt;script&nbsp;type="text/javascript"&gt;<BR>d=new&nbsp;dTree('d');<BR>d.add(0,-1,"list");<BR>&lt;xsl:apply-templates&nbsp;select="/table"/&gt;<BR>document．write(d);<BR>&lt;/script&gt;<BR>&lt;/body&gt;<BR>&lt;/html&gt;<BR>&lt;/xsl:template&gt;<BR>&lt;xsl:template&nbsp;match="/table"&gt;<BR>&lt;xsl:for-each&nbsp;select="col"&gt;<BR>d.add(&lt;xsl:value-of&nbsp;select="@id"/&gt;,&lt;xsl:value-of&nbsp;select="@parentid"/&gt;,'&lt;xsl:value-of&nbsp;select="@label"/&gt;','&lt;xsl:value-of&nbsp;select="@url"/&gt;','&lt;xsl:value-of&nbsp;select="@label"/&gt;','&lt;xsl:value-of&nbsp;select="@target"/&gt;');<BR>&lt;/xsl:for-each&gt;<BR>&lt;/xsl:template&gt;<BR>&lt;/xsl:stylesheet&gt;<BR>这些例子在打包文件里可以找到。我在IE&nbsp;6.0下测试通过。<BR>我在xsl方面也只是了解皮毛。所以用到的也只是很基础的东西。希望有人能写一些关于xml+xsl方面的专业的文章。^_^<BR>上面说的东西是b/s结构下tree图的表现层的实现。如果是逻辑上的结构变更和定义，就不能靠jsp+javascript来实现了。我建议的解决方法是用tree型xml来实现,如果直接操作数据库的话，要递归并要保证结构完整性，虽然能实现但是可能会很复杂，并且效力比较低。"tree型xml来实现"可以参考<A href="http://www.matrix.org.cn/article_view.asp?id=246" target=_blank>java&amp;xml心得(三)</A>.<BR>上面就是自己在Tree型结构&nbsp;数据-结构维护-结构交互-表现&nbsp;上自己的理解。当然还有很多不完善的地方。~_~&nbsp;希望能给大家一点帮助或启示。</FONT></TD></TR>
<TR>
<TD><BR><BR>参与论坛讨论:<A href="http://www.matrix.org.cn/javaforum.asp">http://www.matrix.org.cn/forum.asp</A><BR>更多技术文章:<A href="http://www.matrix.org.cn/javaarticle.asp">http://www.matrix.org.cn/article.asp</A><BR>Matrix java门户:<A href="http://www.matrix.org.cn/java.asp">http://www.matrix.org.cn</A></TD></TR>
<TR>
<TD>原文地址：<A href="http://www.matrix.org.cn/article/335.html">http://www.matrix.org.cn/article/335.html</A><BR></TD></TR></TBODY></TABLE><img src ="http://www.blogjava.net/kapok/aggbug/2657.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kapok/" target="_blank">笨笨</a> 2005-03-31 14:08 <a href="http://www.blogjava.net/kapok/archive/2005/03/31/2657.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在线编辑器以及开源项目链接等等</title><link>http://www.blogjava.net/kapok/archive/2005/03/31/2650.html</link><dc:creator>笨笨</dc:creator><author>笨笨</author><pubDate>Thu, 31 Mar 2005 05:19:00 GMT</pubDate><guid>http://www.blogjava.net/kapok/archive/2005/03/31/2650.html</guid><wfw:comment>http://www.blogjava.net/kapok/comments/2650.html</wfw:comment><comments>http://www.blogjava.net/kapok/archive/2005/03/31/2650.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kapok/comments/commentRss/2650.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kapok/services/trackbacks/2650.html</trackback:ping><description><![CDATA[1.<BR>在线编辑器:<A href="http://www.fckeditor.net/"><BR>&nbsp;&nbsp;&nbsp;1.1<BR>http://www.fckeditor.net/</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;目前来说，我对FCK的感觉还不错。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;相关链接：<A href="http://www.chinaunix.net/jh/27/435736.html">http://www.chinaunix.net/jh/27/435736.html</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="http://www.donews.net">http://www.donews.net</A>好像采用的就是这个在线编辑器。<BR>
<P>当前FCKeditor对IE的支持很好，不过在Mozilla Firefox中不能正常工作。从官方网站上得到的消息表明FCKeditor的开发小组正在实现其对Mozilla的支持。<BR><A href="http://www.lividecay.org/doc_view.php?doc_id=1123">http://www.lividecay.org/doc_view.php?doc_id=1123</A><BR><BR><BR><A href="http://www.redsaga.com/mambo/content/view/12/2/">http://www.redsaga.com/mambo/content/view/12/2/</A></P>
<P>在jsp下使用FCKeditor是非常容易的， 在FCKeditor的表中带有一个在JSP下使用Taglib，通过调用这个taglib， 很容易使用FCKeditor， 下面就简单说一下它的使用<BR><STRONG>FCKeditor在Future使用指南</STRONG></P>
<OL>
<LI>在jsp可以直接调用FCKeditor提供的tag， 引入/WEB-INF/FCKeditor.tld就可以使用了 
<LI>FCKeditor中editor tag中的属性使用 
<LI>id是对这个tag的唯一标识，在提交表单以后， 可以通过这个id定义的参数名得到编辑后生成的内容，如果在一个页面中要调用多个fckeditor，id值不能重复 
<LI>canUpload表示是否能上载图片 
<LI>canBrowse表示是否能浏览已上载的图片 
<LI>toolbarSet表示工具栏的类型， 这里的类型可以在/fckeditor/js/fck_config.js中定义 
<LI>width是编辑框的宽度 
<LI>height是编辑框的高度</LI></OL>
<P>toolbarSet的定义是非常容易的， 在FCKeditor中用到的所有功能按钮对是有唯一的名称的， 这个名称你可以在FCKeditor帮助文件或者/fckeditor/js/fck_config.js中定义的Default toolbarSet中找到.<BR><BR>&nbsp;&nbsp;&nbsp;1.2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A href="http://www.freetextbox.com/">http://www.freetextbox.com/</A>&nbsp;不过好像不支持jsp啊<BR><BR>Javascript实现的<BR><A href="http://tinymce.moxiecode.com/">http://tinymce.moxiecode.com/</A><BR><BR><BR>2.<BR>一个在线字典:<BR><A href="http://livid.3322.org/lividict/livid.html">http://livid.3322.org/lividict/livid.html</A><BR><BR><BR>3.<BR>开源的基于php的项目：<BR><A href="http://xoops.org.cn/modules/wfdownloads/singlefile.php?cid=4&amp;lid=222">http://xoops.org.cn/modules/wfdownloads/singlefile.php?cid=4&amp;lid=222</A><BR><A href="http://xoops.org.cn/modules/wfdownloads/topten.php?list=hit">http://xoops.org.cn/modules/wfdownloads/topten.php?list=hit</A><BR><BR><BR><BR>4.<BR><A href="http://forum.javaeye.com/viewtopic.php?t=2047&amp;highlight=cvs">http://forum.javaeye.com/viewtopic.php?t=2047&amp;highlight=cvs</A><BR><A href="http://forum.javaeye.com/viewtopic.php?t=8360&amp;highlight=cvs">http://forum.javaeye.com/viewtopic.php?t=8360&amp;highlight=cvs</A><BR><A href="http://sourceforge.net/cvs/?group_id=94626">http://sourceforge.net/cvs/?group_id=94626</A><BR><BR><BR>5.<BR><A href="http://www.blog.edu.cn/blog.asp?name=yonghui">http://www.blog.edu.cn/blog.asp?name=yonghui</A><BR><A href="http://www.magnolia.info/en/community.html">http://www.magnolia.info/en/community.html</A><BR><BR>6.<BR><A href="http://duduwolf.winzheng.com/">http://duduwolf.winzheng.com/</A><BR><A href="http://www.bris.ac.uk/is/projects/cms/ttw/ttw.html">http://www.bris.ac.uk/is/projects/cms/ttw/ttw.html</A><BR><A href="http://www.aine.be/aynhtml/">http://www.aine.be/aynhtml/</A><BR><BR><BR>6.<BR><A href="http://www.jdsl.org/">http://www.jdsl.org/</A><BR><A href="http://www.cmswiki.com/tiki-index.php?page=JSR170">http://www.cmswiki.com/tiki-index.php?page=JSR170</A><BR><A href="http://jsr170tools.day.com/crx/index.jsp">http://jsr170tools.day.com/crx/index.jsp</A><BR><BR><BR>7.<BR>项目管理：<BR><A href="http://www.codeproject.com/tools/ToDoList2.asp">http://www.codeproject.com/tools/ToDoList2.asp</A><BR><A href="http://www.moon-soft.com/doc/45036.htm">http://www.moon-soft.com/doc/45036.htm</A><BR><A href="http://www.moon-soft.com/doc/45036.htm">http://www.moon-soft.com/doc/45036.htm</A><BR><A href="http://www.neokeen.com/mornlee/2005/02/23/1109168404234.html">http://www.neokeen.com/mornlee/2005/02/23/1109168404234.html</A><BR><A href="http://cosoft.org.cn/forum/forum.php?forum_id=6559">http://cosoft.org.cn/forum/forum.php?forum_id=6559</A><BR><A href="http://blog.csdn.net/kasam/archive/2004/12/30/234644.aspx">http://blog.csdn.net/kasam/archive/2004/12/30/234644.aspx</A><BR><A href="http://www.redsoftfactory.com/chinese/opensource/opensource.html">http://www.redsoftfactory.com/chinese/opensource/opensource.html</A><BR><A href="http://forum.javaeye.com/viewtopic.php?t=2300">http://forum.javaeye.com/viewtopic.php?t=2300</A><BR><BR><BR><A href="http://forum.javaeye.com/viewtopic.php?t=8360">http://forum.javaeye.com/viewtopic.php?t=8360</A><BR><BR><BR>8。<BR><BR><BR><A href="http://java-source.net/open-source/content-managment-systems">http://java-source.net/open-source/content-managment-systems</A></P><img src ="http://www.blogjava.net/kapok/aggbug/2650.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kapok/" target="_blank">笨笨</a> 2005-03-31 13:19 <a href="http://www.blogjava.net/kapok/archive/2005/03/31/2650.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>