FW: SPARQL XML to HTML XSL Performance Bug

[forwarded as per message request]

-----Original Message-----
From: jena-dev@yahoogroups.com [mailto:jena-dev@yahoogroups.com] On Behalf Of stephen.allen@ymail.com
Sent: 02 April 2009 20:55
To: jena-dev@yahoogroups.com
Subject: [jena-dev] SPARQL XML to HTML XSL Performance Bug (Joseki)

Hi,

I've discovered a performance bug in the xml-to-html.xsl stylesheet in Joseki.  This XSL is used to transform SPARQL result queries into XHTML for display in a browser.  The bug does not have much affect on small result sets (10's of results), but has a pretty significant effect for larger result sets (1000's of results).

The bug occurs when the XSL is iterating over the bindings in each <result> tag.  The variables are selected using the xpath expression "//res:head/res:variable", which forces a search over all of the nodes in the document to find a match for "res:head/res:variable".  This is quite slow as it scales with the size of the document.

Since the SPARQL XML result format specifies that the "res:head" elements is on the "res:sparql" element which is directly on the root, we can replace the previous xpath expression with "/res:sparql/res:head/res:variable" and gain a significant speed increase (no need to search the entire document).

Just as a single data point, I am seeing the rendering time in Firefox for a modest 3,000 entity result set drop from 40 seconds to 5 seconds with the fix.

I've attached a patch for this bug in Joseki, however this bug seems to be pretty wide-spread, and I've seen it in all versions of this XSL, including the one in the "W3C SPARQL Query Results XML Format" Recommendation [4].  Does anyone on this list know who to contact about this?  or can forward the patch on the the appropriate person?

Here is a non-exhaustive list of some of the locations I've identified this bug [1], [2], [3], [4].


Best Regards,

Stephen Allen
BBN Technologies


[1] http://joseki.cvs.sourceforge.net/viewvc/joseki/Joseki3/ResultSet/xml-to-html.xsl

[2] http://joseki.cvs.sourceforge.net/viewvc/joseki/Joseki3/ResultSet/result2-to-html.xsl

[3] http://www.sparql.org/xml-to-html.xsl

[4] http://www.w3.org/TR/rdf-sparql-XMLres/result-to-html.xsl



Patch Follows:


--- C:\Temp\tmp\Joseki3\ResultSet\xml-to-html.xsl.orig 2006-02-24 06:10:35.000000000 -0400
+++ C:\Temp\tmp\Joseki3\ResultSet\xml-to-html.xsl 2009-04-02 15:48:06.000000000 -0400
@@ -91,13 +91,13 @@
       </table>
     </div>
   </xsl:template>
 
   <xsl:template match="res:result">
     <xsl:variable name="current" select="."/>
-    <xsl:for-each select="//res:head/res:variable">
+    <xsl:for-each select="/res:sparql/res:head/res:variable">
       <xsl:variable name="name" select="@name"/>
       <td>
  <xsl:choose>
    <xsl:when test="$current/res:binding[@name=$name]">
      <!-- apply template for the correct value type (bnode, uri, literal) -->
      <xsl:apply-templates select="$current/res:binding[@name=$name]"/>






------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/jena-dev/


<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/jena-dev/join

    (Yahoo! ID required)

<*> To change settings via email:
    mailto:jena-dev-digest@yahoogroups.com 
    mailto:jena-dev-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    jena-dev-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Received on Sunday, 12 April 2009 19:43:15 UTC