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 :
- <xsl:for-each select=”/client:process/client:result”> ——> for $result in element(client:process/client:result)
- <xsl:value-of select=”/client:process/client:result” /> ——> data(/client:process/client:result)
- <xsl:if test=”/client:process/client:result gt; 10″ /> ——> where data(/client:process/client:result) gt 10
- All XPaths including predicates are directly mapped