XQuery and XSLT Maps

XSLT used to be everywhere prior to OSB. Now, everyone wants to us XQuery over XSLT for various reasons ranging from the highly controversial better performance and better Code Maintainability. Personally, I feel that XQuery is more procedure driven i.e. you-tell-what-you-want-to-do and hence easier and quicker to script than XSLT which is intuitive and more like a Pattern Driven language.

Anyways, the scope of this article is to show some small syntactical differences between XSLT and XQuery. Not an exhaustive list by any means, but the following are the most common :

  1. <xsl:for-each select=”/client:process/client:result”>      ——> for $result in element(client:process/client:result)
  2. <xsl:value-of select=”/client:process/client:result” />  ——> data(/client:process/client:result)
  3. <xsl:if test=”/client:process/client:result gt; 10″ />    ——> where data(/client:process/client:result) gt 10
  4. All XPaths including predicates are directly mapped

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: