XML

Custom implementation of the Metaweblog API and Windows Live Writer

This blog has been powered by my own custom implementation of the Metaweblog API , because I wanted to test Windows Live Writer. As I posted before the current implementation of the Metaweblog API by WLW is not correct in the beta. According to the WLW newsgroup, on this issue, the team are taking a second look at the Metaweblog specifications. Funny thing is that WLW does not even follow the specifications found at MSDN.

.NET

How to sort XML without XSL in the .NET Framework

I have several times needed a way to sort XML, retrieved from a file or a web service, inline without invoking XSL transformations, which is the most common way to do it as I have seen. The .NET Framework contains the System.Xml.XPath namespace and is available from the .NET Framework 1.1 and up. This namespace contains a number of classes which can improve the performance of your .NET classes when working with XML. Specifically the System.Xml.XPath.XPathExpression contains a method (System.Xml.XPath.XPathExpression.AddSort) to sort the XPath query results.

.NET

Smooth upgrade of .NET XSL transformations from 1.1 to 2.0 or higher

When .NET 2.0 was introduced, quite a long time ago, the whole System.Xml namespace was re-written, due to the poor performance of the System.Xml implementation. Despite the fact that the CLR 2.0 has been around for a few years there are still implementations using CLR 1.x and especially the XSL transformation bits, since that part is completely re-written and marked as obsolete. But note that they are only being marked as obsolete! You can still compile and run most of the code with just a compiler warning. The old .NET 1.1 classes are still in the CLR 2.0, so you can convert your XSL transformations piece by piece and start using .NET 2.0 or even .NET 3.5 since it is based on .CLR 2.0 (read this post by Scott Hanselman to get a better understanding).

.NET

Architecture Journal Reader - a great WPF demo

Microsoft has released a new Windows Presentation Foundation demo sample that is a reader application for The Architecture Journal. The Architecture Journal is a quarterly online magazine focused on IT-architecture and contains nice articles and gives you some good reading. It is available online and as PDF (why not XPS?). The Architecture Journal Reader is a WPF sample, very much like the New York Times Reader that was one of the first killer-apps for WPF, that you can use for offline reading of The Architecture Journal.

.NET

Open Xml SDK CTP available now

Microsoft has released a CTP for Microsoft SDK for Open XML Formats, which can be downloaded here. The SDK contains a strongly typed library, built on top of System.IO.Packaging namespace, for creating documents based on the Open XML Format. Great, now we don’t have to use the System.Xml.XmlWriter to create Office 2007 documents. Here is a sample on how to write out the number of characters in a Word 2007 document: XmlDocument extendedProperties = new XmlDocument(); using (WordprocessingDocument wordDocument = WordprocessingDocument.Open("document.docx", false)) { ExtendedFilePropertiesPart part = wordDocument.ExtendedFilePropertiesPart; extendedProperties.Load(part.GetStream()); } XmlNodeList characters = extendedProperties.GetElementsByTagName("Characters"); Console.WriteLine(characters.Item(0).InnerText); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; overflow-x:visible;border:0px} .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

.NET

Dissecting XPS, part 6 - reading XPS files programatically

The sixth part of the Dissecting XPS series is here and this time we will, finally, look at some code for reading XML Paper Specification [1], XPS, files. I will in the following sample not use the Microsoft.NET 3.0 Framework, which has built-in functionality for reading and writing XPS files [2]. Instead I will do it using .NET 2.0 (you can try it in .NET 1.1 if you like) and an excellent ZIP library called #ziplib [3]. This will show you more of what’s really happening and it will show you how to integrate XPS into applications built using other .NET Frameworks than 3.0 or in Mono or in what ever you like. For instance, you can use Java and the Java Zip packages.

XML

Dissecting XPS, part 5 - Document properties

This is the fith part of the Dissecting XPS series and will focus on the Xml Paper Specification, XPS, document properties. Core Properties The properties used in an XPS document are stored in the Core Properties Part, specified in the Open Packaging Conventions, OPC [1]. The Part is located by reading the [Content_Types].xml file and finding the content type application/vnd.openxmlformats-package.core-properties+xml. A document should have one Core Properties part, so there is no requirement to have one but having serveral indicates an invalid package. But there should be no reason to leave out the part. There are also no requirements on which elements that should be present in the part.

XML

Dissecting XPS, part 4 - the content markup

This part in the Dissecting XPS series will take off were we ended part 3, by looking into how the actual content is marked up. The content is contained in the FixedPage element and it is marked up by three different elements the Path element which specified a geometry filled with a brush the Glyphs element which represents text the Canvas element which groups elements together The Path element The Path element is used to specify a geometry shape and optionally fill it using a brush. This XPS markup code creates the triangle shown on the right.

XML

Dissecting XPS, part 2 - inside the XPS document

This is the second part of the Dissecting XPS series, last post generally described the XML Paper Specification. This post in the series will describe the XPS file format internals. This will give you an overview of how the XPS files are built from ground and up, instead of reading the XPS Specification which covers 453 pages. The XPS file The XPS file, with the .xps extension, is a ZIP file - called the physical Package, and consists of a number of XML and binary files - called Parts. There are also files describing how the files are organized and connected together - called Relationships. 

Microsoft

Dissecting XPS, part 1 - The basics

I will in a number of posts try to explain the XML Paper Specification document format, XPS format, that has been developed by Microsoft. I think the XPS initiative is nice from a developer and ISV perspective, since creating and reading XPS documents is easy and supported from various environments. This series of XPS articles will start off with an introduction to the XML Paper Specification and then continue with general support and competitors and then of course some nice introduction on how to use XPS in applications.

.NET

XSLT 2.0 in Microsoft.NET?

As you probably already have read by now is that the XSLT 2.0 and XPath 2.0 are now W3C Recommendations. XSLT 2.0 is a really nice step forward in the XML transformation technology, a technique that we base our software on to enable us to produce content for different devices, platforms and targets. XPath 2.0 and XSLT 2.0, in specific, could help us making these transformations much easier without having to use XSLT Extension Objects for some tasks. 

XML

Announcing: msfeedicon version 2.0

msfeedicon is now released at version 2.0 and is a major update to the previous versions. msfeedicon is a plugin to the Windows RSS platform and Internet Explorer 7 Feeds and appears as an icon in the Windows XP/Vista system tray and displays when you have unread posts in your subscribed feeds. Whenever there is new posts in a feed msfeedicon will show an alert window with direct access to unread posts. No more need to have the Feeds Favorites Center visible in Internet Explorer nor Internet Explorer open to see when your feeds are updated.

.NET

ASP.NET AJAX 1.0 Released

Finally ASP.NET AJAX 1.0, known as Atlas, is released in a fully supported version. The Download is available at http://ajax.asp.net. Here’s a summary from Scott’s blog: The ASP.NET AJAX 1.0, which is available for free with full Microsoft support, can be extended with the ASP.NET AJAX Control Toolkit - a set of more than 30 controls for ASP.NET. Microsoft also releases the client-side ASP.NET AJAX JavaScript library under the Microsoft Permissive License (Ms-PL) which allows you to modify the library and the server-side code is released under Microsoft Reference License (Ms-RL) so your debugging will be easier.

XML

JSON vs XML - final debate?

We have been doing a lot of work, on our product, with dynamic updates of web pages - you know the AJAX stuff. Most of the server side results are returned as XML and are delivered from different Web Services. Since I really like optimizations and like good and nice looking code I have been going back and forth in decision of how to return data to the client; XML or JSON. JSON are in some cases more effective but when the object model it tries to represent gets more complex you neither get nice looking code nor saves that much bytes.

.NET

Updated: Even better encapsulation of getting a value from XmlNode

I previously suggested a better method for getting attributes for an System.Xml.XmlNode in a response to an post by Marcus. Craig Nicholson highlighted in a comment that the code i provided can be even further optimized. private static string GetAttribute(XmlNode node, string name) { XmlElement elm = node as XmlElement; return (elm == null) ? string.Empty : elm.GetAttribute(name); } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

XML

XSLT 2.0 is now a Proposed Recommendation by W3C

W3C has announced Proposed Recommendations of XSLT 2.0, XPath 2.0 and XML Query 1.0. It has been seven years since XSLT 1.0 was published and I think it is great that XSLT has been updated. Some features that I find interesting in XSLT 2.0 is: xsl:analyze-string This instruction let’s you match a string to a regular expression xsl:output This instruction now has xhtml as a valid output parameter xsl:perform-sort With this you can create sorted sequences

Microsoft

Google, Yahoo and Microsoft teams up on Sitemap protocol

According to CNET News Google, Yahoo and Microsoft teams up on using the Sitemap protocol. The Sitemap protocol is an XML standard for describing the site content and the update frequency to make it easier for search engines to crawl a site. This is great news for all site developers and owners to have their sites crawled correctly. The only problem so far is that you have to submit the Sitemap to each and every crawler that supports the Sitemap protocol.

Microsoft

About Microsoft Open Office Xml document format

The new Office document format present in the new Microsoft Office 2007 suite is completely new and open and based on XML. This opens up a lot of possibilites for us developers; there is now an easy way to create your own Word or Excel documents from an application. The file format used is called Ecma Office Open Xml format. Previously it has been very difficult or expensive to provide the customers with nice Word or Excel output from an application. For example when delivering an Excel sheet from a website it has been done by creating a table in html and then sending it to the browser with the correct content type (application/vnd.ms-excel), the same thing for Word. But when it came to embedding images or attachments or creating advanced layouts (headers or footers) it has been troublesome. It can be done; for example I created a web application that had a Word document as output, nicely formatted using the mht format.

.NET

Preventing comment spam using LinkSleeve

I have a lot of problem with comment spam on the blog as well as spamming on the trackbacks and the problem is spread widely over the blogging world. A lot of you turn off comments or have registration or other methods to get rid of the comment spamming. LinkSleeve (SLV - Spam Link Verification) is a link spam solution that checks a text for well-known URL’s in a text and tells if it contains any known spam addresses. This service is provided via an XML-RPC service without any licensing.

.NET

Even better encapsulation of getting a value from XmlNode

Marcus writes in his blog how he often ends up with a method that reads an attribute from an XmlNode object. He has optimized his method so that the exception handling will be minimal, since that is pretty expensive. This is a pretty common scenario for me and I have an even better solution, that does’nt involve exception handling at all. private static string GetAttribute(XmlNode node, string name) { XmlElement elm = node as XmlElement; if (elm == null) { return ""; } return elm.GetAttribute(name); } This method uses the C# as operator which cast the XmlNode to an XmlElement, if it fails it will return null instead of invoking exception handling.

Microsoft

Microsoft XPS Essentials Pack

To view XPS files, if you do not have Windows Vista or Microsoft.NET Framework 3.0, you can download the Microsoft XML Paper Specification Essentials Pack Version 1.0. The download contains an XPS Reader, very much like the Adobe PDF reader and an XPS Document writer, which allow you to print to XPS files. There are other goodies in this pack such as: an XPS IFilter that will help you index XPS files, with Windows Desktop Search for example Windows shell handlers for thumbnail views in Windows Explorer The pack requires Windows 2000, 2003 or XP with the latest service packs and Microsoft Core XML Services 6.0. It’s still a beta, but worth a shot.

Business

Winternals resurrected in Microsoft Desktop Optimization Pack

The Windows Vista blog announces the Microsoft Desktop Optimization Pack, a desktop solution that will help Windows desktop users tune their applications and operating systems. It will include applications and features that will enhance: desktop deployment application comaptibility diagnostics and repair This pack is a result of Microsoft aquiring a handful of nice companies, such as the great Winternals. You can read all about it at the Desktop Optimization Pack site. When I first read through that page something caught my attention:

XML

Simple List Extensions in my feed

Simple List Extensions (SLE) is a set of extensions to RSS 2.0 and Atom feeds created by Microsoft to make it easier to exposing ordered lists through the feeds. Simple List Extension contains a set of tags that tells the feed readers how to sort or filter the items in the feed. It also contains a tag that instructs the reader to interpret the feed as a list. If the feed is marked as a list the reader should treat the feed as the complete ordered list which means that readers must remove any cached items not present in the feed.

.NET

XML Notepad 2006 - what's the fuzz about?

There seems to be some kind of software release frenzy at Redmond right now. Microsoft are spitting out application after application and I don’t mean the two huge ones; MIcrosoft Windows Vista and Microsoft Office (Server) System. Applications, small and big, like Internet Explorer 7, Windows Live Writer, XNA Game Studios, different Microsoft Live applications, Windows Desktop Search and now XML Notepad 2006 are dropping out from the software factory. It’s fun, but it takes me so much time reading and catching up on the releases.

Microsoft

Microsoft Soccer Scoreboard

Sitting here in the halftime of the Brazil vs Croatia World Cup Soccer game and enjoying a good game. During this FIFA World Cup tournament a must have application is the Microsoft Soccer Scoreboard. It’s a nice little application with direct results, standings and schedule of all games and teams. You can also use the application to be your football news RSS reader and Microsoft provides us with a number of interesting football feeds.

XML

Anatomy of a blog - part II: What is a TrackBack?

This is the second part of my dissection of a blog and I will try to explain what a TrackBack is.TrackBack is a way to communicate between blogs; for example when a blogger writes a post with comments/links to another blog the blogger can inform the blog that is being commented with a TrackBack ping. This ping will normally be fetched by the commented blog and appended as a comment.To get this to work, both the commenting blog and commented blog has to support the TrackBack protocol, see below.

Microsoft

How to read .xps documents

XPS (XML Paper Specification) is an electronic paper format and is competing with Adobes PDF. Since Microsoft is forced to withdraw the function of publishing to PDF from Office 2007 the XPS will be more widely adopted. Read more about it here; Adobe PDF vs Microsoft XPS. Windows Vista will include a XPS reader, but if you already now get XPS files you can download either the WinFX runtime components or the XPS Essentials Pack (beta).

.NET

Anatomy of a blog: What is a ping and how does it work?

During the creation of this site I wanted to know more about how the blog world works behind the scenes. I will make a few articles about my findings in this matter and what I have done to create this blog. The first article will describe on how you inform other sources and parties that your blog is updated. This is done through a Ping. You should ping whenever you have created or updated a post on your feed. Pinging is either done automatically or manually. Manual pinging is done by finding a site with a Ping interface, like http://www.bloglines.com/ping, and then enter the Url to your feed. You can find some more on the Blog Ping List at AYWE