summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2012-09-12 11:07:56 +0800
committerDaniel Veillard <veillard@redhat.com>2012-09-12 11:07:56 +0800
commit92bc8136311ed86d85f764cbfc82da77d90c0e29 (patch)
tree5631ffae1e9fa9e6e70740db07b14ad0b3b77a85
parentdc23a2a0dd4a9b23bea81eedf907a5b9e299ca7d (diff)
downloadlibxslt-92bc8136311ed86d85f764cbfc82da77d90c0e29.tar.gz
libxslt-92bc8136311ed86d85f764cbfc82da77d90c0e29.tar.bz2
libxslt-92bc8136311ed86d85f764cbfc82da77d90c0e29.zip
Add the saxon:systemId extension
For https://bugzilla.gnome.org/show_bug.cgi?id=519926 Both Xalan and Saxon have a systemId function (in their respective namespaces) to provide the URI of the file that is being transformed. It would be nice to have that function in libxslt1.1 as well, because then DocBook could use it[0]. [0] See line 250 et seq in /usr/share/xml/docbook/stylesheet/nwalsh/common/stripns.xsl
-rw-r--r--libexslt/saxon.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/libexslt/saxon.c b/libexslt/saxon.c
index fcb1547a..60880c80 100644
--- a/libexslt/saxon.c
+++ b/libexslt/saxon.c
@@ -180,6 +180,32 @@ exsltSaxonEvaluateFunction (xmlXPathParserContextPtr ctxt, int nargs) {
}
/**
+ * 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 (ctxt == NULL)
+ return;
+ if (nargs != 0) {
+ xmlXPathSetArityError(ctxt);
+ return;
+ }
+
+ if ((ctxt->context) && (ctxt->context->doc) &&
+ (ctxt->context->doc->URL))
+ valuePush(ctxt, xmlXPathNewString(ctxt->context->doc->URL));
+ else
+ valuePush(ctxt, xmlXPathNewString(BAD_CAST ""));
+}
+
+/**
* exsltSaxonLineNumberFunction:
* @ctxt: an XPath parser context
* @nargs: number of arguments
@@ -264,4 +290,7 @@ exsltSaxonRegister (void) {
xsltRegisterExtModuleFunction ((const xmlChar *) "line-number",
SAXON_NAMESPACE,
exsltSaxonLineNumberFunction);
+ xsltRegisterExtModuleFunction ((const xmlChar *) "systemId",
+ SAXON_NAMESPACE,
+ exsltSaxonSystemIdFunction);
}