XSL(like) declarative language as MVC view over strongtyped model?

Posted by Martin Kool on Stack Overflow See other posts from Stack Overflow or by Martin Kool
Published on 2008-11-19T08:32:45Z Indexed on 2010/05/08 19:18 UTC
Read the original article Hit count: 179

Filed under:
|
|
|
|

As a huge XSL fan, I am very happy to use xsl as the view in our proprietary MVC framework on ASP.NET. Objects in the model are serialized under the hood using .NET's xml serializer, and we use quite atomic xsl templates to declare how each object or property should transform.

For example:

  <xsl:template match="/Article">
    <html>
      <body>
        <div class="article">
          <xsl:apply-templates />
        </div>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="Article/Title">
    <h1>
      <xsl:apply-templates />
    </h1>
  </xsl:template>

  <xsl:template match="@*|text()">
    <xsl:copy />
  </xsl:template>

This mechanism allows us to quickly override default matching templates, like having a template matching on the last item in a list, or the selected one, etc. Also, xsl extension objects in .NET allow us just the bit of extra grip that we need. Common shared templates can be split up and included.

However

Even though I can ignore the verbosity downside of xsl (because Visual Studio schema intellisense + snippets really is slick, praise to the VS-team), the downside of not having intellisense over strongtyped objects in the model is really something that's bugging me.

I've seen ASP.NET MVC + user controls in action and really starting to love it, but I wonder;

Is there a way of getting some sort of intellisense over XML that we're iterating over, or do you know of a language that offers the freedom and declarativeness of XSL but has the strongtype/intellisense benefits of say webforms/usercontrols/asp.net.mvc-view?

(I probably know the answer: "no", and I'll find myself using Phil Haack's utterly cool mvc shizzle soon...)

© Stack Overflow or respective owner

Related posts about xsl

Related posts about xslt