July 2003 Archives

Tempting things

| No Comments | No TrackBacks |
I've got an invitation from Mono guys to consider contributing to Mono Managed XSLT Processor implemenation (now they have only a wrapper around libxslt engine). Well, we at Multiconn have designed and built one XSLT processor couple of years ago (it's quite specialized and highly (may be even too) optimized XSLT 1.0 engine for mainframe OLTP environment, written in ANSI C). It was great opportunity to learn XPath and XSLT thoroughly from cover to cover and it was actually cool (apart from programming in ANSI C nowadays). I definitely have some ideas about XSLT implementation, especially if you have C#, .NET plumbing available and considering rumors around next Microsoft .NET XSLT impl :). So it's really awfully tempting.
But it's quite big open source project and I'm too busy unfortunately... I have long TODO list of not-less-interesing (but smaller) projects, I've started another article, I'm in MCAD cert preparation curve after all. And day work of course - we've just finished one trivial Web Service project, but another BizTalk-related one is on the horizon already. So I'm not sure...

Real Bloggers

| No TrackBacks

Outlook and news://

| 4 Comments | No TrackBacks |
Isn't it strange that Microsoft Outlook doesn't support reading newsgroups? Almost decided to move from Mozilla to Outlook 2003 today, but at the very last moment realized I have also to use Outlook Express for reading beloved newsgroups. That's really disappointing to use 2 apps instead of 1... so I'm still on Mozilla.

New horizons

| No Comments | No TrackBacks |
VSIP is free now. Terrific news!

Log file in XML format?

| 6 Comments | 7 TrackBacks |
One more logger with clunky text-based log file format and appropriate plumbing (object model, writer, parser and viewer) were written by me this week. Format was defined by customer and it was non disputable unfortunately. As for me it's just ugly. Why not use XML as log format?
Pros: trivial writing/parsing, portability, readability, simplicity. Constras: everybody seems to think it's unfeasible due to XML well-formedness and hence root element end tag problem - to append records you need to seek an appropriate place hence to parse the whole XML document. That's true for XML documents, but what about XML fragment?

XML fragment is actually external general parsed entity in XML 1.0 specification terms - it's freestanding fragment of XML, which can be incorporated into an XML document by entity reference, but it's still useful on its own - one can append elements to it (and because it's not XML document, root-level well-formedness rules don't apply to it, so one can just append elements to the end of file, without necessity to parse the whole log file) and then read such log file by XmlTextReader, which [thankfully to .NET developers] supports XML fragments (see "Reading XML Fragments with the XmlTextReader").

So here is small proof-of-concept example:

Writing to log:

class Test {
  static void Main(string[] args) {
    using (FileStream fs = File.Open("log.xml", 
        FileMode.Append, FileAccess.Write, FileShare.Read)) {
        XmlTextWriter writer = new XmlTextWriter(fs, Encoding.ASCII);
        for (int i=0; i<3; i++) {
          writer.WriteElementString("item", "", 
            DateTime.Now.ToString());
          writer.WriteWhitespace("\n");
        }
        writer.Close();
    }
  }
}
First run creates log.xml:
<item>7/22/2003 11:15:42 AM</item>
<item>7/22/2003 11:15:42 AM</item>
<item>7/22/2003 11:15:42 AM</item>
Second run appends three more items:
<item>7/22/2003 11:15:42 AM</item>
<item>7/22/2003 11:15:42 AM</item>
<item>7/22/2003 11:15:42 AM</item>
<item>7/22/2003 11:16:12 AM</item>
<item>7/22/2003 11:16:12 AM</item>
<item>7/22/2003 11:16:12 AM</item>
Reading log:
class Test {
  static void Main(string[] args) {
    using (FileStream fs = File.OpenRead("log.xml")) {
      XmlParserContext context = new XmlParserContext(
        new NameTable(), null, null, XmlSpace.Default);
      XmlTextReader reader = new XmlTextReader(fs, 
        XmlNodeType.Element, context);
      while (reader.Read()) {
        if (reader.NodeType == XmlNodeType.Element) {
          Console.WriteLine("Element: {0}, Value: {1}", 
            reader.Name, reader.ReadElementString());
        }
      }
    }
  }
}
And result is:
D:\projects\Test2\bin\Debug>Test2.exe
Element: item, Value: 7/22/2003 11:15:42 AM
Element: item, Value: 7/22/2003 11:15:42 AM
Element: item, Value: 7/22/2003 11:15:42 AM
Element: item, Value: 7/22/2003 11:16:12 AM
Element: item, Value: 7/22/2003 11:16:12 AM
Element: item, Value: 7/22/2003 11:16:12 AM 
I like it. Comments?
Doing web page design on your own can be as successful as your web site design coming from a professional web designer but you'll want to make sure that your web site design is user-friendly and clean before worrying about bells and whistles.

I'm in

| No Comments | No TrackBacks
A week with no internet connection at work - what could be more terrible? Finally it's over.