james mckay dot net

because there are few things that are less logical than business logic
17
Nov

An XSLT sweetener

If you’ve ever done anything with XSLT, you’ll no doubt be wondering why anyone would want to use such a verbose programming language, given that you need to churn out code such as this all over the place:

<xsl:element name="foo">
  <xsl:attribute name="bar">
    <xsl:value-of select="/some/xpath/@expression" />
  </xsl:attribute>
</xsl:element>

However, did you know that you can do this instead? Much cleaner and easier to read:

<foo bar="{/some/xpath/@expression}" />

(Hat tip: Ned Batchelder)

1 comment:

  • Yes I done that quite often and yes It´s so much easier and make so much more sens when working inside tags in XSLT

    # » Reply from Roy at 10:16 on 17 Nov 2008

Comments on this entry are now closed.