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:

  • Roy
    17 Nov 2008
    10:16

    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

RSS feed for comments on this entryAdd your comments



(Personal blogs only please: leave blank if you don't have one)

Your comments:

-) razz mad lol cool ??? shock sad smile

Maximum 2 links per comment. Do not use BBCode.