Welcome to MSDN Blogs Sign in | Join | Help

Marcelo's WebLog

Improving the world one entity at a time
Windows 7 - 7 Second Demos

Very, very cute of showing off some new Windows love - it even fits my attention span.

http://www.microsoft.com/en/us/default.aspx

Don't know if this will still be around a few months from now, so for future reference, these are "7 second demos".

MSXML4 SP3, now with a CAB

Yep, the redistributable CAB for MSXML4 SP3 is now available for download. Now you can deploy the latest / greatest version MSXML4 along with your app.

http://www.microsoft.com/DOWNLOADS/details.aspx?familyid=7F6C0CB4-7A5E-4790-A7CF-9E139E6819C0&displaylang=en

Remember, of course, that MSXML4 has been superseded by MSXML6, so you're better off upgrading; but if you can't because for example you don't own the component that has the dependency, the latest service pack contains the latest fixes.

Enjoy!

ADO.NET Data Services - CTP and more

In case you haven't seen this yet, the CTP release has been announced at http://blogs.msdn.com/astoriateam/archive/2009/08/31/ado-net-data-services-v1-5-ctp2-now-available-for-download.aspx.

Following the philosophy that folks like tables, here you go.

Feature Available in CTP1? New in CTP2
Projections No Yes!
Data Binding Yes API cleanup for types
Row Count Yes Bug fixes
Feed Customization Yes Renamed attributes and more flexibility
Server Driven Paging Yes Client library support
Enhanced BLOB support Yes Client library support
Request Pipeline No Yes!
New Provider Interface Yes API refactoring

You probably want to keep checking the blog, as there are some posts coming that will dive deeper into some of the new features.

Enjoy!

Problems when installing SQL Server 2005 on an upgraded Windows XP SP3 with MSXML6 SP2

As mentioned in the SQL Server Support Blog, you may find an issue installing SQL Server 2005 if you install MSXML Core Services 6.0 Service Pack 2 on Windows XP SP2, then upgrade to Windows XP SP3, then try the SQL install.

Check out that post for more details, along with the KB for the problem.

ADO.NET Data Services and PHP

Data, data, data everywhere... Go ahead and click - code samples ahead.

http://blogs.msdn.com/interoperability/archive/2009/08/21/a-new-bridge-for-php-developers-to-net-through-rest-php-toolkit-for-ado-net-data-services.aspx

Enjoy!

ADO.NET Data Services Cheat Sheet

Just run into this today - very nifty cheat sheet for ADO.NET Data Services.

http://www.sadev.co.za/files/Posters/ADO.NET%20Data%20Services%20Cheat%20Sheet.pdf

 

XSLT Timer Released on Code Gallery

Over this past weekend, the XSLT Timer tool has been released on Code Gallery.

This is a very simple tool, that will simply allow you to type / paste in a document and an XSLT stylesheet, and then tell you how long it takes on average to do the transform using the XslCompiledTransform class. Very simple, but handy when trying ad hoc variations on ideas and such.

You might want to look at the XML Resources page for links to other tools as well.

Enjoy!

update #1 - adding an actual link to the tool helps :)

History of Microsoft

There's a fascinating look at Microsoft's history, year-by-year, on Channel 9. I hadn't looked at these before, but they're relatively short so you can view them whenver you have a break and come back later.

Looking forward to more of these.

Enjoy!

Performance Tools

I've written about performance tools in the past - it's a topic that interests me quite a bit, because I believe that perceived performance is a very fundamental part of the user experience and can wow you or frustrate you immensely. And I believe "real performance" (so to speak) is very important of course, especially when you don't have a person sitting in front of the computer, but I think every developer will appreciate the difference that a 2' checkin script has vs. a 20' checkin script or a 60' script. 'Nuff said.

In any case, this post about Visual Studio 2010 profiler tools shows some fabulously productive stuff. And all with Visual Studio usability, rather than what it feels like to use some of the more arcane tools (that are admittedly very well suited to automated scenarios, we'll always grant them that).

Anyway, read up and enjoy!

Group slicing in XSLT with parameters

One other twist on the last slicing stylesheet. Let's say that we didn't want to hard-code the number of items in a group, but instead we wanted to be able to control this separately. We can use an xsl:param on the stylesheet to control this externally and provide a default as well.

Here is the touched up stylesheet, with the changes highlighted.

<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
 <xsl:output method='xml' indent='yes'/>
 <xsl:param name='itemcount'>2</xsl:param>

 <!-- Just copy everything. -->
 <xsl:template match='@* | node()' mode='everything'>
  <xsl:copy>
   <xsl:apply-templates select='@* | node()' mode='everything'/>
  </xsl:copy>
 </xsl:template>

 <!-- Copy everything but replace items with the replacement parameter. -->
 <xsl:template match='@* | node()' mode='withreplacement'>
  <xsl:param name='replacement' />
  <xsl:copy>
   <!-- Copy everything except item elements. -->
   <xsl:apply-templates select='@* | node()[local-name() != "item"]' mode='withreplacement'>
    <xsl:with-param name='replacement' select='$replacement' />
   </xsl:apply-templates>

   <!-- If this is where items are, apply the replacement node-set. -->
   <xsl:if test='item'>
    <xsl:apply-templates select='$replacement' mode='everything' />
   </xsl:if>
  </xsl:copy>
 </xsl:template>

 <!--
 We matched the first of a slice of items.
 Copy everything from the root, passing the current item
 and its sibling(s) as the replacement.
 -->
 <xsl:template match='item' mode='firstofslice'>
  <xsl:apply-templates select='/group' mode='withreplacement'>
   <xsl:with-param
    name='replacement'
    select='. | following-sibling::item[position() &lt; $itemcount]'
    />
  </xsl:apply-templates>
 </xsl:template>

 <!-- Match to root, and put everything under a single element. -->
 <xsl:template match='/'>
  <root>
   <!-- Grab every second item to create a new group. -->
   <xsl:apply-templates select='group/item[position() mod $itemcount = 1]' mode='firstofslice' />
  </root>
 </xsl:template>
</xsl:stylesheet>

By the way, if you haven't already, check out the comments on the first post for a more efficient variation of the stylesheet.

Enjoy!

StackPanel, DockPanel and scrolling items

I spent a little bit of time with this the other day, and I thought I'd pass the learnings on, in hopes it helps someone.

This is the layout what I was trying to accomplish with WPF. In a section of my window, I wanted a bit of text at the top, and then the rest filled with items. The items in this case were bits of XML with an item template that created a nice representation, but for this post we'll just use buttons, which have the same effect.

My initial XAML looked like this. You can try pasting these into XAMLPad to follow along (and add more buttons or resize the window so all buttons won't fit in the view).

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<StackPanel>
 <ItemsControl>
  <Button>Button</Button>
  <Button>Button</Button>
  <Button>Button</Button>
  <!-- ... -->
 </ItemsControl>
</StackPanel>
</Grid>

This is all well and good, but some of the Buttons are just clipped from the window and you can't get to them. This is because the ItemsControl doesn't have the built-in ability to scroll its contents, so I decided to go ahead an add a wrapping ScrollViewer.

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<StackPanel>
 <ScrollViewer>
  <ItemsControl>
   <Button>Button</Button>
   <Button>Button</Button>
   <Button>Button</Button>
   <!-- ... -->
  </ItemsControl>
 </ScrollViewer>
</StackPanel>
</Grid>

This produces a very confusing situation, in which the scroll viewer is present, but the scroll bar is disabled and goes off the window.

After looking at this for a while, I realized that the problem is that the StackPanel doesn't constrain the size of its children. So if the scroll viewer wants to be huge so it doesn't have to, the StackPanel will arrange it so, even if it clips.

The solution then was to switch to something that did constrain its children. In particular, a DockPanel is great, as it will size the last child to occupy all remaining space.

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<DockPanel>
 <ScrollViewer>
  <ItemsControl>
  <Button>Button</Button>
  <Button>Button</Button>
  <Button>Button</Button>
  <!-- ... -->
  </ItemsControl>
 </ScrollViewer>
</DockPanel>
</Grid>

Now I have a scroll viewer with an enabled scroll bar, which allows me to get to all the buttons.

Enjoy!

Aaron Dunnington on Velocity

Aaron published an MSDN article on using Velocity that is very much worth checking out.

Some of the highlights:

  • Why and how to scale your applications.
  • Deployment and configuration of Velocity.
  • Data analysis and cache design.
  • ASP.NET Session integration.

One of the things I remember from DevConnections is how ridiculously popular it is to use this from ASP.NET, and how easy it is to improve the performance of your ASP.NET applications with the integrated support.

Enjoy!

XmlLite says: error C2146: syntax error : missing ';' before identifier 'IXmlReader'

This is something that I've been asked more than once, and so here goes an answer that might help if you run into this.

Let's say that you create a new project and borrow code or do something of the sort, and suddenly start getting an error message such as this one

xmllite.h(49) : error C2146: syntax error : missing ';' before identifier 'IXmlReader'

This typically points to a missing macro. You can fix this by adding this to your include headers:

#include "objbase.h"

If you're using Visual C++-style projects, this may already be included via stdafx.h including the Windows headers for you.

 

More group slicing in XSLT

To continue on my previous example on slicing (I made the term up, by the way), today we'll do something a little different.

Let's say that instead of just inserting the slice elements and a few items, we want to copy the whole tree n times (where n is the number of slices), each time with a different slice of items. That includes elements beyond the things we're currently slicing.

So let's say we have this document, similar to the previous one.

<group groupattribute='1'>
  <repeat-me>each time</repeat-me>
  <item item='1'>1 <sub>text</sub> </item>
  <item item='2'>2 <sub>text</sub> </item>
  <item item='3'>3 <sub>text</sub> </item>
  <item item='4'>4 <sub>text</sub> </item>
  <item item='5'>5 <sub>text</sub> </item>
</group>

And we want to get this effect.

<root>
  <group groupattribute="1">
    <repeat-me>each time</repeat-me>
    <item item="1">1 <sub>text</sub></item>
    <item item="2">2 <sub>text</sub></item>
  </group>
  <group groupattribute="1">
    <repeat-me>each time</repeat-me>
    <item item="3">3 <sub>text</sub></item>
    <item item="4">4 <sub>text</sub></item>
  </group>
  <group groupattribute="1">
    <repeat-me>each time</repeat-me>
    <item item="5">5 <sub>text</sub></item>
  </group>
</root>

Here is a stylesheet that can accomplish this, using parameters to pass around the replacements nodes for each copy of the tree. As always, variations in the comments are welcome.

<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
 <xsl:output method='xml' indent='yes'/>

 <!-- Just copy everything. -->
 <xsl:template match='@* | node()' mode='everything'>
  <xsl:copy>
   <xsl:apply-templates select='@* | node()' mode='everything'/>
  </xsl:copy>
 </xsl:template>

 <!-- Copy everything but replace items with the replacement parameter. -->
 <xsl:template match='@* | node()' mode='withreplacement'>
  <xsl:param name='replacement' />
  <xsl:copy>
   <!-- Copy everything except item elements. -->
   <xsl:apply-templates select='@* | node()[local-name() != "item"]' mode='withreplacement'>
    <xsl:with-param name='replacement' select='$replacement' />
   </xsl:apply-templates>

   <!-- If this is where items are, apply the replacement node-set. -->
   <xsl:if test='item'>
    <xsl:apply-templates select='$replacement' mode='everything' />
   </xsl:if>
  </xsl:copy>
 </xsl:template>

 <!--
 We matched the first of a slice of items.
 Copy everything from the root, passing the current item
 and its sibling(s) as the replacement.
 -->
 <xsl:template match='item' mode='firstofslice'>
  <xsl:apply-templates select='/group' mode='withreplacement'>
   <xsl:with-param
    name='replacement'
    select='. | following-sibling::item[1]'
    />
  </xsl:apply-templates>
 </xsl:template>

 <!-- Match to root, and put everything under a single element. -->
 <xsl:template match='/'>
  <root>
   <!-- Grab every second item to create a new group. -->
   <xsl:apply-templates select='group/item[position() mod 2 = 1]' mode='firstofslice' />
  </root>
 </xsl:template>
</xsl:stylesheet>

Enjoy!

LINQ to XSD on CodePlex

I'm very, very pleased about today's announcement on LINQ to XSD being available on CodePlex.

The functionality available should be esentially the same as what was released in the last Alpha Preview, so if you were already using this, it should be a smooth transition.

The community of developers interested in LINQ to XSD will now be able to include this in their applications, as it's being released under the Ms-PL license.

Enjoy!

More Posts Next page »
Page view tracker