Monday, July 15, 2013

Comparison of XSLT and XQuery

Recently I am working on one project which gets involved in transforming a large XML document in Oracle SOA Suite 11g.  Initially this transformation is done using XSLT.   We did the end-to-end testing with a large payload and noticed that the XSLT transformation took the most of the message processing time.  Later someone suggests that with large payload XQuery is more efficient than XSLT.   So we decided to implement the same transformation using XQuery.   The comparison result is a bit surprise to me.  
 <ein:InvoiceDescription>LYRECO JUN 2013</ein:InvoiceDescription>
 <ein:SupplierName>LYRECO PTY LTD</ein:SupplierName>
  <ein:Description>Some description text</ein:Description>
  <ein:ExpenditureType>Office Supplies</ein:ExpenditureType>

Firstly I tried the transformation of a XML message like the above but with over 2700 <POInvoiceItems> elements using XMLSpy.  The result shows XQuery is much faster than XSLT when transforming this message.   Roughly XQuery is 3~4 times faster. 

Then I put these two transformations into one Oracle SOA application respectively and invoke the application with the same large message payload.   The comparison show that under Oracle Weblogic environment there is no obvious difference between XQuery and XSLT and XSLT is even faster than XQuery.   I am not quite sure what cause the different results using XMLSpy and Oracle Weblogic.  Maybe it is related to the implementation of XQuery and XSLT enegines within XMLSpy and Oracle Weblogic.


  1. Interesting finding, did you tested for some other scenarios to suggest that both are same ?

  2. Wow, i read this article and thought this cannot be the case every expert and blog has said xquery is faster and took their word for it, and this might be the case outside of Oracle Middleware, so we did a POC with a 15000 line xml, and ran through xquery and xslt and could not believe that in Oracle SOA 12c (OSB) that XSLT was faster than xquery doing the same transformation, around 25% quicker with a 15000 line xml, however when we did a 20 line xml we found that XSLT was more than 100% quicker. Amazing. Thanks for the post.

  3. You can find some additional analysis that i did here: