Early beginnings
SketchPath began as a project to investigate the use of Windows Forms and C# in the .NET Framework 2.0. However, I quickly found that I could use this initial work to produce something that could assist me with the XSLT development that I was engaged on in a project with my company.
XSLT Problems
The XML source I was writing Stylesheets for was converted from loosely structured HTML like tagged content. Worse still, a large amount of metadata, (complete with <span> tags) was embedded within the formatted body. XPath expressions used to extract the metadata became increasingly complex with a large number of axes cross-references and predicates embedded within.
The XSLT tools I was using fortunately provided good debugging to allow the 'stepping-through' of the stylesheet. This, combined with a basic built-in XPath checker was sufficient, but hardly ideal when so many XPath expressions were involved.
Requirements
I needed a dedicated XPath tool with a simple interface, but with all the features such as colorizing, variables, debugging, commenting and all the other conveniences that any other language have. Along with this I needed context-sensitive auto-completion based on the source xml, oh, and why can't I just click on the xml text and generate a location path automatically? This is when the idea for SketchPath first took hold.
Raw XML and RTF
The first snag I hit was a basic one, how do I show the raw source XML, complete with color and indenting? After some experimentation, generating RTF from the XmlReader class seemed the reasonable way to go. After a bit of fun and games with RTF headers, I was up and running.
Regular Expressions
Well, sort of. I quickly found that I'd need to escape all RTF specific characters (I'm sure there's a better way to do this but time was an issue). So, to the next problem - regular expressions! The documentation I had at the time seemed impenetrable, so out of despair I decided to try building a simple tool with the .NET regex engine. Quickly, it seemed that here was another bit of useful funcionality that could actually be built into SketchPath. So that's how the regex support first arrived.
Windows Forms
With Microsoft Visual Studio 2005 and the new .NET Framework 2.0 controls, especially SplitContainers and TableLayoutPanels, developing a fairly sophisticated multi-pane environment with auto-resizing became a comparitively simple design exercise, which allowed me to concentrate coding effort on core functionality.
The Setback
Every project has some minor hickups and I hit one about mid-way. Normally, I would have just skirted round the issue with some non-pretty workaround, but for some reason I got so obsessed with getting a resolution that it delayed things for at least 8 weeks.
The problem was how to highlight the start and end tags of an element (but not the middle) with perhaps a yellow background, when it was selected. Lots of tools do this and it shouldn't be a problem but the performance issues and side-effects I encountered were not good. I'm sure there's some simple PInvoke command I can use, but I didn't want to do something low-level.
At one stage I was even sizing the RichTextBox to fit the XML and then placing it inside another container for which I coded all scrolling functionality, not realizing of course that the RichTextBox was not designed to work this way, and hits a ceiling after a fixed number of lines. I also hit issues related to multi-threading at about this time.
The Resolution
The current solution simply sets the background color of the entire element or node, in most contexts this is probably more effective than just marking the beginning and end. Careful control of focus as well as a work-around fix for high-speed scrolling of the (using the Timer class), provides for a very reasonable solution.
WPF - An interesting diversion
The next generation WPF combined with XAML produced a number of exciting new possibilities. And I must confess delaying the project for a couple of months while I side-tracked into investigating the use of WPF (this sort of coincided with the problems I was having with the RichTextBox). In the end I hit a few performance issues with the beta and found problems with CTP and beta versions of Visual Studio and what is now Expression Blend. Because of this I reverted back to Windows forms, but hope to extend this project or another to use WPF or even Silverlight (for cross-platform support) in the future.
Parsing XPath
bookstore/book//*[count( ancestor::*) <4]
Even though SketchPath using the .NET System.XML.XPath namespace for all XPath evaluation, there are a number of features that were needed that meant that I had to develop a parser for XPath, these are:
- Colorization of operators, variables, functions etc. within an XPath expression
- Recognition and realization of XSLT variables
- Underlining XSLT variables where a name match is not found in the SketchPath environment
- Insertion of a default prefix, if a default namespace is declared in the source and no other prefix is supplied
- Auto-Completion on incomplete XPath expressions
Focus
When developing any application, it help to focus on one particular area of functionality and try to do it well, especially when you have limited resources. The area where there has been the most emphasis in design/development is probably in the management of XML expressions and the reusing these as XPath variables. This seems to be something lacking in other XML tools, but XPath variables for example in XSLT can really help break down complex XPath into simpler expressions that are easier to understand, document manage and reuse.
First Beta Release and Onwards
The first Beta was published at the end of May 2007. Internet profile of SketchPath was quite low at the start as one would expect. Since September 2007) however, there has been a marked increase in the popularity of SketchPath, hopefully this will continue and will increase the level of feedback to allow the continued improvement of the product. Downloads are at about 1000 per month.
Current Status
Since its early hesitant start as a Beta, Sketchpath has made very good progress. It is now at Release Version 2.0 and has been enhanced considerably to support XPath 2.0 and XSD validation and a range of other features.
What's Next
Well, that depends on you, so please let me know what features or fixes you'd like to see.