虎克的博客

Enthusiasm Biogeography-Biodiversity Informatics-Data Sciences

网络应用程序界面快速创建

| Comments

Web applications are dynamic- many requiring unique content and interfaces for each user. There are a myriad of ways to take user content out of a database and present it in a browser. This article focuses on the different ways it can be done in the Microsoft world (specifically in ASP.NET), why we chose XSLT for our own product, and finally a look at our technical implementation.

Planning for Dynamic Content

Whether you are in the process of building a new business web application or planning to build one, you most likely need to address how your web application will handle displaying different content for different users.

Considerations

When considering the different options for displaying dynamic content you generally need to take into account the following aspects:

  • Usability
    Usability might be one of the most critical aspects in the success (or lack thereof) of your application.
  • Development Time
    This includes the total amount of development time involved in satisfying your current application requirements.
  • Flexibility
    Regardless of how comprehensive your current requirements are, applications tend to evolve over time. It’s important to evaluate the development effort and skill sets required to accommodate changes.
  • Support, Maintenance & Ongoing Enhancements
    Commonly ignored by many when planning new development projects, it is generally responsible for a good chunk of the total cost of an application over the span of its life. This includes bug fixes, client customizations, minor application enhancements and of course, QA and testing.

The Options in ASP.NET

Generally web applications that use ASP.NET have two main options for displaying dynamic content:

  • Server Controls
    • With Binding – retrieving the relevant data and binding it to the appropriate ASP.Net server controls on a web form
    • In Code – populating the appropriate ASP.Net server controls in code
  • HTML
    • In Code – constructing the HTML to display in code based on the information retrieved from the database
    • With XSLT – retrieving the database information in XML format and then transforming it into HTML with XSLT

A third option is Silverlight, a new technology introduced as an option for web applications by Microsoft about a year ago. Silverlight provides a very rich GUI with the power of the .Net platform (a subset, actually) and tools that make web application development similar to the XAML interfaces found in the latest Windows application development. Silverlight is outside the scope of this particular article though.

Comparing the Different Options

Before you decide on the best route to take to display dynamic content you need to evaluate the impact of each approach on your application. You might find the table below helpful when making this decision.

 

Approach Pros  & Cons When to Use
Server Controls
With Binding The quickest approach in terms of development time but also the least flexible. Best suited for applications with low data complexity and that are not expected to change often.
In Code Hooking up the controls in code takes longer in terms of development but is much more flexible than binding. This approach also requires a higher level of support and maintenance. Best suited for applications with high data complexity and that are not expected to change often.
HTML
In Code Constructing HTML in code gives a good deal of flexibility over the markup that’s created but is time-consuming and extraordinarily brittle. This approach requires extensive testing and support. I wouldn’t recommend this to be used as a general strategy for web applications but at times this might be used for particular sections depending on a unique set of requirements.
Using XSLT Offers high flexibility and the least amount of ongoing maintenance and testing. The development time might be longer depending on your team’s skill set. Best suited for applications with high data complexity and ones that are expected to change significantly and frequently. In addition, this allows for a lot of room for creativity as far as interface design goes.
Silverlight Provides the richest GUI possibilities and the complete separation of interface and code. The time to develop, test and support are currently higher than other options. Best suited for applications that require very rich user interfaces, and for development teams that primarily focus on Windows development.

 

Real-World Use Case: Scopings

When we started evaluating the requirements for Scopings, our homegrown recruiting platform, we needed a way to present complex content with a unique look and feel, a high level of usability, an infrastructure that can easily adapt to frequent and substantial changes, and built-in capabilities for globalization.

Very quickly we realized that although we can use ASP.Net server controls to build the first revision of Scopings in a relatively short period of time, this wouldn’t adapt well to the frequent changes we expected to be an inevitable part of the product lifecycle. This option would substantially increase our total cost of ownership.

After much analysis and many discussions, it became clear to us that designing our own infrastructure for constructing HTML using XML and XSLT would satisfy all of our requirements. We sat down and started to design an infrastructure that has ultimately been used for more than 80% of the functionality on Scopings.

Constructing the HTML

The idea behind the Scopings infrastructure was to allow us to make substantial changes to our user interface, while eliminating the need for any code changes and development staff involvement, and substantially decreasing the amount of QA required following any changes to the user interface.

To accommodate these requirements the Scopings infrastructure was built to be completely indifferent to the information retrieved from our database and to the way the information is ultimately displayed.

To achieve this we designed the infrastructure as follows:

    <li>A separate stored procedure was built against each web content page to be displayed, and was designed to only return XML back to the calling code. </li>
    <li>Upon loading a web page, the code behind would load the XML for the current user. The XSLT would then transform the XML to an HTML interface for the user. </li>
    <li>The web page would be responsible for all functionality,<p class='post-footer'>
       original link:
       <a href='http://Apiaceae.github.io/blog/2009/03/27/%E7%BD%91%E7%BB%9C%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%95%8C%E9%9D%A2%E5%BF%AB%E9%80%9F%E5%88%9B%E5%BB%BA/'>http://Apiaceae.github.io/blog/2009/03/27/%E7%BD%91%E7%BB%9C%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%95%8C%E9%9D%A2%E5%BF%AB%E9%80%9F%E5%88%9B%E5%BB%BA/</a><br/>
       &nbsp;written by <a href='http://Apiaceae.github.io'>Hooker</a>
       &nbsp;posted at <a href='http://Apiaceae.github.io'>http://Apiaceae.github.io</a>
       </p>
    

后分类学家的时代

| Comments

萨拉Kemmitt和同事在大英图书馆刚刚发布了一个播客棒网页的最近谈论'姓名有什么意义? -分类在危机' 。这是图书馆优秀TalkScience系列。播客仅限于棒的初步介绍,但大多数的行动发生在随后的讨论中,并在随后的酒吧。我有点失望的是,生物分类灯具观众无法拿出一个更强有力的国防分类。反复出现的一个主题讨论的是'后的分类学者'的时代,以及我们如何对待挑战的分类和系统在一段时间内如果没有更多的专业人士。这是空气中的必然性有关这一时期,任何人在观众甚至质疑这一构想。的确,对于许多分类组别这不是我们的未来远景,但反映了本。为越来越多的分类根本没有分类学家提供专业级别的报道,我知道等机构自然历史博物馆必须考虑非常战略有关如何填补空出的职位退休分类学家。我没有听到太多的投诉,更广泛的科学界对缺乏专业分类学家。但是,由于生物分类学是一个长尾巴的科学(即半衰期分类引文是衡量几十年来,有时几个世纪,这是公正的分类信息,正式引用! ) ,我不会期望投诉量成为发声的人,可能做一些事情他们(即出资) ,直到它远远为时已晚。

所有这些讨论使我觉得我更多的个人与非专业分类社会和我的作用,更好地调动他们的努力。缺乏资金的分类内容(即做分类)的手段,我根本无法辩解的传统分类学博物馆管理员,除了高度魅力的分类,或在我的分类是一个明确的目的的手段,而不是目的本身。我在高兴的立场,我的研究项目是合理的多样化,大部分工作(如基础设施项目,如Scratchpads ,或工作的加拉帕戈斯鸟虱子)符合这些标准。但我也意识到,我的许多同事都没有在这幸福的立场,我可以不再甚至我的分类社会(工作的人的演变寄生虱子- Phthiraptera ) ,以同样的水平,我利用至。显然,最有效地利用我现在的时间是在更广泛的社区动员的努力(特别是'亲业余社会' ,谁的工作,以一个专业的标准,但没有报酬的工作) 。如果有任何罗德的谈话和随后的讨论中,我更加确信我个人的战略,处理后的分类学家'时代,但这种讨论不会离开我高兴的是,它应该有来此。

题目涉及棒的讨论包括:
•为什么生物分类的问题?
•为什么生物分类学家不满,是它的部分自己的错吗?
•我们不知道究竟有多少物种仍然undescribed但这个问题?
• Cybertaxonomy和'舞倡议' -是更多的钱的答案吗?
•米老鼠和分类-我们如何处理版权和其他障碍,共享数据?
•谁会希望成为一个分类学家在21世纪?

继续讨论这些问题,看看论坛的性质分类网络。

XML显示出错

| Comments

今天编译一些学习处理XML文档的代码,结果调试出现上图的错误。网络搜索的解决方案如下:

解决的方法是在命令行窗口(开始–运行–cmd)中输入“C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i”。这样问题就解决了。发现,在原先在IIS>默认网站>属性>主目录>配置>映射应用程序映射中,比原先多出了许多扩展名,如我就需要运行了.aspx等,这样,在IIS中就注册完成了。
或者点开始–程序–Microsoft Visual Studio .net 2005–Visual Studio Tools–Visual Studio 命令提示行
在里面写aspnet_regiis.exe -i
重新注册IIS

不管用

 示例代码如下:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Xml.XPath;

public partial class UpdateXML : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Response.ContentType = "txt/xml";//错误的问题就出在这里,注释掉就好了。
        string xmlPath = Request.PhysicalApplicationPath + @"App_Data\Books.xml";
        XmlDocument document = new XmlDocument();
        document.Load(xmlPath);
        XPathNavigator navigator = document.CreateNavigator();
        int count = navigator.Select("/bookstore/book").Count;
        navigator.MoveToChild("bookstore", "");
        navigator.MoveToChild("book", "");
        for (int i = 0; i < count; i++)
        {
            navigator.MoveToChild("price", "");
            double discount = navigator.ValueAsDouble * (.1);
            navigator.CreateAttribute("","discount","",discount.ToString());
            navigator.MoveToParent();
            navigator.MoveToNext();
        }
        navigator.MoveToRoot();
        Response.Write(navigator.OuterXml);
    }
}

另外一段代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Xml.Schema;
using System.IO;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Response.ContentType = "text/xml";//注释掉也不管用,还是出现老问题
        string xmlFilePath = Request.PhysicalApplicationPath + @"App_Data\Authors.xml";
        XmlReader reader = XmlReader.Create(xmlFilePath);
        XmlSchemaSet schemaSet = new XmlSchemaSet();
        XmlSchemaInference schema = new XmlSchemaInference();
        schemaSet = schema.InferSchema(reader);
        foreach (XmlSchema schemaObj in schemaSet.Schemas())
        {
            schemaObj.Write(Response.Output);
        }
    }
}

调用XPath显示XML文档

| Comments

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Xml.Schema;

public partial class ShowXpath : System.Web.UI.Page
{
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ddlExpressions.Items.Add("//book/title");
            ddlExpressions.Items.Add("//book/[@genre='novel']/title");
            ddlExpressions.Items.Add("//book/author/first-name");
            ddlExpressions.Items.Add("//book/[@genre='philosophy']/title");
            ddlExpressions.Items.Add("//book/price");
            ddlExpressions.Items.Add("//book[3]/title");
            ddlExpressions.SelectedIndex = 0;
            UpdateDisplay();
        }

    }
    /// <summary>
    /// Handles the SelectedIndexChanged event of the ddlExpressions control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void ddlExpressions_SelectedIndexChanged(object sender, EventArgs e)
    {
        UpdateDisplay();
    }
    /// <summary>
    /// Updates the display.
    /// </summary>
    void UpdateDisplay()
    {
        lstOutput.Items.Clear();
        string xmlFilePath = Request.PhysicalApplicationPath + @"App_Data\Books.xml";
        XmlDocument doc = new XmlDocument();
        doc.Load(xmlFilePath);
        XmlNodeList nodeList = doc.DocumentElement.SelectNodes(ddlExpressions.SelectedItem.Text);
        foreach (XmlNode child in nodeList)
        {
            lstOutput.Items.Add("Node name: " + child.Name);
            lstOutput.Items.Add("Node value: " + child.FirstChild.Value);
        }
 
    }
}

创建XML文档

| Comments

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.IO;

public partial class CreateXML : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string xmlFilePath = Request.PhysicalApplicationPath + @"\App_Data\NewBooks.xml";
        XmlDocument doc = new XmlDocument();
        if (File.Exists(xmlFilePath))
        {
            doc.Load(xmlFilePath);
            XmlNode bookNode = CreateBookNode(doc);
            XmlNode bookStoreNode = doc.SelectSingleNode("bookstore");
            bookStoreNode.AppendChild(bookNode);
            lblResult.Text = "文件写入成功!";
        }
        else
        {
            XmlNode declarationNode = doc.CreateXmlDeclaration("1.0", "", "");
            doc.AppendChild(declarationNode);
            XmlComment comment = doc.CreateComment("这是一个测试性XML文档");
            doc.AppendChild(comment);

            XmlNode bookStoreNode = doc.CreateElement("bookstore");
            XmlNode bookNode = CreateBookNode(doc);

            bookStoreNode.AppendChild(bookNode);
            doc.AppendChild(bookStoreNode);

            lblResult.Text = "文件成功写入!";
        }
        doc.Save(xmlFilePath);
    }
    XmlNode CreateBookNode(XmlDocument doc)
    {
       
        XmlNode bookNode = doc.CreateElement("book");
        XmlAttribute genreAttribute = doc.CreateAttribute("genre");
        genreAttribute.Value = txtGenre.Text;
        bookNode.Attributes.Append(genreAttribute);

        XmlNode titleNode = doc.CreateElement("title");
        titleNode.InnerText = txtTitle.Text;
        bookNode.AppendChild(titleNode);

        XmlNode authorNode = doc.CreateElement("author");
        XmlNode firstNameNode = doc.CreateElement("first-name");
        firstNameNode.InnerText = txtFirstName.Text;
        authorNode.AppendChild(firstNameNode);

        XmlNode lastNameNode = doc.CreateElement("last-name");
        lastNameNode.InnerText = txtLastName.Text;
        authorNode.AppendChild(lastNameNode);

        bookNode.AppendChild(authorNode);

        XmlNode priceNode = doc.CreateElement("price");
        priceNode.InnerText = txtPrice.Text;
        bookNode.AppendChild(priceNode);

        return bookNode;
    }
    XmlNode CreateBookNodeFragment(XmlDocument doc)
    {
        XmlDocumentFragment docFragment = doc.CreateDocumentFragment();
        docFragment.InnerXml = "<book genre='" + txtGenre.Text + "'>" + "<title>" + txtTitle.Text + "</title>" + "<author><first-name>" + txtFirstName.Text + "</first-name>" + "<last-name>" + txtLastName.Text + "</last-name></author>" + "<price>" + txtPrice.Text + "</price></book>";
        return docFragment;

    }
}

企鹅的谱系生物地理学

| Comments

谱系地理1

谱系地理1

Multiple gene evidence for expansion of extant penguins out of Antarctica due to global cooling.

Classic problems in historical biogeography are where did penguins originate, and why are such mobile birds restricted to the Southern Hemisphere?

Competing hypotheses posit they arose in tropical–warm temperate waters, species-diverse cool temperate regions, or in Gondwanaland w100 mya when it was further north.

To test these hypotheses we constructed a strongly supported phylogeny of extant penguins from 5851 bp of mitochondrial and nuclear DNA. Using Bayesian inference of ancestral areas we show that an Antarctic origin of extant taxa is highly likely, and that more derived taxa occur in lower latitudes. Molecular dating estimated penguins originated about 71 million years ago in Gondwanaland when it was further south and cooler.

Moreover, extant taxa are inferred to have originated in the Eocene, coincident with the extinction of the larger-bodied fossil taxa as global climate cooled. We hypothesize that, as Antarctica became ice-encrusted, modern penguins expanded via the circumpolar current to oceanic islands within the Antarctic Convergence, and later to the southern continents.

Thus, global cooling has had a major impact on penguin evolution, as it has on vertebrates generally. Penguins only reached cooler tropical waters in the Galapagos about 4 mya, and have not crossed the equatorial thermal barrier.

Keywords: penguins; divergence time; biogeography; nuclear DNA; mitochondrial DNA

极地植物的长距离散布

| Comments

LDD

由于缺乏对植物物种长距离散布频度好的量化估计,我们对它们的分布在气候变化条件下的响应情况的理解受到很大限制。通过分析分布与北极岛屿和Svalbard及其邻近地区的9个有花植物种的超过4000个取样的遗传变异分析,Alsos等的研究表明,自从最后大大冰期以来,在Svalbard岛屿居群的建立过程中,长距离散布的种类来源于多个地区。因此,长距离散布现象比我们所通常认为的那样要普遍的多,这反过来也表明这些种类分布范围的向北转移可能在全球变暖后发生地相当快速。

ASP.NET WebPart控件介绍

| Comments

本来以为这也是经典的红皮书系列,但是当你真真读几章后会有种大失所望的感觉。主要原因是作者的叙述和写书的风格实在不敢恭维。太啰嗦,不该讲的讲了一大堆,当该仔细的讲代码的时候却又简略的让人有些晕,不知道实际如何动手。完全就是一本“纸上谈兵”的书,比较空洞。看起来花的时间和收获实在不能成正比啊。

ASP.NET网站管理工具的使用

| Comments

   original link:
   <a href='http://Apiaceae.github.io/blog/2009/03/25/ASP.NET%E7%BD%91%E7%AB%99%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7%E7%9A%84%E4%BD%BF%E7%94%A8/'>http://Apiaceae.github.io/blog/2009/03/25/ASP.NET%E7%BD%91%E7%AB%99%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7%E7%9A%84%E4%BD%BF%E7%94%A8/</a><br/>
   &nbsp;written by <a href='http://Apiaceae.github.io'>Hooker</a>
   &nbsp;posted at <a href='http://Apiaceae.github.io'>http://Apiaceae.github.io</a>
   </p>