From dc6badfd89fc8d40f5ee76a23ff871d0490ccbb6 Mon Sep 17 00:00:00 2001 From: David Lichteblau Date: Sun, 27 Apr 2008 12:37:29 +0200 Subject: [PATCH] Disallow empty attributes in xsl:sort --- TEST | 6 +++--- instructions.lisp | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/TEST b/TEST index 5455ea8..253b161 100644 --- a/TEST +++ b/TEST @@ -16893,7 +16893,7 @@ PASS Sorting__77548 [XSLT-Data-Manipulation] Expected output (1): MSFT_Conformance_Tests/Sorting/Sorting__77548.saxon Actual output: MSFT_Conformance_Tests/Sorting/Sorting__77548.xuriella -FAIL Sorting__77550 [XSLT-Data-Manipulation]: expected error not signalled: +PASS Sorting__77550 [XSLT-Data-Manipulation]: raised an xslt-error as expected Stylesheet: MSFT_Conformance_Tests/Sorting/XSLT19008.noindent-xsl Data: MSFT_Conformance_Tests/Sorting/sort3.xml Expected output (1): MSFT_Conformance_Tests/Sorting/Sorting__77550.saxon @@ -16911,7 +16911,7 @@ PASS Sorting__77553 [XSLT-Data-Manipulation]: raised an xslt-error as expected Expected output (1): MSFT_Conformance_Tests/Sorting/Sorting__77553.saxon Actual output: MSFT_Conformance_Tests/Sorting/Sorting__77553.xuriella -FAIL Sorting__77555 [XSLT-Data-Manipulation]: expected error not signalled: +PASS Sorting__77555 [XSLT-Data-Manipulation]: raised an xslt-error as expected Stylesheet: MSFT_Conformance_Tests/Sorting/XSLT20010.noindent-xsl Data: MSFT_Conformance_Tests/Sorting/sort3.xml Expected output (1): MSFT_Conformance_Tests/Sorting/Sorting__77555.saxon @@ -19294,4 +19294,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 2976/3070 tests (11 expected failures, 83 unexpected failures). +Passed 2978/3070 tests (11 expected failures, 81 unexpected failures). diff --git a/instructions.lisp b/instructions.lisp index a41d2e8..970eed8 100644 --- a/instructions.lisp +++ b/instructions.lisp @@ -417,7 +417,7 @@ (cond ((equal str "number") t) - ((or (equal str "") (equal str "text")) + ((or (null str) (equal str "text")) nil) (t (xslt-error "invalid data-type in sort")))) @@ -426,7 +426,7 @@ (cond ((equal str "lower-first") *lower-first-order*) - ((or (equal str "") (equal str "upper-first")) + ((or (null str) (equal str "upper-first")) *upper-first-order*) (t (xslt-error "invalid case-order in sort")))) @@ -435,19 +435,24 @@ (cond ((equal str "descending") -1) - ((or (equal str "") (equal str "ascending")) + ((or (null str) (equal str "ascending")) 1) (t (xslt-error "invalid order in sort")))) +(defun compile-optional-avt (template-string env) + (if template-string + (compile-avt template-string env) + (values (constantly nil) t))) + (defun make-sorter/lazy (spec env) (destructuring-bind (&key select lang data-type order case-order) (cdr spec) (let ((select-thunk (compile-xpath (or select ".") env)) - (lang-thunk (compile-avt (or lang "") env)) - (data-type-thunk (compile-avt (or data-type "") env)) - (order-thunk (compile-avt (or order "") env)) - (case-order-thunk (compile-avt (or case-order "") env))) + (lang-thunk (compile-optional-avt lang env)) + (data-type-thunk (compile-optional-avt data-type env)) + (order-thunk (compile-optional-avt order env)) + (case-order-thunk (compile-optional-avt case-order env))) (lambda (ctx) (let ((numberp (sort/@data-type (funcall data-type-thunk ctx))) (char-table (sort/@case-order (funcall case-order-thunk ctx))) -- 2.11.4.GIT