From 4a0be87cfe611f5c8fd1ce6bbebc507c01b65f05 Mon Sep 17 00:00:00 2001 From: David Lichteblau Date: Fri, 14 Mar 2008 20:14:49 +0100 Subject: [PATCH] Implemented xsl:extension-element-prefixes --- TEST | 10 +++++----- instructions.lisp | 5 +++++ package.lisp | 1 + parser.lisp | 43 +++++++++++++++++++++++++++++-------------- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/TEST b/TEST index 8ad6fb5..10ea98f 100644 --- a/TEST +++ b/TEST @@ -3172,7 +3172,7 @@ PASS lre_lre20 [XSLT-Result-Tree] Expected output (1): Xalan_Conformance_Tests/lre/lre_lre20.saxon Actual output: Xalan_Conformance_Tests/lre/lre_lre20.xuriella -FAIL lre_lre21 [XSLT-Result-Tree]: output doesn't match +PASS lre_lre21 [XSLT-Result-Tree] Stylesheet: Xalan_Conformance_Tests/lre/lre21.noindent-xsl Data: Xalan_Conformance_Tests/lre/lre21.xml Expected output (1): Xalan_Conformance_Tests/lre/lre_lre21.saxon @@ -21037,19 +21037,19 @@ PASS Stylesheet__91811 [XSLT-Structure] Expected output (1): MSFT_Conformance_Tests/Stylesheet/Stylesheet__91811.saxon Actual output: MSFT_Conformance_Tests/Stylesheet/Stylesheet__91811.xuriella -FAIL Stylesheet__91813 [XSLT-Structure]: expected error not signalled: +PASS Stylesheet__91813 [XSLT-Structure]: raised an xslt-error as expected Stylesheet: MSFT_Conformance_Tests/Stylesheet/91813.noindent-xsl Data: MSFT_Conformance_Tests/Stylesheet/books.xml Expected output (1): MSFT_Conformance_Tests/Stylesheet/Stylesheet__91813.saxon Actual output: MSFT_Conformance_Tests/Stylesheet/Stylesheet__91813.xuriella -FAIL Stylesheet__91814 [XSLT-Structure]: expected error not signalled: +PASS Stylesheet__91814 [XSLT-Structure]: raised an xslt-error as expected Stylesheet: MSFT_Conformance_Tests/Stylesheet/91814.noindent-xsl Data: MSFT_Conformance_Tests/Stylesheet/books.xml Expected output (1): MSFT_Conformance_Tests/Stylesheet/Stylesheet__91814.saxon Actual output: MSFT_Conformance_Tests/Stylesheet/Stylesheet__91814.xuriella -FAIL Stylesheet__91815 [XSLT-Structure]: expected error not signalled: +PASS Stylesheet__91815 [XSLT-Structure]: raised an xslt-error as expected Stylesheet: MSFT_Conformance_Tests/Stylesheet/91815.noindent-xsl Data: MSFT_Conformance_Tests/Stylesheet/books.xml Expected output (1): MSFT_Conformance_Tests/Stylesheet/Stylesheet__91815.saxon @@ -22744,4 +22744,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 2506/3085 tests. +Passed 2510/3085 tests. diff --git a/instructions.lisp b/instructions.lisp index bb3cec0..49dd0b8 100644 --- a/instructions.lisp +++ b/instructions.lisp @@ -391,6 +391,11 @@ (let ((*excluded-namespaces* (append uris *excluded-namespaces*))) (compile-instruction `(progn ,@body) env)))) +(define-instruction xsl:with-extension-namespaces (args env) + (destructuring-bind ((&rest uris) &rest body) args + (let ((*extension-namespaces* (append uris *extension-namespaces*))) + (compile-instruction `(progn ,@body) env)))) + ;; XSLT disallows multiple definitions of the same variable within a ;; template. Local variables can shadow global variables though. ;; Since our LET syntax makes it natural to shadow local variables the diff --git a/package.lisp b/package.lisp index 76ac29d..296605f 100644 --- a/package.lisp +++ b/package.lisp @@ -31,6 +31,7 @@ ;; xuriella internals #:with-namespaces #:with-excluded-namespaces + #:with-extension-namespaces #:with-duplicates-check)) (defpackage :xuriella diff --git a/parser.lisp b/parser.lisp index 315506d..6d0635c 100644 --- a/parser.lisp +++ b/parser.lisp @@ -121,20 +121,35 @@ `(xsl:text ,(stp:data node))))) (defun parse-instruction/literal-element (node) - `(xsl:literal-element - (,(stp:local-name node) - ,(stp:namespace-uri node) - ,(stp:namespace-prefix node)) - (xsl:use-attribute-sets - ,(stp:attribute-value node "use-attribute-sets" *xsl*)) - ,@(loop for a in (stp:list-attributes node) - unless (equal (stp:namespace-uri a) *xsl*) - collect `(xsl:literal-attribute - (,(stp:local-name a) - ,(stp:namespace-uri a) - ,(stp:namespace-prefix a)) - ,(stp:value a))) - ,@(parse-body node))) + (let ((le + `(xsl:literal-element + (,(stp:local-name node) + ,(stp:namespace-uri node) + ,(stp:namespace-prefix node)) + (xsl:use-attribute-sets + ,(stp:attribute-value node "use-attribute-sets" *xsl*)) + ,@(loop for a in (stp:list-attributes node) + unless (equal (stp:namespace-uri a) *xsl*) + collect `(xsl:literal-attribute + (,(stp:local-name a) + ,(stp:namespace-uri a) + ,(stp:namespace-prefix a)) + ,(stp:value a))) + ,@(parse-body node))) + (extensions '())) + (stp:with-attributes ((eep "extension-element-prefixes" *xsl*)) + node + (dolist (prefix (words (or eep ""))) + (when (equal prefix "#default") + (setf prefix nil)) + (push (or (stp:find-namespace prefix node) + (xslt-error "namespace not found: ~A" prefix)) + extensions))) + (if extensions + `(xsl:with-extension-namespaces ,extensions + (xsl:with-excluded-namespaces ,extensions + ,le)) + le))) (defun parse-fallback-children (node) `(progn -- 2.11.4.GIT