--- saxon.c.orig	2007-10-26 23:00:56.000000000 +0000
+++ saxon.c	2007-10-26 23:21:39.000000000 +0000
@@ -180,6 +180,25 @@
 }
 
 /**
+ * exsltSaxonSystemIdFunction:
+ * @ctxt:  an XPath parser context
+ * @nargs: number of arguments
+ *
+ * Implements the SAXON systemId() function
+ *     string saxon:systemId ()
+ * This function returns the system ID of the document being styled.
+ */
+static void
+exsltSaxonSystemIdFunction (xmlXPathParserContextPtr ctxt, int nargs) {
+    if (nargs != 0) {
+	    xmlXPathSetArityError(ctxt);
+        return;
+    }
+
+    valuePush(ctxt, xmlXPathNewString(ctxt->context->doc->URL));
+}
+
+/**
  * exsltSaxonLineNumberFunction:
  * @ctxt:  an XPath parser context
  * @nargs: number of arguments
@@ -264,4 +283,7 @@
     xsltRegisterExtModuleFunction ((const xmlChar *) "line-number",
 				   SAXON_NAMESPACE,
 				   exsltSaxonLineNumberFunction);
+    xsltRegisterExtModuleFunction ((const xmlChar *) "systemId",
+				   SAXON_NAMESPACE,
+				   exsltSaxonSystemIdFunction);
 }
