<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>LiquidFoot &#187; coldfusion</title>
	<atom:link href="http://www.liquidfoot.com/tag/coldfusion/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.liquidfoot.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 02 Jan 2012 22:56:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Facebook Developer API</title>
		<link>http://www.liquidfoot.com/2008/03/18/facebook-developer-api/</link>
		<comments>http://www.liquidfoot.com/2008/03/18/facebook-developer-api/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 15:59:32 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[facebook]]></category>
		<guid isPermaLink="false">http://www.liquidfoot.com/?p=172</guid>
		<description><![CDATA[It&#8217;s been a long while since I posted anything here. Things have been a bit hectic with the launching of a new institutional repository service (using DSpace), taking a computer graphics course (linear algebra, ray tracing, scientific visualization, etc.), and finishing up my book on the Facebook API. This is the first book I&#8217;ve written [...]]]></description>
			<content:encoded><![CDATA[<div class="body">
<p>It&#8217;s been a long while since I posted anything here. Things have been a bit hectic with the launching of a new institutional repository service (using DSpace), taking a computer graphics course (linear algebra, ray tracing, scientific visualization, etc.), and finishing up my book on the <a href="http://www.facebook.com/pages/Facebook-API-Developers-Guide/8672611380">Facebook API</a>.</p>
<p><a href="http://www.amazon.com/gp/product/1430209690/"> <img style="border: 0pt none;" src="http://ecx.images-amazon.com/images/I/41YiSZ1UfJL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA240_SH20_OU01_.jpg" border="0" alt="" align="left" /></a></p>
<p>This is the first book I&#8217;ve written and I have to admit it was far more of a task than I had first thought it would be. Not that the subject matter was very dense, but there were at least four major changes in the API that required an almost total rewrite of the code base for the examples. There were even a couple of sections that had to get cut because Facebook &#8220;fixed&#8221; their code because of security and user concerns (plus a lot of folks &#8220;abuse&#8221; some of the things you could do with the API).</p>
<p>There are some great Coldfusion resources for building Facebook applications in ColdFusion. The &#8220;un-official&#8221; ColdFusion client library for Facebook apps is at <a href="http://www.nearpersonal.com/code/">nearpersonal</a>. There is also a RIAForge starter project for FBML (FBML is a tag based language for Facebook) named <a href="http://fbmlstarter.riaforge.org/">Facebook FBML Starter Kit</a>.</p>
<p>So, if you&#8217;re wanting a short book that highlights some of the more common elements of developing Facebook applications, be sure to check out my book!</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.liquidfoot.com/2008/03/18/facebook-developer-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SolColdfusion Update</title>
		<link>http://www.liquidfoot.com/2007/10/31/solcoldfusion-update/</link>
		<comments>http://www.liquidfoot.com/2007/10/31/solcoldfusion-update/#comments</comments>
		<pubDate>Wed, 31 Oct 2007 20:01:19 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[solr]]></category>
		<guid isPermaLink="false">http://www.liquidfoot.com/?p=175</guid>
		<description><![CDATA[I&#8217;ve been knocked out by a really bad cold the last couple of weeks and I&#8217;m just starting to get things back to normal. I did want to send a quick post on the status of the SolColdfusion project. After seeing Ray&#8217;s Seeker project, it reminded me that I hadn&#8217;t set up a project at [...]]]></description>
			<content:encoded><![CDATA[<div class="body">
<p>I&#8217;ve been knocked out by a really bad cold the last couple of weeks and I&#8217;m just starting to get things back to normal. I did want to send a quick post on the status of the SolColdfusion project. After seeing Ray&#8217;s Seeker project, it reminded me that I hadn&#8217;t set up a project at RIAForge yet, so I took care of that last night. You can now access the official project at <a href="http://solcoldfusion.riaforge.org/">http://solcoldfusion.riaforge.org/</a>.</p>
<p>Since the project site is up-and-running, I also submitted it to the Solr project <a href="http://issues.apache.org/jira/browse/SOLR-404">SOLR-404</a> (I know it&#8217;s a coincidence that it&#8217;s number 404, but it makes me wonder if it&#8217;s some type of bad omen <img src='http://www.liquidfoot.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  &#8230;). Anyway, if you think the client should get included in the project, be sure to vote for it!</p>
<p>I&#8217;ve also been working on a generic interface, much like Erik Hatcher&#8217;s <a href="http://wiki.apache.org/solr/Flare">Solr Flare</a>. It&#8217;s been a bit slow coming as I&#8217;ve not had a lot of time to work on these projects, but hopefully things will settle down shortly so I can devote a bit more time to them.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.liquidfoot.com/2007/10/31/solcoldfusion-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solr Schema</title>
		<link>http://www.liquidfoot.com/2007/10/05/solr-schema/</link>
		<comments>http://www.liquidfoot.com/2007/10/05/solr-schema/#comments</comments>
		<pubDate>Fri, 05 Oct 2007 20:27:02 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[solr]]></category>
		<category><![CDATA[XML]]></category>
		<guid isPermaLink="false">http://www.liquidfoot.com/?p=178</guid>
		<description><![CDATA[If you&#8217;ve ever worked on a project that involved Coldfusion&#8217;s bundled version of Verity, you&#8217;ve no doubt run into the issue of trying to confine your fields into the structure that Verity imposes, and those custom fields are really precious in these instances. About 6 months ago, I ran into an issue with a search [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever worked on a project that involved Coldfusion&#8217;s bundled version of Verity, you&#8217;ve no doubt run into the issue of trying to confine your fields into the structure that Verity imposes, and those custom fields are really precious in these instances. About 6 months ago, I ran into an issue with a search project where I had about 125,000 documents to index. Since we also wanted to be able to use the indexes for some other projects, I was a bit nervous to commit almost the entire allotment of indexable objects to one collection. This launched me into writing a custom search engine and indexer using Lucene and slapping Coldfusion around the responses to do things that Verity did. However, once the projects were complete, I never really got around to making it easy to use. It does cool stuff like search across multiple collections, context highlighting, relevancy calculations, term vector calculations, &#8220;did you mean&#8221;, etc. Essentially everything I think all good search engines need to be able to do. Something this system lacked was an easy way to define the fields that you wanted indexed (along with a knowledge of Java to actually make the changes).</p>
<p>The ability to create any number of fields to index in different ways (along with faceting) is a real strong point of Solr. Not only can you add fields and choose how that data is analyzed, you can create your own field types that process the information in your index the way you want them to be.</p>
<p>This is done in the <code>$SOLR_HOME/config/schema.xml</code> file. The first section (&lt;types&gt;) defines the types of fields that you will be using, and how Solr should process them with Lucene. If you look at some of the fieldtypes, you&#8217;ll get an idea of what&#8217;s possible. For instance, the fieldtype for &#8220;string&#8221; is an untokenized field that doesn&#8217;t normalize the fields and sorts missing information last.</p>
<div class="code"><span style="color: #ff8000;">&lt;fieldtype name=<span style="color: #0000ff;">&#8220;string&#8221;</span> class=<span style="color: #0000ff;">&#8220;solr.StrField&#8221;</span> sortMissingLast=<span style="color: #0000ff;">&#8220;true&#8221;</span> omitNorms=<span style="color: #0000ff;">&#8220;true&#8221;</span>/&gt;</span></div>
<p>However, if you need a more robust fieldtype, look at the fieldtype for &#8220;text&#8221;. This uses a whitespace tokenizer (splits words with whitespace) and uses the stopwords defined in the stopwords.txt file. It does some other processing (filters words, converts them to lowercase, runs a porter stemmer, and then removes duplicates). This fieldtype also defines what to do when a query is passed to it (uses the same filters). This is slightly different than the defined &#8220;textTight&#8221; which does not perform any further analysis on the text when being queried. You&#8217;ll probably find that most of these work for most instances, but if you need to, you can build your own fieldtype that has very specific indexing and query filters.</p>
<p>The next section contains the actual fields you want to use in the aptly named &#8220;fields&#8221; element. This is where you actually define the fields that will be in your index, the type of analysis to perform on the field, if it should be indexed, stored, have term vectors, or be multivalued (have multiple instances of the same field in the index).</p>
<p>Let&#8217;s say you&#8217;re wanting to develop an indexing schema for books (hey, I work in a library). At a very basic level, you&#8217;d want a field for an id, title, author, reviews, and a set of topics (or tags). Your fields element would contain something along the lines of:</p>
<div class="code"><span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;id&#8221;</span> type=<span style="color: #0000ff;">&#8220;string&#8221;</span> indexed=<span style="color: #0000ff;">&#8220;true&#8221;</span> stored=<span style="color: #0000ff;">&#8220;true&#8221;</span>/&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;title&#8221;</span> type=<span style="color: #0000ff;">&#8220;text&#8221;</span> indexed=<span style="color: #0000ff;">&#8220;true&#8221;</span> stored=<span style="color: #0000ff;">&#8220;true&#8221;</span> termVectors=<span style="color: #0000ff;">&#8220;true&#8221;</span> /&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;titleStr&#8221;</span> type=<span style="color: #0000ff;">&#8220;string&#8221;</span> indexed=<span style="color: #0000ff;">&#8220;true&#8221;</span> stored=<span style="color: #0000ff;">&#8220;false&#8221;</span> multiValued=<span style="color: #0000ff;">&#8220;true&#8221;</span>/&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;author&#8221;</span> type=<span style="color: #0000ff;">&#8220;text&#8221;</span> indexed=<span style="color: #0000ff;">&#8220;true&#8221;</span> stored=<span style="color: #0000ff;">&#8220;true&#8221;</span>termVectors=<span style="color: #0000ff;">&#8220;true&#8221;</span> /&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;authorStr&#8221;</span> type=<span style="color: #0000ff;">&#8220;string&#8221;</span> indexed=<span style="color: #0000ff;">&#8220;true&#8221;</span> stored=<span style="color: #0000ff;">&#8220;false&#8221;</span> multiValued=<span style="color: #0000ff;">&#8220;true&#8221;</span>/&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;review&#8221;</span> type=<span style="color: #0000ff;">&#8220;text&#8221;</span> indexed=<span style="color: #0000ff;">&#8220;true&#8221;</span> stored=<span style="color: #0000ff;">&#8220;true&#8221;</span> multiValued=<span style="color: #0000ff;">&#8220;true&#8221;</span>/&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;topic&#8221;</span> type=<span style="color: #0000ff;">&#8220;text&#8221;</span> indexed=<span style="color: #0000ff;">&#8220;true&#8221;</span> stored=<span style="color: #0000ff;">&#8220;true&#8221;</span> multiValued=<span style="color: #0000ff;">&#8220;true&#8221;</span> termVectors=<span style="color: #0000ff;">&#8220;true&#8221;</span>/&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;topicStr&#8221;</span> type=<span style="color: #0000ff;">&#8220;string&#8221;</span> indexed=<span style="color: #0000ff;">&#8220;true&#8221;</span> stored=<span style="color: #0000ff;">&#8220;false&#8221;</span> multiValued=<span style="color: #0000ff;">&#8220;true&#8221;</span>/&gt;</span></div>
<p>You&#8217;ll notice that I have a couple of extra fields for title, author, and topic, these are for the faceting info and are just untokenized fields to make the calculations for facets a little more efficient.</p>
<p>Now, we&#8217;re almost done with creating the schema. We just need to declare a unique key, default search field, and default search operator.</p>
<div class="code"><span style="color: #000080;">&lt;uniqueKey&gt;</span>id<span style="color: #000080;">&lt;/uniqueKey&gt;</span><br />
<span style="color: #000080;">&lt;defaultSearchField&gt;</span>title<span style="color: #000080;">&lt;/defaultSearchField&gt;</span><br />
<span style="color: #000080;">&lt;solrQueryParser defaultOperator=<span style="color: #0000ff;">&#8220;OR&#8221;</span>/&gt;</span></div>
<p>Remember when I made the fields with the &#8220;Str&#8221; suffix? We can use a really cool feature of Solr called a &#8220;copyField&#8221; that literally copies the information from one field to another.</p>
<div class="code">&lt;copyField source=<span style="color: #0000ff;">&#8220;author&#8221;</span> dest=<span style="color: #0000ff;">&#8220;authorStr&#8221;</span>/&gt;<br />
&lt;copyField source=<span style="color: #0000ff;">&#8220;title&#8221;</span> dest=<span style="color: #0000ff;">&#8220;titleStr&#8221;</span>/&gt;<br />
&lt;copyField source=<span style="color: #0000ff;">&#8220;topic&#8221;</span> dest=<span style="color: #0000ff;">&#8220;topicStr&#8221;</span>/&gt;</div>
<p>It&#8217;s worth mentioning here that Solr indexes are not databases! While there are some similarities in the way that Solr allows you to add, update, select, store, and delete information from the index, Solr isn&#8217;t an RDBMS. I&#8217;ve seen a few discussions where there is some confusion as to why Solr can&#8217;t do the equivalent of a stored procedure, or some other function of a database.</p>
<p>Now, your index server is ready to receive documents to search against. The server, in with the above example as the schema, will expect information to be in the following format:</p>
<div class="code"><span style="color: #000080;">&lt;doc&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;id&#8221;</span>&gt;</span>1<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;title&#8221;</span>&gt;</span>Solr Rocks!<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;author&#8221;</span>&gt;</span>Barr, Foo<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;review&#8221;</span>&gt;</span>This book rocks!<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;review&#8221;</span>&gt;</span>This book is horrible!<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;topic&#8221;</span>&gt;</span>information retrieval systems<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;topic&#8221;</span>&gt;</span>xml<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;topic&#8221;</span>&gt;</span>search<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;topic&#8221;</span>&gt;</span>apache foundation<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #000080;">&lt;/doc&gt;</span></div>
<p>Next week when I get some time, I&#8217;ll write about creating facet queries&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liquidfoot.com/2007/10/05/solr-schema/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solr and Coldfusion &#8212; Setting Up</title>
		<link>http://www.liquidfoot.com/2007/10/05/solr-and-coldfusion-setting-up/</link>
		<comments>http://www.liquidfoot.com/2007/10/05/solr-and-coldfusion-setting-up/#comments</comments>
		<pubDate>Fri, 05 Oct 2007 19:22:14 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[solr]]></category>
		<guid isPermaLink="false">http://www.liquidfoot.com/?p=180</guid>
		<description><![CDATA[To get up and running with Solr, you&#8217;ll need some type of Servlet container. Typically when folks start talking about servlet containers, they&#8217;re talking about Tomcat or Jetty. In fact, Solr comes with Jetty 6.1.3 (they haven&#8217;t upgraded to 6.1.5 yet in the distribution). You may also hear about Resin, but in my experience, it [...]]]></description>
			<content:encoded><![CDATA[<div class="body">
<p>To get up and running with Solr, you&#8217;ll need some type of Servlet container. Typically when folks start talking about servlet containers, they&#8217;re talking about <a href="http://tomcat.apache.org/">Tomcat</a> or <a href="http://jetty.mortbay.org/">Jetty</a>. In fact, Solr comes with Jetty 6.1.3 (they haven&#8217;t upgraded to 6.1.5 yet in the distribution). You may also hear about <a href="http://www.caucho.com/">Resin</a>, but in my experience, it runs a bit slower than Jetty and Tomcat. As a small note, servlet containers are different than J2EE application servers like JRun, Geronimo, GlassFish, and JBoss (which use servlet containers like Tomcat and Jetty, but also have EJB containers and can handle other types of logic). If you have a J2EE application server running, you can easily use Solr, and if not, consider using Jetty or Tomcat as your container server.</p>
<p>Since your environment can be as varied as there are IT departments, I won&#8217;t try to cover everything. Essentially you need to have at least the Java 1.5 JRE. However, I would <strong>strongly</strong> suggest the most current <a href="http://java.sun.com/">Java JDK (and not the JRE)</a> as it has performance enhancements to run in server mode (with -server). If you don&#8217;t already have this Java version installed on your server (assuming this is the same server running CF), don&#8217;t worry, ColdFusion will still work if you install the required Java runtime.</p>
<p>Essentially the process for deploying Solr, once you have a servlet container up-and-running is to drop the solr.war file into the webapps directory on the server. It won&#8217;t do anything at this point as you need to set the configuration files for Solr. The easiest way to do this is copy the files from example/solr into a new directory (which I will refer to now as solr_home).</p>
<p>You can tell Java about the home directory by setting the solr.solr.home (-Dsolr.sol.home), set the JNDI lookup (&#8220;java:comp/env/solr/home&#8221;), or just throw it into the JVM&#8217;s working directory (the default path is ./solr). Now you just need to make sure everything is running. Just point your browser to http://&lt;server&gt;:&lt;port&gt;/solr/admin. You should then see the administration interface (you may need to restart your servlet container to get everything working properly), but it&#8217;s not an administrative interface like you get in CFAdmin. This is more of an informational administration panel. You can make sure everything is running, that there are documents in your index is set up properly, check out the schema and configuration files, and thread information. Really the only thing you can administer here is the log level.</p>
<p>For some more specific notes on intalling Solr in <a href="http://wiki.apache.org/solr/SolrTomcat">Tomcat</a> and <a href="http://wiki.apache.org/solr/SolrJetty">Jetty</a>, check out <a href="http://wiki.apache.org/solr/SolrInstall">Solr&#8217;s wiki</a>. In particular, if you&#8217;re going to need multiple instances of Solr to run, pay attention to the sections on Multipe Solr apps on those wiki pages.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.liquidfoot.com/2007/10/05/solr-and-coldfusion-setting-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coldfusion Solr Client &#8211; SolColdfusion</title>
		<link>http://www.liquidfoot.com/2007/10/04/coldfusion-solr-client-solcoldfusion/</link>
		<comments>http://www.liquidfoot.com/2007/10/04/coldfusion-solr-client-solcoldfusion/#comments</comments>
		<pubDate>Thu, 04 Oct 2007 22:19:47 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[lucene]]></category>
		<category><![CDATA[solr]]></category>
		<guid isPermaLink="false">http://www.liquidfoot.com/?p=182</guid>
		<description><![CDATA[As I hinted at yesterday, I was close to having some code in the pipeline to abstract using Solr. I&#8217;ve finished the initial code with the following built in. Here&#8217;s a brief setup guide to start playing with the code. First, you&#8217;re going to need to grab the latest release version of Solr (currently 1.2). [...]]]></description>
			<content:encoded><![CDATA[<div class="body">
<p>As I hinted at yesterday, I was close to having some code in the pipeline to abstract using Solr. I&#8217;ve finished the initial code with the following built in. Here&#8217;s a brief setup guide to start playing with the code.</p>
<p>First, you&#8217;re going to need to grab the latest <a href="http://www.apache.org/dyn/closer.cgi/lucene/solr/">release version of Solr (currently 1.2)</a>. The only real requirement to run this software is that you have a JRE of 1.5 or higher. Untar/zip the file somewhere convenient and open a command prompt. Get to the example directory in the apache-solr.1.2.x folder (cd /example). To start up the sample server running Jetty, just issue the following command:</p>
<div class="code">java -jar start.jar</div>
<p>This will start a new instance of the Solr server on your computer on port 8983. You can make sure this is running by navigating to <a href="http://localhost:8983/solr">http://localhost:8983/solr</a> (NOTE: this is a link to your computer. If you get an error, it&#8217;s because your computer isn&#8217;t running an instance of Solr on port 8983).</p>
<p>At this point, it&#8217;s probably good to send you over to the Solr website to take a look at <a href="http://lucene.apache.org/solr/tutorial.html">their tutorial</a>. Go ahead. I&#8217;ll wait&#8230;</p>
<p>&#8230;</p>
<p>Great, you&#8217;re back.</p>
<p>You&#8217;ve seen some basic inserting, deleting, and querying of Solr index data. You may have also noticed that there are clients for PHP, Ruby, Python, and Java&#8230;no ColdFusion. I want to do a little more testing on this before I submit the patch, but I&#8217;ve added the initial code as an encosure here to do updating, deleting, and searching in Coldfusion.</p>
<p>The CFC SolColdfusion should be in the path org/apache/client (at least that&#8217;s where I&#8217;m putting in for the purposes of this initial demonstration). The initialization takes one required parameter (the Solr host) and then has two optional parameters (port and path).</p>
<p>To set this up, create an instance with</p>
<div class="code"><span style="color: #800000;">&lt;cfset solr = createObject(<span style="color: #0000ff;">&#8220;component&#8221;</span>, <span style="color: #0000ff;">&#8220;org.apache.solr.client.SolColdfusion&#8221;</span>).init(<span style="color: #0000ff;">&#8220;<a href="http://localhost/" target="_blank">http://localhost</a>&#8220;</span>, <span style="color: #0000ff;">&#8220;8983&#8243;</span>, <span style="color: #0000ff;">&#8220;/solr&#8221;</span>) /&gt;</span></div>
<p>Now, there are a lot of different parameters you can send to Solr to perform different queries. And, since some of these key names can repeat, I chose to implement sending these parameters as an array. So, let&#8217;s set this up.</p>
<div class="code"><span style="color: #800000;">&lt;cfset params = arrayNew(<span style="color: #0000ff;">1</span>) /&gt;</span></p>
<p><span style="color: #800000;">&lt;cfset params[1][1] = <span style="color: #0000ff;">&#8220;indent&#8221;</span>&gt;</span><br />
<span style="color: #800000;">&lt;cfset params[1][2] = <span style="color: #0000ff;">&#8220;on&#8221;</span> /&gt;</span><br />
<span style="color: #800000;">&lt;cfset params[2][1] = <span style="color: #0000ff;">&#8220;wt&#8221;</span>&gt;</span><br />
<span style="color: #800000;">&lt;cfset params[2][2] = <span style="color: #0000ff;">&#8220;standard&#8221;</span> /&gt;</span><br />
<span style="color: #800000;">&lt;cfset params[3][1] = <span style="color: #0000ff;">&#8220;fl&#8221;</span> /&gt;</span><br />
<span style="color: #800000;">&lt;cfset params[3][2] = <span style="color: #0000ff;">&#8220;*,score&#8221;</span> /&gt;</span><br />
<span style="color: #800000;">&lt;cfset params[4][1] = <span style="color: #0000ff;">&#8220;qt&#8221;</span> /&gt;</span><br />
<span style="color: #800000;">&lt;cfset params[4][2] = <span style="color: #0000ff;">&#8220;standard&#8221;</span> /&gt;</span><br />
<span style="color: #800000;">&lt;cfset params[5][1] = <span style="color: #0000ff;">&#8220;wt&#8221;</span> /&gt;</span><br />
<span style="color: #800000;">&lt;cfset params[5][2] = <span style="color: #0000ff;">&#8220;standard&#8221;</span> /&gt;</span></div>
<p>These parameters are basically what are the defaults that Solr will return back to you. If you want highlighting, you would need to add two additional row vectors with &#8216;hl = on&#8217; and &#8216;hl.fl = &#8216;.</p>
<p>Searching is straight forward, taking a query, the start row, number of rows to return, and the array of parameters:</p>
<div class="code"><span style="color: #800000;">&lt;cfset results = solr.search(<span style="color: #0000ff;">&#8220;*:*&#8221;</span>,<span style="color: #0000ff;"> 0</span>,<span style="color: #0000ff;"> 10</span>, params) /&gt;</span></div>
<p>This searches all fields and all content and returns back an XML document with the search results in it.</p>
<div class="code"><span style="color: #800000;">&lt;cfdump var=<span style="color: #0000ff;">&#8220;#results#&#8221;</span> /&gt;</span></div>
<p>In the result node, you&#8217;ll see that Solr returns an xmlAttribute of</p>
<div class="code">numFound</div>
<p>of 0 (assuming you don&#8217;t have anything in the index). Let&#8217;s add an example document from the documents that come with Solr.</p>
<div class="code"><span style="color: #808080;"><em>&lt;!&#8212; Create a new sample document &#8212;&gt;</em></span><br />
<span style="color: #800000;">&lt;cfxml variable=<span style="color: #0000ff;">&#8220;sample&#8221;</span>&gt;</span><br />
<span style="color: #000080;">&lt;doc&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;id&#8221;</span>&gt;</span>F8V7067-APL-KIT<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;name&#8221;</span>&gt;</span>Belkin Mobile Power Cord for iPod w/ Dock<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;manu&#8221;</span>&gt;</span>Belkin<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;cat&#8221;</span>&gt;</span>electronics<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;cat&#8221;</span>&gt;</span>connector<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;features&#8221;</span>&gt;</span>car power adapter, white<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;weight&#8221;</span>&gt;</span>4<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;price&#8221;</span>&gt;</span>19.95<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;popularity&#8221;</span>&gt;</span>1<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #ff8000;">&lt;field name=<span style="color: #0000ff;">&#8220;inStock&#8221;</span>&gt;</span>false<span style="color: #ff8000;">&lt;/field&gt;</span><br />
<span style="color: #000080;">&lt;/doc&gt;</span><br />
<span style="color: #800000;">&lt;/cfxml&gt;</span></p>
<p><span style="color: #808080;"><em>&lt;!&#8212; add this document to the index &#8212;&gt;</em></span><br />
<span style="color: #800000;">&lt;cfset solr.add(sample) /&gt;</span><br />
<span style="color: #800000;">&lt;cfset solr.commit() /&gt;</span><br />
<span style="color: #800000;">&lt;cfset solr.optimize() /&gt;</span></p>
<p><span style="color: #808080;"><em>&lt;!&#8212; search for the newly added document &#8212;&gt;</em></span><br />
<span style="color: #800000;">&lt;cfset results = solr.search(<span style="color: #0000ff;">&#8220;id:F8V7067-APL-KIT&#8221;</span>,<span style="color: #0000ff;"> 0</span>,<span style="color: #0000ff;"> 10</span>, params) /&gt;</span></p>
<p><span style="color: #800000;">&lt;cfdump var=<span style="color: #0000ff;">&#8220;#xmlParse(results)#&#8221;</span> /&gt;</span></div>
<p>You&#8217;ll notice I used a commit and optmize statement. Neither of these statements are necessary every time you add a document, but be aware that Solr caches documents and won&#8217;t flush the new documents to disk unless you either commit the documents or the mergefactor setting you used in your solrconfig.xml file has been reached.</p>
<p>Now, let&#8217;s delete this document&#8230;</p>
<div class="code"><span style="color: #800000;">&lt;cfset solr.deleteById(<span style="color: #0000ff;">&#8220;F8V7067-APL-KIT&#8221;</span>) /&gt;</span><br />
<span style="color: #800000;">&lt;cfset solr.commit() /&gt;</span></div>
<p>Don&#8217;t forget to commit deletions to the index!</p>
<p>There&#8217;ll be more soon (add multiple documents, delete by queries). In the mean time, try it out. If you have any comments, questions, concerns, whatever, let me know.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.liquidfoot.com/2007/10/04/coldfusion-solr-client-solcoldfusion/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ColdFusion and Solr</title>
		<link>http://www.liquidfoot.com/2007/10/03/coldfusion-and-solr/</link>
		<comments>http://www.liquidfoot.com/2007/10/03/coldfusion-and-solr/#comments</comments>
		<pubDate>Wed, 03 Oct 2007 22:38:43 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[lucene]]></category>
		<category><![CDATA[solr]]></category>
		<guid isPermaLink="false">http://www.liquidfoot.com/?p=184</guid>
		<description><![CDATA[I&#8217;ve spent the last few months working on some projects that didn&#8217;t really have anything to do with ColdFusion (lots of Java and PHP). One of the projects I&#8217;ve been working with (Vufind.org) uses Solr as it&#8217;s indexing/search engine. That&#8217;s starting to get picked up by some pretty big companies (Netflix just relaunched their search [...]]]></description>
			<content:encoded><![CDATA[<div class="body">
<p>I&#8217;ve spent the last few months working on some projects that didn&#8217;t really have anything to do with ColdFusion (lots of Java and PHP). One of the projects I&#8217;ve been working with (<a href="http://www.vufind.org/">Vufind.org</a>) uses <a href="http://lucene.apache.org/solr/">Solr</a> as it&#8217;s indexing/search engine. That&#8217;s starting to get picked up by some pretty big companies (Netflix just relaunched their search using Solr this week).</p>
<p>I&#8217;ve been working with Solr in Java for a bit now, and I wanted to start to build an interface for using it as a search engine (my Lucene code is stuck in open source limbo) in Coldfusion. One of the cool things about Solr is that it returns results back through HTTP (in XML, JSON, or ruby).</p>
<p>As soon as I get the code finished, I&#8217;ll post it as a patch in Solr.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.liquidfoot.com/2007/10/03/coldfusion-and-solr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Her Royal Majesty</title>
		<link>http://www.liquidfoot.com/2007/04/30/her-royal-majesty/</link>
		<comments>http://www.liquidfoot.com/2007/04/30/her-royal-majesty/#comments</comments>
		<pubDate>Mon, 30 Apr 2007 15:30:20 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[modelglue]]></category>
		<guid isPermaLink="false">http://www.liquidfoot.com/?p=194</guid>
		<description><![CDATA[Ok, it&#8217;s been a while. I&#8217;ve been working on some non-ColdFusion projects so I&#8217;ve been a bit remiss in keeping things up-to-date here. But big news (at least for William and Mary). Her Royal Majesty, Queen Elizabeth II will be visiting William and Mary this Friday as part Jamestown&#8217;s 400th anniversary. Normally this wouldn&#8217;t be [...]]]></description>
			<content:encoded><![CDATA[<div class="body">
<p>Ok, it&#8217;s been a while. I&#8217;ve been working on some non-ColdFusion projects so I&#8217;ve been a bit remiss in keeping things up-to-date here. But big news (at least for William and Mary). Her Royal Majesty, Queen Elizabeth II will be visiting William and Mary this Friday as part Jamestown&#8217;s 400th anniversary.</p>
<p>Normally this wouldn&#8217;t be related to ColdFusion at all, but last week it was announced that she would be coming here and thus ensued a mad rush to get an <a href="http://swem.wm.edu/exhibits/queen/">online exhibit of the Queen&#8217;s 1957 visit up</a> that would make available pretty much everything we have stored in our Special Collections from her previous visit. I got to use Model-Glue after a long time of not looking at it. I had almost forgotten how painless Model-Glue makes putting projects like this together.</p>
<p>I just wanted to give a big thanks to Joe Rinehart and Doug Hughes for bringing the &#8220;rapid&#8221; back into rapid application development!</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.liquidfoot.com/2007/04/30/her-royal-majesty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MS Access via JDBC</title>
		<link>http://www.liquidfoot.com/2007/02/02/ms-access-via-jdbc/</link>
		<comments>http://www.liquidfoot.com/2007/02/02/ms-access-via-jdbc/#comments</comments>
		<pubDate>Fri, 02 Feb 2007 22:23:14 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Server]]></category>
		<guid isPermaLink="false">http://www.liquidfoot.com/?p=198</guid>
		<description><![CDATA[We recently made the move from an IIS Windows web server to an Apache *nix based web server as part of our efforts to consolidate our library&#8217;s server infrastructure. And for reasons I won&#8217;t expound upon, we had one MS Access DSN that didn&#8217;t get migrated to MSSQL and that needed to be used still. [...]]]></description>
			<content:encoded><![CDATA[<div class="body">
<p>We recently made the move from an IIS Windows web server to an Apache *nix based web server as part of our efforts to consolidate our library&#8217;s server infrastructure. And for reasons I won&#8217;t expound upon, we had one MS Access DSN that didn&#8217;t get migrated to MSSQL and that needed to be used still. Since ColdFusion uses a Windows only driver for MS Access, I needed to figure out a way around this. I found a couple of JDBC drivers for Access (Easysoft&#8217;s <a href="http://www.easysoft.com/products/data_access/jdbc_odbc_bridge/index.html">JDBC-ODBC Bridge</a> and HXTT&#8217;s <a href="http://www.hxtt.com/access.html">Access Pure Java JDBC Drivers</a>), but these seemed to be a bit on the expensive side for the short amount of time that I&#8217;d need to keep Access in production.</p>
<p>I did notice on Easysoft&#8217;s website that they were using the JdbcOdbc bridge, so after a little bit more digging, I found the syntax to use configure ColdFusion to use MS Access through the JdbcOdbc Bridge; the JDBC URL is</p>
<div class="code">jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=/path/to/datasource.mdb;DriverID22;</div>
<p>and the Driver Class</p>
<div class="code">sun.jdbc.odbc.JdbcOdbcDriver</div>
<p>For the very basic inserting of data from a seldom-used web form into a single table, this band aid fix has been doing pretty good!</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.liquidfoot.com/2007/02/02/ms-access-via-jdbc/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Form Validation</title>
		<link>http://www.liquidfoot.com/2006/09/21/form-validation/</link>
		<comments>http://www.liquidfoot.com/2006/09/21/form-validation/#comments</comments>
		<pubDate>Thu, 21 Sep 2006 16:17:42 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web]]></category>
		<guid isPermaLink="false">http://www.liquidfoot.com/?p=202</guid>
		<description><![CDATA[I&#8217;ve been playing with some form validation stuff for CF. I had been usign , but I wanted the HTML interface to act a bit more like the Flash interface, but I don&#8217;t really want to use Flash. I&#8217;ve also been doing a lot more work with some of the DHTML libraries that AJAX has [...]]]></description>
			<content:encoded><![CDATA[<div class="body">
<p>I&#8217;ve been playing with some form validation stuff for CF. I had been usign , but I wanted the HTML interface to act a bit more like the Flash interface, but I don&#8217;t really want to use Flash. I&#8217;ve also been doing a lot more work with some of the DHTML libraries that AJAX has made popular, so I figured there had to be a relatively elegent way to do form validations with something like <a href="http://prototype.conio.net/%3Eprototype%3C/a%3E.%3C/p%3E%3Cp%3EI%20remembered%20seeing%20something%20on%20%3Ca%20href=">Ajaxian</a> about easy form validation and decided to give it a try. The article on <a href="http://tetlaw.id.au/view/blog/really-easy-field-validation-with-prototype/">Dexagogo</a> shows how they created a library to handle form-validations that doesn&#8217;t require any other work than creating a form. This was just what I was looking for!</p>
<p>Basically, you just need the latest files from <a href="http://script.aculo.us/">script.aclo.us</a> with the latest prototype version (the 1.5 release candidate is included in the latest script.aculo.us lib folder), and the validation library. Convienently, they&#8217;re all included <a href="http://tetlaw.id.au/upload/dev/validation/validation1.5.3.zip">in the demo file on the site</a>.</p>
<p>To use this, you really only need prototype and the validation library (script.aculo.us adds a nice effect – much like the Flash format in cfform). For me, I made these calls:</p>
<div class="code"><span style="color: #000080;">&lt;head&gt;</span><br />
<span style="color: #000080;"><span style="color: #800000;">&lt;script type=<span style="color: #0000ff;">&#8220;text/javascript&#8221;</span> src=<span style="color: #0000ff;">&#8220;/scripts/scriptaculous/lib/prototype.js&#8221;</span>&gt;</span></span><span style="color: #000080;"><span style="color: #800000;">&lt;/script&gt;</span></span><br />
<span style="color: #000080;"><span style="color: #800000;">&lt;script type=<span style="color: #0000ff;">&#8220;text/javascript&#8221;</span> src=<span style="color: #0000ff;">&#8220;/scripts/validator.js&#8221;</span>&gt;</span></span><span style="color: #000080;"><span style="color: #800000;">&lt;/script&gt;</span></span><br />
<span style="color: #000080;"><span style="color: #800000;">&lt;script type=<span style="color: #0000ff;">&#8220;text/javascript&#8221;</span> src=<span style="color: #0000ff;">&#8220;/scripts/scriptaculous/scriptaculous.js?load=effects&#8221;</span>&gt;</span></span><span style="color: #000080;"><span style="color: #800000;">&lt;/script&gt;</span></span><br />
<span style="color: #000080;">&lt;/head&gt;</span></div>
<p>This is slightly different than the example on their page; they load the effects.js file directly, I&#8217;m calling the library via script.aculo.us with the load parameter. This isn&#8217;t really a big deal for one library, but it is convenient when you want to use several, but not all, of the libraries (e.g. scriptaculous.js?load=effects,dragdrop,slider).</p>
<p>Anyway, to actually use this, you need to create a form with an id attribute:</p>
<div class="code"><span style="color: #000080;"><span style="color: #ff8000;">&lt;form name=<span style="color: #0000ff;">&#8220;feedback&#8221;</span> id=<span style="color: #0000ff;">&#8220;feedback&#8221;</span> action=<span style="color: #0000ff;">&#8220;#cgi.script_name#&#8221;</span> method=<span style="color: #0000ff;">&#8220;post&#8221;</span>&gt;</span></span><br />
&#8230;<br />
<span style="color: #000080;"><span style="color: #ff8000;">&lt;/form&gt;</span></span></div>
<p>Now, we add some fields and use the class attribute to call the validator:</p>
<div class="code">Name: <span style="color: #000080;"><span style="color: #ff8000;">&lt;input type=<span style="color: #0000ff;">&#8220;text&#8221;</span> name=<span style="color: #0000ff;">&#8220;name&#8221;</span> id=<span style="color: #0000ff;">&#8220;name&#8221;</span> class=<span style="color: #0000ff;">&#8220;required&#8221;</span> /&gt;</span></span><span style="color: #000080;">&lt;br/&gt;</span><br />
Email: <span style="color: #000080;"><span style="color: #ff8000;">&lt;input type=<span style="color: #0000ff;">&#8220;text&#8221;</span> name=<span style="color: #0000ff;">&#8220;email&#8221;</span> id=<span style="color: #0000ff;">&#8220;email&#8221;</span> class=<span style="color: #0000ff;">&#8220;required validate-email&#8221;</span> /&gt;</span></span><br />
<span style="color: #000080;"><span style="color: #ff8000;">&lt;input type=<span style="color: #0000ff;">&#8220;submit&#8221;</span> /&gt;</span></span></div>
<p>There are 11 options for use in the validation library (this is directly off their page):</p>
<ul>
<li>required (not blank)</li>
<li>validate-number (a valid number)</li>
<li>validate-digits (digits only)</li>
<li>validate-alpha (letters only)</li>
<li>validate-alphanum (only letters and numbers)</li>
<li>validate-date (a valid date value)</li>
<li>validate-email (a valid email address)</li>
<li>validate-url (a valid URL)</li>
<li>validate-date-au (a date formatted as; dd/mm/yyyy)</li>
<li>validate-currency-dollar (a valid dollar value)</li>
<li>validate-one-required (At least one textbox/radio element must be selected in a group)</li>
</ul>
<p>This is really nice, because if you want to allow an optional field, but validate it, you can do:</p>
<div class="code"><span style="color: #000080;"><span style="color: #ff8000;">&lt;input type=<span style="color: #0000ff;">&#8220;text&#8221;</span> name=<span style="color: #0000ff;">&#8220;email&#8221;</span> class=<span style="color: #0000ff;">&#8220;validate-email&#8221;</span> /&gt;</span></span></div>
<p>There&#8217;s one more piece of the pie&#8230;to call the validation library. At the bottom of your page add:</p>
<div class="code"><span style="color: #000080;"><span style="color: #800000;">&lt;script type=<span style="color: #0000ff;">&#8220;text/javascript&#8221;</span>&gt;</span></span><br />
new Validation(&#8216;feedback&#8217;, {immediate:true});<br />
<span style="color: #000080;"><span style="color: #800000;">&lt;/script&gt;</span></span></div>
<p>The first argument is the id attribute of the form you&#8217;re wanting to validate. The second tells the Validator object what to do. This particular example enables validation on each field as you leave it (which I find useful). Some of the other options are:</p>
<ul>
<li>stopOnFirst (boolean): Stop on the first validation failure; default: false</li>
<li>onSubmit (boolean): Override the default behavior of adding an even listener to the onsubmit event (set to false if you want to make sure your onsubmit method gets called no matter what); default: true</li>
<li>immediate (boolean): validate when the cursor leaves the field; default: false</li>
<li>focusOnError (boolean): place the focus on the first field with an error; default: true</li>
<li>useTitles (boolean): make field validators use form element title attributes as error advice message; default: false</li>
<li>onFormValidate (string function): call a function when the form is validated</li>
<li>onElementValidate (string function): call a function when an element is validated</li>
</ul>
<p>What I thought was really cool was the ability to add custom validation types via an API. Say you only want folks to use capital letters for their names, you simply add a new validation type like:</p>
<div class="code"><span style="color: #000080;"><span style="color: #800000;">&lt;script type=<span style="color: #0000ff;">&#8220;javascript&#8221;</span>&gt;</span></span><br />
Validation.add(&#8216;validate-ucase&#8217;, &#8216;Please only use upper-case letters (A-Z) in this field.&#8217;, function(v){<br />
return Validation.get(&#8216;IsEmpty&#8217;).test(v) || /^[A-Z]+$/.test(v);<br />
}<br />
<span style="color: #000080;"><span style="color: #800000;">&lt;/script&gt;</span></span></div>
<p>Want to add several? You can do that too:</p>
<div class="code"><span style="color: #000080;"><span style="color: #800000;">&lt;script type=<span style="color: #0000ff;">&#8220;javascript&#8221;</span>&gt;</span></span><br />
Validation.addAllThese([<br />
['validate-lcase', 'Please only use lower-case (a-z) letters in this field', function(v){<br />
return Validation.get('IsEmpty').test(v) || /^[a-z]+$/.test(v);<br />
}],<br />
['validate-zip', 'Please check your zip code', function(v){<br />
return Validation.get('IsEmpty').test(v) || /^(\d{5})(( |-)?(\d{4}))?$/.test(v);<br />
}],<br />
['validate-phone', 'Please check your phone number', function(v){<br />
return Validation.get('IsEmpty').test(v) || /^(([0-9]{3}-)|\([0-9]{3}\) ?)?[0-9]{3}-[0-9]{4}$/.test(v);<br />
}],<br />
['validate-ssn', 'Please check the Social Security Number. It should follow the format 999-99-9999', function(v){<br />
return Validation.get('IsEmpty').test(v) || /^([0-9]{3}(-?)[0-9]{2}(-?)[0-9]{4})$/.test(v);<br />
}],<br />
['validate-ip', 'Please check the IP address', function(v){<br />
return Validation.get('IsEmpty').test(v) || /^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$/.test(v);<br />
}],<br />
['validate-uuid', 'Please check the UUID', function(v){<br />
return Validation.get('IsEmpty').test(v) || /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{16}$/.test(v);<br />
}],<br />
['validate-guid', 'Please check the GUID', function(v){<br />
return Validation.get('IsEmpty').test(v) || /^[0-9a-f]{8,<span style="color: #0000ff;">8</span>}-[0-9a-f]{4,<span style="color: #0000ff;">4</span>}-[0-9a-f]{4,<span style="color: #0000ff;">4</span>}-[0-9a-f]{4,<span style="color: #0000ff;">4</span>}-[0-9a-f]{12,<span style="color: #0000ff;">12</span>}]$/.test(v);<br />
}],<br />
['validate-float', 'Please only use floating point numbers in this field', function(v){<br />
return Validation.get('IsEmpty').test(v) || /^(\b[0-9]+\.([0-9]+\b)?|\.[0-9]+\b)$/.test(v);<br />
}],<br />
['validate-visa', 'Please check your credit card number', function(v){<br />
return Validation.get('IsEmpty').test(v) || /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/.test(v);<br />
}],<br />
['validate-mastercard', 'Please check your credit card number', function(v){<br />
return Validation.get('IsEmpty').test(v) || /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/.test(v);<br />
}],<br />
['validate-discovery', 'Please check your credit card number', function(v){<br />
return Validation.get('IsEmpty').test(v) || /^6011-?\d{4}-?\d{4}-?\d{4}$/.test(v);<br />
}],<br />
['validate-amex', 'Please check your credit card number', function(v){<br />
return Validation.get('IsEmpty').test(v) || /^3[4,<span style="color: #0000ff;">7</span>]\d{13}$/.test(v);<br />
}],<br />
['validate-diners', 'Please check your credit card number', function(v){<br />
return Validation.get('IsEmpty').test(v) || /^3[0,<span style="color: #0000ff;">6</span>,<span style="color: #0000ff;">8</span>]\d{12}$/.test(v);<br />
}],<br />
['validate-time', 'Please only use time in this field', function(v){<br />
return Validation.get('IsEmpty').test(v) || /^\d{1,<span style="color: #0000ff;">2</span>}[:]\d{2}([:]\d{2})?( [aApP][mM]?)?$/.test(v);<br />
}]<br />
]);<br />
<span style="color: #000080;"><span style="color: #800000;">&lt;/script&gt;</span></span></div>
<p>This should be all of the normal items included in  (plus a couple extra for good measure). Now the only thing left is to make it look pretty. One of the nice things about the Flash format in  is that it color codes required fields with the different halo effects. To obtain a similar effect in the forms, we&#8217;ll use style sheets instead.</p>
<p>This is a rather light stylesheet, but it&#8217;ll give you something to start with (based on the default haloGreen skin):</p>
<div class="code">input.required, textarea.required {<br />
border: 1px solid #ffbf2b;<br />
}<br />
input.validation-failed, textarea.validation-failed{<br />
border: 1px solid #ff3300;<br />
color: #ff3300;<br />
}<br />
input.validation-passed, textarea.validation-passed{<br />
border: 1px solid #00cc00;<br />
color: #000;<br />
}<br />
.validation-advice {<br />
margin: 5px 0;<br />
padding: 5px;<br />
background-color: #FF3300;<br />
color: #fff;<br />
font-weight: bold;<br />
}<br />
.custom-advice {<br />
margin: 5px 0;<br />
padding: 5px;<br />
background-color: #c8aa00;<br />
color: #fff;<br />
font-weight:bold;<br />
}</div>
<p>I made a short example of some of the validations at <a href="http://swem.wm.edu/blogs/waynegraham/examples/validation/">http://swem.wm.edu/blogs/waynegraham/examples/validation/</a>. I have to say that I&#8217;ve found this to be a bit better solution (at least for my needs) than using !</div>
]]></content:encoded>
			<wfw:commentRss>http://www.liquidfoot.com/2006/09/21/form-validation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Real Life XSLT 2.0 transformations</title>
		<link>http://www.liquidfoot.com/2006/08/23/real-life-xslt-20-transformations/</link>
		<comments>http://www.liquidfoot.com/2006/08/23/real-life-xslt-20-transformations/#comments</comments>
		<pubDate>Wed, 23 Aug 2006 18:56:31 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[xslt]]></category>
		<guid isPermaLink="false">http://www.liquidfoot.com/?p=208</guid>
		<description><![CDATA[I ran into a bit of a situation that was really blowing my mind. I have a rather large XML file (around 20,000+ lines) marked up in TEI that I wanted to do some transformations on (a day book and ledger from the 1850s). Essentially the code follows the format &#8230; &#60;figure&#62; &#60;head&#62;Page 12&#60;/head&#62; &#60;graphic [...]]]></description>
			<content:encoded><![CDATA[<div class="body">
<p>I ran into a bit of a situation that was really blowing my mind. I have a rather large XML file (around 20,000+ lines) marked up in TEI that I wanted to do some transformations on (a day book and ledger from the 1850s). Essentially the code follows the format</p>
<div class="code">&#8230;<br />
<span style="color: #ff8000;">&lt;figure&gt;</span><br />
<span style="color: #000080;">&lt;head&gt;</span>Page 12<span style="color: #000080;">&lt;/head&gt;</span><br />
&lt;graphic url=<span style="color: #0000ff;">&#8220;0023_p12&#8243;</span>/&gt;<br />
<span style="color: #ff8000;">&lt;/figure&gt;</span></p>
<p>&lt;fw type=<span style="color: #0000ff;">&#8220;header&#8221;</span> place=<span style="color: #0000ff;">&#8220;top-center&#8221;</span>&gt;<br />
<span style="color: #000080;">&lt;name type=<span style="color: #0000ff;">&#8220;place&#8221;</span> key=<span style="color: #0000ff;">&#8220;7022220&#8243;</span>&gt;</span>Williamsburg<span style="color: #000080;">&lt;/name&gt;</span>,<br />
<span style="color: #000080;">&lt;date value=<span style="color: #0000ff;">&#8220;1850&#8243;</span>&gt;</span>1850<span style="color: #000080;">&lt;/date&gt;</span>,<br />
&lt;/fw&gt;</p>
<p><span style="color: #008080;">&lt;table&gt;</span><br />
<span style="color: #000080;">&lt;row&gt;</span><br />
<span style="color: #000080;">&lt;cell&gt;</span><br />
<span style="color: #000080;">&lt;date value=<span style="color: #0000ff;">&#8220;1850-10-03&#8243;</span>&gt;</span>&lt;choice&gt;<span style="color: #008000;">&lt;abbr&gt;</span>Oct<span style="color: #000080;">&lt;hi rend=<span style="color: #0000ff;">&#8220;sup;underline&#8221;</span>&gt;</span>r<span style="color: #000080;">&lt;/hi&gt;</span><span style="color: #008000;">&lt;/abbr&gt;</span><span style="color: #000080;">&lt;expan&gt;</span>October<span style="color: #000080;">&lt;/expan&gt;</span>&lt;/choice&gt; 3<span style="color: #000080;">&lt;hi rend=<span style="color: #0000ff;">&#8220;sup&#8221;</span>&gt;</span>th<span style="color: #000080;">&lt;/hi&gt;</span> 1850<span style="color: #000080;">&lt;/date&gt;</span><br />
<span style="color: #000080;">&lt;/cell&gt;</span><br />
<span style="color: #000080;">&lt;cell&gt;</span><br />
<span style="color: #000080;">&lt;name type=<span style="color: #0000ff;">&#8220;person&#8221;</span> key=<span style="color: #0000ff;">&#8220;griffss01&#8243;</span>&gt;</span>Doct<span style="color: #000080;">&lt;hi rend=<span style="color: #0000ff;">&#8220;sup;underline&#8221;</span>&gt;</span>r<span style="color: #000080;">&lt;/hi&gt;</span> S S Griffin<span style="color: #000080;">&lt;/name&gt;</span><br />
<span style="color: #000080;">&lt;/cell&gt;</span><br />
<span style="color: #000080;">&lt;cell&gt;</span><strong><em>&amp;nbsp;</em></strong><span style="color: #000080;">&lt;/cell&gt;</span><br />
<span style="color: #000080;">&lt;/row&gt;</span><br />
&#8230;<br />
<span style="color: #008080;">&lt;/table&gt;</span><br />
<span style="color: #000080;">&lt;pb/&gt;</span><br />
&#8230;</div>
<p>What I wanted to accomplish was group all this together in separate divs for HTML output (ok, I actually need to write each page to its own file, but this is pretty much just one more step).</p>
<p>I just could not find a way to group this info this way using XSLT 1 without wrapping each page within its own div structure. I didn&#8217;t really want to go back and do this, so I asked the TEI-L list. David Sewell pinged me back with some XQuery code that recursively recalls the document structure for a given node.</p>
<p>He also mentioned that it would be pretty easy to write an XSLT 2 transformation that groups these nodes together. I did a little bit of digging and came up with</p>
<div class="code"><span style="color: #000080;">&lt;xsl:template match=<span style="color: #0000ff;">&#8220;tei:div&#8221;</span>&gt;</span><br />
<span style="color: #000080;">&lt;xsl:for-each-group select=<span style="color: #0000ff;">&#8220;*&#8221;</span> group-ending-with<span style="color: #0000ff;">&#8220;tei:pb&#8221;</span>&gt;</span><br />
<span style="color: #000080;">&lt;div class=<span style="color: #0000ff;">&#8220;page&#8221;</span>&gt;</span><br />
<span style="color: #000080;">&lt;xsl:apply-templates select=<span style="color: #0000ff;">&#8220;current-group()&#8221;</span> /&gt;</span><br />
<span style="color: #000080;">&lt;/div&gt;</span><br />
<span style="color: #000080;">&lt;/xsl:for-each-group&gt;</span><br />
<span style="color: #000080;">&lt;/xsl:template&gt;</span></div>
<p>This transformed the pages to what I was wanting</p>
<div class="code"><span style="color: #000080;">&lt;div class=<span style="color: #0000ff;">&#8220;page&#8221;</span>&gt;</span><br />
<span style="color: #000080;"><span style="color: #800080;">&lt;img src=<span style="color: #0000ff;">&#8220;0023_12.png&#8221;</span> alt=<span style="color: #0000ff;">&#8220;Page 12&#8243;</span> /&gt;</span></span></p>
<p><span style="color: #000080;">&lt;h1 class=<span style="color: #0000ff;">&#8220;fw&#8221;</span>&gt;</span>Williamsburg,<span style="color: #0000ff;"> 1850</span>,<span style="color: #000080;">&lt;/h1&gt;</span></p>
<p><span style="color: #008080;">&lt;table&gt;</span><br />
<span style="color: #008080;">&lt;tr&gt;</span><br />
<span style="color: #008080;">&lt;td&gt;</span><br />
<span style="color: #000080;">&lt;span class=<span style="color: #0000ff;">&#8220;abbr&#8221;</span>&gt;</span>Oct<span style="color: #000080;">&lt;sup&gt;</span><span style="color: #000080;">&lt;u&gt;</span>r<span style="color: #000080;">&lt;/u&gt;</span><span style="color: #000080;">&lt;/sup&gt;</span><span style="color: #000080;">&lt;/span&gt;</span><span style="color: #000080;">&lt;span class=<span style="color: #0000ff;">&#8220;expan&#8221;</span>&gt;</span>October<span style="color: #000080;">&lt;/span&gt;</span> 3<span style="color: #000080;">&lt;sup&gt;</span>th<span style="color: #000080;">&lt;/sup&gt;</span> 1850<span style="color: #000080;">&lt;/date&gt;</span><br />
<span style="color: #008080;">&lt;/td&gt;</span><br />
<span style="color: #008080;">&lt;td&gt;</span><br />
<span style="color: #008000;">&lt;a href=<span style="color: #0000ff;">&#8220;javascript:getName(&#8216;griffss01&#8242;);&gt;</span>Doct<span style="color: #000080;">&lt;sup&gt;</span><span style="color: #000080;">&lt;u&gt;</span>r<span style="color: #000080;">&lt;/u&gt;</span><span style="color: #000080;">&lt;/sup&gt;</span> S S Griffin<span style="color: #008000;">&lt;/a&gt;</span><br />
<span style="color: #008080;">&lt;/td&gt;</span><br />
<span style="color: #008080;">&lt;td&gt;</span><strong><em>&amp;nbsp;</em></strong><span style="color: #008080;">&lt;/td&gt;</span><br />
<span style="color: #000080;">&lt;/row&gt;</span><br />
&#8230;<br />
<span style="color: #008080;">&lt;/table&gt;</span><br />
<span style="color: #000080;">&lt;/div&gt;</span></p>
<p><span style="color: #000080;">&lt;div class=&#8221;</span>page&#8221;&gt;</span><br />
&#8230;<br />
<span style="color: #000080;">&lt;/div&gt;</span></div>
<p>The XSLT processor for ColdFusion doesn&#8217;t support XSLT 2.0 (it&#8217;s still a draft spec). However, Saxon does (specifically Saxon 8). For more on doing XSLT transformations, see <a href="http://swem.wm.edu/blogs/waynegraham/index.cfm/2005/11/21/XSLT-20-in-ColdFusion">XSLT 2.0 in ColdFusion</a>.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.liquidfoot.com/2006/08/23/real-life-xslt-20-transformations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

