From eb48b93416591e4ed7cc6f0f99431c61db6af712 Mon Sep 17 00:00:00 2001 From: David Lichteblau Date: Sun, 23 Mar 2008 15:00:13 +0100 Subject: [PATCH] xsl:number fixes: non-element nodes --- TMP | 4 ++-- number.lisp | 28 ++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/TMP b/TMP index 8c6fdff..0262d60 100644 --- a/TMP +++ b/TMP @@ -484,7 +484,7 @@ PASS numbering_numbering88 [XSLT-Result-Tree] Expected output (1): Xalan_Conformance_Tests/numbering/numbering_numbering88.saxon Actual output: Xalan_Conformance_Tests/numbering/numbering_numbering88.xuriella -FAIL numbering_numbering89 [XSLT-Result-Tree]: output doesn't match +PASS numbering_numbering89 [XSLT-Result-Tree] Stylesheet: Xalan_Conformance_Tests/numbering/numbering89.noindent-xsl Data: Xalan_Conformance_Tests/numbering/numbering89.xml Expected output (1): Xalan_Conformance_Tests/numbering/numbering_numbering89.saxon @@ -514,4 +514,4 @@ PASS numbering_numbering93 [XSLT-Result-Tree] Expected output (1): Xalan_Conformance_Tests/numbering/numbering_numbering93.saxon Actual output: Xalan_Conformance_Tests/numbering/numbering_numbering93.xuriella -Passed 84/86 tests. +Passed 85/86 tests. diff --git a/number.lisp b/number.lisp index 3421498..cf040e8 100644 --- a/number.lisp +++ b/number.lisp @@ -105,18 +105,34 @@ (xpath::force (funcall (xpath::axis-function :preceding-sibling) node))))) +(defun node-type (node) + (dolist (type '(:element + :attribute + :text + :document + :namespace + :processing-instruction + :comment)) + (when (xpath-protocol:node-type-p node type) + (return type)))) + (defun compute-number-list (level node count from) (unless count (setf count (let ((uri (xpath-protocol:namespace-uri node)) - (lname (xpath-protocol:local-name node))) + (lname (xpath-protocol:local-name node)) + (node-type (node-type node))) (lambda (ctx) - (let ((node (xpath:context-node ctx))) + (let ((ctx-node (xpath:context-node ctx))) (xpath-sys:make-node-set - (if (and (xpath-protocol:node-type-p node :element) - (equal (xpath-protocol:namespace-uri node) uri) - (equal (xpath-protocol:local-name node) lname)) - (list node) + (if (if (eq node-type :element) + (and (xpath-protocol:node-type-p ctx-node :element) + (equal (xpath-protocol:namespace-uri ctx-node) + uri) + (equal (xpath-protocol:local-name ctx-node) + lname)) + (xpath-protocol:node-type-p ctx-node node-type)) + (list ctx-node) nil))))))) (cond ((equal level "single") -- 2.11.4.GIT