Tuesday, February 20, 2007

View Results from the Textml QueryAnalyzer Object

I wasn't sure if I had an error in my code or if I uncovered a bug in Textml's QueryAnalyzer, so I wrote a little ASP.NET page where I could pass in a search string and see what QueryAnalyzer would do with it. This is how I found the bug with their .NET implementation of the choice operator.

Here are the ASPX and C# files
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="QueryAnalyzer.aspx.cs"
Inherits="QueryAnalyzer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>QueryAnalyzer Test Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtQuery" runat="server"></asp:TextBox>
<asp:Button ID="btnRun" runat="server" Text="Run" /><br />
<div id="divQuery" runat="server"></div>
<div id="divError" runat="server"></div>
</form>
</body>
</html>

--

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Ixiasoft.TextmlServer;
using Ixiasoft.TextmlServer.Tools;

public partial class QueryAnalyzer : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
divError.InnerHtml = "";
divQuery.InnerHtml = "";
IxiaQueryAnalyzer TextmlQueryAnalyzer = new IxiaQueryAnalyzer();
try
{
string queryEdited =
TextmlQueryAnalyzer.GetXMLQueryString(txtQuery.Text, "words");
divQuery.InnerHtml = HttpUtility.HtmlEncode(queryEdited);
}
catch (Exception ex)
{
divError.InnerHtml += "<br />" + ex.ToString() +
"<br />" + ex.StackTrace.ToString() +
"<br />Passed to QueryAnalyzer: " +
HttpUtility.HtmlEncode(txtQuery.Text);
}
}
}
}

No comments: