From 13a8acd7a178393c6dbde783509ef9c1a32c0519 Mon Sep 17 00:00:00 2001 From: David Lichteblau Date: Fri, 14 Mar 2008 23:38:09 +0100 Subject: [PATCH] Fixed document() with attribute nodes --- TEST | 19 ++++++++----------- xslt.lisp | 39 +++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/TEST b/TEST index 1807200..c9971ad 100644 --- a/TEST +++ b/TEST @@ -4046,8 +4046,7 @@ PASS mdocs_mdocs04 [XSLT-Result-Tree] Expected output (1): Xalan_Conformance_Tests/mdocs/mdocs_mdocs04.saxon Actual output: Xalan_Conformance_Tests/mdocs/mdocs_mdocs04.xuriella -FAIL mdocs_mdocs05 [XSLT-Result-Tree]: cannot parse referenced document /compu.xml: error opening #P"/compu.xml": - No such file or directory +PASS mdocs_mdocs05 [XSLT-Result-Tree] Stylesheet: Xalan_Conformance_Tests/mdocs/mdocs05.noindent-xsl Data: Xalan_Conformance_Tests/mdocs/mdocs05.xml Supplemental data: Xalan_Conformance_Tests/mdocs/compu.xml @@ -8129,16 +8128,14 @@ PASS reluri_reluri08 [XSLT-Result-Tree] Expected output (1): Xalan_Conformance_Tests/reluri/reluri_reluri08.saxon Actual output: Xalan_Conformance_Tests/reluri/reluri_reluri08.xuriella -FAIL reluri_reluri09 [XSLT-Result-Tree]: cannot parse referenced document ...Xalan_Conformance_Tests/reluri/level3/xreluri09a.xml: error opening #P"...Xalan_Conformance_Tests/reluri/level3/xreluri09a.xml": - No such file or directory +PASS reluri_reluri09 [XSLT-Result-Tree] Stylesheet: Xalan_Conformance_Tests/reluri/reluri09.noindent-xsl Data: Xalan_Conformance_Tests/reluri/reluri09.xml Supplemental data: Xalan_Conformance_Tests/reluri/level1/level2/level3/xreluri09a.xml Expected output (1): Xalan_Conformance_Tests/reluri/reluri_reluri09.saxon Actual output: Xalan_Conformance_Tests/reluri/reluri_reluri09.xuriella -FAIL reluri_reluri10 [XSLT-Result-Tree]: cannot parse referenced document ...Xalan_Conformance_Tests/reluri/level3/xreluri09a.xml: error opening #P"...Xalan_Conformance_Tests/reluri/level3/xreluri09a.xml": - No such file or directory +PASS reluri_reluri10 [XSLT-Result-Tree] Stylesheet: Xalan_Conformance_Tests/reluri/reluri10.noindent-xsl Data: Xalan_Conformance_Tests/reluri/reluri10.xml Supplemental data: Xalan_Conformance_Tests/reluri/level1/level2/xreluri10b.xml @@ -22605,10 +22602,11 @@ PASS XSLTFunctions_DocumentFunctionNoArg [Mixed] Actual output: MSFT_Conformance_Tests/XSLTFunctions/XSLTFunctions_DocumentFunctionNoArg.xuriella FAIL XSLTFunctions_DocumentFunctionWithAbsoluteArgument [Mixed]: There is no applicable method for the generic function - # + # when called with arguments (:DEFAULT-NAVIGATOR - NIL). + NIL + :DOCUMENT). Stylesheet: MSFT_Conformance_Tests/XSLTFunctions/xslt_func_document_function_abs_arg.noindent-xsl Data: MSFT_Conformance_Tests/XSLTFunctions/foo.xml Expected output (1): MSFT_Conformance_Tests/XSLTFunctions/XSLTFunctions_DocumentFunctionWithAbsoluteArgument.saxon @@ -22729,8 +22727,7 @@ PASS XSLTFunctions_Bug76054 [Mixed] Expected output (1): MSFT_Conformance_Tests/XSLTFunctions/XSLTFunctions_Bug76054.saxon Actual output: MSFT_Conformance_Tests/XSLTFunctions/XSLTFunctions_Bug76054.xuriella -FAIL XSLTFunctions_Bug76984 [Mixed]: cannot parse referenced document /a.xml: error opening #P"/a.xml": - No such file or directory +FAIL XSLTFunctions_Bug76984 [Mixed]: output doesn't match Stylesheet: MSFT_Conformance_Tests/XSLTFunctions/Bug76984.noindent-xsl Data: MSFT_Conformance_Tests/XSLTFunctions/Bug76984.xml Supplemental data: MSFT_Conformance_Tests/XSLTFunctions/b.xml @@ -22743,4 +22740,4 @@ PASS XSLTFunctions_DocumentFuncWithEmptyArg [Mixed] Expected output (1): MSFT_Conformance_Tests/XSLTFunctions/XSLTFunctions_DocumentFuncWithEmptyArg.saxon Actual output: MSFT_Conformance_Tests/XSLTFunctions/XSLTFunctions_DocumentFuncWithEmptyArg.xuriella -Passed 2515/3085 tests. +Passed 2518/3085 tests. diff --git a/xslt.lisp b/xslt.lisp index 06ee3bb..4b1fa64 100644 --- a/xslt.lisp +++ b/xslt.lisp @@ -849,6 +849,19 @@ (xpath-sys:define-extension xslt *xsl*) +(defun document-base-uri (node) + (xpath-protocol:base-uri + (cond + ((xpath-protocol:node-type-p node :document) + (xpath::find-in-pipe-if + (lambda (x) + (xpath-protocol:node-type-p x :element)) + (xpath-protocol:child-pipe node))) + ((xpath-protocol:node-type-p node :element) + node) + (t + (xpath-protocol:parent-node node))))) + (xpath-sys:define-xpath-function/lazy xslt :document (object &optional node-set) @@ -856,30 +869,20 @@ (lambda (ctx) (let* ((object (funcall object ctx)) (node-set (and node-set (funcall node-set ctx))) - (uri - (when node-set - ;; FIXME: should use first node of the node set - ;; _in document order_ - (xpath-protocol:base-uri (xpath:first-node node-set))))) + (base-uri + (if node-set + (document-base-uri (xpath::textually-first-node node-set)) + instruction-base-uri))) (xpath-sys:make-node-set (if (xpath:node-set-p object) (xpath:map-node-set->list (lambda (node) (%document (xpath:string-value node) - (if (plusp (length uri)) - uri - (xpath-protocol:base-uri - (if (xpath-protocol:node-type-p node :document) - (xpath::find-in-pipe-if - (lambda (x) - (xpath-protocol:node-type-p x :element)) - (xpath-protocol:child-pipe node)) - node))))) + (if node-set + base-uri + (document-base-uri node)))) object) - (list (%document (xpath:string-value object) - (if (plusp (length uri)) - uri - instruction-base-uri))))))))) + (list (%document (xpath:string-value object) base-uri)))))))) (xpath-sys:define-xpath-function/lazy xslt :key (name object) (let ((namespaces *namespaces*)) -- 2.11.4.GIT