July 26, 2006

Anton Lapounov is blogging

Anton Lapounov is blogging! He's one of the brilliant guys responsible for XSLT in the Microsoft XML Team. If you are subscribed to my blog, you want to subscibe to "Anton Lapounov: XML XSLT and Beyond" blog too.

July 24, 2006

Summer colors

© Alenka Tkachenko

July 20, 2006

XPathMania - free Visual Studio add-in for XPath Development

Just in case if somebody have missed this cool new tool - check out DonXML's into into XPathmania. It's free open-source Visual Studio add-in for XPath development. I just can't live without it already. Very cool stuff, part of our Mvp.Xml project.

July 14, 2006

MSXML 6.0 SDK finally released

Microsoft finally released MSXML6 (aka Microsoft Core XML Services) SDK. I've been told it was expected back in December. Anyway, it's ready. Now it would be nice if Microsoft updated MSXSL utility to support MSXML6 (I know it was also ready back in December too).

Poor little Lebanon

I've been reading some Lebanese blogs trying to understand what people from the other side of the bleeding border think. And I realized how weird country Lebanon is. Where in the world a government would strongly refuse to control a half of its own country? It's like the whole world is asking the Lebanese government - come on, you guys are the Lebanon government, please, please, take control over south Lebanon, that's your land. No, no, no, never ever said the freaking government - there is a bunch of bad guys over there, terrorists you know they can bite so we better don't. Oooooookay. Now they badly surprised it hurts to host bad guys, hmmm.

Yes, I found out that almost every single Lebanese blog I spotted says something like "That f#cking Hezbollah terrorists! That's all their fault! Hezbollah != Lebanon, we have nothing to do with this war, we are just suffering here". That even made sense for a moment, but then - who are those bad Hezbollah guys? As it turned out they are not martians not even iranians, but ordinar lebanese people, moreover Hezbollah (being widely recognized as a terrorists group) is representing the largest Lebanon's religious group, it's a recognized political party holding 23 seats in the 128-member Lebanese Parliament and participating in Lebanese government. So, again - "Hezbollah != Lebanon"? Oh come on, that's ridiculous. Hezbollah == Lebanon, face it.

I think in fact there is no one single country of Lebanon. I have no idea how such different groups can live in the same state. Those normal lebanese people whose blogs I read - you should do something about this, guys. Otherwise don't be surprised to be paying painfully for what your evil brothers do.

July 11, 2006

How to validate XSLT output in .NET 2.0

How would you validate XSLT output on the fly without caching transformation result as a whole? That's easy - just use MvpXslTransform class that adds to the XslCompiledTransform class ability to transform into XmlReader and wrap that reader witth a validating reader. As a result - streaming validation, no memory hogging and ability to abort transformation at first validation error. Simple sample below.

XPathDocument doc = 
    new XPathDocument("source.xml");
MvpXslTransform xslt = new MvpXslTransform();
xslt.Load("XSLTFile1.xslt");
XmlReader resultReader = 
    xslt.Transform(new XmlInput(doc), null);
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.Schemas.Add("", "orders.xsd");
XmlReader validatingReader = 
    XmlReader.Create(resultReader, settings);
XmlWriter w = XmlWriter.Create(Console.Out);
w.WriteNode(validatingReader, false);
w.Close();

You can get MvpXslTransform class with Mvp.Xml library v2.0 at the Mvp.Xml project site.

July 5, 2006

Adding scrolling to the ScriptAculoUs autocomplete web control

ScriptAculoUs autocomplete web control from SimoneB is a nice lightweight easy to use ASP.NET autocomplete textbox control with many virtues. The only problem I had with it was that dropdown autocomplete list has no scrolling and so long autocomplete lists look ugly. Happily it comes with sources so I hacked it to add scrolling, here is the solution in case somebody needs it.

  1. In Suggestion.cs add a CSS class to the UL tag generated for an autocomplete list:
    StringBuilder returnValue = new StringBuilder("<ul class=\"autocomplete\">");
  2. In a stylesheet constrain autocomplete list height and enable scrolling on overflow:
    UL.autocomplete 
    {
        height: 10em;
        overflow:auto;
    }
    
  3. In controls.js, modify "render" function to make autocomplete list automatically scrolling so a selected item is always visible:
      render: function() {
        if(this.entryCount > 0) {
          for (var i = 0; i < this.entryCount; i++) {
            this.index==i ? 
              Element.addClassName(this.getEntry(i),"selected") : 
              Element.removeClassName(this.getEntry(i),"selected");        
            if (this.index == i) {
              var element = this.getEntry(i);
              element.scrollIntoView(false);
            }
          }        
          if(this.hasFocus) { 
            this.show();
            this.active = true;
          }
        } else {
          this.active = false;
          this.hide();
        }
      },
    
That does it. Works fine in both IE and FF.