logo
  • Jobs
  • About Me
  • Contact
  • Home

Archive for September, 2003

« Previous Entries

MovablePoster v1.0.1.6

A very minor release, to hold people over until the next *major* one.

This release addresses a problem with categories not being associated to the post until the entry was rebuilt. This was due to mt.publishPost not being called.

Download MovablePoster .msi | .zip

As always, comments and requests are welcomed.

2 Comments

Football question (Intentional Grounding)

I’ve wondered for quite a while why, when a quarterback spikes the ball it is not called intentional grounding.

Anyone know the answer to this?

5 Comments

Download Times

Ive always wondered about my cable modem connection speed. However, looking at the graphic below, something doesnt seem quite right.

wow.JPG

2,605,530 minutes remaining. According to my math, thats just under 5 years (4.957, to be exact) to finish downloading. Ouch!

No Comments

The Matrix: Revolutions

I’m sure that by now you’ve probably seen the new Matrix: Revolutions trailer, coming to theatres on 11.05. If not, get it at http://www.whatisthematrix.com.

No Comments

Implementing your own custom XsltContext objects, cont’d

In my previous post, I mentioned that the only changes are prefacing your XPath function with a namespace prefix.

However, thanks to a post from Oleg Tkachenko, I found a way around this.

In the CustomContext class, override LookupNamespace(string prefix) with the following code:

public override string LookupNamespace(string prefix)
{
    if (prefix == String.Empty)
        return String.Empty;
 
    string uri = base.LookupNamespace(NameTable.Get(prefix));
    if (uri == null)
        throw new XsltException("Undeclared namespace prefix - " + prefix, null);
 
    return uri;
}
2 Comments

Software and the construction trades

Joel Spolsky linked to this article about how the building industry cant build anything on schedule or on budget either.

Reading this article though did remind me of another way that the software industry is similar to the construction trades.

When building a house, or any kind of structure, everything starts with the foundation. While a foundation that runs off 1/8 inch every foot may not seem too bad. If you stretch that out to the width of your foundation (let’s say 80 feet), your foundation has now run off 10 inches total.

Think of the foundation of your construction project as the design for the latest project you worked on. Did you take the time to make sure that you didnt lose that 1/8 inch every foot, or were you willing to live with it? What happened when you went to build your project on top of your foundation? Did everything come together as smoothly as it could have? Would you have spent less time bringing everything together if you would have spent a little more time paying attention to that 1/8 of an inch?

When building a house, if the foundation is just a little off, it carries all the way through, all the way up to the roof. Same goes for software, if you build on top of a poor design, the price is paid down the road trying to make up for the foundation.

I’m sure we’ve all worked on projects that were thrown together on a whim, with no thought given to design or architecture. Less of us, I think, have spent that extra time in upfront design discussions and architecture meetings.

The projects that I’ve worked on that have spent that time have always seemed to come in on time and under budget. These same projects ultimately also ended up being much easier to extend and maintain.

Had a similar experience? Think Im completely off my rocker? Leave a comment… :=)

No Comments

mattberther.com and the Navy Seals

I got this email today from link-builder.com. Im curious as to how mattberther.com can even be remotely relevant to a site that has to do with Navy Seals survival gear.

I am contacting you about cross linking. I am interested in mattberther.com because it looks like it’s relevant to a site that I am the link manager for. The site is about Navy Seals survival gear, videos, and equipment.

I keep the web address confidential and will send it to you only if you give me permission to do so. Just let me know if it’s OK, and I’ll send you the web address for your review. If you approve of the site, then we’ll exchange links.

Looking forward to your reply.

No Comments

Implementing your own custom XsltContext objects

Today I was trying to execute a programmatic XPath query against a document with a query that contained the current() function.

current() is not part of the XPath standard, as it is an XSLT 1.0 extension. However, after spending the better part of an afternoon battling a cryptic exception (’System.Xml.XPath.XPathException: Namespace Manager or XsltContext needed. This query has prefix or variable or userdefined function.”), I finally stumbled across another gem in the .NET framework: The ability to create your own XPath functions.

This capability comes from theSystem.Xml.Xsl.XsltContext class and System.Xml.Xsl.IXsltContextFunction class.

I hope the sample code below will help someone else. Information via Google is virtually non-existent on this topic.

public class CustomContext : System.Xml.Xsl.XsltContext
{
    public CustomContext() : base()
    {
    }
 
    public CustomContext(NameTable nt) : base(nt)
    {
    }
 
    public override int CompareDocument(string baseUri, string nextbaseUri)
    {
        return 0;
    }
 
    public override bool PreserveWhitespace(System.Xml.XPath.XPathNavigator node)
    {
        return false;
    }
 
    public override IXsltContextFunction ResolveFunction(string prefix, string name, System.Xml.XPath.XPathResultType[] ArgTypes)
    {
        if (name.Equals("current"))
        {
            return new XPathContextFunction("current");
        }
 
        return null;
    }
 
    public override IXsltContextVariable ResolveVariable(string prefix, string name)
    {
        return null;
    }
 
    public override bool Whitespace
    {
        get { return false; }
    }
 
    private class XPathContextFunction : IXsltContextFunction
    {
        private string _functionName;
 
        public XPathContextFunction(string functionName)
        {
            this._functionName = functionName;
        }
 
        public System.Xml.XPath.XPathResultType[] ArgTypes
        {
            get { return null; }
        }
 
        public System.Xml.XPath.XPathResultType ReturnType
        {
            get { return XPathResultType.Navigator; }
        }
 
        public int Minargs
        {
            get { return 0; }
        }
 
        public int Maxargs
        {
            get { return 0; }
        }
 
        public object Invoke(XsltContext xsltContext, object[] args, System.Xml.XPath.XPathNavigator docContext)
        {
            if (_functionName.Equals("current"))
            {
                XmlNode currentNode = ((IHasXmlNode)docContext).GetNode();
 
                return currentNode;
            }
 
            return null;
        }
    }
}

This XPath extension function can now be called via the method below:

CustomContext ctxt = new CustomContext(new NameTable());
ctxt.AddNamespace("mb", "urn:mattberther-com:xpath");
 
XmlNodeList nodes = node.SelectNodes("//NodeName[mb:current() = preceding-sibling::*]",
    ctxt);

The only changes are the prefacing of the method with your namespace prefix, and the addition of the CustomContext object to the SelectNodes call.

No Comments

ListControl/Tab Pages and data binding

I’ve been helping a user on codeproject.com to try and get my autocomplete combo box code running in tab pages for him (using data binding).

He was setting SelectedIndex = -1 (to flag the fields as unmodified) on both controls in his form’s OnLoad. We were noticing that the first tab page worked fine, however, when you place the control on the second tab page, it would reset SelectedIndex to 0.

According to this article at MSDN, this is expected behaviour, as the TabControl fires ListControl.OnBindingContextChanged when the tab page is switched.

Using .NET Reflector, I examined what happens in that method and realized that the data connection gets reset.

Fixing this problem was as simple as overriding OnBindingContextChanged to do one of the following two things:

class TabPageComboBox : MattBerther.Controls.AutoCompleteComboBox
{
    protected override void OnBindingContextChanged(EventArgs e)
    {
        // Do nothing
    }
}

or

class TabPageComboBox : MattBerther.Controls.AutoCompleteComboBox
{
    protected override void OnBindingContextChanged(EventArgs e)
    {
        if (this.SelectedIndex != -1)
        {
            base.OnBindingContextChanged(e);
        }
    }
}

Hopefully this solution can help someone else out, as Im now sure that this was the problem that I had been fighting for quite some time when I finally decided to bag data binding.

2 Comments

Big changes coming for MovablePoster, cont’d

Well, I guess I spoke too soon.

Seems like something came up with what I had planned, which makes it virtually unusable at this point. I will be looking at ways around this and providing these changes as soon as I can.

Thanks for your patience.

11 Comments
« Previous Entries
flag
Favorite Charity
wounded warrior project
Search
Social
  • mattberther on twitter
  • mattberther on linkedin
Syndication
Archives
  • January 2010
  • September 2009
  • July 2009
  • June 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • September 2008
  • August 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007
  • February 2007
  • January 2007
  • December 2006
  • November 2006
  • October 2006
  • September 2006
  • August 2006
  • July 2006
  • June 2006
  • May 2006
  • April 2006
  • March 2006
  • February 2006
  • January 2006
  • December 2005
  • November 2005
  • October 2005
  • September 2005
  • August 2005
  • July 2005
  • June 2005
  • May 2005
  • April 2005
  • March 2005
  • February 2005
  • January 2005
  • December 2004
  • November 2004
  • October 2004
  • September 2004
  • August 2004
  • July 2004
  • June 2004
  • May 2004
  • April 2004
  • March 2004
  • February 2004
  • January 2004
  • December 2003
  • November 2003
  • October 2003
  • September 2003
  • August 2003
  • July 2003
  • June 2003
  • May 2003
  • April 2003
  • March 2003
mattberther.com © 2003 - 2010