-add libxslt 1.1.24
authorChristoph von Wittich <christoph_vw@reactos.org>
Wed, 21 Jan 2009 12:09:32 +0000 (12:09 +0000)
committerChristoph von Wittich <christoph_vw@reactos.org>
Wed, 21 Jan 2009 12:09:32 +0000 (12:09 +0000)
-update libxml2 to 2.7.3
-add a new lib "wineldr" to hack around wine's .so lib crap (attention this depends on kernel32!)
-enable the usage of libxslt in msxml3

svn path=/trunk/; revision=38989

99 files changed:
reactos/boot/bootdata/packages/reactos.dff
reactos/dll/3rdparty/3rdparty.rbuild
reactos/dll/3rdparty/libxslt/AUTHORS [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/COPYING [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/ChangeLog [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/Makefile.am [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/Makefile.in [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/NEWS [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/README [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/attributes.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/attributes.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/attrvt.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/config.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/documents.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/documents.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/extensions.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/extensions.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/extra.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/extra.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/functions.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/functions.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/imports.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/imports.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/keys.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/keys.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/libxslt.3 [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/libxslt.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/libxslt.rbuild [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/namespaces.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/namespaces.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/numbers.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/numbersInternals.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/pattern.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/pattern.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/preproc.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/preproc.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/security.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/security.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/templates.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/templates.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/transform.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/transform.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/trio.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/triodef.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/variables.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/variables.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/win32config.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/xslt.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/xslt.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/xsltInternals.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/xsltconfig.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/xsltconfig.h.in [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/xsltexports.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/xsltutils.c [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/xsltutils.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/xsltwin32config.h [new file with mode: 0644]
reactos/dll/3rdparty/libxslt/xsltwin32config.h.in [new file with mode: 0644]
reactos/dll/win32/msxml3/msxml3.rbuild
reactos/include/psdk/msxml2.idl
reactos/include/reactos/libs/libxml/parser.h
reactos/include/reactos/libs/libxml/parserInternals.h
reactos/include/reactos/libs/libxml/relaxng.h
reactos/include/reactos/libs/libxml/tree.h
reactos/include/reactos/libs/libxml/valid.h
reactos/include/reactos/libs/libxml/xmlerror.h
reactos/include/reactos/libs/libxml/xmlmemory.h
reactos/include/reactos/libs/libxml/xmlschemas.h
reactos/include/reactos/libs/libxml/xmlversion.h
reactos/include/reactos/libs/libxml/xmlversion.h.in
reactos/include/reactos/libs/libxml/xmlwriter.h
reactos/include/reactos/libs/libxslt/extensions.h [new file with mode: 0644]
reactos/include/reactos/libs/libxslt/libxslt.h [new file with mode: 0644]
reactos/include/reactos/libs/libxslt/numbersInternals.h [new file with mode: 0644]
reactos/include/reactos/libs/libxslt/pattern.h [new file with mode: 0644]
reactos/include/reactos/libs/libxslt/transform.h [new file with mode: 0644]
reactos/include/reactos/libs/libxslt/xslt.h [new file with mode: 0644]
reactos/include/reactos/libs/libxslt/xsltInternals.h [new file with mode: 0644]
reactos/include/reactos/libs/libxslt/xsltconfig.h [new file with mode: 0644]
reactos/include/reactos/libs/libxslt/xsltexports.h [new file with mode: 0644]
reactos/include/reactos/libs/libxslt/xsltutils.h [new file with mode: 0644]
reactos/include/reactos/wine/config.h
reactos/include/reactos/wine/library.h
reactos/lib/3rdparty/libwine/libwine.rbuild
reactos/lib/3rdparty/libwine/loader.c [new file with mode: 0644]
reactos/lib/3rdparty/libxml2/ChangeLog
reactos/lib/3rdparty/libxml2/SAX2.c
reactos/lib/3rdparty/libxml2/configure
reactos/lib/3rdparty/libxml2/configure.in
reactos/lib/3rdparty/libxml2/elfgcchack.h
reactos/lib/3rdparty/libxml2/libxml2.rbuild
reactos/lib/3rdparty/libxml2/libxml2.spec
reactos/lib/3rdparty/libxml2/parser.c
reactos/lib/3rdparty/libxml2/testapi.c
reactos/lib/3rdparty/libxml2/threads.c
reactos/lib/3rdparty/libxml2/tree.c
reactos/lib/3rdparty/libxml2/valid.c
reactos/lib/3rdparty/libxml2/xmllint.c
reactos/lib/3rdparty/libxml2/xmlwriter.c
reactos/lib/3rdparty/libxml2/xpath.c

index f7ea519..08f1b46 100644 (file)
@@ -109,6 +109,7 @@ base\system\smss\smss.exe                           1
 ; Dynamic Link Libraries
 dll\3rdparty\freetype\freetype.dll                  1
 dll\3rdparty\mesa32\mesa32.dll                      1
+dll\3rdparty\libxslt\ibxslt.dll                     1
 dll\3rdparty\dxtn\dxtn.dll                          1   optional
 
 dll\cpl\access\access.cpl                           1
index fee1af4..7ce3520 100644 (file)
@@ -7,6 +7,9 @@
        <directory name="mesa32">
                <xi:include href="mesa32/mesa32.rbuild" />
        </directory>
+       <directory name="libxslt">
+               <xi:include href="libxslt/libxslt.rbuild" />
+       </directory>
        <if property="NSWPAT" value="1">
                <directory name="dxtn">
                        <xi:include href="dxtn/dxtn.rbuild" />
diff --git a/reactos/dll/3rdparty/libxslt/AUTHORS b/reactos/dll/3rdparty/libxslt/AUTHORS
new file mode 100644 (file)
index 0000000..094ebbc
--- /dev/null
@@ -0,0 +1,20 @@
+Daniel Veillard:
+   daniel@veillard.com
+   DV on #gnome IRC channel
+   http://veillard.com/
+   Used to work at W3C, now Red Hat
+   co-chair of W3C XML Linking WG
+   invited expert on the W3C XML Core WG
+   Author of libxml upon which this library is based.
+
+Bjorn Reese:
+   breese@users.sourceforge.net
+   http://home1.stofanet.dk/breese/
+   Software developer at http://www.systematic.dk/
+   Member of the XML-MTF Mapping WG.
+
+William Brack <wbrack@mmm.com.hk>
+
+Thomas Broyer <tbroyer@ltgt.net>
+
+Igor Zlatkovic <igor@zlatkovic.com> for the Windows port
diff --git a/reactos/dll/3rdparty/libxslt/COPYING b/reactos/dll/3rdparty/libxslt/COPYING
new file mode 100644 (file)
index 0000000..627eeff
--- /dev/null
@@ -0,0 +1,53 @@
+Licence for libxslt except libexslt
+----------------------------------------------------------------------
+ Copyright (C) 2001-2002 Daniel Veillard.  All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is fur-
+nished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Daniel Veillard shall not
+be used in advertising or otherwise to promote the sale, use or other deal-
+ings in this Software without prior written authorization from him.
+
+----------------------------------------------------------------------
+
+Licence for libexslt
+----------------------------------------------------------------------
+ Copyright (C) 2001-2002 Thomas Broyer, Charlie Bozeman and Daniel Veillard.
+ All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is fur-
+nished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the authors shall not
+be used in advertising or otherwise to promote the sale, use or other deal-
+ings in this Software without prior written authorization from him.
+----------------------------------------------------------------------
diff --git a/reactos/dll/3rdparty/libxslt/ChangeLog b/reactos/dll/3rdparty/libxslt/ChangeLog
new file mode 100644 (file)
index 0000000..175e5b4
--- /dev/null
@@ -0,0 +1,7573 @@
+Tue May 13 17:51:05 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in doc/*: release of 1.1.24
+       * python/generator.py: syntactic cleanup (Martin)
+
+Tue May 13 16:32:22 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xslt.c libxslt/extensions.c libxslt/extensions.h:
+         fix the processing of top level elements of stylesheets which
+         are not in the XSLT namespace and are not an extension either
+         should fix #529223
+       * tests/docs/Makefile.am tests/docs/bug-167.xml
+         tests/general/Makefile.am tests/general/bug-167.*: add the
+         test to the regression suite
+
+Fri May  9 14:30:35 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/documents.c libxslt/keys.c libxslt/xsltInternals.h
+         libxslt/transform.c libxslt/pattern.c: fix the key initialization
+         problem introduced when tracking Josef Urban problem from 22 Dec
+         2007, this should also handle the problem of recursive keys
+         definitions should fix #531873.
+       * tests/docs/bug-166.xml tests/docs/Makefile.am
+         tests/general/Makefile.am tests/general/bug-166.xsl
+         tests/general/bug-166.out: add the regression tests when a key
+         computation depends on another one.
+
+Mon Apr 21 16:16:29 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+       * doc/xsltproc.1 doc/xsltproc.xml: update the man page based on
+         Vincent Lefevre suggestion.
+
+Mon Apr 14 11:19:14 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: fixes #527297 general patter comps fix and cleanup
+       * libxslt/xsltInternals.h libxslt/pattern.h: other cleanups
+
+Tue Apr  8 19:15:19 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in doc/*: release of 1.1.23
+
+Tue Apr  8 18:52:36 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/date.c: new version of patch from Peter Pawlowski
+
+Tue Apr  8 10:19:01 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+       * python/generator.py: fix an infinite loop bug
+
+Thu Apr  3 09:32:49 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltutils.c: avoid a scary realloc() loop should fix #520383
+
+Thu Apr  3 07:32:36 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/date.c: applied patch from Peter Pawlowski  fixing
+         a timezone offset problem, fixes #521680
+       * libxslt/namespaces.c: a bit of space/tabs cleanup
+
+Thu Apr  3 06:25:02 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+       * doc/xsltproc.xml doc/xsltproc.1 doc/xsltproc.html: small fix to
+         man page synopsis, should fix #525822
+
+Sat Mar 15 11:13:18 HKT 2008 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/functions.c: fixed minor error reported on the mailing
+        list by Mark Howe, which caused a segfault if func:result was
+        postitioned as top-level element.
+
+Thu Mar 13 09:33:21 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/win32config.h: patch from Rob Richards for VS 2008
+       * python/types.c: fix a problem with namespace nodes coming from
+         XPath nodesets.
+
+Mon Mar  3 09:39:31 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+       * doc/xsltproc.xml doc/xsltproc.1: fix maxdepth default value
+         documentation fixes #519921.
+
+Sat Feb 16 01:24:58 HKT 2008 William Brack <wbrack@mmm.com.hk>
+
+       *libxslt/extensions.c: fixed minor error bug #516483
+       *tests/exslt/common - deleted node-set.9 regression test,
+        because it relied upon an external web import.
+
+Tue Feb  5 08:53:30 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xslt.c: applied documentation patch from Jason Viers
+         for xsltParseStylesheetDoc
+
+Tue Feb  5 08:36:53 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+       * python/tests/pyxsltproc.py: applied a portability patch from 
+         Stephane Bidoul
+
+Thu Jan 24 16:24:05 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+       * doc/xslt.html doc/docbook.html: fix links for Cygwin DocBook
+         setup as suggested by Philippe Bourcier
+
+Sun Dec 23 16:40:38 PST 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/keys.c, libxslt/pattern.c, libxslt/xsltInternals.h:
+         fixed a problem on superfluous re-generation of keys reported
+         on the mailing list by Josef Urban.
+
+Thu Nov 29 11:43:14 CET 2007 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: avoid a problem in configure if an old gcrypt
+         version is installed, patch from Brent Cowgill, fixes #500390
+
+Tue Nov 13 13:08:08 PDT 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/common.c, libexslt/dynamic.c: After discussion on
+         Bugzilla with Peter Pawlowski, added same code for preventing
+         deletion of function result during garbage collection (see
+         bug #495995).
+         
+Mon Nov 12 13:53:58 PDT 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/strings.c: Added code to mark the results of
+         str:tokenize and str:split as "function result" to avoid
+         garbage-collecting them during global variable initialisation.
+         Should fix bug #495995.
+
+Wed Oct 24 17:41:08 PDT 2007 William Brack <wbrack@mmm.com.hk>
+
+       * python/libxslt.c: changed iterator argument for Py_Dict_Next
+         from int to ssize_t (seems Python docs are incorrect) to fix
+         x86_64 bug #489854.
+
+Wed Oct 10 16:33:09 CEST 2007 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/date.c tests/exslt/date/datetime.1.out
+         tests/exslt/date/date.1.out tests/exslt/date/date.1.xml:
+         applied patch from Maurice van der Pot to fix EXSLT
+         week-in-year extenson which was not conforming to the definition.
+         This also changes the output of the tests a bit. Should fix #452876
+
+Thu Aug 30 08:18:08 HKT 2007 William Brack <wbrack@mmm.com.hk>
+
+       * python/libxslt.c: applied patch from Daniel Gryniewicz to
+         fix a segfault caused by a parameter array not being preset
+         to zero.
+
+Thu Aug 23 17:18:03 CEST 2007 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in doc/*: preparing release of 1.1.22
+
+Thu Aug 23 15:39:18 CEST 2007 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xslt.c: applied patch from Rob Richards to fix a 
+         stylesheet compilation error handling problem #382570
+
+Thu Aug 23 15:22:55 CEST 2007 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/security.c: applied patch from Roland Schwarz and Rob
+         Richards to fix the security file checks on Windows, should 
+         close #464432
+
+Thu Aug 23 21:15:28 HKT 2007 William Brack <wbrack@mmm.com.hk>
+
+       * tests/general/bug-165.[xsl,out,err], tests/docs/bug-165.xml,
+         tests/general/Makefile.am, tests/docs/Makefile.am:
+         added regression test for bug #469410
+
+Thu Aug 23 14:13:02 CEST 2007 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: patch from Drazen Kacar to add a --encoding
+         option fixes #443868
+       * doc/xsltproc.xml doc/xsltproc.1: augment and regenerate man page.
+       
+Thu Aug 23 11:47:20 CEST 2007 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/date.c: apply patch from Björn Wiberg fixing build on AIX
+         and closing bug #332173
+
+Fri Aug  3 15:49:26 CEST 2007 Daniel Veillard <daniel@veillard.com>
+
+       * win32/Makefile.msvc win32/configure.js: apply patch from
+         Rob Richards to improve build with VS2005
+
+Thu Jul 26 12:43:38 PDT 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xslt.c: Removed the exclude-result-prefix change of
+         31 May 2007.  Fixes bug #459713.
+
+Sat Jun 16 07:42:18 PDT 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: Fixed problem with RVT cleanup related
+         to some exslt functions (reported on the list by Marc Adkins).
+
+Wed Jun 13 13:27:48 PDT 2007 William Brack <wbrack@mmm.com.hk>
+
+       * tests/exslt/common/node-set.9.[xml,xsl,out],
+         tests/exslt/common/Makefile.am: added test case for bug #413451
+
+Tue Jun 12 18:43:05 CEST 2007 Daniel Veillard <daniel@veillard.com>
+
+       * NEWS configure.in doc/*: preparing release of 1.1.21
+
+Thu May 31 12:38:08 PDT 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xslt.c: fixed obscure namespace problem related to
+         exclude-result-prefix
+
+Mon May  7 00:14:28 HKT 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: fixed minor compilation warning; no change
+         to logic.
+
+Sun May  6 23:42:38 HKT 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/math.c: fixed two memory leaks, one in exsltMathConstant
+         and one in exsltMathConstantFunction (bug #436324)
+
+Fri May  4 15:51:58 HKT 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: fixed xpath context housekeeping problem
+         on processing "choose" (bug 435479).
+
+Thu Apr 26 11:10:18 HKT 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: fixed (another) problem with cached
+         RVT's (from re-opened #378766).
+
+Tue Mar 27 16:50:52 CEST 2007 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltutils.c: apply patch fron Shaun McCance to hook
+         xsl:message construct to the new per-xsltTransformCtxt error
+         callback if set up.
+       * Makefile.am: do not package svn files in releases
+
+Fri Mar  2 18:45:48 HKT 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xsltconfig.h.in: added setting of TRIO_REPLACE_STDIO
+         when TRIO routines are required.
+       * libxslt/namespaces.c, libxslt/xsltutils.c: enhanced handling
+         of stdio.h vs. trio.h when trio routines are required (now
+         use XSLT_NEED_TRIO) (bug #412787)
+
+Sun Feb 18 09:00:08 PST 2007 William Brack <wbrack@mmm.com.hk>
+
+       * python/libxsl.py: fixed tab/space inconsistency with patch
+         provided by Andreas Hanke (bug #409193)
+
+Thu Feb 15 14:03:18 PST 2007 William Brack <wbrack@mmm.com.hk>
+
+       * doc/xslt.html: Changed all
+         references to CVS to be SVN; changed corresponding links.
+       * doc/*html: regenerated the documentation for above
+
+Wed Feb 14 01:21:38 PST 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/pattern.c: Fixed problem with namespace on compound
+         predicate (bug #407731)
+
+Wed Jan 24 11:05:28 PST 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/pattern.c: added check for memory allocation error
+         (bug #400242); fixed "type-punned pointer" warnings.
+       * libxslt/xsltutils.c: added checks for memory allocation error
+         (bug #400242)
+       * restored NEWS, doc/EXSLT/downloads.html which mysteriously
+         disappeared from svn
+       
+Wed Jan 17 14:20:18 CET 2007 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in doc/*: preparing release of 1.1.20
+       * libexslt/crypto.c: small patch for missing includes on some BSD,
+         fixes #397373
+       * configure.in: replace == by = in test, raised by Roland Illig,
+         should fix #397371
+
+Sun Jan 14 18:45:08 PST 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/functions.c: fixed two problems related to checking
+         of fragments, related to python htmlCtxtReadFile problem
+         reported on mailing list by Nic Ferrier.
+
+Fri Jan 12 23:24:08 PST 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/extensions.c: reverted last change, fixed some
+         comments.  Note that in it's current state the 'plugin'
+         implementation will fail if called from a program
+         compiled as static!
+
+Fri Jan 12 15:40:08 PST 2007 William Brack <wbrack@mmm.com.hk>
+
+       * configure.in: fixed problem with DV/WMB testing env.
+       * regenerated docs; doc/APIchunk1[012].html added to SVN
+       * libxslt/extensions.c: fixed problem with plugin loading;
+         removed testplugin.c from SVN (current version kept as
+         tests/plugin/testplugin.c)
+
+Thu Jan 11 11:08:18 PST 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: enhanced to ignore empty text node
+         in xsltDefaultProcessOneNode (avoid calling xsltCopyText)
+         (bug #354900)
+       * xsltproc/xsltproc.c: added check for output file problem,
+         yielding new error code 11 (Mike Hommey).
+       * doc/xsltproc.html, doc/xsltproc.xml: added documentation
+         for above, regenerated docs (doc/xsltproc.1)
+
+Wed Jan 10 19:13:08 PST 2007 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/strings.c: added new function 'replace' from Joel
+         Reed.
+       * tests/exslt/Makefile.am, replace.1.xml, replace.1.xsl,
+         replace.1.out: added new test case for above.
+       * libxslt.spec.in: trivial change from 'Gnome' to 'GNOME'
+       * configure.in: trivial change for flags on my compilations
+       * libxslt/documents.c, libxslt/documents.h, libxslt/keys.c,
+         libxslt/keys.h, libxslt/variables.c, libxslt/templates.c,
+         libxslt/transform.c, libxslt/variables.c, libxslt/xslt.c,
+         libxslt/xsltutils.c: fixed some documentation/comments and
+         compilation warnings - no change to logic.
+       * re-generated the documentation.
+
+Wed Jan  3 16:46:05 CET 2007 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: adapt the extra versioning code to SVN
+
+Fri Dec 22 09:12:08 PST 2006 William Brack <wbrack@mmm.com.hk>
+
+       * python/libxslt.c: applied patch supplied by Kjartan Maraas
+         (bug #388567).
+
+Mon Dec 11 14:38:22 PST 2006 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/functions.c: further enhancement to the original
+         fix for bug #381319 (which was not correct).
+       * tests/exslt/functions: minor enhancement to function.9.xsl;
+         function.10.[xsl,xml,out] added to regression tests to check
+         recursive calls.
+
+Mon Dec 11 12:13:14 CET 2006 Daniel Veillard <daniel@veillard.com>
+
+       * configure python/generator.py python/libxsl.py
+         python/libxslt-python-api.xml python/libxslt.c
+         python/tests/2stage.py python/tests/loader.py: applied patch from
+         Nic James Ferrier to make stylesheets comparable and to add
+         transformContext handling
+
+Sat Dec  9 15:22:34 PST 2006 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/functions.c: changed handling of function params
+         to fix bug #381319
+       * libxslt/transform.[ch]: exposed xsltLocalVariablePush and
+         xsltLocalVariablePop as global entries so that they could
+         be used from within libexslt/functions.c
+       * tests/exslt/functions/function.9.[xsl,xml,out] added to
+         regression tests
+
+Tue Dec  5 10:45:04 CET 2006 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extensions.c: applied patch from Marcus Meissner removing
+         a strict aliasing problem should fix #317921
+
+Fri Dec  1 23:02:27 HKT 2006 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: fixed problem with housekeeping of
+         localRVTBase, bug #378766
+
+Wed Nov 29 16:06:43 CET 2006 Daniel Veillard <daniel@veillard.com>
+
+       * NEWS configure.in doc//*: preparing release of libxslt-1.1.19
+
+Sat Nov 25 11:48:28 HKT 2006 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/variables.c: fixed problem with cached RVT's,
+         bug #378766
+
+Thu Nov 23 17:49:31 CET 2006 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: applied patch from Mike Hommey about saving
+         the current in-scope namespace list when calling a template, fixes
+         bug #377579
+
+Thu Nov 23 15:36:28 CET 2006 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: fix a python detection problem pointed out by 
+         Joseph Sacco, fixes bug #376391
+
+Fri Nov 17 09:53:08 HKT 2006 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: fixed problem with entity handling
+         within xsltCopyAttrListNoOverwrite (#352907)
+       * tests/general/bug-164.xsl, tests/general/bug-164.out,
+         tests/docs/bug-164.oxml: added a regression test for this
+
+Thu Oct 26 15:31:01 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * NEWS configure.in doc//*: preparing release of libxslt-1.1.18,
+         this bumps libxml2 requirement to 1.6.27
+       * libexslt/date.c libxslt/namespaces.h libxslt/xslt.c 
+         libxslt/xsltInternals.h: cosmetic cleanups to restore the
+         API extraction
+
+Thu Oct 26 10:36:43 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * doc//*: removed all remaining references to the old Wiki
+
+Thu Oct 12 23:12:24 HKT 2006 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/date.c: fixed end-of-month problem in exsltDateCurrent
+         (#359246)
+
+Thu Oct 12 14:39:37 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/preproc.c: applied patch from Mike Hommey fixing 2 
+         erroneous xmlFree() and adding a message on an unsupported feature
+
+Wed Oct 11 23:16:10 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxslt-python-api.xml: applied fix for accessor functions
+         of a stylesheet returning pointers to immutable strings, patch
+         from #320540
+       * xsltproc/xsltproc.c: fix the xinclude on stylehseet problem
+         by adding a new parameter to xsltproc names --xincludestyle
+
+Wed Oct 11 22:27:37 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: apply patch from Gary Coady to compile when
+         libxml2 has no xinclude support #319886
+       * docs/*: renamed Gnome to GNOME fixes #352159
+
+Wed Oct 11 21:37:27 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/Makefile.am: a missing DESTDIR
+       * python/Makefile.am: fix reference to build paths in python module
+       * libexslt/exsltconfig.h.in libxslt/xsltconfig.h.in: fix the header
+         comments on version values, the 3 are patches from Peter
+         Breitenlohner   and should fix #340995
+
+Wed Oct 11 11:16:34 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/security.c: applied cleanup patch from Mikhail Zabaluev
+         which should finish fixing #337486
+
+Wed Oct 11 09:55:06 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/security.c: applied fix from Shane Corgatelli to pass
+         the full URL when checking security access for network URLs,
+         should fix bug #359366
+
+Mon Aug 21 10:46:25 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * doc/xslt.html python/tests/pyxsltproc.py xsltproc/xsltproc.c: 
+         applied patch from Daniel Leidert to fix some typo
+       * xsltproc.xml xsltproc.1: applied another patch from Daniel Leidert
+         and regenerated
+
+Wed Aug 16 17:39:04 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: --xinclude should also force XInclude
+         processing on the stylesheets themselves, raised by Daniel Leidert
+
+Thu Aug 10 15:54:02 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/transform.c libxslt/variables.c
+         libxslt/xsltInternals.h: Fixed restoring the context doc
+         for XPath in xsltForEach(). Eliminated the use of @tmpDoc
+         of the transformation context.
+
+Thu Aug 10 13:40:35 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/preproc.c: Added missing QName-validation of some
+         attributes of XSLT-elements. This fixes bug #304921, reported
+         by Frans Englich.
+
+Thu Aug 10 13:27:48 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/transform.c: As suggested by Bill, I changed
+         xsltShallowCopyNsNode() to return an xmlNsPtr instead of
+         an int. The fix of bug #350085 is OK; i.e. the removal
+         of the call to xsltFreeRVTs() in
+         xsltApplyStylesheetInternal(). I think I tried to clear
+         the transformation context as much as possible, in case
+         it is reused; Daniel informed me on the list that reusing
+         the context is not intended, so no need anymore to try
+         to free the fragments immediately after the transformation.
+
+Wed Aug  9 13:22:13 PDT 2006 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: Fixed problem with cleanup of RVT's, should
+         clear bug350085; cleaned up most warnings (still a problem in
+         xsltShallowCopyNsNode)
+       * trivial warning cleanup in libxslt/[extensions.c, namespaces.c,
+         xslt.c and xsltInternals.h] and libexslt/functions.c
+
+Fri Aug  4 14:50:41 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * python/generator.py: fixed the conversion of long parameters
+
+Wed Jul 19 15:06:39 EDT 2006 Daniel Veillard <daniel@veillard.com>
+
+       * python/types.c: fix float and boolean XPath conversions
+       * libxslt/xsltutils.c: try to fix Stephane Bidoul attempt
+         at setting XInclude support.
+
+Mon Jul 17 11:15:23 PDT 2006 William Brack <wbrack@mmm.com.hk>
+
+       * Updated tests affected by recent library changes -
+         tests/general/bug-1-.out, tests/general/bug-24-.out,
+         tests/keys/month.out : (<t></t> now becomes <t/>);
+         tests/general/bug-41-.xsl and tests/general/bug-43.xsl :
+         call-template and apply-template, where the template has
+         no parameter but one is supplied (var should not be affected)
+         tests/general/bug-145.err : changed error text
+         
+Fri Jul 14 18:16:59 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/attributes.c libxslt/documents.c
+         libxslt/functions.c libxslt/keys.c libxslt/namespaces.c
+         libxslt/pattern.c libxslt/preproc.c libxslt/templates.c
+         libxslt/templates.h libxslt/transform.c
+         libxslt/variables.c libxslt/xslt.c
+         libxslt/xsltInternals.h libxslt/xsltutils.c
+         libxslt/xsltutils.h libexslt/common.c libexslt/dynamic.c
+         libexslt/functions.c libexslt/strings.c:
+         Committing again, since I forgot to switch from win to linux
+         linebreaks in the files.
+                                                   
+Fri Jul 14 17:55:42 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/attributes.c libxslt/documents.c
+         libxslt/functions.c libxslt/keys.c libxslt/namespaces.c
+         libxslt/pattern.c libxslt/preproc.c libxslt/templates.c
+         libxslt/templates.h libxslt/transform.c libxslt/variables.c
+         libxslt/xslt.c libxslt/xsltInternals.h libxslt/xsltutils.c
+         libxslt/xsltutils.h libexslt/common.c libexslt/dynamic.c
+         libexslt/functions.c libexslt/strings.c:
+         Refactored xsltValueOf(). Changed to use xmlXPathCastToString()
+         directly, rather than creating an intermediate object with
+         xmlXPathConvertString(). This now does not add a text-node to
+         the result if the string is empty (this has impact on
+         serialization, since an empty text-node is serialized as
+         <foo></foo>, and now it will be serialized as <foo/>).
+         Refactored other functions in transform.c:
+         Mostly code cleanup/restructuring. Minimized number of
+         function variables for instruction which eat up function stack
+         memory when recursing templates (xsltIf(), xsltChoose(),
+         xsltApplyTemplates(),  xsltCallTemplate()).
+         Changed XSLT tests to use xmlXPathCompiledEvalToBoolean().
+         Implemented redefinition checks at compilation-time and
+         eliminating them at transformation time in the refactored code
+         paths.
+         Introduced the field @currentTemplateRule on xsltTransformContext to
+         reflect the "Current Template Rule" as defined by the spec.
+         NOTE that ctxt->currentTemplateRule and ctxt->templ is not the
+         same; the former is the "Current Template Rule" as defined by the
+         XSLT spec, the latter is simply the template struct being
+         currently processed by Libxslt.
+         Added XML_COMMENT_NODE and XML_CDATA_SECTION_NODE to the macro
+         IS_XSLT_REAL_NODE.
+         Misc code cleanup/restructuring and everything else I already forgot.
+         Refactored lifetime of temporary result tree fragments.
+         Substituted all calls to the now deprecated xsltRegisterTmpRVT()
+         for the new xsltRegisterLocalRVT().
+         Fragments of xsl:variable and xsl:param are freed when the
+         variable/pram is freed.
+         Fragments created when evaluating a "select" of xsl:varible and
+         xsl:param are also bound to the lifetime of the var/param.
+         EXSLT's func:function now uses the following functions to let take
+         care the transformation's garbage collector of returned tree
+         fragments:
+           xsltExtensionInstructionResultRegister(),
+           xsltExtensionInstructionResultFinalize()
+         Fixes:
+         #339222 - xsl:param at invalid position inside an xsl:template is
+                   not catched
+         #346015 - Non-declared caller-parameters are accepted
+         #160400 - Compiles invalid XSLT; unbound variable accepted
+         #308441 - namespaced parameters become unregistered
+         #307103 - problem with proximity position in predicates of match
+                   patterns
+         #328218 - problem with exsl:node-set() when converting strings
+                   to node sets
+         #318088 - infinite recursion detection
+         #321505 - Multiple contiguous CDATA in output
+         #334493 - "--param" option does not have root context
+         #114377 - weird func:result/xsl:variable/exsl:node-set interaction
+         #150309 - Regression caused by fix for 142768
+
+Wed Jun 21 15:13:27 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * tests/docs/bug-54.xml tests/general/bug-54.out
+         tests/general/bug-99.out tests/general/bug-136.out
+         tests/REC/test-7.1.3.xsl tests/REC/test-7.1.4.xsl
+         tests/REC/test-7.3.xsl tests/REC/test-7.4.xsl:
+         Fixed incorrect regression tests/results.
+
+Mon Jun 19 13:33:50 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/attributes.c libxslt/attrvt.c libxslt/namespaces.c
+         libxslt/namespaces.h libxslt/preproc.c libxslt/templates.c
+         libxslt/transform.c libxslt/variables.c libxslt/xslt.c
+         libxslt/xsltInternals.h libxslt/xsltutils.c:
+         Merged all the namespace lookup/create/disable functions
+         into xsltGetSpecialNamespace(). Changed xsltGetNamespace()
+         and xsltGetPlainNamespace() to call xsltGetSpecialNamespace(),
+         but kept the ns-aliasing mechanism; the ns-aliasing needs
+         to be removed when we move to the refactored code, which
+         applies ns-alias only at compilaton time.
+         Refactored xsltElementComp() (preproc.c); enhanced error reports.
+         Fixed: if the "namespace" attribute was not given, then this
+         performed incorrectly only a lookup for a default namespace;
+         i.e., without taking any prefix on the "name" attribute into
+         account.
+         Refactored xsltElement() (transform.c); enhanced error reports.
+         Refactored xsltAttributeComp() (preproc.c). Added namespace
+         lookup as in xsltElementComp(). Enhanced error reports.
+         Refactored xsltAttribute() (transform.c); enhanced error reports.
+         xsltCopyTreeInternal(): eliminated the need to call xmlGetNsList()
+         for every element in the tree; this needs to be done only for
+         the top-most elements. For subsequent elements reconcile only
+         the ns-declarations. Disallowed setting of ns-declarations if
+         children have been already added to an element.
+         Removed ns-aliasing code where necessary.
+         xsltCopyProp(): disallowed setting of attribute nodes if
+         children have been already added to an element.
+         xsltCopy(): removed the incorrect skipping of attributes in the
+         XSLT namespace. Removed the incorrect ns-aliasing for attributes.
+         Changed to use the introduced function xsltShallowCopyAttr().
+         xsltShallowCopyAttr():  Centralized all attribute-copy related
+         code in this function. It will now be called by
+         xsltCopyTreeInternal(), xsltCopyOf() and xsltCopy().
+         xsltCopyAttrListNoOverwrite(): Renamed. Refactored. Optimized to
+         use xsltGetSpecialNamespace() and xmlNewDocProp().
+         Further substitution of various scattered namespace-lookup
+         related code for the use of xsltGetSpecialNamespace().
+         xsltAttrTemplateProcess(): Refactored. Removed the incorrect
+         processing of attribute-sets. Attribute sets need to be applied
+         before adding any normal attribute of the literal result element;
+         this is now done in  xsltAttrListTemplateProcess(). Fixed to
+         ensure that the ns-prefix of the overwriting attribute is used.
+         xsltAttrListTemplateProcess(): Refactored. Moved semantics from
+         xsltAttrTemplateProcess() over to this function in order to
+         optimize processing of multiple attributes. This does not call
+         xsltAttrTemplateProcess() anymore.
+         Fixed: do not exclude the XSLT namespace after ns-aliasing have
+         beed applied.
+         The IFDEFed-out refactored code fixes the following issues:
+         - #313711: namespace collision with namespace-alias (reported
+                     by by Oleg Paraschenko)
+         - #338214: Incorrect scope for exclude-result-prefixes
+         - #341392: Excluding namespace declarations of literal result
+                    elements.
+         - #341325: Namespace aliasing and resulting namespace prefixes
+         Already enabled fixes:
+         - #344183: xsl:copy misses to copy attributes in the XSLT namespace
+         - #341463: Namespace-alias using #default for result-prefix with no
+                    default namespace in scope
+         - #313890: namespace collision with xsl:element and xsl:attribute,
+                    reported by Oleg Paraschenko
+         - #344176: xsl:copy misses to set an element's namespace-URI in
+                    some cases
+         - #305739: the "name" QName of xsl:element is incorrectly always
+                    resolved to the default namespace
+
+Mon Jun 12 16:34:15 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * doc/xsltproc.1 doc/xsltproc.xml: more info about --output
+         from Daniel Leidert c.f. #344654
+
+Tue Jun  6 17:16:33 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in libxslt.spec.in doc//*: preparing release of 1.1.17
+
+Tue Jun  6 11:44:34 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/attributes.c: Eliminated a tiny difference wrt to
+         the old behaviour in the naming of newly generated ns-decls
+         in xsltAttributeInternal().
+
+Thu Jun  1 15:06:31 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: fix a problem in Python detection
+
+Thu Jun  1 13:58:19 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/attributes.c libxslt/variables.c
+         libxslt/transform.c libxslt/xslt.c:
+         Next step in the refactored code: enhanced xsl:attribute;
+         enhanced xsltCopyProp.
+         Added the creation of an XPath cache in
+         xsltNewTransformContext().
+
+Wed May 31 22:32:44 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/transform.c: Fixed a difference in processing of
+         xsl:value-of and  xsl:text wrt to merging of strings of
+         output-escaped text-nodes. This difference made the
+         optimized string-merging mechanism run out of sync, which
+         led to segfaults in subsequent string reallocations. See
+         bug #343411, reported by Grzegorz Kaczor.
+       * xslt.c: Added check for ctxt->internalized when we parse
+         xsl:text and internalize the strings.
+
+Mon May 22 10:32:57 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/attributes.c libxslt/documents.c
+         libxslt/extensions.c libxslt/keys.c libxslt/pattern.c
+         libxslt/preproc.c libxslt/templates.c
+         libxslt/transform.c libxslt/variables.c
+         libxslt/xslt.c libxslt/xsltInternals.h:
+         Next tiny step of refactoring - mostly bug fixes and
+         cosmetic changes.
+         Changes outside of the refactored code:
+         1) Optimized xsl:attribute if the content consists of
+          just 1 text node.
+         2) Optimized computation of xsl:key. The keys will now be
+          computed for a specific document not until the first call
+          of a key() function; here only the keys with the specific
+          name used by key() are computed. This means that this
+          now avoids computation of all keys for all loaded
+          input documents (even if no key() was called on them).
+          One exception is the scenario where a key() is used in
+          a template's match pattern; in this case all keys are
+          computed for a document if there's a chance that
+          a "keyed" template could match a node (this could still
+          be optimized a bit).
+
+Mon May 15 22:32:13 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/namespaces.c libxslt/attributes.c:
+         Fixed bug #302020, reported by Thomas Blatter.
+
+Fri May 12 23:23:06 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/documents.c libxslt/namespaces.c
+         libxslt/preproc.c libxslt/transform.c
+         libxslt/xslt.c libxslt/xsltInternals.h libxslt/xsltutils.c:
+         Next step of refactoring. For more details see bug #341588.
+         I applied the suggestion of Jerome Pesenti to the refactored
+         (still IDFEDed out with XSLT_REFACTORED) code: The XPath
+         compilation context (accessible via the compilation context)
+         is now reused for compilation of expressions at
+         compilation-time; this should reduce compilation time to 50%
+         for avarage stylesheets.
+
+Thu May 11 22:12:22 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/extensions.c: Changed a comment to indicate that a
+         specific bug was already fixed.
+         
+Fri May  5 23:10:47 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/xsltInternals.h libxslt/attributes.c
+         libxslt/documents.c libxslt/extensions.c
+         libxslt/extensions.h libxslt/functions.c
+         libxslt/imports.c libxslt/keys.c libxslt/preproc.c
+         libxslt/transform.c libxslt/variables.c libxslt/xslt.c
+         libxslt/xsltutils.c libxslt/xsltutils.h libexslt/functions.c:
+         Next step of refactoring (plus some bug-fixes).
+         For more details see #340780.
+
+Fri May  5 14:31:53 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * tests/exslt/common/node-set.5.out
+         tests/exslt/sets/difference.1.out
+         tests/exslt/functions/function.6.out: Reverting the
+         changes; I'll rather change the processing stylesheet
+         documents in a way that they will produce the same results
+         for broken and stricter whitespace-stripping.
+
+Thu May  4 22:55:26 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * tests/exslt/common/node-set.5.out
+         tests/exslt/sets/difference.1.out
+         tests/exslt/functions/function.6.out: Changed regression test
+         results (bug #340684). Those will now produce regression
+         errors; so we need to fix the processor.
+
+Mon May  1 17:39:27 EDT 2006 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in NEWS doc//*: preparing release of 1.1.16, updated and
+         regenerated the docs.
+
+Tue Apr 25 15:02:42 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: applied patch from Joseph Sacco changing slightly
+         the python detection scheme should fix bug #338527
+
+Wed Apr 12 13:35:45 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/attributes.c libxslt/preproc.c libxslt/transform.c
+         libxslt/variables.c libxslt/xslt.c libxslt/xsltInternals.h
+         libxslt/xsltutils.c libxslt/xsltutils.h:
+         Refactored the internal structures into specialized
+         structures and adjusted the code to work with those new
+         structures. I didn't yet (we should in the future)
+         renamed any fields of the old structures in order to avoid
+         changing too much code.
+         Introduced the internal structure xsltCompilerCtxt to be
+         used for storage and control of the compilation.
+         Optimized the way lists of in-scope namespaces are created
+         and stored; this will now only generate a new list if
+         really needed, i.e. if we encounter a ns-decl.
+         All this changes here are IFDEFed out with XSLT_REFACTORED.
+         
+Thu Apr  6 10:16:59 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * doc/xsltproc.1 doc/xsltproc.xml: applied man page improvement
+         from Daniel Leidert
+
+Thu Mar 30 17:23:52 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * tests/general/bug-36-inc.xsl tests/general/bug-37-inc.xsl
+         tests/general/bug-65-inc.xsl tests/general/bug-100.xsl
+         tests/REC/test-15-1.xsl tests/REC/test-7.1.1-3.xsl
+         tests/namespaces/extra2.xsl tests/extensions/module.xsl
+         tests/plugins/plugin.xsl python/tests/extelem.py
+         python/tests/extfunc.py: Fixed regression tests wrt
+         usage of the attributes "exclude-result-prefixes"
+         and "extension-element-prefixes". test-7.1.1-3.xsl fails
+         now, since the code still does not exclude ns-decls
+         correctly.
+
+Thu Mar 30 17:11:53 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+       * libxslt/xslt.c libxslt/xsltutils.c libxslt/preproc.c
+         libxslt/namespaces.c libxslt/imports.c
+         libxslt/attributes.c: Eliminated usage of xsltGetNsProp() in cases
+         where an attribute with a specific namespace is requested.
+         xsltGetNsProp() uses xmlGetProp() which is not namespace aware
+         and thus will return the first attribute with the requested
+         name but of arbitrary namespace.
+         Changed retrieval of the attributes "exclude-result-prefixes"
+         and "extension-element-prefixes", which are expected to be in
+         no namespace on XSLT elements and in the XSLT namespace on
+         literal result elements or extension elements.
+         Additional change: for XSLT elements the attribute
+         "exclude-result-prefixes" is only allowed on xsl:stylesheet
+         and xsl:transform. This attribute was previously processed on
+         all XSLT elements.
+
+Wed Mar 29 12:16:41 CEST 2006 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: Charles Hardin pointed an OOM condition where
+         a NULL pointer could be dereferenced, closes #336394
+
+Fri Mar 10 12:49:18 CET 2006 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/crypto.c libexslt/date.c libexslt/saxon.c
+         libxslt/attributes.c libxslt/imports.c libxslt/pattern.c
+         libxslt/preproc.c libxslt/transform.c libxslt/variables.c
+         libxslt/xslt.c libxslt/xsltutils.c: various assorted small cleanups
+         based on the Coverity reports
+
+Wed Feb 22 16:09:10 CET 2006 Daniel Veillard <daniel@veillard.com>
+
+       * python/types.c: Nic Ferrier found debug statement left in the
+         XPath conversion code
+
+Tue Feb 21 20:21:07 CET 2006 Daniel Veillard <daniel@veillard.com>
+
+       * doc/xsltproc.1 doc/xsltproc.xml: new update from Daniel Leidert
+
+Tue Feb 21 17:59:11 CET 2006 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extensions.c libxslt/xslt.c libxslt/xslt.h
+         libxslt/xsltInternals.h: applied patch from Christopher R. Palmer
+         to avoid a race condition in xsltInit()
+
+Sun Feb 19 22:40:58 CET 2006 Daniel Veillard <daniel@veillard.com>
+
+       * doc/xsltproc.1 doc/xsltproc.xml: improvement of the man page
+         by Daniel Leidert, c.f. #331779
+
+Sat Feb 11 13:10:01 CET 2006 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltutils.c: fix xsltSaveResultToString comment
+       * libxslt/transform.c: detect loops when computing variables, should
+         fix bug #330772
+       * doc/xsltproc.xml doc/xsltproc.1: fix typo in man page
+       * tests/namespaces/tst7.out tests/general/bug-152.out: small output
+         changes due to libxml2 xhtml meta handling modification
+
+Mon Nov 21 12:22:21 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/date.c: Albert Chin found another signed/unsigned problem
+         in the date and time code raised on IRIX 6.5
+
+Mon Nov 21 12:08:05 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/crypto.c: patch from Albert Chin needed for HP-UX
+         which doesn't have <sys/select.h>
+
+Mon Nov 21 12:05:41 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/date.c: Albert Chin posted a patch to fix a problem on
+         Solaris with dates, extended bitfield size too to match libxml2
+         code from xmlschemastypes.c
+
+Wed Nov 16 12:47:25 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/functions.c: fix an problem raised by Ralf Junker in the
+         use of xmlHashScanFull() fixes bug #321582
+       
+Sun Nov  6 19:22:45 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attrvt.c: added a missing parameter to a debug function
+
+Tue Oct  4 20:37:09 HKT 2005 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/date.c: applied fix to date:week-in-year posted to
+         the mailing list by Thomas Broyer
+       * tests/exslt/date/date.1.out, tests/exslt/date/datetime.1.out:
+         updated to reflect above fix
+
+Sun Oct  2 11:52:44 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in libxslt/Makefile.am libxslt/xsltconfig.h.in
+         libxslt.spec.in tests/plugins/Makefile.am xslt-config.in: applied
+         patch from Joel Reed to ease plugin integration
+
+Thu Sep 22 21:51:22 HKT 2005 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/pattern.c: fixed problem in internal XPath compilation
+         of patterns including variables, fixes #316861
+
+Wed Sep 14 14:30:03 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: removed a superfluous second sorting of
+         the node set on xsl:copy-of, fixes #316288
+       * libxslt/xsltutils.c: marked xsltDocumentSortFunction as slow,
+         obsolete and deprecated :-)
+
+Sat Sep 10 14:35:06 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: check environment for PYTHON, fixes #315367
+
+Mon Sep  5 00:44:24 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in NEWS doc/*: preparing release 1.1.15
+       * libxslt/pattern.c libxslt/xsltutils.c: a bit more cleanup
+
+Mon Sep  5 00:07:40 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: fixed #303289 variable in match are forbidden
+       * tests/general/bug-89.xsl: had to fix that test which was doing this
+       * tests/general/bug-142.out tests/general/bug-152.out
+         tests/namespaces/tst7.out: small output change on libxml2-2.6.21
+         new way of serializing encoding meta in HTML
+
+Wed Aug 31 13:49:51 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixed #314936 a dictionnary issue on text
+         node merging, which probably fixed #311267 too.
+
+Thu Aug 25 13:29:20 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xslt.c: libxslt should deallocate directly text node content
+         use xmlSetNodeContent(..., NULL)
+
+Fri Aug 12 12:17:10 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * tests/general/bug-163.*, tests/general/Makefile.am,
+         tests/docs/bug-163.*, tests/docs/Makefile.am: check fix for
+         #310692
+
+Tue Aug  9 22:13:18 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * tests/plugins/Makefile.am: try to get rid of complaints from
+         jhbuild newbies.
+
+Sun Aug  7 16:04:47 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltutils.c: fixed a bug when size of xmlXPathContext
+         changes, uses the libxml2 alloc and dealloc functions instead.
+
+Tue Jul 13 22:41:03 PDT 2005 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: added check in xsltCopyText to assure
+         content is in dictionary before doing a straight copy of
+         content (bug 302821)
+
+Tue Jul 13 16:16:31 PDT 2005 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: fixed to set current default value for
+         XInclude when creating new TransformContext
+       * libxslt/xslt.c: minor change for per-mille
+
+Sun Jul 10 16:17:53 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltwin32config.h*: try to avoid generating conflicts
+       * libexslt/dynamic.c: applied patch from Mark Vakoc to implement
+         dyn:map
+       * configure.in tests/exslt/Makefile.am tests/exslt/dynamic/*:
+         added test for dyn:map to the regression suite
+
+Sat Jul  2 02:32:24 PDT 2005 <wbrack@mmm.com.hk>
+
+       * libxslt/numbers.c: further fixes for bug 309209, changing
+         behaviour of format-number.
+       * libxslt/xslt.c: changed definition of per-mille character from
+         '?' to Unicode #2030 (UTF-8 '‰') (ref XSLT spec 12.3)
+         
+2005-06-30  Federico Mena Quintero  <federico@ximian.com>
+
+       * libxslt/xsltwin32config.h: Added this file back.  We'll have to
+       figure out a way to make jhbuild not get CVS conflicts with it.
+
+Thu Jun 30 14:09:55 PDT 2005 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/numbers.c: fixed bug in negative prefix (bug 309209)
+       
+2005-06-17  Federico Mena Quintero  <federico@ximian.com>
+
+       * libxslt/xsltwin32config.h: Removed from CVS; this is a generated
+       file anyway and it breaks jhbuild all the time.
+
+Sat May  7 11:28:41 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/libexslt.3: applied patch from Jonathan Wakely to fix
+         the namespace name for the EXSLT date and time functions in the man
+         page.
+
+Wed Apr  6 23:58:12 CEST 2005 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * libexslt/exslt.c libexslt/libexslt.h: Windows build cleanups,
+         removed obsolete checks
+       * libxslt/libxslt.h libxslt/win32config.h libxslt/xsltutils.h: 
+         Windows build cleanups, removed obsolete checks
+       * win32/configure.js: removed obsolete copy operations
+       * win32/Makefile.*: make install cleanup
+       * xsltproc/xsltproc.c: Windows build cleanup, removed obsolete 
+         macro definitions
+       * .cvsignore: added Eclipse project files
+
+Sat Apr  2 13:34:11 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in NEWS doc/*: preparing release of 1.1.14, updated docs
+         and rebuilt.
+
+Thu Mar 31 23:50:43 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docbook/result/fo/gdp-handbook.fo tests/general/bug-105.out
+         tests/general/bug-142.out: updated the result of some tests
+         following the change to serailization in libxml2.
+
+Thu Mar 31 11:54:31 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: fixed bug #171488 with cascading select in
+         patterns.
+       * tests/general/bug-161.*, tests/general/Makefile.am,
+         tests/docs/bug-161.*, tests/docs/Makefile.am: added test provided
+         by Ben Ko
+       
+Thu Mar 31 00:28:38 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * tests/plugins/Makefile.am: fixed build outside of source tree
+         bug #172155 thanks to patch from Mike Castle
+
+Wed Mar 30 14:09:19 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: fixed the xinclude problem with document()
+         as in bug #171893
+       * configure.in tests/Makefile.am tests/xinclude/*: added a new
+         xinclude directory with the test for this problem
+
+Wed Mar 30 11:59:06 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: fixed bug 169718 with ancestors in patterns
+         similar to same bug fixed in libxml2
+       * tests/general/bug-160.*, tests/general/Makefile.am,
+         tests/docs/bug-160.*, tests/docs/Makefile.am: added test provided
+         by Aaron Kaplan
+
+Tue Mar 29 22:35:14 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * tests/general/bug-159.*, tests/general/Makefile.am,
+         tests/docs/bug-159.*, tests/docs/Makefile.am: added test for
+         bug #168196 fixed in libxml2
+
+Tue Mar 29 21:06:11 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: working around Mark Vakoc' reported bug related
+         to mode internaing
+       * xsltproc/xsltproc.c: adding a --nodict mode to check problems with
+         document without a dictionnary.
+       * tests/REC/Makefile.am tests/general/Makefile.am: testing without 
+         dictionnary
+
+Tue Mar 29 15:37:13 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xslt.c: fix bug #165201 when calling xsltInit() multiple
+         times.
+
+Tue Mar 29 15:13:59 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/preproc.c libxslt/xslt.c libxslt/xsltInternals.h: 
+         added DTD like checking when compiling stylesheets, closes
+         bug #160402 and a long term TODO
+       * tests/general/bug-89.xsl: thos spotted a misconstruct of one
+         of the test cases where <xsl:when> was not within <xsl:choose>
+
+Mon Mar 21 20:56:43 MST 2005 John Fleck (jfleck@inkstain.net)
+
+       * doc/xsltproc.xml, xsltproc.html, xsltproc.1:
+       update documentation to reflect addition of --nodtdattr
+       command line flag. Bug #171098
+
+Wed Mar 16 17:19:24 HKT 2005 William Brack (wbrack@mmm.com.hk)
+
+       * libxslt/xslt.c: fixed problem with text node on stylesheet
+         document without a dictionary (bug 170533)
+
+Sun Mar 13 20:08:34 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * NEWS configure.in doc/*: preparing 1.1.13, updated and rebuilt
+         the docs.
+       * tests/plugins/Makefile.am xsltproc/Makefile.am: trying to fix
+         some build problems.
+       * libxslt.spec.in: adding a build require and a require for 
+         libgcrypt-devel, c.f. Red Hat bug #133211
+       * libxslt/xsltInternals.h: as for libxml2, XML_CAST_FPTR was wrong.
+
+Wed Feb 23 19:25:13 HKT 2005 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/pattern.c: fixed a problem with '//' and
+         namespaces (bug 168208)
+
+Mon Feb 14 23:10:21 HKT 2005 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/namespaces.c: fixed a problem with
+         exclude-result-prefixes (bug 165560)
+
+Mon Feb 14 12:51:07 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/variables.c: added a cretion of ctxt->globalVars in
+         xsltProcessUserParamInternal if missing.
+
+Wed Feb  9 21:58:56 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * doc/Makefile.am doc/libxslt-api.xml doc/libxslt-refs.xml 
+         doc/EXSLT/libexslt-api.xml: applied patch for make wiki from
+         Joel Reed and rebuild
+       * tests/plugins/Makefile.am: fix from Joel Reed for make dist
+
+Sun Jan 30 20:01:21 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * tests/plugins/testplugin.c win32/Makefile.msvc win32/configure.js:
+         applied plugin patch for Windows by Joel Reed
+
+Fri Jan 28 01:00:56 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * win32/configure.js: Makefile fixes for Widows from Joel Reed
+
+Sat Jan 22 22:14:26 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c libxslt/preproc.c libxslt/templates.c
+         libxslt/xslt.c libxslt/xsltInternals.h: chasing xmlStrEqual
+         calls and removed them when comparing mode and modeURI for
+         templates by interning those strings when compiling the
+         stylesheets.
+
+Sat Jan 22 19:17:13 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: small fix for local setup
+       * libxslt/transform.c libxslt/variables.c : speeding up some
+         variable lookup. In the process dug out something nasty about
+         ctxt->dict creation and key initialization order.
+
+Sat Jan 22 16:28:27 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/templates.c libxslt/transform.c libxslt/xslt.c
+         libxslt/xsltInternals.h: when copying text nodes in elements
+         or attributes to the output, if interning, then reuse the strings
+         directly without copying them in the output tree if dicts are
+         shared between the context and the output docs. Less allocations
+         smaller output document and no copying involved anymore.
+
+Sat Jan 22 11:24:43 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xslt.c: internalize all text node content from
+         stylesheet documents with the stylesheet dictionnary
+
+Fri Jan 21 12:04:18 HKT 2005 William Brack <wbrack@mmm.com.hk>
+
+       * tests/plugins/Makefile.am: Applied patch 11 (with small
+         modification) from Joel
+
+Thu Jan 20 21:05:27 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * tests/plugins/Makefile.am tests/plugins/testplugin.c: applied
+         patch 10 from Joel Reed
+
+Wed Jan 19 10:08:55 HKT 2005 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xsltwin32config.h, libxslt/xsltwin32config.h.in:
+         fixed a small error in LIBXSLT_VERSION_EXTRA pointed out
+         by Michael.Hewarth on the mailing list
+        
+Wed Jan 19 13:58:16 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: patch #9 from Joel Reed
+
+Wed Jan 19 10:21:37 HKT 2005 William Brack <wbrack@mmm.com.hk>
+
+       * transform.c: fixed problem with parserOptions not being
+         set before loading a new document (bug 164530)
+
+Mon Jan 17 16:50:02 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in libxslt/Makefile.am libxslt/xsltwin32config.h
+         tests/Makefile.am tests/plugins/Makefile.am
+         tests/plugins/testplugin.c: applied another patch from Joel Reed
+         still failing here but looking better
+
+Sun Jan 16 00:09:11 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extensions.c: applied another patch from Joel Reed
+
+Sat Jan 15 13:54:28 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * tests/plugins/plugin.* tests/Makefile.am libxslt/extensions.c
+         libxslt/Makefile.am configure.in: Applied another patch from
+         Joel Reed, fixed a segfault and changed the configure code
+         a bit to work in my debug environment.
+
+Tue Jan 11 10:50:33 HKT 2005 William Brack <wbrack@mmm.com.hk>
+
+       * configure.in: added python2.4 to the list of accepted
+         versions (bug 163274)
+
+Sun Jan  9 17:04:23 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extensions.c: oops previous patch could break build
+
+Sun Jan  9 16:41:59 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in win32/configure.js libxslt/extensions.c
+         libxslt/xsltconfig.h.in libxslt/xsltwin32config.h.in:
+         integrated the module patch from Joel Reed with just a couple
+         of changes and cleanup.
+
+Tue Dec 27 17:50:10 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/pattern.c: fixed a problem with the expression
+         "*//name" (bug 162265), also a small problem with the '|'
+         operator.
+
+Thu Dec 23 16:04:47 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c, libxslt/templates.c: fixed a couple of
+         spots where out-of-memory errors were not detected in time
+         (bug #153660 on OSF/1)
+         
+Thu Dec  2 21:10:31 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       *doc/xslt.html, doc/downloads.html: changed the download link
+        on the web page for cvs snapshot
+        
+Wed Dec  1 22:37:55 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/extensions.c, libxslt/functions.c, libxslt/numbers.c,
+         libxslt/pattern.c, libxslt/transform.c, libxslt/xslt.c,
+         libxslt/xsltInternals.h: minor changes to get rid of gcc
+         warnings, especially on 64-bit system. Implemented
+         XML_CAST_FPTR macro to cast between function pointer <->
+         object pointer while avoiding gcc warnings (a hack).
+         No change to the logic.
+
+Wed Dec  1 10:47:15 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/security.c xsltproc/xsltproc.c: applied patch from
+         Aleksey Gurtovoy moving some stat() definition for Windows
+         to the right place.
+
+Wed Dec  1 14:30:22 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xslt.c: applied patch from Mark Vakoc fixing bug with
+         namespace URI on template names.
+       * tests/namespaces/tst9*, tests/namespaces/Makefile.am: added
+         test case for this
+
+Tue Nov 30 10:53:18 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/pattern.c: more on RVT's in XPath predicates, this
+         time for bug 159726.  Cleaned up the logic a little, hopefully
+         now covers all setting of XSLT_RUNTIME_EXTRA.
+       * tests/general/bug-158.xsl: corrected a typo
+
+Thu Nov 25 22:24:03 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/variables.c, libxslt/xsltInternals.h: backed out the
+         last change and re-did it the "right way" (bug 158372).
+       * tests/general/bug-158.*, tests/general/Makefile.am,
+         tests/docs/bug-158.*, tests/general/Makefile.am: added test
+         case for this bug
+
+Wed Nov 24 10:51:51 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/variables.c, libxslt/xsltInternals.h: enhanced the
+         evaluation of global variables to take account of possible
+         changes to the current document (bug 158372).
+         
+Mon Nov 22 08:10:18 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/pattern.c: small change to previous fix for bug 153137,
+         fixes bug 158840.
+       * tests/general/bug-157.*, tests/general/Makefile.am,
+         tests/docs/bug-157.*, tests/docs/Makefile.am: added test for this
+
+Sun Nov 21 09:42:22 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: enhanced code to assure the "current
+         template rule" is not changed by xsl:call-template (bug 157859).
+       * tests/general/bug-156.*, tests/general/Makefile.am,
+         tests/docs/bug-156.*, tests/docs/Makefile.am: added a test case
+         
+Mon Nov  8 11:41:32 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/date.c: fixed problem with day-of-week-in-month
+         (bug 157592) with patch from Sal Paradise
+       * tests/exslt/date/datetime.1.out: corrected expected output
+         after above fix
+
+Mon Nov  1 15:57:24 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * tests/general/bug-155.*, tests/general/Makefile.am,
+         tests/docs/bug-155*, tests/docs/Makefile.am: added a test case
+         provided by Markus Bertheau breaking on libxml2-2.6.15
+
+Fri Oct 29 17:03:26 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in NEWS doc/*: preparing release of libxslt-1.1.12
+       * libexslt/crypto.c: mini change to avoid breaking apibuild.py
+       * libxslt/templates.c: small fix, first step in adressing #153660
+
+Fri Oct 29 14:18:35 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * doc/xsltproc.1 doc/xsltproc.xml: indicate - means stdin closing
+         #156626
+
+Wed Oct 27 17:00:54 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: another dictionnary/string interning fix
+
+Wed Oct 27 00:00:07 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fix to force string interning on generated
+         documents
+
+Sat Oct 23 09:36:12 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/crypto.c, libexslt/functions.c, libxslt/keys.c,
+         libxslt/numbers.c, libxslt/pattern.c, libxslt/transform.c,
+         libxslt/variables.c: changed some variable names for warning
+         cleanup when -ansi flag is not present.
+       * libxslt/namespaces.c: fixed potential NULL pointer reference
+         pointed out by Dennis Dams (bug 156187)
+
+Mon Oct 18 17:04:27 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt.spec.in doc/Makefile.am: fix for RedHat bug #136072
+         to include EXSLT doc in libxslt package.
+
+Thu Oct 14 22:43:22 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * configure.in, config.h.in, libexslt/date.c: changed date.c to use
+         gmtime_r if available (bug 129983)
+       * libexslt/functions.c: fixed a namespace problem concerning a
+         function with a namespace-qualified name (bug 155197)
+
+Tue Oct 12 03:54:44 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/namespaces.c: fixed a bug in namespace lookup exhibited
+         by the recent namespace tests in libxml2
+
+Thu Oct  7 16:15:15 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixed a problem of tree structure raised
+         by the new libxml2 tree checking code.
+
+Thu Sep 30 11:28:03 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/date.c: fixed problem with negative periods
+         (bug 154021)
+       * tests/exslt/date/sum.2.out: changed expected output, now
+         agrees with comments in sum.2.xml test data file
+         
+Thu Sep 30 08:19:28 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/templates.c: patch from Mark Vakoc about an incorrect
+         attribute document pointer.
+
+Thu Sep 30 08:13:57 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * doc/tutorial2/libxslt_pipes.*: updated the tutorial from Panagiotis
+         Louridas
+
+Thu Sep 30 00:10:09 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in doc/*: release of 1.1.11, rebuilt the docs
+
+Wed Sep 29 15:42:33 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: try to fix #153137 but without a test case
+         it's shooting in the dark.
+
+Tue Sep 28 16:20:48 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * doc/tutorial2/libxslt_pipes.*: New tutorial from Panagiotis Louridas
+       * libxslt.spec.in doc/Makefile.am: integrated the tutorial in the
+         distribution
+
+Sat Sep 25 21:38:57 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/preproc.c libxslt/variables.c: fixed 2 leaks with
+         namespaced variable names.
+       * tests/general/bug-154.*, tests/general/Makefile.am,
+         tests/docs/bug-154*, tests/docs/Makefile.am: added test case
+         for above
+
+Fri Sep 24 18:13:45 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * Makefile.am: add missing variable
+       * libxslt/transform.c: fixed some error callback data
+       * tests/exslt/date/Makefile.am tests/exslt/date/sum*: added new
+         date:sum testing from Derek Poon
+
+Fri Sep 24 09:17:22 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/date.c: fixed problem with empty sets, etc.
+         (see discussion on mailing list)
+
+Sat Sep 18 17:08:31 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/date.c: fixed problem with timezone offset
+         (bug 153000)
+       * tests/exslt/date/add.1.out: changed regression test output,
+         which was apparently incorrect for above case
+
+Sat Sep 18 00:04:02 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: re-arranged sequence of setting up
+         namespaces within xsltCopyTree (see the list thread
+         http://mail.gnome.org/archives/xml/2004-September/msg00072.html)
+       * tests/general/bug-104.out: slight change to expected output
+         due to above fix
+
+Fri Sep 17 23:15:33 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/date.c: enhanced validation of date-time to catch
+         bit-field overflow (bug 152836)
+       * tests/exslt/date/date.2.*, tests/exslt/time.2.*: added test
+         cases for above
+
+Tue Sep  7 18:04:55 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/numbers.c: further refinement to UTF8 pattern
+         separator (bug 151975)
+
+Tue Sep  7 00:14:12 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/numbers.c: fixed problem with UTF8 pattern
+         separator (bug 151975)
+
+Mon Sep  6 14:27:38 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/imports.c, libxslt/xslt.c, libxslt/xsltInternals.h:
+         fixed 2 problems with xsl:include (bug #151795)
+
+Tue Aug 31 15:45:42 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * NEWS configure.in doc/*: Release of libxslt-1.1.10
+
+Tue Aug 31 11:41:11 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * doc/xsltproc.1 doc/xsltproc.xml: added missing descriptions
+         for --path as well as --load-trace, fixes Red Hat bug #106545
+
+Fri Aug 27 20:52:52 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/keys.c: fixed small problem with key initialisation
+         disturbing the transformation context (bug 151201).
+       * tests/general/bug-153.*, tests/general/Makefile.am,
+         tests/docs/bug-153*, tests/docs/Makefile.am: added test case
+         for above
+
+Tue Aug 24 16:40:51 CEST 2004 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * win32/configure.js: added support for version extra
+
+Mon Aug 23 16:53:02 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/date.c libxslt/imports.c libxslt/xslt.c: fixing 
+         compilation problems on Solaris #150844
+
+Sun Aug 22 17:19:49 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in NEWS doc/*: preparing release of 1.1.9
+
+Sat Aug 21 22:08:14 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * transform.c: Further enhancement for keys on exslt:node-sets.
+         Corrects a rather serious timing problem (bug 150741)
+       * tests/exslt/common/node-set.8.*: added regression test for this
+
+Fri Aug 20 18:53:50 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * Makefile.am configure.in: a bit of cleanup and a extra variable for
+         CVS dist
+
+Fri Aug 20 11:30:19 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/imports.c: fix a 64bit bug reported by Andreas Schwab
+
+Wed Aug 18 14:27:18 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * configure.in libxslt/xsltconfig.h.in libxslt/xslt.c
+         libxslt/xsltwin32config.* libexslt/exsltconfig.h.in
+         libexslt/exslt.c: added some code to include the CVS
+         ChangeLog version in the version strings available for
+         printing (e.g. by xsltproc)
+
+Wed Aug 18 00:22:00 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: implemented --nodtdattr to avoid defaulting
+         DTD attributes, RFE 150311 . Also cleanup the code from all
+         libxml2 pre 2.6.0 specific code since we are using 
+         LIBXML_REQUIRED_VERSION=2.6.8 in configure.in
+
+Tue Aug 17 01:01:22 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/documents.c libxslt/documents.h libxslt/imports.c
+         libxslt/xslt.c libxslt/xsltutils.c: Implemented a hook to
+         provide document loading as suggested by David Hyatt for
+         Safari
+
+Mon Aug 16 12:53:55 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: added a call to xmlXPathOrderDocElems
+         in xmlNewTransformContext for the principal document (bug 133289)
+
+Sat Aug 14 21:49:48 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/namespaces.[ch], transform.c, xslt.c, xsltInternals.h:
+         fixed handling of #default in namespace-alias for default
+         namespace (bug 149659)
+       * tests/namespaces/tst7.* tst8.*: added regression tests for above
+
+Fri Aug  6 11:05:31 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/date.c: added date:sum routine supplied by Joel
+         Reed
+
+Wed Aug  4 00:04:13 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * doc/downloads.html doc/xslt.html: fixed a couple of problems
+         reported by Oliver Stoeneberg
+               
+Mon Aug  2 08:48:03 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/documents.c, libxslt/functions.c, libxslt/transform.c,
+         libxslt/variables.c: added code to assure keys are generated
+         when needed for node-sets (bug 148773)
+       * tests/exslt/common/node-set.7.* - added test case for above.
+
+Mon Jul 26 17:03:22 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/strings.c: fixed str:tokenize for case when 2nd
+         argument is an empty string (should produce a token for
+         each char in the string).  Reported on the mailing list by
+         Peter Pawlowski.
+
+Fri Jul 23 21:55:14 PDT 2004 William Brack <wbrack@mmm.com.hk>
+       * libxslt/imports.c: further enhancement for template priorities
+         on imported stylesheets (better fix for bug 141279, fixes
+         bug 148246).
+
+Fri Jul 16 12:14:57 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in libexslt/crypto.c libexslt/exslt.[ch] 
+         libexslt/exsltconfig.h.in win32/configure.js: apply patch from
+         Rob Richards to add a normal --with-crypto configure option.
+
+Tue Jul 13 22:57:43 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/functions.c: added some logic to xsltKeyFunction
+         to set the transform context doc ptr when the xpath context
+         doc is different (bug 147445)
+       * tests/exslt/common/Makefile.am, tests/exslt/common/node-set.5*
+         and tests/exslt/common/node-set.6*: added regression tests
+         for bug 145547 (UNION and FILTER for RVT's)
+
+Mon Jul 12 08:28:07 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * python/libxslt-python-api.xml: fixed type for doctypeSystem
+         and doctypePublic (problem reported on the list by Sitsofe
+         Wheeler)
+       * doc/libxslt-api.xml: updated database.
+
+Sun Jul 11 22:46:31 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * transform.c: small change to key handling for RVT, needed
+         because of enhancement to libxml2 xpath.
+
+Fri Jul  9 02:51:38 PDT 2004 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxsl.py: fixes Python on 64bits box problem.
+
+Tue Jul  6 18:43:37 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt.spec.in: better python dependancy Red hat bug #126364
+         by Robert Scheck
+
+Tue Jul  6 21:35:44 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * tests/namespaces/Makefile.am: added extra2.err, tst5.xml,
+         tst5.xsl and tst.out to EXTRA_DIST
+
+Mon Jul  5 21:48:13 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in doc/*: releasing 1.1.8
+
+Sun Jul  4 24:18:12 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * xsltproc/Makefile.am: changed the sequence of LD_ADDS and
+         LIBGCRYPT_LIBS on xsltproc_LDADD.  Previously this was
+         causing the wrong libs to be linked when using the configure
+         option --with-libxml-libs-prefix, or --with-libxml-src (nasty)
+
+Sun Jul  4 21:42:48 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/Makefile.am: implemented change from Joel Reed for
+         automake-1.4 compatibility.
+       * libexslt/crypto.c: reformatted source to remove an overly
+         generous supply of tabs.  Added a #include for sys/select to
+         fix a compilation error caused by the gcrypt include file's
+         usage of 'fd_set'.  Made some minor changes to fix
+         some warning messages (no change to the logic).
+       * configure.in, config.h.in: added test for presence of
+         sys/select.h.
+         Added test for libgcrypt version > 1.1.41 (bug 145245)
+         
+Sat Jul  3 17:52:27 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * doc/xslt.html, doc/extensions.html: corrected the URI for libxslt
+         namespace, also a small enhancement of the surrounding text on
+         extension functions. (bug 145250)
+         
+Fri Jul  2 15:51:49 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: convenience change
+       * python/libxsl.py python/libxslt-python-api.xml python/libxslt.c:
+         try to avoid calling libxml2 cleanup function directly but go
+         though the python wrapper of libxml2 for memory debug accounting.
+
+Fri Jul  2 16:24:12 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/keys.c: added namespace setup before calling XPath
+         to evaluate key (Bug 143520)
+
+Thu Jul  1 10:07:55 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: added coding to xsltCopyTree to copy
+         namespaces (bug 139578).
+       * tests/general/bug-128.out: changed to reflect above fix
+       * libxslt/xslt.c: minor change to an error message
+
+Wed Jun 30 18:41:20 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * win32/Makefile.msvc win32/Makefile.mingw libexslt/Makefile.am
+         libexslt/exslt.c libexslt/exslt.h config.h.in configure.in
+         libexslt/crypto.c: applied patch from Joel Reed to get EXSLT
+         crypto extensions based on libgcrypt if found at configure time.
+       * tests/namespaces/Makefile.am: fixed a small breakage
+
+Wed Jun 30 12:28:34 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/namespaces: some enhancement for fixing bug 142768
+       * tests/namespaces/Makefile.am, tests/namespaces/tst6*:
+         added regression test for this bug
+
+Tue Jun 29 09:23:03 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * Makefile.am examples/xsltICUSort.c: seems I never commited to CVS
+         the example from Richard Jinks
+
+Wed Jun  9 16:33:56 CEST 2004 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * win32/configure.js win32/Makefile.* minor changes for the new
+         layout of the Windows binary package
+
+Wed May 26 10:51:22 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * doc/search.php.inc, doc/search/php: enhanced to remove
+         forcing module names to lower case, and to fix problem
+         with links between pages in libxml2 directory.
+
+Mon May 24 12:46:10 HKT 2004 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * win32/makefile.msvc, win32/configure.js: included the cruntime 
+         option, contributed by Oliver Stoeneberg
+
+Mon May 24 08:37:22 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xsltutils.c: fixed bug in error message printing
+         for undefined namespace (bug 143004)
+
+Mon May 17 23:08:42 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * NEWS doc/*: updated for 1.1.7
+
+Mon May 17 06:14:09 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: release of libxslt-1.1.7
+
+Sun May 16 23:08:05 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * tests/general/bug-151*, tests/docs/bug-151.xml,
+         tests/general/Makefile.am, tests/docs/Makefile.am: added
+         regression test for old bug #127877
+
+Sun May 16 20:48:35 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixing bug #135542 about the DOCTYPE name
+         being generated when the root element is namespaced 
+       * tests/general/bug-151*, tests/docs/bug-151.xml,
+         tests/general/Makefile.am, tests/docs/Makefile.am: added
+         regression test for bug #135542
+
+Sun May 16 19:39:44 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/namespaces.c libxslt/namespaces.h libxslt/templates.c
+         libxslt/transform.c: fixing bug #134500 on namespace lookup for
+         attribute which sometimes lead to default namespace
+       * tests/general/bug-150*, tests/docs/bug-150.xml,
+         tests/general/Makefile.am, tests/docs/Makefile.am: added
+         regression test for bug #134500
+
+Sun May 16 18:09:36 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/date.h: fixing a small portability problem on Solaris
+         for the declaration of localtime_r bug #140468
+
+Sun May 16 16:36:38 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt.m4: applied patch from Edward Rudd to fix the problems
+         raised in bug #142429
+         
+Sun May 16 11:01:52 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xslt.c: fixed a weird namespace bug #141532
+       * tests/docs/Makefile.am tests/docs/bug-14[89].xml
+         tests/general/Makefile.am tests/docs/bug-14[89]*: added tests
+         to the regression for bug #141532
+
+Sun May  2 23:47:43 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/imports.c: added comments and function header,
+         improved logic of routine just added.
+       * tests/general/bug-147*, tests/docs/bug-147.xml,
+         tests/general/Makefile.am, tests/docs/Makefile.am: added
+         regression test for bug 141279
+
+Sun May  2 12:47:32 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/imports.c: enhanced normalization of comp steps
+         when an imported stylesheet has it's own imports
+         (bug 141279)
+
+Sat May  1 10:35:03 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: added code to recognize
+         disable-output-escaping on certain text nodes (bug 140755)
+       * tests/general/bug-100.out: regenerated to account for change
+         from next ChangeLog entry (bug 140558)
+
+Wed Apr 28 18:17:24 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xsltutils.c: suppressed any automatic linefeed after
+         a comment following the document root element (bug 140558)
+
+Thu Apr 22 08:38:35 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fix a problem where we updated an
+         ELEMENT node psvi field as if it was a DOCUMENT one, leading
+         to a subtle crash later, valgrind rules.
+
+The Apr 20 00:22:37 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/strings.c: fixed bug in UTF8 string tokenize
+         kindly reported by Vasily Tchekalkin
+
+Mon Apr 19 00:39:18 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in doc/*: preparing release 1.1.6
+       * libxslt.spec.in: keep the ChangeLog compressed 
+
+Mon Apr  5 15:23:53 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/keys.c: fixed a stupid cut'npaste bug #139132
+       * tests/docs/Makefile.am tests/docs/bug-146.xml
+         tests/general/Makefile.am tests/docs/bug-146*: added test
+         to the regression for bug #139132
+
+2004-04-02 10:17:23 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/keys.c: applied patch from Mark Vakoc to fix problem
+         with key matching attribute node.
+
+2004-04-01  Johan Dahlin  <johan@gnome.org>
+
+       * python/.cvsignore: Add generated files, to make cvs silent.
+
+       * .cvsignore: Add missing libexslt.pc and stamp-h1
+
+Tue Mar 23 13:13:56 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: prepare release of 1.1.5, made a hard dependancy
+         to libxml2 2.6.8 due to the dictionnary reference counting change
+       * doc/*: updated and rebuilt the doc.
+       * tests/namespaces/Makefile.am: fixed a build problem (tst5 ?)
+
+Mon Mar 22 20:25:41 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltconfig.h.in: small fix for OpenVMS
+       * libxslt/documents.c: fixed a leak associated to the change
+         in reference counting when running the XML parser and using
+         the document() function.
+
+Wed Mar 17 18:49:55 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * xsltproc/xsltproc.c: added check for state XSLT_STATE_STOPPED
+         when output file is used (bug 137341)
+         
+Tue Mar 16 08:55:18 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xsltutils.c: corrected my error from bug 135938
+         pointed out on the mailing list by Mark Vakoc.
+       * libxslt/transform.c: enhanced the error message for
+         call-template when namespace is present.
+       * tests/general/bug-145.err: regenerated for new message
+
+Fri Mar 12 13:07:03 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/namespaces.c: added additional check to prevent
+         superfluous namespace href's being generated on elements
+         (bug 136914)
+       * tests/namespaces/Makefile.am, tests/namespaces/tst5.x[ms]l:
+         added new test for bug 136914
+       * tests/namespaces, tests/extensions/ tests/reports: fixed
+         error in "enhanced" Makefile.am, removed superfluous .err files
+         from cvs
+
+Wed Mar 10 19:27:39 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * doc/search.php.incl: minor addition for later version of php
+         requiring $HTTP_GET_VARS.
+         doc/*: rebuilt the docs
+
+Wed Mar 10 17:14:13 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/strings.c: modified the 'tokenize' routine to work with
+         UTF8 chars in both string and tokens (Bug 136183)
+
+Tue Mar  9 23:44:31 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/attrvt.c: added coding to allow growing the
+         AVT structure when a large number of segments are present
+         (bug 136624)
+       * libxslt/keys.c: fixed a compilation warning (no logic change)
+
+Sat Mar  6 23:42:47 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * tests/docbook/Makefile.am: small fix to typo
+
+Sat Mar  6 23:05:11 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * Makefile.am, tests/Makefile.am, tests/REC/Makefile.am,
+         tests/REC1/Makefile.am, tests/REC2/Makefile.am,
+         tests/XSLTMark/Makefile.am, tests/docbook/Makefile.am,
+         tests/exslt/common/Makefile.am, tests/exslt/date/Makefile.am,
+         tests/exslt/functions/Makefile.am, tests/exslt/math/Makefile.am,
+         tests/exslt/sets/Makefile.am, tests/exslt/strings/Makefile.am,
+         tests/extensions/Makefile.am, tests/general/Makefile.am,
+         tests/keys/Makefile.am, tests/multiple/Makefile.am,
+         tests/namespaces/Makefile.am, tests/numbers/Makefile.am,
+         tests/reports/Makefile.am, test/xmlspec/Makefile.am,
+         tests/general/bug-60.err, tests/docbook/result/html/gdp-handbook.err,
+         tests/REC/test-2.5-1.err:
+         Major enhancement to "make tests". All but Python tests
+         cleaned up to produce minimum summary output if no problems.
+       * tests/general/bug-145.xsl, tests/general/bug-145.err,
+         tests/docs/Makefile.am, tests/docs/bug-145.xml:
+         Added test case for bugzilla bug 135938
+         
+Thu Mar  4 23:02:18 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xsltutils.h, libxslt/xsltutils.c, libxslt/preproc.c:
+         fixed problem with dictionary handling (bug 135938).
+       * doc/EXSLT/*: fixed a few more "href_base" files.
+
+Wed Mar  3 21:33:33 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * doc/*, doc/html/*, doc/EXSLT/*: rebuilt the docs to fix
+         the "href_base" problem.
+
+Fri Feb 27 01:04:47 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * configure.in, config.h.in: added test for localtime_r
+       * libexslt/date.c: added usage of localtime_r if present on
+         system (bug 129983, suggested by Vasily Tchekalkin)
+
+Thu Feb 26 16:59:45 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/keys.c libxslt/pattern.c: removed the last use
+         of _private that time in the input document, use the psvi
+         field again, this may be interesting if XSLT2 support gets
+         in but since this is very unlikely ...
+
+Thu Feb 26 16:04:28 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c libxslt/variables.c: use the psvi field
+         of teh document used for RVT instead of _private. 
+
+Thu Feb 26 15:17:52 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attrvt.c libxslt/templates.c: use the psvi field of
+         the attribute instead of the _private one to compile AVT infos
+
+Thu Feb 26 14:53:16 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-144.xml
+         tests/general/Makefile.am tests/docs/bug-144*: added test
+         similar to 143 but checking for AVT in local variables.
+       
+Thu Feb 26 13:16:33 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attrvt.c libxslt/variables.c: fixed a regression for
+         AVT found in global variable content.
+       * tests/docs/Makefile.am tests/docs/bug-143.xml
+         tests/general/Makefile.am tests/docs/bug-143*: added test
+         to the regression suite.
+
+Wed Feb 25 16:35:01 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attributes.c libxslt/keys.h libxslt/preproc.c 
+         libxslt/transform.c libxslt/variables.c libxslt/xsltutils.c:
+         First step toward _private cleanup: use the psvi field to store
+         the precompilation informations in the stylesheet nodes.
+
+Wed Feb 25 14:24:34 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/variables.c: trying to use the fact that names comes
+         from a dictionnary when looking up for variables.
+       * tests/documents/Makefile.am: try to fix an error reported on
+         the list.
+
+Wed Feb 25 17:02:22 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * tests/general/Makefile.am, tests/general/bug-142.xsl,
+         tests/general/bug-142.out, tests/docs/Makefile.am,
+         tests/general/bug-142.xml: added test for language
+         attribute which previously triggered a memory leak
+         (from list report by Mike Hommey)
+
+Mon Feb 23 18:01:44 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * NEWS configure.in doc/*: preparing release 1.1.4, updated and
+         regenerated the documentation
+
+Tue Feb 24 00:37:28 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xsltutils.c, libxslt/templates.c, libxslt/preproc.c:
+         minor changes to eliminate compilation warnings.  No change
+         to logic.
+
+Sun Feb 22 23:59:12 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/exsltexports.h libxslt/xsltexports.h: patches from
+         Mikhail S Grushinskiy to compile on Mingw
+
+Sat Feb 21 16:47:04 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * win32/Makefile.msvc: patch from Mark Vadoc for attrvt.c
+
+Wed Feb 18 13:32:55 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extensions.c: applied patch from Steve Little to 
+         display the extension modules.
+
+Wed Feb 18 11:40:23 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: trying to fix an extension regression pointed
+         out on the list.
+
+Tue Feb 17 12:20:26 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: try to fix the problem with yelp
+         and dictionnaries
+
+Tue Feb 17 11:29:15 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/templates.c: applied patch from #134588 provided by
+         Mariano Suárez-Alvarez, attribute text node without doc.
+
+Mon Feb 16 15:55:57 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in, doc/*: updated and rebuilt the documentation
+         preparing release of 1.1.3
+       * libxslt/attrvt.c libxslt/xsltInternals.h: cleanup
+
+2004-02-15  Tomasz KÅ‚oczko <kloczek@pld.org.pl>
+
+       * libxslt.m4: small fix: added missing [] quotation macro name
+         defined in AC_DEFUN(). Fix is neccessary for aclocal from automake
+         1.8.x and is backward compatible with older auto tools.
+
+Sun Feb 15 23:01:09 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attrvt.c libxslt/templates.c: removed the two last
+         known bug with the new code, was overoptimizing a bit...
+
+Sun Feb 15 19:57:20 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attrvt.c: found the memory leak shown in DocBook,
+         mostly an error handling some ATV coupled with doctionnaries
+         reference counting.
+       * libxslt/documents.c libxslt/transform.c libxslt/variables.c
+         libxslt/xslt.c: added a bit of debug to be able to trace 
+         dictionnaries.
+
+Fri Feb 13 16:59:46 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attrvt.c libxslt/Makefile.am: added new code to handle
+         attribute value templates
+       * libxslt/*.c libxslt/*.h: also a lot of work to reuse the 
+         dictionaries at the stylesheet and transformation level.
+       * configure.in: this relies on a recent version of libxml2 
+         with the sub dictionnary catalog.
+
+Sun Feb  8 16:53:14 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: added check for "?>" in PI content
+         (Bug 133726)
+
+Sat Jan 31 02:43:45 PST 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/namespaces.c: fixed problem with attribute
+         namespace (Bug 132953)
+
+Thu Jan 29 14:47:22 PST 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: added check for "--" or ending '-'
+         in xsl:comment (Bug 132742)
+
+Thu Jan 29 14:08:31 PST 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c, libxslt/attributes.c: added
+         validation of QName for xsl:element and xsl:attribute
+         (Bug 132531)
+
+Fri Jan 23 18:52:22 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/pattern.c: changed priority of template patterns
+         starting with '//' from 0.0 to 0.5 (Bug 131705)
+
+Thu Jan 22 18:42:03 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xslt.c: applied patch from Stefan Kost to fix
+         behaviour on unknown element from the XSLT namespace.
+       * python/generator.py: applied patch from Stephane bidoul
+         to export enums in the bindings.
+
+Thu Jan 22 10:35:14 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * tests/general/Makefile.am, tests/general/bug-141.out,
+         tests/general/bug-141.xsl, tests/docs/Makefile.am,
+         tests/general/bug-141.xml: added test case for
+         Bug 13971 (libxml2 xpath.c bug, but tested here)
+
+Fri Jan 16 22:15:34 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xsltutils.c: added a newline for any comment before
+         the root element (Bug 130433)
+       * libxslt/xslt.c: fixed problem with cdata-section-elements when
+         default namespace is changed (Bug 130793)
+       * tests/extensions/module.out, tests/general/bug-100.out: adjusted
+         for newline after comment change above.
+       * tests/general/Makefile.am, tests/general/bug-140.xsl,
+         tests/general/Makefile.am, tests/docs/bug-140.xml: added test for
+         cdata-section-elements problem.
+
+Wed Jan 14 16:44:58 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxsl.py: applied shared lib loading patch for OS X from
+         Gianni Ceccarelli
+
+Wed Jan 14 14:28:02 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/math.c, libexslt/common.c: fixed problem,
+         reported on the list by Markus Bayerlein, concerning
+         math functions on nodesets generated with
+         exslt:node-set
+       * tests/exslt/math/max.3.xsl, tests/exslt/math/max.3.xml,
+         tests/exslt/math/max.3.out, tests/exslt/math/Makefile.am:
+         added test case for above.
+
+Tue Jan 13 00:33:50 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: changed to assure comment which
+         preceeds root node is output after DTD (Bug 130433)
+       * test/exslt/common/node-set.4.*: added test case for
+         Bug 130922
+
+Mon Jan 12 12:51:45 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * doc/site.xsl: Changed logo spacing to avoid stacking
+       * doc/*: rebuilt web pages
+
+Sun Jan 11 20:10:09 MST 2004 John Fleck <jfleck@inkstain.net>
+
+       * doc/site.xsl
+       * doc/w3c.png
+       * doc/*
+       Test William's new site.xsl improvements by adding the
+       W3C logo icon, rebuild docs, and presto! It shows up
+       everywhere!
+
+Mon Jan 10 08:33:18 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: Refined wrapper code with large
+         test case submitted by Norm Walsh. (Bug 130922)
+
+Sun Jan 10 23:33:21 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: Added coding to create a xsltDocument
+         wrapper for an RVT, in order to produce the applicable
+         keys (Bug 130922)
+
+Sat Jan  9 17:04:38 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * doc/search.xml, doc/search.templ, doc/Makefile.am,
+         doc/search.php.inc: Added new facility to "autogen"
+         the search script.  Fixed a few more problems with
+         the API page generation.
+       * doc/site.xsl, doc/api.xsl, doc/newapi.xsl: integrated
+         the autogeneration of the php script.  Note that from
+         this point doc/search.php will be include in the
+         generic "Rebuilt docs".
+       * doc/*: api docs rebuilt.
+       
+Fri Jan  8 08:32:55 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * doc/site.xsl, doc/api.xsl, doc/newapi.xsl, doc/search.php:
+         Further cleanup, fully implemented common routine for
+         "generic page" within the docs.
+       * doc/*: api docs rebuilt with enhanced scripts.
+
+Thu Jan  8 06:45:04 MST 2004 John Fleck <jfleck@inkstain.net>
+
+       * doc/xslt.html, doc/bugs.html
+       made link to bugzilla more useful
+
+Wed Jan  7 20:12:14 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * doc/api.xsl, doc/site.xsl, doc/search.php: a little
+         cleanup of scripts, assuring page tables are consistent.
+       * doc/*: api docs rebuilt with enhanced scripts.
+
+Tue Jan  6 23:38:47 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * configure.in: fixed Bug130593.
+       * doc/apibuild.py: fixed a couple of sequence problems on
+         references within APIxxx.html files, rebuild doc/* (and NEWS)
+
+Sun Jan  4 19:06:59 MST 2004 John Fleck <jfleck@inkstain.net>
+
+       * doc/newapi.xsl: change background color of function
+       declaration to improve readability
+       * doc/*: rebuild docs with new stylesheet
+
+Fri Jan  2 21:42:49 MST 2004 John Fleck <jfleck@inkstain.net>
+
+       * libxslt/transform.c: fix bad doc comment formatting on 
+       xsltDebugSetDefaultTrace and xsltDebugGetDefaultTrace
+       * doc/*: rebuild docs
+
+Wed Dec 24 15:15:52 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in doc/*: prepared release of libxslt-1.1.2
+       * libxslt.spec.in doc/Makefile.am: some tweaking following the
+         new EXSLT docs.
+
+Mon Dec 22 20:33:08 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxlst/numbers.c: fixed xsl:number level="any" for Bug
+         129057
+
+Sun Dec 21 21:38:11 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/numbers.c: added namespace comparison for
+         xsl:number count function (Bug 129057)
+
+Sun Dec 21 13:56:48 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-139.xml
+         tests/general/Makefile.am tests/general/bug-139*: added
+         test for entities parsing (Bug #129489)
+
+Sun Dec 21 20:33:27 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * tests/docs/Makefile.am tests/docs/bug-138.xml
+         tests/general/Makefile.am tests/general/bug-138*: added
+         test for namespace problem (Bug #129624)
+
+Sun Dec 21 13:17:05 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc.c: fixed #129327 make sure parser flags get transmitted to
+         the transformation context
+       * libxslt/documents.c libxslt/transform.c libxslt/xsltInternals.h 
+         libxslt/xsltutils.c libxslt/xsltutils.h: add a new call
+         xsltSetCtxtParseOptions() to update parsing options in document()
+
+Sun Dec 21 12:51:12 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/keys.c: fixed second problem on #122483, namespace
+         definitions must be propagated to keys.
+       * tests/docs/Makefile.am tests/docs/bug-137.xml
+         tests/general/Makefile.am tests/docs/bug-137*: added test
+         to the regression for bug #122483
+       
+Sun Dec 21 12:08:45 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: added the cast needed to fix #129188 warning
+
+Sat Dec 20 23:37:31 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/transform.c: fixed Bug 129624 (erroneous output
+         of namespaces)
+
+Sat Dec 20 16:22:11 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/date.c: fixed several routines to assure empty
+         string returned (rather than a string object with a null
+         string pointer) (Bug 129561)
+
+Mon Dec 16 00:30:47 PST 2003 William Brack <wbrack@mmm.com.hk>
+
+       * doc/Makefile.am doc/site.xsl doc/api.xsl doc/newapi.xsl
+         doc/xslt.html doc/apibuild.py doc/EXSLT doc/EXSLT/exslt.html:
+         enhanced documentation to include exslt; rebuilt docs
+         
+Mon Dec 15 20:33:52 MST 2003 John Fleck <jfleck@inkstain.net>
+
+       * libxslt/xsltutils.h
+       * doc/*
+       document XSLT_TRACE macro (sort of) and rebuild docs
+
+Thu Dec 11 19:50:41 CET 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * win32/Makefile.mingw win32/configure.js: tried to fix mingw
+         build, no success, it still works halfway.
+
+Thu Dec 11 16:33:41 CET 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * win32/Makefile.* win32/configure.js libxslt/xsltexports.h
+         libexslt/exsltexports.h libxslt/win32config.h: msvc and
+         mingw compilation fixes.
+
+Wed Dec 10 20:37:46 MST 2003 John Fleck <jfleck@inkstain.net>
+
+       * doc/xslt.html docs.html
+       remove reference to gtk-doc
+
+Wed Dec 10 17:20:27 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in NEWS doc/*: updated the docs, made release 1.1.1
+
+Wed Dec 10 16:13:38 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: upp'ed the dependancy to libxml2-2.6.3
+       * libxslt/documents.c xsltproc/xsltproc.c: fixed #127473
+         by using the new XInclude APIs provided by 2.6.3...
+
+Mon Dec  8 23:34:32 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c, libxslt/xslt.c: modified to assure
+         XML_CDATA_SECTION_NODE's do not have xmlStringTextNoenc
+         set into node name.  This modification arises from
+         bug #128520, and avoids unnecessary work in libxml2.
+         
+Mon Dec  1 16:41:27 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/*.h *.h.in: updated the metadata informations in the headers
+       * doc/* doc/html/*: regenerated the docs.
+
+Sun Nov 30 23:25:22 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * doc/Makefile.am: small further enhancement to makefile
+       * doc/APIchunk[127].html, doc/libxslt-api.xml, doc/libxslt-refs.xml,
+         doc/html/libxslt-transform.html: updated to reflect last change
+         to transform.c
+
+Sun Nov 30 22:44:07 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * doc/newapi.xsl, doc/api.xsl, doc/apibuild.py, doc/site.xsl,
+         Makefile.am: adapted the libxml files for libxslt.
+       * doc/API*.html, doc/html/*.html, doc/libxslt-api.xml,
+         doc/libexslt-api.xml, doc/libxslt-refs.xml,
+         win32/libxslt.def.src, win32/libexslt.def.src: regenerated
+         the docs.
+
+Sun Nov 30 18:48:27 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: change initialisation of external functions
+         to take place in xsltNewTransformContext instead of in
+         xsltApplyStylesheetInternal.  This fixes bug 122483, and should
+         also fix problem reported on the mailing list on today's date.
+
+Wed Nov 26 09:49:11 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/imports.c, libxslt/xsltInternals.h: Changed to
+         detect recursion in xslt:include (bug #127687).
+       * tests/XSLTMark/reverser.out,
+       * test/docbook/result/xhtml/gdp-handbook.xhtml: results changed
+         because of fix of bug #127877 in libxml2 (quotes in text)
+
+Mon Nov 24 07:32:38 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xslt.c, libxslt/imports.c, libxslt/parserInternals.h:
+         Changed to detect recursion in xslt:import (bug #127687).
+       * doc/libxslt-api.xml, python/libxsltclass.txt: regenerated to
+         include change to xsltParseStylesheetImportedDoc parameters for
+         above.
+
+Sat Nov 22 13:04:59 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/keys.c libxslt/templates.c libxslt/transform.c
+         libxslt/variables.c libxslt/xsltInternals.h libxslt/xsltutils.h:
+         Applied patch from Mark Vadoc adding flexible trace debugging
+         support to the library.
+
+Sat Nov 22 00:53:47 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: fixed bug #127561 (xsl:element with a
+         'computed' namespace attribute)
+       * tests/docs/Makefile.am tests/docs/bug-136.xml
+         tests/general/Makefile.am tests/docs/bug-136*: added tests
+         to the regression for bug #127561
+
+Fri Nov 21 18:17:32 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/keys.c: small further enhancement, bug #127450
+
+Thu Nov 20 17:26:57 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/keys.c: another problem reported by Oleg Paraschenko
+         on the same code in #127450
+       * tests/docs/Makefile.am tests/docs/bug-135.xml
+         tests/general/Makefile.am tests/docs/bug-135*: added tests
+         to the regression suite for bug #127450.
+
+Thu Nov 20 10:59:48 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/keys.c: fixed an error from #120684 patch raised in
+         #127450
+       * tests/docs/Makefile.am tests/docs/bug-134.xml
+         tests/general/Makefile.am tests/docs/bug-134*: added tests
+         to the regression suite for bug #127450.
+       
+Thu Nov 20 00:22:14 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/keys.c: fixed a bug in the keys selector parsing
+         #120684 when | is in a predicate or a string.
+       * tests/docs/Makefile.am tests/docs/bug-133.xml
+         tests/general/Makefile.am tests/docs/bug-133*: added tests
+         to the regression suite for bug #120684.
+       * Makefile.am: don't package cvs temp files
+       * doc/apibuild.py: update from libxml2 one
+
+Tue Nov 18 13:42:12 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/strings.c: fixed entity problem in exslt:tokenize
+         uncovered by newapi.xsl
+       * libxslt/transform.c,libxslt/pattern.c,libxslt/keys.c: changed
+         to use IS_BLANK_CH for char compares (fixes warnings)
+
+Fri Nov 14 23:59:08 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/preproc.c: applied fix from Bjorn Reese to close
+         number formatting bug #126994
+
+Fri Nov 14 18:44:50 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * Makefile.am configure.in libexslt.pc.in libxslt.spec.in: adding
+         libexslt.pc support
+
+Thu Nov 13 11:54:36 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attributes.c libxslt/documents.c libxslt/transform.c
+         libxslt/variables.c libxslt/xsltInternals.h: applied Mark Vakoc
+         patch to moves the control of the XSLT debugger into the transform
+         context.
+
+Tue Nov 12 18:17:24 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/functions.c: applied patch for param visibility from
+         Shaun McCance.  Changed variable scoping in accordance with
+         Shaun's suggestions.  This fixed problem reported on the list
+         by Bernd Lang
+       * tests/exslt/functions/function.8.[xml,xsl,out], Makefile.am:
+         regression test for above
+       
+Sat Nov  8 13:27:12 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/libexslt.3: applied improvement patch from Jonathan Wakely
+         describing the entry points.
+
+Wed Nov  6 17:27:23 CET 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * win32/configure.js: fixed #122146
+
+Wed Nov  5 12:25:34 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * tests/multiple/Makefile.am: applied last fix from #125614
+
+Tue Nov  4 19:08:53 PST 2003 William Brack <wbrack@mmm.com.hk>
+
+       Minor enhancements to eliminate compile/test warnings
+       * libxslt/xsltconfig.h.in, libexstl/exsltconfig.h.in:
+         changed macro ATTRIBUTE_UNUSED for gcc so that, if undefined,
+         it's defined as __attribute__((unused))
+       * python/libxslt.c: fixed ATTRIBUTE_UNUSED to appear after
+         variable declaration
+       * libxslt/preproc.c: minor change to get rid of unused var/code
+         
+Tue Nov  4 14:21:06 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * doc/* NEWS: preparing release 1.1.0
+
+Tue Nov  4 14:04:58 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/preproc.c: fixing the Document element precompilation
+         to avoid the problem raised in #125614
+
+Tue Nov  4 01:08:17 PST 2003 William Brack <wbrack@mmm.com.hk>
+
+       * tests/multiple/out/letter*.orig: updated to reflect change
+         to HTML output in libxml2 (formatting of <p>, bug #125093)
+
+Sun Nov  2 09:07:32 PST 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xslt.c: fixed bug #124286 - detect invalid name on
+         template
+       
+Sun Nov  2 10:51:58 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * Makefile.am configure.in libxslt.spec.in doc/libxslt-api.xml
+         libxslt/xslt.h libxslt/xsltwin32config.h: some cleanup and trial
+         for the upcoming 1.1.0 release
+       * breakpoint/*: this release removes the deprecated breakpoint library
+
+Sat Nov  1 17:04:27 PST 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c, tests/general/bug-119.out: fixed
+         bug #125502 and corrected expected test output
+       * tests/general/bug-79.out: fixed broken test (bug #123328)
+       * libxslt/pattern.c, libexslt/functions.c: minor change to
+         eliminate compilation warning
+         
+Sat Nov  1 22:36:30 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * tests/REC/test-5.2-17.xsl tests/REC/test-5.2-18.xsl: fixing two
+         broken tests (revealed by #125502)
+
+Sat Nov  1 07:41:06 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/strings.c: fix bug #125265 about entities breaking
+         exsl:tokenize and exsl:split
+       * tests/exslt/strings/split.1.* tests/exslt/strings/tokenize.1.*:
+         augmented the reression tests with the example from the bug report.
+
+Fri Oct 31 20:26:04 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/preproc.c: fix bug #120828 make sure that xsl:sort is
+         empty.
+
+Fri Oct 31 15:53:45 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/documents.c libxslt/imports.c libxslt/xslt.c libxslt/xslt.h
+         xsltproc/xsltproc.c: switch to use xmlReadfile instead of
+         xmlParseFile, this avoid relying on global parser options, far
+         far cleaner.
+       * tests/XSLTMark/xslbench1.out tests/general/bug-90.out: fixes a
+         slightly corrected output for CDATA and STYLE element save.
+
+Tue Oct 28 15:30:54 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in python/Makefile.am python/tests/Makefile.am: applied
+         patch from Roumen Petrov for bug #124539 when building outside the
+         source directory
+       * libxslt/xsltutils.c: fixed the way to grab the line number from
+         the document, use the predefiend libxml2 API which mate it work
+         with both 2.5.x and 2.6.x
+
+Mon Oct 27 08:57:43 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xslt.c: put in #undef for IS_BLANK macros to fix
+         problem reported on the mailing list by Justin Fletcher
+
+Fri Oct 24 00:49:05 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in libxslt.spec.in: doing some testing and raising
+         the build requirement to 2.5.10 
+       * libexslt/Makefile.am configure.in: applied patch from Graham Wilson
+         for linking the exslt lib with the lib being build instead of the
+         installed one
+
+Thu Oct 23 15:48:39 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/pattern.c: Fixed problem with cascaded predicates
+         (more of bug 119946)
+
+Thu Oct 23 15:37:26 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * restored earliest portion of ChangeLog (was corrupted)
+
+Wed Oct 22 13:07:50 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltutils.[ch]: applied patch from Kasimier Buchcik
+         for xsltGetDebuggerStatus and xsltSetDebuggerStatus
+       * doc/libxslt-api.xml: regenerated the API
+
+Sun Oct 19 23:32:23 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: bump the libxml2 require to 2.6.0 which
+         should ship for good real soon...
+       * doc/Makefile.am: fix installation of HTML pages
+       * doc/libxslt-api.xml: rebuilt
+       * libxslt/xsltexports.h: cleanup
+       * python/generator.py: ATTRIBUTE_UNUSED is after the parameter
+       * xsltproc/xsltproc.c: applied Crutcher Dunnavant --load-trace patch 2
+
+Fri Oct 17 18:25:42 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/attributes.c: fixed bug 123822
+
+Fri Oct 17 12:40:37 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/pattern.c: fixed bug 119946
+       * configure.in: enhanced for better devel (me) testing
+
+Wed Oct 15 17:30:43 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: applied a small patch from Troels Walsted Hansen
+         for python libxml2 detection.
+
+Sat Sep 27 18:42:57 PDT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/numbers.c, libxslt/extensions.c, libexslt/date.c,
+         python/libxslt.c, xsltproc/xsltproc.c: minor cleanup for
+         various compilation warnings (AIX as well as gcc)
+
+Sat Sep 27 17:29:43 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/saxon.c: applied patch from Brett Kail to implement
+         saxon:line-number()
+
+Thu Sep 25 11:46:40 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extensions.h libxslt/extra.h: fix some header paths
+         as pointed by Steve Ball
+
+Wed Sep 24 23:31:45 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extensions.c: applied patch from Karl Eichwalder
+         apparently the xmlFree was introducting a memory error
+         on x86_64, though not reproduced.
+       * libxslt/transform.c: patch from Shaun McCance fixing a comment.
+
+Thu Sep 18 11:32:20 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxslt.c: don't output errors to stdout by default
+         use stderr instead.
+
+Thu Sep 18 11:28:43 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/functions.c libxslt/numbers.c: small fixes w.r.t.
+         IS_XSLT_REAL_NODE change
+       * python/Makefile.am Makefile.am: some makefile "distclean"
+         target improvement from Graham Wilson
+       * xsltproc/xsltproc.c: small fix from Alexey Efimov for options
+         display.
+
+Mon Sep 15 07:41:14 PDT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xsltutils.h: Added XML_PI_NODE to the macro
+         IS_XSLT_REAL_NODE, fixed bug 120644.
+
+Sat Sep 13 02:04:13 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c doc/xsltproc.1 doc/xsltproc.xml
+         libxslt/xsltutils.h: removing the DocBook SGML support
+
+Fri Sep 12 13:52:07 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: preparing release libxslt-1.0.33
+       * doc/*: updated and rebuilt the docs
+       * doc/apibuild.py: small fixes for new tokens
+
+Wed Sep 10 23:32:42 PDT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * transform.c: enhanced previous fix to bug #120684, using
+         excellent suggestion by Daniel
+       * attributes.c: fixed bug #119583, merging attribute sets
+         from imported stylesheets.
+       * tests/docs/Makefile.am tests/docs/bug-131.xml
+         tests/general/Makefile.am tests/docs/bug-131*: added tests
+         to the regression suite for bug #120684.
+         
+Sat Sep  6 09:57:03 PDT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * pattern.c pattern.h imports.c: fixed bug 119946, caused by
+         incorrect creation of "extra" variables when compiling
+         templates on imported stylesheets.
+       * tests/docs/Makefile.am tests/docs/bug-130.xml tests/docs/bug-130.doc
+         tests/general/Makefile.am test/docs/bug-130*: added tests
+         to the regression suite for this bug.
+
+
+Wed Sep  3 15:33:40 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * tests/xmlspec/*.html: tyny change HTML -> html DOCTYPE due to
+         a libxml2 change
+
+Tue Sep  2 18:22:46 PDT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * transform.c: fixing bug #120684 on crash caused by text between
+         apply-templates
+
+Tue Sep  2 16:05:37 CEST 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * libxslt/xsltexports.h libexslt/exsltexports.h: defined additional 
+         macros which affect exports and added mingw section
+
+Mon Sep  1 23:02:12 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/function.c: patch from Mark Vadoc to allow compiling
+         against libxml2 without XPointer supoort.
+
+Fri Aug 29 12:28:12 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixing the bug #120971 on cdata-section-elements
+         with namespaced names reported by Steve Hay
+       * tests/docs/Makefile.am tests/docs/bug-129.*
+         tests/general/Makefile.am tests/general/bug-129*: added the
+         test to the regression suite for this bug.
+
+Thu Aug 28 18:30:11 CEST 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * libxslt/xsltexports.h libexslt/exsltexports.h: fixed typos reported by
+         Mark Vakoc 
+
+Wed Aug 27 12:07:13 CEST 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * libxslt/*.h: realigned parameters after taint
+
+Wed Aug 27 09:59:54 CEST 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * libxslt/xsltexports.h libexslt/exsltexports.h: fixed defs for 
+         Borland compiler, as reported by Eric Zurcher
+
+Mon Aug 25 13:39:40 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/Makefile.am libexslt/Makefile.am: add the new header so they
+         get included in the distrib
+
+Mon Aug 25 11:56:02 CEST 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * libxslt/*.h libexslt/*.h: exportability taint of the headers.
+       * libxslt/xsltexports.h libexslt/exsltexports.h: new files,
+         contain the export defs.
+
+Tue Aug 19 00:38:46 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/Makefile.am libxslt/libxslt.h libxslt/numbersInternals.h
+         libexslt/*.c configure.in: applied patch from Mikhail Grushinskiy
+         for compilation with MingW compiler on Windows.
+
+Mon Aug 18 14:42:12 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * keys.c: enhanced xsltInitCtxtKey to take care of multiple
+         instances of a key with the same namespace:name, reported
+         on the mailing list by Ian Young.  Added regression test
+         (bug-128).
+
+Thu Aug 15 13:00:02 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * variables.c: fixed bug 119699 (missing error on shadowed
+         variable)
+       * autogen.sh: removed dependency on automake-1.4, updated
+         links for fetching auto* tools
+       * doc/Makefile.am: added check for automatic regeneration of
+         win32/*.def.src when api xml files are updated.
+
+Thu Aug 14 23:15:14 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * transform.c: fixed bug 114563 (params not passed when
+         default template processed)
+
+Thu Aug 14 22:04:37 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * xslt.c: fixed bug 119862 (missing param on ns error print)
+
+Sun Aug 10 00:21:48 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * News configure.in: preparing libxslt-1.0.32 release
+       * doc/* : updated the doc and rebuilt
+
+Thu Aug  7 21:02:07 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * breakpoint/Makefile.am: removed ref to libxslt.la
+       * numbers.c transform.c python/libxml_wrap.h python/types.c
+         xlstproc/xsltproc.c: Minor cleanup of warning errors
+
+Mon Aug  4 22:43:05 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * doc/libxslt-api.xml doc/* doc/html/*: revuilt the API and docs
+
+Sun Aug  3 21:34:44 EDT 2003 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-127.*
+         tests/general/Makefile.am tests/general/bug-127*: added the
+         test from bug #118763 to the regression suite.
+
+Sun Aug  3 17:40:13 EDT 2003 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: minor change, avoid wasting CPU cycles
+
+Sun Aug 3 21:05:07 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       Minor cleanup of regression test general/bug-125
+
+Sun Aug 3 19:46:42 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       Fixed bug 116517 - handling of '{' and '}'
+       * templates.c: added checks for escaping and balancing of
+         curly brackets
+       * tests/general/Makefile.am tests/docs/Makefile.am:
+         Added test case (bug-126) to regression suite.
+
+Sun Aug 3 15:50:51 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       Fixed bug 117552 - sort with multiple keys
+       * xsltutils.c: enhanced treatment of NaN when multiple sort
+         keys are specified.
+       * tests/general/Makefile.am tests/docs/Makefile.am:
+         Added test case (bug-125) to regression suite.
+         
+Sat Aug 2 09:55:38 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       Fixing bug 118561 (IRIX MIPSPro compiler warnings)
+       * transform.c, variables.c, xslt.c, xsltutils.c:
+         removed some unused variables
+  
+Thu Jul 31 20:33:12 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       Fixing bug 118558 (Solaris 8 compiler warnings)
+       * xslt.c: minor re-ordering of code
+       * functions.c: added an explicit cast
+       * number.c: added include for string.h
+       * security.c: added an explicit cast
+
+Tue Jul 29 12:43:17 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libexslt/date.c test/exslt/data/seconds.1 : changed sign
+         of date:seconds as previously posted to the mailing list
+       * numbers.c: extensive modification to cater for UTF8 within
+         the various routines.
+
+Thu Jul 24 19:38:56 IST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/strings.c: applied patch from Shaun McCance to fix bug
+         #117616 about EXST str:tokenize.
+       * tests/exslt/strings/Makefile.am tests/exslt/strings/tokenize.3.*:
+         added the test in the regression suite.
+
+Wed Jul 23 21:57:39 IST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: applying a patch based on #117377
+         for --path option.
+
+Mon Jul 21 20:28:11 IST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: allow strip-space to support full namespaces
+         using prefix:* , should fix #114287
+       * tests/docs/Makefile.am tests/docs/bug-124.*
+         tests/general/Makefile.am tests/general/bug-124*: added a
+         test to the regression suite for this bug.
+
+Mon Jul 21 20:09:57 IST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/tramsform.c: make xsl:copy on attribute a copy in case
+         the attribute was already defined, should fix bug #113812
+       * tests/docs/Makefile.am tests/docs/bug-123.*
+         tests/general/Makefile.am tests/general/bug-123*: added the
+         test to the regression suite.
+
+Fri Jul 18 13:13:52 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/strings.c: applied patch from Shaun McCance to implement
+         exslt:split c.f. #117752
+       * tests/exslt/strings/Makefile.am tests/exslt/strings/split.1.*:
+         added the test to the regression suite.
+
+Thu Jul 17 10:35:22 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/numbers.c: quick fix for an HP-UX compilation problem,
+         might require more attention could be an Unicode support breakage.
+
+Wed Jul 16 10:46:35 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/numbers.c libxslt/transform.c libxslt/transform.h
+         libxslt/xsltInternals.h: optimize text node coalescing by 
+         caching info about the last text node generated and doing
+         fast alloc/copy of the text. Should fix #115273
+
+Mon Jul 14 13:00:00 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * fixed bug 113520, incorrect result for date:seconds
+         with change to type casting in libexslt/date.c
+
+Sat Jul 12 20:35:28 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * fixed bug 114764: trouble with globals and RVT's
+         with minor changes in variables.c and transform.c
+         so that any global instantiated with an RVT gets
+         uninitialized when the RVT is destroyed.
+         
+Thu Jul 10 15:47:33 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: simple cast missing Peter Breitenlohner
+       * breakpoint/Makefile.am: added deps to libxslt
+       * tests/exslt/common/Makefile.am: integrated William Brack test
+         in the regression suite
+
+Wed Jul  9 21:27:43 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * fixed bug 114812, trouble with imported exslt functions
+         added lookup function in libxslt/extension.c
+         enhanced exsltInitFunc in libexslt/functions.c to take
+         better care of imports
+
+Wed Jul  9 12:19:34 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * python/generator.py python/libxslt-python-api.xml python/libxslt.c
+         python/libxslt_wrap.h python/libxsltclass.txt: patch from
+         Sean Treadway, adding Python bindings for extension element and
+         some bindings cleanups.
+       * python/tests/Makefile.am python/tests/extelem.py: also add an
+         example/test.
+
+Tue Jul  8 12:20:11 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxml_wrap.h: applied patch from #116943 which should
+         fix the xsltSaveResultToFile python binding.
+
+Mon Jul  7 11:03:18 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * INSTALL: removed an old reference to libxml2 >= 2.2.12
+
+Sun Jul  6 23:57:35 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: releasing 1.0.31
+       * doc/*: update and rebuild of the docs
+
+Sun Jul  6 18:31:56 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixing bug #115913 for xsl:copy with namespace
+         nodes.
+       * tests/docs/Makefile.am tests/docs/bug-122.*
+         tests/general/Makefile.am tests/general/bug-122*: added the
+         test to the regression suite.
+       
+Sun Jul  6 18:09:13 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/preproc.c: fix bug #115778 for attribute value template
+         on xsl:sort order
+
+Sun Jul  6 17:22:35 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/documents.c libxslt/transform.c: applied patch from
+         Keith Isdale to desactivate node numbering when running under
+         the debugger.
+
+Sun Jul  6 00:00:31 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/security.c: fix the write checking code when
+         the output filename does not parse as an URL bug #115402
+
+Sun Jun 22 19:38:04 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/Makefile.am: Albert Chin pointed out that trio.h and
+         triodef.h were missing from the distribution
+
+Fri Jun 13 16:53:33 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt.spec.in libexslt/Makefile.am libexslt/libexslt.3
+         libxslt/Makefile.am libxslt/libxslt.3: Moved the man pages
+         to section 3
+       * libexslt/sets.c: applied patch from Peter Breitenlohner
+       * doc/*: rebuilt the docs
+       * tests/docbook/result//* tests/xmlspec/*.html: changes in
+         generattion of &quot; as " in element content.
+
+Sun Jun 08 22:57:13 CEST 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * libxslt/transform.c: changed xsltChoose to ignore whitespace 
+         which is a sibling of xsl:when
+
+Sat May 31 17:18:21 CEST 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * libxslt/xslt.c: fixed a possible crash when the document
+         wasn't a proper stylesheet.
+
+Tue May 20 12:14:12 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/variables.c: fixes a 64bits cleanliness issue #113318
+
+Sat May 17 13:25:32 CEST 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * win32/defgen.xsl: new file, generates the export sources.
+       * win32/*.def.src: these are now autogenerated, changes to these
+         will not be logged anymore.
+
+Fri May 16 13:22:31 EDT 2003 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-121.*
+         tests/general/Makefile.am tests/general/bug-121*: added the
+         example for bug #112904 in the regression tests, the bug fix is
+         actually in libxml2
+
+Thu May 15 16:26:34 EDT 2003 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: fixing portability bug #113002 on HP-UX
+       * configure.in libxslt.spec.in python/Makefile.am: cleanup
+         of --with-python like for libxml2
+
+Thu May 15 11:45:00 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/xsltutils.c: fixing bug #112995, a problem with
+         NaN within the sort element. Also added regression test.
+
+Tue May 13 18:22:38 EDT 2003 Daniel Veillard <daniel@veillard.com>
+
+       * doc/Makefile.am: fixing bug #112803 , make sure to avoid
+         network accesses when building
+
+Sat May 10 14:19:14 EDT 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixed a segfault introduced with the RVT
+         handling change, bug #112703 .
+
+Sat May 10 13:05:21 EDT 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xslt.c: make sure stylesheet compilation errors
+         forces a NULL stylesheet, fixes #112270
+
+Sun May  4 17:41:23 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * NEWS configure.in : preparing release 1.0.30
+       * doc/apibuild.py: backported a patch from libxml2
+       * doc/*: updated and rebuilt the docs
+
+Wed Apr 30 22:44:49 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c libxslt/variables.c libxslt/xsltInternals.h:
+         cleaning up Result Value Tree handling
+       * libexslt/functions.c libexslt/strings.c: fixed a pair of
+         implementations.
+       * tests/exslt/strings/Makefile.am tests/exslt/strings/tokenize.2.*:
+         added Mark Vakoc test combining for-each and exslt:tokenize
+
+Wed Apr 30 15:23:33 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixing bug #111755 when a template is
+         applied to an attribute
+       * tests/docs/Makefile.am tests/docs/bug-119.*
+         tests/general/Makefile.am tests/general/bug-119*: added the
+         example in the regression tests for that bug.
+
+Tue Apr 29 15:18:31 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * doc/Makefile.am doc/libxslt.xml: upgraded to the XML/XSLT toolchain
+         for the HTML generation fixing #111799
+       * doc/html/*.html doc/html/*.png: associated update
+
+Sun Apr 27 18:00:12 CEST 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * libxslt/variables.c: removed premature call to xsltFreeStackElem
+       * win32/libxslty.def.src: added more exports
+
+Sun Apr 27 12:46:31 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * NEWS doc/*.xsl doc/*.html: updated the web site, made the
+         transition to XHTML1 added validity checking to the makefile rules.
+
+Sat Apr 26 14:00:58 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * python/generator.py: fixed a problem in the generator where
+         the way functions are remapped as methods on classes was
+         not symetric and dependant on python internal hash order,
+         as reported by Stéphane Bidoul
+       * libexslt/strings.c: attempt at fixing an object type pbm
+       * libxslt/triodef.h: update for OpenVMS from libxml2
+
+Fri Apr 25 15:26:26 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * doc/Makefile.am doc/xsltproc.1 doc/xsltproc.xml: automated the
+         generation of the man page
+
+Wed Apr 23 23:27:44 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/sets.c: fixed a bug introduced in the last commit
+       * libxslt/transform.c: tried to fix #111437
+       * tests/docbook/result/xtchunk/html/*.orig
+         tests/multiple/out/*.orig: side effect of #111437 change.
+
+Wed Apr 23 22:41:08 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/strings.c: applied last patch for #110023 from 
+         Mark Vakoc
+       * libexslt/sets.c: fixed a memory leak when mixing one of the
+         EXSLT set functions and a Result Value Tree
+       * TODO: there are other bugs around in libexslt/sets.c in conjunction
+         with Result Value Tree
+
+Wed Apr 23 17:00:16 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       *  libxslt/extensions.c: patch from Vasily Tchekalkin fixing
+          bug #111420 about double initialization of extension contexts
+
+Wed Apr 23 14:25:46 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fix bug #110577 namespace in copy-of
+         don't obbey the same rules as for literal reusl elements.
+       * tests/docs/Makefile.am tests/docs/bug-118.*
+         tests/general/Makefile.am tests/general/bug-118*: added the
+         example in the regression tests for that bug.
+       * libxslt/variables.c: fixed a bug introduced in fixing #110020
+       * tests/docs/Makefile.am tests/docs/bug-11[67].*
+         tests/general/Makefile.am tests/general/bug-11[67]*: added 2
+         regression tests one still exposing a mem leak (Mark Vadoc).
+
+Tue Apr 22 16:01:25 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: fix a memory related segfault on a
+         pattern compilation error #110189
+
+Tue Apr 22 15:45:25 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/variables.c: fixing bug #110020 on global parameter
+         and variables mismatch
+       * tests/reports/Makefile.am tests/reports/cmdlineparams.*: added
+         the test to the regression suite
+
+Mon Apr 21 12:22:31 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/math.c: applied patch from Charles Bozeman fixing
+         the math power function where args were inverted #110996
+       * tests/exslt/math/Makefile.am tests/exslt/math/power.1.*:
+         added the test to the regraession for #110996
+       * libexslt/sets.c: avoid a problem with nodesets.
+
+Wed Apr 14 18:10:21 CEST 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * libxslt/win32config.h: added HAVE_MATH_H
+         
+Wed Apr 13 14:04:15 CEST 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * win32/Makefile.msvc: fixed compilation with thread-enabled
+         libxml
+         
+Wed Apr  9 22:02:17 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/strings.c: applied patch from Mark Vakoc fixing a problem
+         with RTF in libexslt
+
+Mon Apr  7 14:39:01 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/keys.c libxslt/templates.c libxslt/transform.c
+         libxslt/variables.c: Fixes bug #110023 reported by Mark Vakoc and
+         other places where ctxt->document pointer may be used without 
+         checking it agaisnt NULL.
+       * tests/docs/Makefile.am tests/docs/bug-115.*
+         tests/general/Makefile.am tests/general/bug-115*: added the
+         example in the regression tests for that bug.
+       * libxslt/trio.h libxslt/triodef.h: update of Trio from Bjorn Reese
+
+Tue Apr  1 13:39:26 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in NEWS: preparing 1.0.29 release
+       * libxslt/documents.c: generate the document order for document()
+         loaded resources.
+       * doc/*: updated and regenerated the docs
+
+Tue Apr  1 11:28:01 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixed a namespace redundancy problem
+         in xsl:element
+       * tests/docs/Makefile.am tests/docs/bug-114.*
+         tests/general/Makefile.am tests/general/bug-114*: added an
+         example in the regression tests for that bug.
+
+Fri Mar 28 12:19:35 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxsl.py: fix bug #109395 as pointed out by Ben Phillips
+         and avoid some warnings when loading the python modules on non
+         Linux platforms.
+       * libxslt/transform.c: fix a bug introduced in the document lookup
+         and exhibited by the keys test.
+
+Wed Mar 26 22:41:00 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-113.*
+         tests/general/Makefile.am tests/general/bug-113*: added an
+         example in the regression tests for bug #109160 fixed in libxml2
+
+Wed Mar 26 21:43:30 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in python/Makefile.am python/libxslt.c libxslt/xsltutils.c
+         libxslt/trio.h libxslt/triodef.h: portability fixes from Albert Chin
+       * python/libxslt.py: avoid RTLD_GLOBAL detection warning too
+
+Wed Mar 26 19:08:55 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: forgot to make one change related to
+         Result Value Tree change, pointed out by Sebastian Rahtz
+       * tests/docs/Makefile.am tests/docs/bug-112.*
+         tests/general/Makefile.am tests/general/bug-112*: added an
+         example in the regression tests that bug
+
+Wed Mar 26 01:38:38 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: second part of the patch fixing #108905
+         performances problems, ask for computation of document order on
+         the document transformed and avoid inefficiencies building large
+         nodesets of unique nodes.
+       * configure.in: fix a trouble with libtool in my debug environment.
+
+Mon Mar 24 22:30:00 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c libxslt/transform.c libxslt/variables.c:
+         Result Value Tree are now generated with a document root node
+         not an element, it's quite cleaner.
+       * configure.in libxslt.spec.in NEWS: But this requires libxml2-2.5.5
+         also prepared for libxslt-1.0.28 release
+       * doc/*: updated and regenerated the docs
+
+Mon Mar 24 15:01:07 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c libxslt/transform.c libxslt/variables.c:
+         Finally fixed bug #75813, processing or Result Value Tree 
+         converted into node-sets should be a bit more sensible now.
+       * tests/exslt/common/node-set.2.out: the associated fix in libxml2
+         fixes this regression test, there is 4 nodes, not 3
+       * tests/docs/Makefile.am tests/docs/bug-111.*
+         tests/general/Makefile.am tests/general/bug-111*: added an
+         example in the regression tests for bug #75813
+       
+Sun Mar 23 13:09:17 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-110.*
+         tests/general/Makefile.am tests/general/bug-110*: added an
+         example in the regression tests for bug #108976 which is
+         fixed in libxml2
+
+Sat Mar 22 12:35:47 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-109.xml
+         tests/general/Makefile.am tests/general/bug-109*: added an
+         example in the regression tests for the invalid bug #108716
+
+Sat Mar 22 12:01:24 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/variables.c: fixed bug #108633 reported by
+         Jerome Pesenti about recursive global variables/param detections
+       * tests/reports/Makefile.am tests/reports/rec*: added regression
+         tests for the checking of recusion in global/local param/variables.
+
+Fri Mar  7 16:08:24 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/numbers.c: valgrind pointed out an uninitialized
+         variable use in format-number()
+
+Fri Mar  7 15:27:56 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-108.xml
+         tests/general/Makefile.am tests/general/bug-108*: added an
+         example in the regression tests bug #107804 fixed in libxml2
+
+Wed Mar  5 12:47:31 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: fixed bug #107591 node() in pattern
+         matches should catch comments and PIs
+       * tests/docs/Makefile.am tests/docs/bug-107.xml
+         tests/general/Makefile.am tests/general/bug-107*: added an
+         example in the regression tests for this case
+
+Wed Feb 26 16:49:17 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-106.xml
+         tests/general/Makefile.am tests/general/bug-106*: added the next
+         example for bug #106788 from James Clark in the regression tests,
+         the bug fix is actually in libxml2
+
+Tue Feb 25 16:19:45 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in doc/Makefile.am xsltproc/Makefile.am: some cleanup
+         for Python checks, makefile cleanup, and convenience changes
+
+Mon Feb 24 23:49:01 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: had to comment out Igor last change
+         since it made libxslt-1.0.27 depends on libxml2 newly 
+         API extension which hasn't propagated yet :-(
+
+Mon Feb 24 22:21:09 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: preparing release 1.0.27
+       * doc/*: updated and rebuilt the docs
+
+Mon Feb 24 19:43:15 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/namespaces.c: fixed #106554 for spurious xmlns:nsX=""
+         generation
+
+Sun Feb 23 14:52:57 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-105.xml
+         tests/general/Makefile.am tests/general/bug-105*: added the
+         example for bug #106788 from James Clark in the regression tests,
+         the bug fix is actually in libxml2
+
+Sun Feb 23 14:25:13 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/namespaces.c libxslt/transform.c: fixed bug #106789 from
+         James Clark and a bit of cleanup
+       * tests/docs/Makefile.am tests/docs/bug-104.xml
+         tests/general/Makefile.am tests/general/bug-104*: added the
+         example in the regression tests for this case
+
+Fri Feb 21 17:07:59 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt.spec.in: fixed RH#84801 wrong prereqs in the spec file
+
+Wed Feb 19 18:51:06 CET 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * libxslt/functions.c libxslt/xslt.c: fixed bug 106251
+
+Wed Feb 19 15:52:33 CET 2003 Igor Zlatkovic <igor@zlatkovic.com>
+
+       * xsltproc/xsltproc.c: obsoleted xmlNormalizeWindowsPath
+       * win32/configure.js: included handling of the trio option
+
+Mon Feb 10 17:34:32 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in doc/*: preparing release 1.0.26
+
+Fri Feb  7 15:47:20 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/functions.c: fixing another bug in document(), bug #105450
+       * tests/documents/test_bad.result: Slight change to the output
+
+Fri Feb  7 15:34:24 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/functions.c: fixing a segfault in document(), bug #105418
+       * tests/documents/Makefile.am tests/documents/test_bad: add the
+         specific test as suggested by Jean T Anderson
+
+Fri Feb  7 14:18:40 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extensions.c libxslt/keys.c libxslt/pattern.c
+         libxslt/preproc.c libxslt/transform.c libxslt/variables.c
+         libxslt/xslt.c: tried to fix 105387 and all similar cases
+         in the library sources.
+
+Wed Feb  5 16:04:10 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * doc/* configure.in: preparing for release of 1.0.25
+
+Wed Feb  5 00:07:43 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: fixed bug #99623
+
+Tue Feb  4 22:10:17 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixing bug #105116 sometimes one need
+         to generate a default namespace reset xmlns="" in the output
+       * tests/docs/Makefile.am tests/docs/bug-103.xml
+         tests/general/Makefile.am tests/general/bug-103*: added the
+         example in the regression tests for this case
+
+Tue Feb  4 18:39:35 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c libxslt/transform.c: changed the way the
+         root element of value tree are handled to fix bug #104123
+
+Tue Feb  4 18:15:01 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * README: change of policy w.r.t. mails
+       * configure.in: small cleanup
+       * libxslt/transform.c libxslt/xslt.c libxslt/variables.c: fixed
+         a couple of bugs raised by Eric van der Vlist in #104114
+       * tests/exslt/*/*.out: slight change to the tests
+
+Tue Feb  4 17:18:54 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * doc/xsltproc.1 doc/xsltproc.xml: fixing bug #104096, put
+         emphasis on the fact that --docbook should not be used
+         for XML.
+
+Wed Jan 22 16:43:49 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxslt.c: fixed a couple of return error #104150
+         reported by Peter O'Shea 
+
+Fri Jan 17 17:43:43 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: fixed a double free of stylesheet
+         when applied to a standalone stylesheet
+
+Tue Jan 14 16:22:48 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: preparing release 2.0.24
+       * libxslt.spec.in: small update
+       * doc/*: updated the news, rebuilt the APIs descriptions
+
+Tue Jan 14 14:23:47 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/functions.c: fixed #101502 by applying and cleaning up
+         the associated patch from Daniel Stodden.
+       * tests/documents/Makefile.am tests/documents/fragment*: added a
+         specific test.
+
+Mon Jan 13 23:25:59 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extensions.c libxslt/transform.c: fixing bug #101602
+         for extension modules init and shutdown callbacks, check that
+         they are now called when needed.
+       * python/libxsl.py python/libxslt-python-api.xml python/libxslt.c:
+         started adding the extension module support at the Python level.
+         Still a strange bug to hunt down left.
+
+Sun Jan 12 23:56:18 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attributes.c libxslt/xsltInternals.h libxslt/imports.c
+         libxslt/xslt.c: fixed bug #101003 on attribute-sets value
+         computation in the presence of imports
+       * tests/docs/Makefile.am tests/docs/bug-102.xml
+         tests/general/Makefile.am tests/general/bug-102*: added an
+         example in the regression tests for this case
+
+Fri Jan 10 10:34:23 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: final touch to #102800 fix
+
+Thu Jan  9 18:17:40 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: tried to fix #102800 for good. Reenabled
+         memory debug checking which got deactivated at some point ?!?
+       * libexslt/date.c libxslt/attributes.c: fixing some memory leaks
+       * libxslt/xsltutils.c: very small change on HTML indentation handling
+
+Thu Jan  9 14:28:19 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * tests/REC/test-8-1.xsl tests/REC/test-9.1-2.xsl 
+         tests/general/bug-83.xsl tests/multiple/dict.xsl: added some
+         exclude-result-prefixes to avoid extra namespace declaration being
+         dumped following the fix for #102920 in libxml2
+
+Wed Jan  8 12:33:47 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixed a problem related to directory
+         checking and creation raised by Craig Goss
+
+Thu Jan  2 23:23:30 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/strings.c: applied patch from Jörg Walter to provide
+         URI escaping and unescaping functions.
+
+Thu Dec 26 15:43:31 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/strings.c: Alexey Efimov found a typo bug in
+         exsltStrPaddingFunction()
+
+Mon Dec 23 15:43:59 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxslt.c: patch from Stéphane Bidoul for Python 2.1
+
+Sun Dec 22 22:54:04 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * vms/build_xslt.com libxslt/xsltconfig.h.in libxslt/xsltutils.c:
+         applied patch from Craig A. Berry for the VMS port.
+
+Wed Dec 18 15:41:21 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltInternals.h: increase the max number of cascaded
+         sort operations.
+       * AUTHORS doc/* win32/*: updated Igor's mail and the Web page for
+         the Windows binaries.
+
+Mon Dec 16 19:31:16 CET 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * win32/libxslt.def.src: added more exports for Stephane Bidoul
+       
+Fri Dec 13 14:50:12 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/apibuild.py doc/libexslt-api.xml doc/libxslt-api.xml: updated
+         the apibuilder script, regenerated the APIs
+
+Fri Dec 13 11:59:07 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/numbers.c: numbering should not traverse XInclude
+         nodes left in the tree. Closes bug #101114 raised by
+         Bernd Kuemmerlen
+
+Thu Dec 12 01:17:09 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/apibuild.py: fixed a bug in merging public info from
+         C modules.
+       * win32/Makefile.msvc win32/configure.js: patch from Mark Vakoc
+         the iconv option to configure.js didn't work, and 
+         added zlib option needed when linking xsltproc statically
+
+Wed Dec 11 19:18:45 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/Makefile.am doc/apibuild.py doc/libexslt-api.xml: added
+         the generation of libexslt-api.xml
+        * libexslt/exslt.h: small cleanup.
+
+Wed Dec 11 18:45:09 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/Makefile.am doc/apibuild.py doc/libxslt-api.xml:
+         copied over the apibuild.py from libxml2, adapted a bit and
+         regenerated the API description in XML. Todo: libexslt-api.xml
+       * libxslt/attributes.c libxslt/documents.c libxslt/extensions.c
+         libxslt/imports.c libxslt/numbers.c libxslt/numbersInternals.h
+         libxslt/pattern.c libxslt/preproc.c libxslt/security.c
+         libxslt/templates.c libxslt/transform.c libxslt/transform.h
+         libxslt/variables.c libxslt/xslt.c libxslt/xsltInternals.h
+         libxslt/xsltutils.c libxslt/xsltutils.h: cleanup based on the
+         report from the scripts.
+       * libxslt.spec.in: make sure libxslt-api.xml ends up in the devel
+         package
+
+Thu Dec  5 18:05:44 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: xsl:element generated superfluous xmlns
+         declarations, closes bug #99905
+       * tests/docs/Makefile.am tests/docs/bug-101.xml
+         tests/general/Makefile.am tests/general/bug-101.*: added the
+         example in the regression tests for this case
+
+Wed Dec  4 18:12:24 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xslt.c: Matt Sergeant reported a bug when having comments
+         within an <xsl:text>
+
+Mon Dec  2 17:19:38 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extensions.c: applied patch from Josh Parsons fixing bug
+         #100056
+       * tests/docs/Makefile.am tests/docs/bug-100.xml
+         tests/general/Makefile.am tests/general/bug-100.*: added the
+         example in the regression tests for this case
+       * tests/docs/Makefile.am tests/docs/bug-99.xml
+         tests/general/Makefile.am tests/general/bug-99.*: this test
+         covers an xsl:attribute namespace bug that Norm pointed out.
+
+Thu Nov 28 17:52:21 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltInternals.h libxslt/xsltutils.c libxslt/xsltutils.h
+         win32/libxslt.def.src: applied another patch from Richard Jinks
+         for the export of teh sorting routine and allowing per context
+         sort.
+
+Wed Nov 27 13:33:26 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/preproc.c libxslt/xsltInternals.h libxslt/xsltutils.c
+         libxslt/xsltutils.h: Applied patch from Richard Jinks to allow
+         redefining the sorting routine, plus a bit of tweaking of the
+         interfaces.
+
+Tue Nov 26 16:02:38 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/Makefile.am doc/parsedecl.py: fixed the API generation
+         scripts.
+       * doc/libxslt-api.xml doc/libxslt-refs.xml: regenerated
+       * doc/html/*.html: updated too
+       * python/libxsltclass.txt: updated too
+
+Tue Nov 26 15:17:13 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltutils.c libxslt/xsltutils.h: added the function
+         xsltGetProfileInformation() to retrieve profiling informations
+         from an XSLT transformation context. It returns it as an XML
+         tree. Provided by Michael Rothwell this closes RFE #99527
+
+Tue Nov 26 14:40:45 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/imports.c: apply patch from Daniel Stodden, a bug
+         in xsltFindElemSpaceHandling() missing imported informations
+       * tests/REC/stand-2.7-1.stand.out: this change slightly the result
+         of this test.
+
+Mon Nov 25 17:33:48 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/namespaces.c: fix for namespace generation on 
+         attributes created with xsl:attribute
+
+Mon Nov 25 17:30:02 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt.spec.in configure.in: add a line in %changelog for releases
+
+Mon Nov 25 14:57:53 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.h: Kir Kolyshkin pointed out it lacked 
+         xsltInternals.h reference.
+
+Sun Nov 24 15:49:58 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/tests/*.py: enable libxml2 memory debug before
+         loading libxslt since libxslt initialization now includes
+         EXSLT registration which initialize the libxml2 library and
+         allocate memory
+
+Sun Nov 24 13:58:48 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxsl.py: updated with new version from Stéphane Bidoul
+
+Sat Nov 23 22:49:08 CET 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * win32/libxslt.def.src: exported new functions
+
+Sat Nov 23 14:46:06 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/date.c: patch from Charles Bozeman fixing a memory
+         leak in exsltDateDurationFunction pointed out by Bernard Brinkhus
+       * python/tests/exslt.py: trouble with mem debug in that specific
+         test...
+
+Sat Nov 23 12:33:58 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltInternals.h: Alexey Efimov reported a portability
+         problem when compiling on HP-UX
+
+Sat Nov 23 12:23:32 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/generator.py python/libxslt.c: fixes for compiling
+         without config.h
+
+Thu Nov 21 18:51:29 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixed bug #99168 select evaluating to
+         a node list check
+
+Thu Nov 21 15:12:33 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * tests/documents/result.xhtml: the XHTML1 serialization change
+         to libxml2 modifies slightly the result of that test.
+
+Mon Nov 18 11:38:46 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: the python bindings requires libxml2 >= 2.4.25
+         for the regexp stuff.
+
+Mon Nov 18 10:09:06 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: similar patch to #98825 for --with-python
+
+Sun Nov 17 22:06:59 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/variables.c: fix bug #98793 on clash of imported global
+         variables.
+       * tests/reports/tst-1.err: this changes the output of that test
+
+Sun Nov 17 18:12:20 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: preparing 1.0.23
+       * doc/*: rebuilding the docs
+
+Sat Nov 16 23:23:41 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxslt.c: make sure to register EXSLT for the bindings
+       * python/tests/Makefile.am python/tests/exslt.py: add a specific test
+       * xsltproc/xsltproc.c: minor cleanup
+
+Fri Nov 15 12:35:57 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/Makefile.am python/tests/Makefile.am: trying to fix #98518
+         when building outside of the source tree
+
+Thu Nov 14 21:39:37 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/generator.py: xpathObjectRet() pertains to the libxml2
+         module, add the namespace.
+
+Thu Nov 14 18:48:00 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * libxslt/win32config.h: cleanup
+       * win32/Makefile.mingw: new file, integrated mingw in JScript configure
+       * win32/Makefile.msvc: modified to allow mingw coexistence
+       * win32/configure.js: integrated mingw
+       * win32/Readme.txt: cleanup
+       * xsltproc/xsltproc.c: allowed stdarg for mingw
+
+Thu Nov 14 07:22:23 MST 2002 John Fleck <jfleck@inkstain.net>
+
+       * doc/xsltproc.1
+       * doc/xsltproc.html - ran stylesheets to update man page
+       and html with Daniel's fix to #95510
+
+Thu Nov 14 15:10:13 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: applied patch from Brian McCauley fixing #95493 
+       * doc/xsltproc.xml: fixing #95510 missing description of --writesubtree
+       * README: fix the bug page URL
+
+Thu Nov 14 10:03:12 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/functions.c: make sure the fixup for key() reported
+         by John Escott actually works.
+       * tests/docs/Makefile.am tests/docs/bug-98.xml
+         tests/general/Makefile.am tests/general/bug-98.*: added the
+         example in the regression tests for this case
+
+Wed Nov 13 10:35:46 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: fixes bug #97969 for @*[...] patterns
+       * tests/docs/Makefile.am tests/docs/bug-97.xml
+         tests/general/Makefile.am tests/general/bug-97.*: added the
+         example in the regression tests for this case
+       
+Tue Nov 12 22:35:47 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixes bug #97950 for cdata-section-elements
+         checks in recursive copies.
+       * tests/docs/Makefile.am tests/docs/bug-96.xml
+         tests/general/Makefile.am tests/general/bug-96.*: added the
+         example in the regression tests for this case
+
+Tue Nov 12 19:31:49 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/functions.c: autoconvert key() first arg to string,
+         reported by John Escott
+
+Tue Nov 12 13:40:47 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: corner case handling of copying a CDATA node.
+
+Fri Nov  8 18:12:46 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * libxslt/win32config.h: retired xmlwin32version.h
+
+Fri Nov  8 17:09:14 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * Makefile.am libxslt.m4 libxslt.spec.in: integrated libxslt.m4
+         written by Thomas Schraitle (RFE #96485)
+
+Thu Nov  7 11:18:42 MST 2002 John Fleck <jfleck@inkstain.net>
+
+       * doc/xsltproc.xml
+       * doc/xsltproc.1
+       clarifying --catalog option and xsltproc's use of 
+       XML_CATALOG_FILES and /etc/xml/catalog. fixes
+       http://bugzilla.gnome.org/show_bug.cgi?id=97891
+       
+Mon Nov  4 06:55:36 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: remove the use of snprintf, and use
+         libxml2 string API instead.
+       * configure.in libxslt/xsltconfig.h.in libxslt/xsltutils.c:
+         try to cope with architecture lacking some of the string functions,
+         reuse the trio ones compiled in libxml2 , should close #97113
+
+Wed Oct 23 17:06:24 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * Makefile.am libxslt.spec.in doc/Makefile.am: cleaned up
+         the spec file and associated changes in the Makefiles.
+
+Tue Oct 22 21:02:37 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: Forgot to check a pointer, fixes bug #96495
+
+Tue Oct 22 20:53:10 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/keys.h: fixed include c.f. bug #96487
+       * config.h.in:  Red Hat 8.0 induced change 
+
+Mon Oct 21 20:56:31 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/numbers.c libxslt/numbersInternals.h libxslt/xsltutils.[ch]:
+         fixed bug #78501 when using a non ascii character for the
+         number formatting grouping separator.
+       * tests/docs/Makefile.am tests/docs/bug-95.xml
+         tests/general/Makefile.am tests/general/bug-95.*: added the
+         example in the regression tests for this case
+       * libxslt/attributes.c: cleaning up a problem introduced in last
+         patch
+
+Mon Oct 21 09:31:55 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * libxslt/attributes.c: fixed minor typo in a call to
+         xmlHasNsProp
+
+Sun Oct 20 23:20:37 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/types.c: fixed bugs when passing result value tree
+         to Python functions.
+
+Sun Oct 20 15:23:28 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * libxslt/win32config.h: mapped vsnprintf to _vsnprintf for the
+         MS runtime
+       * xsltproc/xsltproc.c: mapped snprintf to _snprintf for the MS
+         runtime
+       
+Fri Oct 18 13:40:12 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: preparing 1.0.22
+       * doc/*: upated and rebuilt the docs
+
+Thu Oct 17 16:32:44 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/variables.c: fixed bug #86421 
+       * tests/docs/Makefile.am tests/docs/bug-94.xml
+         tests/general/Makefile.am tests/general/bug-94.*: added the
+         example in the regression tests for this case
+
+Thu Oct 17 15:50:04 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc: added and tested the --path option to close #79638
+
+Thu Oct 17 15:25:46 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attributes.c: fixing bug #95826 the attribute was reset
+         with the inherited stylesheet value.
+       * tests/docs/Makefile.am tests/docs/bug-93.xml
+         tests/general/Makefile.am tests/general/bug-93-inc.*
+         tests/general/bug-93.*: added the example in the regression
+         tests for this case
+       
+Tue Oct 15 18:02:37 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltInternals.h libxslt/xsltutils.[ch]: added the
+         possibility to register a transformation context specific
+         error handler, with xsltSetTransformErrorFunc() and provided
+         a new routine xsltTransformError() to handle contextual errors,
+         this should fix #94435
+       * libxslt/*.c: modified all the code to use the context specific
+         error handling, as a result xsltPrintErrorContext() is not called
+         anymore except internally from xsltTransformError()
+
+Tue Oct 15 14:52:23 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: closing #94933, any error will make
+         the transformation abort with  no result.
+       * tests/reports/tst-1.err tests/reports/tst-1.out 
+         tests/reports/undefvar.err: this changed the regression tests
+         output.
+       * tests/exslt/date/difference.1.out tests/exslt/date/seconds.1.out:
+         updated the result accordingly to the fixes done last month.
+       * libxslt/namespaces.c: make sure to avoid duplicate namespace
+         declarations in the result trees. May fix #93692 but it's unclear.
+
+Tue Oct 15 12:45:42 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: added a --path option to provide the
+         enhancement requested by #79638, first cut at it, untested
+         yet.
+
+Tue Oct 15 13:02:40 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xslt.c: seems the media-type attribute wasn't
+         always correctly handled
+
+Mon Oct 14 09:27:01 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: added URI escaping in case the resource 
+         target computation of exslt:element failed. Should fix #81837
+
+Tue Oct 15 12:42:25 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * README: updated the contact informations
+
+Tue Oct 15 11:40:19 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: fixed the behaviour of node() patter which
+         didn't patch the one defined in XPath :-( . Closes bug #95793
+       * tests/docs/Makefile.am tests/docs/bug-92.xml
+         tests/general/Makefile.am tests/general/bug-92.*: added the
+         example in the regression tests for this case
+
+Mon Oct 14 12:29:53 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * libxslt/win32config.h: remapped mkdir to _mkdir for MS runtime
+       * win32/Makefile.msvc: added security.c to the build
+       * win32/libxslt.def.src: exported functions from security.c
+
+Thu Oct 10 18:41:56 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: added another option --writesubtree to allow
+         documents to be written only to  a given subtree.
+
+Thu Oct 10 17:16:52 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/security.[ch] libxslt/Makefile.am: new module with
+         runtime security checks, it will also check and do directory
+         creation when allowed
+       * libxslt/documents.c libxslt/imports.c libxslt/transform.c
+         libxslt/xslt.c libxslt/xsltInternals.h: plug-in the new
+         security infrastructure probes at file reading or file creation
+       * xsltproc/xsltproc.c: plugged the security module there too,
+         added the new options --nowrite and --nomkdir
+       * doc/*: updated the man page and regenerated.
+
+Wed Oct  9 18:37:56 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/*: updated the doc XSLT to add the search, added the search
+         page, fixed a link problem raised by Yves Pratter, regenerated
+
+Wed Oct  9 14:27:17 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/index.py: the indexer version of the XSLT part of the
+         xmlsoft site + archives
+
+Sun Sep 29 20:02:25 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * win32/Makefile.msvc: introduced double-run compilation.
+       * win32/configure.js: introduced double-run compilation.
+
+Thu Sep 26 20:08:50 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: preparing 1.0.21
+       * doc/* : updated and regenerated the docs and web pages
+
+Wed Sep 25 11:16:06 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixed a disable output escaping bug for
+         HTML output introduced in 1.0.20 and raised by Mario Weilguni
+       * tests/docs/Makefile.am tests/docs/bug-91.xml
+         tests/general/Makefile.am tests/general/bug-91.*: added the
+         example in the regression tests for this case
+
+Tue Sep 24 20:33:08 MDT 2002 John Fleck <jfleck@inkstain.net>
+
+       * doc/xlst.html: changing link on ftp.gnome.org
+
+Mon Sep 23 10:14:38 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * Makefile.am: set-up DIST_SUBDIRS to avoid the same problem Jacob
+         reported for libxml2
+
+Fri Sep 20 14:06:45 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * Makefile.am configure.in: trying to fix the same problem as
+         #88412 by bypassing all the python subdir if python ain't detected
+
+Fri Sep 20 10:55:03 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/templates.c: fixed a problem reported by Mark Vakoc
+
+Wed Sep 18 15:46:50 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * libexslt/date.c: fixed the embedded '-' in the duration format 
+         function
+       * tests/.../difference.1.xml: added test cases which illustrated
+         the above bug
+
+Tue Sep 17 18:01:22 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * libexslt/date.c: fixed date:difference() bugs, removed all
+         type conversion warnings.
+       * libxslt/xsltutils.c: removed unused local variable.
+
+Sat Sep 14 16:17:51 MDT 2002 John Fleck <jfleck@inkstain.net>
+
+       * doc/xsltproc.html:
+       oops, forgot to update the html version of the man page
+
+Sat Sep 14 16:10:21 MDT 2002 John Fleck <jfleck@inkstain.net>
+
+       * doc/xsltproc.xml
+       * doc/xsltproc.1
+       * doc/xsltproc2.html
+       Fixing erroneous mention of old --warnnet option (thanks to Jean
+       T. Anderson for pointing this out)
+
+Tue Sep 10 21:05:28 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * win32/configure.js: added more readme info for the binary
+         package.
+       
+Mon Sep  9 14:07:06 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: fixed a bug in match="node()" reported by
+         Ben Ko
+
+Mon Sep  9 14:06:25 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt.spec.in: fixes libary path for x86_64 AMD
+
+Thu Sep  5 10:07:13 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/Makefile.am: applied patch from Christophe Merlet to
+         reestablish DESTDIR
+
+Thu Aug 29 21:26:30 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: re-applied the patch from Nathan Myers about
+         a possible memory leak in case of error
+
+Wed Aug 28 13:44:54 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/Libxslt-Logo-180x168.gif doc/Libxslt-Logo-90x34.gif:
+         nice logos generated by Marc Liyanage
+       * doc/site.xsl *.html: changed the stylesheet to show the new
+         logo and regenerated the pages
+
+Sun Aug 25 17:01:40 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxslt-python-api.xml python/libxslt.c
+         python/libxsltclass.txt python/tests/basic.py: applied a patch
+         from Ralf Mattes providing style.saveResultToString()
+
+Fri Aug 23 13:53:50 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: preparing release 1.0.20
+       * doc/*: updated and regenerated the docs
+
+Wed Aug 21 21:27:29 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/templates.c: fixed a bug w.r.t. namespace context when
+         doing the evaluation of attribute value templates 
+       * libxslt.spec.in python/Makefile.am: fixed some troubles
+         with "make rpm"
+
+Wed Aug 21 18:59:28 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxslt.c: fixed the parameter order when calling
+         Python based extensions.
+
+Wed Aug 21 13:48:07 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c libxslt/xslt.c: fixed bug #89258 and a bit of
+         cleanup.
+       * tests/docs/Makefile.am tests/docs/bug-90.xml
+         tests/general/Makefile.am tests/general/bug-90.*: added the
+         example in the regression tests for this case
+
+Tue Aug 20 16:40:48 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * win32/Makefile.msvc: added the prefix location to the include
+       and lib search path.
+
+Mon Aug 19 15:03:11 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: found and fixed the small <xsl:choose>
+         bug which was giving troubles to DocBook users (the test expression
+         of <when> was evaluated in the namespace context of <choose> !)
+
+2002-08-18  Havoc Pennington  <hp@pobox.com>
+
+       * autogen.sh: hardcode aclocal-1.4/automake-1.4 so that users with
+       both automake 1.6 and 1.4 installed get the right automake. Means
+       compilation from CVS will now require the latest automake 1.4
+       release, or manually creating symlinks called "automake-1.4" and
+       "aclocal-1.4"
+
+Wed Aug 14 18:54:19 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in python/Makefile.am: AMD x86-64 induced changes from
+         Frederic Crozat
+
+Wed Aug 14 13:35:04 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/functions.c: recovering to the old (somewhat) broken
+         implementation of document('') when there is no base for the
+         source document or it can't be realoaded (e.g. when the sytlesheet
+         was loaded from a memory string). Matt Sergeant insisted on this
+         one :-)
+
+Tue Aug 13 11:21:44 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: applied another patch from Nathan Myers about
+         a possible memory leak in case of error
+
+Mon Aug 12 23:12:59 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: applied a patch from Nathan Myers about
+         an erroneous free in case of error
+
+Thu Aug  1 14:29:11 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: upon suggestion of Marc-Andre Lemburg, make 
+         the misdetection of libxml2 python bindings a warning only
+
+Sun Jul 21 19:10:00 HKT 2002 William Brack <wbrack@mmm.com.hk>
+
+       * xsltInternals.h/xslt.c/transform.c and pattern.c: fixed
+         a bug reported by Gero Meissner (87230)
+       * fixed a problem compiling python directory when multiple
+         'make' jobs were executed (python/Makefile.am)
+
+Wed Jul 17 19:58:36 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attributes.c: fixed a bug reported by Keith Isdale
+         at the xsltdbg interface when encountering an empty attribute
+         set.
+
+Wed Jul 17 19:51:47 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * tests/* : the change in HTML meta encoding tag serialization
+         affected some of the results
+
+Thu Jul 11 22:04:30 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/Makefile.am: adding doc/xsltproc.xml to the tarball
+         to fix Red Hat bug #68614 
+
+Wed Jul 10 21:28:11 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+       
+       * win32/Makefile.msvc: Made the copy *.pdb in install succeed even
+         if there is no *.pdb
+       
+Sat Jul  6 22:00:08 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: preparing 1.0.19
+       * doc/* : rebuilt the docs
+
+Sat Jul  6 17:51:14 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixed bug #83749 about namespace generated
+         being invalid when they are inherited from the context.
+
+Fri Jul  5 22:27:47 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixed bug #86753 on multiple identical
+         attributes being generated, oops ...
+       * tests/docs/Makefile.am tests/docs/bug-89.xml
+         tests/general/Makefile.am tests/general/bug-89.*: added an
+         example in the regression tests for this case
+       
+Fri Jul  5 18:28:08 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/preproc.c libxslt/transform.c: fixed bug #87279
+       * tests/docs/Makefile.am tests/docs/bug-88.xml
+         tests/general/Makefile.am tests/general/bug-88.*: added an
+         example in the regression tests for this case
+
+Fri Jul  5 16:30:02 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/preproc.c libxslt/xsltutils.c: applied a patch from
+         Ken Neighbors to implement/fix sorting orders
+       * tests/docbook/result/*/gdp-handbook.* 
+         tests/docbook/result/xtchunk/html/*.orig
+         tests/general/bug-12-.out tests/general/bug-63.out:
+         cleaned up the result of "make tests" following some changes
+         in namespace axis order and serialization rules in libxml2
+
+Thu Jul  4 16:53:00 HKT 2002 William Brack <wbrack@mmm.com.hk>
+
+       * transform.c further enhancement for bug 84902 (another
+         path), also cleaned up code slightly
+
+Wed Jul  3 00:50:00 HKT 2002 William Brack <wbrack@mmm.com.hk>
+
+       * transform.c: fixed bug 84902 - message with terminate=yes
+         caused segfault
+
+Tue Jul  2 00:02:53 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-87.xml
+         tests/general/Makefile.am tests/general/bug-87.*: added a
+         example in the regression tests for a case where the XML
+         default namespace was missing from the namespace axis
+       * xsltproc/xsltproc.c: added the informations that parameter
+         strings are expected to be UTF8
+       * libxslt/attributes.c: fixes on attribute group implementation
+
+Sat Jun 29 21:12:14 MDT 2002 John Fleck <jfleck@inkstain.net>
+
+       * doc/xsltproc.xml, doc/xsltproc.html/, doc/xsltproc.1
+       updating docs to add reference to UTF-8 requirement for
+       stringparam command line option
+
+Wed Jun 19 13:43:00 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/documents.c libxslt/functions.c libxslt/xsltInternals.h:
+         fixed document('') as pointed by Eric van der Vlist
+       * tests/docs/Makefile.am tests/docs/bug-86.xml
+         tests/general/Makefile.am tests/general/bug-86.*: added the
+         specific example in the regression tests
+
+Sat Jun 15 15:44:58 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/numbers.c libxslt/numbersInternals.h: applied a
+         patch from Ken Neighbors fixing some format-number inconsistencies
+       * tests/numbers/format-number.out tests/numbers/format-number.xml
+         tests/numbers/format-number.xsl: the patch also included
+         updates to the regression tests
+
+Mon Jun 10 14:55:31 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/numbers.c: patch from Richard Jinks t correct a bug in
+         xsl:number level="multiple"
+       * tests/docs/Makefile.am tests/docs/bug-84.xml
+         tests/general/Makefile.am tests/general/bug-84.*: added a 
+         specific example in the regression tests
+
+Fri May 31 09:33:09 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/dynamic.c: turned a function static
+       * libxslt/win32config.h: applied patch from Mark Vadoc
+
+Thu May 30 23:35:47 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * win32/Makefile.msvc libexslt/Makefile.am libexslt/date.c
+         libexslt/dynamic.c libexslt/exslt.c libexslt/exslt.h: applied
+         a patch from Mark Vakoc to implement the EXSLT
+         object dyn:evaluate(string) extension function, and a small fix
+         to date.c
+
+Mon May 27 23:24:57 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: preparing 1.0.18
+       * doc/*: recompiled the API and web site
+
+Mon May 27 19:14:46 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/namespaces.c libxslt/transform.c: fix bug #81099 about
+         duplicated namespace declarations, this might not be as generic as
+         it should but works well for DocBook stylesheets
+
+Sat May 25 12:07:45 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt.pc.in: fix bug #82970
+
+Fri May 24 15:02:50 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxslt-python-api.xml python/libxslt.c 
+         python/libxsltclass.txt : tried to fix #79105 by providing a 
+         specific error registering routine.
+
+Thu May 23 17:28:35 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltutils.[ch] : applied patch from Morus Walter
+         adding xsltSaveResultToString()
+       * doc/APIfiles.html doc/APIfunctions.html doc/libxslt-api.xml
+         doc/libxslt-decl.txt doc/libxslt-refs.xml: this increased the
+         API with the new function.
+
+Wed May 22 11:50:36 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/function.c: applied a patch from Richard Jinks
+         to avoid a crash in element-available()
+
+Tue May 21 19:38:20 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt.spec.in: applied patch from Geert Kloosterman to
+         not miss gif and .png files in the RPM  documentation
+
+Tue May 21 08:43:11 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/libexslt.4: Applied patch for the EXSLT man page
+         from Charles Bozeman
+
+Sat May 18 10:01:38 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/libexslt.4 libxslt/libxslt.4 libxslt/keys.c 
+         libxslt/xsltconfig.h.in: applied a man page patch from 
+         Christian Cornelssen and fixed a couple of issues he raised.
+
+Thu May 16 19:38:24 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: moved the extension dump out of the loop
+
+Thu May 16 19:31:35 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extensions.[ch]  xsltproc/xsltproc.c win32/libxslt.def.src:
+         Applied Mark Vakoc patch to show registered extensions in xsltproc
+       * doc/*: rebuilt the API, docs and website
+       * python/libxsltclass.txt: this added an entry point
+
+Wed May 15 00:20:10 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * libxslt/xslt.c: xsl:include crash fix
+       * libxslt/imports.c: xsl:include crash fix
+       * libxslt/imports.h: xsl:include crash fix      
+
+Wed May  9 01:39:14 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * libexslt/exslt.h: fixed a typo _cplusplus -> __cplusplus
+
+Thu May  2 11:08:22 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c libxslt/xsltutils.c doc/xsltproc.xml:
+         fixed some return code problems raised by Thomas Mauch
+
+Tue Apr 30 18:06:14 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: don't allow adding an attribute to
+         a document node
+
+Mon Apr 29 19:00:22 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in libxslt/xsltwin32config.h: preparing 1.0.17
+       * doc/*: rebuilt the docs.
+
+Mon Apr 29 17:22:08 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/variables.c: better attempt to fix the problem in
+         xsltProcessUserParamInternal reported by Babak Vahedipour-Kunze
+
+Sun Apr 28 17:53:23 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * win32/dsp/*.dsp: Removed obsolete macros
+       * win32/dsp/*.def: Updated export definitions
+       
+Sun Apr 28 17:47:17 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/variables.c: tried to fix a problem in
+         xsltProcessUserParamInternal reported by Babak Vahedipour-Kunze
+
+Fri Apr 26 08:15:30 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/date.c: applied another patch from Charles Bozeman to
+         enhance date/duration support
+       * tests/exslt/date: added the associated set of regression tests
+
+Thu Apr 25 08:18:57 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/date.c: applied a patch from Charles Bozeman to add
+         duration routines to the date exslt extensions.
+
+Thu Apr 18 22:56:06 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/exslt.h: extern "C" {  missing by Mark Vakoc
+
+Tue Apr 17 23:16:54 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * libexslt/date.c: fixed type inconsistencies, double->int
+        and unsigned/signed mismatch warnings eliminated
+
+Tue Apr 16 19:40:21 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+       * win32/Makefile.msvc: XSLT debugger support fix
+       * win32/configure.js: XSLT debugger support fix
+       * libxslt/xsltconfig.h.in: XSLT debugger support fix
+
+Mon Apr 15 19:27:31 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: preparing 1.0.16
+       * doc/*: updated and rebuilt the docs
+
+Mon Apr 15 17:27:51 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attributes.c: removed a warning
+       * libxslt/transform.c libxslt/transform.h win32/libxslt.def.src:
+         added xsltRunStylesheetUser() API needed to fix #78546
+       * xsltproc/xsltproc.c: second part of the fix #78546
+
+Mon Apr 15 15:57:28 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/Makefile.am: fixing the equivalent of #75779
+
+Mon Apr 15 14:00:12 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/keys.c: fixed bug #78735
+       * configure.in tests/Makefile.am tests/keys/*:
+         added the tests in a separate directory
+
+Mon Apr 15 00:01:07 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-83.xml
+         tests/general/Makefile.am tests/general/bug-83.*: added a 
+         specific example for bug #78662 in the regression tests
+       * tests/docbook/: this also changed a couple of DocBook results
+       
+Sun Apr 14 15:32:23 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: trying to kill #77827 IEEE conformance on alphas
+       * libxslt/imports.c libxslt/transform.c libxslt/xslt.c: fixing
+         bug #78211
+       * tests/docs/Makefile.am tests/docs/bug-82.xml
+         tests/general/Makefile.am tests/general/bug-82.*: added a 
+         specific example for bug #78211 in the regression tests
+
+Wed Apr 10 20:35:54 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: applied patch from Mark Vakoc
+
+Fri Mar 29 18:28:23 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-81.xml
+         tests/general/Makefile.am tests/general/bug-81.*: added a 
+         specific example for bug #76927 in the regression tests
+       
+Wed Mar 27 10:03:11 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * AUTHORS HACKING: Added Igor Zlatkovic as official maintainer
+       * python/Makefile.am python/tests/Makefile.am: Albert Chin pointed
+         that $(datadir) should be used for docs
+
+Mon Mar 25 17:56:44 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: preparing 1.0.15
+       * doc/*: updated and rebuilt
+
+Mon Mar 25 17:11:42 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attributes.c libxslt/attributes.h libxslt/pattern.c
+         libxslt/xslt.c: Fix bug #76043 about cascading attribute sets
+       * tests/docs/Makefile.am tests/docs/bug-80.xml
+         tests/general/Makefile.am tests/general/bug-80.*: added a 
+         specific example for bug #76043 in the regression tests
+
+Fri Mar 22 19:26:47 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: Fixing bug #75902 error with @foo[..]
+         steps which were not compiled
+       * tests/docs/Makefile.am tests/docs/bug-79.xml
+         tests/general/Makefile.am tests/general/bug-79.*: added a 
+         specific example for bug #75902 in the regression tests
+       
+Fri Mar 22 16:13:22 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: Fixing bug #75777 error with namespaced
+         attribute match rules evaluation
+       * tests/docs/Makefile.am tests/docs/bug-78.xml
+         tests/general/Makefile.am tests/general/bug-78.*: added a 
+         specific example for bug #75777 in the regression tests
+       
+Thu Mar 21 17:19:56 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: found another stupid bug by step by 
+         step processing of the code
+       * libxslt/pattern.c: idem, except that once stupid mistake
+         ELEM vs NODE forced the templates to be stored in a list
+         instead of a hash table, fixing this stupidity should
+         again lead to a substantive improvement of processing speed.
+         Like divide by 2 processing time for DocBook stylesheets.
+
+Thu Mar 21 00:25:12 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixing bug #75603
+       * tests/docs/Makefile.am tests/docs/bug-77.xml
+         tests/general/Makefile.am tests/general/bug-77.*: added a 
+         specific example for bug #75603 in the regression tests
+
+Wed Mar 20 17:49:43 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/Makefile.am: Art Haas pointed a stupid error
+
+Tue Mar 19 19:42:01 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * Makefile.am tests/Makefile.am tests/*/Makefile.am
+         tests/*/*/Makefile.am : added "make valgrind" targets
+         to run the test suite under the debugger control
+       * transform.c: valgrind spotted 2 bugs, one related to
+         the ordering of the deallocation of the data associated to
+         a transofrmation, the second in xsltCopyTree when the new
+         node may have been coalesced with an adjacent text node.
+         The regression tests now pass cleanly under testgrind.
+
+Mon Mar 18 21:33:38 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/Makefile.am: fixed a stupid bug
+
+Mon Mar 18 20:45:27 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: preparing 1.0.14
+       * doc/*: updated rebuilt
+       * libxslt/*.c libexslt/*.c libxslt/libxslt.h libexslt/libexslt.h:
+         implemented the IN_LIBXSLT and IN_LIBEXSLT mechanism discussed
+         with the Windows maintainers
+
+Mon Mar 18 16:22:46 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/Makefile.am python/generator.py python/libxslt.c
+         python/types.c python/tests/Makefile.am: applied the same kind of
+         fixes to the Python Makefiels than to libxml2 ones. Updates
+         and cleanups too.
+
+Sat Mar 16 23:48:21 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/common.c libxslt/pattern.c  libxslt/transform.c
+         libxslt/variables.c: chaing result tree values which may
+         be deallocated and must not be kept in the template 
+         pattern lookup cache. Thanks to Valgrin to allow finding
+         the real problem in bug #74857
+
+Wed Mar 13 15:17:51 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/*.h doc/* python/*: applied another cleanup comment
+         diff from Heiko W. Rupp, regenerated the API and python
+
+Wed Mar 13 13:41:19 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-76.xml
+         tests/general/Makefile.am tests/general/bug-76.*: added a 
+         home brewed test for path computation elmininating duplicate
+         in result sets.
+
+Sat Mar  9 11:53:39 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/Makefile.am: fixed a build problem in some environements
+
+2002-03-08  jacob berkman  <jacob@ximian.com>
+
+       * python/Makefile.am (libxsltmodule_la_SOURCES): remove $(srcdir)
+       as make will automatically look there for these files
+
+Fri Mar  8 17:44:31 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in libxslt/xsltwin32config.h: preparing release
+         1.0.13
+       * doc/*: updated and rebuilt the docs
+       * python/libxslt.c: fixed a possible reentrancy problem
+
+Fri Mar  8 14:51:59 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: Fixes the problems exposed by #73880
+         those ought to be computed at stylesheet compile time, not
+         at run-time, and the computation was wrong.
+       * libxslt/transform.c: get rid of fake nodes coming from node-set
+          transformations. At least if they are still produced they will
+         become easy to spot as resulting document won't be well-formed.
+
+Thu Mar  7 17:01:21 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extensions.c: fixed bug #73791 related to extension
+         function declared in included stylesheets
+       * tests/exslt/functions/function.7.*: added specific test
+
+Thu Mar  7 15:20:32 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-75.xml
+         tests/general/Makefile.am tests/general/bug-75.*: added a 
+         specific example for bug #72150 in the regression tests
+
+Thu Mar  7 15:17:21 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in xsltproc/xsltproc.c: fixed bug #71488 in a
+         similar way as #71457
+
+Thu Mar  7 09:41:59 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * tests/xmlspec/REC-xml-20001006*.html tests/XSLTMark/xslbench1.out:
+         some HTML meta encoding fixups resulting from fix in libxml2
+
+Mon Mar  4 18:09:48 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/namespaces.c tests/general/bug-63.out: small fixups
+         related to the XPath changes in fixing #61290
+         
+Mon Mar  4 12:57:21 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: fixed bug #73363, bad tokenization of
+         pattern
+
+Mon Mar  4 12:01:34 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/date.c: patch from Charles Bozeman for the exslt date
+         extension
+       * configure.in tests/exslt/Makefile.am tests/exslt/date/*: added
+         the associated regression test provided by Charles
+
+Fri Mar  1 10:17:26 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/preproc.c: Fixed #73088 with the associated patch
+
+Fri Mar  1 10:14:07 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: similar to #72663 and #72658, don't memdump
+         unless compiled explicitely with memory debugging switched on
+       * TODO: refreshed a bit
+
+Fri Feb 22 23:44:57 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/generator.py python/libxslt.c: changes for the 'usual'
+         setup.py to allow building a libxml2-python
+         module based on the same code. The initialization is however
+         different the 2 .so files fo libxml2 and libxslt are identical and
+         they entry point initialize both libraries. this is done to avoid
+         some possible nasty problem since the Python don't merge the maps
+         of all shared modules.
+       * python/libxsl.py: attempt to cope with the shared library loading
+         problem when both modules are not merged.
+
+Thu Feb 21 12:59:59 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/site.xml doc/xslt.html doc/python.html doc/*.html: added
+         documentation for the wrappers and python modules.
+
+Wed Feb 13 14:22:22 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-74.xml
+         tests/general/Makefile.am tests/general/bug-74.*: added a 
+         specific example for bug #71342 in the regression tests
+       * tests/docbook/result/xhtml/gdp-handbook.xhtml: fixing
+         #71342 changed one attribute serialization.
+
+Tue Feb 12 15:08:38 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/Makefile.am: trying to fix #71270 
+
+Mon Feb 11 19:40:34 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/*.py: removed tab used spaces
+       * configure.in libxslt/xsltwin32config.h: preparing 1.0.12
+       * doc/news.html doc/xslt.html: rebuild/updated
+
+Mon Feb 11 16:34:37 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-73.xml
+         tests/general/Makefile.am tests/general/bug-73.*: added a 
+         specific example for bug #71181 in the regression tests
+
+Mon Feb 11 16:22:36 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: fixed bug #71181 p/text() would not
+         work. A bit of cleanup.
+
+Mon Feb 11 15:01:42 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * xslt-config: fixing Red Hat bug #59508
+
+Mon Feb 11 14:27:25 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-72.xml
+         tests/general/Makefile.am tests/general/bug-72.*: added a 
+         specific example for bug #58444 in the regression tests
+
+Mon Feb 11 14:13:07 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixed bug #58444, was quite simpler
+         than expected.
+
+Mon Feb 11 13:27:42 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltInternals.h libxslt/pattern.c: expected to have
+         closed bug #70131, still wondering about the position() when
+         the node is selected.
+
+Mon Feb 11 10:45:27 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docs/Makefile.am tests/docs/bug-71.xml
+         tests/general/Makefile.am tests/general/bug-71.*: added a 
+         specific example for Norm's bug in the regression tests
+
+Sun Feb 10 22:08:51 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attributes.c: fixed a bug reported by Norm
+
+Sun Feb 10 20:25:28 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxml.c : fixed a small warning.
+       * doc/libxslt-api.xml doc/libxslt-decl.txt doc/libxslt-refs.xml
+         python/libxsltclass.txt: rebuilt the APIs
+
+Sun Feb 10 20:16:15 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/imports.c libxslt/numbers.c libxslt/pattern.c
+         libxslt/pattern.h libxslt/transform.c libxslt/xslt.c
+         libxslt/xsltInternals.h: adding extra run-time informations
+         to make the stylesheet really read-only at run-time.
+
+Sun Feb 10 16:21:09 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixing bug #70281
+
+Sun Feb 10 15:10:56 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/numbers.c: trying to fix #68759
+
+Sat Feb  9 23:17:53 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/Makefile.am: seems some version of automake didn't
+         generate the dependancies right as Jacob found out. Add
+         an extra dependancy rule.
+
+Sat Feb  9 19:04:01 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in libxslt.spec.in python/Makefile.am python/generator.py
+         python/libxsl.py python/libxslt.c python/tests/Makefile.am:
+         Fixed the python Makefiles, corrected a bug showing up on ia64,
+         changed the name of the python internal module too
+
+Fri Feb  8 17:01:10 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * Copyright Makefile.am configure.in libxslt.spec.in: change the
+         Licence to MIT Licence and release of 1.0.11
+       * doc/FAQ.html doc/intro.html doc/libxslt-decl.txt doc/news.html 
+         doc/xslt.html: updates of the docs accordingly
+       * libxslt/xsltwin32config.h: numbering
+       * python/generator.py python/libxml_wrap.h python/libxsltclass.txt
+         python/libxslt-python-api.xml: cleanup the dependancies with
+         libxml2
+       * python/tests/extfunc.py: updated examples.
+
+Thu Feb  7 23:21:18 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/libxslt-api.xml doc/libxslt-decl.txt doc/libxslt-refs.xml
+         doc/parsedecl.py: fixup the script and rebuid the API
+       * libxslt/extensions.h: cleanup
+       * python/generator.py python/libxslt-python-api.xml python/libxslt.c
+         python/libxsltclass.txt: provided accessors for a lot of the
+         tructures involved in the transformation. Stylesheet and
+         transformation python object don't free automatically the
+         encapsulated object when deallocated.
+       * python/tests/Makefile.am python/tests/basic.py
+         python/tests/extfunc.py python/tests/pyxsltproc.py:
+         updated the examples
+
+Thu Feb  7 17:59:27 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: small fix
+       * Makefile.am: cleanup
+       * python/tests/Makefile.am: avoid a problem with $(TESTS)
+       * python/generator.py python/libxml_wrap.h python/libxsl.py
+         python/libxslt.c python/libxsltclass.txt: augmented the
+         wrappers
+       * python/tests/pyxsltproc.py: rewrote xsltproc on top of the
+         libxslt-python API to get an estimate of what is missing
+
+Wed Feb  6 23:34:10 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxsl.py python/libxslt-python-api.xml python/libxslt.c
+         python/libxsltclass.txt: added libxslt_xsltCleanup() added parameters
+         to libxslt_xsltApplyStylesheet() removed the memleaks left and
+         fixed an import order.
+       * python/tests/basic.py python/tests/extfunc.py: updated the tests
+
+Wed Feb  6 19:46:09 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * python/libxlst.c python/libxslt-python-api.xml 
+         python/libxsltclass.txt: plugged the extension of the engine
+         with python defined functions
+       * python/tests/Makefile.am python/tests/extfunc.py: added a
+         basic test, still a memleak, cleanup function needed.
+
+Wed Feb  6 13:49:55 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt.spec.in python/Makefile.am python/libxsl.py: the
+         spec file will now build libxslt-python, fought with shared
+         and other crazyness, seems to work now :-)
+       * doc/libxslt-api.xml: regenerated
+
+Wed Feb  6 11:29:31 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * Makefile.am configure.in tests/Makefile.am tests/*/Makefile.am
+         tests/*/*/Makefile.am: refactored make tests, make all now don't
+         run the test suite
+       * python/Makefile.am: added tests
+       * python/tests/basic.py python/tests/Makefile.am: added the first
+         basic test, memory debug included
+
+Wed Feb  6 00:20:57 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in python/Makefile.am: attempst to tweak to get
+         full memory debug...
+       * python/generator.py python/libxsl.py python/libxslt-python-api.xml
+         python/libxslt.c python/libxslt_wrap.h python/libxsltclass.txt:
+         the basic API starts to work
+       * python/tests/test.*: first basic test
+       * libxslt/xsltutils.c: fixed a comment
+
+Tue Feb  5 17:35:00 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in doc/Makefile.am: do not install outside of prefix,
+         make sure the API get shipped.
+
+Mon Feb  4 19:47:32 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.[ch] doc/libxslt-api.xml doc/libxslt-refs.xml:
+         reactivated xsltMatchPattern() since this is really something
+         one may want to have access to in an extension function.
+       * Makefile.am configure.in python/Makefile.am python/generator.py
+         python/libxml_wrap.h python/libxsl.py python/libxslt-python-api.xml
+         python/libxslt.c python/libxslt_wrap.h python/libxsltclass.txt
+         python/types.c: started working on the python bindings, borrowed
+         most of the work done for libxml2, most of the generator code
+         is similar. Commit at the point where this compiles cleanly and
+         "import libxslt" doesn't yield any missing entry point.
+
+Wed Jan 30 12:46:41 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: patch from Charles Bozeman to support
+         child::* patterns.
+
+Wed Jan 30 12:35:28 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/keys.c: Bob Stayton pointed out a problem when
+         using unions in key match patterns.
+       * tests/docs/Makefile.am tests/docs/bug-70.xml
+         tests/general/Makefile.am tests/general/bug-70.*: added a 
+         specific example in the regression tests
+       
+Sun Jan 27 13:54:10 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: avoid a problem with Sun's Workshop CC,
+         closes bug #69809 submitted by Michael Kroell
+
+Fri Jan 25 15:31:23 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: added links to the Web site from usage()
+
+Wed Jan 23 23:13:37 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/API*.html doc/parsedecl.py doc/*.xsl parsedecl.py: generated
+         an index based on comments content similar to libxml2 one
+         The code need more specific comments.
+       * doc/*: rebuilt the web site with the new references
+
+Mon Jan 21 09:53:45 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/functions.h: roll back the change after more analysis
+         proper fix is to restore the definition of xmlXPathFuncLookupFunc
+         int libxml2
+
+Mon Jan 21 09:41:10 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/functions.h: fixed a proble  after some cleanup of libxml2
+         includes.
+
+Sun Jan 20 14:33:33 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: Fixed RH bug #58124 due to an off-by-one
+         error when parsing -o arguments.
+
+Sun Jan 20 14:15:55 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/xsltproc.xml libxslt/xsltutils.c xsltproc/xsltproc.c:
+         Fixed RH bug #57496, xsltproc was not returning error
+         code on internal runtime errors. Should return 9 now.
+
+Fri Jan 18 09:43:16 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/math.c: Charlie Bozeman provided the implementation
+         for the EXSLT math other functions
+
+Thu Jan 17 23:41:53 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/Makefile.am: jacob berkman pointed out that the
+         Cygwin patch forgot to add libexslt.h to the tarball
+
+Thu Jan 17 23:39:00 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: fixed I18N problemes in the template parser
+         pointed out by Xavier Cazin
+       * tests/docs/Makefile.am tests/docs/bug-69.xml
+         tests/general/Makefile.am tests/general/bug-69.*: added a 
+         specific example in the regression tests
+
+Thu Jan 17 10:40:03 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * Makefile.am libexslt/common.c libexslt/date.c libexslt/exslt.c
+         libexslt/exslt.h libexslt/exsltconfig.h.in libexslt/functions.c
+         libexslt/libexslt.h libexslt/math.c libexslt/saxon.c
+         libexslt/sets.c libexslt/strings.c libxslt/libxslt.h
+         libxslt/xslt.h libxslt/xsltconfig.h.in libxslt/xsltutils.c
+         xsltproc/xsltproc.c: applied Robert Collins patch for 
+         Cygwin support
+
+Thu Jan 17 10:34:39 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/Makefile.am configure.in: ugly way to keep
+         the memory debugging active on my devel workstation
+         by bypassing libtool completely
+
+Tue Jan 15 12:00:18 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/templates.c: fixed bug #68751
+       * tests/docs/Makefile.am tests/docs/bug-68.xml
+         tests/general/Makefile.am tests/general/bug-68.*: added a 
+         specific example in the regression tests
+       
+Tue Jan 15 10:40:41 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c xsltproc/xsltproc.c: fixed a couple of
+         small problems raised by Justin Fletcher
+
+Mon Jan 14 18:35:18 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: releasing 1.0.10
+       * doc/*: updating the docs for the release.
+       * libxslt/namespaces.c libxslt/pattern.c libxslt/transform.c:
+         seems I inadvertantly commited previously stuff from a failed
+         attempt at fixing namespace nodes parents.
+
+Mon Jan 14 12:20:33 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/numbers.c: the xsl:number implementation incorrectly
+         cached the format string in some case. Fixes bug #65391
+
+Mon Jan 14 10:35:27 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: fixed a couple of cut and paste errors in the
+         math functions detection
+       * libxslt.spec.in: added missing file entry for libxslt.pc
+
+Tue Jan  8 21:04:17 MST 2002 John Fleck <jfleck@inkstain.net>
+
+       * doc/xsltproc.xml, doc/xsltproc.1, doc/xsltproc.html
+       update xsltproc man page to add --stringparam option
+
+Tue Jan  8 17:21:02 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: added the --stringparam option
+       * xsltproc/xsltproc.c: applied John Fleck's patch to correct
+         the --novalid behaviour.
+
+Tue Jan  8 13:51:08 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/site.xsl doc/*.html: added a DocBook section docbook.html
+
+Tue Jan  8 12:51:15 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * doc/*.html: updated gdome2 homepage
+
+Sat Jan  5 19:32:17 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * win32/dsp: Windows/MSVC project files update from Igor Zlatkovic
+
+Fri Jan  4 22:13:40 MST 2002 John Fleck <jfleck@inkstain.net>
+
+       * doc/xsltproc.xml, xsltproc.1 - updating man page to reflect
+       increased number of parameteres, changed license, cleaned up some
+       places where it looked junky because of stylesheet issues
+
+Fri Jan  4 15:50:25 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: increased the max number of parameters
+
+Thu Dec 20 14:54:27 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt.pc.in configure.in: added pkg-config file from Rodrigo Moya
+
+Thu Dec 20 14:49:39 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: applied albert portability patch
+       * libxslt/libxslt.h libxslt/xslt.h libxslt/xsltconfig.h.in
+        libxslt/xsltutils.c libxslt/xsltwin32config.h.in win32/dsp/libxslt.def:
+        applied Igor patch for Windows
+
+Tue Dec 11 15:27:15 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltutils.c: fixed a problem with the debuuger interface.
+
+Fri Dec  7 15:48:48 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: preparing 1.0.9
+       * doc/*: updated and rebuild the doc
+
+Thu Dec  6 14:57:56 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in libexslt/Makefile.am: trying to fix the problem
+         related to prelinking and libtools crazyness
+
+Wed Dec  5 18:49:53 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c libxslt/variables.c: applied Keith Isdale
+         patch for the debugger glue.
+
+Wed Dec  5 18:43:45 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * breakpoint/Makefile.am breakpoint/deprecated.c: replaced
+         the whole module with just the entry points.
+
+Fri Nov 30 18:59:50 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: Nik Clayton found a bug introduced in
+         1.0.8 when using doctypes for HTML output
+
+Fri Nov 30 12:59:05 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attributes.c libxslt/transform.c libxslt/xsltutils.c
+         libxslt/xsltutils.h: revamped the mechanism to hook a debuger
+         to use a callback setup function, deprecating libxsltbreakpoint
+       * xsltproc/Makefile.am configure.in breakpoint/Makefile.am: removing
+         dependancies on libxsltbreakpoint
+
+Thu Nov 29 09:52:38 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+        Build patch from  Peter Williams  <peterw@ximian.com>
+       * breakpoint/Makefile.am (INCLUDES): meed $(top_builddir)/libxslt.
+       * doc/Makefile.am ($(PAGES)): xslt.html and site.xsl live in
+         $(srcdir), not the build directory.
+
+Wed Nov 28 11:17:04 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * doc/FAQ.html doc/site.xsl doc/*.html doc/Makefile.am: added an FAQ
+
+Tue Nov 27 21:15:43 MST 2001 John Fleck <jfleck@inkstain.net>
+
+       * doc/xsltproc.xml, xsltproc.1, xsltproc.html - documenting new
+       xsltproc return codes, per
+       https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=56649 
+
+Tue Nov 27 22:16:50 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: Marc Tardif provided a patch to use as
+         much as 40 steps. A dynamic alloc would still be better
+
+Mon Nov 26 21:45:07 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: return useful code signaling error conditions
+         closing #56649 (RH)
+
+Mon Nov 26 13:14:14 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in libxslt/xsltwin32config.h: preparing release of 1.0.8
+
+Mon Nov 26 11:21:27 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: fixing bug #64044 reported by Gero Meißner,
+         template matches compilation was failing to skip blanks bewteen
+         consecutive predicates
+
+Mon Nov 26 10:27:30 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * Makefile.am configure.in breakpoint/Makefile.am libexslt/Makefile.am:
+         updating Makefiles to fix the prelinking.
+
+Sun Nov 25 15:52:38 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+* libxslt/transform.c: fixed a bug in the document extension
+         element where the doctype infos were not taken into account.
+
+Thu Nov 22 19:08:23 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extra.c: fixed xsltDebug() to output with the normal
+         error routines
+       * tests/namespaces/*: updated the tests to separate stdout and
+         stderr
+       * libxslt/transform.c: increasing xsltMaxDepth to 5000
+
+Thu Nov 22 12:09:56 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in libexslt/Makefile.am: more Makefile fixups
+
+Wed Nov 21 16:29:04 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in libexslt/Makefile.am: trying to fix more Makefiles
+         crapola
+       * libxslt/transform.c: small fix.
+
+Tue Nov 13 16:16:41 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * vms/* Makefile.am: included OpenVMS port instructions from
+         John A Fotheringham, integrated in the tar file.
+
+Mon Nov 12 22:46:26 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * win32/dsp/* xsltproc/xsltproc.c libxslt/transform.c: Patches
+         from Igor for Windows
+       * libxslt/xslt.h: try to fix the  LIBXSLT_PUBLIC mess
+
+Sun Nov 11 21:15:05 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixing bug #64298 reported by T. V. Raman
+
+Sat Nov 10 14:01:44 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: preparing 1.0.7
+       * libxslt.spec.in: cleanup similar to libxml2 one
+       * breakpoint/*.[hc]: finished cleaning up contributed code
+       * doc/*: updated and rebuilt the documentation
+       * xsltproc/xsltproc.c: cleanup of the timing code
+       * xsltproc/Makefile.am: auto* sucks
+       * libxslt/transform.c: added a missing include
+
+Mon Nov  5 14:29:26 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * Makefile.am acconfig.h config.h.in configure.in 
+         xsltproc/Makefile.am breakpoint/* libxslt/transform.[ch]
+         libxslt/xsltconfig.h.in:  Applied Keith Isdale patch for
+         the debugger support, make it the default, added the
+         WITH_XSLT_DEBUGGER define to xsltconfig.h.in, small cleanups
+
+Fri Nov  2 11:19:49 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/libxslt.h: make sure LIBXSLT_PUBLIC is defined
+
+Thu Nov  1 15:15:39 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltutils.c: handle indent=no when using an HTML
+         output
+       * tests/docbook/result/* tests/xmlspec/REC-xml-*.html: this
+         modified the output of those test suites
+
+Wed Oct 31 18:53:26 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: cleanup, moved xsllNoNetExternalEntityLoader()
+         to libxml and removed the --warnnet option
+
+Tue Oct 30 19:32:08 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: applied patches from David Härdeman closing
+         bug #62891
+
+Tue Oct 30 15:25:19 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in libxslt/xsltwin32config.h: preparing 1.0.6
+       * libexslt/date.c: applied patch from Bruce Miller
+       * doc/*: updated and rebuilt the docs
+
+Fri Oct 26 14:12:14 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * win32/dsp/libexslt_a.dsp win32/dsp/libexslt_so.dsp
+         win32/dsp/libxslt.def: updated with latest ZIP from Igor,
+         made sure the .def is handled as binary
+
+Fri Oct 26 11:37:01 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * win32/dsp/libxslt.def libxslt/xslt.h: applied Igor patches
+         for Win32
+       * doc/*.html doc/site.xsl: changed the site stylesheet a bit
+
+Thu Oct 25 23:05:14 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libxslt/numbers.c: take NaN and infinity attributes of
+         xsl:decimal-format into account. Closes #62577
+
+Wed Oct 24 13:02:15 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * doc/*.html doc/site.xsl doc/Makefile.am: the web site
+         is now extracted from the xslt.html flat file using
+         the site stylesheet ... eat your own dogfood !
+       * libxslt/transform.c libxslt/xsltutils.c: fixed the 
+         HTML output to not generate a DOCTYPE if it should not
+         i.e. no identifier nor version specified in the xsl:output
+       * tests/multiple/out/*.orig tests/general/bug-11-.out 
+         tests/general/bug-33-.out tests/general/bug-52.out
+         tests/docbook/result/xtchunk/html/*.orig
+         tests/docbook/result/html/gdp-handbook.html
+         tests/XSLTMark/*.out: fixing xsl:output with method=html
+         resulted in a number of small changes in the regression tests
+         output
+
+Fri Oct 19 16:46:06 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/*.c libexslt/exsltconfig.h.in: moved the 
+         config.h include out of exsltconfig.h since this header is
+         exported and config.h is not.
+
+Wed Oct 17 21:20:55 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attributes.c libxslt/extensions.c libxslt/preproc.c
+         libxslt/transform.c libxslt/xsltutils.h: cleanup TODO into
+         XSLT_TODO
+
+Wed Oct 17 02:46:55 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libxslt/numbers.c: reworked internal representation of
+         tokenized number format and parsing/tokenization. This fixes
+         many bugs regarding separator and default tokens.
+       * tests/REC/test-7.7-3.out: the fix changes the output of this
+         test. It now complies to the XSLT spec (wow! ;o)
+
+Tue Oct 16 11:25:15 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/Makefile.am configure.in config.h.in: trying to
+         bypass libtool crazyness when compiling in my debug environment
+       * libxslt/templates.c: fix a compilation problem due to recent
+         libxml changes
+
+Sun Oct 14 17:17:03 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libxslt/numbers.c tests/REC/test-7.7-4.out: implement initial
+         non-alphanumeric token handling in number formatting.
+
+Wed Oct 10 11:58:41 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: releasing 1.0.5
+       * doc/xslt.html doc/html/*: updated and rebuilt the docs
+
+Wed Oct 10 00:10:01 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * tests/REC/test-7.7-4.out: fixed a typo
+       
+Tue Oct  9 22:59:00 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libexslt/saxon.c: fixed a typo and improved handling of
+         non-XPath-expression arguments.
+       * libexslt/strings.c: fixed a bug in tokenize: function was using
+         tctxt->output instead of tctxt->document->doc.
+       * libxslt/transform.c: fixed a bug in xsltDefaultProcessOneNode
+         which was using variable "node" instead of "cur"
+
+Tue Oct  9 19:51:48 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libxslt/extra.[ch]: removed older SAXON extensions
+         implementations from Darren Graves.
+       * libexslt/date.c: applied patch from Charlie Bozeman to fix
+         a bug with time zone offset on Linux.
+
+Tue Oct  9 13:02:46 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/documents.c libxslt/extra.c libxslt/transform.[ch]:
+         strip-space should also be applied to document imported
+         at run-time.
+
+Tue Oct  9 12:36:53 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/imports.[ch] libxslt/transform.c libxslt/xslt.c:
+         rewrote the way strip-space gets applied. Closes bugs #61962
+       * tests/docs/Makefile.am tests/docs/bug-66.xml
+         tests/general/Makefile.am tests/general/bug-66.*: added a 
+         specific example in the regression tests
+
+Mon Oct  8 11:27:52 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xslt.c: Fixing bug #61913
+       * libxslt/transform.c: removing a small memleak when running with
+         the profiler.
+
+Sun Oct  7 18:53:34 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libexslt/saxon.c libexslt/Makefile.am libexslt/exslt.[ch]:
+         added implementation of SAXON expression(), eval() and
+         evaluate() functions.
+         See http://saxon.sourceforge.net/saxon6.4.4/extensions.html
+       * tests/extension/evaluate.xsl tests/extension/list.{xsl,out}:
+         modified to use SAXON namespace (functions are not registered
+         in the LibXSLT namespace)
+       * tests/exslt/common/object-type.1.out: modified to take account
+         of the new saxon:expression function
+
+Sun Oct  7 13:15:33 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/numbers.c: fixed bug #61070, number ANY formatting 
+         should be faster too.
+       * tests/docbook/result/xtchunk/html/* tests/xmlspec/REC-xml-20001006*.html:
+         updated the result of the tests. A subtle bug unnnoticed yet
+         in the XML Rec formatting got fixed.
+
+Sat Oct  6 19:45:07 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/numbers.c: trying to fix bug #61070, seems there
+         is still a couple of problem left. And optimizations are
+         certainly needed.
+
+Sat Oct  6 15:10:16 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/variables.c: fixing bug #61673 part II
+       * tests/docs/Makefile.am tests/docs/bug-65.xml
+         tests/general/Makefile.am tests/general/bug-65.*: added a 
+         specific example in the regression tests
+
+Sat Oct  6 12:41:37 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: fixed bug #61627
+       * tests/docs/Makefile.am tests/docs/bug-64.xml
+         tests/general/Makefile.am tests/general/bug-64.*: added a 
+         specific example in the regression tests
+       * tests/docs/Makefile.am tests/docs/bug-63.xml
+         tests/general/Makefile.am tests/general/bug-63.*: added a 
+         specific example in the regression tests for bug #61291
+         (fixed in libxml2 module)
+       * tests/reports/Makefile.am tests/reports/undefvar.*: added
+         a test for handling undefined variables
+
+Thu Oct  4 15:49:57 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in xslt-config.in: trying to fix bug #60890
+
+Thu Oct  4 15:28:25 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: applied patch to close bug #60724
+
+Tue Oct  2 21:38:23 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libexslt/date.c: applied patch from Charlie Bozeman that fixes
+         a bug in DAY_IN_WEEK and implements the date:week-in-month function
+
+Tue Oct  2 17:11:15 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extra.[ch] tests/extensions/list.*
+         tests/extensions/evaluate.*: applied patch from Darren Graves
+         adding support for Saxon's evaluate & expression extension functions
+         http://users.iclway.co.uk/mhkay/saxon/saxon6.3/extensions.html
+
+Mon Oct  1 17:18:32 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltwin32config.h.in win32/dsp/libexslt_*.dsp: applied
+         patches from Igor for Windows.
+
+Tue Sep 18 11:48:20 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xslt.c: fixed bug #60624
+       * libxslt/xsltutils.c: improver the error context reporting
+       * tests/reports/Makefile.am tests/reports/tst-2.*: added a
+         specific regression test
+       * xsltproc/xsltproc: free the stylesheet if it contained an error.
+
+Mon Sep 17 14:45:48 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/variables.c: fixed a problem with global var override
+         being reported as an error.
+       * tests/docs/Makefile.am tests/docs/bug-61.xml
+         tests/general/Makefile.am tests/general/bug-61.*: added a 
+         specific example in the regression tests
+       * configure.in tests/Makefile.am tests/reports/*: adding a test
+         to make sure redefinition of global variables in the same stylesheet
+         are still reported
+
+Sat Sep 15 17:32:16 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extra.c: okay the code from Norm is really non
+         portable and break everywhere except on Sun and Linux
+         platform. Compile it only on those targets.
+
+Sat Sep 15 06:25:02 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libexslt/date.c: fixed some bugs (reported by Charles Bozeman
+         and Justin Fletcher)
+
+Fri Sep 14 15:22:30 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/numbers.c: Fixing bug #60415 
+       * tests/docs/Makefile.am tests/docs/bug-61.xml
+         tests/general/Makefile.am tests/general/bug-61.*: added a 
+         specific example in the regression tests
+
+Fri Sep 14 12:42:22 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * tests/docbook/result/*: the change in libxml to output
+         decimal charrefs instead of hexadecimal changed a lot of
+         docbook results
+
+Thu Sep 13 15:30:01 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt.spec.in doc/Makefile.am: install xsltproc man page
+
+Wed Sep 12 21:09:53 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: preparing for 1.0.4
+       * doc/xslt.html doc/html/*: updated and regenerated docs
+
+Wed Sep 12 18:10:33 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libexslt/date.c: fixed some compile warnings and disabled
+         debugging by default.
+
+Wed Sep 12 17:00:53 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * win32/dsp/libxslt.def libxslt/variables.[ch]: trying to
+         incorporate comments from bug #59220
+
+Wed Sep 12 05:51:32 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * configure.in libexslt/date.c libexslt/Makefile.am
+         libexslt/exslt.[ch] libexslt/.cvsignore: added implementation
+         of the EXSLT - Dates and Times core functions.
+         The exsltDateFormat* functions need to be reworked but it
+         works like this, even if it's quite messy.
+       * tests/exslt/strings/.cvsignore: added
+
+Tue Sep 11 14:48:43 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: tell in usage that parameter strings
+         need to be quoted 
+
+Tue Sep 11 13:42:49 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/Makefile.am libxslt/transform.c: trying to close
+         bug #60304 on xsl:fallback usage
+       * tests/docs/Makefile.am tests/docs/bug-60.xml
+         tests/general/Makefile.am tests/general/bug-60.*: added a 
+         specific example in the regression tests
+
+Tue Sep 11 13:02:34 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * tests/documents/Makefile.am tests/documents/*: changed the
+         test to use doc%5Ffile instead of doc%20file, this is 
+         sufficient to preserve the test capacities while closing
+         bug #60090
+
+Tue Sep 11 12:33:03 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extra.c : close #59570 by simply not providing
+         Norm's extension on FreeBSD.
+       * tests/general tests/docs: added a couple of new entries
+         in the testsuite
+       * libexslt/strings.c: NULL initialized a local variable
+         which was tested later on.
+
+Mon Sep 10 22:52:44 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c tests/docbook/result/fo/*: applied fix from
+         #60143 and rebuilt the FO test outputs
+
+Mon Sep 10 19:38:54 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/attributes.c libxslt/transform.c: fixed bug #59757
+         on inheritance of attributes from multiple attributes-sets
+
+Mon Sep  3 02:14:58 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libexslt/Makefile.am libexslt/exslt.[ch] libexslt/strings.c:
+         added implementation of EXSLT - Strings.
+         Currently implemented functins are str:tokenize, str:align
+         str:concat and str:padding.
+       * configure.in tests/exslt/Makefile.am
+         tests/exslt/strings/Makefile.am
+         tests/exslt/strings/tokenize.1.*: added a test for the
+         str:tokenize function.
+
+Fri Aug 31 13:51:53 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/libxslt.4 libexslt/libexslt.4 libxslt/Makefile.am
+         libexslt/Makefile.am: added man pages provided by Heiko Rupp
+
+Wed Aug 29 21:23:54 MDT 2001 John Fleck <jfleck@inkstain.net>
+
+       * doc/tutorial/libxslttutorial.xml, libxslttutorial.html - update
+       tutorial text to add references to global variables cleanups
+
+Wed Aug 29 21:05:43 MDT 2001 John Fleck <jfleck@inkstain.net>
+
+       * doc/xsltproc.1 - added xsltproc man page (note: this has not
+       been added into the build yet)
+
+Wed Aug 29 22:58:58 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * doc/tutorial/libxslt_tutorial.c doc/tutorial/libxslttutorial.html
+         doc/tutorial/libxslttutorial.xml: added global variables cleanups
+         to the example.
+       * tests/documents/Makefile.am: mjcox pointed to some missing files
+
+Wed Aug 29 15:32:52 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libexslt/common.c: fixed a bug in exsltNodeSetFunction
+
+Wed Aug 29 15:18:28 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libexslt/common.c: implemented version 3 of the exslt:node-set()
+         function.
+       * tests/exslt/common/Makefile.am
+         tests/exslt/common/node-set.3.{xml,xsl,out}: added a test
+
+Mon Aug 27 08:27:21 MDT 2001 John Fleck <jfleck@inkstain.net>
+
+       * adding doc/xsltproc.html - html generated from xsltproc.xml,
+       update doc/xslt.html with link to xsltproc.html
+
+Mon Aug 27 08:21:47 MDT 2001 John Fleck <jfleck@inkstain.net>
+
+       * adding doc/xsltproc.xml - user manual for xsltproc
+       
+Sun Aug 26 20:52:02 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/numbers.c libxslt/xslt.c: removed a couple of
+         warning raised by the Windows compiler (Chris Poblete)
+
+Fri Aug 24 01:15:24 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/functions.h libxslt/preproc.c libxslt/transform.c:
+         closed bugs #59212 and #59220
+
+Thu Aug 23 23:18:44 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * config.h.in configure.in xsltproc/xsltproc.c: complete test
+         of a DocBook XSLt transform with --nonet, need stat(), added
+         checking in configure.
+
+Thu Aug 23 17:37:40 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: catalog integration, cleanup with
+         the --nonet option closing #59427
+       * libxslt/xslt.c: removed a small memleak when using a 
+         stylesheet PI
+
+Tue Aug 21 13:17:19 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * //Makefile.am : fixed an error I propagated to nearly all
+         Makefiles.am on Saturday
+
+Tue Aug 21 13:10:03 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/math.c libxslt/numbers.c: use xmlXPathIsNaN() and
+         xmlXPathIsInf()
+       * libxslt/pattern.c: tag a potential threading problem.
+
+Tue Aug 21 11:18:45 CEST 2001 Bjorn Reese <breese@users.sourceforge.net>
+
+       * libxslt/numbers.c libexslt/math.c: Re-worked NaN and Inf
+         support.
+
+Sat Aug 18 15:57:46 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * //Makefile.am : fixed a number of small problems with
+         Makefiles spotted by Albert Chin
+
+Thu Aug 16 14:37:55 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * win32/dsp/libxslt.def: minimal changes to compile 1.0.2 on
+         Windows/MSC
+
+Thu Aug 16 12:58:11 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extensions.c: fixed a permutation of args to
+         xsltPrintErrorContext()
+
+Wed Aug 15 15:19:14 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * Makefile.am config.h.in configure.in libxslt/xsltwin32config.h:
+         release of 1.0.2
+       * tests/docs/Makefile.am libexslt/Makefile.am
+         tests/documents/Makefile.am tests/general/Makefile.am
+         xsltproc/Makefile.am: cleaning of Makefiles pointed out
+         by make distcheck
+
+Wed Aug 15 13:54:41 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/functions.h libxslt/transform.c: a bit of cleanup
+
+Wed Aug 15 12:06:43 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/common.c libexslt/math.c libxslt/Makefile.am
+         libxslt/libxslt.h libxslt/xsltconfig.h.in: cleanup of includes
+         export xsltconfig.h at make install stage
+
+Tue Aug 14 20:51:09 MDT 2001 John Fleck <jfleck@inkstain.net>
+
+       * doc/xslt.html updated xsltproc description with the many new
+         command line options Daniel has added, cleaned up some spelling
+
+Tue Aug 14 18:41:02 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extra.c libxslt/keys.c libxslt/templates.c 
+         libxslt/transform.c libxslt/variables.c libxslt/xsltutils.c:
+         serious changes on Result Value Trees and NodeSets
+         w.r.t. deallocation and collect operations. Probably not
+         100% clean (merge of allocated trees smells like a problem).
+         Seems sufficient to close #58943 . Also check if XPath evaluations
+         failed, and in this case stops the processing and avoid
+         going further, goal is to not segfault on broken XSLT.
+
+Tue Aug 14 15:32:08 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c libxslt/transform.c: trying to kill bug #58878,
+         some associated serious cleanup in the pattern code.
+       * tests/docbook/result/*: regenerated all the results for the
+         docbook testsuite. Seems killing #58878 also changes the
+         fo results seriously.
+       * tests/docs/Makefile.am tests/docs/bug-5[56].xml 
+         tests/general/Makefile.am tests/general/bug-5[56].*: added
+         2 more tests
+
+Tue Aug 14 05:01:30 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libxslt/xslt.c libxslt/xsltInternals.h libxslt/transform.c
+         libxslt/extra.[ch] libxslt/extensions.c libxslt/preproc.[ch]:
+         fixed compilation warnings due to recent changes to the extension
+         framework.
+       * libxslt/preproc.[ch] libexslt/common.c
+         fixed the precomputation of *:document elements
+       * libxslt/functions.h: fixed a compilation warning
+
+Mon Aug 13 11:41:02 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltutils.c: applied fix suggested by Tom Moog
+         for xsltTimeStamp() in bug report #58012
+
+Sun Aug 12 21:53:13 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/functions.c libxslt/keys.c libxslt/transform.c 
+         libxslt/xsltutils.h: cleaned up the code w.r.t. handling
+         of 'non-standard' libxml element like namespace nodes.
+       * tests/docs/Makefile.am tests/docs/bug-54.xml
+         tests/general/Makefile.am tests/general/bug-54.*: added a 
+         specific example in the regression tests
+
+Wed Aug  8 22:57:05 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * HACKING: added John Fleck right to commit in the doc subdir
+
+Tue Aug  7 03:11:31 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * xsltproc/xsltproc.c: for heriting defaulted atts from the DTD
+       * tests/docs/Makefile.am tests/docs/bug-52.xml tests/docs/bug-53.xml
+         tests/general/Makefile.am tests/general/bug-52.*
+         tests/general/bug-53.*: Added a few new tests for recently fixed
+         stuff in libxml
+       * tests/xmlspec/REC-xml-20001006-review.html
+         tests/xmlspec/REC-xml-20001006.html: inheriting default attrs from
+         DTD changed the result by adding extra attributes to the HTML output
+
+2001-08-06  Peter Williams  <peterw@ximian.com>
+
+       * libexslt/Makefile.am, xsltproc/Makefile.am: Fixes for compiling
+       when srcdir != builddir.
+
+Sun Aug  5 09:37:14 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libxslt/extensions.[ch] libxslt/preproc.[ch] libxslt/transform.c
+         libxslt/xslt.c libxslt/xsltInternals.h: modified extension framework
+         to easify extension element precomputation.
+       * libexslt/functions.c: uses the new framework and precomputes
+         func:result elements.
+
+Sat Aug  4 20:42:32 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: bug fix on output="text" from Nicolas Marsgui
+
+Fri Aug  3 14:23:25 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * tests/general/bug-21-.out tests/general/bug-31-.out:
+         this got fixed by libxml patches
+       * win32/readme.msvc win32/dsp/* xsltproc/xsltproc.c
+         Makefile.am libexslt/exslt.[ch] libexslt/exsltconfig.h.in
+         libexslt/functions.c libexslt/math.c libxslt/win32config.h
+         libxslt/xsltconfig.h.in libxslt/xsltutils.h
+         libxslt/xsltwin32config.h libxslt/xsltwin32config.h.in:
+         Applied Igor  Zlatkovic Win32 Facelift No.2 patch, and fixed
+         a few things related to those changes.
+
+Wed Aug  1 13:58:21 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltutils.c: well one need one \n after DOCTYPE
+       * test//*/*.out: the output of some tests changed, looks better
+         actually
+
+Wed Aug  1 13:21:18 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltutils.c: avoid extra \n when serializing top
+         text nodes.
+
+Wed Aug  1 10:37:50 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extra.c: one more revision on Norm's localTime() function
+
+Wed Aug  1 01:37:41 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libexslt/sets.c: fixed bugs in exsltTrailingFunction and
+         exsltLeadingFunction when passing an empty node-set as the
+         second argument
+       * libxslt/functions.[ch]: gave priority to context-level functions
+         over extension module functions. This allows a function declared
+         with a func:function element to override an extension module
+         function for example. This is a bit hackish...
+       * tests/exslt/sets/{lead,trail}ing.1.out: fixed errors. The result
+         values didn't conform to the expected values. This is a bug in
+         the EXSLT official use cases.
+
+Tue Jul 31 23:53:55 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * config.h.in configure.in libxslt/extra.c: tried to integrate
+         Norm's implemntation of localTime()
+
+Tue Jul 31 03:47:10 EDT 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extra.c: fixed a serious proble is node-set was called
+         on a nodeset
+       * tests//*/Makefile.am: fixed the rule to rebuild xsltproc
+
+Lun Jul 30 05:47:43 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libexslt/functions.c: fixed memory leaks
+       
+Sun Jul 29 08:37:59 EDT 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/functions.c libxslt/extensions.[ch] libxslt/extensions.h
+         libxslt/xslt.[hc] libxslt/xsltInternals.h xsltproc/xsltproc.c:
+         more cleanup of the problems introduced with EXSLT, also closes
+         bug #58180
+
+Sat Jul 28 08:25:05 MDT 2001 John Fleck <jfleck@inkstain.net>
+
+       * doc/internals.html - general cleanup
+
+Fri Jul 27 04:00:38 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * configure.in tests/Makefile.am tests/exslt/*: added some tests
+         to check EXSLT conformance
+       * libexslt/sets.c: fixed a typo when registering has-same-node
+
+Fri Jul 27 12:33:52 EDT 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/extensions.c xsltproc/xsltproc.c: quick cleanup
+         of memory allocations, raise a bug in the test suite, also
+         need to be centralized as a single cleanup function.
+
+Fri Jul 27 10:50:39 EDT 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.[ch]: applied changes from Tom Moog #58002
+       * libexslt/functions.c libxslt/documents.c libxslt/extensions.c:
+         Some cleanup, there is still a memory leak left and some warnings
+         in libexslt.
+
+Thu Jul 26 19:05:48 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libxslt/extensions.[ch] libxslt/functions.[ch] libxslt/preproc.c
+         libxslt/transform.[ch] libxslt/variables.c libxslt/xslt.c 
+         libxslt/xsltInternals.h: new extension framework.
+         Added stylesheet module data, top-level and extension elements
+         precomputing, global registration of top-level elements and 
+         extension elements and functions.
+         Extensions are no longer initialized from extension-element-prefixes
+         declarations but when modules need the data.
+         init/shutdown functions registered with xsltRegisterExtModule{,Full}
+         only allocate and free module data, they shouldn't register the
+         elements and functions any more.
+       * libxslt/xsltutils.c: fixed a bug in xsltPrintErrorContext when
+         @node wasn't NULL.
+       * libxslt/xslt.c: fixed xsltPrecomputeStylesheetTop which allowed
+         non-XSLT top-level elements before any xsl:import element.
+       * libexslt/common.c libexslt/functions.c libexslt/math.c
+         libexslt/sets.c: adapted to use the new extension framework.
+       * libxslt/functions.c libxslt/extensions[ch] xsltproc/xsltproc.c:
+         moved the test module from functions.c to extensions.[ch],
+         modified it to use the new extension framework. Updated xsltproc
+         to register the test module.
+
+Thu Jul 26 10:20:19 EDT 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c: fixed an ugly problem with namespaces
+         in templates compilation
+       * tests/namespaces/tst4.*: added a specific testcase
+       * libxslt/transform.c: reenabled debug
+
+Tue Jul 24 17:45:22 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in libxslt.spec.in libxslt/xsltwin32config.h:
+         releasing 1.0.1
+       * doc/html/*.html: updated the docs.
+       * xsltproc/xsltproc.c: activate line numbering unfortunately
+         this works only with CVS, libxml2-2.4.1 is broken in this respect
+
+Mon Jul 23 23:35:00 HKT 2001 William M. Brack <wbrack@mmm.com.hk>
+
+       * libxslt/documents.c enhancement to xsltFindDocument to
+         cater for the Matt Sergeant patch
+
+Mon Jul 23 09:32:27 MDT 2001 John Fleck <jfleck@inkstain.net>
+
+       * updating libxslt tutorial to include param support
+
+Mon Jul 23 20:12:38 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/math.c: small cleanup
+       * libxslt/functions.c: patch to document('') from Matt Sergeant
+       * libxslt/xsltInternals.h libxslt/xsltutils.[ch]: profiler on Windows
+         c.f. bug #57464 from Tom Moog
+
+2001-07-19  Darin Adler  <darin@bentspoon.com>
+
+       * configure.in: Add HTML_DIR definition.
+       * xsltproc/.cvsignore: Ignore some generated files.
+
+2001-07-18  Peter Williams  <peterw@ximian.com>
+
+       * xsltproc/Makefile.am (INCLUDES): Fix compiling when
+       srcdir != builddir.
+
+2001-07-17  Thomas Broyer <tbroyer@ltgt.net>
+
+       * libexslt/.cvsignore libexslt/Makefile.am libexslt/utils.[ch]
+         libexslt/common.c libexslt/functions.c libexslt/math.c
+         libexslt/sets.c: removed utils.[ch] as their content is
+         integrated in libxml
+       * libexslt/sets.c: uses the new libxml functions
+       * libxslt/extra.[ch]: removed exsl:document
+       * AUTHORS: added /me
+
+2001-07-16  Thomas Broyer <tbroyer@ltgt.net>
+
+       * libexslt/.cvsignore: some more generated files to ignore
+       * libexslt/Makefile.am: utils.h not installed anymore
+       * libexslt/common.c libexslt/exslt.[ch] libexslt/functions.c
+         libexslt/math.c libexslt/sets.c:
+         changed function prefix from exsl* to exslt*
+         {common.c,exslt.c} moved exsltLib{rary,exslt,xslt,xml}Version
+         from common.c to exslt.c
+         {common.c} removed exslNodeSetFunction, uses xsltFunctionNodeSet
+         instead
+       * libxslt/extra.c: fixed xsltFunctionNodeSet to accept
+         XPATH_NODESET arguments in addition to XPATH_XSLT_TREE
+       * xsltproc/xsltproc.c: updated to use the new function prefix
+
+2001-07-15  Darin Adler  <darin@bentspoon.com>
+
+       * libxslt/.cvsignore:
+       * tests/XSLTMark/.cvsignore:
+       * tests/extensions/.cvsignore:
+       * tests/xmlspec/.cvsignore:
+       Some more generated files to ignore.
+
+Mon Jul 16 14:26:48 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * Makefile.am configure.in libexslt/Makefile.am:
+         Integration of libexslt in the build system
+       * libxslt/Makefile.am libxslt/xsltproc.c libxslt/xsltutils.c
+         xsltproc/Makefile.am xsltproc/xsltproc.c:
+         Moved xsltproc to a separate directory, linked it to libexslt,
+         and added exslt version reports to -V
+       * tests/*/Makefile.am: updated the path to xsltproc
+       * libexslt/common.c libexslt/exslt.h libexslt/exsltconfig.h.in
+         libexslt/functions.c libexslt/math.c libexslt/sets.c: added
+         versionning informations, some cleanup, and added documentation
+         to a couple of exported functions
+
+Sun Jul 15 15:27:47 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libexslt/Makefile.am: account for new source files
+       * libexslt/.cvsignore: added
+
+Sun Jul 15 05:02:50 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libexslt/exslt.[hc] libexslt/common.[hc] libexslt/functions.[hc]
+         libexslt/math.[hc] libexslt/sets.[hc] libexslt/utils.[hc]:
+         start implementing EXSLT
+
+Sun Jul 15 16:01:55 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/numbers.c libxslt/numbersInternals.h libxslt/preproc.c:
+         trying to accept AVT for "format" in xsl:number
+
+Fri Jul 13 16:57:08 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * win32/libxslt/libxslt.defs: trying to close #57460 by adding
+         xsltProfileStylesheet
+
+Thu Jul 12 21:31:06 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/documents.c libxslt/extensions.c libxslt/extra.c
+         libxslt/functions.c libxslt/imports.c libxslt/keys.c
+         libxslt/namespaces.c libxslt/numbers.c libxslt/pattern.c
+         libxslt/preproc.c libxslt/templates.c libxslt/transform.c
+         libxslt/variables.c libxslt/xslt.c: provide context for
+         error messages. Requires libxml head changes.
+       * libxslt/xsltutils.c libxslt/xsltutils.h: fixed a --profile
+         problem
+
+Wed Jul 11 00:32:21 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libexslt/Makefile.am: initial EXSLT framework
+
+Tue Jul 10 18:03:36 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in libxslt/xsltwin32config.h: releaseing 1.0.0
+       * win32/libxslt/libxslt.def: added another entry point
+       * libxslt/transform.c: fixed a comment block
+       * doc/xslt.html doc/html/*: updated and regenerated the docs
+
+Tue Jul 10 17:25:59 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * win32/libxslt/libxslt.def: added missing functions
+
+Tue Jul 10 16:48:43 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES libxslt/xsltproc.c libxslt/transform.c
+         libxslt/xsltInternals.h: added Embedding Stylesheets
+       * tests/REC/Makefile.am tests/REC/stand-2.7-1.*: added the test
+         from the REC about it
+       * libxslt/transform.c libxslt/extra.[ch] libxslt/preproc.c:
+         tried to accomodate the various (and changing) proprietary
+         ways of implementing chunking.
+       * tests/docbook/result/xtchunk/html: now output is generated in
+         ISO-8859-1
+
+Mon Jul  9 23:23:50 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltproc.c: small cleanup
+       * libxslt/transform.c libxslt/xslt.c : patch from Michal Sajdak
+         for cdata/text handling
+
+Mon Jul  9 22:02:40 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltutils.c: small fix for xsl:message by Stephane GUIBOU
+       * tests/documents/Makefile.am tests/documents/message.*: added
+         a specific regression test
+       * libxslt/transform.c: fixed an infinite loop
+       * configure.in doc/Makefile.am: attempt to add --with-html-dir,
+         this may work
+
+Mon Jul  9 15:55:14 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c libxslt/xslt.c libxslt/xsltInternals.h:
+         fixed exclude-result-prefixes handling and how namespaces
+         propagate from the stylesheet to the result in general, this
+         is a serious cleanup.
+       * tests/general/bug-3[67]-inc.xsl tests/general/bug-6-.xsl
+         tests/general/itemschoose.out tests/namespaces/extra.xsl
+         tests/REC/test-10-1.xsl tests/REC/test-10-2.xsl
+         tests/REC/test-11.2-1.xsl tests/REC/test-11.2-2.xsl
+         tests/REC/test-11.2-6.xsl tests/REC/test-15-1.xsl
+         tests/REC/test-16.1-1.xsl tests/REC/test-16.1-2.xsl
+         tests/REC/test-5.4-1.out tests/REC/test-5.4-2.out
+         tests/REC/test-5.4-3.out tests/REC/test-5.4-4.out
+         tests/REC/test-7.1.1-2.out tests/REC/test-7.1.1-2.xsl
+         tests/REC/test-7.1.1-3.out tests/REC/test-7.1.1-3.xsl
+         tests/REC/test-7.1.1.out tests/REC/test-7.1.3.xsl
+         tests/REC/test-7.3.xsl tests/REC/test-7.4.xsl
+         tests/REC/test-7.6.1-1.xsl tests/REC/test-7.6.1-2.xsl
+         tests/REC/test-7.6.1-3.xsl tests/REC/test-7.6.2-1.xsl:
+         fixed and rechecked all the tests where the namespace
+         propagation was wrong either taht the rules were not applied
+         correctly or that superfluous namespaces were declared in the
+         stylesheets
+
+Sun Jul  8 22:12:02 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/extra.c libxslt/functions.c libxslt/transform.[ch]
+         libxslt/variables.h: Norm pointed out that element-available()
+         didn't work, implemented it
+       * tests/extensions/Makefile.am tests/extensions/list.*: added
+         a test for all registered xslt element, function and default
+         extensions.
+
+Sun Jul  8 20:44:25 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/documents/Makefile.am 'tests/documents/doc file.xml'
+         tests/documents/docfile.xml tests/documents/test.result
+         tests/documents/test.xml tests/documents/test.xsl:
+         added a test for URI-escaping on document() input
+
+Sun Jul  8 16:34:07 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/docs/Makefile.am tests/general/Makefile.am
+         tests/general/bug-49-* tests/docs/bug-49-*
+         tests/general/bug-50-* tests/docs/bug-50-*: added a
+         couple of regression tests for bugs posted on the list
+
+Sun Jul  8 15:40:44 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltproc.c: avoid generating CDATA node in document
+         tree when parsed, force generation of text nodes instead.
+
+Sun Jul  8 14:39:27 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * doc/extensions.html: fixed a number of typo found by Dan York
+       * libxslt/xsltutils.c: improved the profiling ouput, added the
+         average value too.
+
+Sun Jul  8 00:01:21 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/variables.c: tryingt to fix a problem raised by Norm
+
+Sat Jul  7 23:19:09 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * config.h.in configure.in: added gettimeofday() check
+       * libxslt/transform.c libxslt/xsltInternals.h libxslt/xsltutils.[ch]:
+         profiling works option --profile (or --norman ;)
+
+Sat Jul  7 18:58:56 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/templates.c libxslt/transform.c libxslt/transform.h
+         libxslt/variables.c: big cleanup on the way templates or 
+         template fragments are processed, cleanup of stack building
+       * tests/docs/Makefile.am tests/general/Makefile.am
+         tests/general/bug-4[1-8]-* tests/docs/bug-4[1-8]-*: added a
+         series of regression test for the variable/params lookups
+       * libxslt/transform.c libxslt/xsltutils.[ch] libxslt/xsltproc.c:
+         started working on profiling code, there is just invocation counting
+         yet but the framework is in place.
+
+Sat Jul  7 11:20:59 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/docs/Makefile.am tests/general/Makefile.am
+         tests/general/bug-40-* tests/docs/bug-40-*: added a specific
+         regression test for the variable scope within templates problem
+
+Sat Jul  7 17:05:00 HKT 2001 Wiliam Brack <wbrack@mmm.com.hk>
+
+       * xsltInternals.h variables.c transform.c:
+         fixed problem with variable scope within templates
+
+Fri Jul  6 17:42:06 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * doc/extensions.html doc/internals.html doc/xslt.html:
+         added a documentation on writing libxslt extensions, and
+         added links to the main page
+       * libxslt/functions.c libxslt/xsltInternals.h
+
+Fri Jul  6 14:30:00 HKT 2001 William Brack <wbrack@mmm.com.hk>
+
+       * cleaned up many comments and error messages
+
+Fri Jul  6 01:43:51 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in libxslt/xsltwin32config.h: released 0.14.0
+       * doc/xslt.html: added 0.14.0 release
+
+Fri Jul  6 01:00:55 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * doc/html/*: rebuilt docs before release
+       * libxslt/extensions.c: fixed a function doc header
+
+Fri Jul  6 00:40:55 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES: updated
+       * libxslt/xslt.c libxslt/xsltInternals.h: added exclude-result-prefix
+         support
+       * tests/REC/Makefile.am tests/REC/test-7.1.1-[23]*: added a couple
+         of specific tests
+       * tests/xmlspec/REC-xml-20001006-review.html: seems this changed
+         something there, not visually perceptible
+
+Thu Jul  5 22:49:57 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/docbook/result/: the change in libxml affected the
+         output of the Docbook tests (of course it was detected on
+         a DocBook example)
+
+Thu Jul  5 15:11:58 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES: updated
+       * libxslt/transform.c: added cdata-section-elements
+       * tests/REC/Makefile.am tests/REC/test-16.1-*: added 2 tests from
+         the REC
+
+Thu Jul  5 10:44:47 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES: updated
+       * libxslt/xsltutils.c: do not dump document for which there have
+         been no generated content
+       * tests/multiple/result.xml tests/namespaces/extra2.out: fixed
+         test output accordingly
+       * libxslt/transform.c libxslt/preproc.c: added xsl:fallback support
+       * tests/REC/Makefile.am tests/REC/test-15-1.*: xsl:fallback test
+       * tests/xmlspec/Makefile.am tests/docbook/Makefile.am: cleanups
+
+Wed Jul  4 15:15:50 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/extension.[ch] libxslt/extra.[ch] libxslt/xsltInternals.h
+         libxslt/transform.c libxslt/functions.c: Added the extension API
+         suggested by Thomas Broyer, this should allow implementation of
+         EXSLT for example.
+       * libxslt/extra.[ch]: added a fake xsltFunctionLocalTime() in Norm's
+         CVS extension namespace to avoid complaints, some cleanup
+       * configure.in tests/Makefile.am tests/extensions/*: added a test
+         for new modules testing both elements and functions registration
+
+Fri Jun 29 23:32:37 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/pattern.c libxslt/preproc.c libxslt/transform.c
+         libxslt/xslt.c libxslt/xsltutils.[ch]: added xsltGetQNameURI()
+         and cleaned up the way URI for QNames were computed through
+         the code, serious cleanup.
+       * libxslt/xsltInternals.h libxslt/xslt.c: moved cdata-sections
+         in their own hash table, implementation not yet finished.
+
+Thu Jun 28 23:01:14 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/keys.c libxslt/templates.c libxslt/transform.c
+         libxslt/variables.c libxslt/xsltutils.c: hum seems I forgot
+         to save/restore some XPath context, bug raised by
+         Steve Cheng
+
+Thu Jun 28 15:48:06 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltwin32config.h[.in]: added configuration/version
+         informations for Windows/MSC
+       * libxslt/libxslt.h libxslt/*.c: internal header to centralize
+         includes switches
+       * libxslt/Makefile.am: added libxslt.h and xsltwin32config.h[.in]
+       * libxslt/*.[ch] libxslt/*.in: quite a bit of cleanup, especially
+         the email addresses
+       * AUTHORS: added William
+
+Tue Jun 26 18:45:38 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in doc/xslt.html: releasing 0.13.0
+       * doc/Makefile.am: don't index the win32 include
+       * doc/html/*: rebuilt the docs
+
+Mon Jun 25 15:30:30 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltproc.c: John Fleck found a typo in usage()
+       * libxslt/xslt.c: avoid warning if version="1.1" is used
+       * libxslt/transform.c: forgot to initialize cur->outputFile
+       * libxslt/functions.c: DOCBOOK_XSL_HACK some versions of DocBook XSL
+         use the vendor string to detect supporting chunking, this
+         is a workaround to be considered in the list of decent XSLT
+         processors <grin/>
+
+Mon Jun 25 12:41:30 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.[ch] libxslt/xslt.c libxslt/xsltInternals.h:
+         added a new interface xsltRunStylesheet() for a more flexible
+         handling of the output and trying to adhere to xsl:document
+         filename generation semantic if one knows the URL of the output,
+         also add IObuf capacity and SAX for output but is currently not
+         implemented.
+       * libxslt/xsltproc.c: added a -o or --output filename argument
+         to test xsltRunStylesheet() or provide a base when generating
+         multiple outputs
+       * tests/docbook/Makefile.am tests/docbook/result/xtchunk/html/*:
+         updated tests to add DocBook xt:document based chunking
+       * tests/multiple/Makefile.am: cleaned up the makefile a bit
+       * tests/multiple/out/*.html: the new xt:document now generate
+         the DOCTYPE if available as is the case for HTML
+
+Mon Jun 25 08:45:00 HKT 2001 William Brack <wbrack@mmm.com.hk>
+
+       * Removed some redundant code in xsltDefaultProcessOneNode
+         and revised the default processing of an attribute node
+
+Sun Jun 24 14:40:00 HKT 2001 William Brack <wbrack@mmm.com.hk>
+
+       * Enhanced ApplyTemplates and ForEach to allow multiple
+         documents within a nodelist.
+       * Repaired small bug in xsltDocument function which caused
+         a crash if invalid second argument was provided.
+
+Sat Jun 23 15:44:00 MDT 2001 John Fleck <jfleck@inkstain.net>
+
+       * doc/tutorial/libxslttutorial.xml, libxslttutorial.html
+         updating tutorial with explanation of xsltSave vs. xmlSave
+         functions 
+
+Sat Jun 23 19:04:27 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * test/docbook: updated to docbook-xsl-1.4, regenerated results
+
+Sat Jun 23 15:32:25 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * Makefile.am libxslt/Makefile.am libxslt/numbers.c 
+         libxslt/win32config.h libxslt/xsltconfig.h.in libxslt/xsltproc.c:
+         Patches for Windows mostly contributed by Yon Derek
+       * win32/libxslt/libxslt.def win32/libxslt/libxslt.dsw
+         win32/libxslt/libxslt_so.dsp win32/libxslt/xsltproc.dsp:
+         Project file for Mircrosoft C provided by Yon Derek
+
+Sat Jun 23 14:20:01 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/pattern.c: closing bug #56517, fixed a number of
+         problems in the patterns compilations, priorities and debug
+       * libxslt/transform.c: improved the template debug message
+       * tests/docs/Makefile.am tests/general/Makefile.am
+         tests/general/bug-39-* tests/docs/bug-39-*: added a specific
+         regression test for #56517
+
+Fri Jun 22 16:17:23 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt.c: avoid a stupid bug when compiling with
+         libxml < 2.3.11 and without LIBXML_DEBUG_ENABLED
+
+Fri Jun 22 00:11:18 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/numbers.c: fix of a small bug
+       * libxslt/transform.c libxslt/variables.c libxslt/xslt.c: cleanups
+         while bug-hunting
+
+Tue Jun 19 16:13:49 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/docbook/Makefile.am: added XHTML and XSL FO to the
+         regression tests
+       * tests/docbook/xhtml/*: added XHTML stylesheets
+       * tests/docbook/fo/*: added XSL FO stylesheets
+       * tests/docbook/result/xhtml/*: added XHTML results
+       * tests/docbook/result/fo/*: added XSL FO results
+
+Tue Jun 19 00:20:32 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * HACKING: fixed, added William
+
+Mon Jun 18 18:36:36 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltutils.c: forgot to flush in xsltSaveTo() in html and
+         xml cases, and fixed text output to be recursive in text nodes
+         lookups
+
+Mon Jun 18 15:44:51 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in: patch from Tony Graham to cleanup libxml2 detection
+
+Sun Jun 17 17:42:33 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltutils.[ch]: fixed xsltGetNsProp, i always forget
+         'namespace' is a reserved C++ identifier
+
+Sun Jun 17 17:08:30 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * doc/xslt.html: adding 0.12.0 release
+
+Sun Jun 17 13:15:48 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in: preparing 0.12.0 release
+       * libxslt/transform.c: a bit of cleanup on the XInclude defaults
+       * libxslt/xsltconfig.h.in: added doc inline comment
+       * libxslt/xslt.[ch] libxslt/xsltproc.c: added more version informations
+         and enriched xsltproc --version to show them
+       * doc/html/*.html: rebuilt the docs
+       * doc/Makefile.am libxslt.spec.in: try to make sure John Fleck
+         tutorial ends up in the tars and RPMs
+
+Sat Jun 16 23:58:57 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt.spec.in: updated the descriptions
+
+Sat Jun 16 23:26:46 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/namespaces.[ch]: added a single namespace def copy
+         operation xsltCopyNamespace(). cleaned up xsltCopyNamespaceList()
+       * libxslt/transform.c: cleaned up xsltCopyNode to cope with
+         any kind of input nodes.
+       * libxslt/variables.c: checked and closed the last TODO about
+         namespace propagation
+       * tests/docs/Makefile.am tests/general/Makefile.am
+         tests/general/bug-38-* tests/docs/bug-38-*: added a specific
+         regression test for #56115 
+
+Sat Jun 16 09:27:27 MDT 2001 John Fleck <jfleck@inkstain.net>
+
+       * updating tutorial: adding discussion of freeing memory, image
+       files for callouts, link to xsltproc.c code
+
+Sat Jun 16 15:23:43 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/variables.c: bug #56267 was still not fixed, forgot
+         to remove the old code
+       * tests/general/bug-37-.xsl: wrong reference to 36 fixed, this does
+         the test for good
+
+Sat Jun 16 00:32:39 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/variables.c: fixed bug #56267, namespaces must
+         be propagated when evaluating local variables.
+       * tests/docs/Makefile.am tests/general/Makefile.am
+         tests/general/bug-37-* tests/docs/bug-37-*: added a specific
+         regression test for #56267 
+
+Fri Jun 15 18:29:29 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/keys.c: avoid a possibility of an uninitialized variable
+       * libxslt/documents.c libxslt/transform.[ch] libxslt/transform.h
+         libxslt/xsltInternals.h libxslt/xsltproc.c: Implement Raphael Hertzog
+         request to have xinclude processing done on document() if requested
+
+Thu Jun 14 20:52:13 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/Makefile.am: applied patch from Sander Vesik for -j2 
+
+Thu Jun 14 10:07:59 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/preproc.c: removed a warning on xsl:transform
+       * tests/docs/Makefile.am tests/docs/array.xml tests/general/Makefile.am
+         tests/general/array.out tests/general/array.xsl: added a new
+         test fround in xsl-dev
+
+Wed Jun 13 23:12:57 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/docbook/result/html/*.html tests/XSLTMark/xslbench[12].out
+         tests/xmlspec/REC-xml-20001006*.html: the changes to the HTML
+         serializer of libxml impacted the result of some tests. Checked
+         that the XML REC renders identically.
+
+Mon Jun 11 07:19:06 MDT 2001 John Fleck <jfleck@inkstain.net>
+
+       * fixing embarassing typos in doc/tutorial/libxslttutorial.xml and 
+       generated html
+
+Tue Jun 12 07:42:35 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/variables.c: fixed bug #55670, namespaces must
+         be propagated when evaluating global variables.
+       * tests/docs/Makefile.am tests/general/Makefile.am
+         tests/general/bug-36-* tests/docs/bug-36-*: added a specific
+         regression test for #55670 
+
+Mon Jun 11 09:35:53 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * doc/xslt.html: linked to the tutorial
+
+Sun Jun 10 19:36:31 MDT 2001 John Fleck <jfleck@inkstain.net>
+
+       * doc/tutorial/libxslt_tutorial.c,  libxslttutorial.html,
+       libxslttutorial.xml 
+       adding tutorial
+
+Sun Jun 10 21:52:35 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c: closed bug #55723, problem was due to
+         a limitation of xsltGetNamespace() when the insertion point
+         is the document.
+       * tests/docs/Makefile.am tests/general/Makefile.am
+         tests/general/bug-35-* tests/docs/bug-35-*: added a specific
+         regression test for #55723 
+
+Sun Jun 10 13:37:33 HKT 2001 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: fixed problems with document() in
+         xsltApplyTemplates and xsltForEach.  Cleaned up several
+         error messages.
+       * libxslt/keys.c: saved and restored ctxt->document within
+         xsltInitKey to fix problem with keys when doc changed
+       * libxslt/documents.[ch]: added new procedure xsltFindDocument
+         needed when document() causes a change of doc within
+         xsltApplyTemplates and xsltForEach
+
+Thu Jun  7 21:31:46 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltutils.[ch]: closing bug #55683 required to add
+         xsltGetNsProp()
+       * libxslt/attributes.c libxslt/imports.c libxslt/namespaces.c
+         libxslt/preproc.c libxslt/templates.c libxslt/xslt.c:
+         Updated to use the new function
+       * tests/XSLTMark/prettyprint.out tests/docbook/result/html/*.html:
+         the fixes in the serialization of <pre> in HTML in libxml
+         led to a number of changes in the output
+
+Thu Jun  7 04:23:38 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/docs/Makefile.am tests/general/Makefile.am
+         tests/general/bug-32-* tests/docs/bug-32-*: added a specific
+         regression test for #55722 
+
+Wed Jun  6 09:48:53 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * doc/xslt.html: updated to ask to not send mail directly
+       * tests/docs/Makefile.am tests/general/Makefile.am
+         tests/general/bug-33-* tests/docs/bug-33-*: added a specific
+         regression test for #55722 
+
+Wed Jun  6 11:07:50 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/pattern.c : trying to fix #55670
+       * tests/XSLTMark/reverser.out : result of test changed when
+         William fixed XPath
+
+Sat Jun  2 06:52:12 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * doc/xslt.html: updated with 0.11.0
+
+Fri Jun  1 11:30:49 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in libxslt.spec.in: released 0.11.0
+
+Mon May 28 12:54:45 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c: William M. Brack found a small bug
+         when call-template didn't find the template.
+
+Sat May 26 17:08:19 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c: fixed handling of PI and comments
+         (bug raised by Brent M Hendricks).
+       * tests/docs/Makefile.am tests/general/Makefile.am
+         tests/general/bug-31-* tests/docs/bug-31-*: added a specific
+         regression test
+
+Wed May 23 13:25:37 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltproc.c: added --xinclude in the option list,
+         patch from Raphael Hertzog
+       * test/docbook/Makefile.am: force at least the gdp-handbook.xml
+         test in the normal testsuite
+
+Wed May 23 00:05:19 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/variables.c: Mark Vakoc found a bug in variable eval
+         at the top template level 
+       * tests/docs/Makefile.am tests/general/Makefile.am
+         tests/general/bug-30-* tests/docs/bug-30-*: added a specific
+         regression test
+
+Tue May 22 18:52:30 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/functions.c: fixed the document() bug reported by
+         Stephane GUIBOUD-RIBAUD
+       * tests/docs/Makefile.am tests/general/Makefile.am
+         tests/general/bug-29-* tests/docs/bug-29-*: added a specific
+         regression test
+
+Tue May 22 15:09:02 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in libxslt/Makefile.am: fixed bug #54953
+       * libxslt/attributes.c: cleanup pointed by Joe Orton
+       * libxslt/xsltproc.c: added --catalogs to load catalogs from
+         $SGML_CATALOG_FILES
+       * libxslt/functions.c: cleanup unreached code
+       * configure.in config.h.in libxslt/xsltproc.c: guarded the
+         include with preprocessor definitions
+
+Sun May 20 20:55:00 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/documents/Makefile.am tests/general/Makefile.am
+         tests/multiple/Makefile.am tests/namespaces/Makefile.am
+         tests/numbers/Makefile.am tests/xmlspec/Makefile.am
+         tests/REC/Makefile.am tests/REC1/Makefile.am tests/REC2/Makefile.am
+         tests/XSLTMark/Makefile.am tests/docbook/Makefile.am
+         configure.in: Makefiles cleanup from Joe Orton
+
+Sun May 20 15:20:49 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/docbook/result/html/external.html 
+         tests/docbook/result/html/graphics.html
+         tests/docbook/result/html/gtest.html
+         tests/docbook/test/external.xml tests/docbook/test/subdoc.ent:
+         Added a test from coolo for IDs in external parsed entities
+         and fixed 2 outputs
+
+Sat May 19 22:28:05 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt.[ch] libxslt/xsltconfig.h.in libxslt/xsltproc.c:
+         added --version info to xsltproc closing #54952
+
+Sat May 19 17:41:23 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/documents/Makefile.am tests/general/Makefile.am 
+         tests/multiple/Makefile.am tests/namespaces/Makefile.am 
+         tests/numbers/Makefile.am tests/xmlspec/Makefile.am:
+         Seems some of the changes I made for 0.9.0 Makefiles were
+         not commited ...
+
+Sat May 19 17:23:54 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in: preparing 0.10.0 release
+       * doc/xslt.html: updated
+       * doc/html/* : rebuilt the docs
+
+Fri May 18 16:48:13 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt.c libxslt/variables.c libxslt/templates.c
+         libxslt/keys.[ch] libxslt/functions.c: cleanups for ctxt->inst
+         avoiding modifying stylesheet informations, and fixing
+         document() when called from a global variable init
+
+Thu May 17 17:24:35 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/functions.c libxslt/transform.c libxslt/xsltInternals.h:
+         add ctxt->inst to allow stylesheet element lookup (needed
+         for document() fix)
+       * libxslt/*.[ch]: generate docs for the structures and
+         macros, general cleanup for docs
+       * doc/html/*.html: regenerated all docs
+
+Wed May 16 23:00:53 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/extra.c libxslt/transform.c libxslt/variables.[ch]
+         libxslt/xsltInternals.h: optimizations, cleanup of global
+         variables handling
+
+Wed May 16 12:29:17 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/extensions.c libxslt/preproc.c libxslt/transform.c
+         libxslt/variables.c: force the precompilation of XPath expressions
+         at stylesheet compilation time
+
+Tue May 15 14:34:23 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/keys.c libxslt/transform.c: avoid some possibilities
+         of crashes on debug
+       * tests/REC/Makefile.am: be less verbose if things really go wrong
+       * tests/docs/Makefile.am tests/general/Makefile.am
+         tests/docs/bug-28-.xml tests/general/bug-28-.*: added bug-28 in
+         the regression tests
+
+Sat May 12 12:39:54 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c libxslt/xsltutils.c: fixed the default
+         detection method to generate HTML documents 
+       * tests/REC/test-2.5-1.out tests/REC/test-8-1.out
+         tests/REC/test-9.1-2.out tests/REC2/html.xml tests/XSLTMark/game.out
+         tests/XSLTMark/html.out tests/XSLTMark/products.out
+         tests/XSLTMark/xslbench1.out tests/XSLTMark/xslbench2.out
+         tests/XSLTMark/xslbench3.out tests/general/bug-15-.out
+         tests/general/bug-5-.out: updated a number of tests output
+         accordingly
+
+Sat May 12 09:43:10 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltproc.c: use LIBXML_DOCB_ENABLED, William M. Brack
+
+Fri May 11 19:12:26 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/templates.c libxslt/transform.c: fixed bug #54446
+         about attribute being generated twice. Fixed a number of related
+         bugs on attributes handling.
+       * tests/REC/test-7.1.4.out: this changed an attribute generation
+         order
+       * tests/docs/bug-27-.xml tests/general/bug-27-.*: added test
+
+Fri May 11 17:08:14 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/templates.c: fixed bug #54451 on escaped curly brackets
+       * tests/docs/bug-26-.xml tests/general/bug-26-.*: added test
+
+Fri May 11 16:20:40 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in tests/XSLTMark/Makefile.am: try to handle gracefully
+         the cases where perl is not in the path (nor in /usr/bin)
+       * tests/docbook/result/html/gdp-handbook.html
+         tests/docbook/result/html/kwrite.html
+         tests/docbook/test/gdp-handbook.xml
+         tests/docbook/test/kwrite.xml: commited a few more DocBook tests
+
+Wed May  9 12:29:47 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltproc.c: added --nonet and --warnnet to catch
+         cases where a network access is needed to load a DTD or entity
+       * tests/docbook/Makefile.am: added --nonet
+       * tests/docbook/test/classsynop.xml tests/docbook/test/docbook40.xml:
+         fixed 2 tests as a result
+
+Wed May  9 10:43:53 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in tests/docbook/Makefile.am tests/docbook/**/Makefile.am:
+         try to remove the unneeded docbook Makefile stuff 
+
+Tue May  8 16:18:19 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * doc/xslt.html: fixed a link error
+       * libxslt/transform.c libxslt/xsltutils.c: fixed DOCTYPE generation
+       * libxslt/xsltproc.c: cleaned up the --repeat loop
+       * tests/documents/result.xhtml tests/xmlspec/REC-xml-20001006*.html:
+         fixed the DOCTYPE in tests output
+       * tests/docs/bug-25-.xml tests/doc/Makefile.am 
+         tests/general/bug-25-.* tests/general/Makefile.am : added a new
+         test case and fixed the EXTRA_DIST
+
+Mon May  7 22:27:03 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/extra.c: add more debug to xsltDebug
+       * libxslt/transform.c: spent a few hours tracking down an ugly
+         race like bug in xsltCopyTreeList() arghhh
+       * libxslt/xsltproc.c: call xmlInitMemory() explictely
+
+Mon May  7 11:38:54 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * doc/internals.html: more work done on the doc, mostly complete
+         except the section on the XSLT stack and the extensions API
+         since both still need more work.
+
+Sun May  6 15:03:59 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * doc/internals.html doc/contexts.* doc/object.*: more work done
+         on the doc
+
+Sun May  6 00:18:39 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * doc/internals.html: more work done on the doc
+
+Sat May  5 18:58:13 CEST 2001 Bjorn Reese <breese@users.sourceforge.net>
+
+       * libxslt/transform.c tests/XSLTMark/xslbench1.out: Another fix
+         for the CDATA output
+
+Sat May  5 18:09:15 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt.c: do not escape content of CDATA nodes on output
+
+Sat May  5 17:52:52 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * doc/internals.html doc/node.fig doc/node.gif doc/processing.fig
+         doc/processing.gif doc/stylesheet.fig doc/stylesheet.gif
+         doc/templates.fig doc/templates.gif: started writing tye doc
+         on how libxslt works.
+
+Sat May  5 17:13:16 CEST 2001 Bjorn Reese <breese@users.sourceforge.net>
+
+       * libxslt/numbersInternals.h libxslt/numbers.c
+         tests/numbers/format-number.out tests/XSLTMark/number.out:
+         Patch from William Brack to bring format-number() more in alignment
+         with the Java implementations.
+
+       * libxslt/xslt.c tests/XSLTMark/xslbench1.out: Do not remove CDATA
+         from stylesheet
+
+Fri May  4 20:10:45 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/docbook/result/html/* tests/general/bug-11-.out 
+         tests/multiple/result.xml tests/XSLTMark/*.out 
+         libxslt/transform.c: all the PUBLIC and SYSTEM IDs
+         were swapped
+
+Fri May  4 19:09:45 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltproc.c: add a --docbook option if your libxml2
+         has the SGML DocBook support compiled in.
+
+Fri May  4 17:06:01 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/general/bug-2[0-4].* tests/docs/bug-2[0-4].*: added more
+         tests especially on sorting
+       * test/xsltutils.c: oops multiple sorts was actually broken !!!
+         this should fix it
+
+Thu May  3 19:02:21 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * TODO configure.in libxslt.spec.in: getting ready for 0.9.0
+         release
+       * doc/html/* doc/xslt.html: updated and regenerated the docs
+
+Thu May  3 17:56:55 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * xsltutils.[ch] transform.c: implemented multiple levels of
+         sorting
+       * test/REC/test-10-2.*: added a really small test for it
+
+Wed May  2 14:04:34 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c libxslt/xslt.c: fixed xsl:text processing
+         there can be multiple text and CDATA child
+
+Wed May  2 10:55:56 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/multiple/makefile.am: fixing #54015
+       * tests/XSLTMark/makefile.am tests/docbook/makefile.am: fixing #54014
+         and a similar problem for the docbook tests
+
+Mon Apr 30 22:31:59 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/general/bug-8-.out: fixed in libxml xpath
+       * libxslt/templates.[ch] libxslt/pattern.c: fixed an namespace
+         problem in predicates within a pattern. Spotted another
+         potential namespace problem
+
+Mon Apr 30 19:29:34 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/preproc.c libxslt/xslt.c libxslt/xsltInternals.h
+         libxslt/xsltproc.c: counting errors and warnings at compilation
+         time. Stop processing in case of error.
+       * tests/docs/bug-1[89]* tests/general/-1[89]* tests/general/inner.xsl:
+         added more namespace related bug checks
+
+Mon Apr 30 13:47:11 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/preproc.c libxslt/variables.c: found the source of a
+         memory leak with DocBook introduced this w.e.. bit of cleanup.
+       * tests/docbook/result/html/*.html : regenerated the DocBook tests
+         results.
+
+Sun Apr 29 18:54:03 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/variables.c: fixing bug #53769
+       * tests/general tests/docs: added new examples from the
+         bug reports to the regression tests, updated the Makefiles
+
+Sun Apr 29 11:47:58 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * preproc.[ch] templates.[ch] variables.[ch] xslt.c xsltInternals.h
+         attributes.c extensions.[ch]: moved all stylesheet precomputation
+         at stylesheet loading time (stylesheet transform should be thread
+         safe now), improved params and variables evaluations (but optim
+         is not complete yet).
+       * TODO: updated
+
+Sat Apr 28 16:28:45 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltproc.c : changed the way --repeat works when
+         used twice
+
+Sat Apr 28 16:19:06 CEST 2001 Bjorn Reese <breese@users.sourceforge.net>
+
+       * libxslt/numbers.c libxslt/preproc.c tests/REC/test-7.7-3.out:
+         fixed default formatting
+
+Sat Apr 28 14:20:29 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/preproc.c : fixed <xsl:sort/> bug reported by Ankh
+       * libxslt/xsltproc.c : added an option to process HTML input
+
+Thu Apr 26 21:13:59 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c: Tony Gorski found a bug pointed by
+         a compiler on Tandem
+       * tests/documents/result.xhtml: this results in a small
+         change in the output of this test
+
+Thu Apr 26 16:33:36 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * test/general/bug-14*.* test/docs/bug-14*.xml: added testcase from
+         bug #53689
+
+Wed Apr 25 16:58:11 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * transform.c: fixed text and cdata handling in xsl:copy
+       * xslt.c : avoid crashing on invalid xslt input
+       * test/general/bug-*.* test/docs/bug-*.xml : added a number of
+         bugs submitted to the regression tests
+
+Wed Apr 25 12:42:48 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltproc.c : Renaud Chaillat provided a fix for #53535
+
+Sun Apr 22 22:47:44 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in: updated to 0.8.0
+
+Sun Apr 22 22:46:03 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * transform.c: fixed a bug introduced on handling #53401
+
+Sun Apr 22 22:27:09 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * transform.c: fixed #53401
+       * configure.in libxslt/*.c: allowed to suppress debug reporting
+         functionalities but it brings not noticeable improvements
+       * doc/xslt.html doc/html/*: updated and regenerated docs
+
+Wed Apr 18 15:24:50 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/general/bug-5-.out tests/multiple/out/*.orig
+         tests/xmlspec/REC-xml-20001006*.html: fixed the test output
+         following the libxml changes
+
+Wed Apr 18 12:05:04 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/functions.c: applied TOM's patch to key()
+       * tests/XSLTMark/chart.out tests/XSLTMark/dbonerow.out
+         tests/XSLTMark/prettyprint.out tests/multiple/out/*.html:
+         small HTML output change 
+
+Mon Apr 16 16:14:02 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/functions.c libxslt/transform.c libxslt/xsltInternals.h:
+         fixed current()
+
+Tue Apr 17 10:10:56 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/keys.c libxslt/preproc.c libxslt/templates.c
+         libxslt/transform.c libxslt/variables.c libxslt/xsltInternals.h:
+         fixed for the most part the namespace handling problem in XPath
+         expression computations.
+       * test/doc/ tests/general: added bug 5 and 6
+
+Thu Apr 12 14:40:22 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt.c: applied William M. Brack patch fixing the
+         template lack of support for priority
+       * test/XSLTMark/*.out : this fixed anumber of problems in the
+         XSLTMark output
+
+Thu Apr 12 14:29:48 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/functions.c: removed warning in unparsed-entity-uri()
+         fixed a bug in generate-id()
+       * libxslt/transform.c: fixed null list result errors
+       * libxslt/transform.c libxslt/xsltutils.c: applied William M. Brack
+         fixes for sorting semantic
+
+Wed Apr 11 14:25:23 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * config.h.in configure.in libxslt/xsltconfig.h.in: added
+         ansidecl.h test
+       * libxslt/xsltproc.c : added --xinclude option
+       * tests/XSLTMark/union.out : fixed the output
+
+Tue Apr 10 20:05:00 CEST 2001 Fatih Demir <kabalak@gtranslator.org>
+
+       * .cvsignore & doc/.cvsignore: Added CVS ignore files.
+
+Tue Apr 10 12:10:25 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in: released 0.7.0
+       * tests/XSLTMark/Makefile.am: trying to solve some make distcheck
+         problems
+
+Sun Apr  8 11:42:03 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/functions.c libxslt/keys.c libxslt/transform.c:
+         some checking against NULL pointers
+
+Mon Apr  2 17:00:39 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in tests/Makefile.am tests/XSLTMark/* tests/multiple:
+         added the XSLTMark in the regression tests as well as multiple
+         output test from Ankh
+       * libxslt/functions.c libxslt/keys.c libxslt/transform.c
+         libxslt/variables.c libxslt/xsltutils.c: applied William M. Brack
+         patches and fixed a memory leak
+       * tests/docbook/result/html/*.html : updated the results after
+         William's patch
+       * tests/xmlspec/REC-xml-20001006-review.html 
+         tests/xmlspec/REC-xml-20001006.html: libxml now don't invent
+         an HTML doctype when serializing HTML result, but adds the
+         encoding in ALT
+
+Thu Mar 29 10:24:42 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c: applied fix to xsltApplyTemplates from
+         William M. Brack
+       * test/docbook/result/html/*.html: this change the output
+       * tests/xmlspec/REC-xml-20001006-review.html 
+         tests/xmlspec/REC-xml-20001006.html: this also fixed some of
+         the reference anchors generated for the XML spec
+
+Mon Mar 26 18:57:58 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/attributes.c libxslt/extra.c libxslt/keys.c libxslt/numbers.c
+         libxslt/templates.c libxslt/transform.c libxslt/xsltconfig.h.in
+         libxslt/xsltutils.c: of course the way I defined
+         UNUSED breaks on old gcc version. Try to be smart and
+         also define it directly in xsltconfig.h
+       * tests/xmlspec/Makefile.am: fixed the timing arg test
+
+Sun Mar 25 22:07:34 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.[ch] libxslt/variables.[ch] libxslt/xsltproc.c:
+         implemented command line parameter passing
+       * tests/xmlspec/Makefile.am tests/xmlspec/REC-xml-20001006-review.html:
+         tested it by passing show.diff.markup=1 to build the review version too
+
+Sat Mar 24 19:35:42 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+        Huge cleanup, I switched to compile with
+       -Wall -g -O -ansi -pedantic -W -Wunused -Wimplicit
+       -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat
+       -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow
+       -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return
+       -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline
+       * libxslt/attributes.c libxslt/extensions.c libxslt/extra.c
+         libxslt/functions.c libxslt/keys.c libxslt/numbers.c
+         libxslt/pattern.c libxslt/preproc.c libxslt/templates.c
+         libxslt/transform.c libxslt/variables.c libxslt/xslt.c
+         libxslt/xsltutils.c: basically made static unexported functions
+         avoided name clashes and flagged unused parameters.
+
+Thu Mar 22 22:52:48 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in: 0.6.0 yet another release
+       * doc/xslt.html doc/html/*: updated the docs
+
+Wed Mar 21 23:19:11 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltInternals.h libxslt/xslt.c libxslt/transform.c
+         libxslt/templates.[ch] libxslt/preproc.c libxslt/extensions.[ch]
+         extended xsltEvalStaticAttrValueTemplate and 
+         xsltEvalAttrValueTemplate to support foreign namespaces,
+         and fixed document()
+
+Mon Mar 19 18:40:40 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * xsltutils.h: cleanup some garbage added last night
+       * xsltInternals.h variables.c transform.c templates.[ch]
+         preproc.c pattern.c keys.c: switched the whole XSLt processing
+         to use XPath precompiled expressions and reusing them.
+       * functions.c: some cleanup, seems people don't use 
+         unparsed-entity-uri() the way it's supposed to be used
+
+Mon Mar 19 01:08:05 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/keys.c libxslt/templates.c libxslt/transform.c
+         libxslt/variables.c libxslt/xsltutils.h: Changed to work
+         with the new way XPath is interpreted. This doesn't yet
+         take advantage of the separate parsing/evaluation phases
+
+Wed Mar 14 15:51:36 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c: robert@xsl.00008.org pointed out a
+         problem in xsl:copy-of in case of attributes
+       * tests/docs/Makefile.am tests/docs/bug-3-.xml
+         tests/general/Makefile.am tests/general/bug-3-.*:
+         added the test to the general regression suite
+
+Wed Mar 14 14:21:45 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/functions.c: applied and fixed ptittom@free.fr patch
+         fixing some of the missing functionnalities in the XSLT
+         functions implementations.
+         
+Tue Mar 13 14:38:48 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/Makefile.am: nick@debian.org forwarded a fix
+
+Tue Mar 13 10:29:45 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * README.cvs-commits: added, pointing to HACKING
+       * HACKING: added defines commit rules.
+
+Mon Mar 12 14:43:20 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/extra.c libxslt/variables.c: fixing compilation
+         when libxml was compiled without debug support
+
+Sat Mar 10 13:50:16 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in: time for 0.5.0
+       * tests/docs/Makefile.am tests/general/Makefile.am: make sure the
+         new test files are included in the distribution
+       * doc/xslt.html : updated
+       * doc/html/*.html: regenerated the docs
+
+Thu Mar  8 02:34:52 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/docbook/result/html/*.html: regenerated the HTML
+         now that value-of an result tree don't include the fake root
+
+Thu Mar  8 02:26:56 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c libxslt/variables.c: removed a couple
+         of possibly uninitialized var probs
+       * tests/xmlspec/Makefile.am: run the processing without verbose
+         avoid raising generated id differences.
+
+Wed Mar  7 23:22:09 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/preproc.c libxslt/xsltInternals.h: fixed a stylesheet
+         reuse problem.
+       * libxslt/transform.c: fixed a bug which exaplined why no
+         optimization were resulting from preproc stuff
+
+Wed Mar  7 21:51:52 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/preproc.c libxslt/transform.c: a couple of nastyness
+         w.r.t. value of tree result (and attributes within it) fixed.
+       * tests/xmlspec/Makefile.am tests/xmlspec/REC-xml-20001006.html:
+         Integrated the xmlspec to the test (i.e. diffed output for
+         changes).
+
+Wed Mar  7 18:01:07 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * imports.c transform.c xslt.c xsltInternals.h: fixed a
+         strip-spaces problem
+       * tests/docs/*.xml tests/general/*.[xsl,out]: added reported
+         bugs to testsuite
+
+Wed Mar  7 13:34:13 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.[ch]: finished integrating the current
+         state of the preproc optimizations.
+       * tests/xmlspec/diffspec.xsl: switched off diff printing
+
+Wed Mar  7 12:46:09 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/preproc.c libxslt/transform.c: started rolling in
+         some of the optimizations.
+
+Tue Mar  6 19:39:25 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * attributes.[ch] extra.[ch] preproc.c xsltInternals.h
+         transform.[ch]: previous commit broke a lot of stuff, fixing
+         and preparing for next step
+
+Tue Mar  6 19:03:21 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/preproc.[ch] Makefile.am templates.[ch] transform.[ch]
+         xsltInternals.h: started working on optimizing stylesheet
+         element parsing. Just builds the extra informations so far.
+       * xsltutils.h: added a missing XPath decl
+
+Tue Mar  6 09:52:13 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/variables.c: William M. Brack found a serious bug
+         with imports and global variables ...
+
+Mon Mar  5 21:51:54 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/pattern.[ch] libxslt/transform.c: added 
+         xsltCleanupTemplates() to clean up state left after processing.
+
+Sun Mar  4 19:03:27 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c: applied patch from William M. Brack
+         to support with-param in xsltApplyTemplates().
+
+Sun Mar  4 17:53:13 CET 2001 Bjorn Reese <breese@users.sourceforge.net>
+
+       * libxslt/pattern.c: fixed the compilation of patterns which
+         contains XPath NodeTypes. Handling of nested predicates.
+
+Sat Mar  3 20:56:47 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c: save ctxt->node after for-each
+
+Thu Mar  1 18:16:58 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in libxslt.spec.in: updated to 0.4.0 and 2.3.3
+       * doc/xslt.html: updated
+
+Wed Feb 28 19:24:51 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/extra.[ch] libxslt/transform.[ch] libxslt/xsltInternals.h:
+         added xsltDocumentElem implementing multiple file output,
+         including 1.1 xsl:document but yet untested.
+
+Wed Feb 28 00:03:44 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/extensions.c: fixed stoopid bug
+       * libxslt/Makefile.am libxslt/extra.[ch]: added a new module
+         carrying extensions to the specification. Added node-set()
+         for existing saxon and xt namespaces and debug() in libxslt
+         namespace (http://xmlsoft.org/XSLT/namespace)
+       * libxslt/xsltutils.[ch] transform.c: moved xsltDebug to extra.c
+         plus cleanup.
+       * configure.in tests/Makefile.am tests/namespaces: added some
+         namespaces tests, including a test calling the extra debugging
+         function in libxslt namespace, worked first time !!!
+
+Tue Feb 27 16:15:47 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt.c: extension prefix support for the full stylesheet
+       * libxslt/transform.c libxslt/extensions.[ch]: more work should
+         start working
+
+Mon Feb 26 22:59:44 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * doc/xslt.html : cleaned up, added a bit more description on
+         the API section.
+
+Mon Feb 26 09:41:04 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/Makefile.am libxslt/extensions.[ch]: started working
+         on functions and element extensions. First on list will be
+         a document element.
+
+Sun Feb 25 06:52:14 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in libxslt.spec.in: releasing 0.3.0
+       * doc/xslt.html: updated
+       
+Sun Feb 25 05:28:30 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in tests/docbook/html : oops forgot to add
+         the stylesheets themselves :-\
+
+Sun Feb 25 04:51:33 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in tests/Makefile.am tests/docbook tree:
+         added docbook XSL based test suite
+
+Sat Feb 24 14:02:05 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltutils.c: reformat of messages
+       * libxslt/xsltproc.c: removed memleak on --noout
+       * libxslt/xsltInternals.h libxslt/variables.[ch] libxslt/transform.c:
+         changed again the way parameter are evaluated before a
+         call-template, seems to fix a few nasty bugs, memory alloc debug too
+       
+Wed Feb 21 09:10:13 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c libxslt/variables.c libxslt/xsltInternals.h:
+         fixed the param evaluation problem in apply-template
+       * libxslt/pattern.c: speed up seriously some context computation
+       * libxslt/xsltInternals.h: preparing for extension support
+         
+Mon Feb 19 19:34:59 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/Makefile.am: small cleanup
+       * libxslt/functions.c libxslt/transform.c libxslt/xsltInternals.h:
+         fixed current() I hope
+
+Mon Feb 19 18:05:47 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/numbers.c libxslt/numbersInternals.h libxslt/xslt.c
+         libxslt/pattern.[ch] libxslt/xsltInternals.h:  more work on
+         support of namespaces, both in templates and in XPath subexpressions
+
+Sun Feb 18 19:11:26 CET 2001 Bjorn Reese <breese@users.sourceforge.net>
+
+       * libxslt/xsltutils.c: xsltSortFunction uses Shell's sort
+
+Sun Feb 18 17:13:00 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/pattern.c: when precompiled pattern is ALL, predicate
+         contextual info must be recomputed
+
+Sun Feb 18 16:39:17 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt.h libxslt/transform.c: defined and exported xsltMaxDepth
+       * libxslt/xsltproc.c : added --maxdepth
+
+Sun Feb 18 15:44:33 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+
+       * libxslt/xsltproc.c: added --novalid and --noout as well
+         as options printing when no args
+       * libxslt/variables.c libxslt/transform.c: trying to get rid
+         if some variable/params addressing errors.
+
+Sat Feb 17 14:27:47 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES libxslt/attributes.c: fixed use-attribute-sets
+       * libxslt/xsltutils.c: add carriage return to xsl:message when
+         needed
+
+Sat Feb 17 02:25:45 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/functions.c: fixed a bug with generate-id()
+
+Sat Feb 17 00:51:53 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltutils.c: started doing more useful stuff in
+         xsltDebug
+       * libxslt/transform.[ch] libxslt/variables.[ch] libxslt/templates.c
+         libxslt/xsltInternals.h: changed the way variables/params
+         are stored
+       * libxslt/xsltproc.c: removed a pedantic warning
+       * libxslt/variables.[ch]: found an ugly evaluation bug
+
+Thu Feb 15 18:14:48 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/REC/Makefile.am: updated
+
+Thu Feb 15 17:40:28 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxlst/functions.c: fixed ID generation
+       * doc/xslt.html doc/html/*.html: updated/regenerated the doc
+
+Thu Feb 15 13:34:42 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/numbers.c: removed a couple of memleaks
+
+Thu Feb 15 12:41:44 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/pattern.[ch]: exported pattern matching interfaces
+         for numbers.c and future debug module
+       * libxslt/numbers.c: updated to new interface, should avoid
+         unnecessary recompilation of patterns.
+       * libxslt/xsltutils.[ch]: cleanup
+       * tests/REC/gmon.out: removed :-)
+
+Wed Feb 14 19:13:33 CET 2001 Bjorn Reese <breese@users.sourceforge.net>
+
+       * libxslt/numbers.c: implemented level=any
+       * libxslt/transform.c: corrected some default values
+       * tests/REC/test-7.7-*.*: added
+
+Wed Feb 14 18:07:25 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/pattern.c: priorities were horribly broken, hope it's
+         fixed
+
+Wed Feb 14 15:39:06 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES libxslt/imports.h libxslt/pattern.[ch]
+         libxslt/xsltInternals.h libxslt/transform.[ch]
+         libxslt/templates.c libxslt/xslt.c:
+         Added apply-imports, keep a stack of running templates
+       * libxslt/xsltutils.c: bugfixes, gather the output informations
+         down the cascade
+       * tests/xmlspec/Makefile.am tests/xmlspec/REC-xml-2e.xsl
+         tests/xmlspec/diffspec.xsl tests/xmlspec/xmlspec.xsl: running
+         the real set of transformation on XML-1.0 2e generages a near
+         perfect HTML. Needs just more number fixes and implementation
+         and an obscure problem in 3.3.3
+
+Tue Feb 13 20:31:03 CET 2001 Bjorn Reese <breese@users.sourceforge.net>
+
+       * libxslt/pattern.c: added xsltMatchPattern()
+       * libxslt/numbers.c: implemented "level=multiple" for xsl:number
+
+Tue Feb 13 18:07:12 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c libxslt/xsltproc.c: cleanup and debug
+       * libxslt/xsltutils.[ch] : added a small debugging hook
+
+Mon Feb 12 18:30:26 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/FEATURES libxslt/transform.c: added support for
+         disable-output-escaping in xsl:copy-of
+       * xmlspec/Makefile.am libxslt/variables.c libxslt/transform.c:
+         give more debugging info
+
+Sun Feb 11 21:08:35 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/documents.[ch] libxslt/functions.c libxslt/imports.c
+         libxslt/xslt.c libxslt/xsltInternals.h: changed teh way to store
+         Includes, more document changes
+       * libxslt/xsltutils.c: fix the output of doctype and what is or
+         is not HTML
+       * tests/REC/*.out tests/REC2/html.xml : changed output accordingly
+       * tests/Makefile.am tests/documents/* : added a new test from Stric
+         exercising document() among other things
+
+Sun Feb 11 17:24:03 CET 2001 Bjorn Reese <breese@users.sourceforge.net>
+
+       * FEATURES libxslt/transform.c libxslt/numbers.c: partial support
+         for the level attribute for xsl:number
+       * libxslt/numbers.c: internal restructuring
+
+Fri Feb  9 15:49:19 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/Makefile.am libxslt/documents.[ch]: added a new module
+         to deal with documents
+       * libxslt/functions.c: fixed document() to return the same set
+         for teh same URL
+       * libxslt/keys.[ch] libxslt/templates.c libxslt/transform.c
+         libxslt/variables.c libxslt/xsltInternals.h: keys are really
+         associated to loaded documents, not to the transformation
+         context, made the change, this impacted a number of modules
+
+Thu Feb  8 12:51:00 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * doc/libxslt.sgml doc/html/*.html: updated and rebuilt the doc list
+
+Thu Feb  8 12:36:23 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * README configure.in libxslt.spec.in: bumped to 0.1.0, getting
+         ready for the release
+       * libxslt/keys.c libxslt/xslt.c: cleanup of uninitialized vars
+       * tests/REC1/Makefile.am tests/REC/Makefile.am: the EXTRA list
+         was not up to date
+
+Thu Feb  8 12:09:58 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES libxslt/xsltInternals.h libxslt/pattern.c libxslt/keys.c:
+         added support for keys in patterns
+       * tests/REC/test-12.2-2.*: added a specific testcase
+
+Wed Feb  7 21:16:47 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/functions.c FEATURES: started adding support for key()
+       * tests/REC/test-12.2-1.*: first key test
+
+Wed Feb  7 19:46:07 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES: updated
+       * libxslt/Makefile.am libxslt/keys.[ch] libxslt/xslt.c
+         libxslt/transform.c libxslt/xsltInternals.h: started adding key
+         support
+       * libxslt/xsltutils.c: warning cleanup
+       * libxslt/pattern.h: fixed soopid cut'n paste prob
+
+Tue Feb  6 10:56:38 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c libxslt/xslt.c: chased some reported
+         unitinitialized variables.
+
+Tue Feb  6 10:55:26 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/numbers/Makefile.am: fixed the EXTRA stuff
+
+Mon Feb  5 22:02:24 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * Copyright IPR Makefile.am: added some wording and a rewrite
+         of the W3C IPR but without giving Copyright rights to W3C,
+         should suit everybody
+
+Mon Feb  5 18:58:17 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES: updated, added mode support for templates
+       * pattern.[ch] transform.c xslt.c xsltInternals.h: added mode
+         support for templates
+       * templates.c variables.c: simple fixes
+       * xslt.c: added a separate DEBUG_BLANKS debug class disabled
+       * xsltproc.c: added option -timing
+       * xsltutils.c: seem I forgot to add encoding support in output...
+       * configure.in tests/Makefile.am tests/xmlspec/*: added a test
+         consisting of reformatting the XML REC with the xmlspec XSLT,
+         heavy !
+
+Mon Feb  5 18:43:37 CET 2001 Bjorn Reese <breese@users.sourceforge.net>
+
+       * FEATURES: updated
+       * numbers.c: handles actual number formatting for both xsl:number
+         and the format-number extension function.
+       * function.c: formatting moved to numbers.c
+       * transform.c: added xsl:number
+       * xslt.c: minor memory leak removed
+       * Makefile.am: added numbers.c and numbersInternals.h
+
+Sat Feb  3 21:49:36 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * TODO: updated
+       * doc/html/*.html updated
+       * doc/libxslt.sgml: added new modules
+       * libxslt/pattern.c: fix loop on hash clashes.
+
+Sat Feb  3 16:13:35 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES: updated
+       * imports.c: bugfix
+       * pattern.c: lots of changes to make most patterns work
+       * templates.[ch]: added xsltEvalXPathPredicate() for predicate testing
+       * transform.c: cleanup and attribute patterns testing
+       * xslt.c: added xsltFreeStylesheetList() and now cleanup
+         the imports
+       * tests/REC/test-2.3* tests/REC/test-2.6.2*: more tests
+       * tests/REC/test-5.2-*: 18 pattern tests from the spec, all should
+         work now.
+
+Fri Feb  2 11:15:24 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES: updated
+       * transform.c: added xsl:element support
+       * namespaces.[ch]: added xsltGetSpecialNamespace()
+       * attributes.c: added xsl:attribute namespace support.
+
+Thu Feb  1 20:58:54 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/Makefile.am libxslt/imports.[ch]: new module to
+         implement import cascade lookups and traversal
+       * libxslt/attributes.c libxslt/namespaces.c libxslt/pattern.[ch]
+         libxslt/transform.c libxslt/xslt.c libxslt/xsltInternals.h:
+         started coding the import cascade lookup in the places needed,
+         probably incomplete.
+
+Thu Feb  1 18:04:39 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltInternals.h libxslt/xslt.h: started implementing
+         xsl:include and xsl:import, untested
+
+Thu Feb  1 14:54:39 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES: updated choose/when/otherwise added
+       * libxslt/transform.c: plugged choose in
+       * configure.in tests/Makefile.am tests/REC/Makefile.am
+         tests/docs/Makefile.am tests/docs/items.xml tests/general/Makefile.am
+         tests/general/itemschoose.*: started adding a more generic
+         infrastructure for testing.
+
+Thu Feb  1 05:36:28 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/REC/test-11*: added more tests
+       * libxslt/transform.c libxslt/variables.c: fixing bugs raised by
+         said tests
+
+Wed Jan 31 21:42:43 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/REC/test-[9-10]*: added more tests
+       * tests/REC2/html.xml libxslt/xsltutils.c libxslt/transform.c:
+         fixed sorting
+
+Wed Jan 31 19:25:38 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/REC/test-[7-9]*: added more tests
+       * libxslt/templates.c libxslt/transform.c libxslt/variables.c:
+         fixing bugs raised by said tests, cleaned up the way ctxt->xpathctxt
+         is allocated, overall cleanup.
+
+Wed Jan 31 14:25:25 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/REC/test-7.*: added more tests
+       * libxslt/pattern.c libxslt/templates.c libxslt/transform.c:
+         fixing bugs raised by said tests
+
+Tue Jan 30 18:55:49 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/REC/test-7.*: added more tests
+       * libxslt/namespaces.[ch] libxslt/pattern.c libxslt/attributes.c
+         libxslt/templates.c libxslt/transform.c libxslt/xslt.c: fixing bugs
+         raised by said tests
+
+Tue Jan 30 15:16:56 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * TODO: updated
+       * configure.in tests/Makefile.am tests/REC/*: started adding
+         some regression tests based from fragments of spec examples
+       * libxslt/transform.c: fixed a problem on namespace generation
+
+Mon Jan 29 18:40:23 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES: updated
+       * tests/numbers/Makefile.am tests/numbers/format-number.*
+         tests/Makefile.am configure.in: added number formattting
+         test from Bjorn
+       * libxslt/attributes.[ch]: separated attribute support, started
+         add support for attribute-sets
+       * libxslt/functions.[ch]: update for number and formatting
+         from Bjorn
+       * libxslt/transform.c libxslt/xslt.c libxslt/xsltInternals.h:
+         cleanups updates, etc ...
+
+Mon Jan 29 00:53:25 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES: updated
+       * libxslt/transform.c: added copy-of support
+       * libxslt/xsltutils.[ch]: added xsltDocumentSortFunction()
+
+Sun Jan 28 21:45:23 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES TODO: updates
+       * libxslt/xsltutils.[ch] libxslt/xsltInternals.h libxslt/xsltutils.h:
+         added xsl:message
+
+Sun Jan 28 17:25:35 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES TODO: updates
+       * libxslt/namespaces.[ch] libxslt/templates.c libxslt/transform.c
+         libxslt/xslt.c libxslt/xsltInternals.h: added support for
+         namespace aliases and cleaned up the overall namespace related
+         code. This materialize as a new module.
+
+Sun Jan 28 08:41:10 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in libxslt.spec.in: changes needed for libxml2-devel
+         changes
+
+Sat Jan 27 11:00:20 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt.spec.in doc/xslt.html: updating doc and trying to add
+         it to the RPM.
+
+Fri Jan 26 22:29:34 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * Makefile.am configure.in doc/Makefile.am: added a doc subdir
+         and the rules to generates the makefiles.
+       * doc/libxslt.sgml doc/xslt.html: very first version of the manual
+       * doc/html/*.html : autogenerated documentation
+       * libxslt/xsltInternals.h: fixed a typedef wich was breaking gtk-doc
+
+Fri Jan 26 21:48:25 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/functions.c: xsltGenerateIdFunction() small patch
+
+Thu Jan 25 19:36:45 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES TODO README INSTALL: updated
+       * libxslt/xslt.h: added URL and version/vendor :-)
+       * libxslt/transform.c: fixed a problem in xsl:attribute, removed
+         attempt to support older libxml2 version.
+       * libxslt/variables.h libxslt/xsltInternals.h: update to structures
+         and macros to add/register new document created by document()
+       * libxslt/functions.c: implemented current(), unparsed-entity-uri()
+         system-property(), element-available() and function-available().
+         A crippled version of document() has been added too.
+
+Thu Jan 25 12:13:04 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * functions.[ch]: Bjorn Reese <breese@mail1.stofanet.dk> provided
+         number formatting !!!
+       * acconfig.h config.h.in configure.in libxslt/Makefile.am
+         tests/Makefile.am; added testing for mathematical functions,
+         fixed make test(s)
+       * FEATURES: updated
+
+Wed Jan 24 16:59:05 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltInternals.h libxslt/pattern.c: fixed problems
+         with non-named rules (*, ...) added accelerators
+       * libxslt/templates.[ch]: added xsltEvalTemplateString()
+         and xsltEvalAttrValueTemplate() high level functions
+       * libxslt/transform.c: fixed the part where attributes
+         had to be looked at as templates, added comment and
+         PI generation
+       * TODO FEATURES: updated to reflect the new state
+
+Wed Jan 24 05:33:54 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/functions.[ch] Makefile.am: added new module functions
+         with templates for the XSLT functions.
+       * libxslt/variables.h templates.c: added registrations of new
+         functions when an XPath context is created
+
+Tue Jan 23 17:24:26 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * tests/Makefile.am: cleanup
+       * libxslt/pattern.c: should support most of the patterns now
+         except ID/Key and maybe some namespace checks when having
+         a default namespace
+       * TODO: updated
+
+Tue Jan 23 14:58:32 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * Makefile.am libxslt.spec.in tests/REC1/Makefile.am
+         tests/REC2/Makefile.am: updated the makefiles and spec files to
+         add tests, and the FEATURES file to the RPM
+
+Mon Jan 22 23:35:57 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * Makefile.am libxslt.spec.in libxslt/Makefile.am tests/Makefile.am:
+         prepared the Makefiles and spec files for a first release.
+       * COPYING.LIB: added LGPL Licence
+
+Mon Jan 22 22:36:43 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c: applied cleanup patch from Bjorn Reese
+         <breese@mail1.stofanet.dk>
+
+Mon Jan 22 20:24:36 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in libxslt.spec.in: first try to get a spec file
+
+Mon Jan 22 19:37:00 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xsltproc.c: avoid segfault when stylesheet is inproper
+       * libxslt/transform.c: add support for "*" to strip and preserve
+         space.
+
+Mon Jan 22 15:30:19 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * TODO: updated
+       * FEATURES: added with alist of what's in and what's not
+       * libxslt/xslt.c: fixed top level Param and Variable stuff
+
+Mon Jan 22 11:46:44 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * xsltproc.c: removed bug
+       * tests/REC2/html.xml: added newline after doctype
+       * libxslt/variables.[ch] libxslt/xsltInternals.h: added param
+         support, result tree fragment support (requires just commited
+         extensions to libxml2 XPath !!!)
+       * transform.c: added call-template, with-param support
+       * libxslt/pattern.[ch]: xsltFindTemplate() needed for call-template
+       * TODO: updated, added a DONE section and started migrating stuff :-)
+
+Sun Jan 21 12:03:16 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * Makefile.am tests/Makefile.am tests/REC1/Makefile.am
+         tests/REC2/Makefile.am tests/REC2/html.xml: added tests target
+         too, added the HTML output test
+       * libxmls/xsltutils.c: added HTML output
+       * libxslt/xslt.c: check version on literal result used as templates
+       * libxslt/transform.c: fixed an error in VERSION number
+       * libxslt/templates.c: make sure generated nodes have doc and
+         parent properly set
+
+Sat Jan 20 23:35:07 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/Makefile.am libxslt/template.[ch]: added a template
+         specific module. Added attribute value template, at least in
+         one spot.
+       * tests/REC2/Makefile.am tests/REC2/svg.xml: the SVG test from
+         the spec now works too.
+       * libxslt/variables.c: fixed the debug
+       * libxslt/xslt.c: fixed an ugly uninitialized variable
+       * libxslt/transform.c: now using attr template processing
+
+Sat Jan 20 17:59:20 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c libxslt/variables.[ch] libxslt/xslt.c
+         libxslt/xsltInternals.h libxslt/xsltutils.h: changed a few
+         structure to add an execution stack with variables. Tree
+         valued variables still missing.
+       * TODO: updated
+
+Fri Jan 19 13:16:57 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt.c: check version on stylesheets
+       * libxslt/xslt.c libxslt/xsltInternals.h libxslt/variables[.ch]:
+         started adding variables interfaces and modules.
+
+Thu Jan 18 16:08:38 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt.c: added support for disable-output-escaping
+         will need libxml version > 20211
+       * libxslt/transform.c: cleanup
+       * libxslt/xsltutils.[ch]: added output functions
+       * libxslt/xsltproc.c: reuse the output function
+       * tests/REC2/Makefile.am tests/REC2/vrml.xml: added VRML output
+         test
+
+Wed Jan 17 21:03:01 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c libxslt/xslt.c: avoiding some problems
+         with blank node stripping when not allowed.
+
+Wed Jan 17 20:15:40 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.c: modified apply-templates processing
+         added select and sort support support.
+
+Wed Jan 17 17:45:20 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * TODO: guess what, it's growing :-(
+       * configure.in: setup hacking values when compiling in my
+         own environment.
+       * libxslt/transform.c libxslt/xsltutils.[hc]: added a first
+         very rudimentary version of xsl:sort
+
+Wed Jan 17 14:25:25 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * TODO: more stuff
+       * libxslt/transform.c: context position and size in for-each
+       * libxslt/xsltutils[ch] libxslt/makefile.am: added the util module
+         and put Error and Debug routines
+       * libxslt/xslt.c libxslt/transform.c libxslt/pattern.c: switched
+         to use the Debug calls, cleanup
+       * libxslt/xsltproc.c: added -v to enable debug printing
+
+Tue Jan 16 17:17:17 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * TODO: started filling it :-(
+       * libxslt/pattern.c: should now at least compile the full
+         set of patterns authorized. Default priorities added.
+       * libxslt/transform.c: a bit more work and cleanup.
+
+Mon Jan 15 15:34:17 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * TODO: started adding in there :-(
+
+Mon Jan 15 15:31:41 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * transform.c, xslt.c, xsltproc.c: lots of fixes, added
+         support of xslt:if and xslt:attribute, need libxml2 interfaces
+         present only in CVS.
+
+Sat Jan 13 23:26:21 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * test/Makefile.am test/REC*/Makefile.am: added first test
+       * libxslt/pattern.c libxslt/transform.c libxslt/xslt.c:
+         cleanup of nodes at reading of stylesheet, added support
+         for xsl:for-each and fixed a few recursion bugs
+
+Fri Jan 12 22:33:07 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * pattern.c, xslt.c: removed debug
+       * transform.c: added value-of, seems to handle the first
+         REC example correctly
+
+Fri Jan 12 18:34:01 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * transform.c, xsltproc.c: small fight with spaces and formatting
+         may need a revisit later but looks pretty good right now.
+
+Fri Jan 12 13:43:30 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * transform.c: basic processing in place
+       * xsltInternals.h: exported one xslt.c function
+
+Thu Jan 11 21:10:59 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/transform.[ch] Makefile.am: started adding the
+         transformation module
+       * pattern.[ch] xslt.c: more work...
+
+Thu Jan 11 14:02:03 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/pattern.c: started adding xsltTestCompMatch()
+
+Wed Jan 10 20:44:30 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/pattern.c: more work on parsing selectors
+
+Wed Jan 10 16:29:41 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt*: completeted the structures
+       * libxslt/pattern.[ch]: started adding code to precompile patterns
+         and do the lookup
+       * libxslt/makefile.am: added the new files
+
+Mon Jan  8 19:55:18 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt.c : small cleanup
+       * configure.in libxslt/xsltconfig.h.in: add memory debug and
+         mechanism for compile-time options
+
+Sun Jan  7 22:53:12 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt.[ch]: started parsing templates
+
+Sun Jan  7 19:50:02 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt.[ch]: started parsing stylesheet xsl:stylesheet
+
+Sun Jan  7 16:11:42 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt.[ch] libxslt/xsltInternals.h libxslt/xsltproc.c:
+         very early coding
+
+Sun Jan  7 15:10:54 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * configure.in Makefile.am AUTHORS NEWS autogen.sh config.h.in
+         libxslt/Makefile.am tests/Makefile.am:
+         Created the library framework, imported it into the GNOME CVS base
+       * INSTALL: added a small instruction file.
+
+Sun Jan  7 13:51:30 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/xslt.[ch] libxslt/xsltInternals.h libxslt/xsltproc.c:
+         first steps toward building the framework
+
+Sun Jan  7 12:22:13 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * NOTES: added notes taken while reading the spec.
+
+Fri Jan  5 11:34:12 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * test/REC1 test/REC2: added examples from the XSLT REC
+
+Fri Jan  5 11:14:29 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * README: basic informations
+       * Changelog: created
diff --git a/reactos/dll/3rdparty/libxslt/Makefile.am b/reactos/dll/3rdparty/libxslt/Makefile.am
new file mode 100644 (file)
index 0000000..d5aff94
--- /dev/null
@@ -0,0 +1,64 @@
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/libxslt $(LIBXML_CFLAGS)
+
+lib_LTLIBRARIES = libxslt.la
+
+xsltincdir = $(includedir)/libxslt
+
+xsltinc_HEADERS =                      \
+       xslt.h                          \
+       xsltutils.h                     \
+       pattern.h                       \
+       templates.h                     \
+       variables.h                     \
+       keys.h                          \
+       numbersInternals.h              \
+       extensions.h                    \
+       extra.h                         \
+       functions.h                     \
+       namespaces.h                    \
+       imports.h                       \
+       attributes.h                    \
+       documents.h                     \
+       preproc.h                       \
+       transform.h                     \
+       security.h                      \
+       xsltInternals.h                 \
+       xsltconfig.h                    \
+       xsltexports.h
+
+libxslt_la_SOURCES =                   \
+       attrvt.c                        \
+       xslt.c                          \
+       xsltutils.c                     \
+       pattern.c                       \
+       templates.c                     \
+       variables.c                     \
+       keys.c                          \
+       numbers.c                       \
+       extensions.c                    \
+       extra.c                         \
+       functions.c                     \
+       namespaces.c                    \
+       imports.c                       \
+       attributes.c                    \
+       documents.c                     \
+       preproc.c                       \
+       transform.c                     \
+       security.c                      \
+       win32config.h                   \
+       xsltwin32config.h               \
+       xsltwin32config.h.in            \
+       libxslt.h
+
+libxslt_la_LIBADD = $(EXTRA_LIBS)
+libxslt_la_LDFLAGS = -version-info @LIBXSLT_VERSION_INFO@
+
+man_MANS = libxslt.3
+
+EXTRA_DIST = $(man_MANS) trio.h triodef.h
+
+xsltproc: all
+       @(cd ../xsltproc ; $(MAKE))
+
+install-exec-hook:
+       $(mkinstalldirs) "$(DESTDIR)$(libdir)/libxslt-plugins"
diff --git a/reactos/dll/3rdparty/libxslt/Makefile.in b/reactos/dll/3rdparty/libxslt/Makefile.in
new file mode 100644 (file)
index 0000000..3a64996
--- /dev/null
@@ -0,0 +1,679 @@
+# Makefile.in generated by automake 1.10 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = libxslt
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+       $(srcdir)/xsltconfig.h.in $(srcdir)/xsltwin32config.h.in \
+       $(xsltinc_HEADERS)
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES = xsltconfig.h xsltwin32config.h
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(man3dir)" \
+       "$(DESTDIR)$(xsltincdir)"
+libLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(lib_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libxslt_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_libxslt_la_OBJECTS = attrvt.lo xslt.lo xsltutils.lo pattern.lo \
+       templates.lo variables.lo keys.lo numbers.lo extensions.lo \
+       extra.lo functions.lo namespaces.lo imports.lo attributes.lo \
+       documents.lo preproc.lo transform.lo security.lo
+libxslt_la_OBJECTS = $(am_libxslt_la_OBJECTS)
+libxslt_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(libxslt_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+       $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = $(libxslt_la_SOURCES)
+DIST_SOURCES = $(libxslt_la_SOURCES)
+man3dir = $(mandir)/man3
+NROFF = nroff
+MANS = $(man_MANS)
+xsltincHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(xsltinc_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+EXSLT_INCLUDEDIR = @EXSLT_INCLUDEDIR@
+EXSLT_LIBDIR = @EXSLT_LIBDIR@
+EXSLT_LIBS = @EXSLT_LIBS@
+EXTRA_LIBS = @EXTRA_LIBS@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBEXSLT_MAJOR_VERSION = @LIBEXSLT_MAJOR_VERSION@
+LIBEXSLT_MICRO_VERSION = @LIBEXSLT_MICRO_VERSION@
+LIBEXSLT_MINOR_VERSION = @LIBEXSLT_MINOR_VERSION@
+LIBEXSLT_VERSION = @LIBEXSLT_VERSION@
+LIBEXSLT_VERSION_EXTRA = @LIBEXSLT_VERSION_EXTRA@
+LIBEXSLT_VERSION_INFO = @LIBEXSLT_VERSION_INFO@
+LIBEXSLT_VERSION_NUMBER = @LIBEXSLT_VERSION_NUMBER@
+LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
+LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
+LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBXML_CFLAGS = @LIBXML_CFLAGS@
+LIBXML_LIBS = @LIBXML_LIBS@
+LIBXML_REQUIRED_VERSION = @LIBXML_REQUIRED_VERSION@
+LIBXML_SRC = @LIBXML_SRC@
+LIBXSLT_DEFAULT_PLUGINS_PATH = @LIBXSLT_DEFAULT_PLUGINS_PATH@
+LIBXSLT_MAJOR_MINOR_VERSION = @LIBXSLT_MAJOR_MINOR_VERSION@
+LIBXSLT_MAJOR_VERSION = @LIBXSLT_MAJOR_VERSION@
+LIBXSLT_MICRO_VERSION = @LIBXSLT_MICRO_VERSION@
+LIBXSLT_MINOR_VERSION = @LIBXSLT_MINOR_VERSION@
+LIBXSLT_VERSION = @LIBXSLT_VERSION@
+LIBXSLT_VERSION_EXTRA = @LIBXSLT_VERSION_EXTRA@
+LIBXSLT_VERSION_INFO = @LIBXSLT_VERSION_INFO@
+LIBXSLT_VERSION_NUMBER = @LIBXSLT_VERSION_NUMBER@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MV = @MV@
+M_LIBS = @M_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PYTHON = @PYTHON@
+PYTHONSODV = @PYTHONSODV@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_SITE_PACKAGES = @PYTHON_SITE_PACKAGES@
+PYTHON_SUBDIR = @PYTHON_SUBDIR@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+RELDATE = @RELDATE@
+RM = @RM@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STATIC_BINARIES = @STATIC_BINARIES@
+STRIP = @STRIP@
+TAR = @TAR@
+VERSION = @VERSION@
+WIN32_EXTRA_LDFLAGS = @WIN32_EXTRA_LDFLAGS@
+WIN32_EXTRA_LIBADD = @WIN32_EXTRA_LIBADD@
+WITH_CRYPTO = @WITH_CRYPTO@
+WITH_DEBUGGER = @WITH_DEBUGGER@
+WITH_MEM_DEBUG = @WITH_MEM_DEBUG@
+WITH_MODULES = @WITH_MODULES@
+WITH_TRIO = @WITH_TRIO@
+WITH_XSLT_DEBUG = @WITH_XSLT_DEBUG@
+XML_CONFIG = @XML_CONFIG@
+XSLTPROCDV = @XSLTPROCDV@
+XSLT_INCLUDEDIR = @XSLT_INCLUDEDIR@
+XSLT_LIBDIR = @XSLT_LIBDIR@
+XSLT_LIBS = @XSLT_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/libxslt $(LIBXML_CFLAGS)
+lib_LTLIBRARIES = libxslt.la
+xsltincdir = $(includedir)/libxslt
+xsltinc_HEADERS = \
+       xslt.h                          \
+       xsltutils.h                     \
+       pattern.h                       \
+       templates.h                     \
+       variables.h                     \
+       keys.h                          \
+       numbersInternals.h              \
+       extensions.h                    \
+       extra.h                         \
+       functions.h                     \
+       namespaces.h                    \
+       imports.h                       \
+       attributes.h                    \
+       documents.h                     \
+       preproc.h                       \
+       transform.h                     \
+       security.h                      \
+       xsltInternals.h                 \
+       xsltconfig.h                    \
+       xsltexports.h
+
+libxslt_la_SOURCES = \
+       attrvt.c                        \
+       xslt.c                          \
+       xsltutils.c                     \
+       pattern.c                       \
+       templates.c                     \
+       variables.c                     \
+       keys.c                          \
+       numbers.c                       \
+       extensions.c                    \
+       extra.c                         \
+       functions.c                     \
+       namespaces.c                    \
+       imports.c                       \
+       attributes.c                    \
+       documents.c                     \
+       preproc.c                       \
+       transform.c                     \
+       security.c                      \
+       win32config.h                   \
+       xsltwin32config.h               \
+       xsltwin32config.h.in            \
+       libxslt.h
+
+libxslt_la_LIBADD = $(EXTRA_LIBS)
+libxslt_la_LDFLAGS = -version-info @LIBXSLT_VERSION_INFO@
+man_MANS = libxslt.3
+EXTRA_DIST = $(man_MANS) trio.h triodef.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+               && exit 0; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  libxslt/Makefile'; \
+       cd $(top_srcdir) && \
+         $(AUTOMAKE) --gnu  libxslt/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+xsltconfig.h: $(top_builddir)/config.status $(srcdir)/xsltconfig.h.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+xsltwin32config.h: $(top_builddir)/config.status $(srcdir)/xsltwin32config.h.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+       @$(NORMAL_INSTALL)
+       test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+       @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+         if test -f $$p; then \
+           f=$(am__strip_dir) \
+           echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
+           $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
+         else :; fi; \
+       done
+
+uninstall-libLTLIBRARIES:
+       @$(NORMAL_UNINSTALL)
+       @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+         p=$(am__strip_dir) \
+         echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
+         $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
+       done
+
+clean-libLTLIBRARIES:
+       -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+       @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+         dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+         test "$$dir" != "$$p" || dir=.; \
+         echo "rm -f \"$${dir}/so_locations\""; \
+         rm -f "$${dir}/so_locations"; \
+       done
+libxslt.la: $(libxslt_la_OBJECTS) $(libxslt_la_DEPENDENCIES) 
+       $(libxslt_la_LINK) -rpath $(libdir) $(libxslt_la_OBJECTS) $(libxslt_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/attributes.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/attrvt.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/documents.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extensions.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extra.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/functions.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imports.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keys.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/namespaces.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numbers.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pattern.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/preproc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/security.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/templates.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/transform.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/variables.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xslt.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xsltutils.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+install-man3: $(man3_MANS) $(man_MANS)
+       @$(NORMAL_INSTALL)
+       test -z "$(man3dir)" || $(MKDIR_P) "$(DESTDIR)$(man3dir)"
+       @list='$(man3_MANS) $(dist_man3_MANS) $(nodist_man3_MANS)'; \
+       l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+       for i in $$l2; do \
+         case "$$i" in \
+           *.3*) list="$$list $$i" ;; \
+         esac; \
+       done; \
+       for i in $$list; do \
+         if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
+         else file=$$i; fi; \
+         ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+         case "$$ext" in \
+           3*) ;; \
+           *) ext='3' ;; \
+         esac; \
+         inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+         inst=`echo $$inst | sed -e 's/^.*\///'`; \
+         inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+         echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \
+         $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst"; \
+       done
+uninstall-man3:
+       @$(NORMAL_UNINSTALL)
+       @list='$(man3_MANS) $(dist_man3_MANS) $(nodist_man3_MANS)'; \
+       l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+       for i in $$l2; do \
+         case "$$i" in \
+           *.3*) list="$$list $$i" ;; \
+         esac; \
+       done; \
+       for i in $$list; do \
+         ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+         case "$$ext" in \
+           3*) ;; \
+           *) ext='3' ;; \
+         esac; \
+         inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+         inst=`echo $$inst | sed -e 's/^.*\///'`; \
+         inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+         echo " rm -f '$(DESTDIR)$(man3dir)/$$inst'"; \
+         rm -f "$(DESTDIR)$(man3dir)/$$inst"; \
+       done
+install-xsltincHEADERS: $(xsltinc_HEADERS)
+       @$(NORMAL_INSTALL)
+       test -z "$(xsltincdir)" || $(MKDIR_P) "$(DESTDIR)$(xsltincdir)"
+       @list='$(xsltinc_HEADERS)'; for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         f=$(am__strip_dir) \
+         echo " $(xsltincHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(xsltincdir)/$$f'"; \
+         $(xsltincHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(xsltincdir)/$$f"; \
+       done
+
+uninstall-xsltincHEADERS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(xsltinc_HEADERS)'; for p in $$list; do \
+         f=$(am__strip_dir) \
+         echo " rm -f '$(DESTDIR)$(xsltincdir)/$$f'"; \
+         rm -f "$(DESTDIR)$(xsltincdir)/$$f"; \
+       done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '    { files[$$0] = 1; } \
+              END { for (i in files) print i; }'`; \
+       mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       tags=; \
+       here=`pwd`; \
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '    { files[$$0] = 1; } \
+              END { for (i in files) print i; }'`; \
+       if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+           $$tags $$unique; \
+       fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       tags=; \
+       here=`pwd`; \
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '    { files[$$0] = 1; } \
+              END { for (i in files) print i; }'`; \
+       test -z "$(CTAGS_ARGS)$$tags$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$tags $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && cd $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+           fi; \
+           cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+         else \
+           test -f $(distdir)/$$file \
+           || cp -p $$d/$$file $(distdir)/$$file \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(MANS) $(HEADERS)
+installdirs:
+       for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(xsltincdir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man install-xsltincHEADERS
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-libLTLIBRARIES
+       @$(NORMAL_INSTALL)
+       $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man: install-man3
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-libLTLIBRARIES uninstall-man \
+       uninstall-xsltincHEADERS
+
+uninstall-man: uninstall-man3
+
+.MAKE: install-am install-exec-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+       clean-libLTLIBRARIES clean-libtool ctags distclean \
+       distclean-compile distclean-generic distclean-libtool \
+       distclean-tags distdir dvi dvi-am html html-am info info-am \
+       install install-am install-data install-data-am install-dvi \
+       install-dvi-am install-exec install-exec-am install-exec-hook \
+       install-html install-html-am install-info install-info-am \
+       install-libLTLIBRARIES install-man install-man3 install-pdf \
+       install-pdf-am install-ps install-ps-am install-strip \
+       install-xsltincHEADERS installcheck installcheck-am \
+       installdirs maintainer-clean maintainer-clean-generic \
+       mostlyclean mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+       uninstall-am uninstall-libLTLIBRARIES uninstall-man \
+       uninstall-man3 uninstall-xsltincHEADERS
+
+
+xsltproc: all
+       @(cd ../xsltproc ; $(MAKE))
+
+install-exec-hook:
+       $(mkinstalldirs) "$(DESTDIR)$(libdir)/libxslt-plugins"
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/reactos/dll/3rdparty/libxslt/NEWS b/reactos/dll/3rdparty/libxslt/NEWS
new file mode 100644 (file)
index 0000000..de868e5
--- /dev/null
@@ -0,0 +1,790 @@
+
+        NEWS file for libxslt
+
+  Note that this is automatically generated from the news webpage at:
+       http://xmlsoft.org/XSLT/news.html
+
+The change log at 
+ChangeLog.html
+ describes the recents commits
+to the SVN at 
+http://svn.gnome.org/viewcvs/libxslt/trunk/
+ code base.Those are the public releases made:
+1.1.24: May 13 20088:
+   - Documentation: man page fix (Vincent Lefevre).
+   - Bug fixes: pattern bug fix, key initialization problems, exclusion of
+      unknown namespaced element on top of stylesheets, python generator
+      syntactic cleanup (Martin)
+
+
+1.1.23: Apr  8 2008:
+   - Documentation: fix links for Cygwin DocBook setup (Philippe Bourcier),
+      xsltParseStylesheetDoc doc fix (Jason Viers), fix manpage default
+      maxdepth value 
+   - Bug fixes: python segfault (Daniel Gryniewicz), week-in-year bug fix
+      (Maurice van der Pot), fix python iterator problem (William Brack),
+      avoid garbage collection problems on str:tokenize and str:split
+      and function results (William Brack and Peter Pawlowski) 
+      superfluous re-generation of keys (William Brack), remove superfluous
+      code in xsltExtInitTest (Tony Graham), func:result segfault fix
+      (William Brack), timezone offset problem (Peter Pawlowski),
+   - Portability fixes: old gcrypt support fix (Brent Cowgill), Python
+      portability patch (Stephane Bidoul), VS 2008 fix (Rob Richard) 
+
+
+1.1.22: Aug 23 2007:
+   - Bug fixes: RVT cleanup problems (William Brack), exclude-result-prefix
+      bug (William Brack), stylesheet compilation error handling (Rob Richards).
+      
+   - Portability fixes: improve build with VS2005 (Rob Richards), 
+      fixing build on AIX (Bjorn Wiberg), fix the security file checks on
+      Windows (Roland Schwarz and Rob Richards). 
+   - Improvement: add an --encoding option to xsltproc (Drazen Kacar). 
+
+
+1.1.21: Jun 12 2007:
+   - Bug fixes: out of memory allocation errors (William Brack), 
+      namespace problem on compound predicates (William Brack),
+      python space/tab inconsistencies (Andreas Hanke), hook xsl:message
+      to per transformation error callbacks (Shaun McCance),
+      cached RVT problem (William Brack), XPath context maintainance
+      on choose (William Brack), memory leaks in the math module (William
+      Brack), exclude-result-prefix induced namespace problem (William
+      Brack)
+   - Build: configure setup for TRIO_REPLACE_STDIO (William Brack)
+  
+   - Documentation: updated after change from CVs to SVN (William Brack)
+
+
+1.1.20: Jan 17 2007:
+   - Portability fixes: strict aliasing fix (Marcus Meissner), BSD portability
+      patches (Roland Illig)
+   - Bug fixes: Result Value Tree handling fix (William Brack), function
+      parameters fix (William), uninitialized variable (Kjartan Maraas),
+      empty text node handling (William), plugin support and test fixes (William),
+      fragment support fixes (William)
+   - Improvements: python stylesheet compare and transform context
+      access (Nic Ferrier), EXSLT string replace support (Joel Reed),
+      xsltproc better low level error handling (Mike Hommey and William)
+
+
+1.1.19: Nov 29 2006:
+   - Bug fixes: entities within attributes (William Brack), Python detection
+      problem (Joseph Sacco), in-scope namespace bug (Mike Hommey), Result
+      value tree caching bug (William Brack)
+
+
+1.1.18: Oct 26 2006:
+   - portability and build fixes: DESTDIR problem, build paths in python
+      shared lib, compile when libxml2 doesn't support XInclude (Gary Coady).
+   - bug fixes: a number of namespace related bugs (Kasimier Buchcik), 
+      parameters bugs (Kasimier Buchcik), proximity position in predicates
+      of match patterns (Kasimier), exslt-node-set troubles with strings
+      (Kasimier), CDATA serialization, Python floats and booleans XPath
+      conversions, XInclude support fixes, RVT cleanup problem (William Brack
+      and Kasimier), attribute checking in stylesheets (Kasimier), xsltForEach
+      context problem (Kasimier), security check should pass full URLs (Shane
+      Corgatelli), security cleanup patch (Mikhail Zabaluev), some python
+      accessor for stylesheet were broken, memory errors when compiling 
+      stylesheets (Mike Hommey), EXSLT current date end-of-month problem
+      (William Brack).
+   - improvements: refactoring of namespace handling, value-of impleemntation
+      and template internal processing (Kasimier Buchcik), new xsltproc
+      flag to apply Xinclude to stylesheets.
+   - documentation: xsltproc man pages (Daniel Leidert), tests updates
+      (William Brack), various typo fixes (Daniel Leidert), comments on
+      versions macros (Peter Breitenlohner).
+
+
+1.1.17: Jun 6 2006:
+   - portability fixes: python detection
+   - bug fixes: some regression tests, attribute/namespaces output (Kasimier
+    Buchcik), problem in mixed xsl:value-of and xsl:text uses (Kasimier)
+   - improvements: internal refactoring (Kasimier Buchcik), use of the XPath
+    object cache in libxml2-2.6.25 (Kasimier)
+
+
+1.1.16: May 01 2006:
+   - portability fixes: EXSLT date/time on Solaris and IRIX (Albert Chin),
+      HP-UX  build (Albert Chin), 
+  
+   - build fixes: Python detection(Joseph Sacco), plugin configurei
+      (Joel Reed)
+   - bug fixes: pattern compilation fix(William Brack), EXSLT date/time
+      fix (Thomas Broyer), EXSLT function bug, potential loop on variable
+      eval, startup race (Christopher Palmer), debug statement left in python
+      (Nic Ferrier), various cleanup based on Coverity reports), error on
+      Out of memory condition (Charles Hardin), various namespace prefixes
+      fixes (Kasimier Buchcik), 
+   - improvement: speed up sortingi, start of internals refactoring (Kasimier
+      Buchcik)
+   - documentation: man page fixes and updates (Daniel Leidert)
+
+
+
+1.1.15: Sep 04 2005:
+   - build fixes: Windows build cleanups and updates (Igor Zlatkovic),
+    remove jhbuild warnings
+   - bug fixes: negative number formatting (William Brack), number
+    formatting per mille definition (William Brack), XInclude default values
+    (William), text copy bugs (William), bug related to xmlXPathContext size,
+    reuse libxml2 memory management for text nodes, dictionary text bug,
+    forbid variables in match (needs libxml2-2.6.21)
+   - improvements: EXSLT dyn:map (Mark Vakoc),
+   - documentation: EXSLT date and time functions namespace in man (Jonathan
+    Wakely)
+
+
+1.1.14: Apr 02 2005:
+   - bug fixes: text node on stylesheet document without a dictionary
+    (William Brack), more checking of XSLT syntax, calling xsltInit()
+    multiple times, mode values interning raised by Mark Vakoc, bug in
+    pattern matching with ancestors, bug in patterna matching with cascading
+    select, xinclude and document() problem, build outside of source tree
+    (Mike Castle)
+   - improvement: added a --nodict mode to xsltproc to check problems for
+    docuemtns without dictionaries
+
+
+1.1.13: Mar 13 2005:
+   - build fixes: 64bits cleanup (William Brack), python 2.4 test (William),
+    LIBXSLT_VERSION_EXTRA on Windows (William), Windows makefiles fixes (Joel
+    Reed), libgcrypt-devel requires for RPM spec.
+   - bug fixes: exslt day-of-week-in-month (Sal Paradise), xsl:call-template
+    should not change the current template rule (William Brack), evaluation
+    of global variables (William Brack), RVT's in XPath predicates (William),
+    namespace URI on template names (Mark Vakoc), stat() for Windows patch
+    (Aleksey Gurtovoy), pattern expression fixes (William Brack), out of
+    memory detection misses (William), parserOptions propagation (William),
+    exclude-result-prefixes fix (William), // patten fix (William).
+   - extensions: module support (Joel Reed), dictionary based speedups
+    trying to get rid of xmlStrEqual as much as possible.
+   - documentation: added Wiki (Joel Reed)
+
+
+1.1.12: Oct 29 2004:
+   - build fixes: warnings removal (William).
+   - bug fixes: attribute document pointer fix (Mark Vakoc), exslt date
+    negative periods (William Brack), generated tree structure fixes,
+    namespace lookup fix, use reentrant gmtime_r (William Brack),
+    exslt:funtion namespace fix (William), potential NULL pointer reference
+    (Dennis Dams, William), force string interning on generated
+  documents.
+   - documentation: update of the second tutorial (Panagiotis Louridas), add
+    exslt doc in rpm packages, fix the xsltproc man page.
+
+
+1.1.11: Sep 29 2004:
+   - bug fixes: xsl:include problems (William Brack), UTF8 number pattern
+    (William), date-time validation (William), namespace fix (William),
+    various Exslt date fixes (William), error callback fixes, leak with
+    namespaced global variable, attempt to fix a weird problem #153137
+   - improvements: exslt:date-sum tests (Derek Poon)
+   - documentation: second tutorial by Panagiotis Lourida
+
+
+1.1.10: Aug 31 2004:
+   - build fix: NUL in c file blocking compilation on Solaris, Windows build
+    (Igor Zlatkovic)
+   - fix: key initialization problem (William Brack)
+   - documentation: fixed missing man page description for --path
+
+
+1.1.9: Aug 22 2004:
+   - build fixes: missing tests (William Brack), Python dependancies, Python
+    on 64bits boxes, --with-crypto flag (Rob Richards),
+   - fixes: RVT key handling (William), Python binding (William and Sitsofe
+    Wheeler), key and XPath troubles (William), template priority on imports
+    (William), str:tokenize with empty strings (William), #default namespace
+    alias behaviour (William), doc ordering missing for main document
+    (William), 64bit bug (Andreas Schwab)
+   - improvements: EXSLT date:sum added (Joel Reed), hook for document
+    loading for David Hyatt, xsltproc --nodtdattr to avoid defaulting DTD
+    attributes, extend xsltproc --version with CVS stamp (William).
+   - Documentation: web page problem reported by Oliver Stoeneberg
+
+
+1.1.8: July 5 2004:
+   - build fixes: Windows runtime options (Oliver Stoeneberg), Windows
+    binary package layout (Igor Zlatkovic), libgcrypt version test and link
+    (William)
+   - documentation: fix libxslt namespace name in doc (William)
+   - bug fixes: undefined namespace message (William Brack), search engine
+    (William), multiple namespace fixups (William), namespace fix for key
+    evaluation (William), Python memory debug bindings,
+   - improvements: crypto extensions for exslt (Joel Reed, William)
+
+
+1.1.7: May 17 2004:
+   - build fix: warning about localtime_r on Solaris
+   - bug fix: UTF8 string tokenize (William Brack), subtle memory
+    corruption, linefeed after comment at document level (William),
+    disable-output-escaping problem (William), pattern compilation in deep
+    imported stylesheets (William), namespace extension prefix bug,
+    libxslt.m4 bug (Edward Rudd), namespace lookup for attribute, namespaced
+    DOCTYPE name
+
+
+1.1.6: Apr 18 2004:
+   - 2 bug fixes about keys fixed one by Mark Vakoc
+
+
+1.1.5: Mar 23 2004:
+   - performance: use dictionary lookup for variables
+   - remove use of _private from source documents
+   - cleanup of "make tests" output
+   - bugfixes: AVT in local variables, use localtime_r to avoid thread
+    troubles (William), dictionary handling bug (William), limited number of
+    stubstitutions in AVT (William), tokenize fix for UTF-8 (William),
+    superfluous namespace (William), xsltproc error code on
+    <xsl:message> halt, OpenVMS fix, dictionary reference counting
+    change.
+
+
+1.1.4: Feb 23 2004:
+   - bugfixes: attributes without doc (Mariano Suárez-Alvarez), problem with
+    Yelp, extension problem
+   - display extension modules (Steve Little)
+   - Windows compilation patch (Mark Vadoc), Mingw (Mikhail Grushinskiy)
+
+
+1.1.3: Feb 16 2004:
+   - Rewrote the Attribute Value Template code, new XPath compilation
+    interfaces, dictionary reuses for XSLT with potential for serious
+    performance improvements.
+   - bug fixes: portability (William Brack), key() in node-set() results
+    (William), comment before doctype (William), math and node-set() problems
+    (William), cdata element and default namespace (William), behaviour on
+    unknown XSLT elements (Stefan Kost), priority of "//foo" patterns
+    (William), xsl:element and xsl:attribute QName check (William), comments
+    with -- (William), attribute namespace (William), check for ?> in PI
+    (William)
+   - Documentations: cleanup (John Fleck and William)
+   - Python: patch for OS-X (Gianni Ceccarelli), enums export (Stephane
+    bidoul)
+
+
+1.1.2: Dec 24 2003:
+   - Documentation fixes (John Fleck, William Brack), EXSLT documentation
+    (William Brack)
+   - Windows compilation fixes for MSVC and Mingw (Igor Zlatkovic)
+   - Bug fixes: exslt:date returning NULL strings (William Brack),
+    namespaces output (William Brack),  key and namespace definition problem,
+    passing options down to the document() parser, xsl:number fixes (William
+    Brack)
+
+
+1.1.1: Dec 10 2003:
+   - code cleanup (William Brack)
+   - Windows: Makefile improvements (Igor Zlatkovic)
+   - documentation improvements: William Brack, libexslt man page (Jonathan
+    Wakely)
+   - param in EXSLT functions (Shaun McCance)
+   - XSLT debugging improvements (Mark Vakoc)
+   - bug fixes: number formatting (Bjorn Reese), exslt:tokenize (William
+    Brack), key selector parsing with | reported by Oleg Paraschenko,
+    xsl:element with computed namespaces (William Brack), xslt:import/include
+    recursion detection (William Brack), exslt:function used in keys (William
+    Brack), bug when CDATA_SECTION are foun in the tree (William Brack),
+    entities handling when using XInclude.
+
+
+1.1.0: Nov 4 2003:
+   - Removed DocBook SGML broken support
+   - fix xsl:key to work with PIs
+   - Makefile and build improvement (Graham Wilson), build cleanup (William
+    Brack), macro fix (Justin Fletcher), build outside of source tree (Roumen
+    Petrov)
+   - xsltproc option display fix (Alexey Efimov), --load-trace (Crutcher
+    Dunnavant)
+   - Python: never use stdout for error
+   - extension memory error fix (Karl Eichwalder)
+   - header path fixes (Steve Ball)
+   - added saxon:line-number() to libexslt (Brett Kail)
+   - Fix some tortuous template problems when using predicates (William
+    Brack)
+   - Debugger status patch (Kasimier Buchcik)
+   - Use new libxml2-2.6.x APIs for faster processing
+   - Make sure xsl:sort is empty
+   - Fixed a bug in default processing of attributes
+   - Removes the deprecated breakpoint library
+   - detect invalid names on templates (William Brack)
+   - fix exslt:document (and similar) base handling problem
+
+
+1.0.33: Sep 12 2003:
+This is a bugfix only release   - error message missing argument (William Brack)
+   - mode not cascaded in template fallbacks (William Brack)
+   - catch redefinition of parameter/variables  (William Brack)
+   - multiple keys with same namespace name (William Brack)
+   - patch for compilation using MingW on Windows (Mikhail Grushinskiy)
+   - header export macros for Windows (Igor Zlatkovic)
+   - cdata-section-elements handling of namespaced names
+   - compilation without libxml2 XPointer support (Mark Vadoc)
+   - apply-templates crash (William Brack)
+   - bug with imported templates (William Brack)
+   - imported attribute-sets merging bug (DocBook) (William Brack)
+
+
+1.0.32: Aug 9 2003:
+   - bugfixes: xsltSaveResultToFile() python binding (Chris Jaeger), EXSLT
+    function (William Brack), RVT for globals (William Brack), EXSLT date
+    (William Brack),
+    speed of large text output, xsl:copy with attributes, strip-space and
+    namespaces prefix, fix for --path xsltproc option, EXST:tokenize (Shaun
+    McCance), EXSLT:seconds (William Brack), sort with multiple keys (William
+    Brack), checking of { and } for attribute value templates (William
+    Brack)
+  
+   - Python bindings for extension elements (Sean Treadway)
+   - EXSLT:split added (Shaun McCance)
+   - portability fixes for HP-UX/Solaris/IRIX (William Brack)
+   - doc cleanup
+
+
+1.0.31: Jul 6 2003:
+   - bugfixes: xsl:copy on namespace nodes, AVT for xsl:sort order, fix for
+    the debugger (Keith Isdale), output filename limitation, trio.h and
+    triodef.h added (Albert Chin), EXSLT node-set (Peter Breitenlohner),
+    xsltChoose and whitespace (Igor Zlatkovic),
+    stylesheet compilation (Igor Zlatkovic), NaN and sort (William Brack),
+    RVT bug introduced in 1.0.30
+  
+   - avoid generating &quot; (fix in libxml2-2.5.8)
+   - fix 64bit cleaness problem and compilation troubles introduced in
+  1.0.30
+   - Windows makefile generation (Igor Zlatkovic)
+   - HP-UX portability fix
+
+
+1.0.30: May 4 2003:
+   - Fixes and new APIs to handle Result Value Trees and avoid leaks
+   - Fixes for: EXSLT math pow() function (Charles Bozeman), global
+    parameter and global variables mismatch, a segfault on pattern
+    compilation errors, namespace copy in xsl:copy-of, python generator
+    problem, OpenVMS trio update, premature call to xsltFreeStackElem (Igor),
+    current node when templates applies to attributes
+
+
+1.0.29: Apr 1 2003:
+   - performance improvements especially for large flat documents
+   - bug fixes: Result Value Tree handling, XML IDs, keys(), extra namespace
+    declarations with xsl:elements.
+   - portability: python and trio fixes (Albert Chin), python on Solaris
+    (Ben Phillips)
+
+
+1.0.28: Mar 24 2003:
+   - fixed node() in patterns semantic.
+   - fixed a memory access problem in format-number()
+   - fixed stack overflow in recursive global variable or params
+   - cleaned up Result Value Tree handling, and fixed a couple of old bugs
+    in the process
+
+
+1.0.27: Feb 24 2003:
+   - bug fixes: spurious xmlns:nsX="" generation, serialization bug (in
+    libxml2), a namespace copy problem, errors in the RPM spec prereqs
+   - Windows path canonicalization and document cache fix (Igor)
+
+
+1.0.26: Feb 10 2003:
+   - Fixed 3 serious bugs in document() and stylesheet compilation which
+    could lead to a crash
+
+
+1.0.25: Feb 5 2003:
+   - Bug fix: double-free for standalone stylesheets introduced in 1.0.24, C
+    syntax pbm, 3 bugs reported by Eric van der Vlist
+   - Some XPath and XInclude related problems were actually fixed in
+    libxml2-2.5.2
+   - Documentation: emphasize taht --docbook is not for XML docs.
+
+
+1.0.24: Jan 14 2003:
+   - bug fixes: imported global varables, python bindings (Stéphane Bidoul),
+    EXSLT memory leak (Charles Bozeman), namespace generation on
+    xsl:attribute, space handling with imports (Daniel Stodden),
+    extension-element-prefixes (Josh Parsons), comments within xsl:text (Matt
+    Sergeant), superfluous xmlns generation, XInclude related bug for
+    numbering, EXSLT strings (Alexey Efimov), attribute-sets computation on
+    imports, extension module init and shutdown callbacks not called
+   - HP-UX portability (Alexey Efimov), Windows makefiles (Igor and Stephane
+    Bidoul), VMS makefile updates (Craig A. Berry)
+   - adds xsltGetProfileInformation() (Michael Rothwell)
+   - fix the API generation scripts
+   - API to provide the sorting routines (Richard Jinks)
+   - added XML description of the EXSLT API
+   - added ESXLT URI (un)escaping (Jörg Walter)
+   - Some memory leaks have been found and fixed
+   - document() now support fragment identifiers in URIs
+
+
+1.0.23: Nov 17 2002:
+   - Windows build cleanup (Igor)
+   - Unix build and RPM packaging cleanup
+   - Improvement of the python bindings: extension functions and activating
+    EXSLT
+   - various bug fixes: number formatting, portability for bounded string
+    functions, CData nodes, key(), @*[...] patterns
+   - Documentation improvements (John Fleck)
+   - added libxslt.m4 (Thomas Schraitle)
+
+
+1.0.22: Oct 18 2002:
+   - Updates on the Windows Makefiles
+   - Added a security module, and a related set of new options to
+  xsltproc
+   - Allowed per transformation error handler.
+   - Fixed a few bugs: node() semantic, URI escaping, media-type, attribute
+    lists
+
+
+1.0.21: Sep 26 2002:
+   - Bug fixes: match="node()", date:difference() (Igor and Charlie
+    Bozeman), disable-output-escaping
+   - Python bindings: style.saveResultToString() from Ralf Mattes
+   - Logos from Marc Liyanage
+   - Mem leak fix from Nathan Myers
+   - Makefile: DESTDIR fix from Christophe Merlet, AMD x86_64 (Mandrake),
+    Windows (Igor), Python detection
+   - Documentation improvements: John Fleck
+
+
+1.0.20: Aug 23 2002:
+   - Windows makefile updates (Igor) and x86-64 (Frederic Crozat)
+   - fixed HTML meta tag saving for Mac/IE users
+   - possible leak patches from Nathan Myers
+   - try to handle document('') as best as possible depending in the
+  cases
+   - Fixed the DocBook stylesheets handling problem
+   - Fixed a few XSLT reported errors
+
+
+1.0.19:  July 6 2002:
+   - EXSLT: dynamic functions and date support bug fixes (Mark Vakoc)
+   - xsl:number fix: Richard Jinks
+   - xsl:format-numbers fix: Ken Neighbors
+   - document('') fix: bug pointed by Eric van der Vlist
+   - xsl:message with terminate="yes" fixes: William Brack
+   - xsl:sort order support added: Ken Neighbors
+   - a few other bug fixes, some of them requiring the latest version of
+    libxml2
+
+
+1.0.18: May 27 2002:
+   - a number of bug fixes: attributes, extra namespace declarations
+    (DocBook), xsl:include crash (Igor), documentation (Christian Cornelssen,
+    Charles Bozeman and Geert Kloosterman),  element-available (Richard
+  Jinks)
+   - xsltproc can now list teh registered extensions thanks to Mark
+  Vakoc
+   - there is a new API to save directly to a string
+    xsltSaveResultToString() by Morus Walter
+   - specific error registration function for the python API
+
+
+1.0.17: April 29 2002:
+   - cleanup in code, XSLT debugger support and Makefiles for Windows by
+  Igor
+   - a C++ portability fix by Mark Vakoc
+   - EXSLT date improvement and regression tests by Charles Bozeman
+   - attempt to fix a bug in xsltProcessUserParamInternal
+
+
+1.0.16: April 15 2002:
+   - Bug fixes: strip-space, URL in HTML output, error when xsltproc can't
+    save
+   - portability fixes: OSF/1, IEEE on alphas, Windows, Python bindings
+
+
+1.0.15: Mar 25 2002:
+   - Bugfixes: XPath, python Makefile, recursive attribute sets, @foo[..]
+    templates
+   - Debug of memory alocation with valgind
+   - serious profiling leading to significant improvement for DocBook
+    processing
+   - revamp of the Windows build
+
+
+1.0.14: Mar 18 2002:
+   - Improvement in the XPath engine (libxml2-2.4.18)
+   - Nasty bug fix related to exslt:node-set
+   - Fixed the python Makefiles, cleanup of doc comments, Windows
+    portability fixes
+
+
+1.0.13: Mar 8 2002:
+   - a number of bug fixes including "namespace node have no parents"
+   - Improvement of the Python bindings
+   - Charles Bozeman provided fixes and regression tests for exslt date
+    functions.
+
+
+1.0.12: Feb 11 2002:
+   - Fixed the makefiles especially the python module ones
+   - half a dozen bugs fixes including 2 old ones
+
+
+1.0.11: Feb 8 2002:
+   - Change of Licence to the MIT
+  Licence
+   - Added a beta version of the Python bindings, including support to
+    extend the engine with functions written in Python
+   - A number of bug fixes
+   - Charlie Bozeman provided more EXSLT functions
+   - Portability fixes
+
+
+1.0.10: Jan 14 2002:
+   - Windows fixes for Win32 from Igor
+   - Fixed the Solaris compilation trouble (Albert)
+   - Documentation changes and updates: John Fleck
+   - Added a stringparam option to avoid escaping hell at the shell
+  level
+   - A few bug fixes
+
+
+1.0.9: Dec 7 2001:
+   - Makefile patches from Peter Williams
+   - attempt to fix the compilation problem associated to prelinking
+   - obsoleted libxsltbreakpoint now deprecated and frozen to 1.0.8 API
+   - xsltproc return codes are now significant, John Fleck updated the
+    documentation
+   - patch to allow as much as 40 steps in patterns (Marc Tardif), should be
+    made dynamic really
+   - fixed a bug raised by Nik Clayton when using doctypes with HTML
+  output
+   - patches from Keith Isdale to interface with xsltdebugger
+
+
+1.0.8: Nov 26 2001:
+   - fixed an annoying header problem, removed a few bugs and some code
+    cleanup
+   - patches for Windows and update of Windows Makefiles by Igor
+   - OpenVMS port instructions from John A Fotheringham
+   - fixed some Makefiles annoyance and libraries prelinking
+  information
+
+
+1.0.7: Nov 10 2001:
+   - remove a compilation problem with LIBXSLT_PUBLIC
+   - Finishing the integration steps for Keith Isdale debugger
+   - fixes the handling of indent="no" on HTML output
+   - fixes on the configure script and RPM spec file
+
+
+1.0.6: Oct 30 2001:
+   - bug fixes on number formatting (Thomas), date/time functions (Bruce
+    Miller)
+   - update of the Windows Makefiles (Igor)
+   - fixed DOCTYPE generation rules for HTML output (me)
+
+
+1.0.5: Oct 10 2001:
+   - some portability fixes, including Windows makefile updates from
+  Igor
+   - fixed a dozen bugs on XSLT and EXSLT (me and Thomas Broyer)
+   - support for Saxon's evaluate and expressions extensions added (initial
+    contribution from Darren Graves)
+   - better handling of XPath evaluation errors
+
+
+1.0.4: Sep 12 2001:
+   - Documentation updates from John fleck
+   - bug fixes (DocBook  FO generation should be fixed)  and portability
+    improvements
+   - Thomas Broyer improved the existing EXSLT support and added String,
+    Time and Date core functions support
+
+
+1.0.3:  Aug 23 2001:
+   - XML Catalog support see the doc
+   - New NaN/Infinity floating point code
+   - A few bug fixes
+
+
+1.0.2:  Aug 15 2001:
+   - lot of bug fixes, increased the testsuite
+   - a large chunk of EXSLT is implemented
+   - improvements on the extension framework
+   - documentation improvements
+   - Windows MSC projects files should be up-to-date
+   - handle attributes inherited from the DTD by default
+
+
+1.0.1:  July 24 2001:
+   - initial EXSLT framework
+   - better error reporting
+   - fixed the profiler on Windows
+   - bug fixes
+
+
+1.0.0: July 10 2001:
+   - a lot of cleanup, a lot of regression tests added or fixed
+   - added a documentation for writing
+    extensions
+   - fixed some variable evaluation problems (with William)
+   - added profiling of stylesheet execution accessible as the xsltproc
+    --profile option
+   - fixed element-available() and the implementation of the various
+    chunking methods present, Norm Walsh provided a lot of feedback
+   - exclude-result-prefixes and namespaces output should now work as
+    expected
+   - added support of embedded stylesheet as described in section 2.7 of the
+    spec
+
+
+0.14.0: July 5 2001:
+   - lot of bug fixes, and code cleanup
+   - completion of the little XSLT-1.0 features left unimplemented
+   - Added and implemented the extension API suggested by Thomas Broyer
+   - the Windows MSC environment should be complete
+   - tested and optimized with a really large document (DocBook Definitive
+    Guide) libxml/libxslt should really be faster on serious workloads
+
+
+0.13.0: June 26 2001:
+   - lots of cleanups
+   - fixed a C++ compilation problem
+   - couple of fixes to xsltSaveTo()
+   - try to fix Docbook-xslt-1.4 and chunking, updated the regression test
+    with them
+   - fixed pattern compilation and priorities problems
+   - Patches for Windows and MSC project mostly contributed by Yon Derek
+   - update to the Tutorial by John Fleck
+   - William fixed bugs in templates and for-each functions
+   - added a new interface xsltRunStylesheet() for a more flexible output
+    (incomplete), added -o option to xsltproc
+
+
+0.12.0: June 18 2001:
+   - fixed a dozen of bugs reported
+   - HTML generation should be quite better (requires libxml-2.3.11 upgrade
+    too)
+   - William fixed some problems with document()
+   - Fix namespace nodes selection and copy (requires libxml-2.3.11 upgrade
+    too)
+   - John Fleck added a
+  tutorial
+   - Fixes for namespace handling when evaluating variables
+   - XInclude global flag added to process XInclude on document() if
+    requested
+   - made xsltproc --version more detailed
+
+
+0.11.0: June 1 2001:
+Mostly a bug fix release.   - integration of catalogs from xsltproc
+   - added --version to xsltproc for bug reporting
+   - fixed errors when handling ID in external parsed entities
+   - document() should hopefully work correctly but ...
+   - fixed bug with PI and comments processing
+   - William fixed the XPath string functions when using unicode
+
+
+0.10.0: May 19 2001:
+   - cleanups to make stylesheet read-only (not 100% complete)
+   - fixed URI resolution in document()
+   - force all XPath expression to be compiled at stylesheet parsing time,
+    even if unused ...
+   - Fixed HTML default output detection
+   - Fixed double attribute generation #54446
+   - Fixed {{ handling in attributes #54451
+   - More tests and speedups for DocBook document transformations
+   - Fixed a really bad race like bug in xsltCopyTreeList()
+   - added a documentation on the libxslt internals
+   - William Brack and Bjorn Reese improved format-number()
+   - Fixed multiple sort, it should really work now
+   - added a --docbook option for SGML DocBook input (hackish)
+   - a number of other bug fixes and regression test added as people were
+    submitting them
+
+
+0.9.0: May 3 2001:
+   - lot of various bugfixes, extended the regression suite
+   - xsltproc should work with multiple params
+   - added an option to use xsltproc with HTML input
+   - improved the stylesheet compilation, processing of complex stylesheets
+    should be faster
+   - using the same stylesheet for concurrent processing on multithreaded
+    programs should work now
+   - fixed another batch of namespace handling problems
+   - Implemented multiple level of sorting
+
+
+0.8.0: Apr 22 2001:
+   - fixed ansidecl.h problem
+   - fixed unparsed-entity-uri() and generate-id()
+   - sort semantic fixes and priority prob from William M. Brack
+   - fixed namespace handling problems in XPath expression computations
+    (requires libxml-2.3.7)
+   - fixes to current() and key()
+   - other, smaller fixes, lots of testing with N Walsh DocBook HTML
+    stylesheets
+
+
+0.7.0: Apr 10 2001:
+   - cleanup using stricter compiler flags
+   - command line parameter passing
+   - fix to xsltApplyTemplates from William M. Brack
+   - added the XSLTMark in the regression tests as well as document()
+
+
+0.6.0: Mar 22 2001:
+   - another beta
+   - requires 2.3.5, which provide XPath expression compilation support
+   - document() extension should function properly
+   - fixed a number or reported bugs
+
+
+0.5.0: Mar 10 2001:
+   - fifth beta
+   - some optimization work, for the moment 2 XSLT transform cannot use the
+    same stylesheet at the same time (to be fixed)
+   - fixed problems with handling of tree results
+   - fixed a reported strip-spaces problem
+   - added more reported/fixed bugs to the test suite
+   - incorporated William M. Brack fix for imports and global variables as
+    well as patch for with-param support in apply-templates
+   - a bug fix on for-each
+
+
+0.4.0: Mar 1 2001:
+   - fourth beta test, released at the same time of libxml2-2.3.3
+   - bug fixes
+   - some optimization
+   - started implement extension support, not finished
+   - implemented but not tested multiple file output
+
+
+0.3.0: Feb 24 2001:
+   - third beta test, released at the same time of libxml2-2.3.2
+   - lot of bug fixes
+   - some optimization
+   - added DocBook XSL based testsuite
+
+
+0.2.0: Feb 15 2001:
+   - second beta version, released at the same time as libxml2-2.3.1
+   - getting close to feature completion, lot of bug fixes, some in the HTML
+    and XPath support of libxml
+   - start becoming usable for real work. This version can now regenerate
+    the XML 2e HTML from the original XML sources and the associated
+    stylesheets (in section I of the XML
+    REC)
+   - Still misses extension element/function/prefixes support. Support of
+    key() and document() is not complete
+
+
+0.1.0: Feb 8 2001:
+   - first beta version, released at the same time as libxml2-2.3.0
+   - lots of bug fixes, first "testing" version, but incomplete
+
+
+0.0.1: Jan 25 2001:
+   - first alpha version released at the same time as libxml2-2.2.12
+   - Framework in place, should work on simple examples, but far from being
+    feature complete
+
+Daniel Veillard at 
+bugs.html
diff --git a/reactos/dll/3rdparty/libxslt/README b/reactos/dll/3rdparty/libxslt/README
new file mode 100644 (file)
index 0000000..f1e6455
--- /dev/null
@@ -0,0 +1,24 @@
+
+     XSLT support for libxml2 (XML toolkit from the GNOME project)
+
+Full documentation is available on-line at
+    http://xmlsoft.org/XSLT/
+
+This code is released under the MIT Licence see the Copyright file.
+To report bugs, follow the instructions at:
+  http://xmlsoft.org/XSLT/bugs.html
+
+A mailing-list xslt@gnome.org is available, to subscribe:
+    http://mail.gnome.org/mailman/listinfo/xslt
+
+The list archive is at:
+    http://mail.gnome.org/archives/xslt/
+
+All technical answers asked privately will be automatically answered on
+the list and archived for public access unless pricacy is explicitely
+required and justified.
+
+Daniel Veillard
+
+$Id: README,v 1.7 2003/02/04 17:20:01 veillard Exp $
diff --git a/reactos/dll/3rdparty/libxslt/attributes.c b/reactos/dll/3rdparty/libxslt/attributes.c
new file mode 100644 (file)
index 0000000..168dae6
--- /dev/null
@@ -0,0 +1,1132 @@
+/*
+ * attributes.c: Implementation of the XSLT attributes handling
+ *
+ * Reference:
+ *   http://www.w3.org/TR/1999/REC-xslt-19991116
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_MATH_H
+#include <math.h>
+#endif
+#ifdef HAVE_FLOAT_H
+#include <float.h>
+#endif
+#ifdef HAVE_IEEEFP_H
+#include <ieeefp.h>
+#endif
+#ifdef HAVE_NAN_H
+#include <nan.h>
+#endif
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/hash.h>
+#include <libxml/xmlerror.h>
+#include <libxml/uri.h>
+#include <libxml/parserInternals.h>
+#include "xslt.h"
+#include "xsltInternals.h"
+#include "xsltutils.h"
+#include "attributes.h"
+#include "namespaces.h"
+#include "templates.h"
+#include "imports.h"
+#include "transform.h"
+#include "preproc.h"
+
+#define WITH_XSLT_DEBUG_ATTRIBUTES
+#ifdef WITH_XSLT_DEBUG
+#define WITH_XSLT_DEBUG_ATTRIBUTES
+#endif
+
+/*
+ * TODO: merge attribute sets from different import precedence.
+ *       all this should be precomputed just before the transformation
+ *       starts or at first hit with a cache in the context.
+ *       The simple way for now would be to not allow redefinition of
+ *       attributes once generated in the output tree, possibly costlier.
+ */
+
+/*
+ * Useful macros
+ */
+#ifdef IS_BLANK
+#undef IS_BLANK
+#endif
+
+#define IS_BLANK(c) (((c) == 0x20) || ((c) == 0x09) || ((c) == 0xA) || \
+                     ((c) == 0x0D))
+
+#define IS_BLANK_NODE(n)                                               \
+    (((n)->type == XML_TEXT_NODE) && (xsltIsBlank((n)->content)))
+
+
+/*
+ * The in-memory structure corresponding to an XSLT Attribute in
+ * an attribute set
+ */
+
+
+typedef struct _xsltAttrElem xsltAttrElem;
+typedef xsltAttrElem *xsltAttrElemPtr;
+struct _xsltAttrElem {
+    struct _xsltAttrElem *next;/* chained list */
+    xmlNodePtr attr;   /* the xsl:attribute definition */
+    const xmlChar *set; /* or the attribute set */
+    const xmlChar *ns;  /* and its namespace */
+};
+
+/************************************************************************
+ *                                                                     *
+ *                     XSLT Attribute handling                         *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltNewAttrElem:
+ * @attr:  the new xsl:attribute node
+ *
+ * Create a new XSLT AttrElem
+ *
+ * Returns the newly allocated xsltAttrElemPtr or NULL in case of error
+ */
+static xsltAttrElemPtr
+xsltNewAttrElem(xmlNodePtr attr) {
+    xsltAttrElemPtr cur;
+
+    cur = (xsltAttrElemPtr) xmlMalloc(sizeof(xsltAttrElem));
+    if (cur == NULL) {
+        xsltGenericError(xsltGenericErrorContext,
+               "xsltNewAttrElem : malloc failed\n");
+       return(NULL);
+    }
+    memset(cur, 0, sizeof(xsltAttrElem));
+    cur->attr = attr;
+    return(cur);
+}
+
+/**
+ * xsltFreeAttrElem:
+ * @attr:  an XSLT AttrElem
+ *
+ * Free up the memory allocated by @attr
+ */
+static void
+xsltFreeAttrElem(xsltAttrElemPtr attr) {
+    xmlFree(attr);
+}
+
+/**
+ * xsltFreeAttrElemList:
+ * @list:  an XSLT AttrElem list
+ *
+ * Free up the memory allocated by @list
+ */
+static void
+xsltFreeAttrElemList(xsltAttrElemPtr list) {
+    xsltAttrElemPtr next;
+    
+    while (list != NULL) {
+       next = list->next;
+       xsltFreeAttrElem(list);
+       list = next;
+    }
+}
+
+#ifdef XSLT_REFACTORED
+    /*
+    * This was moved to xsltParseStylesheetAttributeSet().
+    */
+#else
+/**
+ * xsltAddAttrElemList:
+ * @list:  an XSLT AttrElem list
+ * @attr:  the new xsl:attribute node
+ *
+ * Add the new attribute to the list.
+ *
+ * Returns the new list pointer
+ */
+static xsltAttrElemPtr
+xsltAddAttrElemList(xsltAttrElemPtr list, xmlNodePtr attr) {
+    xsltAttrElemPtr next, cur;
+
+    if (attr == NULL)
+       return(list);
+    if (list == NULL)
+       return(xsltNewAttrElem(attr));
+    cur = list;
+    while (cur != NULL) {      
+       next = cur->next;
+       if (cur->attr == attr)
+           return(cur);
+       if (cur->next == NULL) {
+           cur->next = xsltNewAttrElem(attr);
+           return(list);
+       }
+       cur = next;
+    }
+    return(list);
+}
+#endif /* XSLT_REFACTORED */
+
+/**
+ * xsltMergeAttrElemList:
+ * @list:  an XSLT AttrElem list
+ * @old:  another XSLT AttrElem list
+ *
+ * Add all the attributes from list @old to list @list,
+ * but drop redefinition of existing values.
+ *
+ * Returns the new list pointer
+ */
+static xsltAttrElemPtr
+xsltMergeAttrElemList(xsltStylesheetPtr style,
+                     xsltAttrElemPtr list, xsltAttrElemPtr old) {
+    xsltAttrElemPtr cur;
+    int add;
+
+    while (old != NULL) {
+       if ((old->attr == NULL) && (old->set == NULL)) {
+           old = old->next;
+           continue;
+       }
+       /*
+        * Check that the attribute is not yet in the list
+        */
+       cur = list;
+       add = 1;
+       while (cur != NULL) {
+           if ((cur->attr == NULL) && (cur->set == NULL)) {
+               if (cur->next == NULL)
+                   break;
+               cur = cur->next;
+               continue;
+           }
+           if ((cur->set != NULL) && (cur->set == old->set)) {
+               add = 0;
+               break;
+           }
+           if (cur->set != NULL) {
+               if (cur->next == NULL)
+                   break;
+               cur = cur->next;
+               continue;
+           }
+           if (old->set != NULL) {
+               if (cur->next == NULL)
+                   break;
+               cur = cur->next;
+               continue;
+           }
+           if (cur->attr == old->attr) {
+               xsltGenericError(xsltGenericErrorContext,
+            "xsl:attribute-set : use-attribute-sets recursion detected\n");
+               return(list);
+           }
+           if (cur->next == NULL)
+               break;
+            cur = cur->next;
+       }
+
+       if (add == 1) {
+           /*
+           * Changed to use the string-dict, rather than duplicating
+           * @set and @ns; this fixes bug #340400.
+           */
+           if (cur == NULL) {
+               list = xsltNewAttrElem(old->attr);
+               if (old->set != NULL) {
+                   list->set = xmlDictLookup(style->dict, old->set, -1);
+                   if (old->ns != NULL)
+                       list->ns = xmlDictLookup(style->dict, old->ns, -1);
+               }
+           } else if (add) {
+               cur->next = xsltNewAttrElem(old->attr);
+               if (old->set != NULL) {
+                   cur->next->set = xmlDictLookup(style->dict, old->set, -1);
+                   if (old->ns != NULL)
+                       cur->next->ns = xmlDictLookup(style->dict, old->ns, -1);
+               }
+           }
+       }
+
+       old = old->next;
+    }
+    return(list);
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     Module interfaces                               *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltParseStylesheetAttributeSet:
+ * @style:  the XSLT stylesheet
+ * @cur:  the "attribute-set" element
+ *
+ * parse an XSLT stylesheet attribute-set element
+ */
+
+void
+xsltParseStylesheetAttributeSet(xsltStylesheetPtr style, xmlNodePtr cur) {
+    const xmlChar *ncname;
+    const xmlChar *prefix;
+    xmlChar *value;
+    xmlNodePtr child;
+    xsltAttrElemPtr attrItems;
+
+    if ((cur == NULL) || (style == NULL))
+       return;
+
+    value = xmlGetNsProp(cur, (const xmlChar *)"name", NULL);
+    if (value == NULL) {
+       xsltGenericError(xsltGenericErrorContext,
+            "xsl:attribute-set : name is missing\n");
+       return;
+    }
+
+    ncname = xsltSplitQName(style->dict, value, &prefix);
+    xmlFree(value);
+    value = NULL;
+
+    if (style->attributeSets == NULL) {
+#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
+       xsltGenericDebug(xsltGenericDebugContext,
+           "creating attribute set table\n");
+#endif
+       style->attributeSets = xmlHashCreate(10);
+    }
+    if (style->attributeSets == NULL)
+       return;
+
+    attrItems = xmlHashLookup2(style->attributeSets, ncname, prefix);
+
+    /*
+    * Parse the content. Only xsl:attribute elements are allowed.
+    */
+    child = cur->children;
+    while (child != NULL) {
+       /*
+       * Report invalid nodes.
+       */
+       if ((child->type != XML_ELEMENT_NODE) ||
+           (child->ns == NULL) ||
+           (! IS_XSLT_ELEM(child)))
+       {
+           if (child->type == XML_ELEMENT_NODE)
+               xsltTransformError(NULL, style, child,
+                       "xsl:attribute-set : unexpected child %s\n",
+                                child->name);
+           else
+               xsltTransformError(NULL, style, child,
+                       "xsl:attribute-set : child of unexpected type\n");
+       } else if (!IS_XSLT_NAME(child, "attribute")) {
+           xsltTransformError(NULL, style, child,
+               "xsl:attribute-set : unexpected child xsl:%s\n",
+               child->name);
+       } else {
+#ifdef XSLT_REFACTORED
+           xsltAttrElemPtr nextAttr, curAttr;
+
+           /*
+           * Process xsl:attribute
+           * ---------------------
+           */
+
+#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
+           xsltGenericDebug(xsltGenericDebugContext,
+               "add attribute to list %s\n", ncname);
+#endif
+           /*
+           * The following was taken over from
+           * xsltAddAttrElemList().
+           */
+           if (attrItems == NULL) {
+               attrItems = xsltNewAttrElem(child);
+           } else {
+               curAttr = attrItems;
+               while (curAttr != NULL) {
+                   nextAttr = curAttr->next;
+                   if (curAttr->attr == child) {
+                       /*
+                       * URGENT TODO: Can somebody explain
+                       *  why attrItems is set to curAttr
+                       *  here? Is this somehow related to
+                       *  avoidance of recursions?
+                       */
+                       attrItems = curAttr;
+                       goto next_child;
+                   }
+                   if (curAttr->next == NULL)                  
+                       curAttr->next = xsltNewAttrElem(child);
+                   curAttr = nextAttr;
+               }
+           }
+           /*
+           * Parse the xsl:attribute and its content.
+           */
+           xsltParseAnyXSLTElem(XSLT_CCTXT(style), child);
+#else
+#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
+           xsltGenericDebug(xsltGenericDebugContext,
+               "add attribute to list %s\n", ncname);
+#endif
+           /*
+           * OLD behaviour:
+           */
+           attrItems = xsltAddAttrElemList(attrItems, child);
+#endif
+       }
+
+#ifdef XSLT_REFACTORED
+next_child:
+#endif
+       child = child->next;
+    }
+
+    /*
+    * Process attribue "use-attribute-sets".
+    */
+    /* TODO check recursion */    
+    value = xmlGetNsProp(cur, (const xmlChar *)"use-attribute-sets",
+       NULL);
+    if (value != NULL) {
+       const xmlChar *curval, *endval;
+       curval = value;
+       while (*curval != 0) {
+           while (IS_BLANK(*curval)) curval++;
+           if (*curval == 0)
+               break;
+           endval = curval;
+           while ((*endval != 0) && (!IS_BLANK(*endval))) endval++;
+           curval = xmlDictLookup(style->dict, curval, endval - curval);
+           if (curval) {
+               const xmlChar *ncname2 = NULL;
+               const xmlChar *prefix2 = NULL;
+               xsltAttrElemPtr refAttrItems;
+               
+#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
+               xsltGenericDebug(xsltGenericDebugContext,
+                   "xsl:attribute-set : %s adds use %s\n", ncname, curval);
+#endif
+               ncname2 = xsltSplitQName(style->dict, curval, &prefix2);
+               refAttrItems = xsltNewAttrElem(NULL);
+               if (refAttrItems != NULL) {
+                   refAttrItems->set = ncname2;
+                   refAttrItems->ns = prefix2;
+                   attrItems = xsltMergeAttrElemList(style,
+                       attrItems, refAttrItems);
+                   xsltFreeAttrElem(refAttrItems);
+               }
+           }
+           curval = endval;
+       }
+       xmlFree(value);
+       value = NULL;
+    }
+
+    /*
+     * Update the value
+     */
+    /*
+    * TODO: Why is this dummy entry needed.?
+    */
+    if (attrItems == NULL)
+       attrItems = xsltNewAttrElem(NULL);
+    xmlHashUpdateEntry2(style->attributeSets, ncname, prefix, attrItems, NULL);
+#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
+    xsltGenericDebug(xsltGenericDebugContext,
+       "updated attribute list %s\n", ncname);
+#endif
+}
+
+/**
+ * xsltGetSAS:
+ * @style:  the XSLT stylesheet
+ * @name:  the attribute list name
+ * @ns:  the attribute list namespace
+ *
+ * lookup an attribute set based on the style cascade
+ *
+ * Returns the attribute set or NULL
+ */
+static xsltAttrElemPtr
+xsltGetSAS(xsltStylesheetPtr style, const xmlChar *name, const xmlChar *ns) {
+    xsltAttrElemPtr values;
+
+    while (style != NULL) {
+       values = xmlHashLookup2(style->attributeSets, name, ns);
+       if (values != NULL)
+           return(values);
+       style = xsltNextImport(style);
+    }
+    return(NULL);
+}
+
+/**
+ * xsltResolveSASCallback,:
+ * @style:  the XSLT stylesheet
+ *
+ * resolve the references in an attribute set.
+ */
+static void
+xsltResolveSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style,
+                      const xmlChar *name, const xmlChar *ns,
+                      ATTRIBUTE_UNUSED const xmlChar *ignored) {
+    xsltAttrElemPtr tmp;
+    xsltAttrElemPtr refs;
+
+    tmp = values;
+    while (tmp != NULL) {
+       if (tmp->set != NULL) {
+           /*
+            * Check against cycles !
+            */
+           if ((xmlStrEqual(name, tmp->set)) && (xmlStrEqual(ns, tmp->ns))) {
+               xsltGenericError(xsltGenericErrorContext,
+     "xsl:attribute-set : use-attribute-sets recursion detected on %s\n",
+                                 name);
+           } else {
+#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
+               xsltGenericDebug(xsltGenericDebugContext,
+                       "Importing attribute list %s\n", tmp->set);
+#endif
+
+               refs = xsltGetSAS(style, tmp->set, tmp->ns);
+               if (refs == NULL) {
+                   xsltGenericError(xsltGenericErrorContext,
+     "xsl:attribute-set : use-attribute-sets %s reference missing %s\n",
+                                    name, tmp->set);
+               } else {
+                   /*
+                    * recurse first for cleanup
+                    */
+                   xsltResolveSASCallback(refs, style, name, ns, NULL);
+                   /*
+                    * Then merge
+                    */
+                   xsltMergeAttrElemList(style, values, refs);
+                   /*
+                    * Then suppress the reference
+                    */
+                   tmp->set = NULL;
+                   tmp->ns = NULL;
+               }
+           }
+       }
+       tmp = tmp->next;
+    }
+}
+
+/**
+ * xsltMergeSASCallback,:
+ * @style:  the XSLT stylesheet
+ *
+ * Merge an attribute set from an imported stylesheet.
+ */
+static void
+xsltMergeSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style,
+                      const xmlChar *name, const xmlChar *ns,
+                      ATTRIBUTE_UNUSED const xmlChar *ignored) {
+    int ret;
+    xsltAttrElemPtr topSet;
+
+    ret = xmlHashAddEntry2(style->attributeSets, name, ns, values);
+    if (ret < 0) {
+       /*
+        * Add failed, this attribute set can be removed.
+        */
+#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
+       xsltGenericDebug(xsltGenericDebugContext,
+               "attribute set %s present already in top stylesheet"
+               " - merging\n", name);
+#endif
+       topSet = xmlHashLookup2(style->attributeSets, name, ns);
+       if (topSet==NULL) {
+           xsltGenericError(xsltGenericErrorContext,
+               "xsl:attribute-set : logic error merging from imports for"
+               " attribute-set %s\n", name);
+       } else {
+           topSet = xsltMergeAttrElemList(style, topSet, values);
+           xmlHashUpdateEntry2(style->attributeSets, name, ns, topSet, NULL);
+       }
+       xsltFreeAttrElemList(values);
+#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
+    } else {
+       xsltGenericDebug(xsltGenericDebugContext,
+               "attribute set %s moved to top stylesheet\n",
+                        name);
+#endif
+    }
+}
+
+/**
+ * xsltResolveStylesheetAttributeSet:
+ * @style:  the XSLT stylesheet
+ *
+ * resolve the references between attribute sets.
+ */
+void
+xsltResolveStylesheetAttributeSet(xsltStylesheetPtr style) {
+    xsltStylesheetPtr cur;
+
+#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
+    xsltGenericDebug(xsltGenericDebugContext,
+           "Resolving attribute sets references\n");
+#endif
+    /*
+     * First aggregate all the attribute sets definitions from the imports
+     */
+    cur = xsltNextImport(style);
+    while (cur != NULL) {
+       if (cur->attributeSets != NULL) {
+           if (style->attributeSets == NULL) {
+#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
+               xsltGenericDebug(xsltGenericDebugContext,
+                   "creating attribute set table\n");
+#endif
+               style->attributeSets = xmlHashCreate(10);
+           }
+           xmlHashScanFull(cur->attributeSets, 
+               (xmlHashScannerFull) xsltMergeSASCallback, style);
+           /*
+            * the attribute lists have either been migrated to style
+            * or freed directly in xsltMergeSASCallback()
+            */
+           xmlHashFree(cur->attributeSets, NULL);
+           cur->attributeSets = NULL;
+       }
+       cur = xsltNextImport(cur);
+    }
+
+    /*
+     * Then resolve all the references and computes the resulting sets
+     */
+    if (style->attributeSets != NULL) {
+       xmlHashScanFull(style->attributeSets, 
+               (xmlHashScannerFull) xsltResolveSASCallback, style);
+    }
+}
+
+/**
+ * xsltAttributeInternal:
+ * @ctxt:  a XSLT process context
+ * @node:  the current node in the source tree
+ * @inst:  the xsl:attribute element
+ * @comp:  precomputed information
+ * @fromAttributeSet:  the attribute comes from an attribute-set
+ *
+ * Process the xslt attribute node on the source node
+ */
+static void
+xsltAttributeInternal(xsltTransformContextPtr ctxt,
+                     xmlNodePtr contextNode,
+                      xmlNodePtr inst,
+                     xsltStylePreCompPtr castedComp,
+                      int fromAttributeSet)
+{
+#ifdef XSLT_REFACTORED
+    xsltStyleItemAttributePtr comp =
+       (xsltStyleItemAttributePtr) castedComp;   
+#else
+    xsltStylePreCompPtr comp = castedComp;
+#endif
+    xmlNodePtr targetElem;
+    xmlChar *prop = NULL;    
+    const xmlChar *name = NULL, *prefix = NULL, *nsName = NULL;
+    xmlChar *value = NULL;
+    xmlNsPtr ns = NULL;
+    xmlAttrPtr attr;    
+
+    if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL))
+        return;
+
+    /* 
+    * A comp->has_name == 0 indicates that we need to skip this instruction,
+    * since it was evaluated to be invalid already during compilation.
+    */
+    if (!comp->has_name)
+        return;
+    /*
+    * BIG NOTE: This previously used xsltGetSpecialNamespace() and
+    *  xsltGetNamespace(), but since both are not appropriate, we
+    *  will process namespace lookup here to avoid adding yet another
+    *  ns-lookup function to namespaces.c.
+    */
+    /*
+    * SPEC XSLT 1.0: Error cases:
+    * - Creating nodes other than text nodes during the instantiation of
+    *   the content of the xsl:attribute element; implementations may
+    *   either signal the error or ignore the offending nodes."
+    */
+
+    if (comp == NULL) {
+        xsltTransformError(ctxt, NULL, inst,
+           "Internal error in xsltAttributeInternal(): "
+           "The XSLT 'attribute' instruction was not compiled.\n");
+        return;
+    }
+    /*
+    * TODO: Shouldn't ctxt->insert == NULL be treated as an internal error?
+    *   So report an internal error?
+    */
+    if (ctxt->insert == NULL)
+        return;    
+    /*
+    * SPEC XSLT 1.0:
+    *  "Adding an attribute to a node that is not an element;
+    *  implementations may either signal the error or ignore the attribute."
+    *
+    * TODO: I think we should signal such errors in the future, and maybe
+    *  provide an option to ignore such errors.
+    */
+    targetElem = ctxt->insert;
+    if (targetElem->type != XML_ELEMENT_NODE)
+       return;
+    
+    /*
+    * SPEC XSLT 1.0:
+    * "Adding an attribute to an element after children have been added
+    *  to it; implementations may either signal the error or ignore the
+    *  attribute."
+    *
+    * TODO: We should decide whether not to report such errors or
+    *  to ignore them; note that we *ignore* if the parent is not an
+    *  element, but here we report an error.
+    */
+    if (targetElem->children != NULL) {
+       /*
+       * NOTE: Ah! This seems to be intended to support streamed
+       *  result generation!.
+       */
+        xsltTransformError(ctxt, NULL, inst,
+           "xsl:attribute: Cannot add attributes to an "
+           "element if children have been already added "
+           "to the element.\n");
+        return;
+    }
+
+    /*
+    * Process the name
+    * ----------------
+    */    
+
+#ifdef WITH_DEBUGGER
+    if (ctxt->debugStatus != XSLT_DEBUG_NONE)
+        xslHandleDebugger(inst, contextNode, NULL, ctxt);
+#endif
+
+    if (comp->name == NULL) {
+       /* TODO: fix attr acquisition wrt to the XSLT namespace */
+        prop = xsltEvalAttrValueTemplate(ctxt, inst,
+           (const xmlChar *) "name", XSLT_NAMESPACE);
+        if (prop == NULL) {
+            xsltTransformError(ctxt, NULL, inst,
+               "xsl:attribute: The attribute 'name' is missing.\n");
+            goto error;
+        }
+       if (xmlValidateQName(prop, 0)) {
+           xsltTransformError(ctxt, NULL, inst,
+               "xsl:attribute: The effective name '%s' is not a "
+               "valid QName.\n", prop);
+           /* we fall through to catch any further errors, if possible */
+       }
+       name = xsltSplitQName(ctxt->dict, prop, &prefix);
+       xmlFree(prop);
+
+       /*
+       * Reject a prefix of "xmlns".
+       */
+       if ((prefix != NULL) &&
+           (!xmlStrncasecmp(prefix, (xmlChar *) "xmlns", 5)))
+       {
+#ifdef WITH_XSLT_DEBUG_PARSING
+           xsltGenericDebug(xsltGenericDebugContext,
+               "xsltAttribute: xmlns prefix forbidden\n");
+#endif
+           /*
+           * SPEC XSLT 1.0:
+           *  "It is an error if the string that results from instantiating
+           *  the attribute value template is not a QName or is the string
+           *  xmlns. An XSLT processor may signal the error; if it does not
+           *  signal the error, it must recover by not adding the attribute
+           *  to the result tree."
+           * TODO: Decide which way to go here.
+           */
+           goto error;
+       }
+
+    } else {
+       /*
+       * The "name" value was static.
+       */
+#ifdef XSLT_REFACTORED
+       prefix = comp->nsPrefix;
+       name = comp->name;
+#else
+       name = xsltSplitQName(ctxt->dict, comp->name, &prefix);
+#endif
+    }
+    
+    /*
+    * Process namespace semantics
+    * ---------------------------
+    *
+    * Evaluate the namespace name.
+    */
+    if (comp->has_ns) {
+       /*
+       * The "namespace" attribute was existent.
+       */
+       if (comp->ns != NULL) {
+           /*
+           * No AVT; just plain text for the namespace name.
+           */
+           if (comp->ns[0] != 0)
+               nsName = comp->ns;
+       } else {
+           xmlChar *tmpNsName;
+           /*
+           * Eval the AVT.
+           */
+           /* TODO: check attr acquisition wrt to the XSLT namespace */
+           tmpNsName = xsltEvalAttrValueTemplate(ctxt, inst,
+               (const xmlChar *) "namespace", XSLT_NAMESPACE); 
+           /*
+           * This fixes bug #302020: The AVT might also evaluate to the 
+           * empty string; this means that the empty string also indicates
+           * "no namespace".
+           * SPEC XSLT 1.0:
+           *  "If the string is empty, then the expanded-name of the
+           *  attribute has a null namespace URI."
+           */
+           if ((tmpNsName != NULL) && (tmpNsName[0] != 0))
+               nsName = xmlDictLookup(ctxt->dict, BAD_CAST tmpNsName, -1);
+           xmlFree(tmpNsName);         
+       };          
+    } else if (prefix != NULL) {
+       /*
+       * SPEC XSLT 1.0:
+       *  "If the namespace attribute is not present, then the QName is
+       *  expanded into an expanded-name using the namespace declarations
+       *  in effect for the xsl:attribute element, *not* including any
+       *  default namespace declaration."
+       */      
+       ns = xmlSearchNs(inst->doc, inst, prefix);
+       if (ns == NULL) {
+           /*
+           * Note that this is treated as an error now (checked with
+           *  Saxon, Xalan-J and MSXML).
+           */
+           xsltTransformError(ctxt, NULL, inst,
+               "xsl:attribute: The QName '%s:%s' has no "
+               "namespace binding in scope in the stylesheet; "
+               "this is an error, since the namespace was not "
+               "specified by the instruction itself.\n", prefix, name);
+       } else
+           nsName = ns->href;  
+    }
+
+    if (fromAttributeSet) {
+       /*
+       * This tries to ensure that xsl:attribute(s) coming
+       * from an xsl:attribute-set won't override attribute of
+       * literal result elements or of explicit xsl:attribute(s).
+       * URGENT TODO: This might be buggy, since it will miss to
+       *  overwrite two equal attributes both from attribute sets.
+       */
+       attr = xmlHasNsProp(targetElem, name, nsName);
+       if (attr != NULL)
+           return;
+    }
+
+    /*
+    * Find/create a matching ns-decl in the result tree.
+    */
+    ns = NULL;
+    
+#if 0
+    if (0) {   
+       /*
+       * OPTIMIZE TODO: How do we know if we are adding to a
+       *  fragment or to the result tree?
+       *
+       * If we are adding to a result tree fragment (i.e., not to the
+       * actual result tree), we'll don't bother searching for the
+       * ns-decl, but just store it in the dummy-doc of the result
+       * tree fragment.
+       */
+       if (nsName != NULL) {
+           /*
+           * TODO: Get the doc of @targetElem.
+           */
+           ns = xsltTreeAcquireStoredNs(some doc, nsName, prefix);
+       }
+    }
+#endif
+
+    if (nsName != NULL) {      
+       /*
+       * Something about ns-prefixes:
+       * SPEC XSLT 1.0:
+       *  "XSLT processors may make use of the prefix of the QName specified
+       *  in the name attribute when selecting the prefix used for outputting
+       *  the created attribute as XML; however, they are not required to do
+       *  so and, if the prefix is xmlns, they must not do so"
+       */
+       /*
+       * xsl:attribute can produce a scenario where the prefix is NULL,
+       * so generate a prefix.
+       */
+       if (prefix == NULL) {
+           xmlChar *pref = xmlStrdup(BAD_CAST "ns_1");
+
+           ns = xsltGetSpecialNamespace(ctxt, inst, nsName, BAD_CAST pref,
+               targetElem);
+
+           xmlFree(pref);
+       } else {
+           ns = xsltGetSpecialNamespace(ctxt, inst, nsName, prefix,
+               targetElem);
+       }
+       if (ns == NULL) {
+           xsltTransformError(ctxt, NULL, inst,
+               "Namespace fixup error: Failed to acquire an in-scope "
+               "namespace binding for the generated attribute '{%s}%s'.\n",
+               nsName, name);
+           goto error;
+       }
+    }
+    /*
+    * Construction of the value
+    * -------------------------
+    */
+    if (inst->children == NULL) {
+       /*
+       * No content.
+       * TODO: Do we need to put the empty string in ?
+       */
+       attr = xmlSetNsProp(ctxt->insert, ns, name, (const xmlChar *) "");
+    } else if ((inst->children->next == NULL) && 
+           ((inst->children->type == XML_TEXT_NODE) ||
+            (inst->children->type == XML_CDATA_SECTION_NODE)))
+    {
+       xmlNodePtr copyTxt;
+       
+       /*
+       * xmlSetNsProp() will take care of duplicates.
+       */
+       attr = xmlSetNsProp(ctxt->insert, ns, name, NULL);
+       if (attr == NULL) /* TODO: report error ? */
+           goto error;
+       /*
+       * This was taken over from xsltCopyText() (transform.c).
+       */
+       if (ctxt->internalized &&
+           (ctxt->insert->doc != NULL) &&
+           (ctxt->insert->doc->dict == ctxt->dict))
+       {
+           copyTxt = xmlNewText(NULL);
+           if (copyTxt == NULL) /* TODO: report error */
+               goto error;
+           /*
+           * This is a safe scenario where we don't need to lookup
+           * the dict.
+           */
+           copyTxt->content = inst->children->content;
+           /*
+           * Copy "disable-output-escaping" information.
+           * TODO: Does this have any effect for attribute values
+           *  anyway?
+           */
+           if (inst->children->name == xmlStringTextNoenc)
+               copyTxt->name = xmlStringTextNoenc;
+       } else {
+           /*
+           * Copy the value.
+           */
+           copyTxt = xmlNewText(inst->children->content);
+           if (copyTxt == NULL) /* TODO: report error */
+               goto error;                 
+       }
+       attr->children = attr->last = copyTxt;
+       copyTxt->parent = (xmlNodePtr) attr;
+       copyTxt->doc = attr->doc;
+       /*
+       * Copy "disable-output-escaping" information.
+       * TODO: Does this have any effect for attribute values
+       *  anyway?
+       */
+       if (inst->children->name == xmlStringTextNoenc)
+           copyTxt->name = xmlStringTextNoenc; 
+
+    } else {
+       /*
+       * The sequence constructor might be complex, so instantiate it.
+       */
+       value = xsltEvalTemplateString(ctxt, contextNode, inst);
+       if (value != NULL) {
+           attr = xmlSetNsProp(ctxt->insert, ns, name, value);
+           xmlFree(value);
+       } else {
+           /*
+           * TODO: Do we have to add the empty string to the attr?
+           * TODO: Does a  value of NULL indicate an
+           *  error in xsltEvalTemplateString() ?
+           */
+           attr = xmlSetNsProp(ctxt->insert, ns, name,
+               (const xmlChar *) "");
+       }
+    }
+
+error:
+    return;    
+}
+
+/**
+ * xsltAttribute:
+ * @ctxt:  a XSLT process context
+ * @node:  the node in the source tree.
+ * @inst:  the xslt attribute node
+ * @comp:  precomputed information
+ *
+ * Process the xslt attribute node on the source node
+ */
+void
+xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr node,
+             xmlNodePtr inst, xsltStylePreCompPtr comp) {
+    xsltAttributeInternal(ctxt, node, inst, comp, 0);
+}
+
+/**
+ * xsltApplyAttributeSet:
+ * @ctxt:  the XSLT stylesheet
+ * @node:  the node in the source tree.
+ * @inst:  the attribute node "xsl:use-attribute-sets"
+ * @attrSets:  the list of QNames of the attribute-sets to be applied
+ *
+ * Apply the xsl:use-attribute-sets.
+ * If @attrSets is NULL, then @inst will be used to exctract this
+ * value.
+ * If both, @attrSets and @inst, are NULL, then this will do nothing.
+ */
+void
+xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                      xmlNodePtr inst,
+                      const xmlChar *attrSets)
+{
+    const xmlChar *ncname = NULL;
+    const xmlChar *prefix = NULL;    
+    const xmlChar *curstr, *endstr;
+    xsltAttrElemPtr attrs;
+    xsltStylesheetPtr style;    
+
+    if (attrSets == NULL) {
+       if (inst == NULL)
+           return;
+       else {
+           /*
+           * Extract the value from @inst.
+           */
+           if (inst->type == XML_ATTRIBUTE_NODE) {
+               if ( ((xmlAttrPtr) inst)->children != NULL)
+                   attrSets = ((xmlAttrPtr) inst)->children->content;
+               
+           }
+           if (attrSets == NULL) {
+               /*
+               * TODO: Return an error?
+               */
+               return;
+           }
+       }
+    }
+    /*
+    * Parse/apply the list of QNames.
+    */
+    curstr = attrSets;
+    while (*curstr != 0) {
+        while (IS_BLANK(*curstr))
+            curstr++;
+        if (*curstr == 0)
+            break;
+        endstr = curstr;
+        while ((*endstr != 0) && (!IS_BLANK(*endstr)))
+            endstr++;
+        curstr = xmlDictLookup(ctxt->dict, curstr, endstr - curstr);
+        if (curstr) {
+           /*
+           * TODO: Validate the QName.
+           */
+
+#ifdef WITH_XSLT_DEBUG_curstrUTES
+            xsltGenericDebug(xsltGenericDebugContext,
+                             "apply curstrute set %s\n", curstr);
+#endif
+            ncname = xsltSplitQName(ctxt->dict, curstr, &prefix);
+
+            style = ctxt->style;
+
+#ifdef WITH_DEBUGGER
+            if ((style != NULL) &&
+               (style->attributeSets != NULL) &&
+               (ctxt->debugStatus != XSLT_DEBUG_NONE))
+           {
+                attrs =
+                    xmlHashLookup2(style->attributeSets, ncname, prefix);
+                if ((attrs != NULL) && (attrs->attr != NULL))
+                    xslHandleDebugger(attrs->attr->parent, node, NULL,
+                       ctxt);
+            }
+#endif
+           /*
+           * Lookup the referenced curstrute-set.
+           */
+            while (style != NULL) {
+                attrs =
+                    xmlHashLookup2(style->attributeSets, ncname, prefix);
+                while (attrs != NULL) {
+                    if (attrs->attr != NULL) {
+                        xsltAttributeInternal(ctxt, node, attrs->attr,
+                           attrs->attr->psvi, 1);
+                    }
+                    attrs = attrs->next;
+                }
+                style = xsltNextImport(style);
+            }
+        }
+        curstr = endstr;
+    }
+}
+
+/**
+ * xsltFreeAttributeSetsHashes:
+ * @style: an XSLT stylesheet
+ *
+ * Free up the memory used by attribute sets
+ */
+void
+xsltFreeAttributeSetsHashes(xsltStylesheetPtr style) {
+    if (style->attributeSets != NULL)
+       xmlHashFree((xmlHashTablePtr) style->attributeSets,
+                   (xmlHashDeallocator) xsltFreeAttrElemList);
+    style->attributeSets = NULL;
+}
diff --git a/reactos/dll/3rdparty/libxslt/attributes.h b/reactos/dll/3rdparty/libxslt/attributes.h
new file mode 100644 (file)
index 0000000..d61ebb0
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Summary: interface for the XSLT attribute handling
+ * Description: this module handles the specificities of attribute
+ *              and attribute groups processing.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_ATTRIBUTES_H__
+#define __XML_XSLT_ATTRIBUTES_H__
+
+#include <libxml/tree.h>
+#include "xsltexports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+XSLTPUBFUN void XSLTCALL
+       xsltParseStylesheetAttributeSet (xsltStylesheetPtr style,
+                                        xmlNodePtr cur);
+XSLTPUBFUN void XSLTCALL    
+       xsltFreeAttributeSetsHashes     (xsltStylesheetPtr style);
+XSLTPUBFUN void XSLTCALL       
+       xsltApplyAttributeSet           (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        const xmlChar *attributes);
+XSLTPUBFUN void XSLTCALL       
+       xsltResolveStylesheetAttributeSet(xsltStylesheetPtr style);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_ATTRIBUTES_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/attrvt.c b/reactos/dll/3rdparty/libxslt/attrvt.c
new file mode 100644 (file)
index 0000000..b63b77b
--- /dev/null
@@ -0,0 +1,377 @@
+/*
+ * attrvt.c: Implementation of the XSL Transformation 1.0 engine
+ *           attribute value template handling part.
+ *
+ * References:
+ *   http://www.w3.org/TR/1999/REC-xslt-19991116
+ *
+ *   Michael Kay "XSLT Programmer's Reference" pp 637-643
+ *   Writing Multiple Output Files
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+#include "xslt.h"
+#include "xsltutils.h"
+#include "xsltInternals.h"
+#include "templates.h"
+
+#ifdef WITH_XSLT_DEBUG
+#define WITH_XSLT_DEBUG_AVT
+#endif
+
+#define MAX_AVT_SEG 10
+
+typedef struct _xsltAttrVT xsltAttrVT;
+typedef xsltAttrVT *xsltAttrVTPtr;
+struct _xsltAttrVT {
+    struct _xsltAttrVT *next; /* next xsltAttrVT */
+    int nb_seg;                /* Number of segments */
+    int max_seg;       /* max capacity before re-alloc needed */
+    int strstart;      /* is the start a string */
+    /*
+     * the namespaces in scope
+     */
+    xmlNsPtr *nsList;
+    int nsNr;
+    /*
+     * the content is an alternate of string and xmlXPathCompExprPtr
+     */
+    void *segments[MAX_AVT_SEG];
+};
+
+/**
+ * xsltNewAttrVT:
+ * @style:  a XSLT process context
+ *
+ * Build a new xsltAttrVT structure
+ *
+ * Returns the structure or NULL in case of error
+ */
+static xsltAttrVTPtr
+xsltNewAttrVT(xsltStylesheetPtr style) {
+    xsltAttrVTPtr cur;
+
+    cur = (xsltAttrVTPtr) xmlMalloc(sizeof(xsltAttrVT));
+    if (cur == NULL) {
+       xsltTransformError(NULL, style, NULL,
+               "xsltNewAttrVTPtr : malloc failed\n");
+       if (style != NULL) style->errors++;
+       return(NULL);
+    }
+    memset(cur, 0, sizeof(xsltAttrVT));
+
+    cur->nb_seg = 0;
+    cur->max_seg = MAX_AVT_SEG;
+    cur->strstart = 0;
+    cur->next = style->attVTs;
+    /*
+     * Note: this pointer may be changed by a re-alloc within xsltCompileAttr,
+     * so that code may change the stylesheet pointer also!
+     */
+    style->attVTs = (xsltAttrVTPtr) cur;
+
+    return(cur);
+}
+
+/**
+ * xsltFreeAttrVT:
+ * @avt: pointer to an xsltAttrVT structure
+ *
+ * Free up the memory associated to the attribute value template
+ */
+static void
+xsltFreeAttrVT(xsltAttrVTPtr avt) {
+    int i;
+
+    if (avt == NULL) return;
+
+    if (avt->strstart == 1) {
+       for (i = 0;i < avt->nb_seg; i += 2)
+           if (avt->segments[i] != NULL)
+               xmlFree((xmlChar *) avt->segments[i]);
+       for (i = 1;i < avt->nb_seg; i += 2)
+           xmlXPathFreeCompExpr((xmlXPathCompExprPtr) avt->segments[i]);
+    } else {
+       for (i = 0;i < avt->nb_seg; i += 2)
+           xmlXPathFreeCompExpr((xmlXPathCompExprPtr) avt->segments[i]);
+       for (i = 1;i < avt->nb_seg; i += 2)
+           if (avt->segments[i] != NULL)
+               xmlFree((xmlChar *) avt->segments[i]);
+    }
+    if (avt->nsList != NULL)
+        xmlFree(avt->nsList);
+    xmlFree(avt);
+}
+
+/**
+ * xsltFreeAVTList:
+ * @avt: pointer to an list of AVT structures
+ *
+ * Free up the memory associated to the attribute value templates
+ */
+void
+xsltFreeAVTList(void *avt) {
+    xsltAttrVTPtr cur = (xsltAttrVTPtr) avt, next;
+
+    while (cur != NULL) {
+        next = cur->next;
+       xsltFreeAttrVT(cur);
+       cur = next;
+    }
+}
+/**
+ * xsltSetAttrVTsegment:
+ * @ avt: pointer to an xsltAttrVT structure
+ * @ val: the value to be set to the next available segment
+ *
+ * Within xsltCompileAttr there are several places where a value
+ * needs to be added to the 'segments' array within the xsltAttrVT
+ * structure, and at each place the allocated size may have to be
+ * re-allocated.  This routine takes care of that situation.
+ *
+ * Returns the avt pointer, which may have been changed by a re-alloc
+ */
+static xsltAttrVTPtr
+xsltSetAttrVTsegment(xsltAttrVTPtr avt, void *val) {
+    if (avt->nb_seg >= avt->max_seg) {
+       avt = (xsltAttrVTPtr) xmlRealloc(avt, sizeof(xsltAttrVT) +
+                       avt->max_seg * sizeof(void *));
+       if (avt == NULL) {
+           return NULL;
+       }
+       memset(&avt->segments[avt->nb_seg], 0, MAX_AVT_SEG*sizeof(void *));
+       avt->max_seg += MAX_AVT_SEG;
+    }
+    avt->segments[avt->nb_seg++] = val;
+    return avt;
+}
+
+/**
+ * xsltCompileAttr:
+ * @style:  a XSLT process context
+ * @attr: the attribute coming from the stylesheet.
+ *
+ * Precompile an attribute in a stylesheet, basically it checks if it is
+ * an attrubute value template, and if yes establish some structures needed
+ * to process it at transformation time.
+ */
+void
+xsltCompileAttr(xsltStylesheetPtr style, xmlAttrPtr attr) {
+    const xmlChar *str;
+    const xmlChar *cur;
+    xmlChar *ret = NULL;
+    xmlChar *expr = NULL;
+    xsltAttrVTPtr avt;
+    int i = 0, lastavt = 0;
+
+    if ((style == NULL) || (attr == NULL) || (attr->children == NULL))
+        return;
+    if ((attr->children->type != XML_TEXT_NODE) || 
+        (attr->children->next != NULL)) {
+        xsltTransformError(NULL, style, attr->parent,
+           "Attribute '%s': The content is expected to be a single text "
+           "node when compiling an AVT.\n", attr->name);
+       style->errors++;
+       return;
+    }
+    str = attr->children->content;
+    if ((xmlStrchr(str, '{') == NULL) &&
+        (xmlStrchr(str, '}') == NULL)) return;
+
+#ifdef WITH_XSLT_DEBUG_AVT
+    xsltGenericDebug(xsltGenericDebugContext,
+                   "Found AVT %s: %s\n", attr->name, str);
+#endif
+    if (attr->psvi != NULL) {
+#ifdef WITH_XSLT_DEBUG_AVT
+       xsltGenericDebug(xsltGenericDebugContext,
+                       "AVT %s: already compiled\n", attr->name);
+#endif
+        return;
+    }
+    /*
+    * Create a new AVT object.
+    */
+    avt = xsltNewAttrVT(style);
+    if (avt == NULL)
+       return;
+    attr->psvi = avt;
+
+    avt->nsList = xmlGetNsList(attr->doc, attr->parent);
+    if (avt->nsList != NULL) {
+       while (avt->nsList[i] != NULL)
+           i++;
+    }
+    avt->nsNr = i;
+
+    cur = str;
+    while (*cur != 0) {
+       if (*cur == '{') {
+           if (*(cur+1) == '{') {      /* escaped '{' */
+               cur++;
+               ret = xmlStrncat(ret, str, cur - str);
+               cur++;
+               str = cur;
+               continue;
+           }
+           if (*(cur+1) == '}') {      /* skip empty AVT */
+               ret = xmlStrncat(ret, str, cur - str);
+               cur += 2;
+               str = cur;
+               continue;
+           }
+           if ((ret != NULL) || (cur - str > 0)) {
+               ret = xmlStrncat(ret, str, cur - str);
+               str = cur;
+               if (avt->nb_seg == 0)
+                   avt->strstart = 1;
+               if ((avt = xsltSetAttrVTsegment(avt, (void *) ret)) == NULL)
+                   goto error;
+               ret = NULL;
+               lastavt = 0;
+           }
+
+           cur++;
+           while ((*cur != 0) && (*cur != '}')) cur++;
+           if (*cur == 0) {
+               xsltTransformError(NULL, style, attr->parent,
+                    "Attribute '%s': The AVT has an unmatched '{'.\n",
+                    attr->name);
+               style->errors++;
+               goto error;
+           }
+           str++;
+           expr = xmlStrndup(str, cur - str);
+           if (expr == NULL) {
+               /*
+               * TODO: What needs to be done here?
+               */
+               XSLT_TODO
+               goto error;
+           } else {
+               xmlXPathCompExprPtr comp;
+
+               comp = xsltXPathCompile(style, expr);
+               if (comp == NULL) {
+                   xsltTransformError(NULL, style, attr->parent,
+                        "Attribute '%s': Failed to compile the expression "
+                        "'%s' in the AVT.\n", attr->name, expr);
+                   style->errors++;
+                   goto error;
+               }
+               if (avt->nb_seg == 0)
+                   avt->strstart = 0;
+               if (lastavt == 1) {
+                   if ((avt = xsltSetAttrVTsegment(avt, NULL)) == NULL)
+                       goto error;
+               }
+               if ((avt = xsltSetAttrVTsegment(avt, (void *) comp)) == NULL)
+                   goto error;
+               lastavt = 1;
+               xmlFree(expr);
+               expr = NULL;
+           }
+           cur++;
+           str = cur;
+       } else if (*cur == '}') {
+           cur++;
+           if (*cur == '}') {  /* escaped '}' */
+               ret = xmlStrncat(ret, str, cur - str);
+               cur++;
+               str = cur;
+               continue;
+           } else {
+               xsltTransformError(NULL, style, attr->parent,
+                    "Attribute '%s': The AVT has an unmatched '}'.\n",
+                    attr->name);
+               goto error;
+           }
+       } else
+           cur++;
+    }
+    if ((ret != NULL) || (cur - str > 0)) {
+       ret = xmlStrncat(ret, str, cur - str);
+       str = cur;
+       if (avt->nb_seg == 0)
+           avt->strstart = 1;
+       if ((avt = xsltSetAttrVTsegment(avt, (void *) ret)) == NULL)
+           goto error;
+       ret = NULL;
+    }
+
+error:
+    if (avt == NULL) {
+        xsltTransformError(NULL, style, attr->parent,
+               "xsltCompileAttr: malloc problem\n");
+    } else {
+        if (attr->psvi != avt) {  /* may have changed from realloc */
+            attr->psvi = avt;
+           /*
+            * This is a "hack", but I can't see any clean method of
+            * doing it.  If a re-alloc has taken place, then the pointer
+            * for this AVT may have changed.  style->attVTs was set by
+            * xsltNewAttrVT, so it needs to be re-set to the new value!
+            */
+           style->attVTs = avt;
+       }
+    }
+    if (ret != NULL)
+       xmlFree(ret);
+    if (expr != NULL)
+       xmlFree(expr);
+}
+
+
+/**
+ * xsltEvalAVT:
+ * @ctxt: the XSLT transformation context
+ * @avt: the prevompiled attribute value template info
+ * @node: the node hosting the attribute
+ *
+ * Process the given AVT, and return the new string value.
+ *
+ * Returns the computed string value or NULL, must be deallocated by the
+ *         caller.
+ */
+xmlChar *
+xsltEvalAVT(xsltTransformContextPtr ctxt, void *avt, xmlNodePtr node) {
+    xmlChar *ret = NULL, *tmp;
+    xmlXPathCompExprPtr comp;
+    xsltAttrVTPtr cur = (xsltAttrVTPtr) avt;
+    int i;
+    int str;
+
+    if ((ctxt == NULL) || (avt == NULL) || (node == NULL))
+        return(NULL);
+    str = cur->strstart;
+    for (i = 0;i < cur->nb_seg;i++) {
+        if (str) {
+           ret = xmlStrcat(ret, (const xmlChar *) cur->segments[i]);
+       } else {
+           comp = (xmlXPathCompExprPtr) cur->segments[i];
+           tmp = xsltEvalXPathStringNs(ctxt, comp, cur->nsNr, cur->nsList);
+           if (tmp != NULL) {
+               if (ret != NULL) {
+                   ret = xmlStrcat(ret, tmp);
+                   xmlFree(tmp);
+               } else {
+                   ret = tmp;
+               }
+           }
+       }
+       str = !str;
+    }
+    return(ret);
+}
diff --git a/reactos/dll/3rdparty/libxslt/config.h b/reactos/dll/3rdparty/libxslt/config.h
new file mode 100644 (file)
index 0000000..7837594
--- /dev/null
@@ -0,0 +1 @@
+#include <win32config.h>
diff --git a/reactos/dll/3rdparty/libxslt/documents.c b/reactos/dll/3rdparty/libxslt/documents.c
new file mode 100644 (file)
index 0000000..128cefe
--- /dev/null
@@ -0,0 +1,434 @@
+/*
+ * documents.c: Implementation of the documents handling
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/hash.h>
+#include <libxml/parser.h>
+#include <libxml/parserInternals.h>
+#include "xslt.h"
+#include "xsltInternals.h"
+#include "xsltutils.h"
+#include "documents.h"
+#include "transform.h"
+#include "imports.h"
+#include "keys.h"
+#include "security.h"
+
+#ifdef LIBXML_XINCLUDE_ENABLED
+#include <libxml/xinclude.h>
+#endif
+
+#define WITH_XSLT_DEBUG_DOCUMENTS
+
+#ifdef WITH_XSLT_DEBUG
+#define WITH_XSLT_DEBUG_DOCUMENTS
+#endif
+
+/************************************************************************
+ *                                                                     *
+ *             Hooks for the document loader                           *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltDocDefaultLoaderFunc:
+ * @URI: the URI of the document to load
+ * @dict: the dictionary to use when parsing that document
+ * @options: parsing options, a set of xmlParserOption
+ * @ctxt: the context, either a stylesheet or a transformation context
+ * @type: the xsltLoadType indicating the kind of loading required
+ *
+ * Default function to load document not provided by the compilation or
+ * transformation API themselve, for example when an xsl:import,
+ * xsl:include is found at compilation time or when a document()
+ * call is made at runtime.
+ *
+ * Returns the pointer to the document (which will be modified and
+ * freed by the engine later), or NULL in case of error.
+ */
+static xmlDocPtr
+xsltDocDefaultLoaderFunc(const xmlChar * URI, xmlDictPtr dict, int options,
+                         void *ctxt ATTRIBUTE_UNUSED,
+                        xsltLoadType type ATTRIBUTE_UNUSED)
+{
+    xmlParserCtxtPtr pctxt;
+    xmlParserInputPtr inputStream;
+    xmlDocPtr doc;
+
+    pctxt = xmlNewParserCtxt();
+    if (pctxt == NULL)
+        return(NULL);
+    if ((dict != NULL) && (pctxt->dict != NULL)) {
+        xmlDictFree(pctxt->dict);
+       pctxt->dict = NULL;
+    }
+    if (dict != NULL) {
+       pctxt->dict = dict;
+       xmlDictReference(pctxt->dict);
+#ifdef WITH_XSLT_DEBUG
+       xsltGenericDebug(xsltGenericDebugContext,
+                     "Reusing dictionary for document\n");
+#endif
+    }
+    xmlCtxtUseOptions(pctxt, options);
+    inputStream = xmlLoadExternalEntity((const char *) URI, NULL, pctxt);
+    if (inputStream == NULL) {
+        xmlFreeParserCtxt(pctxt);
+       return(NULL);
+    }
+    inputPush(pctxt, inputStream);
+    if (pctxt->directory == NULL)
+        pctxt->directory = xmlParserGetDirectory((const char *) URI);
+
+    xmlParseDocument(pctxt);
+
+    if (pctxt->wellFormed) {
+        doc = pctxt->myDoc;
+    }
+    else {
+        doc = NULL;
+        xmlFreeDoc(pctxt->myDoc);
+        pctxt->myDoc = NULL;
+    }
+    xmlFreeParserCtxt(pctxt);
+
+    return(doc);
+}
+
+
+xsltDocLoaderFunc xsltDocDefaultLoader = xsltDocDefaultLoaderFunc;
+
+/**
+ * xsltSetLoaderFunc:
+ * @f: the new function to handle document loading.
+ *
+ * Set the new function to load document, if NULL it resets it to the
+ * default function.
+ */
+void
+xsltSetLoaderFunc(xsltDocLoaderFunc f) {
+    if (f == NULL)
+        xsltDocDefaultLoader = xsltDocDefaultLoaderFunc;
+    else
+        xsltDocDefaultLoader = f;
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     Module interfaces                               *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltNewDocument:
+ * @ctxt: an XSLT transformation context (or NULL)
+ * @doc:  a parsed XML document
+ *
+ * Register a new document, apply key computations
+ *
+ * Returns a handler to the document
+ */
+xsltDocumentPtr        
+xsltNewDocument(xsltTransformContextPtr ctxt, xmlDocPtr doc) {
+    xsltDocumentPtr cur;
+
+    cur = (xsltDocumentPtr) xmlMalloc(sizeof(xsltDocument));
+    if (cur == NULL) {
+       xsltTransformError(ctxt, NULL, (xmlNodePtr) doc,
+               "xsltNewDocument : malloc failed\n");
+       return(NULL);
+    }
+    memset(cur, 0, sizeof(xsltDocument));
+    cur->doc = doc;
+    if (ctxt != NULL) {
+        if (! XSLT_IS_RES_TREE_FRAG(doc)) {
+           cur->next = ctxt->docList;
+           ctxt->docList = cur;
+       }
+       /*
+       * A key with a specific name for a specific document
+       * will only be computed if there's a call to the key()
+       * function using that specific name for that specific
+       * document. I.e. computation of keys will be done in
+       * xsltGetKey() (keys.c) on an on-demand basis.
+       *
+       * xsltInitCtxtKeys(ctxt, cur); not called here anymore
+       */
+    }
+    return(cur);
+}
+
+/**
+ * xsltNewStyleDocument:
+ * @style: an XSLT style sheet
+ * @doc:  a parsed XML document
+ *
+ * Register a new document, apply key computations
+ *
+ * Returns a handler to the document
+ */
+xsltDocumentPtr        
+xsltNewStyleDocument(xsltStylesheetPtr style, xmlDocPtr doc) {
+    xsltDocumentPtr cur;
+
+    cur = (xsltDocumentPtr) xmlMalloc(sizeof(xsltDocument));
+    if (cur == NULL) {
+       xsltTransformError(NULL, style, (xmlNodePtr) doc,
+               "xsltNewStyleDocument : malloc failed\n");
+       return(NULL);
+    }
+    memset(cur, 0, sizeof(xsltDocument));
+    cur->doc = doc;
+    if (style != NULL) {
+       cur->next = style->docList;
+       style->docList = cur;
+    }
+    return(cur);
+}
+
+/**
+ * xsltFreeStyleDocuments:
+ * @style: an XSLT stylesheet (representing a stylesheet-level)
+ *
+ * Frees the node-trees (and xsltDocument structures) of all
+ * stylesheet-modules of the stylesheet-level represented by
+ * the given @style. 
+ */
+void   
+xsltFreeStyleDocuments(xsltStylesheetPtr style) {
+    xsltDocumentPtr doc, cur;
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+    xsltNsMapPtr nsMap;
+#endif
+    
+    if (style == NULL)
+       return;
+
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+    if (XSLT_HAS_INTERNAL_NSMAP(style))
+       nsMap = XSLT_GET_INTERNAL_NSMAP(style);
+    else
+       nsMap = NULL;    
+#endif   
+
+    cur = style->docList;
+    while (cur != NULL) {
+       doc = cur;
+       cur = cur->next;
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+       /*
+       * Restore all changed namespace URIs of ns-decls.
+       */
+       if (nsMap)
+           xsltRestoreDocumentNamespaces(nsMap, doc->doc);
+#endif
+       xsltFreeDocumentKeys(doc);
+       if (!doc->main)
+           xmlFreeDoc(doc->doc);
+        xmlFree(doc);
+    }
+}
+
+/**
+ * xsltFreeDocuments:
+ * @ctxt: an XSLT transformation context
+ *
+ * Free up all the space used by the loaded documents
+ */
+void   
+xsltFreeDocuments(xsltTransformContextPtr ctxt) {
+    xsltDocumentPtr doc, cur;
+
+    cur = ctxt->docList;
+    while (cur != NULL) {
+       doc = cur;
+       cur = cur->next;
+       xsltFreeDocumentKeys(doc);
+       if (!doc->main)
+           xmlFreeDoc(doc->doc);
+        xmlFree(doc);
+    }
+    cur = ctxt->styleList;
+    while (cur != NULL) {
+       doc = cur;
+       cur = cur->next;
+       xsltFreeDocumentKeys(doc);
+       if (!doc->main)
+           xmlFreeDoc(doc->doc);
+        xmlFree(doc);
+    }
+}
+
+/**
+ * xsltLoadDocument:
+ * @ctxt: an XSLT transformation context
+ * @URI:  the computed URI of the document
+ *
+ * Try to load a document (not a stylesheet)
+ * within the XSLT transformation context
+ *
+ * Returns the new xsltDocumentPtr or NULL in case of error
+ */
+xsltDocumentPtr        
+xsltLoadDocument(xsltTransformContextPtr ctxt, const xmlChar *URI) {
+    xsltDocumentPtr ret;
+    xmlDocPtr doc;
+
+    if ((ctxt == NULL) || (URI == NULL))
+       return(NULL);
+
+    /*
+     * Security framework check
+     */
+    if (ctxt->sec != NULL) {
+       int res;
+       
+       res = xsltCheckRead(ctxt->sec, ctxt, URI);
+       if (res == 0) {
+           xsltTransformError(ctxt, NULL, NULL,
+                "xsltLoadDocument: read rights for %s denied\n",
+                            URI);
+           return(NULL);
+       }
+    }
+
+    /*
+     * Walk the context list to find the document if preparsed
+     */
+    ret = ctxt->docList;
+    while (ret != NULL) {
+       if ((ret->doc != NULL) && (ret->doc->URL != NULL) &&
+           (xmlStrEqual(ret->doc->URL, URI)))
+           return(ret);
+       ret = ret->next;
+    }
+
+    doc = xsltDocDefaultLoader(URI, ctxt->dict, ctxt->parserOptions,
+                               (void *) ctxt, XSLT_LOAD_DOCUMENT);
+
+    if (doc == NULL)
+       return(NULL);
+
+    if (ctxt->xinclude != 0) {
+#ifdef LIBXML_XINCLUDE_ENABLED
+#if LIBXML_VERSION >= 20603
+       xmlXIncludeProcessFlags(doc, ctxt->parserOptions);
+#else
+       xmlXIncludeProcess(doc);
+#endif
+#else
+       xsltTransformError(ctxt, NULL, NULL,
+           "xsltLoadDocument(%s) : XInclude processing not compiled in\n",
+                        URI);
+#endif
+    }
+    /*
+     * Apply white-space stripping if asked for
+     */
+    if (xsltNeedElemSpaceHandling(ctxt))
+       xsltApplyStripSpaces(ctxt, xmlDocGetRootElement(doc));
+    if (ctxt->debugStatus == XSLT_DEBUG_NONE)
+       xmlXPathOrderDocElems(doc);
+
+    ret = xsltNewDocument(ctxt, doc);
+    return(ret);
+}
+
+/**
+ * xsltLoadStyleDocument:
+ * @style: an XSLT style sheet
+ * @URI:  the computed URI of the document
+ *
+ * Try to load a stylesheet document within the XSLT transformation context
+ *
+ * Returns the new xsltDocumentPtr or NULL in case of error
+ */
+xsltDocumentPtr        
+xsltLoadStyleDocument(xsltStylesheetPtr style, const xmlChar *URI) {
+    xsltDocumentPtr ret;
+    xmlDocPtr doc;
+    xsltSecurityPrefsPtr sec;
+
+    if ((style == NULL) || (URI == NULL))
+       return(NULL);
+
+    /*
+     * Security framework check
+     */
+    sec = xsltGetDefaultSecurityPrefs();
+    if (sec != NULL) {
+       int res;
+
+       res = xsltCheckRead(sec, NULL, URI);
+       if (res == 0) {
+           xsltTransformError(NULL, NULL, NULL,
+                "xsltLoadStyleDocument: read rights for %s denied\n",
+                            URI);
+           return(NULL);
+       }
+    }
+
+    /*
+     * Walk the context list to find the document if preparsed
+     */
+    ret = style->docList;
+    while (ret != NULL) {
+       if ((ret->doc != NULL) && (ret->doc->URL != NULL) &&
+           (xmlStrEqual(ret->doc->URL, URI)))
+           return(ret);
+       ret = ret->next;
+    }
+
+    doc = xsltDocDefaultLoader(URI, style->dict, XSLT_PARSE_OPTIONS,
+                               (void *) style, XSLT_LOAD_STYLESHEET);
+    if (doc == NULL)
+       return(NULL);
+
+    ret = xsltNewStyleDocument(style, doc);
+    return(ret);
+}
+
+/**
+ * xsltFindDocument:
+ * @ctxt: an XSLT transformation context
+ * @doc: a parsed XML document
+ *
+ * Try to find a document within the XSLT transformation context.
+ * This will not find document infos for temporary
+ * Result Tree Fragments.
+ *
+ * Returns the desired xsltDocumentPtr or NULL in case of error
+ */
+xsltDocumentPtr
+xsltFindDocument (xsltTransformContextPtr ctxt, xmlDocPtr doc) {
+    xsltDocumentPtr ret;
+
+    if ((ctxt == NULL) || (doc == NULL))
+       return(NULL);
+
+    /*
+     * Walk the context list to find the document
+     */
+    ret = ctxt->docList;
+    while (ret != NULL) {
+       if (ret->doc == doc)
+           return(ret);
+       ret = ret->next;
+    }
+    if (doc == ctxt->style->doc)
+       return(ctxt->document);
+    return(NULL);
+}
+
diff --git a/reactos/dll/3rdparty/libxslt/documents.h b/reactos/dll/3rdparty/libxslt/documents.h
new file mode 100644 (file)
index 0000000..2eb1f2a
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Summary: interface for the document handling
+ * Description: implements document loading and cache (multiple
+ *              document() reference for the same resources must
+ *              be equal.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_DOCUMENTS_H__
+#define __XML_XSLT_DOCUMENTS_H__
+
+#include <libxml/tree.h>
+#include "xsltexports.h"
+#include "xsltInternals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+XSLTPUBFUN xsltDocumentPtr XSLTCALL    
+               xsltNewDocument         (xsltTransformContextPtr ctxt,
+                                        xmlDocPtr doc);
+XSLTPUBFUN xsltDocumentPtr XSLTCALL    
+               xsltLoadDocument        (xsltTransformContextPtr ctxt,
+                                        const xmlChar *URI);
+XSLTPUBFUN xsltDocumentPtr XSLTCALL    
+               xsltFindDocument        (xsltTransformContextPtr ctxt,
+                                        xmlDocPtr doc);
+XSLTPUBFUN void XSLTCALL               
+               xsltFreeDocuments       (xsltTransformContextPtr ctxt);
+
+XSLTPUBFUN xsltDocumentPtr XSLTCALL    
+               xsltLoadStyleDocument   (xsltStylesheetPtr style,
+                                        const xmlChar *URI);
+XSLTPUBFUN xsltDocumentPtr XSLTCALL    
+               xsltNewStyleDocument    (xsltStylesheetPtr style,
+                                        xmlDocPtr doc);
+XSLTPUBFUN void XSLTCALL               
+               xsltFreeStyleDocuments  (xsltStylesheetPtr style);
+
+/*
+ * Hooks for document loading
+ */
+
+/**
+ * xsltLoadType:
+ *
+ * Enum defining the kind of loader requirement.
+ */
+typedef enum {
+    XSLT_LOAD_START = 0,       /* loading for a top stylesheet */
+    XSLT_LOAD_STYLESHEET = 1,  /* loading for a stylesheet include/import */
+    XSLT_LOAD_DOCUMENT = 2     /* loading document at transformation time */
+} xsltLoadType;
+
+/**
+ * xsltDocLoaderFunc:
+ * @URI: the URI of the document to load
+ * @dict: the dictionary to use when parsing that document
+ * @options: parsing options, a set of xmlParserOption
+ * @ctxt: the context, either a stylesheet or a transformation context
+ * @type: the xsltLoadType indicating the kind of loading required
+ *
+ * An xsltDocLoaderFunc is a signature for a function which can be
+ * registered to load document not provided by the compilation or
+ * transformation API themselve, for example when an xsl:import,
+ * xsl:include is found at compilation time or when a document()
+ * call is made at runtime.
+ *
+ * Returns the pointer to the document (which will be modified and
+ * freed by the engine later), or NULL in case of error.
+ */
+typedef xmlDocPtr (*xsltDocLoaderFunc)         (const xmlChar *URI,
+                                                xmlDictPtr dict,
+                                                int options,
+                                                void *ctxt,
+                                                xsltLoadType type);
+
+XSLTPUBFUN void XSLTCALL
+               xsltSetLoaderFunc               (xsltDocLoaderFunc f);
+
+/* the loader may be needed by extension libraries so it is exported */
+XSLTPUBVAR xsltDocLoaderFunc xsltDocDefaultLoader;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_DOCUMENTS_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/extensions.c b/reactos/dll/3rdparty/libxslt/extensions.c
new file mode 100644 (file)
index 0000000..87eefb4
--- /dev/null
@@ -0,0 +1,2196 @@
+/*
+ * extensions.c: Implemetation of the extensions support
+ *
+ * Reference:
+ *   http://www.w3.org/TR/1999/REC-xslt-19991116
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+#include <limits.h>
+
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/hash.h>
+#include <libxml/xmlerror.h>
+#include <libxml/parserInternals.h>
+#include <libxml/xpathInternals.h>
+#ifdef WITH_MODULES
+#include <libxml/xmlmodule.h>
+#endif
+#include <libxml/list.h>
+#include <libxml/xmlIO.h>
+#include "xslt.h"
+#include "xsltInternals.h"
+#include "xsltutils.h"
+#include "imports.h"
+#include "extensions.h"
+
+#ifdef _WIN32
+#include <stdlib.h>             /* for _MAX_PATH */
+#ifndef PATH_MAX
+#define PATH_MAX _MAX_PATH
+#endif
+#endif
+
+#ifdef WITH_XSLT_DEBUG
+#define WITH_XSLT_DEBUG_EXTENSIONS
+#endif
+
+/************************************************************************
+ *                                                                     *
+ *                     Private Types and Globals                       *
+ *                                                                     *
+ ************************************************************************/
+
+typedef struct _xsltExtDef xsltExtDef;
+typedef xsltExtDef *xsltExtDefPtr;
+struct _xsltExtDef {
+    struct _xsltExtDef *next;
+    xmlChar *prefix;
+    xmlChar *URI;
+    void *data;
+};
+
+typedef struct _xsltExtModule xsltExtModule;
+typedef xsltExtModule *xsltExtModulePtr;
+struct _xsltExtModule {
+    xsltExtInitFunction initFunc;
+    xsltExtShutdownFunction shutdownFunc;
+    xsltStyleExtInitFunction styleInitFunc;
+    xsltStyleExtShutdownFunction styleShutdownFunc;
+};
+
+typedef struct _xsltExtData xsltExtData;
+typedef xsltExtData *xsltExtDataPtr;
+struct _xsltExtData {
+    xsltExtModulePtr extModule;
+    void *extData;
+};
+
+typedef struct _xsltExtElement xsltExtElement;
+typedef xsltExtElement *xsltExtElementPtr;
+struct _xsltExtElement {
+    xsltPreComputeFunction precomp;
+    xsltTransformFunction transform;
+};
+
+static xmlHashTablePtr xsltExtensionsHash = NULL;
+static xmlHashTablePtr xsltFunctionsHash = NULL;
+static xmlHashTablePtr xsltElementsHash = NULL;
+static xmlHashTablePtr xsltTopLevelsHash = NULL;
+static xmlHashTablePtr xsltModuleHash = NULL;
+
+/************************************************************************
+ *                                                                     *
+ *                     Type functions                                  *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltNewExtDef:
+ * @prefix:  the extension prefix
+ * @URI:  the namespace URI
+ *
+ * Create a new XSLT ExtDef
+ *
+ * Returns the newly allocated xsltExtDefPtr or NULL in case of error
+ */
+static xsltExtDefPtr
+xsltNewExtDef(const xmlChar * prefix, const xmlChar * URI)
+{
+    xsltExtDefPtr cur;
+
+    cur = (xsltExtDefPtr) xmlMalloc(sizeof(xsltExtDef));
+    if (cur == NULL) {
+        xsltTransformError(NULL, NULL, NULL,
+                           "xsltNewExtDef : malloc failed\n");
+        return (NULL);
+    }
+    memset(cur, 0, sizeof(xsltExtDef));
+    if (prefix != NULL)
+        cur->prefix = xmlStrdup(prefix);
+    if (URI != NULL)
+        cur->URI = xmlStrdup(URI);
+    return (cur);
+}
+
+/**
+ * xsltFreeExtDef:
+ * @extensiond:  an XSLT extension definition
+ *
+ * Free up the memory allocated by @extensiond
+ */
+static void
+xsltFreeExtDef(xsltExtDefPtr extensiond)
+{
+    if (extensiond == NULL)
+        return;
+    if (extensiond->prefix != NULL)
+        xmlFree(extensiond->prefix);
+    if (extensiond->URI != NULL)
+        xmlFree(extensiond->URI);
+    xmlFree(extensiond);
+}
+
+/**
+ * xsltFreeExtDefList:
+ * @extensiond:  an XSLT extension definition list
+ *
+ * Free up the memory allocated by all the elements of @extensiond
+ */
+static void
+xsltFreeExtDefList(xsltExtDefPtr extensiond)
+{
+    xsltExtDefPtr cur;
+
+    while (extensiond != NULL) {
+        cur = extensiond;
+        extensiond = extensiond->next;
+        xsltFreeExtDef(cur);
+    }
+}
+
+/**
+ * xsltNewExtModule:
+ * @initFunc:  the module initialization function
+ * @shutdownFunc:  the module shutdown function
+ * @styleInitFunc:  the stylesheet module data allocator function
+ * @styleShutdownFunc:  the stylesheet module data free function
+ *
+ * Create a new XSLT extension module
+ *
+ * Returns the newly allocated xsltExtModulePtr or NULL in case of error
+ */
+static xsltExtModulePtr
+xsltNewExtModule(xsltExtInitFunction initFunc,
+                 xsltExtShutdownFunction shutdownFunc,
+                 xsltStyleExtInitFunction styleInitFunc,
+                 xsltStyleExtShutdownFunction styleShutdownFunc)
+{
+    xsltExtModulePtr cur;
+
+    cur = (xsltExtModulePtr) xmlMalloc(sizeof(xsltExtModule));
+    if (cur == NULL) {
+        xsltTransformError(NULL, NULL, NULL,
+                           "xsltNewExtModule : malloc failed\n");
+        return (NULL);
+    }
+    cur->initFunc = initFunc;
+    cur->shutdownFunc = shutdownFunc;
+    cur->styleInitFunc = styleInitFunc;
+    cur->styleShutdownFunc = styleShutdownFunc;
+    return (cur);
+}
+
+/**
+ * xsltFreeExtModule:
+ * @ext:  an XSLT extension module
+ *
+ * Free up the memory allocated by @ext
+ */
+static void
+xsltFreeExtModule(xsltExtModulePtr ext)
+{
+    if (ext == NULL)
+        return;
+    xmlFree(ext);
+}
+
+/**
+ * xsltNewExtData:
+ * @extModule:  the module
+ * @extData:  the associated data
+ *
+ * Create a new XSLT extension module data wrapper
+ *
+ * Returns the newly allocated xsltExtDataPtr or NULL in case of error
+ */
+static xsltExtDataPtr
+xsltNewExtData(xsltExtModulePtr extModule, void *extData)
+{
+    xsltExtDataPtr cur;
+
+    if (extModule == NULL)
+        return (NULL);
+    cur = (xsltExtDataPtr) xmlMalloc(sizeof(xsltExtData));
+    if (cur == NULL) {
+        xsltTransformError(NULL, NULL, NULL,
+                           "xsltNewExtData : malloc failed\n");
+        return (NULL);
+    }
+    cur->extModule = extModule;
+    cur->extData = extData;
+    return (cur);
+}
+
+/**
+ * xsltFreeExtData:
+ * @ext:  an XSLT extension module data wrapper
+ *
+ * Free up the memory allocated by @ext
+ */
+static void
+xsltFreeExtData(xsltExtDataPtr ext)
+{
+    if (ext == NULL)
+        return;
+    xmlFree(ext);
+}
+
+/**
+ * xsltNewExtElement:
+ * @precomp:  the pre-computation function
+ * @transform:  the transformation function
+ *
+ * Create a new XSLT extension element
+ *
+ * Returns the newly allocated xsltExtElementPtr or NULL in case of
+ * error
+ */
+static xsltExtElementPtr
+xsltNewExtElement(xsltPreComputeFunction precomp,
+                  xsltTransformFunction transform)
+{
+    xsltExtElementPtr cur;
+
+    if (transform == NULL)
+        return (NULL);
+
+    cur = (xsltExtElementPtr) xmlMalloc(sizeof(xsltExtElement));
+    if (cur == NULL) {
+        xsltTransformError(NULL, NULL, NULL,
+                           "xsltNewExtElement : malloc failed\n");
+        return (NULL);
+    }
+    cur->precomp = precomp;
+    cur->transform = transform;
+    return (cur);
+}
+
+/**
+ * xsltFreeExtElement:
+ * @ext: an XSLT extension element
+ *
+ * Frees up the memory allocated by @ext
+ */
+static void
+xsltFreeExtElement(xsltExtElementPtr ext)
+{
+    if (ext == NULL)
+        return;
+    xmlFree(ext);
+}
+
+
+#ifdef WITH_MODULES
+typedef void (*exsltRegisterFunction) (void);
+
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
+
+/**
+ * xsltExtModuleRegisterDynamic:
+ * @URI:  the function or element namespace URI
+ *
+ * Dynamically loads an extension plugin when available.
+ * 
+ * The plugin name is derived from the URI by removing the 
+ * initial protocol designation, e.g. "http://", then converting
+ * the characters ".", "-", "/", and "\" into "_", the removing
+ * any trailing "/", then concatenating LIBXML_MODULE_EXTENSION.
+ * 
+ * Plugins are loaded from the directory specified by the 
+ * environment variable LIBXSLT_PLUGINS_PATH, or if NULL, 
+ * by LIBXSLT_DEFAULT_PLUGINS_PATH() which is determined at
+ * compile time.
+ *
+ * Returns 0 if successful, -1 in case of error. 
+ */
+
+static int
+xsltExtModuleRegisterDynamic(const xmlChar * URI)
+{
+
+    xmlModulePtr m;
+    exsltRegisterFunction regfunc;
+    xmlChar *ext_name;
+    char module_filename[PATH_MAX];
+    const xmlChar *ext_directory = NULL;
+    const xmlChar *protocol = NULL;
+    xmlChar *i, *regfunc_name;
+    void *vregfunc;
+    int rc;
+
+    /* check for bad inputs */
+    if (URI == NULL)
+        return (-1);
+
+    if (NULL == xsltModuleHash) {
+        xsltModuleHash = xmlHashCreate(5);
+        if (xsltModuleHash == NULL)
+            return (-1);
+    }
+
+    /* have we attempted to register this module already? */
+    if (xmlHashLookup(xsltModuleHash, URI) != NULL) {
+        return (-1);
+    }
+
+    /* transform extension namespace into a module name */
+    protocol = xmlStrstr(URI, BAD_CAST "://");
+    if (protocol == NULL) {
+        ext_name = xmlStrdup(URI);
+    } else {
+        ext_name = xmlStrdup(protocol + 3);
+    }
+    if (ext_name == NULL) {
+        return (-1);
+    }
+
+    i = ext_name;
+    while ('\0' != *i) {
+        if (('/' == *i) || ('\\' == *i) || ('.' == *i) || ('-' == *i))
+            *i = '_';
+        i++;
+    }
+
+    if (*(i - 1) == '_')
+        *i = '\0';
+
+    /* determine module directory */
+    ext_directory = (xmlChar *) getenv("LIBXSLT_PLUGINS_PATH");
+
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+    xsltGenericDebug(xsltGenericDebugContext,
+                     "LIBXSLT_PLUGINS_PATH is %s\n", ext_directory);
+#endif
+
+    if (NULL == ext_directory)
+        ext_directory = BAD_CAST LIBXSLT_DEFAULT_PLUGINS_PATH();
+    if (NULL == ext_directory)
+        return (-1);
+
+    /* build the module filename, and confirm the module exists */
+    xmlStrPrintf((xmlChar *) module_filename, sizeof(module_filename),
+                 BAD_CAST "%s/%s%s",
+                 ext_directory, ext_name, LIBXML_MODULE_EXTENSION);
+
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+    xsltGenericDebug(xsltGenericDebugContext,
+                     "Attempting to load plugin: %s for URI: %s\n", 
+                     module_filename, URI);
+#endif
+
+    if (1 != xmlCheckFilename(module_filename)) {
+
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+       xsltGenericDebug(xsltGenericDebugContext,
+                     "xmlCheckFilename failed for plugin: %s\n", module_filename);
+#endif
+
+        xmlFree(ext_name);
+        return (-1);
+    }
+
+    /* attempt to open the module */
+    m = xmlModuleOpen(module_filename, 0);
+    if (NULL == m) {
+
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+       xsltGenericDebug(xsltGenericDebugContext,
+                     "xmlModuleOpen failed for plugin: %s\n", module_filename);
+#endif
+
+        xmlFree(ext_name);
+        return (-1);
+    }
+
+    /* construct initialization func name */
+    regfunc_name = xmlStrdup(ext_name);
+    regfunc_name = xmlStrcat(regfunc_name, BAD_CAST "_init");
+
+    vregfunc = NULL;
+    rc = xmlModuleSymbol(m, (const char *) regfunc_name, &vregfunc);
+    regfunc = vregfunc;
+    if (0 == rc) {
+        /*
+        * Call the module's init function.  Note that this function
+        * calls xsltRegisterExtModuleFull which will add the module
+        * to xsltExtensionsHash (together with it's entry points).
+        */
+        (*regfunc) ();
+
+        /* register this module in our hash */
+        xmlHashAddEntry(xsltModuleHash, URI, (void *) m);
+    } else {
+
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+       xsltGenericDebug(xsltGenericDebugContext,
+                     "xmlModuleSymbol failed for plugin: %s, regfunc: %s\n", 
+                     module_filename, regfunc_name);
+#endif
+
+        /* if regfunc not found unload the module immediately */
+        xmlModuleClose(m);
+    }
+
+    xmlFree(ext_name);
+    xmlFree(regfunc_name);
+    return (NULL == regfunc) ? -1 : 0;
+}
+#else
+static int
+xsltExtModuleRegisterDynamic(const xmlChar * ATTRIBUTE_UNUSED URI)
+{
+  return -1;
+}
+#endif
+
+/************************************************************************
+ *                                                                     *
+ *             The stylesheet extension prefixes handling              *
+ *                                                                     *
+ ************************************************************************/
+
+
+/**
+ * xsltFreeExts:
+ * @style: an XSLT stylesheet
+ *
+ * Free up the memory used by XSLT extensions in a stylesheet
+ */
+void
+xsltFreeExts(xsltStylesheetPtr style)
+{
+    if (style->nsDefs != NULL)
+        xsltFreeExtDefList((xsltExtDefPtr) style->nsDefs);
+}
+
+/**
+ * xsltRegisterExtPrefix:
+ * @style: an XSLT stylesheet
+ * @prefix: the prefix used (optional)
+ * @URI: the URI associated to the extension
+ * 
+ * Registers an extension namespace
+ * This is called from xslt.c during compile-time.
+ * The given prefix is not needed.
+ * Called by:
+ *   xsltParseExtElemPrefixes() (new function)
+ *   xsltRegisterExtPrefix() (old function)
+ *
+ * Returns 0 in case of success, 1 if the @URI was already
+ *         registered as an extension namespace and
+ *         -1 in case of failure
+ */
+int
+xsltRegisterExtPrefix(xsltStylesheetPtr style,
+                      const xmlChar * prefix, const xmlChar * URI)
+{
+    xsltExtDefPtr def, ret;
+
+    if ((style == NULL) || (URI == NULL))
+        return (-1);
+
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+    xsltGenericDebug(xsltGenericDebugContext,
+       "Registering extension namespace '%s'.\n", URI);
+#endif
+    def = (xsltExtDefPtr) style->nsDefs;
+#ifdef XSLT_REFACTORED
+    /*
+    * The extension is associated with a namespace name.
+    */
+    while (def != NULL) {
+        if (xmlStrEqual(URI, def->URI))
+            return (1);
+        def = def->next;
+    }
+#else
+    while (def != NULL) {
+        if (xmlStrEqual(prefix, def->prefix))
+            return (-1);
+        def = def->next;
+    }
+#endif
+    ret = xsltNewExtDef(prefix, URI);
+    if (ret == NULL)
+        return (-1);
+    ret->next = (xsltExtDefPtr) style->nsDefs;
+    style->nsDefs = ret;
+
+    /*
+     * check whether there is an extension module with a stylesheet
+     * initialization function.
+     */
+#ifdef XSLT_REFACTORED
+    /*
+    * Don't initialize modules based on specified namespaces via
+    * the attribute "[xsl:]extension-element-prefixes".
+    */
+#else
+    if (xsltExtensionsHash != NULL) {
+        xsltExtModulePtr module;
+
+        module = xmlHashLookup(xsltExtensionsHash, URI);
+        if (NULL == module) {
+            if (!xsltExtModuleRegisterDynamic(URI)) {
+                module = xmlHashLookup(xsltExtensionsHash, URI);
+            }
+        }
+        if (module != NULL) {
+            xsltStyleGetExtData(style, URI);
+        }
+    }
+#endif
+    return (0);
+}
+
+/************************************************************************
+ *                                                                     *
+ *             The extensions modules interfaces                       *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltRegisterExtFunction:
+ * @ctxt: an XSLT transformation context
+ * @name: the name of the element
+ * @URI: the URI associated to the element
+ * @function: the actual implementation which should be called 
+ *
+ * Registers an extension function
+ *
+ * Returns 0 in case of success, -1 in case of failure
+ */
+int
+xsltRegisterExtFunction(xsltTransformContextPtr ctxt, const xmlChar * name,
+                        const xmlChar * URI, xmlXPathFunction function)
+{
+    if ((ctxt == NULL) || (name == NULL) ||
+        (URI == NULL) || (function == NULL))
+        return (-1);
+    if (ctxt->xpathCtxt != NULL) {
+        xmlXPathRegisterFuncNS(ctxt->xpathCtxt, name, URI, function);
+    }
+    if (ctxt->extFunctions == NULL)
+        ctxt->extFunctions = xmlHashCreate(10);
+    if (ctxt->extFunctions == NULL)
+        return (-1);
+    return (xmlHashAddEntry2
+            (ctxt->extFunctions, name, URI, XML_CAST_FPTR(function)));
+}
+
+/**
+ * xsltRegisterExtElement:
+ * @ctxt: an XSLT transformation context
+ * @name: the name of the element
+ * @URI: the URI associated to the element
+ * @function: the actual implementation which should be called 
+ *
+ * Registers an extension element
+ *
+ * Returns 0 in case of success, -1 in case of failure
+ */
+int
+xsltRegisterExtElement(xsltTransformContextPtr ctxt, const xmlChar * name,
+                       const xmlChar * URI, xsltTransformFunction function)
+{
+    if ((ctxt == NULL) || (name == NULL) ||
+        (URI == NULL) || (function == NULL))
+        return (-1);
+    if (ctxt->extElements == NULL)
+        ctxt->extElements = xmlHashCreate(10);
+    if (ctxt->extElements == NULL)
+        return (-1);
+    return (xmlHashAddEntry2
+            (ctxt->extElements, name, URI, XML_CAST_FPTR(function)));
+}
+
+/**
+ * xsltFreeCtxtExts:
+ * @ctxt: an XSLT transformation context
+ *
+ * Free the XSLT extension data
+ */
+void
+xsltFreeCtxtExts(xsltTransformContextPtr ctxt)
+{
+    if (ctxt->extElements != NULL)
+        xmlHashFree(ctxt->extElements, NULL);
+    if (ctxt->extFunctions != NULL)
+        xmlHashFree(ctxt->extFunctions, NULL);
+}
+
+/**
+ * xsltStyleGetStylesheetExtData:
+ * @style: an XSLT stylesheet
+ * @URI:  the URI associated to the exension module
+ *
+ * Fires the compile-time initialization callback
+ * of an extension module and returns a container
+ * holding the user-data (retrieved via the callback).
+ *
+ * Returns the create module-data container
+ *         or NULL if such a module was not registered.
+ */
+static xsltExtDataPtr
+xsltStyleInitializeStylesheetModule(xsltStylesheetPtr style,
+                                    const xmlChar * URI)
+{
+    xsltExtDataPtr dataContainer;
+    void *userData = NULL;
+    xsltExtModulePtr module;
+    
+    if ((style == NULL) || (URI == NULL))      
+       return(NULL);
+
+    if (xsltExtensionsHash == NULL) {
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+       xsltGenericDebug(xsltGenericDebugContext,
+           "Not registered extension module: %s\n", URI);
+#endif
+       return(NULL);
+    }
+
+    module = xmlHashLookup(xsltExtensionsHash, URI);
+    if (module == NULL) {
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+       xsltGenericDebug(xsltGenericDebugContext,
+           "Not registered extension module: %s\n", URI);
+#endif
+       return (NULL);
+    }
+    /*
+    * The specified module was registered so initialize it.
+    */
+    if (style->extInfos == NULL) {
+       style->extInfos = xmlHashCreate(10);
+       if (style->extInfos == NULL)
+           return (NULL);
+    }
+    /*
+    * Fire the initialization callback if available.
+    */
+    if (module->styleInitFunc == NULL) {
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+       xsltGenericDebug(xsltGenericDebugContext,
+           "Initializing module with *no* callback: %s\n", URI);
+#endif
+    } else {
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+       xsltGenericDebug(xsltGenericDebugContext,
+           "Initializing module with callback: %s\n", URI);
+#endif
+       /*
+       * Fire the initialization callback.
+       */
+       userData = module->styleInitFunc(style, URI);
+    }    
+    /*
+    * Store the user-data in the context of the given stylesheet.
+    */
+    dataContainer = xsltNewExtData(module, userData);
+    if (dataContainer == NULL)
+       return (NULL);
+
+    if (xmlHashAddEntry(style->extInfos, URI,
+       (void *) dataContainer) < 0)
+    {
+       xsltTransformError(NULL, style, NULL,       
+           "Failed to register module '%s'.\n", URI);
+       style->errors++;
+       if (module->styleShutdownFunc)
+           module->styleShutdownFunc(style, URI, userData);
+       xsltFreeExtData(dataContainer);
+       return (NULL);
+    }
+
+    return(dataContainer);
+}
+
+/**
+ * xsltStyleGetExtData:
+ * @style: an XSLT stylesheet
+ * @URI:  the URI associated to the exension module
+ *
+ * Retrieve the data associated to the extension module
+ * in this given stylesheet.
+ * Called by:
+ *   xsltRegisterExtPrefix(),
+ *   ( xsltExtElementPreCompTest(), xsltExtInitTest )
+ *
+ * Returns the pointer or NULL if not present
+ */
+void *
+xsltStyleGetExtData(xsltStylesheetPtr style, const xmlChar * URI)
+{
+    xsltExtDataPtr dataContainer = NULL;
+    xsltStylesheetPtr tmpStyle;
+
+    if ((style == NULL) || (URI == NULL) ||
+       (xsltExtensionsHash == NULL))
+       return (NULL);
+
+    
+#ifdef XSLT_REFACTORED
+    /*
+    * This is intended for global storage, so only the main
+    * stylesheet will hold the data.
+    */
+    tmpStyle = style;
+    while (tmpStyle->parent != NULL)
+       tmpStyle = tmpStyle->parent;
+    if (tmpStyle->extInfos != NULL) {
+       dataContainer =
+           (xsltExtDataPtr) xmlHashLookup(tmpStyle->extInfos, URI);
+       if (dataContainer != NULL) {
+           /*
+           * The module was already initialized in the context
+           * of this stylesheet; just return the user-data that
+           * comes with it.
+           */
+           return(dataContainer->extData);
+       }
+    }
+#else
+    /*
+    * Old behaviour.
+    */
+    tmpStyle = style;
+    while (tmpStyle != NULL) {
+       if (tmpStyle->extInfos != NULL) {
+           dataContainer =
+               (xsltExtDataPtr) xmlHashLookup(tmpStyle->extInfos, URI);
+           if (dataContainer != NULL) {
+               return(dataContainer->extData);
+           }
+       }
+       tmpStyle = xsltNextImport(tmpStyle);
+    }
+    tmpStyle = style;
+#endif
+
+    dataContainer =
+        xsltStyleInitializeStylesheetModule(tmpStyle, URI);
+    if (dataContainer != NULL)
+       return (dataContainer->extData);
+    return(NULL);
+}
+
+#ifdef XSLT_REFACTORED
+/**
+ * xsltStyleStylesheetLevelGetExtData:
+ * @style: an XSLT stylesheet
+ * @URI:  the URI associated to the exension module
+ *
+ * Retrieve the data associated to the extension module in this given
+ * stylesheet.
+ *
+ * Returns the pointer or NULL if not present
+ */
+void *
+xsltStyleStylesheetLevelGetExtData(xsltStylesheetPtr style,
+                                  const xmlChar * URI)
+{
+    xsltExtDataPtr dataContainer = NULL;
+
+    if ((style == NULL) || (URI == NULL) ||
+       (xsltExtensionsHash == NULL))
+       return (NULL);
+
+    if (style->extInfos != NULL) {
+       dataContainer = (xsltExtDataPtr) xmlHashLookup(style->extInfos, URI);
+       /*
+       * The module was already initialized in the context
+       * of this stylesheet; just return the user-data that
+       * comes with it.
+       */
+       if (dataContainer)
+           return(dataContainer->extData);
+    }  
+
+    dataContainer =
+        xsltStyleInitializeStylesheetModule(style, URI);
+    if (dataContainer != NULL)
+       return (dataContainer->extData);
+    return(NULL);
+}
+#endif
+
+/**
+ * xsltGetExtData:
+ * @ctxt: an XSLT transformation context
+ * @URI:  the URI associated to the exension module
+ *
+ * Retrieve the data associated to the extension module in this given
+ * transformation.
+ *
+ * Returns the pointer or NULL if not present
+ */
+void *
+xsltGetExtData(xsltTransformContextPtr ctxt, const xmlChar * URI)
+{
+    xsltExtDataPtr data;
+
+    if ((ctxt == NULL) || (URI == NULL))
+        return (NULL);
+    if (ctxt->extInfos == NULL) {
+        ctxt->extInfos = xmlHashCreate(10);
+        if (ctxt->extInfos == NULL)
+            return (NULL);
+        data = NULL;
+    } else {
+        data = (xsltExtDataPtr) xmlHashLookup(ctxt->extInfos, URI);
+    }
+    if (data == NULL) {
+        void *extData;
+        xsltExtModulePtr module;
+
+        module = xmlHashLookup(xsltExtensionsHash, URI);
+        if (module == NULL) {
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+            xsltGenericDebug(xsltGenericDebugContext,
+                             "Not registered extension module: %s\n", URI);
+#endif
+            return (NULL);
+        } else {
+            if (module->initFunc == NULL)
+                return (NULL);
+
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+            xsltGenericDebug(xsltGenericDebugContext,
+                             "Initializing module: %s\n", URI);
+#endif
+
+            extData = module->initFunc(ctxt, URI);
+            if (extData == NULL)
+                return (NULL);
+
+            data = xsltNewExtData(module, extData);
+            if (data == NULL)
+                return (NULL);
+            if (xmlHashAddEntry(ctxt->extInfos, URI, (void *) data) < 0) {
+                xsltTransformError(ctxt, NULL, NULL,
+                                   "Failed to register module data: %s\n",
+                                   URI);
+                if (module->shutdownFunc)
+                    module->shutdownFunc(ctxt, URI, extData);
+                xsltFreeExtData(data);
+                return (NULL);
+            }
+        }
+    }
+    return (data->extData);
+}
+
+typedef struct _xsltInitExtCtxt xsltInitExtCtxt;
+struct _xsltInitExtCtxt {
+    xsltTransformContextPtr ctxt;
+    int ret;
+};
+
+/**
+ * xsltInitCtxtExt:
+ * @styleData:  the registered stylesheet data for the module
+ * @ctxt:  the XSLT transformation context + the return value
+ * @URI:  the extension URI
+ *
+ * Initializes an extension module
+ */
+static void
+xsltInitCtxtExt(xsltExtDataPtr styleData, xsltInitExtCtxt * ctxt,
+                const xmlChar * URI)
+{
+    xsltExtModulePtr module;
+    xsltExtDataPtr ctxtData;
+    void *extData;
+
+    if ((styleData == NULL) || (ctxt == NULL) || (URI == NULL) ||
+        (ctxt->ret == -1)) {
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+        xsltGenericDebug(xsltGenericDebugContext,
+                         "xsltInitCtxtExt: NULL param or error\n");
+#endif
+        return;
+    }
+    module = styleData->extModule;
+    if ((module == NULL) || (module->initFunc == NULL)) {
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+        xsltGenericDebug(xsltGenericDebugContext,
+                         "xsltInitCtxtExt: no module or no initFunc\n");
+#endif
+        return;
+    }
+
+    ctxtData = (xsltExtDataPtr) xmlHashLookup(ctxt->ctxt->extInfos, URI);
+    if (ctxtData != NULL) {
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+        xsltGenericDebug(xsltGenericDebugContext,
+                         "xsltInitCtxtExt: already initialized\n");
+#endif
+        return;
+    }
+
+    extData = module->initFunc(ctxt->ctxt, URI);
+    if (extData == NULL) {
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+        xsltGenericDebug(xsltGenericDebugContext,
+                         "xsltInitCtxtExt: no extData\n");
+#endif
+    }
+    ctxtData = xsltNewExtData(module, extData);
+    if (ctxtData == NULL) {
+        ctxt->ret = -1;
+        return;
+    }
+
+    if (ctxt->ctxt->extInfos == NULL)
+        ctxt->ctxt->extInfos = xmlHashCreate(10);
+    if (ctxt->ctxt->extInfos == NULL) {
+        ctxt->ret = -1;
+        return;
+    }
+
+    if (xmlHashAddEntry(ctxt->ctxt->extInfos, URI, ctxtData) < 0) {
+        xsltGenericError(xsltGenericErrorContext,
+                         "Failed to register module data: %s\n", URI);
+        if (module->shutdownFunc)
+            module->shutdownFunc(ctxt->ctxt, URI, extData);
+        xsltFreeExtData(ctxtData);
+        ctxt->ret = -1;
+        return;
+    }
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+    xsltGenericDebug(xsltGenericDebugContext, "Registered module %s\n",
+                     URI);
+#endif
+    ctxt->ret++;
+}
+
+/**
+ * xsltInitCtxtExts:
+ * @ctxt: an XSLT transformation context
+ *
+ * Initialize the set of modules with registered stylesheet data
+ *
+ * Returns the number of modules initialized or -1 in case of error
+ */
+int
+xsltInitCtxtExts(xsltTransformContextPtr ctxt)
+{
+    xsltStylesheetPtr style;
+    xsltInitExtCtxt ctx;
+
+    if (ctxt == NULL)
+        return (-1);
+
+    style = ctxt->style;
+    if (style == NULL)
+        return (-1);
+
+    ctx.ctxt = ctxt;
+    ctx.ret = 0;
+
+    while (style != NULL) {
+        if (style->extInfos != NULL) {
+            xmlHashScan(style->extInfos,
+                        (xmlHashScanner) xsltInitCtxtExt, &ctx);
+            if (ctx.ret == -1)
+                return (-1);
+        }
+        style = xsltNextImport(style);
+    }
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+    xsltGenericDebug(xsltGenericDebugContext, "Registered %d modules\n",
+                     ctx.ret);
+#endif
+    return (ctx.ret);
+}
+
+/**
+ * xsltShutdownCtxtExt:
+ * @data:  the registered data for the module
+ * @ctxt:  the XSLT transformation context
+ * @URI:  the extension URI
+ *
+ * Shutdown an extension module loaded
+ */
+static void
+xsltShutdownCtxtExt(xsltExtDataPtr data, xsltTransformContextPtr ctxt,
+                    const xmlChar * URI)
+{
+    xsltExtModulePtr module;
+
+    if ((data == NULL) || (ctxt == NULL) || (URI == NULL))
+        return;
+    module = data->extModule;
+    if ((module == NULL) || (module->shutdownFunc == NULL))
+        return;
+
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+    xsltGenericDebug(xsltGenericDebugContext,
+                     "Shutting down module : %s\n", URI);
+#endif
+    module->shutdownFunc(ctxt, URI, data->extData);
+}
+
+/**
+ * xsltShutdownCtxtExts:
+ * @ctxt: an XSLT transformation context
+ *
+ * Shutdown the set of modules loaded
+ */
+void
+xsltShutdownCtxtExts(xsltTransformContextPtr ctxt)
+{
+    if (ctxt == NULL)
+        return;
+    if (ctxt->extInfos == NULL)
+        return;
+    xmlHashScan(ctxt->extInfos, (xmlHashScanner) xsltShutdownCtxtExt,
+                ctxt);
+    xmlHashFree(ctxt->extInfos, (xmlHashDeallocator) xsltFreeExtData);
+    ctxt->extInfos = NULL;
+}
+
+/**
+ * xsltShutdownExt:
+ * @data:  the registered data for the module
+ * @ctxt:  the XSLT stylesheet
+ * @URI:  the extension URI
+ *
+ * Shutdown an extension module loaded
+ */
+static void
+xsltShutdownExt(xsltExtDataPtr data, xsltStylesheetPtr style,
+                const xmlChar * URI)
+{
+    xsltExtModulePtr module;
+
+    if ((data == NULL) || (style == NULL) || (URI == NULL))
+        return;
+    module = data->extModule;
+    if ((module == NULL) || (module->styleShutdownFunc == NULL))
+        return;
+
+#ifdef WITH_XSLT_DEBUG_EXTENSIONS
+    xsltGenericDebug(xsltGenericDebugContext,
+                     "Shutting down module : %s\n", URI);
+#endif
+    module->styleShutdownFunc(style, URI, data->extData);
+    /*
+    * Don't remove the entry from the hash table here, since
+    * this will produce segfaults - this fixes bug #340624.
+    *
+    * xmlHashRemoveEntry(style->extInfos, URI,
+    *   (xmlHashDeallocator) xsltFreeExtData);
+    */    
+}
+
+/**
+ * xsltShutdownExts:
+ * @style: an XSLT stylesheet
+ *
+ * Shutdown the set of modules loaded
+ */
+void
+xsltShutdownExts(xsltStylesheetPtr style)
+{
+    if (style == NULL)
+        return;
+    if (style->extInfos == NULL)
+        return;
+    xmlHashScan(style->extInfos, (xmlHashScanner) xsltShutdownExt, style);
+    xmlHashFree(style->extInfos, (xmlHashDeallocator) xsltFreeExtData);
+    style->extInfos = NULL;
+}
+
+/**
+ * xsltCheckExtPrefix:
+ * @style: the stylesheet
+ * @URI: the namespace prefix (possibly NULL)
+ *
+ * Check if the given prefix is one of the declared extensions.
+ * This is intended to be called only at compile-time.
+ * Called by:
+ *  xsltGetInheritedNsList() (xslt.c)
+ *  xsltParseTemplateContent (xslt.c)
+ *
+ * Returns 1 if this is an extension, 0 otherwise
+ */
+int
+xsltCheckExtPrefix(xsltStylesheetPtr style, const xmlChar * URI)
+{    
+#ifdef XSLT_REFACTORED
+    if ((style == NULL) || (style->compCtxt == NULL) ||
+       (XSLT_CCTXT(style)->inode == NULL) ||
+       (XSLT_CCTXT(style)->inode->extElemNs == NULL))
+        return (0);    
+    /*
+    * Lookup the extension namespaces registered
+    * at the current node in the stylesheet's tree.
+    */
+    if (XSLT_CCTXT(style)->inode->extElemNs != NULL) {
+       int i;
+       xsltPointerListPtr list = XSLT_CCTXT(style)->inode->extElemNs;
+
+       for (i = 0; i < list->number; i++) {
+           if (xmlStrEqual((const xmlChar *) list->items[i],
+               URI))
+           {
+               return(1);
+           }       
+       }
+    }
+#else
+    xsltExtDefPtr cur;
+
+    if ((style == NULL) || (style->nsDefs == NULL))
+        return (0);
+    if (URI == NULL)
+        URI = BAD_CAST "#default";
+    cur = (xsltExtDefPtr) style->nsDefs;
+    while (cur != NULL) {
+       /*
+       * NOTE: This was change to work on namespace names rather
+       * than namespace prefixes. This fixes bug #339583.
+       * TODO: Consider renaming the field "prefix" of xsltExtDef
+       *  to "href".
+       */
+        if (xmlStrEqual(URI, cur->prefix))
+            return (1);
+        cur = cur->next;
+    }
+#endif
+    return (0);
+}
+
+/**
+ * xsltCheckExtURI:
+ * @style: the stylesheet
+ * @URI: the namespace URI (possibly NULL)
+ *
+ * Check if the given prefix is one of the declared extensions.
+ * This is intended to be called only at compile-time.
+ * Called by:
+ *  xsltPrecomputeStylesheet() (xslt.c)
+ *  xsltParseTemplateContent (xslt.c)
+ *
+ * Returns 1 if this is an extension, 0 otherwise
+ */
+int
+xsltCheckExtURI(xsltStylesheetPtr style, const xmlChar * URI)
+{
+    xsltExtDefPtr cur;
+
+    if ((style == NULL) || (style->nsDefs == NULL))
+        return (0);
+    if (URI == NULL)
+        return (0);
+    cur = (xsltExtDefPtr) style->nsDefs;
+    while (cur != NULL) {
+        if (xmlStrEqual(URI, cur->URI))
+            return (1);
+        cur = cur->next;
+    }
+    return (0);
+}
+
+/**
+ * xsltRegisterExtModuleFull:
+ * @URI:  URI associated to this module
+ * @initFunc:  the module initialization function
+ * @shutdownFunc:  the module shutdown function
+ * @styleInitFunc:  the module initialization function
+ * @styleShutdownFunc:  the module shutdown function
+ *
+ * Register an XSLT extension module to the library.
+ *
+ * Returns 0 if sucessful, -1 in case of error
+ */
+int
+xsltRegisterExtModuleFull(const xmlChar * URI,
+                          xsltExtInitFunction initFunc,
+                          xsltExtShutdownFunction shutdownFunc,
+                          xsltStyleExtInitFunction styleInitFunc,
+                          xsltStyleExtShutdownFunction styleShutdownFunc)
+{
+    int ret;
+    xsltExtModulePtr module;
+
+    if ((URI == NULL) || (initFunc == NULL))
+        return (-1);
+    if (xsltExtensionsHash == NULL)
+        xsltExtensionsHash = xmlHashCreate(10);
+
+    if (xsltExtensionsHash == NULL)
+        return (-1);
+
+    module = xmlHashLookup(xsltExtensionsHash, URI);
+    if (module != NULL) {
+        if ((module->initFunc == initFunc) &&
+            (module->shutdownFunc == shutdownFunc))
+            return (0);
+        return (-1);
+    }
+    module = xsltNewExtModule(initFunc, shutdownFunc,
+                              styleInitFunc, styleShutdownFunc);
+    if (module == NULL)
+        return (-1);
+    ret = xmlHashAddEntry(xsltExtensionsHash, URI, (void *) module);
+    return (ret);
+}
+
+/**
+ * xsltRegisterExtModule:
+ * @URI:  URI associated to this module
+ * @initFunc:  the module initialization function
+ * @shutdownFunc:  the module shutdown function
+ *
+ * Register an XSLT extension module to the library.
+ *
+ * Returns 0 if sucessful, -1 in case of error
+ */
+int
+xsltRegisterExtModule(const xmlChar * URI,
+                      xsltExtInitFunction initFunc,
+                      xsltExtShutdownFunction shutdownFunc)
+{
+    return xsltRegisterExtModuleFull(URI, initFunc, shutdownFunc,
+                                     NULL, NULL);
+}
+
+/**
+ * xsltUnregisterExtModule:
+ * @URI:  URI associated to this module
+ *
+ * Unregister an XSLT extension module from the library.
+ *
+ * Returns 0 if sucessful, -1 in case of error
+ */
+int
+xsltUnregisterExtModule(const xmlChar * URI)
+{
+    int ret;
+
+    if (URI == NULL)
+        return (-1);
+    if (xsltExtensionsHash == NULL)
+        return (-1);
+
+    ret =
+        xmlHashRemoveEntry(xsltExtensionsHash, URI,
+                           (xmlHashDeallocator) xsltFreeExtModule);
+    return (ret);
+}
+
+/**
+ * xsltUnregisterAllExtModules:
+ *
+ * Unregister all the XSLT extension module from the library.
+ */
+static void
+xsltUnregisterAllExtModules(void)
+{
+    if (xsltExtensionsHash == NULL)
+        return;
+
+    xmlHashFree(xsltExtensionsHash,
+                (xmlHashDeallocator) xsltFreeExtModule);
+    xsltExtensionsHash = NULL;
+}
+
+/**
+ * xsltXPathGetTransformContext:
+ * @ctxt:  an XPath transformation context
+ *
+ * Provides the XSLT transformation context from the XPath transformation
+ * context. This is useful when an XPath function in the extension module
+ * is called by the XPath interpreter and that the XSLT context is needed
+ * for example to retrieve the associated data pertaining to this XSLT
+ * transformation.
+ *
+ * Returns the XSLT transformation context or NULL in case of error.
+ */
+xsltTransformContextPtr
+xsltXPathGetTransformContext(xmlXPathParserContextPtr ctxt)
+{
+    if ((ctxt == NULL) || (ctxt->context == NULL))
+        return (NULL);
+    return (ctxt->context->extra);
+}
+
+/**
+ * xsltRegisterExtModuleFunction:
+ * @name:  the function name
+ * @URI:  the function namespace URI
+ * @function:  the function callback
+ *
+ * Registers an extension module function.
+ *
+ * Returns 0 if successful, -1 in case of error.
+ */
+int
+xsltRegisterExtModuleFunction(const xmlChar * name, const xmlChar * URI,
+                              xmlXPathFunction function)
+{
+    if ((name == NULL) || (URI == NULL) || (function == NULL))
+        return (-1);
+
+    if (xsltFunctionsHash == NULL)
+        xsltFunctionsHash = xmlHashCreate(10);
+    if (xsltFunctionsHash == NULL)
+        return (-1);
+
+    xmlHashUpdateEntry2(xsltFunctionsHash, name, URI,
+                        XML_CAST_FPTR(function), NULL);
+
+    return (0);
+}
+
+/**
+ * xsltExtModuleFunctionLookup:
+ * @name:  the function name
+ * @URI:  the function namespace URI
+ *
+ * Looks up an extension module function
+ *
+ * Returns the function if found, NULL otherwise.
+ */
+xmlXPathFunction
+xsltExtModuleFunctionLookup(const xmlChar * name, const xmlChar * URI)
+{
+    xmlXPathFunction ret;
+
+    if ((xsltFunctionsHash == NULL) || (name == NULL) || (URI == NULL))
+        return (NULL);
+
+    XML_CAST_FPTR(ret) = xmlHashLookup2(xsltFunctionsHash, name, URI);
+
+    /* if lookup fails, attempt a dynamic load on supported platforms */
+    if (NULL == ret) {
+        if (!xsltExtModuleRegisterDynamic(URI)) {
+            XML_CAST_FPTR(ret) =
+                xmlHashLookup2(xsltFunctionsHash, name, URI);
+        }
+    }
+
+    return ret;
+}
+
+/**
+ * xsltUnregisterExtModuleFunction:
+ * @name:  the function name
+ * @URI:  the function namespace URI
+ *
+ * Unregisters an extension module function
+ *
+ * Returns 0 if successful, -1 in case of error.
+ */
+int
+xsltUnregisterExtModuleFunction(const xmlChar * name, const xmlChar * URI)
+{
+    if ((xsltFunctionsHash == NULL) || (name == NULL) || (URI == NULL))
+        return (-1);
+
+    return xmlHashRemoveEntry2(xsltFunctionsHash, name, URI, NULL);
+}
+
+/**
+ * xsltUnregisterAllExtModuleFunction:
+ *
+ * Unregisters all extension module function
+ */
+static void
+xsltUnregisterAllExtModuleFunction(void)
+{
+    xmlHashFree(xsltFunctionsHash, NULL);
+    xsltFunctionsHash = NULL;
+}
+
+
+/**
+ * xsltNewElemPreComp:
+ * @style:  the XSLT stylesheet
+ * @inst:  the element node
+ * @function: the transform function
+ *
+ * Creates and initializes an #xsltElemPreComp
+ *
+ * Returns the new and initialized #xsltElemPreComp
+ */
+xsltElemPreCompPtr
+xsltNewElemPreComp(xsltStylesheetPtr style, xmlNodePtr inst,
+                   xsltTransformFunction function)
+{
+    xsltElemPreCompPtr cur;
+
+    cur = (xsltElemPreCompPtr) xmlMalloc(sizeof(xsltElemPreComp));
+    if (cur == NULL) {
+        xsltTransformError(NULL, style, NULL,
+                           "xsltNewExtElement : malloc failed\n");
+        return (NULL);
+    }
+    memset(cur, 0, sizeof(xsltElemPreComp));
+
+    xsltInitElemPreComp(cur, style, inst, function,
+                        (xsltElemPreCompDeallocator) xmlFree);
+
+    return (cur);
+}
+
+/**
+ * xsltInitElemPreComp:
+ * @comp:  an #xsltElemPreComp (or generally a derived structure)
+ * @style:  the XSLT stylesheet
+ * @inst:  the element node
+ * @function:  the transform function
+ * @freeFunc:  the @comp deallocator
+ *
+ * Initializes an existing #xsltElemPreComp structure. This is usefull
+ * when extending an #xsltElemPreComp to store precomputed data.
+ * This function MUST be called on any extension element precomputed
+ * data struct.
+ */
+void
+xsltInitElemPreComp(xsltElemPreCompPtr comp, xsltStylesheetPtr style,
+                    xmlNodePtr inst, xsltTransformFunction function,
+                    xsltElemPreCompDeallocator freeFunc)
+{
+    comp->type = XSLT_FUNC_EXTENSION;
+    comp->func = function;
+    comp->inst = inst;
+    comp->free = freeFunc;
+
+    comp->next = style->preComps;
+    style->preComps = comp;
+}
+
+/**
+ * xsltPreComputeExtModuleElement:
+ * @style:  the stylesheet
+ * @inst:  the element node
+ *
+ * Precomputes an extension module element
+ *
+ * Returns the precomputed data
+ */
+xsltElemPreCompPtr
+xsltPreComputeExtModuleElement(xsltStylesheetPtr style, xmlNodePtr inst)
+{
+    xsltExtElementPtr ext;
+    xsltElemPreCompPtr comp = NULL;
+
+    if ((style == NULL) || (inst == NULL) ||
+        (inst->type != XML_ELEMENT_NODE) || (inst->ns == NULL))
+        return (NULL);
+
+    ext = (xsltExtElementPtr)
+        xmlHashLookup2(xsltElementsHash, inst->name, inst->ns->href);
+    /*
+    * EXT TODO: Now what?
+    */
+    if (ext == NULL)
+        return (NULL);
+
+    if (ext->precomp != NULL) {
+       /*
+       * REVISIT TODO: Check if the text below is correct.
+       * This will return a xsltElemPreComp structure or NULL.
+       * 1) If the the author of the extension needs a
+       *  custom structure to hold the specific values of
+       *  this extension, he will derive a structure based on
+       *  xsltElemPreComp; thus we obviously *cannot* refactor
+       *  the xsltElemPreComp structure, since all already derived
+       *  user-defined strucures will break.
+       *  Example: For the extension xsl:document,
+       *   in xsltDocumentComp() (preproc.c), the structure
+       *   xsltStyleItemDocument is allocated, filled with
+       *   specific values and returned.
+       * 2) If the author needs no values to be stored in
+       *  this structure, then he'll return NULL;
+       */
+        comp = ext->precomp(style, inst, ext->transform);
+    }
+    if (comp == NULL) {
+       /*
+       * Default creation of a xsltElemPreComp structure, if
+       * the author of this extension did not create a custom
+       * structure.
+       */
+        comp = xsltNewElemPreComp(style, inst, ext->transform);
+    }
+
+    return (comp);
+}
+
+/**
+ * xsltRegisterExtModuleElement:
+ * @name:  the element name
+ * @URI:  the element namespace URI
+ * @precomp:  the pre-computation callback
+ * @transform:  the transformation callback
+ *
+ * Registers an extension module element.
+ *
+ * Returns 0 if successful, -1 in case of error.
+ */
+int
+xsltRegisterExtModuleElement(const xmlChar * name, const xmlChar * URI,
+                             xsltPreComputeFunction precomp,
+                             xsltTransformFunction transform)
+{
+    xsltExtElementPtr ext;
+
+    if ((name == NULL) || (URI == NULL) || (transform == NULL))
+        return (-1);
+
+    if (xsltElementsHash == NULL)
+        xsltElementsHash = xmlHashCreate(10);
+    if (xsltElementsHash == NULL)
+        return (-1);
+
+    ext = xsltNewExtElement(precomp, transform);
+    if (ext == NULL)
+        return (-1);
+
+    xmlHashUpdateEntry2(xsltElementsHash, name, URI, (void *) ext,
+                        (xmlHashDeallocator) xsltFreeExtElement);
+
+    return (0);
+}
+
+/**
+ * xsltExtElementLookup:
+ * @ctxt:  an XSLT process context
+ * @name:  the element name
+ * @URI:  the element namespace URI
+ *
+ * Looks up an extension element. @ctxt can be NULL to search only in
+ * module elements.
+ *
+ * Returns the element callback or NULL if not found
+ */
+xsltTransformFunction
+xsltExtElementLookup(xsltTransformContextPtr ctxt,
+                     const xmlChar * name, const xmlChar * URI)
+{
+    xsltTransformFunction ret;
+
+    if ((name == NULL) || (URI == NULL))
+        return (NULL);
+
+    if ((ctxt != NULL) && (ctxt->extElements != NULL)) {
+        XML_CAST_FPTR(ret) = xmlHashLookup2(ctxt->extElements, name, URI);
+        if (ret != NULL)
+            return (ret);
+    }
+    return xsltExtModuleElementLookup(name, URI);
+}
+
+/**
+ * xsltExtModuleElementLookup:
+ * @name:  the element name
+ * @URI:  the element namespace URI
+ *
+ * Looks up an extension module element
+ *
+ * Returns the callback function if found, NULL otherwise.
+ */
+xsltTransformFunction
+xsltExtModuleElementLookup(const xmlChar * name, const xmlChar * URI)
+{
+    xsltExtElementPtr ext;
+
+    if ((xsltElementsHash == NULL) || (name == NULL) || (URI == NULL))
+        return (NULL);
+
+    ext = (xsltExtElementPtr) xmlHashLookup2(xsltElementsHash, name, URI);
+
+    /* if function lookup fails, attempt a dynamic load on supported platforms */
+    ext = (xsltExtElementPtr) xmlHashLookup2(xsltElementsHash, name, URI);
+    if (NULL == ext) {
+        if (!xsltExtModuleRegisterDynamic(URI)) {
+            ext = (xsltExtElementPtr)
+                 xmlHashLookup2(xsltElementsHash, name, URI);
+        }
+    }
+
+    if (ext == NULL)
+        return (NULL);
+    return (ext->transform);
+}
+
+/**
+ * xsltExtModuleElementPreComputeLookup:
+ * @name:  the element name
+ * @URI:  the element namespace URI
+ *
+ * Looks up an extension module element pre-computation function
+ *
+ * Returns the callback function if found, NULL otherwise.
+ */
+xsltPreComputeFunction
+xsltExtModuleElementPreComputeLookup(const xmlChar * name,
+                                     const xmlChar * URI)
+{
+    xsltExtElementPtr ext;
+
+    if ((xsltElementsHash == NULL) || (name == NULL) || (URI == NULL))
+        return (NULL);
+
+    ext = (xsltExtElementPtr) xmlHashLookup2(xsltElementsHash, name, URI);
+
+    if (ext == NULL) {
+        if (!xsltExtModuleRegisterDynamic(URI)) {
+            ext = (xsltExtElementPtr)
+                 xmlHashLookup2(xsltElementsHash, name, URI);
+        }
+    }
+
+    if (ext == NULL)
+        return (NULL);
+    return (ext->precomp);
+}
+
+/**
+ * xsltUnregisterExtModuleElement:
+ * @name:  the element name
+ * @URI:  the element namespace URI
+ *
+ * Unregisters an extension module element
+ *
+ * Returns 0 if successful, -1 in case of error.
+ */
+int
+xsltUnregisterExtModuleElement(const xmlChar * name, const xmlChar * URI)
+{
+    if ((xsltElementsHash == NULL) || (name == NULL) || (URI == NULL))
+        return (-1);
+
+    return xmlHashRemoveEntry2(xsltElementsHash, name, URI,
+                               (xmlHashDeallocator) xsltFreeExtElement);
+}
+
+/**
+ * xsltUnregisterAllExtModuleElement:
+ *
+ * Unregisters all extension module element
+ */
+static void
+xsltUnregisterAllExtModuleElement(void)
+{
+    xmlHashFree(xsltElementsHash, (xmlHashDeallocator) xsltFreeExtElement);
+    xsltElementsHash = NULL;
+}
+
+/**
+ * xsltRegisterExtModuleTopLevel:
+ * @name:  the top-level element name
+ * @URI:  the top-level element namespace URI
+ * @function:  the top-level element callback
+ *
+ * Registers an extension module top-level element.
+ *
+ * Returns 0 if successful, -1 in case of error.
+ */
+int
+xsltRegisterExtModuleTopLevel(const xmlChar * name, const xmlChar * URI,
+                              xsltTopLevelFunction function)
+{
+    if ((name == NULL) || (URI == NULL) || (function == NULL))
+        return (-1);
+
+    if (xsltTopLevelsHash == NULL)
+        xsltTopLevelsHash = xmlHashCreate(10);
+    if (xsltTopLevelsHash == NULL)
+        return (-1);
+
+    xmlHashUpdateEntry2(xsltTopLevelsHash, name, URI,
+                        XML_CAST_FPTR(function), NULL);
+
+    return (0);
+}
+
+/**
+ * xsltExtModuleTopLevelLookup:
+ * @name:  the top-level element name
+ * @URI:  the top-level element namespace URI
+ *
+ * Looks up an extension module top-level element
+ *
+ * Returns the callback function if found, NULL otherwise.
+ */
+xsltTopLevelFunction
+xsltExtModuleTopLevelLookup(const xmlChar * name, const xmlChar * URI)
+{
+    xsltTopLevelFunction ret;
+
+    if ((xsltTopLevelsHash == NULL) || (name == NULL) || (URI == NULL))
+        return (NULL);
+
+    XML_CAST_FPTR(ret) = xmlHashLookup2(xsltTopLevelsHash, name, URI);
+
+    /* if lookup fails, attempt a dynamic load on supported platforms */
+    if (NULL == ret) {
+        if (!xsltExtModuleRegisterDynamic(URI)) {
+            XML_CAST_FPTR(ret) = xmlHashLookup2(xsltTopLevelsHash, name, URI);
+        }
+    }
+
+    return (ret);
+}
+
+/**
+ * xsltUnregisterExtModuleTopLevel:
+ * @name:  the top-level element name
+ * @URI:  the top-level element namespace URI
+ *
+ * Unregisters an extension module top-level element
+ *
+ * Returns 0 if successful, -1 in case of error.
+ */
+int
+xsltUnregisterExtModuleTopLevel(const xmlChar * name, const xmlChar * URI)
+{
+    if ((xsltTopLevelsHash == NULL) || (name == NULL) || (URI == NULL))
+        return (-1);
+
+    return xmlHashRemoveEntry2(xsltTopLevelsHash, name, URI, NULL);
+}
+
+/**
+ * xsltUnregisterAllExtModuleTopLevel:
+ *
+ * Unregisters all extension module function
+ */
+static void
+xsltUnregisterAllExtModuleTopLevel(void)
+{
+    xmlHashFree(xsltTopLevelsHash, NULL);
+    xsltTopLevelsHash = NULL;
+}
+
+/**
+ * xsltGetExtInfo:
+ * @style:  pointer to a stylesheet
+ * @URI:    the namespace URI desired
+ *
+ * looks up URI in extInfos of the stylesheet
+ *
+ * returns a pointer to the hash table if found, else NULL
+ */
+xmlHashTablePtr
+xsltGetExtInfo(xsltStylesheetPtr style, const xmlChar * URI)
+{
+    xsltExtDataPtr data;
+
+    /*
+    * TODO: Why do we have a return type of xmlHashTablePtr?
+    *   Is the user-allocated data for extension modules expected
+    *   to be a xmlHashTablePtr only? Or is this intended for
+    *   the EXSLT module only?
+    */
+
+    if (style != NULL && style->extInfos != NULL) {
+        data = xmlHashLookup(style->extInfos, URI);
+        if (data != NULL && data->extData != NULL)
+            return data->extData;
+    }
+    return NULL;
+}
+
+/************************************************************************
+ *                                                                     *
+ *             Test module http://xmlsoft.org/XSLT/                    *
+ *                                                                     *
+ ************************************************************************/
+
+/************************************************************************
+ *                                                                     *
+ *             Test of the extension module API                        *
+ *                                                                     *
+ ************************************************************************/
+
+static xmlChar *testData = NULL;
+static xmlChar *testStyleData = NULL;
+
+/**
+ * xsltExtFunctionTest:
+ * @ctxt:  the XPath Parser context
+ * @nargs:  the number of arguments
+ *
+ * function libxslt:test() for testing the extensions support.
+ */
+static void
+xsltExtFunctionTest(xmlXPathParserContextPtr ctxt,
+                    int nargs ATTRIBUTE_UNUSED)
+{
+    xsltTransformContextPtr tctxt;
+    void *data = NULL;
+
+    tctxt = xsltXPathGetTransformContext(ctxt);
+
+    if (testData == NULL) {
+        xsltGenericDebug(xsltGenericDebugContext,
+                         "xsltExtFunctionTest: not initialized,"
+                         " calling xsltGetExtData\n");
+        data = xsltGetExtData(tctxt, (const xmlChar *) XSLT_DEFAULT_URL);
+        if (data == NULL) {
+            xsltTransformError(tctxt, NULL, NULL,
+                               "xsltExtElementTest: not initialized\n");
+            return;
+        }
+    }
+    if (tctxt == NULL) {
+        xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+                           "xsltExtFunctionTest: failed to get the transformation context\n");
+        return;
+    }
+    if (data == NULL)
+        data = xsltGetExtData(tctxt, (const xmlChar *) XSLT_DEFAULT_URL);
+    if (data == NULL) {
+        xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+                           "xsltExtFunctionTest: failed to get module data\n");
+        return;
+    }
+    if (data != testData) {
+        xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+                           "xsltExtFunctionTest: got wrong module data\n");
+        return;
+    }
+#ifdef WITH_XSLT_DEBUG_FUNCTION
+    xsltGenericDebug(xsltGenericDebugContext,
+                     "libxslt:test() called with %d args\n", nargs);
+#endif
+}
+
+/**
+ * xsltExtElementPreCompTest:
+ * @style:  the stylesheet
+ * @inst:  the instruction in the stylesheet
+ *
+ * Process a libxslt:test node
+ */
+static xsltElemPreCompPtr
+xsltExtElementPreCompTest(xsltStylesheetPtr style, xmlNodePtr inst,
+                          xsltTransformFunction function)
+{
+    xsltElemPreCompPtr ret;
+
+    if (style == NULL) {
+        xsltTransformError(NULL, NULL, inst,
+                           "xsltExtElementTest: no transformation context\n");
+        return (NULL);
+    }
+    if (testStyleData == NULL) {
+        xsltGenericDebug(xsltGenericDebugContext,
+                         "xsltExtElementPreCompTest: not initialized,"
+                         " calling xsltStyleGetExtData\n");
+        xsltStyleGetExtData(style, (const xmlChar *) XSLT_DEFAULT_URL);
+        if (testStyleData == NULL) {
+            xsltTransformError(NULL, style, inst,
+                               "xsltExtElementPreCompTest: not initialized\n");
+            if (style != NULL)
+                style->errors++;
+            return (NULL);
+        }
+    }
+    if (inst == NULL) {
+        xsltTransformError(NULL, style, inst,
+                           "xsltExtElementPreCompTest: no instruction\n");
+        if (style != NULL)
+            style->errors++;
+        return (NULL);
+    }
+    ret = xsltNewElemPreComp(style, inst, function);
+    return (ret);
+}
+
+/**
+ * xsltExtElementTest:
+ * @ctxt:  an XSLT processing context
+ * @node:  The current node
+ * @inst:  the instruction in the stylesheet
+ * @comp:  precomputed informations
+ *
+ * Process a libxslt:test node
+ */
+static void
+xsltExtElementTest(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                   xmlNodePtr inst,
+                   xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
+{
+    xmlNodePtr commentNode;
+
+    if (testData == NULL) {
+        xsltGenericDebug(xsltGenericDebugContext,
+                         "xsltExtElementTest: not initialized,"
+                         " calling xsltGetExtData\n");
+        xsltGetExtData(ctxt, (const xmlChar *) XSLT_DEFAULT_URL);
+        if (testData == NULL) {
+            xsltTransformError(ctxt, NULL, inst,
+                               "xsltExtElementTest: not initialized\n");
+            return;
+        }
+    }
+    if (ctxt == NULL) {
+        xsltTransformError(ctxt, NULL, inst,
+                           "xsltExtElementTest: no transformation context\n");
+        return;
+    }
+    if (node == NULL) {
+        xsltTransformError(ctxt, NULL, inst,
+                           "xsltExtElementTest: no current node\n");
+        return;
+    }
+    if (inst == NULL) {
+        xsltTransformError(ctxt, NULL, inst,
+                           "xsltExtElementTest: no instruction\n");
+        return;
+    }
+    if (ctxt->insert == NULL) {
+        xsltTransformError(ctxt, NULL, inst,
+                           "xsltExtElementTest: no insertion point\n");
+        return;
+    }
+    commentNode = xmlNewComment((const xmlChar *)
+                                "libxslt:test element test worked");
+    xmlAddChild(ctxt->insert, commentNode);
+}
+
+/**
+ * xsltExtInitTest:
+ * @ctxt:  an XSLT transformation context
+ * @URI:  the namespace URI for the extension
+ *
+ * A function called at initialization time of an XSLT extension module
+ *
+ * Returns a pointer to the module specific data for this transformation
+ */
+static void *
+xsltExtInitTest(xsltTransformContextPtr ctxt, const xmlChar * URI)
+{
+    if (testStyleData == NULL) {
+        xsltGenericDebug(xsltGenericErrorContext,
+                         "xsltExtInitTest: not initialized,"
+                         " calling xsltStyleGetExtData\n");
+        testStyleData = xsltStyleGetExtData(ctxt->style, URI);
+        if (testStyleData == NULL) {
+            xsltTransformError(ctxt, NULL, NULL,
+                               "xsltExtInitTest: not initialized\n");
+            return (NULL);
+        }
+    }
+    if (testData != NULL) {
+        xsltTransformError(ctxt, NULL, NULL,
+                           "xsltExtInitTest: already initialized\n");
+        return (NULL);
+    }
+    testData = (void *) "test data";
+    xsltGenericDebug(xsltGenericDebugContext,
+                     "Registered test module : %s\n", URI);
+    return (testData);
+}
+
+
+/**
+ * xsltExtShutdownTest:
+ * @ctxt:  an XSLT transformation context
+ * @URI:  the namespace URI for the extension
+ * @data:  the data associated to this module
+ *
+ * A function called at shutdown time of an XSLT extension module
+ */
+static void
+xsltExtShutdownTest(xsltTransformContextPtr ctxt,
+                    const xmlChar * URI, void *data)
+{
+    if (testData == NULL) {
+        xsltTransformError(ctxt, NULL, NULL,
+                           "xsltExtShutdownTest: not initialized\n");
+        return;
+    }
+    if (data != testData) {
+        xsltTransformError(ctxt, NULL, NULL,
+                           "xsltExtShutdownTest: wrong data\n");
+    }
+    testData = NULL;
+    xsltGenericDebug(xsltGenericDebugContext,
+                     "Unregistered test module : %s\n", URI);
+}
+
+/**
+ * xsltExtStyleInitTest:
+ * @style:  an XSLT stylesheet
+ * @URI:  the namespace URI for the extension
+ *
+ * A function called at initialization time of an XSLT extension module
+ *
+ * Returns a pointer to the module specific data for this transformation
+ */
+static void *
+xsltExtStyleInitTest(xsltStylesheetPtr style ATTRIBUTE_UNUSED,
+                     const xmlChar * URI)
+{
+    if (testStyleData != NULL) {
+        xsltTransformError(NULL, NULL, NULL,
+                           "xsltExtInitTest: already initialized\n");
+        return (NULL);
+    }
+    testStyleData = (void *) "test data";
+    xsltGenericDebug(xsltGenericDebugContext,
+                     "Registered test module : %s\n", URI);
+    return (testStyleData);
+}
+
+
+/**
+ * xsltExtStyleShutdownTest:
+ * @style:  an XSLT stylesheet
+ * @URI:  the namespace URI for the extension
+ * @data:  the data associated to this module
+ *
+ * A function called at shutdown time of an XSLT extension module
+ */
+static void
+xsltExtStyleShutdownTest(xsltStylesheetPtr style ATTRIBUTE_UNUSED,
+                         const xmlChar * URI, void *data)
+{
+    if (testStyleData == NULL) {
+        xsltGenericError(xsltGenericErrorContext,
+                         "xsltExtShutdownTest: not initialized\n");
+        return;
+    }
+    if (data != testStyleData) {
+        xsltTransformError(NULL, NULL, NULL,
+                           "xsltExtShutdownTest: wrong data\n");
+    }
+    testStyleData = NULL;
+    xsltGenericDebug(xsltGenericDebugContext,
+                     "Unregistered test module : %s\n", URI);
+}
+
+/**
+ * xsltRegisterTestModule:
+ *
+ * Registers the test module
+ */
+void
+xsltRegisterTestModule(void)
+{
+    xsltRegisterExtModuleFull((const xmlChar *) XSLT_DEFAULT_URL,
+                              xsltExtInitTest, xsltExtShutdownTest,
+                              xsltExtStyleInitTest,
+                              xsltExtStyleShutdownTest);
+    xsltRegisterExtModuleFunction((const xmlChar *) "test",
+                                  (const xmlChar *) XSLT_DEFAULT_URL,
+                                  xsltExtFunctionTest);
+    xsltRegisterExtModuleElement((const xmlChar *) "test",
+                                 (const xmlChar *) XSLT_DEFAULT_URL,
+                                 xsltExtElementPreCompTest,
+                                 xsltExtElementTest);
+}
+
+static void
+xsltHashScannerModuleFree(void *payload, void *data ATTRIBUTE_UNUSED,
+                          xmlChar * name ATTRIBUTE_UNUSED)
+{
+#ifdef WITH_MODULES
+    xmlModuleClose(payload);
+#endif
+}
+
+/**
+ * xsltCleanupGlobals:
+ *
+ * Unregister all global variables set up by the XSLT library
+ */
+void
+xsltCleanupGlobals(void)
+{
+    xsltUnregisterAllExtModules();
+    xsltUnregisterAllExtModuleFunction();
+    xsltUnregisterAllExtModuleElement();
+    xsltUnregisterAllExtModuleTopLevel();
+
+    /* cleanup dynamic module hash */
+    if (NULL != xsltModuleHash) {
+        xmlHashScan(xsltModuleHash, xsltHashScannerModuleFree, 0);
+        xmlHashFree(xsltModuleHash, NULL);
+        xsltModuleHash = NULL;
+    }
+
+    xsltUninit();
+}
+
+static void
+xsltDebugDumpExtensionsCallback(void *function ATTRIBUTE_UNUSED,
+                                FILE * output, const xmlChar * name,
+                                const xmlChar * URI,
+                                const xmlChar * not_used ATTRIBUTE_UNUSED)
+{
+    if (!name || !URI)
+        return;
+    fprintf(output, "{%s}%s\n", URI, name);
+}
+
+static void
+xsltDebugDumpExtModulesCallback(void *function ATTRIBUTE_UNUSED,
+                                FILE * output, const xmlChar * URI,
+                                const xmlChar * not_used ATTRIBUTE_UNUSED,
+                                const xmlChar * not_used2 ATTRIBUTE_UNUSED)
+{
+    if (!URI)
+        return;
+    fprintf(output, "%s\n", URI);
+}
+
+/**
+ * xsltDebugDumpExtensions:
+ * @output:  the FILE * for the output, if NULL stdout is used
+ *
+ * Dumps a list of the registered XSLT extension functions and elements
+ */
+void
+xsltDebugDumpExtensions(FILE * output)
+{
+    if (output == NULL)
+        output = stdout;
+    fprintf(output,
+            "Registered XSLT Extensions\n--------------------------\n");
+    if (!xsltFunctionsHash)
+        fprintf(output, "No registered extension functions\n");
+    else {
+        fprintf(output, "Registered Extension Functions:\n");
+        xmlHashScanFull(xsltFunctionsHash,
+                        (xmlHashScannerFull)
+                        xsltDebugDumpExtensionsCallback, output);
+    }
+    if (!xsltElementsHash)
+        fprintf(output, "\nNo registered extension elements\n");
+    else {
+        fprintf(output, "\nRegistered Extension Elements:\n");
+        xmlHashScanFull(xsltElementsHash,
+                        (xmlHashScannerFull)
+                        xsltDebugDumpExtensionsCallback, output);
+    }
+    if (!xsltExtensionsHash)
+        fprintf(output, "\nNo registered extension modules\n");
+    else {
+        fprintf(output, "\nRegistered Extension Modules:\n");
+        xmlHashScanFull(xsltExtensionsHash,
+                        (xmlHashScannerFull)
+                        xsltDebugDumpExtModulesCallback, output);
+    }
+
+}
diff --git a/reactos/dll/3rdparty/libxslt/extensions.h b/reactos/dll/3rdparty/libxslt/extensions.h
new file mode 100644 (file)
index 0000000..30b7d4c
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * Summary: interface for the extension support
+ * Description: This provide the API needed for simple and module
+ *              extension support.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_EXTENSION_H__
+#define __XML_XSLT_EXTENSION_H__
+
+#include <libxml/xpath.h>
+#include "xsltexports.h"
+#include "xsltInternals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Extension Modules API.
+ */
+
+/**
+ * xsltStyleExtInitFunction:
+ * @ctxt:  an XSLT stylesheet
+ * @URI:  the namespace URI for the extension
+ *
+ * A function called at initialization time of an XSLT extension module.
+ *
+ * Returns a pointer to the module specific data for this transformation.
+ */
+typedef void * (*xsltStyleExtInitFunction)     (xsltStylesheetPtr style,
+                                                const xmlChar *URI);
+
+/**
+ * xsltStyleExtShutdownFunction:
+ * @ctxt:  an XSLT stylesheet
+ * @URI:  the namespace URI for the extension
+ * @data:  the data associated to this module
+ *
+ * A function called at shutdown time of an XSLT extension module.
+ */
+typedef void (*xsltStyleExtShutdownFunction)   (xsltStylesheetPtr style,
+                                                const xmlChar *URI,
+                                                void *data);
+
+/**
+ * xsltExtInitFunction:
+ * @ctxt:  an XSLT transformation context
+ * @URI:  the namespace URI for the extension
+ *
+ * A function called at initialization time of an XSLT extension module.
+ *
+ * Returns a pointer to the module specific data for this transformation.
+ */
+typedef void * (*xsltExtInitFunction)  (xsltTransformContextPtr ctxt,
+                                        const xmlChar *URI);
+
+/**
+ * xsltExtShutdownFunction:
+ * @ctxt:  an XSLT transformation context
+ * @URI:  the namespace URI for the extension
+ * @data:  the data associated to this module
+ *
+ * A function called at shutdown time of an XSLT extension module.
+ */
+typedef void (*xsltExtShutdownFunction) (xsltTransformContextPtr ctxt,
+                                        const xmlChar *URI,
+                                        void *data);
+
+XSLTPUBFUN int XSLTCALL
+               xsltRegisterExtModule   (const xmlChar *URI,
+                                        xsltExtInitFunction initFunc,
+                                        xsltExtShutdownFunction shutdownFunc);
+XSLTPUBFUN int XSLTCALL
+               xsltRegisterExtModuleFull
+                                       (const xmlChar * URI,
+                                        xsltExtInitFunction initFunc,
+                                        xsltExtShutdownFunction shutdownFunc,
+                                        xsltStyleExtInitFunction styleInitFunc,
+                                        xsltStyleExtShutdownFunction styleShutdownFunc);
+
+XSLTPUBFUN int XSLTCALL
+               xsltUnregisterExtModule (const xmlChar * URI);
+
+XSLTPUBFUN void * XSLTCALL             
+               xsltGetExtData          (xsltTransformContextPtr ctxt,
+                                        const xmlChar *URI);
+
+XSLTPUBFUN void * XSLTCALL             
+               xsltStyleGetExtData     (xsltStylesheetPtr style,
+                                        const xmlChar *URI);
+#ifdef XSLT_REFACTORED
+XSLTPUBFUN void * XSLTCALL
+               xsltStyleStylesheetLevelGetExtData(
+                                        xsltStylesheetPtr style,
+                                        const xmlChar * URI);
+#endif
+XSLTPUBFUN void XSLTCALL               
+               xsltShutdownCtxtExts    (xsltTransformContextPtr ctxt);
+
+XSLTPUBFUN void XSLTCALL               
+               xsltShutdownExts        (xsltStylesheetPtr style);
+
+XSLTPUBFUN xsltTransformContextPtr XSLTCALL 
+               xsltXPathGetTransformContext
+                                       (xmlXPathParserContextPtr ctxt);
+
+/*
+ * extension functions
+*/
+XSLTPUBFUN int XSLTCALL        
+               xsltRegisterExtModuleFunction   
+                                       (const xmlChar *name,
+                                        const xmlChar *URI,
+                                        xmlXPathFunction function);
+XSLTPUBFUN xmlXPathFunction XSLTCALL
+       xsltExtFunctionLookup           (xsltTransformContextPtr ctxt,
+                                        const xmlChar *name,
+                                        const xmlChar *URI);
+XSLTPUBFUN xmlXPathFunction XSLTCALL
+       xsltExtModuleFunctionLookup     (const xmlChar *name,
+                                        const xmlChar *URI);
+XSLTPUBFUN int XSLTCALL        
+               xsltUnregisterExtModuleFunction 
+                                       (const xmlChar *name,
+                                        const xmlChar *URI);
+
+/*
+ * extension elements
+ */
+typedef xsltElemPreCompPtr (*xsltPreComputeFunction)
+                                       (xsltStylesheetPtr style,
+                                        xmlNodePtr inst,
+                                        xsltTransformFunction function);
+
+XSLTPUBFUN xsltElemPreCompPtr XSLTCALL
+               xsltNewElemPreComp      (xsltStylesheetPtr style,
+                                        xmlNodePtr inst,
+                                        xsltTransformFunction function);
+XSLTPUBFUN void XSLTCALL       
+               xsltInitElemPreComp     (xsltElemPreCompPtr comp,
+                                        xsltStylesheetPtr style,
+                                        xmlNodePtr inst,
+                                        xsltTransformFunction function,
+                                        xsltElemPreCompDeallocator freeFunc);
+
+XSLTPUBFUN int XSLTCALL        
+               xsltRegisterExtModuleElement    
+                                       (const xmlChar *name,
+                                        const xmlChar *URI,
+                                        xsltPreComputeFunction precomp,
+                                        xsltTransformFunction transform);
+XSLTPUBFUN xsltTransformFunction XSLTCALL 
+               xsltExtElementLookup    (xsltTransformContextPtr ctxt,
+                                        const xmlChar *name,
+                                        const xmlChar *URI);
+XSLTPUBFUN xsltTransformFunction XSLTCALL 
+               xsltExtModuleElementLookup
+                                       (const xmlChar *name,
+                                        const xmlChar *URI);
+XSLTPUBFUN xsltPreComputeFunction XSLTCALL 
+               xsltExtModuleElementPreComputeLookup 
+                                       (const xmlChar *name,
+                                        const xmlChar *URI);
+XSLTPUBFUN int XSLTCALL        
+               xsltUnregisterExtModuleElement  
+                                       (const xmlChar *name,
+                                        const xmlChar *URI);
+
+/*
+ * top-level elements
+ */
+typedef void (*xsltTopLevelFunction)   (xsltStylesheetPtr style,
+                                        xmlNodePtr inst);
+
+XSLTPUBFUN int XSLTCALL        
+               xsltRegisterExtModuleTopLevel
+                                       (const xmlChar *name,
+                                        const xmlChar *URI,
+                                        xsltTopLevelFunction function);
+XSLTPUBFUN xsltTopLevelFunction XSLTCALL 
+               xsltExtModuleTopLevelLookup 
+                                       (const xmlChar *name,
+                                        const xmlChar *URI);
+XSLTPUBFUN int XSLTCALL        
+               xsltUnregisterExtModuleTopLevel 
+                                       (const xmlChar *name,
+                                        const xmlChar *URI);
+
+
+/* These 2 functions are deprecated for use within modules. */
+XSLTPUBFUN int XSLTCALL                
+               xsltRegisterExtFunction (xsltTransformContextPtr ctxt,
+                                        const xmlChar *name,
+                                        const xmlChar *URI,
+                                        xmlXPathFunction function);
+XSLTPUBFUN int XSLTCALL                
+               xsltRegisterExtElement  (xsltTransformContextPtr ctxt,
+                                        const xmlChar *name,
+                                        const xmlChar *URI,
+                                        xsltTransformFunction function);
+
+/*
+ * Extension Prefix handling API.
+ * Those are used by the XSLT (pre)processor.
+ */
+
+XSLTPUBFUN int XSLTCALL                
+               xsltRegisterExtPrefix   (xsltStylesheetPtr style,
+                                        const xmlChar *prefix,
+                                        const xmlChar *URI);
+XSLTPUBFUN int XSLTCALL                
+               xsltCheckExtPrefix      (xsltStylesheetPtr style,
+                                        const xmlChar *URI);
+XSLTPUBFUN int XSLTCALL
+               xsltCheckExtURI         (xsltStylesheetPtr style,
+                                        const xmlChar *URI);
+XSLTPUBFUN int XSLTCALL                
+               xsltInitCtxtExts        (xsltTransformContextPtr ctxt);
+XSLTPUBFUN void XSLTCALL               
+               xsltFreeCtxtExts        (xsltTransformContextPtr ctxt);
+XSLTPUBFUN void XSLTCALL               
+               xsltFreeExts            (xsltStylesheetPtr style);
+
+XSLTPUBFUN xsltElemPreCompPtr XSLTCALL 
+               xsltPreComputeExtModuleElement
+                                       (xsltStylesheetPtr style,
+                                        xmlNodePtr inst);
+/*
+ * Extension Infos access.
+ * Used by exslt initialisation
+ */
+
+XSLTPUBFUN xmlHashTablePtr XSLTCALL 
+               xsltGetExtInfo          (xsltStylesheetPtr style, 
+                                        const xmlChar *URI);
+
+/**
+ * Test module http://xmlsoft.org/XSLT/
+ */
+XSLTPUBFUN void XSLTCALL       
+               xsltRegisterTestModule  (void);
+XSLTPUBFUN void XSLTCALL       
+               xsltDebugDumpExtensions (FILE * output);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_EXTENSION_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/extra.c b/reactos/dll/3rdparty/libxslt/extra.c
new file mode 100644 (file)
index 0000000..9128ab4
--- /dev/null
@@ -0,0 +1,330 @@
+/*
+ * extra.c: Implementation of non-standard features
+ *
+ * Reference:
+ *   Michael Kay "XSLT Programmer's Reference" pp 637-643
+ *   The node-set() extension function
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+#ifdef HAVE_TIME_H
+#define __USE_XOPEN
+#include <time.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/hash.h>
+#include <libxml/xmlerror.h>
+#include <libxml/parserInternals.h>
+#include "xslt.h"
+#include "xsltInternals.h"
+#include "xsltutils.h"
+#include "extensions.h"
+#include "variables.h"
+#include "transform.h"
+#include "extra.h"
+#include "preproc.h"
+
+#ifdef WITH_XSLT_DEBUG
+#define WITH_XSLT_DEBUG_EXTRA
+#endif
+
+/************************************************************************
+ *                                                                     *
+ *             Handling of XSLT debugging                              *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltDebug:
+ * @ctxt:  an XSLT processing context
+ * @node:  The current node
+ * @inst:  the instruction in the stylesheet
+ * @comp:  precomputed informations
+ *
+ * Process an debug node
+ */
+void
+xsltDebug(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED,
+          xmlNodePtr inst ATTRIBUTE_UNUSED,
+          xsltStylePreCompPtr comp ATTRIBUTE_UNUSED)
+{
+    int i, j;
+
+    xsltGenericError(xsltGenericErrorContext, "Templates:\n");
+    for (i = 0, j = ctxt->templNr - 1; ((i < 15) && (j >= 0)); i++, j--) {
+        xsltGenericError(xsltGenericErrorContext, "#%d ", i);
+        if (ctxt->templTab[j]->name != NULL)
+            xsltGenericError(xsltGenericErrorContext, "name %s ",
+                             ctxt->templTab[j]->name);
+        if (ctxt->templTab[j]->match != NULL)
+            xsltGenericError(xsltGenericErrorContext, "name %s ",
+                             ctxt->templTab[j]->match);
+        if (ctxt->templTab[j]->mode != NULL)
+            xsltGenericError(xsltGenericErrorContext, "name %s ",
+                             ctxt->templTab[j]->mode);
+        xsltGenericError(xsltGenericErrorContext, "\n");
+    }
+    xsltGenericError(xsltGenericErrorContext, "Variables:\n");
+    for (i = 0, j = ctxt->varsNr - 1; ((i < 15) && (j >= 0)); i++, j--) {
+        xsltStackElemPtr cur;
+
+        if (ctxt->varsTab[j] == NULL)
+            continue;
+        xsltGenericError(xsltGenericErrorContext, "#%d\n", i);
+        cur = ctxt->varsTab[j];
+        while (cur != NULL) {
+            if (cur->comp == NULL) {
+                xsltGenericError(xsltGenericErrorContext,
+                                 "corrupted !!!\n");
+            } else if (cur->comp->type == XSLT_FUNC_PARAM) {
+                xsltGenericError(xsltGenericErrorContext, "param ");
+            } else if (cur->comp->type == XSLT_FUNC_VARIABLE) {
+                xsltGenericError(xsltGenericErrorContext, "var ");
+            }
+            if (cur->name != NULL)
+                xsltGenericError(xsltGenericErrorContext, "%s ",
+                                 cur->name);
+            else
+                xsltGenericError(xsltGenericErrorContext, "noname !!!!");
+#ifdef LIBXML_DEBUG_ENABLED
+            if (cur->value != NULL) {
+                xmlXPathDebugDumpObject(stdout, cur->value, 1);
+            } else {
+                xsltGenericError(xsltGenericErrorContext, "NULL !!!!");
+            }
+#endif
+            xsltGenericError(xsltGenericErrorContext, "\n");
+            cur = cur->next;
+        }
+
+    }
+}
+
+/************************************************************************
+ *                                                                     *
+ *             Classic extensions as described by M. Kay               *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltFunctionNodeSet:
+ * @ctxt:  the XPath Parser context
+ * @nargs:  the number of arguments
+ *
+ * Implement the node-set() XSLT function
+ *   node-set node-set(result-tree)
+ *
+ * This function is available in libxslt, saxon or xt namespace.
+ */
+void
+xsltFunctionNodeSet(xmlXPathParserContextPtr ctxt, int nargs){
+    if (nargs != 1) {
+       xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+               "node-set() : expects one result-tree arg\n");
+       ctxt->error = XPATH_INVALID_ARITY;
+       return;
+    }
+    if ((ctxt->value == NULL) ||
+       ((ctxt->value->type != XPATH_XSLT_TREE) &&
+        (ctxt->value->type != XPATH_NODESET))) {
+       xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+           "node-set() invalid arg expecting a result tree\n");
+       ctxt->error = XPATH_INVALID_TYPE;
+       return;
+    }
+    if (ctxt->value->type == XPATH_XSLT_TREE) {
+       ctxt->value->type = XPATH_NODESET;
+    }
+}
+
+
+/*
+ * Okay the following really seems unportable and since it's not
+ * part of any standard I'm not too ashamed to do this
+ */
+#if defined(linux) || defined(__sun)
+#if defined(HAVE_MKTIME) && defined(HAVE_LOCALTIME) && defined(HAVE_ASCTIME)
+#define WITH_LOCALTIME
+
+/**
+ * xsltFunctionLocalTime:
+ * @ctxt:  the XPath Parser context
+ * @nargs:  the number of arguments
+ *
+ * Implement the localTime XSLT function used by NORM
+ *   string localTime(???)
+ *
+ * This function is available in Norm's extension namespace
+ * Code (and comments) contributed by Norm
+ */
+static void
+xsltFunctionLocalTime(xmlXPathParserContextPtr ctxt, int nargs) {
+    xmlXPathObjectPtr obj;
+    char *str;
+    char digits[5];
+    char result[29];
+    long int field;
+    time_t gmt, lmt;
+    struct tm gmt_tm;
+    struct tm *local_tm;
+    if (nargs != 1) {
+       xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+                      "localTime() : invalid number of args %d\n", nargs);
+       ctxt->error = XPATH_INVALID_ARITY;
+       return;
+    }
+    obj = valuePop(ctxt);
+
+    if (obj->type != XPATH_STRING) {
+       obj = xmlXPathConvertString(obj);
+    }
+    if (obj == NULL) {
+       valuePush(ctxt, xmlXPathNewString((const xmlChar *)""));
+       return;
+    }
+    
+    str = (char *) obj->stringval;
+
+    /* str = "$Date: 2002-10-15 18:06:47 +0200 (Tue, 15 Oct 2002) $" */
+    memset(digits, 0, sizeof(digits));
+    strncpy(digits, str+7, 4);
+    field = strtol(digits, NULL, 10);
+    gmt_tm.tm_year = field - 1900;
+
+    memset(digits, 0, sizeof(digits));
+    strncpy(digits, str+12, 2);
+    field = strtol(digits, NULL, 10);
+    gmt_tm.tm_mon = field - 1;
+
+    memset(digits, 0, sizeof(digits));
+    strncpy(digits, str+15, 2);
+    field = strtol(digits, NULL, 10);
+    gmt_tm.tm_mday = field;
+
+    memset(digits, 0, sizeof(digits));
+    strncpy(digits, str+18, 2);
+    field = strtol(digits, NULL, 10);
+    gmt_tm.tm_hour = field;
+
+    memset(digits, 0, sizeof(digits));
+    strncpy(digits, str+21, 2);
+    field = strtol(digits, NULL, 10);
+    gmt_tm.tm_min = field;
+
+    memset(digits, 0, sizeof(digits));
+    strncpy(digits, str+24, 2);
+    field = strtol(digits, NULL, 10);
+    gmt_tm.tm_sec = field;
+
+    /* Now turn gmt_tm into a time. */
+    gmt = mktime(&gmt_tm);
+
+
+    /*
+     * FIXME: it's been too long since I did manual memory management.
+     * (I swore never to do it again.) Does this introduce a memory leak?
+     */
+    local_tm = localtime(&gmt);
+
+    /*
+     * Calling localtime() has the side-effect of setting timezone.
+     * After we know the timezone, we can adjust for it
+     */
+    lmt = gmt - timezone;
+
+    /*
+     * FIXME: it's been too long since I did manual memory management.
+     * (I swore never to do it again.) Does this introduce a memory leak?
+     */
+    local_tm = localtime(&lmt);
+
+    /*
+     * Now convert local_tm back into a string. This doesn't introduce
+     * a memory leak, so says asctime(3).
+     */
+
+    str = asctime(local_tm);           /* "Tue Jun 26 05:02:16 2001" */
+                                       /*  0123456789 123456789 123 */
+
+    memset(result, 0, sizeof(result)); /* "Thu, 26 Jun 2001" */
+                                       /*  0123456789 12345 */
+
+    strncpy(result, str, 20);
+    strcpy(result+20, "???");          /* tzname doesn't work, fake it */
+    strncpy(result+23, str+19, 5);
+
+    /* Ok, now result contains the string I want to send back. */
+    valuePush(ctxt, xmlXPathNewString((xmlChar *)result));
+}
+#endif
+#endif /* linux or sun */
+
+
+/**
+ * xsltRegisterExtras:
+ * @ctxt:  a XSLT process context
+ *
+ * Registers the built-in extensions. This function is deprecated, use
+ * xsltRegisterAllExtras instead.
+ */
+void
+xsltRegisterExtras(xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED) {
+    xsltRegisterAllExtras();
+}
+
+/**
+ * xsltRegisterAllExtras:
+ *
+ * Registers the built-in extensions
+ */
+void
+xsltRegisterAllExtras (void) {
+    xsltRegisterExtModuleFunction((const xmlChar *) "node-set",
+                                 XSLT_LIBXSLT_NAMESPACE,
+                                 xsltFunctionNodeSet);
+    xsltRegisterExtModuleFunction((const xmlChar *) "node-set",
+                                 XSLT_SAXON_NAMESPACE,
+                                 xsltFunctionNodeSet);
+    xsltRegisterExtModuleFunction((const xmlChar *) "node-set",
+                                 XSLT_XT_NAMESPACE,
+                                 xsltFunctionNodeSet);
+#ifdef WITH_LOCALTIME
+    xsltRegisterExtModuleFunction((const xmlChar *) "localTime",
+                                 XSLT_NORM_SAXON_NAMESPACE,
+                                 xsltFunctionLocalTime);
+#endif
+    xsltRegisterExtModuleElement((const xmlChar *) "debug",
+                                XSLT_LIBXSLT_NAMESPACE,
+                                NULL,
+                                (xsltTransformFunction) xsltDebug);
+    xsltRegisterExtModuleElement((const xmlChar *) "output",
+                                XSLT_SAXON_NAMESPACE,
+                                xsltDocumentComp,
+                                (xsltTransformFunction) xsltDocumentElem);
+    xsltRegisterExtModuleElement((const xmlChar *) "write",
+                                XSLT_XALAN_NAMESPACE,
+                                xsltDocumentComp,
+                                (xsltTransformFunction) xsltDocumentElem);
+    xsltRegisterExtModuleElement((const xmlChar *) "document",
+                                XSLT_XT_NAMESPACE,
+                                xsltDocumentComp,
+                                (xsltTransformFunction) xsltDocumentElem);
+    xsltRegisterExtModuleElement((const xmlChar *) "document",
+                                XSLT_NAMESPACE,
+                                xsltDocumentComp,
+                                (xsltTransformFunction) xsltDocumentElem);
+}
diff --git a/reactos/dll/3rdparty/libxslt/extra.h b/reactos/dll/3rdparty/libxslt/extra.h
new file mode 100644 (file)
index 0000000..59e932b
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Summary: interface for the non-standard features
+ * Description: implement some extension outside the XSLT namespace
+ *              but not EXSLT with is in a different library.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_EXTRA_H__
+#define __XML_XSLT_EXTRA_H__
+
+#include <libxml/xpath.h>
+#include "xsltexports.h"
+#include "xsltInternals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * XSLT_LIBXSLT_NAMESPACE:
+ *
+ * This is the libxslt namespace for specific extensions.
+ */
+#define XSLT_LIBXSLT_NAMESPACE ((xmlChar *) "http://xmlsoft.org/XSLT/namespace")
+
+/**
+ * XSLT_SAXON_NAMESPACE:
+ *
+ * This is Michael Kay's Saxon processor namespace for extensions.
+ */
+#define XSLT_SAXON_NAMESPACE ((xmlChar *) "http://icl.com/saxon")
+
+/**
+ * XSLT_XT_NAMESPACE:
+ *
+ * This is James Clark's XT processor namespace for extensions.
+ */
+#define XSLT_XT_NAMESPACE ((xmlChar *) "http://www.jclark.com/xt")
+
+/**
+ * XSLT_XALAN_NAMESPACE:
+ *
+ * This is the Apache project XALAN processor namespace for extensions.
+ */
+#define XSLT_XALAN_NAMESPACE ((xmlChar *)      \
+                               "org.apache.xalan.xslt.extensions.Redirect")
+
+/**
+ * XSLT_NORM_SAXON_NAMESPACE:
+ *
+ * This is Norm's namespace for SAXON extensions.
+ */
+#define XSLT_NORM_SAXON_NAMESPACE ((xmlChar *) \
+       "http://nwalsh.com/xslt/ext/com.nwalsh.saxon.CVS")
+
+
+XSLTPUBFUN void XSLTCALL
+               xsltFunctionNodeSet     (xmlXPathParserContextPtr ctxt,
+                                        int nargs);
+XSLTPUBFUN void XSLTCALL               
+               xsltDebug               (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+
+
+XSLTPUBFUN void XSLTCALL               
+               xsltRegisterExtras      (xsltTransformContextPtr ctxt);
+XSLTPUBFUN void XSLTCALL               
+               xsltRegisterAllExtras   (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_EXTRA_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/functions.c b/reactos/dll/3rdparty/libxslt/functions.c
new file mode 100644 (file)
index 0000000..7ae2499
--- /dev/null
@@ -0,0 +1,973 @@
+/*
+ * functions.c: Implementation of the XSLT extra functions
+ *
+ * Reference:
+ *   http://www.w3.org/TR/1999/REC-xslt-19991116
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ * Bjorn Reese <breese@users.sourceforge.net> for number formatting
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/valid.h>
+#include <libxml/hash.h>
+#include <libxml/xmlerror.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+#include <libxml/parserInternals.h>
+#include <libxml/uri.h>
+#include <libxml/xpointer.h>
+#include "xslt.h"
+#include "xsltInternals.h"
+#include "xsltutils.h"
+#include "functions.h"
+#include "extensions.h"
+#include "numbersInternals.h"
+#include "keys.h"
+#include "documents.h"
+
+#ifdef WITH_XSLT_DEBUG
+#define WITH_XSLT_DEBUG_FUNCTION
+#endif
+
+/*
+ * Some versions of DocBook XSL use the vendor string to detect
+ * supporting chunking, this is a workaround to be considered
+ * in the list of decent XSLT processors <grin/>
+ */
+#define DOCBOOK_XSL_HACK
+
+/**
+ * xsltXPathFunctionLookup:
+ * @ctxt:  a void * but the XSLT transformation context actually
+ * @name:  the function name
+ * @ns_uri:  the function namespace URI
+ *
+ * This is the entry point when a function is needed by the XPath
+ * interpretor.
+ *
+ * Returns the callback function or NULL if not found
+ */
+xmlXPathFunction
+xsltXPathFunctionLookup (xmlXPathContextPtr ctxt,
+                        const xmlChar *name, const xmlChar *ns_uri) {
+    xmlXPathFunction ret;
+
+    if ((ctxt == NULL) || (name == NULL) || (ns_uri == NULL))
+       return (NULL);
+
+#ifdef WITH_XSLT_DEBUG_FUNCTION
+    xsltGenericDebug(xsltGenericDebugContext,
+            "Lookup function {%s}%s\n", ns_uri, name);
+#endif
+
+    /* give priority to context-level functions */
+    /*
+    ret = (xmlXPathFunction) xmlHashLookup2(ctxt->funcHash, name, ns_uri);
+    */
+    XML_CAST_FPTR(ret) = xmlHashLookup2(ctxt->funcHash, name, ns_uri);
+
+    if (ret == NULL)
+       ret = xsltExtModuleFunctionLookup(name, ns_uri);
+
+#ifdef WITH_XSLT_DEBUG_FUNCTION
+    if (ret != NULL)
+        xsltGenericDebug(xsltGenericDebugContext,
+            "found function %s\n", name);
+#endif
+    return(ret);
+}
+
+
+/************************************************************************
+ *                                                                     *
+ *                     Module interfaces                               *
+ *                                                                     *
+ ************************************************************************/
+
+static void
+xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt, xmlChar* URI)
+{
+    xsltTransformContextPtr tctxt;
+    xmlURIPtr uri;
+    xmlChar *fragment;
+    xsltDocumentPtr idoc; /* document info */
+    xmlDocPtr doc;
+    xmlXPathContextPtr xptrctxt = NULL;
+    xmlXPathObjectPtr resObj = NULL;
+
+    tctxt = xsltXPathGetTransformContext(ctxt);
+    if (tctxt == NULL) {
+       xsltTransformError(NULL, NULL, NULL,
+           "document() : internal error tctxt == NULL\n");
+       valuePush(ctxt, xmlXPathNewNodeSet(NULL));
+       return;
+    } 
+       
+    uri = xmlParseURI((const char *) URI);
+    if (uri == NULL) {
+       xsltTransformError(tctxt, NULL, NULL,
+           "document() : failed to parse URI\n");
+       valuePush(ctxt, xmlXPathNewNodeSet(NULL));
+       return;
+    } 
+    
+    /*
+     * check for and remove fragment identifier
+     */
+    fragment = (xmlChar *)uri->fragment;
+    if (fragment != NULL) {
+        xmlChar *newURI;
+       uri->fragment = NULL;
+       newURI = xmlSaveUri(uri);
+       idoc = xsltLoadDocument(tctxt, newURI);
+       xmlFree(newURI);
+    } else
+       idoc = xsltLoadDocument(tctxt, URI);
+    xmlFreeURI(uri);
+    
+    if (idoc == NULL) {
+       if ((URI == NULL) ||
+           (URI[0] == '#') ||
+           ((tctxt->style->doc != NULL) &&
+           (xmlStrEqual(tctxt->style->doc->URL, URI)))) 
+       {
+           /*
+           * This selects the stylesheet's doc itself.
+           */
+           doc = tctxt->style->doc;
+       } else {
+           valuePush(ctxt, xmlXPathNewNodeSet(NULL));
+
+           if (fragment != NULL)
+               xmlFree(fragment);
+
+           return;
+       }
+    } else
+       doc = idoc->doc;
+
+    if (fragment == NULL) {
+       valuePush(ctxt, xmlXPathNewNodeSet((xmlNodePtr) doc));
+       return;
+    }
+       
+    /* use XPointer of HTML location for fragment ID */
+#ifdef LIBXML_XPTR_ENABLED
+    xptrctxt = xmlXPtrNewContext(doc, NULL, NULL);
+    if (xptrctxt == NULL) {
+       xsltTransformError(tctxt, NULL, NULL,
+           "document() : internal error xptrctxt == NULL\n");
+       goto out_fragment;
+    }
+
+    resObj = xmlXPtrEval(fragment, xptrctxt);
+    xmlXPathFreeContext(xptrctxt);
+#endif
+    xmlFree(fragment); 
+
+    if (resObj == NULL)
+       goto out_fragment;
+       
+    switch (resObj->type) {
+       case XPATH_NODESET:
+           break;
+       case XPATH_UNDEFINED:
+       case XPATH_BOOLEAN:
+       case XPATH_NUMBER:
+       case XPATH_STRING:
+       case XPATH_POINT:
+       case XPATH_USERS:
+       case XPATH_XSLT_TREE:
+       case XPATH_RANGE:
+       case XPATH_LOCATIONSET:
+           xsltTransformError(tctxt, NULL, NULL,
+               "document() : XPointer does not select a node set: #%s\n", 
+               fragment);
+       goto out_object;
+    }
+    
+    valuePush(ctxt, resObj);
+    return;
+
+out_object:
+    xmlXPathFreeObject(resObj);
+
+out_fragment:
+    valuePush(ctxt, xmlXPathNewNodeSet(NULL));
+}
+
+/**
+ * xsltDocumentFunction:
+ * @ctxt:  the XPath Parser context
+ * @nargs:  the number of arguments
+ *
+ * Implement the document() XSLT function
+ *   node-set document(object, node-set?)
+ */
+void
+xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs)
+{
+    xmlXPathObjectPtr obj, obj2 = NULL;
+    xmlChar *base = NULL, *URI;
+
+
+    if ((nargs < 1) || (nargs > 2)) {
+        xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+                         "document() : invalid number of args %d\n",
+                         nargs);
+        ctxt->error = XPATH_INVALID_ARITY;
+        return;
+    }
+    if (ctxt->value == NULL) {
+        xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+                         "document() : invalid arg value\n");
+        ctxt->error = XPATH_INVALID_TYPE;
+        return;
+    }
+
+    if (nargs == 2) {
+        if (ctxt->value->type != XPATH_NODESET) {
+            xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+                             "document() : invalid arg expecting a nodeset\n");
+            ctxt->error = XPATH_INVALID_TYPE;
+            return;
+        }
+
+        obj2 = valuePop(ctxt);
+    }
+
+    if (ctxt->value->type == XPATH_NODESET) {
+        int i;
+        xmlXPathObjectPtr newobj, ret;
+
+        obj = valuePop(ctxt);
+        ret = xmlXPathNewNodeSet(NULL);
+
+        if (obj->nodesetval) {
+            for (i = 0; i < obj->nodesetval->nodeNr; i++) {
+                valuePush(ctxt,
+                          xmlXPathNewNodeSet(obj->nodesetval->nodeTab[i]));
+                xmlXPathStringFunction(ctxt, 1);
+                if (nargs == 2) {
+                    valuePush(ctxt, xmlXPathObjectCopy(obj2));
+                } else {
+                    valuePush(ctxt,
+                              xmlXPathNewNodeSet(obj->nodesetval->
+                                                 nodeTab[i]));
+                }
+                xsltDocumentFunction(ctxt, 2);
+                newobj = valuePop(ctxt);
+                ret->nodesetval = xmlXPathNodeSetMerge(ret->nodesetval,
+                                                       newobj->nodesetval);
+                xmlXPathFreeObject(newobj);
+            }
+        }
+
+        xmlXPathFreeObject(obj);
+        if (obj2 != NULL)
+            xmlXPathFreeObject(obj2);
+        valuePush(ctxt, ret);
+        return;
+    }
+    /*
+     * Make sure it's converted to a string
+     */
+    xmlXPathStringFunction(ctxt, 1);
+    if (ctxt->value->type != XPATH_STRING) {
+        xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+                         "document() : invalid arg expecting a string\n");
+        ctxt->error = XPATH_INVALID_TYPE;
+        if (obj2 != NULL)
+            xmlXPathFreeObject(obj2);
+        return;
+    }
+    obj = valuePop(ctxt);
+    if (obj->stringval == NULL) {
+        valuePush(ctxt, xmlXPathNewNodeSet(NULL));
+    } else {
+        if ((obj2 != NULL) && (obj2->nodesetval != NULL) &&
+            (obj2->nodesetval->nodeNr > 0) &&
+            IS_XSLT_REAL_NODE(obj2->nodesetval->nodeTab[0])) {
+            xmlNodePtr target;
+
+            target = obj2->nodesetval->nodeTab[0];
+            if ((target->type == XML_ATTRIBUTE_NODE) ||
+               (target->type == XML_PI_NODE)) {
+                target = ((xmlAttrPtr) target)->parent;
+            }
+            base = xmlNodeGetBase(target->doc, target);
+        } else {
+            xsltTransformContextPtr tctxt;
+
+            tctxt = xsltXPathGetTransformContext(ctxt);
+            if ((tctxt != NULL) && (tctxt->inst != NULL)) {
+                base = xmlNodeGetBase(tctxt->inst->doc, tctxt->inst);
+            } else if ((tctxt != NULL) && (tctxt->style != NULL) &&
+                       (tctxt->style->doc != NULL)) {
+                base = xmlNodeGetBase(tctxt->style->doc,
+                                      (xmlNodePtr) tctxt->style->doc);
+            }
+        }
+        URI = xmlBuildURI(obj->stringval, base);
+        if (base != NULL)
+            xmlFree(base);
+        if (URI == NULL) {
+            valuePush(ctxt, xmlXPathNewNodeSet(NULL));
+        } else {
+           xsltDocumentFunctionLoadDocument( ctxt, URI );
+           xmlFree(URI);
+       }
+    }
+    xmlXPathFreeObject(obj);
+    if (obj2 != NULL)
+        xmlXPathFreeObject(obj2);
+}
+
+/**
+ * xsltKeyFunction:
+ * @ctxt:  the XPath Parser context
+ * @nargs:  the number of arguments
+ *
+ * Implement the key() XSLT function
+ *   node-set key(string, object)
+ */
+void
+xsltKeyFunction(xmlXPathParserContextPtr ctxt, int nargs){    
+    xmlXPathObjectPtr obj1, obj2;    
+    
+    if (nargs != 2) {
+       xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+               "key() : expects two arguments\n");
+       ctxt->error = XPATH_INVALID_ARITY;
+       return;
+    }    
+
+    /*
+    * Get the key's value.
+    */
+    obj2 = valuePop(ctxt);
+    xmlXPathStringFunction(ctxt, 1);
+    if ((obj2 == NULL) ||
+       (ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
+       xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+           "key() : invalid arg expecting a string\n");
+       ctxt->error = XPATH_INVALID_TYPE;
+       xmlXPathFreeObject(obj2);
+
+       return;
+    }
+    /*
+    * Get the key's name.
+    */
+    obj1 = valuePop(ctxt);    
+
+    if ((obj2->type == XPATH_NODESET) || (obj2->type == XPATH_XSLT_TREE)) {
+       int i;
+       xmlXPathObjectPtr newobj, ret;
+
+       ret = xmlXPathNewNodeSet(NULL);
+
+       if (obj2->nodesetval != NULL) {
+           for (i = 0; i < obj2->nodesetval->nodeNr; i++) {
+               valuePush(ctxt, xmlXPathObjectCopy(obj1));
+               valuePush(ctxt,
+                         xmlXPathNewNodeSet(obj2->nodesetval->nodeTab[i]));
+               xmlXPathStringFunction(ctxt, 1);
+               xsltKeyFunction(ctxt, 2);
+               newobj = valuePop(ctxt);
+               ret->nodesetval = xmlXPathNodeSetMerge(ret->nodesetval,
+                                                      newobj->nodesetval);
+               xmlXPathFreeObject(newobj);
+           }
+       }
+       valuePush(ctxt, ret);
+    } else {
+       xmlNodeSetPtr nodelist = NULL;
+       xmlChar *key = NULL, *value;
+       const xmlChar *keyURI;
+       xsltTransformContextPtr tctxt;   
+       xmlChar *qname, *prefix;
+       xmlXPathContextPtr xpctxt = ctxt->context;
+       xmlNodePtr tmpNode = NULL;
+       xsltDocumentPtr oldDocInfo;
+
+       tctxt = xsltXPathGetTransformContext(ctxt);
+
+       oldDocInfo = tctxt->document;
+
+       if (xpctxt->node == NULL) {
+           xsltTransformError(tctxt, NULL, tctxt->inst,
+               "Internal error in xsltKeyFunction(): "
+               "The context node is not set on the XPath context.\n");
+           tctxt->state = XSLT_STATE_STOPPED;
+           goto error;
+       }       
+       /*
+        * Get the associated namespace URI if qualified name
+        */
+       qname = obj1->stringval;
+       key = xmlSplitQName2(qname, &prefix);
+       if (key == NULL) {
+           key = xmlStrdup(obj1->stringval);
+           keyURI = NULL;
+           if (prefix != NULL)
+               xmlFree(prefix);
+       } else {
+           if (prefix != NULL) {
+               keyURI = xmlXPathNsLookup(xpctxt, prefix);
+               if (keyURI == NULL) {
+                   xsltTransformError(tctxt, NULL, tctxt->inst,
+                       "key() : prefix %s is not bound\n", prefix);
+                   /*
+                   * TODO: Shouldn't we stop here?
+                   */
+               }
+               xmlFree(prefix);
+           } else {
+               keyURI = NULL;
+           }
+       }
+
+       /*
+        * Force conversion of first arg to string
+        */
+       valuePush(ctxt, obj2);
+       xmlXPathStringFunction(ctxt, 1);
+       if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
+           xsltTransformError(tctxt, NULL, tctxt->inst,
+               "key() : invalid arg expecting a string\n");
+           ctxt->error = XPATH_INVALID_TYPE;
+           goto error;
+       }
+       obj2 = valuePop(ctxt);
+       value = obj2->stringval;
+       
+       /*
+       * We need to ensure that ctxt->document is available for
+       * xsltGetKey().
+       * First find the relevant doc, which is the context node's
+       * owner doc; using context->doc is not safe, since
+       * the doc could have been acquired via the document() function,
+       * or the doc might be a Result Tree Fragment.
+       * FUTURE INFO: In XSLT 2.0 the key() function takes an additional
+       * argument indicating the doc to use.
+       */      
+       if (xpctxt->node->type == XML_NAMESPACE_DECL) {
+           /*
+           * REVISIT: This is a libxml hack! Check xpath.c for details.
+           * The XPath module sets the owner element of a ns-node on
+           * the ns->next field.
+           */
+           if ((((xmlNsPtr) xpctxt->node)->next != NULL) &&
+               (((xmlNsPtr) xpctxt->node)->next->type == XML_ELEMENT_NODE))
+           {
+               tmpNode = (xmlNodePtr) ((xmlNsPtr) xpctxt->node)->next;
+           }
+       } else
+           tmpNode = xpctxt->node;
+
+       if ((tmpNode == NULL) || (tmpNode->doc == NULL)) {
+           xsltTransformError(tctxt, NULL, tctxt->inst,
+               "Internal error in xsltKeyFunction(): "
+               "Couldn't get the doc of the XPath context node.\n");
+           goto error;
+       }
+
+       if ((tctxt->document == NULL) ||
+           (tctxt->document->doc != tmpNode->doc))
+       {          
+           if (tmpNode->doc->name && (tmpNode->doc->name[0] == ' ')) {
+               /*
+               * This is a Result Tree Fragment.
+               */
+               if (tmpNode->doc->_private == NULL) {
+                   tmpNode->doc->_private = xsltNewDocument(tctxt, tmpNode->doc);
+                   if (tmpNode->doc->_private == NULL)
+                       goto error;
+               }
+               tctxt->document = (xsltDocumentPtr) tmpNode->doc->_private;             
+           } else {
+               /*
+               * May be the initial source doc or a doc acquired via the
+               * document() function.
+               */
+               tctxt->document = xsltFindDocument(tctxt, tmpNode->doc);
+           }
+           if (tctxt->document == NULL) {
+               xsltTransformError(tctxt, NULL, tctxt->inst,
+                   "Internal error in xsltKeyFunction(): "
+                   "Could not get the document info of a context doc.\n");
+               tctxt->state = XSLT_STATE_STOPPED;
+               goto error;
+           }
+       }
+       /*
+       * Get/compute the key value.
+       */
+       nodelist = xsltGetKey(tctxt, key, keyURI, value);
+
+error: 
+       tctxt->document = oldDocInfo;
+       valuePush(ctxt, xmlXPathWrapNodeSet(
+           xmlXPathNodeSetMerge(NULL, nodelist)));
+       if (key != NULL)
+           xmlFree(key);
+    }    
+
+    if (obj1 != NULL)
+       xmlXPathFreeObject(obj1);
+    if (obj2 != NULL)
+       xmlXPathFreeObject(obj2);    
+}
+
+/**
+ * xsltUnparsedEntityURIFunction:
+ * @ctxt:  the XPath Parser context
+ * @nargs:  the number of arguments
+ *
+ * Implement the unparsed-entity-uri() XSLT function
+ *   string unparsed-entity-uri(string)
+ */
+void
+xsltUnparsedEntityURIFunction(xmlXPathParserContextPtr ctxt, int nargs){
+    xmlXPathObjectPtr obj;
+    xmlChar *str;
+
+    if ((nargs != 1) || (ctxt->value == NULL)) {
+        xsltGenericError(xsltGenericErrorContext,
+               "unparsed-entity-uri() : expects one string arg\n");
+       ctxt->error = XPATH_INVALID_ARITY;
+       return;
+    }
+    obj = valuePop(ctxt);
+    if (obj->type != XPATH_STRING) {
+       obj = xmlXPathConvertString(obj);
+    }
+
+    str = obj->stringval;
+    if (str == NULL) {
+       valuePush(ctxt, xmlXPathNewString((const xmlChar *)""));
+    } else {
+       xmlEntityPtr entity;
+
+       entity = xmlGetDocEntity(ctxt->context->doc, str);
+       if (entity == NULL) {
+           valuePush(ctxt, xmlXPathNewString((const xmlChar *)""));
+       } else {
+           if (entity->URI != NULL)
+               valuePush(ctxt, xmlXPathNewString(entity->URI));
+           else
+               valuePush(ctxt, xmlXPathNewString((const xmlChar *)""));
+       }
+    }
+    xmlXPathFreeObject(obj);
+}
+
+/**
+ * xsltFormatNumberFunction:
+ * @ctxt:  the XPath Parser context
+ * @nargs:  the number of arguments
+ *
+ * Implement the format-number() XSLT function
+ *   string format-number(number, string, string?)
+ */
+void
+xsltFormatNumberFunction(xmlXPathParserContextPtr ctxt, int nargs)
+{
+    xmlXPathObjectPtr numberObj = NULL;
+    xmlXPathObjectPtr formatObj = NULL;
+    xmlXPathObjectPtr decimalObj = NULL;
+    xsltStylesheetPtr sheet;
+    xsltDecimalFormatPtr formatValues;
+    xmlChar *result;
+    xsltTransformContextPtr tctxt;
+
+    tctxt = xsltXPathGetTransformContext(ctxt);
+    if (tctxt == NULL)
+       return;
+    sheet = tctxt->style;
+    if (sheet == NULL)
+       return;
+    formatValues = sheet->decimalFormat;
+    
+    switch (nargs) {
+    case 3:
+       CAST_TO_STRING;
+       decimalObj = valuePop(ctxt);
+       formatValues = xsltDecimalFormatGetByName(sheet, decimalObj->stringval);
+       if (formatValues == NULL) {
+           xsltTransformError(tctxt, NULL, NULL,
+                   "format-number() : undeclared decimal format '%s'\n", 
+                   decimalObj->stringval);
+       }
+       /* Intentional fall-through */
+    case 2:
+       CAST_TO_STRING;
+       formatObj = valuePop(ctxt);
+       CAST_TO_NUMBER;
+       numberObj = valuePop(ctxt);
+       break;
+    default:
+       XP_ERROR(XPATH_INVALID_ARITY);
+    }
+
+    if (formatValues != NULL) {
+       if (xsltFormatNumberConversion(formatValues,
+                                      formatObj->stringval,
+                                      numberObj->floatval,
+                                      &result) == XPATH_EXPRESSION_OK) {
+           valuePush(ctxt, xmlXPathNewString(result));
+           xmlFree(result);
+       }
+    }
+
+    xmlXPathFreeObject(numberObj);
+    xmlXPathFreeObject(formatObj);
+    xmlXPathFreeObject(decimalObj);
+}
+
+/**
+ * xsltGenerateIdFunction:
+ * @ctxt:  the XPath Parser context
+ * @nargs:  the number of arguments
+ *
+ * Implement the generate-id() XSLT function
+ *   string generate-id(node-set?)
+ */
+void
+xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
+    xmlNodePtr cur = NULL;
+    unsigned long val;
+    xmlChar str[20];
+
+    if (nargs == 0) {
+       cur = ctxt->context->node;
+    } else if (nargs == 1) {
+       xmlXPathObjectPtr obj;
+       xmlNodeSetPtr nodelist;
+       int i, ret;
+
+       if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_NODESET)) {
+           ctxt->error = XPATH_INVALID_TYPE;
+           xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+               "generate-id() : invalid arg expecting a node-set\n");
+           return;
+       }
+       obj = valuePop(ctxt);
+       nodelist = obj->nodesetval;
+       if ((nodelist == NULL) || (nodelist->nodeNr <= 0)) {
+           xmlXPathFreeObject(obj);
+           valuePush(ctxt, xmlXPathNewCString(""));
+           return;
+       }
+       cur = nodelist->nodeTab[0];
+       for (i = 1;i < nodelist->nodeNr;i++) {
+           ret = xmlXPathCmpNodes(cur, nodelist->nodeTab[i]);
+           if (ret == -1)
+               cur = nodelist->nodeTab[i];
+       }
+       xmlXPathFreeObject(obj);
+    } else {
+       xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+               "generate-id() : invalid number of args %d\n", nargs);
+       ctxt->error = XPATH_INVALID_ARITY;
+       return;
+    }
+    /*
+     * Okay this is ugly but should work, use the NodePtr address
+     * to forge the ID
+     */
+    val = (unsigned long)((char *)cur - (char *)0);
+    val /= sizeof(xmlNode);
+    sprintf((char *)str, "id%ld", val);
+    valuePush(ctxt, xmlXPathNewString(str));
+}
+
+/**
+ * xsltSystemPropertyFunction:
+ * @ctxt:  the XPath Parser context
+ * @nargs:  the number of arguments
+ *
+ * Implement the system-property() XSLT function
+ *   object system-property(string)
+ */
+void
+xsltSystemPropertyFunction(xmlXPathParserContextPtr ctxt, int nargs){
+    xmlXPathObjectPtr obj;
+    xmlChar *prefix, *name;
+    const xmlChar *nsURI = NULL;
+
+    if (nargs != 1) {
+       xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+               "system-property() : expects one string arg\n");
+       ctxt->error = XPATH_INVALID_ARITY;
+       return;
+    }
+    if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
+       xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+           "system-property() : invalid arg expecting a string\n");
+       ctxt->error = XPATH_INVALID_TYPE;
+       return;
+    }
+    obj = valuePop(ctxt);
+    if (obj->stringval == NULL) {
+       valuePush(ctxt, xmlXPathNewString((const xmlChar *)""));
+    } else {
+       name = xmlSplitQName2(obj->stringval, &prefix);
+       if (name == NULL) {
+           name = xmlStrdup(obj->stringval);
+       } else {
+           nsURI = xmlXPathNsLookup(ctxt->context, prefix);
+           if (nsURI == NULL) {
+               xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+                   "system-property() : prefix %s is not bound\n", prefix);
+           }
+       }
+
+       if (xmlStrEqual(nsURI, XSLT_NAMESPACE)) {
+#ifdef DOCBOOK_XSL_HACK
+           if (xmlStrEqual(name, (const xmlChar *)"vendor")) {
+               xsltStylesheetPtr sheet;
+               xsltTransformContextPtr tctxt;
+
+               tctxt = xsltXPathGetTransformContext(ctxt);
+               if ((tctxt != NULL) && (tctxt->inst != NULL) &&
+                   (xmlStrEqual(tctxt->inst->name, BAD_CAST "variable")) &&
+                   (tctxt->inst->parent != NULL) &&
+                   (xmlStrEqual(tctxt->inst->parent->name,
+                                BAD_CAST "template")))
+                   sheet = tctxt->style;
+               else
+                   sheet = NULL;
+               if ((sheet != NULL) && (sheet->doc != NULL) &&
+                   (sheet->doc->URL != NULL) &&
+                   (xmlStrstr(sheet->doc->URL,
+                              (const xmlChar *)"chunk") != NULL)) {
+                   valuePush(ctxt, xmlXPathNewString(
+                       (const xmlChar *)"libxslt (SAXON 6.2 compatible)"));
+
+               } else {
+                   valuePush(ctxt, xmlXPathNewString(
+                       (const xmlChar *)XSLT_DEFAULT_VENDOR));
+               }
+           } else
+#else
+           if (xmlStrEqual(name, (const xmlChar *)"vendor")) {
+               valuePush(ctxt, xmlXPathNewString(
+                         (const xmlChar *)XSLT_DEFAULT_VENDOR));
+           } else
+#endif
+           if (xmlStrEqual(name, (const xmlChar *)"version")) {
+               valuePush(ctxt, xmlXPathNewString(
+                   (const xmlChar *)XSLT_DEFAULT_VERSION));
+           } else if (xmlStrEqual(name, (const xmlChar *)"vendor-url")) {
+               valuePush(ctxt, xmlXPathNewString(
+                   (const xmlChar *)XSLT_DEFAULT_URL));
+           } else {
+               valuePush(ctxt, xmlXPathNewString((const xmlChar *)""));
+           }
+       }
+       if (name != NULL)
+           xmlFree(name);
+       if (prefix != NULL)
+           xmlFree(prefix);
+    }
+    xmlXPathFreeObject(obj);
+}
+
+/**
+ * xsltElementAvailableFunction:
+ * @ctxt:  the XPath Parser context
+ * @nargs:  the number of arguments
+ *
+ * Implement the element-available() XSLT function
+ *   boolean element-available(string)
+ */
+void
+xsltElementAvailableFunction(xmlXPathParserContextPtr ctxt, int nargs){
+    xmlXPathObjectPtr obj;
+    xmlChar *prefix, *name;
+    const xmlChar *nsURI = NULL;
+    xsltTransformContextPtr tctxt;
+
+    if (nargs != 1) {
+       xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+               "element-available() : expects one string arg\n");
+       ctxt->error = XPATH_INVALID_ARITY;
+       return;
+    }
+    if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
+       xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+           "element-available() : invalid arg expecting a string\n");
+       ctxt->error = XPATH_INVALID_TYPE;
+       return;
+    }
+    obj = valuePop(ctxt);
+    tctxt = xsltXPathGetTransformContext(ctxt);
+    if (tctxt == NULL) {
+       xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+               "element-available() : internal error tctxt == NULL\n");
+       xmlXPathFreeObject(obj);
+       valuePush(ctxt, xmlXPathNewBoolean(0));
+       return;
+    }
+
+
+    name = xmlSplitQName2(obj->stringval, &prefix);
+    if (name == NULL) {
+       xmlNsPtr ns;
+
+       name = xmlStrdup(obj->stringval);
+       ns = xmlSearchNs(tctxt->inst->doc, tctxt->inst, NULL);
+       if (ns != NULL) nsURI = xmlStrdup(ns->href);
+    } else {
+       nsURI = xmlXPathNsLookup(ctxt->context, prefix);
+       if (nsURI == NULL) {
+           xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+               "element-available() : prefix %s is not bound\n", prefix);
+       }
+    }
+
+    if (xsltExtElementLookup(tctxt, name, nsURI) != NULL) {
+       valuePush(ctxt, xmlXPathNewBoolean(1));
+    } else {
+       valuePush(ctxt, xmlXPathNewBoolean(0));
+    }
+
+    xmlXPathFreeObject(obj);
+    if (name != NULL)
+       xmlFree(name);
+    if (prefix != NULL)
+       xmlFree(prefix);
+}
+
+/**
+ * xsltFunctionAvailableFunction:
+ * @ctxt:  the XPath Parser context
+ * @nargs:  the number of arguments
+ *
+ * Implement the function-available() XSLT function
+ *   boolean function-available(string)
+ */
+void
+xsltFunctionAvailableFunction(xmlXPathParserContextPtr ctxt, int nargs){
+    xmlXPathObjectPtr obj;
+    xmlChar *prefix, *name;
+    const xmlChar *nsURI = NULL;
+
+    if (nargs != 1) {
+       xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+               "function-available() : expects one string arg\n");
+       ctxt->error = XPATH_INVALID_ARITY;
+       return;
+    }
+    if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
+       xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+           "function-available() : invalid arg expecting a string\n");
+       ctxt->error = XPATH_INVALID_TYPE;
+       return;
+    }
+    obj = valuePop(ctxt);
+
+    name = xmlSplitQName2(obj->stringval, &prefix);
+    if (name == NULL) {
+       name = xmlStrdup(obj->stringval);
+    } else {
+       nsURI = xmlXPathNsLookup(ctxt->context, prefix);
+       if (nsURI == NULL) {
+           xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+               "function-available() : prefix %s is not bound\n", prefix);
+       }
+    }
+
+    if (xmlXPathFunctionLookupNS(ctxt->context, name, nsURI) != NULL) {
+       valuePush(ctxt, xmlXPathNewBoolean(1));
+    } else {
+       valuePush(ctxt, xmlXPathNewBoolean(0));
+    }
+
+    xmlXPathFreeObject(obj);
+    if (name != NULL)
+       xmlFree(name);
+    if (prefix != NULL)
+       xmlFree(prefix);
+}
+
+/**
+ * xsltCurrentFunction:
+ * @ctxt:  the XPath Parser context
+ * @nargs:  the number of arguments
+ *
+ * Implement the current() XSLT function
+ *   node-set current()
+ */
+static void
+xsltCurrentFunction(xmlXPathParserContextPtr ctxt, int nargs){
+    xsltTransformContextPtr tctxt;
+
+    if (nargs != 0) {
+       xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+               "current() : function uses no argument\n");
+       ctxt->error = XPATH_INVALID_ARITY;
+       return;
+    }
+    tctxt = xsltXPathGetTransformContext(ctxt);
+    if (tctxt == NULL) {
+       xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
+               "current() : internal error tctxt == NULL\n");
+       valuePush(ctxt, xmlXPathNewNodeSet(NULL));
+    } else {
+       valuePush(ctxt, xmlXPathNewNodeSet(tctxt->node)); /* current */
+    }
+}
+
+/************************************************************************
+ *                                                                     *
+ *             Registration of XSLT and libxslt functions              *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltRegisterAllFunctions:
+ * @ctxt:  the XPath context
+ *
+ * Registers all default XSLT functions in this context
+ */
+void
+xsltRegisterAllFunctions(xmlXPathContextPtr ctxt)
+{
+    xmlXPathRegisterFunc(ctxt, (const xmlChar *) "current",
+                         xsltCurrentFunction);
+    xmlXPathRegisterFunc(ctxt, (const xmlChar *) "document",
+                         xsltDocumentFunction);
+    xmlXPathRegisterFunc(ctxt, (const xmlChar *) "key", xsltKeyFunction);
+    xmlXPathRegisterFunc(ctxt, (const xmlChar *) "unparsed-entity-uri",
+                         xsltUnparsedEntityURIFunction);
+    xmlXPathRegisterFunc(ctxt, (const xmlChar *) "format-number",
+                         xsltFormatNumberFunction);
+    xmlXPathRegisterFunc(ctxt, (const xmlChar *) "generate-id",
+                         xsltGenerateIdFunction);
+    xmlXPathRegisterFunc(ctxt, (const xmlChar *) "system-property",
+                         xsltSystemPropertyFunction);
+    xmlXPathRegisterFunc(ctxt, (const xmlChar *) "element-available",
+                         xsltElementAvailableFunction);
+    xmlXPathRegisterFunc(ctxt, (const xmlChar *) "function-available",
+                         xsltFunctionAvailableFunction);
+}
diff --git a/reactos/dll/3rdparty/libxslt/functions.h b/reactos/dll/3rdparty/libxslt/functions.h
new file mode 100644 (file)
index 0000000..caa4941
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Summary: interface for the XSLT functions not from XPath
+ * Description: a set of extra functions coming from XSLT but not in XPath
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard and Bjorn Reese <breese@users.sourceforge.net>
+ */
+
+#ifndef __XML_XSLT_FUNCTIONS_H__
+#define __XML_XSLT_FUNCTIONS_H__
+
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+#include "xsltexports.h"
+#include "xsltInternals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * XSLT_REGISTER_FUNCTION_LOOKUP:
+ *
+ * Registering macro, not general purpose at all but used in different modules.
+ */
+#define XSLT_REGISTER_FUNCTION_LOOKUP(ctxt)                    \
+    xmlXPathRegisterFuncLookup((ctxt)->xpathCtxt,              \
+       (xmlXPathFuncLookupFunc) xsltXPathFunctionLookup,       \
+       (void *)(ctxt->xpathCtxt));
+
+XSLTPUBFUN xmlXPathFunction XSLTCALL
+       xsltXPathFunctionLookup         (xmlXPathContextPtr ctxt,
+                                        const xmlChar *name,
+                                        const xmlChar *ns_uri);
+
+/*
+ * Interfaces for the functions implementations.
+ */
+
+XSLTPUBFUN void XSLTCALL       
+       xsltDocumentFunction            (xmlXPathParserContextPtr ctxt,
+                                        int nargs);
+XSLTPUBFUN void XSLTCALL       
+       xsltKeyFunction                 (xmlXPathParserContextPtr ctxt,
+                                        int nargs);
+XSLTPUBFUN void XSLTCALL       
+       xsltUnparsedEntityURIFunction   (xmlXPathParserContextPtr ctxt,
+                                        int nargs);
+XSLTPUBFUN void XSLTCALL       
+       xsltFormatNumberFunction        (xmlXPathParserContextPtr ctxt,
+                                        int nargs);
+XSLTPUBFUN void XSLTCALL       
+       xsltGenerateIdFunction          (xmlXPathParserContextPtr ctxt,
+                                        int nargs);
+XSLTPUBFUN void XSLTCALL       
+       xsltSystemPropertyFunction      (xmlXPathParserContextPtr ctxt,
+                                        int nargs);
+XSLTPUBFUN void XSLTCALL       
+       xsltElementAvailableFunction    (xmlXPathParserContextPtr ctxt,
+                                        int nargs);
+XSLTPUBFUN void XSLTCALL       
+       xsltFunctionAvailableFunction   (xmlXPathParserContextPtr ctxt,
+                                        int nargs);
+
+/*
+ * And the registration
+ */
+
+XSLTPUBFUN void XSLTCALL       
+       xsltRegisterAllFunctions        (xmlXPathContextPtr ctxt);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_FUNCTIONS_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/imports.c b/reactos/dll/3rdparty/libxslt/imports.c
new file mode 100644 (file)
index 0000000..8ff9f3d
--- /dev/null
@@ -0,0 +1,414 @@
+/*
+ * imports.c: Implementation of the XSLT imports
+ *
+ * Reference:
+ *   http://www.w3.org/TR/1999/REC-xslt-19991116
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_MATH_H
+#include <math.h>
+#endif
+#ifdef HAVE_FLOAT_H
+#include <float.h>
+#endif
+#ifdef HAVE_IEEEFP_H
+#include <ieeefp.h>
+#endif
+#ifdef HAVE_NAN_H
+#include <nan.h>
+#endif
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/hash.h>
+#include <libxml/xmlerror.h>
+#include <libxml/uri.h>
+#include "xslt.h"
+#include "xsltInternals.h"
+#include "xsltutils.h"
+#include "preproc.h"
+#include "imports.h"
+#include "documents.h"
+#include "security.h"
+#include "pattern.h"
+
+
+/************************************************************************
+ *                                                                     *
+ *                     Module interfaces                               *
+ *                                                                     *
+ ************************************************************************/
+/**
+ * xsltFixImportedCompSteps:
+ * @master: the "master" stylesheet
+ * @style: the stylesheet being imported by the master
+ *
+ * normalize the comp steps for the stylesheet being imported
+ * by the master, together with any imports within that. 
+ *
+ */
+static void xsltFixImportedCompSteps(xsltStylesheetPtr master, 
+                       xsltStylesheetPtr style) {
+    xsltStylesheetPtr res;
+    xmlHashScan(style->templatesHash,
+                   (xmlHashScanner) xsltNormalizeCompSteps, master);
+    master->extrasNr += style->extrasNr;
+    for (res = style->imports; res != NULL; res = res->next) {
+        xsltFixImportedCompSteps(master, res);
+    }
+}
+
+/**
+ * xsltParseStylesheetImport:
+ * @style:  the XSLT stylesheet
+ * @cur:  the import element
+ *
+ * parse an XSLT stylesheet import element
+ *
+ * Returns 0 in case of success -1 in case of failure.
+ */
+
+int
+xsltParseStylesheetImport(xsltStylesheetPtr style, xmlNodePtr cur) {
+    int ret = -1;
+    xmlDocPtr import = NULL;
+    xmlChar *base = NULL;
+    xmlChar *uriRef = NULL;
+    xmlChar *URI = NULL;
+    xsltStylesheetPtr res;
+    xsltSecurityPrefsPtr sec;
+
+    if ((cur == NULL) || (style == NULL))
+       return (ret);
+
+    uriRef = xmlGetNsProp(cur, (const xmlChar *)"href", NULL);
+    if (uriRef == NULL) {
+       xsltTransformError(NULL, style, cur,
+           "xsl:import : missing href attribute\n");
+       goto error;
+    }
+
+    base = xmlNodeGetBase(style->doc, cur);
+    URI = xmlBuildURI(uriRef, base);
+    if (URI == NULL) {
+       xsltTransformError(NULL, style, cur,
+           "xsl:import : invalid URI reference %s\n", uriRef);
+       goto error;
+    }
+
+    res = style;
+    while (res != NULL) {
+        if (res->doc == NULL)
+           break;
+       if (xmlStrEqual(res->doc->URL, URI)) {
+           xsltTransformError(NULL, style, cur,
+              "xsl:import : recursion detected on imported URL %s\n", URI);
+           goto error;
+       }
+       res = res->parent;
+    }
+
+    /*
+     * Security framework check
+     */
+    sec = xsltGetDefaultSecurityPrefs();
+    if (sec != NULL) {
+       int secres;
+
+       secres = xsltCheckRead(sec, NULL, URI);
+       if (secres == 0) {
+           xsltTransformError(NULL, NULL, NULL,
+                "xsl:import: read rights for %s denied\n",
+                            URI);
+           goto error;
+       }
+    }
+
+    import = xsltDocDefaultLoader(URI, style->dict, XSLT_PARSE_OPTIONS,
+                                  (void *) style, XSLT_LOAD_STYLESHEET);
+    if (import == NULL) {
+       xsltTransformError(NULL, style, cur,
+           "xsl:import : unable to load %s\n", URI);
+       goto error;
+    }
+
+    res = xsltParseStylesheetImportedDoc(import, style);
+    if (res != NULL) {
+       res->next = style->imports;
+       style->imports = res;
+       if (style->parent == NULL) {
+           xsltFixImportedCompSteps(style, res);
+       }
+       ret = 0;
+    } else {
+       xmlFreeDoc(import);
+       }
+
+error:
+    if (uriRef != NULL)
+       xmlFree(uriRef);
+    if (base != NULL)
+       xmlFree(base);
+    if (URI != NULL)
+       xmlFree(URI);
+
+    return (ret);
+}
+
+/**
+ * xsltParseStylesheetInclude:
+ * @style:  the XSLT stylesheet
+ * @cur:  the include node
+ *
+ * parse an XSLT stylesheet include element
+ *
+ * Returns 0 in case of success -1 in case of failure
+ */
+
+int
+xsltParseStylesheetInclude(xsltStylesheetPtr style, xmlNodePtr cur) {
+    int ret = -1;
+    xmlDocPtr oldDoc;
+    xmlChar *base = NULL;
+    xmlChar *uriRef = NULL;
+    xmlChar *URI = NULL;
+    xsltStylesheetPtr result;
+    xsltDocumentPtr include;
+    xsltDocumentPtr docptr;
+    int oldNopreproc;
+
+    if ((cur == NULL) || (style == NULL))
+       return (ret);
+
+    uriRef = xmlGetNsProp(cur, (const xmlChar *)"href", NULL);
+    if (uriRef == NULL) {
+       xsltTransformError(NULL, style, cur,
+           "xsl:include : missing href attribute\n");
+       goto error;
+    }
+
+    base = xmlNodeGetBase(style->doc, cur);
+    URI = xmlBuildURI(uriRef, base);
+    if (URI == NULL) {
+       xsltTransformError(NULL, style, cur,
+           "xsl:include : invalid URI reference %s\n", uriRef);
+       goto error;
+    }
+
+    /*
+     * in order to detect recursion, we check all previously included
+     * stylesheets.
+     */
+    docptr = style->includes;
+    while (docptr != NULL) {
+        if (xmlStrEqual(docptr->doc->URL, URI)) {
+           xsltTransformError(NULL, style, cur,
+               "xsl:include : recursion detected on included URL %s\n", URI);
+           goto error;
+       }
+       docptr = docptr->includes;
+    }
+
+    include = xsltLoadStyleDocument(style, URI);
+    if (include == NULL) {
+       xsltTransformError(NULL, style, cur,
+           "xsl:include : unable to load %s\n", URI);
+       goto error;
+    }
+#ifdef XSLT_REFACTORED    
+    if (IS_XSLT_ELEM_FAST(cur) && (cur->psvi != NULL)) {
+       ((xsltStyleItemIncludePtr) cur->psvi)->include = include;
+    } else {
+       xsltTransformError(NULL, style, cur,
+           "Internal error: (xsltParseStylesheetInclude) "
+           "The xsl:include element was not compiled.\n", URI);
+       style->errors++;
+    }
+#endif
+    oldDoc = style->doc;
+    style->doc = include->doc;
+    /* chain to stylesheet for recursion checking */
+    include->includes = style->includes;
+    style->includes = include;
+    oldNopreproc = style->nopreproc;
+    style->nopreproc = include->preproc;
+    /*
+    * TODO: This will change some values of the
+    *  including stylesheet with every included module
+    *  (e.g. excluded-result-prefixes)
+    *  We need to strictly seperate such stylesheet-owned values.
+    */
+    result = xsltParseStylesheetProcess(style, include->doc);
+    style->nopreproc = oldNopreproc;
+    include->preproc = 1;
+    style->includes = include->includes;
+    style->doc = oldDoc;
+    if (result == NULL) {
+       ret = -1;
+       goto error;
+    }
+    ret = 0;
+
+error:
+    if (uriRef != NULL)
+       xmlFree(uriRef);
+    if (base != NULL)
+       xmlFree(base);
+    if (URI != NULL)
+       xmlFree(URI);
+
+    return (ret);
+}
+
+/**
+ * xsltNextImport:
+ * @cur:  the current XSLT stylesheet
+ *
+ * Find the next stylesheet in import precedence.
+ *
+ * Returns the next stylesheet or NULL if it was the last one
+ */
+
+xsltStylesheetPtr
+xsltNextImport(xsltStylesheetPtr cur) {
+    if (cur == NULL)
+       return(NULL);
+    if (cur->imports != NULL)
+       return(cur->imports);
+    if (cur->next != NULL)
+       return(cur->next) ;
+    do {
+       cur = cur->parent;
+       if (cur == NULL) break;
+       if (cur->next != NULL) return(cur->next);
+    } while (cur != NULL);
+    return(cur);
+}
+
+/**
+ * xsltNeedElemSpaceHandling:
+ * @ctxt:  an XSLT transformation context
+ *
+ * Checks whether that stylesheet requires white-space stripping
+ *
+ * Returns 1 if space should be stripped, 0 if not
+ */
+
+int
+xsltNeedElemSpaceHandling(xsltTransformContextPtr ctxt) {
+    xsltStylesheetPtr style;
+
+    if (ctxt == NULL)
+       return(0);
+    style = ctxt->style;
+    while (style != NULL) {
+       if (style->stripSpaces != NULL)
+           return(1);
+       style = xsltNextImport(style);
+    }
+    return(0);
+}
+
+/**
+ * xsltFindElemSpaceHandling:
+ * @ctxt:  an XSLT transformation context
+ * @node:  an XML node
+ *
+ * Find strip-space or preserve-space informations for an element
+ * respect the import precedence or the wildcards
+ *
+ * Returns 1 if space should be stripped, 0 if not, and 2 if everything
+ *         should be CDTATA wrapped.
+ */
+
+int
+xsltFindElemSpaceHandling(xsltTransformContextPtr ctxt, xmlNodePtr node) {
+    xsltStylesheetPtr style;
+    const xmlChar *val;
+
+    if ((ctxt == NULL) || (node == NULL))
+       return(0);
+    style = ctxt->style;
+    while (style != NULL) {
+       if (node->ns != NULL) {
+           val = (const xmlChar *)
+             xmlHashLookup2(style->stripSpaces, node->name, node->ns->href);
+       } else {
+           val = (const xmlChar *)
+                 xmlHashLookup2(style->stripSpaces, node->name, NULL);
+       }
+       if (val != NULL) {
+           if (xmlStrEqual(val, (xmlChar *) "strip"))
+               return(1);
+           if (xmlStrEqual(val, (xmlChar *) "preserve"))
+               return(0);
+       } 
+       if (style->stripAll == 1)
+           return(1);
+       if (style->stripAll == -1)
+           return(0);
+
+       style = xsltNextImport(style);
+    }
+    return(0);
+}
+
+/**
+ * xsltFindTemplate:
+ * @ctxt:  an XSLT transformation context
+ * @name: the template name
+ * @nameURI: the template name URI
+ *
+ * Finds the named template, apply import precedence rule.
+ * REVISIT TODO: We'll change the nameURI fields of
+ *  templates to be in the string dict, so if the
+ *  specified @nameURI is in the same dict, then use pointer
+ *  comparison. Check if this can be done in a sane way.
+ *  Maybe this function is not needed internally at
+ *  transformation-time if we hard-wire the called templates
+ *  to the caller.
+ *
+ * Returns the xsltTemplatePtr or NULL if not found
+ */
+xsltTemplatePtr
+xsltFindTemplate(xsltTransformContextPtr ctxt, const xmlChar *name,
+                const xmlChar *nameURI) {
+    xsltTemplatePtr cur;
+    xsltStylesheetPtr style;
+
+    if ((ctxt == NULL) || (name == NULL))
+       return(NULL);
+    style = ctxt->style;
+    while (style != NULL) {
+       cur = style->templates;
+       while (cur != NULL) {
+           if (xmlStrEqual(name, cur->name)) {
+               if (((nameURI == NULL) && (cur->nameURI == NULL)) ||
+                   ((nameURI != NULL) && (cur->nameURI != NULL) &&
+                    (xmlStrEqual(nameURI, cur->nameURI)))) {
+                   return(cur);
+               }
+           }
+           cur = cur->next;
+       }
+
+       style = xsltNextImport(style);
+    }
+    return(NULL);
+}
+
diff --git a/reactos/dll/3rdparty/libxslt/imports.h b/reactos/dll/3rdparty/libxslt/imports.h
new file mode 100644 (file)
index 0000000..38656f1
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Summary: interface for the XSLT import support
+ * Description: macros and fuctions needed to implement and
+ *              access the import tree
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_IMPORTS_H__
+#define __XML_XSLT_IMPORTS_H__
+
+#include <libxml/tree.h>
+#include "xsltexports.h"
+#include "xsltInternals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * XSLT_GET_IMPORT_PTR:
+ *
+ * A macro to import pointers from the stylesheet cascading order.
+ */
+#define XSLT_GET_IMPORT_PTR(res, style, name) {                        \
+    xsltStylesheetPtr st = style;                              \
+    res = NULL;                                                        \
+    while (st != NULL) {                                       \
+       if (st->name != NULL) { res = st->name; break; }        \
+       st = xsltNextImport(st);                                \
+    }}
+
+/**
+ * XSLT_GET_IMPORT_INT:
+ *
+ * A macro to import intergers from the stylesheet cascading order.
+ */
+#define XSLT_GET_IMPORT_INT(res, style, name) {                        \
+    xsltStylesheetPtr st = style;                              \
+    res = -1;                                                  \
+    while (st != NULL) {                                       \
+       if (st->name != -1) { res = st->name; break; }  \
+       st = xsltNextImport(st);                                \
+    }}
+
+/*
+ * Module interfaces
+ */
+XSLTPUBFUN int XSLTCALL                        
+                       xsltParseStylesheetImport(xsltStylesheetPtr style,
+                                                 xmlNodePtr cur);
+XSLTPUBFUN int XSLTCALL                        
+                       xsltParseStylesheetInclude
+                                                (xsltStylesheetPtr style,
+                                                 xmlNodePtr cur);
+XSLTPUBFUN xsltStylesheetPtr XSLTCALL  
+                       xsltNextImport           (xsltStylesheetPtr style);
+XSLTPUBFUN int XSLTCALL                        
+                       xsltNeedElemSpaceHandling(xsltTransformContextPtr ctxt);
+XSLTPUBFUN int XSLTCALL                        
+                       xsltFindElemSpaceHandling(xsltTransformContextPtr ctxt,
+                                                 xmlNodePtr node);
+XSLTPUBFUN xsltTemplatePtr XSLTCALL            
+                       xsltFindTemplate         (xsltTransformContextPtr ctxt,
+                                                 const xmlChar *name,
+                                                 const xmlChar *nameURI);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_IMPORTS_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/keys.c b/reactos/dll/3rdparty/libxslt/keys.c
new file mode 100644 (file)
index 0000000..583495d
--- /dev/null
@@ -0,0 +1,916 @@
+/*
+ * keys.c: Implemetation of the keys support
+ *
+ * Reference:
+ *   http://www.w3.org/TR/1999/REC-xslt-19991116
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/valid.h>
+#include <libxml/hash.h>
+#include <libxml/xmlerror.h>
+#include <libxml/parserInternals.h>
+#include <libxml/xpathInternals.h>
+#include "xslt.h"
+#include "xsltInternals.h"
+#include "xsltutils.h"
+#include "imports.h"
+#include "templates.h"
+#include "keys.h"
+
+#ifdef WITH_XSLT_DEBUG
+#define WITH_XSLT_DEBUG_KEYS
+#endif
+
+static int
+xsltInitDocKeyTable(xsltTransformContextPtr ctxt, const xmlChar *name,
+                    const xmlChar *nameURI);
+
+/************************************************************************
+ *                                                                     *
+ *                     Type functions                                  *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltNewKeyDef:
+ * @name:  the key name or NULL
+ * @nameURI:  the name URI or NULL
+ *
+ * Create a new XSLT KeyDef
+ *
+ * Returns the newly allocated xsltKeyDefPtr or NULL in case of error
+ */
+static xsltKeyDefPtr
+xsltNewKeyDef(const xmlChar *name, const xmlChar *nameURI) {
+    xsltKeyDefPtr cur;
+
+    cur = (xsltKeyDefPtr) xmlMalloc(sizeof(xsltKeyDef));
+    if (cur == NULL) {
+       xsltTransformError(NULL, NULL, NULL,
+               "xsltNewKeyDef : malloc failed\n");
+       return(NULL);
+    }
+    memset(cur, 0, sizeof(xsltKeyDef));
+    if (name != NULL)
+       cur->name = xmlStrdup(name);
+    if (nameURI != NULL)
+       cur->nameURI = xmlStrdup(nameURI);
+    cur->nsList = NULL;
+    return(cur);
+}
+
+/**
+ * xsltFreeKeyDef:
+ * @keyd:  an XSLT key definition
+ *
+ * Free up the memory allocated by @keyd
+ */
+static void
+xsltFreeKeyDef(xsltKeyDefPtr keyd) {
+    if (keyd == NULL)
+       return;
+    if (keyd->comp != NULL)
+       xmlXPathFreeCompExpr(keyd->comp);
+    if (keyd->usecomp != NULL)
+       xmlXPathFreeCompExpr(keyd->usecomp);
+    if (keyd->name != NULL)
+       xmlFree(keyd->name);
+    if (keyd->nameURI != NULL)
+       xmlFree(keyd->nameURI);
+    if (keyd->match != NULL)
+       xmlFree(keyd->match);
+    if (keyd->use != NULL)
+       xmlFree(keyd->use);
+    if (keyd->nsList != NULL)
+        xmlFree(keyd->nsList);
+    memset(keyd, -1, sizeof(xsltKeyDef));
+    xmlFree(keyd);
+}
+
+/**
+ * xsltFreeKeyDefList:
+ * @keyd:  an XSLT key definition list
+ *
+ * Free up the memory allocated by all the elements of @keyd
+ */
+static void
+xsltFreeKeyDefList(xsltKeyDefPtr keyd) {
+    xsltKeyDefPtr cur;
+
+    while (keyd != NULL) {
+       cur = keyd;
+       keyd = keyd->next;
+       xsltFreeKeyDef(cur);
+    }
+}
+
+/**
+ * xsltNewKeyTable:
+ * @name:  the key name or NULL
+ * @nameURI:  the name URI or NULL
+ *
+ * Create a new XSLT KeyTable
+ *
+ * Returns the newly allocated xsltKeyTablePtr or NULL in case of error
+ */
+static xsltKeyTablePtr
+xsltNewKeyTable(const xmlChar *name, const xmlChar *nameURI) {
+    xsltKeyTablePtr cur;
+
+    cur = (xsltKeyTablePtr) xmlMalloc(sizeof(xsltKeyTable));
+    if (cur == NULL) {
+       xsltTransformError(NULL, NULL, NULL,
+               "xsltNewKeyTable : malloc failed\n");
+       return(NULL);
+    }
+    memset(cur, 0, sizeof(xsltKeyTable));
+    if (name != NULL)
+       cur->name = xmlStrdup(name);
+    if (nameURI != NULL)
+       cur->nameURI = xmlStrdup(nameURI);
+    cur->keys = xmlHashCreate(0);
+    return(cur);
+}
+
+/**
+ * xsltFreeKeyTable:
+ * @keyt:  an XSLT key table
+ *
+ * Free up the memory allocated by @keyt
+ */
+static void
+xsltFreeKeyTable(xsltKeyTablePtr keyt) {
+    if (keyt == NULL)
+       return;
+    if (keyt->name != NULL)
+       xmlFree(keyt->name);
+    if (keyt->nameURI != NULL)
+       xmlFree(keyt->nameURI);
+    if (keyt->keys != NULL)
+       xmlHashFree(keyt->keys, 
+                   (xmlHashDeallocator) xmlXPathFreeNodeSet);
+    memset(keyt, -1, sizeof(xsltKeyTable));
+    xmlFree(keyt);
+}
+
+/**
+ * xsltFreeKeyTableList:
+ * @keyt:  an XSLT key table list
+ *
+ * Free up the memory allocated by all the elements of @keyt
+ */
+static void
+xsltFreeKeyTableList(xsltKeyTablePtr keyt) {
+    xsltKeyTablePtr cur;
+
+    while (keyt != NULL) {
+       cur = keyt;
+       keyt = keyt->next;
+       xsltFreeKeyTable(cur);
+    }
+}
+
+/************************************************************************
+ *                                                                     *
+ *             The interpreter for the precompiled patterns            *
+ *                                                                     *
+ ************************************************************************/
+
+
+/**
+ * xsltFreeKeys:
+ * @style: an XSLT stylesheet
+ *
+ * Free up the memory used by XSLT keys in a stylesheet
+ */
+void
+xsltFreeKeys(xsltStylesheetPtr style) {
+    if (style->keys)
+       xsltFreeKeyDefList((xsltKeyDefPtr) style->keys);
+}
+
+/**
+ * skipString:
+ * @cur: the current pointer
+ * @end: the current offset
+ *
+ * skip a string delimited by " or '
+ *
+ * Returns the byte after the string or -1 in case of error
+ */
+static int
+skipString(const xmlChar *cur, int end) {
+    xmlChar limit;
+
+    if ((cur == NULL) || (end < 0)) return(-1);
+    if ((cur[end] == '\'') || (cur[end] == '"')) limit = cur[end];
+    else return(end);
+    end++;
+    while (cur[end] != 0) {
+        if (cur[end] == limit)
+           return(end + 1);
+       end++;
+    }
+    return(-1);
+}
+
+/**
+ * skipPredicate:
+ * @cur: the current pointer
+ * @end: the current offset
+ *
+ * skip a predicate
+ *
+ * Returns the byte after the predicate or -1 in case of error
+ */
+static int
+skipPredicate(const xmlChar *cur, int end) {
+    if ((cur == NULL) || (end < 0)) return(-1);
+    if (cur[end] != '[') return(end);
+    end++;
+    while (cur[end] != 0) {
+        if ((cur[end] == '\'') || (cur[end] == '"')) {
+           end = skipString(cur, end);
+           if (end <= 0)
+               return(-1);
+           continue;
+       } else if (cur[end] == '[') {
+           end = skipPredicate(cur, end);
+           if (end <= 0)
+               return(-1);
+           continue;
+       } else if (cur[end] == ']')
+           return(end + 1);
+       end++;
+    }
+    return(-1);
+}
+
+/**
+ * xsltAddKey:
+ * @style: an XSLT stylesheet
+ * @name:  the key name or NULL
+ * @nameURI:  the name URI or NULL
+ * @match:  the match value
+ * @use:  the use value
+ * @inst: the key instruction
+ *
+ * add a key definition to a stylesheet
+ *
+ * Returns 0 in case of success, and -1 in case of failure.
+ */
+int
+xsltAddKey(xsltStylesheetPtr style, const xmlChar *name,
+          const xmlChar *nameURI, const xmlChar *match,
+          const xmlChar *use, xmlNodePtr inst) {
+    xsltKeyDefPtr key;
+    xmlChar *pattern = NULL;
+    int current, end, start, i = 0;
+
+    if ((style == NULL) || (name == NULL) || (match == NULL) || (use == NULL))
+       return(-1);
+
+#ifdef WITH_XSLT_DEBUG_KEYS
+    xsltGenericDebug(xsltGenericDebugContext,
+       "Add key %s, match %s, use %s\n", name, match, use);
+#endif
+
+    key = xsltNewKeyDef(name, nameURI);
+    key->match = xmlStrdup(match);
+    key->use = xmlStrdup(use);
+    key->inst = inst;
+    key->nsList = xmlGetNsList(inst->doc, inst);
+    if (key->nsList != NULL) {
+        while (key->nsList[i] != NULL)
+           i++;
+    }
+    key->nsNr = i;
+
+    /*
+     * Split the | and register it as as many keys
+     */
+    current = end = 0;
+    while (match[current] != 0) {
+       start = current;
+       while (IS_BLANK_CH(match[current]))
+           current++;
+       end = current;
+       while ((match[end] != 0) && (match[end] != '|')) {
+           if (match[end] == '[') {
+               end = skipPredicate(match, end);
+               if (end <= 0) {
+                   xsltTransformError(NULL, style, inst,
+                                      "key pattern is malformed: %s",
+                                      key->match);
+                   if (style != NULL) style->errors++;
+                   goto error;
+               }
+           } else
+               end++;
+       }
+       if (current == end) {
+           xsltTransformError(NULL, style, inst,
+                              "key pattern is empty\n");
+           if (style != NULL) style->errors++;
+           goto error;
+       }
+       if (match[start] != '/') {
+           pattern = xmlStrcat(pattern, (xmlChar *)"//");
+           if (pattern == NULL) {
+               if (style != NULL) style->errors++;
+               goto error;
+           }
+       }
+       pattern = xmlStrncat(pattern, &match[start], end - start);
+       if (pattern == NULL) {
+           if (style != NULL) style->errors++;
+           goto error;
+       }
+
+       if (match[end] == '|') {
+           pattern = xmlStrcat(pattern, (xmlChar *)"|");
+           end++;
+       }
+       current = end;
+    }
+#ifdef WITH_XSLT_DEBUG_KEYS
+    xsltGenericDebug(xsltGenericDebugContext,
+       "   resulting pattern %s\n", pattern);
+#endif
+    /*
+    * XSLT-1: "It is an error for the value of either the use
+    *  attribute or the match attribute to contain a
+    *  VariableReference."
+    * TODO: We should report a variable-reference at compile-time.
+    *   Maybe a search for "$", if it occurs outside of quotation
+    *   marks, could be sufficient.
+    */
+    key->comp = xsltXPathCompile(style, pattern);
+    if (key->comp == NULL) {
+       xsltTransformError(NULL, style, inst,
+               "xsl:key : XPath pattern compilation failed '%s'\n",
+                        pattern);
+       if (style != NULL) style->errors++;
+    }
+    key->usecomp = xsltXPathCompile(style, use);
+    if (key->usecomp == NULL) {
+       xsltTransformError(NULL, style, inst,
+               "xsl:key : XPath pattern compilation failed '%s'\n",
+                        use);
+       if (style != NULL) style->errors++;
+    }
+
+    /*
+     * Sometimes the stylesheet writer use the order to ease the
+     * resolution of keys when they are dependant, keep the provided
+     * order so add the new one at the end.
+     */
+    if (style->keys == NULL) {
+       style->keys = key;
+    } else {
+        xsltKeyDefPtr prev = style->keys;
+
+       while (prev->next != NULL)
+           prev = prev->next;
+
+       prev->next = key;
+    }
+    key->next = NULL;
+
+error:
+    if (pattern != NULL)
+       xmlFree(pattern);
+    return(0);
+}
+
+/**
+ * xsltGetKey:
+ * @ctxt: an XSLT transformation context
+ * @name:  the key name or NULL
+ * @nameURI:  the name URI or NULL
+ * @value:  the key value to look for
+ *
+ * Looks up a key of the in current source doc (the document info
+ * on @ctxt->document). Computes the key if not already done
+ * for the current source doc.
+ *
+ * Returns the nodeset resulting from the query or NULL
+ */
+xmlNodeSetPtr
+xsltGetKey(xsltTransformContextPtr ctxt, const xmlChar *name,
+          const xmlChar *nameURI, const xmlChar *value) {
+    xmlNodeSetPtr ret;
+    xsltKeyTablePtr table;
+    int init_table = 0;
+
+    if ((ctxt == NULL) || (name == NULL) || (value == NULL) ||
+       (ctxt->document == NULL))
+       return(NULL);
+
+#ifdef WITH_XSLT_DEBUG_KEYS
+    xsltGenericDebug(xsltGenericDebugContext,
+       "Get key %s, value %s\n", name, value);
+#endif
+
+    /*
+     * keys are computed only on-demand on first key access for a document
+     */
+    if ((ctxt->document->nbKeysComputed < ctxt->nbKeys) &&
+        (ctxt->keyInitLevel == 0)) {
+        /*
+        * If non-recursive behaviour, just try to initialize all keys
+        */
+       if (xsltInitAllDocKeys(ctxt))
+           return(NULL);
+    }
+
+retry:
+    table = (xsltKeyTablePtr) ctxt->document->keys;
+    while (table != NULL) {
+       if (((nameURI != NULL) == (table->nameURI != NULL)) &&
+           xmlStrEqual(table->name, name) &&
+           xmlStrEqual(table->nameURI, nameURI))
+       {
+           ret = (xmlNodeSetPtr)xmlHashLookup(table->keys, value);
+           return(ret);
+       }
+       table = table->next;
+    }
+
+    if ((ctxt->keyInitLevel != 0) && (init_table == 0)) {
+        /*
+        * Apparently one key is recursive and this one is needed,
+        * initialize just it, that time and retry
+        */
+        xsltInitDocKeyTable(ctxt, name, nameURI);
+       init_table = 1;
+       goto retry;
+    }
+
+    return(NULL);
+}
+
+
+/**
+ * xsltInitDocKeyTable:
+ *
+ * INTERNAL ROUTINE ONLY
+ *
+ * Check if any keys on the current document need to be computed
+ */
+static int
+xsltInitDocKeyTable(xsltTransformContextPtr ctxt, const xmlChar *name,
+                    const xmlChar *nameURI)
+{
+    xsltStylesheetPtr style;
+    xsltKeyDefPtr keyd = NULL;
+    int found = 0;
+
+#ifdef KEY_INIT_DEBUG
+fprintf(stderr, "xsltInitDocKeyTable %s\n", name);
+#endif
+
+    style = ctxt->style;
+    while (style != NULL) {
+       keyd = (xsltKeyDefPtr) style->keys;
+       while (keyd != NULL) {
+           if (((keyd->nameURI != NULL) ==
+                (nameURI != NULL)) &&
+               xmlStrEqual(keyd->name, name) &&
+               xmlStrEqual(keyd->nameURI, nameURI))
+           {
+               xsltInitCtxtKey(ctxt, ctxt->document, keyd);
+               if (ctxt->document->nbKeysComputed == ctxt->nbKeys)
+                   return(0);
+               found = 1;
+           }
+           keyd = keyd->next;
+       }
+       style = xsltNextImport(style);
+    }
+    if (found == 0) {
+#ifdef WITH_XSLT_DEBUG_KEYS
+       XSLT_TRACE(ctxt,XSLT_TRACE_KEYS,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltInitDocKeyTable: did not found %s\n", name));
+#endif
+       xsltTransformError(ctxt, NULL, keyd->inst,
+           "Failed to find key definition for %s\n", name);
+       ctxt->state = XSLT_STATE_STOPPED;
+        return(-1);
+    }
+#ifdef KEY_INIT_DEBUG
+fprintf(stderr, "xsltInitDocKeyTable %s done\n", name);
+#endif
+    return(0);
+}
+
+/**
+ * xsltInitAllDocKeys:
+ *
+ * INTERNAL ROUTINE ONLY
+ *
+ * Check if any keys on the current document need to be computed
+ */
+int
+xsltInitAllDocKeys(xsltTransformContextPtr ctxt)
+{
+    xsltStylesheetPtr style;
+    xsltKeyDefPtr keyd;
+    xsltKeyTablePtr table;
+
+    if (ctxt == NULL)
+       return(-1);
+
+#ifdef KEY_INIT_DEBUG
+fprintf(stderr, "xsltInitAllDocKeys %d %d\n",
+        ctxt->document->nbKeysComputed, ctxt->nbKeys);
+#endif
+
+    if (ctxt->document->nbKeysComputed == ctxt->nbKeys)
+       return(0);
+
+
+    /*
+    * TODO: This could be further optimized
+    */
+    style = ctxt->style;
+    while (style) {
+       keyd = (xsltKeyDefPtr) style->keys;
+       while (keyd != NULL) {
+#ifdef KEY_INIT_DEBUG
+fprintf(stderr, "Init key %s\n", keyd->name);
+#endif
+           /*
+           * Check if keys with this QName have been already
+           * computed.
+           */
+           table = (xsltKeyTablePtr) ctxt->document->keys;
+           while (table) {
+               if (((keyd->nameURI != NULL) == (table->nameURI != NULL)) &&
+                   xmlStrEqual(keyd->name, table->name) &&
+                   xmlStrEqual(keyd->nameURI, table->nameURI))
+               {
+                   break;
+               }
+               table = table->next;
+           }
+           if (table == NULL) {
+               /*
+               * Keys with this QName have not been yet computed.
+               */
+               xsltInitDocKeyTable(ctxt, keyd->name, keyd->nameURI);
+           }
+           keyd = keyd->next;
+       }
+       style = xsltNextImport(style);
+    }
+#ifdef KEY_INIT_DEBUG
+fprintf(stderr, "xsltInitAllDocKeys: done\n");
+#endif
+    return(0);
+}
+
+/**
+ * xsltInitCtxtKey:
+ * @ctxt: an XSLT transformation context
+ * @idoc:  the document information (holds key values)
+ * @keyDef: the key definition
+ *
+ * Computes the key tables this key and for the current input document.
+ *
+ * Returns: 0 on success, -1 on error
+ */
+int
+xsltInitCtxtKey(xsltTransformContextPtr ctxt, xsltDocumentPtr idoc,
+               xsltKeyDefPtr keyDef)
+{
+    int i, len, k;
+    xmlNodeSetPtr matchList = NULL, keylist;
+    xmlXPathObjectPtr matchRes = NULL, useRes = NULL;
+    xmlChar *str = NULL;
+    xsltKeyTablePtr table;
+    xmlNodePtr oldInst, cur;
+    xmlNodePtr oldContextNode;
+    xsltDocumentPtr oldDocInfo;
+    int        oldXPPos, oldXPSize;
+    xmlDocPtr oldXPDoc;
+    int oldXPNsNr;
+    xmlNsPtr *oldXPNamespaces;
+    xmlXPathContextPtr xpctxt;
+
+#ifdef KEY_INIT_DEBUG
+fprintf(stderr, "xsltInitCtxtKey %s : %d\n", keyDef->name, ctxt->keyInitLevel);
+#endif
+
+    if ((keyDef->comp == NULL) || (keyDef->usecomp == NULL))
+       return(-1);
+
+    /*
+     * Detect recursive keys
+     */
+    if (ctxt->keyInitLevel > ctxt->nbKeys) {
+#ifdef WITH_XSLT_DEBUG_KEYS
+       XSLT_TRACE(ctxt,XSLT_TRACE_KEYS,
+                  xsltGenericDebug(xsltGenericDebugContext,
+                      "xsltInitCtxtKey: key definition of %s is recursive\n",
+                      keyDef->name));
+#endif
+       xsltTransformError(ctxt, NULL, keyDef->inst,
+           "Key definition for %s is recursive\n", keyDef->name);
+       ctxt->state = XSLT_STATE_STOPPED;
+        return(-1);
+    }
+    ctxt->keyInitLevel++;
+
+    xpctxt = ctxt->xpathCtxt;
+    idoc->nbKeysComputed++;
+    /*
+    * Save context state.
+    */
+    oldInst = ctxt->inst;
+    oldDocInfo = ctxt->document;
+    oldContextNode = ctxt->node;
+
+    oldXPDoc = xpctxt->doc;
+    oldXPPos = xpctxt->proximityPosition;
+    oldXPSize = xpctxt->contextSize;
+    oldXPNsNr = xpctxt->nsNr;
+    oldXPNamespaces = xpctxt->namespaces;
+
+    /*
+    * Set up contexts.
+    */
+    ctxt->document = idoc;
+    ctxt->node = (xmlNodePtr) idoc->doc;
+    ctxt->inst = keyDef->inst;
+
+    xpctxt->doc = idoc->doc;
+    xpctxt->node = (xmlNodePtr) idoc->doc;
+    /* TODO : clarify the use of namespaces in keys evaluation */
+    xpctxt->namespaces = keyDef->nsList;
+    xpctxt->nsNr = keyDef->nsNr;
+
+    /*
+    * Evaluate the 'match' expression of the xsl:key.
+    * TODO: The 'match' is a *pattern*.
+    */
+    matchRes = xmlXPathCompiledEval(keyDef->comp, xpctxt);
+    if (matchRes == NULL) {
+
+#ifdef WITH_XSLT_DEBUG_KEYS
+       XSLT_TRACE(ctxt,XSLT_TRACE_KEYS,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltInitCtxtKey: %s evaluation failed\n", keyDef->match));
+#endif
+       xsltTransformError(ctxt, NULL, keyDef->inst,
+           "Failed to evaluate the 'match' expression.\n");
+       ctxt->state = XSLT_STATE_STOPPED;
+       goto error;
+    } else {
+       if (matchRes->type == XPATH_NODESET) {
+           matchList = matchRes->nodesetval;
+
+#ifdef WITH_XSLT_DEBUG_KEYS
+           if (matchList != NULL)
+               XSLT_TRACE(ctxt,XSLT_TRACE_KEYS,xsltGenericDebug(xsltGenericDebugContext,
+                    "xsltInitCtxtKey: %s evaluates to %d nodes\n",
+                                keyDef->match, matchList->nodeNr));
+#endif
+       } else {
+           /*
+           * Is not a node set, but must be.
+           */
+#ifdef WITH_XSLT_DEBUG_KEYS
+           XSLT_TRACE(ctxt,XSLT_TRACE_KEYS,xsltGenericDebug(xsltGenericDebugContext,
+                "xsltInitCtxtKey: %s is not a node set\n", keyDef->match));
+#endif
+           xsltTransformError(ctxt, NULL, keyDef->inst,
+               "The 'match' expression did not evaluate to a node set.\n");
+           ctxt->state = XSLT_STATE_STOPPED;
+           goto error;
+       }
+    }
+    if ((matchList == NULL) || (matchList->nodeNr <= 0))
+       goto exit;
+
+    /**
+     * Multiple key definitions for the same name are allowed, so
+     * we must check if the key is already present for this doc
+     */
+    table = (xsltKeyTablePtr) idoc->keys;
+    while (table != NULL) {
+        if (xmlStrEqual(table->name, keyDef->name) &&
+           (((keyDef->nameURI == NULL) && (table->nameURI == NULL)) ||
+            ((keyDef->nameURI != NULL) && (table->nameURI != NULL) &&
+             (xmlStrEqual(table->nameURI, keyDef->nameURI)))))
+           break;
+       table = table->next;
+    }
+    /**
+     * If the key was not previously defined, create it now and
+     * chain it to the list of keys for the doc
+     */
+    if (table == NULL) {
+        table = xsltNewKeyTable(keyDef->name, keyDef->nameURI);
+        if (table == NULL)
+           goto error;
+        table->next = idoc->keys;
+        idoc->keys = table;
+    }
+
+    /*
+    * SPEC XSLT 1.0 (XSLT 2.0 does not clarify the context size!)
+    * "...the use attribute of the xsl:key element is evaluated with x as
+    "  the current node and with a node list containing just x as the
+    *  current node list"
+    */
+    xpctxt->contextSize = 1;
+    xpctxt->proximityPosition = 1;
+
+    for (i = 0; i < matchList->nodeNr; i++) {
+       cur = matchList->nodeTab[i];
+       if (! IS_XSLT_REAL_NODE(cur))
+           continue;
+       xpctxt->node = cur;
+       /*
+       * Process the 'use' of the xsl:key.
+       * SPEC XSLT 1.0:
+       * "The use attribute is an expression specifying the values of
+       *  the key; the expression is evaluated once for each node that
+       *  matches the pattern."
+       */
+       if (useRes != NULL)
+           xmlXPathFreeObject(useRes);
+       useRes = xmlXPathCompiledEval(keyDef->usecomp, xpctxt);
+       if (useRes == NULL) {
+           xsltTransformError(ctxt, NULL, keyDef->inst,
+               "Failed to evaluate the 'use' expression.\n");
+           ctxt->state = XSLT_STATE_STOPPED;
+           break;
+       }
+       if (useRes->type == XPATH_NODESET) {
+           if ((useRes->nodesetval != NULL) &&
+               (useRes->nodesetval->nodeNr != 0))
+           {
+               len = useRes->nodesetval->nodeNr;
+               str = xmlXPathCastNodeToString(useRes->nodesetval->nodeTab[0]);
+           } else {
+               continue;
+           }
+       } else {
+           len = 1;
+           if (useRes->type == XPATH_STRING) {
+               /*
+               * Consume the string value.
+               */
+               str = useRes->stringval;
+               useRes->stringval = NULL;
+           } else {
+               str = xmlXPathCastToString(useRes);
+           }
+       }
+       /*
+       * Process all strings.
+       */
+       k = 0;
+       while (1) {
+           if (str == NULL)
+               goto next_string;
+
+#ifdef WITH_XSLT_DEBUG_KEYS
+           XSLT_TRACE(ctxt,XSLT_TRACE_KEYS,xsltGenericDebug(xsltGenericDebugContext,
+               "xsl:key : node associated to ('%s', '%s')\n", keyDef->name, str));
+#endif
+
+           keylist = xmlHashLookup(table->keys, str);
+           if (keylist == NULL) {
+               keylist = xmlXPathNodeSetCreate(cur);
+               if (keylist == NULL)
+                   goto error;
+               xmlHashAddEntry(table->keys, str, keylist);
+           } else {
+               /*
+               * TODO: How do we know if this function failed?
+               */
+               xmlXPathNodeSetAdd(keylist, cur);
+           }
+           switch (cur->type) {
+               case XML_ELEMENT_NODE:
+               case XML_TEXT_NODE:
+               case XML_CDATA_SECTION_NODE:
+               case XML_PI_NODE:
+               case XML_COMMENT_NODE:
+                   cur->psvi = keyDef;
+                   break;
+               case XML_ATTRIBUTE_NODE:
+                   ((xmlAttrPtr) cur)->psvi = keyDef;
+                   break;
+               case XML_DOCUMENT_NODE:
+               case XML_HTML_DOCUMENT_NODE:
+                   ((xmlDocPtr) cur)->psvi = keyDef;
+                   break;
+               default:
+                   break;
+           }
+           xmlFree(str);
+           str = NULL;
+
+next_string:
+           k++;
+           if (k >= len)
+               break;
+           str = xmlXPathCastNodeToString(useRes->nodesetval->nodeTab[k]);
+       }
+    }
+
+exit:
+error:
+    ctxt->keyInitLevel--;
+    /*
+    * Restore context state.
+    */
+    xpctxt->doc = oldXPDoc;
+    xpctxt->nsNr = oldXPNsNr;
+    xpctxt->namespaces = oldXPNamespaces;
+    xpctxt->proximityPosition = oldXPPos;
+    xpctxt->contextSize = oldXPSize;
+
+    ctxt->node = oldContextNode;
+    ctxt->document = oldDocInfo;
+    ctxt->inst = oldInst;
+
+    if (str)
+       xmlFree(str);
+    if (useRes != NULL)
+       xmlXPathFreeObject(useRes);
+    if (matchRes != NULL)
+       xmlXPathFreeObject(matchRes);
+    return(0);
+}
+
+/**
+ * xsltInitCtxtKeys:
+ * @ctxt:  an XSLT transformation context
+ * @idoc:  a document info
+ *
+ * Computes all the keys tables for the current input document.
+ * Should be done before global varibales are initialized.
+ * NOTE: Not used anymore in the refactored code.
+ */
+void
+xsltInitCtxtKeys(xsltTransformContextPtr ctxt, xsltDocumentPtr idoc) {
+    xsltStylesheetPtr style;
+    xsltKeyDefPtr keyDef;
+
+    if ((ctxt == NULL) || (idoc == NULL))
+       return;
+
+#ifdef KEY_INIT_DEBUG
+fprintf(stderr, "xsltInitCtxtKeys on document\n");
+#endif
+
+#ifdef WITH_XSLT_DEBUG_KEYS
+    if ((idoc->doc != NULL) && (idoc->doc->URL != NULL))
+       XSLT_TRACE(ctxt,XSLT_TRACE_KEYS,xsltGenericDebug(xsltGenericDebugContext, "Initializing keys on %s\n",
+                    idoc->doc->URL));
+#endif
+    style = ctxt->style;
+    while (style != NULL) {
+       keyDef = (xsltKeyDefPtr) style->keys;
+       while (keyDef != NULL) {
+           xsltInitCtxtKey(ctxt, idoc, keyDef);
+
+           keyDef = keyDef->next;
+       }
+
+       style = xsltNextImport(style);
+    }
+
+#ifdef KEY_INIT_DEBUG
+fprintf(stderr, "xsltInitCtxtKeys on document: done\n");
+#endif
+
+}
+
+/**
+ * xsltFreeDocumentKeys:
+ * @idoc: a XSLT document
+ *
+ * Free the keys associated to a document
+ */
+void
+xsltFreeDocumentKeys(xsltDocumentPtr idoc) {
+    if (idoc != NULL)
+        xsltFreeKeyTableList(idoc->keys);
+}
+
diff --git a/reactos/dll/3rdparty/libxslt/keys.h b/reactos/dll/3rdparty/libxslt/keys.h
new file mode 100644 (file)
index 0000000..9182baa
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Summary:  interface for the key matching used in key() and template matches.
+ * Description: implementation of the key mechanims.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_KEY_H__
+#define __XML_XSLT_KEY_H__
+
+#include <libxml/xpath.h>
+#include "xsltexports.h"
+#include "xsltInternals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * NODE_IS_KEYED:
+ *
+ * check for bit 15 set
+ */
+#define NODE_IS_KEYED (1 >> 15)
+
+XSLTPUBFUN int XSLTCALL
+               xsltAddKey              (xsltStylesheetPtr style,
+                                        const xmlChar *name,
+                                        const xmlChar *nameURI,
+                                        const xmlChar *match,
+                                        const xmlChar *use,
+                                        xmlNodePtr inst);
+XSLTPUBFUN xmlNodeSetPtr XSLTCALL      
+               xsltGetKey              (xsltTransformContextPtr ctxt,
+                                        const xmlChar *name,
+                                        const xmlChar *nameURI,
+                                        const xmlChar *value);
+XSLTPUBFUN void XSLTCALL               
+               xsltInitCtxtKeys        (xsltTransformContextPtr ctxt,
+                                        xsltDocumentPtr doc);
+XSLTPUBFUN void XSLTCALL               
+               xsltFreeKeys            (xsltStylesheetPtr style);
+XSLTPUBFUN void XSLTCALL               
+               xsltFreeDocumentKeys    (xsltDocumentPtr doc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/libxslt.3 b/reactos/dll/3rdparty/libxslt/libxslt.3
new file mode 100644 (file)
index 0000000..06f256d
--- /dev/null
@@ -0,0 +1,31 @@
+.TH libxslt 3 "30 August 2001"
+.SH NAME
+libxslt \- library used to do XSL transformations on XML documents
+.SH DESCRIPTION
+The 
+.I libxslt
+library is used to do XSL transformations on XML documents that
+have been loaded into memory with functions from
+.I libxml.
+.LP
+.SH FILES
+.TP 2.2i
+.B /usr/lib/libxslt_1.0.0/libxslt.a
+static library
+.TP
+.B /usr/lib/libxslt_1.0.0/libxslt.so
+sharable library
+.TP
+.B /usr/package/libxslt_1.0.0/bin/xsltproc
+binary application to do XSL transformations on the command line
+.SH AUTHORS
+Daniel Veillard (daniel@veillard.com).
+If you download and install this package look at instructions on the
+Web site http://xmlsoft.org/XSLT/ .
+Manual page by Heiko W. Rupp (hwr@pilhuhn.de)
+.SH SEE ALSO
+.IR libexslt (3), 
+.IR libxml (3), 
+.IR xsltproc (1), 
+.IR xmllint (1)
+.\" end of manual page
diff --git a/reactos/dll/3rdparty/libxslt/libxslt.h b/reactos/dll/3rdparty/libxslt/libxslt.h
new file mode 100644 (file)
index 0000000..903f900
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Summary: internal header only used during the compilation of libxslt
+ * Description: internal header only used during the compilation of libxslt
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XSLT_LIBXSLT_H__
+#define __XSLT_LIBXSLT_H__
+
+#if defined(WIN32) && !defined (__CYGWIN__) && !defined (__MINGW32__)
+#include <win32config.h>
+#else
+#include "config.h"
+#endif
+
+#include "xsltconfig.h"
+#include <libxml/xmlversion.h>
+
+#if !defined LIBXSLT_PUBLIC
+#if (defined (__CYGWIN__) || defined _MSC_VER) && !defined IN_LIBXSLT && !defined LIBXSLT_STATIC
+#define LIBXSLT_PUBLIC __declspec(dllimport)
+#else
+#define LIBXSLT_PUBLIC 
+#endif
+#endif
+
+#endif /* ! __XSLT_LIBXSLT_H__ */
diff --git a/reactos/dll/3rdparty/libxslt/libxslt.rbuild b/reactos/dll/3rdparty/libxslt/libxslt.rbuild
new file mode 100644 (file)
index 0000000..5d14e21
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
+<module name="libxslt" type="win32dll" entrypoint="0" installbase="system32" installname="libxslt.dll" allowwarnings="true" crt="msvcrt">
+       <define name="HAVE_CONFIG_H" />
+       <define name="WIN32" />
+       <define name="_WINDOWS" />
+       <define name="_MBCS" />
+       <define name="HAVE_WIN32_THREADS" />
+       <define name="_REENTRANT" />
+       <define name="_WINSOCKAPI_" />
+       <define name="LIBXML_STATIC" />
+       <include base="libxslt">include</include>
+       <include base="libxslt">.</include>
+       <library>libxml2</library>
+       <library>ws2_32</library>
+       <file>attributes.c</file>
+       <file>attrvt.c</file>
+       <file>documents.c</file>
+       <file>extensions.c</file>
+       <file>extra.c</file>
+       <file>functions.c</file>
+       <file>imports.c</file>
+       <file>keys.c</file>
+       <file>namespaces.c</file>
+       <file>numbers.c</file>
+       <file>pattern.c</file>
+       <file>preproc.c</file>
+       <file>security.c</file>
+       <file>templates.c</file>
+       <file>transform.c</file>
+       <file>variables.c</file>
+       <file>xslt.c</file>
+       <file>xsltutils.c</file>
+</module>
diff --git a/reactos/dll/3rdparty/libxslt/namespaces.c b/reactos/dll/3rdparty/libxslt/namespaces.c
new file mode 100644 (file)
index 0000000..b147df8
--- /dev/null
@@ -0,0 +1,847 @@
+/*
+ * namespaces.c: Implementation of the XSLT namespaces handling
+ *
+ * Reference:
+ *   http://www.w3.org/TR/1999/REC-xslt-19991116
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_MATH_H
+#include <math.h>
+#endif
+#ifdef HAVE_FLOAT_H
+#include <float.h>
+#endif
+#ifdef HAVE_IEEEFP_H
+#include <ieeefp.h>
+#endif
+#ifdef HAVE_NAN_H
+#include <nan.h>
+#endif
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+#ifndef        XSLT_NEED_TRIO
+#include <stdio.h>
+#else
+#include <trio.h>
+#endif
+
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/hash.h>
+#include <libxml/xmlerror.h>
+#include <libxml/uri.h>
+#include "xslt.h"
+#include "xsltInternals.h"
+#include "xsltutils.h"
+#include "namespaces.h"
+#include "imports.h"
+
+/************************************************************************
+ *                                                                     *
+ *                     Module interfaces                               *
+ *                                                                     *
+ ************************************************************************/
+
+#ifdef XSLT_REFACTORED  
+static xsltNsAliasPtr
+xsltNewNsAlias(xsltCompilerCtxtPtr cctxt)
+{
+    xsltNsAliasPtr ret;
+
+    if (cctxt == NULL)
+       return(NULL);
+
+    ret = (xsltNsAliasPtr) xmlMalloc(sizeof(xsltNsAlias));
+    if (ret == NULL) {
+       xsltTransformError(NULL, cctxt->style, NULL,
+           "Internal error in xsltNewNsAlias(): Memory allocation failed.\n");
+       cctxt->style->errors++;
+       return(NULL);
+    }
+    memset(ret, 0, sizeof(xsltNsAlias));    
+    /*
+    * TODO: Store the item at current stylesheet-level.
+    */
+    ret->next = cctxt->nsAliases;
+    cctxt->nsAliases = ret;       
+
+    return(ret);
+}
+#endif /* XSLT_REFACTORED */
+/**
+ * xsltNamespaceAlias:
+ * @style:  the XSLT stylesheet
+ * @node:  the xsl:namespace-alias node
+ *
+ * Read the stylesheet-prefix and result-prefix attributes, register
+ * them as well as the corresponding namespace.
+ */
+void
+xsltNamespaceAlias(xsltStylesheetPtr style, xmlNodePtr node)
+{
+    xmlChar *resultPrefix = NULL;
+    xmlChar *stylePrefix = NULL;
+    xmlNsPtr literalNs = NULL;
+    xmlNsPtr targetNs = NULL;
+#ifdef XSLT_REFACTORED 
+    xsltNsAliasPtr alias;
+
+    if ((style == NULL) || (node == NULL))
+       return;
+
+    /*
+    * SPEC XSLT 1.0:
+    *  "If a namespace URI is declared to be an alias for multiple
+    *  different namespace URIs, then the declaration with the highest
+    *  import precedence is used. It is an error if there is more than
+    *  one such declaration. An XSLT processor may signal the error;
+    *  if it does not signal the error, it must recover by choosing,
+    *  from amongst the declarations with the highest import precedence,
+    *  the one that occurs last in the stylesheet."
+    *
+    * SPEC TODO: Check for the errors mentioned above.
+    */
+    /*
+    * NOTE that the XSLT 2.0 also *does* use the NULL namespace if
+    *  "#default" is used and there's no default namespace is scope.
+    *  I.e., this is *not* an error. 
+    *  Most XSLT 1.0 implementations work this way.
+    *  The XSLT 1.0 spec has nothing to say on the subject. 
+    */
+    /*
+    * Attribute "stylesheet-prefix".
+    */
+    stylePrefix = xmlGetNsProp(node, (const xmlChar *)"stylesheet-prefix", NULL);
+    if (stylePrefix == NULL) {
+       xsltTransformError(NULL, style, node,
+           "The attribute 'stylesheet-prefix' is missing.\n");
+       return;
+    }
+    if (xmlStrEqual(stylePrefix, (const xmlChar *)"#default"))
+       literalNs = xmlSearchNs(node->doc, node, NULL); 
+    else {
+       literalNs = xmlSearchNs(node->doc, node, stylePrefix);
+       if (literalNs == NULL) {
+           xsltTransformError(NULL, style, node,
+               "Attribute 'stylesheet-prefix': There's no namespace "
+               "declaration in scope for the prefix '%s'.\n",
+                   stylePrefix);
+           goto error;
+       }
+    }
+    /*
+    * Attribute "result-prefix".
+    */
+    resultPrefix = xmlGetNsProp(node, (const xmlChar *)"result-prefix", NULL);
+    if (resultPrefix == NULL) {
+       xsltTransformError(NULL, style, node,
+           "The attribute 'result-prefix' is missing.\n");
+       goto error;
+    }        
+    if (xmlStrEqual(resultPrefix, (const xmlChar *)"#default"))
+       targetNs = xmlSearchNs(node->doc, node, NULL);
+    else {
+       targetNs = xmlSearchNs(node->doc, node, resultPrefix);
+
+        if (targetNs == NULL) {
+          xsltTransformError(NULL, style, node,
+               "Attribute 'result-prefix': There's no namespace "
+               "declaration in scope for the prefix '%s'.\n",
+                   stylePrefix);
+           goto error;
+       }
+    }
+    /*
+     *
+     * Same alias for multiple different target namespace URIs:
+     *  TODO: The one with the highest import precedence is used.
+     *  Example:
+     *  <xsl:namespace-alias stylesheet-prefix="foo"
+     *                       result-prefix="bar"/>
+     *
+     *  <xsl:namespace-alias stylesheet-prefix="foo"
+     *                       result-prefix="zar"/>
+     *
+     * Same target namespace URI for multiple different aliases:
+     *  All alias-definitions will be used.
+     *  Example:
+     *  <xsl:namespace-alias stylesheet-prefix="bar"
+     *                       result-prefix="foo"/>
+     *
+     *  <xsl:namespace-alias stylesheet-prefix="zar"
+     *                       result-prefix="foo"/>
+     * Cases using #default:
+     *  <xsl:namespace-alias stylesheet-prefix="#default"
+     *                       result-prefix="#default"/>
+     *  TODO: Has this an effect at all?
+     *
+     *  <xsl:namespace-alias stylesheet-prefix="foo"
+     *                       result-prefix="#default"/>
+     *  From namespace to no namespace.
+     *
+     *  <xsl:namespace-alias stylesheet-prefix="#default"
+     *                       result-prefix="foo"/>
+     *  From no namespace to namespace.
+     */
+    
+       
+     /*
+     * Store the ns-node in the alias-object.
+    */
+    alias = xsltNewNsAlias(XSLT_CCTXT(style));
+    if (alias == NULL)
+       return;
+    alias->literalNs = literalNs;
+    alias->targetNs = targetNs;
+    XSLT_CCTXT(style)->hasNsAliases = 1;
+
+
+#else /* XSLT_REFACTORED */
+    const xmlChar *literalNsName;
+    const xmlChar *targetNsName;
+    
+
+    if ((style == NULL) || (node == NULL))
+       return;
+
+    stylePrefix = xmlGetNsProp(node, (const xmlChar *)"stylesheet-prefix", NULL);
+    if (stylePrefix == NULL) {
+       xsltTransformError(NULL, style, node,
+           "namespace-alias: stylesheet-prefix attribute missing\n");
+       return;
+    }
+    resultPrefix = xmlGetNsProp(node, (const xmlChar *)"result-prefix", NULL);
+    if (resultPrefix == NULL) {
+       xsltTransformError(NULL, style, node,
+           "namespace-alias: result-prefix attribute missing\n");
+       goto error;
+    }
+    
+    if (xmlStrEqual(stylePrefix, (const xmlChar *)"#default")) {
+       literalNs = xmlSearchNs(node->doc, node, NULL);
+       if (literalNs == NULL) {
+           literalNsName = NULL;
+       } else
+           literalNsName = literalNs->href; /* Yes - set for nsAlias table */
+    } else {
+       literalNs = xmlSearchNs(node->doc, node, stylePrefix);
+       if ((literalNs == NULL) || (literalNs->href == NULL)) {
+           xsltTransformError(NULL, style, node,
+               "namespace-alias: prefix %s not bound to any namespace\n",
+                                       stylePrefix);
+           goto error;
+       } else
+           literalNsName = literalNs->href;
+    }
+
+    /*
+     * When "#default" is used for result, if a default namespace has not
+     * been explicitly declared the special value UNDEFINED_DEFAULT_NS is
+     * put into the nsAliases table
+     */
+    if (xmlStrEqual(resultPrefix, (const xmlChar *)"#default")) {
+       targetNs = xmlSearchNs(node->doc, node, NULL);
+       if (targetNs == NULL) {
+           targetNsName = UNDEFINED_DEFAULT_NS;
+       } else
+           targetNsName = targetNs->href;
+    } else {
+       targetNs = xmlSearchNs(node->doc, node, resultPrefix);
+
+        if ((targetNs == NULL) || (targetNs->href == NULL)) {
+           xsltTransformError(NULL, style, node,
+               "namespace-alias: prefix %s not bound to any namespace\n",
+                                       resultPrefix);
+           goto error;
+       } else
+           targetNsName = targetNs->href;
+    }
+    /*
+     * Special case: if #default is used for
+     *  the stylesheet-prefix (literal namespace) and there's no default
+     *  namespace in scope, we'll use style->defaultAlias for this.
+     */   
+    if (literalNsName == NULL) {
+        if (targetNs != NULL) {
+           /*
+           * BUG TODO: Is it not sufficient to have only 1 field for
+           *  this, since subsequently alias declarations will
+           *  overwrite this.      
+           *  Example:
+           *   <xsl:namespace-alias result-prefix="foo"
+           *                        stylesheet-prefix="#default"/>
+           *   <xsl:namespace-alias result-prefix="bar"
+           *                        stylesheet-prefix="#default"/>
+           *  The mapping for "foo" won't be visible anymore.
+           */
+            style->defaultAlias = targetNs->href;
+       }
+    } else {
+        if (style->nsAliases == NULL)
+           style->nsAliases = xmlHashCreate(10);
+        if (style->nsAliases == NULL) {
+           xsltTransformError(NULL, style, node,
+               "namespace-alias: cannot create hash table\n");
+           goto error;
+        }
+       xmlHashAddEntry((xmlHashTablePtr) style->nsAliases,
+           literalNsName, (void *) targetNsName);
+    }
+#endif /* else of XSLT_REFACTORED */
+
+error:
+    if (stylePrefix != NULL)
+       xmlFree(stylePrefix);
+    if (resultPrefix != NULL)
+       xmlFree(resultPrefix);
+}
+
+/**
+ * xsltGetSpecialNamespace:
+ * @ctxt:  the transformation context
+ * @invocNode: the invoking node; e.g. a literal result element/attr;
+ *             only used for error reports
+ * @nsName:  the namespace name (or NULL)
+ * @nsPrefix:  the suggested namespace prefix (or NULL)
+ * @target:  the result element on which to anchor a namespace
+ *
+ * Find a matching (prefix and ns-name) ns-declaration
+ * for the requested @nsName and @nsPrefix in the result tree.
+ * If none is found then a new ns-declaration will be
+ * added to @resultElem. If, in this case, the given prefix is
+ * already in use, then a ns-declaration with a modified ns-prefix
+ * be we created. Note that this function's priority is to
+ * preserve ns-prefixes; it will only change a prefix if there's
+ * a namespace clash.
+ * If both @nsName and @nsPrefix are NULL, then this will try to
+ * "undeclare" a default namespace by declaring an xmlns="".
+ *
+ * Returns a namespace declaration or NULL.
+ */
+xmlNsPtr
+xsltGetSpecialNamespace(xsltTransformContextPtr ctxt, xmlNodePtr invocNode,
+               const xmlChar *nsName, const xmlChar *nsPrefix,
+               xmlNodePtr target)
+{
+    xmlNsPtr ns;
+    int prefixOccupied = 0;
+
+    if ((ctxt == NULL) || (target == NULL) ||
+       (target->type != XML_ELEMENT_NODE))
+       return(NULL);
+
+    /*
+    * NOTE: Namespace exclusion and ns-aliasing is performed at
+    *  compilation-time in the refactored code; so this need not be done
+    *  here (it was in the old code).
+    * NOTE: @invocNode was named @cur in the old code and was documented to
+    *  be an input node; since it was only used to anchor an error report
+    *  somewhere, we can safely change this to @invocNode, which now
+    *  will be the XSLT instruction (also a literal result element/attribute),
+    *  which was responsible for this call.
+    */
+    /*
+    * OPTIMIZE TODO: This all could be optimized by keeping track of
+    *  the ns-decls currently in-scope via a specialized context.
+    */    
+    if ((nsPrefix == NULL) && ((nsName == NULL) || (nsName[0] == 0))) {
+       /*
+       * NOTE: the "undeclaration" of the default namespace was
+       * part of the logic of the old xsltGetSpecialNamespace() code,
+       * so we'll keep that mechanism.
+       * Related to the old code: bug #302020:
+       */
+       /*
+       * OPTIMIZE TODO: This all could be optimized by keeping track of
+       *  the ns-decls currently in-scope via a specialized context.
+       */
+       /*
+       * Search on the result element itself.
+       */
+       if (target->nsDef != NULL) {
+           ns = target->nsDef;
+           do {
+               if (ns->prefix == NULL) {
+                   if ((ns->href != NULL) && (ns->href[0] != 0)) {
+                       /*
+                       * Raise a namespace normalization error.
+                       */
+                       xsltTransformError(ctxt, NULL, invocNode,
+                           "Namespace normalization error: Cannot undeclare "
+                           "the default namespace, since the default namespace "
+                           "'%s' is already declared on the result element "
+                           "'%s'.\n", ns->href, target->name);
+                       return(NULL);
+                   } else {
+                       /*
+                       * The default namespace was undeclared on the
+                       * result element.
+                       */
+                       return(NULL);
+                   }
+                   break;
+               }
+               ns = ns->next;
+           } while (ns != NULL);
+       }       
+       if ((target->parent != NULL) &&
+           (target->parent->type == XML_ELEMENT_NODE))
+       {
+           /*
+           * The parent element is in no namespace, so assume
+           * that there is no default namespace in scope.
+           */
+           if (target->parent->ns == NULL)
+               return(NULL);
+           
+           ns = xmlSearchNs(target->doc, target->parent,
+               NULL);
+           /*
+           * Fine if there's no default ns is scope, or if the
+           * default ns was undeclared.
+           */
+           if ((ns == NULL) || (ns->href == NULL) || (ns->href[0] == 0))
+               return(NULL);
+           
+           /*
+           * Undeclare the default namespace.
+           */
+           xmlNewNs(target, BAD_CAST "", NULL);
+           /* TODO: Check result */    
+           return(NULL);
+       }
+       return(NULL);
+    }
+    /*
+    * Handle the XML namespace.
+    * QUESTION: Is this faster than using xmlStrEqual() anyway?
+    */
+    if ((nsPrefix != NULL) &&
+       (nsPrefix[0] == 'x') && (nsPrefix[1] == 'm') &&
+       (nsPrefix[2] == 'l') && (nsPrefix[3] == 0))
+    {
+       return(xmlSearchNs(target->doc, target, nsPrefix));
+    }
+    /*
+    * First: search on the result element itself.
+    */
+    if (target->nsDef != NULL) {
+       ns = target->nsDef;
+       do {
+           if ((ns->prefix == NULL) == (nsPrefix == NULL)) {
+               if (ns->prefix == nsPrefix) {
+                   if (xmlStrEqual(ns->href, nsName))
+                       return(ns);
+                   prefixOccupied = 1;
+                   break;
+               } else if (xmlStrEqual(ns->prefix, nsPrefix)) {
+                   if (xmlStrEqual(ns->href, nsName))
+                       return(ns);
+                   prefixOccupied = 1;
+                   break;
+               }
+           }
+           ns = ns->next;
+       } while (ns != NULL);
+    }
+    if (prefixOccupied) {
+       /*
+       * If the ns-prefix is occupied by an other ns-decl on the
+       * result element, then this means:
+       * 1) The desired prefix is shadowed
+       * 2) There's no way around changing the prefix  
+       *
+       * Try a desperate search for an in-scope ns-decl
+       * with a matching ns-name before we use the last option,
+       * which is to recreate the ns-decl with a modified prefix.
+       */
+       ns = xmlSearchNsByHref(target->doc, target, nsName);
+       if (ns != NULL)
+           return(ns);
+
+       /*
+       * Fallback to changing the prefix.
+       */    
+    } else if ((target->parent != NULL) &&
+       (target->parent->type == XML_ELEMENT_NODE))
+    {
+       /*
+       * Try to find a matching ns-decl in the ancestor-axis.
+       *
+       * Check the common case: The parent element of the current
+       * result element is in the same namespace (with an equal ns-prefix).
+       */     
+       if ((target->parent->ns != NULL) &&
+           ((target->parent->ns->prefix != NULL) == (nsPrefix != NULL)))
+       {
+           ns = target->parent->ns;
+           
+           if (nsPrefix == NULL) {
+               if (xmlStrEqual(ns->href, nsName))
+                   return(ns);
+           } else if (xmlStrEqual(ns->prefix, nsPrefix) &&
+               xmlStrEqual(ns->href, nsName))
+           {
+               return(ns);
+           }
+       }
+       /*
+       * Lookup the remaining in-scope namespaces.
+       */    
+       ns = xmlSearchNs(target->doc, target->parent, nsPrefix);
+       if (ns != NULL) {
+           if (xmlStrEqual(ns->href, nsName))
+               return(ns);         
+           /*
+           * Now check for a nasty case: We need to ensure that the new
+           * ns-decl won't shadow a prefix in-use by an existing attribute.
+           * <foo xmlns:a="urn:test:a">
+           *   <bar a:a="val-a">
+           *     <xsl:attribute xmlns:a="urn:test:b" name="a:b">
+           *        val-b</xsl:attribute>
+           *   </bar>
+           * </foo>
+           */
+           if (target->properties) {
+               xmlAttrPtr attr = target->properties;
+               do {
+                   if ((attr->ns) &&
+                       xmlStrEqual(attr->ns->prefix, nsPrefix))
+                   {
+                       /*
+                       * Bad, this prefix is already in use.
+                       * Since we'll change the prefix anyway, try
+                       * a search for a matching ns-decl based on the
+                       * namespace name.
+                       */
+                       ns = xmlSearchNsByHref(target->doc, target, nsName);
+                       if (ns != NULL)
+                           return(ns);
+                       goto declare_new_prefix;
+                   }
+                   attr = attr->next;
+               } while (attr != NULL);
+           }
+       } else {
+           /*
+           * Either no matching ns-prefix was found or the namespace is
+           * shadowed.
+           * Create a new ns-decl on the current result element.
+           *
+           * Hmm, we could also try to reuse an in-scope
+           * namespace with a matching ns-name but a different
+           * ns-prefix.
+           * What has higher priority?
+           *  1) If keeping the prefix: create a new ns-decl.
+           *  2) If reusal: first lookup ns-names; then fallback
+           *     to creation of a new ns-decl.
+           * REVISIT: this currently uses case 1) although
+           *  the old way was use xmlSearchNsByHref() and to let change
+           *  the prefix.
+           */
+#if 0
+           ns = xmlSearchNsByHref(target->doc, target, nsName);
+           if (ns != NULL)
+               return(ns);
+#endif
+       }
+       /*
+       * Create the ns-decl on the current result element.
+       */
+       ns = xmlNewNs(target, nsName, nsPrefix);
+       /* TODO: check errors */
+       return(ns);
+    } else {
+       /*
+       * This is either the root of the tree or something weird is going on.
+       */
+       ns = xmlNewNs(target, nsName, nsPrefix);
+       /* TODO: Check result */
+       return(ns);
+    }
+
+declare_new_prefix:
+    /*
+    * Fallback: we need to generate a new prefix and declare the namespace
+    * on the result element.
+    */
+    {
+       xmlChar pref[30];
+       int counter = 1;
+
+       do {
+           snprintf((char *) pref, 30, "%s_%d", nsPrefix, counter++);
+           ns = xmlSearchNs(target->doc, target, BAD_CAST pref);
+           if (counter > 1000) {
+               xsltTransformError(ctxt, NULL, invocNode,
+                   "Internal error in xsltAcquireResultInScopeNs(): "
+                   "Failed to compute a unique ns-prefix for the "
+                   "generated element");
+               return(NULL);
+           }
+       } while (ns != NULL);
+       ns = xmlNewNs(target, nsName, BAD_CAST pref);
+       /* TODO: Check result */
+       return(ns);
+    }
+    return(NULL);
+}
+
+/**
+ * xsltGetNamespace:
+ * @ctxt:  a transformation context
+ * @cur:  the input node
+ * @ns:  the namespace
+ * @out:  the output node (or its parent)
+ *
+ * Find a matching (prefix and ns-name) ns-declaration
+ * for the requested @ns->prefix and @ns->href in the result tree.
+ * If none is found then a new ns-declaration will be
+ * added to @resultElem. If, in this case, the given prefix is
+ * already in use, then a ns-declaration with a modified ns-prefix
+ * be we created.
+ *
+ * Called by:
+ *  - xsltCopyPropList() (*not*  anymore)
+ *  - xsltShallowCopyElement()
+ *  - xsltCopyTreeInternal() (*not*  anymore)
+ *  - xsltApplySequenceConstructor() (*not* in the refactored code),
+ *  - xsltElement() (*not* anymore)
+ *
+ * Returns a namespace declaration or NULL in case of
+ *         namespace fixup failures or API or internal errors.
+ */
+xmlNsPtr
+xsltGetNamespace(xsltTransformContextPtr ctxt, xmlNodePtr cur, xmlNsPtr ns,
+                xmlNodePtr out)
+{    
+    
+    if (ns == NULL)
+       return(NULL);
+
+#ifdef XSLT_REFACTORED
+    /*
+    * Namespace exclusion and ns-aliasing is performed at
+    * compilation-time in the refactored code.
+    * Additionally, aliasing is not intended for non Literal
+    * Result Elements.
+    */
+    return(xsltGetSpecialNamespace(ctxt, cur, ns->href, ns->prefix, out));
+#else
+    {
+       xsltStylesheetPtr style;
+       const xmlChar *URI = NULL; /* the replacement URI */
+
+       if ((ctxt == NULL) || (cur == NULL) || (out == NULL))
+           return(NULL);
+
+       style = ctxt->style;
+       while (style != NULL) {
+           if (style->nsAliases != NULL)
+               URI = (const xmlChar *) 
+               xmlHashLookup(style->nsAliases, ns->href);
+           if (URI != NULL)
+               break;
+           
+           style = xsltNextImport(style);
+       }
+       
+       
+       if (URI == UNDEFINED_DEFAULT_NS) {
+           return(xsltGetSpecialNamespace(ctxt, cur, NULL, NULL, out));
+#if 0
+           /*
+           * TODO: Removed, since wrong. If there was no default
+           * namespace in the stylesheet then this must resolve to
+           * the NULL namespace.
+           */
+           xmlNsPtr dflt;          
+           dflt = xmlSearchNs(cur->doc, cur, NULL);
+           if (dflt != NULL)
+               URI = dflt->href;
+           else
+               return NULL;
+#endif
+       } else if (URI == NULL)
+           URI = ns->href;
+
+       return(xsltGetSpecialNamespace(ctxt, cur, URI, ns->prefix, out));
+    }
+#endif
+}
+
+/**
+ * xsltGetPlainNamespace:
+ * @ctxt:  a transformation context
+ * @cur:  the input node
+ * @ns:  the namespace
+ * @out:  the result element
+ *
+ * Obsolete. 
+ * *Not* called by any Libxslt/Libexslt function.
+ * Exaclty the same as xsltGetNamespace(). 
+ *
+ * Returns a namespace declaration or NULL in case of
+ *         namespace fixup failures or API or internal errors.
+ */
+xmlNsPtr
+xsltGetPlainNamespace(xsltTransformContextPtr ctxt, xmlNodePtr cur,
+                      xmlNsPtr ns, xmlNodePtr out)
+{    
+    return(xsltGetNamespace(ctxt, cur, ns, out));
+}
+
+/**
+ * xsltCopyNamespaceList:
+ * @ctxt:  a transformation context
+ * @node:  the target node
+ * @cur:  the first namespace
+ *
+ * Do a copy of an namespace list. If @node is non-NULL the
+ * new namespaces are added automatically. This handles namespaces
+ * aliases.
+ * This function is intended only for *internal* use at
+ * transformation-time for copying ns-declarations of Literal
+ * Result Elements.
+ * 
+ * Called by:
+ *   xsltCopyTreeInternal() (transform.c)
+ *   xsltShallowCopyElem() (transform.c)
+ *
+ * REVISIT: This function won't be used in the refactored code.
+ *
+ * Returns: a new xmlNsPtr, or NULL in case of error.
+ */
+xmlNsPtr
+xsltCopyNamespaceList(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                     xmlNsPtr cur) {
+    xmlNsPtr ret = NULL, tmp;
+    xmlNsPtr p = NULL,q;    
+
+    if (cur == NULL)
+       return(NULL);
+    if (cur->type != XML_NAMESPACE_DECL)
+       return(NULL);
+
+    /*
+     * One can add namespaces only on element nodes
+     */
+    if ((node != NULL) && (node->type != XML_ELEMENT_NODE))
+       node = NULL;
+
+    while (cur != NULL) {
+       if (cur->type != XML_NAMESPACE_DECL)
+           break;
+
+       /*
+        * Avoid duplicating namespace declarations in the tree if
+        * a matching declaration is in scope.
+        */
+       if (node != NULL) {
+           if ((node->ns != NULL) &&
+               (xmlStrEqual(node->ns->prefix, cur->prefix)) &&
+               (xmlStrEqual(node->ns->href, cur->href))) {
+               cur = cur->next;
+               continue;
+           }
+           tmp = xmlSearchNs(node->doc, node, cur->prefix);
+           if ((tmp != NULL) && (xmlStrEqual(tmp->href, cur->href))) {
+               cur = cur->next;
+               continue;
+           }
+       }
+#ifdef XSLT_REFACTORED
+       /*
+       * Namespace exclusion and ns-aliasing is performed at
+       * compilation-time in the refactored code.
+       */
+       q = xmlNewNs(node, cur->href, cur->prefix);
+       if (p == NULL) {
+           ret = p = q;
+       } else {
+           p->next = q;
+           p = q;
+       }
+#else
+       /*
+       * TODO: Remove this if the refactored code gets enabled.
+       */
+       if (!xmlStrEqual(cur->href, XSLT_NAMESPACE)) {
+           const xmlChar *URI;
+           /* TODO apply cascading */
+           URI = (const xmlChar *) xmlHashLookup(ctxt->style->nsAliases,
+                                                 cur->href);
+           if (URI == UNDEFINED_DEFAULT_NS)
+               continue;
+           if (URI != NULL) {
+               q = xmlNewNs(node, URI, cur->prefix);
+           } else {
+               q = xmlNewNs(node, cur->href, cur->prefix);
+           }
+           if (p == NULL) {
+               ret = p = q;
+           } else {
+               p->next = q;
+               p = q;
+           }
+       }
+#endif
+       cur = cur->next;
+    }
+    return(ret);
+}
+
+/**
+ * xsltCopyNamespace:
+ * @ctxt:  a transformation context
+ * @elem:  the target element node
+ * @ns:  the namespace node
+ *
+ * Copies a namespace node (declaration). If @elem is not NULL,
+ * then the new namespace will be declared on @elem.
+ *
+ * Returns: a new xmlNsPtr, or NULL in case of an error.
+ */
+xmlNsPtr
+xsltCopyNamespace(xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED,
+                 xmlNodePtr elem, xmlNsPtr ns)
+{    
+    if ((ns == NULL) || (ns->type != XML_NAMESPACE_DECL))
+       return(NULL);
+    /*
+     * One can add namespaces only on element nodes
+     */
+    if ((elem != NULL) && (elem->type != XML_ELEMENT_NODE))
+       return(xmlNewNs(NULL, ns->href, ns->prefix));
+    else
+       return(xmlNewNs(elem, ns->href, ns->prefix));
+}
+
+
+/**
+ * xsltFreeNamespaceAliasHashes:
+ * @style: an XSLT stylesheet
+ *
+ * Free up the memory used by namespaces aliases
+ */
+void
+xsltFreeNamespaceAliasHashes(xsltStylesheetPtr style) {
+    if (style->nsAliases != NULL)
+       xmlHashFree((xmlHashTablePtr) style->nsAliases, NULL);
+    style->nsAliases = NULL;
+}
diff --git a/reactos/dll/3rdparty/libxslt/namespaces.h b/reactos/dll/3rdparty/libxslt/namespaces.h
new file mode 100644 (file)
index 0000000..0bda596
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Summary: interface for the XSLT namespace handling
+ * Description: set of function easing the processing and generation
+ *              of namespace nodes in XSLT.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_NAMESPACES_H__
+#define __XML_XSLT_NAMESPACES_H__
+
+#include <libxml/tree.h>
+#include "xsltexports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Used within nsAliases hashtable when the default namespace is required
+ * but it's not been explicitly defined
+ */
+/**
+ * UNDEFINED_DEFAULT_NS:
+ *
+ * Special value for undefined namespace, internal
+ */
+#define        UNDEFINED_DEFAULT_NS    (const xmlChar *) -1L
+
+XSLTPUBFUN void XSLTCALL
+               xsltNamespaceAlias      (xsltStylesheetPtr style,
+                                        xmlNodePtr node);
+XSLTPUBFUN xmlNsPtr XSLTCALL   
+               xsltGetNamespace        (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr cur,
+                                        xmlNsPtr ns,
+                                        xmlNodePtr out);
+XSLTPUBFUN xmlNsPtr XSLTCALL   
+               xsltGetPlainNamespace   (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr cur,
+                                        xmlNsPtr ns,
+                                        xmlNodePtr out);
+XSLTPUBFUN xmlNsPtr XSLTCALL   
+               xsltGetSpecialNamespace (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr cur,
+                                        const xmlChar *URI,
+                                        const xmlChar *prefix,
+                                        xmlNodePtr out);
+XSLTPUBFUN xmlNsPtr XSLTCALL   
+               xsltCopyNamespace       (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr elem,
+                                        xmlNsPtr ns);
+XSLTPUBFUN xmlNsPtr XSLTCALL   
+               xsltCopyNamespaceList   (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNsPtr cur);
+XSLTPUBFUN void XSLTCALL               
+               xsltFreeNamespaceAliasHashes
+                                       (xsltStylesheetPtr style);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_NAMESPACES_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/numbers.c b/reactos/dll/3rdparty/libxslt/numbers.c
new file mode 100644 (file)
index 0000000..8683ca8
--- /dev/null
@@ -0,0 +1,1351 @@
+/*
+ * numbers.c: Implementation of the XSLT number functions
+ *
+ * Reference:
+ *   http://www.w3.org/TR/1999/REC-xslt-19991116
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ * Bjorn Reese <breese@users.sourceforge.net>
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <math.h>
+#include <limits.h>
+#include <float.h>
+#include <string.h>
+
+#include <libxml/xmlmemory.h>
+#include <libxml/parserInternals.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+#include <libxml/encoding.h>
+#include "xsltutils.h"
+#include "pattern.h"
+#include "templates.h"
+#include "transform.h"
+#include "numbersInternals.h"
+
+#ifndef FALSE
+# define FALSE (0 == 1)
+# define TRUE (1 == 1)
+#endif
+
+#define SYMBOL_QUOTE           ((xmlChar)'\'')
+
+#define DEFAULT_TOKEN          (xmlChar)'0'
+#define DEFAULT_SEPARATOR      "."
+
+#define MAX_TOKENS             1024
+
+typedef struct _xsltFormatToken xsltFormatToken;
+typedef xsltFormatToken *xsltFormatTokenPtr;
+struct _xsltFormatToken {
+    xmlChar    *separator;
+    xmlChar     token;
+    int                 width;
+};
+
+typedef struct _xsltFormat xsltFormat;
+typedef xsltFormat *xsltFormatPtr;
+struct _xsltFormat {
+    xmlChar            *start;
+    xsltFormatToken     tokens[MAX_TOKENS];
+    int                         nTokens;
+    xmlChar            *end;
+};
+
+static char alpha_upper_list[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+static char alpha_lower_list[] = "abcdefghijklmnopqrstuvwxyz";
+static xsltFormatToken default_token;
+
+/*
+ * **** Start temp insert ****
+ *
+ * The following two routines (xsltUTF8Size and xsltUTF8Charcmp)
+ * will be replaced with calls to the corresponding libxml routines
+ * at a later date (when other inter-library dependencies require it)
+ */
+
+/**
+ * xsltUTF8Size:
+ * @utf: pointer to the UTF8 character
+ *
+ * returns the numbers of bytes in the character, -1 on format error
+ */
+static int
+xsltUTF8Size(xmlChar *utf) {
+    xmlChar mask;
+    int len;
+
+    if (utf == NULL)
+        return -1;
+    if (*utf < 0x80)
+        return 1;
+    /* check valid UTF8 character */
+    if (!(*utf & 0x40))
+        return -1;
+    /* determine number of bytes in char */
+    len = 2;
+    for (mask=0x20; mask != 0; mask>>=1) {
+        if (!(*utf & mask))
+            return len;
+        len++;
+    }
+    return -1;
+}
+
+/**
+ * xsltUTF8Charcmp
+ * @utf1: pointer to first UTF8 char
+ * @utf2: pointer to second UTF8 char
+ *
+ * returns result of comparing the two UCS4 values
+ * as with xmlStrncmp
+ */
+static int
+xsltUTF8Charcmp(xmlChar *utf1, xmlChar *utf2) {
+
+    if (utf1 == NULL ) {
+        if (utf2 == NULL)
+            return 0;
+        return -1;
+    }
+    return xmlStrncmp(utf1, utf2, xsltUTF8Size(utf1));
+}
+
+/***** Stop temp insert *****/
+/************************************************************************
+ *                                                                     *
+ *                     Utility functions                               *
+ *                                                                     *
+ ************************************************************************/
+
+#define IS_SPECIAL(self,letter)                        \
+    ((xsltUTF8Charcmp((letter), (self)->zeroDigit) == 0)           ||  \
+     (xsltUTF8Charcmp((letter), (self)->digit) == 0)       ||  \
+     (xsltUTF8Charcmp((letter), (self)->decimalPoint) == 0)  ||        \
+     (xsltUTF8Charcmp((letter), (self)->grouping) == 0)            ||  \
+     (xsltUTF8Charcmp((letter), (self)->patternSeparator) == 0))
+
+#define IS_DIGIT_ZERO(x) xsltIsDigitZero(x)
+#define IS_DIGIT_ONE(x) xsltIsDigitZero((xmlChar)(x)-1)
+
+static int
+xsltIsDigitZero(unsigned int ch)
+{
+    /*
+     * Reference: ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
+     */
+    switch (ch) {
+    case 0x0030: case 0x0660: case 0x06F0: case 0x0966:
+    case 0x09E6: case 0x0A66: case 0x0AE6: case 0x0B66:
+    case 0x0C66: case 0x0CE6: case 0x0D66: case 0x0E50:
+    case 0x0E60: case 0x0F20: case 0x1040: case 0x17E0:
+    case 0x1810: case 0xFF10:
+       return TRUE;
+    default:
+       return FALSE;
+    }
+}
+
+static void
+xsltNumberFormatDecimal(xmlBufferPtr buffer,
+                       double number,
+                       int digit_zero,
+                       int width,
+                       int digitsPerGroup,
+                       int groupingCharacter,
+                       int groupingCharacterLen)
+{
+    /*
+     * This used to be
+     *  xmlChar temp_string[sizeof(double) * CHAR_BIT * sizeof(xmlChar) + 4];
+     * which would be length 68 on x86 arch.  It was changed to be a longer,
+     * fixed length in order to try to cater for (reasonable) UTF8
+     * separators and numeric characters.  The max UTF8 char size will be
+     * 6 or less, so the value used [500] should be *much* larger than needed
+     */
+    xmlChar temp_string[500];
+    xmlChar *pointer;
+    xmlChar temp_char[6];
+    int i;
+    int val;
+    int len;
+
+    /* Build buffer from back */
+    pointer = &temp_string[sizeof(temp_string)] - 1;   /* last char */
+    *pointer = 0;
+    i = 0;
+    while (pointer > temp_string) {
+       if ((i >= width) && (fabs(number) < 1.0))
+           break; /* for */
+       if ((i > 0) && (groupingCharacter != 0) &&
+           (digitsPerGroup > 0) &&
+           ((i % digitsPerGroup) == 0)) {
+           if (pointer - groupingCharacterLen < temp_string) {
+               i = -1;         /* flag error */
+               break;
+           }
+           pointer -= groupingCharacterLen;
+           xmlCopyCharMultiByte(pointer, groupingCharacter);
+       }
+       
+       val = digit_zero + (int)fmod(number, 10.0);
+       if (val < 0x80) {                       /* shortcut if ASCII */
+           if (pointer <= temp_string) {       /* Check enough room */
+               i = -1;
+               break;
+           }
+           *(--pointer) = val;
+       }
+       else {
+       /* 
+        * Here we have a multibyte character.  It's a little messy,
+        * because until we generate the char we don't know how long
+        * it is.  So, we generate it into the buffer temp_char, then
+        * copy from there into temp_string.
+        */
+           len = xmlCopyCharMultiByte(temp_char, val);
+           if ( (pointer - len) < temp_string ) {
+               i = -1;
+               break;
+           }
+           pointer -= len;
+           memcpy(pointer, temp_char, len);
+       }
+       number /= 10.0;
+       ++i;
+    }
+    if (i < 0)
+        xsltGenericError(xsltGenericErrorContext,
+               "xsltNumberFormatDecimal: Internal buffer size exceeded");
+    xmlBufferCat(buffer, pointer);
+}
+
+static void
+xsltNumberFormatAlpha(xmlBufferPtr buffer,
+                     double number,
+                     int is_upper)
+{
+    char temp_string[sizeof(double) * CHAR_BIT * sizeof(xmlChar) + 1];
+    char *pointer;
+    int i;
+    char *alpha_list;
+    double alpha_size = (double)(sizeof(alpha_upper_list) - 1);
+
+    /* Build buffer from back */
+    pointer = &temp_string[sizeof(temp_string)];
+    *(--pointer) = 0;
+    alpha_list = (is_upper) ? alpha_upper_list : alpha_lower_list;
+    
+    for (i = 1; i < (int)sizeof(temp_string); i++) {
+       number--;
+       *(--pointer) = alpha_list[((int)fmod(number, alpha_size))];
+       number /= alpha_size;
+       if (fabs(number) < 1.0)
+           break; /* for */
+    }
+    xmlBufferCCat(buffer, pointer);
+}
+
+static void
+xsltNumberFormatRoman(xmlBufferPtr buffer,
+                     double number,
+                     int is_upper)
+{
+    /*
+     * Based on an example by Jim Walsh
+     */
+    while (number >= 1000.0) {
+       xmlBufferCCat(buffer, (is_upper) ? "M" : "m");
+       number -= 1000.0;
+    }
+    if (number >= 900.0) {
+       xmlBufferCCat(buffer, (is_upper) ? "CM" : "cm");
+       number -= 900.0;
+    }
+    while (number >= 500.0) {
+       xmlBufferCCat(buffer, (is_upper) ? "D" : "d");
+       number -= 500.0;
+    }
+    if (number >= 400.0) {
+       xmlBufferCCat(buffer, (is_upper) ? "CD" : "cd");
+       number -= 400.0;
+    }
+    while (number >= 100.0) {
+       xmlBufferCCat(buffer, (is_upper) ? "C" : "c");
+       number -= 100.0;
+    }
+    if (number >= 90.0) {
+       xmlBufferCCat(buffer, (is_upper) ? "XC" : "xc");
+       number -= 90.0;
+    }
+    while (number >= 50.0) {
+       xmlBufferCCat(buffer, (is_upper) ? "L" : "l");
+       number -= 50.0;
+    }
+    if (number >= 40.0) {
+       xmlBufferCCat(buffer, (is_upper) ? "XL" : "xl");
+       number -= 40.0;
+    }
+    while (number >= 10.0) {
+       xmlBufferCCat(buffer, (is_upper) ? "X" : "x");
+       number -= 10.0;
+    }
+    if (number >= 9.0) {
+       xmlBufferCCat(buffer, (is_upper) ? "IX" : "ix");
+       number -= 9.0;
+    }
+    while (number >= 5.0) {
+       xmlBufferCCat(buffer, (is_upper) ? "V" : "v");
+       number -= 5.0;
+    }
+    if (number >= 4.0) {
+       xmlBufferCCat(buffer, (is_upper) ? "IV" : "iv");
+       number -= 4.0;
+    }
+    while (number >= 1.0) {
+       xmlBufferCCat(buffer, (is_upper) ? "I" : "i");
+       number--;
+    }
+}
+
+static void
+xsltNumberFormatTokenize(const xmlChar *format,
+                        xsltFormatPtr tokens)
+{
+    int ix = 0;
+    int j;
+    int val;
+    int len;
+
+    default_token.token = DEFAULT_TOKEN;
+    default_token.width = 1;
+    default_token.separator = BAD_CAST(DEFAULT_SEPARATOR);
+
+
+    tokens->start = NULL;
+    tokens->tokens[0].separator = NULL;
+    tokens->end = NULL;
+
+    /*
+     * Insert initial non-alphanumeric token.
+     * There is always such a token in the list, even if NULL
+     */
+    while (! (IS_LETTER(val=xmlStringCurrentChar(NULL, format+ix, &len)) ||
+             IS_DIGIT(val)) ) {
+       if (format[ix] == 0)            /* if end of format string */
+           break; /* while */
+       ix += len;
+    }
+    if (ix > 0)
+       tokens->start = xmlStrndup(format, ix);
+
+
+    for (tokens->nTokens = 0; tokens->nTokens < MAX_TOKENS;
+        tokens->nTokens++) {
+       if (format[ix] == 0)
+           break; /* for */
+
+       /*
+        * separator has already been parsed (except for the first
+        * number) in tokens->end, recover it.
+        */
+       if (tokens->nTokens > 0) {
+           tokens->tokens[tokens->nTokens].separator = tokens->end;
+           tokens->end = NULL;
+       }
+
+       val = xmlStringCurrentChar(NULL, format+ix, &len);
+       if (IS_DIGIT_ONE(val) ||
+                IS_DIGIT_ZERO(val)) {
+           tokens->tokens[tokens->nTokens].width = 1;
+           while (IS_DIGIT_ZERO(val)) {
+               tokens->tokens[tokens->nTokens].width++;
+               ix += len;
+               val = xmlStringCurrentChar(NULL, format+ix, &len);
+           }
+           if (IS_DIGIT_ONE(val)) {
+               tokens->tokens[tokens->nTokens].token = val - 1;
+               ix += len;
+               val = xmlStringCurrentChar(NULL, format+ix, &len);
+           }
+       } else if ( (val == (xmlChar)'A') ||
+                   (val == (xmlChar)'a') ||
+                   (val == (xmlChar)'I') ||
+                   (val == (xmlChar)'i') ) {
+           tokens->tokens[tokens->nTokens].token = val;
+           ix += len;
+           val = xmlStringCurrentChar(NULL, format+ix, &len);
+       } else {
+           /* XSLT section 7.7
+            * "Any other format token indicates a numbering sequence
+            *  that starts with that token. If an implementation does
+            *  not support a numbering sequence that starts with that
+            *  token, it must use a format token of 1."
+            */
+           tokens->tokens[tokens->nTokens].token = (xmlChar)'0';
+           tokens->tokens[tokens->nTokens].width = 1;
+       }
+       /*
+        * Skip over remaining alphanumeric characters from the Nd
+        * (Number, decimal digit), Nl (Number, letter), No (Number,
+        * other), Lu (Letter, uppercase), Ll (Letter, lowercase), Lt
+        * (Letters, titlecase), Lm (Letters, modifiers), and Lo
+        * (Letters, other (uncased)) Unicode categories. This happens
+        * to correspond to the Letter and Digit classes from XML (and
+        * one wonders why XSLT doesn't refer to these instead).
+        */
+       while (IS_LETTER(val) || IS_DIGIT(val)) {
+           ix += len;
+           val = xmlStringCurrentChar(NULL, format+ix, &len);
+       }
+
+       /*
+        * Insert temporary non-alphanumeric final tooken.
+        */
+       j = ix;
+       while (! (IS_LETTER(val) || IS_DIGIT(val))) {
+           if (val == 0)
+               break; /* while */
+           ix += len;
+           val = xmlStringCurrentChar(NULL, format+ix, &len);
+       }
+       if (ix > j)
+           tokens->end = xmlStrndup(&format[j], ix - j);
+    }
+}
+
+static void
+xsltNumberFormatInsertNumbers(xsltNumberDataPtr data,
+                             double *numbers,
+                             int numbers_max,
+                             xsltFormatPtr tokens,
+                             xmlBufferPtr buffer)
+{
+    int i = 0;
+    double number;
+    xsltFormatTokenPtr token;
+
+    /*
+     * Handle initial non-alphanumeric token
+     */
+    if (tokens->start != NULL)
+        xmlBufferCat(buffer, tokens->start);
+
+    for (i = 0; i < numbers_max; i++) {
+       /* Insert number */
+       number = numbers[(numbers_max - 1) - i];
+       if (i < tokens->nTokens) {
+         /*
+          * The "n"th format token will be used to format the "n"th
+          * number in the list
+          */
+         token = &(tokens->tokens[i]);
+       } else if (tokens->nTokens > 0) {
+         /*
+          * If there are more numbers than format tokens, then the
+          * last format token will be used to format the remaining
+          * numbers.
+          */
+         token = &(tokens->tokens[tokens->nTokens - 1]);
+       } else {
+         /*
+          * If there are no format tokens, then a format token of
+          * 1 is used to format all numbers.
+          */
+         token = &default_token;
+       }
+
+       /* Print separator, except for the first number */
+       if (i > 0) {
+           if (token->separator != NULL)
+               xmlBufferCat(buffer, token->separator);
+           else
+               xmlBufferCCat(buffer, DEFAULT_SEPARATOR);
+       }
+
+       switch (xmlXPathIsInf(number)) {
+       case -1:
+           xmlBufferCCat(buffer, "-Infinity");
+           break;
+       case 1:
+           xmlBufferCCat(buffer, "Infinity");
+           break;
+       default:
+           if (xmlXPathIsNaN(number)) {
+               xmlBufferCCat(buffer, "NaN");
+           } else {
+
+               switch (token->token) {
+               case 'A':
+                   xsltNumberFormatAlpha(buffer,
+                                         number,
+                                         TRUE);
+
+                   break;
+               case 'a':
+                   xsltNumberFormatAlpha(buffer,
+                                         number,
+                                         FALSE);
+
+                   break;
+               case 'I':
+                   xsltNumberFormatRoman(buffer,
+                                         number,
+                                         TRUE);
+
+                   break;
+               case 'i':
+                   xsltNumberFormatRoman(buffer,
+                                         number,
+                                         FALSE);
+
+                   break;
+               default:
+                   if (IS_DIGIT_ZERO(token->token)) {
+                       xsltNumberFormatDecimal(buffer,
+                                               number,
+                                               token->token,
+                                               token->width,
+                                               data->digitsPerGroup,
+                                               data->groupingCharacter,
+                                               data->groupingCharacterLen);
+                   }
+                   break;
+               }
+           }
+
+       }
+    }
+
+    /*
+     * Handle final non-alphanumeric token
+     */
+    if (tokens->end != NULL)
+        xmlBufferCat(buffer, tokens->end);
+
+}
+
+static int
+xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context,
+                           xmlNodePtr node,
+                           const xmlChar *count,
+                           const xmlChar *from,
+                           double *array,
+                           xmlDocPtr doc,
+                           xmlNodePtr elem)
+{
+    int amount = 0;
+    int cnt = 0;
+    xmlNodePtr cur;
+    xsltCompMatchPtr countPat = NULL;
+    xsltCompMatchPtr fromPat = NULL;
+
+    if (count != NULL)
+       countPat = xsltCompilePattern(count, doc, elem, NULL, context);
+    if (from != NULL)
+       fromPat = xsltCompilePattern(from, doc, elem, NULL, context);
+       
+    /* select the starting node */
+    switch (node->type) {
+       case XML_ELEMENT_NODE:
+           cur = node;
+           break;
+       case XML_ATTRIBUTE_NODE:
+           cur = ((xmlAttrPtr) node)->parent;
+           break;
+       case XML_TEXT_NODE:
+       case XML_PI_NODE:
+       case XML_COMMENT_NODE:
+           cur = node->parent;
+           break;
+       default:
+           cur = NULL;
+           break;
+    }
+
+    while (cur != NULL) {
+       /* process current node */
+       if (count == NULL) {
+           if ((node->type == cur->type) &&
+               /* FIXME: must use expanded-name instead of local name */
+               xmlStrEqual(node->name, cur->name)) {
+                   if ((node->ns == cur->ns) ||
+                       ((node->ns != NULL) &&
+                        (cur->ns != NULL) &&
+                        (xmlStrEqual(node->ns->href,
+                            cur->ns->href) )))
+                       cnt++;
+           }
+       } else {
+           if (xsltTestCompMatchList(context, cur, countPat))
+               cnt++;
+       }
+       if ((from != NULL) &&
+           xsltTestCompMatchList(context, cur, fromPat)) {
+           break; /* while */
+       }
+
+       /* Skip to next preceding or ancestor */
+       if ((cur->type == XML_DOCUMENT_NODE) ||
+#ifdef LIBXML_DOCB_ENABLED
+            (cur->type == XML_DOCB_DOCUMENT_NODE) ||
+#endif
+            (cur->type == XML_HTML_DOCUMENT_NODE))
+           break; /* while */
+
+       while ((cur->prev != NULL) && ((cur->prev->type == XML_DTD_NODE) ||
+              (cur->prev->type == XML_XINCLUDE_START) ||
+              (cur->prev->type == XML_XINCLUDE_END)))
+           cur = cur->prev;
+       if (cur->prev != NULL) {
+           for (cur = cur->prev; cur->last != NULL; cur = cur->last);
+       } else {
+           cur = cur->parent;
+       }
+
+    }
+
+    array[amount++] = (double) cnt;
+
+    if (countPat != NULL)
+       xsltFreeCompMatchList(countPat);
+    if (fromPat != NULL)
+       xsltFreeCompMatchList(fromPat);
+    return(amount);
+}
+
+static int
+xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context,
+                                xmlNodePtr node,
+                                const xmlChar *count,
+                                const xmlChar *from,
+                                double *array,
+                                int max,
+                                xmlDocPtr doc,
+                                xmlNodePtr elem)
+{
+    int amount = 0;
+    int cnt;
+    xmlNodePtr ancestor;
+    xmlNodePtr preceding;
+    xmlXPathParserContextPtr parser;
+    xsltCompMatchPtr countPat;
+    xsltCompMatchPtr fromPat;
+
+    if (count != NULL)
+       countPat = xsltCompilePattern(count, doc, elem, NULL, context);
+    else
+       countPat = NULL;
+    if (from != NULL)
+       fromPat = xsltCompilePattern(from, doc, elem, NULL, context);
+    else
+       fromPat = NULL;
+    context->xpathCtxt->node = node;
+    parser = xmlXPathNewParserContext(NULL, context->xpathCtxt);
+    if (parser) {
+       /* ancestor-or-self::*[count] */
+       for (ancestor = node;
+            (ancestor != NULL) && (ancestor->type != XML_DOCUMENT_NODE);
+            ancestor = xmlXPathNextAncestor(parser, ancestor)) {
+           
+           if ((from != NULL) &&
+               xsltTestCompMatchList(context, ancestor, fromPat))
+               break; /* for */
+           
+           if ((count == NULL && node->type == ancestor->type && 
+               xmlStrEqual(node->name, ancestor->name)) ||
+               xsltTestCompMatchList(context, ancestor, countPat)) {
+               /* count(preceding-sibling::*) */
+               cnt = 0;
+               for (preceding = ancestor;
+                    preceding != NULL;
+                    preceding = 
+                       xmlXPathNextPrecedingSibling(parser, preceding)) {
+                   if (count == NULL) {
+                       if ((preceding->type == ancestor->type) &&
+                           xmlStrEqual(preceding->name, ancestor->name)){
+                           if ((preceding->ns == ancestor->ns) ||
+                               ((preceding->ns != NULL) &&
+                                (ancestor->ns != NULL) &&
+                                (xmlStrEqual(preceding->ns->href,
+                                    ancestor->ns->href) )))
+                               cnt++;
+                       }
+                   } else {
+                       if (xsltTestCompMatchList(context, preceding,
+                                                 countPat))
+                           cnt++;
+                   }
+               }
+               array[amount++] = (double)cnt;
+               if (amount >= max)
+                   break; /* for */
+           }
+       }
+       xmlXPathFreeParserContext(parser);
+    }
+    xsltFreeCompMatchList(countPat);
+    xsltFreeCompMatchList(fromPat);
+    return amount;
+}
+
+static int
+xsltNumberFormatGetValue(xmlXPathContextPtr context,
+                        xmlNodePtr node,
+                        const xmlChar *value,
+                        double *number)
+{
+    int amount = 0;
+    xmlBufferPtr pattern;
+    xmlXPathObjectPtr obj;
+    
+    pattern = xmlBufferCreate();
+    if (pattern != NULL) {
+       xmlBufferCCat(pattern, "number(");
+       xmlBufferCat(pattern, value);
+       xmlBufferCCat(pattern, ")");
+       context->node = node;
+       obj = xmlXPathEvalExpression(xmlBufferContent(pattern),
+                                    context);
+       if (obj != NULL) {
+           *number = obj->floatval;
+           amount++;
+           xmlXPathFreeObject(obj);
+       }
+       xmlBufferFree(pattern);
+    }
+    return amount;
+}
+
+/**
+ * xsltNumberFormat:
+ * @ctxt: the XSLT transformation context
+ * @data: the formatting informations
+ * @node: the data to format
+ *
+ * Convert one number.
+ */
+void
+xsltNumberFormat(xsltTransformContextPtr ctxt,
+                xsltNumberDataPtr data,
+                xmlNodePtr node)
+{
+    xmlBufferPtr output = NULL;
+    int amount, i;
+    double number;
+    xsltFormat tokens;
+    int tempformat = 0;
+
+    if ((data->format == NULL) && (data->has_format != 0)) {
+       data->format = xsltEvalAttrValueTemplate(ctxt, data->node,
+                                            (const xmlChar *) "format",
+                                            XSLT_NAMESPACE);
+       tempformat = 1;
+    }
+    if (data->format == NULL) {
+       return;
+    }
+
+    output = xmlBufferCreate();
+    if (output == NULL)
+       goto XSLT_NUMBER_FORMAT_END;
+
+    xsltNumberFormatTokenize(data->format, &tokens);
+
+    /*
+     * Evaluate the XPath expression to find the value(s)
+     */
+    if (data->value) {
+       amount = xsltNumberFormatGetValue(ctxt->xpathCtxt,
+                                         node,
+                                         data->value,
+                                         &number);
+       if (amount == 1) {
+           xsltNumberFormatInsertNumbers(data,
+                                         &number,
+                                         1,
+                                         &tokens,
+                                         output);
+       }
+       
+    } else if (data->level) {
+       
+       if (xmlStrEqual(data->level, (const xmlChar *) "single")) {
+           amount = xsltNumberFormatGetMultipleLevel(ctxt,
+                                                     node,
+                                                     data->count,
+                                                     data->from,
+                                                     &number,
+                                                     1,
+                                                     data->doc,
+                                                     data->node);
+           if (amount == 1) {
+               xsltNumberFormatInsertNumbers(data,
+                                             &number,
+                                             1,
+                                             &tokens,
+                                             output);
+           }
+       } else if (xmlStrEqual(data->level, (const xmlChar *) "multiple")) {
+           double numarray[1024];
+           int max = sizeof(numarray)/sizeof(numarray[0]);
+           amount = xsltNumberFormatGetMultipleLevel(ctxt,
+                                                     node,
+                                                     data->count,
+                                                     data->from,
+                                                     numarray,
+                                                     max,
+                                                     data->doc,
+                                                     data->node);
+           if (amount > 0) {
+               xsltNumberFormatInsertNumbers(data,
+                                             numarray,
+                                             amount,
+                                             &tokens,
+                                             output);
+           }
+       } else if (xmlStrEqual(data->level, (const xmlChar *) "any")) {
+           amount = xsltNumberFormatGetAnyLevel(ctxt,
+                                                node,
+                                                data->count,
+                                                data->from,
+                                                &number, 
+                                                data->doc,
+                                                data->node);
+           if (amount > 0) {
+               xsltNumberFormatInsertNumbers(data,
+                                             &number,
+                                             1,
+                                             &tokens,
+                                             output);
+           }
+       }
+    }
+    /* Insert number as text node */
+    xsltCopyTextString(ctxt, ctxt->insert, xmlBufferContent(output), 0);
+
+    if (tokens.start != NULL)
+       xmlFree(tokens.start);
+    if (tokens.end != NULL)
+       xmlFree(tokens.end);
+    for (i = 0;i < tokens.nTokens;i++) {
+       if (tokens.tokens[i].separator != NULL)
+           xmlFree(tokens.tokens[i].separator);
+    }
+    
+XSLT_NUMBER_FORMAT_END:
+    if (tempformat == 1) {
+       /* The format need to be recomputed each time */
+       data->format = NULL;
+    }
+    if (output != NULL)
+       xmlBufferFree(output);
+}
+
+static int
+xsltFormatNumberPreSuffix(xsltDecimalFormatPtr self, xmlChar **format, xsltFormatNumberInfoPtr info)
+{
+    int        count=0;        /* will hold total length of prefix/suffix */
+    int len;
+
+    while (1) {
+       /* 
+        * prefix / suffix ends at end of string or at 
+        * first 'special' character 
+        */
+       if (**format == 0)
+           return count;
+       /* if next character 'escaped' just count it */
+       if (**format == SYMBOL_QUOTE) {
+           if (*++(*format) == 0)
+               return -1;
+       }
+       else if (IS_SPECIAL(self, *format))
+           return count;
+       /*
+        * else treat percent/per-mille as special cases,
+        * depending on whether +ve or -ve 
+        */
+       else {
+           /*
+            * for +ve prefix/suffix, allow only a 
+            * single occurence of either 
+            */
+           if (xsltUTF8Charcmp(*format, self->percent) == 0) {
+               if (info->is_multiplier_set)
+                   return -1;
+               info->multiplier = 100;
+               info->is_multiplier_set = TRUE;
+           } else if (xsltUTF8Charcmp(*format, self->permille) == 0) {
+               if (info->is_multiplier_set)
+                   return -1;
+               info->multiplier = 1000;
+               info->is_multiplier_set = TRUE;
+           }
+       }
+       
+       if ((len=xsltUTF8Size(*format)) < 1)
+           return -1;
+       count += len;
+       *format += len;
+    }
+}
+           
+/**
+ * xsltFormatNumberConversion:
+ * @self: the decimal format
+ * @format: the format requested
+ * @number: the value to format
+ * @result: the place to ouput the result
+ *
+ * format-number() uses the JDK 1.1 DecimalFormat class:
+ *
+ * http://java.sun.com/products/jdk/1.1/docs/api/java.text.DecimalFormat.html
+ *
+ * Structure:
+ *
+ *   pattern    := subpattern{;subpattern}
+ *   subpattern := {prefix}integer{.fraction}{suffix}
+ *   prefix     := '\\u0000'..'\\uFFFD' - specialCharacters
+ *   suffix     := '\\u0000'..'\\uFFFD' - specialCharacters
+ *   integer    := '#'* '0'* '0'
+ *   fraction   := '0'* '#'*
+ *
+ *   Notation:
+ *    X*       0 or more instances of X
+ *    (X | Y)  either X or Y.
+ *    X..Y     any character from X up to Y, inclusive.
+ *    S - T    characters in S, except those in T
+ *
+ * Special Characters:
+ *
+ *   Symbol Meaning
+ *   0      a digit
+ *   #      a digit, zero shows as absent
+ *   .      placeholder for decimal separator
+ *   ,      placeholder for grouping separator.
+ *   ;      separates formats.
+ *   -      default negative prefix.
+ *   %      multiply by 100 and show as percentage
+ *   ?      multiply by 1000 and show as per mille
+ *   X      any other characters can be used in the prefix or suffix
+ *   '      used to quote special characters in a prefix or suffix.
+ *
+ * Returns a possible XPath error
+ */
+xmlXPathError
+xsltFormatNumberConversion(xsltDecimalFormatPtr self,
+                          xmlChar *format,
+                          double number,
+                          xmlChar **result)
+{
+    xmlXPathError status = XPATH_EXPRESSION_OK;
+    xmlBufferPtr buffer;
+    xmlChar *the_format, *prefix = NULL, *suffix = NULL;
+    xmlChar *nprefix, *nsuffix = NULL;
+    xmlChar pchar;
+    int            prefix_length, suffix_length = 0, nprefix_length, nsuffix_length;
+    double  scale;
+    int            j, len;
+    int     self_grouping_len;
+    xsltFormatNumberInfo format_info;
+    /* 
+     * delayed_multiplier allows a 'trailing' percent or
+     * permille to be treated as suffix 
+     */
+    int                delayed_multiplier = 0;
+    /* flag to show no -ve format present for -ve number */
+    char       default_sign = 0;
+    /* flag to show error found, should use default format */
+    char       found_error = 0;
+
+    if (xmlStrlen(format) <= 0) {
+       xsltTransformError(NULL, NULL, NULL,
+                "xsltFormatNumberConversion : "
+               "Invalid format (0-length)\n");
+    }
+    *result = NULL;
+    switch (xmlXPathIsInf(number)) {
+       case -1:
+           if (self->minusSign == NULL)
+               *result = xmlStrdup(BAD_CAST "-");
+           else
+               *result = xmlStrdup(self->minusSign);
+           /* no-break on purpose */
+       case 1:
+           if ((self == NULL) || (self->infinity == NULL))
+               *result = xmlStrcat(*result, BAD_CAST "Infinity");
+           else
+               *result = xmlStrcat(*result, self->infinity);
+           return(status);
+       default:
+           if (xmlXPathIsNaN(number)) {
+               if ((self == NULL) || (self->noNumber == NULL))
+                   *result = xmlStrdup(BAD_CAST "NaN");
+               else
+                   *result = xmlStrdup(self->noNumber);
+               return(status);
+           }
+    }
+
+    buffer = xmlBufferCreate();
+    if (buffer == NULL) {
+       return XPATH_MEMORY_ERROR;
+    }
+
+    format_info.integer_hash = 0;
+    format_info.integer_digits = 0;
+    format_info.frac_digits = 0;
+    format_info.frac_hash = 0;
+    format_info.group = -1;
+    format_info.multiplier = 1;
+    format_info.add_decimal = FALSE;
+    format_info.is_multiplier_set = FALSE;
+    format_info.is_negative_pattern = FALSE;
+
+    the_format = format;
+
+    /*
+     * First we process the +ve pattern to get percent / permille,
+     * as well as main format 
+     */
+    prefix = the_format;
+    prefix_length = xsltFormatNumberPreSuffix(self, &the_format, &format_info);
+    if (prefix_length < 0) {
+       found_error = 1;
+       goto OUTPUT_NUMBER;
+    }
+
+    /* 
+     * Here we process the "number" part of the format.  It gets 
+     * a little messy because of the percent/per-mille - if that
+     * appears at the end, it may be part of the suffix instead 
+     * of part of the number, so the variable delayed_multiplier 
+     * is used to handle it 
+     */
+    self_grouping_len = xmlStrlen(self->grouping);
+    while ((*the_format != 0) &&
+          (xsltUTF8Charcmp(the_format, self->decimalPoint) != 0) &&
+          (xsltUTF8Charcmp(the_format, self->patternSeparator) != 0)) {
+       
+       if (delayed_multiplier != 0) {
+           format_info.multiplier = delayed_multiplier;
+           format_info.is_multiplier_set = TRUE;
+           delayed_multiplier = 0;
+       }
+       if (xsltUTF8Charcmp(the_format, self->digit) == 0) {
+           if (format_info.integer_digits > 0) {
+               found_error = 1;
+               goto OUTPUT_NUMBER;
+           }
+           format_info.integer_hash++;
+           if (format_info.group >= 0)
+               format_info.group++;
+       } else if (xsltUTF8Charcmp(the_format, self->zeroDigit) == 0) {
+           format_info.integer_digits++;
+           if (format_info.group >= 0)
+               format_info.group++;
+       } else if ((self_grouping_len > 0) &&
+           (!xmlStrncmp(the_format, self->grouping, self_grouping_len))) {
+           /* Reset group count */
+           format_info.group = 0;
+           the_format += self_grouping_len;
+           continue;
+       } else if (xsltUTF8Charcmp(the_format, self->percent) == 0) {
+           if (format_info.is_multiplier_set) {
+               found_error = 1;
+               goto OUTPUT_NUMBER;
+           }
+           delayed_multiplier = 100;
+       } else  if (xsltUTF8Charcmp(the_format, self->permille) == 0) {
+           if (format_info.is_multiplier_set) {
+               found_error = 1;
+               goto OUTPUT_NUMBER;
+           }
+           delayed_multiplier = 1000;
+       } else
+           break; /* while */
+       
+       if ((len=xsltUTF8Size(the_format)) < 1) {
+           found_error = 1;
+           goto OUTPUT_NUMBER;
+       }
+       the_format += len;
+
+    }
+
+    /* We have finished the integer part, now work on fraction */
+    if (xsltUTF8Charcmp(the_format, self->decimalPoint) == 0) {
+        format_info.add_decimal = TRUE;
+       the_format += xsltUTF8Size(the_format); /* Skip over the decimal */
+    }
+    
+    while (*the_format != 0) {
+       
+       if (xsltUTF8Charcmp(the_format, self->zeroDigit) == 0) {
+           if (format_info.frac_hash != 0) {
+               found_error = 1;
+               goto OUTPUT_NUMBER;
+           }
+           format_info.frac_digits++;
+       } else if (xsltUTF8Charcmp(the_format, self->digit) == 0) {
+           format_info.frac_hash++;
+       } else if (xsltUTF8Charcmp(the_format, self->percent) == 0) {
+           if (format_info.is_multiplier_set) {
+               found_error = 1;
+               goto OUTPUT_NUMBER;
+           }
+           delayed_multiplier = 100;
+           if ((len = xsltUTF8Size(the_format)) < 1) {
+               found_error = 1;
+               goto OUTPUT_NUMBER;
+           }
+           the_format += len;
+           continue; /* while */
+       } else if (xsltUTF8Charcmp(the_format, self->permille) == 0) {
+           if (format_info.is_multiplier_set) {
+               found_error = 1;
+               goto OUTPUT_NUMBER;
+           }
+           delayed_multiplier = 1000;
+           if  ((len = xsltUTF8Size(the_format)) < 1) {
+               found_error = 1;
+               goto OUTPUT_NUMBER;
+           }
+           the_format += len;
+           continue; /* while */
+       } else if (xsltUTF8Charcmp(the_format, self->grouping) != 0) {
+           break; /* while */
+       }
+       if ((len = xsltUTF8Size(the_format)) < 1) {
+           found_error = 1;
+           goto OUTPUT_NUMBER;
+       }
+       the_format += len;
+       if (delayed_multiplier != 0) {
+           format_info.multiplier = delayed_multiplier;
+           delayed_multiplier = 0;
+           format_info.is_multiplier_set = TRUE;
+       }
+    }
+
+    /* 
+     * If delayed_multiplier is set after processing the 
+     * "number" part, should be in suffix 
+     */
+    if (delayed_multiplier != 0) {
+       the_format -= len;
+       delayed_multiplier = 0;
+    }
+
+    suffix = the_format;
+    suffix_length = xsltFormatNumberPreSuffix(self, &the_format, &format_info);
+    if ( (suffix_length < 0) ||
+        ((*the_format != 0) && 
+         (xsltUTF8Charcmp(the_format, self->patternSeparator) != 0)) ) {
+       found_error = 1;
+       goto OUTPUT_NUMBER;
+    }
+
+    /*
+     * We have processed the +ve prefix, number part and +ve suffix.
+     * If the number is -ve, we must substitute the -ve prefix / suffix
+     */
+    if (number < 0) {
+        /*
+        * Note that j is the number of UTF8 chars before the separator,
+        * not the number of bytes! (bug 151975)
+        */
+        j =  xmlUTF8Strloc(format, self->patternSeparator);
+       if (j < 0) {
+       /* No -ve pattern present, so use default signing */
+           default_sign = 1;
+       }
+       else {
+           /* Skip over pattern separator (accounting for UTF8) */
+           the_format = (xmlChar *)xmlUTF8Strpos(format, j + 1);
+           /* 
+            * Flag changes interpretation of percent/permille 
+            * in -ve pattern 
+            */
+           format_info.is_negative_pattern = TRUE;
+           format_info.is_multiplier_set = FALSE;
+
+           /* First do the -ve prefix */
+           nprefix = the_format;
+           nprefix_length = xsltFormatNumberPreSuffix(self, 
+                                       &the_format, &format_info);
+           if (nprefix_length<0) {
+               found_error = 1;
+               goto OUTPUT_NUMBER;
+           }
+
+           while (*the_format != 0) {
+               if ( (xsltUTF8Charcmp(the_format, (self)->percent) == 0) ||
+                    (xsltUTF8Charcmp(the_format, (self)->permille)== 0) ) {
+                   if (format_info.is_multiplier_set) {
+                       found_error = 1;
+                       goto OUTPUT_NUMBER;
+                   }
+                   format_info.is_multiplier_set = TRUE;
+                   delayed_multiplier = 1;
+               }
+               else if (IS_SPECIAL(self, the_format))
+                   delayed_multiplier = 0;
+               else
+                   break; /* while */
+               if ((len = xsltUTF8Size(the_format)) < 1) {
+                   found_error = 1;
+                   goto OUTPUT_NUMBER;
+               }
+               the_format += len;
+           }
+           if (delayed_multiplier != 0) {
+               format_info.is_multiplier_set = FALSE;
+               the_format -= len;
+           }
+
+           /* Finally do the -ve suffix */
+           if (*the_format != 0) {
+               nsuffix = the_format;
+               nsuffix_length = xsltFormatNumberPreSuffix(self, 
+                                       &the_format, &format_info);
+               if (nsuffix_length < 0) {
+                   found_error = 1;
+                   goto OUTPUT_NUMBER;
+               }
+           }
+           else
+               nsuffix_length = 0;
+           if (*the_format != 0) {
+               found_error = 1;
+               goto OUTPUT_NUMBER;
+           }
+           /*
+            * Here's another Java peculiarity:
+            * if -ve prefix/suffix == +ve ones, discard & use default
+            */
+           if ((nprefix_length != prefix_length) ||
+               (nsuffix_length != suffix_length) ||
+               ((nprefix_length > 0) && 
+                (xmlStrncmp(nprefix, prefix, prefix_length) !=0 )) ||
+               ((nsuffix_length > 0) && 
+                (xmlStrncmp(nsuffix, suffix, suffix_length) !=0 ))) {
+               prefix = nprefix;
+               prefix_length = nprefix_length;
+               suffix = nsuffix;
+               suffix_length = nsuffix_length;
+           } /* else {
+               default_sign = 1;
+           }
+           */
+       }
+    }
+
+OUTPUT_NUMBER:
+    if (found_error != 0) {
+       xsltTransformError(NULL, NULL, NULL,
+                "xsltFormatNumberConversion : "
+               "error in format string '%s', using default\n", format);
+       default_sign = (number < 0.0) ? 1 : 0;
+       prefix_length = suffix_length = 0;
+       format_info.integer_hash = 0;
+       format_info.integer_digits = 1;
+       format_info.frac_digits = 1;
+       format_info.frac_hash = 4;
+       format_info.group = -1;
+       format_info.multiplier = 1;
+       format_info.add_decimal = TRUE;
+    }
+
+    /* Ready to output our number.  First see if "default sign" is required */
+    if (default_sign != 0)
+       xmlBufferAdd(buffer, self->minusSign, xsltUTF8Size(self->minusSign));
+
+    /* Put the prefix into the buffer */
+    for (j = 0; j < prefix_length; j++) {
+       if ((pchar = *prefix++) == SYMBOL_QUOTE) {
+           len = xsltUTF8Size(prefix);
+           xmlBufferAdd(buffer, prefix, len);
+           prefix += len;
+           j += len - 1;       /* length of symbol less length of quote */
+       } else
+           xmlBufferAdd(buffer, &pchar, 1);
+    }
+
+    /* Next do the integer part of the number */
+    number = fabs(number) * (double)format_info.multiplier;
+    scale = pow(10.0, (double)(format_info.frac_digits + format_info.frac_hash));
+    number = floor((scale * number + 0.5)) / scale;
+    if ((self->grouping != NULL) && 
+        (self->grouping[0] != 0)) {
+       
+       len = xmlStrlen(self->grouping);
+       pchar = xsltGetUTF8Char(self->grouping, &len);
+       xsltNumberFormatDecimal(buffer, floor(number), self->zeroDigit[0],
+                               format_info.integer_digits,
+                               format_info.group,
+                               pchar, len);
+    } else
+       xsltNumberFormatDecimal(buffer, floor(number), self->zeroDigit[0],
+                               format_info.integer_digits,
+                               format_info.group,
+                               ',', 1);
+
+    /* Special case: java treats '.#' like '.0', '.##' like '.0#', etc. */
+    if ((format_info.integer_digits + format_info.integer_hash +
+        format_info.frac_digits == 0) && (format_info.frac_hash > 0)) {
+        ++format_info.frac_digits;
+       --format_info.frac_hash;
+    }
+
+    /* Add leading zero, if required */
+    if ((floor(number) == 0) &&
+       (format_info.integer_digits + format_info.frac_digits == 0)) {
+        xmlBufferAdd(buffer, self->zeroDigit, xsltUTF8Size(self->zeroDigit));
+    }
+
+    /* Next the fractional part, if required */
+    if (format_info.frac_digits + format_info.frac_hash == 0) {
+        if (format_info.add_decimal)
+           xmlBufferAdd(buffer, self->decimalPoint, 
+                        xsltUTF8Size(self->decimalPoint));
+    }
+    else {
+      number -= floor(number);
+       if ((number != 0) || (format_info.frac_digits != 0)) {
+           xmlBufferAdd(buffer, self->decimalPoint,
+                        xsltUTF8Size(self->decimalPoint));
+           number = floor(scale * number + 0.5);
+           for (j = format_info.frac_hash; j > 0; j--) {
+               if (fmod(number, 10.0) >= 1.0)
+                   break; /* for */
+               number /= 10.0;
+           }
+           xsltNumberFormatDecimal(buffer, floor(number), self->zeroDigit[0],
+                               format_info.frac_digits + j,
+                               0, 0, 0);
+       }
+    }
+    /* Put the suffix into the buffer */
+    for (j = 0; j < suffix_length; j++) {
+       if ((pchar = *suffix++) == SYMBOL_QUOTE) {
+            len = xsltUTF8Size(suffix);
+           xmlBufferAdd(buffer, suffix, len);
+           suffix += len;
+           j += len - 1;       /* length of symbol less length of escape */
+       } else
+           xmlBufferAdd(buffer, &pchar, 1);
+    }
+
+    *result = xmlStrdup(xmlBufferContent(buffer));
+    xmlBufferFree(buffer);
+    return status;
+}
+
diff --git a/reactos/dll/3rdparty/libxslt/numbersInternals.h b/reactos/dll/3rdparty/libxslt/numbersInternals.h
new file mode 100644 (file)
index 0000000..7b3cb17
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Summary: Implementation of the XSLT number functions
+ * Description: Implementation of the XSLT number functions
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Bjorn Reese <breese@users.sourceforge.net> and Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_NUMBERSINTERNALS_H__
+#define __XML_XSLT_NUMBERSINTERNALS_H__
+
+#include <libxml/tree.h>
+#include "xsltexports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * xsltNumberData:
+ *
+ * This data structure is just a wrapper to pass xsl:number data in.
+ */
+typedef struct _xsltNumberData xsltNumberData;
+typedef xsltNumberData *xsltNumberDataPtr;
+    
+struct _xsltNumberData {
+    const xmlChar *level;
+    const xmlChar *count;
+    const xmlChar *from;
+    const xmlChar *value;
+    const xmlChar *format;
+    int has_format;
+    int digitsPerGroup;
+    int groupingCharacter;
+    int groupingCharacterLen;
+    xmlDocPtr doc;
+    xmlNodePtr node;
+
+    /*
+     * accelerators
+     */
+};
+
+/**
+ * xsltFormatNumberInfo,:
+ *
+ * This data structure lists the various parameters needed to format numbers.
+ */
+typedef struct _xsltFormatNumberInfo xsltFormatNumberInfo;
+typedef xsltFormatNumberInfo *xsltFormatNumberInfoPtr;
+
+struct _xsltFormatNumberInfo {
+    int            integer_hash;       /* Number of '#' in integer part */
+    int            integer_digits;     /* Number of '0' in integer part */
+    int            frac_digits;        /* Number of '0' in fractional part */
+    int            frac_hash;          /* Number of '#' in fractional part */
+    int            group;              /* Number of chars per display 'group' */
+    int     multiplier;                /* Scaling for percent or permille */
+    char    add_decimal;       /* Flag for whether decimal point appears in pattern */
+    char    is_multiplier_set; /* Flag to catch multiple occurences of percent/permille */
+    char    is_negative_pattern;/* Flag for processing -ve prefix/suffix */
+};
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __XML_XSLT_NUMBERSINTERNALS_H__ */
diff --git a/reactos/dll/3rdparty/libxslt/pattern.c b/reactos/dll/3rdparty/libxslt/pattern.c
new file mode 100644 (file)
index 0000000..419fa3d
--- /dev/null
@@ -0,0 +1,2619 @@
+/*
+ * pattern.c: Implemetation of the template match compilation and lookup
+ *
+ * Reference:
+ *   http://www.w3.org/TR/1999/REC-xslt-19991116
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+/*
+ * TODO: handle pathological cases like *[*[@a="b"]]
+ * TODO: detect [number] at compilation, optimize accordingly
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/valid.h>
+#include <libxml/hash.h>
+#include <libxml/xmlerror.h>
+#include <libxml/parserInternals.h>
+#include "xslt.h"
+#include "xsltInternals.h"
+#include "xsltutils.h"
+#include "imports.h"
+#include "templates.h"
+#include "keys.h"
+#include "pattern.h"
+#include "documents.h"
+
+#ifdef WITH_XSLT_DEBUG
+#define WITH_XSLT_DEBUG_PATTERN
+#endif
+
+/*
+ * Types are private:
+ */
+
+typedef enum {
+    XSLT_OP_END=0,
+    XSLT_OP_ROOT,
+    XSLT_OP_ELEM,
+    XSLT_OP_CHILD,
+    XSLT_OP_ATTR,
+    XSLT_OP_PARENT,
+    XSLT_OP_ANCESTOR,
+    XSLT_OP_ID,
+    XSLT_OP_KEY,
+    XSLT_OP_NS,
+    XSLT_OP_ALL,
+    XSLT_OP_PI,
+    XSLT_OP_COMMENT,
+    XSLT_OP_TEXT,
+    XSLT_OP_NODE,
+    XSLT_OP_PREDICATE
+} xsltOp;
+
+typedef struct _xsltStepState xsltStepState;
+typedef xsltStepState *xsltStepStatePtr;
+struct _xsltStepState {
+    int step;
+    xmlNodePtr node;
+};
+
+typedef struct _xsltStepStates xsltStepStates;
+typedef xsltStepStates *xsltStepStatesPtr;
+struct _xsltStepStates {
+    int nbstates;
+    int maxstates;
+    xsltStepStatePtr states;
+};
+
+typedef struct _xsltStepOp xsltStepOp;
+typedef xsltStepOp *xsltStepOpPtr;
+struct _xsltStepOp {
+    xsltOp op;
+    xmlChar *value;
+    xmlChar *value2;
+    xmlChar *value3;
+    xmlXPathCompExprPtr comp;
+    /*
+     * Optimisations for count
+     */
+    int        previousExtra;
+    int        indexExtra;
+    int        lenExtra;
+};
+
+struct _xsltCompMatch {
+    struct _xsltCompMatch *next; /* siblings in the name hash */
+    float priority;              /* the priority */
+    const xmlChar *pattern;       /* the pattern */
+    const xmlChar *mode;         /* the mode */
+    const xmlChar *modeURI;      /* the mode URI */
+    xsltTemplatePtr template;    /* the associated template */
+
+    int direct;
+    /* TODO fix the statically allocated size steps[] */
+    int nbStep;
+    int maxStep;
+    xmlNsPtr *nsList;          /* the namespaces in scope */
+    int nsNr;                  /* the number of namespaces in scope */
+    xsltStepOpPtr steps;        /* ops for computation */
+};
+
+typedef struct _xsltParserContext xsltParserContext;
+typedef xsltParserContext *xsltParserContextPtr;
+struct _xsltParserContext {
+    xsltStylesheetPtr style;           /* the stylesheet */
+    xsltTransformContextPtr ctxt;      /* the transformation or NULL */
+    const xmlChar *cur;                        /* the current char being parsed */
+    const xmlChar *base;               /* the full expression */
+    xmlDocPtr      doc;                        /* the source document */
+    xmlNodePtr    elem;                        /* the source element */
+    int error;                         /* error code */
+    xsltCompMatchPtr comp;             /* the result */
+};
+
+/************************************************************************
+ *                                                                     *
+ *                     Type functions                                  *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltNewCompMatch:
+ *
+ * Create a new XSLT CompMatch
+ *
+ * Returns the newly allocated xsltCompMatchPtr or NULL in case of error
+ */
+static xsltCompMatchPtr
+xsltNewCompMatch(void) {
+    xsltCompMatchPtr cur;
+
+    cur = (xsltCompMatchPtr) xmlMalloc(sizeof(xsltCompMatch));
+    if (cur == NULL) {
+       xsltTransformError(NULL, NULL, NULL,
+               "xsltNewCompMatch : out of memory error\n");
+       return(NULL);
+    }
+    memset(cur, 0, sizeof(xsltCompMatch));
+    cur->maxStep = 10;
+    cur->nbStep = 0;
+    cur-> steps = (xsltStepOpPtr) xmlMalloc(sizeof(xsltStepOp) *
+                                            cur->maxStep);
+    if (cur->steps == NULL) {
+       xsltTransformError(NULL, NULL, NULL,
+               "xsltNewCompMatch : out of memory error\n");
+       xmlFree(cur);
+       return(NULL);
+    }
+    cur->nsNr = 0;
+    cur->nsList = NULL;
+    cur->direct = 0;
+    return(cur);
+}
+
+/**
+ * xsltFreeCompMatch:
+ * @comp:  an XSLT comp
+ *
+ * Free up the memory allocated by @comp
+ */
+static void
+xsltFreeCompMatch(xsltCompMatchPtr comp) {
+    xsltStepOpPtr op;
+    int i;
+
+    if (comp == NULL)
+       return;
+    if (comp->pattern != NULL)
+       xmlFree((xmlChar *)comp->pattern);
+    if (comp->nsList != NULL)
+       xmlFree(comp->nsList);
+    for (i = 0;i < comp->nbStep;i++) {
+       op = &comp->steps[i];
+       if (op->value != NULL)
+           xmlFree(op->value);
+       if (op->value2 != NULL)
+           xmlFree(op->value2);
+       if (op->value3 != NULL)
+           xmlFree(op->value3);
+       if (op->comp != NULL)
+           xmlXPathFreeCompExpr(op->comp);
+    }
+    xmlFree(comp->steps);
+    memset(comp, -1, sizeof(xsltCompMatch));
+    xmlFree(comp);
+}
+
+/**
+ * xsltFreeCompMatchList:
+ * @comp:  an XSLT comp list
+ *
+ * Free up the memory allocated by all the elements of @comp
+ */
+void
+xsltFreeCompMatchList(xsltCompMatchPtr comp) {
+    xsltCompMatchPtr cur;
+
+    while (comp != NULL) {
+       cur = comp;
+       comp = comp->next;
+       xsltFreeCompMatch(cur);
+    }
+}
+
+/**
+ * xsltNormalizeCompSteps:
+ * @payload: pointer to template hash table entry
+ * @data: pointer to the stylesheet
+ * @name: template match name
+ *
+ * This is a hashtable scanner function to normalize the compiled
+ * steps of an imported stylesheet.
+ */
+void xsltNormalizeCompSteps(void *payload,
+        void *data, const xmlChar *name ATTRIBUTE_UNUSED) {
+    xsltCompMatchPtr comp = payload;
+    xsltStylesheetPtr style = data;
+    int ix;
+
+    for (ix = 0; ix < comp->nbStep; ix++) {
+        comp->steps[ix].previousExtra += style->extrasNr;
+        comp->steps[ix].indexExtra += style->extrasNr;
+        comp->steps[ix].lenExtra += style->extrasNr;
+    }
+}
+
+/**
+ * xsltNewParserContext:
+ * @style:  the stylesheet
+ * @ctxt:  the transformation context, if done at run-time
+ *
+ * Create a new XSLT ParserContext
+ *
+ * Returns the newly allocated xsltParserContextPtr or NULL in case of error
+ */
+static xsltParserContextPtr
+xsltNewParserContext(xsltStylesheetPtr style, xsltTransformContextPtr ctxt) {
+    xsltParserContextPtr cur;
+
+    cur = (xsltParserContextPtr) xmlMalloc(sizeof(xsltParserContext));
+    if (cur == NULL) {
+       xsltTransformError(NULL, NULL, NULL,
+               "xsltNewParserContext : malloc failed\n");
+       return(NULL);
+    }
+    memset(cur, 0, sizeof(xsltParserContext));
+    cur->style = style;
+    cur->ctxt = ctxt;
+    return(cur);
+}
+
+/**
+ * xsltFreeParserContext:
+ * @ctxt:  an XSLT parser context
+ *
+ * Free up the memory allocated by @ctxt
+ */
+static void
+xsltFreeParserContext(xsltParserContextPtr ctxt) {
+    if (ctxt == NULL)
+       return;
+    memset(ctxt, -1, sizeof(xsltParserContext));
+    xmlFree(ctxt);
+}
+
+/**
+ * xsltCompMatchAdd:
+ * @comp:  the compiled match expression
+ * @op:  an op
+ * @value:  the first value
+ * @value2:  the second value
+ * @novar:  flag to set XML_XPATH_NOVAR
+ *
+ * Add an step to an XSLT Compiled Match
+ *
+ * Returns -1 in case of failure, 0 otherwise.
+ */
+static int
+xsltCompMatchAdd(xsltParserContextPtr ctxt, xsltCompMatchPtr comp,
+                 xsltOp op, xmlChar * value, xmlChar * value2, int novar)
+{
+    if (comp->nbStep >= comp->maxStep) {
+        xsltStepOpPtr tmp;
+
+       tmp = (xsltStepOpPtr) xmlRealloc(comp->steps, comp->maxStep * 2 *
+                                        sizeof(xsltStepOp));
+       if (tmp == NULL) {
+           xsltGenericError(xsltGenericErrorContext,
+            "xsltCompMatchAdd: memory re-allocation failure.\n");
+           if (ctxt->style != NULL)
+               ctxt->style->errors++;
+           return (-1);
+       }
+        comp->maxStep *= 2;
+       comp->steps = tmp;
+    }
+    comp->steps[comp->nbStep].op = op;
+    comp->steps[comp->nbStep].value = value;
+    comp->steps[comp->nbStep].value2 = value2;
+    comp->steps[comp->nbStep].value3 = NULL;
+    comp->steps[comp->nbStep].comp = NULL;
+    if (ctxt->ctxt != NULL) {
+       comp->steps[comp->nbStep].previousExtra =
+           xsltAllocateExtraCtxt(ctxt->ctxt);
+       comp->steps[comp->nbStep].indexExtra =
+           xsltAllocateExtraCtxt(ctxt->ctxt);
+       comp->steps[comp->nbStep].lenExtra =
+           xsltAllocateExtraCtxt(ctxt->ctxt);
+    } else {
+       comp->steps[comp->nbStep].previousExtra =
+           xsltAllocateExtra(ctxt->style);
+       comp->steps[comp->nbStep].indexExtra =
+           xsltAllocateExtra(ctxt->style);
+       comp->steps[comp->nbStep].lenExtra =
+           xsltAllocateExtra(ctxt->style);
+    }
+    if (op == XSLT_OP_PREDICATE) {
+       xmlXPathContextPtr xctxt;
+
+       if (ctxt->style != NULL)
+           xctxt = xmlXPathNewContext(ctxt->style->doc);
+       else
+           xctxt = xmlXPathNewContext(NULL);
+#ifdef XML_XPATH_NOVAR
+       if (novar != 0)
+           xctxt->flags = XML_XPATH_NOVAR;
+#endif
+       if (ctxt->style != NULL)
+           xctxt->dict = ctxt->style->dict;
+       comp->steps[comp->nbStep].comp = xmlXPathCtxtCompile(xctxt, value);
+       xmlXPathFreeContext(xctxt);
+       if (comp->steps[comp->nbStep].comp == NULL) {
+           xsltTransformError(NULL, ctxt->style, ctxt->elem,
+                   "Failed to compile predicate\n");
+           if (ctxt->style != NULL)
+               ctxt->style->errors++;
+       }
+    }
+    comp->nbStep++;
+    return (0);
+}
+
+/**
+ * xsltSwapTopCompMatch:
+ * @comp:  the compiled match expression
+ *
+ * reverse the two top steps.
+ */
+static void
+xsltSwapTopCompMatch(xsltCompMatchPtr comp) {
+    int i;
+    int j = comp->nbStep - 1;
+
+    if (j > 0) {
+       register xmlChar *tmp;
+       register xsltOp op;
+       register xmlXPathCompExprPtr expr; 
+       register int t;
+       i = j - 1;
+       tmp = comp->steps[i].value;
+       comp->steps[i].value = comp->steps[j].value;
+       comp->steps[j].value = tmp;
+       tmp = comp->steps[i].value2;
+       comp->steps[i].value2 = comp->steps[j].value2;
+       comp->steps[j].value2 = tmp;
+       tmp = comp->steps[i].value3;
+       comp->steps[i].value3 = comp->steps[j].value3;
+       comp->steps[j].value3 = tmp;
+       op = comp->steps[i].op;
+       comp->steps[i].op = comp->steps[j].op;
+       comp->steps[j].op = op;
+       expr = comp->steps[i].comp;
+       comp->steps[i].comp = comp->steps[j].comp;
+       comp->steps[j].comp = expr;
+       t = comp->steps[i].previousExtra;
+       comp->steps[i].previousExtra = comp->steps[j].previousExtra;
+       comp->steps[j].previousExtra = t;
+       t = comp->steps[i].indexExtra;
+       comp->steps[i].indexExtra = comp->steps[j].indexExtra;
+       comp->steps[j].indexExtra = t;
+       t = comp->steps[i].lenExtra;
+       comp->steps[i].lenExtra = comp->steps[j].lenExtra;
+       comp->steps[j].lenExtra = t;
+    }
+}
+
+/**
+ * xsltReverseCompMatch:
+ * @ctxt: the parser context
+ * @comp:  the compiled match expression
+ *
+ * reverse all the stack of expressions
+ */
+static void
+xsltReverseCompMatch(xsltParserContextPtr ctxt, xsltCompMatchPtr comp) {
+    int i = 0;
+    int j = comp->nbStep - 1;
+
+    while (j > i) {
+       register xmlChar *tmp;
+       register xsltOp op;
+       register xmlXPathCompExprPtr expr;
+       register int t;
+
+       tmp = comp->steps[i].value;
+       comp->steps[i].value = comp->steps[j].value;
+       comp->steps[j].value = tmp;
+       tmp = comp->steps[i].value2;
+       comp->steps[i].value2 = comp->steps[j].value2;
+       comp->steps[j].value2 = tmp;
+       tmp = comp->steps[i].value3;
+       comp->steps[i].value3 = comp->steps[j].value3;
+       comp->steps[j].value3 = tmp;
+       op = comp->steps[i].op;
+       comp->steps[i].op = comp->steps[j].op;
+       comp->steps[j].op = op;
+       expr = comp->steps[i].comp;
+       comp->steps[i].comp = comp->steps[j].comp;
+       comp->steps[j].comp = expr;
+       t = comp->steps[i].previousExtra;
+       comp->steps[i].previousExtra = comp->steps[j].previousExtra;
+       comp->steps[j].previousExtra = t;
+       t = comp->steps[i].indexExtra;
+       comp->steps[i].indexExtra = comp->steps[j].indexExtra;
+       comp->steps[j].indexExtra = t;
+       t = comp->steps[i].lenExtra;
+       comp->steps[i].lenExtra = comp->steps[j].lenExtra;
+       comp->steps[j].lenExtra = t;
+       j--;
+       i++;
+    }
+    xsltCompMatchAdd(ctxt, comp, XSLT_OP_END, NULL, NULL, 0);
+
+    /*
+     * detect consecutive XSLT_OP_PREDICATE indicating a direct
+     * matching should be done.
+     */
+    for (i = 0;i < comp->nbStep - 1;i++) {
+        if ((comp->steps[i].op == XSLT_OP_PREDICATE) &&
+           (comp->steps[i + 1].op == XSLT_OP_PREDICATE)) {
+
+           comp->direct = 1;
+           if (comp->pattern[0] != '/') {
+               xmlChar *query;
+
+               query = xmlStrdup((const xmlChar *)"//");
+               query = xmlStrcat(query, comp->pattern);
+
+               xmlFree((xmlChar *) comp->pattern);
+               comp->pattern = query;
+           }
+           break;
+       }
+    }
+}
+
+/************************************************************************
+ *                                                                     *
+ *             The interpreter for the precompiled patterns            *
+ *                                                                     *
+ ************************************************************************/
+
+static int
+xsltPatPushState(xsltTransformContextPtr ctxt, xsltStepStates *states,
+                 int step, xmlNodePtr node) {
+    if ((states->states == NULL) || (states->maxstates <= 0)) {
+        states->maxstates = 4;
+       states->nbstates = 0;
+       states->states = xmlMalloc(4 * sizeof(xsltStepState));
+    }
+    else if (states->maxstates <= states->nbstates) {
+        xsltStepState *tmp;
+
+       tmp = (xsltStepStatePtr) xmlRealloc(states->states,
+                              2 * states->maxstates * sizeof(xsltStepState));
+       if (tmp == NULL) {
+           xsltGenericError(xsltGenericErrorContext,
+            "xsltPatPushState: memory re-allocation failure.\n");
+           ctxt->state = XSLT_STATE_STOPPED;
+           return(-1);
+       }
+       states->states = tmp;
+       states->maxstates *= 2;
+    }
+    states->states[states->nbstates].step = step;
+    states->states[states->nbstates++].node = node;
+#if 0
+    fprintf(stderr, "Push: %d, %s\n", step, node->name);
+#endif
+    return(0);
+}
+
+/**
+ * xsltTestCompMatchDirect:
+ * @ctxt:  a XSLT process context
+ * @comp: the precompiled pattern
+ * @node: a node
+ * @nsList: the namespaces in scope
+ * @nsNr: the number of namespaces in scope
+ *
+ * Test whether the node matches the pattern, do a direct evalutation
+ * and not a step by step evaluation.
+ *
+ * Returns 1 if it matches, 0 if it doesn't and -1 in case of failure
+ */
+static int
+xsltTestCompMatchDirect(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
+                       xmlNodePtr node, xmlNsPtr *nsList, int nsNr) {
+    xsltStepOpPtr sel = NULL;
+    xmlDocPtr prevdoc;
+    xmlDocPtr doc;
+    xmlXPathObjectPtr list;
+    int ix, j;
+    int nocache = 0;
+    int isRVT;
+
+    doc = node->doc;
+    if (XSLT_IS_RES_TREE_FRAG(doc))
+       isRVT = 1;
+    else
+       isRVT = 0;
+    sel = &comp->steps[0]; /* store extra in first step arbitrarily */
+
+    prevdoc = (xmlDocPtr)
+       XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr);
+    ix = XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival);
+    list = (xmlXPathObjectPtr)
+       XSLT_RUNTIME_EXTRA_LST(ctxt, sel->lenExtra);
+    
+    if ((list == NULL) || (prevdoc != doc)) {
+       xmlXPathObjectPtr newlist;
+       xmlNodePtr parent = node->parent;
+       xmlDocPtr olddoc;
+       xmlNodePtr oldnode;
+       int oldNsNr;
+       xmlNsPtr *oldNamespaces;
+
+       oldnode = ctxt->xpathCtxt->node;
+       olddoc = ctxt->xpathCtxt->doc;
+       oldNsNr = ctxt->xpathCtxt->nsNr;
+       oldNamespaces = ctxt->xpathCtxt->namespaces;
+       ctxt->xpathCtxt->node = node;
+       ctxt->xpathCtxt->doc = doc;
+       ctxt->xpathCtxt->namespaces = nsList;
+       ctxt->xpathCtxt->nsNr = nsNr;
+       newlist = xmlXPathEval(comp->pattern, ctxt->xpathCtxt);
+       ctxt->xpathCtxt->node = oldnode;
+       ctxt->xpathCtxt->doc = olddoc;
+       ctxt->xpathCtxt->namespaces = oldNamespaces;
+       ctxt->xpathCtxt->nsNr = oldNsNr;
+       if (newlist == NULL)
+           return(-1);
+       if (newlist->type != XPATH_NODESET) {
+           xmlXPathFreeObject(newlist);
+           return(-1);
+       }
+       ix = 0;
+
+       if ((parent == NULL) || (node->doc == NULL) || isRVT)
+           nocache = 1;
+       
+       if (nocache == 0) {
+           if (list != NULL)
+               xmlXPathFreeObject(list);
+           list = newlist;
+
+           XSLT_RUNTIME_EXTRA_LST(ctxt, sel->lenExtra) =
+               (void *) list;
+           XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) =
+               (void *) doc;
+           XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) =
+               0;
+           XSLT_RUNTIME_EXTRA_FREE(ctxt, sel->lenExtra) =
+               (xmlFreeFunc) xmlXPathFreeObject;
+       } else
+           list = newlist;
+    }
+    if ((list->nodesetval == NULL) ||
+       (list->nodesetval->nodeNr <= 0)) {
+       if (nocache == 1)
+           xmlXPathFreeObject(list);
+       return(0);
+    }
+    /* TODO: store the index and use it for the scan */
+    if (ix == 0) {
+       for (j = 0;j < list->nodesetval->nodeNr;j++) {
+           if (list->nodesetval->nodeTab[j] == node) {
+               if (nocache == 1)
+                   xmlXPathFreeObject(list);
+               return(1);
+           }
+       }
+    } else {
+    }
+    if (nocache == 1)
+       xmlXPathFreeObject(list);
+    return(0);
+}
+
+/**
+ * xsltTestCompMatch:
+ * @ctxt:  a XSLT process context
+ * @comp: the precompiled pattern
+ * @node: a node
+ * @mode:  the mode name or NULL
+ * @modeURI:  the mode URI or NULL
+ *
+ * Test whether the node matches the pattern
+ *
+ * Returns 1 if it matches, 0 if it doesn't and -1 in case of failure
+ */
+static int
+xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
+                 xmlNodePtr node, const xmlChar *mode,
+                 const xmlChar *modeURI) {
+    int i;
+    xsltStepOpPtr step, sel = NULL;
+    xsltStepStates states = {0, 0, NULL}; /* // may require backtrack */
+
+    if ((comp == NULL) || (node == NULL) || (ctxt == NULL)) {
+       xsltTransformError(ctxt, NULL, node,
+               "xsltTestCompMatch: null arg\n");
+        return(-1);
+    }
+    if (mode != NULL) {
+       if (comp->mode == NULL)
+           return(0);
+       /*
+        * both mode strings must be interned on the stylesheet dictionary
+        */
+       if (comp->mode != mode)
+           return(0);
+    } else {
+       if (comp->mode != NULL)
+           return(0);
+    }
+    if (modeURI != NULL) {
+       if (comp->modeURI == NULL)
+           return(0);
+       /*
+        * both modeURI strings must be interned on the stylesheet dictionary
+        */
+       if (comp->modeURI != modeURI)
+           return(0);
+    } else {
+       if (comp->modeURI != NULL)
+           return(0);
+    }
+
+    i = 0;
+restart:
+    for (;i < comp->nbStep;i++) {
+       step = &comp->steps[i];
+       if (step->op != XSLT_OP_PREDICATE)
+           sel = step;
+       switch (step->op) {
+            case XSLT_OP_END:
+               goto found;
+            case XSLT_OP_ROOT:
+               if ((node->type == XML_DOCUMENT_NODE) ||
+#ifdef LIBXML_DOCB_ENABLED
+                   (node->type == XML_DOCB_DOCUMENT_NODE) ||
+#endif
+                   (node->type == XML_HTML_DOCUMENT_NODE))
+                   continue;
+               if ((node->type == XML_ELEMENT_NODE) && (node->name[0] == ' '))
+                   continue;
+               goto rollback;
+            case XSLT_OP_ELEM:
+               if (node->type != XML_ELEMENT_NODE)
+                   goto rollback;
+               if (step->value == NULL)
+                   continue;
+               if (step->value[0] != node->name[0])
+                   goto rollback;
+               if (!xmlStrEqual(step->value, node->name))
+                   goto rollback;
+
+               /* Namespace test */
+               if (node->ns == NULL) {
+                   if (step->value2 != NULL)
+                       goto rollback;
+               } else if (node->ns->href != NULL) {
+                   if (step->value2 == NULL)
+                       goto rollback;
+                   if (!xmlStrEqual(step->value2, node->ns->href))
+                       goto rollback;
+               }
+               continue;
+            case XSLT_OP_CHILD: {
+               xmlNodePtr lst;
+
+               if ((node->type != XML_ELEMENT_NODE) &&
+                   (node->type != XML_DOCUMENT_NODE) &&
+#ifdef LIBXML_DOCB_ENABLED
+                   (node->type != XML_DOCB_DOCUMENT_NODE) &&
+#endif
+                   (node->type != XML_HTML_DOCUMENT_NODE))
+                   goto rollback;
+
+               lst = node->children;
+
+               if (step->value != NULL) {
+                   while (lst != NULL) {
+                       if ((lst->type == XML_ELEMENT_NODE) &&
+                           (step->value[0] == lst->name[0]) &&
+                           (xmlStrEqual(step->value, lst->name)))
+                           break;
+                       lst = lst->next;
+                   }
+                   if (lst != NULL)
+                       continue;
+               }
+               goto rollback;
+           }
+            case XSLT_OP_ATTR:
+               if (node->type != XML_ATTRIBUTE_NODE)
+                   goto rollback;
+               if (step->value != NULL) {
+                   if (step->value[0] != node->name[0])
+                       goto rollback;
+                   if (!xmlStrEqual(step->value, node->name))
+                       goto rollback;
+               }
+               /* Namespace test */
+               if (node->ns == NULL) {
+                   if (step->value2 != NULL)
+                       goto rollback;
+               } else if (step->value2 != NULL) {
+                   if (!xmlStrEqual(step->value2, node->ns->href))
+                       goto rollback;
+               }
+               continue;
+            case XSLT_OP_PARENT:
+               if ((node->type == XML_DOCUMENT_NODE) ||
+                   (node->type == XML_HTML_DOCUMENT_NODE) ||
+#ifdef LIBXML_DOCB_ENABLED
+                   (node->type == XML_DOCB_DOCUMENT_NODE) ||
+#endif
+                   (node->type == XML_NAMESPACE_DECL))
+                   goto rollback;
+               node = node->parent;
+               if (node == NULL)
+                   goto rollback;
+               if (step->value == NULL)
+                   continue;
+               if (step->value[0] != node->name[0])
+                   goto rollback;
+               if (!xmlStrEqual(step->value, node->name))
+                   goto rollback;
+               /* Namespace test */
+               if (node->ns == NULL) {
+                   if (step->value2 != NULL)
+                       goto rollback;
+               } else if (node->ns->href != NULL) {
+                   if (step->value2 == NULL)
+                       goto rollback;
+                   if (!xmlStrEqual(step->value2, node->ns->href))
+                       goto rollback;
+               }
+               continue;
+            case XSLT_OP_ANCESTOR:
+               /* TODO: implement coalescing of ANCESTOR/NODE ops */
+               if (step->value == NULL) {
+                   step = &comp->steps[i+1];
+                   if (step->op == XSLT_OP_ROOT)
+                       goto found;
+                   /* added NS, ID and KEY as a result of bug 168208 */
+                   if ((step->op != XSLT_OP_ELEM) && 
+                       (step->op != XSLT_OP_ALL) && 
+                       (step->op != XSLT_OP_NS) &&
+                       (step->op != XSLT_OP_ID) &&
+                       (step->op != XSLT_OP_KEY))
+                       goto rollback;
+               }
+               if (node == NULL)
+                   goto rollback;
+               if ((node->type == XML_DOCUMENT_NODE) ||
+                   (node->type == XML_HTML_DOCUMENT_NODE) ||
+#ifdef LIBXML_DOCB_ENABLED
+                   (node->type == XML_DOCB_DOCUMENT_NODE) ||
+#endif
+                   (node->type == XML_NAMESPACE_DECL))
+                   goto rollback;
+               node = node->parent;
+               if ((step->op != XSLT_OP_ELEM) && step->op != XSLT_OP_ALL) {
+                   xsltPatPushState(ctxt, &states, i, node);
+                   continue;
+               }
+               i++;
+               if (step->value == NULL) {
+                   xsltPatPushState(ctxt, &states, i - 1, node);
+                   continue;
+               }
+               while (node != NULL) {
+                   if ((node->type == XML_ELEMENT_NODE) &&
+                       (step->value[0] == node->name[0]) &&
+                       (xmlStrEqual(step->value, node->name))) {
+                       /* Namespace test */
+                       if (node->ns == NULL) {
+                           if (step->value2 == NULL)
+                               break;
+                       } else if (node->ns->href != NULL) {
+                           if ((step->value2 != NULL) &&
+                               (xmlStrEqual(step->value2, node->ns->href)))
+                               break;
+                       }
+                   }
+                   node = node->parent;
+               }
+               if (node == NULL)
+                   goto rollback;
+               xsltPatPushState(ctxt, &states, i - 1, node);
+               continue;
+            case XSLT_OP_ID: {
+               /* TODO Handle IDs decently, must be done differently */
+               xmlAttrPtr id;
+
+               if (node->type != XML_ELEMENT_NODE)
+                   goto rollback;
+
+               id = xmlGetID(node->doc, step->value);
+               if ((id == NULL) || (id->parent != node))
+                   goto rollback;
+               break;
+           }
+            case XSLT_OP_KEY: {
+               xmlNodeSetPtr list;
+               int indx;
+
+               list = xsltGetKey(ctxt, step->value,
+                                 step->value3, step->value2);
+               if (list == NULL)
+                   goto rollback;
+               for (indx = 0;indx < list->nodeNr;indx++)
+                   if (list->nodeTab[indx] == node)
+                       break;
+               if (indx >= list->nodeNr)
+                   goto rollback;
+               break;
+           }
+            case XSLT_OP_NS:
+               if (node->type != XML_ELEMENT_NODE)
+                   goto rollback;
+               if (node->ns == NULL) {
+                   if (step->value != NULL)
+                       goto rollback;
+               } else if (node->ns->href != NULL) {
+                   if (step->value == NULL)
+                       goto rollback;
+                   if (!xmlStrEqual(step->value, node->ns->href))
+                       goto rollback;
+               }
+               break;
+            case XSLT_OP_ALL:
+               if (node->type != XML_ELEMENT_NODE)
+                   goto rollback;
+               break;
+           case XSLT_OP_PREDICATE: {
+               xmlNodePtr oldNode;
+               xmlDocPtr doc;
+               int oldCS, oldCP;
+               int pos = 0, len = 0;
+               int isRVT;
+
+               /*
+                * when there is cascading XSLT_OP_PREDICATE, then use a
+                * direct computation approach. It's not done directly
+                * at the beginning of the routine to filter out as much
+                * as possible this costly computation.
+                */
+               if (comp->direct) {
+                   if (states.states != NULL) {
+                       /* Free the rollback states */
+                       xmlFree(states.states);
+                   }
+                   return(xsltTestCompMatchDirect(ctxt, comp, node,
+                                                  comp->nsList, comp->nsNr));
+               }
+
+               doc = node->doc;
+               if (XSLT_IS_RES_TREE_FRAG(doc))
+                   isRVT = 1;
+               else
+                   isRVT = 0;
+
+               /*
+                * Depending on the last selection, one may need to
+                * recompute contextSize and proximityPosition.
+                */
+               oldCS = ctxt->xpathCtxt->contextSize;
+               oldCP = ctxt->xpathCtxt->proximityPosition;
+               if ((sel != NULL) &&
+                   (sel->op == XSLT_OP_ELEM) &&
+                   (sel->value != NULL) &&
+                   (node->type == XML_ELEMENT_NODE) &&
+                   (node->parent != NULL)) {
+                   xmlNodePtr previous;
+                   int ix, nocache = 0;
+
+                   previous = (xmlNodePtr)
+                       XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr);
+                   ix = XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival);
+                   if ((previous != NULL) &&
+                       (previous->parent == node->parent)) {
+                       /*
+                        * just walk back to adjust the index
+                        */
+                       int indx = 0;
+                       xmlNodePtr sibling = node;
+
+                       while (sibling != NULL) {
+                           if (sibling == previous)
+                               break;
+                           if ((previous->type == XML_ELEMENT_NODE) &&
+                               (previous->name != NULL) &&
+                               (sibling->name != NULL) &&
+                               (previous->name[0] == sibling->name[0]) &&
+                               (xmlStrEqual(previous->name, sibling->name)))
+                           {
+                               if ((sel->value2 == NULL) ||
+                                   ((sibling->ns != NULL) &&
+                                    (xmlStrEqual(sel->value2,
+                                                 sibling->ns->href))))
+                                   indx++;
+                           }
+                           sibling = sibling->prev;
+                       }
+                       if (sibling == NULL) {
+                           /* hum going backward in document order ... */
+                           indx = 0;
+                           sibling = node;
+                           while (sibling != NULL) {
+                               if (sibling == previous)
+                                   break;
+                               if ((previous->type == XML_ELEMENT_NODE) &&
+                                   (previous->name != NULL) &&
+                                   (sibling->name != NULL) &&
+                                   (previous->name[0] == sibling->name[0]) &&
+                                   (xmlStrEqual(previous->name, sibling->name)))
+                               {
+                                   if ((sel->value2 == NULL) ||
+                                       ((sibling->ns != NULL) &&
+                                       (xmlStrEqual(sel->value2,
+                                       sibling->ns->href))))
+                                   {
+                                       indx--;
+                                   }
+                               }
+                               sibling = sibling->next;
+                           }
+                       }
+                       if (sibling != NULL) {
+                           pos = ix + indx;
+                           /*
+                            * If the node is in a Value Tree we need to
+                            * save len, but cannot cache the node!
+                            * (bugs 153137 and 158840)
+                            */
+                           if (node->doc != NULL) {
+                               len = XSLT_RUNTIME_EXTRA(ctxt,
+                                       sel->lenExtra, ival);
+                               if (!isRVT) {
+                                   XSLT_RUNTIME_EXTRA(ctxt,
+                                       sel->previousExtra, ptr) = node;
+                                   XSLT_RUNTIME_EXTRA(ctxt,
+                                       sel->indexExtra, ival) = pos;
+                               }
+                           }
+                           ix = pos;
+                       } else
+                           pos = 0;
+                   } else {
+                       /*
+                        * recompute the index
+                        */
+                       xmlNodePtr siblings = node->parent->children;
+                       xmlNodePtr parent = node->parent;
+
+                       while (siblings != NULL) {
+                           if (siblings->type == XML_ELEMENT_NODE) {
+                               if (siblings == node) {
+                                   len++;
+                                   pos = len;
+                               } else if ((node->name != NULL) &&
+                                          (siblings->name != NULL) &&
+                                   (node->name[0] == siblings->name[0]) &&
+                                   (xmlStrEqual(node->name, siblings->name))) {
+                                   if ((sel->value2 == NULL) ||
+                                       ((siblings->ns != NULL) &&
+                                        (xmlStrEqual(sel->value2,
+                                                     siblings->ns->href))))
+                                       len++;
+                               }
+                           }
+                           siblings = siblings->next;
+                       }
+                       if ((parent == NULL) || (node->doc == NULL))
+                           nocache = 1;
+                       else {
+                           while (parent->parent != NULL)
+                               parent = parent->parent;
+                           if (((parent->type != XML_DOCUMENT_NODE) &&
+                                (parent->type != XML_HTML_DOCUMENT_NODE)) ||
+                                (parent != (xmlNodePtr) node->doc))
+                               nocache = 1;
+                       }
+                   }
+                   if (pos != 0) {
+                       ctxt->xpathCtxt->contextSize = len;
+                       ctxt->xpathCtxt->proximityPosition = pos;
+                       /*
+                        * If the node is in a Value Tree we cannot
+                        * cache it !
+                        */
+                       if ((!isRVT) && (node->doc != NULL) &&
+                           (nocache == 0)) {
+                           XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) =
+                               node;
+                           XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) =
+                               pos;
+                           XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) =
+                               len;
+                       }
+                   }
+               } else if ((sel != NULL) && (sel->op == XSLT_OP_ALL) &&
+                          (node->type == XML_ELEMENT_NODE)) {
+                   xmlNodePtr previous;
+                   int ix, nocache = 0;
+
+                   previous = (xmlNodePtr)
+                       XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr);
+                   ix = XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival);
+                   if ((previous != NULL) &&
+                       (previous->parent == node->parent)) {
+                       /*
+                        * just walk back to adjust the index
+                        */
+                       int indx = 0;
+                       xmlNodePtr sibling = node;
+
+                       while (sibling != NULL) {
+                           if (sibling == previous)
+                               break;
+                           if (sibling->type == XML_ELEMENT_NODE)
+                               indx++;
+                           sibling = sibling->prev;
+                       }
+                       if (sibling == NULL) {
+                           /* hum going backward in document order ... */
+                           indx = 0;
+                           sibling = node;
+                           while (sibling != NULL) {
+                               if (sibling == previous)
+                                   break;
+                               if (sibling->type == XML_ELEMENT_NODE)
+                                   indx--;
+                               sibling = sibling->next;
+                           }
+                       }
+                       if (sibling != NULL) {
+                           pos = ix + indx;
+                           /*
+                            * If the node is in a Value Tree we cannot
+                            * cache it !
+                            */
+                           if ((node->doc != NULL) && !isRVT) {
+                               len = XSLT_RUNTIME_EXTRA(ctxt,
+                                       sel->lenExtra, ival);
+                               XSLT_RUNTIME_EXTRA(ctxt,
+                                       sel->previousExtra, ptr) = node;
+                               XSLT_RUNTIME_EXTRA(ctxt,
+                                       sel->indexExtra, ival) = pos;
+                           }
+                       } else
+                           pos = 0;
+                   } else {
+                       /*
+                        * recompute the index
+                        */
+                       xmlNodePtr siblings = node->parent->children;
+                       xmlNodePtr parent = node->parent;
+
+                       while (siblings != NULL) {
+                           if (siblings->type == XML_ELEMENT_NODE) {
+                               len++;
+                               if (siblings == node) {
+                                   pos = len;
+                               }
+                           }
+                           siblings = siblings->next;
+                       }
+                       if ((parent == NULL) || (node->doc == NULL))
+                           nocache = 1;
+                       else {
+                           while (parent->parent != NULL)
+                               parent = parent->parent;
+                           if (((parent->type != XML_DOCUMENT_NODE) &&
+                                (parent->type != XML_HTML_DOCUMENT_NODE)) ||
+                                (parent != (xmlNodePtr) node->doc))
+                               nocache = 1;
+                       }
+                   }
+                   if (pos != 0) {
+                       ctxt->xpathCtxt->contextSize = len;
+                       ctxt->xpathCtxt->proximityPosition = pos;
+                       /*
+                        * If the node is in a Value Tree we cannot
+                        * cache it !
+                        */
+                       if ((node->doc != NULL) && (nocache == 0) && !isRVT) {
+                           XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) =
+                               node;
+                           XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) =
+                               pos;
+                           XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) =
+                               len;
+                       }
+                   }
+               }
+               oldNode = ctxt->node;
+               ctxt->node = node;
+
+               if (step->value == NULL)
+                   goto wrong_index;
+               if (step->comp == NULL)
+                   goto wrong_index;
+
+               if (!xsltEvalXPathPredicate(ctxt, step->comp, comp->nsList,
+                                           comp->nsNr))
+                   goto wrong_index;
+
+               if (pos != 0) {
+                   ctxt->xpathCtxt->contextSize = oldCS;
+                   ctxt->xpathCtxt->proximityPosition = oldCP;
+               }
+               ctxt->node = oldNode;
+               break;
+wrong_index:
+               if (pos != 0) {
+                   ctxt->xpathCtxt->contextSize = oldCS;
+                   ctxt->xpathCtxt->proximityPosition = oldCP;
+               }
+               ctxt->node = oldNode;
+               goto rollback;
+           }
+            case XSLT_OP_PI:
+               if (node->type != XML_PI_NODE)
+                   goto rollback;
+               if (step->value != NULL) {
+                   if (!xmlStrEqual(step->value, node->name))
+                       goto rollback;
+               }
+               break;
+            case XSLT_OP_COMMENT:
+               if (node->type != XML_COMMENT_NODE)
+                   goto rollback;
+               break;
+            case XSLT_OP_TEXT:
+               if ((node->type != XML_TEXT_NODE) &&
+                   (node->type != XML_CDATA_SECTION_NODE))
+                   goto rollback;
+               break;
+            case XSLT_OP_NODE:
+               switch (node->type) {
+                   case XML_ELEMENT_NODE:
+                   case XML_CDATA_SECTION_NODE:
+                   case XML_PI_NODE:
+                   case XML_COMMENT_NODE:
+                   case XML_TEXT_NODE:
+                       break;
+                   default:
+                       goto rollback;
+               }
+               break;
+       }
+    }
+found:
+    if (states.states != NULL) {
+        /* Free the rollback states */
+       xmlFree(states.states);
+    }
+    return(1);
+rollback:
+    /* got an error try to rollback */
+    if (states.states == NULL)
+       return(0);
+    if (states.nbstates <= 0) {
+       xmlFree(states.states);
+       return(0);
+    }
+    states.nbstates--;
+    i = states.states[states.nbstates].step;
+    node = states.states[states.nbstates].node;
+#if 0
+    fprintf(stderr, "Pop: %d, %s\n", i, node->name);
+#endif
+    goto restart;
+}
+
+/**
+ * xsltTestCompMatchList:
+ * @ctxt:  a XSLT process context
+ * @node: a node
+ * @comp: the precompiled pattern list
+ *
+ * Test whether the node matches one of the patterns in the list
+ *
+ * Returns 1 if it matches, 0 if it doesn't and -1 in case of failure
+ */
+int
+xsltTestCompMatchList(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                     xsltCompMatchPtr comp) {
+    int ret;
+
+    if ((ctxt == NULL) || (node == NULL))
+       return(-1);
+    while (comp != NULL) {
+       ret = xsltTestCompMatch(ctxt, comp, node, NULL, NULL);
+       if (ret == 1)
+           return(1);
+       comp = comp->next;
+    }
+    return(0);
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     Dedicated parser for templates                  *
+ *                                                                     *
+ ************************************************************************/
+
+#define CUR (*ctxt->cur)
+#define SKIP(val) ctxt->cur += (val)
+#define NXT(val) ctxt->cur[(val)]
+#define CUR_PTR ctxt->cur
+
+#define SKIP_BLANKS                                                    \
+    while (IS_BLANK_CH(CUR)) NEXT
+
+#define CURRENT (*ctxt->cur)
+#define NEXT ((*ctxt->cur) ?  ctxt->cur++: ctxt->cur)
+
+
+#define PUSH(op, val, val2, novar)                                             \
+    if (xsltCompMatchAdd(ctxt, ctxt->comp, (op), (val), (val2), (novar))) goto error;
+
+#define SWAP()                                                 \
+    xsltSwapTopCompMatch(ctxt->comp);
+
+#define XSLT_ERROR(X)                                                  \
+    { xsltError(ctxt, __FILE__, __LINE__, X);                  \
+      ctxt->error = (X); return; }
+
+#define XSLT_ERROR0(X)                                                 \
+    { xsltError(ctxt, __FILE__, __LINE__, X);                  \
+      ctxt->error = (X); return(0); }
+
+/**
+ * xsltScanLiteral:
+ * @ctxt:  the XPath Parser context
+ *
+ * Parse an XPath Litteral:
+ *
+ * [29] Literal ::= '"' [^"]* '"'
+ *                | "'" [^']* "'"
+ *
+ * Returns the Literal parsed or NULL
+ */
+
+static xmlChar *
+xsltScanLiteral(xsltParserContextPtr ctxt) {
+    const xmlChar *q, *cur;
+    xmlChar *ret = NULL;
+    int val, len;
+
+    SKIP_BLANKS;
+    if (CUR == '"') {
+        NEXT;
+       cur = q = CUR_PTR;
+       val = xmlStringCurrentChar(NULL, cur, &len);
+       while ((IS_CHAR(val)) && (val != '"')) {
+           cur += len;
+           val = xmlStringCurrentChar(NULL, cur, &len);
+       }
+       if (!IS_CHAR(val)) {
+           ctxt->error = 1;
+           return(NULL);
+       } else {
+           ret = xmlStrndup(q, cur - q);
+        }
+       cur += len;
+       CUR_PTR = cur;
+    } else if (CUR == '\'') {
+        NEXT;
+       cur = q = CUR_PTR;
+       val = xmlStringCurrentChar(NULL, cur, &len);
+       while ((IS_CHAR(val)) && (val != '\'')) {
+           cur += len;
+           val = xmlStringCurrentChar(NULL, cur, &len);
+       }
+       if (!IS_CHAR(val)) {
+           ctxt->error = 1;
+           return(NULL);
+       } else {
+           ret = xmlStrndup(q, cur - q);
+        }
+       cur += len;
+       CUR_PTR = cur;
+    } else {
+       /* XP_ERROR(XPATH_START_LITERAL_ERROR); */
+       ctxt->error = 1;
+       return(NULL);
+    }
+    return(ret);
+}
+
+/**
+ * xsltScanName:
+ * @ctxt:  the XPath Parser context
+ *
+ * [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | 
+ *                  CombiningChar | Extender
+ *
+ * [5] Name ::= (Letter | '_' | ':') (NameChar)*
+ *
+ * [6] Names ::= Name (S Name)*
+ *
+ * Returns the Name parsed or NULL
+ */
+
+static xmlChar *
+xsltScanName(xsltParserContextPtr ctxt) {
+    const xmlChar *q, *cur;
+    xmlChar *ret = NULL;
+    int val, len;
+
+    SKIP_BLANKS;
+
+    cur = q = CUR_PTR;
+    val = xmlStringCurrentChar(NULL, cur, &len);
+    if (!IS_LETTER(val) && (val != '_') && (val != ':'))
+       return(NULL);
+
+    while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
+           (val == '.') || (val == '-') ||
+          (val == '_') || 
+          (IS_COMBINING(val)) ||
+          (IS_EXTENDER(val))) {
+       cur += len;
+       val = xmlStringCurrentChar(NULL, cur, &len);
+    }
+    ret = xmlStrndup(q, cur - q);
+    CUR_PTR = cur;
+    return(ret);
+}
+
+/**
+ * xsltScanNCName:
+ * @ctxt:  the XPath Parser context
+ *
+ * Parses a non qualified name
+ *
+ * Returns the Name parsed or NULL
+ */
+
+static xmlChar *
+xsltScanNCName(xsltParserContextPtr ctxt) {
+    const xmlChar *q, *cur;
+    xmlChar *ret = NULL;
+    int val, len;
+
+    SKIP_BLANKS;
+
+    cur = q = CUR_PTR;
+    val = xmlStringCurrentChar(NULL, cur, &len);
+    if (!IS_LETTER(val) && (val != '_'))
+       return(NULL);
+
+    while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
+           (val == '.') || (val == '-') ||
+          (val == '_') ||
+          (IS_COMBINING(val)) ||
+          (IS_EXTENDER(val))) {
+       cur += len;
+       val = xmlStringCurrentChar(NULL, cur, &len);
+    }
+    ret = xmlStrndup(q, cur - q);
+    CUR_PTR = cur;
+    return(ret);
+}
+
+/**
+ * xsltScanQName:
+ * @ctxt:  the XPath Parser context
+ * @prefix:  the place to store the prefix
+ *
+ * Parse a qualified name
+ *
+ * Returns the Name parsed or NULL
+ */
+
+static xmlChar *
+xsltScanQName(xsltParserContextPtr ctxt, xmlChar **prefix) {
+    xmlChar *ret = NULL;
+
+    *prefix = NULL;
+    ret = xsltScanNCName(ctxt);
+    if (CUR == ':') {
+        *prefix = ret;
+       NEXT;
+       ret = xsltScanNCName(ctxt);
+    }
+    return(ret);
+}
+
+/*
+ * xsltCompileIdKeyPattern:
+ * @ctxt:  the compilation context
+ * @name:  a preparsed name
+ * @aid:  whether id/key are allowed there
+ * @novar:  flag to prohibit xslt var
+ *
+ * Compile the XSLT LocationIdKeyPattern
+ * [3] IdKeyPattern ::= 'id' '(' Literal ')'
+ *                    | 'key' '(' Literal ',' Literal ')'
+ *
+ * also handle NodeType and PI from:
+ *
+ * [7]  NodeTest ::= NameTest
+ *                 | NodeType '(' ')'
+ *                 | 'processing-instruction' '(' Literal ')'
+ */
+static void
+xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, xmlChar *name,
+               int aid, int novar) {
+    xmlChar *lit = NULL;
+    xmlChar *lit2 = NULL;
+
+    if (CUR != '(') {
+       xsltTransformError(NULL, NULL, NULL,
+               "xsltCompileIdKeyPattern : ( expected\n");
+       ctxt->error = 1;
+       return;
+    }
+    if ((aid) && (xmlStrEqual(name, (const xmlChar *)"id"))) {
+       NEXT;
+       SKIP_BLANKS;
+        lit = xsltScanLiteral(ctxt);
+       if (ctxt->error)
+           return;
+       SKIP_BLANKS;
+       if (CUR != ')') {
+           xsltTransformError(NULL, NULL, NULL,
+                   "xsltCompileIdKeyPattern : ) expected\n");
+           ctxt->error = 1;
+           return;
+       }
+       NEXT;
+       PUSH(XSLT_OP_ID, lit, NULL, novar);
+    } else if ((aid) && (xmlStrEqual(name, (const xmlChar *)"key"))) {
+       NEXT;
+       SKIP_BLANKS;
+        lit = xsltScanLiteral(ctxt);
+       if (ctxt->error)
+           return;
+       SKIP_BLANKS;
+       if (CUR != ',') {
+           xsltTransformError(NULL, NULL, NULL,
+                   "xsltCompileIdKeyPattern : , expected\n");
+           ctxt->error = 1;
+           return;
+       }
+       NEXT;
+       SKIP_BLANKS;
+        lit2 = xsltScanLiteral(ctxt);
+       if (ctxt->error)
+           return;
+       SKIP_BLANKS;
+       if (CUR != ')') {
+           xsltTransformError(NULL, NULL, NULL,
+                   "xsltCompileIdKeyPattern : ) expected\n");
+           ctxt->error = 1;
+           return;
+       }
+       NEXT;
+       /* URGENT TODO: support namespace in keys */
+       PUSH(XSLT_OP_KEY, lit, lit2, novar);
+    } else if (xmlStrEqual(name, (const xmlChar *)"processing-instruction")) {
+       NEXT;
+       SKIP_BLANKS;
+       if (CUR != ')') {
+           lit = xsltScanLiteral(ctxt);
+           if (ctxt->error)
+               return;
+           SKIP_BLANKS;
+           if (CUR != ')') {
+               xsltTransformError(NULL, NULL, NULL,
+                       "xsltCompileIdKeyPattern : ) expected\n");
+               ctxt->error = 1;
+               return;
+           }
+       }
+       NEXT;
+       PUSH(XSLT_OP_PI, lit, NULL, novar);
+    } else if (xmlStrEqual(name, (const xmlChar *)"text")) {
+       NEXT;
+       SKIP_BLANKS;
+       if (CUR != ')') {
+           xsltTransformError(NULL, NULL, NULL,
+                   "xsltCompileIdKeyPattern : ) expected\n");
+           ctxt->error = 1;
+           return;
+       }
+       NEXT;
+       PUSH(XSLT_OP_TEXT, NULL, NULL, novar);
+    } else if (xmlStrEqual(name, (const xmlChar *)"comment")) {
+       NEXT;
+       SKIP_BLANKS;
+       if (CUR != ')') {
+           xsltTransformError(NULL, NULL, NULL,
+                   "xsltCompileIdKeyPattern : ) expected\n");
+           ctxt->error = 1;
+           return;
+       }
+       NEXT;
+       PUSH(XSLT_OP_COMMENT, NULL, NULL, novar);
+    } else if (xmlStrEqual(name, (const xmlChar *)"node")) {
+       NEXT;
+       SKIP_BLANKS;
+       if (CUR != ')') {
+           xsltTransformError(NULL, NULL, NULL,
+                   "xsltCompileIdKeyPattern : ) expected\n");
+           ctxt->error = 1;
+           return;
+       }
+       NEXT;
+       PUSH(XSLT_OP_NODE, NULL, NULL, novar);
+    } else if (aid) {
+       xsltTransformError(NULL, NULL, NULL,
+           "xsltCompileIdKeyPattern : expecting 'key' or 'id' or node type\n");
+       ctxt->error = 1;
+       return;
+    } else {
+       xsltTransformError(NULL, NULL, NULL,
+           "xsltCompileIdKeyPattern : node type\n");
+       ctxt->error = 1;
+       return;
+    }
+error:
+    if (name != NULL)
+       xmlFree(name);
+}
+
+/**
+ * xsltCompileStepPattern:
+ * @ctxt:  the compilation context
+ * @token:  a posible precompiled name
+ * @novar: flag to prohibit xslt variables from pattern
+ *
+ * Compile the XSLT StepPattern and generates a precompiled
+ * form suitable for fast matching.
+ *
+ * [5] StepPattern ::= ChildOrAttributeAxisSpecifier NodeTest Predicate* 
+ * [6] ChildOrAttributeAxisSpecifier ::= AbbreviatedAxisSpecifier
+ *                                     | ('child' | 'attribute') '::'
+ * from XPath
+ * [7]  NodeTest ::= NameTest
+ *                 | NodeType '(' ')'
+ *                 | 'processing-instruction' '(' Literal ')'
+ * [8] Predicate ::= '[' PredicateExpr ']'
+ * [9] PredicateExpr ::= Expr
+ * [13] AbbreviatedAxisSpecifier ::= '@'?
+ * [37] NameTest ::= '*' | NCName ':' '*' | QName
+ */
+
+static void
+xsltCompileStepPattern(xsltParserContextPtr ctxt, xmlChar *token, int novar) {
+    xmlChar *name = NULL;
+    const xmlChar *URI = NULL;
+    xmlChar *URL = NULL;
+    int level;
+
+    SKIP_BLANKS;
+    if ((token == NULL) && (CUR == '@')) {
+       xmlChar *prefix = NULL;
+
+       NEXT;
+       if (CUR == '*') {
+           NEXT;
+           PUSH(XSLT_OP_ATTR, NULL, NULL, novar);
+           goto parse_predicate;
+       }
+       token = xsltScanQName(ctxt, &prefix);
+       if (prefix != NULL) {
+           xmlNsPtr ns;
+
+           ns = xmlSearchNs(ctxt->doc, ctxt->elem, prefix);
+           if (ns == NULL) {
+               xsltTransformError(NULL, NULL, NULL,
+               "xsltCompileStepPattern : no namespace bound to prefix %s\n",
+                                prefix);
+           } else {
+               URL = xmlStrdup(ns->href);
+           }
+           xmlFree(prefix);
+       }
+       if (token == NULL) {
+           if (CUR == '*') {
+               NEXT;
+               PUSH(XSLT_OP_ATTR, NULL, URL, novar);
+               return;
+           }
+           xsltTransformError(NULL, NULL, NULL,
+                   "xsltCompileStepPattern : Name expected\n");
+           ctxt->error = 1;
+           goto error;
+       }
+       PUSH(XSLT_OP_ATTR, token, URL, novar);
+       goto parse_predicate;
+    }
+    if (token == NULL)
+       token = xsltScanName(ctxt);
+    if (token == NULL) {
+       if (CUR == '*') {
+           NEXT;
+           PUSH(XSLT_OP_ALL, token, NULL, novar);
+           goto parse_predicate;
+       } else {
+           xsltTransformError(NULL, NULL, NULL,
+                   "xsltCompileStepPattern : Name expected\n");
+           ctxt->error = 1;
+           goto error;
+       }
+    }
+
+
+    SKIP_BLANKS;
+    if (CUR == '(') {
+       xsltCompileIdKeyPattern(ctxt, token, 0, novar);
+       if (ctxt->error)
+           goto error;
+    } else if (CUR == ':') {
+       NEXT;
+       if (CUR != ':') {
+           xmlChar *prefix = token;
+           xmlNsPtr ns;
+
+           /*
+            * This is a namespace match
+            */
+           token = xsltScanName(ctxt);
+           ns = xmlSearchNs(ctxt->doc, ctxt->elem, prefix);
+           if (ns == NULL) {
+               xsltTransformError(NULL, NULL, NULL,
+           "xsltCompileStepPattern : no namespace bound to prefix %s\n",
+                                prefix);
+               ctxt->error = 1;
+               goto error;
+           } else {
+               URL = xmlStrdup(ns->href);
+           }
+           xmlFree(prefix);
+           if (token == NULL) {
+               if (CUR == '*') {
+                   NEXT;
+                   PUSH(XSLT_OP_NS, URL, NULL, novar);
+               } else {
+                   xsltTransformError(NULL, NULL, NULL,
+                           "xsltCompileStepPattern : Name expected\n");
+                   ctxt->error = 1;
+                   goto error;
+               }
+           } else {
+               PUSH(XSLT_OP_ELEM, token, URL, novar);
+           }
+       } else {
+           NEXT;
+           if (xmlStrEqual(token, (const xmlChar *) "child")) {
+               xmlFree(token);
+               token = xsltScanName(ctxt);
+               if (token == NULL) {
+                   if (CUR == '*') {
+                       NEXT;
+                       PUSH(XSLT_OP_ALL, token, NULL, novar);
+                       goto parse_predicate;
+                   } else {
+                       xsltTransformError(NULL, NULL, NULL,
+                           "xsltCompileStepPattern : QName expected\n");
+                       ctxt->error = 1;
+                       goto error;
+                   }
+               }
+               URI = xsltGetQNameURI(ctxt->elem, &token);
+               if (token == NULL) {
+                   ctxt->error = 1;
+                   goto error;
+               } else {
+                   name = xmlStrdup(token);
+                   if (URI != NULL)
+                       URL = xmlStrdup(URI);
+               }
+               PUSH(XSLT_OP_CHILD, name, URL, novar);
+           } else if (xmlStrEqual(token, (const xmlChar *) "attribute")) {
+               xmlFree(token);
+               token = xsltScanName(ctxt);
+               if (token == NULL) {
+                   xsltTransformError(NULL, NULL, NULL,
+                           "xsltCompileStepPattern : QName expected\n");
+                   ctxt->error = 1;
+                   goto error;
+               }
+               URI = xsltGetQNameURI(ctxt->elem, &token);
+               if (token == NULL) {
+                   ctxt->error = 1;
+                   goto error;
+               } else {
+                   name = xmlStrdup(token);
+                   if (URI != NULL)
+                       URL = xmlStrdup(URI);
+               }
+               PUSH(XSLT_OP_ATTR, name, URL, novar);
+           } else {
+               xsltTransformError(NULL, NULL, NULL,
+                   "xsltCompileStepPattern : 'child' or 'attribute' expected\n");
+               ctxt->error = 1;
+               goto error;
+           }
+           xmlFree(token);
+       }
+    } else if (CUR == '*') {
+       NEXT;
+       PUSH(XSLT_OP_ALL, token, NULL, novar);
+    } else {
+       URI = xsltGetQNameURI(ctxt->elem, &token);
+       if (token == NULL) {
+           ctxt->error = 1;
+           goto error;
+       }
+       if (URI != NULL)
+           URL = xmlStrdup(URI);
+       PUSH(XSLT_OP_ELEM, token, URL, novar);
+    }
+parse_predicate:
+    SKIP_BLANKS;
+    level = 0;
+    while (CUR == '[') {
+       const xmlChar *q;
+       xmlChar *ret = NULL;
+
+       level++;
+       NEXT;
+       q = CUR_PTR;
+       while (CUR != 0) {
+           /* Skip over nested predicates */
+           if (CUR == '[')
+               level++;
+           else if (CUR == ']') {
+               level--;
+               if (level == 0)
+                   break;
+           } else if (CUR == '"') {
+               NEXT;
+               while ((CUR != 0) && (CUR != '"'))
+                   NEXT;
+           } else if (CUR == '\'') {
+               NEXT;
+               while ((CUR != 0) && (CUR != '\''))
+                   NEXT;
+           }
+           NEXT;
+       }
+       if (CUR == 0) {
+           xsltTransformError(NULL, NULL, NULL,
+                   "xsltCompileStepPattern : ']' expected\n");
+           ctxt->error = 1;
+           return;
+        }
+       ret = xmlStrndup(q, CUR_PTR - q);
+       PUSH(XSLT_OP_PREDICATE, ret, NULL, novar);
+       /* push the predicate lower than local test */
+       SWAP();
+       NEXT;
+       SKIP_BLANKS;
+    }
+    return;
+error:
+    if (token != NULL)
+       xmlFree(token);
+    if (name != NULL)
+       xmlFree(name);
+}
+
+/**
+ * xsltCompileRelativePathPattern:
+ * @comp:  the compilation context
+ * @token:  a posible precompiled name
+ * @novar:  flag to prohibit xslt variables
+ *
+ * Compile the XSLT RelativePathPattern and generates a precompiled
+ * form suitable for fast matching.
+ *
+ * [4] RelativePathPattern ::= StepPattern
+ *                           | RelativePathPattern '/' StepPattern
+ *                           | RelativePathPattern '//' StepPattern
+ */
+static void
+xsltCompileRelativePathPattern(xsltParserContextPtr ctxt, xmlChar *token, int novar) {
+    xsltCompileStepPattern(ctxt, token, novar);
+    if (ctxt->error)
+       goto error;
+    SKIP_BLANKS;
+    while ((CUR != 0) && (CUR != '|')) {
+       if ((CUR == '/') && (NXT(1) == '/')) {
+           PUSH(XSLT_OP_ANCESTOR, NULL, NULL, novar);
+           NEXT;
+           NEXT;
+           SKIP_BLANKS;
+           xsltCompileStepPattern(ctxt, NULL, novar);
+       } else if (CUR == '/') {
+           PUSH(XSLT_OP_PARENT, NULL, NULL, novar);
+           NEXT;
+           SKIP_BLANKS;
+           if ((CUR != 0) && (CUR != '|')) {
+               xsltCompileRelativePathPattern(ctxt, NULL, novar);
+           }
+       } else {
+           ctxt->error = 1;
+       }
+       if (ctxt->error)
+           goto error;
+       SKIP_BLANKS;
+    }
+error:
+    return;
+}
+
+/**
+ * xsltCompileLocationPathPattern:
+ * @ctxt:  the compilation context
+ * @novar:  flag to prohibit xslt variables
+ *
+ * Compile the XSLT LocationPathPattern and generates a precompiled
+ * form suitable for fast matching.
+ *
+ * [2] LocationPathPattern ::= '/' RelativePathPattern?
+ *                           | IdKeyPattern (('/' | '//') RelativePathPattern)?
+ *                           | '//'? RelativePathPattern
+ */
+static void
+xsltCompileLocationPathPattern(xsltParserContextPtr ctxt, int novar) {
+    SKIP_BLANKS;
+    if ((CUR == '/') && (NXT(1) == '/')) {
+       /*
+        * since we reverse the query
+        * a leading // can be safely ignored
+        */
+       NEXT;
+       NEXT;
+       ctxt->comp->priority = 0.5;     /* '//' means not 0 priority */
+       xsltCompileRelativePathPattern(ctxt, NULL, novar);
+    } else if (CUR == '/') {
+       /*
+        * We need to find root as the parent
+        */
+       NEXT;
+       SKIP_BLANKS;
+       PUSH(XSLT_OP_ROOT, NULL, NULL, novar);
+       if ((CUR != 0) && (CUR != '|')) {
+           PUSH(XSLT_OP_PARENT, NULL, NULL, novar);
+           xsltCompileRelativePathPattern(ctxt, NULL, novar);
+       }
+    } else if (CUR == '*') {
+       xsltCompileRelativePathPattern(ctxt, NULL, novar);
+    } else if (CUR == '@') {
+       xsltCompileRelativePathPattern(ctxt, NULL, novar);
+    } else {
+       xmlChar *name;
+       name = xsltScanName(ctxt);
+       if (name == NULL) {
+           xsltTransformError(NULL, NULL, NULL,
+                   "xsltCompileLocationPathPattern : Name expected\n");
+           ctxt->error = 1;
+           return;
+       }
+       SKIP_BLANKS;
+       if ((CUR == '(') && !xmlXPathIsNodeType(name)) {
+           xsltCompileIdKeyPattern(ctxt, name, 1, novar);
+           if ((CUR == '/') && (NXT(1) == '/')) {
+               PUSH(XSLT_OP_ANCESTOR, NULL, NULL, novar);
+               NEXT;
+               NEXT;
+               SKIP_BLANKS;
+               xsltCompileRelativePathPattern(ctxt, NULL, novar);
+           } else if (CUR == '/') {
+               PUSH(XSLT_OP_PARENT, NULL, NULL, novar);
+               NEXT;
+               SKIP_BLANKS;
+               xsltCompileRelativePathPattern(ctxt, NULL, novar);
+           }
+           return;
+       }
+       xsltCompileRelativePathPattern(ctxt, name, novar);
+    }
+error:
+    return;
+}
+
+/**
+ * xsltCompilePatternInternal:
+ * @pattern: an XSLT pattern
+ * @doc:  the containing document
+ * @node:  the containing element
+ * @style:  the stylesheet
+ * @runtime:  the transformation context, if done at run-time
+ * @novar:  flag to prohibit xslt variables
+ *
+ * Compile the XSLT pattern and generates a list of precompiled form suitable
+ * for fast matching.
+ *
+ * [1] Pattern ::= LocationPathPattern | Pattern '|' LocationPathPattern
+ *
+ * Returns the generated pattern list or NULL in case of failure
+ */
+
+static xsltCompMatchPtr
+xsltCompilePatternInternal(const xmlChar *pattern, xmlDocPtr doc,
+                  xmlNodePtr node, xsltStylesheetPtr style,
+                  xsltTransformContextPtr runtime, int novar) {
+    xsltParserContextPtr ctxt = NULL;
+    xsltCompMatchPtr element, first = NULL, previous = NULL;
+    int current, start, end, level, j;
+
+    if (pattern == NULL) {
+       xsltTransformError(NULL, NULL, node,
+                        "xsltCompilePattern : NULL pattern\n");
+       return(NULL);
+    }
+
+    ctxt = xsltNewParserContext(style, runtime);
+    if (ctxt == NULL)
+       return(NULL);
+    ctxt->doc = doc;
+    ctxt->elem = node;
+    current = end = 0;
+    while (pattern[current] != 0) {
+       start = current;
+       while (IS_BLANK_CH(pattern[current]))
+           current++;
+       end = current;
+       level = 0;
+       while ((pattern[end] != 0) && ((pattern[end] != '|') || (level != 0))) {
+           if (pattern[end] == '[')
+               level++;
+           else if (pattern[end] == ']')
+               level--;
+           else if (pattern[end] == '\'') {
+               end++;
+               while ((pattern[end] != 0) && (pattern[end] != '\''))
+                   end++;
+           } else if (pattern[end] == '"') {
+               end++;
+               while ((pattern[end] != 0) && (pattern[end] != '"'))
+                   end++;
+           }
+           end++;
+       }
+       if (current == end) {
+           xsltTransformError(NULL, NULL, node,
+                            "xsltCompilePattern : NULL pattern\n");
+           goto error;
+       }
+       element = xsltNewCompMatch();
+       if (element == NULL) {
+           goto error;
+       }
+       if (first == NULL)
+           first = element;
+       else if (previous != NULL)
+           previous->next = element;
+       previous = element;
+
+       ctxt->comp = element;
+       ctxt->base = xmlStrndup(&pattern[start], end - start);
+       if (ctxt->base == NULL)
+           goto error;
+       ctxt->cur = &(ctxt->base)[current - start];
+       element->pattern = ctxt->base;
+       element->nsList = xmlGetNsList(doc, node);
+       j = 0;
+       if (element->nsList != NULL) {
+           while (element->nsList[j] != NULL)
+               j++;
+       }
+       element->nsNr = j;
+
+
+#ifdef WITH_XSLT_DEBUG_PATTERN
+       xsltGenericDebug(xsltGenericDebugContext,
+                        "xsltCompilePattern : parsing '%s'\n",
+                        element->pattern);
+#endif
+       /*
+        Preset default priority to be zero.
+        This may be changed by xsltCompileLocationPathPattern.
+        */
+       element->priority = 0;
+       xsltCompileLocationPathPattern(ctxt, novar);
+       if (ctxt->error) {
+           xsltTransformError(NULL, style, node,
+                            "xsltCompilePattern : failed to compile '%s'\n",
+                            element->pattern);
+           if (style != NULL) style->errors++;
+           goto error;
+       }
+
+       /*
+        * Reverse for faster interpretation.
+        */
+       xsltReverseCompMatch(ctxt, element);
+
+       /*
+        * Set-up the priority
+        */
+       if (element->priority == 0) {   /* if not yet determined */
+           if (((element->steps[0].op == XSLT_OP_ELEM) ||
+                (element->steps[0].op == XSLT_OP_ATTR) ||
+                (element->steps[0].op == XSLT_OP_PI)) &&
+               (element->steps[0].value != NULL) &&
+               (element->steps[1].op == XSLT_OP_END)) {
+               ;       /* previously preset */
+           } else if ((element->steps[0].op == XSLT_OP_ATTR) &&
+                      (element->steps[0].value2 != NULL) &&
+                      (element->steps[1].op == XSLT_OP_END)) {
+                       element->priority = -0.25;
+           } else if ((element->steps[0].op == XSLT_OP_NS) &&
+                      (element->steps[0].value != NULL) &&
+                      (element->steps[1].op == XSLT_OP_END)) {
+                       element->priority = -0.25;
+           } else if ((element->steps[0].op == XSLT_OP_ATTR) &&
+                      (element->steps[0].value == NULL) &&
+                      (element->steps[0].value2 == NULL) &&
+                      (element->steps[1].op == XSLT_OP_END)) {
+                       element->priority = -0.5;
+           } else if (((element->steps[0].op == XSLT_OP_PI) ||
+                      (element->steps[0].op == XSLT_OP_TEXT) ||
+                      (element->steps[0].op == XSLT_OP_ALL) ||
+                      (element->steps[0].op == XSLT_OP_NODE) ||
+                      (element->steps[0].op == XSLT_OP_COMMENT)) &&
+                      (element->steps[1].op == XSLT_OP_END)) {
+                       element->priority = -0.5;
+           } else {
+               element->priority = 0.5;
+           }
+       }
+#ifdef WITH_XSLT_DEBUG_PATTERN
+       xsltGenericDebug(xsltGenericDebugContext,
+                    "xsltCompilePattern : parsed %s, default priority %f\n",
+                        element->pattern, element->priority);
+#endif
+       if (pattern[end] == '|')
+           end++;
+       current = end;
+    }
+    if (end == 0) {
+       xsltTransformError(NULL, style, node,
+                        "xsltCompilePattern : NULL pattern\n");
+       if (style != NULL) style->errors++;
+       goto error;
+    }
+
+    xsltFreeParserContext(ctxt);
+    return(first);
+
+error:
+    if (ctxt != NULL)
+       xsltFreeParserContext(ctxt);
+    if (first != NULL)
+       xsltFreeCompMatchList(first);
+    return(NULL);
+}
+
+/**
+ * xsltCompilePattern:
+ * @pattern: an XSLT pattern
+ * @doc:  the containing document
+ * @node:  the containing element
+ * @style:  the stylesheet
+ * @runtime:  the transformation context, if done at run-time
+ *
+ * Compile the XSLT pattern and generates a list of precompiled form suitable
+ * for fast matching.
+ *
+ * [1] Pattern ::= LocationPathPattern | Pattern '|' LocationPathPattern
+ *
+ * Returns the generated pattern list or NULL in case of failure
+ */
+
+xsltCompMatchPtr
+xsltCompilePattern(const xmlChar *pattern, xmlDocPtr doc,
+                  xmlNodePtr node, xsltStylesheetPtr style,
+                  xsltTransformContextPtr runtime) {
+    return (xsltCompilePatternInternal(pattern, doc, node, style, runtime, 0));
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     Module interfaces                               *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltAddTemplate:
+ * @style: an XSLT stylesheet
+ * @cur: an XSLT template
+ * @mode:  the mode name or NULL
+ * @modeURI:  the mode URI or NULL
+ *
+ * Register the XSLT pattern associated to @cur
+ *
+ * Returns -1 in case of error, 0 otherwise
+ */
+int
+xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur,
+               const xmlChar *mode, const xmlChar *modeURI) {
+    xsltCompMatchPtr pat, list, next;
+    /*
+     * 'top' will point to style->xxxMatch ptr - declaring as 'void'
+     *  avoids gcc 'type-punned pointer' warning.
+     */
+    void **top = NULL;
+    const xmlChar *name = NULL;
+    float priority;              /* the priority */
+
+    if ((style == NULL) || (cur == NULL) || (cur->match == NULL))
+       return(-1);
+
+    priority = cur->priority;
+    pat = xsltCompilePatternInternal(cur->match, style->doc, cur->elem,
+                   style, NULL, 1);
+    if (pat == NULL)
+       return(-1);
+    while (pat) {
+       next = pat->next;
+       pat->next = NULL;
+       name = NULL;
+       
+       pat->template = cur;
+       if (mode != NULL)
+           pat->mode = xmlDictLookup(style->dict, mode, -1);
+       if (modeURI != NULL)
+           pat->modeURI = xmlDictLookup(style->dict, modeURI, -1);
+       if (priority != XSLT_PAT_NO_PRIORITY)
+           pat->priority = priority;
+
+       /*
+        * insert it in the hash table list corresponding to its lookup name
+        */
+       switch (pat->steps[0].op) {
+        case XSLT_OP_ATTR:
+           if (pat->steps[0].value != NULL)
+               name = pat->steps[0].value;
+           else
+               top = &(style->attrMatch);
+           break;
+        case XSLT_OP_CHILD:
+        case XSLT_OP_PARENT:
+        case XSLT_OP_ANCESTOR:
+           top = &(style->elemMatch);
+           break;
+        case XSLT_OP_ROOT:
+           top = &(style->rootMatch);
+           break;
+        case XSLT_OP_KEY:
+           top = &(style->keyMatch);
+           break;
+        case XSLT_OP_ID:
+           /* TODO optimize ID !!! */
+        case XSLT_OP_NS:
+        case XSLT_OP_ALL:
+           top = &(style->elemMatch);
+           break;
+        case XSLT_OP_END:
+       case XSLT_OP_PREDICATE:
+           xsltTransformError(NULL, style, NULL,
+                            "xsltAddTemplate: invalid compiled pattern\n");
+           xsltFreeCompMatch(pat);
+           return(-1);
+           /*
+            * TODO: some flags at the top level about type based patterns
+            *       would be faster than inclusion in the hash table.
+            */
+       case XSLT_OP_PI:
+           if (pat->steps[0].value != NULL)
+               name = pat->steps[0].value;
+           else
+               top = &(style->piMatch);
+           break;
+       case XSLT_OP_COMMENT:
+           top = &(style->commentMatch);
+           break;
+       case XSLT_OP_TEXT:
+           top = &(style->textMatch);
+           break;
+        case XSLT_OP_ELEM:
+       case XSLT_OP_NODE:
+           if (pat->steps[0].value != NULL)
+               name = pat->steps[0].value;
+           else
+               top = &(style->elemMatch);
+           break;
+       }
+       if (name != NULL) {
+           if (style->templatesHash == NULL) {
+               style->templatesHash = xmlHashCreate(1024);
+               if (style->templatesHash == NULL) {
+                   xsltFreeCompMatch(pat);
+                   return(-1);
+               }
+               xmlHashAddEntry3(style->templatesHash, name, mode, modeURI, pat);
+           } else {
+               list = (xsltCompMatchPtr) xmlHashLookup3(style->templatesHash,
+                                                        name, mode, modeURI);
+               if (list == NULL) {
+                   xmlHashAddEntry3(style->templatesHash, name,
+                                    mode, modeURI, pat);
+               } else {
+                   /*
+                    * Note '<=' since one must choose among the matching
+                    * template rules that are left, the one that occurs
+                    * last in the stylesheet
+                    */
+                   if (list->priority <= pat->priority) {
+                       pat->next = list;
+                       xmlHashUpdateEntry3(style->templatesHash, name,
+                                           mode, modeURI, pat, NULL);
+                   } else {
+                       while (list->next != NULL) {
+                           if (list->next->priority <= pat->priority)
+                               break;
+                           list = list->next;
+                       }
+                       pat->next = list->next;
+                       list->next = pat;
+                   }
+               }
+           }
+       } else if (top != NULL) {
+           list = *top;
+           if (list == NULL) {
+               *top = pat;
+               pat->next = NULL;
+           } else if (list->priority <= pat->priority) {
+               pat->next = list;
+               *top = pat;
+           } else {
+               while (list->next != NULL) {
+                   if (list->next->priority <= pat->priority)
+                       break;
+                   list = list->next;
+               }
+               pat->next = list->next;
+               list->next = pat;
+           }
+       } else {
+           xsltTransformError(NULL, style, NULL,
+                            "xsltAddTemplate: invalid compiled pattern\n");
+           xsltFreeCompMatch(pat);
+           return(-1);
+       }
+#ifdef WITH_XSLT_DEBUG_PATTERN
+       if (mode)
+           xsltGenericDebug(xsltGenericDebugContext,
+                        "added pattern : '%s' mode '%s' priority %f\n",
+                            pat->pattern, pat->mode, pat->priority);
+       else
+           xsltGenericDebug(xsltGenericDebugContext,
+                        "added pattern : '%s' priority %f\n",
+                            pat->pattern, pat->priority);
+#endif
+
+       pat = next;
+    }
+    return(0);
+}
+
+static int
+xsltComputeAllKeys(xsltTransformContextPtr ctxt, xmlNodePtr contextNode)
+{
+    if ((ctxt == NULL) || (contextNode == NULL)) {
+       xsltTransformError(ctxt, NULL, ctxt->inst,
+           "Internal error in xsltComputeAllKeys(): "
+           "Bad arguments.\n");
+       return(-1);
+    }
+
+    if (ctxt->document == NULL) {
+       /*
+       * The document info will only be NULL if we have a RTF.
+       */
+       if (contextNode->doc->_private != NULL)
+           goto doc_info_mismatch;
+       /*
+       * On-demand creation of the document info (needed for keys).
+       */
+       ctxt->document = xsltNewDocument(ctxt, contextNode->doc);
+       if (ctxt->document == NULL)
+           return(-1);
+    }
+    return xsltInitAllDocKeys(ctxt);
+
+doc_info_mismatch:
+    xsltTransformError(ctxt, NULL, ctxt->inst,
+       "Internal error in xsltComputeAllKeys(): "
+       "The context's document info doesn't match the "
+       "document info of the current result tree.\n");
+    ctxt->state = XSLT_STATE_STOPPED;
+    return(-1);
+}
+
+/**
+ * xsltGetTemplate:
+ * @ctxt:  a XSLT process context
+ * @node:  the node being processed
+ * @style:  the current style
+ *
+ * Finds the template applying to this node, if @style is non-NULL
+ * it means one needs to look for the next imported template in scope.
+ *
+ * Returns the xsltTemplatePtr or NULL if not found
+ */
+xsltTemplatePtr
+xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
+               xsltStylesheetPtr style)
+{
+    xsltStylesheetPtr curstyle;
+    xsltTemplatePtr ret = NULL;
+    const xmlChar *name = NULL;
+    xsltCompMatchPtr list = NULL;
+    float priority;
+    int keyed = 0;
+
+    if ((ctxt == NULL) || (node == NULL))
+       return(NULL);
+
+    if (style == NULL) {
+       curstyle = ctxt->style;
+    } else {
+       curstyle = xsltNextImport(style);
+    }
+
+    while ((curstyle != NULL) && (curstyle != style)) {
+       priority = XSLT_PAT_NO_PRIORITY;
+       /* TODO : handle IDs/keys here ! */
+       if (curstyle->templatesHash != NULL) {
+           /*
+            * Use the top name as selector
+            */
+           switch (node->type) {
+               case XML_ELEMENT_NODE:
+                   if (node->name[0] == ' ')
+                       break;
+               case XML_ATTRIBUTE_NODE:
+               case XML_PI_NODE:
+                   name = node->name;
+                   break;
+               case XML_DOCUMENT_NODE:
+               case XML_HTML_DOCUMENT_NODE:
+               case XML_TEXT_NODE:
+               case XML_CDATA_SECTION_NODE:
+               case XML_COMMENT_NODE:
+               case XML_ENTITY_REF_NODE:
+               case XML_ENTITY_NODE:
+               case XML_DOCUMENT_TYPE_NODE:
+               case XML_DOCUMENT_FRAG_NODE:
+               case XML_NOTATION_NODE:
+               case XML_DTD_NODE:
+               case XML_ELEMENT_DECL:
+               case XML_ATTRIBUTE_DECL:
+               case XML_ENTITY_DECL:
+               case XML_NAMESPACE_DECL:
+               case XML_XINCLUDE_START:
+               case XML_XINCLUDE_END:
+                   break;
+               default:
+                   return(NULL);
+
+           }
+       }
+       if (name != NULL) {
+           /*
+            * find the list of applicable expressions based on the name
+            */
+           list = (xsltCompMatchPtr) xmlHashLookup3(curstyle->templatesHash,
+                                            name, ctxt->mode, ctxt->modeURI);
+       } else
+           list = NULL;
+       while (list != NULL) {
+           if (xsltTestCompMatch(ctxt, list, node,
+                                 ctxt->mode, ctxt->modeURI)) {
+               ret = list->template;
+               priority = list->priority;
+               break;
+           }
+           list = list->next;
+       }
+       list = NULL;
+
+       /*
+        * find alternate generic matches
+        */
+       switch (node->type) {
+           case XML_ELEMENT_NODE:
+               if (node->name[0] == ' ')
+                   list = curstyle->rootMatch;
+               else
+                   list = curstyle->elemMatch;
+               if (node->psvi != NULL) keyed = 1;
+               break;
+           case XML_ATTRIBUTE_NODE: {
+               xmlAttrPtr attr;
+
+               list = curstyle->attrMatch;
+               attr = (xmlAttrPtr) node;
+               if (attr->psvi != NULL) keyed = 1;
+               break;
+           }
+           case XML_PI_NODE:
+               list = curstyle->piMatch;
+               if (node->psvi != NULL) keyed = 1;
+               break;
+           case XML_DOCUMENT_NODE:
+           case XML_HTML_DOCUMENT_NODE: {
+               xmlDocPtr doc;
+
+               list = curstyle->rootMatch;
+               doc = (xmlDocPtr) node;
+               if (doc->psvi != NULL) keyed = 1;
+               break;
+           }
+           case XML_TEXT_NODE:
+           case XML_CDATA_SECTION_NODE:
+               list = curstyle->textMatch;
+               if (node->psvi != NULL) keyed = 1;
+               break;
+           case XML_COMMENT_NODE:
+               list = curstyle->commentMatch;
+               if (node->psvi != NULL) keyed = 1;
+               break;
+           case XML_ENTITY_REF_NODE:
+           case XML_ENTITY_NODE:
+           case XML_DOCUMENT_TYPE_NODE:
+           case XML_DOCUMENT_FRAG_NODE:
+           case XML_NOTATION_NODE:
+           case XML_DTD_NODE:
+           case XML_ELEMENT_DECL:
+           case XML_ATTRIBUTE_DECL:
+           case XML_ENTITY_DECL:
+           case XML_NAMESPACE_DECL:
+           case XML_XINCLUDE_START:
+           case XML_XINCLUDE_END:
+               break;
+           default:
+               break;
+       }
+       while ((list != NULL) &&
+              ((ret == NULL)  || (list->priority > priority))) {
+           if (xsltTestCompMatch(ctxt, list, node,
+                                 ctxt->mode, ctxt->modeURI)) {
+               ret = list->template;
+               priority = list->priority;
+               break;
+           }
+           list = list->next;
+       }
+       /*
+        * Some of the tests for elements can also apply to documents
+        */
+       if ((node->type == XML_DOCUMENT_NODE) ||
+           (node->type == XML_HTML_DOCUMENT_NODE) ||
+           (node->type == XML_TEXT_NODE)) {
+           list = curstyle->elemMatch;
+           while ((list != NULL) &&
+                  ((ret == NULL)  || (list->priority > priority))) {
+               if (xsltTestCompMatch(ctxt, list, node,
+                                     ctxt->mode, ctxt->modeURI)) {
+                   ret = list->template;
+                   priority = list->priority;
+                   break;
+               }
+               list = list->next;
+           }
+       } else if ((node->type == XML_PI_NODE) ||
+                  (node->type == XML_COMMENT_NODE)) {
+           list = curstyle->elemMatch;
+           while ((list != NULL) &&
+                  ((ret == NULL)  || (list->priority > priority))) {
+               if (xsltTestCompMatch(ctxt, list, node,
+                                     ctxt->mode, ctxt->modeURI)) {
+                   ret = list->template;
+                   priority = list->priority;
+                   break;
+               }
+               list = list->next;
+           }
+       }
+
+keyed_match:
+       if (keyed) {
+           list = curstyle->keyMatch;
+           while ((list != NULL) &&
+                  ((ret == NULL)  || (list->priority > priority))) {
+               if (xsltTestCompMatch(ctxt, list, node,
+                                     ctxt->mode, ctxt->modeURI)) {
+                   ret = list->template;
+                   priority = list->priority;
+                   break;
+               }
+               list = list->next;
+           }
+       }
+       else if (ctxt->hasTemplKeyPatterns &&
+           ((ctxt->document == NULL) ||
+            (ctxt->document->nbKeysComputed < ctxt->nbKeys)))
+       {
+           /*
+           * Compute all remaining keys for this document.
+           *
+           * REVISIT TODO: I think this could be further optimized.
+           */
+           if (xsltComputeAllKeys(ctxt, node) == -1)
+               goto error;
+
+           switch (node->type) {
+               case XML_ELEMENT_NODE:              
+                   if (node->psvi != NULL) keyed = 1;
+                   break;
+               case XML_ATTRIBUTE_NODE:
+                   if (((xmlAttrPtr) node)->psvi != NULL) keyed = 1;
+                   break;
+               case XML_TEXT_NODE:
+               case XML_CDATA_SECTION_NODE:
+               case XML_COMMENT_NODE:
+               case XML_PI_NODE:               
+                   if (node->psvi != NULL) keyed = 1;
+                   break;
+               case XML_DOCUMENT_NODE:
+               case XML_HTML_DOCUMENT_NODE:
+                   if (((xmlDocPtr) node)->psvi != NULL) keyed = 1;
+                   break;              
+               default:
+                   break;
+           }
+           if (keyed)
+               goto keyed_match;
+       }
+       if (ret != NULL)
+           return(ret);
+
+       /*
+        * Cycle on next curstylesheet import.
+        */
+       curstyle = xsltNextImport(curstyle);
+    }
+
+error:
+    return(NULL);
+}
+
+/**
+ * xsltCleanupTemplates:
+ * @style: an XSLT stylesheet
+ *
+ * Cleanup the state of the templates used by the stylesheet and
+ * the ones it imports.
+ */
+void
+xsltCleanupTemplates(xsltStylesheetPtr style ATTRIBUTE_UNUSED) {
+}
+
+/**
+ * xsltFreeTemplateHashes:
+ * @style: an XSLT stylesheet
+ *
+ * Free up the memory used by xsltAddTemplate/xsltGetTemplate mechanism
+ */
+void
+xsltFreeTemplateHashes(xsltStylesheetPtr style) {
+    if (style->templatesHash != NULL)
+       xmlHashFree((xmlHashTablePtr) style->templatesHash,
+                   (xmlHashDeallocator) xsltFreeCompMatchList);
+    if (style->rootMatch != NULL)
+        xsltFreeCompMatchList(style->rootMatch);
+    if (style->keyMatch != NULL)
+        xsltFreeCompMatchList(style->keyMatch);
+    if (style->elemMatch != NULL)
+        xsltFreeCompMatchList(style->elemMatch);
+    if (style->attrMatch != NULL)
+        xsltFreeCompMatchList(style->attrMatch);
+    if (style->parentMatch != NULL)
+        xsltFreeCompMatchList(style->parentMatch);
+    if (style->textMatch != NULL)
+        xsltFreeCompMatchList(style->textMatch);
+    if (style->piMatch != NULL)
+        xsltFreeCompMatchList(style->piMatch);
+    if (style->commentMatch != NULL)
+        xsltFreeCompMatchList(style->commentMatch);
+}
+
diff --git a/reactos/dll/3rdparty/libxslt/pattern.h b/reactos/dll/3rdparty/libxslt/pattern.h
new file mode 100644 (file)
index 0000000..eb21be3
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Summary: interface for the pattern matching used in template matches.
+ * Description: the implementation of the lookup of the right template
+ *              for a given node must be really fast in order to keep
+ *              decent performances.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_PATTERN_H__
+#define __XML_XSLT_PATTERN_H__
+
+#include "xsltInternals.h"
+#include "xsltexports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * xsltCompMatch:
+ *
+ * Data structure used for the implementation of patterns.
+ * It is kept private (in pattern.c).
+ */
+typedef struct _xsltCompMatch xsltCompMatch;
+typedef xsltCompMatch *xsltCompMatchPtr;
+
+/*
+ * Pattern related interfaces.
+ */
+
+XSLTPUBFUN xsltCompMatchPtr XSLTCALL
+               xsltCompilePattern      (const xmlChar *pattern,
+                                        xmlDocPtr doc,
+                                        xmlNodePtr node,
+                                        xsltStylesheetPtr style,
+                                        xsltTransformContextPtr runtime);
+XSLTPUBFUN void XSLTCALL
+               xsltFreeCompMatchList   (xsltCompMatchPtr comp);
+XSLTPUBFUN int XSLTCALL
+               xsltTestCompMatchList   (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xsltCompMatchPtr comp);
+XSLTPUBFUN void XSLTCALL
+               xsltNormalizeCompSteps  (void *payload,
+                                        void *data,
+                                        const xmlChar *name);
+
+/*
+ * Template related interfaces.
+ */
+XSLTPUBFUN int XSLTCALL
+               xsltAddTemplate         (xsltStylesheetPtr style,
+                                        xsltTemplatePtr cur,
+                                        const xmlChar *mode,
+                                        const xmlChar *modeURI);
+XSLTPUBFUN xsltTemplatePtr XSLTCALL
+               xsltGetTemplate         (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xsltStylesheetPtr style);
+XSLTPUBFUN void XSLTCALL
+               xsltFreeTemplateHashes  (xsltStylesheetPtr style);
+XSLTPUBFUN void XSLTCALL
+               xsltCleanupTemplates    (xsltStylesheetPtr style);
+
+#if 0
+int            xsltMatchPattern        (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        const xmlChar *pattern,
+                                        xmlDocPtr ctxtdoc,
+                                        xmlNodePtr ctxtnode);
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_PATTERN_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/preproc.c b/reactos/dll/3rdparty/libxslt/preproc.c
new file mode 100644 (file)
index 0000000..2842370
--- /dev/null
@@ -0,0 +1,2340 @@
+/*
+ * preproc.c: Preprocessing of style operations
+ *
+ * References:
+ *   http://www.w3.org/TR/1999/REC-xslt-19991116
+ *
+ *   Michael Kay "XSLT Programmer's Reference" pp 637-643
+ *   Writing Multiple Output Files
+ *
+ *   XSLT-1.1 Working Draft
+ *   http://www.w3.org/TR/xslt11#multiple-output
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/valid.h>
+#include <libxml/hash.h>
+#include <libxml/uri.h>
+#include <libxml/encoding.h>
+#include <libxml/xmlerror.h>
+#include "xslt.h"
+#include "xsltutils.h"
+#include "xsltInternals.h"
+#include "transform.h"
+#include "templates.h"
+#include "variables.h"
+#include "numbersInternals.h"
+#include "preproc.h"
+#include "extra.h"
+#include "imports.h"
+#include "extensions.h"
+
+#ifdef WITH_XSLT_DEBUG
+#define WITH_XSLT_DEBUG_PREPROC
+#endif
+
+const xmlChar *xsltExtMarker = (const xmlChar *) "Extension Element";
+
+/************************************************************************
+ *                                                                     *
+ *                     Grammar checks                                  *
+ *                                                                     *
+ ************************************************************************/
+
+#ifdef XSLT_REFACTORED
+    /*
+    * Grammar checks are now performed in xslt.c.
+    */
+#else
+/**
+ * xsltCheckTopLevelElement:
+ * @style: the XSLT stylesheet
+ * @inst: the XSLT instruction
+ * @err: raise an error or not
+ *
+ * Check that the instruction is instanciated as a top level element.
+ *
+ * Returns -1 in case of error, 0 if failed and 1 in case of success
+ */
+static int
+xsltCheckTopLevelElement(xsltStylesheetPtr style, xmlNodePtr inst, int err) {
+    xmlNodePtr parent;
+    if ((style == NULL) || (inst == NULL) || (inst->ns == NULL))
+        return(-1);
+    
+    parent = inst->parent;
+    if (parent == NULL) {
+        if (err) {
+           xsltTransformError(NULL, style, inst,
+                   "internal problem: element has no parent\n");
+           style->errors++;
+       }
+       return(0);
+    }
+    if ((parent->ns == NULL) ||
+        ((parent->ns != inst->ns) &&
+        (!xmlStrEqual(parent->ns->href, inst->ns->href))) ||
+       ((!xmlStrEqual(parent->name, BAD_CAST "stylesheet")) &&
+        (!xmlStrEqual(parent->name, BAD_CAST "transform")))) {
+       if (err) {
+           xsltTransformError(NULL, style, inst,
+                   "element %s only allowed as child of stylesheet\n",
+                              inst->name);
+           style->errors++;
+       }
+       return(0);
+    }
+    return(1);
+}
+
+/**
+ * xsltCheckInstructionElement:
+ * @style: the XSLT stylesheet
+ * @inst: the XSLT instruction
+ *
+ * Check that the instruction is instanciated as an instruction element.
+ */
+static void
+xsltCheckInstructionElement(xsltStylesheetPtr style, xmlNodePtr inst) {
+    xmlNodePtr parent;
+    int has_ext;
+
+    if ((style == NULL) || (inst == NULL) || (inst->ns == NULL) ||
+        (style->literal_result))
+        return;
+
+    has_ext = (style->extInfos != NULL);
+    
+    parent = inst->parent;
+    if (parent == NULL) {
+       xsltTransformError(NULL, style, inst,
+               "internal problem: element has no parent\n");
+       style->errors++;
+       return;
+    }
+    while ((parent != NULL) && (parent->type != XML_DOCUMENT_NODE)) {
+        if (((parent->ns == inst->ns) ||
+            ((parent->ns != NULL) &&
+             (xmlStrEqual(parent->ns->href, inst->ns->href)))) &&
+           ((xmlStrEqual(parent->name, BAD_CAST "template")) ||
+            (xmlStrEqual(parent->name, BAD_CAST "param")) ||
+            (xmlStrEqual(parent->name, BAD_CAST "attribute")) ||
+            (xmlStrEqual(parent->name, BAD_CAST "variable")))) {
+           return;
+       }
+
+       /*
+        * if we are within an extension element all bets are off
+        * about the semantic there e.g. xsl:param within func:function
+        */
+       if ((has_ext) && (parent->ns != NULL) &&
+           (xmlHashLookup(style->extInfos, parent->ns->href) != NULL))
+           return;
+       
+        parent = parent->parent;
+    }
+    xsltTransformError(NULL, style, inst,
+           "element %s only allowed within a template, variable or param\n",
+                          inst->name);
+    style->errors++;
+}
+
+/**
+ * xsltCheckParentElement:
+ * @style: the XSLT stylesheet
+ * @inst: the XSLT instruction
+ * @allow1: allowed parent1
+ * @allow2: allowed parent2
+ *
+ * Check that the instruction is instanciated as the childre of one of the
+ * possible parents.
+ */
+static void
+xsltCheckParentElement(xsltStylesheetPtr style, xmlNodePtr inst,
+                       const xmlChar *allow1, const xmlChar *allow2) {
+    xmlNodePtr parent;
+
+    if ((style == NULL) || (inst == NULL) || (inst->ns == NULL) ||
+        (style->literal_result))
+        return;
+
+    parent = inst->parent;
+    if (parent == NULL) {
+       xsltTransformError(NULL, style, inst,
+               "internal problem: element has no parent\n");
+       style->errors++;
+       return;
+    }
+    if (((parent->ns == inst->ns) ||
+        ((parent->ns != NULL) &&
+         (xmlStrEqual(parent->ns->href, inst->ns->href)))) &&
+       ((xmlStrEqual(parent->name, allow1)) ||
+        (xmlStrEqual(parent->name, allow2)))) {
+       return;
+    }
+
+    if (style->extInfos != NULL) {
+       while ((parent != NULL) && (parent->type != XML_DOCUMENT_NODE)) {
+           /*
+            * if we are within an extension element all bets are off
+            * about the semantic there e.g. xsl:param within func:function
+            */
+           if ((parent->ns != NULL) &&
+               (xmlHashLookup(style->extInfos, parent->ns->href) != NULL))
+               return;
+           
+           parent = parent->parent;
+       }
+    }
+    xsltTransformError(NULL, style, inst,
+                      "element %s is not allowed within that context\n",
+                      inst->name);
+    style->errors++;
+}
+#endif
+
+/************************************************************************
+ *                                                                     *
+ *                     handling of precomputed data                    *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltNewStylePreComp:
+ * @style:  the XSLT stylesheet
+ * @type:  the construct type
+ *
+ * Create a new XSLT Style precomputed block
+ *
+ * Returns the newly allocated specialized structure
+ *         or NULL in case of error
+ */
+static xsltStylePreCompPtr
+xsltNewStylePreComp(xsltStylesheetPtr style, xsltStyleType type) {
+    xsltStylePreCompPtr cur;
+#ifdef XSLT_REFACTORED
+    size_t size;
+#endif
+
+    if (style == NULL)
+        return(NULL);
+   
+#ifdef XSLT_REFACTORED
+    /*
+    * URGENT TODO: Use specialized factory functions in order
+    *   to avoid this ugliness.
+    */
+    switch (type) {
+        case XSLT_FUNC_COPY:
+            size = sizeof(xsltStyleItemCopy); break;
+        case XSLT_FUNC_SORT:
+            size = sizeof(xsltStyleItemSort); break;
+        case XSLT_FUNC_TEXT:
+            size = sizeof(xsltStyleItemText); break;
+        case XSLT_FUNC_ELEMENT:
+            size = sizeof(xsltStyleItemElement); break;
+        case XSLT_FUNC_ATTRIBUTE:
+            size = sizeof(xsltStyleItemAttribute); break;
+        case XSLT_FUNC_COMMENT:
+            size = sizeof(xsltStyleItemComment); break;
+        case XSLT_FUNC_PI:
+            size = sizeof(xsltStyleItemPI); break;
+        case XSLT_FUNC_COPYOF:
+            size = sizeof(xsltStyleItemCopyOf); break;
+        case XSLT_FUNC_VALUEOF:
+            size = sizeof(xsltStyleItemValueOf); break;;
+        case XSLT_FUNC_NUMBER:
+            size = sizeof(xsltStyleItemNumber); break;
+        case XSLT_FUNC_APPLYIMPORTS:
+            size = sizeof(xsltStyleItemApplyImports); break;
+        case XSLT_FUNC_CALLTEMPLATE:
+            size = sizeof(xsltStyleItemCallTemplate); break;
+        case XSLT_FUNC_APPLYTEMPLATES:
+            size = sizeof(xsltStyleItemApplyTemplates); break;
+        case XSLT_FUNC_CHOOSE:
+            size = sizeof(xsltStyleItemChoose); break;
+        case XSLT_FUNC_IF:
+            size = sizeof(xsltStyleItemIf); break;
+        case XSLT_FUNC_FOREACH:
+            size = sizeof(xsltStyleItemForEach); break;
+        case XSLT_FUNC_DOCUMENT:
+            size = sizeof(xsltStyleItemDocument); break;
+       case XSLT_FUNC_WITHPARAM:
+           size = sizeof(xsltStyleItemWithParam); break;
+       case XSLT_FUNC_PARAM:
+           size = sizeof(xsltStyleItemParam); break;
+       case XSLT_FUNC_VARIABLE:
+           size = sizeof(xsltStyleItemVariable); break;
+       case XSLT_FUNC_WHEN:
+           size = sizeof(xsltStyleItemWhen); break;
+       case XSLT_FUNC_OTHERWISE:
+           size = sizeof(xsltStyleItemOtherwise); break;
+       default:        
+           xsltTransformError(NULL, style, NULL,
+                   "xsltNewStylePreComp : invalid type %d\n", type);
+           style->errors++;
+           return(NULL);
+    }
+    /*
+    * Create the structure.
+    */
+    cur = (xsltStylePreCompPtr) xmlMalloc(size);
+    if (cur == NULL) {
+       xsltTransformError(NULL, style, NULL,
+               "xsltNewStylePreComp : malloc failed\n");
+       style->errors++;
+       return(NULL);
+    }
+    memset(cur, 0, size);
+
+#else /* XSLT_REFACTORED */
+    /*
+    * Old behaviour.
+    */
+    cur = (xsltStylePreCompPtr) xmlMalloc(sizeof(xsltStylePreComp));
+    if (cur == NULL) {
+       xsltTransformError(NULL, style, NULL,
+               "xsltNewStylePreComp : malloc failed\n");
+       style->errors++;
+       return(NULL);
+    }
+    memset(cur, 0, sizeof(xsltStylePreComp));
+#endif /* XSLT_REFACTORED */
+
+    /*
+    * URGENT TODO: Better to move this to spezialized factory functions.
+    */
+    cur->type = type;
+    switch (cur->type) {
+        case XSLT_FUNC_COPY:
+            cur->func = (xsltTransformFunction) xsltCopy;break;
+        case XSLT_FUNC_SORT:
+            cur->func = (xsltTransformFunction) xsltSort;break;
+        case XSLT_FUNC_TEXT:
+            cur->func = (xsltTransformFunction) xsltText;break;
+        case XSLT_FUNC_ELEMENT:
+            cur->func = (xsltTransformFunction) xsltElement;break;
+        case XSLT_FUNC_ATTRIBUTE:
+            cur->func = (xsltTransformFunction) xsltAttribute;break;
+        case XSLT_FUNC_COMMENT:
+            cur->func = (xsltTransformFunction) xsltComment;break;
+        case XSLT_FUNC_PI:
+            cur->func = (xsltTransformFunction) xsltProcessingInstruction;
+           break;
+        case XSLT_FUNC_COPYOF:
+            cur->func = (xsltTransformFunction) xsltCopyOf;break;
+        case XSLT_FUNC_VALUEOF:
+            cur->func = (xsltTransformFunction) xsltValueOf;break;
+        case XSLT_FUNC_NUMBER:
+            cur->func = (xsltTransformFunction) xsltNumber;break;
+        case XSLT_FUNC_APPLYIMPORTS:
+            cur->func = (xsltTransformFunction) xsltApplyImports;break;
+        case XSLT_FUNC_CALLTEMPLATE:
+            cur->func = (xsltTransformFunction) xsltCallTemplate;break;
+        case XSLT_FUNC_APPLYTEMPLATES:
+            cur->func = (xsltTransformFunction) xsltApplyTemplates;break;
+        case XSLT_FUNC_CHOOSE:
+            cur->func = (xsltTransformFunction) xsltChoose;break;
+        case XSLT_FUNC_IF:
+            cur->func = (xsltTransformFunction) xsltIf;break;
+        case XSLT_FUNC_FOREACH:
+            cur->func = (xsltTransformFunction) xsltForEach;break;
+        case XSLT_FUNC_DOCUMENT:
+            cur->func = (xsltTransformFunction) xsltDocumentElem;break;
+       case XSLT_FUNC_WITHPARAM:
+       case XSLT_FUNC_PARAM:       
+       case XSLT_FUNC_VARIABLE:            
+       case XSLT_FUNC_WHEN:
+           break;
+       default:
+       if (cur->func == NULL) {
+           xsltTransformError(NULL, style, NULL,
+                   "xsltNewStylePreComp : no function for type %d\n", type);
+           style->errors++;
+       }
+    }
+    cur->next = style->preComps;
+    style->preComps = (xsltElemPreCompPtr) cur;
+
+    return(cur);
+}
+
+/**
+ * xsltFreeStylePreComp:
+ * @comp:  an XSLT Style precomputed block
+ *
+ * Free up the memory allocated by @comp
+ */
+static void
+xsltFreeStylePreComp(xsltStylePreCompPtr comp) {
+    if (comp == NULL)
+       return;
+#ifdef XSLT_REFACTORED
+    /*
+    * URGENT TODO: Implement destructors.
+    */
+    switch (comp->type) {
+       case XSLT_FUNC_LITERAL_RESULT_ELEMENT:
+           break;
+       case XSLT_FUNC_COPY:
+            break;
+        case XSLT_FUNC_SORT: {
+               xsltStyleItemSortPtr item = (xsltStyleItemSortPtr) comp;
+               if (item->comp != NULL)
+                   xmlXPathFreeCompExpr(item->comp);
+           }
+            break;
+        case XSLT_FUNC_TEXT:
+            break;
+        case XSLT_FUNC_ELEMENT:
+            break;
+        case XSLT_FUNC_ATTRIBUTE:
+            break;
+        case XSLT_FUNC_COMMENT:
+            break;
+        case XSLT_FUNC_PI:
+           break;
+        case XSLT_FUNC_COPYOF: {
+               xsltStyleItemCopyOfPtr item = (xsltStyleItemCopyOfPtr) comp;
+               if (item->comp != NULL)
+                   xmlXPathFreeCompExpr(item->comp);
+           }
+            break;
+        case XSLT_FUNC_VALUEOF: {
+               xsltStyleItemValueOfPtr item = (xsltStyleItemValueOfPtr) comp;
+               if (item->comp != NULL)
+                   xmlXPathFreeCompExpr(item->comp);
+           }
+            break;
+        case XSLT_FUNC_NUMBER:
+            break;
+        case XSLT_FUNC_APPLYIMPORTS:
+            break;
+        case XSLT_FUNC_CALLTEMPLATE:
+            break;
+        case XSLT_FUNC_APPLYTEMPLATES: {
+               xsltStyleItemApplyTemplatesPtr item =
+                   (xsltStyleItemApplyTemplatesPtr) comp;
+               if (item->comp != NULL)
+                   xmlXPathFreeCompExpr(item->comp);
+           }
+            break;
+        case XSLT_FUNC_CHOOSE:
+            break;
+        case XSLT_FUNC_IF: {
+               xsltStyleItemIfPtr item = (xsltStyleItemIfPtr) comp;
+               if (item->comp != NULL)
+                   xmlXPathFreeCompExpr(item->comp);
+           }
+            break;
+        case XSLT_FUNC_FOREACH: {
+               xsltStyleItemForEachPtr item =
+                   (xsltStyleItemForEachPtr) comp;
+               if (item->comp != NULL)
+                   xmlXPathFreeCompExpr(item->comp);
+           }
+            break;
+        case XSLT_FUNC_DOCUMENT:
+            break;
+       case XSLT_FUNC_WITHPARAM: {
+               xsltStyleItemWithParamPtr item =
+                   (xsltStyleItemWithParamPtr) comp;
+               if (item->comp != NULL)
+                   xmlXPathFreeCompExpr(item->comp);
+           }
+           break;
+       case XSLT_FUNC_PARAM: {
+               xsltStyleItemParamPtr item =
+                   (xsltStyleItemParamPtr) comp;
+               if (item->comp != NULL)
+                   xmlXPathFreeCompExpr(item->comp);
+           }
+           break;
+       case XSLT_FUNC_VARIABLE: {
+               xsltStyleItemVariablePtr item =
+                   (xsltStyleItemVariablePtr) comp;
+               if (item->comp != NULL)
+                   xmlXPathFreeCompExpr(item->comp);
+           }
+           break;
+       case XSLT_FUNC_WHEN: {
+               xsltStyleItemWhenPtr item =
+                   (xsltStyleItemWhenPtr) comp;
+               if (item->comp != NULL)
+                   xmlXPathFreeCompExpr(item->comp);
+           }
+           break;
+       case XSLT_FUNC_OTHERWISE:           
+       case XSLT_FUNC_FALLBACK:
+       case XSLT_FUNC_MESSAGE:
+       case XSLT_FUNC_INCLUDE:
+       case XSLT_FUNC_ATTRSET:
+       
+           break;
+       default:
+           /* TODO: Raise error. */
+           break;
+    }
+#else    
+    if (comp->comp != NULL)
+       xmlXPathFreeCompExpr(comp->comp);
+    if (comp->nsList != NULL)
+       xmlFree(comp->nsList);
+#endif
+
+    xmlFree(comp);
+}
+
+
+/************************************************************************
+ *                                                                     *
+ *                 XSLT-1.1 extensions                                 *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltDocumentComp:
+ * @style:  the XSLT stylesheet
+ * @inst:  the instruction in the stylesheet
+ * @function:  unused
+ *
+ * Pre process an XSLT-1.1 document element
+ *
+ * Returns a precompiled data structure for the element
+ */
+xsltElemPreCompPtr
+xsltDocumentComp(xsltStylesheetPtr style, xmlNodePtr inst,
+                xsltTransformFunction function ATTRIBUTE_UNUSED) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemDocumentPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+    const xmlChar *filename = NULL;
+
+    /*
+    * As of 2006-03-30, this function is currently defined in Libxslt
+    * to be used for:
+    * (in libxslt/extra.c)
+    * "output" in XSLT_SAXON_NAMESPACE
+    * "write" XSLT_XALAN_NAMESPACE
+    * "document" XSLT_XT_NAMESPACE
+    * "document" XSLT_NAMESPACE (from the abandoned old working
+    *                            draft of XSLT 1.1)
+    * (in libexslt/common.c)
+    * "document" in EXSLT_COMMON_NAMESPACE
+    */
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemDocumentPtr)
+       xsltNewStylePreComp(style, XSLT_FUNC_DOCUMENT);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_DOCUMENT);
+#endif
+    
+    if (comp == NULL)
+       return (NULL);
+    comp->inst = inst;
+    comp->ver11 = 0;
+
+    if (xmlStrEqual(inst->name, (const xmlChar *) "output")) {
+#ifdef WITH_XSLT_DEBUG_EXTRA
+       xsltGenericDebug(xsltGenericDebugContext,
+           "Found saxon:output extension\n");
+#endif
+       /*
+       * The element "output" is in the namespace XSLT_SAXON_NAMESPACE
+       *   (http://icl.com/saxon)
+       * The @file is in no namespace; it is an AVT.
+       *   (http://www.computerwizards.com/saxon/doc/extensions.html#saxon:output)
+       *
+       * TODO: Do we need not to check the namespace here?
+       */
+       filename = xsltEvalStaticAttrValueTemplate(style, inst,
+                        (const xmlChar *)"file",
+                        NULL, &comp->has_filename);
+    } else if (xmlStrEqual(inst->name, (const xmlChar *) "write")) {
+#ifdef WITH_XSLT_DEBUG_EXTRA
+       xsltGenericDebug(xsltGenericDebugContext,
+           "Found xalan:write extension\n");
+#endif
+       /* the filename need to be interpreted */
+       /*
+       * TODO: Is "filename need to be interpreted" meant to be a todo?
+       *   Where will be the filename of xalan:write be processed?
+       *
+       * TODO: Do we need not to check the namespace here?
+       *   The extension ns is "http://xml.apache.org/xalan/redirect".
+       *   See http://xml.apache.org/xalan-j/extensionslib.html.
+       */
+    } else if (xmlStrEqual(inst->name, (const xmlChar *) "document")) {
+       if (inst->ns != NULL) {
+           if (xmlStrEqual(inst->ns->href, XSLT_NAMESPACE)) {
+               /*
+               * Mark the instruction as being of
+               * XSLT version 1.1 (abandoned).
+               */
+               comp->ver11 = 1;
+#ifdef WITH_XSLT_DEBUG_EXTRA
+               xsltGenericDebug(xsltGenericDebugContext,
+                   "Found xslt11:document construct\n");
+#endif                 
+           } else {            
+               if (xmlStrEqual(inst->ns->href,
+                   (const xmlChar *)"http://exslt.org/common")) {
+                   /* EXSLT. */
+#ifdef WITH_XSLT_DEBUG_EXTRA
+                   xsltGenericDebug(xsltGenericDebugContext,
+                       "Found exslt:document extension\n");
+#endif
+               } else if (xmlStrEqual(inst->ns->href, XSLT_XT_NAMESPACE)) {
+                   /* James Clark's XT. */
+#ifdef WITH_XSLT_DEBUG_EXTRA
+                   xsltGenericDebug(xsltGenericDebugContext,
+                       "Found xt:document extension\n");
+#endif
+               }
+           }
+       }
+       /*
+       * The element "document" is used in conjunction with the
+       * following namespaces:
+       *
+       * 1) XSLT_NAMESPACE (http://www.w3.org/1999/XSL/Transform version 1.1)
+       *    <!ELEMENT xsl:document %template;>
+       *    <!ATTLIST xsl:document
+       *       href %avt; #REQUIRED
+       *    @href is an AVT
+       *    IMPORTANT: xsl:document was in the abandoned XSLT 1.1 draft,
+       *    it was removed and isn't available in XSLT 1.1 anymore.
+       *    In XSLT 2.0 it was renamed to xsl:result-document.
+       *
+       *   All other attributes are identical to the attributes
+       *   on xsl:output
+       *
+       * 2) EXSLT_COMMON_NAMESPACE (http://exslt.org/common)
+       *    <exsl:document
+       *       href = { uri-reference }
+       *    TODO: is @href is an AVT?
+       *
+       * 3) XSLT_XT_NAMESPACE (http://www.jclark.com/xt)
+       *     Example: <xt:document method="xml" href="myFile.xml">
+       *    TODO: is @href is an AVT?
+       *               
+       * In all cases @href is in no namespace.
+       */
+       filename = xsltEvalStaticAttrValueTemplate(style, inst,
+           (const xmlChar *)"href", NULL, &comp->has_filename);
+    }          
+    if (!comp->has_filename) {
+       goto error;
+    }
+    comp->filename = filename;
+
+error:
+    return ((xsltElemPreCompPtr) comp);
+}
+
+/************************************************************************
+ *                                                                     *
+ *             Most of the XSLT-1.0 transformations                    *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltSortComp:
+ * @style:  the XSLT stylesheet
+ * @inst:  the xslt sort node
+ *
+ * Process the xslt sort node on the source node
+ */
+static void
+xsltSortComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemSortPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemSortPtr) xsltNewStylePreComp(style, XSLT_FUNC_SORT);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_SORT);
+#endif
+    
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+
+    comp->stype = xsltEvalStaticAttrValueTemplate(style, inst,
+                        (const xmlChar *)"data-type",
+                        NULL, &comp->has_stype);
+    if (comp->stype != NULL) {
+       if (xmlStrEqual(comp->stype, (const xmlChar *) "text"))
+           comp->number = 0;
+       else if (xmlStrEqual(comp->stype, (const xmlChar *) "number"))
+           comp->number = 1;
+       else {
+           xsltTransformError(NULL, style, inst,
+                "xsltSortComp: no support for data-type = %s\n", comp->stype);
+           comp->number = 0; /* use default */
+           if (style != NULL) style->warnings++;
+       }
+    }
+    comp->order = xsltEvalStaticAttrValueTemplate(style, inst,
+                             (const xmlChar *)"order",
+                             NULL, &comp->has_order);
+    if (comp->order != NULL) {
+       if (xmlStrEqual(comp->order, (const xmlChar *) "ascending"))
+           comp->descending = 0;
+       else if (xmlStrEqual(comp->order, (const xmlChar *) "descending"))
+           comp->descending = 1;
+       else {
+           xsltTransformError(NULL, style, inst,
+                "xsltSortComp: invalid value %s for order\n", comp->order);
+           comp->descending = 0; /* use default */
+           if (style != NULL) style->warnings++;
+       }
+    }
+    comp->case_order = xsltEvalStaticAttrValueTemplate(style, inst,
+                             (const xmlChar *)"case-order",
+                             NULL, &comp->has_use);
+    if (comp->case_order != NULL) {
+       if (xmlStrEqual(comp->case_order, (const xmlChar *) "upper-first"))
+           comp->lower_first = 0;
+       else if (xmlStrEqual(comp->case_order, (const xmlChar *) "lower-first"))
+           comp->lower_first = 1;
+       else {
+           xsltTransformError(NULL, style, inst,
+                "xsltSortComp: invalid value %s for order\n", comp->order);
+           comp->lower_first = 0; /* use default */
+           if (style != NULL) style->warnings++;
+       }
+    }
+
+    comp->lang = xsltEvalStaticAttrValueTemplate(style, inst,
+                                (const xmlChar *)"lang",
+                                NULL, &comp->has_lang);
+
+    comp->select = xsltGetCNsProp(style, inst,(const xmlChar *)"select", XSLT_NAMESPACE);
+    if (comp->select == NULL) {
+       /*
+        * The default value of the select attribute is ., which will
+        * cause the string-value of the current node to be used as
+        * the sort key.
+        */
+       comp->select = xmlDictLookup(style->dict, BAD_CAST ".", 1);
+    }
+    comp->comp = xsltXPathCompile(style, comp->select);
+    if (comp->comp == NULL) {
+       xsltTransformError(NULL, style, inst,
+            "xsltSortComp: could not compile select expression '%s'\n",
+                        comp->select);
+       if (style != NULL) style->errors++;
+    }
+    if (inst->children != NULL) {
+       xsltTransformError(NULL, style, inst,
+       "xsl:sort : is not empty\n");
+       if (style != NULL) style->errors++;
+    }
+}
+
+/**
+ * xsltCopyComp:
+ * @style:  the XSLT stylesheet
+ * @inst:  the xslt copy node
+ *
+ * Process the xslt copy node on the source node
+ */
+static void
+xsltCopyComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemCopyPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemCopyPtr) xsltNewStylePreComp(style, XSLT_FUNC_COPY);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_COPY);
+#endif
+    
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+
+
+    comp->use = xsltGetCNsProp(style, inst, (const xmlChar *)"use-attribute-sets",
+                                   XSLT_NAMESPACE);
+    if (comp->use == NULL)
+       comp->has_use = 0;
+    else
+       comp->has_use = 1;
+}
+
+#ifdef XSLT_REFACTORED
+    /* Enable if ever needed for xsl:text. */
+#else
+/**
+ * xsltTextComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt text node
+ *
+ * TODO: This function is obsolete, since xsl:text won't
+ *  be compiled, but removed from the tree.
+ *
+ * Process the xslt text node on the source node
+ */
+static void
+xsltTextComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemTextPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+    const xmlChar *prop;
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemTextPtr) xsltNewStylePreComp(style, XSLT_FUNC_TEXT);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_TEXT);
+#endif    
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+    comp->noescape = 0;
+
+    prop = xsltGetCNsProp(style, inst,
+           (const xmlChar *)"disable-output-escaping",
+                       XSLT_NAMESPACE);
+    if (prop != NULL) {
+       if (xmlStrEqual(prop, (const xmlChar *)"yes")) {
+           comp->noescape = 1;
+       } else if (!xmlStrEqual(prop,
+           (const xmlChar *)"no")){
+           xsltTransformError(NULL, style, inst,
+               "xsl:text: disable-output-escaping allows only yes or no\n");
+           if (style != NULL) style->warnings++;
+       }
+    }
+}
+#endif /* else of XSLT_REFACTORED */
+
+/**
+ * xsltElementComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt element node
+ *
+ * Process the xslt element node on the source node
+ */
+static void
+xsltElementComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemElementPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    /*
+    * <xsl:element
+    *   name = { qname }
+    *   namespace = { uri-reference }
+    *   use-attribute-sets = qnames>
+    *   <!-- Content: template -->
+    * </xsl:element>
+    */
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemElementPtr) xsltNewStylePreComp(style, XSLT_FUNC_ELEMENT);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_ELEMENT);
+#endif
+
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+
+    /*
+    * Attribute "name".
+    */
+    /*
+    * TODO: Precompile the AVT. See bug #344894.
+    */
+    comp->name = xsltEvalStaticAttrValueTemplate(style, inst,
+       (const xmlChar *)"name", NULL, &comp->has_name);
+    if (! comp->has_name) {
+       xsltTransformError(NULL, style, inst,
+           "xsl:element: The attribute 'name' is missing.\n");
+       style->errors++;
+       goto error;
+    }
+    /*
+    * Attribute "namespace".
+    */
+    /*
+    * TODO: Precompile the AVT. See bug #344894.
+    */
+    comp->ns = xsltEvalStaticAttrValueTemplate(style, inst,
+       (const xmlChar *)"namespace", NULL, &comp->has_ns);
+    
+    if (comp->name != NULL) {  
+       if (xmlValidateQName(comp->name, 0)) {
+           xsltTransformError(NULL, style, inst,
+               "xsl:element: The value '%s' of the attribute 'name' is "
+               "not a valid QName.\n", comp->name);
+           style->errors++;
+       } else {
+           const xmlChar *prefix = NULL, *name;
+
+           name = xsltSplitQName(style->dict, comp->name, &prefix);
+           if (comp->has_ns == 0) {        
+               xmlNsPtr ns;
+
+               /*
+               * SPEC XSLT 1.0:
+               *  "If the namespace attribute is not present, then the QName is
+               *  expanded into an expanded-name using the namespace declarations
+               *  in effect for the xsl:element element, including any default
+               *  namespace declaration.
+               */              
+               ns = xmlSearchNs(inst->doc, inst, prefix);
+               if (ns != NULL) {
+                   comp->ns = xmlDictLookup(style->dict, ns->href, -1);
+                   comp->has_ns = 1;
+#ifdef XSLT_REFACTORED
+                   comp->nsPrefix = prefix;
+                   comp->name = name;
+#endif
+               } else if (prefix != NULL) {
+                   xsltTransformError(NULL, style, inst,
+                       "xsl:element: The prefixed QName '%s' "
+                       "has no namespace binding in scope in the "
+                       "stylesheet; this is an error, since the namespace was "
+                       "not specified by the instruction itself.\n", comp->name);
+                   style->errors++;
+               }
+           }       
+           if ((prefix != NULL) &&
+               (!xmlStrncasecmp(prefix, (xmlChar *)"xml", 3)))
+           {
+               /*
+               * Mark is to be skipped.
+               */
+               comp->has_name = 0;             
+           }
+       }
+    }    
+    /*
+    * Attribute "use-attribute-sets",
+    */
+    comp->use = xsltEvalStaticAttrValueTemplate(style, inst,
+                      (const xmlChar *)"use-attribute-sets",
+                      NULL, &comp->has_use);
+
+error:    
+    return;
+}
+
+/**
+ * xsltAttributeComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt attribute node
+ *
+ * Process the xslt attribute node on the source node
+ */
+static void
+xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemAttributePtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    /*
+    * <xsl:attribute
+    *   name = { qname }
+    *   namespace = { uri-reference }>
+    *   <!-- Content: template -->
+    * </xsl:attribute>
+    */
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemAttributePtr) xsltNewStylePreComp(style,
+       XSLT_FUNC_ATTRIBUTE);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_ATTRIBUTE);
+#endif
+    
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+
+    /*
+    * Attribute "name".
+    */
+    /*
+    * TODO: Precompile the AVT. See bug #344894.
+    */
+    comp->name = xsltEvalStaticAttrValueTemplate(style, inst,
+                                (const xmlChar *)"name",
+                                NULL, &comp->has_name);
+    if (! comp->has_name) {
+       xsltTransformError(NULL, style, inst,
+           "XSLT-attribute: The attribute 'name' is missing.\n");
+       style->errors++;
+       return;
+    }    
+    /*
+    * Attribute "namespace".
+    */
+    /*
+    * TODO: Precompile the AVT. See bug #344894.
+    */
+    comp->ns = xsltEvalStaticAttrValueTemplate(style, inst,
+       (const xmlChar *)"namespace",
+       NULL, &comp->has_ns);
+
+    if (comp->name != NULL) {
+       if (xmlValidateQName(comp->name, 0)) {
+           xsltTransformError(NULL, style, inst,
+               "xsl:attribute: The value '%s' of the attribute 'name' is "
+               "not a valid QName.\n", comp->name);
+           style->errors++;
+       } else {
+           const xmlChar *prefix = NULL, *name;
+
+           name = xsltSplitQName(style->dict, comp->name, &prefix);
+           if (prefix != NULL) {
+               if (comp->has_ns == 0) {
+                   xmlNsPtr ns;
+
+                   /*
+                   * SPEC XSLT 1.0:
+                   *  "If the namespace attribute is not present, then the
+                   *  QName is expanded into an expanded-name using the
+                   *  namespace declarations in effect for the xsl:element
+                   *  element, including any default namespace declaration.
+                   */              
+                   ns = xmlSearchNs(inst->doc, inst, prefix);
+                   if (ns != NULL) {
+                       comp->ns = xmlDictLookup(style->dict, ns->href, -1);
+                       comp->has_ns = 1;
+#ifdef XSLT_REFACTORED
+                       comp->nsPrefix = prefix;
+                       comp->name = name;
+#endif
+                   } else {
+                       xsltTransformError(NULL, style, inst,
+                           "xsl:attribute: The prefixed QName '%s' "
+                           "has no namespace binding in scope in the "
+                           "stylesheet; this is an error, since the "
+                           "namespace was not specified by the instruction "
+                           "itself.\n", comp->name);
+                       style->errors++;
+                   }
+               }
+               if (!xmlStrncasecmp(prefix, (xmlChar *) "xmlns", 5)) {
+                   /*
+                   * SPEC XSLT 1.0:
+                   *  "It is an error if the string that results from
+                   *  instantiating the attribute value template is not a
+                   *  QName or is the string xmlns. An XSLT processor may
+                   *  signal the error; if it does not signal the error,
+                   *  it must recover by not adding the attribute to the
+                   *  result tree."
+                   *
+                   * Reject a prefix of "xmlns". Mark to be skipped.
+                   */
+                   comp->has_name = 0;
+                   
+#ifdef WITH_XSLT_DEBUG_PARSING
+                   xsltGenericDebug(xsltGenericDebugContext,
+                       "xsltAttribute: xmlns prefix forbidden\n");
+#endif             
+                   return;
+               }
+               
+           }
+       }       
+    }
+}
+
+/**
+ * xsltCommentComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt comment node
+ *
+ * Process the xslt comment node on the source node
+ */
+static void
+xsltCommentComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemCommentPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemCommentPtr) xsltNewStylePreComp(style, XSLT_FUNC_COMMENT);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_COMMENT);
+#endif
+
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+}
+
+/**
+ * xsltProcessingInstructionComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt processing-instruction node
+ *
+ * Process the xslt processing-instruction node on the source node
+ */
+static void
+xsltProcessingInstructionComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemPIPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemPIPtr) xsltNewStylePreComp(style, XSLT_FUNC_PI);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_PI);
+#endif
+
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+
+    comp->name = xsltEvalStaticAttrValueTemplate(style, inst,
+                                (const xmlChar *)"name",
+                                XSLT_NAMESPACE, &comp->has_name);
+}
+
+/**
+ * xsltCopyOfComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt copy-of node
+ *
+ * Process the xslt copy-of node on the source node
+ */
+static void
+xsltCopyOfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemCopyOfPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemCopyOfPtr) xsltNewStylePreComp(style, XSLT_FUNC_COPYOF);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_COPYOF);
+#endif
+
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+
+    comp->select = xsltGetCNsProp(style, inst, (const xmlChar *)"select",
+                               XSLT_NAMESPACE);
+    if (comp->select == NULL) {
+       xsltTransformError(NULL, style, inst,
+            "xsl:copy-of : select is missing\n");
+       if (style != NULL) style->errors++;
+       return;
+    }
+    comp->comp = xsltXPathCompile(style, comp->select);
+    if (comp->comp == NULL) {
+       xsltTransformError(NULL, style, inst,
+            "xsl:copy-of : could not compile select expression '%s'\n",
+                        comp->select);
+       if (style != NULL) style->errors++;
+    }
+}
+
+/**
+ * xsltValueOfComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt value-of node
+ *
+ * Process the xslt value-of node on the source node
+ */
+static void
+xsltValueOfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemValueOfPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+    const xmlChar *prop;
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemValueOfPtr) xsltNewStylePreComp(style, XSLT_FUNC_VALUEOF);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_VALUEOF);
+#endif
+
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+
+    prop = xsltGetCNsProp(style, inst,
+           (const xmlChar *)"disable-output-escaping",
+                       XSLT_NAMESPACE);
+    if (prop != NULL) {
+       if (xmlStrEqual(prop, (const xmlChar *)"yes")) {
+           comp->noescape = 1;
+       } else if (!xmlStrEqual(prop,
+                               (const xmlChar *)"no")){
+           xsltTransformError(NULL, style, inst,
+"xsl:value-of : disable-output-escaping allows only yes or no\n");
+           if (style != NULL) style->warnings++;
+       }
+    }
+    comp->select = xsltGetCNsProp(style, inst, (const xmlChar *)"select",
+                               XSLT_NAMESPACE);
+    if (comp->select == NULL) {
+       xsltTransformError(NULL, style, inst,
+            "xsl:value-of : select is missing\n");
+       if (style != NULL) style->errors++;
+       return;
+    }
+    comp->comp = xsltXPathCompile(style, comp->select);
+    if (comp->comp == NULL) {
+       xsltTransformError(NULL, style, inst,
+            "xsl:value-of : could not compile select expression '%s'\n",
+                        comp->select);
+       if (style != NULL) style->errors++;
+    }
+}
+
+static void
+xsltGetQNameProperty(xsltStylesheetPtr style, xmlNodePtr inst,
+                    const xmlChar *propName,
+                    int mandatory,
+                    int *hasProp, const xmlChar **nsName,
+                    const xmlChar** localName)
+{
+    const xmlChar *prop;
+
+    if (nsName)
+       *nsName = NULL;
+    if (localName)
+       *localName = NULL;
+    if (hasProp)
+       *hasProp = 0;
+
+    prop = xsltGetCNsProp(style, inst, propName, XSLT_NAMESPACE);
+    if (prop == NULL) {
+       if (mandatory) {
+           xsltTransformError(NULL, style, inst,
+               "The attribute '%s' is missing.\n", propName);
+           style->errors++;
+           return;
+       }
+    } else {
+        const xmlChar *URI;
+
+       if (xmlValidateQName(prop, 0)) {
+           xsltTransformError(NULL, style, inst,
+               "The value '%s' of the attribute "
+               "'%s' is not a valid QName.\n", prop, propName);
+           style->errors++;
+           return;
+       } else {
+           /*
+           * @prop will be in the string dict afterwards, @URI not.
+           */
+           URI = xsltGetQNameURI2(style, inst, &prop);
+           if (prop == NULL) {
+               style->errors++;
+           } else {
+               *localName = prop;
+               if (hasProp)
+                   *hasProp = 1;
+               if (URI != NULL) {
+                   /*
+                   * Fixes bug #308441: Put the ns-name in the dict
+                   * in order to pointer compare names during XPath's
+                   * variable lookup.
+                   */
+                   if (nsName)
+                       *nsName = xmlDictLookup(style->dict, URI, -1);
+                   /* comp->has_ns = 1; */
+               }
+           }
+       }
+    }
+    return;
+}
+
+/**
+ * xsltWithParamComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt with-param node
+ *
+ * Process the xslt with-param node on the source node
+ * Allowed parents: xsl:call-template, xsl:apply-templates.
+ * <xsl:with-param
+ *  name = qname
+ *  select = expression>
+ *  <!-- Content: template -->
+ * </xsl:with-param>
+ */
+static void
+xsltWithParamComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemWithParamPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemWithParamPtr) xsltNewStylePreComp(style, XSLT_FUNC_WITHPARAM);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_WITHPARAM);
+#endif
+
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+
+    /*
+    * Attribute "name".
+    */
+    xsltGetQNameProperty(style, inst, BAD_CAST "name",
+       1, &(comp->has_name), &(comp->ns), &(comp->name));
+    if (comp->ns)
+       comp->has_ns = 1;
+    /*
+    * Attribute "select".
+    */
+    comp->select = xsltGetCNsProp(style, inst, (const xmlChar *)"select",
+                               XSLT_NAMESPACE);
+    if (comp->select != NULL) {
+       comp->comp = xsltXPathCompile(style, comp->select);
+       if (comp->comp == NULL) {
+           xsltTransformError(NULL, style, inst,
+                "XSLT-with-param: Failed to compile select "
+                "expression '%s'\n", comp->select);
+           style->errors++;
+       }
+       if (inst->children != NULL) {
+           xsltTransformError(NULL, style, inst,
+               "XSLT-with-param: The content should be empty since "
+               "the attribute select is present.\n");
+           style->warnings++;
+       }
+    }
+}
+
+/**
+ * xsltNumberComp:
+ * @style: an XSLT compiled stylesheet
+ * @cur:   the xslt number node
+ *
+ * Process the xslt number node on the source node
+ */
+static void
+xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemNumberPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+    const xmlChar *prop;
+
+    if ((style == NULL) || (cur == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemNumberPtr) xsltNewStylePreComp(style, XSLT_FUNC_NUMBER);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_NUMBER);
+#endif
+
+    if (comp == NULL)
+       return;
+    cur->psvi = comp;
+
+    if ((style == NULL) || (cur == NULL))
+       return;
+
+    comp->numdata.doc = cur->doc;
+    comp->numdata.node = cur;
+    comp->numdata.value = xsltGetCNsProp(style, cur, (const xmlChar *)"value",
+                                       XSLT_NAMESPACE);
+    
+    prop = xsltEvalStaticAttrValueTemplate(style, cur,
+                        (const xmlChar *)"format",
+                        XSLT_NAMESPACE, &comp->numdata.has_format);
+    if (comp->numdata.has_format == 0) {
+       comp->numdata.format = xmlDictLookup(style->dict, BAD_CAST "" , 0);
+    } else {
+       comp->numdata.format = prop;
+    }
+
+    comp->numdata.count = xsltGetCNsProp(style, cur, (const xmlChar *)"count",
+                                       XSLT_NAMESPACE);
+    comp->numdata.from = xsltGetCNsProp(style, cur, (const xmlChar *)"from",
+                                       XSLT_NAMESPACE);
+    
+    prop = xsltGetCNsProp(style, cur, (const xmlChar *)"level", XSLT_NAMESPACE);
+    if (prop != NULL) {
+       if (xmlStrEqual(prop, BAD_CAST("single")) ||
+           xmlStrEqual(prop, BAD_CAST("multiple")) ||
+           xmlStrEqual(prop, BAD_CAST("any"))) {
+           comp->numdata.level = prop;
+       } else {
+           xsltTransformError(NULL, style, cur,
+                        "xsl:number : invalid value %s for level\n", prop);
+           if (style != NULL) style->warnings++;
+       }
+    }
+    
+    prop = xsltGetCNsProp(style, cur, (const xmlChar *)"lang", XSLT_NAMESPACE);
+    if (prop != NULL) {
+           xsltTransformError(NULL, style, cur,
+                "xsl:number : lang attribute not implemented\n");
+       XSLT_TODO; /* xsl:number lang attribute */
+    }
+    
+    prop = xsltGetCNsProp(style, cur, (const xmlChar *)"letter-value", XSLT_NAMESPACE);
+    if (prop != NULL) {
+       if (xmlStrEqual(prop, BAD_CAST("alphabetic"))) {
+           xsltTransformError(NULL, style, cur,
+                "xsl:number : letter-value 'alphabetic' not implemented\n");
+           if (style != NULL) style->warnings++;
+           XSLT_TODO; /* xsl:number letter-value attribute alphabetic */
+       } else if (xmlStrEqual(prop, BAD_CAST("traditional"))) {
+           xsltTransformError(NULL, style, cur,
+                "xsl:number : letter-value 'traditional' not implemented\n");
+           if (style != NULL) style->warnings++;
+           XSLT_TODO; /* xsl:number letter-value attribute traditional */
+       } else {
+           xsltTransformError(NULL, style, cur,
+                    "xsl:number : invalid value %s for letter-value\n", prop);
+           if (style != NULL) style->warnings++;
+       }
+    }
+    
+    prop = xsltGetCNsProp(style, cur, (const xmlChar *)"grouping-separator",
+                       XSLT_NAMESPACE);
+    if (prop != NULL) {
+        comp->numdata.groupingCharacterLen = xmlStrlen(prop);
+       comp->numdata.groupingCharacter =
+           xsltGetUTF8Char(prop, &(comp->numdata.groupingCharacterLen));
+    }
+    
+    prop = xsltGetCNsProp(style, cur, (const xmlChar *)"grouping-size", XSLT_NAMESPACE);
+    if (prop != NULL) {
+       sscanf((char *)prop, "%d", &comp->numdata.digitsPerGroup);
+    } else {
+       comp->numdata.groupingCharacter = 0;
+    }
+
+    /* Set default values */
+    if (comp->numdata.value == NULL) {
+       if (comp->numdata.level == NULL) {
+           comp->numdata.level = xmlDictLookup(style->dict,
+                                               BAD_CAST"single", 6);
+       }
+    }
+    
+}
+
+/**
+ * xsltApplyImportsComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt apply-imports node
+ *
+ * Process the xslt apply-imports node on the source node
+ */
+static void
+xsltApplyImportsComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemApplyImportsPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemApplyImportsPtr) xsltNewStylePreComp(style, XSLT_FUNC_APPLYIMPORTS);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_APPLYIMPORTS);
+#endif
+
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+}
+
+/**
+ * xsltCallTemplateComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt call-template node
+ *
+ * Process the xslt call-template node on the source node
+ */
+static void
+xsltCallTemplateComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemCallTemplatePtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemCallTemplatePtr)
+       xsltNewStylePreComp(style, XSLT_FUNC_CALLTEMPLATE);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_CALLTEMPLATE);
+#endif
+
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+
+    /*
+     * Attribute "name".
+     */
+    xsltGetQNameProperty(style, inst, BAD_CAST "name",
+       1, &(comp->has_name), &(comp->ns), &(comp->name));
+    if (comp->ns)
+       comp->has_ns = 1;
+}
+
+/**
+ * xsltApplyTemplatesComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the apply-templates node
+ *
+ * Process the apply-templates node on the source node
+ */
+static void
+xsltApplyTemplatesComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemApplyTemplatesPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemApplyTemplatesPtr)
+       xsltNewStylePreComp(style, XSLT_FUNC_APPLYTEMPLATES);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_APPLYTEMPLATES);
+#endif
+
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+
+    /*
+     * Attribute "mode".
+     */
+    xsltGetQNameProperty(style, inst, BAD_CAST "mode",
+       0, NULL, &(comp->modeURI), &(comp->mode));
+    /*
+    * Attribute "select".
+    */
+    comp->select = xsltGetCNsProp(style, inst, BAD_CAST "select",
+       XSLT_NAMESPACE);
+    if (comp->select != NULL) {
+       comp->comp = xsltXPathCompile(style, comp->select);
+       if (comp->comp == NULL) {
+           xsltTransformError(NULL, style, inst,
+               "XSLT-apply-templates: could not compile select "
+               "expression '%s'\n", comp->select);
+            style->errors++;
+       }
+    }
+    /* TODO: handle (or skip) the xsl:sort and xsl:with-param */
+}
+
+/**
+ * xsltChooseComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt choose node
+ *
+ * Process the xslt choose node on the source node
+ */
+static void
+xsltChooseComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemChoosePtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemChoosePtr)
+       xsltNewStylePreComp(style, XSLT_FUNC_CHOOSE);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_CHOOSE);
+#endif
+
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+}
+
+/**
+ * xsltIfComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt if node
+ *
+ * Process the xslt if node on the source node
+ */
+static void
+xsltIfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemIfPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemIfPtr)
+       xsltNewStylePreComp(style, XSLT_FUNC_IF);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_IF);
+#endif
+
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+
+    comp->test = xsltGetCNsProp(style, inst, (const xmlChar *)"test", XSLT_NAMESPACE);
+    if (comp->test == NULL) {
+       xsltTransformError(NULL, style, inst,
+            "xsl:if : test is not defined\n");
+       if (style != NULL) style->errors++;
+       return;
+    }
+    comp->comp = xsltXPathCompile(style, comp->test);
+    if (comp->comp == NULL) {
+       xsltTransformError(NULL, style, inst,
+            "xsl:if : could not compile test expression '%s'\n",
+                        comp->test);
+       if (style != NULL) style->errors++;
+    }
+}
+
+/**
+ * xsltWhenComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt if node
+ *
+ * Process the xslt if node on the source node
+ */
+static void
+xsltWhenComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemWhenPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemWhenPtr)
+       xsltNewStylePreComp(style, XSLT_FUNC_WHEN);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_WHEN);
+#endif
+
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+
+    comp->test = xsltGetCNsProp(style, inst, (const xmlChar *)"test", XSLT_NAMESPACE);
+    if (comp->test == NULL) {
+       xsltTransformError(NULL, style, inst,
+            "xsl:when : test is not defined\n");
+       if (style != NULL) style->errors++;
+       return;
+    }
+    comp->comp = xsltXPathCompile(style, comp->test);
+    if (comp->comp == NULL) {
+       xsltTransformError(NULL, style, inst,
+            "xsl:when : could not compile test expression '%s'\n",
+                        comp->test);
+       if (style != NULL) style->errors++;
+    }
+}
+
+/**
+ * xsltForEachComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt for-each node
+ *
+ * Process the xslt for-each node on the source node
+ */
+static void
+xsltForEachComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemForEachPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemForEachPtr)
+       xsltNewStylePreComp(style, XSLT_FUNC_FOREACH);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_FOREACH);
+#endif
+
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+
+    comp->select = xsltGetCNsProp(style, inst, (const xmlChar *)"select",
+                               XSLT_NAMESPACE);
+    if (comp->select == NULL) {
+       xsltTransformError(NULL, style, inst,
+               "xsl:for-each : select is missing\n");
+       if (style != NULL) style->errors++;
+    } else {
+       comp->comp = xsltXPathCompile(style, comp->select);
+       if (comp->comp == NULL) {
+           xsltTransformError(NULL, style, inst,
+     "xsl:for-each : could not compile select expression '%s'\n",
+                            comp->select);
+           if (style != NULL) style->errors++;
+       }
+    }
+    /* TODO: handle and skip the xsl:sort */
+}
+
+/**
+ * xsltVariableComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt variable node
+ *
+ * Process the xslt variable node on the source node
+ */
+static void
+xsltVariableComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemVariablePtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemVariablePtr)
+       xsltNewStylePreComp(style, XSLT_FUNC_VARIABLE);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_VARIABLE);
+#endif
+
+    if (comp == NULL)
+       return;
+
+    inst->psvi = comp;
+    comp->inst = inst;
+    /*
+     * The full template resolution can be done statically
+     */
+
+    /*
+    * Attribute "name".
+    */
+    xsltGetQNameProperty(style, inst, BAD_CAST "name",
+       1, &(comp->has_name), &(comp->ns), &(comp->name));
+    if (comp->ns)
+       comp->has_ns = 1;    
+    /*
+    * Attribute "select".
+    */
+    comp->select = xsltGetCNsProp(style, inst, (const xmlChar *)"select",
+                               XSLT_NAMESPACE);
+    if (comp->select != NULL) {
+       comp->comp = xsltXPathCompile(style, comp->select);
+       if (comp->comp == NULL) {
+           xsltTransformError(NULL, style, inst,
+               "XSLT-variable: Failed to compile the XPath expression '%s'.\n",
+               comp->select);
+           style->errors++;
+       }
+       if (inst->children != NULL) {
+           xsltTransformError(NULL, style, inst,
+               "XSLT-variable: The must be no child nodes, since the "
+               "attribute 'select' was specified.\n");
+           style->errors++;
+       }
+    }
+}
+
+/**
+ * xsltParamComp:
+ * @style: an XSLT compiled stylesheet
+ * @inst:  the xslt param node
+ *
+ * Process the xslt param node on the source node
+ */
+static void
+xsltParamComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemParamPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((style == NULL) || (inst == NULL))
+       return;
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleItemParamPtr)
+       xsltNewStylePreComp(style, XSLT_FUNC_PARAM);
+#else
+    comp = xsltNewStylePreComp(style, XSLT_FUNC_PARAM);
+#endif
+
+    if (comp == NULL)
+       return;
+    inst->psvi = comp;
+    comp->inst = inst;
+
+    /*
+     * Attribute "name".
+     */
+    xsltGetQNameProperty(style, inst, BAD_CAST "name",
+       1, &(comp->has_name), &(comp->ns), &(comp->name));
+    if (comp->ns)
+       comp->has_ns = 1;
+    /*
+    * Attribute "select".
+    */
+    comp->select = xsltGetCNsProp(style, inst, (const xmlChar *)"select",
+                               XSLT_NAMESPACE);
+    if (comp->select != NULL) {
+       comp->comp = xsltXPathCompile(style, comp->select);
+       if (comp->comp == NULL) {
+           xsltTransformError(NULL, style, inst,
+               "XSLT-param: could not compile select expression '%s'.\n",
+               comp->select);
+           style->errors++;
+       }
+       if (inst->children != NULL) {
+           xsltTransformError(NULL, style, inst,
+               "XSLT-param: The content should be empty since the "
+               "attribute 'select' is present.\n");
+           style->warnings++;
+       }
+    }
+}
+
+/************************************************************************
+ *                                                                     *
+ *                 Generic interface                                   *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltFreeStylePreComps:
+ * @style:  an XSLT transformation context
+ *
+ * Free up the memory allocated by all precomputed blocks
+ */
+void
+xsltFreeStylePreComps(xsltStylesheetPtr style) {
+    xsltElemPreCompPtr cur, next;
+
+    if (style == NULL)
+       return;        
+    
+    cur = style->preComps;
+    while (cur != NULL) {
+       next = cur->next;               
+       if (cur->type == XSLT_FUNC_EXTENSION)
+           cur->free(cur);
+       else
+           xsltFreeStylePreComp((xsltStylePreCompPtr) cur);
+       cur = next;
+    }
+}
+
+#ifdef XSLT_REFACTORED
+
+/**
+ * xsltStylePreCompute:
+ * @style:  the XSLT stylesheet
+ * @node:  the element in the XSLT namespace
+ *
+ * Precompute an XSLT element.
+ * This expects the type of the element to be already
+ * set in style->compCtxt->inode->type;
+ */
+void
+xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr node) {
+    /*    
+    * The xsltXSLTElemMarker marker was set beforehand by
+    *  the parsing mechanism for all elements in the XSLT namespace.
+    */
+    if (style == NULL) {
+       if (node != NULL)
+           node->psvi = NULL;
+       return;
+    }
+    if (node == NULL)
+       return;
+    if (! IS_XSLT_ELEM_FAST(node))
+       return;
+
+    node->psvi = NULL;
+    if (XSLT_CCTXT(style)->inode->type != 0) {
+       switch (XSLT_CCTXT(style)->inode->type) {
+           case XSLT_FUNC_APPLYTEMPLATES:
+               xsltApplyTemplatesComp(style, node);
+               break;
+           case XSLT_FUNC_WITHPARAM:                      
+               xsltWithParamComp(style, node);
+               break;
+           case XSLT_FUNC_VALUEOF:         
+               xsltValueOfComp(style, node);
+               break;
+           case XSLT_FUNC_COPY:            
+               xsltCopyComp(style, node);
+               break;
+           case XSLT_FUNC_COPYOF:
+               xsltCopyOfComp(style, node);
+               break;
+           case XSLT_FUNC_IF:      
+               xsltIfComp(style, node);
+               break;
+           case XSLT_FUNC_CHOOSE:          
+               xsltChooseComp(style, node);
+               break;
+           case XSLT_FUNC_WHEN:            
+               xsltWhenComp(style, node);
+               break;
+           case XSLT_FUNC_OTHERWISE:       
+               /* NOP yet */
+               return;
+           case XSLT_FUNC_FOREACH:         
+               xsltForEachComp(style, node);
+               break;
+           case XSLT_FUNC_APPLYIMPORTS:            
+               xsltApplyImportsComp(style, node);
+               break;
+           case XSLT_FUNC_ATTRIBUTE:       
+               xsltAttributeComp(style, node);
+               break;
+           case XSLT_FUNC_ELEMENT:         
+               xsltElementComp(style, node);
+               break;
+           case XSLT_FUNC_SORT:            
+               xsltSortComp(style, node);
+               break;
+           case XSLT_FUNC_COMMENT:         
+               xsltCommentComp(style, node);
+               break;
+           case XSLT_FUNC_NUMBER:          
+               xsltNumberComp(style, node);
+               break;
+           case XSLT_FUNC_PI:      
+               xsltProcessingInstructionComp(style, node);
+               break;
+           case XSLT_FUNC_CALLTEMPLATE:            
+               xsltCallTemplateComp(style, node);
+               break;
+           case XSLT_FUNC_PARAM:           
+               xsltParamComp(style, node);
+               break;
+           case XSLT_FUNC_VARIABLE:        
+               xsltVariableComp(style, node);
+               break;
+           case XSLT_FUNC_FALLBACK:        
+               /* NOP yet */
+               return;
+           case XSLT_FUNC_DOCUMENT:        
+               /* The extra one */
+               node->psvi = (void *) xsltDocumentComp(style, node,
+                   (xsltTransformFunction) xsltDocumentElem);
+               break;
+           case XSLT_FUNC_MESSAGE:
+               /* NOP yet */
+               return;
+           default:
+               /*
+               * NOTE that xsl:text, xsl:template, xsl:stylesheet,
+               *  xsl:transform, xsl:import, xsl:include are not expected
+               *  to be handed over to this function.
+               */
+               xsltTransformError(NULL, style, node,
+                   "Internal error: (xsltStylePreCompute) cannot handle "
+                   "the XSLT element '%s'.\n", node->name);
+               style->errors++;
+               return;
+       }
+    } else {
+       /*
+       * Fallback to string comparison.
+       */      
+       if (IS_XSLT_NAME(node, "apply-templates")) {
+           xsltApplyTemplatesComp(style, node);
+       } else if (IS_XSLT_NAME(node, "with-param")) {
+           xsltWithParamComp(style, node);
+       } else if (IS_XSLT_NAME(node, "value-of")) {
+           xsltValueOfComp(style, node);
+       } else if (IS_XSLT_NAME(node, "copy")) {
+           xsltCopyComp(style, node);
+       } else if (IS_XSLT_NAME(node, "copy-of")) {
+           xsltCopyOfComp(style, node);
+       } else if (IS_XSLT_NAME(node, "if")) {
+           xsltIfComp(style, node);
+       } else if (IS_XSLT_NAME(node, "choose")) {
+           xsltChooseComp(style, node);
+       } else if (IS_XSLT_NAME(node, "when")) {
+           xsltWhenComp(style, node);  
+       } else if (IS_XSLT_NAME(node, "otherwise")) {
+           /* NOP yet */
+           return;
+       } else if (IS_XSLT_NAME(node, "for-each")) {
+           xsltForEachComp(style, node);
+       } else if (IS_XSLT_NAME(node, "apply-imports")) {
+           xsltApplyImportsComp(style, node);
+       } else if (IS_XSLT_NAME(node, "attribute")) {
+           xsltAttributeComp(style, node);
+       } else if (IS_XSLT_NAME(node, "element")) {
+           xsltElementComp(style, node);
+       } else if (IS_XSLT_NAME(node, "sort")) {
+           xsltSortComp(style, node);
+       } else if (IS_XSLT_NAME(node, "comment")) {
+           xsltCommentComp(style, node);
+       } else if (IS_XSLT_NAME(node, "number")) {
+           xsltNumberComp(style, node);
+       } else if (IS_XSLT_NAME(node, "processing-instruction")) {
+           xsltProcessingInstructionComp(style, node);
+       } else if (IS_XSLT_NAME(node, "call-template")) {
+           xsltCallTemplateComp(style, node);
+       } else if (IS_XSLT_NAME(node, "param")) {
+           xsltParamComp(style, node);
+       } else if (IS_XSLT_NAME(node, "variable")) {
+           xsltVariableComp(style, node);
+       } else if (IS_XSLT_NAME(node, "fallback")) {
+           /* NOP yet */
+           return;
+       } else if (IS_XSLT_NAME(node, "document")) {
+           /* The extra one */
+           node->psvi = (void *) xsltDocumentComp(style, node,
+               (xsltTransformFunction) xsltDocumentElem);      
+       } else if (IS_XSLT_NAME(node, "output")) {
+           /* Top-level */
+           return;
+       } else if (IS_XSLT_NAME(node, "preserve-space")) {
+           /* Top-level */
+           return;
+       } else if (IS_XSLT_NAME(node, "strip-space")) {
+           /* Top-level */
+           return;     
+       } else if (IS_XSLT_NAME(node, "key")) {
+           /* Top-level */
+           return;
+       } else if (IS_XSLT_NAME(node, "message")) {
+           return;
+       } else if (IS_XSLT_NAME(node, "attribute-set")) {
+           /* Top-level */
+           return;
+       } else if (IS_XSLT_NAME(node, "namespace-alias")) {
+           /* Top-level */
+           return;
+       } else if (IS_XSLT_NAME(node, "decimal-format")) {
+           /* Top-level */
+           return;
+       } else if (IS_XSLT_NAME(node, "include")) {
+           /* Top-level */                 
+       } else {
+           /*
+           * NOTE that xsl:text, xsl:template, xsl:stylesheet,
+           *  xsl:transform, xsl:import, xsl:include are not expected
+           *  to be handed over to this function.
+           */
+           xsltTransformError(NULL, style, node,
+               "Internal error: (xsltStylePreCompute) cannot handle "
+               "the XSLT element '%s'.\n", node->name);
+               style->errors++;
+           return;
+       }       
+    }
+    /*
+    * Assign the current list of in-scope namespaces to the
+    * item. This is needed for XPath expressions.
+    */
+    if (node->psvi != NULL) {
+       ((xsltStylePreCompPtr) node->psvi)->inScopeNs =
+           XSLT_CCTXT(style)->inode->inScopeNs;
+    }
+}
+
+#else
+
+/**
+ * xsltStylePreCompute:
+ * @style:  the XSLT stylesheet
+ * @inst:  the instruction in the stylesheet
+ *
+ * Precompute an XSLT stylesheet element
+ */
+void
+xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst) {
+    /*
+    * URGENT TODO: Normally inst->psvi Should never be reserved here,
+    *   BUT: since if we include the same stylesheet from
+    *   multiple imports, then the stylesheet will be parsed
+    *   again. We simply must not try to compute the stylesheet again.
+    * TODO: Get to the point where we don't need to query the
+    *   namespace- and local-name of the node, but can evaluate this
+    *   using cctxt->style->inode->category;
+    */
+    if (inst->psvi != NULL)
+       return;
+
+    if (IS_XSLT_ELEM(inst)) {
+       xsltStylePreCompPtr cur;
+
+       if (IS_XSLT_NAME(inst, "apply-templates")) {
+           xsltCheckInstructionElement(style, inst);
+           xsltApplyTemplatesComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "with-param")) {
+           xsltCheckParentElement(style, inst, BAD_CAST "apply-templates",
+                                  BAD_CAST "call-template");
+           xsltWithParamComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "value-of")) {
+           xsltCheckInstructionElement(style, inst);
+           xsltValueOfComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "copy")) {
+           xsltCheckInstructionElement(style, inst);
+           xsltCopyComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "copy-of")) {
+           xsltCheckInstructionElement(style, inst);
+           xsltCopyOfComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "if")) {
+           xsltCheckInstructionElement(style, inst);
+           xsltIfComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "when")) {
+           xsltCheckParentElement(style, inst, BAD_CAST "choose", NULL);
+           xsltWhenComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "choose")) {
+           xsltCheckInstructionElement(style, inst);
+           xsltChooseComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "for-each")) {
+           xsltCheckInstructionElement(style, inst);
+           xsltForEachComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "apply-imports")) {
+           xsltCheckInstructionElement(style, inst);
+           xsltApplyImportsComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "attribute")) {
+           xmlNodePtr parent = inst->parent;
+
+           if ((parent == NULL) || (parent->ns == NULL) ||
+               ((parent->ns != inst->ns) &&
+                (!xmlStrEqual(parent->ns->href, inst->ns->href))) ||
+               (!xmlStrEqual(parent->name, BAD_CAST "attribute-set"))) {
+               xsltCheckInstructionElement(style, inst);
+           }
+           xsltAttributeComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "element")) {
+           xsltCheckInstructionElement(style, inst);
+           xsltElementComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "text")) {
+           xsltCheckInstructionElement(style, inst);
+           xsltTextComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "sort")) {
+           xsltCheckParentElement(style, inst, BAD_CAST "apply-templates",
+                                  BAD_CAST "for-each");
+           xsltSortComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "comment")) {
+           xsltCheckInstructionElement(style, inst);
+           xsltCommentComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "number")) {
+           xsltCheckInstructionElement(style, inst);
+           xsltNumberComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "processing-instruction")) {
+           xsltCheckInstructionElement(style, inst);
+           xsltProcessingInstructionComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "call-template")) {
+           xsltCheckInstructionElement(style, inst);
+           xsltCallTemplateComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "param")) {          
+           if (xsltCheckTopLevelElement(style, inst, 0) == 0)
+               xsltCheckInstructionElement(style, inst);
+           xsltParamComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "variable")) {
+           if (xsltCheckTopLevelElement(style, inst, 0) == 0)
+               xsltCheckInstructionElement(style, inst);
+           xsltVariableComp(style, inst);
+       } else if (IS_XSLT_NAME(inst, "otherwise")) {
+           xsltCheckParentElement(style, inst, BAD_CAST "choose", NULL);
+           xsltCheckInstructionElement(style, inst);
+           return;
+       } else if (IS_XSLT_NAME(inst, "template")) {
+           xsltCheckTopLevelElement(style, inst, 1);
+           return;
+       } else if (IS_XSLT_NAME(inst, "output")) {
+           xsltCheckTopLevelElement(style, inst, 1);
+           return;
+       } else if (IS_XSLT_NAME(inst, "preserve-space")) {
+           xsltCheckTopLevelElement(style, inst, 1);
+           return;
+       } else if (IS_XSLT_NAME(inst, "strip-space")) {
+           xsltCheckTopLevelElement(style, inst, 1);
+           return;
+       } else if ((IS_XSLT_NAME(inst, "stylesheet")) ||
+                  (IS_XSLT_NAME(inst, "transform"))) {
+           xmlNodePtr parent = inst->parent;
+
+           if ((parent == NULL) || (parent->type != XML_DOCUMENT_NODE)) {
+               xsltTransformError(NULL, style, inst,
+                   "element %s only allowed only as root element\n",
+                                  inst->name);
+               style->errors++;
+           }
+           return;
+       } else if (IS_XSLT_NAME(inst, "key")) {
+           xsltCheckTopLevelElement(style, inst, 1);
+           return;
+       } else if (IS_XSLT_NAME(inst, "message")) {
+           xsltCheckInstructionElement(style, inst);
+           return;
+       } else if (IS_XSLT_NAME(inst, "attribute-set")) {
+           xsltCheckTopLevelElement(style, inst, 1);
+           return;
+       } else if (IS_XSLT_NAME(inst, "namespace-alias")) {
+           xsltCheckTopLevelElement(style, inst, 1);
+           return;
+       } else if (IS_XSLT_NAME(inst, "include")) {
+           xsltCheckTopLevelElement(style, inst, 1);
+           return;
+       } else if (IS_XSLT_NAME(inst, "import")) {
+           xsltCheckTopLevelElement(style, inst, 1);
+           return;
+       } else if (IS_XSLT_NAME(inst, "decimal-format")) {
+           xsltCheckTopLevelElement(style, inst, 1);
+           return;
+       } else if (IS_XSLT_NAME(inst, "fallback")) {
+           xsltCheckInstructionElement(style, inst);
+           return;
+       } else if (IS_XSLT_NAME(inst, "document")) {
+           xsltCheckInstructionElement(style, inst);
+           inst->psvi = (void *) xsltDocumentComp(style, inst,
+                               (xsltTransformFunction) xsltDocumentElem);
+       } else {
+           xsltTransformError(NULL, style, inst,
+                "xsltStylePreCompute: unknown xsl:%s\n", inst->name);
+           if (style != NULL) style->warnings++;
+       }
+       
+       cur = (xsltStylePreCompPtr) inst->psvi;
+       /*
+       * A ns-list is build for every XSLT item in the
+       * node-tree. This is needed for XPath expressions.
+       */
+       if (cur != NULL) {
+           int i = 0;
+
+           cur->nsList = xmlGetNsList(inst->doc, inst);
+            if (cur->nsList != NULL) {
+               while (cur->nsList[i] != NULL)
+                   i++;
+           }
+           cur->nsNr = i;
+       }
+    } else {
+       inst->psvi =
+           (void *) xsltPreComputeExtModuleElement(style, inst);
+
+       /*
+        * Unknown element, maybe registered at the context
+        * level. Mark it for later recognition.
+        */
+       if (inst->psvi == NULL)
+           inst->psvi = (void *) xsltExtMarker;
+    }
+}
+#endif /* XSLT_REFACTORED */
diff --git a/reactos/dll/3rdparty/libxslt/preproc.h b/reactos/dll/3rdparty/libxslt/preproc.h
new file mode 100644 (file)
index 0000000..f67b389
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Summary: precomputing stylesheets
+ * Description: this is the compilation phase, where most of the
+ *              stylesheet is "compiled" into faster to use data.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_PRECOMP_H__
+#define __XML_XSLT_PRECOMP_H__
+
+#include <libxml/tree.h>
+#include "xsltexports.h"
+#include "xsltInternals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Interfaces
+ */
+extern const xmlChar *xsltExtMarker;
+
+XSLTPUBFUN xsltElemPreCompPtr XSLTCALL 
+               xsltDocumentComp        (xsltStylesheetPtr style,
+                                        xmlNodePtr inst,
+                                        xsltTransformFunction function);
+
+XSLTPUBFUN void XSLTCALL               
+               xsltStylePreCompute     (xsltStylesheetPtr style,
+                                        xmlNodePtr inst);
+XSLTPUBFUN void XSLTCALL               
+               xsltFreeStylePreComps   (xsltStylesheetPtr style);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_PRECOMP_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/security.c b/reactos/dll/3rdparty/libxslt/security.c
new file mode 100644 (file)
index 0000000..4130729
--- /dev/null
@@ -0,0 +1,475 @@
+/*
+ * security.c: Implementation of the XSLT security framework
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#ifdef HAVE_MATH_H
+#include <math.h>
+#endif
+#ifdef HAVE_FLOAT_H
+#include <float.h>
+#endif
+#ifdef HAVE_IEEEFP_H
+#include <ieeefp.h>
+#endif
+#ifdef HAVE_NAN_H
+#include <nan.h>
+#endif
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+
+#if defined(WIN32) && !defined(__CYGWIN__)
+#include <windows.h>
+#ifndef INVALID_FILE_ATTRIBUTES
+#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
+#endif
+#endif
+
+#ifndef HAVE_STAT
+#  ifdef HAVE__STAT
+     /* MS C library seems to define stat and _stat. The definition
+      *         is identical. Still, mapping them to each other causes a warning. */
+#    ifndef _MSC_VER
+#      define stat(x,y) _stat(x,y)
+#    endif
+#    define HAVE_STAT
+#  endif
+#endif
+
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/uri.h>
+#include "xslt.h"
+#include "xsltInternals.h"
+#include "xsltutils.h"
+#include "security.h"
+
+
+struct _xsltSecurityPrefs {
+    xsltSecurityCheck readFile;
+    xsltSecurityCheck createFile;
+    xsltSecurityCheck createDir;
+    xsltSecurityCheck readNet;
+    xsltSecurityCheck writeNet;
+};
+
+static xsltSecurityPrefsPtr xsltDefaultSecurityPrefs = NULL;
+
+/************************************************************************
+ *                                                                     *
+ *                     Module interfaces                               *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltNewSecurityPrefs:
+ *
+ * Create a new security preference block
+ *
+ * Returns a pointer to the new block or NULL in case of error
+ */
+xsltSecurityPrefsPtr
+xsltNewSecurityPrefs(void) {
+    xsltSecurityPrefsPtr ret;
+
+    ret = (xsltSecurityPrefsPtr) xmlMalloc(sizeof(xsltSecurityPrefs));
+    if (ret == NULL) {
+       xsltTransformError(NULL, NULL, NULL,
+               "xsltNewSecurityPrefs : malloc failed\n");
+       return(NULL);
+    }
+    memset(ret, 0, sizeof(xsltSecurityPrefs));
+    return(ret);
+}
+
+/**
+ * xsltFreeSecurityPrefs:
+ * @sec:  the security block to free
+ *
+ * Free up a security preference block
+ */
+void
+xsltFreeSecurityPrefs(xsltSecurityPrefsPtr sec) {
+    if (sec == NULL)
+       return;
+    xmlFree(sec);
+}
+
+/**
+ * xsltSetSecurityPrefs:
+ * @sec:  the security block to update
+ * @option:  the option to update
+ * @func:  the user callback to use for this option
+ *
+ * Update the security option to use the new callback checking function
+ *
+ * Returns -1 in case of error, 0 otherwise
+ */
+int
+xsltSetSecurityPrefs(xsltSecurityPrefsPtr sec, xsltSecurityOption option,
+                     xsltSecurityCheck func) {
+    if (sec == NULL)
+       return(-1);
+    switch (option) {
+        case XSLT_SECPREF_READ_FILE:
+            sec->readFile = func; return(0);
+        case XSLT_SECPREF_WRITE_FILE:
+            sec->createFile = func; return(0);
+        case XSLT_SECPREF_CREATE_DIRECTORY:
+            sec->createDir = func; return(0);
+        case XSLT_SECPREF_READ_NETWORK:
+            sec->readNet = func; return(0);
+        case XSLT_SECPREF_WRITE_NETWORK:
+            sec->writeNet = func; return(0);
+    }
+    return(-1);
+}
+
+/**
+ * xsltGetSecurityPrefs:
+ * @sec:  the security block to update
+ * @option:  the option to lookup
+ *
+ * Lookup the security option to get the callback checking function
+ *
+ * Returns NULL if not found, the function otherwise
+ */
+xsltSecurityCheck
+xsltGetSecurityPrefs(xsltSecurityPrefsPtr sec, xsltSecurityOption option) {
+    if (sec == NULL)
+       return(NULL);
+    switch (option) {
+        case XSLT_SECPREF_READ_FILE:
+            return(sec->readFile);
+        case XSLT_SECPREF_WRITE_FILE:
+            return(sec->createFile);
+        case XSLT_SECPREF_CREATE_DIRECTORY:
+            return(sec->createDir);
+        case XSLT_SECPREF_READ_NETWORK:
+            return(sec->readNet);
+        case XSLT_SECPREF_WRITE_NETWORK:
+            return(sec->writeNet);
+    }
+    return(NULL);
+}
+
+/**
+ * xsltSetDefaultSecurityPrefs:
+ * @sec:  the security block to use
+ *
+ * Set the default security preference application-wide
+ */
+void
+xsltSetDefaultSecurityPrefs(xsltSecurityPrefsPtr sec) {
+    xsltDefaultSecurityPrefs = sec;
+}
+
+/**
+ * xsltGetDefaultSecurityPrefs:
+ *
+ * Get the default security preference application-wide
+ *
+ * Returns the current xsltSecurityPrefsPtr in use or NULL if none
+ */
+xsltSecurityPrefsPtr
+xsltGetDefaultSecurityPrefs(void) {
+    return(xsltDefaultSecurityPrefs);
+}
+
+/**
+ * xsltSetCtxtSecurityPrefs:
+ * @sec:  the security block to use
+ * @ctxt:  an XSLT transformation context
+ *
+ * Set the security preference for a specific transformation
+ *
+ * Returns -1 in case of error, 0 otherwise
+ */
+int                    
+xsltSetCtxtSecurityPrefs(xsltSecurityPrefsPtr sec,
+                        xsltTransformContextPtr ctxt) {
+    if (ctxt == NULL)
+       return(-1);
+    ctxt->sec = (void *) sec;
+    return(0);
+}
+
+
+/**
+ * xsltSecurityAllow:
+ * @sec:  the security block to use
+ * @ctxt:  an XSLT transformation context
+ * @value:  unused
+ *
+ * Function used to always allow an operation
+ *
+ * Returns 1 always
+ */
+int
+xsltSecurityAllow(xsltSecurityPrefsPtr sec ATTRIBUTE_UNUSED,
+                 xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED,
+                 const char *value ATTRIBUTE_UNUSED) {
+    return(1);
+}
+
+/**
+ * xsltSecurityForbid:
+ * @sec:  the security block to use
+ * @ctxt:  an XSLT transformation context
+ * @value:  unused
+ *
+ * Function used to always forbid an operation
+ *
+ * Returns 0 always
+ */
+int
+xsltSecurityForbid(xsltSecurityPrefsPtr sec ATTRIBUTE_UNUSED,
+                 xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED,
+                 const char *value ATTRIBUTE_UNUSED) {
+    return(0);
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     Internal interfaces                             *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltCheckFilename
+ * @path:  the path to check
+ *
+ * function checks to see if @path is a valid source
+ * (file, socket...) for XML.
+ *
+ * TODO: remove at some point !!!
+ * Local copy of xmlCheckFilename to avoid a hard dependency on
+ * a new version of libxml2 
+ *
+ * if stat is not available on the target machine,
+ * returns 1.  if stat fails, returns 0 (if calling
+ * stat on the filename fails, it can't be right).
+ * if stat succeeds and the file is a directory,
+ * returns 2.  otherwise returns 1.
+ */
+
+static int
+xsltCheckFilename (const char *path)
+{
+#ifdef HAVE_STAT
+    struct stat stat_buffer;
+#if defined(WIN32) && !defined(__CYGWIN__)
+    DWORD dwAttrs;
+
+    dwAttrs = GetFileAttributes(path); 
+    if (dwAttrs != INVALID_FILE_ATTRIBUTES) {
+        if (dwAttrs & FILE_ATTRIBUTE_DIRECTORY) {
+            return 2;
+               }
+    }
+#endif
+
+    if (stat(path, &stat_buffer) == -1)
+        return 0;
+
+#ifdef S_ISDIR
+    if (S_ISDIR(stat_buffer.st_mode)) {
+        return 2;
+    }
+#endif
+#endif
+    return 1;
+}
+
+static int
+xsltCheckWritePath(xsltSecurityPrefsPtr sec,
+                  xsltTransformContextPtr ctxt,
+                  const char *path)
+{
+    int ret;
+    xsltSecurityCheck check;
+    char *directory;
+
+    check = xsltGetSecurityPrefs(sec, XSLT_SECPREF_WRITE_FILE);
+    if (check != NULL) {
+       ret = check(sec, ctxt, path);
+       if (ret == 0) {
+           xsltTransformError(ctxt, NULL, NULL,
+                              "File write for %s refused\n", path);
+           return(0);
+       }
+    }
+
+    directory = xmlParserGetDirectory (path);
+
+    if (directory != NULL) {
+       ret = xsltCheckFilename(directory);
+       if (ret == 0) {
+           /*
+            * The directory doesn't exist check for creation
+            */
+           check = xsltGetSecurityPrefs(sec,
+                                        XSLT_SECPREF_CREATE_DIRECTORY);
+           if (check != NULL) {
+               ret = check(sec, ctxt, directory);
+               if (ret == 0) {
+                   xsltTransformError(ctxt, NULL, NULL,
+                                      "Directory creation for %s refused\n",
+                                      path);
+                   xmlFree(directory);
+                   return(0);
+               }
+           }
+           ret = xsltCheckWritePath(sec, ctxt, directory);
+           if (ret == 1)
+               ret = mkdir(directory, 0755);
+       }
+       xmlFree(directory);
+       if (ret < 0)
+           return(ret);
+    }
+
+    return(1);
+}
+
+/**
+ * xsltCheckWrite:
+ * @sec:  the security options
+ * @ctxt:  an XSLT transformation context
+ * @URL:  the resource to be written
+ *
+ * Check if the resource is allowed to be written, if necessary makes
+ * some preliminary work like creating directories
+ *
+ * Return 1 if write is allowed, 0 if not and -1 in case or error.
+ */
+int
+xsltCheckWrite(xsltSecurityPrefsPtr sec,
+              xsltTransformContextPtr ctxt, const xmlChar *URL) {
+    int ret;
+    xmlURIPtr uri;
+    xsltSecurityCheck check;
+
+    uri = xmlParseURI((const char *)URL);
+    if (uri == NULL) {
+        uri = xmlCreateURI();
+       if (uri == NULL) {
+           xsltTransformError(ctxt, NULL, NULL,
+            "xsltCheckWrite: out of memory for %s\n", URL);
+           return(-1);
+       }
+       uri->path = (char *)xmlStrdup(URL);
+    }
+    if ((uri->scheme == NULL) ||
+       (xmlStrEqual(BAD_CAST uri->scheme, BAD_CAST "file"))) {
+
+#if defined(WIN32) && !defined(__CYGWIN__)
+    if ((uri->path)&&(uri->path[0]=='/')&&
+        (uri->path[1]!='\0')&&(uri->path[2]==':'))
+    ret = xsltCheckWritePath(sec, ctxt, uri->path+1);
+    else
+#endif
+
+       /*
+        * Check if we are allowed to write this file
+        */
+       ret = xsltCheckWritePath(sec, ctxt, uri->path);
+       if (ret <= 0) {
+           xmlFreeURI(uri);
+           return(ret);
+       }
+    } else {
+       /*
+        * Check if we are allowed to write this network resource
+        */
+       check = xsltGetSecurityPrefs(sec, XSLT_SECPREF_WRITE_NETWORK);
+       if (check != NULL) {
+           ret = check(sec, ctxt, (const char *)URL);
+           if (ret == 0) {
+               xsltTransformError(ctxt, NULL, NULL,
+                            "File write for %s refused\n", URL);
+               xmlFreeURI(uri);
+               return(0);
+           }
+       }
+    }
+    xmlFreeURI(uri);
+    return(1);
+}
+
+
+/**
+ * xsltCheckRead:
+ * @sec:  the security options
+ * @ctxt: an XSLT transformation context
+ * @URL:  the resource to be read
+ *
+ * Check if the resource is allowed to be read
+ *
+ * Return 1 if read is allowed, 0 if not and -1 in case or error.
+ */
+int
+xsltCheckRead(xsltSecurityPrefsPtr sec,
+             xsltTransformContextPtr ctxt, const xmlChar *URL) {
+    int ret;
+    xmlURIPtr uri;
+    xsltSecurityCheck check;
+
+    uri = xmlParseURI((const char *)URL);
+    if (uri == NULL) {
+       xsltTransformError(ctxt, NULL, NULL,
+        "xsltCheckRead: URL parsing failed for %s\n",
+                        URL);
+       return(-1);
+    }
+    if ((uri->scheme == NULL) ||
+       (xmlStrEqual(BAD_CAST uri->scheme, BAD_CAST "file"))) {
+
+       /*
+        * Check if we are allowed to read this file
+        */
+       check = xsltGetSecurityPrefs(sec, XSLT_SECPREF_READ_FILE);
+       if (check != NULL) {
+           ret = check(sec, ctxt, uri->path);
+           if (ret == 0) {
+               xsltTransformError(ctxt, NULL, NULL,
+                            "Local file read for %s refused\n", URL);
+               xmlFreeURI(uri);
+               return(0);
+           }
+       }
+    } else {
+       /*
+        * Check if we are allowed to write this network resource
+        */
+       check = xsltGetSecurityPrefs(sec, XSLT_SECPREF_READ_NETWORK);
+       if (check != NULL) {
+           ret = check(sec, ctxt, (const char *)URL);
+           if (ret == 0) {
+               xsltTransformError(ctxt, NULL, NULL,
+                            "Network file read for %s refused\n", URL);
+               xmlFreeURI(uri);
+               return(0);
+           }
+       }
+    }
+    xmlFreeURI(uri);
+    return(1);
+}
+
diff --git a/reactos/dll/3rdparty/libxslt/security.h b/reactos/dll/3rdparty/libxslt/security.h
new file mode 100644 (file)
index 0000000..d52c0ae
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Summary: interface for the libxslt security framework
+ * Description: the libxslt security framework allow to restrict
+ *              the access to new resources (file or URL) from
+ *              the stylesheet at runtime.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_SECURITY_H__
+#define __XML_XSLT_SECURITY_H__
+
+#include <libxml/tree.h>
+#include "xsltexports.h"
+#include "xsltInternals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * xsltSecurityPref:
+ *
+ * structure to indicate the preferences for security in the XSLT
+ * transformation.
+ */
+typedef struct _xsltSecurityPrefs xsltSecurityPrefs;
+typedef xsltSecurityPrefs *xsltSecurityPrefsPtr;
+
+/**
+ * xsltSecurityOption:
+ *
+ * the set of option that can be configured
+ */
+typedef enum {
+    XSLT_SECPREF_READ_FILE = 1,
+    XSLT_SECPREF_WRITE_FILE,
+    XSLT_SECPREF_CREATE_DIRECTORY,
+    XSLT_SECPREF_READ_NETWORK,
+    XSLT_SECPREF_WRITE_NETWORK
+} xsltSecurityOption;
+
+/**
+ * xsltSecurityCheck:
+ *
+ * User provided function to check the value of a string like a file
+ * path or an URL ...
+ */
+typedef int (*xsltSecurityCheck)       (xsltSecurityPrefsPtr sec,
+                                        xsltTransformContextPtr ctxt,
+                                        const char *value);
+
+/*
+ * Module interfaces
+ */
+XSLTPUBFUN xsltSecurityPrefsPtr XSLTCALL       
+                   xsltNewSecurityPrefs        (void);
+XSLTPUBFUN void XSLTCALL                       
+                   xsltFreeSecurityPrefs       (xsltSecurityPrefsPtr sec);
+XSLTPUBFUN int XSLTCALL                        
+                   xsltSetSecurityPrefs        (xsltSecurityPrefsPtr sec,
+                                                xsltSecurityOption option,
+                                                xsltSecurityCheck func);
+XSLTPUBFUN xsltSecurityCheck XSLTCALL  
+                   xsltGetSecurityPrefs        (xsltSecurityPrefsPtr sec,
+                                                xsltSecurityOption option);
+
+XSLTPUBFUN void XSLTCALL                       
+                   xsltSetDefaultSecurityPrefs (xsltSecurityPrefsPtr sec);
+XSLTPUBFUN xsltSecurityPrefsPtr XSLTCALL       
+                   xsltGetDefaultSecurityPrefs (void);
+
+XSLTPUBFUN int XSLTCALL                        
+                   xsltSetCtxtSecurityPrefs    (xsltSecurityPrefsPtr sec,
+                                                xsltTransformContextPtr ctxt);
+
+XSLTPUBFUN int XSLTCALL                        
+                   xsltSecurityAllow           (xsltSecurityPrefsPtr sec,
+                                                xsltTransformContextPtr ctxt,
+                                                const char *value);
+XSLTPUBFUN int XSLTCALL        
+                   xsltSecurityForbid          (xsltSecurityPrefsPtr sec,
+                                                xsltTransformContextPtr ctxt,
+                                                const char *value);
+/*
+ * internal interfaces
+ */
+XSLTPUBFUN int XSLTCALL                        
+                   xsltCheckWrite              (xsltSecurityPrefsPtr sec,
+                                                xsltTransformContextPtr ctxt,
+                                                const xmlChar *URL);
+XSLTPUBFUN int XSLTCALL                        
+                   xsltCheckRead               (xsltSecurityPrefsPtr sec,
+                                                xsltTransformContextPtr ctxt,
+                                                const xmlChar *URL);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_SECURITY_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/templates.c b/reactos/dll/3rdparty/libxslt/templates.c
new file mode 100644 (file)
index 0000000..8d26a8a
--- /dev/null
@@ -0,0 +1,822 @@
+/*
+ * templates.c: Implementation of the template processing
+ *
+ * Reference:
+ *   http://www.w3.org/TR/1999/REC-xslt-19991116
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+
+#include <libxml/xmlmemory.h>
+#include <libxml/globals.h>
+#include <libxml/xmlerror.h>
+#include <libxml/tree.h>
+#include <libxml/xpathInternals.h>
+#include <libxml/parserInternals.h>
+#include "xslt.h"
+#include "xsltInternals.h"
+#include "xsltutils.h"
+#include "variables.h"
+#include "functions.h"
+#include "templates.h"
+#include "transform.h"
+#include "namespaces.h"
+#include "attributes.h"
+
+#ifdef WITH_XSLT_DEBUG
+#define WITH_XSLT_DEBUG_TEMPLATES
+#endif
+
+/************************************************************************
+ *                                                                     *
+ *                     Module interfaces                               *
+ *                                                                     *
+ ************************************************************************/
+/**
+ * xsltEvalXPathPredicate:
+ * @ctxt:  the XSLT transformation context
+ * @comp:  the XPath compiled expression
+ * @nsList:  the namespaces in scope
+ * @nsNr:  the number of namespaces in scope
+ *
+ * Process the expression using XPath and evaluate the result as
+ * an XPath predicate
+ *
+ * Returns 1 is the predicate was true, 0 otherwise
+ */
+int
+xsltEvalXPathPredicate(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp,
+                      xmlNsPtr *nsList, int nsNr) {
+    int ret;
+    xmlXPathObjectPtr res;
+    int oldNsNr;
+    xmlNsPtr *oldNamespaces;
+    xmlNodePtr oldInst;
+    int oldProximityPosition, oldContextSize;
+
+    oldContextSize = ctxt->xpathCtxt->contextSize;
+    oldProximityPosition = ctxt->xpathCtxt->proximityPosition;
+    oldNsNr = ctxt->xpathCtxt->nsNr;
+    oldNamespaces = ctxt->xpathCtxt->namespaces;
+    oldInst = ctxt->inst;
+
+    ctxt->xpathCtxt->node = ctxt->node;
+    ctxt->xpathCtxt->namespaces = nsList;
+    ctxt->xpathCtxt->nsNr = nsNr;
+
+    res = xmlXPathCompiledEval(comp, ctxt->xpathCtxt);
+
+    if (res != NULL) {
+       ret = xmlXPathEvalPredicate(ctxt->xpathCtxt, res);
+       xmlXPathFreeObject(res);
+#ifdef WITH_XSLT_DEBUG_TEMPLATES
+       XSLT_TRACE(ctxt,XSLT_TRACE_TEMPLATES,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltEvalXPathPredicate: returns %d\n", ret));
+#endif
+    } else {
+#ifdef WITH_XSLT_DEBUG_TEMPLATES
+       XSLT_TRACE(ctxt,XSLT_TRACE_TEMPLATES,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltEvalXPathPredicate: failed\n"));
+#endif
+       ctxt->state = XSLT_STATE_STOPPED;
+       ret = 0;
+    }
+    ctxt->xpathCtxt->nsNr = oldNsNr;
+
+    ctxt->xpathCtxt->namespaces = oldNamespaces;
+    ctxt->inst = oldInst;
+    ctxt->xpathCtxt->contextSize = oldContextSize;
+    ctxt->xpathCtxt->proximityPosition = oldProximityPosition;
+
+    return(ret);
+}
+
+/**
+ * xsltEvalXPathStringNs:
+ * @ctxt:  the XSLT transformation context
+ * @comp:  the compiled XPath expression
+ * @nsNr:  the number of namespaces in the list
+ * @nsList:  the list of in-scope namespaces to use
+ *
+ * Process the expression using XPath, allowing to pass a namespace mapping
+ * context and get a string
+ *
+ * Returns the computed string value or NULL, must be deallocated by the
+ *    caller.
+ */
+xmlChar *
+xsltEvalXPathStringNs(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp,
+                     int nsNr, xmlNsPtr *nsList) {
+    xmlChar *ret = NULL;
+    xmlXPathObjectPtr res;
+    xmlNodePtr oldInst;
+    xmlNodePtr oldNode;
+    int        oldPos, oldSize;
+    int oldNsNr;
+    xmlNsPtr *oldNamespaces;
+
+    oldInst = ctxt->inst;
+    oldNode = ctxt->node;
+    oldPos = ctxt->xpathCtxt->proximityPosition;
+    oldSize = ctxt->xpathCtxt->contextSize;
+    oldNsNr = ctxt->xpathCtxt->nsNr;
+    oldNamespaces = ctxt->xpathCtxt->namespaces;
+
+    ctxt->xpathCtxt->node = ctxt->node;
+    /* TODO: do we need to propagate the namespaces here ? */
+    ctxt->xpathCtxt->namespaces = nsList;
+    ctxt->xpathCtxt->nsNr = nsNr;
+    res = xmlXPathCompiledEval(comp, ctxt->xpathCtxt);
+    if (res != NULL) {
+       if (res->type != XPATH_STRING)
+           res = xmlXPathConvertString(res);
+       if (res->type == XPATH_STRING) {
+            ret = res->stringval;
+           res->stringval = NULL;
+       } else {
+           xsltTransformError(ctxt, NULL, NULL,
+                "xpath : string() function didn't return a String\n");
+       }
+       xmlXPathFreeObject(res);
+    } else {
+       ctxt->state = XSLT_STATE_STOPPED;
+    }
+#ifdef WITH_XSLT_DEBUG_TEMPLATES
+    XSLT_TRACE(ctxt,XSLT_TRACE_TEMPLATES,xsltGenericDebug(xsltGenericDebugContext,
+        "xsltEvalXPathString: returns %s\n", ret));
+#endif
+    ctxt->inst = oldInst;
+    ctxt->node = oldNode;
+    ctxt->xpathCtxt->contextSize = oldSize;
+    ctxt->xpathCtxt->proximityPosition = oldPos;
+    ctxt->xpathCtxt->nsNr = oldNsNr;
+    ctxt->xpathCtxt->namespaces = oldNamespaces;
+    return(ret);
+}
+
+/**
+ * xsltEvalXPathString:
+ * @ctxt:  the XSLT transformation context
+ * @comp:  the compiled XPath expression
+ *
+ * Process the expression using XPath and get a string
+ *
+ * Returns the computed string value or NULL, must be deallocated by the
+ *    caller.
+ */
+xmlChar *
+xsltEvalXPathString(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp) {
+    return(xsltEvalXPathStringNs(ctxt, comp, 0, NULL));
+}
+
+/**
+ * xsltEvalTemplateString:
+ * @ctxt:  the XSLT transformation context
+ * @contextNode:  the current node in the source tree
+ * @inst:  the XSLT instruction (xsl:comment, xsl:processing-instruction)
+ *
+ * Processes the sequence constructor of the given instruction on
+ * @contextNode and converts the resulting tree to a string.
+ * This is needed by e.g. xsl:comment and xsl:processing-instruction.
+ *
+ * Returns the computed string value or NULL; it's up to the caller to
+ *         free the result.
+ */
+xmlChar *
+xsltEvalTemplateString(xsltTransformContextPtr ctxt,
+                      xmlNodePtr contextNode,
+                      xmlNodePtr inst)
+{
+    xmlNodePtr oldInsert, insert = NULL;
+    xmlChar *ret;
+
+    if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL))
+       return(NULL);
+
+    if (inst->children == NULL)
+       return(NULL);
+
+    /*
+    * This creates a temporary element-node to add the resulting
+    * text content to.
+    * OPTIMIZE TODO: Keep such an element-node in the transformation
+    *  context to avoid creating it every time.
+    */
+    insert = xmlNewDocNode(ctxt->output, NULL,
+                          (const xmlChar *)"fake", NULL);
+    if (insert == NULL) {
+       xsltTransformError(ctxt, NULL, contextNode,
+               "Failed to create temporary node\n");
+       return(NULL);
+    }
+    oldInsert = ctxt->insert;
+    ctxt->insert = insert;
+    /*
+    * OPTIMIZE TODO: if inst->children consists only of text-nodes.
+    */
+    xsltApplyOneTemplate(ctxt, contextNode, inst->children, NULL, NULL);
+
+    ctxt->insert = oldInsert;
+
+    ret = xmlNodeGetContent(insert);
+    if (insert != NULL)
+       xmlFreeNode(insert);
+    return(ret);
+}
+
+/**
+ * xsltAttrTemplateValueProcessNode:
+ * @ctxt:  the XSLT transformation context
+ * @str:  the attribute template node value
+ * @inst:  the instruction (or LRE) in the stylesheet holding the
+ *         attribute with an AVT
+ *
+ * Process the given string, allowing to pass a namespace mapping
+ * context and return the new string value.
+ *
+ * Called by:
+ *  - xsltAttrTemplateValueProcess() (templates.c)
+ *  - xsltEvalAttrValueTemplate() (templates.c)
+ *
+ * QUESTION: Why is this function public? It is not used outside
+ *  of templates.c.
+ *
+ * Returns the computed string value or NULL, must be deallocated by the
+ *    caller.
+ */
+xmlChar *
+xsltAttrTemplateValueProcessNode(xsltTransformContextPtr ctxt,
+         const xmlChar *str, xmlNodePtr inst)
+{
+    xmlChar *ret = NULL;
+    const xmlChar *cur;
+    xmlChar *expr, *val;
+    xmlNsPtr *nsList = NULL;
+    int nsNr = 0;
+
+    if (str == NULL) return(NULL);
+    if (*str == 0)
+       return(xmlStrndup((xmlChar *)"", 0));
+
+    cur = str;
+    while (*cur != 0) {
+       if (*cur == '{') {
+           if (*(cur+1) == '{') {      /* escaped '{' */
+               cur++;
+               ret = xmlStrncat(ret, str, cur - str);
+               cur++;
+               str = cur;
+               continue;
+           }
+           ret = xmlStrncat(ret, str, cur - str);
+           str = cur;
+           cur++;
+           while ((*cur != 0) && (*cur != '}')) cur++;
+           if (*cur == 0) {
+               xsltTransformError(ctxt, NULL, inst,
+                       "xsltAttrTemplateValueProcessNode: unmatched '{'\n");
+               ret = xmlStrncat(ret, str, cur - str);
+               return(ret);
+           }
+           str++;
+           expr = xmlStrndup(str, cur - str);
+           if (expr == NULL)
+               return(ret);
+           else if (*expr == '{') {
+               ret = xmlStrcat(ret, expr);
+               xmlFree(expr);
+           } else {
+               xmlXPathCompExprPtr comp;
+               /*
+                * TODO: keep precompiled form around
+                */
+               if ((nsList == NULL) && (inst != NULL)) {
+                   int i = 0;
+
+                   nsList = xmlGetNsList(inst->doc, inst);
+                   if (nsList != NULL) {
+                       while (nsList[i] != NULL)
+                           i++;
+                       nsNr = i;
+                   }
+               }
+               comp = xmlXPathCompile(expr);
+                val = xsltEvalXPathStringNs(ctxt, comp, nsNr, nsList);
+               xmlXPathFreeCompExpr(comp);
+               xmlFree(expr);
+               if (val != NULL) {
+                   ret = xmlStrcat(ret, val);
+                   xmlFree(val);
+               }
+           }
+           cur++;
+           str = cur;
+       } else if (*cur == '}') {
+           cur++;
+           if (*cur == '}') {  /* escaped '}' */
+               ret = xmlStrncat(ret, str, cur - str);
+               cur++;
+               str = cur;
+               continue;
+           } else {
+               xsltTransformError(ctxt, NULL, inst,
+                    "xsltAttrTemplateValueProcessNode: unmatched '}'\n");
+           }
+       } else
+           cur++;
+    }
+    if (cur != str) {
+       ret = xmlStrncat(ret, str, cur - str);
+    }
+
+    if (nsList != NULL)
+       xmlFree(nsList);
+
+    return(ret);
+}
+
+/**
+ * xsltAttrTemplateValueProcess:
+ * @ctxt:  the XSLT transformation context
+ * @str:  the attribute template node value
+ *
+ * Process the given node and return the new string value.
+ *
+ * Returns the computed string value or NULL, must be deallocated by the
+ *    caller.
+ */
+xmlChar *
+xsltAttrTemplateValueProcess(xsltTransformContextPtr ctxt, const xmlChar *str) {
+    return(xsltAttrTemplateValueProcessNode(ctxt, str, NULL));
+}
+
+/**
+ * xsltEvalAttrValueTemplate:
+ * @ctxt:  the XSLT transformation context
+ * @inst:  the instruction (or LRE) in the stylesheet holding the
+ *         attribute with an AVT
+ * @name:  the attribute QName
+ * @ns:  the attribute namespace URI
+ *
+ * Evaluate a attribute value template, i.e. the attribute value can
+ * contain expressions contained in curly braces ({}) and those are
+ * substituted by they computed value.
+ *
+ * Returns the computed string value or NULL, must be deallocated by the
+ *    caller.
+ */
+xmlChar *
+xsltEvalAttrValueTemplate(xsltTransformContextPtr ctxt, xmlNodePtr inst,
+                         const xmlChar *name, const xmlChar *ns)
+{
+    xmlChar *ret;
+    xmlChar *expr;
+
+    if ((ctxt == NULL) || (inst == NULL) || (name == NULL))
+       return(NULL);
+
+    expr = xsltGetNsProp(inst, name, ns);
+    if (expr == NULL)
+       return(NULL);
+
+    /*
+     * TODO: though now {} is detected ahead, it would still be good to
+     *       optimize both functions to keep the splitted value if the
+     *       attribute content and the XPath precompiled expressions around
+     */
+
+    ret = xsltAttrTemplateValueProcessNode(ctxt, expr, inst);
+#ifdef WITH_XSLT_DEBUG_TEMPLATES
+    XSLT_TRACE(ctxt,XSLT_TRACE_TEMPLATES,xsltGenericDebug(xsltGenericDebugContext,
+        "xsltEvalAttrValueTemplate: %s returns %s\n", expr, ret));
+#endif
+    if (expr != NULL)
+       xmlFree(expr);
+    return(ret);
+}
+
+/**
+ * xsltEvalStaticAttrValueTemplate:
+ * @style:  the XSLT stylesheet
+ * @inst:  the instruction (or LRE) in the stylesheet holding the
+ *         attribute with an AVT
+ * @name:  the attribute Name
+ * @ns:  the attribute namespace URI
+ * @found:  indicator whether the attribute is present
+ *
+ * Check if an attribute value template has a static value, i.e. the
+ * attribute value does not contain expressions contained in curly braces ({})
+ *
+ * Returns the static string value or NULL, must be deallocated by the
+ *    caller.
+ */
+const xmlChar *
+xsltEvalStaticAttrValueTemplate(xsltStylesheetPtr style, xmlNodePtr inst,
+                       const xmlChar *name, const xmlChar *ns, int *found) {
+    const xmlChar *ret;
+    xmlChar *expr;
+
+    if ((style == NULL) || (inst == NULL) || (name == NULL))
+       return(NULL);
+
+    expr = xsltGetNsProp(inst, name, ns);
+    if (expr == NULL) {
+       *found = 0;
+       return(NULL);
+    }
+    *found = 1;
+
+    ret = xmlStrchr(expr, '{');
+    if (ret != NULL) {
+       xmlFree(expr);
+       return(NULL);
+    }
+    ret = xmlDictLookup(style->dict, expr, -1);
+    xmlFree(expr);
+    return(ret);
+}
+
+/**
+ * xsltAttrTemplateProcess:
+ * @ctxt:  the XSLT transformation context
+ * @target:  the element where the attribute will be grafted
+ * @attr:  the attribute node of a literal result element
+ *
+ * Process one attribute of a Literal Result Element (in the stylesheet).
+ * Evaluates Attribute Value Templates and copies the attribute over to
+ * the result element.
+ * This does *not* process attribute sets (xsl:use-attribute-set).
+ * 
+ *
+ * Returns the generated attribute node.
+ */
+xmlAttrPtr
+xsltAttrTemplateProcess(xsltTransformContextPtr ctxt, xmlNodePtr target,
+                       xmlAttrPtr attr)
+{
+    const xmlChar *value;
+    xmlAttrPtr ret;
+
+    if ((ctxt == NULL) || (attr == NULL) || (target == NULL))
+       return(NULL);
+    
+    if (attr->type != XML_ATTRIBUTE_NODE)
+       return(NULL);
+
+    /*
+    * Skip all XSLT attributes.
+    */
+#ifdef XSLT_REFACTORED    
+    if (attr->psvi == xsltXSLTAttrMarker)
+       return(NULL);
+#else
+    if ((attr->ns != NULL) && xmlStrEqual(attr->ns->href, XSLT_NAMESPACE))
+       return(NULL);
+#endif
+    /*
+    * Get the value.
+    */
+    if (attr->children != NULL) {
+       if ((attr->children->type != XML_TEXT_NODE) ||
+           (attr->children->next != NULL))
+       {
+           xsltTransformError(ctxt, NULL, attr->parent,
+               "Internal error: The children of an attribute node of a "
+               "literal result element are not in the expected form.\n");
+           return(NULL);
+       }
+       value = attr->children->content;
+       if (value == NULL)
+           value = xmlDictLookup(ctxt->dict, BAD_CAST "", 0);
+    } else
+       value = xmlDictLookup(ctxt->dict, BAD_CAST "", 0);
+    /*
+    * Overwrite duplicates.
+    */
+    ret = target->properties;
+    while (ret != NULL) {
+        if (((attr->ns != NULL) == (ret->ns != NULL)) &&
+           xmlStrEqual(ret->name, attr->name) &&
+           ((attr->ns == NULL) || xmlStrEqual(ret->ns->href, attr->ns->href)))
+       {
+           break;
+       }
+        ret = ret->next;
+    }
+    if (ret != NULL) { 
+        /* free the existing value */
+       xmlFreeNodeList(ret->children);
+       ret->children = ret->last = NULL;
+       /*
+       * Adjust ns-prefix if needed.
+       */
+       if ((ret->ns != NULL) &&
+           (! xmlStrEqual(ret->ns->prefix, attr->ns->prefix)))
+       {
+           ret->ns = xsltGetNamespace(ctxt, attr->parent, attr->ns, target);
+       }
+    } else {
+        /* create a new attribute */
+       if (attr->ns != NULL)
+           ret = xmlNewNsProp(target,
+               xsltGetNamespace(ctxt, attr->parent, attr->ns, target),
+                   attr->name, NULL);
+       else
+           ret = xmlNewNsProp(target, NULL, attr->name, NULL); 
+    }
+    /*
+    * Set the value.
+    */
+    if (ret != NULL) {
+        xmlNodePtr text;
+
+        text = xmlNewText(NULL);
+       if (text != NULL) {
+           ret->last = ret->children = text;
+           text->parent = (xmlNodePtr) ret;
+           text->doc = ret->doc;
+
+           if (attr->psvi != NULL) {
+               /*
+               * Evaluate the Attribute Value Template.
+               */
+               xmlChar *val;
+               val = xsltEvalAVT(ctxt, attr->psvi, attr->parent);
+               if (val == NULL) {
+                   /*
+                   * TODO: Damn, we need an easy mechanism to report
+                   * qualified names!
+                   */
+                   if (attr->ns) {
+                       xsltTransformError(ctxt, NULL, attr->parent,
+                           "Internal error: Failed to evaluate the AVT "
+                           "of attribute '{%s}%s'.\n",
+                           attr->ns->href, attr->name);
+                   } else {
+                       xsltTransformError(ctxt, NULL, attr->parent,
+                           "Internal error: Failed to evaluate the AVT "
+                           "of attribute '%s'.\n",
+                           attr->name);
+                   }
+                   text->content = xmlStrdup(BAD_CAST "");
+               } else {
+                   text->content = val;
+               }
+           } else if ((ctxt->internalized) && (target != NULL) &&
+                      (target->doc != NULL) &&
+                      (target->doc->dict == ctxt->dict)) {
+               text->content = (xmlChar *) value;
+           } else {
+               text->content = xmlStrdup(value);
+           }
+       }
+    } else {
+       if (attr->ns) {
+           xsltTransformError(ctxt, NULL, attr->parent,
+               "Internal error: Failed to create attribute '{%s}%s'.\n",
+               attr->ns->href, attr->name);
+       } else {
+           xsltTransformError(ctxt, NULL, attr->parent,
+               "Internal error: Failed to create attribute '%s'.\n",
+               attr->name);
+       }
+    }
+    return(ret);
+}
+
+
+/**
+ * xsltAttrListTemplateProcess:
+ * @ctxt:  the XSLT transformation context
+ * @target:  the element where the attributes will be grafted
+ * @attrs:  the first attribute
+ *
+ * Processes all attributes of a Literal Result Element.
+ * Attribute references are applied via xsl:use-attribute-set
+ * attributes.
+ * Copies all non XSLT-attributes over to the @target element
+ * and evaluates Attribute Value Templates.
+ *
+ * Called by xsltApplySequenceConstructor() (transform.c).
+ *
+ * Returns a new list of attribute nodes, or NULL in case of error.
+ *         (Don't assign the result to @target->properties; if
+ *         the result is NULL, you'll get memory leaks, since the
+ *         attributes will be disattached.)
+ */
+xmlAttrPtr
+xsltAttrListTemplateProcess(xsltTransformContextPtr ctxt, 
+                           xmlNodePtr target, xmlAttrPtr attrs)
+{
+    xmlAttrPtr attr, copy, last;
+    xmlNodePtr oldInsert, text;
+    xmlNsPtr origNs = NULL, copyNs = NULL;
+    const xmlChar *value;
+    xmlChar *valueAVT;
+
+    if ((ctxt == NULL) || (target == NULL) || (attrs == NULL))
+       return(NULL);
+
+    oldInsert = ctxt->insert;
+    ctxt->insert = target;        
+
+    /*
+    * Instantiate LRE-attributes.
+    */
+    if (target->properties) {
+       last = target->properties;
+       while (last->next != NULL)
+           last = last->next;
+    } else {
+       last = NULL;
+    }    
+    attr = attrs;
+    do {
+       /*
+       * Skip XSLT attributes.
+       */
+#ifdef XSLT_REFACTORED
+       if (attr->psvi == xsltXSLTAttrMarker) {
+           goto next_attribute;
+       }
+#else
+       if ((attr->ns != NULL) &&
+           xmlStrEqual(attr->ns->href, XSLT_NAMESPACE))
+       {
+           goto next_attribute;
+       }
+#endif
+       /*
+       * Get the value.
+       */
+       if (attr->children != NULL) {
+           if ((attr->children->type != XML_TEXT_NODE) ||
+               (attr->children->next != NULL))
+           {
+               xsltTransformError(ctxt, NULL, attr->parent,
+                   "Internal error: The children of an attribute node of a "
+                   "literal result element are not in the expected form.\n");
+               goto error;
+           }
+           value = attr->children->content;
+           if (value == NULL)
+               value = xmlDictLookup(ctxt->dict, BAD_CAST "", 0);
+       } else
+           value = xmlDictLookup(ctxt->dict, BAD_CAST "", 0);
+
+       /*
+       * Create a new attribute.
+       */
+       copy = xmlNewDocProp(target->doc, attr->name, NULL);
+       if (copy == NULL) {
+           if (attr->ns) {
+               xsltTransformError(ctxt, NULL, attr->parent,
+                   "Internal error: Failed to create attribute '{%s}%s'.\n",
+                   attr->ns->href, attr->name);
+           } else {
+               xsltTransformError(ctxt, NULL, attr->parent,
+                   "Internal error: Failed to create attribute '%s'.\n",
+                   attr->name);
+           }
+           goto error;
+       }
+       /*
+       * Attach it to the target element.
+       */
+       copy->parent = target;
+       if (last == NULL) {
+           target->properties = copy;
+           last = copy;
+       } else {
+           last->next = copy;
+           copy->prev = last;
+           last = copy;
+       }
+       /*
+       * Set the namespace. Avoid lookups of same namespaces.
+       */
+       if (attr->ns != origNs) {
+           origNs = attr->ns;
+           if (attr->ns != NULL) {
+#ifdef XSLT_REFACTORED
+               copyNs = xsltGetSpecialNamespace(ctxt, attr->parent,
+                   attr->ns->href, attr->ns->prefix, target);
+#else
+               copyNs = xsltGetNamespace(ctxt, attr->parent,
+                   attr->ns, target);
+#endif
+               if (copyNs == NULL)
+                   goto error;
+           } else
+               copyNs = NULL;
+       }
+       copy->ns = copyNs;
+       
+       /*
+       * Set the value.
+       */          
+       text = xmlNewText(NULL);
+       if (text != NULL) {
+           copy->last = copy->children = text;
+           text->parent = (xmlNodePtr) copy;
+           text->doc = copy->doc;
+           
+           if (attr->psvi != NULL) {
+               /*
+               * Evaluate the Attribute Value Template.
+               */              
+               valueAVT = xsltEvalAVT(ctxt, attr->psvi, attr->parent);
+               if (valueAVT == NULL) {
+                   /*
+                   * TODO: Damn, we need an easy mechanism to report
+                   * qualified names!
+                   */
+                   if (attr->ns) {
+                       xsltTransformError(ctxt, NULL, attr->parent,
+                           "Internal error: Failed to evaluate the AVT "
+                           "of attribute '{%s}%s'.\n",
+                           attr->ns->href, attr->name);                            
+                   } else {
+                       xsltTransformError(ctxt, NULL, attr->parent,
+                           "Internal error: Failed to evaluate the AVT "
+                           "of attribute '%s'.\n",
+                           attr->name);
+                   }
+                   text->content = xmlStrdup(BAD_CAST "");
+                   goto error;
+               } else {
+                   text->content = valueAVT;
+               }
+           } else if ((ctxt->internalized) &&
+               (target->doc != NULL) &&
+               (target->doc->dict == ctxt->dict))
+           {
+               text->content = (xmlChar *) value;
+           } else {
+               text->content = xmlStrdup(value);
+           }
+       }
+
+next_attribute:
+       attr = attr->next;
+    } while (attr != NULL);
+
+    /*
+    * Apply attribute-sets.
+    * The creation of such attributes will not overwrite any existing
+    * attribute.
+    */
+    attr = attrs;
+    do {
+#ifdef XSLT_REFACTORED
+       if ((attr->psvi == xsltXSLTAttrMarker) &&
+           xmlStrEqual(attr->name, (const xmlChar *)"use-attribute-sets"))
+       {
+           xsltApplyAttributeSet(ctxt, ctxt->node, (xmlNodePtr) attr, NULL);
+       }
+#else
+       if ((attr->ns != NULL) &&
+           xmlStrEqual(attr->name, (const xmlChar *)"use-attribute-sets") &&
+           xmlStrEqual(attr->ns->href, XSLT_NAMESPACE))
+       {
+           xsltApplyAttributeSet(ctxt, ctxt->node, (xmlNodePtr) attr, NULL);
+       }
+#endif
+       attr = attr->next;
+    } while (attr != NULL);
+
+    ctxt->insert = oldInsert;
+    return(target->properties);
+
+error:
+    ctxt->insert = oldInsert;
+    return(NULL);
+}
+
+
+/**
+ * xsltTemplateProcess:
+ * @ctxt:  the XSLT transformation context
+ * @node:  the attribute template node
+ *
+ * Obsolete. Don't use it.
+ *
+ * Returns NULL.
+ */
+xmlNodePtr *
+xsltTemplateProcess(xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED, xmlNodePtr node) {
+    if (node == NULL)
+       return(NULL);
+    
+    return(0);
+}
+
+
diff --git a/reactos/dll/3rdparty/libxslt/templates.h b/reactos/dll/3rdparty/libxslt/templates.h
new file mode 100644 (file)
index 0000000..18adfdb
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Summary: interface for the template processing
+ * Description: This set of routine encapsulates XPath calls
+ *              and Attribute Value Templates evaluation.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_TEMPLATES_H__
+#define __XML_XSLT_TEMPLATES_H__
+
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+#include "xsltexports.h"
+#include "xsltInternals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+XSLTPUBFUN int XSLTCALL                
+               xsltEvalXPathPredicate          (xsltTransformContextPtr ctxt,
+                                                xmlXPathCompExprPtr comp,
+                                                xmlNsPtr *nsList,
+                                                int nsNr);
+XSLTPUBFUN xmlChar * XSLTCALL  
+               xsltEvalTemplateString          (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr contextNode,
+                                                xmlNodePtr inst);
+XSLTPUBFUN xmlChar * XSLTCALL  
+               xsltEvalAttrValueTemplate       (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr node,
+                                                const xmlChar *name,
+                                                const xmlChar *ns);
+XSLTPUBFUN const xmlChar * XSLTCALL    
+               xsltEvalStaticAttrValueTemplate (xsltStylesheetPtr style,
+                                                xmlNodePtr node,
+                                                const xmlChar *name,
+                                                const xmlChar *ns,
+                                                int *found);
+
+/* TODO: this is obviously broken ... the namespaces should be passed too ! */
+XSLTPUBFUN xmlChar * XSLTCALL  
+               xsltEvalXPathString             (xsltTransformContextPtr ctxt,
+                                                xmlXPathCompExprPtr comp);
+XSLTPUBFUN xmlChar * XSLTCALL  
+               xsltEvalXPathStringNs           (xsltTransformContextPtr ctxt,
+                                                xmlXPathCompExprPtr comp,
+                                                int nsNr,
+                                                xmlNsPtr *nsList);
+
+XSLTPUBFUN xmlNodePtr * XSLTCALL       
+               xsltTemplateProcess             (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr node);
+XSLTPUBFUN xmlAttrPtr XSLTCALL 
+               xsltAttrListTemplateProcess     (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr target,
+                                                xmlAttrPtr cur);
+XSLTPUBFUN xmlAttrPtr XSLTCALL 
+               xsltAttrTemplateProcess         (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr target,
+                                                xmlAttrPtr attr);
+XSLTPUBFUN xmlChar * XSLTCALL  
+               xsltAttrTemplateValueProcess    (xsltTransformContextPtr ctxt,
+                                                const xmlChar* attr);
+XSLTPUBFUN xmlChar * XSLTCALL  
+               xsltAttrTemplateValueProcessNode(xsltTransformContextPtr ctxt,
+                                                const xmlChar* str,
+                                                xmlNodePtr node);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_TEMPLATES_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/transform.c b/reactos/dll/3rdparty/libxslt/transform.c
new file mode 100644 (file)
index 0000000..da37503
--- /dev/null
@@ -0,0 +1,6457 @@
+/*
+ * transform.c: Implementation of the XSL Transformation 1.0 engine
+ *              transform part, i.e. applying a Stylesheet to a document
+ *
+ * References:
+ *   http://www.w3.org/TR/1999/REC-xslt-19991116
+ *
+ *   Michael Kay "XSLT Programmer's Reference" pp 637-643
+ *   Writing Multiple Output Files
+ *
+ *   XSLT-1.1 Working Draft
+ *   http://www.w3.org/TR/xslt11#multiple-output
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/valid.h>
+#include <libxml/hash.h>
+#include <libxml/encoding.h>
+#include <libxml/xmlerror.h>
+#include <libxml/xpath.h>
+#include <libxml/parserInternals.h>
+#include <libxml/xpathInternals.h>
+#include <libxml/HTMLtree.h>
+#include <libxml/debugXML.h>
+#include <libxml/uri.h>
+#include "xslt.h"
+#include "xsltInternals.h"
+#include "xsltutils.h"
+#include "pattern.h"
+#include "transform.h"
+#include "variables.h"
+#include "numbersInternals.h"
+#include "namespaces.h"
+#include "attributes.h"
+#include "templates.h"
+#include "imports.h"
+#include "keys.h"
+#include "documents.h"
+#include "extensions.h"
+#include "extra.h"
+#include "preproc.h"
+#include "security.h"
+
+#ifdef WITH_XSLT_DEBUG
+#define WITH_XSLT_DEBUG_EXTRA
+#define WITH_XSLT_DEBUG_PROCESS
+#endif
+
+#define XSLT_GENERATE_HTML_DOCTYPE
+#ifdef XSLT_GENERATE_HTML_DOCTYPE
+static int xsltGetHTMLIDs(const xmlChar *version, const xmlChar **publicID,
+                         const xmlChar **systemID);
+#endif
+
+int xsltMaxDepth = 3000;
+
+/*
+ * Useful macros
+ */
+
+#ifndef FALSE
+# define FALSE (0 == 1)
+# define TRUE (!FALSE)
+#endif
+
+#define IS_BLANK_NODE(n)                                               \
+    (((n)->type == XML_TEXT_NODE) && (xsltIsBlank((n)->content)))
+
+
+/*
+* Forward declarations
+*/
+
+static xmlNsPtr
+xsltCopyNamespaceListInternal(xmlNodePtr node, xmlNsPtr cur);
+
+static xmlNodePtr
+xsltCopyTreeInternal(xsltTransformContextPtr ctxt,
+                    xmlNodePtr invocNode,
+                    xmlNodePtr node,
+                    xmlNodePtr insert, int isLRE, int topElemVisited);
+
+static void
+xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
+                            xmlNodePtr contextNode, xmlNodePtr list,
+                            xsltTemplatePtr templ);
+
+static void
+xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
+                     xmlNodePtr contextNode,
+                     xmlNodePtr list,
+                     xsltTemplatePtr templ,
+                     xsltStackElemPtr withParams);
+
+/**
+ * templPush:
+ * @ctxt: the transformation context
+ * @value:  the template to push on the stack
+ *
+ * Push a template on the stack
+ *
+ * Returns the new index in the stack or 0 in case of error
+ */
+static int
+templPush(xsltTransformContextPtr ctxt, xsltTemplatePtr value)
+{
+    if (ctxt->templMax == 0) {
+        ctxt->templMax = 4;
+        ctxt->templTab =
+            (xsltTemplatePtr *) xmlMalloc(ctxt->templMax *
+                                          sizeof(ctxt->templTab[0]));
+        if (ctxt->templTab == NULL) {
+            xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
+            return (0);
+        }
+    }
+    if (ctxt->templNr >= ctxt->templMax) {
+        ctxt->templMax *= 2;
+        ctxt->templTab =
+            (xsltTemplatePtr *) xmlRealloc(ctxt->templTab,
+                                           ctxt->templMax *
+                                           sizeof(ctxt->templTab[0]));
+        if (ctxt->templTab == NULL) {
+            xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
+            return (0);
+        }
+    }
+    ctxt->templTab[ctxt->templNr] = value;
+    ctxt->templ = value;
+    return (ctxt->templNr++);
+}
+/**
+ * templPop:
+ * @ctxt: the transformation context
+ *
+ * Pop a template value from the stack
+ *
+ * Returns the stored template value
+ */
+static xsltTemplatePtr
+templPop(xsltTransformContextPtr ctxt)
+{
+    xsltTemplatePtr ret;
+
+    if (ctxt->templNr <= 0)
+        return (0);
+    ctxt->templNr--;
+    if (ctxt->templNr > 0)
+        ctxt->templ = ctxt->templTab[ctxt->templNr - 1];
+    else
+        ctxt->templ = (xsltTemplatePtr) 0;
+    ret = ctxt->templTab[ctxt->templNr];
+    ctxt->templTab[ctxt->templNr] = 0;
+    return (ret);
+}
+
+/**
+ * xsltLocalVariablePop:
+ * @ctxt: the transformation context
+ * @limitNr: number of variables which should remain
+ * @level: the depth in the xsl:template's tree
+ *
+ * Pops all variable values at the given @depth from the stack.
+ *
+ * Returns the stored variable value
+ * **NOTE:**
+ * This is an internal routine and should not be called by users!
+ */
+void
+xsltLocalVariablePop(xsltTransformContextPtr ctxt, int limitNr, int level)
+{
+    xsltStackElemPtr variable;
+
+    if (ctxt->varsNr <= 0)
+        return;
+
+    do {
+       if (ctxt->varsNr <= limitNr)
+           break;
+       variable = ctxt->varsTab[ctxt->varsNr - 1];
+       if (variable->level <= level)
+           break;      
+       if (variable->level >= 0)
+           xsltFreeStackElemList(variable);
+       ctxt->varsNr--;
+    } while (ctxt->varsNr != 0);
+    if (ctxt->varsNr > 0)
+        ctxt->vars = ctxt->varsTab[ctxt->varsNr - 1];
+    else
+        ctxt->vars = NULL;
+}
+
+/**
+ * xsltTemplateParamsCleanup:
+ *
+ * Removes xsl:param and xsl:with-param items from the
+ * variable-stack. Only xsl:with-param items are not freed. 
+ */
+static void
+xsltTemplateParamsCleanup(xsltTransformContextPtr ctxt)
+{
+    xsltStackElemPtr param;    
+
+    for (; ctxt->varsNr > ctxt->varsBase; ctxt->varsNr--) {
+       param = ctxt->varsTab[ctxt->varsNr -1];
+       /*
+       * Free xsl:param items.
+       * xsl:with-param items will have a level of -1 or -2.
+       */
+       if (param->level >= 0) {            
+           xsltFreeStackElemList(param);
+       }           
+    }    
+    if (ctxt->varsNr > 0)
+        ctxt->vars = ctxt->varsTab[ctxt->varsNr - 1];
+    else
+        ctxt->vars = NULL;
+}
+
+/**
+ * profPush:
+ * @ctxt: the transformation context
+ * @value:  the profiling value to push on the stack
+ *
+ * Push a profiling value on the stack
+ *
+ * Returns the new index in the stack or 0 in case of error
+ */
+static int
+profPush(xsltTransformContextPtr ctxt, long value)
+{
+    if (ctxt->profMax == 0) {
+        ctxt->profMax = 4;
+        ctxt->profTab =
+            (long *) xmlMalloc(ctxt->profMax * sizeof(ctxt->profTab[0]));
+        if (ctxt->profTab == NULL) {
+            xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
+            return (0);
+        }
+    }
+    if (ctxt->profNr >= ctxt->profMax) {
+        ctxt->profMax *= 2;
+        ctxt->profTab =
+            (long *) xmlRealloc(ctxt->profTab,
+                                ctxt->profMax * sizeof(ctxt->profTab[0]));
+        if (ctxt->profTab == NULL) {
+            xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
+            return (0);
+        }
+    }
+    ctxt->profTab[ctxt->profNr] = value;
+    ctxt->prof = value;
+    return (ctxt->profNr++);
+}
+/**
+ * profPop:
+ * @ctxt: the transformation context
+ *
+ * Pop a profiling value from the stack
+ *
+ * Returns the stored profiling value
+ */
+static long
+profPop(xsltTransformContextPtr ctxt)
+{
+    long ret;
+
+    if (ctxt->profNr <= 0)
+        return (0);
+    ctxt->profNr--;
+    if (ctxt->profNr > 0)
+        ctxt->prof = ctxt->profTab[ctxt->profNr - 1];
+    else
+        ctxt->prof = (long) 0;
+    ret = ctxt->profTab[ctxt->profNr];
+    ctxt->profTab[ctxt->profNr] = 0;
+    return (ret);
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     XInclude default settings                       *
+ *                                                                     *
+ ************************************************************************/
+
+static int xsltDoXIncludeDefault = 0;
+
+/**
+ * xsltSetXIncludeDefault:
+ * @xinclude: whether to do XInclude processing
+ *
+ * Set whether XInclude should be processed on document being loaded by default
+ */
+void
+xsltSetXIncludeDefault(int xinclude) {
+    xsltDoXIncludeDefault = (xinclude != 0);
+}
+
+/**
+ * xsltGetXIncludeDefault:
+ *
+ * Provides the default state for XInclude processing
+ *
+ * Returns 0 if there is no processing 1 otherwise
+ */
+int
+xsltGetXIncludeDefault(void) {
+    return(xsltDoXIncludeDefault);
+}
+
+unsigned long xsltDefaultTrace = (unsigned long) XSLT_TRACE_ALL;
+
+/**
+ * xsltDebugSetDefaultTrace:
+ * @val: tracing level mask
+ *
+ * Set the default debug tracing level mask
+ */
+void xsltDebugSetDefaultTrace(xsltDebugTraceCodes val) {
+       xsltDefaultTrace = val;
+}
+
+/**
+ * xsltDebugGetDefaultTrace:
+ *
+ * Get the current default debug tracing level mask
+ *
+ * Returns the current default debug tracing level mask
+ */
+xsltDebugTraceCodes xsltDebugGetDefaultTrace() {
+       return xsltDefaultTrace;
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     Handling of Transformation Contexts             *
+ *                                                                     *
+ ************************************************************************/
+
+static xsltTransformCachePtr
+xsltTransformCacheCreate(void)
+{
+    xsltTransformCachePtr ret;
+    
+    ret = (xsltTransformCachePtr) xmlMalloc(sizeof(xsltTransformCache));
+    if (ret == NULL) {
+       xsltTransformError(NULL, NULL, NULL,
+           "xsltTransformCacheCreate : malloc failed\n");
+       return(NULL);
+    }
+    memset(ret, 0, sizeof(xsltTransformCache));
+    return(ret);
+}
+
+static void
+xsltTransformCacheFree(xsltTransformCachePtr cache)
+{    
+    if (cache == NULL)
+       return;    
+    /*
+    * Free tree fragments.
+    */
+    if (cache->RVT) {
+       xmlDocPtr tmp, cur = cache->RVT;
+       while (cur) {
+           tmp = cur;
+           cur = (xmlDocPtr) cur->next;
+           if (tmp->_private != NULL) {
+               /*
+               * Tree the document info.
+               */
+               xsltFreeDocumentKeys((xsltDocumentPtr) tmp->_private);
+               xmlFree(tmp->_private);
+           }
+           xmlFreeDoc(tmp);
+       }
+    }
+    /*
+    * Free vars/params.
+    */
+    if (cache->stackItems) {
+       xsltStackElemPtr tmp, cur = cache->stackItems;
+       while (cur) {
+           tmp = cur;
+           cur = cur->next;
+           /*
+           * REVISIT TODO: Should be call a destruction-function
+           * instead?
+           */
+           xmlFree(tmp);
+       }
+    }
+    xmlFree(cache);
+}
+
+/**
+ * xsltNewTransformContext:
+ * @style:  a parsed XSLT stylesheet
+ * @doc:  the input document
+ *
+ * Create a new XSLT TransformContext
+ *
+ * Returns the newly allocated xsltTransformContextPtr or NULL in case of error
+ */
+xsltTransformContextPtr
+xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) {
+    xsltTransformContextPtr cur;
+    xsltDocumentPtr docu;
+    int i;
+
+    cur = (xsltTransformContextPtr) xmlMalloc(sizeof(xsltTransformContext));
+    if (cur == NULL) {
+       xsltTransformError(NULL, NULL, (xmlNodePtr)doc,
+               "xsltNewTransformContext : malloc failed\n");
+       return(NULL);
+    }
+    memset(cur, 0, sizeof(xsltTransformContext));
+
+    cur->cache = xsltTransformCacheCreate();
+    if (cur->cache == NULL)
+       goto internal_err;
+    /*
+     * setup of the dictionary must be done early as some of the
+     * processing later like key handling may need it.
+     */
+    cur->dict = xmlDictCreateSub(style->dict);
+    cur->internalized = ((style->internalized) && (cur->dict != NULL));
+#ifdef WITH_XSLT_DEBUG
+    xsltGenericDebug(xsltGenericDebugContext,
+            "Creating sub-dictionary from stylesheet for transformation\n");
+#endif
+
+    /*
+     * initialize the template stack
+     */
+    cur->templTab = (xsltTemplatePtr *)
+               xmlMalloc(10 * sizeof(xsltTemplatePtr));
+    if (cur->templTab == NULL) {
+       xsltTransformError(NULL, NULL, (xmlNodePtr) doc,
+               "xsltNewTransformContext: out of memory\n");
+       goto internal_err;
+    }
+    cur->templNr = 0;
+    cur->templMax = 5;
+    cur->templ = NULL;
+
+    /*
+     * initialize the variables stack
+     */
+    cur->varsTab = (xsltStackElemPtr *)
+               xmlMalloc(10 * sizeof(xsltStackElemPtr));
+    if (cur->varsTab == NULL) {
+        xmlGenericError(xmlGenericErrorContext,
+               "xsltNewTransformContext: out of memory\n");
+       goto internal_err;
+    }
+    cur->varsNr = 0;
+    cur->varsMax = 10;
+    cur->vars = NULL;
+    cur->varsBase = 0;
+
+    /*
+     * the profiling stack is not initialized by default
+     */
+    cur->profTab = NULL;
+    cur->profNr = 0;
+    cur->profMax = 0;
+    cur->prof = 0;
+
+    cur->style = style;
+    xmlXPathInit();
+    cur->xpathCtxt = xmlXPathNewContext(doc);
+    if (cur->xpathCtxt == NULL) {
+       xsltTransformError(NULL, NULL, (xmlNodePtr) doc,
+               "xsltNewTransformContext : xmlXPathNewContext failed\n");
+       goto internal_err;
+    }
+    /*
+    * Create an XPath cache.
+    */
+    if (xmlXPathContextSetCache(cur->xpathCtxt, 1, -1, 0) == -1)
+       goto internal_err;
+    /*
+     * Initialize the extras array
+     */
+    if (style->extrasNr != 0) {
+       cur->extrasMax = style->extrasNr + 20;
+       cur->extras = (xsltRuntimeExtraPtr) 
+           xmlMalloc(cur->extrasMax * sizeof(xsltRuntimeExtra));
+       if (cur->extras == NULL) {
+           xmlGenericError(xmlGenericErrorContext,
+                   "xsltNewTransformContext: out of memory\n");
+           goto internal_err;
+       }
+       cur->extrasNr = style->extrasNr;
+       for (i = 0;i < cur->extrasMax;i++) {
+           cur->extras[i].info = NULL;
+           cur->extras[i].deallocate = NULL;
+           cur->extras[i].val.ptr = NULL;
+       }
+    } else {
+       cur->extras = NULL;
+       cur->extrasNr = 0;
+       cur->extrasMax = 0;
+    }
+
+    XSLT_REGISTER_VARIABLE_LOOKUP(cur);
+    XSLT_REGISTER_FUNCTION_LOOKUP(cur);
+    cur->xpathCtxt->nsHash = style->nsHash;
+    /*
+     * Initialize the registered external modules
+     */
+    xsltInitCtxtExts(cur);
+    /*
+     * Setup document element ordering for later efficiencies
+     * (bug 133289)
+     */
+    if (xslDebugStatus == XSLT_DEBUG_NONE)
+        xmlXPathOrderDocElems(doc);
+    /*
+     * Must set parserOptions before calling xsltNewDocument
+     * (bug 164530)
+     */
+    cur->parserOptions = XSLT_PARSE_OPTIONS;
+    docu = xsltNewDocument(cur, doc);
+    if (docu == NULL) {
+       xsltTransformError(cur, NULL, (xmlNodePtr)doc,
+               "xsltNewTransformContext : xsltNewDocument failed\n");
+       goto internal_err;
+    }
+    docu->main = 1;
+    cur->document = docu;
+    cur->inst = NULL;
+    cur->outputFile = NULL;
+    cur->sec = xsltGetDefaultSecurityPrefs();
+    cur->debugStatus = xslDebugStatus;
+    cur->traceCode = (unsigned long*) &xsltDefaultTrace;
+    cur->xinclude = xsltGetXIncludeDefault();
+    cur->keyInitLevel = 0;
+
+    return(cur);
+
+internal_err:
+    if (cur != NULL)
+       xsltFreeTransformContext(cur);
+    return(NULL);
+}
+
+/**
+ * xsltFreeTransformContext:
+ * @ctxt:  an XSLT parser context
+ *
+ * Free up the memory allocated by @ctxt
+ */
+void
+xsltFreeTransformContext(xsltTransformContextPtr ctxt) {
+    if (ctxt == NULL)
+       return;
+
+    /*
+     * Shutdown the extension modules associated to the stylesheet
+     * used if needed.
+     */
+    xsltShutdownCtxtExts(ctxt);
+
+    if (ctxt->xpathCtxt != NULL) {
+       ctxt->xpathCtxt->nsHash = NULL;
+       xmlXPathFreeContext(ctxt->xpathCtxt);
+    }
+    if (ctxt->templTab != NULL)
+       xmlFree(ctxt->templTab);
+    if (ctxt->varsTab != NULL)
+       xmlFree(ctxt->varsTab);
+    if (ctxt->profTab != NULL)
+       xmlFree(ctxt->profTab);
+    if ((ctxt->extrasNr > 0) && (ctxt->extras != NULL)) {
+       int i;
+
+       for (i = 0;i < ctxt->extrasNr;i++) {
+           if ((ctxt->extras[i].deallocate != NULL) &&
+               (ctxt->extras[i].info != NULL))
+               ctxt->extras[i].deallocate(ctxt->extras[i].info);
+       }
+       xmlFree(ctxt->extras);
+    }
+    xsltFreeGlobalVariables(ctxt);
+    xsltFreeDocuments(ctxt);
+    xsltFreeCtxtExts(ctxt);
+    xsltFreeRVTs(ctxt);
+    xsltTransformCacheFree(ctxt->cache);
+    xmlDictFree(ctxt->dict);
+#ifdef WITH_XSLT_DEBUG
+    xsltGenericDebug(xsltGenericDebugContext,
+                     "freeing transformation dictionary\n");
+#endif
+    memset(ctxt, -1, sizeof(xsltTransformContext));
+    xmlFree(ctxt);
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     Copy of Nodes in an XSLT fashion                *
+ *                                                                     *
+ ************************************************************************/
+
+xmlNodePtr xsltCopyTree(xsltTransformContextPtr ctxt,
+                        xmlNodePtr node, xmlNodePtr insert, int literal);
+
+/**
+ * xsltAddTextString:
+ * @ctxt:  a XSLT process context
+ * @target:  the text node where the text will be attached
+ * @string:  the text string
+ * @len:  the string length in byte
+ *
+ * Extend the current text node with the new string, it handles coalescing
+ *
+ * Returns: the text node
+ */
+static xmlNodePtr
+xsltAddTextString(xsltTransformContextPtr ctxt, xmlNodePtr target,
+                 const xmlChar *string, int len) {
+    /*
+     * optimization
+     */
+    if ((len <= 0) || (string == NULL) || (target == NULL))
+        return(target);
+
+    if (ctxt->lasttext == target->content) {
+
+       if (ctxt->lasttuse + len >= ctxt->lasttsize) {
+           xmlChar *newbuf;
+           int size;
+
+           size = ctxt->lasttsize + len + 100;
+           size *= 2;
+           newbuf = (xmlChar *) xmlRealloc(target->content,size);
+           if (newbuf == NULL) {
+               xsltTransformError(ctxt, NULL, target,
+                "xsltCopyText: text allocation failed\n");
+               return(NULL);
+           }
+           ctxt->lasttsize = size;
+           ctxt->lasttext = newbuf;
+           target->content = newbuf;
+       }
+       memcpy(&(target->content[ctxt->lasttuse]), string, len);
+       ctxt->lasttuse += len;
+       target->content[ctxt->lasttuse] = 0;
+    } else {
+       xmlNodeAddContent(target, string);
+       ctxt->lasttext = target->content;
+       len = xmlStrlen(target->content);
+       ctxt->lasttsize = len;
+       ctxt->lasttuse = len;
+    }
+    return(target);
+}
+
+/**
+ * xsltCopyTextString:
+ * @ctxt:  a XSLT process context
+ * @target:  the element where the text will be attached
+ * @string:  the text string
+ * @noescape:  should disable-escaping be activated for this text node.
+ *
+ * Adds @string to a newly created or an existent text node child of
+ * @target.
+ *
+ * Returns: the text node, where the text content of @cur is copied to.
+ *          NULL in case of API or internal errors.
+ */
+xmlNodePtr
+xsltCopyTextString(xsltTransformContextPtr ctxt, xmlNodePtr target,
+                  const xmlChar *string, int noescape)
+{
+    xmlNodePtr copy;
+    int len;
+
+    if (string == NULL)
+       return(NULL);
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    XSLT_TRACE(ctxt,XSLT_TRACE_COPY_TEXT,xsltGenericDebug(xsltGenericDebugContext,
+                    "xsltCopyTextString: copy text %s\n",
+                    string));
+#endif
+
+    /*
+    * Play save and reset the merging mechanism for every new
+    * target node.
+    */
+    if ((target == NULL) || (target->children == NULL)) {
+       ctxt->lasttext = NULL;
+    }
+
+    /* handle coalescing of text nodes here */
+    len = xmlStrlen(string);
+    if ((ctxt->type == XSLT_OUTPUT_XML) &&
+       (ctxt->style->cdataSection != NULL) &&
+       (target != NULL) && 
+       (target->type == XML_ELEMENT_NODE) &&
+       (((target->ns == NULL) && 
+         (xmlHashLookup2(ctxt->style->cdataSection,
+                         target->name, NULL) != NULL)) ||
+        ((target->ns != NULL) &&
+         (xmlHashLookup2(ctxt->style->cdataSection,
+                         target->name, target->ns->href) != NULL))))
+    {
+       /*
+       * Process "cdata-section-elements".
+       */
+       if ((target->last != NULL) &&
+           (target->last->type == XML_CDATA_SECTION_NODE))
+       {
+           return(xsltAddTextString(ctxt, target->last, string, len));
+       }
+       copy = xmlNewCDataBlock(ctxt->output, string, len);
+    } else if (noescape) {
+       /*
+       * Process "disable-output-escaping".
+       */
+       if ((target != NULL) && (target->last != NULL) &&
+           (target->last->type == XML_TEXT_NODE) &&
+           (target->last->name == xmlStringTextNoenc))
+       {
+           return(xsltAddTextString(ctxt, target->last, string, len));
+       }
+       copy = xmlNewTextLen(string, len);
+       if (copy != NULL)
+           copy->name = xmlStringTextNoenc;
+    } else {
+       /*
+       * Default processing.
+       */
+       if ((target != NULL) && (target->last != NULL) &&
+           (target->last->type == XML_TEXT_NODE) &&
+           (target->last->name == xmlStringText)) {
+           return(xsltAddTextString(ctxt, target->last, string, len));
+       }
+       copy = xmlNewTextLen(string, len);
+    }
+    if (copy != NULL) {
+       if (target != NULL)
+           xmlAddChild(target, copy);
+       ctxt->lasttext = copy->content;
+       ctxt->lasttsize = len;
+       ctxt->lasttuse = len;
+    } else {
+       xsltTransformError(ctxt, NULL, target,
+                        "xsltCopyTextString: text copy failed\n");
+       ctxt->lasttext = NULL;
+    }
+    return(copy);
+}
+
+/**
+ * xsltCopyText:
+ * @ctxt:  a XSLT process context
+ * @target:  the element where the text will be attached
+ * @cur:  the text or CDATA node
+ * @interned:  the string is in the target doc dictionary
+ *
+ * Copy the text content of @cur and append it to @target's children.
+ *
+ * Returns: the text node, where the text content of @cur is copied to.
+ *          NULL in case of API or internal errors.
+ */
+static xmlNodePtr
+xsltCopyText(xsltTransformContextPtr ctxt, xmlNodePtr target,
+            xmlNodePtr cur, int interned)
+{
+    xmlNodePtr copy;
+
+    if ((cur->type != XML_TEXT_NODE) &&
+       (cur->type != XML_CDATA_SECTION_NODE))
+       return(NULL);
+    if (cur->content == NULL) 
+       return(NULL);
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    if (cur->type == XML_CDATA_SECTION_NODE) {
+       XSLT_TRACE(ctxt,XSLT_TRACE_COPY_TEXT,xsltGenericDebug(xsltGenericDebugContext,
+                        "xsltCopyText: copy CDATA text %s\n",
+                        cur->content));
+    } else if (cur->name == xmlStringTextNoenc) {
+       XSLT_TRACE(ctxt,XSLT_TRACE_COPY_TEXT,xsltGenericDebug(xsltGenericDebugContext,
+                    "xsltCopyText: copy unescaped text %s\n",
+                        cur->content));
+    } else {
+       XSLT_TRACE(ctxt,XSLT_TRACE_COPY_TEXT,xsltGenericDebug(xsltGenericDebugContext,
+                        "xsltCopyText: copy text %s\n",
+                        cur->content));
+    }
+#endif
+
+    /*
+    * Play save and reset the merging mechanism for every new
+    * target node.
+    */
+    if ((target == NULL) || (target->children == NULL)) {
+       ctxt->lasttext = NULL;
+    }
+
+    if ((ctxt->style->cdataSection != NULL) &&
+       (ctxt->type == XSLT_OUTPUT_XML) &&      
+       (target != NULL) &&
+       (target->type == XML_ELEMENT_NODE) &&
+       (((target->ns == NULL) && 
+         (xmlHashLookup2(ctxt->style->cdataSection,
+                         target->name, NULL) != NULL)) ||
+        ((target->ns != NULL) &&
+         (xmlHashLookup2(ctxt->style->cdataSection,
+                         target->name, target->ns->href) != NULL))))
+    {
+       /*
+       * Process "cdata-section-elements".
+       */
+       /* 
+       * OPTIMIZE TODO: xsltCopyText() is also used for attribute content.     
+       */
+       /*
+       * TODO: Since this doesn't merge adjacent CDATA-section nodes,
+       * we'll get: <![CDATA[x]]><!CDATA[y]]>.
+       * TODO: Reported in #321505.
+       */
+       if ((target->last != NULL) &&
+            (target->last->type == XML_CDATA_SECTION_NODE))
+       {
+           /*
+           * Append to existing CDATA-section node.
+           */
+           copy = xsltAddTextString(ctxt, target->last, cur->content,
+               xmlStrlen(cur->content));
+           goto exit;
+       } else {
+           unsigned int len;
+
+           len = xmlStrlen(cur->content);          
+           copy = xmlNewCDataBlock(ctxt->output, cur->content, len);
+           if (copy == NULL)
+               goto exit;
+           ctxt->lasttext = copy->content;
+           ctxt->lasttsize = len;
+           ctxt->lasttuse = len;
+       }
+    } else if ((target != NULL) &&
+       (target->last != NULL) &&
+       /* both escaped or both non-escaped text-nodes */
+       (((target->last->type == XML_TEXT_NODE) &&
+       (target->last->name == cur->name)) ||
+        /* non-escaped text nodes and CDATA-section nodes */
+       (((target->last->type == XML_CDATA_SECTION_NODE) &&
+       (cur->name == xmlStringTextNoenc)))))
+    {
+       /*
+        * we are appending to an existing text node
+        */
+       copy = xsltAddTextString(ctxt, target->last, cur->content,
+           xmlStrlen(cur->content));
+       goto exit;
+    } else if ((interned) && (target != NULL) &&
+       (target->doc != NULL) &&
+       (target->doc->dict == ctxt->dict))
+    {        
+       /*
+       * TODO: DO we want to use this also for "text" output?
+       */
+        copy = xmlNewTextLen(NULL, 0);
+       if (copy == NULL)
+           goto exit;  
+       if (cur->name == xmlStringTextNoenc)
+           copy->name = xmlStringTextNoenc;
+       
+       /*
+        * Must confirm that content is in dict (bug 302821)
+        * TODO: This check should be not needed for text coming
+        * from the stylesheets 
+        */
+       if (xmlDictOwns(ctxt->dict, cur->content))
+           copy->content = cur->content;
+       else {
+           if ((copy->content = xmlStrdup(cur->content)) == NULL)
+               return NULL;
+       }
+    } else {
+        /*
+        * normal processing. keep counters to extend the text node
+        * in xsltAddTextString if needed.
+        */
+        unsigned int len;
+
+       len = xmlStrlen(cur->content);
+       copy = xmlNewTextLen(cur->content, len);
+       if (copy == NULL)
+           goto exit;
+       if (cur->name == xmlStringTextNoenc)
+           copy->name = xmlStringTextNoenc;
+       ctxt->lasttext = copy->content;
+       ctxt->lasttsize = len;
+       ctxt->lasttuse = len;
+    }
+    if (copy != NULL) {
+       if (target != NULL) {
+           copy->doc = target->doc;
+           /*
+           * MAYBE TODO: Maybe we should reset the ctxt->lasttext here
+           *  to ensure that the optimized text-merging mechanism
+           *  won't interfere with normal node-merging in any case.
+           */
+           xmlAddChild(target, copy);
+       }
+    } else {
+       xsltTransformError(ctxt, NULL, target,
+                        "xsltCopyText: text copy failed\n");
+    }
+
+exit:
+    if ((copy == NULL) || (copy->content == NULL)) {
+       xsltTransformError(ctxt, NULL, target,
+           "Internal error in xsltCopyText(): "
+           "Failed to copy the string.\n");
+       ctxt->state = XSLT_STATE_STOPPED;
+    }
+    return(copy);
+}
+
+/**
+ * xsltShallowCopyAttr:
+ * @ctxt:  a XSLT process context
+ * @invocNode: responsible node in the stylesheet; used for error reports
+ * @target:  the element where the attribute will be grafted
+ * @attr: the attribute to be copied
+ *
+ * Do a copy of an attribute.
+ * Called by:
+ *  - xsltCopyTreeInternal()
+ *  - xsltCopyOf()
+ *  - xsltCopy()
+ *
+ * Returns: a new xmlAttrPtr, or NULL in case of error.
+ */
+static xmlAttrPtr
+xsltShallowCopyAttr(xsltTransformContextPtr ctxt, xmlNodePtr invocNode,
+            xmlNodePtr target, xmlAttrPtr attr)
+{
+    xmlAttrPtr copy;
+    xmlChar *value;
+
+    if (attr == NULL)
+       return(NULL);
+
+    if (target->type != XML_ELEMENT_NODE) {
+       xsltTransformError(ctxt, NULL, invocNode,
+           "Cannot add an attribute node to a non-element node.\n");
+       return(NULL);
+    }
+    
+    if (target->children != NULL) {
+       xsltTransformError(ctxt, NULL, invocNode,
+           "Attribute nodes must be added before "
+           "any child nodes to an element.\n");
+       return(NULL);
+    }
+
+    value = xmlNodeListGetString(attr->doc, attr->children, 1);
+    if (attr->ns != NULL) {
+       xmlNsPtr ns; 
+
+       ns = xsltGetSpecialNamespace(ctxt, invocNode,
+           attr->ns->href, attr->ns->prefix, target);
+       if (ns == NULL) {
+           xsltTransformError(ctxt, NULL, invocNode,
+               "Namespace fixup error: Failed to acquire an in-scope "
+               "namespace binding of the copied attribute '{%s}%s'.\n",
+               attr->ns->href, attr->name);
+           /*
+           * TODO: Should we just stop here?
+           */
+       }
+       /*
+       * Note that xmlSetNsProp() will take care of duplicates
+       * and assigns the new namespace even to a duplicate.
+       */
+       copy = xmlSetNsProp(target, ns, attr->name, value);
+    } else {
+       copy = xmlSetNsProp(target, NULL, attr->name, value);
+    }
+    if (value != NULL)
+       xmlFree(value);
+
+    if (copy == NULL)
+       return(NULL);
+
+#if 0
+    /*
+    * NOTE: This was optimized according to bug #342695.
+    * TODO: Can this further be optimized, if source and target
+    *  share the same dict and attr->children is just 1 text node
+    *  which is in the dict? How probable is such a case?
+    */
+    /*
+    * TODO: Do we need to create an empty text node if the value
+    *  is the empty string?
+    */
+    value = xmlNodeListGetString(attr->doc, attr->children, 1);
+    if (value != NULL) {
+       txtNode = xmlNewDocText(target->doc, NULL);
+       if (txtNode == NULL)
+           return(NULL);
+       if ((target->doc != NULL) &&
+           (target->doc->dict != NULL))
+       {
+           txtNode->content =
+               (xmlChar *) xmlDictLookup(target->doc->dict,
+                   BAD_CAST value, -1);
+           xmlFree(value);
+       } else
+           txtNode->content = value;
+       copy->children = txtNode;
+    }
+#endif
+
+    return(copy);
+}
+
+/**
+ * xsltCopyAttrListNoOverwrite:
+ * @ctxt:  a XSLT process context
+ * @invocNode: responsible node in the stylesheet; used for error reports
+ * @target:  the element where the new attributes will be grafted
+ * @attr:  the first attribute in the list to be copied
+ *
+ * Copies a list of attribute nodes, starting with @attr, over to the
+ * @target element node.
+ *
+ * Called by:
+ *  - xsltCopyTreeInternal()
+ *
+ * Returns 0 on success and -1 on errors and internal errors.
+ */
+static int
+xsltCopyAttrListNoOverwrite(xsltTransformContextPtr ctxt,
+                           xmlNodePtr invocNode,
+                           xmlNodePtr target, xmlAttrPtr attr)
+{
+    xmlAttrPtr last = NULL, copy;
+    xmlNsPtr origNs = NULL, copyNs = NULL;
+    xmlChar *value = NULL;
+
+    /*
+    * Don't use xmlCopyProp() here, since it will try to
+    * reconciliate namespaces.
+    */
+    while (attr != NULL) {
+       /*
+       * Find a namespace node in the tree of @target.
+       * Avoid searching for the same ns.
+       */
+       if (attr->ns != origNs) {
+           origNs = attr->ns;
+           if (attr->ns != NULL) {
+               copyNs = xsltGetSpecialNamespace(ctxt, invocNode,
+                   attr->ns->href, attr->ns->prefix, target);
+               if (copyNs == NULL)
+                   return(-1);
+           } else
+               copyNs = NULL;
+       }
+       /*
+        * If attribute has a value, we need to copy it (watching out
+        * for possible entities)
+        */
+       if (attr->children)
+           value = xmlNodeListGetString(attr->doc, attr->children, 0);
+       /*
+       * REVISIT: I think xmlNewDocProp() is the only attr function
+       * which does not eval if the attr is of type ID. This is good,
+       * since we don't need this.
+       */
+       copy = xmlNewDocProp(target->doc, attr->name, BAD_CAST value);
+       if (copy == NULL)
+           return(-1);
+       copy->parent = target;
+       copy->ns = copyNs;
+       
+       if (last == NULL) {
+           target->properties = copy;
+           last = copy;
+       } else {
+           last->next = copy;
+           copy->prev = last;
+           last = copy;
+       }
+       /*
+       * OPTIMIZE TODO: How to avoid this intermediate string?
+       */
+       if (value != NULL) {
+           xmlFree(value);
+           value = NULL;
+       }
+       attr = attr->next;
+    }    
+    return(0);
+}
+
+/**
+ * xsltShallowCopyElem:
+ * @ctxt:  the XSLT process context
+ * @node:  the element node in the source tree
+ *         or the Literal Result Element
+ * @insert:  the parent in the result tree
+ * @isLRE: if @node is a Literal Result Element
+ *
+ * Make a copy of the element node @node
+ * and insert it as last child of @insert.
+ *
+ * URGENT TODO: The problem with this one (for the non-refactored code)
+ * is that it is used for both, Literal Result Elements *and*
+ * copying input nodes.
+ *
+ * BIG NOTE: This is only called for XML_ELEMENT_NODEs.
+ *
+ * Called from:
+ *   xsltApplySequenceConstructor()
+ *    (for Literal Result Elements - which is a problem)
+ *   xsltCopy() (for shallow-copying elements via xsl:copy)
+ *
+ * Returns a pointer to the new node, or NULL in case of error
+ */
+static xmlNodePtr
+xsltShallowCopyElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                   xmlNodePtr insert, int isLRE)
+{
+    xmlNodePtr copy;
+
+    if ((node->type == XML_DTD_NODE) || (insert == NULL))
+       return(NULL);
+    if ((node->type == XML_TEXT_NODE) ||
+       (node->type == XML_CDATA_SECTION_NODE))
+       return(xsltCopyText(ctxt, insert, node, 0));
+
+    copy = xmlDocCopyNode(node, insert->doc, 0);
+    if (copy != NULL) {
+       copy->doc = ctxt->output;
+       xmlAddChild(insert, copy);
+
+       if (node->type == XML_ELEMENT_NODE) {
+           /*
+            * Add namespaces as they are needed
+            */
+           if (node->nsDef != NULL) {
+               /*
+               * TODO: Remove the LRE case in the refactored code
+               * gets enabled.
+               */
+               if (isLRE)
+                   xsltCopyNamespaceList(ctxt, copy, node->nsDef);
+               else
+                   xsltCopyNamespaceListInternal(copy, node->nsDef);
+           }
+
+           /*
+           * URGENT TODO: The problem with this is that it does not
+           *  copy over all namespace nodes in scope.
+           *  The damn thing about this is, that we would need to
+           *  use the xmlGetNsList(), for every single node; this is
+           *  also done in xsltCopyTreeInternal(), but only for the top node.
+           */
+           if (node->ns != NULL) {
+               if (isLRE) {
+                   /*
+                   * REVISIT TODO: Since the non-refactored code still does
+                   *  ns-aliasing, we need to call xsltGetNamespace() here.
+                   *  Remove this when ready.
+                   */
+                   copy->ns = xsltGetNamespace(ctxt, node, node->ns, copy);
+               } else {
+                   copy->ns = xsltGetSpecialNamespace(ctxt,
+                       node, node->ns->href, node->ns->prefix, copy);
+                   
+               }
+           } else if ((insert->type == XML_ELEMENT_NODE) &&
+                      (insert->ns != NULL))
+           {
+               /*
+               * "Undeclare" the default namespace.
+               */
+               xsltGetSpecialNamespace(ctxt, node, NULL, NULL, copy);
+           }
+       }
+    } else {
+       xsltTransformError(ctxt, NULL, node,
+               "xsltShallowCopyElem: copy %s failed\n", node->name);
+    }
+    return(copy);
+}
+
+/**
+ * xsltCopyTreeList:
+ * @ctxt:  a XSLT process context
+ * @invocNode: responsible node in the stylesheet; used for error reports
+ * @list:  the list of element nodes in the source tree.
+ * @insert:  the parent in the result tree.
+ * @isLRE:  is this a literal result element list
+ * @topElemVisited: indicates if a top-most element was already processed
+ *
+ * Make a copy of the full list of tree @list
+ * and insert it as last children of @insert
+ *
+ * NOTE: Not to be used for Literal Result Elements.
+ *
+ * Used by:
+ *  - xsltCopyOf()
+ *
+ * Returns a pointer to the new list, or NULL in case of error
+ */
+static xmlNodePtr
+xsltCopyTreeList(xsltTransformContextPtr ctxt, xmlNodePtr invocNode,
+                xmlNodePtr list,
+                xmlNodePtr insert, int isLRE, int topElemVisited)
+{
+    xmlNodePtr copy, ret = NULL;
+
+    while (list != NULL) {
+       copy = xsltCopyTreeInternal(ctxt, invocNode,
+           list, insert, isLRE, topElemVisited);
+       if (copy != NULL) {
+           if (ret == NULL) {
+               ret = copy;
+           }
+       }
+       list = list->next;
+    }
+    return(ret);
+}
+
+/**
+ * xsltCopyNamespaceListInternal:
+ * @node:  the target node
+ * @cur:  the first namespace
+ *
+ * Do a copy of a namespace list. If @node is non-NULL the
+ * new namespaces are added automatically.
+ * Called by:
+ *   xsltCopyTreeInternal()
+ *
+ * QUESTION: What is the exact difference between this function
+ *  and xsltCopyNamespaceList() in "namespaces.c"?
+ * ANSWER: xsltCopyNamespaceList() tries to apply ns-aliases.
+ *
+ * Returns: a new xmlNsPtr, or NULL in case of error.
+ */
+static xmlNsPtr
+xsltCopyNamespaceListInternal(xmlNodePtr elem, xmlNsPtr ns) {
+    xmlNsPtr ret = NULL;
+    xmlNsPtr p = NULL, q, luNs;
+
+    if (ns == NULL)
+       return(NULL);
+    /*
+     * One can add namespaces only on element nodes
+     */
+    if ((elem != NULL) && (elem->type != XML_ELEMENT_NODE))
+       elem = NULL;
+
+    do {
+       if (ns->type != XML_NAMESPACE_DECL)
+           break;
+       /*
+        * Avoid duplicating namespace declarations on the tree.
+        */
+       if (elem != NULL) {         
+           if ((elem->ns != NULL) &&
+               xmlStrEqual(elem->ns->prefix, ns->prefix) &&
+               xmlStrEqual(elem->ns->href, ns->href))
+           {
+               ns = ns->next;
+               continue;
+           }
+           luNs = xmlSearchNs(elem->doc, elem, ns->prefix);
+           if ((luNs != NULL) && (xmlStrEqual(luNs->href, ns->href)))
+           {
+               ns = ns->next;
+               continue;
+           }
+       }               
+       q = xmlNewNs(elem, ns->href, ns->prefix);
+       if (p == NULL) {
+           ret = p = q;
+       } else if (q != NULL) {
+           p->next = q;
+           p = q;
+       }
+       ns = ns->next;  
+    } while (ns != NULL);
+    return(ret);
+}
+
+/**
+ * xsltShallowCopyNsNode:
+ * @ctxt:  the XSLT transformation context
+ * @invocNode: responsible node in the stylesheet; used for error reports
+ * @insert:  the target element node in the result tree
+ * @ns: the namespace node
+ *
+ * This is used for copying ns-nodes with xsl:copy-of and xsl:copy.
+ *
+ * Returns a new/existing ns-node, or NULL.
+ */
+static xmlNsPtr
+xsltShallowCopyNsNode(xsltTransformContextPtr ctxt,
+                     xmlNodePtr invocNode,
+                     xmlNodePtr insert,
+                     xmlNsPtr ns)
+{
+    /*
+     * TODO: Contrary to header comments, this is declared as int.  
+     * be modified to return a node pointer, or NULL if any error
+     */
+    xmlNsPtr tmpns;
+
+    if ((insert == NULL) || (insert->type != XML_ELEMENT_NODE))
+       return(NULL);
+    
+    if (insert->children != NULL) {
+       xsltTransformError(ctxt, NULL, invocNode,
+           "Namespace nodes must be added before "
+           "any child nodes are added to an element.\n");
+       return(NULL);
+    }
+    /*    
+    *
+    * BIG NOTE: Xalan-J simply overwrites any ns-decls with
+    * an equal prefix. We definitively won't do that.
+    *
+    * MSXML 4.0 and the .NET ignores ns-decls for which an
+    * equal prefix is already in use.
+    *
+    * Saxon raises an error like:
+    * "net.sf.saxon.xpath.DynamicError: Cannot create two namespace
+    * nodes with the same name".
+    *
+    * NOTE: We'll currently follow MSXML here.
+    * REVISIT TODO: Check if it's better to follow Saxon here.
+    */
+    if (ns->prefix == NULL) {
+       /*
+       * If we are adding ns-nodes to an element using e.g.
+       * <xsl:copy-of select="/foo/namespace::*">, then we need
+       * to ensure that we don't incorrectly declare a default
+       * namespace on an element in no namespace, which otherwise
+       * would move the element incorrectly into a namespace, if
+       * the node tree is serialized.
+       */
+       if (insert->ns == NULL)
+           goto occupied;
+    } else if ((ns->prefix[0] == 'x') &&
+       xmlStrEqual(ns->prefix, BAD_CAST "xml"))
+    {
+       /*
+       * The XML namespace is built in.
+       */
+       return(NULL);
+    }
+
+    if (insert->nsDef != NULL) {
+       tmpns = insert->nsDef;
+       do {
+           if ((tmpns->prefix == NULL) == (ns->prefix == NULL)) {              
+               if ((tmpns->prefix == ns->prefix) ||
+                   xmlStrEqual(tmpns->prefix, ns->prefix))
+               {
+                   /*
+                   * Same prefix.
+                   */
+                   if (xmlStrEqual(tmpns->href, ns->href))
+                       return(NULL);
+                   goto occupied;
+               }
+           }
+           tmpns = tmpns->next;
+       } while (tmpns != NULL);
+    }
+    tmpns = xmlSearchNs(insert->doc, insert, ns->prefix);
+    if ((tmpns != NULL) && xmlStrEqual(tmpns->href, ns->href))
+       return(NULL);
+    /*
+    * Declare a new namespace.
+    * TODO: The problem (wrt efficiency) with this xmlNewNs() is
+    * that it will again search the already declared namespaces
+    * for a duplicate :-/
+    */
+    return(xmlNewNs(insert, ns->href, ns->prefix));
+
+occupied:
+    /*
+    * TODO: We could as well raise an error here (like Saxon does),
+    * or at least generate a warning.
+    */
+    return(NULL);
+}
+
+/**
+ * xsltCopyTreeInternal:
+ * @ctxt:  the XSLT transformation context
+ * @invocNode: responsible node in the stylesheet; used for error reports
+ * @node:  the element node in the source tree
+ * @insert:  the parent in the result tree
+ * @isLRE:  indicates if @node is a Literal Result Element
+ * @topElemVisited: indicates if a top-most element was already processed
+ *
+ * Make a copy of the full tree under the element node @node
+ * and insert it as last child of @insert
+ *
+ * NOTE: Not to be used for Literal Result Elements.
+ *
+ * Used by:
+ *  - xsltCopyOf()
+ *
+ * Returns a pointer to the new tree, or NULL in case of error
+ */
+static xmlNodePtr
+xsltCopyTreeInternal(xsltTransformContextPtr ctxt,
+                    xmlNodePtr invocNode,
+                    xmlNodePtr node,
+                    xmlNodePtr insert, int isLRE, int topElemVisited)
+{
+    xmlNodePtr copy;
+
+    if (node == NULL)
+       return(NULL);
+    switch (node->type) {
+        case XML_ELEMENT_NODE:
+        case XML_ENTITY_REF_NODE:
+        case XML_ENTITY_NODE:
+        case XML_PI_NODE:
+        case XML_COMMENT_NODE:
+        case XML_DOCUMENT_NODE:
+        case XML_HTML_DOCUMENT_NODE:
+#ifdef LIBXML_DOCB_ENABLED
+        case XML_DOCB_DOCUMENT_NODE:
+#endif
+           break;
+        case XML_TEXT_NODE: {
+           int noenc = (node->name == xmlStringTextNoenc);
+           return(xsltCopyTextString(ctxt, insert, node->content, noenc));
+           }
+        case XML_CDATA_SECTION_NODE:
+           return(xsltCopyTextString(ctxt, insert, node->content, 0));
+        case XML_ATTRIBUTE_NODE:
+           return((xmlNodePtr)
+               xsltShallowCopyAttr(ctxt, invocNode, insert, (xmlAttrPtr) node));
+        case XML_NAMESPACE_DECL:
+           return((xmlNodePtr) xsltShallowCopyNsNode(ctxt, invocNode,
+               insert, (xmlNsPtr) node));
+           
+        case XML_DOCUMENT_TYPE_NODE:
+        case XML_DOCUMENT_FRAG_NODE:
+        case XML_NOTATION_NODE:
+        case XML_DTD_NODE:
+        case XML_ELEMENT_DECL:
+        case XML_ATTRIBUTE_DECL:
+        case XML_ENTITY_DECL:
+        case XML_XINCLUDE_START:
+        case XML_XINCLUDE_END:
+            return(NULL);
+    }    
+    if (XSLT_IS_RES_TREE_FRAG(node)) {
+       if (node->children != NULL)
+           copy = xsltCopyTreeList(ctxt, invocNode,
+               node->children, insert, 0, 0);
+       else
+           copy = NULL;
+       return(copy);
+    }
+    copy = xmlDocCopyNode(node, insert->doc, 0);
+    if (copy != NULL) {
+       copy->doc = ctxt->output;
+       xmlAddChild(insert, copy);
+       /*
+        * The node may have been coalesced into another text node.
+        */
+       if (insert->last != copy)
+           return(insert->last);
+       copy->next = NULL;
+
+       if (node->type == XML_ELEMENT_NODE) {       
+           /*
+           * Copy in-scope namespace nodes.
+           *
+           * REVISIT: Since we try to reuse existing in-scope ns-decls by
+           *  using xmlSearchNsByHref(), this will eventually change
+           *  the prefix of an original ns-binding; thus it might
+           *  break QNames in element/attribute content.
+           * OPTIMIZE TODO: If we had a xmlNsPtr * on the transformation
+           *  context, plus a ns-lookup function, which writes directly
+           *  to a given list, then we wouldn't need to create/free the
+           *  nsList every time.
+           */
+           if ((topElemVisited == 0) &&
+               (node->parent != NULL) &&
+               (node->parent->type != XML_DOCUMENT_NODE) &&
+               (node->parent->type != XML_HTML_DOCUMENT_NODE))
+           {
+               xmlNsPtr *nsList, *curns, ns;
+               
+               /*
+               * If this is a top-most element in a tree to be
+               * copied, then we need to ensure that all in-scope
+               * namespaces are copied over. For nodes deeper in the
+               * tree, it is sufficient to reconcile only the ns-decls
+               * (node->nsDef entries).
+               */
+               
+               nsList = xmlGetNsList(node->doc, node);
+               if (nsList != NULL) {
+                   curns = nsList;
+                   do {
+                       /*
+                       * Search by prefix first in order to break as less
+                       * QNames in element/attribute content as possible.
+                       */
+                       ns = xmlSearchNs(insert->doc, insert,
+                           (*curns)->prefix);
+                       
+                       if ((ns == NULL) ||
+                           (! xmlStrEqual(ns->href, (*curns)->href)))
+                       {
+                           ns = NULL;
+                           /*
+                           * Search by namespace name.
+                           * REVISIT TODO: Currently disabled.
+                           */
+#if 0
+                           ns = xmlSearchNsByHref(insert->doc,
+                               insert, (*curns)->href);
+#endif
+                       }
+                       if (ns == NULL) {
+                           /*
+                           * Declare a new namespace on the copied element.
+                           */
+                           ns = xmlNewNs(copy, (*curns)->href,
+                               (*curns)->prefix);
+                           /* TODO: Handle errors */
+                       }
+                       if (node->ns == *curns) {
+                           /*
+                           * If this was the original's namespace then set
+                           * the generated counterpart on the copy.
+                           */
+                           copy->ns = ns;
+                       }
+                       curns++;
+                   } while (*curns != NULL);
+                   xmlFree(nsList);
+               }
+           } else if (node->nsDef != NULL) {           
+               /*
+               * Copy over all namespace declaration attributes.               
+               */
+               if (node->nsDef != NULL) {
+                   if (isLRE)
+                       xsltCopyNamespaceList(ctxt, copy, node->nsDef);
+                   else
+                       xsltCopyNamespaceListInternal(copy, node->nsDef);
+               }
+           }
+           /*
+           * Set the namespace.
+           */
+           if (node->ns != NULL) {
+               if (copy->ns == NULL) {
+                   /*
+                   * This will map copy->ns to one of the newly created
+                   * in-scope ns-decls, OR create a new ns-decl on @copy.
+                   */
+                   copy->ns = xsltGetSpecialNamespace(ctxt, invocNode,
+                       node->ns->href, node->ns->prefix, copy);
+               }
+           } else if ((insert->type == XML_ELEMENT_NODE) &&
+               (insert->ns != NULL))
+           {
+               /*
+               * "Undeclare" the default namespace on @copy with xmlns="".
+               */
+               xsltGetSpecialNamespace(ctxt, invocNode, NULL, NULL, copy);
+           }
+           /*
+           * Copy attribute nodes.
+           */
+           if (node->properties != NULL) {
+               xsltCopyAttrListNoOverwrite(ctxt, invocNode,
+                   copy, node->properties);
+           }
+           if (topElemVisited == 0)
+               topElemVisited = 1;
+       }
+       /*
+       * Copy the subtree.
+       */
+       if (node->children != NULL) {
+           xsltCopyTreeList(ctxt, invocNode,
+               node->children, copy, isLRE, topElemVisited);
+       }
+    } else {
+       xsltTransformError(ctxt, NULL, invocNode,
+           "xsltCopyTreeInternal: Copying of '%s' failed.\n", node->name);
+    }
+    return(copy);
+}
+
+/**
+ * xsltCopyTree:
+ * @ctxt:  the XSLT transformation context
+ * @node:  the element node in the source tree
+ * @insert:  the parent in the result tree
+ * @literal:  indicates if @node is a Literal Result Element
+ *
+ * Make a copy of the full tree under the element node @node
+ * and insert it as last child of @insert
+ * For literal result element, some of the namespaces may not be copied
+ * over according to section 7.1.
+ * TODO: Why is this a public function?
+ *
+ * Returns a pointer to the new tree, or NULL in case of error
+ */
+xmlNodePtr
+xsltCopyTree(xsltTransformContextPtr ctxt, xmlNodePtr node,
+            xmlNodePtr insert, int literal)
+{
+    return(xsltCopyTreeInternal(ctxt, node, node, insert, literal, 0));
+    
+}
+
+/************************************************************************
+ *                                                                     *
+ *             Error/fallback processing                               *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltApplyFallbacks:
+ * @ctxt:  a XSLT process context
+ * @node:  the node in the source tree.
+ * @inst:  the node generating the error
+ *
+ * Process possible xsl:fallback nodes present under @inst
+ *
+ * Returns the number of xsl:fallback element found and processed
+ */
+static int
+xsltApplyFallbacks(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                  xmlNodePtr inst) {
+
+    xmlNodePtr child;
+    int ret = 0;
+    
+    if ((ctxt == NULL) || (node == NULL) || (inst == NULL) ||
+       (inst->children == NULL))
+       return(0);
+
+    child = inst->children;
+    while (child != NULL) {
+        if ((IS_XSLT_ELEM(child)) &&
+            (xmlStrEqual(child->name, BAD_CAST "fallback"))) {
+#ifdef WITH_XSLT_DEBUG_PARSING
+           xsltGenericDebug(xsltGenericDebugContext,
+                            "applying xsl:fallback\n");
+#endif
+           ret++;
+           xsltApplySequenceConstructor(ctxt, node, child->children,
+               NULL);
+       }
+       child = child->next;
+    }
+    return(ret);
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     Default processing                              *
+ *                                                                     *
+ ************************************************************************/
+
+void xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                       xsltStackElemPtr params);
+/**
+ * xsltDefaultProcessOneNode:
+ * @ctxt:  a XSLT process context
+ * @node:  the node in the source tree.
+ * @params: extra parameters passed to the template if any
+ *
+ * Process the source node with the default built-in template rule:
+ * <xsl:template match="*|/">
+ *   <xsl:apply-templates/>
+ * </xsl:template>
+ *
+ * and
+ *
+ * <xsl:template match="text()|@*">
+ *   <xsl:value-of select="."/>
+ * </xsl:template>
+ *
+ * Note also that namespace declarations are copied directly:
+ *
+ * the built-in template rule is the only template rule that is applied
+ * for namespace nodes.
+ */
+static void
+xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                         xsltStackElemPtr params) {
+    xmlNodePtr copy;
+    xmlNodePtr delete = NULL, cur;
+    int nbchild = 0, oldSize;
+    int childno = 0, oldPos;
+    xsltTemplatePtr template;
+
+    CHECK_STOPPED;
+    /*
+     * Handling of leaves
+     */
+    switch (node->type) {
+       case XML_DOCUMENT_NODE:
+       case XML_HTML_DOCUMENT_NODE:
+       case XML_ELEMENT_NODE:
+           break;
+       case XML_CDATA_SECTION_NODE:
+#ifdef WITH_XSLT_DEBUG_PROCESS
+           XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltDefaultProcessOneNode: copy CDATA %s\n",
+               node->content));
+#endif
+           copy = xsltCopyText(ctxt, ctxt->insert, node, 0);
+           if (copy == NULL) {
+               xsltTransformError(ctxt, NULL, node,
+                "xsltDefaultProcessOneNode: cdata copy failed\n");
+           }
+           return;
+       case XML_TEXT_NODE:
+#ifdef WITH_XSLT_DEBUG_PROCESS
+           if (node->content == NULL) {
+               XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+                "xsltDefaultProcessOneNode: copy empty text\n"));
+               return;
+           } else {
+               XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+                "xsltDefaultProcessOneNode: copy text %s\n",
+                       node->content));
+            }
+#endif
+           copy = xsltCopyText(ctxt, ctxt->insert, node, 0);
+           if (copy == NULL) {
+               xsltTransformError(ctxt, NULL, node,
+                "xsltDefaultProcessOneNode: text copy failed\n");
+           }
+           return;
+       case XML_ATTRIBUTE_NODE:
+           cur = node->children;
+           while ((cur != NULL) && (cur->type != XML_TEXT_NODE))
+               cur = cur->next;
+           if (cur == NULL) {
+               xsltTransformError(ctxt, NULL, node,
+                "xsltDefaultProcessOneNode: no text for attribute\n");
+           } else {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+               if (cur->content == NULL) {
+                   XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+                    "xsltDefaultProcessOneNode: copy empty text\n"));
+               } else {
+                   XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+                    "xsltDefaultProcessOneNode: copy text %s\n",
+                       cur->content));
+                }
+#endif
+               copy = xsltCopyText(ctxt, ctxt->insert, cur, 0);
+               if (copy == NULL) {
+                   xsltTransformError(ctxt, NULL, node,
+                    "xsltDefaultProcessOneNode: text copy failed\n");
+               }
+           }
+           return;
+       default:
+           return;
+    }
+    /*
+     * Handling of Elements: first pass, cleanup and counting
+     */
+    cur = node->children;
+    while (cur != NULL) {
+       switch (cur->type) {
+           case XML_TEXT_NODE:
+           case XML_CDATA_SECTION_NODE:
+           case XML_DOCUMENT_NODE:
+           case XML_HTML_DOCUMENT_NODE:
+           case XML_ELEMENT_NODE:
+           case XML_PI_NODE:
+           case XML_COMMENT_NODE:
+               nbchild++;
+               break;
+            case XML_DTD_NODE:
+               /* Unlink the DTD, it's still reachable using doc->intSubset */
+               if (cur->next != NULL)
+                   cur->next->prev = cur->prev;
+               if (cur->prev != NULL)
+                   cur->prev->next = cur->next;
+               break;
+           default:
+#ifdef WITH_XSLT_DEBUG_PROCESS
+               XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+                "xsltDefaultProcessOneNode: skipping node type %d\n",
+                                cur->type));
+#endif
+               delete = cur;
+       }
+       cur = cur->next;
+       if (delete != NULL) {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+           XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+                "xsltDefaultProcessOneNode: removing ignorable blank node\n"));
+#endif
+           xmlUnlinkNode(delete);
+           xmlFreeNode(delete);
+           delete = NULL;
+       }
+    }
+    if (delete != NULL) {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+       XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltDefaultProcessOneNode: removing ignorable blank node\n"));
+#endif
+       xmlUnlinkNode(delete);
+       xmlFreeNode(delete);
+       delete = NULL;
+    }
+
+    /*
+     * Handling of Elements: second pass, actual processing
+     */
+    oldSize = ctxt->xpathCtxt->contextSize;
+    oldPos = ctxt->xpathCtxt->proximityPosition;
+    cur = node->children;
+    while (cur != NULL) {
+       childno++;
+       switch (cur->type) {
+           case XML_DOCUMENT_NODE:
+           case XML_HTML_DOCUMENT_NODE:
+           case XML_ELEMENT_NODE:
+               ctxt->xpathCtxt->contextSize = nbchild;
+               ctxt->xpathCtxt->proximityPosition = childno;
+               xsltProcessOneNode(ctxt, cur, params);
+               break;
+           case XML_CDATA_SECTION_NODE:
+               template = xsltGetTemplate(ctxt, cur, NULL);
+               if (template) {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+                   XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+                "xsltDefaultProcessOneNode: applying template for CDATA %s\n",
+                                    cur->content));
+#endif
+                   /*
+                   * Instantiate the xsl:template.
+                   */
+                   xsltApplyXSLTTemplate(ctxt, cur, template->content,
+                       template, params);
+               } else /* if (ctxt->mode == NULL) */ {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+                   XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+                    "xsltDefaultProcessOneNode: copy CDATA %s\n",
+                                    cur->content));
+#endif
+                   copy = xsltCopyText(ctxt, ctxt->insert, cur, 0);
+                   if (copy == NULL) {
+                       xsltTransformError(ctxt, NULL, cur,
+                           "xsltDefaultProcessOneNode: cdata copy failed\n");
+                   }
+               }
+               break;
+           case XML_TEXT_NODE:
+               template = xsltGetTemplate(ctxt, cur, NULL);
+               if (template) {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+                   XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltDefaultProcessOneNode: applying template for text %s\n",
+                                    cur->content));
+#endif
+                   ctxt->xpathCtxt->contextSize = nbchild;
+                   ctxt->xpathCtxt->proximityPosition = childno;
+                   /*
+                   * Instantiate the xsl:template.
+                   */
+                   xsltApplyXSLTTemplate(ctxt, cur, template->content,
+                       template, params);
+               } else /* if (ctxt->mode == NULL) */ {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+                   if (cur->content == NULL) {
+                       XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+                        "xsltDefaultProcessOneNode: copy empty text\n"));
+                   } else {
+                       XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+                    "xsltDefaultProcessOneNode: copy text %s\n",
+                                        cur->content));
+                    }
+#endif
+                   copy = xsltCopyText(ctxt, ctxt->insert, cur, 0);
+                   if (copy == NULL) {
+                       xsltTransformError(ctxt, NULL, cur,
+                           "xsltDefaultProcessOneNode: text copy failed\n");
+                   }
+               }
+               break;
+           case XML_PI_NODE:
+           case XML_COMMENT_NODE:
+               template = xsltGetTemplate(ctxt, cur, NULL);
+               if (template) {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+                   if (cur->type == XML_PI_NODE) {
+                       XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+                    "xsltDefaultProcessOneNode: template found for PI %s\n",
+                                        cur->name));
+                   } else if (cur->type == XML_COMMENT_NODE) {
+                       XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+                    "xsltDefaultProcessOneNode: template found for comment\n"));
+                    }
+#endif
+                   ctxt->xpathCtxt->contextSize = nbchild;
+                   ctxt->xpathCtxt->proximityPosition = childno;
+                   /*
+                   * Instantiate the xsl:template.
+                   */
+                   xsltApplyXSLTTemplate(ctxt, cur, template->content,
+                       template, params);
+               }
+               break;
+           default:
+               break;
+       }
+       cur = cur->next;
+    }
+    ctxt->xpathCtxt->contextSize = oldSize;
+    ctxt->xpathCtxt->proximityPosition = oldPos;
+}
+
+/**
+ * xsltProcessOneNode:
+ * @ctxt:  a XSLT process context
+ * @contextNode:  the "current node" in the source tree
+ * @withParams:  extra parameters (e.g. xsl:with-param) passed to the
+ *               template if any
+ *
+ * Process the source node.
+ */
+void
+xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
+                  xsltStackElemPtr withParams)
+{
+    xsltTemplatePtr templ;
+    xmlNodePtr oldNode;
+    
+    templ = xsltGetTemplate(ctxt, contextNode, NULL);
+    /*
+     * If no template is found, apply the default rule.
+     */
+    if (templ == NULL) {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+       if (contextNode->type == XML_DOCUMENT_NODE) {
+           XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltProcessOneNode: no template found for /\n"));
+       } else if (contextNode->type == XML_CDATA_SECTION_NODE) {
+           XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltProcessOneNode: no template found for CDATA\n"));
+       } else if (contextNode->type == XML_ATTRIBUTE_NODE) {
+           XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltProcessOneNode: no template found for attribute %s\n",
+                            ((xmlAttrPtr) contextNode)->name));
+       } else  {
+           XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltProcessOneNode: no template found for %s\n", contextNode->name));
+        }
+#endif
+       oldNode = ctxt->node;
+       ctxt->node = contextNode;
+       xsltDefaultProcessOneNode(ctxt, contextNode, withParams);
+       ctxt->node = oldNode;
+       return;
+    }
+
+    if (contextNode->type == XML_ATTRIBUTE_NODE) {
+       xsltTemplatePtr oldCurTempRule = ctxt->currentTemplateRule; 
+       /*
+       * Set the "current template rule".
+       */
+       ctxt->currentTemplateRule = templ;
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+       XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltProcessOneNode: applying template '%s' for attribute %s\n",
+                        templ->match, contextNode->name));
+#endif
+       xsltApplyXSLTTemplate(ctxt, contextNode, templ->content, templ, withParams);
+
+       ctxt->currentTemplateRule = oldCurTempRule;
+    } else {
+       xsltTemplatePtr oldCurTempRule = ctxt->currentTemplateRule; 
+       /*
+       * Set the "current template rule".
+       */
+       ctxt->currentTemplateRule = templ;
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+       if (contextNode->type == XML_DOCUMENT_NODE) {
+           XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltProcessOneNode: applying template '%s' for /\n",
+                            templ->match));
+       } else {
+           XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltProcessOneNode: applying template '%s' for %s\n",
+                            templ->match, contextNode->name));
+        }
+#endif
+       xsltApplyXSLTTemplate(ctxt, contextNode, templ->content, templ, withParams);
+
+       ctxt->currentTemplateRule = oldCurTempRule;
+    }
+}
+
+static xmlNodePtr
+xsltDebuggerStartSequenceConstructor(xsltTransformContextPtr ctxt,
+                                    xmlNodePtr contextNode,
+                                    xmlNodePtr list,
+                                    xsltTemplatePtr templ,
+                                    int *addCallResult)
+{
+    xmlNodePtr debugedNode = NULL;    
+
+    if (ctxt->debugStatus != XSLT_DEBUG_NONE) {
+        if (templ) {
+            *addCallResult = xslAddCall(templ, templ->elem);
+        } else {
+            *addCallResult = xslAddCall(NULL, list);
+        }
+        switch (ctxt->debugStatus) {
+            case XSLT_DEBUG_RUN_RESTART:
+            case XSLT_DEBUG_QUIT:
+                if (*addCallResult)
+                    xslDropCall();
+                return(NULL);
+        }
+        if (templ) {
+            xslHandleDebugger(templ->elem, contextNode, templ, ctxt);
+            debugedNode = templ->elem;
+        } else if (list) {
+            xslHandleDebugger(list, contextNode, templ, ctxt);
+            debugedNode = list;
+        } else if (ctxt->inst) {
+            xslHandleDebugger(ctxt->inst, contextNode, templ, ctxt);
+            debugedNode = ctxt->inst;
+        }
+    }
+    return(debugedNode);
+}
+
+/**
+ * xsltLocalVariablePush:
+ * @ctxt: the transformation context
+ * @variable: variable to be pushed to the variable stack
+ * @level: new value for variable's level
+ *
+ * Places the variable onto the local variable stack
+ *
+ * Returns: 0 for success, -1 for any error
+ * **NOTE:**
+ * This is an internal routine and should not be called by users!
+ */
+int
+xsltLocalVariablePush(xsltTransformContextPtr ctxt,
+                     xsltStackElemPtr variable,
+                     int level)
+{
+    if (ctxt->varsMax == 0) {
+       ctxt->varsMax = 10;
+       ctxt->varsTab =
+           (xsltStackElemPtr *) xmlMalloc(ctxt->varsMax *
+           sizeof(ctxt->varsTab[0]));
+       if (ctxt->varsTab == NULL) {
+           xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
+           return (-1);
+       }
+    }
+    if (ctxt->varsNr >= ctxt->varsMax) {
+       ctxt->varsMax *= 2;
+       ctxt->varsTab =
+           (xsltStackElemPtr *) xmlRealloc(ctxt->varsTab,
+           ctxt->varsMax *
+           sizeof(ctxt->varsTab[0]));
+       if (ctxt->varsTab == NULL) {
+           xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
+           return (-1);
+       }
+    }
+    ctxt->varsTab[ctxt->varsNr++] = variable;
+    ctxt->vars = variable;
+    variable->level = level;
+    return(0);
+}
+
+/**
+ * xsltReleaseLocalRVTs:
+ *
+ * Fragments which are results of extension instructions
+ * are preserved; all other fragments are freed/cached.
+ */
+static void
+xsltReleaseLocalRVTs(xsltTransformContextPtr ctxt, xmlDocPtr base)
+{
+    xmlDocPtr cur = ctxt->localRVT, tmp;
+    
+    while ((cur != NULL) && (cur != base)) {
+       if (cur->psvi == (void *) ((long) 1)) {
+           cur = (xmlDocPtr) cur->next;
+       } else {
+           tmp = cur;
+           cur = (xmlDocPtr) cur->next;
+
+           if (tmp == ctxt->localRVT)
+               ctxt->localRVT = cur;
+
+           /*
+           * We need ctxt->localRVTBase for extension instructions
+           * which return values (like EXSLT's function).
+           */
+           if (tmp == ctxt->localRVTBase)
+               ctxt->localRVTBase = cur;
+
+           if (tmp->prev)
+               tmp->prev->next = (xmlNodePtr) cur;
+           if (cur)
+               cur->prev = tmp->prev;
+           xsltReleaseRVT(ctxt, tmp);
+       }
+    }
+}
+
+/**
+ * xsltApplySequenceConstructor:
+ * @ctxt:  a XSLT process context
+ * @contextNode:  the "current node" in the source tree
+ * @list:  the nodes of a sequence constructor;
+ *         (plus leading xsl:param elements)
+ * @templ: the compiled xsl:template (optional)
+ *
+ * Processes a sequence constructor.
+ * 
+ * NOTE: ctxt->currentTemplateRule was introduced to reflect the
+ * semantics of "current template rule". I.e. the field ctxt->templ
+ * is not intended to reflect this, thus always pushed onto the
+ * template stack.
+ */
+static void
+xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
+                            xmlNodePtr contextNode, xmlNodePtr list,
+                            xsltTemplatePtr templ)
+{
+    xmlNodePtr oldInsert, oldInst, oldCurInst, oldContextNode;
+    xmlNodePtr cur, insert, copy = NULL;
+    int level = 0, oldVarsNr;
+    xmlDocPtr oldLocalFragmentTop, oldLocalFragmentBase;
+
+#ifdef XSLT_REFACTORED
+    xsltStylePreCompPtr info;
+#endif
+
+#ifdef WITH_DEBUGGER
+    int addCallResult = 0;
+    xmlNodePtr debuggedNode = NULL;
+#endif
+
+    if (ctxt == NULL)
+       return;
+
+#ifdef WITH_DEBUGGER 
+    if (ctxt->debugStatus != XSLT_DEBUG_NONE) {
+       debuggedNode =
+           xsltDebuggerStartSequenceConstructor(ctxt, contextNode,
+               list, templ, &addCallResult);
+       if (debuggedNode == NULL)
+           return;
+    }
+#endif
+
+    if (list == NULL)
+        return;
+    CHECK_STOPPED;
+
+    oldLocalFragmentTop = ctxt->localRVT;
+    oldInsert = insert = ctxt->insert;
+    oldInst = oldCurInst = ctxt->inst;
+    oldContextNode = ctxt->node;
+    /*
+    * Save current number of variables on the stack; new vars are popped when
+    * exiting.
+    */
+    oldVarsNr = ctxt->varsNr;
+    /*
+    * Process the sequence constructor.
+    */
+    cur = list;
+    while (cur != NULL) {
+        ctxt->inst = cur;
+
+#ifdef WITH_DEBUGGER
+        switch (ctxt->debugStatus) {
+            case XSLT_DEBUG_RUN_RESTART:
+            case XSLT_DEBUG_QUIT:
+                break;
+
+        }
+#endif
+        /*
+         * Test; we must have a valid insertion point.
+         */
+        if (insert == NULL) {
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+            XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
+               "xsltApplySequenceConstructor: insert == NULL !\n"));
+#endif
+            goto error;
+        }
+
+#ifdef WITH_DEBUGGER
+        if ((ctxt->debugStatus != XSLT_DEBUG_NONE) && (debuggedNode != cur))
+            xslHandleDebugger(cur, contextNode, templ, ctxt);
+#endif
+
+#ifdef XSLT_REFACTORED
+       if (cur->type == XML_ELEMENT_NODE) {
+           info = (xsltStylePreCompPtr) cur->psvi;
+           /*
+           * We expect a compiled representation on:
+           * 1) XSLT instructions of this XSLT version (1.0)
+           *    (with a few exceptions)
+           * 2) Literal result elements
+           * 3) Extension instructions
+           * 4) XSLT instructions of future XSLT versions
+           *    (forwards-compatible mode).
+           */
+           if (info == NULL) {
+               /*
+               * Handle the rare cases where we don't expect a compiled
+               * representation on an XSLT element.
+               */
+               if (IS_XSLT_ELEM_FAST(cur) && IS_XSLT_NAME(cur, "message")) {
+                   xsltMessage(ctxt, contextNode, cur);
+                   goto skip_children;
+               }                                
+               /*
+               * Something really went wrong:
+               */
+               xsltTransformError(ctxt, NULL, cur,
+                   "Internal error in xsltApplySequenceConstructor(): "
+                   "The element '%s' in the stylesheet has no compiled "
+                   "representation.\n",
+                   cur->name);
+                goto skip_children;
+            }
+
+           if (info->type == XSLT_FUNC_LITERAL_RESULT_ELEMENT) {
+               xsltStyleItemLRElementInfoPtr lrInfo =
+                   (xsltStyleItemLRElementInfoPtr) info;
+               /*
+               * Literal result elements
+               * --------------------------------------------------------
+               */
+#ifdef WITH_XSLT_DEBUG_PROCESS
+               XSLT_TRACE(ctxt, XSLT_TRACE_APPLY_TEMPLATE,
+                   xsltGenericDebug(xsltGenericDebugContext,
+                   "xsltApplySequenceConstructor: copy literal result "
+                   "element '%s'\n", cur->name));
+#endif
+               /*
+               * Copy the raw element-node.
+               * OLD: if ((copy = xsltShallowCopyElem(ctxt, cur, insert))
+               *     == NULL)
+               *   goto error;
+               */              
+               copy = xmlDocCopyNode(cur, insert->doc, 0);
+               if (copy == NULL) {
+                   xsltTransformError(ctxt, NULL, cur,
+                       "Internal error in xsltApplySequenceConstructor(): "
+                       "Failed to copy literal result element '%s'.\n",
+                       cur->name);
+                   goto error;
+               } else {
+                   /*
+                   * Add the element-node to the result tree.
+                   */
+                   copy->doc = ctxt->output;
+                   xmlAddChild(insert, copy);
+                   /*
+                   * Create effective namespaces declarations.
+                   * OLD: xsltCopyNamespaceList(ctxt, copy, cur->nsDef);
+                   */
+                   if (lrInfo->effectiveNs != NULL) {
+                       xsltEffectiveNsPtr effNs = lrInfo->effectiveNs;
+                       xmlNsPtr ns, lastns = NULL;
+
+                       while (effNs != NULL) {
+                           /*
+                           * Avoid generating redundant namespace
+                           * declarations; thus lookup if there is already
+                           * such a ns-decl in the result.
+                           */                      
+                           ns = xmlSearchNs(copy->doc, copy, effNs->prefix);
+                           if ((ns != NULL) &&
+                               (xmlStrEqual(ns->href, effNs->nsName)))
+                           {
+                               effNs = effNs->next;
+                               continue;                           
+                           }
+                           ns = xmlNewNs(copy, effNs->nsName, effNs->prefix);
+                           if (ns == NULL) {
+                               xsltTransformError(ctxt, NULL, cur,
+                                   "Internal error in "
+                                   "xsltApplySequenceConstructor(): "
+                                   "Failed to copy a namespace "
+                                   "declaration.\n");
+                               goto error;
+                           }
+                                                               
+                           if (lastns == NULL)
+                               copy->nsDef = ns;
+                           else
+                               lastns->next =ns;
+                           lastns = ns;
+
+                           effNs = effNs->next;
+                       }
+                       
+                   }
+                   /*
+                   * NOTE that we don't need to apply ns-alising: this was
+                   *  already done at compile-time.
+                   */
+                   if (cur->ns != NULL) {
+                       /*
+                       * If there's no such ns-decl in the result tree,
+                       * then xsltGetSpecialNamespace() will
+                       * create a ns-decl on the copied node.
+                       */                      
+                       copy->ns = xsltGetSpecialNamespace(ctxt, cur,
+                           cur->ns->href, cur->ns->prefix, copy);                          
+                   } else {
+                       /*
+                       * Undeclare the default namespace if needed.
+                       * This can be skipped, if the result element has
+                       *  no ns-decls, in which case the result element
+                       *  obviously does not declare a default namespace;
+                       *  AND there's either no parent, or the parent
+                       *  element is in no namespace; this means there's no
+                       *  default namespace is scope to care about.
+                       *
+                       * REVISIT: This might result in massive
+                       *  generation of ns-decls if nodes in a default
+                       *  namespaces are mixed with nodes in no namespace.
+                       *  
+                       */
+                       if (copy->nsDef ||
+                           ((insert != NULL) &&
+                            (insert->type == XML_ELEMENT_NODE) &&
+                            (insert->ns != NULL)))
+                       {
+                           xsltGetSpecialNamespace(ctxt, cur,
+                               NULL, NULL, copy);
+                       }
+                   }
+               }
+               /*
+               * SPEC XSLT 2.0 "Each attribute of the literal result
+               *  element, other than an attribute in the XSLT namespace,
+               *  is processed to produce an attribute for the element in
+               *  the result tree."
+               * NOTE: See bug #341325.
+               */
+               if (cur->properties != NULL) {
+                   xsltAttrListTemplateProcess(ctxt, copy, cur->properties);
+               }
+           } else if (IS_XSLT_ELEM_FAST(cur)) {
+               /*
+               * XSLT instructions
+               * --------------------------------------------------------
+               */
+               if (info->type == XSLT_FUNC_UNKOWN_FORWARDS_COMPAT) {
+                   /*
+                   * We hit an unknown XSLT element.
+                   * Try to apply one of the fallback cases.
+                   */          
+                   ctxt->insert = insert;
+                   if (!xsltApplyFallbacks(ctxt, contextNode, cur)) {
+                       xsltTransformError(ctxt, NULL, cur,
+                           "The is no fallback behaviour defined for "
+                           "the unknown XSLT element '%s'.\n",
+                           cur->name);
+                   }                   
+                   ctxt->insert = oldInsert;
+               } else if (info->func != NULL) {
+                   /*
+                   * Execute the XSLT instruction.
+                   */
+                   ctxt->insert = insert;
+
+                   info->func(ctxt, contextNode, cur,
+                       (xsltElemPreCompPtr) info);
+
+                   /*
+                   * Cleanup temporary tree fragments.
+                   */
+                   if (oldLocalFragmentTop != ctxt->localRVT)
+                       xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
+
+                   ctxt->insert = oldInsert;
+               } else if (info->type == XSLT_FUNC_VARIABLE) {          
+                   xsltStackElemPtr tmpvar = ctxt->vars;
+               
+                   xsltParseStylesheetVariable(ctxt, cur);
+                   
+                   if (tmpvar != ctxt->vars) {
+                       /*
+                       * TODO: Using a @tmpvar is an annoying workaround, but
+                       *  the current mechanisms do not provide any other way
+                       *  of knowing if the var was really pushed onto the
+                       *  stack.
+                       */
+                       ctxt->vars->level = level;
+                   }
+               } else if (info->type == XSLT_FUNC_MESSAGE) {
+                   /*
+                   * TODO: Won't be hit, since we don't compile xsl:message.
+                   */
+                   xsltMessage(ctxt, contextNode, cur);
+               } else {
+                   xsltTransformError(ctxt, NULL, cur,
+                       "Unexpected XSLT element '%s'.\n", cur->name);                  
+               }
+               goto skip_children;
+
+           } else {
+               xsltTransformFunction func;
+               /*
+               * Extension intructions (elements)
+               * --------------------------------------------------------
+               */                              
+               if (cur->psvi == xsltExtMarker) {
+                   /*
+                   * The xsltExtMarker was set during the compilation
+                   * of extension instructions if there was no registered
+                   * handler for this specific extension function at
+                   * compile-time.
+                   * Libxslt will now lookup if a handler is
+                   * registered in the context of this transformation.
+                   */
+                   func = (xsltTransformFunction)
+                       xsltExtElementLookup(ctxt, cur->name, cur->ns->href);
+               } else
+                   func = ((xsltElemPreCompPtr) cur->psvi)->func;
+               
+               if (func == NULL) {
+                   /*
+                   * No handler available.
+                   * Try to execute fallback behaviour via xsl:fallback.
+                   */
+#ifdef WITH_XSLT_DEBUG_PROCESS
+                   XSLT_TRACE(ctxt, XSLT_TRACE_APPLY_TEMPLATE,
+                       xsltGenericDebug(xsltGenericDebugContext,
+                           "xsltApplySequenceConstructor: unknown extension %s\n",
+                           cur->name));
+#endif
+                   ctxt->insert = insert;
+                   if (!xsltApplyFallbacks(ctxt, contextNode, cur)) {
+                       xsltTransformError(ctxt, NULL, cur,
+                           "Unknown extension instruction '{%s}%s'.\n",
+                           cur->ns->href, cur->name);
+                   }                   
+                   ctxt->insert = oldInsert;               
+               } else {
+                   /*
+                   * Execute the handler-callback.
+                   */
+#ifdef WITH_XSLT_DEBUG_PROCESS
+                   XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
+                       "xsltApplySequenceConstructor: extension construct %s\n",
+                       cur->name));
+#endif             
+                   ctxt->insert = insert;
+                   /*
+                   * We need the fragment base for extension instructions
+                   * which return values (like EXSLT's function).
+                   */
+                   oldLocalFragmentBase = ctxt->localRVTBase;
+                   ctxt->localRVTBase = NULL;
+
+                   func(ctxt, contextNode, cur, cur->psvi);
+
+                   ctxt->localRVTBase = oldLocalFragmentBase;
+                   /*
+                   * Cleanup temporary tree fragments.
+                   */
+                   if (oldLocalFragmentTop != ctxt->localRVT)
+                       xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
+
+                   ctxt->insert = oldInsert;
+               }
+               goto skip_children;
+           }
+
+       } else if (XSLT_IS_TEXT_NODE(cur)) {
+           /*
+           * Text
+           * ------------------------------------------------------------
+           */
+#ifdef WITH_XSLT_DEBUG_PROCESS
+            if (cur->name == xmlStringTextNoenc) {
+                XSLT_TRACE(ctxt, XSLT_TRACE_APPLY_TEMPLATE,
+                   xsltGenericDebug(xsltGenericDebugContext,
+                   "xsltApplySequenceConstructor: copy unescaped text '%s'\n",
+                   cur->content));
+            } else {
+                XSLT_TRACE(ctxt, XSLT_TRACE_APPLY_TEMPLATE,
+                   xsltGenericDebug(xsltGenericDebugContext,
+                   "xsltApplySequenceConstructor: copy text '%s'\n",
+                   cur->content));
+            }
+#endif
+            if (xsltCopyText(ctxt, insert, cur, ctxt->internalized) == NULL)
+               goto error;         
+       }
+
+#else /* XSLT_REFACTORED */
+
+        if (IS_XSLT_ELEM(cur)) {
+            /*
+             * This is an XSLT node
+             */
+            xsltStylePreCompPtr info = (xsltStylePreCompPtr) cur->psvi;
+
+            if (info == NULL) {
+                if (IS_XSLT_NAME(cur, "message")) {
+                    xsltMessage(ctxt, contextNode, cur);
+                } else {                   
+                    /*
+                     * That's an error try to apply one of the fallback cases
+                     */
+                    ctxt->insert = insert;
+                    if (!xsltApplyFallbacks(ctxt, contextNode, cur)) {
+                        xsltGenericError(xsltGenericErrorContext,
+                           "xsltApplySequenceConstructor: %s was not compiled\n",
+                           cur->name);
+                    }
+                    ctxt->insert = oldInsert;
+                }
+                goto skip_children;
+            }      
+
+            if (info->func != NULL) {
+               oldCurInst = ctxt->inst;
+               ctxt->inst = cur;
+                ctxt->insert = insert;
+               oldLocalFragmentBase = ctxt->localRVTBase;
+               ctxt->localRVTBase = NULL;
+
+                info->func(ctxt, contextNode, cur, (xsltElemPreCompPtr) info);
+
+               ctxt->localRVTBase = oldLocalFragmentBase;
+               /*
+               * Cleanup temporary tree fragments.
+               */
+               if (oldLocalFragmentTop != ctxt->localRVT)
+                   xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
+
+                ctxt->insert = oldInsert;
+               ctxt->inst = oldCurInst;
+                goto skip_children;
+            }
+
+            if (IS_XSLT_NAME(cur, "variable")) {
+               xsltStackElemPtr tmpvar = ctxt->vars;
+               
+               oldCurInst = ctxt->inst;
+               ctxt->inst = cur;
+
+               xsltParseStylesheetVariable(ctxt, cur);
+
+               ctxt->inst = oldCurInst;
+               
+               if (tmpvar != ctxt->vars) {
+                   /*
+                   * TODO: Using a @tmpvar is an annoying workaround, but
+                   *  the current mechanisms do not provide any other way
+                   *  of knowing if the var was really pushed onto the
+                   *  stack.
+                   */
+                   ctxt->vars->level = level;
+               }
+            } else if (IS_XSLT_NAME(cur, "message")) {
+                xsltMessage(ctxt, contextNode, cur);
+            } else {
+               xsltTransformError(ctxt, NULL, cur,
+                   "Unexpected XSLT element '%s'.\n", cur->name);
+            }
+            goto skip_children;
+        } else if ((cur->type == XML_TEXT_NODE) ||
+                   (cur->type == XML_CDATA_SECTION_NODE)) {
+
+            /*
+             * This text comes from the stylesheet
+             * For stylesheets, the set of whitespace-preserving
+             * element names consists of just xsl:text.
+             */
+#ifdef WITH_XSLT_DEBUG_PROCESS
+            if (cur->type == XML_CDATA_SECTION_NODE) {
+                XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
+                                 "xsltApplySequenceConstructor: copy CDATA text %s\n",
+                                 cur->content));
+            } else if (cur->name == xmlStringTextNoenc) {
+                XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
+                                 "xsltApplySequenceConstructor: copy unescaped text %s\n",
+                                 cur->content));
+            } else {
+                XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
+                                 "xsltApplySequenceConstructor: copy text %s\n",
+                                 cur->content));
+            }
+#endif
+            if (xsltCopyText(ctxt, insert, cur, ctxt->internalized) == NULL)
+               goto error;
+        } else if ((cur->type == XML_ELEMENT_NODE) &&
+                   (cur->ns != NULL) && (cur->psvi != NULL)) {
+            xsltTransformFunction function;
+
+           oldCurInst = ctxt->inst;
+           ctxt->inst = cur;
+            /*
+             * Flagged as an extension element
+             */
+            if (cur->psvi == xsltExtMarker)
+                function = (xsltTransformFunction)
+                    xsltExtElementLookup(ctxt, cur->name, cur->ns->href);
+            else
+                function = ((xsltElemPreCompPtr) cur->psvi)->func;
+
+            if (function == NULL) {
+                xmlNodePtr child;
+                int found = 0;
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+                XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
+                   "xsltApplySequenceConstructor: unknown extension %s\n",
+                    cur->name));
+#endif
+                /*
+                 * Search if there are fallbacks
+                 */
+                child = cur->children;
+                while (child != NULL) {
+                    if ((IS_XSLT_ELEM(child)) &&
+                        (IS_XSLT_NAME(child, "fallback")))
+                   {
+                        found = 1;
+                        xsltApplySequenceConstructor(ctxt, contextNode,
+                           child->children, NULL);
+                    }
+                    child = child->next;
+                }
+
+                if (!found) {
+                    xsltTransformError(ctxt, NULL, cur,
+                       "xsltApplySequenceConstructor: failed to find extension %s\n",
+                       cur->name);
+                }
+            } else {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+                XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
+                   "xsltApplySequenceConstructor: extension construct %s\n",
+                    cur->name));
+#endif
+
+                ctxt->insert = insert;
+               /*
+               * We need the fragment base for extension instructions
+               * which return values (like EXSLT's function).
+               */
+               oldLocalFragmentBase = ctxt->localRVTBase;
+               ctxt->localRVTBase = NULL;
+
+                function(ctxt, contextNode, cur, cur->psvi);
+               /*
+               * Cleanup temporary tree fragments.
+               */
+               if (oldLocalFragmentTop != ctxt->localRVT)
+                   xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
+
+               ctxt->localRVTBase = oldLocalFragmentBase;
+                ctxt->insert = oldInsert;
+
+            }
+           ctxt->inst = oldCurInst;
+            goto skip_children;
+        } else if (cur->type == XML_ELEMENT_NODE) {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+            XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
+               "xsltApplySequenceConstructor: copy node %s\n",
+                cur->name));
+#endif
+           oldCurInst = ctxt->inst;
+           ctxt->inst = cur;
+
+            if ((copy = xsltShallowCopyElem(ctxt, cur, insert, 1)) == NULL)
+               goto error;            
+            /*
+             * Add extra namespaces inherited from the current template
+             * if we are in the first level children and this is a
+            * "real" template.      
+             */
+            if ((templ != NULL) && (oldInsert == insert) &&
+                (ctxt->templ != NULL) && (ctxt->templ->inheritedNs != NULL)) {
+                int i;
+                xmlNsPtr ns, ret;
+
+                for (i = 0; i < ctxt->templ->inheritedNsNr; i++) {
+                   const xmlChar *URI = NULL;
+                   xsltStylesheetPtr style;
+                    ns = ctxt->templ->inheritedNs[i];              
+                   
+                   /* Note that the XSLT namespace was already excluded
+                   * in xsltGetInheritedNsList().
+                   */
+#if 0
+                   if (xmlStrEqual(ns->href, XSLT_NAMESPACE))
+                       continue;
+#endif
+                   style = ctxt->style;
+                   while (style != NULL) {
+                       if (style->nsAliases != NULL)
+                           URI = (const xmlChar *) 
+                               xmlHashLookup(style->nsAliases, ns->href);
+                       if (URI != NULL)
+                           break;
+                       
+                       style = xsltNextImport(style);
+                   }
+                   if (URI == UNDEFINED_DEFAULT_NS)
+                       continue;
+                   if (URI == NULL)
+                       URI = ns->href;
+                   /*
+                   * TODO: The following will still be buggy for the
+                   * non-refactored code.
+                   */
+                   ret = xmlSearchNs(copy->doc, copy, ns->prefix);
+                   if ((ret == NULL) || (!xmlStrEqual(ret->href, URI)))
+                   {
+                       xmlNewNs(copy, URI, ns->prefix);
+                   }
+                }
+               if (copy->ns != NULL) {
+                   /*
+                    * Fix the node namespace if needed
+                    */
+                   copy->ns = xsltGetNamespace(ctxt, cur, copy->ns, copy);
+               }
+            }
+           /*
+             * all the attributes are directly inherited
+             */
+            if (cur->properties != NULL) {
+                xsltAttrListTemplateProcess(ctxt, copy, cur->properties);
+            }
+           ctxt->inst = oldCurInst;
+        }
+#endif /* else of XSLT_REFACTORED */
+
+        /*
+         * Descend into content in document order.
+         */
+        if (cur->children != NULL) {
+            if (cur->children->type != XML_ENTITY_DECL) {
+                cur = cur->children;
+               level++;
+                if (copy != NULL)
+                    insert = copy;
+                continue;
+            }
+        }
+
+skip_children:
+       /*
+       * If xslt:message was just processed, we might have hit a
+       * terminate='yes'; if so, then break the loop and clean up.
+       * TODO: Do we need to check this also before trying to descend
+       *  into the content?
+       */
+       if (ctxt->state == XSLT_STATE_STOPPED)
+           break;
+        if (cur->next != NULL) {
+            cur = cur->next;
+            continue;
+        }
+
+        do {
+            cur = cur->parent;
+           level--;
+           /*
+           * Pop variables/params (xsl:variable and xsl:param).
+           */
+           if ((ctxt->varsNr > oldVarsNr) && (ctxt->vars->level > level)) {
+               xsltLocalVariablePop(ctxt, oldVarsNr, level);           
+           }
+
+            insert = insert->parent;
+            if (cur == NULL)
+                break;
+            if (cur == list->parent) {
+                cur = NULL;
+                break;
+            }
+            if (cur->next != NULL) {
+                cur = cur->next;
+                break;
+            }
+        } while (cur != NULL);
+    }
+
+error:
+    /*
+    * In case of errors: pop remaining variables.
+    */
+    if (ctxt->varsNr > oldVarsNr)
+       xsltLocalVariablePop(ctxt, oldVarsNr, -1);     
+
+    ctxt->node = oldContextNode;
+    ctxt->inst = oldInst;
+    ctxt->insert = oldInsert;
+    
+#ifdef WITH_DEBUGGER
+    if ((ctxt->debugStatus != XSLT_DEBUG_NONE) && (addCallResult)) {
+        xslDropCall();
+    }
+#endif
+}
+
+/*
+* xsltApplyXSLTTemplate:
+* @ctxt:  a XSLT transformation context
+* @contextNode:  the node in the source tree.
+* @list:  the nodes of a sequence constructor;
+*         (plus leading xsl:param elements)
+* @templ: the compiled xsl:template declaration;
+*         NULL if a sequence constructor
+* @withParams:  a set of caller-parameters (xsl:with-param) or NULL
+*
+* Called by:
+* - xsltApplyImports()
+* - xsltCallTemplate()
+* - xsltDefaultProcessOneNode()
+* - xsltProcessOneNode()
+*/
+static void
+xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
+                     xmlNodePtr contextNode,
+                     xmlNodePtr list,
+                     xsltTemplatePtr templ,
+                     xsltStackElemPtr withParams)
+{
+    int oldVarsBase = 0;
+    long start = 0;
+    xmlNodePtr cur;
+    xsltStackElemPtr tmpParam = NULL;
+    xmlDocPtr oldUserFragmentTop, oldLocalFragmentTop;
+
+#ifdef XSLT_REFACTORED
+    xsltStyleItemParamPtr iparam;
+#else
+    xsltStylePreCompPtr iparam;
+#endif
+
+#ifdef WITH_DEBUGGER
+    int addCallResult = 0;
+#endif 
+
+    if (ctxt == NULL)
+       return;    
+    if (templ == NULL) {
+       xsltTransformError(ctxt, NULL, list,
+           "xsltApplyXSLTTemplate: Bad arguments; @templ is mandatory.\n");
+       return;
+    }
+
+#ifdef WITH_DEBUGGER
+    if (ctxt->debugStatus != XSLT_DEBUG_NONE) {
+       if (xsltDebuggerStartSequenceConstructor(ctxt, contextNode,
+               list, templ, &addCallResult) == NULL)
+           return;
+    }
+#endif
+
+    if (list == NULL)
+        return;
+    CHECK_STOPPED;
+
+    /*
+    * Check for infinite recursion: stop if the maximum of nested templates
+    * is excceeded. Adjust xsltMaxDepth if you need more.
+    */
+    if (((ctxt->templNr >= xsltMaxDepth) ||
+        (ctxt->varsNr >= 5 * xsltMaxDepth)))
+    {
+        xsltTransformError(ctxt, NULL, list,
+           "xsltApplyXSLTTemplate: A potential infinite template recursion "
+           "was detected.\n"
+           "You can adjust xsltMaxDepth (--maxdepth) in order to "
+           "raise the maximum number of nested template calls and "
+           "variables/params (currently set to %d).\n",
+           xsltMaxDepth);
+        xsltDebug(ctxt, contextNode, list, NULL);
+        return;
+    }
+    
+    oldUserFragmentTop = ctxt->tmpRVT;
+    ctxt->tmpRVT = NULL;
+    oldLocalFragmentTop = ctxt->localRVT;
+       
+    /*
+    * Initiate a distinct scope of local params/variables.
+    */
+    oldVarsBase = ctxt->varsBase;
+    ctxt->varsBase = ctxt->varsNr;
+    
+    ctxt->node = contextNode;
+    if (ctxt->profile) {
+       templ->nbCalls++;
+       start = xsltTimestamp();
+       profPush(ctxt, 0);
+    }
+    /*
+    * Push the xsl:template declaration onto the stack.
+    */
+    templPush(ctxt, templ);
+    
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    if (templ->name != NULL)
+       XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
+       "applying xsl:template '%s'\n", templ->name));
+#endif
+    /*
+    * Process xsl:param instructions and skip those elements for
+    * further processing.
+    */
+    cur = list;
+    do {
+       if (cur->type == XML_TEXT_NODE) {
+           cur = cur->next;
+           continue;
+       }
+       if ((cur->type != XML_ELEMENT_NODE) ||
+           (cur->name[0] != 'p') ||
+           (cur->psvi == NULL) ||
+           (! xmlStrEqual(cur->name, BAD_CAST "param")) ||
+           (! IS_XSLT_ELEM(cur)))
+       {
+           break;
+       }
+
+       list = cur->next;
+
+#ifdef XSLT_REFACTORED
+       iparam = (xsltStyleItemParamPtr) cur->psvi;
+#else
+       iparam = (xsltStylePreCompPtr) cur->psvi;
+#endif
+       
+       /*
+       * Substitute xsl:param for a given xsl:with-param.
+       * Since the XPath expression will reference the params/vars
+       * by index, we need to slot the xsl:with-params in the
+       * order of encountered xsl:params to keep the sequence of
+       * params/variables in the stack exactly as it was at
+       * compile time,
+       */
+       tmpParam = NULL;
+       if (withParams) {
+           tmpParam = withParams;
+           do {
+               if ((tmpParam->name == (iparam->name)) &&
+                   (tmpParam->nameURI == (iparam->ns)))
+               {
+                   /*
+                   * Push the caller-parameter.
+                   */              
+                   xsltLocalVariablePush(ctxt, tmpParam, -1);
+                   break;
+               }
+               tmpParam = tmpParam->next;
+           } while (tmpParam != NULL);
+       }
+       /*
+       * Push the xsl:param.
+       */
+       if (tmpParam == NULL) {
+           /*
+           * Note that we must assume that the added parameter
+           * has a @depth of 0.
+           */
+           xsltParseStylesheetParam(ctxt, cur);
+       }
+       cur = cur->next;
+    } while (cur != NULL);    
+    /*
+    * Process the sequence constructor.
+    */
+    xsltApplySequenceConstructor(ctxt, contextNode, list, templ);
+    
+    /*
+    * Remove remaining xsl:param and xsl:with-param items from
+    * the stack. Don't free xsl:with-param items.
+    */
+    if (ctxt->varsNr > ctxt->varsBase)
+       xsltTemplateParamsCleanup(ctxt);    
+    ctxt->varsBase = oldVarsBase;
+    
+    /*
+    * Clean up remaining local tree fragments.
+    * This also frees fragments which are the result of
+    * extension instructions. Should normally not be hit; but
+    * just for the case xsltExtensionInstructionResultFinalize()
+    * was not called by the extension author.
+    */
+    if (oldLocalFragmentTop != ctxt->localRVT) {
+       xmlDocPtr curdoc = ctxt->localRVT, tmp;
+
+       do {
+           tmp = curdoc;
+           curdoc = (xmlDocPtr) curdoc->next;
+           /* Need to housekeep localRVTBase */
+           if (tmp == ctxt->localRVTBase)
+               ctxt->localRVTBase = curdoc;
+           if (tmp->prev)
+               tmp->prev->next = (xmlNodePtr) curdoc;
+           if (curdoc)
+               curdoc->prev = tmp->prev;
+           xsltReleaseRVT(ctxt, tmp);
+       } while (curdoc != oldLocalFragmentTop);
+    }
+    ctxt->localRVT = oldLocalFragmentTop;
+
+    /*
+    * Release user-created fragments stored in the scope
+    * of xsl:template. Note that this mechanism is deprecated:
+    * user code should now use xsltRegisterLocalRVT() instead
+    * of the obsolete xsltRegisterTmpRVT().    
+    */
+    if (ctxt->tmpRVT) {
+       xmlDocPtr curdoc = ctxt->tmpRVT, tmp;
+
+       while (curdoc != NULL) {
+           tmp = curdoc;
+           curdoc = (xmlDocPtr) curdoc->next;
+           xsltReleaseRVT(ctxt, tmp);
+       }       
+    }
+    ctxt->tmpRVT = oldUserFragmentTop;    
+    
+    /*
+    * Pop the xsl:template declaration from the stack.
+    */
+    templPop(ctxt);    
+    if (ctxt->profile) {
+       long spent, child, total, end;
+       
+       end = xsltTimestamp();
+       child = profPop(ctxt);
+       total = end - start;
+       spent = total - child;
+       if (spent <= 0) {
+           /*
+           * Not possible unless the original calibration failed
+           * we can try to correct it on the fly.
+           */
+           xsltCalibrateAdjust(spent);
+           spent = 0;
+       }
+       
+       templ->time += spent;
+       if (ctxt->profNr > 0)
+           ctxt->profTab[ctxt->profNr - 1] += total;
+    }
+    
+#ifdef WITH_DEBUGGER
+    if ((ctxt->debugStatus != XSLT_DEBUG_NONE) && (addCallResult)) {
+        xslDropCall();
+    }
+#endif
+}
+
+
+/**
+ * xsltApplyOneTemplate:
+ * @ctxt:  a XSLT process context
+ * @contextNode:  the node in the source tree.
+ * @list:  the nodes of a sequence constructor
+ * @templ: not used
+ * @params:  a set of parameters (xsl:param) or NULL
+ *
+ * Processes a sequence constructor on the current node in the source tree.
+ *
+ * @params are the already computed variable stack items; this function
+ * pushes them on the variable stack, and pops them before exiting; it's
+ * left to the caller to free or reuse @params afterwards. The initial
+ * states of the variable stack will always be restored before this
+ * function exits.
+ * NOTE that this does *not* initiate a new distinct variable scope; i.e.
+ * variables already on the stack are visible to the process. The caller's
+ * side needs to start a new variable scope if needed (e.g. in exsl:function).
+ *
+ * @templ is obsolete and not used anymore (e.g. <exslt:function> does not
+ * provide a @templ); a non-NULL @templ might raise an error in the future.
+ *
+ * BIG NOTE: This function is not intended to process the content of an
+ * xsl:template; it does not expect xsl:param instructions in @list and
+ * will report errors if found.
+ *
+ * Called by:
+ *  - xsltEvalVariable() (variables.c)
+ *  - exsltFuncFunctionFunction() (libexsl/functions.c)
+ */
+void
+xsltApplyOneTemplate(xsltTransformContextPtr ctxt,
+                    xmlNodePtr contextNode,
+                     xmlNodePtr list,
+                    xsltTemplatePtr templ ATTRIBUTE_UNUSED,
+                     xsltStackElemPtr params)
+{
+    if ((ctxt == NULL) || (list == NULL))
+       return;
+    CHECK_STOPPED;
+
+    if (params) {
+       /*
+        * This code should be obsolete - was previously used
+        * by libexslt/functions.c, but due to bug 381319 the
+        * logic there was changed.
+        */
+       int oldVarsNr = ctxt->varsNr;
+
+       /*
+       * Push the given xsl:param(s) onto the variable stack.
+       */
+       while (params != NULL) {
+           xsltLocalVariablePush(ctxt, params, -1);
+           params = params->next;
+       }
+       xsltApplySequenceConstructor(ctxt, contextNode, list, templ);
+       /*
+       * Pop the given xsl:param(s) from the stack but don't free them.
+       */
+       xsltLocalVariablePop(ctxt, oldVarsNr, -2);
+    } else
+       xsltApplySequenceConstructor(ctxt, contextNode, list, templ);    
+}
+
+/************************************************************************
+ *                                                                     *
+ *                 XSLT-1.1 extensions                                 *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltDocumentElem:
+ * @ctxt:  an XSLT processing context
+ * @node:  The current node
+ * @inst:  the instruction in the stylesheet
+ * @castedComp:  precomputed information
+ *
+ * Process an EXSLT/XSLT-1.1 document element
+ */
+void
+xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                 xmlNodePtr inst, xsltStylePreCompPtr castedComp)
+{
+#ifdef XSLT_REFACTORED
+    xsltStyleItemDocumentPtr comp = (xsltStyleItemDocumentPtr) castedComp;
+#else
+    xsltStylePreCompPtr comp = castedComp;
+#endif
+    xsltStylesheetPtr style = NULL;
+    int ret;
+    xmlChar *filename = NULL, *prop, *elements;
+    xmlChar *element, *end;
+    xmlDocPtr res = NULL;
+    xmlDocPtr oldOutput;
+    xmlNodePtr oldInsert, root;
+    const char *oldOutputFile;
+    xsltOutputType oldType;
+    xmlChar *URL = NULL;
+    const xmlChar *method;
+    const xmlChar *doctypePublic;
+    const xmlChar *doctypeSystem;
+    const xmlChar *version;
+
+    if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL))
+        return;
+
+    if (comp->filename == NULL) {
+
+        if (xmlStrEqual(inst->name, (const xmlChar *) "output")) {
+           /*
+           * The element "output" is in the namespace XSLT_SAXON_NAMESPACE
+           *   (http://icl.com/saxon)
+           * The @file is in no namespace.
+           */
+#ifdef WITH_XSLT_DEBUG_EXTRA
+            xsltGenericDebug(xsltGenericDebugContext,
+                             "Found saxon:output extension\n");
+#endif
+            URL = xsltEvalAttrValueTemplate(ctxt, inst,
+                                                 (const xmlChar *) "file",
+                                                 XSLT_SAXON_NAMESPACE);
+            
+           if (URL == NULL)
+               URL = xsltEvalAttrValueTemplate(ctxt, inst,
+                                                 (const xmlChar *) "href",
+                                                 XSLT_SAXON_NAMESPACE);
+        } else if (xmlStrEqual(inst->name, (const xmlChar *) "write")) {
+#ifdef WITH_XSLT_DEBUG_EXTRA
+            xsltGenericDebug(xsltGenericDebugContext,
+                             "Found xalan:write extension\n");
+#endif
+            URL = xsltEvalAttrValueTemplate(ctxt, inst,
+                                                 (const xmlChar *)
+                                                 "select",
+                                                 XSLT_XALAN_NAMESPACE);
+           if (URL != NULL) {
+               xmlXPathCompExprPtr cmp;
+               xmlChar *val;
+
+               /*
+                * Trying to handle bug #59212
+                * The value of the "select" attribute is an
+                * XPath expression.
+                * (see http://xml.apache.org/xalan-j/extensionslib.html#redirect) 
+                */
+               cmp = xmlXPathCompile(URL);
+                val = xsltEvalXPathString(ctxt, cmp);
+               xmlXPathFreeCompExpr(cmp);
+               xmlFree(URL);
+               URL = val;
+           }
+           if (URL == NULL)
+               URL = xsltEvalAttrValueTemplate(ctxt, inst,
+                                                    (const xmlChar *)
+                                                    "file",
+                                                    XSLT_XALAN_NAMESPACE);
+           if (URL == NULL)
+               URL = xsltEvalAttrValueTemplate(ctxt, inst,
+                                                    (const xmlChar *)
+                                                    "href",
+                                                    XSLT_XALAN_NAMESPACE);
+        } else if (xmlStrEqual(inst->name, (const xmlChar *) "document")) {
+            URL = xsltEvalAttrValueTemplate(ctxt, inst,
+                                                 (const xmlChar *) "href",
+                                                 NULL);
+        }
+
+    } else {
+        URL = xmlStrdup(comp->filename);
+    }
+
+    if (URL == NULL) {
+       xsltTransformError(ctxt, NULL, inst,
+                        "xsltDocumentElem: href/URI-Reference not found\n");
+       return;
+    }
+
+    /*
+     * If the computation failed, it's likely that the URL wasn't escaped
+     */
+    filename = xmlBuildURI(URL, (const xmlChar *) ctxt->outputFile);
+    if (filename == NULL) {
+       xmlChar *escURL;
+
+       escURL=xmlURIEscapeStr(URL, BAD_CAST ":/.?,");
+       if (escURL != NULL) {
+           filename = xmlBuildURI(escURL, (const xmlChar *) ctxt->outputFile);
+           xmlFree(escURL);
+       }
+    }
+
+    if (filename == NULL) {
+       xsltTransformError(ctxt, NULL, inst,
+                        "xsltDocumentElem: URL computation failed for %s\n",
+                        URL);
+       xmlFree(URL);
+       return;
+    }
+
+    /*
+     * Security checking: can we write to this resource
+     */
+    if (ctxt->sec != NULL) {
+       ret = xsltCheckWrite(ctxt->sec, ctxt, filename);
+       if (ret == 0) {
+           xsltTransformError(ctxt, NULL, inst,
+                "xsltDocumentElem: write rights for %s denied\n",
+                            filename);
+           xmlFree(URL);
+           xmlFree(filename);
+           return;
+       }
+    }
+
+    oldOutputFile = ctxt->outputFile;
+    oldOutput = ctxt->output;
+    oldInsert = ctxt->insert;
+    oldType = ctxt->type;
+    ctxt->outputFile = (const char *) filename;
+
+    style = xsltNewStylesheet();
+    if (style == NULL) {
+       xsltTransformError(ctxt, NULL, inst,
+                         "xsltDocumentElem: out of memory\n");
+        goto error;
+    }
+
+    /*
+     * Version described in 1.1 draft allows full parameterization
+     * of the output.
+     */
+    prop = xsltEvalAttrValueTemplate(ctxt, inst,
+                                    (const xmlChar *) "version",
+                                    NULL);
+    if (prop != NULL) {
+       if (style->version != NULL)
+           xmlFree(style->version);
+       style->version = prop;
+    }
+    prop = xsltEvalAttrValueTemplate(ctxt, inst,
+                                    (const xmlChar *) "encoding",
+                                    NULL);
+    if (prop != NULL) {
+       if (style->encoding != NULL)
+           xmlFree(style->encoding);
+       style->encoding = prop;
+    }
+    prop = xsltEvalAttrValueTemplate(ctxt, inst,
+                                    (const xmlChar *) "method",
+                                    NULL);
+    if (prop != NULL) {
+       const xmlChar *URI;
+
+       if (style->method != NULL)
+           xmlFree(style->method);
+       style->method = NULL;
+       if (style->methodURI != NULL)
+           xmlFree(style->methodURI);
+       style->methodURI = NULL;
+
+       URI = xsltGetQNameURI(inst, &prop);
+       if (prop == NULL) {
+           if (style != NULL) style->errors++;
+       } else if (URI == NULL) {
+           if ((xmlStrEqual(prop, (const xmlChar *) "xml")) ||
+               (xmlStrEqual(prop, (const xmlChar *) "html")) ||
+               (xmlStrEqual(prop, (const xmlChar *) "text"))) {
+               style->method = prop;
+           } else {
+               xsltTransformError(ctxt, NULL, inst,
+                                "invalid value for method: %s\n", prop);
+               if (style != NULL) style->warnings++;
+           }
+       } else {
+           style->method = prop;
+           style->methodURI = xmlStrdup(URI);
+       }
+    }
+    prop = xsltEvalAttrValueTemplate(ctxt, inst,
+                                    (const xmlChar *)
+                                    "doctype-system", NULL);
+    if (prop != NULL) {
+       if (style->doctypeSystem != NULL)
+           xmlFree(style->doctypeSystem);
+       style->doctypeSystem = prop;
+    }
+    prop = xsltEvalAttrValueTemplate(ctxt, inst,
+                                    (const xmlChar *)
+                                    "doctype-public", NULL);
+    if (prop != NULL) {
+       if (style->doctypePublic != NULL)
+           xmlFree(style->doctypePublic);
+       style->doctypePublic = prop;
+    }
+    prop = xsltEvalAttrValueTemplate(ctxt, inst,
+                                    (const xmlChar *) "standalone",
+                                    NULL);
+    if (prop != NULL) {
+       if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
+           style->standalone = 1;
+       } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
+           style->standalone = 0;
+       } else {
+           xsltTransformError(ctxt, NULL, inst,
+                            "invalid value for standalone: %s\n",
+                            prop);
+           if (style != NULL) style->warnings++;
+       }
+       xmlFree(prop);
+    }
+
+    prop = xsltEvalAttrValueTemplate(ctxt, inst,
+                                    (const xmlChar *) "indent",
+                                    NULL);
+    if (prop != NULL) {
+       if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
+           style->indent = 1;
+       } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
+           style->indent = 0;
+       } else {
+           xsltTransformError(ctxt, NULL, inst,
+                            "invalid value for indent: %s\n", prop);
+           if (style != NULL) style->warnings++;
+       }
+       xmlFree(prop);
+    }
+
+    prop = xsltEvalAttrValueTemplate(ctxt, inst,
+                                    (const xmlChar *)
+                                    "omit-xml-declaration",
+                                    NULL);
+    if (prop != NULL) {
+       if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
+           style->omitXmlDeclaration = 1;
+       } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
+           style->omitXmlDeclaration = 0;
+       } else {
+           xsltTransformError(ctxt, NULL, inst,
+                            "invalid value for omit-xml-declaration: %s\n",
+                            prop);
+           if (style != NULL) style->warnings++;
+       }
+       xmlFree(prop);
+    }
+
+    elements = xsltEvalAttrValueTemplate(ctxt, inst,
+                                        (const xmlChar *)
+                                        "cdata-section-elements",
+                                        NULL);
+    if (elements != NULL) {
+       if (style->stripSpaces == NULL)
+           style->stripSpaces = xmlHashCreate(10);
+       if (style->stripSpaces == NULL)
+           return;
+
+       element = elements;
+       while (*element != 0) {
+           while (IS_BLANK_CH(*element))
+               element++;
+           if (*element == 0)
+               break;
+           end = element;
+           while ((*end != 0) && (!IS_BLANK_CH(*end)))
+               end++;
+           element = xmlStrndup(element, end - element);
+           if (element) {
+               const xmlChar *URI;
+
+#ifdef WITH_XSLT_DEBUG_PARSING
+               xsltGenericDebug(xsltGenericDebugContext,
+                                "add cdata section output element %s\n",
+                                element);
+#endif
+                URI = xsltGetQNameURI(inst, &element);
+
+               xmlHashAddEntry2(style->stripSpaces, element, URI,
+                               (xmlChar *) "cdata");
+               xmlFree(element);
+           }
+           element = end;
+       }
+       xmlFree(elements);
+    }
+
+    /*
+     * Create a new document tree and process the element template
+     */
+    XSLT_GET_IMPORT_PTR(method, style, method)
+    XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic)
+    XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem)
+    XSLT_GET_IMPORT_PTR(version, style, version)
+
+    if ((method != NULL) &&
+       (!xmlStrEqual(method, (const xmlChar *) "xml"))) {
+       if (xmlStrEqual(method, (const xmlChar *) "html")) {
+           ctxt->type = XSLT_OUTPUT_HTML;
+           if (((doctypePublic != NULL) || (doctypeSystem != NULL)))
+               res = htmlNewDoc(doctypeSystem, doctypePublic);
+           else {
+               if (version != NULL) {
+#ifdef XSLT_GENERATE_HTML_DOCTYPE
+                   xsltGetHTMLIDs(version, &doctypePublic, &doctypeSystem);
+#endif
+                }
+               res = htmlNewDocNoDtD(doctypeSystem, doctypePublic);
+           }
+           if (res == NULL)
+               goto error;
+           res->dict = ctxt->dict;
+           xmlDictReference(res->dict);
+       } else if (xmlStrEqual(method, (const xmlChar *) "xhtml")) {
+           xsltTransformError(ctxt, NULL, inst,
+            "xsltDocumentElem: unsupported method xhtml\n",
+                            style->method);
+           ctxt->type = XSLT_OUTPUT_HTML;
+           res = htmlNewDocNoDtD(doctypeSystem, doctypePublic);
+           if (res == NULL)
+               goto error;
+           res->dict = ctxt->dict;
+           xmlDictReference(res->dict);
+       } else if (xmlStrEqual(method, (const xmlChar *) "text")) {
+           ctxt->type = XSLT_OUTPUT_TEXT;
+           res = xmlNewDoc(style->version);
+           if (res == NULL)
+               goto error;
+           res->dict = ctxt->dict;
+           xmlDictReference(res->dict);
+#ifdef WITH_XSLT_DEBUG
+           xsltGenericDebug(xsltGenericDebugContext,
+                     "reusing transformation dict for output\n");
+#endif
+       } else {
+           xsltTransformError(ctxt, NULL, inst,
+                            "xsltDocumentElem: unsupported method %s\n",
+                            style->method);
+           goto error;
+       }
+    } else {
+       ctxt->type = XSLT_OUTPUT_XML;
+       res = xmlNewDoc(style->version);
+       if (res == NULL)
+           goto error;
+       res->dict = ctxt->dict;
+       xmlDictReference(res->dict);
+#ifdef WITH_XSLT_DEBUG
+       xsltGenericDebug(xsltGenericDebugContext,
+                     "reusing transformation dict for output\n");
+#endif
+    }
+    res->charset = XML_CHAR_ENCODING_UTF8;
+    if (style->encoding != NULL)
+       res->encoding = xmlStrdup(style->encoding);
+    ctxt->output = res;
+    ctxt->insert = (xmlNodePtr) res;
+    xsltApplySequenceConstructor(ctxt, node, inst->children, NULL);
+
+    /*
+     * Do some post processing work depending on the generated output
+     */
+    root = xmlDocGetRootElement(res);
+    if (root != NULL) {
+        const xmlChar *doctype = NULL;
+
+        if ((root->ns != NULL) && (root->ns->prefix != NULL))
+           doctype = xmlDictQLookup(ctxt->dict, root->ns->prefix, root->name);
+       if (doctype == NULL)
+           doctype = root->name;
+
+        /*
+         * Apply the default selection of the method
+         */
+        if ((method == NULL) &&
+            (root->ns == NULL) &&
+            (!xmlStrcasecmp(root->name, (const xmlChar *) "html"))) {
+            xmlNodePtr tmp;
+
+            tmp = res->children;
+            while ((tmp != NULL) && (tmp != root)) {
+                if (tmp->type == XML_ELEMENT_NODE)
+                    break;
+                if ((tmp->type == XML_TEXT_NODE) && (!xmlIsBlankNode(tmp)))
+                    break;
+               tmp = tmp->next;
+            }
+            if (tmp == root) {
+                ctxt->type = XSLT_OUTPUT_HTML;
+                res->type = XML_HTML_DOCUMENT_NODE;
+                if (((doctypePublic != NULL) || (doctypeSystem != NULL))) {
+                    res->intSubset = xmlCreateIntSubset(res, doctype,
+                                                        doctypePublic,
+                                                        doctypeSystem);
+#ifdef XSLT_GENERATE_HTML_DOCTYPE
+               } else if (version != NULL) {
+                    xsltGetHTMLIDs(version, &doctypePublic,
+                                   &doctypeSystem);
+                    if (((doctypePublic != NULL) || (doctypeSystem != NULL)))
+                        res->intSubset =
+                            xmlCreateIntSubset(res, doctype,
+                                               doctypePublic,
+                                               doctypeSystem);
+#endif
+                }
+            }
+
+        }
+        if (ctxt->type == XSLT_OUTPUT_XML) {
+            XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic)
+                XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem)
+                if (((doctypePublic != NULL) || (doctypeSystem != NULL)))
+                res->intSubset = xmlCreateIntSubset(res, doctype,
+                                                    doctypePublic,
+                                                    doctypeSystem);
+        }
+    }
+
+    /*
+     * Save the result
+     */
+    ret = xsltSaveResultToFilename((const char *) filename,
+                                   res, style, 0);
+    if (ret < 0) {
+       xsltTransformError(ctxt, NULL, inst,
+                         "xsltDocumentElem: unable to save to %s\n",
+                         filename);
+       ctxt->state = XSLT_STATE_ERROR;
+#ifdef WITH_XSLT_DEBUG_EXTRA
+    } else {
+        xsltGenericDebug(xsltGenericDebugContext,
+                         "Wrote %d bytes to %s\n", ret, filename);
+#endif
+    }
+
+  error:
+    ctxt->output = oldOutput;
+    ctxt->insert = oldInsert;
+    ctxt->type = oldType;
+    ctxt->outputFile = oldOutputFile;
+    if (URL != NULL)
+        xmlFree(URL);
+    if (filename != NULL)
+        xmlFree(filename);
+    if (style != NULL)
+        xsltFreeStylesheet(style);
+    if (res != NULL)
+        xmlFreeDoc(res);
+}
+
+/************************************************************************
+ *                                                                     *
+ *             Most of the XSLT-1.0 transformations                    *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltSort:
+ * @ctxt:  a XSLT process context
+ * @node:  the node in the source tree.
+ * @inst:  the xslt sort node
+ * @comp:  precomputed information
+ *
+ * function attached to xsl:sort nodes, but this should not be
+ * called directly
+ */
+void
+xsltSort(xsltTransformContextPtr ctxt,
+       xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr inst,
+       xsltStylePreCompPtr comp) {
+    if (comp == NULL) {
+       xsltTransformError(ctxt, NULL, inst,
+            "xsl:sort : compilation failed\n");
+       return;
+    }
+    xsltTransformError(ctxt, NULL, inst,
+        "xsl:sort : improper use this should not be reached\n");
+}
+
+/**
+ * xsltCopy:
+ * @ctxt:  an XSLT process context
+ * @node:  the node in the source tree
+ * @inst:  the element node of the XSLT-copy instruction
+ * @castedComp:  computed information of the XSLT-copy instruction
+ *
+ * Execute the XSLT-copy instruction on the source node.
+ */
+void
+xsltCopy(xsltTransformContextPtr ctxt, xmlNodePtr node,
+        xmlNodePtr inst, xsltStylePreCompPtr castedComp)
+{
+#ifdef XSLT_REFACTORED
+    xsltStyleItemCopyPtr comp = (xsltStyleItemCopyPtr) castedComp;
+#else
+    xsltStylePreCompPtr comp = castedComp;
+#endif
+    xmlNodePtr copy, oldInsert;
+   
+    oldInsert = ctxt->insert;
+    if (ctxt->insert != NULL) {
+       switch (node->type) {
+           case XML_TEXT_NODE:
+           case XML_CDATA_SECTION_NODE:
+               /*
+                * This text comes from the stylesheet
+                * For stylesheets, the set of whitespace-preserving
+                * element names consists of just xsl:text.
+                */
+#ifdef WITH_XSLT_DEBUG_PROCESS
+               if (node->type == XML_CDATA_SECTION_NODE) {
+                   XSLT_TRACE(ctxt,XSLT_TRACE_COPY,xsltGenericDebug(xsltGenericDebugContext,
+                        "xsltCopy: CDATA text %s\n", node->content));
+               } else {
+                   XSLT_TRACE(ctxt,XSLT_TRACE_COPY,xsltGenericDebug(xsltGenericDebugContext,
+                        "xsltCopy: text %s\n", node->content));
+                }
+#endif
+               xsltCopyText(ctxt, ctxt->insert, node, 0);
+               break;
+           case XML_DOCUMENT_NODE:
+           case XML_HTML_DOCUMENT_NODE:
+               break;
+           case XML_ELEMENT_NODE:
+               /*
+               * REVISIT NOTE: The "fake" is a doc-node, not an element node.
+               * REMOVED:
+               *   if (xmlStrEqual(node->name, BAD_CAST " fake node libxslt"))
+               *    return;
+               */              
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+               XSLT_TRACE(ctxt,XSLT_TRACE_COPY,xsltGenericDebug(xsltGenericDebugContext,
+                                "xsltCopy: node %s\n", node->name));
+#endif
+               copy = xsltShallowCopyElem(ctxt, node, ctxt->insert, 0);
+               ctxt->insert = copy;
+               if (comp->use != NULL) {
+                   xsltApplyAttributeSet(ctxt, node, inst, comp->use);
+               }
+               break;
+           case XML_ATTRIBUTE_NODE: {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+               XSLT_TRACE(ctxt,XSLT_TRACE_COPY,xsltGenericDebug(xsltGenericDebugContext,
+                                "xsltCopy: attribute %s\n", node->name));
+#endif
+               /*
+               * REVISIT: We could also raise an error if the parent is not
+               * an element node.
+               * OPTIMIZE TODO: Can we set the value/children of the
+               * attribute without an intermediate copy of the string value?
+               */
+               xsltShallowCopyAttr(ctxt, inst, ctxt->insert, (xmlAttrPtr) node);               
+               break;
+           }
+           case XML_PI_NODE:
+#ifdef WITH_XSLT_DEBUG_PROCESS
+               XSLT_TRACE(ctxt,XSLT_TRACE_COPY,xsltGenericDebug(xsltGenericDebugContext,
+                                "xsltCopy: PI %s\n", node->name));
+#endif
+               copy = xmlNewDocPI(ctxt->insert->doc, node->name,
+                                  node->content);
+               xmlAddChild(ctxt->insert, copy);
+               break;
+           case XML_COMMENT_NODE:
+#ifdef WITH_XSLT_DEBUG_PROCESS
+               XSLT_TRACE(ctxt,XSLT_TRACE_COPY,xsltGenericDebug(xsltGenericDebugContext,
+                                "xsltCopy: comment\n"));
+#endif
+               copy = xmlNewComment(node->content);
+               xmlAddChild(ctxt->insert, copy);
+               break;
+           case XML_NAMESPACE_DECL:
+#ifdef WITH_XSLT_DEBUG_PROCESS
+               XSLT_TRACE(ctxt,XSLT_TRACE_COPY,xsltGenericDebug(xsltGenericDebugContext,
+                                "xsltCopy: namespace declaration\n"));
+#endif         
+               xsltShallowCopyNsNode(ctxt, inst, ctxt->insert, (xmlNsPtr)node);                     
+               break;
+           default:
+               break;
+
+       }
+    }
+
+    switch (node->type) {
+       case XML_DOCUMENT_NODE:
+       case XML_HTML_DOCUMENT_NODE:
+       case XML_ELEMENT_NODE:
+           xsltApplySequenceConstructor(ctxt, ctxt->node, inst->children,
+               NULL);
+           break;
+       default:
+           break;
+    }
+    ctxt->insert = oldInsert;
+}
+
+/**
+ * xsltText:
+ * @ctxt:  a XSLT process context
+ * @node:  the node in the source tree.
+ * @inst:  the xslt text node
+ * @comp:  precomputed information
+ *
+ * Process the xslt text node on the source node
+ */
+void
+xsltText(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED,
+           xmlNodePtr inst, xsltStylePreCompPtr comp ATTRIBUTE_UNUSED) {
+    if ((inst->children != NULL) && (comp != NULL)) {
+       xmlNodePtr text = inst->children;
+       xmlNodePtr copy;
+
+       while (text != NULL) {
+           if ((text->type != XML_TEXT_NODE) &&
+                (text->type != XML_CDATA_SECTION_NODE)) {
+               xsltTransformError(ctxt, NULL, inst,
+                                "xsl:text content problem\n");
+               break;
+           }
+           copy = xmlNewDocText(ctxt->output, text->content);
+           if (text->type != XML_CDATA_SECTION_NODE) {
+#ifdef WITH_XSLT_DEBUG_PARSING
+               xsltGenericDebug(xsltGenericDebugContext,
+                    "Disable escaping: %s\n", text->content);
+#endif
+               copy->name = xmlStringTextNoenc;
+           }
+           xmlAddChild(ctxt->insert, copy);
+           text = text->next;
+       }
+    }
+}
+
+/**
+ * xsltElement:
+ * @ctxt:  a XSLT process context
+ * @node:  the node in the source tree.
+ * @inst:  the xslt element node
+ * @castedComp:  precomputed information
+ *
+ * Process the xslt element node on the source node
+ */
+void
+xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
+           xmlNodePtr inst, xsltStylePreCompPtr castedComp) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemElementPtr comp = (xsltStyleItemElementPtr) castedComp;
+#else
+    xsltStylePreCompPtr comp = castedComp;
+#endif
+    xmlChar *prop = NULL;
+    const xmlChar *name, *prefix = NULL, *nsName = NULL;    
+    xmlNodePtr copy;
+    xmlNodePtr oldInsert;
+
+    if (ctxt->insert == NULL)
+       return;
+
+    /* 
+    * A comp->has_name == 0 indicates that we need to skip this instruction,
+    * since it was evaluated to be invalid already during compilation.
+    */
+    if (!comp->has_name)
+        return;
+
+    /*
+     * stack and saves
+     */
+    oldInsert = ctxt->insert;
+
+    if (comp->name == NULL) {
+       /* TODO: fix attr acquisition wrt to the XSLT namespace */
+        prop = xsltEvalAttrValueTemplate(ctxt, inst,
+           (const xmlChar *) "name", XSLT_NAMESPACE);
+        if (prop == NULL) {
+            xsltTransformError(ctxt, NULL, inst,
+               "xsl:element: The attribute 'name' is missing.\n");
+            goto error;
+        }
+       if (xmlValidateQName(prop, 0)) {
+           xsltTransformError(ctxt, NULL, inst,
+               "xsl:element: The effective name '%s' is not a "
+               "valid QName.\n", prop);
+           /* we fall through to catch any further errors, if possible */
+       }
+       name = xsltSplitQName(ctxt->dict, prop, &prefix);
+       xmlFree(prop);
+       if ((prefix != NULL) &&
+           (!xmlStrncasecmp(prefix, (xmlChar *)"xml", 3)))
+       {
+           /*
+           * TODO: Should we really disallow an "xml" prefix?
+           */
+           goto error;
+       }
+    } else {
+       /*
+       * The "name" value was static.
+       */
+#ifdef XSLT_REFACTORED
+       prefix = comp->nsPrefix;
+       name = comp->name;
+#else  
+       name = xsltSplitQName(ctxt->dict, comp->name, &prefix);
+#endif
+    }
+    
+    /*
+     * Create the new element
+     */
+    if (ctxt->output->dict == ctxt->dict) {
+       copy = xmlNewDocNodeEatName(ctxt->output, NULL, (xmlChar *)name, NULL);
+    } else {
+       copy = xmlNewDocNode(ctxt->output, NULL, (xmlChar *)name, NULL);
+    }
+    if (copy == NULL) {
+       xsltTransformError(ctxt, NULL, inst,
+           "xsl:element : creation of %s failed\n", name);
+       return;
+    }
+    xmlAddChild(ctxt->insert, copy);    
+
+    /*
+    * Namespace
+    * ---------
+    */
+    if (comp->has_ns) {         
+       if (comp->ns != NULL) {
+           /*
+           * No AVT; just plain text for the namespace name.
+           */
+           if (comp->ns[0] != 0)
+               nsName = comp->ns;
+       } else {
+           xmlChar *tmpNsName;
+           /*
+           * Eval the AVT.
+           */
+           /* TODO: check attr acquisition wrt to the XSLT namespace */
+           tmpNsName = xsltEvalAttrValueTemplate(ctxt, inst,
+               (const xmlChar *) "namespace", XSLT_NAMESPACE); 
+           /*
+           * SPEC XSLT 1.0:
+           *  "If the string is empty, then the expanded-name of the
+           *  attribute has a null namespace URI."
+           */
+           if ((tmpNsName != NULL) && (tmpNsName[0] != 0))
+               nsName = xmlDictLookup(ctxt->dict, BAD_CAST tmpNsName, -1);
+           xmlFree(tmpNsName);         
+       };          
+    } else {
+       xmlNsPtr ns;
+       /*
+       * SPEC XSLT 1.0:
+       *  "If the namespace attribute is not present, then the QName is
+       *  expanded into an expanded-name using the namespace declarations
+       *  in effect for the xsl:element element, including any default
+       *  namespace declaration.
+       */      
+       ns = xmlSearchNs(inst->doc, inst, prefix);
+       if (ns == NULL) {
+           /*
+           * TODO: Check this in the compilation layer in case it's a
+           * static value.
+           */
+           if (prefix != NULL) {
+               xsltTransformError(ctxt, NULL, inst,
+                   "xsl:element: The QName '%s:%s' has no "
+                   "namespace binding in scope in the stylesheet; "
+                   "this is an error, since the namespace was not "
+                   "specified by the instruction itself.\n", prefix, name);
+           }
+       } else
+           nsName = ns->href;  
+    }
+    /*
+    * Find/create a matching ns-decl in the result tree.
+    */
+    if (nsName != NULL) {
+       copy->ns = xsltGetSpecialNamespace(ctxt, inst, nsName, prefix, copy);
+    } else if ((copy->parent != NULL) &&
+       (copy->parent->type == XML_ELEMENT_NODE) &&
+       (copy->parent->ns != NULL))
+    {
+       /*
+       * "Undeclare" the default namespace.
+       */
+       xsltGetSpecialNamespace(ctxt, inst, NULL, NULL, copy);
+    }
+
+    ctxt->insert = copy;
+
+    if (comp->has_use) {
+       if (comp->use != NULL) {
+           xsltApplyAttributeSet(ctxt, node, inst, comp->use);
+       } else {
+           xmlChar *attrSets = NULL;
+           /*
+           * BUG TODO: use-attribute-sets is not a value template.
+           *  use-attribute-sets = qnames
+           */
+           attrSets = xsltEvalAttrValueTemplate(ctxt, inst,
+               (const xmlChar *)"use-attribute-sets", NULL);
+           if (attrSets != NULL) {
+               xsltApplyAttributeSet(ctxt, node, inst, attrSets);
+               xmlFree(attrSets);
+           }
+       }
+    }
+    /*
+    * Instantiate the sequence constructor.
+    */
+    if (inst->children != NULL)
+       xsltApplySequenceConstructor(ctxt, ctxt->node, inst->children,
+           NULL);
+
+error:
+    ctxt->insert = oldInsert;
+    return;    
+}
+
+
+/**
+ * xsltComment:
+ * @ctxt:  a XSLT process context
+ * @node:  the node in the source tree.
+ * @inst:  the xslt comment node
+ * @comp:  precomputed information
+ *
+ * Process the xslt comment node on the source node
+ */
+void
+xsltComment(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                  xmlNodePtr inst, xsltStylePreCompPtr comp ATTRIBUTE_UNUSED) {
+    xmlChar *value = NULL;
+    xmlNodePtr commentNode;
+    int len;
+    
+    value = xsltEvalTemplateString(ctxt, node, inst);
+    /* TODO: use or generate the compiled form */
+    len = xmlStrlen(value);
+    if (len > 0) {
+        if ((value[len-1] == '-') || 
+           (xmlStrstr(value, BAD_CAST "--"))) {
+           xsltTransformError(ctxt, NULL, inst,
+                   "xsl:comment : '--' or ending '-' not allowed in comment\n");
+           /* fall through to try to catch further errors */
+       }
+    }
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    if (value == NULL) {
+       XSLT_TRACE(ctxt,XSLT_TRACE_COMMENT,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltComment: empty\n"));
+    } else {
+       XSLT_TRACE(ctxt,XSLT_TRACE_COMMENT,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltComment: content %s\n", value));
+    }
+#endif
+
+    commentNode = xmlNewComment(value);
+    xmlAddChild(ctxt->insert, commentNode);
+
+    if (value != NULL)
+       xmlFree(value);
+}
+
+/**
+ * xsltProcessingInstruction:
+ * @ctxt:  a XSLT process context
+ * @node:  the node in the source tree.
+ * @inst:  the xslt processing-instruction node
+ * @castedComp:  precomputed information
+ *
+ * Process the xslt processing-instruction node on the source node
+ */
+void
+xsltProcessingInstruction(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                  xmlNodePtr inst, xsltStylePreCompPtr castedComp) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemPIPtr comp = (xsltStyleItemPIPtr) castedComp;
+#else
+    xsltStylePreCompPtr comp = castedComp;
+#endif
+    const xmlChar *name;
+    xmlChar *value = NULL;
+    xmlNodePtr pi;
+
+
+    if (ctxt->insert == NULL)
+       return;
+    if (comp->has_name == 0)
+       return;
+    if (comp->name == NULL) {
+       name = xsltEvalAttrValueTemplate(ctxt, inst,
+                           (const xmlChar *)"name", NULL);
+       if (name == NULL) {
+           xsltTransformError(ctxt, NULL, inst,
+                "xsl:processing-instruction : name is missing\n");
+           goto error;
+       }
+    } else {
+       name = comp->name;
+    }
+    /* TODO: check that it's both an an NCName and a PITarget. */
+
+
+    value = xsltEvalTemplateString(ctxt, node, inst);
+    if (xmlStrstr(value, BAD_CAST "?>") != NULL) {
+       xsltTransformError(ctxt, NULL, inst,
+            "xsl:processing-instruction: '?>' not allowed within PI content\n");
+       goto error;
+    }
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    if (value == NULL) {
+       XSLT_TRACE(ctxt,XSLT_TRACE_PI,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltProcessingInstruction: %s empty\n", name));
+    } else {
+       XSLT_TRACE(ctxt,XSLT_TRACE_PI,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltProcessingInstruction: %s content %s\n", name, value));
+    }
+#endif
+
+    pi = xmlNewDocPI(ctxt->insert->doc, name, value);
+    xmlAddChild(ctxt->insert, pi);
+
+error:
+    if ((name != NULL) && (name != comp->name))
+        xmlFree((xmlChar *) name);
+    if (value != NULL)
+       xmlFree(value);
+}
+
+/**
+ * xsltCopyOf:
+ * @ctxt:  an XSLT transformation context
+ * @node:  the current node in the source tree
+ * @inst:  the element node of the XSLT copy-of instruction 
+ * @castedComp:  precomputed information of the XSLT copy-of instruction
+ *
+ * Process the XSLT copy-of instruction.
+ */
+void
+xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                  xmlNodePtr inst, xsltStylePreCompPtr castedComp) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemCopyOfPtr comp = (xsltStyleItemCopyOfPtr) castedComp;
+#else
+    xsltStylePreCompPtr comp = castedComp;
+#endif
+    xmlXPathObjectPtr res = NULL;
+    xmlNodeSetPtr list = NULL;
+    int i;
+    xmlDocPtr oldXPContextDoc;
+    xmlNsPtr *oldXPNamespaces;
+    xmlNodePtr oldXPContextNode;
+    int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
+    xmlXPathContextPtr xpctxt;
+
+    if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
+       return;
+    if ((comp == NULL) || (comp->select == NULL) || (comp->comp == NULL)) {
+       xsltTransformError(ctxt, NULL, inst,
+            "xsl:copy-of : compilation failed\n");
+       return;
+    }
+
+     /*
+    * SPEC XSLT 1.0:
+    *  "The xsl:copy-of element can be used to insert a result tree
+    *  fragment into the result tree, without first converting it to
+    *  a string as xsl:value-of does (see [7.6.1 Generating Text with
+    *  xsl:value-of]). The required select attribute contains an
+    *  expression. When the result of evaluating the expression is a
+    *  result tree fragment, the complete fragment is copied into the
+    *  result tree. When the result is a node-set, all the nodes in the
+    *  set are copied in document order into the result tree; copying
+    *  an element node copies the attribute nodes, namespace nodes and
+    *  children of the element node as well as the element node itself;
+    *  a root node is copied by copying its children. When the result
+    *  is neither a node-set nor a result tree fragment, the result is
+    *  converted to a string and then inserted into the result tree,
+    *  as with xsl:value-of.
+    */
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    XSLT_TRACE(ctxt,XSLT_TRACE_COPY_OF,xsltGenericDebug(xsltGenericDebugContext,
+        "xsltCopyOf: select %s\n", comp->select));
+#endif
+
+    /*
+    * Evaluate the "select" expression.
+    */
+    xpctxt = ctxt->xpathCtxt;
+    oldXPContextDoc = xpctxt->doc;
+    oldXPContextNode = xpctxt->node;
+    oldXPProximityPosition = xpctxt->proximityPosition;
+    oldXPContextSize = xpctxt->contextSize;
+    oldXPNsNr = xpctxt->nsNr;
+    oldXPNamespaces = xpctxt->namespaces;
+    
+    xpctxt->node = node;
+    if (comp != NULL) {
+
+#ifdef XSLT_REFACTORED
+       if (comp->inScopeNs != NULL) {
+           xpctxt->namespaces = comp->inScopeNs->list;
+           xpctxt->nsNr = comp->inScopeNs->xpathNumber;
+       } else {
+           xpctxt->namespaces = NULL;
+           xpctxt->nsNr = 0;
+       }
+#else
+       xpctxt->namespaces = comp->nsList;
+       xpctxt->nsNr = comp->nsNr;
+#endif
+    } else {
+       xpctxt->namespaces = NULL;
+       xpctxt->nsNr = 0;
+    }
+
+    res = xmlXPathCompiledEval(comp->comp, xpctxt);
+
+    xpctxt->doc = oldXPContextDoc;
+    xpctxt->node = oldXPContextNode;
+    xpctxt->contextSize = oldXPContextSize;
+    xpctxt->proximityPosition = oldXPProximityPosition;        
+    xpctxt->nsNr = oldXPNsNr;
+    xpctxt->namespaces = oldXPNamespaces;
+
+    if (res != NULL) {
+       if (res->type == XPATH_NODESET) {
+           /*
+           * Node-set
+           * --------
+           */
+#ifdef WITH_XSLT_DEBUG_PROCESS
+           XSLT_TRACE(ctxt,XSLT_TRACE_COPY_OF,xsltGenericDebug(xsltGenericDebugContext,
+                "xsltCopyOf: result is a node set\n"));
+#endif
+           list = res->nodesetval;
+           if (list != NULL) {
+               xmlNodePtr cur;
+               /*
+               * The list is already sorted in document order by XPath.
+               * Append everything in this order under ctxt->insert.
+               */
+               for (i = 0;i < list->nodeNr;i++) {
+                   cur = list->nodeTab[i];
+                   if (cur == NULL)
+                       continue;
+                   if ((cur->type == XML_DOCUMENT_NODE) ||
+                       (cur->type == XML_HTML_DOCUMENT_NODE))
+                   {
+                       xsltCopyTreeList(ctxt, inst,
+                           cur->children, ctxt->insert, 0, 0);
+                   } else if (cur->type == XML_ATTRIBUTE_NODE) {
+                       xsltShallowCopyAttr(ctxt, inst,
+                           ctxt->insert, (xmlAttrPtr) cur);
+                   } else {
+                       xsltCopyTreeInternal(ctxt, inst,
+                           cur, ctxt->insert, 0, 0);
+                   }
+               }
+           }
+       } else if (res->type == XPATH_XSLT_TREE) {
+           /*
+           * Result tree fragment
+           * --------------------
+           * E.g. via <xsl:variable ...><foo/></xsl:variable>
+           * Note that the root node of such trees is an xmlDocPtr in Libxslt.
+           */
+#ifdef WITH_XSLT_DEBUG_PROCESS
+           XSLT_TRACE(ctxt,XSLT_TRACE_COPY_OF,xsltGenericDebug(xsltGenericDebugContext,
+                "xsltCopyOf: result is a result tree fragment\n"));
+#endif     
+           list = res->nodesetval;
+           if ((list != NULL) && (list->nodeTab != NULL) &&
+               (list->nodeTab[0] != NULL) &&
+               (IS_XSLT_REAL_NODE(list->nodeTab[0])))
+           {
+               xsltCopyTreeList(ctxt, inst,
+                   list->nodeTab[0]->children, ctxt->insert, 0, 0);
+           }
+       } else {
+           xmlChar *value = NULL;
+           /*
+           * Convert to a string.
+           */
+           value = xmlXPathCastToString(res);
+           if (value == NULL) {
+               xsltTransformError(ctxt, NULL, inst,
+                   "Internal error in xsltCopyOf(): "
+                   "failed to cast an XPath object to string.\n");
+               ctxt->state = XSLT_STATE_STOPPED;
+           } else {
+               if (value[0] != 0) {
+                   /*
+                   * Append content as text node.
+                   */
+                   xsltCopyTextString(ctxt, ctxt->insert, value, 0);
+               }
+               xmlFree(value);
+               
+#ifdef WITH_XSLT_DEBUG_PROCESS
+               XSLT_TRACE(ctxt,XSLT_TRACE_COPY_OF,xsltGenericDebug(xsltGenericDebugContext,
+                   "xsltCopyOf: result %s\n", res->stringval));
+#endif
+           }
+       }
+    } else {
+       ctxt->state = XSLT_STATE_STOPPED;
+    }
+
+    if (res != NULL)
+       xmlXPathFreeObject(res);
+}
+
+/**
+ * xsltValueOf:
+ * @ctxt:  a XSLT process context
+ * @node:  the node in the source tree.
+ * @inst:  the xslt value-of node
+ * @castedComp:  precomputed information
+ *
+ * Process the xslt value-of node on the source node
+ */
+void
+xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                  xmlNodePtr inst, xsltStylePreCompPtr castedComp)
+{
+#ifdef XSLT_REFACTORED
+    xsltStyleItemValueOfPtr comp = (xsltStyleItemValueOfPtr) castedComp;
+#else
+    xsltStylePreCompPtr comp = castedComp;
+#endif
+    xmlXPathObjectPtr res = NULL;
+    xmlNodePtr copy = NULL;
+    xmlChar *value = NULL;
+    xmlDocPtr oldXPContextDoc;
+    xmlNsPtr *oldXPNamespaces;
+    xmlNodePtr oldXPContextNode;
+    int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
+    xmlXPathContextPtr xpctxt;
+
+    if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
+       return;
+
+    if ((comp == NULL) || (comp->select == NULL) || (comp->comp == NULL)) {
+       xsltTransformError(ctxt, NULL, inst,
+           "Internal error in xsltValueOf(): "
+           "The XSLT 'value-of' instruction was not compiled.\n");
+       return;
+    }
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    XSLT_TRACE(ctxt,XSLT_TRACE_VALUE_OF,xsltGenericDebug(xsltGenericDebugContext,
+        "xsltValueOf: select %s\n", comp->select));
+#endif
+
+    xpctxt = ctxt->xpathCtxt;
+    oldXPContextDoc = xpctxt->doc;
+    oldXPContextNode = xpctxt->node;
+    oldXPProximityPosition = xpctxt->proximityPosition;
+    oldXPContextSize = xpctxt->contextSize;
+    oldXPNsNr = xpctxt->nsNr;
+    oldXPNamespaces = xpctxt->namespaces;
+    
+    xpctxt->node = node;
+    if (comp != NULL) {
+
+#ifdef XSLT_REFACTORED
+       if (comp->inScopeNs != NULL) {
+           xpctxt->namespaces = comp->inScopeNs->list;
+           xpctxt->nsNr = comp->inScopeNs->xpathNumber;
+       } else {
+           xpctxt->namespaces = NULL;
+           xpctxt->nsNr = 0;
+       }
+#else
+       xpctxt->namespaces = comp->nsList;
+       xpctxt->nsNr = comp->nsNr;
+#endif
+    } else {
+       xpctxt->namespaces = NULL;
+       xpctxt->nsNr = 0;
+    }
+
+    res = xmlXPathCompiledEval(comp->comp, xpctxt);
+
+    xpctxt->doc = oldXPContextDoc;
+    xpctxt->node = oldXPContextNode;
+    xpctxt->contextSize = oldXPContextSize;
+    xpctxt->proximityPosition = oldXPProximityPosition;        
+    xpctxt->nsNr = oldXPNsNr;
+    xpctxt->namespaces = oldXPNamespaces;
+
+    /*
+    * Cast the XPath object to string.
+    */
+    if (res != NULL) {
+       value = xmlXPathCastToString(res);
+       if (value == NULL) {
+           xsltTransformError(ctxt, NULL, inst,
+               "Internal error in xsltValueOf(): "
+               "failed to cast an XPath object to string.\n");
+           ctxt->state = XSLT_STATE_STOPPED;
+           goto error;
+       }
+       if (value[0] != 0) {
+           copy = xsltCopyTextString(ctxt,
+               ctxt->insert, value, comp->noescape);
+       }
+    } else {
+       xsltTransformError(ctxt, NULL, inst,        
+           "XPath evaluation returned no result.\n");
+       ctxt->state = XSLT_STATE_STOPPED;
+       goto error;     
+    }
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    if (value) {    
+       XSLT_TRACE(ctxt,XSLT_TRACE_VALUE_OF,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltValueOf: result '%s'\n", value));
+    }
+#endif
+
+error:
+    if (value != NULL)
+       xmlFree(value);
+    if (res != NULL)
+       xmlXPathFreeObject(res);
+}
+
+/**
+ * xsltNumber:
+ * @ctxt:  a XSLT process context
+ * @node:  the node in the source tree.
+ * @inst:  the xslt number node
+ * @castedComp:  precomputed information
+ *
+ * Process the xslt number node on the source node
+ */
+void
+xsltNumber(xsltTransformContextPtr ctxt, xmlNodePtr node,
+          xmlNodePtr inst, xsltStylePreCompPtr castedComp)
+{
+#ifdef XSLT_REFACTORED
+    xsltStyleItemNumberPtr comp = (xsltStyleItemNumberPtr) castedComp;
+#else
+    xsltStylePreCompPtr comp = castedComp;
+#endif
+    if (comp == NULL) {
+       xsltTransformError(ctxt, NULL, inst,
+            "xsl:number : compilation failed\n");
+       return;
+    }
+
+    if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL))
+       return;
+
+    comp->numdata.doc = inst->doc;
+    comp->numdata.node = inst;
+    
+    xsltNumberFormat(ctxt, &comp->numdata, node);
+}
+
+/**
+ * xsltApplyImports:
+ * @ctxt:  an XSLT transformation context
+ * @contextNode:  the current node in the source tree.
+ * @inst:  the element node of the XSLT 'apply-imports' instruction
+ * @comp:  the compiled instruction
+ *
+ * Process the XSLT apply-imports element.
+ */
+void
+xsltApplyImports(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
+                xmlNodePtr inst,
+                xsltStylePreCompPtr comp ATTRIBUTE_UNUSED)
+{
+    xsltTemplatePtr templ;
+
+    if ((ctxt == NULL) || (inst == NULL))
+       return;
+
+    if (comp == NULL) {
+       xsltTransformError(ctxt, NULL, inst,
+           "Internal error in xsltApplyImports(): "
+           "The XSLT 'apply-imports' instruction was not compiled.\n");
+       return;
+    }
+    /*
+    * NOTE that ctxt->currentTemplateRule and ctxt->templ is not the
+    * same; the former is the "Current Template Rule" as defined by the
+    * XSLT spec, the latter is simply the template struct being
+    * currently processed.
+    */
+    if (ctxt->currentTemplateRule == NULL) {
+       /*
+       * SPEC XSLT 2.0:
+       * "[ERR XTDE0560] It is a non-recoverable dynamic error if
+       *  xsl:apply-imports or xsl:next-match is evaluated when the
+       *  current template rule is null."
+       */
+       xsltTransformError(ctxt, NULL, inst,
+            "It is an error to call 'apply-imports' "
+            "when there's no current template rule.\n");
+       return;
+    }
+    /*
+    * TODO: Check if this is correct.
+    */
+    templ = xsltGetTemplate(ctxt, contextNode,
+       ctxt->currentTemplateRule->style);
+
+    if (templ != NULL) {
+       xsltTemplatePtr oldCurTemplRule = ctxt->currentTemplateRule;
+       /*
+       * Set the current template rule.
+       */
+       ctxt->currentTemplateRule = templ;
+       /*
+       * URGENT TODO: Need xsl:with-param be handled somehow here?
+       */
+       xsltApplyXSLTTemplate(ctxt, contextNode, templ->content,
+           templ, NULL);
+
+       ctxt->currentTemplateRule = oldCurTemplRule;
+    }
+}
+
+/**
+ * xsltCallTemplate:
+ * @ctxt:  a XSLT transformation context
+ * @node:  the "current node" in the source tree
+ * @inst:  the XSLT 'call-template' instruction
+ * @castedComp:  the compiled information of the instruction
+ *
+ * Processes the XSLT call-template instruction on the source node.
+ */
+void
+xsltCallTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                  xmlNodePtr inst, xsltStylePreCompPtr castedComp)
+{
+#ifdef XSLT_REFACTORED
+    xsltStyleItemCallTemplatePtr comp =
+       (xsltStyleItemCallTemplatePtr) castedComp;
+#else
+    xsltStylePreCompPtr comp = castedComp;
+#endif
+    xsltStackElemPtr withParams = NULL;
+
+    if (ctxt->insert == NULL)
+       return;
+    if (comp == NULL) {
+       xsltTransformError(ctxt, NULL, inst,
+            "The XSLT 'call-template' instruction was not compiled.\n");
+       return;
+    }
+
+    /*
+     * The template must have been precomputed
+     */
+    if (comp->templ == NULL) {
+       comp->templ = xsltFindTemplate(ctxt, comp->name, comp->ns);
+       if (comp->templ == NULL) {
+           if (comp->ns != NULL) {
+               xsltTransformError(ctxt, NULL, inst,
+                       "The called template '{%s}%s' was not found.\n",
+                       comp->ns, comp->name);
+           } else {
+               xsltTransformError(ctxt, NULL, inst,
+                       "The called template '%s' was not found.\n",
+                       comp->name);
+           }
+           return;
+       }
+    }
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    if ((comp != NULL) && (comp->name != NULL))
+       XSLT_TRACE(ctxt,XSLT_TRACE_CALL_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
+                        "call-template: name %s\n", comp->name));
+#endif
+
+    if (inst->children) {
+       xmlNodePtr cur;
+       xsltStackElemPtr param;
+
+       cur = inst->children;
+       while (cur != NULL) {
+#ifdef WITH_DEBUGGER
+           if (ctxt->debugStatus != XSLT_DEBUG_NONE)
+               xslHandleDebugger(cur, node, comp->templ, ctxt);
+#endif
+           if (ctxt->state == XSLT_STATE_STOPPED) break;
+           /*
+           * TODO: The "with-param"s could be part of the "call-template"
+           *   structure. Avoid to "search" for params dynamically
+           *   in the XML tree every time.
+           */
+           if (IS_XSLT_ELEM(cur)) {
+               if (IS_XSLT_NAME(cur, "with-param")) {
+                   param = xsltParseStylesheetCallerParam(ctxt, cur);
+                   if (param != NULL) {
+                       param->next = withParams;
+                       withParams = param;
+                   }
+               } else {
+                   xsltGenericError(xsltGenericErrorContext,
+                       "xsl:call-template: misplaced xsl:%s\n", cur->name);
+               }
+           } else {
+               xsltGenericError(xsltGenericErrorContext,
+                   "xsl:call-template: misplaced %s element\n", cur->name);
+           }
+           cur = cur->next;
+       }
+    }
+    /*
+     * Create a new frame using the params first     
+     */
+    xsltApplyXSLTTemplate(ctxt, node, comp->templ->content, comp->templ,
+       withParams);
+    if (withParams != NULL)
+       xsltFreeStackElemList(withParams);
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    if ((comp != NULL) && (comp->name != NULL))
+       XSLT_TRACE(ctxt,XSLT_TRACE_CALL_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
+                        "call-template returned: name %s\n", comp->name));
+#endif
+}
+
+/**
+ * xsltApplyTemplates:
+ * @ctxt:  a XSLT transformation context
+ * @node:  the 'current node' in the source tree
+ * @inst:  the element node of an XSLT 'apply-templates' instruction
+ * @castedComp:  the compiled instruction
+ *
+ * Processes the XSLT 'apply-templates' instruction on the current node.
+ */
+void
+xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                  xmlNodePtr inst, xsltStylePreCompPtr castedComp)
+{
+#ifdef XSLT_REFACTORED
+    xsltStyleItemApplyTemplatesPtr comp =
+       (xsltStyleItemApplyTemplatesPtr) castedComp;
+#else
+    xsltStylePreCompPtr comp = castedComp;
+#endif
+    int i;
+    xmlNodePtr cur, delNode = NULL, oldContextNode;    
+    xmlNodeSetPtr list = NULL, oldList;
+    xsltStackElemPtr withParams = NULL;
+    int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
+    const xmlChar *oldMode, *oldModeURI;
+    xmlDocPtr oldXPDoc;
+    xsltDocumentPtr oldDocInfo;
+    xmlXPathContextPtr xpctxt;
+    xmlNsPtr *oldXPNamespaces;
+
+    if (comp == NULL) {
+       xsltTransformError(ctxt, NULL, inst,
+            "xsl:apply-templates : compilation failed\n");
+       return;
+    }
+    if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL))
+       return;
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    if ((node != NULL) && (node->name != NULL))
+       XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATES,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltApplyTemplates: node: '%s'\n", node->name));
+#endif
+
+    xpctxt = ctxt->xpathCtxt;   
+    /*
+    * Save context states.
+    */
+    oldContextNode = ctxt->node;
+    oldMode = ctxt->mode;
+    oldModeURI = ctxt->modeURI;    
+    oldDocInfo = ctxt->document;
+    oldList = ctxt->nodeList;    
+
+    /*
+     * The xpath context size and proximity position, as
+     * well as the xpath and context documents, may be changed
+     * so we save their initial state and will restore on exit
+     */    
+    oldXPContextSize = xpctxt->contextSize;
+    oldXPProximityPosition = xpctxt->proximityPosition;
+    oldXPDoc = xpctxt->doc;
+    oldXPNsNr = xpctxt->nsNr;
+    oldXPNamespaces = xpctxt->namespaces;
+
+    /*
+    * Set up contexts.
+    */
+    ctxt->mode = comp->mode;
+    ctxt->modeURI = comp->modeURI;
+
+    if (comp->select != NULL) {        
+       xmlXPathObjectPtr res = NULL;
+
+       if (comp->comp == NULL) {
+           xsltTransformError(ctxt, NULL, inst,
+                "xsl:apply-templates : compilation failed\n");
+           goto error;
+       }
+#ifdef WITH_XSLT_DEBUG_PROCESS
+       XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATES,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltApplyTemplates: select %s\n", comp->select));
+#endif
+
+       /*
+       * Set up XPath.
+       */
+       xpctxt->node = node; /* Set the "context node" */
+#ifdef XSLT_REFACTORED
+       if (comp->inScopeNs != NULL) {
+           xpctxt->namespaces = comp->inScopeNs->list;
+           xpctxt->nsNr = comp->inScopeNs->xpathNumber;
+       } else {
+           xpctxt->namespaces = NULL;
+           xpctxt->nsNr = 0;
+       }
+#else
+       xpctxt->namespaces = comp->nsList;
+       xpctxt->nsNr = comp->nsNr;
+#endif
+       res = xmlXPathCompiledEval(comp->comp, xpctxt);
+
+       xpctxt->contextSize = oldXPContextSize;
+       xpctxt->proximityPosition = oldXPProximityPosition;
+       if (res != NULL) {
+           if (res->type == XPATH_NODESET) {
+               list = res->nodesetval; /* consume the node set */
+               res->nodesetval = NULL; 
+           } else {
+               xsltTransformError(ctxt, NULL, inst,
+                   "The 'select' expression did not evaluate to a "
+                   "node set.\n");
+               ctxt->state = XSLT_STATE_STOPPED;
+               xmlXPathFreeObject(res);
+               goto error;
+           }
+           xmlXPathFreeObject(res);
+           /*
+           * Note: An xsl:apply-templates with a 'select' attribute,
+           * can change the current source doc.
+           */      
+       } else {
+           xsltTransformError(ctxt, NULL, inst,
+               "Failed to evaluate the 'select' expression.\n");
+           ctxt->state = XSLT_STATE_STOPPED;
+           goto error;
+       }          
+       if (list == NULL) {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+           XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATES,xsltGenericDebug(xsltGenericDebugContext,
+               "xsltApplyTemplates: select didn't evaluate to a node list\n"));
+#endif
+           goto exit;
+       }
+       /*
+       * 
+       * NOTE: Previously a document info (xsltDocument) was
+       * created and attached to the Result Tree Fragment.
+       * But such a document info is created on demand in
+       * xsltKeyFunction() (functions.c), so we need to create
+       * it here beforehand.
+       * In order to take care of potential keys we need to
+       * do some extra work for the case when a Result Tree Fragment
+       * is converted into a nodeset (e.g. exslt:node-set()) :
+       * We attach a "pseudo-doc" (xsltDocument) to _private.          
+       * This xsltDocument, together with the keyset, will be freed
+       * when the Result Tree Fragment is freed.
+       *               
+       */
+#if 0
+       if ((ctxt->nbKeys > 0) &&
+           (list->nodeNr != 0) &&                  
+           (list->nodeTab[0]->doc != NULL) &&
+           XSLT_IS_RES_TREE_FRAG(list->nodeTab[0]->doc))
+       {
+           /*
+           * NOTE that it's also OK if @effectiveDocInfo will be
+           * set to NULL.
+           */
+           isRTF = 1;
+           effectiveDocInfo = list->nodeTab[0]->doc->_private;
+       }
+#endif
+    } else {
+       /*
+        * Build an XPath node set with the children
+        */
+       list = xmlXPathNodeSetCreate(NULL);
+       if (list == NULL)
+           goto error;
+       cur = node->children;
+       while (cur != NULL) {
+           switch (cur->type) {
+               case XML_TEXT_NODE:
+                   if ((IS_BLANK_NODE(cur)) &&
+                       (cur->parent != NULL) &&
+                       (cur->parent->type == XML_ELEMENT_NODE) &&
+                       (ctxt->style->stripSpaces != NULL)) {
+                       const xmlChar *val;
+
+                       if (cur->parent->ns != NULL) {
+                           val = (const xmlChar *)
+                                 xmlHashLookup2(ctxt->style->stripSpaces,
+                                                cur->parent->name,
+                                                cur->parent->ns->href);
+                           if (val == NULL) {
+                               val = (const xmlChar *)
+                                 xmlHashLookup2(ctxt->style->stripSpaces,
+                                                BAD_CAST "*",
+                                                cur->parent->ns->href);
+                           }
+                       } else {
+                           val = (const xmlChar *)
+                                 xmlHashLookup2(ctxt->style->stripSpaces,
+                                                cur->parent->name, NULL);
+                       }
+                       if ((val != NULL) &&
+                           (xmlStrEqual(val, (xmlChar *) "strip"))) {
+                           delNode = cur;
+                           break;
+                       }
+                   }
+                   /* no break on purpose */
+               case XML_ELEMENT_NODE:
+               case XML_DOCUMENT_NODE:
+               case XML_HTML_DOCUMENT_NODE:
+               case XML_CDATA_SECTION_NODE:
+               case XML_PI_NODE:
+               case XML_COMMENT_NODE:
+                   xmlXPathNodeSetAddUnique(list, cur);
+                   break;
+               case XML_DTD_NODE:
+                   /* Unlink the DTD, it's still reachable
+                    * using doc->intSubset */
+                   if (cur->next != NULL)
+                       cur->next->prev = cur->prev;
+                   if (cur->prev != NULL)
+                       cur->prev->next = cur->next;
+                   break;
+               default:
+#ifdef WITH_XSLT_DEBUG_PROCESS
+                   XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATES,xsltGenericDebug(xsltGenericDebugContext,
+                    "xsltApplyTemplates: skipping cur type %d\n",
+                                    cur->type));
+#endif
+                   delNode = cur;
+           }
+           cur = cur->next;
+           if (delNode != NULL) {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+               XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATES,xsltGenericDebug(xsltGenericDebugContext,
+                    "xsltApplyTemplates: removing ignorable blank cur\n"));
+#endif
+               xmlUnlinkNode(delNode);
+               xmlFreeNode(delNode);
+               delNode = NULL;
+           }
+       }
+    }
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    if (list != NULL)
+    XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATES,xsltGenericDebug(xsltGenericDebugContext,
+       "xsltApplyTemplates: list of %d nodes\n", list->nodeNr));
+#endif
+
+    if ((list == NULL) || (list->nodeNr == 0))
+       goto exit;
+
+    /*
+    * Set the context's node set and size; this is also needed for
+    * for xsltDoSortFunction().
+    */
+    ctxt->nodeList = list;
+    /* 
+    * Process xsl:with-param and xsl:sort instructions.
+    * (The code became so verbose just to avoid the
+    *  xmlNodePtr sorts[XSLT_MAX_SORT] if there's no xsl:sort)
+    * BUG TODO: We are not using namespaced potentially defined on the
+    * xsl:sort or xsl:with-param elements; XPath expression might fail.
+    */
+    if (inst->children) {
+       xsltStackElemPtr param;
+
+       cur = inst->children;
+       while (cur) {
+
+#ifdef WITH_DEBUGGER
+           if (ctxt->debugStatus != XSLT_DEBUG_NONE)
+               xslHandleDebugger(cur, node, NULL, ctxt);
+#endif
+           if (ctxt->state == XSLT_STATE_STOPPED)
+               break;
+           if (cur->type == XML_TEXT_NODE) {
+               cur = cur->next;
+               continue;
+           }       
+           if (! IS_XSLT_ELEM(cur))
+               break;
+           if (IS_XSLT_NAME(cur, "with-param")) {
+               param = xsltParseStylesheetCallerParam(ctxt, cur);
+               if (param != NULL) {
+                   param->next = withParams;
+                   withParams = param;
+               }
+           }
+           if (IS_XSLT_NAME(cur, "sort")) {
+               xsltTemplatePtr oldCurTempRule =
+                   ctxt->currentTemplateRule;
+               int nbsorts = 0;
+               xmlNodePtr sorts[XSLT_MAX_SORT];                
+               
+               sorts[nbsorts++] = cur;
+               
+               while (cur) {
+                   
+#ifdef WITH_DEBUGGER
+                   if (ctxt->debugStatus != XSLT_DEBUG_NONE)
+                       xslHandleDebugger(cur, node, NULL, ctxt);
+#endif
+                   if (ctxt->state == XSLT_STATE_STOPPED)
+                       break;
+                   
+                   if (cur->type == XML_TEXT_NODE) {
+                       cur = cur->next;
+                       continue;
+                   }
+                   
+                   if (! IS_XSLT_ELEM(cur))
+                       break;
+                   if (IS_XSLT_NAME(cur, "with-param")) {
+                       param = xsltParseStylesheetCallerParam(ctxt, cur);
+                       if (param != NULL) {
+                           param->next = withParams;
+                           withParams = param;
+                       }
+                   }   
+                   if (IS_XSLT_NAME(cur, "sort")) {
+                       if (nbsorts >= XSLT_MAX_SORT) {
+                           xsltTransformError(ctxt, NULL, cur,
+                               "The number (%d) of xsl:sort instructions exceeds the "
+                               "maximum allowed by this processor's settings.\n",
+                               nbsorts);
+                           ctxt->state = XSLT_STATE_STOPPED;
+                           break;
+                       } else {
+                           sorts[nbsorts++] = cur;
+                       }
+                   }
+                   cur = cur->next;
+               }
+               /*
+               * The "current template rule" is cleared for xsl:sort.
+               */
+               ctxt->currentTemplateRule = NULL;
+               /*
+               * Sort.
+               */
+               xsltDoSortFunction(ctxt, sorts, nbsorts);
+               ctxt->currentTemplateRule = oldCurTempRule;
+               break;
+           }
+           cur = cur->next;
+       }
+    }    
+    xpctxt->contextSize = list->nodeNr;
+    /*
+    * Apply templates for all selected source nodes.
+    */    
+    for (i = 0; i < list->nodeNr; i++) {
+       cur = list->nodeTab[i];
+       /*
+       * The node becomes the "current node".
+       */
+       ctxt->node = cur;
+       /*
+       * An xsl:apply-templates can change the current context doc.
+       * OPTIMIZE TODO: Get rid of the need to set the context doc.
+       */
+       if ((cur->type != XML_NAMESPACE_DECL) && (cur->doc != NULL))
+           xpctxt->doc = cur->doc;
+
+       xpctxt->proximityPosition = i + 1;
+       /*
+       * Find and apply a template for this node.
+       */
+       xsltProcessOneNode(ctxt, cur, withParams);
+    }
+
+exit:
+error:
+    /*
+    * Free the parameter list.
+    */
+    if (withParams != NULL)
+       xsltFreeStackElemList(withParams);
+    if (list != NULL)
+       xmlXPathFreeNodeSet(list);    
+    /*
+    * Restore context states.
+    */
+    xpctxt->nsNr = oldXPNsNr;
+    xpctxt->namespaces = oldXPNamespaces;
+    xpctxt->doc = oldXPDoc;
+    xpctxt->contextSize = oldXPContextSize;
+    xpctxt->proximityPosition = oldXPProximityPosition;
+
+    ctxt->document = oldDocInfo;
+    ctxt->nodeList = oldList;
+    ctxt->node = oldContextNode;
+    ctxt->mode = oldMode;
+    ctxt->modeURI = oldModeURI;
+}
+
+
+/**
+ * xsltChoose:
+ * @ctxt:  a XSLT process context
+ * @contextNode:  the current node in the source tree
+ * @inst:  the xsl:choose instruction
+ * @comp:  compiled information of the instruction
+ *
+ * Processes the xsl:choose instruction on the source node.
+ */
+void
+xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
+          xmlNodePtr inst, xsltStylePreCompPtr comp ATTRIBUTE_UNUSED)
+{
+    xmlNodePtr cur;
+
+    if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL))
+       return;
+    
+    /* 
+    * TODO: Content model checks should be done only at compilation
+    * time.
+    */
+    cur = inst->children;
+    if (cur == NULL) {
+       xsltTransformError(ctxt, NULL, inst,
+           "xsl:choose: The instruction has no content.\n");
+       return;
+    }
+
+#ifdef XSLT_REFACTORED
+    /*
+    * We don't check the content model during transformation.
+    */
+#else
+    if ((! IS_XSLT_ELEM(cur)) || (! IS_XSLT_NAME(cur, "when"))) {
+       xsltTransformError(ctxt, NULL, inst,
+            "xsl:choose: xsl:when expected first\n");
+       return;
+    }
+#endif
+
+    {
+       int testRes = 0, res = 0;
+       xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;    
+       xmlDocPtr oldXPContextDoc = xpctxt->doc;
+       int oldXPProximityPosition = xpctxt->proximityPosition;
+       int oldXPContextSize = xpctxt->contextSize;
+       xmlNsPtr *oldXPNamespaces = xpctxt->namespaces;
+       int oldXPNsNr = xpctxt->nsNr;
+       
+#ifdef XSLT_REFACTORED
+       xsltStyleItemWhenPtr wcomp = NULL;
+#else
+       xsltStylePreCompPtr wcomp = NULL;
+#endif
+
+       /*
+       * Process xsl:when ---------------------------------------------------
+       */
+       while (IS_XSLT_ELEM(cur) && IS_XSLT_NAME(cur, "when")) {        
+           wcomp = cur->psvi;
+           
+           if ((wcomp == NULL) || (wcomp->test == NULL) ||
+               (wcomp->comp == NULL))
+           {
+               xsltTransformError(ctxt, NULL, cur,
+                   "Internal error in xsltChoose(): "
+                   "The XSLT 'when' instruction was not compiled.\n");
+               goto error;
+           }
+           
+           
+#ifdef WITH_DEBUGGER
+           if (xslDebugStatus != XSLT_DEBUG_NONE) {
+               /* 
+               * TODO: Isn't comp->templ always NULL for xsl:choose?
+               */
+               xslHandleDebugger(cur, contextNode, NULL, ctxt);
+           }
+#endif
+#ifdef WITH_XSLT_DEBUG_PROCESS
+           XSLT_TRACE(ctxt,XSLT_TRACE_CHOOSE,xsltGenericDebug(xsltGenericDebugContext,
+               "xsltChoose: test %s\n", wcomp->test));
+#endif
+
+           xpctxt->node = contextNode;
+           xpctxt->doc = oldXPContextDoc;
+           xpctxt->proximityPosition = oldXPProximityPosition;
+           xpctxt->contextSize = oldXPContextSize;
+           
+#ifdef XSLT_REFACTORED
+           if (wcomp->inScopeNs != NULL) {
+               xpctxt->namespaces = wcomp->inScopeNs->list;
+               xpctxt->nsNr = wcomp->inScopeNs->xpathNumber;
+           } else {
+               xpctxt->namespaces = NULL;
+               xpctxt->nsNr = 0;
+           }
+#else
+           xpctxt->namespaces = wcomp->nsList;
+           xpctxt->nsNr = wcomp->nsNr;
+#endif
+           
+           
+#ifdef XSLT_FAST_IF
+           res = xmlXPathCompiledEvalToBoolean(wcomp->comp, xpctxt);
+           
+           if (res == -1) {
+               ctxt->state = XSLT_STATE_STOPPED;
+               goto error;
+           }
+           testRes = (res == 1) ? 1 : 0;       
+           
+#else /* XSLT_FAST_IF */
+           
+           res = xmlXPathCompiledEval(wcomp->comp, xpctxt);
+           
+           if (res != NULL) {
+               if (res->type != XPATH_BOOLEAN)
+                   res = xmlXPathConvertBoolean(res);
+               if (res->type == XPATH_BOOLEAN)
+                   testRes = res->boolval;
+               else {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+                   XSLT_TRACE(ctxt,XSLT_TRACE_CHOOSE,xsltGenericDebug(xsltGenericDebugContext,
+                       "xsltChoose: test didn't evaluate to a boolean\n"));
+#endif
+                   goto error;
+               }
+               xmlXPathFreeObject(res);
+               res = NULL;
+           } else {
+               ctxt->state = XSLT_STATE_STOPPED;
+               goto error;
+           }
+           
+#endif /* else of XSLT_FAST_IF */
+           
+#ifdef WITH_XSLT_DEBUG_PROCESS
+           XSLT_TRACE(ctxt,XSLT_TRACE_CHOOSE,xsltGenericDebug(xsltGenericDebugContext,
+               "xsltChoose: test evaluate to %d\n", testRes));
+#endif
+           if (testRes)                
+               goto test_is_true;
+           
+           cur = cur->next;
+       }
+    
+       /*
+       * Process xsl:otherwise ----------------------------------------------
+       */
+       if (IS_XSLT_ELEM(cur) && IS_XSLT_NAME(cur, "otherwise")) {
+           
+#ifdef WITH_DEBUGGER
+           if (xslDebugStatus != XSLT_DEBUG_NONE)
+               xslHandleDebugger(cur, contextNode, NULL, ctxt);
+#endif
+           
+#ifdef WITH_XSLT_DEBUG_PROCESS
+           XSLT_TRACE(ctxt,XSLT_TRACE_CHOOSE,xsltGenericDebug(xsltGenericDebugContext,
+               "evaluating xsl:otherwise\n"));
+#endif     
+           goto test_is_true;
+       }
+       xpctxt->node = contextNode;
+       xpctxt->doc = oldXPContextDoc;
+       xpctxt->proximityPosition = oldXPProximityPosition;
+       xpctxt->contextSize = oldXPContextSize;
+       xpctxt->namespaces = oldXPNamespaces;
+       xpctxt->nsNr = oldXPNsNr;
+       goto exit;
+
+test_is_true:
+
+       xpctxt->node = contextNode;
+       xpctxt->doc = oldXPContextDoc;
+       xpctxt->proximityPosition = oldXPProximityPosition;
+       xpctxt->contextSize = oldXPContextSize;
+       xpctxt->namespaces = oldXPNamespaces;
+       xpctxt->nsNr = oldXPNsNr;
+       goto process_sequence;
+    }
+
+process_sequence:
+    
+    /*
+    * Instantiate the sequence constructor.
+    */
+    xsltApplySequenceConstructor(ctxt, ctxt->node, cur->children,
+       NULL);
+
+exit:
+error:
+    return;
+}
+
+/**
+ * xsltIf:
+ * @ctxt:  a XSLT process context
+ * @contextNode:  the current node in the source tree
+ * @inst:  the xsl:if instruction
+ * @castedComp:  compiled information of the instruction
+ *
+ * Processes the xsl:if instruction on the source node.
+ */
+void
+xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
+                  xmlNodePtr inst, xsltStylePreCompPtr castedComp)
+{
+    int res = 0;
+
+#ifdef XSLT_REFACTORED
+    xsltStyleItemIfPtr comp = (xsltStyleItemIfPtr) castedComp;
+#else
+    xsltStylePreCompPtr comp = castedComp;
+#endif
+
+    if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL))
+       return;
+    if ((comp == NULL) || (comp->test == NULL) || (comp->comp == NULL)) {
+       xsltTransformError(ctxt, NULL, inst,
+           "Internal error in xsltIf(): "
+           "The XSLT 'if' instruction was not compiled.\n");
+       return;
+    }
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    XSLT_TRACE(ctxt,XSLT_TRACE_IF,xsltGenericDebug(xsltGenericDebugContext,
+        "xsltIf: test %s\n", comp->test));
+#endif
+
+#ifdef XSLT_FAST_IF    
+    {
+       xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;
+       xmlDocPtr oldXPContextDoc = xpctxt->doc;
+       xmlNsPtr *oldXPNamespaces = xpctxt->namespaces;
+       xmlNodePtr oldXPContextNode = xpctxt->node;
+       int oldXPProximityPosition = xpctxt->proximityPosition;
+       int oldXPContextSize = xpctxt->contextSize;
+       int oldXPNsNr = xpctxt->nsNr;
+       xmlDocPtr oldLocalFragmentTop = ctxt->localRVT; 
+       
+       xpctxt->node = contextNode;
+       if (comp != NULL) {
+           
+#ifdef XSLT_REFACTORED
+           if (comp->inScopeNs != NULL) {
+               xpctxt->namespaces = comp->inScopeNs->list;
+               xpctxt->nsNr = comp->inScopeNs->xpathNumber;
+           } else {
+               xpctxt->namespaces = NULL;
+               xpctxt->nsNr = 0;
+           }
+#else
+           xpctxt->namespaces = comp->nsList;
+           xpctxt->nsNr = comp->nsNr;
+#endif
+       } else {
+           xpctxt->namespaces = NULL;
+           xpctxt->nsNr = 0;
+       }
+       /*
+       * This XPath function is optimized for boolean results.
+       */      
+       res = xmlXPathCompiledEvalToBoolean(comp->comp, xpctxt);
+
+       /*
+       * Cleanup fragments created during evaluation of the
+       * "select" expression.
+       */
+       if (oldLocalFragmentTop != ctxt->localRVT)
+           xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
+       
+       xpctxt->doc = oldXPContextDoc;
+       xpctxt->node = oldXPContextNode;
+       xpctxt->contextSize = oldXPContextSize;
+       xpctxt->proximityPosition = oldXPProximityPosition;     
+       xpctxt->nsNr = oldXPNsNr;
+       xpctxt->namespaces = oldXPNamespaces;
+    }
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    XSLT_TRACE(ctxt,XSLT_TRACE_IF,xsltGenericDebug(xsltGenericDebugContext,
+       "xsltIf: test evaluate to %d\n", res));
+#endif
+    
+    if (res == -1) {
+       ctxt->state = XSLT_STATE_STOPPED;
+       goto error;
+    }
+    if (res == 1) {
+       /*
+       * Instantiate the sequence constructor of xsl:if.
+       */
+       xsltApplySequenceConstructor(ctxt,
+           contextNode, inst->children, NULL);
+    }
+       
+#else /* XSLT_FAST_IF */
+    {
+       xmlXPathObjectPtr xpobj = NULL;
+       /*
+       * OLD CODE:
+       */
+       {
+           xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;
+           xmlDocPtr oldXPContextDoc = xpctxt->doc;
+           xmlNsPtr *oldXPNamespaces = xpctxt->namespaces;
+           xmlNodePtr oldXPContextNode = xpctxt->node;
+           int oldXPProximityPosition = xpctxt->proximityPosition;
+           int oldXPContextSize = xpctxt->contextSize;
+           int oldXPNsNr = xpctxt->nsNr;       
+           
+           xpctxt->node = contextNode;
+           if (comp != NULL) {
+               
+#ifdef XSLT_REFACTORED
+               if (comp->inScopeNs != NULL) {
+                   xpctxt->namespaces = comp->inScopeNs->list;
+                   xpctxt->nsNr = comp->inScopeNs->xpathNumber;
+               } else {
+                   xpctxt->namespaces = NULL;
+                   xpctxt->nsNr = 0;
+               }
+#else
+               xpctxt->namespaces = comp->nsList;
+               xpctxt->nsNr = comp->nsNr;
+#endif
+           } else {
+               xpctxt->namespaces = NULL;
+               xpctxt->nsNr = 0;
+           }
+           
+           /*
+           * This XPath function is optimized for boolean results.
+           */  
+           xpobj = xmlXPathCompiledEval(comp->comp, xpctxt);
+           
+           xpctxt->doc = oldXPContextDoc;
+           xpctxt->node = oldXPContextNode;
+           xpctxt->contextSize = oldXPContextSize;
+           xpctxt->proximityPosition = oldXPProximityPosition; 
+           xpctxt->nsNr = oldXPNsNr;
+           xpctxt->namespaces = oldXPNamespaces;
+       }
+       if (xpobj != NULL) {
+           if (xpobj->type != XPATH_BOOLEAN)
+               xpobj = xmlXPathConvertBoolean(xpobj);
+           if (xpobj->type == XPATH_BOOLEAN) {
+               res = xpobj->boolval;
+               
+#ifdef WITH_XSLT_DEBUG_PROCESS
+               XSLT_TRACE(ctxt,XSLT_TRACE_IF,xsltGenericDebug(xsltGenericDebugContext,
+                   "xsltIf: test evaluate to %d\n", res));
+#endif
+               if (res) {
+                   xsltApplySequenceConstructor(ctxt,
+                       contextNode, inst->children, NULL);
+               }
+           } else {
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+               XSLT_TRACE(ctxt, XSLT_TRACE_IF,
+                   xsltGenericDebug(xsltGenericDebugContext,
+                   "xsltIf: test didn't evaluate to a boolean\n"));
+#endif
+               ctxt->state = XSLT_STATE_STOPPED;
+           }
+           xmlXPathFreeObject(xpobj);
+       } else {
+           ctxt->state = XSLT_STATE_STOPPED;
+       }
+    }
+#endif /* else of XSLT_FAST_IF */
+
+error:
+    return;
+}
+
+/**
+ * xsltForEach:
+ * @ctxt:  an XSLT transformation context
+ * @contextNode:  the "current node" in the source tree  
+ * @inst:  the element node of the xsl:for-each instruction
+ * @castedComp:  the compiled information of the instruction
+ *
+ * Process the xslt for-each node on the source node
+ */
+void
+xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
+           xmlNodePtr inst, xsltStylePreCompPtr castedComp)
+{
+#ifdef XSLT_REFACTORED
+    xsltStyleItemForEachPtr comp = (xsltStyleItemForEachPtr) castedComp;
+#else
+    xsltStylePreCompPtr comp = castedComp;
+#endif
+    int i;
+    xmlXPathObjectPtr res = NULL;
+    xmlNodePtr cur, curInst;
+    xmlNodeSetPtr list = NULL;
+    xmlNodeSetPtr oldList;        
+    int oldXPProximityPosition, oldXPContextSize;
+    xmlNodePtr oldContextNode;
+    xsltTemplatePtr oldCurTemplRule;    
+    xmlDocPtr oldXPDoc;
+    xsltDocumentPtr oldDocInfo;
+    xmlXPathContextPtr xpctxt;
+
+    if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL)) {
+       xsltGenericError(xsltGenericErrorContext,       
+           "xsltForEach(): Bad arguments.\n");
+       return;
+    }
+
+    if (comp == NULL) {
+        xsltTransformError(ctxt, NULL, inst,
+           "Internal error in xsltForEach(): "
+           "The XSLT 'for-each' instruction was not compiled.\n");
+        return;
+    }
+    if ((comp->select == NULL) || (comp->comp == NULL)) {
+       xsltTransformError(ctxt, NULL, inst,
+           "Internal error in xsltForEach(): "
+           "The selecting expression of the XSLT 'for-each' "
+           "instruction was not compiled correctly.\n");
+       return;
+    }
+    xpctxt = ctxt->xpathCtxt;    
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    XSLT_TRACE(ctxt,XSLT_TRACE_FOR_EACH,xsltGenericDebug(xsltGenericDebugContext,
+        "xsltForEach: select %s\n", comp->select));
+#endif
+
+    /*
+    * Save context states.
+    */
+    oldDocInfo = ctxt->document;
+    oldList = ctxt->nodeList;    
+    oldContextNode = ctxt->node;
+    /*
+    * The "current template rule" is cleared for the instantiation of
+    * xsl:for-each.
+    */
+    oldCurTemplRule = ctxt->currentTemplateRule;
+    ctxt->currentTemplateRule = NULL;
+
+    oldXPDoc = xpctxt->doc;
+    oldXPProximityPosition = xpctxt->proximityPosition;
+    oldXPContextSize = xpctxt->contextSize;
+    /*
+    * Set up XPath.
+    */
+    xpctxt->node = contextNode;
+#ifdef XSLT_REFACTORED
+    if (comp->inScopeNs != NULL) {
+       xpctxt->namespaces = comp->inScopeNs->list;
+       xpctxt->nsNr = comp->inScopeNs->xpathNumber;
+    } else {
+       xpctxt->namespaces = NULL;
+       xpctxt->nsNr = 0;
+    }
+#else
+    xpctxt->namespaces = comp->nsList;
+    xpctxt->nsNr = comp->nsNr;
+#endif   
+    
+    /*
+    * Evaluate the 'select' expression.
+    */
+    res = xmlXPathCompiledEval(comp->comp, ctxt->xpathCtxt);
+
+    if (res != NULL) {
+       if (res->type == XPATH_NODESET)
+           list = res->nodesetval;
+       else {
+           xsltTransformError(ctxt, NULL, inst,
+               "The 'select' expression does not evaluate to a node set.\n");
+           
+#ifdef WITH_XSLT_DEBUG_PROCESS
+           XSLT_TRACE(ctxt,XSLT_TRACE_FOR_EACH,xsltGenericDebug(xsltGenericDebugContext,
+               "xsltForEach: select didn't evaluate to a node list\n"));
+#endif
+           goto error;
+       }
+    } else {
+       xsltTransformError(ctxt, NULL, inst,
+           "Failed to evaluate the 'select' expression.\n");
+       ctxt->state = XSLT_STATE_STOPPED;
+       goto error;
+    }
+
+    if ((list == NULL) || (list->nodeNr <= 0))
+       goto exit;
+
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    XSLT_TRACE(ctxt,XSLT_TRACE_FOR_EACH,xsltGenericDebug(xsltGenericDebugContext,
+       "xsltForEach: select evaluates to %d nodes\n", list->nodeNr));
+#endif
+
+    /*
+    * Restore XPath states for the "current node".
+    */
+    xpctxt->contextSize = oldXPContextSize;
+    xpctxt->proximityPosition = oldXPProximityPosition;
+    xpctxt->node = contextNode;
+    
+    /*
+    * Set the list; this has to be done already here for xsltDoSortFunction().
+    */
+    ctxt->nodeList = list;    
+    /* 
+    * Handle xsl:sort instructions and skip them for further processing.
+    * BUG TODO: We are not using namespaced potentially defined on the
+    * xsl:sort element; XPath expression might fail.
+    */
+    curInst = inst->children;
+    if (IS_XSLT_ELEM(curInst) && IS_XSLT_NAME(curInst, "sort")) {
+       int nbsorts = 0;
+       xmlNodePtr sorts[XSLT_MAX_SORT];
+
+       sorts[nbsorts++] = curInst;
+
+#ifdef WITH_DEBUGGER
+       if (xslDebugStatus != XSLT_DEBUG_NONE)
+           xslHandleDebugger(curInst, contextNode, NULL, ctxt);
+#endif
+
+       curInst = curInst->next;
+       while (IS_XSLT_ELEM(curInst) && IS_XSLT_NAME(curInst, "sort")) {
+           if (nbsorts >= XSLT_MAX_SORT) {
+               xsltTransformError(ctxt, NULL, curInst,
+                   "The number of xsl:sort instructions exceeds the "
+                   "maximum (%d) allowed by this processor.\n",
+                   XSLT_MAX_SORT);
+               goto error;
+           } else {
+               sorts[nbsorts++] = curInst;
+           }
+           
+#ifdef WITH_DEBUGGER
+           if (xslDebugStatus != XSLT_DEBUG_NONE)
+               xslHandleDebugger(curInst, contextNode, NULL, ctxt);
+#endif
+           curInst = curInst->next;
+       }
+       xsltDoSortFunction(ctxt, sorts, nbsorts);
+    }    
+    xpctxt->contextSize = list->nodeNr;
+    /*
+    * Instantiate the sequence constructor for each selected node.
+    */    
+    for (i = 0; i < list->nodeNr; i++) {
+       cur = list->nodeTab[i];
+       /*
+       * The selected node becomes the "current node".
+       */
+       ctxt->node = cur;
+       /*
+       * An xsl:for-each can change the current context doc.
+       * OPTIMIZE TODO: Get rid of the need to set the context doc.
+       */
+       if ((cur->type != XML_NAMESPACE_DECL) && (cur->doc != NULL))
+           xpctxt->doc = cur->doc;
+
+       xpctxt->proximityPosition = i + 1;
+
+       xsltApplySequenceConstructor(ctxt, cur, curInst, NULL);
+    }
+
+exit:
+error:
+    if (res != NULL)
+       xmlXPathFreeObject(res);
+    /*
+    * Restore old states.
+    */
+    ctxt->document = oldDocInfo;
+    ctxt->nodeList = oldList;
+    ctxt->node = oldContextNode;
+    ctxt->currentTemplateRule = oldCurTemplRule;
+
+    xpctxt->doc = oldXPDoc;
+    xpctxt->contextSize = oldXPContextSize;
+    xpctxt->proximityPosition = oldXPProximityPosition;
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     Generic interface                               *
+ *                                                                     *
+ ************************************************************************/
+
+#ifdef XSLT_GENERATE_HTML_DOCTYPE
+typedef struct xsltHTMLVersion {
+    const char *version;
+    const char *public;
+    const char *system;
+} xsltHTMLVersion;
+
+static xsltHTMLVersion xsltHTMLVersions[] = {
+    { "4.01frame", "-//W3C//DTD HTML 4.01 Frameset//EN",
+      "http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd"},
+    { "4.01strict", "-//W3C//DTD HTML 4.01//EN",
+      "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd"},
+    { "4.01trans", "-//W3C//DTD HTML 4.01 Transitional//EN",
+      "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"},
+    { "4.01", "-//W3C//DTD HTML 4.01 Transitional//EN",
+      "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"},
+    { "4.0strict", "-//W3C//DTD HTML 4.01//EN",
+      "http://www.w3.org/TR/html4/strict.dtd"},
+    { "4.0trans", "-//W3C//DTD HTML 4.01 Transitional//EN",
+      "http://www.w3.org/TR/html4/loose.dtd"},
+    { "4.0frame", "-//W3C//DTD HTML 4.01 Frameset//EN",
+      "http://www.w3.org/TR/html4/frameset.dtd"},
+    { "4.0", "-//W3C//DTD HTML 4.01 Transitional//EN",
+      "http://www.w3.org/TR/html4/loose.dtd"},
+    { "3.2", "-//W3C//DTD HTML 3.2//EN", NULL }
+};
+
+/**
+ * xsltGetHTMLIDs:
+ * @version:  the version string
+ * @publicID:  used to return the public ID
+ * @systemID:  used to return the system ID
+ *
+ * Returns -1 if not found, 0 otherwise and the system and public
+ *         Identifier for this given verion of HTML
+ */
+static int
+xsltGetHTMLIDs(const xmlChar *version, const xmlChar **publicID,
+                   const xmlChar **systemID) {
+    unsigned int i;
+    if (version == NULL)
+       return(-1);
+    for (i = 0;i < (sizeof(xsltHTMLVersions)/sizeof(xsltHTMLVersions[1]));
+        i++) {
+       if (!xmlStrcasecmp(version,
+                          (const xmlChar *) xsltHTMLVersions[i].version)) {
+           if (publicID != NULL)
+               *publicID = (const xmlChar *) xsltHTMLVersions[i].public;
+           if (systemID != NULL)
+               *systemID = (const xmlChar *) xsltHTMLVersions[i].system;
+           return(0);
+       }
+    }
+    return(-1);
+}
+#endif
+
+/**
+ * xsltApplyStripSpaces:
+ * @ctxt:  a XSLT process context
+ * @node:  the root of the XML tree
+ *
+ * Strip the unwanted ignorable spaces from the input tree
+ */
+void
+xsltApplyStripSpaces(xsltTransformContextPtr ctxt, xmlNodePtr node) {
+    xmlNodePtr current;
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    int nb = 0;
+#endif
+
+
+    current = node;
+    while (current != NULL) {
+       /*
+        * Cleanup children empty nodes if asked for
+        */
+       if ((IS_XSLT_REAL_NODE(current)) &&
+           (current->children != NULL) &&
+           (xsltFindElemSpaceHandling(ctxt, current))) {
+           xmlNodePtr delete = NULL, cur = current->children;
+
+           while (cur != NULL) {
+               if (IS_BLANK_NODE(cur))
+                   delete = cur;
+               
+               cur = cur->next;
+               if (delete != NULL) {
+                   xmlUnlinkNode(delete);
+                   xmlFreeNode(delete);
+                   delete = NULL;
+#ifdef WITH_XSLT_DEBUG_PROCESS
+                   nb++;
+#endif
+               }
+           }
+       }
+
+       /*
+        * Skip to next node in document order.
+        */
+       if (node->type == XML_ENTITY_REF_NODE) {
+           /* process deep in entities */
+           xsltApplyStripSpaces(ctxt, node->children);
+       }
+       if ((current->children != NULL) &&
+            (current->type != XML_ENTITY_REF_NODE)) {
+           current = current->children;
+       } else if (current->next != NULL) {
+           current = current->next;
+       } else {
+           do {
+               current = current->parent;
+               if (current == NULL)
+                   break;
+               if (current == node)
+                   goto done;
+               if (current->next != NULL) {
+                   current = current->next;
+                   break;
+               }
+           } while (current != NULL);
+       }
+    }
+
+done:
+#ifdef WITH_XSLT_DEBUG_PROCESS
+    XSLT_TRACE(ctxt,XSLT_TRACE_STRIP_SPACES,xsltGenericDebug(xsltGenericDebugContext,
+            "xsltApplyStripSpaces: removed %d ignorable blank node\n", nb));
+#endif
+    return;
+}
+
+static int
+xsltCountKeys(xsltTransformContextPtr ctxt)
+{
+    xsltStylesheetPtr style;
+    xsltKeyDefPtr keyd;
+
+    if (ctxt == NULL)
+       return(-1);
+
+    /*
+    * Do we have those nastly templates with a key() in the match pattern?
+    */
+    ctxt->hasTemplKeyPatterns = 0;
+    style = ctxt->style;
+    while (style != NULL) {
+       if (style->keyMatch != NULL) {
+           ctxt->hasTemplKeyPatterns = 1;
+           break;
+       }
+       style = xsltNextImport(style);
+    }
+    /*
+    * Count number of key declarations.
+    */
+    ctxt->nbKeys = 0;
+    style = ctxt->style;
+    while (style != NULL) {
+       keyd = style->keys;
+       while (keyd) {
+           ctxt->nbKeys++;
+           keyd = keyd->next;
+       }
+       style = xsltNextImport(style);
+    }
+    return(ctxt->nbKeys);
+}
+
+/**
+ * xsltApplyStylesheetInternal:
+ * @style:  a parsed XSLT stylesheet
+ * @doc:  a parsed XML document
+ * @params:  a NULL terminated array of parameters names/values tuples
+ * @output:  the targetted output
+ * @profile:  profile FILE * output or NULL
+ * @user:  user provided parameter
+ *
+ * Apply the stylesheet to the document
+ * NOTE: This may lead to a non-wellformed output XML wise !
+ *
+ * Returns the result document or NULL in case of error
+ */
+static xmlDocPtr
+xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
+                            const char **params, const char *output,
+                            FILE * profile, xsltTransformContextPtr userCtxt)
+{
+    xmlDocPtr res = NULL;
+    xsltTransformContextPtr ctxt = NULL;
+    xmlNodePtr root, node;
+    const xmlChar *method;
+    const xmlChar *doctypePublic;
+    const xmlChar *doctypeSystem;
+    const xmlChar *version;
+    xsltStackElemPtr variables;
+    xsltStackElemPtr vptr;
+
+    if ((style == NULL) || (doc == NULL))
+        return (NULL);
+
+    if (style->internalized == 0) {
+#ifdef WITH_XSLT_DEBUG
+       xsltGenericDebug(xsltGenericDebugContext,
+                        "Stylesheet was not fully internalized !\n");
+#endif
+    }
+    if (doc->intSubset != NULL) {
+       /*
+        * Avoid hitting the DTD when scanning nodes
+        * but keep it linked as doc->intSubset
+        */
+       xmlNodePtr cur = (xmlNodePtr) doc->intSubset;
+       if (cur->next != NULL)
+           cur->next->prev = cur->prev;
+       if (cur->prev != NULL)
+           cur->prev->next = cur->next;
+       if (doc->children == cur)
+           doc->children = cur->next;
+       if (doc->last == cur)
+           doc->last = cur->prev;
+       cur->prev = cur->next = NULL;
+    }
+
+    /*
+     * Check for XPath document order availability
+     */
+    root = xmlDocGetRootElement(doc);
+    if (root != NULL) {
+       if (((long) root->content) >= 0 && (xslDebugStatus == XSLT_DEBUG_NONE))
+           xmlXPathOrderDocElems(doc);
+    }
+
+    if (userCtxt != NULL)
+       ctxt = userCtxt;
+    else
+       ctxt = xsltNewTransformContext(style, doc);
+
+    if (ctxt == NULL)
+        return (NULL);
+
+    ctxt->initialContextDoc = doc;
+    ctxt->initialContextNode = (xmlNodePtr) doc;
+
+    if (profile != NULL)
+        ctxt->profile = 1;
+
+    if (output != NULL)
+        ctxt->outputFile = output;
+    else
+        ctxt->outputFile = NULL;
+
+    /*
+     * internalize the modes if needed
+     */
+    if (ctxt->dict != NULL) {
+        if (ctxt->mode != NULL)
+           ctxt->mode = xmlDictLookup(ctxt->dict, ctxt->mode, -1);
+        if (ctxt->modeURI != NULL)
+           ctxt->modeURI = xmlDictLookup(ctxt->dict, ctxt->modeURI, -1);
+    }
+
+    XSLT_GET_IMPORT_PTR(method, style, method)
+    XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic)
+    XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem)
+    XSLT_GET_IMPORT_PTR(version, style, version)
+
+    if ((method != NULL) &&
+       (!xmlStrEqual(method, (const xmlChar *) "xml")))
+    {
+        if (xmlStrEqual(method, (const xmlChar *) "html")) {
+            ctxt->type = XSLT_OUTPUT_HTML;
+            if (((doctypePublic != NULL) || (doctypeSystem != NULL))) {
+                res = htmlNewDoc(doctypeSystem, doctypePublic);
+           } else {
+                if (version == NULL) {
+                   xmlDtdPtr dtd;
+                   
+                   res = htmlNewDoc(NULL, NULL);
+                   /*
+                   * Make sure no DTD node is generated in this case
+                   */
+                   if (res != NULL) {
+                       dtd = xmlGetIntSubset(res);
+                       if (dtd != NULL) {
+                           xmlUnlinkNode((xmlNodePtr) dtd);
+                           xmlFreeDtd(dtd);
+                       }
+                       res->intSubset = NULL;
+                       res->extSubset = NULL;
+                   }
+               } else {
+
+#ifdef XSLT_GENERATE_HTML_DOCTYPE
+                   xsltGetHTMLIDs(version, &doctypePublic, &doctypeSystem);
+#endif
+                   res = htmlNewDoc(doctypeSystem, doctypePublic);
+               }
+            }
+            if (res == NULL)
+                goto error;
+           res->dict = ctxt->dict;
+           xmlDictReference(res->dict);
+
+#ifdef WITH_XSLT_DEBUG
+           xsltGenericDebug(xsltGenericDebugContext,
+               "reusing transformation dict for output\n");
+#endif
+        } else if (xmlStrEqual(method, (const xmlChar *) "xhtml")) {
+           xsltTransformError(ctxt, NULL, (xmlNodePtr) doc,
+               "xsltApplyStylesheetInternal: unsupported method xhtml, using html\n",
+               style->method);
+            ctxt->type = XSLT_OUTPUT_HTML;
+            res = htmlNewDoc(doctypeSystem, doctypePublic);
+            if (res == NULL)
+                goto error;
+           res->dict = ctxt->dict;
+           xmlDictReference(res->dict);
+
+#ifdef WITH_XSLT_DEBUG
+           xsltGenericDebug(xsltGenericDebugContext,
+               "reusing transformation dict for output\n");
+#endif
+        } else if (xmlStrEqual(method, (const xmlChar *) "text")) {
+            ctxt->type = XSLT_OUTPUT_TEXT;
+            res = xmlNewDoc(style->version);
+            if (res == NULL)
+                goto error;
+           res->dict = ctxt->dict;
+           xmlDictReference(res->dict);
+
+#ifdef WITH_XSLT_DEBUG
+           xsltGenericDebug(xsltGenericDebugContext,
+               "reusing transformation dict for output\n");
+#endif
+        } else {
+           xsltTransformError(ctxt, NULL, (xmlNodePtr) doc,
+               "xsltApplyStylesheetInternal: unsupported method %s\n",
+               style->method);
+            goto error;
+        }
+    } else {
+        ctxt->type = XSLT_OUTPUT_XML;
+        res = xmlNewDoc(style->version);
+        if (res == NULL)
+            goto error;
+       res->dict = ctxt->dict;
+       xmlDictReference(ctxt->dict);
+#ifdef WITH_XSLT_DEBUG
+       xsltGenericDebug(xsltGenericDebugContext,
+                        "reusing transformation dict for output\n");
+#endif
+    }
+    res->charset = XML_CHAR_ENCODING_UTF8;
+    if (style->encoding != NULL)
+        res->encoding = xmlStrdup(style->encoding);
+    variables = style->variables;
+
+    /*
+     * Start the evaluation, evaluate the params, the stylesheets globals
+     * and start by processing the top node.
+     */
+    if (xsltNeedElemSpaceHandling(ctxt))
+       xsltApplyStripSpaces(ctxt, xmlDocGetRootElement(doc));    
+    /*
+    * Evaluate global params and user-provided params.
+    */
+    ctxt->node = (xmlNodePtr) doc;
+    if (ctxt->globalVars == NULL)
+       ctxt->globalVars = xmlHashCreate(20);
+    if (params != NULL) {      
+        xsltEvalUserParams(ctxt, params);
+    }
+
+    /* need to be called before evaluating global variables */
+    xsltCountKeys(ctxt);
+
+    xsltEvalGlobalVariables(ctxt);
+
+    ctxt->node = (xmlNodePtr) doc;
+    ctxt->output = res;
+    ctxt->insert = (xmlNodePtr) res;
+    ctxt->varsBase = ctxt->varsNr - 1;
+
+    ctxt->xpathCtxt->contextSize = 1;
+    ctxt->xpathCtxt->proximityPosition = 1;
+    ctxt->xpathCtxt->node = NULL; /* TODO: Set the context node here? */
+    /*
+    * Start processing the source tree -----------------------------------
+    */
+    xsltProcessOneNode(ctxt, ctxt->node, NULL);
+    /*
+    * Remove all remaining vars from the stack.
+    */
+    xsltLocalVariablePop(ctxt, 0, -2);
+    xsltShutdownCtxtExts(ctxt);
+
+    xsltCleanupTemplates(style); /* TODO: <- style should be read only */
+
+    /*
+     * Now cleanup our variables so stylesheet can be re-used
+     *
+     * TODO: this is not needed anymore global variables are copied
+     *       and not evaluated directly anymore, keep this as a check
+     */
+    if (style->variables != variables) {
+        vptr = style->variables;
+        while (vptr->next != variables)
+            vptr = vptr->next;
+        vptr->next = NULL;
+        xsltFreeStackElemList(style->variables);
+        style->variables = variables;
+    }
+    vptr = style->variables;
+    while (vptr != NULL) {
+        if (vptr->computed) {
+            if (vptr->value != NULL) {
+                xmlXPathFreeObject(vptr->value);
+                vptr->value = NULL;
+                vptr->computed = 0;
+            }
+        }
+        vptr = vptr->next;
+    }
+#if 0
+    /*
+     * code disabled by wmb; awaiting kb's review
+     * problem is that global variable(s) may contain xpath objects
+     * from doc associated with RVT, so can't be freed at this point.
+     * xsltFreeTransformContext includes a call to xsltFreeRVTs, so
+     * I assume this shouldn't be required at this point.
+     */
+    /*
+    * Free all remaining tree fragments.
+    */
+    xsltFreeRVTs(ctxt);
+#endif
+    /*
+     * Do some post processing work depending on the generated output
+     */
+    root = xmlDocGetRootElement(res);
+    if (root != NULL) {
+        const xmlChar *doctype = NULL;
+
+        if ((root->ns != NULL) && (root->ns->prefix != NULL))
+           doctype = xmlDictQLookup(ctxt->dict, root->ns->prefix, root->name);
+       if (doctype == NULL)
+           doctype = root->name;
+
+        /*
+         * Apply the default selection of the method
+         */
+        if ((method == NULL) &&
+            (root->ns == NULL) &&
+            (!xmlStrcasecmp(root->name, (const xmlChar *) "html"))) {
+            xmlNodePtr tmp;
+
+            tmp = res->children;
+            while ((tmp != NULL) && (tmp != root)) {
+                if (tmp->type == XML_ELEMENT_NODE)
+                    break;
+                if ((tmp->type == XML_TEXT_NODE) && (!xmlIsBlankNode(tmp)))
+                    break;
+               tmp = tmp->next;
+            }
+            if (tmp == root) {
+                ctxt->type = XSLT_OUTPUT_HTML;
+               /*
+               * REVISIT TODO: XML_HTML_DOCUMENT_NODE is set after the
+               *  transformation on the doc, but functions like
+               */
+                res->type = XML_HTML_DOCUMENT_NODE;
+                if (((doctypePublic != NULL) || (doctypeSystem != NULL))) {
+                    res->intSubset = xmlCreateIntSubset(res, doctype,
+                                                        doctypePublic,
+                                                        doctypeSystem);
+#ifdef XSLT_GENERATE_HTML_DOCTYPE
+               } else if (version != NULL) {
+                    xsltGetHTMLIDs(version, &doctypePublic,
+                                   &doctypeSystem);
+                    if (((doctypePublic != NULL) || (doctypeSystem != NULL)))
+                        res->intSubset =
+                            xmlCreateIntSubset(res, doctype,
+                                               doctypePublic,
+                                               doctypeSystem);
+#endif
+                }
+            }
+
+        }
+        if (ctxt->type == XSLT_OUTPUT_XML) {
+            XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic)
+            XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem)
+            if (((doctypePublic != NULL) || (doctypeSystem != NULL))) {
+               xmlNodePtr last;
+               /* Need a small "hack" here to assure DTD comes before
+                  possible comment nodes */
+               node = res->children;
+               last = res->last;
+               res->children = NULL;
+               res->last = NULL;
+                res->intSubset = xmlCreateIntSubset(res, doctype,
+                                                    doctypePublic,
+                                                    doctypeSystem);
+               if (res->children != NULL) {
+                   res->children->next = node;
+                   node->prev = res->children;
+                   res->last = last;
+               } else {
+                   res->children = node;
+                   res->last = last;
+               }
+           }
+        }
+    }
+    xmlXPathFreeNodeSet(ctxt->nodeList);
+    if (profile != NULL) {
+        xsltSaveProfiling(ctxt, profile);
+    }
+
+    /*
+     * Be pedantic.
+     */
+    if ((ctxt != NULL) && (ctxt->state == XSLT_STATE_ERROR)) {
+       xmlFreeDoc(res);
+       res = NULL;
+    }
+    if ((res != NULL) && (ctxt != NULL) && (output != NULL)) {
+       int ret;
+
+       ret = xsltCheckWrite(ctxt->sec, ctxt, (const xmlChar *) output);
+       if (ret == 0) {
+           xsltTransformError(ctxt, NULL, NULL,
+                    "xsltApplyStylesheet: forbidden to save to %s\n",
+                              output);
+       } else if (ret < 0) {
+           xsltTransformError(ctxt, NULL, NULL,
+                    "xsltApplyStylesheet: saving to %s may not be possible\n",
+                              output);
+       }
+    }
+
+#ifdef XSLT_DEBUG_PROFILE_CACHE
+    printf("# Cache:\n");
+    printf("# Reused tree fragments: %d\n", ctxt->cache->dbgReusedRVTs);
+    printf("# Reused variables     : %d\n", ctxt->cache->dbgReusedVars);
+#endif
+
+    if ((ctxt != NULL) && (userCtxt == NULL))
+       xsltFreeTransformContext(ctxt);
+
+    return (res);
+
+error:
+    if (res != NULL)
+        xmlFreeDoc(res);
+
+#ifdef XSLT_DEBUG_PROFILE_CACHE
+    printf("# Cache:\n");
+    printf("# Reused tree fragments: %d\n", ctxt->cache->dbgReusedRVTs);
+    printf("# Reused variables     : %d\n", ctxt->cache->dbgReusedVars);
+#endif
+
+    if ((ctxt != NULL) && (userCtxt == NULL))
+        xsltFreeTransformContext(ctxt);
+    return (NULL);
+}
+
+/**
+ * xsltApplyStylesheet:
+ * @style:  a parsed XSLT stylesheet
+ * @doc:  a parsed XML document
+ * @params:  a NULL terminated arry of parameters names/values tuples
+ *
+ * Apply the stylesheet to the document
+ * NOTE: This may lead to a non-wellformed output XML wise !
+ *
+ * Returns the result document or NULL in case of error
+ */
+xmlDocPtr
+xsltApplyStylesheet(xsltStylesheetPtr style, xmlDocPtr doc,
+                    const char **params)
+{
+    return (xsltApplyStylesheetInternal(style, doc, params, NULL, NULL, NULL));
+}
+
+/**
+ * xsltProfileStylesheet:
+ * @style:  a parsed XSLT stylesheet
+ * @doc:  a parsed XML document
+ * @params:  a NULL terminated arry of parameters names/values tuples
+ * @output:  a FILE * for the profiling output
+ *
+ * Apply the stylesheet to the document and dump the profiling to
+ * the given output.
+ *
+ * Returns the result document or NULL in case of error
+ */
+xmlDocPtr
+xsltProfileStylesheet(xsltStylesheetPtr style, xmlDocPtr doc,
+                      const char **params, FILE * output)
+{
+    xmlDocPtr res;
+
+    res = xsltApplyStylesheetInternal(style, doc, params, NULL, output, NULL);
+    return (res);
+}
+
+/**
+ * xsltApplyStylesheetUser:
+ * @style:  a parsed XSLT stylesheet
+ * @doc:  a parsed XML document
+ * @params:  a NULL terminated array of parameters names/values tuples
+ * @output:  the targetted output
+ * @profile:  profile FILE * output or NULL
+ * @userCtxt:  user provided transform context
+ *
+ * Apply the stylesheet to the document and allow the user to provide
+ * its own transformation context.
+ *
+ * Returns the result document or NULL in case of error
+ */
+xmlDocPtr
+xsltApplyStylesheetUser(xsltStylesheetPtr style, xmlDocPtr doc,
+                            const char **params, const char *output,
+                            FILE * profile, xsltTransformContextPtr userCtxt)
+{
+    xmlDocPtr res;
+
+    res = xsltApplyStylesheetInternal(style, doc, params, output,
+                                     profile, userCtxt);
+    return (res);
+}
+
+/**
+ * xsltRunStylesheetUser:
+ * @style:  a parsed XSLT stylesheet
+ * @doc:  a parsed XML document
+ * @params:  a NULL terminated array of parameters names/values tuples
+ * @output:  the URL/filename ot the generated resource if available
+ * @SAX:  a SAX handler for progressive callback output (not implemented yet)
+ * @IObuf:  an output buffer for progressive output (not implemented yet)
+ * @profile:  profile FILE * output or NULL
+ * @userCtxt:  user provided transform context
+ *
+ * Apply the stylesheet to the document and generate the output according
+ * to @output @SAX and @IObuf. It's an error to specify both @SAX and @IObuf.
+ *
+ * NOTE: This may lead to a non-wellformed output XML wise !
+ * NOTE: This may also result in multiple files being generated
+ * NOTE: using IObuf, the result encoding used will be the one used for
+ *       creating the output buffer, use the following macro to read it
+ *       from the stylesheet
+ *       XSLT_GET_IMPORT_PTR(encoding, style, encoding)
+ * NOTE: using SAX, any encoding specified in the stylesheet will be lost
+ *       since the interface uses only UTF8
+ *
+ * Returns the number of by written to the main resource or -1 in case of
+ *         error.
+ */
+int
+xsltRunStylesheetUser(xsltStylesheetPtr style, xmlDocPtr doc,
+                  const char **params, const char *output,
+                  xmlSAXHandlerPtr SAX, xmlOutputBufferPtr IObuf,
+                 FILE * profile, xsltTransformContextPtr userCtxt)
+{
+    xmlDocPtr tmp;
+    int ret;
+
+    if ((output == NULL) && (SAX == NULL) && (IObuf == NULL))
+        return (-1);
+    if ((SAX != NULL) && (IObuf != NULL))
+        return (-1);
+
+    /* unsupported yet */
+    if (SAX != NULL) {
+        XSLT_TODO   /* xsltRunStylesheet xmlSAXHandlerPtr SAX */
+       return (-1);
+    }
+
+    tmp = xsltApplyStylesheetInternal(style, doc, params, output, profile,
+                                     userCtxt);
+    if (tmp == NULL) {
+       xsltTransformError(NULL, NULL, (xmlNodePtr) doc,
+                         "xsltRunStylesheet : run failed\n");
+        return (-1);
+    }
+    if (IObuf != NULL) {
+        /* TODO: incomplete, IObuf output not progressive */
+        ret = xsltSaveResultTo(IObuf, tmp, style);
+    } else {
+        ret = xsltSaveResultToFilename(output, tmp, style, 0);
+    }
+    xmlFreeDoc(tmp);
+    return (ret);
+}
+
+/**
+ * xsltRunStylesheet:
+ * @style:  a parsed XSLT stylesheet
+ * @doc:  a parsed XML document
+ * @params:  a NULL terminated array of parameters names/values tuples
+ * @output:  the URL/filename ot the generated resource if available
+ * @SAX:  a SAX handler for progressive callback output (not implemented yet)
+ * @IObuf:  an output buffer for progressive output (not implemented yet)
+ *
+ * Apply the stylesheet to the document and generate the output according
+ * to @output @SAX and @IObuf. It's an error to specify both @SAX and @IObuf.
+ *
+ * NOTE: This may lead to a non-wellformed output XML wise !
+ * NOTE: This may also result in multiple files being generated
+ * NOTE: using IObuf, the result encoding used will be the one used for
+ *       creating the output buffer, use the following macro to read it
+ *       from the stylesheet
+ *       XSLT_GET_IMPORT_PTR(encoding, style, encoding)
+ * NOTE: using SAX, any encoding specified in the stylesheet will be lost
+ *       since the interface uses only UTF8
+ *
+ * Returns the number of bytes written to the main resource or -1 in case of
+ *         error.
+ */
+int
+xsltRunStylesheet(xsltStylesheetPtr style, xmlDocPtr doc,
+                  const char **params, const char *output,
+                  xmlSAXHandlerPtr SAX, xmlOutputBufferPtr IObuf)
+{
+    return(xsltRunStylesheetUser(style, doc, params, output, SAX, IObuf,
+                                NULL, NULL));
+}
+
+/**
+ * xsltRegisterAllElement:
+ * @ctxt:  the XPath context
+ *
+ * Registers all default XSLT elements in this context
+ */
+void
+xsltRegisterAllElement(xsltTransformContextPtr ctxt)
+{
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "apply-templates",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltApplyTemplates);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "apply-imports",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltApplyImports);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "call-template",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltCallTemplate);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "element",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltElement);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "attribute",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltAttribute);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "text",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltText);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "processing-instruction",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltProcessingInstruction);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "comment",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltComment);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "copy",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltCopy);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "value-of",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltValueOf);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "number",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltNumber);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "for-each",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltForEach);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "if",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltIf);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "choose",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltChoose);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "sort",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltSort);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "copy-of",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltCopyOf);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "message",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltMessage);
+
+    /*
+     * Those don't have callable entry points but are registered anyway
+     */
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "variable",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltDebug);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "param",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltDebug);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "with-param",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltDebug);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "decimal-format",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltDebug);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "when",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltDebug);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "otherwise",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltDebug);
+    xsltRegisterExtElement(ctxt, (const xmlChar *) "fallback",
+                           XSLT_NAMESPACE,
+                          (xsltTransformFunction) xsltDebug);
+
+}
diff --git a/reactos/dll/3rdparty/libxslt/transform.h b/reactos/dll/3rdparty/libxslt/transform.h
new file mode 100644 (file)
index 0000000..105ac2d
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ * Summary: the XSLT engine transformation part.
+ * Description: This module implements the bulk of the actual
+ *              transformation processing. Most of the xsl: element
+ *              constructs are implemented in this module.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_TRANSFORM_H__
+#define __XML_XSLT_TRANSFORM_H__
+
+#include <libxml/parser.h>
+#include <libxml/xmlIO.h>
+#include "xsltexports.h"
+#include <libxslt/xsltInternals.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * XInclude default processing.
+ */
+XSLTPUBFUN void XSLTCALL               
+               xsltSetXIncludeDefault  (int xinclude);
+XSLTPUBFUN int XSLTCALL                
+               xsltGetXIncludeDefault  (void);
+
+/**
+ * Export context to users.
+ */
+XSLTPUBFUN xsltTransformContextPtr XSLTCALL 
+               xsltNewTransformContext (xsltStylesheetPtr style,
+                                        xmlDocPtr doc);
+
+XSLTPUBFUN void XSLTCALL                       
+               xsltFreeTransformContext(xsltTransformContextPtr ctxt);
+
+XSLTPUBFUN xmlDocPtr XSLTCALL          
+               xsltApplyStylesheetUser (xsltStylesheetPtr style,
+                                        xmlDocPtr doc,
+                                        const char **params,
+                                        const char *output,
+                                        FILE * profile,
+                                        xsltTransformContextPtr userCtxt);
+/**
+ * Private Interfaces.
+ */
+XSLTPUBFUN void XSLTCALL               
+               xsltApplyStripSpaces    (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node);
+XSLTPUBFUN xmlDocPtr XSLTCALL  
+               xsltApplyStylesheet     (xsltStylesheetPtr style,
+                                        xmlDocPtr doc,
+                                        const char **params);
+XSLTPUBFUN xmlDocPtr XSLTCALL  
+               xsltProfileStylesheet   (xsltStylesheetPtr style,
+                                        xmlDocPtr doc,
+                                        const char **params,
+                                        FILE * output);
+XSLTPUBFUN int XSLTCALL                
+               xsltRunStylesheet       (xsltStylesheetPtr style,
+                                        xmlDocPtr doc,
+                                        const char **params,
+                                        const char *output,
+                                        xmlSAXHandlerPtr SAX,
+                                        xmlOutputBufferPtr IObuf);
+XSLTPUBFUN int XSLTCALL                
+               xsltRunStylesheetUser   (xsltStylesheetPtr style,
+                                        xmlDocPtr doc,
+                                        const char **params,
+                                        const char *output,
+                                        xmlSAXHandlerPtr SAX,
+                                        xmlOutputBufferPtr IObuf,
+                                        FILE * profile,
+                                        xsltTransformContextPtr userCtxt);
+XSLTPUBFUN void XSLTCALL               
+               xsltApplyOneTemplate    (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr list,
+                                        xsltTemplatePtr templ,
+                                        xsltStackElemPtr params);
+XSLTPUBFUN void XSLTCALL               
+               xsltDocumentElem        (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltSort                (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltCopy                (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltText                (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltElement             (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltComment             (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltAttribute           (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltProcessingInstruction(xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltCopyOf              (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltValueOf             (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltNumber              (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltApplyImports        (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltCallTemplate        (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltApplyTemplates      (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltChoose              (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltIf                  (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltForEach             (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltRegisterAllElement  (xsltTransformContextPtr ctxt);
+
+XSLTPUBFUN xmlNodePtr XSLTCALL 
+               xsltCopyTextString      (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr target,
+                                        const xmlChar *string,
+                                        int noescape);
+
+/* Following 2 functions needed for libexslt/functions.c */
+XSLTPUBFUN void XSLTCALL
+               xsltLocalVariablePop    (xsltTransformContextPtr ctxt,
+                                        int limitNr,
+                                        int level);
+XSLTPUBFUN int XSLTCALL
+               xsltLocalVariablePush   (xsltTransformContextPtr ctxt,
+                                        xsltStackElemPtr variable,
+                                        int level);
+/*
+ * Hook for the debugger if activated.
+ */
+XSLTPUBFUN void XSLTCALL               
+               xslHandleDebugger       (xmlNodePtr cur,
+                                        xmlNodePtr node,
+                                        xsltTemplatePtr templ,
+                                        xsltTransformContextPtr ctxt);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_TRANSFORM_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/trio.h b/reactos/dll/3rdparty/libxslt/trio.h
new file mode 100644 (file)
index 0000000..b788dc8
--- /dev/null
@@ -0,0 +1,216 @@
+/*************************************************************************
+ *
+ * $Id: trio.h 897 2003-04-07 12:41:56Z veillard $
+ *
+ * Copyright (C) 1998 Bjorn Reese and Daniel Stenberg.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
+ * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
+ *
+ *************************************************************************
+ *
+ * http://ctrio.sourceforge.net/
+ *
+ ************************************************************************/
+
+#ifndef TRIO_TRIO_H
+#define TRIO_TRIO_H
+
+#if !defined(WITHOUT_TRIO)
+
+/*
+ * Use autoconf defines if present. Packages using trio must define
+ * HAVE_CONFIG_H as a compiler option themselves.
+ */
+#if defined(HAVE_CONFIG_H)
+# include <config.h>
+#endif
+
+#include "triodef.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#if defined(TRIO_COMPILER_ANCIENT)
+# include <varargs.h>
+#else
+# include <stdarg.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Error codes.
+ *
+ * Remember to add a textual description to trio_strerror.
+ */
+enum {
+  TRIO_EOF      = 1,
+  TRIO_EINVAL   = 2,
+  TRIO_ETOOMANY = 3,
+  TRIO_EDBLREF  = 4,
+  TRIO_EGAP     = 5,
+  TRIO_ENOMEM   = 6,
+  TRIO_ERANGE   = 7,
+  TRIO_ERRNO    = 8,
+  TRIO_ECUSTOM  = 9
+};
+
+/* Error macros */
+#define TRIO_ERROR_CODE(x) ((-(x)) & 0x00FF)
+#define TRIO_ERROR_POSITION(x) ((-(x)) >> 8)
+#define TRIO_ERROR_NAME(x) trio_strerror(x)
+
+typedef int (*trio_outstream_t) TRIO_PROTO((trio_pointer_t, int));
+typedef int (*trio_instream_t) TRIO_PROTO((trio_pointer_t));
+
+TRIO_CONST char *trio_strerror TRIO_PROTO((int));
+
+/*************************************************************************
+ * Print Functions
+ */
+
+int trio_printf TRIO_PROTO((TRIO_CONST char *format, ...));
+int trio_vprintf TRIO_PROTO((TRIO_CONST char *format, va_list args));
+int trio_printfv TRIO_PROTO((TRIO_CONST char *format, void **args));
+
+int trio_fprintf TRIO_PROTO((FILE *file, TRIO_CONST char *format, ...));
+int trio_vfprintf TRIO_PROTO((FILE *file, TRIO_CONST char *format, va_list args));
+int trio_fprintfv TRIO_PROTO((FILE *file, TRIO_CONST char *format, void **args));
+
+int trio_dprintf TRIO_PROTO((int fd, TRIO_CONST char *format, ...));
+int trio_vdprintf TRIO_PROTO((int fd, TRIO_CONST char *format, va_list args));
+int trio_dprintfv TRIO_PROTO((int fd, TRIO_CONST char *format, void **args));
+
+int trio_cprintf TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure,
+                            TRIO_CONST char *format, ...));
+int trio_vcprintf TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure,
+                             TRIO_CONST char *format, va_list args));
+int trio_cprintfv TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure,
+                             TRIO_CONST char *format, void **args));
+
+int trio_sprintf TRIO_PROTO((char *buffer, TRIO_CONST char *format, ...));
+int trio_vsprintf TRIO_PROTO((char *buffer, TRIO_CONST char *format, va_list args));
+int trio_sprintfv TRIO_PROTO((char *buffer, TRIO_CONST char *format, void **args));
+
+int trio_snprintf TRIO_PROTO((char *buffer, size_t max, TRIO_CONST char *format, ...));
+int trio_vsnprintf TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format,
+                  va_list args));
+int trio_snprintfv TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format,
+                  void **args));
+
+int trio_snprintfcat TRIO_PROTO((char *buffer, size_t max, TRIO_CONST char *format, ...));
+int trio_vsnprintfcat TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format,
+                      va_list args));
+
+char *trio_aprintf TRIO_PROTO((TRIO_CONST char *format, ...));
+char *trio_vaprintf TRIO_PROTO((TRIO_CONST char *format, va_list args));
+
+int trio_asprintf TRIO_PROTO((char **ret, TRIO_CONST char *format, ...));
+int trio_vasprintf TRIO_PROTO((char **ret, TRIO_CONST char *format, va_list args));
+
+/*************************************************************************
+ * Scan Functions
+ */
+int trio_scanf TRIO_PROTO((TRIO_CONST char *format, ...));
+int trio_vscanf TRIO_PROTO((TRIO_CONST char *format, va_list args));
+int trio_scanfv TRIO_PROTO((TRIO_CONST char *format, void **args));
+
+int trio_fscanf TRIO_PROTO((FILE *file, TRIO_CONST char *format, ...));
+int trio_vfscanf TRIO_PROTO((FILE *file, TRIO_CONST char *format, va_list args));
+int trio_fscanfv TRIO_PROTO((FILE *file, TRIO_CONST char *format, void **args));
+
+int trio_dscanf TRIO_PROTO((int fd, TRIO_CONST char *format, ...));
+int trio_vdscanf TRIO_PROTO((int fd, TRIO_CONST char *format, va_list args));
+int trio_dscanfv TRIO_PROTO((int fd, TRIO_CONST char *format, void **args));
+
+int trio_cscanf TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure,
+                           TRIO_CONST char *format, ...));
+int trio_vcscanf TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure,
+                            TRIO_CONST char *format, va_list args));
+int trio_cscanfv TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure,
+                            TRIO_CONST char *format, void **args));
+
+int trio_sscanf TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, ...));
+int trio_vsscanf TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, va_list args));
+int trio_sscanfv TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, void **args));
+
+/*************************************************************************
+ * Locale Functions
+ */
+void trio_locale_set_decimal_point TRIO_PROTO((char *decimalPoint));
+void trio_locale_set_thousand_separator TRIO_PROTO((char *thousandSeparator));
+void trio_locale_set_grouping TRIO_PROTO((char *grouping));
+
+/*************************************************************************
+ * Renaming
+ */
+#ifdef TRIO_REPLACE_STDIO
+/* Replace the <stdio.h> functions */
+#ifndef HAVE_PRINTF
+# define printf trio_printf
+#endif
+#ifndef HAVE_VPRINTF
+# define vprintf trio_vprintf
+#endif
+#ifndef HAVE_FPRINTF
+# define fprintf trio_fprintf
+#endif
+#ifndef HAVE_VFPRINTF
+# define vfprintf trio_vfprintf
+#endif
+#ifndef HAVE_SPRINTF
+# define sprintf trio_sprintf
+#endif
+#ifndef HAVE_VSPRINTF
+# define vsprintf trio_vsprintf
+#endif
+#ifndef HAVE_SNPRINTF
+# define snprintf trio_snprintf
+#endif
+#ifndef HAVE_VSNPRINTF
+# define vsnprintf trio_vsnprintf
+#endif
+#ifndef HAVE_SCANF
+# define scanf trio_scanf
+#endif
+#ifndef HAVE_VSCANF
+# define vscanf trio_vscanf
+#endif
+#ifndef HAVE_FSCANF
+# define fscanf trio_fscanf
+#endif
+#ifndef HAVE_VFSCANF
+# define vfscanf trio_vfscanf
+#endif
+#ifndef HAVE_SSCANF
+# define sscanf trio_sscanf
+#endif
+#ifndef HAVE_VSSCANF
+# define vsscanf trio_vsscanf
+#endif
+/* These aren't stdio functions, but we make them look similar */
+#define dprintf trio_dprintf
+#define vdprintf trio_vdprintf
+#define aprintf trio_aprintf
+#define vaprintf trio_vaprintf
+#define asprintf trio_asprintf
+#define vasprintf trio_vasprintf
+#define dscanf trio_dscanf
+#define vdscanf trio_vdscanf
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* WITHOUT_TRIO */
+
+#endif /* TRIO_TRIO_H */
diff --git a/reactos/dll/3rdparty/libxslt/triodef.h b/reactos/dll/3rdparty/libxslt/triodef.h
new file mode 100644 (file)
index 0000000..58c7fce
--- /dev/null
@@ -0,0 +1,220 @@
+/*************************************************************************
+ *
+ * $Id: triodef.h 912 2003-04-26 12:06:36Z veillard $
+ *
+ * Copyright (C) 2001 Bjorn Reese <breese@users.sourceforge.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
+ * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
+ *
+ ************************************************************************/
+
+#ifndef TRIO_TRIODEF_H
+#define TRIO_TRIODEF_H
+
+/*************************************************************************
+ * Platform and compiler support detection
+ */
+#if defined(__GNUC__)
+# define TRIO_COMPILER_GCC
+#elif defined(__SUNPRO_C)
+# define TRIO_COMPILER_SUNPRO
+#elif defined(__SUNPRO_CC)
+# define TRIO_COMPILER_SUNPRO
+# define __SUNPRO_C __SUNPRO_CC
+#elif defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__)
+# define TRIO_COMPILER_XLC
+#elif defined(_AIX) && !defined(__GNUC__)
+# define TRIO_COMPILER_XLC /* Workaround for old xlc */
+#elif defined(__DECC) || defined(__DECCXX)
+# define TRIO_COMPILER_DECC
+#elif defined(__osf__) && defined(__LANGUAGE_C__)
+# define TRIO_COMPILER_DECC /* Workaround for old DEC C compilers */
+#elif defined(_MSC_VER)
+# define TRIO_COMPILER_MSVC
+#elif defined(__BORLANDC__)
+# define TRIO_COMPILER_BCB
+#endif
+
+#if defined(VMS) || defined(__VMS)
+/*
+ * VMS is placed first to avoid identifying the platform as Unix
+ * based on the DECC compiler later on.
+ */
+# define TRIO_PLATFORM_VMS
+#elif defined(unix) || defined(__unix) || defined(__unix__)
+# define TRIO_PLATFORM_UNIX
+#elif defined(TRIO_COMPILER_XLC) || defined(_AIX)
+# define TRIO_PLATFORM_UNIX
+#elif defined(TRIO_COMPILER_DECC) || defined(__osf___)
+# define TRIO_PLATFORM_UNIX
+#elif defined(__NetBSD__)
+# define TRIO_PLATFORM_UNIX
+#elif defined(__QNX__)
+# define TRIO_PLATFORM_UNIX
+# define TRIO_PLATFORM_QNX
+#elif defined(__CYGWIN__)
+# define TRIO_PLATFORM_UNIX
+#elif defined(AMIGA) && defined(TRIO_COMPILER_GCC)
+# define TRIO_PLATFORM_UNIX
+#elif defined(TRIO_COMPILER_MSVC) || defined(WIN32) || defined(_WIN32)
+# define TRIO_PLATFORM_WIN32
+#elif defined(mpeix) || defined(__mpexl)
+# define TRIO_PLATFORM_MPEIX
+#endif
+
+#if defined(_AIX)
+# define TRIO_PLATFORM_AIX
+#elif defined(__hpux)
+# define TRIO_PLATFORM_HPUX
+#elif defined(sun) || defined(__sun__)
+# if defined(__SVR4) || defined(__svr4__)
+#  define TRIO_PLATFORM_SOLARIS
+# else
+#  define TRIO_PLATFORM_SUNOS
+# endif
+#endif
+
+#if defined(__STDC__) || defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
+# define TRIO_COMPILER_SUPPORTS_C89
+# if defined(__STDC_VERSION__)
+#  define TRIO_COMPILER_SUPPORTS_C90
+#  if (__STDC_VERSION__ >= 199409L)
+#   define TRIO_COMPILER_SUPPORTS_C94
+#  endif
+#  if (__STDC_VERSION__ >= 199901L)
+#   define TRIO_COMPILER_SUPPORTS_C99
+#  endif
+# elif defined(TRIO_COMPILER_SUNPRO)
+#  if (__SUNPRO_C >= 0x420)
+#   define TRIO_COMPILER_SUPPORTS_C94
+#  endif
+# endif
+#endif
+
+#if defined(_XOPEN_SOURCE)
+# if defined(_XOPEN_SOURCE_EXTENDED)
+#  define TRIO_COMPILER_SUPPORTS_UNIX95
+# endif
+# if (_XOPEN_VERSION >= 500)
+#  define TRIO_COMPILER_SUPPORTS_UNIX98
+# endif
+# if (_XOPEN_VERSION >= 600)
+#  define TRIO_COMPILER_SUPPORTS_UNIX01
+# endif
+#endif
+
+/*************************************************************************
+ * Generic defines
+ */
+
+#if !defined(TRIO_PUBLIC)
+# define TRIO_PUBLIC
+#endif
+#if !defined(TRIO_PRIVATE)
+# define TRIO_PRIVATE static
+#endif
+
+#if !(defined(TRIO_COMPILER_SUPPORTS_C89) || defined(__cplusplus))
+# define TRIO_COMPILER_ANCIENT
+#endif
+
+#if defined(TRIO_COMPILER_ANCIENT)
+# define TRIO_CONST
+# define TRIO_VOLATILE
+# define TRIO_SIGNED
+typedef double trio_long_double_t;
+typedef char * trio_pointer_t;
+# define TRIO_SUFFIX_LONG(x) x
+# define TRIO_PROTO(x) ()
+# define TRIO_NOARGS
+# define TRIO_ARGS1(list,a1) list a1;
+# define TRIO_ARGS2(list,a1,a2) list a1; a2;
+# define TRIO_ARGS3(list,a1,a2,a3) list a1; a2; a3;
+# define TRIO_ARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4;
+# define TRIO_ARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5;
+# define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) list a1; a2; a3; a4; a5; a6;
+# define TRIO_VARGS2(list,a1,a2) list a1; a2
+# define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3
+# define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4
+# define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5
+# define TRIO_VA_DECL va_dcl
+# define TRIO_VA_START(x,y) va_start(x)
+# define TRIO_VA_END(x) va_end(x)
+#else /* ANSI C */
+# define TRIO_CONST const
+# define TRIO_VOLATILE volatile
+# define TRIO_SIGNED signed
+typedef long double trio_long_double_t;
+typedef void * trio_pointer_t;
+# define TRIO_SUFFIX_LONG(x) x ## L
+# define TRIO_PROTO(x) x
+# define TRIO_NOARGS void
+# define TRIO_ARGS1(list,a1) (a1)
+# define TRIO_ARGS2(list,a1,a2) (a1,a2)
+# define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3)
+# define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4)
+# define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5)
+# define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
+# define TRIO_VARGS2 TRIO_ARGS2
+# define TRIO_VARGS3 TRIO_ARGS3
+# define TRIO_VARGS4 TRIO_ARGS4
+# define TRIO_VARGS5 TRIO_ARGS5
+# define TRIO_VA_DECL ...
+# define TRIO_VA_START(x,y) va_start(x,y)
+# define TRIO_VA_END(x) va_end(x)
+#endif
+
+#if defined(TRIO_COMPILER_SUPPORTS_C99) || defined(__cplusplus)
+# define TRIO_INLINE inline
+#elif defined(TRIO_COMPILER_GCC)
+# define TRIO_INLINE __inline__
+#elif defined(TRIO_COMPILER_MSVC)
+# define TRIO_INLINE _inline
+#elif defined(TRIO_COMPILER_BCB)
+# define TRIO_INLINE __inline
+#else
+# define TRIO_INLINE
+#endif
+
+/*************************************************************************
+ * Workarounds
+ */
+
+#if defined(TRIO_PLATFORM_VMS)
+/*
+ * Computations done with constants at compile time can trigger these
+ * even when compiling with IEEE enabled.
+ */
+# pragma message disable (UNDERFLOW, FLOATOVERFL)
+
+# if (__CRTL_VER < 80000000)
+/*
+ * Although the compiler supports C99 language constructs, the C
+ * run-time library does not contain all C99 functions.
+ *
+ * This was the case for 70300022. Update the 80000000 value when
+ * it has been accurately determined what version of the library
+ * supports C99.
+ */
+#  if defined(TRIO_COMPILER_SUPPORTS_C99)
+#   undef TRIO_COMPILER_SUPPORTS_C99
+#  endif
+# endif
+#endif
+
+/*
+ * Not all preprocessors supports the LL token.
+ */
+#if defined(TRIO_COMPILER_BCB)
+#else
+# define TRIO_COMPILER_SUPPORTS_LL
+#endif
+
+#endif /* TRIO_TRIODEF_H */
diff --git a/reactos/dll/3rdparty/libxslt/variables.c b/reactos/dll/3rdparty/libxslt/variables.c
new file mode 100644 (file)
index 0000000..1cdfa80
--- /dev/null
@@ -0,0 +1,2308 @@
+/*
+ * variables.c: Implementation of the variable storage and lookup
+ *
+ * Reference:
+ *   http://www.w3.org/TR/1999/REC-xslt-19991116
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/valid.h>
+#include <libxml/hash.h>
+#include <libxml/xmlerror.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+#include <libxml/parserInternals.h>
+#include <libxml/dict.h>
+#include "xslt.h"
+#include "xsltInternals.h"
+#include "xsltutils.h"
+#include "variables.h"
+#include "transform.h"
+#include "imports.h"
+#include "preproc.h"
+#include "keys.h"
+
+#ifdef WITH_XSLT_DEBUG
+ #define WITH_XSLT_DEBUG_VARIABLE
+#endif
+
+#ifdef XSLT_REFACTORED
+const xmlChar *xsltDocFragFake = (const xmlChar *) " fake node libxslt";
+#endif
+
+const xmlChar *xsltComputingGlobalVarMarker =
+ (const xmlChar *) " var/param being computed";
+
+/************************************************************************
+ *                                                                     *
+ *  Result Value Tree (Result Tree Fragment) interfaces                        *
+ *                                                                     *
+ ************************************************************************/
+/**
+ * xsltCreateRVT:
+ * @ctxt:  an XSLT transformation context
+ *
+ * Creates a Result Value Tree
+ * (the XSLT 1.0 term for this is "Result Tree Fragment") 
+ *
+ * Returns the result value tree or NULL in case of API or internal errors.
+ */
+xmlDocPtr
+xsltCreateRVT(xsltTransformContextPtr ctxt)
+{
+    xmlDocPtr container;
+
+    /*
+    * Question: Why is this function public?
+    * Answer: It is called by the EXSLT module.
+    */    
+    if (ctxt == NULL)
+       return(NULL);
+
+    /*
+    * Reuse a RTF from the cache if available.
+    */
+    if (ctxt->cache->RVT) {
+       container = ctxt->cache->RVT;
+       ctxt->cache->RVT = (xmlDocPtr) container->next;
+       /* clear the internal pointers */
+       container->next = NULL;
+       container->prev = NULL;
+       if (ctxt->cache->nbRVT > 0)
+           ctxt->cache->nbRVT--;
+#ifdef XSLT_DEBUG_PROFILE_CACHE
+       ctxt->cache->dbgReusedRVTs++;
+#endif
+       return(container);
+    }
+
+    container = xmlNewDoc(NULL);
+    if (container == NULL)
+       return(NULL);
+    container->dict = ctxt->dict;
+    xmlDictReference(container->dict);
+    XSLT_MARK_RES_TREE_FRAG(container);
+    container->doc = container;
+    container->parent = NULL;
+    return(container);
+}
+
+/**
+ * xsltRegisterTmpRVT:
+ * @ctxt:  an XSLT transformation context
+ * @RVT:  a result value tree (Result Tree Fragment)
+ *
+ * Registers the result value tree (XSLT 1.0 term: Result Tree Fragment)
+ * in the garbage collector.
+ * The fragment will be freed at the exit of the currently
+ * instantiated xsl:template.
+ * Obsolete; this function might produce massive memory overhead,
+ * since the fragment is only freed when the current xsl:template
+ * exits. Use xsltRegisterLocalRVT() instead.
+ *
+ * Returns 0 in case of success and -1 in case of API or internal errors.
+ */
+int
+xsltRegisterTmpRVT(xsltTransformContextPtr ctxt, xmlDocPtr RVT)
+{
+    if ((ctxt == NULL) || (RVT == NULL))
+       return(-1);
+
+    /*
+    * We'll restrict the lifetime of user-created fragments
+    * insinde an xsl:variable and xsl:param to the lifetime of the
+    * var/param itself.
+    */
+    if (ctxt->contextVariable != NULL) {
+       RVT->next = (xmlNodePtr) XSLT_TCTXT_VARIABLE(ctxt)->fragment;
+       XSLT_TCTXT_VARIABLE(ctxt)->fragment = RVT;
+       return(0);
+    }
+
+    RVT->next = (xmlNodePtr) ctxt->tmpRVT;
+    if (ctxt->tmpRVT != NULL)
+       ctxt->tmpRVT->prev = (xmlNodePtr) RVT;
+    ctxt->tmpRVT = RVT;
+    return(0);
+}
+
+/**
+ * xsltRegisterLocalRVT:
+ * @ctxt:  an XSLT transformation context
+ * @RVT:  a result value tree (Result Tree Fragment; xmlDocPtr)
+ *
+ * Registers a result value tree (XSLT 1.0 term: Result Tree Fragment)
+ * in the RVT garbage collector.
+ * The fragment will be freed when the instruction which created the
+ * fragment exits.
+ *
+ * Returns 0 in case of success and -1 in case of API or internal errors.
+ */
+int
+xsltRegisterLocalRVT(xsltTransformContextPtr ctxt,
+                    xmlDocPtr RVT)
+{
+    if ((ctxt == NULL) || (RVT == NULL))
+       return(-1);
+    
+    /*
+    * When evaluating "select" expressions of xsl:variable
+    * and xsl:param, we need to bind newly created tree fragments
+    * to the variable itself; otherwise the tragment will be
+    * freed before we leave the scope of a var.
+    */
+    if ((ctxt->contextVariable != NULL) &&
+       (XSLT_TCTXT_VARIABLE(ctxt)->flags & XSLT_VAR_IN_SELECT))
+    {
+       RVT->next = (xmlNodePtr) XSLT_TCTXT_VARIABLE(ctxt)->fragment;
+       XSLT_TCTXT_VARIABLE(ctxt)->fragment = RVT;
+       return(0);
+    }
+    /*
+    * Store the fragment in the scope of the current instruction.
+    * If not reference by a returning instruction (like EXSLT's function),
+    * then this fragment will be freed, when the instruction exits.
+    */
+    RVT->next = (xmlNodePtr) ctxt->localRVT;
+    if (ctxt->localRVT != NULL)
+       ctxt->localRVT->prev = (xmlNodePtr) RVT;
+    ctxt->localRVT = RVT;
+    /*
+    * We need to keep track of the first registered fragment
+    * for extension instructions which return fragments
+    * (e.g. EXSLT'S function), in order to let
+    * xsltExtensionInstructionResultFinalize() clear the
+    * preserving flag on the fragments.
+    */
+    if (ctxt->localRVTBase == NULL)
+       ctxt->localRVTBase = RVT;
+    return(0);
+}
+
+/**
+ * xsltExtensionInstructionResultFinalize:
+ * @ctxt:  an XSLT transformation context
+ *
+ * Finalizes the data (e.g. result tree fragments) created
+ * within a value-returning process (e.g. EXSLT's function).
+ * Tree fragments marked as being returned by a function are
+ * set to normal state, which means that the fragment garbage
+ * collector will free them after the function-calling process exits.
+ *
+ * Returns 0 in case of success and -1 in case of API or internal errors.
+ */
+int
+xsltExtensionInstructionResultFinalize(xsltTransformContextPtr ctxt)
+{
+    xmlDocPtr cur;
+
+    if (ctxt == NULL)
+       return(-1);
+    if (ctxt->localRVTBase == NULL)
+       return(0);
+    /*
+    * Enable remaining local tree fragments to be freed
+    * by the fragment garbage collector.
+    */
+    cur = ctxt->localRVTBase;
+    do {
+       cur->psvi = NULL;
+       cur = (xmlDocPtr) cur->next;
+    } while (cur != NULL);
+    return(0);
+}
+
+/**
+ * xsltExtensionInstructionResultRegister:
+ * @ctxt: an XSLT transformation context
+ * @obj: an XPath object to be inspected for result tree fragments
+ *
+ * Marks the result of a value-returning extension instruction
+ * in order to avoid it being garbage collected before the
+ * extension instruction exits.
+ * Note that one still has to additionally register any newly created
+ * tree fragments (via xsltCreateRVT()) with xsltRegisterLocalRVT().
+ *
+ * Returns 0 in case of success and -1 in case of error.
+ */
+int
+xsltExtensionInstructionResultRegister(xsltTransformContextPtr ctxt,
+                                      xmlXPathObjectPtr obj)
+{
+    int i;
+    xmlNodePtr cur;
+    xmlDocPtr doc;
+
+    if ((ctxt == NULL) || (obj == NULL))
+       return(-1);
+
+    /*
+    * OPTIMIZE TODO: If no local variables/params and no local tree
+    * fragments were created, then we don't need to analyse the XPath
+    * objects for tree fragments.
+    */
+
+    if ((obj->type != XPATH_NODESET) && (obj->type != XPATH_XSLT_TREE))
+       return(0);
+    if ((obj->nodesetval == NULL) || (obj->nodesetval->nodeNr == 0))
+       return(0);
+
+    for (i = 0; i < obj->nodesetval->nodeNr; i++) {
+       cur = obj->nodesetval->nodeTab[i];
+       if (cur->type == XML_NAMESPACE_DECL) {
+           /*
+           * The XPath module sets the owner element of a ns-node on
+           * the ns->next field.
+           */
+           if ((((xmlNsPtr) cur)->next != NULL) &&
+               (((xmlNsPtr) cur)->next->type == XML_ELEMENT_NODE))
+           {
+               cur = (xmlNodePtr) ((xmlNsPtr) cur)->next;
+               doc = cur->doc; 
+           } else {
+               xsltTransformError(ctxt, NULL, ctxt->inst,
+                   "Internal error in "
+                   "xsltExtensionInstructionResultRegister(): "
+                   "Cannot retrieve the doc of a namespace node.\n");
+               goto error;
+           }
+       } else {
+           doc = cur->doc;
+       }
+       if (doc == NULL) {
+           xsltTransformError(ctxt, NULL, ctxt->inst,
+               "Internal error in "
+               "xsltExtensionInstructionResultRegister(): "
+               "Cannot retrieve the doc of a node.\n");
+           goto error;
+       }
+       if (doc->name && (doc->name[0] == ' ')) {
+           /*
+           * This is a result tree fragment.
+           * We'll use the @psvi field for reference counting.
+           * TODO: How do we know if this is a value of a
+           *  global variable or a doc acquired via the
+           *  document() function?
+           */
+           doc->psvi = (void *) ((long) 1);
+       }
+    }
+
+    return(0);
+error:
+    return(-1);
+}
+
+/**
+ * xsltReleaseRVT:
+ * @ctxt:  an XSLT transformation context
+ * @RVT:  a result value tree (Result Tree Fragment)
+ *
+ * Either frees the RVT (which is an xmlDoc) or stores
+ * it in the context's cache for later reuse.
+ */
+void
+xsltReleaseRVT(xsltTransformContextPtr ctxt, xmlDocPtr RVT)
+{
+    if (RVT == NULL)
+       return;
+
+    if (ctxt && (ctxt->cache->nbRVT < 40)) {
+       /*
+       * Store the Result Tree Fragment.
+       * Free the document info.
+       */
+       if (RVT->_private != NULL) {
+           xsltFreeDocumentKeys((xsltDocumentPtr) RVT->_private);
+           xmlFree(RVT->_private);
+           RVT->_private = NULL;
+       }
+       /*
+       * Clear the document tree.
+       * REVISIT TODO: Do we expect ID/IDREF tables to be existent?    
+       */
+       if (RVT->children != NULL) {
+           xmlFreeNodeList(RVT->children);
+           RVT->children = NULL;
+           RVT->last = NULL;
+       }
+       if (RVT->ids != NULL) {
+           xmlFreeIDTable((xmlIDTablePtr) RVT->ids);
+           RVT->ids = NULL;
+       }
+       if (RVT->refs != NULL) {
+           xmlFreeRefTable((xmlRefTablePtr) RVT->refs);
+           RVT->refs = NULL;
+       }
+
+       /*
+       * Reset the reference counter.
+       */
+       RVT->psvi = 0;
+
+       RVT->next = (xmlNodePtr) ctxt->cache->RVT;
+       ctxt->cache->RVT = RVT;
+
+       ctxt->cache->nbRVT++;
+
+#ifdef XSLT_DEBUG_PROFILE_CACHE
+       ctxt->cache->dbgCachedRVTs++;
+#endif
+       return;
+    }
+    /*
+    * Free it.
+    */
+    if (RVT->_private != NULL) {
+       xsltFreeDocumentKeys((xsltDocumentPtr) RVT->_private);
+       xmlFree(RVT->_private);
+    }
+    xmlFreeDoc(RVT);
+}
+
+/**
+ * xsltRegisterPersistRVT:
+ * @ctxt:  an XSLT transformation context
+ * @RVT:  a result value tree (Result Tree Fragment)
+ *
+ * Register the result value tree (XSLT 1.0 term: Result Tree Fragment)
+ * in the fragment garbage collector.
+ * The fragment will be freed when the transformation context is
+ * freed.
+ *
+ * Returns 0 in case of success and -1 in case of error.
+ */
+int
+xsltRegisterPersistRVT(xsltTransformContextPtr ctxt, xmlDocPtr RVT)
+{
+    if ((ctxt == NULL) || (RVT == NULL)) return(-1);
+
+    RVT->next = (xmlNodePtr) ctxt->persistRVT;
+    if (ctxt->persistRVT != NULL)
+       ctxt->persistRVT->prev = (xmlNodePtr) RVT;
+    ctxt->persistRVT = RVT;
+    return(0);
+}
+
+/**
+ * xsltFreeRVTs:
+ * @ctxt:  an XSLT transformation context
+ *
+ * Frees all registered result value trees (Result Tree Fragments)
+ * of the transformation. Internal function; should not be called
+ * by user-code.
+ */
+void
+xsltFreeRVTs(xsltTransformContextPtr ctxt)
+{
+    xmlDocPtr cur, next;
+
+    if (ctxt == NULL)
+       return;
+    /*
+    * Local fragments.
+    */
+    cur = ctxt->localRVT;
+    while (cur != NULL) {
+        next = (xmlDocPtr) cur->next;
+       if (cur->_private != NULL) {
+           xsltFreeDocumentKeys(cur->_private);
+           xmlFree(cur->_private);
+       }
+       xmlFreeDoc(cur);
+       cur = next;
+    }
+    ctxt->localRVT = NULL;
+    /*
+    * User-created per-template fragments.
+    */
+    cur = ctxt->tmpRVT;
+    while (cur != NULL) {
+        next = (xmlDocPtr) cur->next;
+       if (cur->_private != NULL) {
+           xsltFreeDocumentKeys(cur->_private);
+           xmlFree(cur->_private);
+       }
+       xmlFreeDoc(cur);
+       cur = next;
+    }
+    ctxt->tmpRVT = NULL;
+    /*
+    * Global fragments.
+    */
+    cur = ctxt->persistRVT;
+    while (cur != NULL) {
+        next = (xmlDocPtr) cur->next;
+       if (cur->_private != NULL) {
+           xsltFreeDocumentKeys(cur->_private);
+           xmlFree(cur->_private);
+       }
+       xmlFreeDoc(cur);
+       cur = next;
+    }
+    ctxt->persistRVT = NULL;
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     Module interfaces                               *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltNewStackElem:
+ *
+ * Create a new XSLT ParserContext
+ *
+ * Returns the newly allocated xsltParserStackElem or NULL in case of error
+ */
+static xsltStackElemPtr
+xsltNewStackElem(xsltTransformContextPtr ctxt)
+{
+    xsltStackElemPtr ret;
+    /*
+    * Reuse a stack item from the cache if available.
+    */
+    if (ctxt && ctxt->cache->stackItems) {
+       ret = ctxt->cache->stackItems;
+       ctxt->cache->stackItems = ret->next;
+       ret->next = NULL;
+       ctxt->cache->nbStackItems--;
+#ifdef XSLT_DEBUG_PROFILE_CACHE
+       ctxt->cache->dbgReusedVars++;
+#endif
+       return(ret);
+    }
+    ret = (xsltStackElemPtr) xmlMalloc(sizeof(xsltStackElem));
+    if (ret == NULL) {
+       xsltTransformError(NULL, NULL, NULL,
+               "xsltNewStackElem : malloc failed\n");
+       return(NULL);
+    }
+    memset(ret, 0, sizeof(xsltStackElem));
+    ret->context = ctxt;
+    return(ret);
+}
+
+/**
+ * xsltCopyStackElem:
+ * @elem:  an XSLT stack element
+ *
+ * Makes a copy of the stack element
+ *
+ * Returns the copy of NULL
+ */
+static xsltStackElemPtr
+xsltCopyStackElem(xsltStackElemPtr elem) {
+    xsltStackElemPtr cur;
+
+    cur = (xsltStackElemPtr) xmlMalloc(sizeof(xsltStackElem));
+    if (cur == NULL) {
+       xsltTransformError(NULL, NULL, NULL,
+               "xsltCopyStackElem : malloc failed\n");
+       return(NULL);
+    }
+    memset(cur, 0, sizeof(xsltStackElem));
+    cur->context = elem->context;
+    cur->name = elem->name;
+    cur->nameURI = elem->nameURI;
+    cur->select = elem->select;
+    cur->tree = elem->tree;
+    cur->comp = elem->comp;    
+    return(cur);
+}
+
+/**
+ * xsltFreeStackElem:
+ * @elem:  an XSLT stack element
+ *
+ * Free up the memory allocated by @elem
+ */
+static void
+xsltFreeStackElem(xsltStackElemPtr elem) {
+    if (elem == NULL)
+       return;
+    if (elem->value != NULL)
+       xmlXPathFreeObject(elem->value);
+    /*
+    * Release the list of temporary Result Tree Fragments.
+    */
+    if (elem->fragment) {
+       xmlDocPtr cur;
+
+       while (elem->fragment != NULL) {
+           cur = elem->fragment;
+           elem->fragment = (xmlDocPtr) cur->next;
+
+           if (elem->context &&
+               (cur->psvi == (void *) ((long) 1)))
+           {
+               /*
+               * This fragment is a result of an extension instruction
+               * (e.g. XSLT's function) and needs to be preserved until
+               * the instruction exits.
+               * Example: The fragment of the variable must not be freed
+               *  since it is returned by the EXSLT function:
+               *  <f:function name="foo">
+               *   <xsl:variable name="bar">
+               *     <bar/>
+               *   </xsl:variable>
+               *   <f:result select="$bar"/>
+               *  </f:function>
+               * 
+               */
+               xsltRegisterLocalRVT(elem->context, cur);
+           } else {
+               xsltReleaseRVT((xsltTransformContextPtr) elem->context,
+                   cur);
+           }       
+       }
+    }
+    /*
+    * Cache or free the variable structure.
+    */
+    if (elem->context && (elem->context->cache->nbStackItems < 50)) {
+       /*
+       * Store the item in the cache.
+       */
+       xsltTransformContextPtr ctxt = elem->context;
+       memset(elem, 0, sizeof(xsltStackElem));
+       elem->context = ctxt;
+       elem->next = ctxt->cache->stackItems;
+       ctxt->cache->stackItems = elem; 
+       ctxt->cache->nbStackItems++;
+#ifdef XSLT_DEBUG_PROFILE_CACHE
+       ctxt->cache->dbgCachedVars++;
+#endif
+       return;
+    }
+    xmlFree(elem);
+}
+
+/**
+ * xsltFreeStackElemList:
+ * @elem:  an XSLT stack element
+ *
+ * Free up the memory allocated by @elem
+ */
+void
+xsltFreeStackElemList(xsltStackElemPtr elem) {
+    xsltStackElemPtr next;
+    
+    while (elem != NULL) {
+       next = elem->next;
+       xsltFreeStackElem(elem);
+       elem = next;
+    }
+}
+
+/**
+ * xsltStackLookup:
+ * @ctxt:  an XSLT transformation context
+ * @name:  the local part of the name
+ * @nameURI:  the URI part of the name
+ *
+ * Locate an element in the stack based on its name.
+ */
+#if 0 /* TODO: Those seem to have been used for debugging. */
+static int stack_addr = 0;
+static int stack_cmp = 0;
+#endif
+
+static xsltStackElemPtr
+xsltStackLookup(xsltTransformContextPtr ctxt, const xmlChar *name,
+               const xmlChar *nameURI) {
+    int i;
+    xsltStackElemPtr cur;
+
+    if ((ctxt == NULL) || (name == NULL) || (ctxt->varsNr == 0))
+       return(NULL);
+
+    /*
+     * Do the lookup from the top of the stack, but
+     * don't use params being computed in a call-param
+     * First lookup expects the variable name and URI to
+     * come from the disctionnary and hence pointer comparison.
+     */
+    for (i = ctxt->varsNr; i > ctxt->varsBase; i--) {
+       cur = ctxt->varsTab[i-1];
+       while (cur != NULL) {
+           if ((cur->name == name) && (cur->nameURI == nameURI)) {
+#if 0
+               stack_addr++;
+#endif
+               return(cur);
+           }
+           cur = cur->next;
+       }
+    }
+
+    /*
+     * Redo the lookup with interned string compares
+     * to avoid string compares.
+     */
+    name = xmlDictLookup(ctxt->dict, name, -1);
+    if (nameURI != NULL)
+        nameURI = xmlDictLookup(ctxt->dict, nameURI, -1);
+
+    for (i = ctxt->varsNr; i > ctxt->varsBase; i--) {
+       cur = ctxt->varsTab[i-1];
+       while (cur != NULL) {
+           if ((cur->name == name) && (cur->nameURI == nameURI)) {
+#if 0
+               stack_cmp++;
+#endif
+               return(cur);
+           }
+           cur = cur->next;
+       }
+    }
+
+    return(NULL);
+}
+
+/**
+ * xsltCheckStackElem:
+ * @ctxt:  xn XSLT transformation context
+ * @name:  the variable name
+ * @nameURI:  the variable namespace URI
+ *
+ * Checks whether a variable or param is already defined.
+ *
+ * URGENT TODO: Checks for redefinition of vars/params should be
+ *  done only at compilation time.
+ *
+ * Returns 1 if variable is present, 2 if param is present, 3 if this
+ *         is an inherited param, 0 if not found, -1 in case of failure.
+ */
+static int
+xsltCheckStackElem(xsltTransformContextPtr ctxt, const xmlChar *name,
+                  const xmlChar *nameURI) {
+    xsltStackElemPtr cur;
+
+    if ((ctxt == NULL) || (name == NULL))
+       return(-1);
+
+    cur = xsltStackLookup(ctxt, name, nameURI);
+    if (cur == NULL)
+        return(0);
+    if (cur->comp != NULL) {
+        if (cur->comp->type == XSLT_FUNC_WITHPARAM)
+           return(3);
+       else if (cur->comp->type == XSLT_FUNC_PARAM)
+           return(2);
+    }
+    
+    return(1);
+}
+
+/**
+ * xsltAddStackElem:
+ * @ctxt:  xn XSLT transformation context
+ * @elem:  a stack element
+ *
+ * Push an element (or list) onto the stack.
+ * In case of a list, each member will be pushed into
+ * a seperate slot; i.e. there's always 1 stack entry for
+ * 1 stack element.
+ *
+ * Returns 0 in case of success, -1 in case of failure.
+ */
+static int
+xsltAddStackElem(xsltTransformContextPtr ctxt, xsltStackElemPtr elem)
+{
+    if ((ctxt == NULL) || (elem == NULL))
+       return(-1);
+
+    do {
+       if (ctxt->varsMax == 0) {
+           ctxt->varsMax = 10;
+           ctxt->varsTab =
+               (xsltStackElemPtr *) xmlMalloc(ctxt->varsMax *
+               sizeof(ctxt->varsTab[0]));
+           if (ctxt->varsTab == NULL) {
+               xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
+               return (-1);
+           }
+       }
+       if (ctxt->varsNr >= ctxt->varsMax) {
+           ctxt->varsMax *= 2;
+           ctxt->varsTab =
+               (xsltStackElemPtr *) xmlRealloc(ctxt->varsTab,
+               ctxt->varsMax *
+               sizeof(ctxt->varsTab[0]));
+           if (ctxt->varsTab == NULL) {
+               xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
+               return (-1);
+           }
+       }
+       ctxt->varsTab[ctxt->varsNr++] = elem;
+       ctxt->vars = elem;
+       
+       elem = elem->next;
+    } while (elem != NULL);
+    
+    return(0);
+}
+
+/**
+ * xsltAddStackElemList:
+ * @ctxt:  xn XSLT transformation context
+ * @elems:  a stack element list
+ *
+ * Push an element list onto the stack.
+ *
+ * Returns 0 in case of success, -1 in case of failure.
+ */
+int
+xsltAddStackElemList(xsltTransformContextPtr ctxt, xsltStackElemPtr elems)
+{
+    return(xsltAddStackElem(ctxt, elems));
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     Module interfaces                               *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltEvalVariable:
+ * @ctxt:  the XSLT transformation context
+ * @variable:  the variable or parameter item
+ * @comp: the compiled XSLT instruction
+ *
+ * Evaluate a variable value.
+ *
+ * Returns the XPath Object value or NULL in case of error
+ */
+static xmlXPathObjectPtr
+xsltEvalVariable(xsltTransformContextPtr ctxt, xsltStackElemPtr variable,
+                xsltStylePreCompPtr castedComp)
+{
+#ifdef XSLT_REFACTORED
+    xsltStyleItemVariablePtr comp =
+       (xsltStyleItemVariablePtr) castedComp;
+#else
+    xsltStylePreCompPtr comp = castedComp;
+#endif   
+    xmlXPathObjectPtr result = NULL;
+    xmlNodePtr oldInst;
+
+    if ((ctxt == NULL) || (variable == NULL))
+       return(NULL);
+
+    /*
+    * A variable or parameter are evaluated on demand; thus the
+    * context (of XSLT and XPath) need to be temporarily adjusted and
+    * restored on exit.
+    */
+    oldInst = ctxt->inst;
+
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+    XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+       "Evaluating variable '%s'\n", variable->name));
+#endif
+    if (variable->select != NULL) {
+       xmlXPathCompExprPtr xpExpr = NULL;
+       xmlDocPtr oldXPDoc;
+       xmlNodePtr oldXPContextNode;
+       int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
+       xmlNsPtr *oldXPNamespaces;
+       xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;
+       xsltStackElemPtr oldVar = ctxt->contextVariable;
+
+       if ((comp != NULL) && (comp->comp != NULL)) {
+           xpExpr = comp->comp;
+       } else {
+           xpExpr = xmlXPathCompile(variable->select);
+       }
+       if (xpExpr == NULL)
+           return(NULL);
+       /*
+       * Save context states.
+       */
+       oldXPDoc = xpctxt->doc;
+       oldXPContextNode = xpctxt->node;
+       oldXPProximityPosition = xpctxt->proximityPosition;
+       oldXPContextSize = xpctxt->contextSize;
+       oldXPNamespaces = xpctxt->namespaces;
+       oldXPNsNr = xpctxt->nsNr;
+               
+       xpctxt->node = ctxt->node;
+       /*
+       * OPTIMIZE TODO: Lame try to set the context doc.
+       *   Get rid of this somehow in xpath.c.
+       */
+       if ((ctxt->node->type != XML_NAMESPACE_DECL) &&
+           ctxt->node->doc)
+           xpctxt->doc = ctxt->node->doc;
+       /*
+       * BUG TODO: The proximity position and the context size will
+       *  potentially be wrong.
+       *  Example: 
+       *  <xsl:template select="foo">
+       *    <xsl:variable name="pos" select="position()"/>
+       *    <xsl:for-each select="bar">
+       *      <xsl:value-of select="$pos"/>
+       *    </xsl:for-each>
+       *  </xsl:template>
+       *  Here the proximity position and context size are changed
+       *  to the context of <xsl:for-each select="bar">, but
+       *  the variable needs to be evaluated in the context of
+       *  <xsl:template select="foo">.
+       */      
+       if (comp != NULL) {
+           
+#ifdef XSLT_REFACTORED
+           if (comp->inScopeNs != NULL) {
+               xpctxt->namespaces = comp->inScopeNs->list;
+               xpctxt->nsNr = comp->inScopeNs->xpathNumber;
+           } else {
+               xpctxt->namespaces = NULL;
+               xpctxt->nsNr = 0;
+           }
+#else
+           xpctxt->namespaces = comp->nsList;
+           xpctxt->nsNr = comp->nsNr;
+#endif
+       } else {
+           xpctxt->namespaces = NULL;
+           xpctxt->nsNr = 0;
+       }
+
+       /*
+       * We need to mark that we are "selecting" a var's value;
+       * if any tree fragments are created inside the expression,
+       * then those need to be stored inside the variable; otherwise
+       * we'll eventually free still referenced fragments, before
+       * we leave the scope of the variable.
+       */
+       ctxt->contextVariable = variable;       
+       variable->flags |= XSLT_VAR_IN_SELECT;  
+       
+       result = xmlXPathCompiledEval(xpExpr, xpctxt);
+
+       variable->flags ^= XSLT_VAR_IN_SELECT;
+       /*
+       * Restore Context states.
+       */
+       ctxt->contextVariable = oldVar;
+
+       xpctxt->doc = oldXPDoc;
+       xpctxt->node = oldXPContextNode;
+       xpctxt->contextSize = oldXPContextSize;
+       xpctxt->proximityPosition = oldXPProximityPosition;
+       xpctxt->namespaces = oldXPNamespaces;
+       xpctxt->nsNr = oldXPNsNr;
+
+       if ((comp == NULL) || (comp->comp == NULL))
+           xmlXPathFreeCompExpr(xpExpr);
+       if (result == NULL) {
+           xsltTransformError(ctxt, NULL,
+               (comp != NULL) ? comp->inst : NULL,
+               "Failed to evaluate the expression of variable '%s'.\n",
+               variable->name);
+           ctxt->state = XSLT_STATE_STOPPED;
+
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+#ifdef LIBXML_DEBUG_ENABLED
+       } else {
+           if ((xsltGenericDebugContext == stdout) ||
+               (xsltGenericDebugContext == stderr))
+               xmlXPathDebugDumpObject((FILE *)xsltGenericDebugContext,
+                                       result, 0);
+#endif
+#endif
+       }
+    } else {
+       if (variable->tree == NULL) {
+           result = xmlXPathNewCString("");
+       } else {            
+           if (variable->tree) {
+               xmlDocPtr container;
+               xmlNodePtr oldInsert;
+               xmlDocPtr  oldOutput;
+               xsltStackElemPtr oldVar = ctxt->contextVariable;
+
+               /*
+               * Generate a result tree fragment.
+               */
+               container = xsltCreateRVT(ctxt);
+               if (container == NULL)
+                   goto error;
+               /*
+               * NOTE: Local Result Tree Fragments of params/variables
+               * are not registered globally anymore; the life-time
+               * is not directly dependant of the param/variable itself.
+               *
+               * OLD: xsltRegisterTmpRVT(ctxt, container);
+               */
+               /*
+               * Attach the Result Tree Fragment to the variable;
+               * when the variable is freed, it will also free 
+               * the Result Tree Fragment.
+               */
+               variable->fragment = container;
+               
+               oldOutput = ctxt->output;
+               oldInsert = ctxt->insert;               
+               
+               ctxt->output = container;
+               ctxt->insert = (xmlNodePtr) container;
+               ctxt->contextVariable = variable;
+               /*
+               * Process the sequence constructor (variable->tree).
+               * The resulting tree will be held by @container.
+               */
+               xsltApplyOneTemplate(ctxt, ctxt->node, variable->tree,
+                   NULL, NULL);
+
+               ctxt->contextVariable = oldVar;         
+               ctxt->insert = oldInsert;
+               ctxt->output = oldOutput;
+               
+               result = xmlXPathNewValueTree((xmlNodePtr) container);
+           }
+           if (result == NULL) {
+               result = xmlXPathNewCString("");
+           } else {
+               /*
+               * Freeing is not handled there anymore.
+               * QUESTION TODO: What does the above comment mean?
+               */
+               result->boolval = 0; 
+           }
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+#ifdef LIBXML_DEBUG_ENABLED
+
+           if ((xsltGenericDebugContext == stdout) ||
+               (xsltGenericDebugContext == stderr))
+               xmlXPathDebugDumpObject((FILE *)xsltGenericDebugContext,
+                                       result, 0);
+#endif
+#endif
+       }
+    }
+
+error:
+    ctxt->inst = oldInst;
+    return(result);
+}
+
+/**
+ * xsltEvalGlobalVariable:
+ * @elem:  the variable or parameter
+ * @ctxt:  the XSLT transformation context
+ *
+ * Evaluates a the value of a global xsl:variable or
+ * xsl:param declaration.
+ *
+ * Returns the XPath Object value or NULL in case of error
+ */
+static xmlXPathObjectPtr
+xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt)
+{
+    xmlXPathObjectPtr result = NULL;
+    xmlNodePtr oldInst;
+    const xmlChar* oldVarName;
+
+#ifdef XSLT_REFACTORED
+    xsltStyleBasicItemVariablePtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((ctxt == NULL) || (elem == NULL))
+       return(NULL);
+    if (elem->computed)
+       return(elem->value);
+
+
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+    XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+       "Evaluating global variable %s\n", elem->name));
+#endif
+
+#ifdef WITH_DEBUGGER
+    if ((ctxt->debugStatus != XSLT_DEBUG_NONE) &&
+        elem->comp && elem->comp->inst)
+        xslHandleDebugger(elem->comp->inst, NULL, NULL, ctxt);
+#endif
+
+    oldInst = ctxt->inst;
+    comp = elem->comp;
+    oldVarName = elem->name;
+    elem->name = xsltComputingGlobalVarMarker;
+    /*
+    * OPTIMIZE TODO: We should consider instantiating global vars/params
+    *  on-demand. The vars/params don't need to be evaluated if never
+    *  called; and in the case of global params, if values for such params
+    *  are provided by the user.
+    */
+    if (elem->select != NULL) {                
+       xmlXPathCompExprPtr xpExpr = NULL;
+       xmlDocPtr oldXPDoc;
+       xmlNodePtr oldXPContextNode;
+       int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
+       xmlNsPtr *oldXPNamespaces;
+       xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;
+
+       if ((comp != NULL) && (comp->comp != NULL)) {
+           xpExpr = comp->comp;
+       } else {
+           xpExpr = xmlXPathCompile(elem->select);
+       }
+       if (xpExpr == NULL)
+           goto error;
+       
+       
+       if (comp != NULL)
+           ctxt->inst = comp->inst;
+       else
+           ctxt->inst = NULL;
+       /*
+       * SPEC XSLT 1.0:
+       * "At top-level, the expression or template specifying the
+       *  variable value is evaluated with the same context as that used
+       *  to process the root node of the source document: the current
+       *  node is the root node of the source document and the current
+       *  node list is a list containing just the root node of the source
+       *  document."   
+       */
+       /*
+       * Save context states.
+       */
+       oldXPDoc = xpctxt->doc;
+       oldXPContextNode = xpctxt->node;
+       oldXPProximityPosition = xpctxt->proximityPosition;
+       oldXPContextSize = xpctxt->contextSize;
+       oldXPNamespaces = xpctxt->namespaces;
+       oldXPNsNr = xpctxt->nsNr;
+               
+       xpctxt->node = ctxt->initialContextNode;
+       xpctxt->doc = ctxt->initialContextDoc;
+       xpctxt->contextSize = 1;
+       xpctxt->proximityPosition = 1;
+               
+       if (comp != NULL) {
+           
+#ifdef XSLT_REFACTORED
+           if (comp->inScopeNs != NULL) {
+               xpctxt->namespaces = comp->inScopeNs->list;
+               xpctxt->nsNr = comp->inScopeNs->xpathNumber;
+           } else {
+               xpctxt->namespaces = NULL;
+               xpctxt->nsNr = 0;
+           }
+#else
+           xpctxt->namespaces = comp->nsList;
+           xpctxt->nsNr = comp->nsNr;
+#endif
+       } else {
+           xpctxt->namespaces = NULL;
+           xpctxt->nsNr = 0;
+       }
+       
+       result = xmlXPathCompiledEval(xpExpr, xpctxt);
+
+       /*
+       * Restore Context states.
+       */
+       xpctxt->doc = oldXPDoc;
+       xpctxt->node = oldXPContextNode;
+       xpctxt->contextSize = oldXPContextSize;
+       xpctxt->proximityPosition = oldXPProximityPosition;
+       xpctxt->namespaces = oldXPNamespaces;
+       xpctxt->nsNr = oldXPNsNr;
+
+       if ((comp == NULL) || (comp->comp == NULL))
+           xmlXPathFreeCompExpr(xpExpr);
+       if (result == NULL) {
+           if (comp == NULL)
+               xsltTransformError(ctxt, NULL, NULL,
+                   "Evaluating global variable %s failed\n", elem->name);
+           else
+               xsltTransformError(ctxt, NULL, comp->inst,
+                   "Evaluating global variable %s failed\n", elem->name);
+           ctxt->state = XSLT_STATE_STOPPED;
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+#ifdef LIBXML_DEBUG_ENABLED
+       } else {
+           if ((xsltGenericDebugContext == stdout) ||
+               (xsltGenericDebugContext == stderr))
+               xmlXPathDebugDumpObject((FILE *)xsltGenericDebugContext,
+                                       result, 0);
+#endif
+#endif
+       }
+    } else {
+       if (elem->tree == NULL) {
+           result = xmlXPathNewCString("");
+       } else {
+           xmlDocPtr container;
+           xmlNodePtr oldInsert;
+           xmlDocPtr  oldOutput, oldXPDoc;         
+           /*
+           * Generate a result tree fragment.
+           */
+           container = xsltCreateRVT(ctxt);
+           if (container == NULL)
+               goto error;
+           /*
+           * Let the lifetime of the tree fragment be handled by
+           * the Libxslt's garbage collector.
+           */
+           xsltRegisterPersistRVT(ctxt, container);        
+
+           oldOutput = ctxt->output;
+           oldInsert = ctxt->insert;
+
+           oldXPDoc = ctxt->xpathCtxt->doc;
+           
+           ctxt->output = container;       
+           ctxt->insert = (xmlNodePtr) container;
+
+           ctxt->xpathCtxt->doc = ctxt->initialContextDoc;
+           /*
+           * Process the sequence constructor.
+           */
+           xsltApplyOneTemplate(ctxt, ctxt->node, elem->tree, NULL, NULL);
+
+           ctxt->xpathCtxt->doc = oldXPDoc;
+
+           ctxt->insert = oldInsert;
+           ctxt->output = oldOutput;
+           
+           result = xmlXPathNewValueTree((xmlNodePtr) container);
+           if (result == NULL) {
+               result = xmlXPathNewCString("");
+           } else {
+               result->boolval = 0; /* Freeing is not handled there anymore */
+           }
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+#ifdef LIBXML_DEBUG_ENABLED
+           if ((xsltGenericDebugContext == stdout) ||
+               (xsltGenericDebugContext == stderr))
+               xmlXPathDebugDumpObject((FILE *)xsltGenericDebugContext,
+                                       result, 0);
+#endif
+#endif
+       }
+    }
+
+error:
+    elem->name = oldVarName;
+    ctxt->inst = oldInst;
+    if (result != NULL) {
+       elem->value = result;
+       elem->computed = 1;
+    }
+    return(result);
+}
+
+/**
+ * xsltEvalGlobalVariables:
+ * @ctxt:  the XSLT transformation context
+ *
+ * Evaluates all global variables and parameters of a stylesheet.
+ * For internal use only. This is called at start of a transformation.
+ *
+ * Returns 0 in case of success, -1 in case of error
+ */
+int
+xsltEvalGlobalVariables(xsltTransformContextPtr ctxt) {
+    xsltStackElemPtr elem;
+    xsltStylesheetPtr style;    
+
+    if ((ctxt == NULL) || (ctxt->document == NULL))
+       return(-1);
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+    XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+       "Registering global variables\n"));
+#endif
+    /*
+     * Walk the list from the stylesheets and populate the hash table
+     */
+    style = ctxt->style;
+    while (style != NULL) {
+       elem = style->variables;
+       
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+       if ((style->doc != NULL) && (style->doc->URL != NULL)) {
+           XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+                            "Registering global variables from %s\n",
+                            style->doc->URL));
+       }
+#endif
+
+       while (elem != NULL) {
+           xsltStackElemPtr def;
+
+           /*
+            * Global variables are stored in the variables pool.
+            */
+           def = (xsltStackElemPtr) 
+                   xmlHashLookup2(ctxt->globalVars,
+                                elem->name, elem->nameURI);
+           if (def == NULL) {
+
+               def = xsltCopyStackElem(elem);
+               xmlHashAddEntry2(ctxt->globalVars,
+                                elem->name, elem->nameURI, def);
+           } else if ((elem->comp != NULL) &&
+                      (elem->comp->type == XSLT_FUNC_VARIABLE)) {
+               /*
+                * Redefinition of variables from a different stylesheet
+                * should not generate a message.
+                */
+               if ((elem->comp->inst != NULL) &&
+                   (def->comp != NULL) && (def->comp->inst != NULL) &&
+                   (elem->comp->inst->doc == def->comp->inst->doc))
+               {
+                   xsltTransformError(ctxt, style, elem->comp->inst,
+                       "Global variable %s already defined\n", elem->name);
+                   if (style != NULL) style->errors++;
+               }
+           }
+           elem = elem->next;
+       }
+
+       style = xsltNextImport(style);
+    }
+
+    /*
+     * This part does the actual evaluation
+     */    
+    xmlHashScan(ctxt->globalVars,
+               (xmlHashScanner) xsltEvalGlobalVariable, ctxt);
+
+    return(0);
+}
+
+/**
+ * xsltRegisterGlobalVariable:
+ * @style:  the XSLT transformation context
+ * @name:  the variable name
+ * @ns_uri:  the variable namespace URI
+ * @sel:  the expression which need to be evaluated to generate a value
+ * @tree:  the subtree if sel is NULL
+ * @comp:  the precompiled value
+ * @value:  the string value if available
+ *
+ * Register a new variable value. If @value is NULL it unregisters
+ * the variable
+ *
+ * Returns 0 in case of success, -1 in case of error
+ */
+static int
+xsltRegisterGlobalVariable(xsltStylesheetPtr style, const xmlChar *name,
+                    const xmlChar *ns_uri, const xmlChar *sel,
+                    xmlNodePtr tree, xsltStylePreCompPtr comp,
+                    const xmlChar *value) {
+    xsltStackElemPtr elem, tmp;
+    if (style == NULL)
+       return(-1);
+    if (name == NULL)
+       return(-1);
+    if (comp == NULL)
+       return(-1);
+
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+    if (comp->type == XSLT_FUNC_PARAM)
+       xsltGenericDebug(xsltGenericDebugContext,
+                        "Defining global param %s\n", name);
+    else
+       xsltGenericDebug(xsltGenericDebugContext,
+                        "Defining global variable %s\n", name);
+#endif
+
+    elem = xsltNewStackElem(NULL);
+    if (elem == NULL)
+       return(-1);
+    elem->comp = comp;
+    elem->name = xmlDictLookup(style->dict, name, -1);
+    elem->select = xmlDictLookup(style->dict, sel, -1);
+    if (ns_uri)
+       elem->nameURI = xmlDictLookup(style->dict, ns_uri, -1);
+    elem->tree = tree;
+    tmp = style->variables;
+    if (tmp == NULL) {
+       elem->next = NULL;
+       style->variables = elem;
+    } else {
+       while (tmp != NULL) {
+           if ((elem->comp->type == XSLT_FUNC_VARIABLE) &&
+               (tmp->comp->type == XSLT_FUNC_VARIABLE) &&
+               (xmlStrEqual(elem->name, tmp->name)) &&
+               ((elem->nameURI == tmp->nameURI) ||
+                (xmlStrEqual(elem->nameURI, tmp->nameURI))))
+           {
+               xsltTransformError(NULL, style, comp->inst,
+               "redefinition of global variable %s\n", elem->name);
+               style->errors++;
+           }
+           if (tmp->next == NULL)
+               break;
+           tmp = tmp->next;
+       }
+       elem->next = NULL;
+       tmp->next = elem;
+    }
+    if (value != NULL) {
+       elem->computed = 1;
+       elem->value = xmlXPathNewString(value);
+    }
+    return(0);
+}
+
+/**
+ * xsltProcessUserParamInternal
+ *
+ * @ctxt:  the XSLT transformation context
+ * @name:  a null terminated parameter name
+ * @value: a null terminated value (may be an XPath expression)
+ * @eval:  0 to treat the value literally, else evaluate as XPath expression
+ *
+ * If @eval is 0 then @value is treated literally and is stored in the global
+ * parameter/variable table without any change.
+ *
+ * Uf @eval is 1 then @value is treated as an XPath expression and is
+ * evaluated.  In this case, if you want to pass a string which will be
+ * interpreted literally then it must be enclosed in single or double quotes.
+ * If the string contains single quotes (double quotes) then it cannot be
+ * enclosed single quotes (double quotes).  If the string which you want to
+ * be treated literally contains both single and double quotes (e.g. Meet
+ * at Joe's for "Twelfth Night" at 7 o'clock) then there is no suitable
+ * quoting character.  You cannot use &apos; or &quot; inside the string
+ * because the replacement of character entities with their equivalents is
+ * done at a different stage of processing.  The solution is to call
+ * xsltQuoteUserParams or xsltQuoteOneUserParam.
+ *
+ * This needs to be done on parsed stylesheets before starting to apply
+ * transformations.  Normally this will be called (directly or indirectly)
+ * only from xsltEvalUserParams, xsltEvalOneUserParam, xsltQuoteUserParams,
+ * or xsltQuoteOneUserParam.
+ *
+ * Returns 0 in case of success, -1 in case of error
+ */
+
+static
+int
+xsltProcessUserParamInternal(xsltTransformContextPtr ctxt,
+                            const xmlChar * name,
+                            const xmlChar * value,
+                            int eval) {
+
+    xsltStylesheetPtr style;
+    const xmlChar *prefix;
+    const xmlChar *href;
+    xmlXPathCompExprPtr xpExpr;
+    xmlXPathObjectPtr result;
+    
+    xsltStackElemPtr elem;
+    int res;
+    void *res_ptr;
+
+    if (ctxt == NULL)
+       return(-1);
+    if (name == NULL)
+       return(0);
+    if (value == NULL)
+       return(0);
+
+    style = ctxt->style;
+
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+    XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+           "Evaluating user parameter %s=%s\n", name, value));
+#endif
+
+    /*
+     * Name lookup
+     */
+
+    name = xsltSplitQName(ctxt->dict, name, &prefix);
+    href = NULL;
+    if (prefix != NULL) {
+       xmlNsPtr ns;
+
+       ns = xmlSearchNs(style->doc, xmlDocGetRootElement(style->doc),
+                        prefix);
+       if (ns == NULL) {
+           xsltTransformError(ctxt, style, NULL,
+           "user param : no namespace bound to prefix %s\n", prefix);
+           href = NULL;
+       } else {
+           href = ns->href;
+       }
+    }
+
+    if (name == NULL)
+       return (-1);
+
+    res_ptr = xmlHashLookup2(ctxt->globalVars, name, href);
+    if (res_ptr != 0) {
+       xsltTransformError(ctxt, style, NULL,
+           "Global parameter %s already defined\n", name);
+    }
+    if (ctxt->globalVars == NULL)
+       ctxt->globalVars = xmlHashCreate(20);
+
+    /*
+     * do not overwrite variables with parameters from the command line
+     */
+    while (style != NULL) {
+        elem = ctxt->style->variables;
+       while (elem != NULL) {
+           if ((elem->comp != NULL) &&
+               (elem->comp->type == XSLT_FUNC_VARIABLE) &&
+               (xmlStrEqual(elem->name, name)) &&
+               (xmlStrEqual(elem->nameURI, href))) {
+               return(0);
+           }
+            elem = elem->next;
+       }
+        style = xsltNextImport(style);
+    }
+    style = ctxt->style;
+    elem = NULL;
+
+    /*
+     * Do the evaluation if @eval is non-zero.
+     */
+
+    result = NULL;
+    if (eval != 0) {
+        xpExpr = xmlXPathCompile(value);
+       if (xpExpr != NULL) {
+           xmlDocPtr oldXPDoc;
+           xmlNodePtr oldXPContextNode;
+           int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
+           xmlNsPtr *oldXPNamespaces;
+           xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;
+          
+           /*
+           * Save context states.
+           */
+           oldXPDoc = xpctxt->doc;
+           oldXPContextNode = xpctxt->node;
+           oldXPProximityPosition = xpctxt->proximityPosition;
+           oldXPContextSize = xpctxt->contextSize;
+           oldXPNamespaces = xpctxt->namespaces;
+           oldXPNsNr = xpctxt->nsNr;
+
+           /*
+           * SPEC XSLT 1.0:
+           * "At top-level, the expression or template specifying the
+           *  variable value is evaluated with the same context as that used
+           *  to process the root node of the source document: the current
+           *  node is the root node of the source document and the current
+           *  node list is a list containing just the root node of the source
+           *  document."
+           */
+           xpctxt->doc = ctxt->initialContextDoc;          
+           xpctxt->node = ctxt->initialContextNode;        
+           xpctxt->contextSize = 1;
+           xpctxt->proximityPosition = 1;
+           /* 
+           * There is really no in scope namespace for parameters on the
+           * command line.
+           */
+           xpctxt->namespaces = NULL;
+           xpctxt->nsNr = 0;      
+           
+           result = xmlXPathCompiledEval(xpExpr, xpctxt);
+           
+           /*
+           * Restore Context states.
+           */
+           xpctxt->doc = oldXPDoc;
+           xpctxt->node = oldXPContextNode;
+           xpctxt->contextSize = oldXPContextSize;
+           xpctxt->proximityPosition = oldXPProximityPosition;
+           xpctxt->namespaces = oldXPNamespaces;
+           xpctxt->nsNr = oldXPNsNr;
+           
+           xmlXPathFreeCompExpr(xpExpr);
+       }
+       if (result == NULL) {
+           xsltTransformError(ctxt, style, NULL,
+               "Evaluating user parameter %s failed\n", name);
+           ctxt->state = XSLT_STATE_STOPPED;
+           return(-1);
+       }
+    }
+
+    /* 
+     * If @eval is 0 then @value is to be taken literally and result is NULL
+     * 
+     * If @eval is not 0, then @value is an XPath expression and has been
+     * successfully evaluated and result contains the resulting value and
+     * is not NULL.
+     *
+     * Now create an xsltStackElemPtr for insertion into the context's
+     * global variable/parameter hash table.
+     */
+
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+#ifdef LIBXML_DEBUG_ENABLED
+    if ((xsltGenericDebugContext == stdout) ||
+        (xsltGenericDebugContext == stderr))
+           xmlXPathDebugDumpObject((FILE *)xsltGenericDebugContext,
+                                   result, 0);
+#endif
+#endif
+
+    elem = xsltNewStackElem(NULL);
+    if (elem != NULL) {
+       elem->name = name;
+       elem->select = xmlDictLookup(ctxt->dict, value, -1);
+       if (href != NULL)
+           elem->nameURI = xmlDictLookup(ctxt->dict, href, -1);
+       elem->tree = NULL;
+       elem->computed = 1;
+       if (eval == 0) {
+           elem->value = xmlXPathNewString(value);
+       } 
+       else {
+           elem->value = result;
+       }
+    }
+
+    /*
+     * Global parameters are stored in the XPath context variables pool.
+     */
+
+    res = xmlHashAddEntry2(ctxt->globalVars, name, href, elem);
+    if (res != 0) {
+       xsltFreeStackElem(elem);
+       xsltTransformError(ctxt, style, NULL,
+           "Global parameter %s already defined\n", name);
+    }
+    return(0);
+}
+
+/**
+ * xsltEvalUserParams:
+ *
+ * @ctxt:  the XSLT transformation context
+ * @params:  a NULL terminated array of parameters name/value tuples
+ *
+ * Evaluate the global variables of a stylesheet. This needs to be
+ * done on parsed stylesheets before starting to apply transformations.
+ * Each of the parameters is evaluated as an XPath expression and stored
+ * in the global variables/parameter hash table.  If you want your
+ * parameter used literally, use xsltQuoteUserParams.
+ *
+ * Returns 0 in case of success, -1 in case of error
+ */
+int
+xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params) {
+    int indx = 0;
+    const xmlChar *name;
+    const xmlChar *value;
+
+    if (params == NULL)
+       return(0);
+    while (params[indx] != NULL) {
+       name = (const xmlChar *) params[indx++];
+       value = (const xmlChar *) params[indx++];
+       if (xsltEvalOneUserParam(ctxt, name, value) != 0) 
+           return(-1);
+    }
+    return 0;
+}
+
+/**
+ * xsltQuoteUserParams:
+ *
+ * @ctxt:  the XSLT transformation context
+ * @params:  a NULL terminated arry of parameters names/values tuples
+ *
+ * Similar to xsltEvalUserParams, but the values are treated literally and
+ * are * *not* evaluated as XPath expressions. This should be done on parsed
+ * stylesheets before starting to apply transformations.
+ *
+ * Returns 0 in case of success, -1 in case of error.
+ */
+int
+xsltQuoteUserParams(xsltTransformContextPtr ctxt, const char **params) {
+    int indx = 0;
+    const xmlChar *name;
+    const xmlChar *value;
+
+    if (params == NULL)
+       return(0);
+    while (params[indx] != NULL) {
+       name = (const xmlChar *) params[indx++];
+       value = (const xmlChar *) params[indx++];
+       if (xsltQuoteOneUserParam(ctxt, name, value) != 0) 
+           return(-1);
+    }
+    return 0;
+}
+
+/**
+ * xsltEvalOneUserParam:
+ * @ctxt:  the XSLT transformation context
+ * @name:  a null terminated string giving the name of the parameter
+ * @value:  a null terminated string giving the XPath expression to be evaluated
+ *
+ * This is normally called from xsltEvalUserParams to process a single
+ * parameter from a list of parameters.  The @value is evaluated as an
+ * XPath expression and the result is stored in the context's global
+ * variable/parameter hash table.
+ *
+ * To have a parameter treated literally (not as an XPath expression)
+ * use xsltQuoteUserParams (or xsltQuoteOneUserParam).  For more
+ * details see description of xsltProcessOneUserParamInternal.
+ *
+ * Returns 0 in case of success, -1 in case of error.
+ */
+
+int
+xsltEvalOneUserParam(xsltTransformContextPtr ctxt,
+                    const xmlChar * name,
+                    const xmlChar * value) {
+    return xsltProcessUserParamInternal(ctxt, name, value,
+                                       1 /* xpath eval ? */);
+}
+
+/**
+ * xsltQuoteOneUserParam:
+ * @ctxt:  the XSLT transformation context
+ * @name:  a null terminated string giving the name of the parameter
+ * @value:  a null terminated string giving the parameter value
+ *
+ * This is normally called from xsltQuoteUserParams to process a single
+ * parameter from a list of parameters.  The @value is stored in the
+ * context's global variable/parameter hash table.
+ *
+ * Returns 0 in case of success, -1 in case of error.
+ */
+
+int
+xsltQuoteOneUserParam(xsltTransformContextPtr ctxt,
+                        const xmlChar * name,
+                        const xmlChar * value) {
+    return xsltProcessUserParamInternal(ctxt, name, value,
+                                       0 /* xpath eval ? */);
+}
+
+/**
+ * xsltBuildVariable:
+ * @ctxt:  the XSLT transformation context
+ * @comp:  the precompiled form
+ * @tree:  the tree if select is NULL
+ *
+ * Computes a new variable value.
+ *
+ * Returns the xsltStackElemPtr or NULL in case of error
+ */
+static xsltStackElemPtr
+xsltBuildVariable(xsltTransformContextPtr ctxt,
+                 xsltStylePreCompPtr castedComp,
+                 xmlNodePtr tree)
+{
+#ifdef XSLT_REFACTORED
+    xsltStyleBasicItemVariablePtr comp =
+       (xsltStyleBasicItemVariablePtr) castedComp;
+#else
+    xsltStylePreCompPtr comp = castedComp;
+#endif 
+    xsltStackElemPtr elem;
+
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+    XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+                    "Building variable %s", comp->name));
+    if (comp->select != NULL)
+       XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+                        " select %s", comp->select));
+    XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext, "\n"));
+#endif
+
+    elem = xsltNewStackElem(ctxt);
+    if (elem == NULL)
+       return(NULL);
+    elem->comp = (xsltStylePreCompPtr) comp;
+    elem->name = comp->name;
+    elem->select = comp->select;
+    elem->nameURI = comp->ns;
+    elem->tree = tree;
+    elem->value = xsltEvalVariable(ctxt, elem,
+       (xsltStylePreCompPtr) comp);
+    if (elem->value != NULL)
+       elem->computed = 1;
+    return(elem);
+}
+
+/**
+ * xsltRegisterVariable:
+ * @ctxt:  the XSLT transformation context
+ * @comp: the compiled XSLT-variable (or param) instruction
+ * @tree:  the tree if select is NULL
+ * @isParam:  indicates if this is a parameter
+ *
+ * Computes and registers a new variable.
+ *
+ * Returns 0 in case of success, -1 in case of error
+ */
+static int
+xsltRegisterVariable(xsltTransformContextPtr ctxt,
+                    xsltStylePreCompPtr castedComp,
+                    xmlNodePtr tree, int isParam)
+{
+#ifdef XSLT_REFACTORED
+    xsltStyleBasicItemVariablePtr comp =
+       (xsltStyleBasicItemVariablePtr) castedComp;
+#else
+    xsltStylePreCompPtr comp = castedComp;
+    int present;
+#endif
+    xsltStackElemPtr variable;    
+    
+#ifdef XSLT_REFACTORED
+    /*
+    * REFACTORED NOTE: Redefinitions of vars/params are checked
+    *  at compilation time in the refactored code.
+    * xsl:with-param parameters are checked in xsltApplyXSLTTemplate().
+    */
+#else
+    present = xsltCheckStackElem(ctxt, comp->name, comp->ns);
+    if (isParam == 0) {        
+       if ((present != 0) && (present != 3)) {
+           /* TODO: report QName. */
+           xsltTransformError(ctxt, NULL, comp->inst,
+               "XSLT-variable: Redefinition of variable '%s'.\n", comp->name);
+           return(0);
+       }
+    } else if (present != 0) {
+       if ((present == 1) || (present == 2)) {
+           /* TODO: report QName. */
+           xsltTransformError(ctxt, NULL, comp->inst,
+               "XSLT-param: Redefinition of parameter '%s'.\n", comp->name);
+           return(0);
+       }
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+       XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+                "param %s defined by caller\n", comp->name));
+#endif
+       return(0);
+    }
+#endif /* else of XSLT_REFACTORED */
+
+    variable = xsltBuildVariable(ctxt, (xsltStylePreCompPtr) comp, tree);
+    xsltAddStackElem(ctxt, variable);
+    return(0);
+}
+
+/**
+ * xsltGlobalVariableLookup:
+ * @ctxt:  the XSLT transformation context
+ * @name:  the variable name
+ * @ns_uri:  the variable namespace URI
+ *
+ * Search in the Variable array of the context for the given
+ * variable value.
+ *
+ * Returns the value or NULL if not found
+ */
+static xmlXPathObjectPtr
+xsltGlobalVariableLookup(xsltTransformContextPtr ctxt, const xmlChar *name,
+                        const xmlChar *ns_uri) {
+    xsltStackElemPtr elem;
+    xmlXPathObjectPtr ret = NULL;
+
+    /*
+     * Lookup the global variables in XPath global variable hash table
+     */
+    if ((ctxt->xpathCtxt == NULL) || (ctxt->globalVars == NULL))
+       return(NULL);
+    elem = (xsltStackElemPtr)
+           xmlHashLookup2(ctxt->globalVars, name, ns_uri);
+    if (elem == NULL) {
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+       XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+                        "global variable not found %s\n", name));
+#endif
+       return(NULL);
+    }
+    /*
+    * URGENT TODO: Move the detection of recursive definitions
+    * to compile-time.
+    */
+    if (elem->computed == 0) {
+       if (elem->name == xsltComputingGlobalVarMarker) {
+           xsltTransformError(ctxt, NULL, elem->comp->inst,
+               "Recursive definition of %s\n", name);
+           return(NULL);
+       }
+       ret = xsltEvalGlobalVariable(elem, ctxt);
+    } else
+       ret = elem->value;
+    return(xmlXPathObjectCopy(ret));
+}
+
+/**
+ * xsltVariableLookup:
+ * @ctxt:  the XSLT transformation context
+ * @name:  the variable name
+ * @ns_uri:  the variable namespace URI
+ *
+ * Search in the Variable array of the context for the given
+ * variable value.
+ *
+ * Returns the value or NULL if not found
+ */
+xmlXPathObjectPtr
+xsltVariableLookup(xsltTransformContextPtr ctxt, const xmlChar *name,
+                  const xmlChar *ns_uri) {
+    xsltStackElemPtr elem;
+
+    if (ctxt == NULL)
+       return(NULL);
+
+    elem = xsltStackLookup(ctxt, name, ns_uri);
+    if (elem == NULL) {
+       return(xsltGlobalVariableLookup(ctxt, name, ns_uri));
+    }
+    if (elem->computed == 0) {
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+       XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+                        "uncomputed variable %s\n", name));
+#endif
+        elem->value = xsltEvalVariable(ctxt, elem, NULL);
+       elem->computed = 1;
+    }
+    if (elem->value != NULL)
+       return(xmlXPathObjectCopy(elem->value));
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+    XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+                    "variable not found %s\n", name));
+#endif
+    return(NULL);
+}
+
+/**
+ * xsltParseStylesheetCallerParam:
+ * @ctxt:  the XSLT transformation context 
+ * @inst:  the xsl:with-param instruction element
+ *
+ * Processes an xsl:with-param instruction at transformation time.
+ * The value is compute, but not recorded.
+ * NOTE that this is also called with an *xsl:param* element
+ * from exsltFuncFunctionFunction(). 
+ *
+ * Returns the new xsltStackElemPtr or NULL
+ */
+
+xsltStackElemPtr
+xsltParseStylesheetCallerParam(xsltTransformContextPtr ctxt, xmlNodePtr inst)
+{
+#ifdef XSLT_REFACTORED
+    xsltStyleBasicItemVariablePtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+    xmlNodePtr tree = NULL; /* The first child node of the instruction or
+                               the instruction itself. */
+    xsltStackElemPtr param = NULL;
+    
+    if ((ctxt == NULL) || (inst == NULL))
+       return(NULL);
+
+#ifdef XSLT_REFACTORED
+    comp = (xsltStyleBasicItemVariablePtr) inst->psvi;
+#else
+    comp = (xsltStylePreCompPtr) inst->psvi;
+#endif
+    
+    if (comp == NULL) {
+        xsltTransformError(ctxt, NULL, inst,
+           "Internal error in xsltParseStylesheetCallerParam(): "
+           "The XSLT 'with-param' instruction was not compiled.\n");
+        return(NULL);
+    }
+    if (comp->name == NULL) {
+       xsltTransformError(ctxt, NULL, inst,
+           "Internal error in xsltParseStylesheetCallerParam(): "
+           "XSLT 'with-param': The attribute 'name' was not compiled.\n");
+       return(NULL);
+    }
+
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+    XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+           "Handling xsl:with-param %s\n", comp->name));
+#endif
+
+    if (comp->select == NULL) {
+       tree = inst->children;
+    } else {
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+       XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+           "        select %s\n", comp->select));
+#endif
+       tree = inst;
+    }
+
+    param = xsltBuildVariable(ctxt, (xsltStylePreCompPtr) comp, tree);
+
+    return(param);
+}
+
+/**
+ * xsltParseGlobalVariable:
+ * @style:  the XSLT stylesheet
+ * @cur:  the "variable" element
+ *
+ * Parses a global XSLT 'variable' declaration at compilation time
+ * and registers it
+ */
+void
+xsltParseGlobalVariable(xsltStylesheetPtr style, xmlNodePtr cur)
+{
+#ifdef XSLT_REFACTORED
+    xsltStyleItemVariablePtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((cur == NULL) || (style == NULL))
+       return;
+    
+#ifdef XSLT_REFACTORED
+    /*
+    * Note that xsltStylePreCompute() will be called from
+    * xslt.c only.
+    */
+    comp = (xsltStyleItemVariablePtr) cur->psvi;
+#else
+    xsltStylePreCompute(style, cur);
+    comp = (xsltStylePreCompPtr) cur->psvi;
+#endif
+    if (comp == NULL) {
+       xsltTransformError(NULL, style, cur,
+            "xsl:variable : compilation failed\n");
+       return;
+    }
+
+    if (comp->name == NULL) {
+       xsltTransformError(NULL, style, cur,
+           "xsl:variable : missing name attribute\n");
+       return;
+    }
+
+    /*
+    * Parse the content (a sequence constructor) of xsl:variable.
+    */
+    if (cur->children != NULL) {
+#ifdef XSLT_REFACTORED 
+        xsltParseSequenceConstructor(XSLT_CCTXT(style), cur->children);
+#else
+        xsltParseTemplateContent(style, cur);
+#endif
+    }
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+    xsltGenericDebug(xsltGenericDebugContext,
+       "Registering global variable %s\n", comp->name);
+#endif
+
+    xsltRegisterGlobalVariable(style, comp->name, comp->ns,
+       comp->select, cur->children, (xsltStylePreCompPtr) comp,
+       NULL);
+}
+
+/**
+ * xsltParseGlobalParam:
+ * @style:  the XSLT stylesheet
+ * @cur:  the "param" element
+ *
+ * parse an XSLT transformation param declaration and record
+ * its value.
+ */
+
+void
+xsltParseGlobalParam(xsltStylesheetPtr style, xmlNodePtr cur) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemParamPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((cur == NULL) || (style == NULL))
+       return;
+    
+#ifdef XSLT_REFACTORED
+    /*
+    * Note that xsltStylePreCompute() will be called from
+    * xslt.c only.
+    */
+    comp = (xsltStyleItemParamPtr) cur->psvi;
+#else
+    xsltStylePreCompute(style, cur);
+    comp = (xsltStylePreCompPtr) cur->psvi;
+#endif    
+    if (comp == NULL) {
+       xsltTransformError(NULL, style, cur,
+            "xsl:param : compilation failed\n");
+       return;
+    }
+
+    if (comp->name == NULL) {
+       xsltTransformError(NULL, style, cur,
+           "xsl:param : missing name attribute\n");
+       return;
+    }
+
+    /*
+    * Parse the content (a sequence constructor) of xsl:param.
+    */
+    if (cur->children != NULL) {
+#ifdef XSLT_REFACTORED 
+        xsltParseSequenceConstructor(XSLT_CCTXT(style), cur->children);
+#else
+        xsltParseTemplateContent(style, cur);
+#endif
+    }
+
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+    xsltGenericDebug(xsltGenericDebugContext,
+       "Registering global param %s\n", comp->name);
+#endif
+
+    xsltRegisterGlobalVariable(style, comp->name, comp->ns,
+       comp->select, cur->children, (xsltStylePreCompPtr) comp,
+       NULL);
+}
+
+/**
+ * xsltParseStylesheetVariable:
+ * @ctxt:  the XSLT transformation context
+ * @inst:  the xsl:variable instruction element
+ *
+ * Registers a local XSLT 'variable' instruction at transformation time
+ * and evaluates its value.
+ */
+void
+xsltParseStylesheetVariable(xsltTransformContextPtr ctxt, xmlNodePtr inst)
+{
+#ifdef XSLT_REFACTORED
+    xsltStyleItemVariablePtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((inst == NULL) || (ctxt == NULL))
+       return;
+
+    comp = inst->psvi;
+    if (comp == NULL) {
+        xsltTransformError(ctxt, NULL, inst,
+           "Internal error in xsltParseStylesheetVariable(): "
+           "The XSLT 'variable' instruction was not compiled.\n");
+        return;
+    }
+    if (comp->name == NULL) {
+       xsltTransformError(ctxt, NULL, inst,
+           "Internal error in xsltParseStylesheetVariable(): "
+           "The attribute 'name' was not compiled.\n");
+       return;
+    }
+
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+    XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+       "Registering variable '%s'\n", comp->name));
+#endif
+
+    xsltRegisterVariable(ctxt, (xsltStylePreCompPtr) comp, inst->children, 0);
+}
+
+/**
+ * xsltParseStylesheetParam:
+ * @ctxt:  the XSLT transformation context
+ * @cur:  the XSLT 'param' element
+ *
+ * Registers a local XSLT 'param' declaration at transformation time and
+ * evaluates its value.
+ */
+void
+xsltParseStylesheetParam(xsltTransformContextPtr ctxt, xmlNodePtr cur)
+{
+#ifdef XSLT_REFACTORED
+    xsltStyleItemParamPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+
+    if ((cur == NULL) || (ctxt == NULL))
+       return;
+
+    comp = cur->psvi;
+    if ((comp == NULL) || (comp->name == NULL)) {
+       xsltTransformError(ctxt, NULL, cur,
+           "Internal error in xsltParseStylesheetParam(): "
+           "The XSLT 'param' declaration was not compiled correctly.\n");
+       return;
+    }
+
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+    XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+       "Registering param %s\n", comp->name));
+#endif
+
+    xsltRegisterVariable(ctxt, (xsltStylePreCompPtr) comp, cur->children, 1);
+}
+
+/**
+ * xsltFreeGlobalVariables:
+ * @ctxt:  the XSLT transformation context
+ *
+ * Free up the data associated to the global variables
+ * its value.
+ */
+
+void
+xsltFreeGlobalVariables(xsltTransformContextPtr ctxt) {
+    xmlHashFree(ctxt->globalVars, (xmlHashDeallocator) xsltFreeStackElem);
+}
+
+/**
+ * xsltXPathVariableLookup:
+ * @ctxt:  a void * but the the XSLT transformation context actually
+ * @name:  the variable name
+ * @ns_uri:  the variable namespace URI
+ *
+ * This is the entry point when a varibale is needed by the XPath
+ * interpretor.
+ *
+ * Returns the value or NULL if not found
+ */
+xmlXPathObjectPtr
+xsltXPathVariableLookup(void *ctxt, const xmlChar *name,
+                       const xmlChar *ns_uri) {
+    xsltTransformContextPtr tctxt;
+    xmlXPathObjectPtr valueObj = NULL;
+
+    if ((ctxt == NULL) || (name == NULL))
+       return(NULL);
+
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+    XSLT_TRACE(((xsltTransformContextPtr)ctxt),XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+           "Lookup variable '%s'\n", name));
+#endif
+    
+    tctxt = (xsltTransformContextPtr) ctxt;
+    /*
+    * Local variables/params ---------------------------------------------
+    *
+    * Do the lookup from the top of the stack, but
+    * don't use params being computed in a call-param
+    * First lookup expects the variable name and URI to
+    * come from the disctionnary and hence pointer comparison.
+    */
+    if (tctxt->varsNr != 0) {
+       int i;
+       xsltStackElemPtr variable = NULL, cur;
+
+       for (i = tctxt->varsNr; i > tctxt->varsBase; i--) {
+           cur = tctxt->varsTab[i-1];
+           if ((cur->name == name) && (cur->nameURI == ns_uri)) {
+#if 0
+               stack_addr++;
+#endif
+               variable = cur;
+               goto local_variable_found;
+           }
+           cur = cur->next;
+       }       
+       /*
+       * Redo the lookup with interned strings to avoid string comparison.
+       *
+       * OPTIMIZE TODO: The problem here is, that if we request a
+       *  global variable, then this will be also executed.
+       */
+       {
+           const xmlChar *tmpName = name, *tmpNsName = ns_uri;
+
+           name = xmlDictLookup(tctxt->dict, name, -1);
+           if (ns_uri)
+               ns_uri = xmlDictLookup(tctxt->dict, ns_uri, -1);
+           if ((tmpName != name) || (tmpNsName != ns_uri)) {           
+               for (i = tctxt->varsNr; i > tctxt->varsBase; i--) {
+                   cur = tctxt->varsTab[i-1];
+                   if ((cur->name == name) && (cur->nameURI == ns_uri)) {
+#if 0
+                       stack_cmp++;
+#endif
+                       variable = cur;
+                       goto local_variable_found;
+                   }
+               }
+           }
+       }
+
+local_variable_found:
+
+       if (variable) {
+           if (variable->computed == 0) {
+               
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+               XSLT_TRACE(tctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+                   "uncomputed variable '%s'\n", name));
+#endif
+               variable->value = xsltEvalVariable(tctxt, variable, NULL);
+               variable->computed = 1;
+           }
+           if (variable->value != NULL) {
+               valueObj = xmlXPathObjectCopy(variable->value); 
+           }
+           return(valueObj);
+       }
+    }
+    /*
+    * Global variables/params --------------------------------------------
+    */    
+    if (tctxt->globalVars) {
+       valueObj = xsltGlobalVariableLookup(tctxt, name, ns_uri);
+    }
+
+    if (valueObj == NULL) {
+
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+    XSLT_TRACE(tctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+                    "variable not found '%s'\n", name));
+#endif
+
+       if (ns_uri) {
+           xsltTransformError(tctxt, NULL, tctxt->inst,
+               "Variable '{%s}%s' has not been declared.\n", ns_uri, name);
+       } else {
+           xsltTransformError(tctxt, NULL, tctxt->inst,
+               "Variable '%s' has not been declared.\n", name);
+       }
+    } else {
+
+#ifdef WITH_XSLT_DEBUG_VARIABLE
+       XSLT_TRACE(tctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
+           "found variable '%s'\n", name));
+#endif
+    }
+
+    return(valueObj);
+}
+
+
diff --git a/reactos/dll/3rdparty/libxslt/variables.h b/reactos/dll/3rdparty/libxslt/variables.h
new file mode 100644 (file)
index 0000000..85055e4
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Summary: interface for the variable matching and lookup.
+ * Description: interface for the variable matching and lookup.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_VARIABLES_H__
+#define __XML_XSLT_VARIABLES_H__
+
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+#include "xsltexports.h"
+#include "xsltInternals.h"
+#include "functions.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * XSLT_REGISTER_VARIABLE_LOOKUP:
+ *
+ * Registering macro, not general purpose at all but used in different modules.
+ */
+
+#define XSLT_REGISTER_VARIABLE_LOOKUP(ctxt)                    \
+    xmlXPathRegisterVariableLookup((ctxt)->xpathCtxt,          \
+              xsltXPathVariableLookup, (void *)(ctxt));        \
+    xsltRegisterAllFunctions((ctxt)->xpathCtxt);               \
+    xsltRegisterAllElement(ctxt);                              \
+    (ctxt)->xpathCtxt->extra = ctxt
+
+/*
+ * Interfaces for the variable module.
+ */
+
+XSLTPUBFUN int XSLTCALL                
+               xsltEvalGlobalVariables         (xsltTransformContextPtr ctxt);
+XSLTPUBFUN int XSLTCALL                
+               xsltEvalUserParams              (xsltTransformContextPtr ctxt,
+                                                const char **params);
+XSLTPUBFUN int XSLTCALL                
+               xsltQuoteUserParams             (xsltTransformContextPtr ctxt,
+                                                const char **params);
+XSLTPUBFUN int XSLTCALL                
+               xsltEvalOneUserParam            (xsltTransformContextPtr ctxt,
+                                                const xmlChar * name,
+                                                const xmlChar * value);
+XSLTPUBFUN int XSLTCALL                
+               xsltQuoteOneUserParam           (xsltTransformContextPtr ctxt,
+                                                const xmlChar * name,
+                                                const xmlChar * value);
+
+XSLTPUBFUN void XSLTCALL               
+               xsltParseGlobalVariable         (xsltStylesheetPtr style,
+                                                xmlNodePtr cur);
+XSLTPUBFUN void XSLTCALL               
+               xsltParseGlobalParam            (xsltStylesheetPtr style,
+                                                xmlNodePtr cur);
+XSLTPUBFUN void XSLTCALL               
+               xsltParseStylesheetVariable     (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr cur);
+XSLTPUBFUN void XSLTCALL               
+               xsltParseStylesheetParam        (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr cur);
+XSLTPUBFUN xsltStackElemPtr XSLTCALL 
+               xsltParseStylesheetCallerParam  (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr cur);
+XSLTPUBFUN int XSLTCALL                
+               xsltAddStackElemList            (xsltTransformContextPtr ctxt,
+                                                xsltStackElemPtr elems);
+XSLTPUBFUN void XSLTCALL               
+               xsltFreeGlobalVariables         (xsltTransformContextPtr ctxt);
+XSLTPUBFUN xmlXPathObjectPtr XSLTCALL  
+               xsltVariableLookup              (xsltTransformContextPtr ctxt,
+                                                const xmlChar *name,
+                                                const xmlChar *ns_uri);
+XSLTPUBFUN xmlXPathObjectPtr XSLTCALL  
+               xsltXPathVariableLookup         (void *ctxt,
+                                                const xmlChar *name,
+                                                const xmlChar *ns_uri);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_VARIABLES_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/win32config.h b/reactos/dll/3rdparty/libxslt/win32config.h
new file mode 100644 (file)
index 0000000..169b03d
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Summary: Windows configuration header
+ * Description: Windows configuration header
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Igor Zlatkovic
+ */
+#ifndef __LIBXSLT_WIN32_CONFIG__
+#define __LIBXSLT_WIN32_CONFIG__
+
+#define HAVE_CTYPE_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STDARG_H 1
+#define HAVE_MALLOC_H 1
+#define HAVE_TIME_H 1
+#define HAVE_LOCALTIME 1
+#define HAVE_GMTIME 1
+#define HAVE_TIME 1
+#define HAVE_MATH_H 1
+#define HAVE_FCNTL_H 1
+
+#include <io.h>
+
+#define HAVE_ISINF
+#define HAVE_ISNAN
+
+#include <math.h>
+#if defined _MSC_VER || defined __MINGW32__
+/* MS C-runtime has functions which can be used in order to determine if
+   a given floating-point variable contains NaN, (+-)INF. These are 
+   preferred, because floating-point technology is considered propriatary
+   by MS and we can assume that their functions know more about their 
+   oddities than we do. */
+#include <float.h>
+/* Bjorn Reese figured a quite nice construct for isinf() using the 
+   _fpclass() function. */
+#ifndef isinf
+#define isinf(d) ((_fpclass(d) == _FPCLASS_PINF) ? 1 \
+       : ((_fpclass(d) == _FPCLASS_NINF) ? -1 : 0))
+#endif
+/* _isnan(x) returns nonzero if (x == NaN) and zero otherwise. */
+#ifndef isnan
+#define isnan(d) (_isnan(d))
+#endif
+#else /* _MSC_VER */
+static int isinf (double d) {
+    int expon = 0;
+    double val = frexp (d, &expon);
+    if (expon == 1025) {
+        if (val == 0.5) {
+            return 1;
+        } else if (val == -0.5) {
+            return -1;
+        } else {
+            return 0;
+        }
+    } else {
+        return 0;
+    }
+}
+static int isnan (double d) {
+    int expon = 0;
+    double val = frexp (d, &expon);
+    if (expon == 1025) {
+        if (val == 0.5) {
+            return 0;
+        } else if (val == -0.5) {
+            return 0;
+        } else {
+            return 1;
+        }
+    } else {
+        return 0;
+    }
+}
+#endif /* _MSC_VER */
+
+#include <direct.h>
+#if defined(_MSC_VER) || defined(__MINGW32__)
+#define mkdir(p,m) _mkdir(p)
+#define snprintf _snprintf
+#if _MSC_VER < 1500
+#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
+#endif
+#endif
+
+#define HAVE_SYS_STAT_H
+#define HAVE__STAT
+#define HAVE_STRING_H
+
+#include <libxml/xmlversion.h>
+
+#ifndef ATTRIBUTE_UNUSED
+#define ATTRIBUTE_UNUSED
+#endif
+
+#endif /* __LIBXSLT_WIN32_CONFIG__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/xslt.c b/reactos/dll/3rdparty/libxslt/xslt.c
new file mode 100644 (file)
index 0000000..6f76a33
--- /dev/null
@@ -0,0 +1,6923 @@
+/*
+ * xslt.c: Implemetation of an XSL Transformation 1.0 engine
+ *
+ * Reference:
+ *   XSLT specification
+ *   http://www.w3.org/TR/1999/REC-xslt-19991116
+ *
+ *   Associating Style Sheets with XML documents
+ *   http://www.w3.org/1999/06/REC-xml-stylesheet-19990629
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#include <string.h>
+
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/valid.h>
+#include <libxml/hash.h>
+#include <libxml/uri.h>
+#include <libxml/xmlerror.h>
+#include <libxml/parserInternals.h>
+#include <libxml/xpathInternals.h>
+#include <libxml/xpath.h>
+#include "xslt.h"
+#include "xsltInternals.h"
+#include "pattern.h"
+#include "variables.h"
+#include "namespaces.h"
+#include "attributes.h"
+#include "xsltutils.h"
+#include "imports.h"
+#include "keys.h"
+#include "documents.h"
+#include "extensions.h"
+#include "preproc.h"
+#include "extra.h"
+#include "security.h"
+
+#ifdef WITH_XSLT_DEBUG
+#define WITH_XSLT_DEBUG_PARSING
+/* #define WITH_XSLT_DEBUG_BLANKS */
+#endif
+
+const char *xsltEngineVersion = LIBXSLT_VERSION_STRING LIBXSLT_VERSION_EXTRA;
+const int xsltLibxsltVersion = LIBXSLT_VERSION;
+const int xsltLibxmlVersion = LIBXML_VERSION;
+
+#ifdef XSLT_REFACTORED
+
+const xmlChar *xsltConstNamespaceNameXSLT = (const xmlChar *) XSLT_NAMESPACE;
+
+/*
+* xsltLiteralResultMarker:
+* Marker for Literal result elements, in order to avoid multiple attempts
+* to recognize such elements in the stylesheet's tree.
+* This marker is set on node->psvi during the initial traversal
+* of a stylesheet's node tree.
+*
+const xmlChar *xsltLiteralResultMarker =
+    (const xmlChar *) "Literal Result Element";
+*/
+
+/*
+* xsltXSLTTextMarker:
+* Marker for xsl:text elements. Used to recognize xsl:text elements
+* for post-processing of the stylesheet's tree, where those
+* elements are removed from the tree.
+*/
+const xmlChar *xsltXSLTTextMarker = (const xmlChar *) "XSLT Text Element";
+
+/*
+* xsltXSLTAttrMarker:
+* Marker for XSLT attribute on Literal Result Elements.
+*/
+const xmlChar *xsltXSLTAttrMarker = (const xmlChar *) "LRE XSLT Attr";
+
+#endif
+
+/*
+ * Harmless but avoiding a problem when compiling against a
+ * libxml <= 2.3.11 without LIBXML_DEBUG_ENABLED
+ */
+#ifndef LIBXML_DEBUG_ENABLED
+double xmlXPathStringEvalNumber(const xmlChar *str);
+#endif
+/*
+ * Useful macros
+ */
+
+#ifdef  IS_BLANK
+#undef IS_BLANK
+#endif
+#define IS_BLANK(c) (((c) == 0x20) || ((c) == 0x09) || ((c) == 0xA) || \
+                     ((c) == 0x0D))
+
+#ifdef IS_BLANK_NODE
+#undef IS_BLANK_NODE
+#endif
+#define IS_BLANK_NODE(n)                                               \
+    (((n)->type == XML_TEXT_NODE) && (xsltIsBlank((n)->content)))
+
+/**
+ * xsltParseContentError:
+ *
+ * @style: the stylesheet
+ * @node: the node where the error occured
+ *
+ * Compile-time error function.
+ */
+static void
+xsltParseContentError(xsltStylesheetPtr style,
+                      xmlNodePtr node)
+{
+    if ((style == NULL) || (node == NULL))
+       return;
+
+    if (IS_XSLT_ELEM(node))
+       xsltTransformError(NULL, style, node,
+           "The XSLT-element '%s' is not allowed at this position.\n",
+           node->name);
+    else
+       xsltTransformError(NULL, style, node,
+           "The element '%s' is not allowed at this position.\n",
+           node->name);
+    style->errors++;
+}
+
+#ifdef XSLT_REFACTORED
+#else
+/**
+ * exclPrefixPush:
+ * @style: the transformation stylesheet
+ * @value:  the excluded namespace name to push on the stack
+ *
+ * Push an excluded namespace name on the stack
+ *
+ * Returns the new index in the stack or 0 in case of error
+ */
+static int
+exclPrefixPush(xsltStylesheetPtr style, xmlChar * value)
+{
+    if (style->exclPrefixMax == 0) {
+        style->exclPrefixMax = 4;
+        style->exclPrefixTab =
+            (xmlChar * *)xmlMalloc(style->exclPrefixMax *
+                                   sizeof(style->exclPrefixTab[0]));
+        if (style->exclPrefixTab == NULL) {
+            xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
+            return (0);
+        }
+    }
+    if (style->exclPrefixNr >= style->exclPrefixMax) {
+        style->exclPrefixMax *= 2;
+        style->exclPrefixTab =
+            (xmlChar * *)xmlRealloc(style->exclPrefixTab,
+                                    style->exclPrefixMax *
+                                    sizeof(style->exclPrefixTab[0]));
+        if (style->exclPrefixTab == NULL) {
+            xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
+            return (0);
+        }
+    }
+    style->exclPrefixTab[style->exclPrefixNr] = value;
+    style->exclPrefix = value;
+    return (style->exclPrefixNr++);
+}
+/**
+ * exclPrefixPop:
+ * @style: the transformation stylesheet
+ *
+ * Pop an excluded prefix value from the stack
+ *
+ * Returns the stored excluded prefix value
+ */
+static xmlChar *
+exclPrefixPop(xsltStylesheetPtr style)
+{
+    xmlChar *ret;
+
+    if (style->exclPrefixNr <= 0)
+        return (0);
+    style->exclPrefixNr--;
+    if (style->exclPrefixNr > 0)
+        style->exclPrefix = style->exclPrefixTab[style->exclPrefixNr - 1];
+    else
+        style->exclPrefix = NULL;
+    ret = style->exclPrefixTab[style->exclPrefixNr];
+    style->exclPrefixTab[style->exclPrefixNr] = 0;
+    return (ret);
+}
+#endif
+
+/************************************************************************
+ *                                                                     *
+ *                     Helper functions                                *
+ *                                                                     *
+ ************************************************************************/
+
+static int initialized = 0;
+/**
+ * xsltInit:
+ *
+ * Initializes the processor (e.g. registers built-in extensions,
+ * etc.)
+ */
+void
+xsltInit (void) {
+    if (initialized == 0) {
+       initialized = 1;
+        xsltRegisterAllExtras();
+    }
+}
+
+/**
+ * xsltUninit:
+ *
+ * Uninitializes the processor.
+ */
+void
+xsltUninit (void) {
+    initialized = 0;
+}
+
+/**
+ * xsltIsBlank:
+ * @str:  a string
+ *
+ * Check if a string is ignorable
+ *
+ * Returns 1 if the string is NULL or made of blanks chars, 0 otherwise
+ */
+int
+xsltIsBlank(xmlChar *str) {
+    if (str == NULL)
+       return(1);
+    while (*str != 0) {
+       if (!(IS_BLANK(*str))) return(0);
+       str++;
+    }
+    return(1);
+}
+
+/************************************************************************
+ *                                                                     *
+ *             Routines to handle XSLT data structures                 *
+ *                                                                     *
+ ************************************************************************/
+static xsltDecimalFormatPtr
+xsltNewDecimalFormat(xmlChar *name)
+{
+    xsltDecimalFormatPtr self;
+    /* UTF-8 for 0x2030 */
+    static const xmlChar permille[4] = {0xe2, 0x80, 0xb0, 0};
+
+    self = xmlMalloc(sizeof(xsltDecimalFormat));
+    if (self != NULL) {
+       self->next = NULL;
+       self->name = name;
+       
+       /* Default values */
+       self->digit = xmlStrdup(BAD_CAST("#"));
+       self->patternSeparator = xmlStrdup(BAD_CAST(";"));
+       self->decimalPoint = xmlStrdup(BAD_CAST("."));
+       self->grouping = xmlStrdup(BAD_CAST(","));
+       self->percent = xmlStrdup(BAD_CAST("%"));
+       self->permille = xmlStrdup(BAD_CAST(permille));
+       self->zeroDigit = xmlStrdup(BAD_CAST("0"));
+       self->minusSign = xmlStrdup(BAD_CAST("-"));
+       self->infinity = xmlStrdup(BAD_CAST("Infinity"));
+       self->noNumber = xmlStrdup(BAD_CAST("NaN"));
+    }
+    return self;
+}
+
+static void
+xsltFreeDecimalFormat(xsltDecimalFormatPtr self)
+{
+    if (self != NULL) {
+       if (self->digit)
+           xmlFree(self->digit);
+       if (self->patternSeparator)
+           xmlFree(self->patternSeparator);
+       if (self->decimalPoint)
+           xmlFree(self->decimalPoint);
+       if (self->grouping)
+           xmlFree(self->grouping);
+       if (self->percent)
+           xmlFree(self->percent);
+       if (self->permille)
+           xmlFree(self->permille);
+       if (self->zeroDigit)
+           xmlFree(self->zeroDigit);
+       if (self->minusSign)
+           xmlFree(self->minusSign);
+       if (self->infinity)
+           xmlFree(self->infinity);
+       if (self->noNumber)
+           xmlFree(self->noNumber);
+       if (self->name)
+           xmlFree(self->name);
+       xmlFree(self);
+    }
+}
+
+static void
+xsltFreeDecimalFormatList(xsltStylesheetPtr self)
+{
+    xsltDecimalFormatPtr iter;
+    xsltDecimalFormatPtr tmp;
+
+    if (self == NULL)
+       return;
+    
+    iter = self->decimalFormat;
+    while (iter != NULL) {
+       tmp = iter->next;
+       xsltFreeDecimalFormat(iter);
+       iter = tmp;
+    }
+}
+
+/**
+ * xsltDecimalFormatGetByName:
+ * @style: the XSLT stylesheet
+ * @name: the decimal-format name to find
+ *
+ * Find decimal-format by name
+ *
+ * Returns the xsltDecimalFormatPtr
+ */
+xsltDecimalFormatPtr
+xsltDecimalFormatGetByName(xsltStylesheetPtr style, xmlChar *name)
+{
+    xsltDecimalFormatPtr result = NULL;
+
+    if (name == NULL)
+       return style->decimalFormat;
+
+    while (style != NULL) {
+       for (result = style->decimalFormat->next;
+            result != NULL;
+            result = result->next) {
+           if (xmlStrEqual(name, result->name))
+               return result;
+       }
+       style = xsltNextImport(style);
+    }
+    return result;
+}
+
+
+/**
+ * xsltNewTemplate:
+ *
+ * Create a new XSLT Template
+ *
+ * Returns the newly allocated xsltTemplatePtr or NULL in case of error
+ */
+static xsltTemplatePtr
+xsltNewTemplate(void) {
+    xsltTemplatePtr cur;
+
+    cur = (xsltTemplatePtr) xmlMalloc(sizeof(xsltTemplate));
+    if (cur == NULL) {
+       xsltTransformError(NULL, NULL, NULL,
+               "xsltNewTemplate : malloc failed\n");
+       return(NULL);
+    }
+    memset(cur, 0, sizeof(xsltTemplate));
+    cur->priority = XSLT_PAT_NO_PRIORITY;
+    return(cur);
+}
+
+/**
+ * xsltFreeTemplate:
+ * @template:  an XSLT template
+ *
+ * Free up the memory allocated by @template
+ */
+static void
+xsltFreeTemplate(xsltTemplatePtr template) {
+    if (template == NULL)
+       return;
+    if (template->match) xmlFree(template->match);
+/*
+*   NOTE: @name and @nameURI are put into the string dict now.
+*   if (template->name) xmlFree(template->name);
+*   if (template->nameURI) xmlFree(template->nameURI);
+*/
+/*
+    if (template->mode) xmlFree(template->mode);
+    if (template->modeURI) xmlFree(template->modeURI);
+ */
+    if (template->inheritedNs) xmlFree(template->inheritedNs);
+    memset(template, -1, sizeof(xsltTemplate));
+    xmlFree(template);
+}
+
+/**
+ * xsltFreeTemplateList:
+ * @template:  an XSLT template list
+ *
+ * Free up the memory allocated by all the elements of @template
+ */
+static void
+xsltFreeTemplateList(xsltTemplatePtr template) {
+    xsltTemplatePtr cur;
+
+    while (template != NULL) {
+       cur = template;
+       template = template->next;
+       xsltFreeTemplate(cur);
+    }
+}
+
+#ifdef XSLT_REFACTORED
+
+static void
+xsltFreeNsAliasList(xsltNsAliasPtr item)
+{
+    xsltNsAliasPtr tmp;
+    
+    while (item) {
+       tmp = item;
+       item = item->next;
+       xmlFree(tmp);
+    } 
+    return;
+}
+
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+static void
+xsltFreeNamespaceMap(xsltNsMapPtr item)
+{
+    xsltNsMapPtr tmp;
+    
+    while (item) {
+       tmp = item;
+       item = item->next;
+       xmlFree(tmp);
+    } 
+    return;
+}
+
+static xsltNsMapPtr
+xsltNewNamespaceMapItem(xsltCompilerCtxtPtr cctxt,
+                       xmlDocPtr doc,
+                       xmlNsPtr ns,
+                       xmlNodePtr elem)
+{
+    xsltNsMapPtr ret;
+
+    if ((cctxt == NULL) || (doc == NULL) || (ns == NULL))
+       return(NULL);
+
+    ret = (xsltNsMapPtr) xmlMalloc(sizeof(xsltNsMap));
+    if (ret == NULL) {
+       xsltTransformError(NULL, cctxt->style, elem,
+           "Internal error: (xsltNewNamespaceMapItem) "
+           "memory allocation failed.\n");
+       return(NULL);
+    }
+    memset(ret, 0, sizeof(xsltNsMap));
+    ret->doc = doc;
+    ret->ns = ns;
+    ret->origNsName = ns->href;
+    /*
+    * Store the item at current stylesheet-level.
+    */
+    if (cctxt->psData->nsMap != NULL)
+       ret->next = cctxt->psData->nsMap;
+    cctxt->psData->nsMap = ret;
+
+    return(ret);
+}
+#endif /* XSLT_REFACTORED_XSLT_NSCOMP */
+
+/**
+ * xsltCompilerVarInfoFree: 
+ * @cctxt: the compilation context
+ * 
+ * Frees the list of information for vars/params.
+ */
+static void
+xsltCompilerVarInfoFree(xsltCompilerCtxtPtr cctxt)
+{
+    xsltVarInfoPtr ivar = cctxt->ivars, ivartmp;    
+
+    while (ivar) {
+       ivartmp = ivar;
+       ivar = ivar->next;
+       xmlFree(ivartmp);
+    }
+}
+
+/**
+ * xsltCompilerCtxtFree:
+ *
+ * Free an XSLT compiler context. 
+ */
+static void
+xsltCompilationCtxtFree(xsltCompilerCtxtPtr cctxt)
+{    
+    if (cctxt == NULL)
+       return;
+#ifdef WITH_XSLT_DEBUG_PARSING
+    xsltGenericDebug(xsltGenericDebugContext,
+       "Freeing compilation context\n");
+    xsltGenericDebug(xsltGenericDebugContext,
+       "### Max inodes: %d\n", cctxt->maxNodeInfos);
+    xsltGenericDebug(xsltGenericDebugContext,
+       "### Max LREs  : %d\n", cctxt->maxLREs);
+#endif
+    /*
+    * Free node-infos.
+    */
+    if (cctxt->inodeList != NULL) {
+       xsltCompilerNodeInfoPtr tmp, cur = cctxt->inodeList;
+       while (cur != NULL) {
+           tmp = cur;
+           cur = cur->next;
+           xmlFree(tmp);
+       }
+    }
+    if (cctxt->tmpList != NULL)
+       xsltPointerListFree(cctxt->tmpList);
+#ifdef XSLT_REFACTORED_XPATHCOMP
+    if (cctxt->xpathCtxt != NULL)
+       xmlXPathFreeContext(cctxt->xpathCtxt);
+#endif
+    if (cctxt->nsAliases != NULL)
+       xsltFreeNsAliasList(cctxt->nsAliases);
+
+    if (cctxt->ivars)
+       xsltCompilerVarInfoFree(cctxt);
+
+    xmlFree(cctxt);
+}
+
+/**
+ * xsltCompilerCreate:
+ *
+ * Creates an XSLT compiler context.
+ *
+ * Returns the pointer to the created xsltCompilerCtxt or
+ *         NULL in case of an internal error.
+ */
+static xsltCompilerCtxtPtr
+xsltCompilationCtxtCreate(xsltStylesheetPtr style) {
+    xsltCompilerCtxtPtr ret;
+
+    ret = (xsltCompilerCtxtPtr) xmlMalloc(sizeof(xsltCompilerCtxt));
+    if (ret == NULL) {
+       xsltTransformError(NULL, style, NULL,
+           "xsltCompilerCreate: allocation of compiler "
+           "context failed.\n");
+       return(NULL);
+    }
+    memset(ret, 0, sizeof(xsltCompilerCtxt));
+
+    ret->errSeverity = XSLT_ERROR_SEVERITY_ERROR;
+    ret->tmpList = xsltPointerListCreate(20);
+    if (ret->tmpList == NULL) {
+       goto internal_err;
+    }
+#ifdef XSLT_REFACTORED_XPATHCOMP
+    /*
+    * Create the XPath compilation context in order
+    * to speed up precompilation of XPath expressions.
+    */
+    ret->xpathCtxt = xmlXPathNewContext(NULL);
+    if (ret->xpathCtxt == NULL)
+       goto internal_err;
+#endif
+    
+    return(ret);
+
+internal_err:
+    xsltCompilationCtxtFree(ret);
+    return(NULL);
+}
+
+static void
+xsltLREEffectiveNsNodesFree(xsltEffectiveNsPtr first)
+{
+    xsltEffectiveNsPtr tmp;
+
+    while (first != NULL) {
+       tmp = first;
+       first = first->nextInStore;
+       xmlFree(tmp);
+    }
+}
+
+static void
+xsltFreePrincipalStylesheetData(xsltPrincipalStylesheetDataPtr data)
+{
+    if (data == NULL)
+       return;
+
+    if (data->inScopeNamespaces != NULL) {
+       int i;
+       xsltNsListContainerPtr nsi;
+       xsltPointerListPtr list =
+           (xsltPointerListPtr) data->inScopeNamespaces;
+
+       for (i = 0; i < list->number; i++) {
+           /*
+           * REVISIT TODO: Free info of in-scope namespaces.
+           */
+           nsi = (xsltNsListContainerPtr) list->items[i];
+           if (nsi->list != NULL)
+               xmlFree(nsi->list);
+           xmlFree(nsi);
+       }
+       xsltPointerListFree(list);
+       data->inScopeNamespaces = NULL;
+    }
+
+    if (data->exclResultNamespaces != NULL) {
+       int i;
+       xsltPointerListPtr list = (xsltPointerListPtr)
+           data->exclResultNamespaces; 
+       
+       for (i = 0; i < list->number; i++)
+           xsltPointerListFree((xsltPointerListPtr) list->items[i]);
+       
+       xsltPointerListFree(list);
+       data->exclResultNamespaces = NULL;
+    }
+
+    if (data->extElemNamespaces != NULL) {
+       xsltPointerListPtr list = (xsltPointerListPtr)
+           data->extElemNamespaces;
+       int i;
+
+       for (i = 0; i < list->number; i++)
+           xsltPointerListFree((xsltPointerListPtr) list->items[i]);
+
+       xsltPointerListFree(list);
+       data->extElemNamespaces = NULL;
+    }
+    if (data->effectiveNs) {
+       xsltLREEffectiveNsNodesFree(data->effectiveNs);
+       data->effectiveNs = NULL;
+    }
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+    xsltFreeNamespaceMap(data->nsMap);
+#endif
+    xmlFree(data);
+}
+
+static xsltPrincipalStylesheetDataPtr
+xsltNewPrincipalStylesheetData(void)
+{
+    xsltPrincipalStylesheetDataPtr ret;
+
+    ret = (xsltPrincipalStylesheetDataPtr)
+       xmlMalloc(sizeof(xsltPrincipalStylesheetData));
+    if (ret == NULL) {
+       xsltTransformError(NULL, NULL, NULL,
+           "xsltNewPrincipalStylesheetData: memory allocation failed.\n");
+       return(NULL);
+    }
+    memset(ret, 0, sizeof(xsltPrincipalStylesheetData));
+    
+    /*
+    * Global list of in-scope namespaces.
+    */    
+    ret->inScopeNamespaces = xsltPointerListCreate(-1);
+    if (ret->inScopeNamespaces == NULL)
+       goto internal_err;
+    /*
+    * Global list of excluded result ns-decls.
+    */
+    ret->exclResultNamespaces = xsltPointerListCreate(-1);
+    if (ret->exclResultNamespaces == NULL)
+       goto internal_err;
+    /*
+    * Global list of extension instruction namespace names.
+    */    
+    ret->extElemNamespaces = xsltPointerListCreate(-1);
+    if (ret->extElemNamespaces == NULL)
+       goto internal_err;
+
+    return(ret);
+
+internal_err:
+
+    return(NULL);
+}
+
+#endif
+
+/**
+ * xsltNewStylesheet:
+ *
+ * Create a new XSLT Stylesheet
+ *
+ * Returns the newly allocated xsltStylesheetPtr or NULL in case of error
+ */
+xsltStylesheetPtr
+xsltNewStylesheet(void) {
+    xsltStylesheetPtr ret = NULL;    
+
+    ret = (xsltStylesheetPtr) xmlMalloc(sizeof(xsltStylesheet));
+    if (ret == NULL) {
+       xsltTransformError(NULL, NULL, NULL,
+               "xsltNewStylesheet : malloc failed\n");
+       goto internal_err;
+    }
+    memset(ret, 0, sizeof(xsltStylesheet));
+
+    ret->omitXmlDeclaration = -1;
+    ret->standalone = -1;
+    ret->decimalFormat = xsltNewDecimalFormat(NULL);
+    ret->indent = -1;
+    ret->errors = 0;
+    ret->warnings = 0;
+    ret->exclPrefixNr = 0;
+    ret->exclPrefixMax = 0;
+    ret->exclPrefixTab = NULL;
+    ret->extInfos = NULL;
+    ret->extrasNr = 0;
+    ret->internalized = 1;
+    ret->literal_result = 0;
+    ret->dict = xmlDictCreate();
+#ifdef WITH_XSLT_DEBUG
+    xsltGenericDebug(xsltGenericDebugContext,
+       "creating dictionary for stylesheet\n");
+#endif
+
+    xsltInit();
+
+    return(ret);
+
+internal_err:
+    if (ret != NULL)
+       xsltFreeStylesheet(ret);
+    return(NULL);
+}
+
+/**
+ * xsltAllocateExtra:
+ * @style:  an XSLT stylesheet
+ *
+ * Allocate an extra runtime information slot statically while compiling
+ * the stylesheet and return its number
+ *
+ * Returns the number of the slot
+ */
+int
+xsltAllocateExtra(xsltStylesheetPtr style)
+{
+    return(style->extrasNr++);
+}
+
+/**
+ * xsltAllocateExtraCtxt:
+ * @ctxt:  an XSLT transformation context
+ *
+ * Allocate an extra runtime information slot at run-time
+ * and return its number
+ * This make sure there is a slot ready in the transformation context
+ *
+ * Returns the number of the slot
+ */
+int
+xsltAllocateExtraCtxt(xsltTransformContextPtr ctxt)
+{
+    if (ctxt->extrasNr >= ctxt->extrasMax) {
+       int i;
+       if (ctxt->extrasNr == 0) {
+           ctxt->extrasMax = 20;
+           ctxt->extras = (xsltRuntimeExtraPtr)
+               xmlMalloc(ctxt->extrasMax * sizeof(xsltRuntimeExtra));
+           if (ctxt->extras == NULL) {
+               xmlGenericError(xmlGenericErrorContext,
+                       "xsltAllocateExtraCtxt: out of memory\n");
+               ctxt->state = XSLT_STATE_ERROR;
+               return(0);
+           }
+           for (i = 0;i < ctxt->extrasMax;i++) {
+               ctxt->extras[i].info = NULL;
+               ctxt->extras[i].deallocate = NULL;
+               ctxt->extras[i].val.ptr = NULL;
+           }
+
+       } else {
+           xsltRuntimeExtraPtr tmp;
+
+           ctxt->extrasMax += 100;
+           tmp = (xsltRuntimeExtraPtr) xmlRealloc(ctxt->extras,
+                           ctxt->extrasMax * sizeof(xsltRuntimeExtra));
+           if (tmp == NULL) {
+               xmlGenericError(xmlGenericErrorContext,
+                       "xsltAllocateExtraCtxt: out of memory\n");
+               ctxt->state = XSLT_STATE_ERROR;
+               return(0);
+           }
+           ctxt->extras = tmp;
+           for (i = ctxt->extrasNr;i < ctxt->extrasMax;i++) {
+               ctxt->extras[i].info = NULL;
+               ctxt->extras[i].deallocate = NULL;
+               ctxt->extras[i].val.ptr = NULL;
+           }
+       }
+    }
+    return(ctxt->extrasNr++);
+}
+
+/**
+ * xsltFreeStylesheetList:
+ * @style:  an XSLT stylesheet list
+ *
+ * Free up the memory allocated by the list @style
+ */
+static void
+xsltFreeStylesheetList(xsltStylesheetPtr style) {
+    xsltStylesheetPtr next;
+
+    while (style != NULL) {
+       next = style->next;
+       xsltFreeStylesheet(style);
+       style = next;
+    }
+}
+
+/**
+ * xsltCleanupStylesheetTree:
+ *
+ * @doc: the document-node
+ * @node: the element where the stylesheet is rooted at
+ *
+ * Actually @node need not be the document-element, but
+ * currently Libxslt does not support embedded stylesheets.
+ *
+ * Returns 0 if OK, -1 on API or internal errors.
+ */
+static int
+xsltCleanupStylesheetTree(xmlDocPtr doc ATTRIBUTE_UNUSED,
+                         xmlNodePtr rootElem ATTRIBUTE_UNUSED)
+{    
+#if 0 /* TODO: Currently disabled, since probably not needed. */
+    xmlNodePtr cur;
+
+    if ((doc == NULL) || (rootElem == NULL) ||
+       (rootElem->type != XML_ELEMENT_NODE) ||
+       (doc != rootElem->doc))
+       return(-1);
+
+    /*
+    * Cleanup was suggested by Aleksey Sanin:
+    * Clear the PSVI field to avoid problems if the
+    * node-tree of the stylesheet is intended to be used for
+    * further processing by the user (e.g. for compiling it
+    * once again - although not recommended).
+    */
+
+    cur = rootElem;
+    while (cur != NULL) {
+       if (cur->type == XML_ELEMENT_NODE) {
+           /*
+           * Clear the PSVI field.
+           */
+           cur->psvi = NULL;
+           if (cur->children) {
+               cur = cur->children;
+               continue;
+           }
+       }
+
+leave_node:
+       if (cur == rootElem)
+           break;
+       if (cur->next != NULL)
+           cur = cur->next;
+       else {
+           cur = cur->parent;
+           if (cur == NULL)
+               break;
+           goto leave_node;
+       }
+    }
+#endif /* #if 0 */
+    return(0);
+}
+
+/**
+ * xsltFreeStylesheet:
+ * @style:  an XSLT stylesheet
+ *
+ * Free up the memory allocated by @style
+ */
+void
+xsltFreeStylesheet(xsltStylesheetPtr style)
+{
+    if (style == NULL)
+        return;
+    
+#ifdef XSLT_REFACTORED
+    /*
+    * Start with a cleanup of the main stylesheet's doc.
+    */
+    if ((style->principal == style) && (style->doc))
+       xsltCleanupStylesheetTree(style->doc,
+           xmlDocGetRootElement(style->doc));
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+    /*
+    * Restore changed ns-decls before freeing the document.
+    */
+    if ((style->doc != NULL) &&
+       XSLT_HAS_INTERNAL_NSMAP(style))
+    {
+       xsltRestoreDocumentNamespaces(XSLT_GET_INTERNAL_NSMAP(style),
+           style->doc);        
+    }
+#endif /* XSLT_REFACTORED_XSLT_NSCOMP */
+#else
+    /*
+    * Start with a cleanup of the main stylesheet's doc.
+    */
+    if ((style->parent == NULL) && (style->doc))
+       xsltCleanupStylesheetTree(style->doc,
+           xmlDocGetRootElement(style->doc));
+#endif /* XSLT_REFACTORED */
+
+    xsltFreeKeys(style);
+    xsltFreeExts(style);
+    xsltFreeTemplateHashes(style);
+    xsltFreeDecimalFormatList(style);
+    xsltFreeTemplateList(style->templates);
+    xsltFreeAttributeSetsHashes(style);
+    xsltFreeNamespaceAliasHashes(style);
+    xsltFreeStylePreComps(style);
+    /*
+    * Free documents of all included stylsheet modules of this
+    * stylesheet level.
+    */
+    xsltFreeStyleDocuments(style);
+    /*
+    * TODO: Best time to shutdown extension stuff?
+    */
+    xsltShutdownExts(style);
+       
+    if (style->variables != NULL)
+        xsltFreeStackElemList(style->variables);
+    if (style->cdataSection != NULL)
+        xmlHashFree(style->cdataSection, NULL);
+    if (style->stripSpaces != NULL)
+        xmlHashFree(style->stripSpaces, NULL);
+    if (style->nsHash != NULL)
+        xmlHashFree(style->nsHash, NULL);
+    if (style->exclPrefixTab != NULL)
+        xmlFree(style->exclPrefixTab);
+    if (style->method != NULL)
+        xmlFree(style->method);
+    if (style->methodURI != NULL)
+        xmlFree(style->methodURI);
+    if (style->version != NULL)
+        xmlFree(style->version);
+    if (style->encoding != NULL)
+        xmlFree(style->encoding);
+    if (style->doctypePublic != NULL)
+        xmlFree(style->doctypePublic);
+    if (style->doctypeSystem != NULL)
+        xmlFree(style->doctypeSystem);
+    if (style->mediaType != NULL)
+        xmlFree(style->mediaType);
+    if (style->attVTs)
+        xsltFreeAVTList(style->attVTs);
+    if (style->imports != NULL)
+        xsltFreeStylesheetList(style->imports);
+
+#ifdef XSLT_REFACTORED
+    /*
+    * If this is the principal stylesheet, then
+    * free its internal data.
+    */
+    if (style->principal == style) {
+       if (style->principalData) {
+           xsltFreePrincipalStylesheetData(style->principalData);
+           style->principalData = NULL;
+       }
+    }    
+#endif
+    /*
+    * Better to free the main document of this stylesheet level
+    * at the end - so here.
+    */
+    if (style->doc != NULL) {  
+        xmlFreeDoc(style->doc);
+    }
+
+#ifdef WITH_XSLT_DEBUG
+    xsltGenericDebug(xsltGenericDebugContext,
+                     "freeing dictionary from stylesheet\n");
+#endif
+    xmlDictFree(style->dict);
+
+    memset(style, -1, sizeof(xsltStylesheet));
+    xmlFree(style);
+}
+
+/************************************************************************
+ *                                                                     *
+ *             Parsing of an XSLT Stylesheet                           *
+ *                                                                     *
+ ************************************************************************/
+
+#ifdef XSLT_REFACTORED
+    /*
+    * This is now performed in an optimized way in xsltParseXSLTTemplate.
+    */
+#else
+/**
+ * xsltGetInheritedNsList:
+ * @style:  the stylesheet
+ * @template: the template
+ * @node:  the current node
+ *
+ * Search all the namespace applying to a given element except the ones 
+ * from excluded output prefixes currently in scope. Initialize the
+ * template inheritedNs list with it.
+ *
+ * Returns the number of entries found
+ */
+static int
+xsltGetInheritedNsList(xsltStylesheetPtr style,
+                      xsltTemplatePtr template,
+                      xmlNodePtr node)
+{
+    xmlNsPtr cur;
+    xmlNsPtr *ret = NULL;
+    int nbns = 0;
+    int maxns = 10;
+    int i;    
+
+    if ((style == NULL) || (template == NULL) || (node == NULL) ||
+       (template->inheritedNsNr != 0) || (template->inheritedNs != NULL))
+       return(0);
+    while (node != NULL) {
+        if (node->type == XML_ELEMENT_NODE) {
+            cur = node->nsDef;
+            while (cur != NULL) {
+               if (xmlStrEqual(cur->href, XSLT_NAMESPACE))
+                   goto skip_ns;
+
+               if ((cur->prefix != NULL) &&
+                   (xsltCheckExtPrefix(style, cur->prefix)))
+                   goto skip_ns;
+               /*
+               * Check if this namespace was excluded.
+               * Note that at this point only the exclusions defined
+               * on the topmost stylesheet element are in the exclusion-list.
+               */
+               for (i = 0;i < style->exclPrefixNr;i++) {
+                   if (xmlStrEqual(cur->href, style->exclPrefixTab[i]))
+                       goto skip_ns;
+               }
+                if (ret == NULL) {
+                    ret =
+                        (xmlNsPtr *) xmlMalloc((maxns + 1) *
+                                               sizeof(xmlNsPtr));
+                    if (ret == NULL) {
+                        xmlGenericError(xmlGenericErrorContext,
+                                        "xsltGetInheritedNsList : out of memory!\n");
+                        return(0);
+                    }
+                    ret[nbns] = NULL;
+                }
+               /*
+               * Skip shadowed namespace bindings.
+               */
+                for (i = 0; i < nbns; i++) {
+                    if ((cur->prefix == ret[i]->prefix) ||
+                        (xmlStrEqual(cur->prefix, ret[i]->prefix)))
+                        break;
+                }
+                if (i >= nbns) {
+                    if (nbns >= maxns) {
+                        maxns *= 2;
+                        ret = (xmlNsPtr *) xmlRealloc(ret,
+                                                      (maxns +
+                                                       1) *
+                                                      sizeof(xmlNsPtr));
+                        if (ret == NULL) {
+                            xmlGenericError(xmlGenericErrorContext,
+                                            "xsltGetInheritedNsList : realloc failed!\n");
+                            return(0);
+                        }
+                    }
+                    ret[nbns++] = cur;
+                    ret[nbns] = NULL;
+                }
+skip_ns:
+                cur = cur->next;
+            }
+        }
+        node = node->parent;
+    }
+    if (nbns != 0) {
+#ifdef WITH_XSLT_DEBUG_PARSING
+        xsltGenericDebug(xsltGenericDebugContext,
+                         "template has %d inherited namespaces\n", nbns);
+#endif
+       template->inheritedNsNr = nbns;
+       template->inheritedNs = ret;
+    }
+    return (nbns);
+}
+#endif /* else of XSLT_REFACTORED */
+
+/**
+ * xsltParseStylesheetOutput:
+ * @style:  the XSLT stylesheet
+ * @cur:  the "output" element
+ *
+ * parse an XSLT stylesheet output element and record
+ * information related to the stylesheet output
+ */
+
+void
+xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur)
+{
+    xmlChar *elements,
+     *prop;
+    xmlChar *element,
+     *end;
+
+    if ((cur == NULL) || (style == NULL))
+        return;
+   
+    prop = xmlGetNsProp(cur, (const xmlChar *) "version", NULL);
+    if (prop != NULL) {
+        if (style->version != NULL)
+            xmlFree(style->version);
+        style->version = prop;
+    }
+
+    prop = xmlGetNsProp(cur, (const xmlChar *) "encoding", NULL);
+    if (prop != NULL) {
+        if (style->encoding != NULL)
+            xmlFree(style->encoding);
+        style->encoding = prop;
+    }
+
+    /* relaxed to support xt:document
+    * TODO KB: What does "relaxed to support xt:document" mean?
+    */
+    prop = xmlGetNsProp(cur, (const xmlChar *) "method", NULL);
+    if (prop != NULL) {
+        const xmlChar *URI;
+
+        if (style->method != NULL)
+            xmlFree(style->method);
+        style->method = NULL;
+        if (style->methodURI != NULL)
+            xmlFree(style->methodURI);
+        style->methodURI = NULL;
+
+       /*
+       * TODO: Don't use xsltGetQNameURI().
+       */
+       URI = xsltGetQNameURI(cur, &prop);
+       if (prop == NULL) {
+           if (style != NULL) style->errors++;
+       } else if (URI == NULL) {
+            if ((xmlStrEqual(prop, (const xmlChar *) "xml")) ||
+                (xmlStrEqual(prop, (const xmlChar *) "html")) ||
+                (xmlStrEqual(prop, (const xmlChar *) "text"))) {
+                style->method = prop;
+            } else {
+               xsltTransformError(NULL, style, cur,
+                                 "invalid value for method: %s\n", prop);
+                if (style != NULL) style->warnings++;
+            }
+       } else {
+           style->method = prop;
+           style->methodURI = xmlStrdup(URI);
+       }
+    }
+
+    prop = xmlGetNsProp(cur, (const xmlChar *) "doctype-system", NULL);
+    if (prop != NULL) {
+        if (style->doctypeSystem != NULL)
+            xmlFree(style->doctypeSystem);
+        style->doctypeSystem = prop;
+    }
+
+    prop = xmlGetNsProp(cur, (const xmlChar *) "doctype-public", NULL);
+    if (prop != NULL) {
+        if (style->doctypePublic != NULL)
+            xmlFree(style->doctypePublic);
+        style->doctypePublic = prop;
+    }
+
+    prop = xmlGetNsProp(cur, (const xmlChar *) "standalone", NULL);
+    if (prop != NULL) {
+        if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
+            style->standalone = 1;
+        } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
+            style->standalone = 0;
+        } else {
+           xsltTransformError(NULL, style, cur,
+                             "invalid value for standalone: %s\n", prop);
+            style->errors++;
+        }
+        xmlFree(prop);
+    }
+
+    prop = xmlGetNsProp(cur, (const xmlChar *) "indent", NULL);
+    if (prop != NULL) {
+        if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
+            style->indent = 1;
+        } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
+            style->indent = 0;
+        } else {
+           xsltTransformError(NULL, style, cur,
+                             "invalid value for indent: %s\n", prop);
+            style->errors++;
+        }
+        xmlFree(prop);
+    }
+
+    prop = xmlGetNsProp(cur, (const xmlChar *) "omit-xml-declaration", NULL);
+    if (prop != NULL) {
+        if (xmlStrEqual(prop, (const xmlChar *) "yes")) {
+            style->omitXmlDeclaration = 1;
+        } else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
+            style->omitXmlDeclaration = 0;
+        } else {
+           xsltTransformError(NULL, style, cur,
+                             "invalid value for omit-xml-declaration: %s\n",
+                             prop);
+            style->errors++;
+        }
+        xmlFree(prop);
+    }
+
+    elements = xmlGetNsProp(cur, (const xmlChar *) "cdata-section-elements",
+       NULL);
+    if (elements != NULL) {
+        if (style->cdataSection == NULL)
+            style->cdataSection = xmlHashCreate(10);
+        if (style->cdataSection == NULL)
+            return;
+
+        element = elements;
+        while (*element != 0) {
+            while (IS_BLANK(*element))
+                element++;
+            if (*element == 0)
+                break;
+            end = element;
+            while ((*end != 0) && (!IS_BLANK(*end)))
+                end++;
+            element = xmlStrndup(element, end - element);
+            if (element) {             
+#ifdef WITH_XSLT_DEBUG_PARSING
+                xsltGenericDebug(xsltGenericDebugContext,
+                                 "add cdata section output element %s\n",
+                                 element);
+#endif
+               if (xmlValidateQName(BAD_CAST element, 0) != 0) {
+                   xsltTransformError(NULL, style, cur,
+                       "Attribute 'cdata-section-elements': The value "
+                       "'%s' is not a valid QName.\n", element);
+                   xmlFree(element);
+                   style->errors++;
+               } else {
+                   const xmlChar *URI;
+
+                   /*
+                   * TODO: Don't use xsltGetQNameURI().
+                   */
+                   URI = xsltGetQNameURI(cur, &element);
+                   if (element == NULL) {
+                       /*
+                       * TODO: We'll report additionally an error
+                       *  via the stylesheet's error handling.                 
+                       */
+                       xsltTransformError(NULL, style, cur,
+                           "Attribute 'cdata-section-elements': The value "
+                           "'%s' is not a valid QName.\n", element);
+                       style->errors++;
+                   } else {
+                       xmlNsPtr ns;
+                       
+                       /*
+                       * XSLT-1.0 "Each QName is expanded into an
+                       *  expanded-name using the namespace declarations in
+                       *  effect on the xsl:output element in which the QName
+                       *  occurs; if there is a default namespace, it is used
+                       *  for QNames that do not have a prefix"
+                       * NOTE: Fix of bug #339570.
+                       */
+                       if (URI == NULL) {
+                           ns = xmlSearchNs(style->doc, cur, NULL);
+                           if (ns != NULL)
+                               URI = ns->href;
+                       }                  
+                       xmlHashAddEntry2(style->cdataSection, element, URI,
+                           (void *) "cdata");
+                       xmlFree(element);
+                   }
+               }
+            }
+            element = end;
+        }
+        xmlFree(elements);
+    }
+
+    prop = xmlGetNsProp(cur, (const xmlChar *) "media-type", NULL);
+    if (prop != NULL) {
+       if (style->mediaType)
+           xmlFree(style->mediaType);
+       style->mediaType = prop;
+    }
+    if (cur->children != NULL) {
+       xsltParseContentError(style, cur->children);
+    }
+}
+
+/**
+ * xsltParseStylesheetDecimalFormat:
+ * @style:  the XSLT stylesheet
+ * @cur:  the "decimal-format" element
+ *
+ * <!-- Category: top-level-element -->
+ * <xsl:decimal-format
+ *   name = qname, decimal-separator = char, grouping-separator = char,
+ *   infinity = string, minus-sign = char, NaN = string, percent = char
+ *   per-mille = char, zero-digit = char, digit = char,
+ * pattern-separator = char />
+ *
+ * parse an XSLT stylesheet decimal-format element and
+ * and record the formatting characteristics
+ */
+static void
+xsltParseStylesheetDecimalFormat(xsltStylesheetPtr style, xmlNodePtr cur)
+{
+    xmlChar *prop;
+    xsltDecimalFormatPtr format;
+    xsltDecimalFormatPtr iter;
+    
+    if ((cur == NULL) || (style == NULL))
+       return;
+
+    format = style->decimalFormat;
+    
+    prop = xmlGetNsProp(cur, BAD_CAST("name"), NULL);
+    if (prop != NULL) {
+       format = xsltDecimalFormatGetByName(style, prop);
+       if (format != NULL) {
+           xsltTransformError(NULL, style, cur,
+        "xsltParseStylestyleDecimalFormat: %s already exists\n", prop);
+           if (style != NULL) style->warnings++;
+           return;
+       }
+       format = xsltNewDecimalFormat(prop);
+       if (format == NULL) {
+           xsltTransformError(NULL, style, cur,
+     "xsltParseStylestyleDecimalFormat: failed creating new decimal-format\n");
+           if (style != NULL) style->errors++;
+           return;
+       }
+       /* Append new decimal-format structure */
+       for (iter = style->decimalFormat; iter->next; iter = iter->next)
+           ;
+       if (iter)
+           iter->next = format;
+    }
+
+    prop = xmlGetNsProp(cur, (const xmlChar *)"decimal-separator", NULL);
+    if (prop != NULL) {
+       if (format->decimalPoint != NULL) xmlFree(format->decimalPoint);
+       format->decimalPoint  = prop;
+    }
+    
+    prop = xmlGetNsProp(cur, (const xmlChar *)"grouping-separator", NULL);
+    if (prop != NULL) {
+       if (format->grouping != NULL) xmlFree(format->grouping);
+       format->grouping  = prop;
+    }
+
+    prop = xmlGetNsProp(cur, (const xmlChar *)"infinity", NULL);
+    if (prop != NULL) {
+       if (format->infinity != NULL) xmlFree(format->infinity);
+       format->infinity  = prop;
+    }
+    
+    prop = xmlGetNsProp(cur, (const xmlChar *)"minus-sign", NULL);
+    if (prop != NULL) {
+       if (format->minusSign != NULL) xmlFree(format->minusSign);
+       format->minusSign  = prop;
+    }
+    
+    prop = xmlGetNsProp(cur, (const xmlChar *)"NaN", NULL);
+    if (prop != NULL) {
+       if (format->noNumber != NULL) xmlFree(format->noNumber);
+       format->noNumber  = prop;
+    }
+    
+    prop = xmlGetNsProp(cur, (const xmlChar *)"percent", NULL);
+    if (prop != NULL) {
+       if (format->percent != NULL) xmlFree(format->percent);
+       format->percent  = prop;
+    }
+    
+    prop = xmlGetNsProp(cur, (const xmlChar *)"per-mille", NULL);
+    if (prop != NULL) {
+       if (format->permille != NULL) xmlFree(format->permille);
+       format->permille  = prop;
+    }
+    
+    prop = xmlGetNsProp(cur, (const xmlChar *)"zero-digit", NULL);
+    if (prop != NULL) {
+       if (format->zeroDigit != NULL) xmlFree(format->zeroDigit);
+       format->zeroDigit  = prop;
+    }
+    
+    prop = xmlGetNsProp(cur, (const xmlChar *)"digit", NULL);
+    if (prop != NULL) {
+       if (format->digit != NULL) xmlFree(format->digit);
+       format->digit  = prop;
+    }
+    
+    prop = xmlGetNsProp(cur, (const xmlChar *)"pattern-separator", NULL);
+    if (prop != NULL) {
+       if (format->patternSeparator != NULL) xmlFree(format->patternSeparator);
+       format->patternSeparator  = prop;
+    }
+    if (cur->children != NULL) {
+       xsltParseContentError(style, cur->children);
+    }
+}
+
+/**
+ * xsltParseStylesheetPreserveSpace:
+ * @style:  the XSLT stylesheet
+ * @cur:  the "preserve-space" element
+ *
+ * parse an XSLT stylesheet preserve-space element and record
+ * elements needing preserving
+ */
+
+static void
+xsltParseStylesheetPreserveSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
+    xmlChar *elements;
+    xmlChar *element, *end;
+
+    if ((cur == NULL) || (style == NULL))
+       return;
+
+    elements = xmlGetNsProp(cur, (const xmlChar *)"elements", NULL);
+    if (elements == NULL) {
+       xsltTransformError(NULL, style, cur,
+           "xsltParseStylesheetPreserveSpace: missing elements attribute\n");
+       if (style != NULL) style->warnings++;
+       return;
+    }
+
+    if (style->stripSpaces == NULL)
+       style->stripSpaces = xmlHashCreate(10);
+    if (style->stripSpaces == NULL)
+       return;
+
+    element = elements;
+    while (*element != 0) {
+       while (IS_BLANK(*element)) element++;
+       if (*element == 0)
+           break;
+        end = element;
+       while ((*end != 0) && (!IS_BLANK(*end))) end++;
+       element = xmlStrndup(element, end - element);
+       if (element) {
+#ifdef WITH_XSLT_DEBUG_PARSING
+           xsltGenericDebug(xsltGenericDebugContext,
+               "add preserved space element %s\n", element);
+#endif
+           if (xmlStrEqual(element, (const xmlChar *)"*")) {
+               style->stripAll = -1;
+           } else {
+               const xmlChar *URI;
+
+               /*
+               * TODO: Don't use xsltGetQNameURI().
+               */
+                URI = xsltGetQNameURI(cur, &element);
+
+               xmlHashAddEntry2(style->stripSpaces, element, URI,
+                               (xmlChar *) "preserve");
+           }
+           xmlFree(element);
+       }
+       element = end;
+    }
+    xmlFree(elements);
+    if (cur->children != NULL) {
+       xsltParseContentError(style, cur->children);
+    }
+}
+
+#ifdef XSLT_REFACTORED
+#else
+/**
+ * xsltParseStylesheetExtPrefix:
+ * @style:  the XSLT stylesheet
+ * @template:  the "extension-element-prefixes" prefix
+ *
+ * parse an XSLT stylesheet's "extension-element-prefix" attribute value
+ * and register the namespaces of extension instruction.
+ * SPEC "A namespace is designated as an extension namespace by using
+ *   an extension-element-prefixes attribute on:
+ *   1) an xsl:stylesheet element
+ *   2) an xsl:extension-element-prefixes attribute on a
+ *      literal result element 
+ *   3) an extension instruction."
+ */
+static void
+xsltParseStylesheetExtPrefix(xsltStylesheetPtr style, xmlNodePtr cur,
+                            int isXsltElem) {
+    xmlChar *prefixes;
+    xmlChar *prefix, *end;
+
+    if ((cur == NULL) || (style == NULL))
+       return;
+
+    if (isXsltElem) {
+       /* For xsl:stylesheet/xsl:transform. */
+       prefixes = xmlGetNsProp(cur,
+           (const xmlChar *)"extension-element-prefixes", NULL);
+    } else {
+       /* For literal result elements and extension instructions. */
+       prefixes = xmlGetNsProp(cur,
+           (const xmlChar *)"extension-element-prefixes", XSLT_NAMESPACE);
+    }
+    if (prefixes == NULL) {
+       return;
+    }
+
+    prefix = prefixes;
+    while (*prefix != 0) {
+       while (IS_BLANK(*prefix)) prefix++;
+       if (*prefix == 0)
+           break;
+        end = prefix;
+       while ((*end != 0) && (!IS_BLANK(*end))) end++;
+       prefix = xmlStrndup(prefix, end - prefix);
+       if (prefix) {
+           xmlNsPtr ns;
+
+           if (xmlStrEqual(prefix, (const xmlChar *)"#default"))
+               ns = xmlSearchNs(style->doc, cur, NULL);
+           else
+               ns = xmlSearchNs(style->doc, cur, prefix);
+           if (ns == NULL) {
+               xsltTransformError(NULL, style, cur,
+           "xsl:extension-element-prefix : undefined namespace %s\n",
+                                prefix);
+               if (style != NULL) style->warnings++;
+           } else {
+#ifdef WITH_XSLT_DEBUG_PARSING
+               xsltGenericDebug(xsltGenericDebugContext,
+                   "add extension prefix %s\n", prefix);
+#endif
+               xsltRegisterExtPrefix(style, prefix, ns->href);
+           }
+           xmlFree(prefix);
+       }
+       prefix = end;
+    }
+    xmlFree(prefixes);
+}
+#endif /* else of XSLT_REFACTORED */
+
+/**
+ * xsltParseStylesheetStripSpace:
+ * @style:  the XSLT stylesheet
+ * @cur:  the "strip-space" element
+ *
+ * parse an XSLT stylesheet's strip-space element and record
+ * the elements needing stripping
+ */
+
+static void
+xsltParseStylesheetStripSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
+    xmlChar *elements;
+    xmlChar *element, *end;
+
+    if ((cur == NULL) || (style == NULL))
+       return;
+
+    elements = xmlGetNsProp(cur, (const xmlChar *)"elements", NULL);
+    if (elements == NULL) {
+       xsltTransformError(NULL, style, cur,
+           "xsltParseStylesheetStripSpace: missing elements attribute\n");
+       if (style != NULL) style->warnings++;
+       return;
+    }
+
+    if (style->stripSpaces == NULL)
+       style->stripSpaces = xmlHashCreate(10);
+    if (style->stripSpaces == NULL)
+       return;
+
+    element = elements;
+    while (*element != 0) {
+       while (IS_BLANK(*element)) element++;
+       if (*element == 0)
+           break;
+        end = element;
+       while ((*end != 0) && (!IS_BLANK(*end))) end++;
+       element = xmlStrndup(element, end - element);
+       if (element) {
+#ifdef WITH_XSLT_DEBUG_PARSING
+           xsltGenericDebug(xsltGenericDebugContext,
+               "add stripped space element %s\n", element);
+#endif
+           if (xmlStrEqual(element, (const xmlChar *)"*")) {
+               style->stripAll = 1;
+           } else {
+               const xmlChar *URI;
+
+               /*
+               * TODO: Don't use xsltGetQNameURI().
+               */
+                URI = xsltGetQNameURI(cur, &element);
+
+               xmlHashAddEntry2(style->stripSpaces, element, URI,
+                               (xmlChar *) "strip");
+           }
+           xmlFree(element);
+       }
+       element = end;
+    }
+    xmlFree(elements);
+    if (cur->children != NULL) {
+       xsltParseContentError(style, cur->children);
+    }
+}
+
+#ifdef XSLT_REFACTORED
+#else
+/**
+ * xsltParseStylesheetExcludePrefix:
+ * @style:  the XSLT stylesheet
+ * @cur:  the current point in the stylesheet
+ *
+ * parse an XSLT stylesheet exclude prefix and record
+ * namespaces needing stripping
+ *
+ * Returns the number of Excluded prefixes added at that level
+ */
+
+static int
+xsltParseStylesheetExcludePrefix(xsltStylesheetPtr style, xmlNodePtr cur,
+                                int isXsltElem)
+{
+    int nb = 0;
+    xmlChar *prefixes;
+    xmlChar *prefix, *end;
+
+    if ((cur == NULL) || (style == NULL))
+       return(0);
+
+    if (isXsltElem)
+       prefixes = xmlGetNsProp(cur,
+           (const xmlChar *)"exclude-result-prefixes", NULL);
+    else
+       prefixes = xmlGetNsProp(cur,
+           (const xmlChar *)"exclude-result-prefixes", XSLT_NAMESPACE);
+
+    if (prefixes == NULL) {
+       return(0);
+    }
+
+    prefix = prefixes;
+    while (*prefix != 0) {
+       while (IS_BLANK(*prefix)) prefix++;
+       if (*prefix == 0)
+           break;
+        end = prefix;
+       while ((*end != 0) && (!IS_BLANK(*end))) end++;
+       prefix = xmlStrndup(prefix, end - prefix);
+       if (prefix) {
+           xmlNsPtr ns;
+
+           if (xmlStrEqual(prefix, (const xmlChar *)"#default"))
+               ns = xmlSearchNs(style->doc, cur, NULL);
+           else
+               ns = xmlSearchNs(style->doc, cur, prefix);
+           if (ns == NULL) {
+               xsltTransformError(NULL, style, cur,
+           "xsl:exclude-result-prefixes : undefined namespace %s\n",
+                                prefix);
+               if (style != NULL) style->warnings++;
+           } else {
+#ifdef WITH_XSLT_DEBUG_PARSING
+               xsltGenericDebug(xsltGenericDebugContext,
+                   "exclude result prefix %s\n", prefix);
+#endif
+               exclPrefixPush(style, (xmlChar *) ns->href);
+               nb++;
+           }
+           xmlFree(prefix);
+       }
+       prefix = end;
+    }
+    xmlFree(prefixes);
+    return(nb);
+}
+#endif /* else of XSLT_REFACTORED */
+
+#ifdef XSLT_REFACTORED
+
+/*
+* xsltTreeEnsureXMLDecl:
+* @doc: the doc
+* 
+* BIG NOTE:
+*  This was copy&pasted from Libxml2's xmlTreeEnsureXMLDecl() in "tree.c".
+* Ensures that there is an XML namespace declaration on the doc.
+* 
+* Returns the XML ns-struct or NULL on API and internal errors.
+*/
+static xmlNsPtr
+xsltTreeEnsureXMLDecl(xmlDocPtr doc)
+{
+    if (doc == NULL)
+       return (NULL);
+    if (doc->oldNs != NULL)
+       return (doc->oldNs);
+    {
+       xmlNsPtr ns;
+       ns = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
+       if (ns == NULL) {
+           xmlGenericError(xmlGenericErrorContext,
+               "xsltTreeEnsureXMLDecl: Failed to allocate "
+               "the XML namespace.\n");        
+           return (NULL);
+       }
+       memset(ns, 0, sizeof(xmlNs));
+       ns->type = XML_LOCAL_NAMESPACE;
+       /*
+       * URGENT TODO: revisit this.
+       */
+#ifdef LIBXML_NAMESPACE_DICT
+       if (doc->dict)
+           ns->href = xmlDictLookup(doc->dict, XML_XML_NAMESPACE, -1);
+       else
+           ns->href = xmlStrdup(XML_XML_NAMESPACE);
+#else
+       ns->href = xmlStrdup(XML_XML_NAMESPACE); 
+#endif
+       ns->prefix = xmlStrdup((const xmlChar *)"xml");
+       doc->oldNs = ns;
+       return (ns);
+    }
+}
+
+/*
+* xsltTreeAcquireStoredNs:
+* @doc: the doc
+* @nsName: the namespace name
+* @prefix: the prefix
+* 
+* BIG NOTE:
+*  This was copy&pasted from Libxml2's xmlDOMWrapStoreNs() in "tree.c".
+* Creates or reuses an xmlNs struct on doc->oldNs with
+* the given prefix and namespace name.
+* 
+* Returns the aquired ns struct or NULL in case of an API
+*         or internal error.
+*/
+static xmlNsPtr
+xsltTreeAcquireStoredNs(xmlDocPtr doc,
+                       const xmlChar *nsName,
+                       const xmlChar *prefix)
+{
+    xmlNsPtr ns;
+
+    if (doc == NULL)
+       return (NULL);
+    if (doc->oldNs != NULL)
+       ns = doc->oldNs;
+    else
+       ns = xsltTreeEnsureXMLDecl(doc);
+    if (ns == NULL)
+       return (NULL);
+    if (ns->next != NULL) {
+       /* Reuse. */
+       ns = ns->next;
+       while (ns != NULL) {
+           if ((ns->prefix == NULL) != (prefix == NULL)) {
+               /* NOP */
+           } else if (prefix == NULL) {
+               if (xmlStrEqual(ns->href, nsName))
+                   return (ns);
+           } else {
+               if ((ns->prefix[0] == prefix[0]) &&
+                    xmlStrEqual(ns->prefix, prefix) &&
+                    xmlStrEqual(ns->href, nsName))
+                   return (ns);
+               
+           }
+           if (ns->next == NULL)
+               break;
+           ns = ns->next;
+       }
+    }
+    /* Create. */
+    ns->next = xmlNewNs(NULL, nsName, prefix);
+    return (ns->next);
+}
+
+/**
+ * xsltLREBuildEffectiveNs:
+ *
+ * Apply ns-aliasing on the namespace of the given @elem and
+ * its attributes.
+ */
+static int
+xsltLREBuildEffectiveNs(xsltCompilerCtxtPtr cctxt,
+                       xmlNodePtr elem)
+{
+    xmlNsPtr ns;
+    xsltNsAliasPtr alias;
+
+    if ((cctxt == NULL) || (elem == NULL))
+       return(-1);
+    if ((cctxt->nsAliases == NULL) || (! cctxt->hasNsAliases))
+       return(0);
+
+    alias = cctxt->nsAliases;                  
+    while (alias != NULL) {
+       if ( /* If both namespaces are NULL... */
+           ( (elem->ns == NULL) &&
+           ((alias->literalNs == NULL) ||
+           (alias->literalNs->href == NULL)) ) ||
+           /* ... or both namespace are equal */
+           ( (elem->ns != NULL) &&
+           (alias->literalNs != NULL) &&
+           xmlStrEqual(elem->ns->href, alias->literalNs->href) ) )
+       {
+           if ((alias->targetNs != NULL) &&
+               (alias->targetNs->href != NULL))
+           {
+               /*
+               * Convert namespace.
+               */
+               if (elem->doc == alias->docOfTargetNs) {
+                   /*
+                   * This is the nice case: same docs.
+                   * This will eventually assign a ns-decl which
+                   * is shadowed, but this has no negative effect on
+                   * the generation of the result tree.
+                   */
+                   elem->ns = alias->targetNs;
+               } else {
+                   /*
+                   * This target xmlNs originates from a different
+                   * stylesheet tree. Try to locate it in the
+                   * in-scope namespaces.
+                   * OPTIMIZE TODO: Use the compiler-node-info inScopeNs.
+                   */
+                   ns = xmlSearchNs(elem->doc, elem,
+                       alias->targetNs->prefix);                   
+                   /*
+                   * If no matching ns-decl found, then assign a
+                   * ns-decl stored in xmlDoc.
+                   */
+                   if ((ns == NULL) ||
+                       (! xmlStrEqual(ns->href, alias->targetNs->href)))
+                   {
+                       /*
+                       * BIG NOTE: The use of xsltTreeAcquireStoredNs()
+                       *  is not very efficient, but currently I don't
+                       *  see an other way of *safely* changing a node's
+                       *  namespace, since the xmlNs struct in
+                       *  alias->targetNs might come from an other
+                       *  stylesheet tree. So we need to anchor it in the
+                       *  current document, without adding it to the tree,
+                       *  which would otherwise change the in-scope-ns
+                       *  semantic of the tree.
+                       */
+                       ns = xsltTreeAcquireStoredNs(elem->doc,
+                           alias->targetNs->href,
+                           alias->targetNs->prefix);
+                       
+                       if (ns == NULL) {
+                           xsltTransformError(NULL, cctxt->style, elem,
+                               "Internal error in "
+                               "xsltLREBuildEffectiveNs(): "
+                               "failed to acquire a stored "
+                               "ns-declaration.\n");
+                           cctxt->style->errors++;
+                           return(-1);
+                           
+                       }
+                   }
+                   elem->ns = ns;
+               }                  
+           } else {
+               /*
+               * Move into or leave in the NULL namespace.
+               */
+               elem->ns = NULL;
+           }
+           break;
+       }
+       alias = alias->next;
+    }
+    /*
+    * Same with attributes of literal result elements.
+    */
+    if (elem->properties != NULL) {
+       xmlAttrPtr attr = elem->properties;
+       
+       while (attr != NULL) {
+           if (attr->ns == NULL) {
+               attr = attr->next;
+               continue;
+           }
+           alias = cctxt->nsAliases;
+           while (alias != NULL) {
+               if ( /* If both namespaces are NULL... */
+                   ( (elem->ns == NULL) &&
+                   ((alias->literalNs == NULL) ||
+                   (alias->literalNs->href == NULL)) ) ||
+                   /* ... or both namespace are equal */
+                   ( (elem->ns != NULL) &&
+                   (alias->literalNs != NULL) &&
+                   xmlStrEqual(elem->ns->href, alias->literalNs->href) ) )
+               {
+                   if ((alias->targetNs != NULL) &&
+                       (alias->targetNs->href != NULL))
+                   {               
+                       if (elem->doc == alias->docOfTargetNs) {
+                           elem->ns = alias->targetNs;
+                       } else {
+                           ns = xmlSearchNs(elem->doc, elem,
+                               alias->targetNs->prefix);
+                           if ((ns == NULL) ||
+                               (! xmlStrEqual(ns->href, alias->targetNs->href)))
+                           {
+                               ns = xsltTreeAcquireStoredNs(elem->doc,
+                                   alias->targetNs->href,
+                                   alias->targetNs->prefix);
+                               
+                               if (ns == NULL) {
+                                   xsltTransformError(NULL, cctxt->style, elem,
+                                       "Internal error in "
+                                       "xsltLREBuildEffectiveNs(): "
+                                       "failed to acquire a stored "
+                                       "ns-declaration.\n");
+                                   cctxt->style->errors++;
+                                   return(-1);
+                                   
+                               }
+                           }
+                           elem->ns = ns;
+                       }
+                   } else {
+                   /*
+                   * Move into or leave in the NULL namespace.
+                       */
+                       elem->ns = NULL;
+                   }
+                   break;
+               }
+               alias = alias->next;
+           }
+           
+           attr = attr->next;
+       }
+    }
+    return(0);
+}
+
+/**
+ * xsltLREBuildEffectiveNsNodes:
+ *
+ * Computes the effective namespaces nodes for a literal result
+ * element.
+ * @effectiveNs is the set of effective ns-nodes
+ *  on the literal result element, which will be added to the result
+ *  element if not already existing in the result tree.
+ *  This means that excluded namespaces (via exclude-result-prefixes,
+ *  extension-element-prefixes and the XSLT namespace) not added
+ *  to the set.
+ *  Namespace-aliasing was applied on the @effectiveNs.
+ */
+static int
+xsltLREBuildEffectiveNsNodes(xsltCompilerCtxtPtr cctxt,
+                            xsltStyleItemLRElementInfoPtr item,
+                            xmlNodePtr elem,
+                            int isLRE)
+{
+    xmlNsPtr ns, tmpns;
+    xsltEffectiveNsPtr effNs, lastEffNs = NULL;
+    int i, j, holdByElem;
+    xsltPointerListPtr extElemNs = cctxt->inode->extElemNs;
+    xsltPointerListPtr exclResultNs = cctxt->inode->exclResultNs;
+
+    if ((cctxt == NULL) || (cctxt->inode == NULL) || (elem == NULL) ||
+       (item == NULL) || (item->effectiveNs != NULL))
+       return(-1);
+
+    if (item->inScopeNs == NULL)    
+       return(0);
+
+    extElemNs = cctxt->inode->extElemNs;
+    exclResultNs = cctxt->inode->exclResultNs;
+
+    for (i = 0; i < item->inScopeNs->totalNumber; i++) {
+       ns = item->inScopeNs->list[i];
+       /*
+       * Skip namespaces designated as excluded namespaces
+       * -------------------------------------------------
+       *
+       * XSLT-20 TODO: In XSLT 2.0 we need to keep namespaces
+       *  which are target namespaces of namespace-aliases
+       *  regardless if designated as excluded.
+       *
+       * Exclude the XSLT namespace.
+       */
+       if (xmlStrEqual(ns->href, XSLT_NAMESPACE))
+           goto skip_ns;
+
+       /*
+       * Apply namespace aliasing
+       * ------------------------
+       *
+       * SPEC XSLT 2.0
+       *  "- A namespace node whose string value is a literal namespace
+       *     URI is not copied to the result tree.
+       *   - A namespace node whose string value is a target namespace URI
+       *     is copied to the result tree, whether or not the URI
+       *     identifies an excluded namespace."
+       * 
+       * NOTE: The ns-aliasing machanism is non-cascading.
+       *  (checked with Saxon, Xalan and MSXML .NET).
+       * URGENT TODO: is style->nsAliases the effective list of
+       *  ns-aliases, or do we need to lookup the whole
+       *  import-tree?
+       * TODO: Get rid of import-tree lookup.
+       */
+       if (cctxt->hasNsAliases) {
+           xsltNsAliasPtr alias;
+           /*
+           * First check for being a target namespace.
+           */
+           alias = cctxt->nsAliases;
+           do {
+               /*
+               * TODO: Is xmlns="" handled already?
+               */
+               if ((alias->targetNs != NULL) &&
+                   (xmlStrEqual(alias->targetNs->href, ns->href)))
+               {
+                   /*
+                   * Recognized as a target namespace; use it regardless
+                   * if excluded otherwise.
+                   */
+                   goto add_effective_ns;
+               }
+               alias = alias->next;
+           } while (alias != NULL);
+
+           alias = cctxt->nsAliases;
+           do {
+               /*
+               * TODO: Is xmlns="" handled already?
+               */
+               if ((alias->literalNs != NULL) &&
+                   (xmlStrEqual(alias->literalNs->href, ns->href)))
+               {
+                   /*
+                   * Recognized as an namespace alias; do not use it.
+                   */
+                   goto skip_ns;
+               }
+               alias = alias->next;
+           } while (alias != NULL);
+       }
+       
+       /*
+       * Exclude excluded result namespaces.
+       */
+       if (exclResultNs) {
+           for (j = 0; j < exclResultNs->number; j++)
+               if (xmlStrEqual(ns->href, BAD_CAST exclResultNs->items[j]))
+                   goto skip_ns;
+       }
+       /*
+       * Exclude extension-element namespaces.
+       */
+       if (extElemNs) {
+           for (j = 0; j < extElemNs->number; j++)
+               if (xmlStrEqual(ns->href, BAD_CAST extElemNs->items[j]))
+                   goto skip_ns;
+       }
+
+add_effective_ns:
+       /*
+       * OPTIMIZE TODO: This information may not be needed.
+       */
+       if (isLRE && (elem->nsDef != NULL)) {
+           holdByElem = 0;
+           tmpns = elem->nsDef;
+           do {
+               if (tmpns == ns) {
+                   holdByElem = 1;
+                   break;
+               }
+               tmpns = tmpns->next;
+           } while (tmpns != NULL);        
+       } else
+           holdByElem = 0;
+       
+       
+       /*
+       * Add the effective namespace declaration.
+       */
+       effNs = (xsltEffectiveNsPtr) xmlMalloc(sizeof(xsltEffectiveNs));
+       if (effNs == NULL) {
+           xsltTransformError(NULL, cctxt->style, elem,
+               "Internal error in xsltLREBuildEffectiveNs(): "
+               "failed to allocate memory.\n");
+           cctxt->style->errors++;
+           return(-1);
+       }
+       if (cctxt->psData->effectiveNs == NULL) {
+           cctxt->psData->effectiveNs = effNs;
+           effNs->nextInStore = NULL;   
+       } else {
+           effNs->nextInStore = cctxt->psData->effectiveNs;
+           cctxt->psData->effectiveNs = effNs;
+       }
+
+       effNs->next = NULL;
+       effNs->prefix = ns->prefix;
+       effNs->nsName = ns->href;
+       effNs->holdByElem = holdByElem;
+       
+       if (lastEffNs == NULL)
+           item->effectiveNs = effNs;
+       else
+           lastEffNs->next = effNs;
+       lastEffNs = effNs;
+       
+skip_ns:
+       {}
+    }
+    return(0);
+}
+
+
+/**
+ * xsltLREInfoCreate:
+ *
+ * @isLRE: indicates if the given @elem is a literal result element
+ *
+ * Creates a new info for a literal result element.
+ */
+static int
+xsltLREInfoCreate(xsltCompilerCtxtPtr cctxt,
+                 xmlNodePtr elem,
+                 int isLRE)
+{
+    xsltStyleItemLRElementInfoPtr item;
+
+    if ((cctxt == NULL) || (cctxt->inode == NULL))
+       return(-1);
+
+    item = (xsltStyleItemLRElementInfoPtr)
+       xmlMalloc(sizeof(xsltStyleItemLRElementInfo));
+    if (item == NULL) {
+       xsltTransformError(NULL, cctxt->style, NULL,
+           "Internal error in xsltLREInfoCreate(): "
+           "memory allocation failed.\n");
+       cctxt->style->errors++;
+       return(-1);
+    }
+    memset(item, 0, sizeof(xsltStyleItemLRElementInfo));
+    item->type = XSLT_FUNC_LITERAL_RESULT_ELEMENT;
+    /*
+    * Store it in the stylesheet.
+    */
+    item->next = cctxt->style->preComps;
+    cctxt->style->preComps = (xsltElemPreCompPtr) item;
+    /*
+    * @inScopeNs are used for execution of XPath expressions
+    *  in AVTs.
+    */
+    item->inScopeNs = cctxt->inode->inScopeNs;
+    
+    if (elem)
+       xsltLREBuildEffectiveNsNodes(cctxt, item, elem, isLRE);
+
+    cctxt->inode->litResElemInfo = item;
+    cctxt->inode->nsChanged = 0;
+    cctxt->maxLREs++;
+    return(0);
+}
+
+/**
+ * xsltCompilerVarInfoPush: 
+ * @cctxt: the compilation context
+ * 
+ * Pushes a new var/param info onto the stack.
+ *
+ * Returns the acquired variable info.
+ */ 
+static xsltVarInfoPtr
+xsltCompilerVarInfoPush(xsltCompilerCtxtPtr cctxt,
+                                 xmlNodePtr inst,
+                                 const xmlChar *name,
+                                 const xmlChar *nsName)
+{
+    xsltVarInfoPtr ivar;
+
+    if ((cctxt->ivar != NULL) && (cctxt->ivar->next != NULL)) {
+       ivar = cctxt->ivar->next;
+    } else if ((cctxt->ivar == NULL) && (cctxt->ivars != NULL)) {
+       ivar = cctxt->ivars;
+    } else {
+       ivar = (xsltVarInfoPtr) xmlMalloc(sizeof(xsltVarInfo));
+       if (ivar == NULL) {
+           xsltTransformError(NULL, cctxt->style, inst,
+               "xsltParseInScopeVarPush: xmlMalloc() failed!\n");
+           cctxt->style->errors++;
+           return(NULL);
+       }
+       /* memset(retVar, 0, sizeof(xsltInScopeVar)); */
+       if (cctxt->ivars == NULL) {
+           cctxt->ivars = ivar;
+           ivar->prev = NULL;
+       } else {
+           cctxt->ivar->next = ivar;
+           ivar->prev = cctxt->ivar;
+       }
+       cctxt->ivar = ivar;
+       ivar->next = NULL;
+    }
+    ivar->depth = cctxt->depth;
+    ivar->name = name;
+    ivar->nsName = nsName;
+    return(ivar);
+}
+
+/**
+ * xsltCompilerVarInfoPop: 
+ * @cctxt: the compilation context
+ * 
+ * Pops all var/param infos from the stack, which
+ * have the current depth.
+ */ 
+static void
+xsltCompilerVarInfoPop(xsltCompilerCtxtPtr cctxt)
+{
+
+    while ((cctxt->ivar != NULL) &&
+       (cctxt->ivar->depth > cctxt->depth))
+    {
+       cctxt->ivar = cctxt->ivar->prev;
+    }
+}
+
+/*
+* xsltCompilerNodePush:
+*
+* @cctxt: the compilation context
+* @node: the node to be pushed (this can also be the doc-node)
+*
+* 
+*
+* Returns the current node info structure or
+*         NULL in case of an internal error.
+*/
+static xsltCompilerNodeInfoPtr
+xsltCompilerNodePush(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
+{    
+    xsltCompilerNodeInfoPtr inode, iprev;
+
+    if ((cctxt->inode != NULL) && (cctxt->inode->next != NULL)) {      
+       inode = cctxt->inode->next;
+    } else if ((cctxt->inode == NULL) && (cctxt->inodeList != NULL)) {
+       inode = cctxt->inodeList;       
+    } else {
+       /*
+       * Create a new node-info.
+       */
+       inode = (xsltCompilerNodeInfoPtr)
+           xmlMalloc(sizeof(xsltCompilerNodeInfo));
+       if (inode == NULL) {
+           xsltTransformError(NULL, cctxt->style, NULL,
+               "xsltCompilerNodePush: malloc failed.\n");
+           return(NULL);
+       }
+       memset(inode, 0, sizeof(xsltCompilerNodeInfo));
+       if (cctxt->inodeList == NULL)
+           cctxt->inodeList = inode;
+       else {
+           cctxt->inodeLast->next = inode;
+           inode->prev = cctxt->inodeLast;
+       }
+       cctxt->inodeLast = inode;
+       cctxt->maxNodeInfos++;  
+       if (cctxt->inode == NULL) {
+           cctxt->inode = inode;
+           /*
+           * Create an initial literal result element info for
+           * the root of the stylesheet.
+           */
+           xsltLREInfoCreate(cctxt, NULL, 0);
+       } 
+    }       
+    cctxt->depth++;
+    cctxt->inode = inode;
+    /*
+    * REVISIT TODO: Keep the reset always complete.    
+    * NOTE: Be carefull with the @node, since it might be
+    *  a doc-node.
+    */
+    inode->node = node;
+    inode->depth = cctxt->depth;
+    inode->templ = NULL;
+    inode->category = XSLT_ELEMENT_CATEGORY_XSLT;
+    inode->type = 0;
+    inode->item = NULL;
+    inode->curChildType = 0;
+    inode->extContentHandled = 0;
+    inode->isRoot = 0;
+    
+    if (inode->prev != NULL) {
+       iprev = inode->prev;
+       /*
+       * Inherit the following information:
+       * ---------------------------------
+       *
+       * In-scope namespaces
+       */
+       inode->inScopeNs = iprev->inScopeNs;
+       /*
+       * Info for literal result elements
+       */
+       inode->litResElemInfo = iprev->litResElemInfo;
+       inode->nsChanged = iprev->nsChanged;
+       /*
+       * Excluded result namespaces
+       */
+       inode->exclResultNs = iprev->exclResultNs;
+       /*
+       * Extension instruction namespaces
+       */
+       inode->extElemNs = iprev->extElemNs;
+       /*
+       * Whitespace preservation
+       */
+       inode->preserveWhitespace = iprev->preserveWhitespace;
+       /*
+       * Forwards-compatible mode
+       */
+       inode->forwardsCompat = iprev->forwardsCompat;  
+    } else {
+       inode->inScopeNs = NULL;
+       inode->exclResultNs = NULL;
+       inode->extElemNs = NULL;
+       inode->preserveWhitespace = 0;
+       inode->forwardsCompat = 0;
+    }
+    
+    return(inode);
+}
+
+/*
+* xsltCompilerNodePop:
+*
+* @cctxt: the compilation context
+* @node: the node to be pushed (this can also be the doc-node)
+*
+* Pops the current node info.
+*/
+static void
+xsltCompilerNodePop(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
+{    
+    if (cctxt->inode == NULL) {
+       xmlGenericError(xmlGenericErrorContext,
+           "xsltCompilerNodePop: Top-node mismatch.\n");
+       return;
+    }
+    /*
+    * NOTE: Be carefull with the @node, since it might be
+    *  a doc-node.
+    */
+    if (cctxt->inode->node != node) {
+       xmlGenericError(xmlGenericErrorContext,
+       "xsltCompilerNodePop: Node mismatch.\n");
+       goto mismatch;
+    }
+    if (cctxt->inode->depth != cctxt->depth) {
+       xmlGenericError(xmlGenericErrorContext,
+       "xsltCompilerNodePop: Depth mismatch.\n");
+       goto mismatch;
+    }
+    /*
+    * Pop information of variables.
+    */
+    if ((cctxt->ivar) && (cctxt->ivar->depth > cctxt->depth))
+       xsltCompilerVarInfoPop(cctxt);
+
+    cctxt->depth--;
+    cctxt->inode = cctxt->inode->prev;
+    if (cctxt->inode != NULL)
+       cctxt->inode->curChildType = 0;
+    return;
+
+mismatch:
+    {
+       const xmlChar *nsName = NULL, *name = NULL;
+       const xmlChar *infnsName = NULL, *infname = NULL;
+       
+       if (node) {
+           if (node->type == XML_ELEMENT_NODE) {
+               name = node->name;
+               if (node->ns != NULL)
+                   nsName = node->ns->href;
+               else
+                   nsName = BAD_CAST "";
+           } else {
+               name = BAD_CAST "#document";
+               nsName = BAD_CAST "";
+           }
+       } else
+           name = BAD_CAST "Not given";
+
+       if (cctxt->inode->node) {
+           if (node->type == XML_ELEMENT_NODE) {
+               infname = cctxt->inode->node->name;
+               if (cctxt->inode->node->ns != NULL)
+                   infnsName = cctxt->inode->node->ns->href;
+               else
+                   infnsName = BAD_CAST "";
+           } else {
+               infname = BAD_CAST "#document";
+               infnsName = BAD_CAST "";
+           }
+       } else
+           infname = BAD_CAST "Not given";
+
+       
+       xmlGenericError(xmlGenericErrorContext,
+           "xsltCompilerNodePop: Given   : '%s' URI '%s'\n",
+           name, nsName);
+       xmlGenericError(xmlGenericErrorContext,
+           "xsltCompilerNodePop: Expected: '%s' URI '%s'\n",
+           infname, infnsName);
+    }
+}
+
+/*
+* xsltCompilerBuildInScopeNsList:
+*
+* Create and store the list of in-scope namespaces for the given
+* node in the stylesheet. If there are no changes in the in-scope
+* namespaces then the last ns-info of the ancestor axis will be returned.
+* Compilation-time only.
+*
+* Returns the ns-info or NULL if there are no namespaces in scope.
+*/
+static xsltNsListContainerPtr
+xsltCompilerBuildInScopeNsList(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
+{
+    xsltNsListContainerPtr nsi = NULL;
+    xmlNsPtr *list = NULL, ns;
+    int i, maxns = 5;
+    /*
+    * Create a new ns-list for this position in the node-tree.
+    * xmlGetNsList() will return NULL, if there are no ns-decls in the
+    * tree. Note that the ns-decl for the XML namespace is not added
+    * to the resulting list; the XPath module handles the XML namespace
+    * internally.
+    */
+    while (node != NULL) {
+        if (node->type == XML_ELEMENT_NODE) {
+            ns = node->nsDef;
+            while (ns != NULL) {
+                if (nsi == NULL) {
+                   nsi = (xsltNsListContainerPtr)
+                       xmlMalloc(sizeof(xsltNsListContainer));
+                   if (nsi == NULL) {
+                       xsltTransformError(NULL, cctxt->style, NULL,
+                           "xsltCompilerBuildInScopeNsList: "
+                           "malloc failed!\n");
+                       goto internal_err;
+                   }
+                   memset(nsi, 0, sizeof(xsltNsListContainer));
+                    nsi->list =
+                        (xmlNsPtr *) xmlMalloc(maxns * sizeof(xmlNsPtr));
+                    if (nsi->list == NULL) {
+                       xsltTransformError(NULL, cctxt->style, NULL,
+                           "xsltCompilerBuildInScopeNsList: "
+                           "malloc failed!\n");
+                       goto internal_err;
+                    }
+                    nsi->list[0] = NULL;
+                }
+               /*
+               * Skip shadowed namespace bindings.
+               */
+                for (i = 0; i < nsi->totalNumber; i++) {
+                    if ((ns->prefix == nsi->list[i]->prefix) ||
+                        (xmlStrEqual(ns->prefix, nsi->list[i]->prefix)))
+                   break;
+                }
+                if (i >= nsi->totalNumber) {
+                    if (nsi->totalNumber +1 >= maxns) {
+                        maxns *= 2;
+                       nsi->list =
+                           (xmlNsPtr *) xmlRealloc(nsi->list,
+                               maxns * sizeof(xmlNsPtr));
+                        if (nsi->list == NULL) {
+                            xsltTransformError(NULL, cctxt->style, NULL,
+                               "xsltCompilerBuildInScopeNsList: "
+                               "realloc failed!\n");
+                               goto internal_err;
+                        }
+                    }
+                    nsi->list[nsi->totalNumber++] = ns;
+                    nsi->list[nsi->totalNumber] = NULL;
+                }
+
+                ns = ns->next;
+            }
+        }
+        node = node->parent;
+    }
+    if (nsi == NULL)
+       return(NULL);
+    /*
+    * Move the default namespace to last position.
+    */
+    nsi->xpathNumber = nsi->totalNumber;
+    for (i = 0; i < nsi->totalNumber; i++) {
+       if (nsi->list[i]->prefix == NULL) {
+           ns = nsi->list[i];
+           nsi->list[i] = nsi->list[nsi->totalNumber-1];
+           nsi->list[nsi->totalNumber-1] = ns;
+           nsi->xpathNumber--;
+           break;
+       }
+    }
+    /*
+    * Store the ns-list in the stylesheet.
+    */
+    if (xsltPointerListAddSize(
+       (xsltPointerListPtr)cctxt->psData->inScopeNamespaces,
+       (void *) nsi, 5) == -1)
+    {  
+       xmlFree(nsi);
+       nsi = NULL;
+       xsltTransformError(NULL, cctxt->style, NULL,
+           "xsltCompilerBuildInScopeNsList: failed to add ns-info.\n");
+       goto internal_err;
+    }
+    /*
+    * Notify of change in status wrt namespaces.
+    */
+    if (cctxt->inode != NULL)
+       cctxt->inode->nsChanged = 1;
+
+    return(nsi);
+
+internal_err:
+    if (list != NULL)
+       xmlFree(list);    
+    cctxt->style->errors++;
+    return(NULL);
+}
+
+static int
+xsltParseNsPrefixList(xsltCompilerCtxtPtr cctxt,
+                     xsltPointerListPtr list,
+                     xmlNodePtr node,
+                     const xmlChar *value)
+{
+    xmlChar *cur, *end;
+    xmlNsPtr ns;
+    
+    if ((cctxt == NULL) || (value == NULL) || (list == NULL))
+       return(-1);
+
+    list->number = 0;
+
+    cur = (xmlChar *) value;
+    while (*cur != 0) {
+       while (IS_BLANK(*cur)) cur++;
+       if (*cur == 0)
+           break;
+       end = cur;
+       while ((*end != 0) && (!IS_BLANK(*end))) end++;
+       cur = xmlStrndup(cur, end - cur);
+       if (cur == NULL) {
+           cur = end;
+           continue;
+       }               
+       /*
+       * TODO: Export and use xmlSearchNsByPrefixStrict()
+       *   in Libxml2, tree.c, since xmlSearchNs() is in most
+       *   cases not efficient and in some cases not correct.
+       *
+       * XSLT-2 TODO: XSLT 2.0 allows an additional "#all" value.
+       */
+       if ((cur[0] == '#') &&
+           xmlStrEqual(cur, (const xmlChar *)"#default"))
+           ns = xmlSearchNs(cctxt->style->doc, node, NULL);
+       else
+           ns = xmlSearchNs(cctxt->style->doc, node, cur);         
+
+       if (ns == NULL) {
+           /*
+           * TODO: Better to report the attr-node, otherwise
+           *  the user won't know which attribute was invalid.
+           */
+           xsltTransformError(NULL, cctxt->style, node,
+               "No namespace binding in scope for prefix '%s'.\n", cur);
+           /*
+           * XSLT-1.0: "It is an error if there is no namespace
+           *  bound to the prefix on the element bearing the
+           *  exclude-result-prefixes or xsl:exclude-result-prefixes
+           *  attribute."
+           */
+           cctxt->style->errors++;
+       } else {
+#ifdef WITH_XSLT_DEBUG_PARSING
+           xsltGenericDebug(xsltGenericDebugContext,
+               "resolved prefix '%s'\n", cur);
+#endif
+           /*
+           * Note that we put the namespace name into the dict.
+           */
+           if (xsltPointerListAddSize(list,
+               (void *) xmlDictLookup(cctxt->style->dict,
+               ns->href, -1), 5) == -1)
+           {
+               xmlFree(cur);
+               goto internal_err;
+           }
+       }
+       xmlFree(cur);
+               
+       cur = end;
+    }
+    return(0);
+
+internal_err:
+    cctxt->style->errors++;
+    return(-1);
+}
+
+/**
+ * xsltCompilerUtilsCreateMergedList:
+ * @dest: the destination list (optional)
+ * @first: the first list
+ * @second: the second list (optional)
+ *
+ * Appends the content of @second to @first into @destination.
+ * If @destination is NULL a new list will be created.
+ *
+ * Returns the merged list of items or NULL if there's nothing to merge.
+ */
+static xsltPointerListPtr
+xsltCompilerUtilsCreateMergedList(xsltPointerListPtr first,
+                           xsltPointerListPtr second)
+{
+    xsltPointerListPtr ret;
+    size_t num;
+
+    if (first)
+       num = first->number;
+    else
+       num = 0;
+    if (second)
+       num += second->number;    
+    if (num == 0)
+       return(NULL);
+    ret = xsltPointerListCreate(num);
+    if (ret == NULL)
+       return(NULL);
+    /*
+    * Copy contents.
+    */
+    if ((first != NULL) &&  (first->number != 0)) {
+       memcpy(ret->items, first->items,
+           first->number * sizeof(void *));
+       if ((second != NULL) && (second->number != 0))
+           memcpy(ret->items + first->number, second->items,
+               second->number * sizeof(void *));
+    } else if ((second != NULL) && (second->number != 0))
+       memcpy(ret->items, (void *) second->items,
+           second->number * sizeof(void *));
+    ret->number = num;
+    return(ret);
+}
+
+/*
+* xsltParseExclResultPrefixes:
+*
+* Create and store the list of in-scope namespaces for the given
+* node in the stylesheet. If there are no changes in the in-scope
+* namespaces then the last ns-info of the ancestor axis will be returned.
+* Compilation-time only.
+*
+* Returns the ns-info or NULL if there are no namespaces in scope.
+*/
+static xsltPointerListPtr
+xsltParseExclResultPrefixes(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
+                           xsltPointerListPtr def,
+                           int instrCategory)
+{    
+    xsltPointerListPtr list = NULL;
+    xmlChar *value;
+    xmlAttrPtr attr;
+
+    if ((cctxt == NULL) || (node == NULL))
+       return(NULL);
+
+    if (instrCategory == XSLT_ELEMENT_CATEGORY_XSLT)
+       attr = xmlHasNsProp(node, BAD_CAST "exclude-result-prefixes", NULL);
+    else
+       attr = xmlHasNsProp(node, BAD_CAST "exclude-result-prefixes",
+           XSLT_NAMESPACE);
+    if (attr == NULL)  
+       return(def);
+
+    if (attr && (instrCategory == XSLT_ELEMENT_CATEGORY_LRE)) {
+       /*
+       * Mark the XSLT attr.
+       */
+       attr->psvi = (void *) xsltXSLTAttrMarker;
+    }
+
+    if ((attr->children != NULL) &&    
+       (attr->children->content != NULL))
+       value = attr->children->content;
+    else {
+       xsltTransformError(NULL, cctxt->style, node,
+           "Attribute 'exclude-result-prefixes': Invalid value.\n");
+       cctxt->style->errors++;
+       return(def);
+    }        
+
+    if (xsltParseNsPrefixList(cctxt, cctxt->tmpList, node,
+       BAD_CAST value) != 0)
+       goto exit;
+    if (cctxt->tmpList->number == 0)   
+       goto exit;    
+    /*
+    * Merge the list with the inherited list.
+    */
+    list = xsltCompilerUtilsCreateMergedList(def, cctxt->tmpList);
+    if (list == NULL)
+       goto exit;    
+    /*
+    * Store the list in the stylesheet/compiler context.
+    */
+    if (xsltPointerListAddSize(
+       cctxt->psData->exclResultNamespaces, list, 5) == -1)
+    {
+       xsltPointerListFree(list);
+       list = NULL;
+       goto exit;
+    }
+    /*
+    * Notify of change in status wrt namespaces.
+    */
+    if (cctxt->inode != NULL)
+       cctxt->inode->nsChanged = 1;
+
+exit:    
+    if (list != NULL)
+       return(list);
+    else
+       return(def);
+}
+
+/*
+* xsltParseExtElemPrefixes:
+*
+* Create and store the list of in-scope namespaces for the given
+* node in the stylesheet. If there are no changes in the in-scope
+* namespaces then the last ns-info of the ancestor axis will be returned.
+* Compilation-time only.
+*
+* Returns the ns-info or NULL if there are no namespaces in scope.
+*/
+static xsltPointerListPtr
+xsltParseExtElemPrefixes(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
+                        xsltPointerListPtr def,
+                        int instrCategory)
+{    
+    xsltPointerListPtr list = NULL;
+    xmlAttrPtr attr;
+    xmlChar *value;
+    int i;
+
+    if ((cctxt == NULL) || (node == NULL))
+       return(NULL);
+
+    if (instrCategory == XSLT_ELEMENT_CATEGORY_XSLT)
+       attr = xmlHasNsProp(node, BAD_CAST "extension-element-prefixes", NULL);
+    else
+       attr = xmlHasNsProp(node, BAD_CAST "extension-element-prefixes",
+           XSLT_NAMESPACE);
+    if (attr == NULL)  
+       return(def);
+
+    if (attr && (instrCategory == XSLT_ELEMENT_CATEGORY_LRE)) {
+       /*
+       * Mark the XSLT attr.
+       */
+       attr->psvi = (void *) xsltXSLTAttrMarker;
+    }
+
+    if ((attr->children != NULL) &&    
+       (attr->children->content != NULL))
+       value = attr->children->content;
+    else {
+       xsltTransformError(NULL, cctxt->style, node,
+           "Attribute 'extension-element-prefixes': Invalid value.\n");
+       cctxt->style->errors++;
+       return(def);
+    }
+
+
+    if (xsltParseNsPrefixList(cctxt, cctxt->tmpList, node,
+       BAD_CAST value) != 0)
+       goto exit;
+
+    if (cctxt->tmpList->number == 0)
+       goto exit;    
+    /*
+    * REVISIT: Register the extension namespaces.
+    */
+    for (i = 0; i < cctxt->tmpList->number; i++)
+       xsltRegisterExtPrefix(cctxt->style, NULL,
+       BAD_CAST cctxt->tmpList->items[i]);
+    /*
+    * Merge the list with the inherited list.
+    */
+    list = xsltCompilerUtilsCreateMergedList(def, cctxt->tmpList);
+    if (list == NULL)
+       goto exit;
+    /*
+    * Store the list in the stylesheet.
+    */
+    if (xsltPointerListAddSize(
+       cctxt->psData->extElemNamespaces, list, 5) == -1)
+    {
+       xsltPointerListFree(list);
+       list = NULL;
+       goto exit;
+    }
+    /*
+    * Notify of change in status wrt namespaces.
+    */
+    if (cctxt->inode != NULL)
+       cctxt->inode->nsChanged = 1;
+
+exit:    
+    if (list != NULL)
+       return(list);
+    else
+       return(def);
+}
+
+/*
+* xsltParseAttrXSLTVersion:
+*
+* @cctxt: the compilation context
+* @node: the element-node
+* @isXsltElem: whether this is an XSLT element
+*
+* Parses the attribute xsl:version.
+*
+* Returns 1 if there was such an attribute, 0 if not and
+*         -1 if an internal or API error occured.
+*/
+static int
+xsltParseAttrXSLTVersion(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,                    
+                        int instrCategory)
+{
+    xmlChar *value;
+    xmlAttrPtr attr;
+
+    if ((cctxt == NULL) || (node == NULL))
+       return(-1);
+
+    if (instrCategory == XSLT_ELEMENT_CATEGORY_XSLT)
+       attr = xmlHasNsProp(node, BAD_CAST "version", NULL);
+    else
+       attr = xmlHasNsProp(node, BAD_CAST "version", XSLT_NAMESPACE);
+
+    if (attr == NULL)  
+       return(0);
+
+    attr->psvi = (void *) xsltXSLTAttrMarker;
+
+    if ((attr->children != NULL) &&    
+       (attr->children->content != NULL))
+       value = attr->children->content;
+    else {
+       xsltTransformError(NULL, cctxt->style, node,
+           "Attribute 'version': Invalid value.\n");
+       cctxt->style->errors++;
+       return(1);
+    }
+    
+    if (! xmlStrEqual(value, (const xmlChar *)"1.0")) {
+       cctxt->inode->forwardsCompat = 1;
+       /*
+       * TODO: To what extent do we support the
+       *  forwards-compatible mode?
+       */
+       /*
+       * Report this only once per compilation episode.
+       */
+       if (! cctxt->hasForwardsCompat) {
+           cctxt->hasForwardsCompat = 1;
+           cctxt->errSeverity = XSLT_ERROR_SEVERITY_WARNING;
+           xsltTransformError(NULL, cctxt->style, node,
+               "Warning: the attribute xsl:version specifies a value "
+               "different from '1.0'. Switching to forwards-compatible "
+               "mode. Only features of XSLT 1.0 are supported by this "
+               "processor.\n");
+           cctxt->style->warnings++;
+           cctxt->errSeverity = XSLT_ERROR_SEVERITY_ERROR;
+       }       
+    } else {
+       cctxt->inode->forwardsCompat = 0;
+    }
+
+    if (attr && (instrCategory == XSLT_ELEMENT_CATEGORY_LRE)) {
+       /*
+       * Set a marker on XSLT attributes.
+       */
+       attr->psvi = (void *) xsltXSLTAttrMarker;
+    }
+    return(1);
+}
+
+static int
+xsltParsePreprocessStylesheetTree(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
+{
+    xmlNodePtr deleteNode, cur, txt, textNode = NULL;
+    xmlDocPtr doc;
+    xsltStylesheetPtr style;
+    int internalize = 0, findSpaceAttr;
+    int xsltStylesheetElemDepth;
+    xmlAttrPtr attr;
+    xmlChar *value;
+    const xmlChar *name, *nsNameXSLT = NULL;
+    int strictWhitespace, inXSLText = 0;
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+    xsltNsMapPtr nsMapItem;
+#endif
+
+    if ((cctxt == NULL) || (cctxt->style == NULL) ||
+       (node == NULL) || (node->type != XML_ELEMENT_NODE))
+        return(-1);
+
+    doc = node->doc;
+    if (doc == NULL)
+       goto internal_err;
+
+    style = cctxt->style;
+    if ((style->dict != NULL) && (doc->dict == style->dict))
+       internalize = 1;
+    else
+        style->internalized = 0;
+
+    /*
+    * Init value of xml:space. Since this might be an embedded
+    * stylesheet, this is needed to be performed on the element
+    * where the stylesheet is rooted at, taking xml:space of
+    * ancestors into account.
+    */
+    if (! cctxt->simplified)
+       xsltStylesheetElemDepth = cctxt->depth +1;
+    else
+       xsltStylesheetElemDepth = 0;
+
+    if (xmlNodeGetSpacePreserve(node) != 1)
+       cctxt->inode->preserveWhitespace = 0;
+    else
+       cctxt->inode->preserveWhitespace = 1; 
+    
+    /*
+    * Eval if we should keep the old incorrect behaviour.
+    */
+    strictWhitespace = (cctxt->strict != 0) ? 1 : 0;
+
+    nsNameXSLT = xsltConstNamespaceNameXSLT;
+
+    deleteNode = NULL;
+    cur = node;
+    while (cur != NULL) {
+       if (deleteNode != NULL) {
+
+#ifdef WITH_XSLT_DEBUG_BLANKS
+           xsltGenericDebug(xsltGenericDebugContext,
+            "xsltParsePreprocessStylesheetTree: removing node\n");
+#endif
+           xmlUnlinkNode(deleteNode);
+           xmlFreeNode(deleteNode);
+           deleteNode = NULL;
+       }
+       if (cur->type == XML_ELEMENT_NODE) {
+           
+           /*
+           * Clear the PSVI field.
+           */
+           cur->psvi = NULL;
+
+           xsltCompilerNodePush(cctxt, cur);
+
+           inXSLText = 0;
+           textNode = NULL;        
+           findSpaceAttr = 1;      
+           cctxt->inode->stripWhitespace = 0;
+           /*
+           * TODO: I'd love to use a string pointer comparison here :-/
+           */
+           if (IS_XSLT_ELEM(cur)) {
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+               if (cur->ns->href != nsNameXSLT) {
+                   nsMapItem = xsltNewNamespaceMapItem(cctxt,
+                       doc, cur->ns, cur);
+                   if (nsMapItem == NULL)
+                       goto internal_err;
+                   cur->ns->href = nsNameXSLT;
+               }
+#endif
+
+               if (cur->name == NULL)
+                   goto process_attributes;
+               /*
+               * Mark the XSLT element for later recognition.
+               * TODO: Using the marker is still too dangerous, since if
+               *   the parsing mechanism leaves out an XSLT element, then
+               *   this might hit the transformation-mechanism, which
+               *   will break if it doesn't expect such a marker.
+               */
+               /* cur->psvi = (void *) xsltXSLTElemMarker; */
+
+               /*
+               * XSLT 2.0: "Any whitespace text node whose parent is
+               * one of the following elements is removed from the "
+               * tree, regardless of any xml:space attributes:..."
+               * xsl:apply-imports, 
+               * xsl:apply-templates,
+               * xsl:attribute-set,
+               * xsl:call-template, 
+               * xsl:choose,
+               * xsl:stylesheet, xsl:transform.
+               * XSLT 2.0: xsl:analyze-string,
+               *           xsl:character-map,
+               *           xsl:next-match              
+               *
+               * TODO: I'd love to use a string pointer comparison here :-/
+               */              
+               name = cur->name;
+               switch (*name) {
+                   case 't':
+                       if ((name[0] == 't') && (name[1] == 'e') &&
+                           (name[2] == 'x') && (name[3] == 't') &&
+                           (name[4] == 0))
+                       {
+                           /*
+                           * Process the xsl:text element.
+                           * ----------------------------
+                           * Mark it for later recognition.
+                           */
+                           cur->psvi = (void *) xsltXSLTTextMarker;
+                           /*
+                           * For stylesheets, the set of
+                           * whitespace-preserving element names
+                           * consists of just xsl:text.
+                           */
+                           findSpaceAttr = 0;
+                           cctxt->inode->preserveWhitespace = 1;
+                           inXSLText = 1;
+                       }                           
+                       break;
+                   case 'c':
+                       if (xmlStrEqual(name, BAD_CAST "choose") ||
+                           xmlStrEqual(name, BAD_CAST "call-template"))
+                           cctxt->inode->stripWhitespace = 1;
+                       break;
+                   case 'a':
+                       if (xmlStrEqual(name, BAD_CAST "apply-templates") ||
+                           xmlStrEqual(name, BAD_CAST "apply-imports") ||
+                           xmlStrEqual(name, BAD_CAST "attribute-set"))
+
+                           cctxt->inode->stripWhitespace = 1;
+                       break;
+                   default:
+                       if (xsltStylesheetElemDepth == cctxt->depth) {
+                           /*
+                           * This is a xsl:stylesheet/xsl:transform.
+                           */
+                           cctxt->inode->stripWhitespace = 1;
+                           break;
+                       }
+
+                       if ((cur->prev != NULL) &&
+                           (cur->prev->type == XML_TEXT_NODE))
+                       {
+                           /*
+                           * XSLT 2.0 : "Any whitespace text node whose
+                           *  following-sibling node is an xsl:param or
+                           *  xsl:sort element is removed from the tree,
+                           *  regardless of any xml:space attributes."
+                           */
+                           if (((*name == 'p') || (*name == 's')) &&
+                               (xmlStrEqual(name, BAD_CAST "param") ||
+                                xmlStrEqual(name, BAD_CAST "sort")))
+                           {
+                               do {
+                                   if (IS_BLANK_NODE(cur->prev)) {
+                                       txt = cur->prev;
+                                       xmlUnlinkNode(txt);
+                                       xmlFreeNode(txt);
+                                   } else {
+                                       /*
+                                       * This will result in a content
+                                       * error, when hitting the parsing
+                                       * functions.
+                                       */
+                                       break;
+                                   }
+                               } while (cur->prev);                                
+                           }
+                       }
+                       break;
+               }
+           }
+
+process_attributes:
+           /*
+           * Process attributes.
+           * ------------------
+           */
+           if (cur->properties != NULL) {
+               if (cur->children == NULL)
+                   findSpaceAttr = 0;
+               attr = cur->properties;
+               do {
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+                   if ((attr->ns) && (attr->ns->href != nsNameXSLT) &&
+                       xmlStrEqual(attr->ns->href, nsNameXSLT))
+                   {                   
+                       nsMapItem = xsltNewNamespaceMapItem(cctxt,
+                           doc, attr->ns, cur);
+                       if (nsMapItem == NULL)
+                           goto internal_err;
+                       attr->ns->href = nsNameXSLT;
+                   }               
+#endif
+                   if (internalize) {
+                       /*
+                       * Internalize the attribute's value; the goal is to
+                       * speed up operations and minimize used space by
+                       * compiled stylesheets.
+                       */
+                       txt = attr->children;
+                       /*
+                       * NOTE that this assumes only one
+                       *  text-node in the attribute's content.
+                       */
+                       if ((txt != NULL) && (txt->content != NULL) &&
+                           (!xmlDictOwns(style->dict, txt->content)))
+                       {
+                           value = (xmlChar *) xmlDictLookup(style->dict,
+                               txt->content, -1);
+                           xmlNodeSetContent(txt, NULL);
+                           txt->content = value;
+                       }
+                   }
+                   /*
+                   * Process xml:space attributes.
+                   * ----------------------------
+                   */
+                   if ((findSpaceAttr != 0) &&
+                       (attr->ns != NULL) &&
+                       (attr->name != NULL) &&
+                       (attr->name[0] == 's') &&                       
+                       (attr->ns->prefix != NULL) &&
+                       (attr->ns->prefix[0] == 'x') &&
+                       (attr->ns->prefix[1] == 'm') &&
+                       (attr->ns->prefix[2] == 'l') &&
+                       (attr->ns->prefix[3] == 0))
+                   {
+                       value = xmlGetNsProp(cur, BAD_CAST "space",
+                           XML_XML_NAMESPACE);
+                       if (value != NULL) {
+                           if (xmlStrEqual(value, BAD_CAST "preserve")) {
+                               cctxt->inode->preserveWhitespace = 1;                           
+                           } else if (xmlStrEqual(value, BAD_CAST "default")) {
+                               cctxt->inode->preserveWhitespace = 0;
+                           } else {
+                               /* Invalid value for xml:space. */
+                               xsltTransformError(NULL, style, cur,
+                                   "Attribute xml:space: Invalid value.\n");
+                               cctxt->style->warnings++;
+                           }
+                           findSpaceAttr = 0;
+                           xmlFree(value);
+                       }
+                       
+                   }
+                   attr = attr->next;
+               } while (attr != NULL);
+           }
+           /*
+           * We'll descend into the children of element nodes only.
+           */
+           if (cur->children != NULL) {
+               cur = cur->children;
+               continue;
+           }
+       } else if ((cur->type == XML_TEXT_NODE) ||
+               (cur->type == XML_CDATA_SECTION_NODE))
+       {
+           /*
+           * Merge adjacent text/CDATA-section-nodes
+           * ---------------------------------------       
+           * In order to avoid breaking of existing stylesheets,
+           * if the old behaviour is wanted (strictWhitespace == 0),
+           * then we *won't* merge adjacent text-nodes
+           * (except in xsl:text); this will ensure that whitespace-only
+           * text nodes are (incorrectly) not stripped in some cases.
+           * 
+           * Example:               : <foo>  <!-- bar -->zoo</foo>
+           * Corrent (strict) result: <foo>  zoo</foo>
+           * Incorrect (old) result : <foo>zoo</foo>
+           *    
+           * NOTE that we *will* merge adjacent text-nodes if
+           * they are in xsl:text.
+           * Example, the following:
+           * <xsl:text>  <!-- bar -->zoo<xsl:text>
+           * will result in both cases in:
+           * <xsl:text>  zoo<xsl:text>
+           */
+           cur->type = XML_TEXT_NODE;
+           if ((strictWhitespace != 0) || (inXSLText != 0)) {
+               /*
+               * New behaviour; merge nodes.
+               */
+               if (textNode == NULL)
+                   textNode = cur;
+               else {
+                   if (cur->content != NULL)
+                       xmlNodeAddContent(textNode, cur->content);
+                   deleteNode = cur;
+               }
+               if ((cur->next == NULL) ||
+                   (cur->next->type == XML_ELEMENT_NODE))
+                   goto end_of_text;
+               else
+                   goto next_sibling;
+           } else {
+               /*
+               * Old behaviour.
+               */
+               if (textNode == NULL)
+                   textNode = cur;
+               goto end_of_text;
+           }              
+       } else if ((cur->type == XML_COMMENT_NODE) ||
+           (cur->type == XML_PI_NODE))
+       {           
+           /*
+           * Remove processing instructions and comments.
+           */
+           deleteNode = cur;
+           if ((cur->next == NULL) ||
+               (cur->next->type == XML_ELEMENT_NODE))
+               goto end_of_text;
+           else
+               goto next_sibling;
+       } else {
+           textNode = NULL;
+           /*
+           * Invalid node-type for this data-model.
+           */
+           xsltTransformError(NULL, style, cur,
+               "Invalid type of node for the XSLT data model.\n");
+           cctxt->style->errors++;
+           goto next_sibling;
+       }
+
+end_of_text:
+       if (textNode) {
+           value = textNode->content;
+           /*
+           * At this point all adjacent text/CDATA-section nodes
+           * have been merged.
+           *
+           * Strip whitespace-only text-nodes.
+           * (cctxt->inode->stripWhitespace)
+           */
+           if ((value == NULL) || (*value == 0) ||
+               (((cctxt->inode->stripWhitespace) ||
+                 (! cctxt->inode->preserveWhitespace)) &&
+                IS_BLANK(*value) &&
+                xsltIsBlank(value)))
+           {           
+               if (textNode != cur) {
+                   xmlUnlinkNode(textNode);
+                   xmlFreeNode(textNode);
+               } else
+                   deleteNode = textNode;
+               textNode = NULL;
+               goto next_sibling;
+           }
+           /*
+           * Convert CDATA-section nodes to text-nodes.
+           * TODO: Can this produce problems?
+           */
+           if (textNode->type != XML_TEXT_NODE) {
+               textNode->type = XML_TEXT_NODE;
+               textNode->name = xmlStringText;
+           }
+           if (internalize &&
+               (textNode->content != NULL) &&
+               (!xmlDictOwns(style->dict, textNode->content)))
+           {
+               /*
+               * Internalize the string.
+               */
+               value = (xmlChar *) xmlDictLookup(style->dict,
+                   textNode->content, -1);
+               xmlNodeSetContent(textNode, NULL);
+               textNode->content = value;
+           }
+           textNode = NULL;
+           /*
+           * Note that "disable-output-escaping" of the xsl:text
+           * element will be applied at a later level, when
+           * XSLT elements are processed.
+           */
+       }
+
+next_sibling:
+       if (cur->type == XML_ELEMENT_NODE) {
+           xsltCompilerNodePop(cctxt, cur);
+       }
+       if (cur == node)
+           break;
+       if (cur->next != NULL) {
+           cur = cur->next;
+       } else {
+           cur = cur->parent;
+           inXSLText = 0;
+           goto next_sibling;
+       };
+    }
+    if (deleteNode != NULL) {
+#ifdef WITH_XSLT_DEBUG_PARSING
+       xsltGenericDebug(xsltGenericDebugContext,
+        "xsltParsePreprocessStylesheetTree: removing node\n");
+#endif
+       xmlUnlinkNode(deleteNode);
+       xmlFreeNode(deleteNode);
+    }
+    return(0);
+
+internal_err:
+    return(-1);
+}
+
+#endif /* XSLT_REFACTORED */
+
+#ifdef XSLT_REFACTORED
+#else
+static void
+xsltPrecomputeStylesheet(xsltStylesheetPtr style, xmlNodePtr cur)
+{
+    xmlNodePtr deleteNode, styleelem;
+    int internalize = 0;
+
+    if ((style == NULL) || (cur == NULL))
+        return;
+
+    if ((cur->doc != NULL) && (style->dict != NULL) &&
+        (cur->doc->dict == style->dict))
+       internalize = 1;
+    else
+        style->internalized = 0;
+
+    if ((cur != NULL) && (IS_XSLT_ELEM(cur)) &&
+        (IS_XSLT_NAME(cur, "stylesheet"))) {
+       styleelem = cur;
+    } else {
+        styleelem = NULL;
+    }
+
+    /*
+     * This content comes from the stylesheet
+     * For stylesheets, the set of whitespace-preserving
+     * element names consists of just xsl:text.
+     */
+    deleteNode = NULL;
+    while (cur != NULL) {
+       if (deleteNode != NULL) {
+#ifdef WITH_XSLT_DEBUG_BLANKS
+           xsltGenericDebug(xsltGenericDebugContext,
+            "xsltPrecomputeStylesheet: removing ignorable blank node\n");
+#endif
+           xmlUnlinkNode(deleteNode);
+           xmlFreeNode(deleteNode);
+           deleteNode = NULL;
+       }
+       if (cur->type == XML_ELEMENT_NODE) {
+           int exclPrefixes;
+           /*
+            * Internalize attributes values.
+            */
+           if ((internalize) && (cur->properties != NULL)) {
+               xmlAttrPtr attr = cur->properties;
+               xmlNodePtr txt;
+
+               while (attr != NULL) {
+                   txt = attr->children;
+                   if ((txt != NULL) && (txt->type == XML_TEXT_NODE) &&
+                       (txt->content != NULL) &&
+                       (!xmlDictOwns(style->dict, txt->content)))
+                   {
+                       xmlChar *tmp;
+
+                       /*
+                        * internalize the text string, goal is to speed
+                        * up operations and minimize used space by compiled
+                        * stylesheets.
+                        */
+                       tmp = (xmlChar *) xmlDictLookup(style->dict,
+                                                       txt->content, -1);
+                       if (tmp != txt->content) {
+                           xmlNodeSetContent(txt, NULL);
+                           txt->content = tmp;
+                       }
+                   }
+                   attr = attr->next;
+               }
+           }
+           if (IS_XSLT_ELEM(cur)) {
+               exclPrefixes = 0;
+               xsltStylePreCompute(style, cur);
+               if (IS_XSLT_NAME(cur, "text")) {
+                   for (;exclPrefixes > 0;exclPrefixes--)
+                       exclPrefixPop(style);
+                   goto skip_children;
+               }
+           } else {
+               exclPrefixes = xsltParseStylesheetExcludePrefix(style, cur, 0);
+           }
+                    
+           if ((cur->nsDef != NULL) && (style->exclPrefixNr > 0)) {
+               xmlNsPtr ns = cur->nsDef, prev = NULL, next;
+               xmlNodePtr root = NULL;
+               int i, moved;
+
+               root = xmlDocGetRootElement(cur->doc);
+               if ((root != NULL) && (root != cur)) {
+                   while (ns != NULL) {
+                       moved = 0;
+                       next = ns->next;
+                       for (i = 0;i < style->exclPrefixNr;i++) {
+                           if ((ns->prefix != NULL) && 
+                               (xmlStrEqual(ns->href,
+                                            style->exclPrefixTab[i]))) {
+                               /*
+                                * Move the namespace definition on the root
+                                * element to avoid duplicating it without
+                                * loosing it.
+                                */
+                               if (prev == NULL) {
+                                   cur->nsDef = ns->next;
+                               } else {
+                                   prev->next = ns->next;
+                               }
+                               ns->next = root->nsDef;
+                               root->nsDef = ns;
+                               moved = 1;
+                               break;
+                           }
+                       }
+                       if (moved == 0)
+                           prev = ns;
+                       ns = next;
+                   }
+               }
+           }
+           /*
+            * If we have prefixes locally, recurse and pop them up when
+            * going back
+            */
+           if (exclPrefixes > 0) {
+               xsltPrecomputeStylesheet(style, cur->children);
+               for (;exclPrefixes > 0;exclPrefixes--)
+                   exclPrefixPop(style);
+               goto skip_children;
+           }
+       } else if (cur->type == XML_TEXT_NODE) {
+           if (IS_BLANK_NODE(cur)) {
+               if (xmlNodeGetSpacePreserve(cur) != 1) {
+                   deleteNode = cur;
+               }
+           } else if ((cur->content != NULL) && (internalize) &&
+                      (!xmlDictOwns(style->dict, cur->content))) {
+               xmlChar *tmp;
+
+               /*
+                * internalize the text string, goal is to speed
+                * up operations and minimize used space by compiled
+                * stylesheets.
+                */
+               tmp = (xmlChar *) xmlDictLookup(style->dict, cur->content, -1);
+               xmlNodeSetContent(cur, NULL);
+               cur->content = tmp;
+           }
+       } else if ((cur->type != XML_ELEMENT_NODE) &&
+                  (cur->type != XML_CDATA_SECTION_NODE)) {
+           deleteNode = cur;
+           goto skip_children;
+       }
+
+       /*
+        * Skip to next node. In case of a namespaced element children of
+        * the stylesheet and not in the XSLT namespace and not an extension
+        * element, ignore its content.
+        */
+       if ((cur->type == XML_ELEMENT_NODE) && (cur->ns != NULL) &&
+           (styleelem != NULL) && (cur->parent == styleelem) &&
+           (!xmlStrEqual(cur->ns->href, XSLT_NAMESPACE)) &&
+           (!xsltCheckExtURI(style, cur->ns->href))) {
+           goto skip_children;
+       } else if (cur->children != NULL) {
+           if ((cur->children->type != XML_ENTITY_DECL) &&
+               (cur->children->type != XML_ENTITY_REF_NODE) &&
+               (cur->children->type != XML_ENTITY_NODE)) {
+               cur = cur->children;
+               continue;
+           }
+       }
+
+skip_children:
+       if (cur->next != NULL) {
+           cur = cur->next;
+           continue;
+       }
+       do {
+
+           cur = cur->parent;
+           if (cur == NULL)
+               break;
+           if (cur == (xmlNodePtr) style->doc) {
+               cur = NULL;
+               break;
+           }
+           if (cur->next != NULL) {
+               cur = cur->next;
+               break;
+           }
+       } while (cur != NULL);
+    }
+    if (deleteNode != NULL) {
+#ifdef WITH_XSLT_DEBUG_PARSING
+       xsltGenericDebug(xsltGenericDebugContext,
+        "xsltPrecomputeStylesheet: removing ignorable blank node\n");
+#endif
+       xmlUnlinkNode(deleteNode);
+       xmlFreeNode(deleteNode);
+    }
+}
+#endif /* end of else XSLT_REFACTORED */
+
+/**
+ * xsltGatherNamespaces:
+ * @style:  the XSLT stylesheet
+ *
+ * Browse the stylesheet and build the namspace hash table which
+ * will be used for XPath interpretation. If needed do a bit of normalization
+ */
+
+static void
+xsltGatherNamespaces(xsltStylesheetPtr style) {
+    xmlNodePtr cur;
+    const xmlChar *URI;
+
+    if (style == NULL)
+        return;
+    /* 
+     * TODO: basically if the stylesheet uses the same prefix for different
+     *       patterns, well they may be in problem, hopefully they will get
+     *       a warning first.
+     */
+    /*
+    * TODO: Eliminate the use of the hash for XPath expressions.
+    *   An expression should be evaluated in the context of the in-scope
+    *   namespaces; eliminate the restriction of an XML document to contain
+    *   no duplicate prefixes for different namespace names.
+    * 
+    */
+    cur = xmlDocGetRootElement(style->doc);
+    while (cur != NULL) {
+       if (cur->type == XML_ELEMENT_NODE) {
+           xmlNsPtr ns = cur->nsDef;
+           while (ns != NULL) {
+               if (ns->prefix != NULL) {
+                   if (style->nsHash == NULL) {
+                       style->nsHash = xmlHashCreate(10);
+                       if (style->nsHash == NULL) {
+                           xsltTransformError(NULL, style, cur,
+                "xsltGatherNamespaces: failed to create hash table\n");
+                           style->errors++;
+                           return;
+                       }
+                   }
+                   URI = xmlHashLookup(style->nsHash, ns->prefix);
+                   if ((URI != NULL) && (!xmlStrEqual(URI, ns->href))) {
+                       xsltTransformError(NULL, style, cur,
+            "Namespaces prefix %s used for multiple namespaces\n",ns->prefix);
+                       style->warnings++;
+                   } else if (URI == NULL) {
+                       xmlHashUpdateEntry(style->nsHash, ns->prefix,
+                           (void *) ns->href, (xmlHashDeallocator)xmlFree);
+
+#ifdef WITH_XSLT_DEBUG_PARSING
+                       xsltGenericDebug(xsltGenericDebugContext,
+                "Added namespace: %s mapped to %s\n", ns->prefix, ns->href);
+#endif
+                   }
+               }
+               ns = ns->next;
+           }
+       }
+
+       /*
+        * Skip to next node
+        */
+       if (cur->children != NULL) {
+           if (cur->children->type != XML_ENTITY_DECL) {
+               cur = cur->children;
+               continue;
+           }
+       }
+       if (cur->next != NULL) {
+           cur = cur->next;
+           continue;
+       }
+       
+       do {
+           cur = cur->parent;
+           if (cur == NULL)
+               break;
+           if (cur == (xmlNodePtr) style->doc) {
+               cur = NULL;
+               break;
+           }
+           if (cur->next != NULL) {
+               cur = cur->next;
+               break;
+           }
+       } while (cur != NULL);
+    }
+}
+
+#ifdef XSLT_REFACTORED
+
+static xsltStyleType
+xsltGetXSLTElementTypeByNode(xsltCompilerCtxtPtr cctxt,
+                            xmlNodePtr node)
+{
+    if ((node == NULL) || (node->type != XML_ELEMENT_NODE) ||
+       (node->name == NULL))
+       return(0);
+
+    if (node->name[0] == 'a') {
+       if (IS_XSLT_NAME(node, "apply-templates"))
+           return(XSLT_FUNC_APPLYTEMPLATES);
+       else if (IS_XSLT_NAME(node, "attribute"))
+           return(XSLT_FUNC_ATTRIBUTE);
+       else if (IS_XSLT_NAME(node, "apply-imports"))
+           return(XSLT_FUNC_APPLYIMPORTS);
+       else if (IS_XSLT_NAME(node, "attribute-set"))
+           return(0);
+
+    } else if (node->name[0] == 'c') {
+       if (IS_XSLT_NAME(node, "choose"))
+           return(XSLT_FUNC_CHOOSE);
+       else if (IS_XSLT_NAME(node, "copy"))
+           return(XSLT_FUNC_COPY);
+       else if (IS_XSLT_NAME(node, "copy-of"))
+           return(XSLT_FUNC_COPYOF);
+       else if (IS_XSLT_NAME(node, "call-template"))
+           return(XSLT_FUNC_CALLTEMPLATE);
+       else if (IS_XSLT_NAME(node, "comment"))
+           return(XSLT_FUNC_COMMENT);
+
+    } else if (node->name[0] == 'd') {
+       if (IS_XSLT_NAME(node, "document"))
+           return(XSLT_FUNC_DOCUMENT);
+       else if (IS_XSLT_NAME(node, "decimal-format"))
+           return(0);
+
+    } else if (node->name[0] == 'e') {
+       if (IS_XSLT_NAME(node, "element"))
+           return(XSLT_FUNC_ELEMENT);
+
+    } else if (node->name[0] == 'f') {
+       if (IS_XSLT_NAME(node, "for-each"))
+           return(XSLT_FUNC_FOREACH);
+       else if (IS_XSLT_NAME(node, "fallback"))
+           return(XSLT_FUNC_FALLBACK);
+
+    } else if (*(node->name) == 'i') {
+       if (IS_XSLT_NAME(node, "if"))
+           return(XSLT_FUNC_IF);
+       else if (IS_XSLT_NAME(node, "include"))
+           return(0);
+       else if (IS_XSLT_NAME(node, "import"))
+           return(0);
+
+    } else if (*(node->name) == 'k') {
+       if (IS_XSLT_NAME(node, "key"))
+           return(0);
+
+    } else if (*(node->name) == 'm') {
+       if (IS_XSLT_NAME(node, "message"))
+           return(XSLT_FUNC_MESSAGE);
+
+    } else if (*(node->name) == 'n') {
+       if (IS_XSLT_NAME(node, "number"))
+           return(XSLT_FUNC_NUMBER);
+       else if (IS_XSLT_NAME(node, "namespace-alias"))
+           return(0);
+
+    } else if (*(node->name) == 'o') {
+       if (IS_XSLT_NAME(node, "otherwise"))
+           return(XSLT_FUNC_OTHERWISE);
+       else if (IS_XSLT_NAME(node, "output"))
+           return(0);
+
+    } else if (*(node->name) == 'p') {
+       if (IS_XSLT_NAME(node, "param"))
+           return(XSLT_FUNC_PARAM);
+       else if (IS_XSLT_NAME(node, "processing-instruction"))
+           return(XSLT_FUNC_PI);
+       else if (IS_XSLT_NAME(node, "preserve-space"))
+           return(0);
+
+    } else if (*(node->name) == 's') {
+       if (IS_XSLT_NAME(node, "sort"))
+           return(XSLT_FUNC_SORT);
+       else if (IS_XSLT_NAME(node, "strip-space"))
+           return(0);
+       else if (IS_XSLT_NAME(node, "stylesheet"))
+           return(0);
+
+    } else if (node->name[0] == 't') {
+       if (IS_XSLT_NAME(node, "text"))
+           return(XSLT_FUNC_TEXT);
+       else if (IS_XSLT_NAME(node, "template"))
+           return(0);
+       else if (IS_XSLT_NAME(node, "transform"))
+           return(0);
+
+    } else if (*(node->name) == 'v') {
+       if (IS_XSLT_NAME(node, "value-of"))
+           return(XSLT_FUNC_VALUEOF);
+       else if (IS_XSLT_NAME(node, "variable"))
+           return(XSLT_FUNC_VARIABLE);
+
+    } else if (*(node->name) == 'w') {
+       if (IS_XSLT_NAME(node, "when"))
+           return(XSLT_FUNC_WHEN);
+       if (IS_XSLT_NAME(node, "with-param"))
+           return(XSLT_FUNC_WITHPARAM);
+    }
+    return(0);
+}
+
+/**
+ * xsltParseAnyXSLTElem:
+ *
+ * @cctxt: the compilation context
+ * @elem: the element node of the XSLT instruction
+ *
+ * Parses, validates the content models and compiles XSLT instructions.
+ *
+ * Returns 0 if everything's fine;
+ *         -1 on API or internal errors.
+ */ 
+int
+xsltParseAnyXSLTElem(xsltCompilerCtxtPtr cctxt, xmlNodePtr elem)
+{
+    if ((cctxt == NULL) || (elem == NULL) ||
+       (elem->type != XML_ELEMENT_NODE))
+       return(-1);
+
+    elem->psvi = NULL;
+
+    if (! (IS_XSLT_ELEM_FAST(elem)))
+       return(-1);
+    /*
+    * Detection of handled content of extension instructions.
+    */
+    if (cctxt->inode->category == XSLT_ELEMENT_CATEGORY_EXTENSION) {
+       cctxt->inode->extContentHandled = 1;
+    }
+    
+    xsltCompilerNodePush(cctxt, elem);
+    /*
+    * URGENT TODO: Find a way to speed up this annoying redundant
+    *  textual node-name and namespace comparison.
+    */
+    if (cctxt->inode->prev->curChildType != 0)
+       cctxt->inode->type = cctxt->inode->prev->curChildType;
+    else
+       cctxt->inode->type = xsltGetXSLTElementTypeByNode(cctxt, elem);    
+    /*
+    * Update the in-scope namespaces if needed.
+    */
+    if (elem->nsDef != NULL)
+       cctxt->inode->inScopeNs =
+           xsltCompilerBuildInScopeNsList(cctxt, elem);
+    /*
+    * xsltStylePreCompute():
+    *  This will compile the information found on the current
+    *  element's attributes. NOTE that this won't process the
+    *  children of the instruction.
+    */
+    xsltStylePreCompute(cctxt->style, elem);
+    /*
+    * TODO: How to react on errors in xsltStylePreCompute() ?
+    */
+
+    /*
+    * Validate the content model of the XSLT-element.
+    */
+    switch (cctxt->inode->type) {      
+       case XSLT_FUNC_APPLYIMPORTS:
+           /* EMPTY */
+           goto empty_content;
+       case XSLT_FUNC_APPLYTEMPLATES:
+           /* <!-- Content: (xsl:sort | xsl:with-param)* --> */
+           goto apply_templates;           
+       case XSLT_FUNC_ATTRIBUTE:           
+           /* <!-- Content: template --> */
+           goto sequence_constructor;
+       case XSLT_FUNC_CALLTEMPLATE:
+           /* <!-- Content: xsl:with-param* --> */
+           goto call_template;
+       case XSLT_FUNC_CHOOSE:      
+           /* <!-- Content: (xsl:when+, xsl:otherwise?) --> */
+           goto choose;
+       case XSLT_FUNC_COMMENT:
+           /* <!-- Content: template --> */
+           goto sequence_constructor;      
+       case XSLT_FUNC_COPY:
+           /* <!-- Content: template --> */
+           goto sequence_constructor;      
+       case XSLT_FUNC_COPYOF:
+           /* EMPTY */
+           goto empty_content;    
+       case XSLT_FUNC_DOCUMENT: /* Extra one */
+           /* ?? template ?? */
+           goto sequence_constructor;
+       case XSLT_FUNC_ELEMENT:
+           /* <!-- Content: template --> */
+           goto sequence_constructor;
+       case XSLT_FUNC_FALLBACK:
+           /* <!-- Content: template --> */
+           goto sequence_constructor;
+       case XSLT_FUNC_FOREACH:
+           /* <!-- Content: (xsl:sort*, template) --> */
+           goto for_each;
+       case XSLT_FUNC_IF:
+           /* <!-- Content: template --> */
+           goto sequence_constructor;
+       case XSLT_FUNC_OTHERWISE:
+           /* <!-- Content: template --> */
+           goto sequence_constructor;
+       case XSLT_FUNC_MESSAGE:
+           /* <!-- Content: template --> */
+           goto sequence_constructor;
+       case XSLT_FUNC_NUMBER:
+           /* EMPTY */
+           goto empty_content;
+       case XSLT_FUNC_PARAM:
+           /*
+           * Check for redefinition.
+           */
+           if ((elem->psvi != NULL) && (cctxt->ivar != NULL)) {
+               xsltVarInfoPtr ivar = cctxt->ivar;
+
+               do {
+                   if ((ivar->name ==
+                        ((xsltStyleItemParamPtr) elem->psvi)->name) &&
+                       (ivar->nsName ==
+                        ((xsltStyleItemParamPtr) elem->psvi)->ns))
+                   {
+                       elem->psvi = NULL;
+                       xsltTransformError(NULL, cctxt->style, elem,
+                           "Redefinition of variable or parameter '%s'.\n",
+                           ivar->name);
+                       cctxt->style->errors++;
+                       goto error;
+                   }
+                   ivar = ivar->prev;
+               } while (ivar != NULL);
+           }
+           /*  <!-- Content: template --> */
+           goto sequence_constructor;
+       case XSLT_FUNC_PI:
+           /*  <!-- Content: template --> */
+           goto sequence_constructor;
+       case XSLT_FUNC_SORT:
+           /* EMPTY */
+           goto empty_content;
+       case XSLT_FUNC_TEXT:
+           /* <!-- Content: #PCDATA --> */
+           goto text;
+       case XSLT_FUNC_VALUEOF:
+           /* EMPTY */
+           goto empty_content;
+       case XSLT_FUNC_VARIABLE:
+           /*
+           * Check for redefinition.
+           */
+           if ((elem->psvi != NULL) && (cctxt->ivar != NULL)) {
+               xsltVarInfoPtr ivar = cctxt->ivar;              
+
+               do {
+                   if ((ivar->name ==
+                        ((xsltStyleItemVariablePtr) elem->psvi)->name) &&
+                       (ivar->nsName ==
+                        ((xsltStyleItemVariablePtr) elem->psvi)->ns))
+                   {
+                       elem->psvi = NULL;
+                       xsltTransformError(NULL, cctxt->style, elem,
+                           "Redefinition of variable or parameter '%s'.\n",
+                           ivar->name);
+                       cctxt->style->errors++;
+                       goto error;
+                   }
+                   ivar = ivar->prev;
+               } while (ivar != NULL);
+           }
+           /* <!-- Content: template --> */
+           goto sequence_constructor;
+       case XSLT_FUNC_WHEN:
+           /* <!-- Content: template --> */
+           goto sequence_constructor;
+       case XSLT_FUNC_WITHPARAM:
+           /* <!-- Content: template --> */
+           goto sequence_constructor;
+       default:
+#ifdef WITH_XSLT_DEBUG_PARSING
+           xsltGenericDebug(xsltGenericDebugContext,
+               "xsltParseXSLTNode: Unhandled XSLT element '%s'.\n",
+               elem->name);        
+#endif
+           xsltTransformError(NULL, cctxt->style, elem,
+               "xsltParseXSLTNode: Internal error; "
+               "unhandled XSLT element '%s'.\n", elem->name);
+           cctxt->style->errors++;
+           goto internal_err;
+    }
+
+apply_templates:
+    /* <!-- Content: (xsl:sort | xsl:with-param)* --> */
+    if (elem->children != NULL) {
+       xmlNodePtr child = elem->children;
+       do {
+           if (child->type == XML_ELEMENT_NODE) {
+               if (IS_XSLT_ELEM_FAST(child)) {
+                   if (xmlStrEqual(child->name, BAD_CAST "with-param")) {
+                       cctxt->inode->curChildType = XSLT_FUNC_WITHPARAM;
+                       xsltParseAnyXSLTElem(cctxt, child);
+                   } else if (xmlStrEqual(child->name, BAD_CAST "sort")) {
+                       cctxt->inode->curChildType = XSLT_FUNC_SORT;
+                       xsltParseAnyXSLTElem(cctxt, child);
+                   } else
+                       xsltParseContentError(cctxt->style, child);
+               } else
+                   xsltParseContentError(cctxt->style, child);
+           }
+           child = child->next;
+       } while (child != NULL);
+    }    
+    goto exit;
+
+call_template:
+    /* <!-- Content: xsl:with-param* --> */
+    if (elem->children != NULL) {
+       xmlNodePtr child = elem->children;
+       do {
+           if (child->type == XML_ELEMENT_NODE) {
+               if (IS_XSLT_ELEM_FAST(child)) {
+                   xsltStyleType type;
+
+                   type = xsltGetXSLTElementTypeByNode(cctxt, child);
+                   if (type == XSLT_FUNC_WITHPARAM) {
+                       cctxt->inode->curChildType = XSLT_FUNC_WITHPARAM;
+                       xsltParseAnyXSLTElem(cctxt, child);
+                   } else {
+                       xsltParseContentError(cctxt->style, child);
+                   }
+               } else
+                   xsltParseContentError(cctxt->style, child);
+           }
+           child = child->next;
+       } while (child != NULL);
+    }    
+    goto exit;
+
+text:
+    if (elem->children != NULL) {
+       xmlNodePtr child = elem->children;
+       do {
+           if ((child->type != XML_TEXT_NODE) &&
+               (child->type != XML_CDATA_SECTION_NODE))
+           {
+               xsltTransformError(NULL, cctxt->style, elem,
+                   "The XSLT 'text' element must have only character "
+                   "data as content.\n");
+           }
+           child = child->next;
+       } while (child != NULL);
+    }
+    goto exit;
+
+empty_content:
+    if (elem->children != NULL) {
+       xmlNodePtr child = elem->children;
+       /*
+       * Relaxed behaviour: we will allow whitespace-only text-nodes.
+       */
+       do {
+           if (((child->type != XML_TEXT_NODE) &&
+                (child->type != XML_CDATA_SECTION_NODE)) ||
+               (! IS_BLANK_NODE(child)))
+           {
+               xsltTransformError(NULL, cctxt->style, elem,
+                   "This XSLT element must have no content.\n");
+               cctxt->style->errors++;
+               break;
+           }
+           child = child->next;
+       } while (child != NULL);                
+    }
+    goto exit;
+
+choose:
+    /* <!-- Content: (xsl:when+, xsl:otherwise?) --> */
+    /*
+    * TODO: text-nodes in between are *not* allowed in XSLT 1.0.
+    *   The old behaviour did not check this.
+    * NOTE: In XSLT 2.0 they are stripped beforehand
+    *  if whitespace-only (regardless of xml:space).
+    */
+    if (elem->children != NULL) {
+       xmlNodePtr child = elem->children;
+       int nbWhen = 0, nbOtherwise = 0, err = 0;
+       do {
+           if (child->type == XML_ELEMENT_NODE) {
+               if (IS_XSLT_ELEM_FAST(child)) {
+                   xsltStyleType type;
+               
+                   type = xsltGetXSLTElementTypeByNode(cctxt, child);
+                   if (type == XSLT_FUNC_WHEN) {
+                       nbWhen++;
+                       if (nbOtherwise) {
+                           xsltParseContentError(cctxt->style, child);
+                           err = 1;
+                           break;
+                       }
+                       cctxt->inode->curChildType = XSLT_FUNC_WHEN;
+                       xsltParseAnyXSLTElem(cctxt, child);
+                   } else if (type == XSLT_FUNC_OTHERWISE) {
+                       if (! nbWhen) {
+                           xsltParseContentError(cctxt->style, child);
+                           err = 1;
+                           break;
+                       }                       
+                       if (nbOtherwise) {
+                           xsltTransformError(NULL, cctxt->style, elem,
+                               "The XSLT 'choose' element must not contain "
+                               "more than one XSLT 'otherwise' element.\n");
+                           cctxt->style->errors++;
+                           err = 1;
+                           break;
+                       }
+                       nbOtherwise++;
+                       cctxt->inode->curChildType = XSLT_FUNC_OTHERWISE;
+                       xsltParseAnyXSLTElem(cctxt, child);
+                   } else
+                       xsltParseContentError(cctxt->style, child);
+               } else
+                   xsltParseContentError(cctxt->style, child);
+           } 
+           /*
+               else
+                   xsltParseContentError(cctxt, child);
+           */
+           child = child->next;
+       } while (child != NULL);
+       if ((! err) && (! nbWhen)) {
+           xsltTransformError(NULL, cctxt->style, elem,
+               "The XSLT element 'choose' must contain at least one "
+               "XSLT element 'when'.\n");
+               cctxt->style->errors++;
+       }       
+    }    
+    goto exit;
+
+for_each:
+    /* <!-- Content: (xsl:sort*, template) --> */
+    /*
+    * NOTE: Text-nodes before xsl:sort are *not* allowed in XSLT 1.0.
+    *   The old behaviour did not allow this, but it catched this
+    *   only at transformation-time.
+    *   In XSLT 2.0 they are stripped beforehand if whitespace-only
+    *   (regardless of xml:space).
+    */
+    if (elem->children != NULL) {
+       xmlNodePtr child = elem->children;
+       /*
+       * Parse xsl:sort first.
+       */
+       do {        
+           if ((child->type == XML_ELEMENT_NODE) &&
+               IS_XSLT_ELEM_FAST(child))
+           {           
+               if (xsltGetXSLTElementTypeByNode(cctxt, child) ==
+                   XSLT_FUNC_SORT)
+               {               
+                   cctxt->inode->curChildType = XSLT_FUNC_SORT;
+                   xsltParseAnyXSLTElem(cctxt, child);
+               } else
+                   break;
+           } else
+               break;
+           child = child->next;
+       } while (child != NULL);
+       /*
+       * Parse the sequece constructor.
+       */
+       if (child != NULL)
+           xsltParseSequenceConstructor(cctxt, child);
+    }    
+    goto exit;
+
+sequence_constructor:
+    /*
+    * Parse the sequence constructor.
+    */
+    if (elem->children != NULL)
+       xsltParseSequenceConstructor(cctxt, elem->children);
+
+    /*
+    * Register information for vars/params. Only needed if there
+    * are any following siblings.
+    */
+    if ((elem->next != NULL) &&
+       ((cctxt->inode->type == XSLT_FUNC_VARIABLE) ||
+        (cctxt->inode->type == XSLT_FUNC_PARAM)))
+    {  
+       if ((elem->psvi != NULL) &&
+           (((xsltStyleBasicItemVariablePtr) elem->psvi)->name))
+       {       
+           xsltCompilerVarInfoPush(cctxt, elem,
+               ((xsltStyleBasicItemVariablePtr) elem->psvi)->name,
+               ((xsltStyleBasicItemVariablePtr) elem->psvi)->ns);
+       }
+    }
+
+error:
+exit:
+    xsltCompilerNodePop(cctxt, elem);
+    return(0);
+
+internal_err:
+    xsltCompilerNodePop(cctxt, elem);
+    return(-1);
+}
+
+/**
+ * xsltForwardsCompatUnkownItemCreate:
+ *
+ * @cctxt: the compilation context 
+ *
+ * Creates a compiled representation of the unknown
+ * XSLT instruction.
+ *
+ * Returns the compiled representation.
+ */ 
+static xsltStyleItemUknownPtr
+xsltForwardsCompatUnkownItemCreate(xsltCompilerCtxtPtr cctxt)
+{
+    xsltStyleItemUknownPtr item;
+
+    item = (xsltStyleItemUknownPtr) xmlMalloc(sizeof(xsltStyleItemUknown));
+    if (item == NULL) {
+       xsltTransformError(NULL, cctxt->style, NULL,
+           "Internal error in xsltForwardsCompatUnkownItemCreate(): "
+           "Failed to allocate memory.\n");
+       cctxt->style->errors++;
+       return(NULL);
+    }
+    memset(item, 0, sizeof(xsltStyleItemUknown));
+    item->type = XSLT_FUNC_UNKOWN_FORWARDS_COMPAT;
+    /*
+    * Store it in the stylesheet.
+    */
+    item->next = cctxt->style->preComps;
+    cctxt->style->preComps = (xsltElemPreCompPtr) item;
+    return(item);
+}
+
+/**
+ * xsltParseUnknownXSLTElem:
+ *
+ * @cctxt: the compilation context
+ * @node: the element of the unknown XSLT instruction
+ *
+ * Parses an unknown XSLT element.
+ * If forwards compatible mode is enabled this will allow
+ * such an unknown XSLT and; otherwise it is rejected.
+ *
+ * Returns 1 in the unknown XSLT instruction is rejected,
+ *         0 if everything's fine and
+ *         -1 on API or internal errors.
+ */ 
+static int
+xsltParseUnknownXSLTElem(xsltCompilerCtxtPtr cctxt,
+                           xmlNodePtr node)
+{
+    if ((cctxt == NULL) || (node == NULL))
+       return(-1);
+
+    /*
+    * Detection of handled content of extension instructions.
+    */
+    if (cctxt->inode->category == XSLT_ELEMENT_CATEGORY_EXTENSION) {
+       cctxt->inode->extContentHandled = 1;
+    }    
+    if (cctxt->inode->forwardsCompat == 0) {   
+       /*
+       * We are not in forwards-compatible mode, so raise an error.
+       */
+       xsltTransformError(NULL, cctxt->style, node,
+           "Unknown XSLT element '%s'.\n", node->name);
+       cctxt->style->errors++;
+       return(1);
+    }
+    /*
+    * Forwards-compatible mode.
+    * ------------------------
+    *    
+    * Parse/compile xsl:fallback elements.
+    *
+    * QUESTION: Do we have to raise an error if there's no xsl:fallback?
+    * ANSWER: No, since in the stylesheet the fallback behaviour might
+    *  also be provided by using the XSLT function "element-available".
+    */
+    if (cctxt->unknownItem == NULL) {
+       /*
+       * Create a singleton for all unknown XSLT instructions.
+       */
+       cctxt->unknownItem = xsltForwardsCompatUnkownItemCreate(cctxt);
+       if (cctxt->unknownItem == NULL) {
+           node->psvi = NULL;
+           return(-1);
+       }
+    }
+    node->psvi = cctxt->unknownItem;
+    if (node->children == NULL)
+       return(0);
+    else {
+       xmlNodePtr child = node->children;
+
+       xsltCompilerNodePush(cctxt, node);
+       /*
+       * Update the in-scope namespaces if needed.
+       */
+       if (node->nsDef != NULL)
+           cctxt->inode->inScopeNs =
+               xsltCompilerBuildInScopeNsList(cctxt, node);
+       /*
+       * Parse all xsl:fallback children.
+       */
+       do {
+           if ((child->type == XML_ELEMENT_NODE) &&
+               IS_XSLT_ELEM_FAST(child) &&
+               IS_XSLT_NAME(child, "fallback"))
+           {
+               cctxt->inode->curChildType = XSLT_FUNC_FALLBACK;
+               xsltParseAnyXSLTElem(cctxt, child);
+           }
+           child = child->next;
+       } while (child != NULL);
+       
+       xsltCompilerNodePop(cctxt, node);
+    }
+    return(0);
+}
+
+/**
+ * xsltParseSequenceConstructor:
+ *
+ * @cctxt: the compilation context
+ * @cur: the start-node of the content to be parsed
+ *
+ * Parses a "template" content (or "sequence constructor" in XSLT 2.0 terms).
+ * This will additionally remove xsl:text elements from the tree.
+ */ 
+void
+xsltParseSequenceConstructor(xsltCompilerCtxtPtr cctxt, xmlNodePtr cur)
+{
+    xsltStyleType type;
+    xmlNodePtr deleteNode = NULL;
+
+    if (cctxt == NULL) {
+       xmlGenericError(xmlGenericErrorContext,
+           "xsltParseSequenceConstructor: Bad arguments\n");
+       cctxt->style->errors++;
+       return;
+    }
+    /*
+    * Detection of handled content of extension instructions.
+    */
+    if (cctxt->inode->category == XSLT_ELEMENT_CATEGORY_EXTENSION) {
+       cctxt->inode->extContentHandled = 1;
+    }
+    if (cur == NULL)
+       return;
+    /*
+    * This is the content reffered to as a "template".
+    * E.g. an xsl:element has such content model:
+    * <xsl:element
+    *   name = { qname }
+    *   namespace = { uri-reference }
+    *   use-attribute-sets = qnames>
+    * <!-- Content: template -->
+    *
+    * NOTE that in XSLT-2 the term "template" was abandoned due to
+    *  confusion with xsl:template and the term "sequence constructor"
+    *  was introduced instead.
+    *
+    * The following XSLT-instructions are allowed to appear:
+    *  xsl:apply-templates, xsl:call-template, xsl:apply-imports,
+    *  xsl:for-each, xsl:value-of, xsl:copy-of, xsl:number,
+    *  xsl:choose, xsl:if, xsl:text, xsl:copy, xsl:variable,
+    *  xsl:message, xsl:fallback,
+    *  xsl:processing-instruction, xsl:comment, xsl:element
+    *  xsl:attribute. 
+    * Additional allowed content:
+    * 1) extension instructions
+    * 2) literal result elements
+    * 3) PCDATA
+    *
+    * NOTE that this content model does *not* allow xsl:param.
+    */    
+    while (cur != NULL) {
+       if (deleteNode != NULL) {
+#ifdef WITH_XSLT_DEBUG_BLANKS
+           xsltGenericDebug(xsltGenericDebugContext,
+            "xsltParseSequenceConstructor: removing xsl:text element\n");
+#endif
+           xmlUnlinkNode(deleteNode);
+           xmlFreeNode(deleteNode);
+           deleteNode = NULL;
+       }
+       if (cur->type == XML_ELEMENT_NODE) {        
+           
+           if (cur->psvi == xsltXSLTTextMarker) {
+               /*
+               * xsl:text elements
+               * --------------------------------------------------------
+               */
+               xmlNodePtr tmp;
+
+               cur->psvi = NULL;
+               /*
+               * Mark the xsl:text element for later deletion.
+               */
+               deleteNode = cur;
+               /*
+               * Validate content.
+               */
+               tmp = cur->children;
+               if (tmp) {
+                   /*
+                   * We don't expect more than one text-node in the
+                   * content, since we already merged adjacent
+                   * text/CDATA-nodes and eliminated PI/comment-nodes.
+                   */
+                   if ((tmp->type == XML_TEXT_NODE) ||
+                       (tmp->next == NULL))
+                   {
+                       /*
+                       * Leave the contained text-node in the tree.
+                       */
+                       xmlUnlinkNode(tmp);
+                       xmlAddPrevSibling(cur, tmp);
+                   } else {
+                       tmp = NULL;
+                       xsltTransformError(NULL, cctxt->style, cur,
+                           "Element 'xsl:text': Invalid type "
+                           "of node found in content.\n");
+                       cctxt->style->errors++;
+                   } 
+               }
+               if (cur->properties) {
+                   xmlAttrPtr attr;
+                   /*
+                   * TODO: We need to report errors for
+                   *  invalid attrs.
+                   */
+                   attr = cur->properties;
+                   do {
+                       if ((attr->ns == NULL) &&
+                           (attr->name != NULL) &&
+                           (attr->name[0] == 'd') &&
+                           xmlStrEqual(attr->name,
+                           BAD_CAST "disable-output-escaping"))
+                       {
+                           /*
+                           * Attr "disable-output-escaping".
+                           * XSLT-2: This attribute is deprecated.
+                           */
+                           if ((attr->children != NULL) &&
+                               xmlStrEqual(attr->children->content,
+                               BAD_CAST "yes"))
+                           {
+                               /*
+                               * Disable output escaping for this
+                               * text node.
+                               */
+                               if (tmp)
+                                   tmp->name = xmlStringTextNoenc;
+                           } else if ((attr->children == NULL) ||
+                               (attr->children->content == NULL) ||
+                               (!xmlStrEqual(attr->children->content,
+                               BAD_CAST "no")))
+                           {
+                               xsltTransformError(NULL, cctxt->style,
+                                   cur,
+                                   "Attribute 'disable-output-escaping': "
+                                   "Invalid value. Expected is "
+                                   "'yes' or 'no'.\n");
+                               cctxt->style->errors++;
+                           }
+                           break;
+                       }
+                       attr = attr->next;
+                   } while (attr != NULL);
+               }
+           } else if (IS_XSLT_ELEM_FAST(cur)) {
+               /*
+               * TODO: Using the XSLT-marker is still not stable yet.
+               */
+               /* if (cur->psvi == xsltXSLTElemMarker) { */        
+               /*
+               * XSLT instructions
+               * --------------------------------------------------------
+               */
+               cur->psvi = NULL;
+               type = xsltGetXSLTElementTypeByNode(cctxt, cur);
+               switch (type) {
+                   case XSLT_FUNC_APPLYIMPORTS:
+                   case XSLT_FUNC_APPLYTEMPLATES:
+                   case XSLT_FUNC_ATTRIBUTE:
+                   case XSLT_FUNC_CALLTEMPLATE:
+                   case XSLT_FUNC_CHOOSE:
+                   case XSLT_FUNC_COMMENT:
+                   case XSLT_FUNC_COPY:
+                   case XSLT_FUNC_COPYOF:
+                   case XSLT_FUNC_DOCUMENT: /* Extra one */
+                   case XSLT_FUNC_ELEMENT:
+                   case XSLT_FUNC_FALLBACK:
+                   case XSLT_FUNC_FOREACH:
+                   case XSLT_FUNC_IF:
+                   case XSLT_FUNC_MESSAGE:
+                   case XSLT_FUNC_NUMBER:
+                   case XSLT_FUNC_PI:
+                   case XSLT_FUNC_TEXT:
+                   case XSLT_FUNC_VALUEOF:
+                   case XSLT_FUNC_VARIABLE:
+                       /*
+                       * Parse the XSLT element.
+                       */
+                       cctxt->inode->curChildType = type;
+                       xsltParseAnyXSLTElem(cctxt, cur);
+                       break;
+                   default:
+                       xsltParseUnknownXSLTElem(cctxt, cur);                   
+                       cur = cur->next;
+                       continue;
+               }
+           } else {
+               /*
+               * Non-XSLT elements
+               * -----------------
+               */
+               xsltCompilerNodePush(cctxt, cur);
+               /*
+               * Update the in-scope namespaces if needed.
+               */
+               if (cur->nsDef != NULL)
+                   cctxt->inode->inScopeNs =
+                       xsltCompilerBuildInScopeNsList(cctxt, cur);
+               /*
+               * The current element is either a literal result element
+               * or an extension instruction.
+               *
+               * Process attr "xsl:extension-element-prefixes".
+               * FUTURE TODO: IIRC in XSLT 2.0 this attribute must be
+               * processed by the implementor of the extension function;
+               * i.e., it won't be handled by the XSLT processor.
+               */
+               /* SPEC 1.0:
+               *   "exclude-result-prefixes" is only allowed on literal
+               *   result elements and "xsl:exclude-result-prefixes"
+               *   on xsl:stylesheet/xsl:transform.
+               * SPEC 2.0:
+               *   "There are a number of standard attributes
+               *   that may appear on any XSLT element: specifically
+               *   version, exclude-result-prefixes,
+               *   extension-element-prefixes, xpath-default-namespace,
+               *   default-collation, and use-when."
+               *
+               * SPEC 2.0:
+               *   For literal result elements:
+               *   "xsl:version, xsl:exclude-result-prefixes,
+               *    xsl:extension-element-prefixes,
+               *    xsl:xpath-default-namespace,
+               *    xsl:default-collation, or xsl:use-when."
+               */
+               if (cur->properties)
+                   cctxt->inode->extElemNs =
+                       xsltParseExtElemPrefixes(cctxt,
+                           cur, cctxt->inode->extElemNs,
+                           XSLT_ELEMENT_CATEGORY_LRE);
+               /*
+               * Eval if we have an extension instruction here.
+               */
+               if ((cur->ns != NULL) &&
+                   (cctxt->inode->extElemNs != NULL) &&
+                   (xsltCheckExtPrefix(cctxt->style, cur->ns->href) == 1))
+               {
+                   /*
+                   * Extension instructions
+                   * ----------------------------------------------------
+                   * Mark the node information.
+                   */
+                   cctxt->inode->category = XSLT_ELEMENT_CATEGORY_EXTENSION;
+                   cctxt->inode->extContentHandled = 0;
+                   if (cur->psvi != NULL) {
+                       cur->psvi = NULL;
+                       /*
+                       * TODO: Temporary sanity check.
+                       */
+                       xsltTransformError(NULL, cctxt->style, cur,
+                           "Internal error in xsltParseSequenceConstructor(): "
+                           "Occupied PSVI field.\n");
+                       cctxt->style->errors++;
+                       cur = cur->next;
+                       continue;
+                   }
+                   cur->psvi = (void *)
+                       xsltPreComputeExtModuleElement(cctxt->style, cur);
+                   
+                   if (cur->psvi == NULL) {
+                       /*
+                       * OLD COMMENT: "Unknown element, maybe registered
+                       *  at the context level. Mark it for later
+                       *  recognition."
+                       * QUESTION: What does the xsltExtMarker mean?
+                       *  ANSWER: It is used in
+                       *   xsltApplySequenceConstructor() at
+                       *   transformation-time to look out for extension
+                       *   registered in the transformation context.
+                       */
+                       cur->psvi = (void *) xsltExtMarker;
+                   }
+                   /*
+                   * BIG NOTE: Now the ugly part. In previous versions
+                   *  of Libxslt (until 1.1.16), all the content of an
+                   *  extension instruction was processed and compiled without
+                   *  the need of the extension-author to explicitely call
+                   *  such a processing;.We now need to mimic this old
+                   *  behaviour in order to avoid breaking old code
+                   *  on the extension-author's side.
+                   * The mechanism:
+                   *  1) If the author does *not* set the
+                   *    compile-time-flag @extContentHandled, then we'll
+                   *    parse the content assuming that it's a "template"
+                   *    (or "sequence constructor in XSLT 2.0 terms).
+                   *    NOTE: If the extension is registered at
+                   *    transformation-time only, then there's no way of
+                   *    knowing that content shall be valid, and we'll
+                   *    process the content the same way.
+                   *  2) If the author *does* set the flag, then we'll assume
+                   *   that the author has handled the parsing him/herself
+                   *   (e.g. called xsltParseSequenceConstructor(), etc.
+                   *   explicitely in his/her code).
+                   */
+                   if ((cur->children != NULL) &&
+                       (cctxt->inode->extContentHandled == 0))
+                   {
+                       /*
+                       * Default parsing of the content using the
+                       * sequence-constructor model.
+                       */
+                       xsltParseSequenceConstructor(cctxt, cur->children);
+                   }
+               } else {
+                   /*
+                   * Literal result element
+                   * ----------------------------------------------------
+                   * Allowed XSLT attributes:
+                   *  xsl:extension-element-prefixes CDATA #IMPLIED
+                   *  xsl:exclude-result-prefixes CDATA #IMPLIED
+                   *  TODO: xsl:use-attribute-sets %qnames; #IMPLIED
+                   *  xsl:version NMTOKEN #IMPLIED
+                   */
+                   cur->psvi = NULL;
+                   cctxt->inode->category = XSLT_ELEMENT_CATEGORY_LRE;
+                   if (cur->properties != NULL) {
+                       xmlAttrPtr attr = cur->properties;
+                       /*
+                       * Attribute "xsl:exclude-result-prefixes".
+                       */
+                       cctxt->inode->exclResultNs =
+                           xsltParseExclResultPrefixes(cctxt, cur,
+                               cctxt->inode->exclResultNs,
+                               XSLT_ELEMENT_CATEGORY_LRE);
+                       /*
+                       * Attribute "xsl:version".
+                       */
+                       xsltParseAttrXSLTVersion(cctxt, cur,
+                           XSLT_ELEMENT_CATEGORY_LRE);
+                       /*
+                       * Report invalid XSLT attributes.                       
+                       * For XSLT 1.0 only xsl:use-attribute-sets is allowed
+                       * next to xsl:version, xsl:exclude-result-prefixes and
+                       * xsl:extension-element-prefixes.
+                       *
+                       * Mark all XSLT attributes, in order to skip such
+                       * attributes when instantiating the LRE.
+                       */
+                       do {
+                           if ((attr->psvi != xsltXSLTAttrMarker) &&
+                               IS_XSLT_ATTR_FAST(attr))
+                           {                               
+                               if (! xmlStrEqual(attr->name,
+                                   BAD_CAST "use-attribute-sets"))
+                               {                               
+                                   xsltTransformError(NULL, cctxt->style,
+                                       cur,
+                                       "Unknown XSLT attribute '%s'.\n",
+                                       attr->name);
+                                   cctxt->style->errors++;
+                               } else {
+                                   /*
+                                   * XSLT attr marker.
+                                   */
+                                   attr->psvi = (void *) xsltXSLTAttrMarker;
+                               }
+                           }
+                           attr = attr->next;
+                       } while (attr != NULL);
+                   }
+                   /*
+                   * Create/reuse info for the literal result element.
+                   */
+                   if (cctxt->inode->nsChanged)
+                       xsltLREInfoCreate(cctxt, cur, 1);
+                   cur->psvi = cctxt->inode->litResElemInfo;
+                   /*
+                   * Apply ns-aliasing on the element and on its attributes.
+                   */
+                   if (cctxt->hasNsAliases)
+                       xsltLREBuildEffectiveNs(cctxt, cur);
+                   /*
+                   * Compile attribute value templates (AVT).
+                   */
+                   if (cur->properties) {
+                       xmlAttrPtr attr = cur->properties;
+                       
+                       while (attr != NULL) {
+                           xsltCompileAttr(cctxt->style, attr);
+                           attr = attr->next;
+                       }
+                   }
+                   /*
+                   * Parse the content, which is defined to be a "template"
+                   * (or "sequence constructor" in XSLT 2.0 terms).
+                   */
+                   if (cur->children != NULL) {
+                       xsltParseSequenceConstructor(cctxt, cur->children);
+                   }
+               }
+               /*
+               * Leave the non-XSLT element.
+               */
+               xsltCompilerNodePop(cctxt, cur);
+           }
+       }
+       cur = cur->next;
+    }
+    if (deleteNode != NULL) {
+#ifdef WITH_XSLT_DEBUG_BLANKS
+       xsltGenericDebug(xsltGenericDebugContext,
+           "xsltParseSequenceConstructor: removing xsl:text element\n");
+#endif
+       xmlUnlinkNode(deleteNode);
+       xmlFreeNode(deleteNode);
+       deleteNode = NULL;
+    }
+}
+
+/**
+ * xsltParseTemplateContent:
+ * @style:  the XSLT stylesheet
+ * @templ:  the node containing the content to be parsed
+ *
+ * Parses and compiles the content-model of an xsl:template element.
+ * Note that this is *not* the "template" content model (or "sequence
+ *  constructor" in XSLT 2.0); it it allows addional xsl:param
+ *  elements as immediate children of @templ.
+ *
+ * Called by: 
+ *   exsltFuncFunctionComp() (EXSLT, functions.c)
+ *   So this is intended to be called from extension functions.
+ */
+void
+xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ) {
+    if ((style == NULL) || (templ == NULL))
+       return;
+
+    /*
+    * Detection of handled content of extension instructions.
+    */
+    if (XSLT_CCTXT(style)->inode->category == XSLT_ELEMENT_CATEGORY_EXTENSION) {
+       XSLT_CCTXT(style)->inode->extContentHandled = 1;
+    }
+
+    if (templ->children != NULL) {     
+       xmlNodePtr child = templ->children;
+       /*
+       * Process xsl:param elements, which can only occur as the
+       * immediate children of xsl:template (well, and of any
+       * user-defined extension instruction if needed).
+       */      
+       do {
+           if ((child->type == XML_ELEMENT_NODE) &&
+               IS_XSLT_ELEM_FAST(child) &&
+               IS_XSLT_NAME(child, "param"))
+           {
+               XSLT_CCTXT(style)->inode->curChildType = XSLT_FUNC_PARAM;
+               xsltParseAnyXSLTElem(XSLT_CCTXT(style), child);
+           } else
+               break;
+           child = child->next;
+       } while (child != NULL);
+       /*
+       * Parse the content and register the pattern.
+       */
+       xsltParseSequenceConstructor(XSLT_CCTXT(style), child);
+    }
+}
+
+#else /* XSLT_REFACTORED */
+
+/**
+ * xsltParseTemplateContent:
+ * @style:  the XSLT stylesheet
+ * @templ:  the container node (can be a document for literal results)
+ *
+ * parse a template content-model
+ * Clean-up the template content from unwanted ignorable blank nodes
+ * and process xslt:text
+ */
+void
+xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ) {
+    xmlNodePtr cur, delete;
+    /*
+     * This content comes from the stylesheet
+     * For stylesheets, the set of whitespace-preserving
+     * element names consists of just xsl:text.
+     */
+    cur = templ->children;
+    delete = NULL;
+    while (cur != NULL) {
+       if (delete != NULL) {
+#ifdef WITH_XSLT_DEBUG_BLANKS
+           xsltGenericDebug(xsltGenericDebugContext,
+            "xsltParseTemplateContent: removing text\n");
+#endif
+           xmlUnlinkNode(delete);
+           xmlFreeNode(delete);
+           delete = NULL;
+       }
+       if (IS_XSLT_ELEM(cur)) {
+           if (IS_XSLT_NAME(cur, "text")) {
+               /*
+               * TODO: Processing of xsl:text should be moved to
+               *   xsltPrecomputeStylesheet(), since otherwise this
+               *   will be performed for every multiply included
+               *   stylesheet; i.e. this here is not skipped with
+               *   the use of the style->nopreproc flag.
+               */
+               if (cur->children != NULL) {
+                   xmlChar *prop;
+                   xmlNodePtr text = cur->children, next;
+                   int noesc = 0;
+                       
+                   prop = xmlGetNsProp(cur,
+                       (const xmlChar *)"disable-output-escaping",
+                       NULL);
+                   if (prop != NULL) {
+#ifdef WITH_XSLT_DEBUG_PARSING
+                       xsltGenericDebug(xsltGenericDebugContext,
+                            "Disable escaping: %s\n", text->content);
+#endif
+                       if (xmlStrEqual(prop, (const xmlChar *)"yes")) {
+                           noesc = 1;
+                       } else if (!xmlStrEqual(prop,
+                                               (const xmlChar *)"no")){
+                           xsltTransformError(NULL, style, cur,
+            "xsl:text: disable-output-escaping allows only yes or no\n");
+                           style->warnings++;
+
+                       }
+                       xmlFree(prop);
+                   }
+
+                   while (text != NULL) {
+                       if (text->type == XML_COMMENT_NODE) {
+                           text = text->next;
+                           continue;
+                       }
+                       if ((text->type != XML_TEXT_NODE) &&
+                            (text->type != XML_CDATA_SECTION_NODE)) {
+                           xsltTransformError(NULL, style, cur,
+                "xsltParseTemplateContent: xslt:text content problem\n");
+                           style->errors++;
+                           break;
+                       }
+                       if ((noesc) && (text->type != XML_CDATA_SECTION_NODE))
+                           text->name = xmlStringTextNoenc;
+                       text = text->next;
+                   }
+
+                   /*
+                    * replace xsl:text by the list of childs
+                    */
+                   if (text == NULL) {
+                       text = cur->children;
+                       while (text != NULL) {
+                           if ((style->internalized) &&
+                               (text->content != NULL) &&
+                               (!xmlDictOwns(style->dict, text->content))) {
+
+                               /*
+                                * internalize the text string
+                                */
+                               if (text->doc->dict != NULL) {
+                                   const xmlChar *tmp;
+                                   
+                                   tmp = xmlDictLookup(text->doc->dict,
+                                                       text->content, -1);
+                                   if (tmp != text->content) {
+                                       xmlNodeSetContent(text, NULL);
+                                       text->content = (xmlChar *) tmp;
+                                   }
+                               }
+                           }
+
+                           next = text->next;
+                           xmlUnlinkNode(text);
+                           xmlAddPrevSibling(cur, text);
+                           text = next;
+                       }
+                   }
+               }
+               delete = cur;
+               goto skip_children;
+           }
+       }
+       else if ((cur->ns != NULL) && (style->nsDefs != NULL) &&
+           (xsltCheckExtPrefix(style, cur->ns->prefix)))
+       {
+           /*
+            * okay this is an extension element compile it too
+            */
+           xsltStylePreCompute(style, cur);
+       } else {
+           /*
+            * This is an element which will be output as part of the
+            * template exectution, precompile AVT if found.
+            */
+           if ((cur->ns == NULL) && (style->defaultAlias != NULL) &&
+                       (cur->type == XML_ELEMENT_NODE)) {
+               cur->ns = xmlSearchNsByHref(cur->doc, cur,
+                       style->defaultAlias);
+           }
+           if (cur->properties != NULL) {
+               xmlAttrPtr attr = cur->properties;
+
+               while (attr != NULL) {
+                   xsltCompileAttr(style, attr);
+                   attr = attr->next;
+               }
+           }
+       }
+       /*
+        * Skip to next node
+        */
+       if (cur->children != NULL) {
+           if (cur->children->type != XML_ENTITY_DECL) {
+               cur = cur->children;
+               continue;
+           }
+       }
+skip_children:
+       if (cur->next != NULL) {
+           cur = cur->next;
+           continue;
+       }
+       
+       do {
+           cur = cur->parent;
+           if (cur == NULL)
+               break;
+           if (cur == templ) {
+               cur = NULL;
+               break;
+           }
+           if (cur->next != NULL) {
+               cur = cur->next;
+               break;
+           }
+       } while (cur != NULL);
+    }
+    if (delete != NULL) {
+#ifdef WITH_XSLT_DEBUG_PARSING
+       xsltGenericDebug(xsltGenericDebugContext,
+        "xsltParseTemplateContent: removing text\n");
+#endif
+       xmlUnlinkNode(delete);
+       xmlFreeNode(delete);
+       delete = NULL;
+    }
+
+    /*
+     * Skip the first params
+     */
+    cur = templ->children;
+    while (cur != NULL) {
+       if ((IS_XSLT_ELEM(cur)) && (!(IS_XSLT_NAME(cur, "param"))))
+           break;
+       cur = cur->next;
+    }
+
+    /*
+     * Browse the remainder of the template
+     */
+    while (cur != NULL) {
+       if ((IS_XSLT_ELEM(cur)) && (IS_XSLT_NAME(cur, "param"))) {
+           xmlNodePtr param = cur;
+
+           xsltTransformError(NULL, style, cur,
+               "xsltParseTemplateContent: ignoring misplaced param element\n");
+           if (style != NULL) style->warnings++;
+            cur = cur->next;
+           xmlUnlinkNode(param);
+           xmlFreeNode(param);
+       } else
+           break;
+    }
+}
+
+#endif /* else XSLT_REFACTORED */
+
+/**
+ * xsltParseStylesheetKey:
+ * @style:  the XSLT stylesheet
+ * @key:  the "key" element
+ *
+ * <!-- Category: top-level-element -->
+ * <xsl:key name = qname, match = pattern, use = expression />
+ *
+ * parse an XSLT stylesheet key definition and register it
+ */
+
+static void
+xsltParseStylesheetKey(xsltStylesheetPtr style, xmlNodePtr key) {
+    xmlChar *prop = NULL;
+    xmlChar *use = NULL;
+    xmlChar *match = NULL;
+    xmlChar *name = NULL;
+    xmlChar *nameURI = NULL;
+
+    if ((style == NULL) || (key == NULL))
+       return;
+
+    /*
+     * Get arguments
+     */
+    prop = xmlGetNsProp(key, (const xmlChar *)"name", NULL);
+    if (prop != NULL) {
+        const xmlChar *URI;
+
+       /*
+       * TODO: Don't use xsltGetQNameURI().
+       */
+       URI = xsltGetQNameURI(key, &prop);
+       if (prop == NULL) {
+           if (style != NULL) style->errors++;
+           goto error;
+       } else {
+           name = prop;
+           if (URI != NULL)
+               nameURI = xmlStrdup(URI);
+       }
+#ifdef WITH_XSLT_DEBUG_PARSING
+       xsltGenericDebug(xsltGenericDebugContext,
+            "xsltParseStylesheetKey: name %s\n", name);
+#endif
+    } else {
+       xsltTransformError(NULL, style, key,
+           "xsl:key : error missing name\n");
+       if (style != NULL) style->errors++;
+       goto error;
+    }
+
+    match = xmlGetNsProp(key, (const xmlChar *)"match", NULL);
+    if (match == NULL) {
+       xsltTransformError(NULL, style, key,
+           "xsl:key : error missing match\n");
+       if (style != NULL) style->errors++;
+       goto error;
+    }
+
+    use = xmlGetNsProp(key, (const xmlChar *)"use", NULL);
+    if (use == NULL) {
+       xsltTransformError(NULL, style, key,
+           "xsl:key : error missing use\n");
+       if (style != NULL) style->errors++;
+       goto error;
+    }
+
+    /*
+     * register the keys
+     */
+    xsltAddKey(style, name, nameURI, match, use, key);
+
+
+error:
+    if (use != NULL)
+       xmlFree(use);
+    if (match != NULL)
+       xmlFree(match);
+    if (name != NULL)
+       xmlFree(name);
+    if (nameURI != NULL)
+       xmlFree(nameURI);
+
+    if (key->children != NULL) {
+       xsltParseContentError(style, key->children);
+    }
+}
+
+#ifdef XSLT_REFACTORED
+/**
+ * xsltParseXSLTTemplate:
+ * @style:  the XSLT stylesheet
+ * @template:  the "template" element
+ *
+ * parse an XSLT stylesheet template building the associated structures
+ * TODO: Is @style ever expected to be NULL?
+ *
+ * Called from:
+ *   xsltParseXSLTStylesheet()
+ *   xsltParseStylesheetTop()
+ */
+
+static void
+xsltParseXSLTTemplate(xsltCompilerCtxtPtr cctxt, xmlNodePtr templNode) {
+    xsltTemplatePtr templ;
+    xmlChar *prop;    
+    double  priority;    
+
+    if ((cctxt == NULL) || (templNode == NULL))
+       return;
+
+    /*
+     * Create and link the structure
+     */
+    templ = xsltNewTemplate();
+    if (templ == NULL)
+       return;
+
+    xsltCompilerNodePush(cctxt, templNode);
+    if (templNode->nsDef != NULL)
+       cctxt->inode->inScopeNs =
+           xsltCompilerBuildInScopeNsList(cctxt, templNode);
+
+    templ->next = cctxt->style->templates;
+    cctxt->style->templates = templ;
+    templ->style = cctxt->style;  
+
+    /*
+    * Attribute "mode".
+    */
+    prop = xmlGetNsProp(templNode, (const xmlChar *)"mode", NULL);
+    if (prop != NULL) {        
+        const xmlChar *modeURI;
+
+       /*
+       * TODO: We need a standardized function for extraction
+       *  of namespace names and local names from QNames.
+       *  Don't use xsltGetQNameURI() as it cannot channeö
+       *  reports through the context.
+       */
+       modeURI = xsltGetQNameURI(templNode, &prop);
+       if (prop == NULL) {
+           cctxt->style->errors++;
+           goto error;
+       }
+       templ->mode = xmlDictLookup(cctxt->style->dict, prop, -1);
+       xmlFree(prop);
+       prop = NULL;
+       if (xmlValidateNCName(templ->mode, 0)) {
+           xsltTransformError(NULL, cctxt->style, templNode,
+               "xsl:template: Attribute 'mode': The local part '%s' "
+               "of the value is not a valid NCName.\n", templ->name);
+           cctxt->style->errors++;
+           goto error;
+       }
+       if (modeURI != NULL)
+           templ->modeURI = xmlDictLookup(cctxt->style->dict, modeURI, -1);
+#ifdef WITH_XSLT_DEBUG_PARSING
+       xsltGenericDebug(xsltGenericDebugContext,
+            "xsltParseXSLTTemplate: mode %s\n", templ->mode);
+#endif
+    }
+    /*
+    * Attribute "match".
+    */
+    prop = xmlGetNsProp(templNode, (const xmlChar *)"match", NULL);
+    if (prop != NULL) {
+       templ->match  = prop;
+       prop = NULL;
+    }
+    /*
+    * Attribute "priority".
+    */
+    prop = xmlGetNsProp(templNode, (const xmlChar *)"priority", NULL);
+    if (prop != NULL) {
+       priority = xmlXPathStringEvalNumber(prop);
+       templ->priority = (float) priority;
+       xmlFree(prop);
+       prop = NULL;
+    }
+    /*
+    * Attribute "name".
+    */
+    prop = xmlGetNsProp(templNode, (const xmlChar *)"name", NULL);
+    if (prop != NULL) {
+        const xmlChar *nameURI;
+       xsltTemplatePtr curTempl;
+       
+       /*
+       * TODO: Don't use xsltGetQNameURI().
+       */
+       nameURI = xsltGetQNameURI(templNode, &prop);
+       if (prop == NULL) {
+           cctxt->style->errors++;
+           goto error;
+       }
+       templ->name = xmlDictLookup(cctxt->style->dict, prop, -1);
+       xmlFree(prop);
+       prop = NULL;
+       if (xmlValidateNCName(templ->name, 0)) {
+           xsltTransformError(NULL, cctxt->style, templNode,
+               "xsl:template: Attribute 'name': The local part '%s' of "
+               "the value is not a valid NCName.\n", templ->name);
+           cctxt->style->errors++;
+           goto error;
+       }       
+       if (nameURI != NULL)
+           templ->nameURI = xmlDictLookup(cctxt->style->dict, nameURI, -1);
+       curTempl = templ->next;
+       while (curTempl != NULL) {
+           if ((nameURI != NULL && xmlStrEqual(curTempl->name, templ->name) &&
+               xmlStrEqual(curTempl->nameURI, nameURI) ) ||
+               (nameURI == NULL && curTempl->nameURI == NULL &&
+               xmlStrEqual(curTempl->name, templ->name)))
+           {
+               xsltTransformError(NULL, cctxt->style, templNode,
+                   "xsl:template: error duplicate name '%s'\n", templ->name);
+               cctxt->style->errors++;
+               goto error;
+           }
+           curTempl = curTempl->next;
+       }
+    }
+    if (templNode->children != NULL) {
+       xsltParseTemplateContent(cctxt->style, templNode);      
+       /*
+       * MAYBE TODO: Custom behaviour: In order to stay compatible with
+       * Xalan and MSXML(.NET), we could allow whitespace
+       * to appear before an xml:param element; this whitespace
+       * will additionally become part of the "template".
+       * NOTE that this is totally deviates from the spec, but
+       * is the de facto behaviour of Xalan and MSXML(.NET).
+       * Personally I wouldn't allow this, since if we have:
+       * <xsl:template ...xml:space="preserve">
+       *   <xsl:param name="foo"/>
+       *   <xsl:param name="bar"/>
+       *   <xsl:param name="zoo"/>
+       * ... the whitespace between every xsl:param would be
+       * added to the result tree.
+       */              
+    }    
+    
+    templ->elem = templNode;
+    templ->content = templNode->children;
+    xsltAddTemplate(cctxt->style, templ, templ->mode, templ->modeURI);
+
+error:
+    xsltCompilerNodePop(cctxt, templNode);
+    return;
+}
+
+#else /* XSLT_REFACTORED */
+
+/**
+ * xsltParseStylesheetTemplate:
+ * @style:  the XSLT stylesheet
+ * @template:  the "template" element
+ *
+ * parse an XSLT stylesheet template building the associated structures
+ */
+
+static void
+xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
+    xsltTemplatePtr ret;
+    xmlChar *prop;
+    xmlChar *mode = NULL;
+    xmlChar *modeURI = NULL;
+    double  priority;
+
+    if (template == NULL)
+       return;
+
+    /*
+     * Create and link the structure
+     */
+    ret = xsltNewTemplate();
+    if (ret == NULL)
+       return;
+    ret->next = style->templates;
+    style->templates = ret;
+    ret->style = style;
+   
+    /*
+     * Get inherited namespaces
+     */
+    /*
+    * TODO: Apply the optimized in-scope-namespace mechanism
+    *   as for the other XSLT instructions.
+    */
+    xsltGetInheritedNsList(style, ret, template);
+
+    /*
+     * Get arguments
+     */
+    prop = xmlGetNsProp(template, (const xmlChar *)"mode", NULL);
+    if (prop != NULL) {
+        const xmlChar *URI;
+
+       /*
+       * TODO: Don't use xsltGetQNameURI().
+       */
+       URI = xsltGetQNameURI(template, &prop);
+       if (prop == NULL) {
+           if (style != NULL) style->errors++;
+           goto error;
+       } else {
+           mode = prop;
+           if (URI != NULL)
+               modeURI = xmlStrdup(URI);
+       }
+       ret->mode = xmlDictLookup(style->dict, mode, -1);
+       ret->modeURI = xmlDictLookup(style->dict, modeURI, -1);
+#ifdef WITH_XSLT_DEBUG_PARSING
+       xsltGenericDebug(xsltGenericDebugContext,
+            "xsltParseStylesheetTemplate: mode %s\n", mode);
+#endif
+        if (mode != NULL) xmlFree(mode);
+       if (modeURI != NULL) xmlFree(modeURI);
+    }
+    prop = xmlGetNsProp(template, (const xmlChar *)"match", NULL);
+    if (prop != NULL) {
+       if (ret->match != NULL) xmlFree(ret->match);
+       ret->match  = prop;
+    }
+
+    prop = xmlGetNsProp(template, (const xmlChar *)"priority", NULL);
+    if (prop != NULL) {
+       priority = xmlXPathStringEvalNumber(prop);
+       ret->priority = (float) priority;
+       xmlFree(prop);
+    }
+
+    prop = xmlGetNsProp(template, (const xmlChar *)"name", NULL);
+    if (prop != NULL) {
+        const xmlChar *URI;
+       xsltTemplatePtr cur;
+       
+       /*
+       * TODO: Don't use xsltGetQNameURI().
+       */
+       URI = xsltGetQNameURI(template, &prop);
+       if (prop == NULL) {
+           if (style != NULL) style->errors++;
+           goto error;
+       } else {
+           if (xmlValidateNCName(prop,0)) {
+               xsltTransformError(NULL, style, template,
+                   "xsl:template : error invalid name '%s'\n", prop);
+               if (style != NULL) style->errors++;
+               goto error;
+           }
+           ret->name = xmlDictLookup(style->dict, BAD_CAST prop, -1);
+           xmlFree(prop);
+           prop = NULL;
+           if (URI != NULL)
+               ret->nameURI = xmlDictLookup(style->dict, BAD_CAST URI, -1);
+           else
+               ret->nameURI = NULL;
+           cur = ret->next;
+           while (cur != NULL) {
+               if ((URI != NULL && xmlStrEqual(cur->name, ret->name) &&
+                               xmlStrEqual(cur->nameURI, URI) ) ||
+                   (URI == NULL && cur->nameURI == NULL &&
+                               xmlStrEqual(cur->name, ret->name))) {
+                   xsltTransformError(NULL, style, template,
+                       "xsl:template: error duplicate name '%s'\n", ret->name);
+                   style->errors++;
+                   goto error;
+               }
+               cur = cur->next;
+           }
+       }
+    }
+
+    /*
+     * parse the content and register the pattern
+     */
+    xsltParseTemplateContent(style, template);
+    ret->elem = template;
+    ret->content = template->children;
+    xsltAddTemplate(style, ret, ret->mode, ret->modeURI);
+
+error:
+    return;
+}
+
+#endif /* else XSLT_REFACTORED */
+
+#ifdef XSLT_REFACTORED
+
+/**
+ * xsltIncludeComp:
+ * @cctxt: the compilation contenxt
+ * @node:  the xsl:include node
+ *
+ * Process the xslt include node on the source node
+ */
+static xsltStyleItemIncludePtr
+xsltCompileXSLTIncludeElem(xsltCompilerCtxtPtr cctxt, xmlNodePtr node) {
+    xsltStyleItemIncludePtr item;
+
+    if ((cctxt == NULL) || (node == NULL))
+       return(NULL);
+
+    node->psvi = NULL;
+    item = (xsltStyleItemIncludePtr) xmlMalloc(sizeof(xsltStyleItemInclude));
+    if (item == NULL) {
+       xsltTransformError(NULL, cctxt->style, node,
+               "xsltIncludeComp : malloc failed\n");
+       cctxt->style->errors++;
+       return(NULL);
+    }
+    memset(item, 0, sizeof(xsltStyleItemInclude));
+
+    node->psvi = item;
+    item->inst = node;
+    item->type = XSLT_FUNC_INCLUDE;
+
+    item->next = cctxt->style->preComps;
+    cctxt->style->preComps = (xsltElemPreCompPtr) item;
+
+    return(item);
+}
+
+/**
+ * xsltParseFindTopLevelElem:
+ */
+static int
+xsltParseFindTopLevelElem(xsltCompilerCtxtPtr cctxt,
+                             xmlNodePtr cur,
+                             const xmlChar *name,
+                             const xmlChar *namespaceURI,
+                             int breakOnOtherElem,                           
+                             xmlNodePtr *resultNode)
+{
+    if (name == NULL)
+       return(-1);
+
+    *resultNode = NULL;
+    while (cur != NULL) {
+       if (cur->type == XML_ELEMENT_NODE) {
+           if ((cur->ns != NULL) && (cur->name != NULL)) {
+               if ((*(cur->name) == *name) &&
+                   xmlStrEqual(cur->name, name) &&
+                   xmlStrEqual(cur->ns->href, namespaceURI))               
+               {
+                   *resultNode = cur;
+                   return(1);
+               }
+           }
+           if (breakOnOtherElem)
+               break;
+       }
+       cur = cur->next;
+    }
+    *resultNode = cur;
+    return(0);
+}
+
+static int
+xsltParseTopLevelXSLTElem(xsltCompilerCtxtPtr cctxt,
+                         xmlNodePtr node,
+                         xsltStyleType type)
+{
+    int ret = 0;
+
+    /*
+    * TODO: The reason why this function exists:
+    *  due to historical reasons some of the
+    *  top-level declarations are processed by functions
+    *  in other files. Since we need still to set
+    *  up the node-info and generate information like
+    *  in-scope namespaces, this is a wrapper around
+    *  those old parsing functions.
+    */
+    xsltCompilerNodePush(cctxt, node);
+    if (node->nsDef != NULL)
+       cctxt->inode->inScopeNs =
+           xsltCompilerBuildInScopeNsList(cctxt, node);
+    cctxt->inode->type = type;
+
+    switch (type) {
+       case XSLT_FUNC_INCLUDE:
+           {
+               int oldIsInclude;
+
+               if (xsltCompileXSLTIncludeElem(cctxt, node) == NULL)
+                   goto exit;          
+               /*
+               * Mark this stylesheet tree as being currently included.
+               */
+               oldIsInclude = cctxt->isInclude;
+               cctxt->isInclude = 1;
+                                               
+               if (xsltParseStylesheetInclude(cctxt->style, node) != 0) {
+                   cctxt->style->errors++;
+               }
+               cctxt->isInclude = oldIsInclude;
+           }
+           break;
+       case XSLT_FUNC_PARAM:
+           xsltStylePreCompute(cctxt->style, node);
+           xsltParseGlobalParam(cctxt->style, node);
+           break;
+       case XSLT_FUNC_VARIABLE:
+           xsltStylePreCompute(cctxt->style, node);
+           xsltParseGlobalVariable(cctxt->style, node);
+           break;
+       case XSLT_FUNC_ATTRSET:
+           xsltParseStylesheetAttributeSet(cctxt->style, node);
+           break;
+       default:
+           xsltTransformError(NULL, cctxt->style, node,
+               "Internal error: (xsltParseTopLevelXSLTElem) "
+               "Cannot handle this top-level declaration.\n");
+           cctxt->style->errors++;
+           ret = -1;
+    }
+
+exit:
+    xsltCompilerNodePop(cctxt, node);
+
+    return(ret);
+}
+
+#if 0
+static int
+xsltParseRemoveWhitespace(xmlNodePtr node)
+{
+    if ((node == NULL) || (node->children == NULL))
+       return(0);
+    else {
+       xmlNodePtr delNode = NULL, child = node->children;
+
+       do {
+           if (delNode) {
+               xmlUnlinkNode(delNode);
+               xmlFreeNode(delNode);
+               delNode = NULL;
+           }
+           if (((child->type == XML_TEXT_NODE) ||
+                (child->type == XML_CDATA_SECTION_NODE)) &&
+               (IS_BLANK_NODE(child)))
+               delNode = child;            
+           child = child->next;
+       } while (child != NULL);
+       if (delNode) {
+           xmlUnlinkNode(delNode);
+           xmlFreeNode(delNode);
+           delNode = NULL;
+       }
+    }
+    return(0);
+}
+#endif
+
+static int
+xsltParseXSLTStylesheetElemCore(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
+{
+#ifdef WITH_XSLT_DEBUG_PARSING
+    int templates = 0;
+#endif
+    xmlNodePtr cur, start = NULL;
+    xsltStylesheetPtr style;
+
+    if ((cctxt == NULL) || (node == NULL) ||
+       (node->type != XML_ELEMENT_NODE))
+       return(-1);    
+
+    style = cctxt->style;    
+    /*
+    * At this stage all import declarations of all stylesheet modules
+    * with the same stylesheet level have been processed.
+    * Now we can safely parse the rest of the declarations.
+    */
+    if (IS_XSLT_ELEM_FAST(node) && IS_XSLT_NAME(node, "include"))
+    {
+       xsltDocumentPtr include;
+       /*
+       * URGENT TODO: Make this work with simplified stylesheets!
+       *   I.e., when we won't find an xsl:stylesheet element.
+       */
+       /*
+       * This is as include declaration.
+       */
+       include = ((xsltStyleItemIncludePtr) node->psvi)->include;
+       if (include == NULL) {
+           /* TODO: raise error? */
+           return(-1);
+       }
+       /*
+       * TODO: Actually an xsl:include should locate an embedded
+       *  stylesheet as well; so the document-element won't always
+       *  be the element where the actual stylesheet is rooted at.
+       *  But such embedded stylesheets are not supported by Libxslt yet.
+       */
+       node = xmlDocGetRootElement(include->doc);
+       if (node == NULL) {
+           return(-1);
+       }
+    }    
+    
+    if (node->children == NULL)
+       return(0);
+    /*
+    * Push the xsl:stylesheet/xsl:transform element.
+    */  
+    xsltCompilerNodePush(cctxt, node);
+    cctxt->inode->isRoot = 1;
+    cctxt->inode->nsChanged = 0;
+    /*
+    * Start with the naked dummy info for literal result elements.
+    */
+    cctxt->inode->litResElemInfo = cctxt->inodeList->litResElemInfo;
+
+    /*
+    * In every case, we need to have
+    * the in-scope namespaces of the element, where the
+    * stylesheet is rooted at, regardless if it's an XSLT
+    * instruction or a literal result instruction (or if
+    * this is an embedded stylesheet).
+    */         
+    cctxt->inode->inScopeNs =
+       xsltCompilerBuildInScopeNsList(cctxt, node);
+
+    /*
+    * Process attributes of xsl:stylesheet/xsl:transform.
+    * --------------------------------------------------
+    * Allowed are:
+    *  id = id
+    *  extension-element-prefixes = tokens
+    *  exclude-result-prefixes = tokens
+    *  version = number (mandatory)    
+    */
+    if (xsltParseAttrXSLTVersion(cctxt, node,
+       XSLT_ELEMENT_CATEGORY_XSLT) == 0)
+    {    
+       /*
+       * Attribute "version".
+       * XSLT 1.0: "An xsl:stylesheet element *must* have a version
+       *  attribute, indicating the version of XSLT that the
+       *  stylesheet requires".
+       * The root element of a simplified stylesheet must also have
+       * this attribute.
+       */
+#ifdef XSLT_REFACTORED_MANDATORY_VERSION
+       if (isXsltElem)
+           xsltTransformError(NULL, cctxt->style, node,
+               "The attribute 'version' is missing.\n");
+       cctxt->style->errors++; 
+#else
+       /* OLD behaviour. */
+       xsltTransformError(NULL, cctxt->style, node,
+           "xsl:version is missing: document may not be a stylesheet\n");
+       cctxt->style->warnings++;
+#endif
+    }    
+    /*
+    * The namespaces declared by the attributes
+    *  "extension-element-prefixes" and
+    *  "exclude-result-prefixes" are local to *this*
+    *  stylesheet tree; i.e., they are *not* visible to
+    *  other stylesheet-modules, whether imported or included.
+    * 
+    * Attribute "extension-element-prefixes".
+    */
+    cctxt->inode->extElemNs =
+       xsltParseExtElemPrefixes(cctxt, node, NULL,
+           XSLT_ELEMENT_CATEGORY_XSLT);
+    /*
+    * Attribute "exclude-result-prefixes".
+    */
+    cctxt->inode->exclResultNs =
+       xsltParseExclResultPrefixes(cctxt, node, NULL,
+           XSLT_ELEMENT_CATEGORY_XSLT);
+    /*
+    * Create/reuse info for the literal result element.
+    */
+    if (cctxt->inode->nsChanged)
+       xsltLREInfoCreate(cctxt, node, 0);
+    /*
+    * Processed top-level elements:
+    * ----------------------------
+    *  xsl:variable, xsl:param (QName, in-scope ns,
+    *    expression (vars allowed))
+    *  xsl:attribute-set (QName, in-scope ns)
+    *  xsl:strip-space, xsl:preserve-space (XPath NameTests,
+    *    in-scope ns)
+    *    I *think* global scope, merge with includes
+    *  xsl:output (QName, in-scope ns)
+    *  xsl:key (QName, in-scope ns, pattern,
+    *    expression (vars *not* allowed))
+    *  xsl:decimal-format (QName, needs in-scope ns)
+    *  xsl:namespace-alias (in-scope ns)
+    *    global scope, merge with includes
+    *  xsl:template (last, QName, pattern)
+    *
+    * (whitespace-only text-nodes have *not* been removed
+    *  yet; this will be done in xsltParseSequenceConstructor)
+    *
+    * Report misplaced child-nodes first.
+    */
+    cur = node->children;
+    while (cur != NULL) {
+       if (cur->type == XML_TEXT_NODE) {
+           xsltTransformError(NULL, style, cur,
+               "Misplaced text node (content: '%s').\n",
+               (cur->content != NULL) ? cur->content : BAD_CAST "");
+           style->errors++;
+       } else if (cur->type != XML_ELEMENT_NODE) {
+           xsltTransformError(NULL, style, cur, "Misplaced node.\n");
+           style->errors++;
+       }
+       cur = cur->next;
+    }
+    /*
+    * Skip xsl:import elements; they have been processed
+    * already.
+    */
+    cur = node->children;
+    while ((cur != NULL) && xsltParseFindTopLevelElem(cctxt, cur,
+           BAD_CAST "import", XSLT_NAMESPACE, 1, &cur) == 1)
+       cur = cur->next;
+    if (cur == NULL)
+       goto exit;
+
+    start = cur;
+    /*
+    * Process all top-level xsl:param elements.
+    */
+    while ((cur != NULL) &&
+       xsltParseFindTopLevelElem(cctxt, cur,
+       BAD_CAST "param", XSLT_NAMESPACE, 0, &cur) == 1)
+    {
+       xsltParseTopLevelXSLTElem(cctxt, cur, XSLT_FUNC_PARAM); 
+       cur = cur->next;
+    }  
+    /*
+    * Process all top-level xsl:variable elements.
+    */
+    cur = start;
+    while ((cur != NULL) &&
+       xsltParseFindTopLevelElem(cctxt, cur,
+       BAD_CAST "variable", XSLT_NAMESPACE, 0, &cur) == 1)
+    {
+       xsltParseTopLevelXSLTElem(cctxt, cur, XSLT_FUNC_VARIABLE);
+       cur = cur->next;
+    }   
+    /*
+    * Process all the rest of top-level elements.
+    */
+    cur = start;
+    while (cur != NULL) {      
+       /*
+       * Process element nodes.
+       */
+       if (cur->type == XML_ELEMENT_NODE) {        
+           if (cur->ns == NULL) {
+               xsltTransformError(NULL, style, cur,
+                   "Unexpected top-level element in no namespace.\n");
+               style->errors++;
+               cur = cur->next;
+               continue;
+           }
+           /*
+           * Process all XSLT elements.
+           */
+           if (IS_XSLT_ELEM_FAST(cur)) {
+               /*
+               * xsl:import is only allowed at the beginning.
+               */
+               if (IS_XSLT_NAME(cur, "import")) {
+                   xsltTransformError(NULL, style, cur,
+                       "Misplaced xsl:import element.\n");
+                   style->errors++;
+                   cur = cur->next;
+                   continue;
+               }
+               /* 
+               * TODO: Change the return type of the parsing functions
+               *  to int.
+               */
+               if (IS_XSLT_NAME(cur, "template")) {
+#ifdef WITH_XSLT_DEBUG_PARSING
+                   templates++;
+#endif
+                   /*
+                   * TODO: Is the position of xsl:template in the
+                   *  tree significant? If not it would be easier to
+                   *  parse them at a later stage.
+                   */
+                   xsltParseXSLTTemplate(cctxt, cur);
+               } else if (IS_XSLT_NAME(cur, "variable")) {
+                   /* NOP; done already */
+               } else if (IS_XSLT_NAME(cur, "param")) {
+                   /* NOP; done already */
+               } else if (IS_XSLT_NAME(cur, "include")) {                  
+                   if (cur->psvi != NULL)                  
+                       xsltParseXSLTStylesheetElemCore(cctxt, cur);
+                   else {
+                       xsltTransformError(NULL, style, cur,
+                           "Internal error: "
+                           "(xsltParseXSLTStylesheetElemCore) "
+                           "The xsl:include element was not compiled.\n");
+                       style->errors++;
+                   }
+               } else if (IS_XSLT_NAME(cur, "strip-space")) {
+                   /* No node info needed. */
+                   xsltParseStylesheetStripSpace(style, cur);
+               } else if (IS_XSLT_NAME(cur, "preserve-space")) {
+                   /* No node info needed. */
+                   xsltParseStylesheetPreserveSpace(style, cur);
+               } else if (IS_XSLT_NAME(cur, "output")) {
+                   /* No node-info needed. */
+                   xsltParseStylesheetOutput(style, cur);
+               } else if (IS_XSLT_NAME(cur, "key")) {
+                   /* TODO: node-info needed for expressions ? */
+                   xsltParseStylesheetKey(style, cur);
+               } else if (IS_XSLT_NAME(cur, "decimal-format")) {
+                   /* No node-info needed. */               
+                   xsltParseStylesheetDecimalFormat(style, cur);
+               } else if (IS_XSLT_NAME(cur, "attribute-set")) {                    
+                   xsltParseTopLevelXSLTElem(cctxt, cur,
+                       XSLT_FUNC_ATTRSET);             
+               } else if (IS_XSLT_NAME(cur, "namespace-alias")) {
+                   /* NOP; done already */                 
+               } else {
+                   if (cctxt->inode->forwardsCompat) {
+                       /*
+                       * Forwards-compatible mode:
+                       *
+                       * XSLT-1: "if it is a top-level element and
+                       *  XSLT 1.0 does not allow such elements as top-level
+                       *  elements, then the element must be ignored along
+                       *  with its content;"
+                       */
+                       /*
+                       * TODO: I don't think we should generate a warning.
+                       */
+                       xsltTransformError(NULL, style, cur,
+                           "Forwards-compatible mode: Ignoring unknown XSLT "
+                           "element '%s'.\n", cur->name);
+                       style->warnings++;
+                   } else {
+                       xsltTransformError(NULL, style, cur,
+                           "Unknown XSLT element '%s'.\n", cur->name);
+                       style->errors++;
+                   }
+               }
+           } else {
+               xsltTopLevelFunction function;
+
+               /*
+               * Process non-XSLT elements, which are in a
+               *  non-NULL namespace.
+               */
+               /*
+               * QUESTION: What does xsltExtModuleTopLevelLookup()
+               *  do exactly?
+               */
+               function = xsltExtModuleTopLevelLookup(cur->name,
+                   cur->ns->href);
+               if (function != NULL)
+                   function(style, cur);
+#ifdef WITH_XSLT_DEBUG_PARSING
+               xsltGenericDebug(xsltGenericDebugContext,
+                   "xsltParseXSLTStylesheetElemCore : User-defined "
+                   "data element '%s'.\n", cur->name);
+#endif
+           }
+       }
+       cur = cur->next;
+    }
+
+exit:
+
+#ifdef WITH_XSLT_DEBUG_PARSING
+    xsltGenericDebug(xsltGenericDebugContext,
+       "### END of parsing top-level elements of doc '%s'.\n",
+       node->doc->URL);
+    xsltGenericDebug(xsltGenericDebugContext,
+       "### Templates: %d\n", templates);
+#ifdef XSLT_REFACTORED
+    xsltGenericDebug(xsltGenericDebugContext,
+       "### Max inodes: %d\n", cctxt->maxNodeInfos);
+    xsltGenericDebug(xsltGenericDebugContext,
+       "### Max LREs  : %d\n", cctxt->maxLREs);
+#endif /* XSLT_REFACTORED */
+#endif /* WITH_XSLT_DEBUG_PARSING */
+
+    xsltCompilerNodePop(cctxt, node);
+    return(0);
+}
+
+/**
+ * xsltParseXSLTStylesheet:
+ * @cctxt: the compiler context
+ * @node: the xsl:stylesheet/xsl:transform element-node
+ *
+ * Parses the xsl:stylesheet and xsl:transform element. 
+ *
+ * <xsl:stylesheet
+ *  id = id
+ *  extension-element-prefixes = tokens
+ *  exclude-result-prefixes = tokens
+ *  version = number>
+ *  <!-- Content: (xsl:import*, top-level-elements) -->
+ * </xsl:stylesheet>
+ *
+ * BIG TODO: The xsl:include stuff.
+ * 
+ * Called by xsltParseStylesheetTree()
+ *
+ * Returns 0 on success, a positive result on errors and
+ *         -1 on API or internal errors.
+ */
+static int
+xsltParseXSLTStylesheetElem(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
+{
+    xmlNodePtr cur, start;
+
+    if ((cctxt == NULL) || (node == NULL))
+       return(-1);
+    
+    if (node->children == NULL)
+       goto exit;
+
+    /*
+    * Process top-level elements:
+    *  xsl:import (must be first)
+    *  xsl:include (this is just a pre-processing)
+    */
+    cur = node->children;
+    /*
+    * Process xsl:import elements.
+    * XSLT 1.0: "The xsl:import element children must precede all
+    *  other element children of an xsl:stylesheet element,
+    *  including any xsl:include element children."
+    */    
+    while ((cur != NULL) &&
+       xsltParseFindTopLevelElem(cctxt, cur,
+           BAD_CAST "import", XSLT_NAMESPACE, 1, &cur) == 1)
+    {
+       if (xsltParseStylesheetImport(cctxt->style, cur) != 0) {
+           cctxt->style->errors++;
+       }
+       cur = cur->next;
+    }
+    if (cur == NULL)
+       goto exit;
+    start = cur;
+    /*
+    * Pre-process all xsl:include elements.
+    */
+    cur = start;
+    while ((cur != NULL) &&
+       xsltParseFindTopLevelElem(cctxt, cur,
+           BAD_CAST "include", XSLT_NAMESPACE, 0, &cur) == 1)
+    {
+       xsltParseTopLevelXSLTElem(cctxt, cur, XSLT_FUNC_INCLUDE);
+       cur = cur->next;
+    }
+    /*
+    * Pre-process all xsl:namespace-alias elements.
+    * URGENT TODO: This won't work correctly: the order of included
+    *  aliases and aliases defined here is significant.
+    */
+    cur = start;
+    while ((cur != NULL) &&
+       xsltParseFindTopLevelElem(cctxt, cur,
+           BAD_CAST "namespace-alias", XSLT_NAMESPACE, 0, &cur) == 1)
+    {
+       xsltNamespaceAlias(cctxt->style, cur);
+       cur = cur->next;
+    }
+
+    if (cctxt->isInclude) {
+       /*
+       * If this stylesheet is intended for inclusion, then
+       * we will process only imports and includes. 
+       */
+       goto exit;
+    } 
+    /*
+    * Now parse the rest of the top-level elements.
+    */
+    xsltParseXSLTStylesheetElemCore(cctxt, node);      
+exit:
+
+    return(0);
+}
+
+#else /* XSLT_REFACTORED */
+
+/**
+ * xsltParseStylesheetTop:
+ * @style:  the XSLT stylesheet
+ * @top:  the top level "stylesheet" or "transform" element
+ *
+ * scan the top level elements of an XSL stylesheet
+ */
+static void
+xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
+    xmlNodePtr cur;
+    xmlChar *prop;
+#ifdef WITH_XSLT_DEBUG_PARSING
+    int templates = 0;
+#endif
+
+    if (top == NULL)
+       return;
+
+    prop = xmlGetNsProp(top, (const xmlChar *)"version", NULL);
+    if (prop == NULL) {
+       xsltTransformError(NULL, style, top,
+           "xsl:version is missing: document may not be a stylesheet\n");
+       if (style != NULL) style->warnings++;
+    } else {
+       if ((!xmlStrEqual(prop, (const xmlChar *)"1.0")) &&
+            (!xmlStrEqual(prop, (const xmlChar *)"1.1"))) {
+           xsltTransformError(NULL, style, top,
+               "xsl:version: only 1.0 features are supported\n");
+            /* TODO set up compatibility when not XSLT 1.0 */
+           if (style != NULL) style->warnings++;
+       }
+       xmlFree(prop);
+    }
+
+    /*
+     * process xsl:import elements
+     */
+    cur = top->children;
+    while (cur != NULL) {
+           if (IS_BLANK_NODE(cur)) {
+                   cur = cur->next;
+                   continue;
+           }
+           if (IS_XSLT_ELEM(cur) && IS_XSLT_NAME(cur, "import")) {
+                   if (xsltParseStylesheetImport(style, cur) != 0)
+                           if (style != NULL) style->errors++;
+           } else
+                   break;
+           cur = cur->next;
+    }
+
+    /*
+     * process other top-level elements
+     */
+    while (cur != NULL) {
+       if (IS_BLANK_NODE(cur)) {
+           cur = cur->next;
+           continue;
+       }
+       if (cur->type == XML_TEXT_NODE) {
+           if (cur->content != NULL) {
+               xsltTransformError(NULL, style, cur,
+                   "misplaced text node: '%s'\n", cur->content);
+           }
+           if (style != NULL) style->errors++;
+            cur = cur->next;
+           continue;
+       }
+       if ((cur->type == XML_ELEMENT_NODE) && (cur->ns == NULL)) {
+           xsltGenericError(xsltGenericErrorContext,
+                    "Found a top-level element %s with null namespace URI\n",
+                    cur->name);
+           if (style != NULL) style->errors++;
+           cur = cur->next;
+           continue;
+       }
+       if ((cur->type == XML_ELEMENT_NODE) && (!(IS_XSLT_ELEM(cur)))) {
+           xsltTopLevelFunction function;
+
+           function = xsltExtModuleTopLevelLookup(cur->name,
+                                                  cur->ns->href);
+           if (function != NULL)
+               function(style, cur);
+
+#ifdef WITH_XSLT_DEBUG_PARSING
+           xsltGenericDebug(xsltGenericDebugContext,
+                   "xsltParseStylesheetTop : found foreign element %s\n",
+                   cur->name);
+#endif
+            cur = cur->next;
+           continue;
+       }
+       if (IS_XSLT_NAME(cur, "import")) {
+           xsltTransformError(NULL, style, cur,
+                       "xsltParseStylesheetTop: ignoring misplaced import element\n");
+           if (style != NULL) style->errors++;
+    } else if (IS_XSLT_NAME(cur, "include")) {
+           if (xsltParseStylesheetInclude(style, cur) != 0)
+               if (style != NULL) style->errors++;
+    } else if (IS_XSLT_NAME(cur, "strip-space")) {
+           xsltParseStylesheetStripSpace(style, cur);
+    } else if (IS_XSLT_NAME(cur, "preserve-space")) {
+           xsltParseStylesheetPreserveSpace(style, cur);
+    } else if (IS_XSLT_NAME(cur, "output")) {
+           xsltParseStylesheetOutput(style, cur);
+    } else if (IS_XSLT_NAME(cur, "key")) {
+           xsltParseStylesheetKey(style, cur);
+    } else if (IS_XSLT_NAME(cur, "decimal-format")) {
+           xsltParseStylesheetDecimalFormat(style, cur);
+    } else if (IS_XSLT_NAME(cur, "attribute-set")) {
+           xsltParseStylesheetAttributeSet(style, cur);
+    } else if (IS_XSLT_NAME(cur, "variable")) {
+           xsltParseGlobalVariable(style, cur);
+    } else if (IS_XSLT_NAME(cur, "param")) {
+           xsltParseGlobalParam(style, cur);
+    } else if (IS_XSLT_NAME(cur, "template")) {
+#ifdef WITH_XSLT_DEBUG_PARSING
+           templates++;
+#endif
+           xsltParseStylesheetTemplate(style, cur);
+    } else if (IS_XSLT_NAME(cur, "namespace-alias")) {
+           xsltNamespaceAlias(style, cur);
+       } else {
+           /*
+           * BUG TODO: The version of the *doc* is irrelevant for
+           *  the forwards-compatible mode.
+           */
+            if ((style != NULL) && (style->doc->version != NULL) &&
+               (!strncmp((const char *) style->doc->version, "1.0", 3))) {
+               xsltTransformError(NULL, style, cur,
+                       "xsltParseStylesheetTop: unknown %s element\n",
+                       cur->name);
+               if (style != NULL) style->errors++;
+           }
+           else {
+                /* do Forwards-Compatible Processing */
+               xsltTransformError(NULL, style, cur,
+                       "xsltParseStylesheetTop: ignoring unknown %s element\n",
+                       cur->name);
+               if (style != NULL) style->warnings++;
+            }
+       }
+       cur = cur->next;
+    }
+#ifdef WITH_XSLT_DEBUG_PARSING
+    xsltGenericDebug(xsltGenericDebugContext,
+                   "parsed %d templates\n", templates);
+#endif
+}
+
+#endif /* else of XSLT_REFACTORED */
+
+#ifdef XSLT_REFACTORED
+/**
+ * xsltParseSimplifiedStylesheetTree:
+ *
+ * @style: the stylesheet (TODO: Change this to the compiler context)
+ * @doc: the document containing the stylesheet.
+ * @node: the node where the stylesheet is rooted at
+ *
+ * Returns 0 in case of success, a positive result if an error occurred
+ *         and -1 on API and internal errors.
+ */
+static int
+xsltParseSimplifiedStylesheetTree(xsltCompilerCtxtPtr cctxt,
+                                 xmlDocPtr doc,
+                                 xmlNodePtr node)
+{
+    xsltTemplatePtr templ;
+    
+    if ((cctxt == NULL) || (node == NULL))
+       return(-1);
+
+    if (xsltParseAttrXSLTVersion(cctxt, node, 0) == XSLT_ELEMENT_CATEGORY_LRE)
+    {
+       /*
+       * TODO: Adjust report, since this might be an
+       * embedded stylesheet.
+       */
+       xsltTransformError(NULL, cctxt->style, node,
+           "The attribute 'xsl:version' is missing; cannot identify "
+           "this document as an XSLT stylesheet document.\n");
+       cctxt->style->errors++;
+       return(1);
+    }
+    
+#ifdef WITH_XSLT_DEBUG_PARSING
+    xsltGenericDebug(xsltGenericDebugContext,
+       "xsltParseSimplifiedStylesheetTree: document is stylesheet\n");
+#endif        
+    
+    /*
+    * Create and link the template
+    */
+    templ = xsltNewTemplate();
+    if (templ == NULL) {
+       return(-1);
+    }
+    templ->next = cctxt->style->templates;
+    cctxt->style->templates = templ;
+    templ->match = xmlStrdup(BAD_CAST "/");
+
+    /*
+    * Note that we push the document-node in this special case.
+    */
+    xsltCompilerNodePush(cctxt, (xmlNodePtr) doc);
+    /*
+    * In every case, we need to have
+    * the in-scope namespaces of the element, where the
+    * stylesheet is rooted at, regardless if it's an XSLT
+    * instruction or a literal result instruction (or if
+    * this is an embedded stylesheet).
+    */
+    cctxt->inode->inScopeNs =
+       xsltCompilerBuildInScopeNsList(cctxt, node);
+    /*
+    * Parse the content and register the match-pattern.
+    */
+    xsltParseSequenceConstructor(cctxt, node);
+    xsltCompilerNodePop(cctxt, (xmlNodePtr) doc);
+
+    templ->elem = (xmlNodePtr) doc;
+    templ->content = node;
+    xsltAddTemplate(cctxt->style, templ, NULL, NULL);
+    cctxt->style->literal_result = 1;
+    return(0);
+}
+
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+int
+xsltRestoreDocumentNamespaces(xsltNsMapPtr ns, xmlDocPtr doc)
+{
+    if (doc == NULL)
+       return(-1);
+    /*
+    * Revert the changes we have applied to the namespace-URIs of
+    * ns-decls.
+    */    
+    while (ns != NULL) {
+       if ((ns->doc == doc) && (ns->ns != NULL)) {
+           ns->ns->href = ns->origNsName;
+           ns->origNsName = NULL;
+           ns->ns = NULL;          
+       }
+       ns = ns->next;
+    }
+    return(0);
+}
+#endif /* XSLT_REFACTORED_XSLT_NSCOMP */
+
+/**
+ * xsltParseStylesheetProcess:
+ * @style:  the XSLT stylesheet (the current stylesheet-level)
+ * @doc:  and xmlDoc parsed XML
+ *
+ * Parses an XSLT stylesheet, adding the associated structures.
+ * Called by:
+ *  xsltParseStylesheetImportedDoc() (xslt.c)
+ *  xsltParseStylesheetInclude() (imports.c)
+ *
+ * Returns the value of the @style parameter if everything
+ * went right, NULL if something went amiss.
+ */
+xsltStylesheetPtr
+xsltParseStylesheetProcess(xsltStylesheetPtr style, xmlDocPtr doc)
+{
+    xsltCompilerCtxtPtr cctxt;
+    xmlNodePtr cur;
+    int oldIsSimplifiedStylesheet;
+
+
+    if ((style == NULL) || (doc == NULL))
+       return(NULL);
+
+    cctxt = XSLT_CCTXT(style);
+
+    cur = xmlDocGetRootElement(doc);
+    if (cur == NULL) {
+       xsltTransformError(NULL, style, (xmlNodePtr) doc,
+               "xsltParseStylesheetProcess : empty stylesheet\n");
+       return(NULL);
+    }
+    oldIsSimplifiedStylesheet = cctxt->simplified;
+
+    if ((IS_XSLT_ELEM(cur)) && 
+       ((IS_XSLT_NAME(cur, "stylesheet")) ||
+        (IS_XSLT_NAME(cur, "transform")))) {   
+#ifdef WITH_XSLT_DEBUG_PARSING
+       xsltGenericDebug(xsltGenericDebugContext,
+               "xsltParseStylesheetProcess : found stylesheet\n");
+#endif
+       cctxt->simplified = 0;
+       style->literal_result = 0;
+    } else {
+       cctxt->simplified = 1;
+       style->literal_result = 1;
+    }
+    /*
+    * Pre-process the stylesheet if not already done before.
+    *  This will remove PIs and comments, merge adjacent
+    *  text nodes, internalize strings, etc.
+    */
+    if (! style->nopreproc)
+       xsltParsePreprocessStylesheetTree(cctxt, cur);
+    /*
+    * Parse and compile the stylesheet.
+    */
+    if (style->literal_result == 0) {
+       if (xsltParseXSLTStylesheetElem(cctxt, cur) != 0)
+           return(NULL);
+    } else {
+       if (xsltParseSimplifiedStylesheetTree(cctxt, doc, cur) != 0)
+           return(NULL);
+    }    
+
+    cctxt->simplified = oldIsSimplifiedStylesheet;
+
+    return(style);
+}
+
+#else /* XSLT_REFACTORED */
+
+xsltStylesheetPtr
+xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) {
+    xmlNodePtr cur;
+
+    if (doc == NULL)
+       return(NULL);
+    if (ret == NULL)
+       return(ret);
+    
+    /*
+     * First steps, remove blank nodes,
+     * locate the xsl:stylesheet element and the
+     * namespace declaration.
+     */
+    cur = xmlDocGetRootElement(doc);
+    if (cur == NULL) {
+       xsltTransformError(NULL, ret, (xmlNodePtr) doc,
+               "xsltParseStylesheetProcess : empty stylesheet\n");
+       return(NULL);
+    }
+
+    if ((IS_XSLT_ELEM(cur)) && 
+       ((IS_XSLT_NAME(cur, "stylesheet")) ||
+        (IS_XSLT_NAME(cur, "transform")))) {   
+#ifdef WITH_XSLT_DEBUG_PARSING
+       xsltGenericDebug(xsltGenericDebugContext,
+               "xsltParseStylesheetProcess : found stylesheet\n");
+#endif
+       ret->literal_result = 0;
+       xsltParseStylesheetExcludePrefix(ret, cur, 1);
+       xsltParseStylesheetExtPrefix(ret, cur, 1);
+    } else {
+       xsltParseStylesheetExcludePrefix(ret, cur, 0);
+       xsltParseStylesheetExtPrefix(ret, cur, 0);
+       ret->literal_result = 1;
+    }
+    if (!ret->nopreproc) {
+       xsltPrecomputeStylesheet(ret, cur);
+    }
+    if (ret->literal_result == 0) {
+       xsltParseStylesheetTop(ret, cur);
+    } else {
+       xmlChar *prop;
+       xsltTemplatePtr template;
+
+       /*
+        * the document itself might be the template, check xsl:version
+        */
+       prop = xmlGetNsProp(cur, (const xmlChar *)"version", XSLT_NAMESPACE);
+       if (prop == NULL) {
+           xsltTransformError(NULL, ret, cur,
+               "xsltParseStylesheetProcess : document is not a stylesheet\n");
+           return(NULL);
+       }
+
+#ifdef WITH_XSLT_DEBUG_PARSING
+        xsltGenericDebug(xsltGenericDebugContext,
+               "xsltParseStylesheetProcess : document is stylesheet\n");
+#endif
+       
+       if (!xmlStrEqual(prop, (const xmlChar *)"1.0")) {
+           xsltTransformError(NULL, ret, cur,
+               "xsl:version: only 1.0 features are supported\n");
+            /* TODO set up compatibility when not XSLT 1.0 */
+           ret->warnings++;
+       }
+       xmlFree(prop);
+
+       /*
+        * Create and link the template
+        */
+       template = xsltNewTemplate();
+       if (template == NULL) {
+           return(NULL);
+       }
+       template->next = ret->templates;
+       ret->templates = template;
+       template->match = xmlStrdup((const xmlChar *)"/");
+
+       /*
+        * parse the content and register the pattern
+        */
+       xsltParseTemplateContent(ret, (xmlNodePtr) doc);
+       template->elem = (xmlNodePtr) doc;
+       template->content = doc->children;
+       xsltAddTemplate(ret, template, NULL, NULL);
+       ret->literal_result = 1;        
+    }
+
+    return(ret);
+}
+
+#endif /* else of XSLT_REFACTORED */
+
+/**
+ * xsltParseStylesheetImportedDoc:
+ * @doc:  an xmlDoc parsed XML
+ * @parentStyle: pointer to the parent stylesheet (if it exists)
+ *
+ * parse an XSLT stylesheet building the associated structures
+ * except the processing not needed for imported documents.
+ *
+ * Returns a new XSLT stylesheet structure.
+ */
+
+xsltStylesheetPtr
+xsltParseStylesheetImportedDoc(xmlDocPtr doc,
+                              xsltStylesheetPtr parentStyle) {
+    xsltStylesheetPtr retStyle;
+
+    if (doc == NULL)
+       return(NULL);
+
+    retStyle = xsltNewStylesheet();
+    if (retStyle == NULL)
+       return(NULL);
+    /*
+    * Set the importing stylesheet module; also used to detect recursion.
+    */
+    retStyle->parent = parentStyle;
+    /*
+    * Adjust the string dict.
+    */
+    if (doc->dict != NULL) {
+        xmlDictFree(retStyle->dict);
+       retStyle->dict = doc->dict;
+#ifdef WITH_XSLT_DEBUG
+        xsltGenericDebug(xsltGenericDebugContext,
+           "reusing dictionary from %s for stylesheet\n",
+           doc->URL);
+#endif
+       xmlDictReference(retStyle->dict);
+    }          
+    
+    /*
+    * TODO: Eliminate xsltGatherNamespaces(); we must not restrict
+    *  the stylesheet to containt distinct namespace prefixes.
+    */
+    xsltGatherNamespaces(retStyle);
+
+#ifdef XSLT_REFACTORED
+    {
+       xsltCompilerCtxtPtr cctxt;
+       xsltStylesheetPtr oldCurSheet;
+           
+       if (parentStyle == NULL) {
+           xsltPrincipalStylesheetDataPtr principalData;
+           /*
+           * Principal stylesheet
+           * --------------------
+           */
+           retStyle->principal = retStyle;
+           /*
+           * Create extra data for the principal stylesheet.
+           */
+           principalData = xsltNewPrincipalStylesheetData();
+           if (principalData == NULL) {
+               xsltFreeStylesheet(retStyle);
+               return(NULL);
+           }
+           retStyle->principalData = principalData;
+           /*
+           * Create the compilation context
+           * ------------------------------
+           * (only once; for the principal stylesheet).
+           * This is currently the only function where the
+           * compilation context is created.
+           */
+           cctxt = xsltCompilationCtxtCreate(retStyle);
+           if (cctxt == NULL) {
+               xsltFreeStylesheet(retStyle);
+               return(NULL);
+           }               
+           retStyle->compCtxt = (void *) cctxt;
+           cctxt->style = retStyle;
+           cctxt->dict = retStyle->dict;
+           cctxt->psData = principalData;
+           /*
+           * Push initial dummy node info.
+           */
+           cctxt->depth = -1;
+           xsltCompilerNodePush(cctxt, (xmlNodePtr) doc);
+       } else {
+           /*
+           * Imported stylesheet.
+           */
+           retStyle->principal = parentStyle->principal;
+           cctxt = parentStyle->compCtxt;
+           retStyle->compCtxt = cctxt;
+       }
+       /*
+       * Save the old and set the current stylesheet structure in the
+       * compilation context.
+       */
+       oldCurSheet = cctxt->style;
+       cctxt->style = retStyle;
+       
+       retStyle->doc = doc;
+       xsltParseStylesheetProcess(retStyle, doc);
+       
+       cctxt->style = oldCurSheet;
+       if (parentStyle == NULL) {
+           /*
+           * Pop the initial dummy node info.
+           */
+           xsltCompilerNodePop(cctxt, (xmlNodePtr) doc);
+       } else {
+           /*
+           * Clear the compilation context of imported
+           * stylesheets.
+           * TODO: really?
+           */
+           /* retStyle->compCtxt = NULL; */
+       }
+       /*
+       * Free the stylesheet if there were errors.
+       */
+       if (retStyle != NULL) {
+           if (retStyle->errors != 0) {
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+               /*
+               * Restore all changes made to namespace URIs of ns-decls.
+               */
+               if (cctxt->psData->nsMap)               
+                   xsltRestoreDocumentNamespaces(cctxt->psData->nsMap, doc);
+#endif
+               /*
+               * Detach the doc from the stylesheet; otherwise the doc
+               * will be freed in xsltFreeStylesheet().
+               */
+               retStyle->doc = NULL;
+               /*
+               * Cleanup the doc if its the main stylesheet.
+               */
+               if (parentStyle == NULL) {
+                   xsltCleanupStylesheetTree(doc, xmlDocGetRootElement(doc));
+                   if (retStyle->compCtxt != NULL) {                   
+                       xsltCompilationCtxtFree(retStyle->compCtxt);
+                       retStyle->compCtxt = NULL;
+                   }
+               }
+
+               xsltFreeStylesheet(retStyle);
+               retStyle = NULL;
+           }
+       }
+    }
+        
+#else /* XSLT_REFACTORED */
+    /*
+    * Old behaviour.
+    */
+    retStyle->doc = doc;
+    if (xsltParseStylesheetProcess(retStyle, doc) == NULL) {
+               retStyle->doc = NULL;
+               xsltFreeStylesheet(retStyle);
+               retStyle = NULL;
+    }
+    if (retStyle != NULL) {
+       if (retStyle->errors != 0) {
+           retStyle->doc = NULL;
+           if (parentStyle == NULL)
+               xsltCleanupStylesheetTree(doc,
+                   xmlDocGetRootElement(doc));
+           xsltFreeStylesheet(retStyle);
+           retStyle = NULL;
+       }
+    }
+#endif /* else of XSLT_REFACTORED */
+        
+    return(retStyle);
+}
+
+/**
+ * xsltParseStylesheetDoc:
+ * @doc:  and xmlDoc parsed XML
+ *
+ * parse an XSLT stylesheet, building the associated structures.  doc
+ * is kept as a reference within the returned stylesheet, so changes
+ * to doc after the parsing will be reflected when the stylesheet
+ * is applied, and the doc is automatically freed when the
+ * stylesheet is closed.
+ *
+ * Returns a new XSLT stylesheet structure.
+ */
+
+xsltStylesheetPtr
+xsltParseStylesheetDoc(xmlDocPtr doc) {
+    xsltStylesheetPtr ret;
+
+    ret = xsltParseStylesheetImportedDoc(doc, NULL);
+    if (ret == NULL)
+       return(NULL);
+
+    xsltResolveStylesheetAttributeSet(ret);
+#ifdef XSLT_REFACTORED
+    /*
+    * Free the compilation context.
+    * TODO: Check if it's better to move this cleanup to
+    *   xsltParseStylesheetImportedDoc().
+    */
+    if (ret->compCtxt != NULL) {
+       xsltCompilationCtxtFree(XSLT_CCTXT(ret));
+       ret->compCtxt = NULL;
+    }
+#endif
+    return(ret);
+}
+
+/**
+ * xsltParseStylesheetFile:
+ * @filename:  the filename/URL to the stylesheet
+ *
+ * Load and parse an XSLT stylesheet
+ *
+ * Returns a new XSLT stylesheet structure.
+ */
+
+xsltStylesheetPtr
+xsltParseStylesheetFile(const xmlChar* filename) {
+    xsltSecurityPrefsPtr sec;
+    xsltStylesheetPtr ret;
+    xmlDocPtr doc;
+    
+
+    if (filename == NULL)
+       return(NULL);
+
+#ifdef WITH_XSLT_DEBUG_PARSING
+    xsltGenericDebug(xsltGenericDebugContext,
+           "xsltParseStylesheetFile : parse %s\n", filename);
+#endif
+
+    /*
+     * Security framework check
+     */
+    sec = xsltGetDefaultSecurityPrefs();
+    if (sec != NULL) {
+       int res;
+
+       res = xsltCheckRead(sec, NULL, filename);
+       if (res == 0) {
+           xsltTransformError(NULL, NULL, NULL,
+                "xsltParseStylesheetFile: read rights for %s denied\n",
+                            filename);
+           return(NULL);
+       }
+    }
+
+    doc = xsltDocDefaultLoader(filename, NULL, XSLT_PARSE_OPTIONS,
+                               NULL, XSLT_LOAD_START);
+    if (doc == NULL) {
+       xsltTransformError(NULL, NULL, NULL,
+               "xsltParseStylesheetFile : cannot parse %s\n", filename);
+       return(NULL);
+    }
+    ret = xsltParseStylesheetDoc(doc);
+    if (ret == NULL) {
+       xmlFreeDoc(doc);
+       return(NULL);
+    }
+
+    return(ret);
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     Handling of Stylesheet PI                       *
+ *                                                                     *
+ ************************************************************************/
+
+#define CUR (*cur)
+#define SKIP(val) cur += (val)
+#define NXT(val) cur[(val)]
+#define SKIP_BLANKS                                            \
+    while (IS_BLANK(CUR)) NEXT
+#define NEXT ((*cur) ?  cur++ : cur)
+
+/**
+ * xsltParseStylesheetPI:
+ * @value: the value of the PI
+ *
+ * This function checks that the type is text/xml and extracts
+ * the URI-Reference for the stylesheet
+ *
+ * Returns the URI-Reference for the stylesheet or NULL (it need to
+ *         be freed by the caller)
+ */
+static xmlChar *
+xsltParseStylesheetPI(const xmlChar *value) {
+    const xmlChar *cur;
+    const xmlChar *start;
+    xmlChar *val;
+    xmlChar tmp;
+    xmlChar *href = NULL;
+    int isXml = 0;
+
+    if (value == NULL)
+       return(NULL);
+
+    cur = value;
+    while (CUR != 0) {
+       SKIP_BLANKS;
+       if ((CUR == 't') && (NXT(1) == 'y') && (NXT(2) == 'p') &&
+           (NXT(3) == 'e')) {
+           SKIP(4);
+           SKIP_BLANKS;
+           if (CUR != '=')
+               continue;
+           NEXT;
+           if ((CUR != '\'') && (CUR != '"'))
+               continue;
+           tmp = CUR;
+           NEXT;
+           start = cur;
+           while ((CUR != 0) && (CUR != tmp))
+               NEXT;
+           if (CUR != tmp)
+               continue;
+           val = xmlStrndup(start, cur - start);
+           NEXT;
+           if (val == NULL) 
+               return(NULL);
+           if ((xmlStrcasecmp(val, BAD_CAST "text/xml")) &&
+               (xmlStrcasecmp(val, BAD_CAST "text/xsl"))) {
+                xmlFree(val);
+               break;
+           }
+           isXml = 1;
+           xmlFree(val);
+       } else if ((CUR == 'h') && (NXT(1) == 'r') && (NXT(2) == 'e') &&
+           (NXT(3) == 'f')) {
+           SKIP(4);
+           SKIP_BLANKS;
+           if (CUR != '=')
+               continue;
+           NEXT;
+           if ((CUR != '\'') && (CUR != '"'))
+               continue;
+           tmp = CUR;
+           NEXT;
+           start = cur;
+           while ((CUR != 0) && (CUR != tmp))
+               NEXT;
+           if (CUR != tmp)
+               continue;
+           if (href == NULL)
+               href = xmlStrndup(start, cur - start);
+           NEXT;
+       } else {
+           while ((CUR != 0) && (!IS_BLANK(CUR)))
+               NEXT;
+       }
+            
+    }
+
+    if (!isXml) {
+       if (href != NULL)
+           xmlFree(href);
+       href = NULL;
+    }
+    return(href);
+}
+
+/**
+ * xsltLoadStylesheetPI:
+ * @doc:  a document to process
+ *
+ * This function tries to locate the stylesheet PI in the given document
+ * If found, and if contained within the document, it will extract 
+ * that subtree to build the stylesheet to process @doc (doc itself will
+ * be modified). If found but referencing an external document it will
+ * attempt to load it and generate a stylesheet from it. In both cases,
+ * the resulting stylesheet and the document need to be freed once the
+ * transformation is done.
+ *
+ * Returns a new XSLT stylesheet structure or NULL if not found.
+ */
+xsltStylesheetPtr
+xsltLoadStylesheetPI(xmlDocPtr doc) {
+    xmlNodePtr child;
+    xsltStylesheetPtr ret = NULL;
+    xmlChar *href = NULL;
+    xmlURIPtr URI;
+
+    if (doc == NULL)
+       return(NULL);
+
+    /*
+     * Find the text/xml stylesheet PI id any before the root
+     */
+    child = doc->children;
+    while ((child != NULL) && (child->type != XML_ELEMENT_NODE)) {
+       if ((child->type == XML_PI_NODE) &&
+           (xmlStrEqual(child->name, BAD_CAST "xml-stylesheet"))) {
+           href = xsltParseStylesheetPI(child->content);
+           if (href != NULL)
+               break;
+       }
+       child = child->next;
+    }
+
+    /*
+     * If found check the href to select processing
+     */
+    if (href != NULL) {
+#ifdef WITH_XSLT_DEBUG_PARSING
+       xsltGenericDebug(xsltGenericDebugContext,
+               "xsltLoadStylesheetPI : found PI href=%s\n", href);
+#endif
+       URI = xmlParseURI((const char *) href);
+       if (URI == NULL) {
+           xsltTransformError(NULL, NULL, child,
+                   "xml-stylesheet : href %s is not valid\n", href);
+           xmlFree(href);
+           return(NULL);
+       }
+       if ((URI->fragment != NULL) && (URI->scheme == NULL) &&
+            (URI->opaque == NULL) && (URI->authority == NULL) &&
+            (URI->server == NULL) && (URI->user == NULL) &&
+            (URI->path == NULL) && (URI->query == NULL)) {
+           xmlAttrPtr ID;
+
+#ifdef WITH_XSLT_DEBUG_PARSING
+           xsltGenericDebug(xsltGenericDebugContext,
+                   "xsltLoadStylesheetPI : Reference to ID %s\n", href);
+#endif
+           if (URI->fragment[0] == '#')
+               ID = xmlGetID(doc, (const xmlChar *) &(URI->fragment[1]));
+           else
+               ID = xmlGetID(doc, (const xmlChar *) URI->fragment);
+           if (ID == NULL) {
+               xsltTransformError(NULL, NULL, child,
+                   "xml-stylesheet : no ID %s found\n", URI->fragment);
+           } else {
+               xmlDocPtr fake;
+               xmlNodePtr subtree;
+
+               /*
+                * move the subtree in a new document passed to
+                * the stylesheet analyzer
+                */
+               subtree = ID->parent;
+               fake = xmlNewDoc(NULL);
+               if (fake != NULL) {
+                    /*
+                    * the dictionary should be shared since nodes are
+                    * moved over.
+                    */
+                   fake->dict = doc->dict;
+                   xmlDictReference(doc->dict);
+#ifdef WITH_XSLT_DEBUG
+                   xsltGenericDebug(xsltGenericDebugContext,
+                         "reusing dictionary from %s for stylesheet\n",
+                        doc->URL);
+#endif
+
+                   xmlUnlinkNode(subtree);
+                   xmlAddChild((xmlNodePtr) fake, subtree);
+                   ret = xsltParseStylesheetDoc(fake);
+                   if (ret == NULL)
+                       xmlFreeDoc(fake);
+               }
+           }
+       } else {
+           xmlChar *URL, *base;
+
+           /*
+            * Reference to an external stylesheet
+            */
+
+           base = xmlNodeGetBase(doc, (xmlNodePtr) doc);
+           URL = xmlBuildURI(href, base);
+           if (URL != NULL) {
+#ifdef WITH_XSLT_DEBUG_PARSING
+               xsltGenericDebug(xsltGenericDebugContext,
+                       "xsltLoadStylesheetPI : fetching %s\n", URL);
+#endif
+               ret = xsltParseStylesheetFile(URL);
+               xmlFree(URL);
+           } else {
+#ifdef WITH_XSLT_DEBUG_PARSING
+               xsltGenericDebug(xsltGenericDebugContext,
+                       "xsltLoadStylesheetPI : fetching %s\n", href);
+#endif
+               ret = xsltParseStylesheetFile(href);
+           }
+           if (base != NULL)
+               xmlFree(base);
+       }
+       xmlFreeURI(URI);
+       xmlFree(href);
+    }
+    return(ret);
+}
diff --git a/reactos/dll/3rdparty/libxslt/xslt.h b/reactos/dll/3rdparty/libxslt/xslt.h
new file mode 100644 (file)
index 0000000..849b03c
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Summary: Interfaces, constants and types related to the XSLT engine
+ * Description: Interfaces, constants and types related to the XSLT engine
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_H__
+#define __XML_XSLT_H__
+
+#include <libxml/tree.h>
+#include "xsltexports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * XSLT_DEFAULT_VERSION:
+ *
+ * The default version of XSLT supported.
+ */
+#define XSLT_DEFAULT_VERSION     "1.0"
+
+/**
+ * XSLT_DEFAULT_VENDOR:
+ *
+ * The XSLT "vendor" string for this processor.
+ */
+#define XSLT_DEFAULT_VENDOR      "libxslt"
+
+/**
+ * XSLT_DEFAULT_URL:
+ *
+ * The XSLT "vendor" URL for this processor.
+ */
+#define XSLT_DEFAULT_URL         "http://xmlsoft.org/XSLT/"
+
+/**
+ * XSLT_NAMESPACE:
+ *
+ * The XSLT specification namespace.
+ */
+#define XSLT_NAMESPACE ((xmlChar *) "http://www.w3.org/1999/XSL/Transform")
+
+/**
+ * XSLT_PARSE_OPTIONS:
+ *
+ * The set of options to pass to an xmlReadxxx when loading files for
+ * XSLT consumption.
+ */
+#define XSLT_PARSE_OPTIONS \
+ XML_PARSE_NOENT | XML_PARSE_DTDLOAD | XML_PARSE_DTDATTR | XML_PARSE_NOCDATA
+
+/**
+ * xsltMaxDepth:
+ *
+ * This value is used to detect templates loops.
+ */
+XSLTPUBVAR int xsltMaxDepth;
+
+/**
+ * xsltEngineVersion:
+ *
+ * The version string for libxslt.
+ */
+XSLTPUBVAR const char *xsltEngineVersion;
+
+/**
+ * xsltLibxsltVersion:
+ *
+ * The version of libxslt compiled.
+ */
+XSLTPUBVAR const int xsltLibxsltVersion;
+
+/**
+ * xsltLibxmlVersion:
+ *
+ * The version of libxml libxslt was compiled against.
+ */
+XSLTPUBVAR const int xsltLibxmlVersion;
+
+/*
+ * Global initialization function.
+ */
+
+XSLTPUBFUN void XSLTCALL
+               xsltInit                (void);
+
+/*
+ * Global cleanup function.
+ */
+XSLTPUBFUN void XSLTCALL       
+               xsltCleanupGlobals      (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/xsltInternals.h b/reactos/dll/3rdparty/libxslt/xsltInternals.h
new file mode 100644 (file)
index 0000000..f176264
--- /dev/null
@@ -0,0 +1,1970 @@
+/*
+ * Summary: internal data structures, constants and functions
+ * Description: Internal data structures, constants and functions used
+ *              by the XSLT engine. 
+ *              They are not part of the API or ABI, i.e. they can change
+ *              without prior notice, use carefully.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_INTERNALS_H__
+#define __XML_XSLT_INTERNALS_H__
+
+#include <libxml/tree.h>
+#include <libxml/hash.h>
+#include <libxml/xpath.h>
+#include <libxml/xmlerror.h>
+#include <libxml/dict.h>
+#include <libxml/xmlstring.h>
+#include <libxslt/xslt.h>
+#include "xsltexports.h"
+#include "numbersInternals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* #define XSLT_DEBUG_PROFILE_CACHE */
+
+/**
+ * XSLT_IS_TEXT_NODE:
+ *
+ * check if the argument is a text node
+ */
+#define XSLT_IS_TEXT_NODE(n) ((n != NULL) && \
+    (((n)->type == XML_TEXT_NODE) || \
+     ((n)->type == XML_CDATA_SECTION_NODE)))
+
+
+/**
+ * XSLT_MARK_RES_TREE_FRAG:
+ *
+ * internal macro to set up tree fragments
+ */
+#define XSLT_MARK_RES_TREE_FRAG(n) \
+    (n)->name = (char *) xmlStrdup(BAD_CAST " fake node libxslt");
+
+/**
+ * XSLT_IS_RES_TREE_FRAG:
+ *
+ * internal macro to test tree fragments
+ */
+#define XSLT_IS_RES_TREE_FRAG(n) \
+    ((n != NULL) && ((n)->type == XML_DOCUMENT_NODE) && \
+     ((n)->name != NULL) && ((n)->name[0] == ' '))
+
+/**
+ * XSLT_REFACTORED_KEYCOMP:
+ *
+ * Internal define to enable on-demand xsl:key computation.
+ * That's the only mode now but the define is kept for compatibility
+ */
+#define XSLT_REFACTORED_KEYCOMP
+
+/**
+ * XSLT_FAST_IF:
+ *
+ * Internal define to enable usage of xmlXPathCompiledEvalToBoolean()
+ * for XSLT "tests"; e.g. in <xsl:if test="/foo/bar">
+ */
+#define XSLT_FAST_IF
+
+/**
+ * XSLT_REFACTORED:
+ *
+ * Internal define to enable the refactored parts of Libxslt.
+ */
+/* #define XSLT_REFACTORED */
+/* ==================================================================== */
+
+/**
+ * XSLT_REFACTORED_VARS:
+ *
+ * Internal define to enable the refactored variable part of libxslt
+ */
+#define XSLT_REFACTORED_VARS
+
+#ifdef XSLT_REFACTORED
+
+extern const xmlChar *xsltXSLTAttrMarker;
+
+
+/* TODO: REMOVE: #define XSLT_REFACTORED_EXCLRESNS */
+
+/* TODO: REMOVE: #define XSLT_REFACTORED_NSALIAS */
+
+/**
+ * XSLT_REFACTORED_XSLT_NSCOMP
+ *
+ * Internal define to enable the pointer-comparison of
+ * namespaces of XSLT elements. 
+ */
+/* #define XSLT_REFACTORED_XSLT_NSCOMP */
+
+/**
+ * XSLT_REFACTORED_XPATHCOMP:
+ *
+ * Internal define to enable the optimization of the
+ * compilation of XPath expressions.
+ */
+#define XSLT_REFACTORED_XPATHCOMP
+
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+
+extern const xmlChar *xsltConstNamespaceNameXSLT;
+
+/**
+ * IS_XSLT_ELEM_FAST:
+ *
+ * quick test to detect XSLT elements
+ */
+#define IS_XSLT_ELEM_FAST(n) \
+    (((n) != NULL) && ((n)->ns != NULL) && \
+    ((n)->ns->href == xsltConstNamespaceNameXSLT))
+
+/**
+ * IS_XSLT_ATTR_FAST:
+ *
+ * quick test to detect XSLT attributes
+ */
+#define IS_XSLT_ATTR_FAST(a) \
+    (((a) != NULL) && ((a)->ns != NULL) && \
+    ((a)->ns->href == xsltConstNamespaceNameXSLT))
+
+/**
+ * XSLT_HAS_INTERNAL_NSMAP:
+ *
+ * check for namespace mapping
+ */
+#define XSLT_HAS_INTERNAL_NSMAP(s) \
+    (((s) != NULL) && ((s)->principal) && \
+     ((s)->principal->principalData) && \
+     ((s)->principal->principalData->nsMap))
+
+/**
+ * XSLT_GET_INTERNAL_NSMAP:
+ *
+ * get pointer to namespace map
+ */
+#define XSLT_GET_INTERNAL_NSMAP(s) ((s)->principal->principalData->nsMap)
+
+#else /* XSLT_REFACTORED_XSLT_NSCOMP */
+
+/**
+ * IS_XSLT_ELEM_FAST:
+ *
+ * quick check whether this is an xslt element
+ */
+#define IS_XSLT_ELEM_FAST(n) \
+    (((n) != NULL) && ((n)->ns != NULL) && \
+     (xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))
+
+/**
+ * IS_XSLT_ATTR_FAST:
+ *
+ * quick check for xslt namespace attribute
+ */
+#define IS_XSLT_ATTR_FAST(a) \
+    (((a) != NULL) && ((a)->ns != NULL) && \
+     (xmlStrEqual((a)->ns->href, XSLT_NAMESPACE)))
+
+
+#endif /* XSLT_REFACTORED_XSLT_NSCOMP */
+
+
+/**
+ * XSLT_REFACTORED_MANDATORY_VERSION:
+ *
+ * TODO: Currently disabled to surpress regression test failures, since
+ *  the old behaviour was that a missing version attribute
+ *  produced a only a warning and not an error, which was incerrect.
+ *  So the regression tests need to be fixed if this is enabled.
+ */
+/* #define XSLT_REFACTORED_MANDATORY_VERSION */
+
+/**
+ * xsltPointerList:
+ *
+ * Pointer-list for various purposes.
+ */
+typedef struct _xsltPointerList xsltPointerList;
+typedef xsltPointerList *xsltPointerListPtr;
+struct _xsltPointerList {
+    void **items;
+    int number;
+    int size;
+};
+
+#endif
+
+/**
+ * XSLT_REFACTORED_PARSING:
+ *
+ * Internal define to enable the refactored parts of Libxslt
+ * related to parsing.
+ */
+/* #define XSLT_REFACTORED_PARSING */
+
+/**
+ * XSLT_MAX_SORT:
+ *
+ * Max number of specified xsl:sort on an element.
+ */
+#define XSLT_MAX_SORT 15
+
+/**
+ * XSLT_PAT_NO_PRIORITY:
+ *
+ * Specific value for pattern without priority expressed.
+ */
+#define XSLT_PAT_NO_PRIORITY -12345789
+
+/**
+ * xsltRuntimeExtra:
+ *
+ * Extra information added to the transformation context.
+ */
+typedef struct _xsltRuntimeExtra xsltRuntimeExtra;
+typedef xsltRuntimeExtra *xsltRuntimeExtraPtr;
+struct _xsltRuntimeExtra {
+    void       *info;          /* pointer to the extra data */
+    xmlFreeFunc deallocate;    /* pointer to the deallocation routine */
+    union {                    /* dual-purpose field */
+        void   *ptr;           /* data not needing deallocation */
+       int    ival;            /* integer value storage */
+    } val;
+};
+
+/**
+ * XSLT_RUNTIME_EXTRA_LST:
+ * @ctxt: the transformation context
+ * @nr: the index
+ *
+ * Macro used to access extra information stored in the context
+ */
+#define XSLT_RUNTIME_EXTRA_LST(ctxt, nr) (ctxt)->extras[(nr)].info
+/**
+ * XSLT_RUNTIME_EXTRA_FREE:
+ * @ctxt: the transformation context
+ * @nr: the index
+ *
+ * Macro used to free extra information stored in the context
+ */
+#define XSLT_RUNTIME_EXTRA_FREE(ctxt, nr) (ctxt)->extras[(nr)].deallocate
+/**
+ * XSLT_RUNTIME_EXTRA:
+ * @ctxt: the transformation context
+ * @nr: the index
+ *
+ * Macro used to define extra information stored in the context
+ */
+#define        XSLT_RUNTIME_EXTRA(ctxt, nr, typ) (ctxt)->extras[(nr)].val.typ
+
+/**
+ * xsltTemplate:
+ *
+ * The in-memory structure corresponding to an XSLT Template.
+ */
+typedef struct _xsltTemplate xsltTemplate;
+typedef xsltTemplate *xsltTemplatePtr;
+struct _xsltTemplate {
+    struct _xsltTemplate *next;/* chained list sorted by priority */
+    struct _xsltStylesheet *style;/* the containing stylesheet */
+    xmlChar *match;    /* the matching string */
+    float priority;    /* as given from the stylesheet, not computed */
+    const xmlChar *name; /* the local part of the name QName */
+    const xmlChar *nameURI; /* the URI part of the name QName */
+    const xmlChar *mode;/* the local part of the mode QName */
+    const xmlChar *modeURI;/* the URI part of the mode QName */
+    xmlNodePtr content;        /* the template replacement value */
+    xmlNodePtr elem;   /* the source element */
+
+    /*
+    * TODO: @inheritedNsNr and @inheritedNs won't be used in the
+    *  refactored code.
+    */
+    int inheritedNsNr;  /* number of inherited namespaces */
+    xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */
+
+    /* Profiling informations */
+    int nbCalls;        /* the number of time the template was called */
+    unsigned long time; /* the time spent in this template */
+    void *params;       /* xsl:param instructions */
+};
+
+/**
+ * xsltDecimalFormat:
+ *
+ * Data structure of decimal-format.
+ */
+typedef struct _xsltDecimalFormat xsltDecimalFormat;
+typedef xsltDecimalFormat *xsltDecimalFormatPtr;
+struct _xsltDecimalFormat {
+    struct _xsltDecimalFormat *next; /* chained list */
+    xmlChar *name;
+    /* Used for interpretation of pattern */
+    xmlChar *digit;
+    xmlChar *patternSeparator;
+    /* May appear in result */
+    xmlChar *minusSign;
+    xmlChar *infinity;
+    xmlChar *noNumber; /* Not-a-number */
+    /* Used for interpretation of pattern and may appear in result */
+    xmlChar *decimalPoint;
+    xmlChar *grouping;
+    xmlChar *percent;
+    xmlChar *permille;
+    xmlChar *zeroDigit;
+};
+
+/**
+ * xsltDocument:
+ *
+ * Data structure associated to a parsed document.
+ */
+typedef struct _xsltDocument xsltDocument;
+typedef xsltDocument *xsltDocumentPtr;
+struct _xsltDocument {
+    struct _xsltDocument *next;        /* documents are kept in a chained list */
+    int main;                  /* is this the main document */
+    xmlDocPtr doc;             /* the parsed document */
+    void *keys;                        /* key tables storage */
+    struct _xsltDocument *includes; /* subsidiary includes */
+    int preproc;               /* pre-processing already done */
+    int nbKeysComputed;
+};
+
+/**
+ * xsltKeyDef:
+ *
+ * Representation of an xsl:key.
+ */
+typedef struct _xsltKeyDef xsltKeyDef;
+typedef xsltKeyDef *xsltKeyDefPtr;
+struct _xsltKeyDef {
+    struct _xsltKeyDef *next;
+    xmlNodePtr inst;
+    xmlChar *name;
+    xmlChar *nameURI;
+    xmlChar *match;
+    xmlChar *use;
+    xmlXPathCompExprPtr comp;
+    xmlXPathCompExprPtr usecomp;
+    xmlNsPtr *nsList;           /* the namespaces in scope */
+    int nsNr;                   /* the number of namespaces in scope */
+};
+
+/**
+ * xsltKeyTable:
+ *
+ * Holds the computed keys for key definitions of the same QName.
+ * Is owned by an xsltDocument.
+ */
+typedef struct _xsltKeyTable xsltKeyTable;
+typedef xsltKeyTable *xsltKeyTablePtr;
+struct _xsltKeyTable {
+    struct _xsltKeyTable *next;
+    xmlChar *name;
+    xmlChar *nameURI;
+    xmlHashTablePtr keys;
+};
+
+/*
+ * The in-memory structure corresponding to an XSLT Stylesheet.
+ * NOTE: most of the content is simply linked from the doc tree
+ *       structure, no specific allocation is made.
+ */
+typedef struct _xsltStylesheet xsltStylesheet;
+typedef xsltStylesheet *xsltStylesheetPtr;
+
+typedef struct _xsltTransformContext xsltTransformContext;
+typedef xsltTransformContext *xsltTransformContextPtr;
+
+/**
+ * xsltElemPreComp:
+ *
+ * The in-memory structure corresponding to element precomputed data,
+ * designed to be extended by extension implementors.
+ */
+typedef struct _xsltElemPreComp xsltElemPreComp;
+typedef xsltElemPreComp *xsltElemPreCompPtr;
+
+/**
+ * xsltTransformFunction:
+ * @ctxt: the XSLT transformation context
+ * @node: the input node
+ * @inst: the stylesheet node
+ * @comp: the compiled information from the stylesheet
+ *
+ * Signature of the function associated to elements part of the
+ * stylesheet language like xsl:if or xsl:apply-templates.
+ */
+typedef void (*xsltTransformFunction) (xsltTransformContextPtr ctxt,
+                                      xmlNodePtr node,
+                                      xmlNodePtr inst,
+                                      xsltElemPreCompPtr comp);
+
+/**
+ * xsltSortFunc:
+ * @ctxt:    a transformation context
+ * @sorts:   the node-set to sort
+ * @nbsorts: the number of sorts
+ *
+ * Signature of the function to use during sorting
+ */
+typedef void (*xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
+                             int nbsorts);
+
+typedef enum {
+    XSLT_FUNC_COPY=1,
+    XSLT_FUNC_SORT,
+    XSLT_FUNC_TEXT,
+    XSLT_FUNC_ELEMENT,
+    XSLT_FUNC_ATTRIBUTE,
+    XSLT_FUNC_COMMENT,
+    XSLT_FUNC_PI,
+    XSLT_FUNC_COPYOF,
+    XSLT_FUNC_VALUEOF,
+    XSLT_FUNC_NUMBER,
+    XSLT_FUNC_APPLYIMPORTS,
+    XSLT_FUNC_CALLTEMPLATE,
+    XSLT_FUNC_APPLYTEMPLATES,
+    XSLT_FUNC_CHOOSE,
+    XSLT_FUNC_IF,
+    XSLT_FUNC_FOREACH,
+    XSLT_FUNC_DOCUMENT,
+    XSLT_FUNC_WITHPARAM,
+    XSLT_FUNC_PARAM,
+    XSLT_FUNC_VARIABLE,
+    XSLT_FUNC_WHEN,
+    XSLT_FUNC_EXTENSION
+#ifdef XSLT_REFACTORED
+    ,
+    XSLT_FUNC_OTHERWISE,
+    XSLT_FUNC_FALLBACK,
+    XSLT_FUNC_MESSAGE,
+    XSLT_FUNC_INCLUDE,
+    XSLT_FUNC_ATTRSET,
+    XSLT_FUNC_LITERAL_RESULT_ELEMENT,
+    XSLT_FUNC_UNKOWN_FORWARDS_COMPAT
+#endif
+} xsltStyleType;
+
+/**
+ * xsltElemPreCompDeallocator:
+ * @comp:  the #xsltElemPreComp to free up
+ *
+ * Deallocates an #xsltElemPreComp structure.
+ */
+typedef void (*xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp);
+
+/**
+ * xsltElemPreComp:
+ *
+ * The basic structure for compiled items of the AST of the XSLT processor.
+ * This structure is also intended to be extended by extension implementors.
+ * TODO: This is somehow not nice, since it has a "free" field, which
+ *   derived stylesheet-structs do not have.
+ */
+struct _xsltElemPreComp {
+    xsltElemPreCompPtr next;           /* next item in the global chained
+                                          list hold by xsltStylesheet. */
+    xsltStyleType type;                /* type of the element */
+    xsltTransformFunction func;        /* handling function */
+    xmlNodePtr inst;                   /* the node in the stylesheet's tree
+                                          corresponding to this item */
+
+    /* end of common part */
+    xsltElemPreCompDeallocator free;   /* the deallocator */
+};
+
+/**
+ * xsltStylePreComp:
+ *
+ * The abstract basic structure for items of the XSLT processor.
+ * This includes:
+ * 1) compiled forms of XSLT instructions (xsl:if, xsl:attribute, etc.)
+ * 2) compiled forms of literal result elements
+ * 3) compiled forms of extension elements
+ */
+typedef struct _xsltStylePreComp xsltStylePreComp;
+typedef xsltStylePreComp *xsltStylePreCompPtr;
+
+#ifdef XSLT_REFACTORED
+
+/*
+* Some pointer-list utility functions.
+*/
+XSLTPUBFUN xsltPointerListPtr XSLTCALL
+               xsltPointerListCreate           (int initialSize);
+XSLTPUBFUN void XSLTCALL
+               xsltPointerListFree             (xsltPointerListPtr list);
+XSLTPUBFUN void XSLTCALL
+               xsltPointerListClear            (xsltPointerListPtr list);
+XSLTPUBFUN int XSLTCALL
+               xsltPointerListAddSize          (xsltPointerListPtr list,                                                
+                                                void *item,
+                                                int initialSize);
+
+/************************************************************************
+ *                                                                     *
+ * Refactored structures                                                *
+ *                                                                     *
+ ************************************************************************/
+
+typedef struct _xsltNsListContainer xsltNsListContainer;
+typedef xsltNsListContainer *xsltNsListContainerPtr;
+struct _xsltNsListContainer {
+    xmlNsPtr *list;
+    int totalNumber;
+    int xpathNumber;    
+};
+
+/**
+ * XSLT_ITEM_COMPATIBILITY_FIELDS:
+ * 
+ * Fields for API compatibility to the structure
+ * _xsltElemPreComp which is used for extension functions.
+ * Note that @next is used for storage; it does not reflect a next
+ * sibling in the tree.
+ * TODO: Evaluate if we really need such a compatibility.
+ */
+#define XSLT_ITEM_COMPATIBILITY_FIELDS \
+    xsltElemPreCompPtr next;\
+    xsltStyleType type;\
+    xsltTransformFunction func;\
+    xmlNodePtr inst;
+
+/**
+ * XSLT_ITEM_NAVIGATION_FIELDS:
+ *
+ * Currently empty.
+ * TODO: It is intended to hold navigational fields in the future.
+ */
+#define XSLT_ITEM_NAVIGATION_FIELDS
+/*
+    xsltStylePreCompPtr parent;\
+    xsltStylePreCompPtr children;\
+    xsltStylePreCompPtr nextItem; 
+*/
+
+/**
+ * XSLT_ITEM_NSINSCOPE_FIELDS:
+ *
+ * The in-scope namespaces.
+ */
+#define XSLT_ITEM_NSINSCOPE_FIELDS xsltNsListContainerPtr inScopeNs;
+
+/**
+ * XSLT_ITEM_COMMON_FIELDS:
+ *
+ * Common fields used for all items.
+ */
+#define XSLT_ITEM_COMMON_FIELDS \
+    XSLT_ITEM_COMPATIBILITY_FIELDS \
+    XSLT_ITEM_NAVIGATION_FIELDS \
+    XSLT_ITEM_NSINSCOPE_FIELDS
+
+/**
+ * _xsltStylePreComp: 
+ *
+ * The abstract basic structure for items of the XSLT processor.
+ * This includes:
+ * 1) compiled forms of XSLT instructions (e.g. xsl:if, xsl:attribute, etc.)
+ * 2) compiled forms of literal result elements
+ * 3) various properties for XSLT instructions (e.g. xsl:when,
+ *    xsl:with-param)
+ *
+ * REVISIT TODO: Keep this structure equal to the fields
+ *   defined by XSLT_ITEM_COMMON_FIELDS
+ */
+struct _xsltStylePreComp {
+    xsltElemPreCompPtr next;    /* next item in the global chained
+                                  list hold by xsltStylesheet */
+    xsltStyleType type;         /* type of the item */ 
+    xsltTransformFunction func; /* handling function */
+    xmlNodePtr inst;           /* the node in the stylesheet's tree
+                                  corresponding to this item. */
+    /* Currently no navigational fields. */
+    xsltNsListContainerPtr inScopeNs;
+};
+
+/**
+ * xsltStyleBasicEmptyItem:
+ * 
+ * Abstract structure only used as a short-cut for
+ * XSLT items with no extra fields.
+ * NOTE that it is intended that this structure looks the same as
+ *  _xsltStylePreComp.
+ */
+typedef struct _xsltStyleBasicEmptyItem xsltStyleBasicEmptyItem;
+typedef xsltStyleBasicEmptyItem *xsltStyleBasicEmptyItemPtr;
+
+struct _xsltStyleBasicEmptyItem {
+    XSLT_ITEM_COMMON_FIELDS
+};
+
+/**
+ * xsltStyleBasicExpressionItem:
+ * 
+ * Abstract structure only used as a short-cut for
+ * XSLT items with just an expression.
+ */
+typedef struct _xsltStyleBasicExpressionItem xsltStyleBasicExpressionItem;
+typedef xsltStyleBasicExpressionItem *xsltStyleBasicExpressionItemPtr;
+
+struct _xsltStyleBasicExpressionItem {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *select; /* TODO: Change this to "expression". */
+    xmlXPathCompExprPtr comp; /* TODO: Change this to compExpr. */
+};
+
+/************************************************************************
+ *                                                                     *
+ * XSLT-instructions/declarations                                       *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltStyleItemElement:
+ * 
+ * <!-- Category: instruction -->
+ * <xsl:element
+ *  name = { qname }
+ *  namespace = { uri-reference }
+ *  use-attribute-sets = qnames>
+ *  <!-- Content: template -->
+ * </xsl:element>
+ */
+typedef struct _xsltStyleItemElement xsltStyleItemElement;
+typedef xsltStyleItemElement *xsltStyleItemElementPtr;
+
+struct _xsltStyleItemElement {
+    XSLT_ITEM_COMMON_FIELDS 
+
+    const xmlChar *use;
+    int      has_use;
+    const xmlChar *name;    
+    int      has_name;
+    const xmlChar *ns;
+    const xmlChar *nsPrefix;
+    int      has_ns;
+};
+
+/**
+ * xsltStyleItemAttribute:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:attribute
+ *  name = { qname }
+ *  namespace = { uri-reference }>
+ *  <!-- Content: template -->
+ * </xsl:attribute>
+ */
+typedef struct _xsltStyleItemAttribute xsltStyleItemAttribute;
+typedef xsltStyleItemAttribute *xsltStyleItemAttributePtr;
+
+struct _xsltStyleItemAttribute {
+    XSLT_ITEM_COMMON_FIELDS
+    const xmlChar *name;
+    int      has_name;
+    const xmlChar *ns;
+    const xmlChar *nsPrefix;
+    int      has_ns;
+};
+
+/**
+ * xsltStyleItemText:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:text
+ *  disable-output-escaping = "yes" | "no">
+ *  <!-- Content: #PCDATA -->
+ * </xsl:text>
+ */
+typedef struct _xsltStyleItemText xsltStyleItemText;
+typedef xsltStyleItemText *xsltStyleItemTextPtr;
+
+struct _xsltStyleItemText {
+    XSLT_ITEM_COMMON_FIELDS
+    int      noescape;         /* text */
+};
+
+/**
+ * xsltStyleItemComment:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:comment>
+ *  <!-- Content: template -->
+ * </xsl:comment>
+ */
+typedef xsltStyleBasicEmptyItem xsltStyleItemComment;
+typedef xsltStyleItemComment *xsltStyleItemCommentPtr;
+
+/**
+ * xsltStyleItemPI:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:processing-instruction
+ *  name = { ncname }>
+ *  <!-- Content: template -->
+ * </xsl:processing-instruction>
+ */
+typedef struct _xsltStyleItemPI xsltStyleItemPI;
+typedef xsltStyleItemPI *xsltStyleItemPIPtr;
+
+struct _xsltStyleItemPI {
+    XSLT_ITEM_COMMON_FIELDS
+    const xmlChar *name;
+    int      has_name;
+};
+
+/**
+ * xsltStyleItemApplyImports:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:apply-imports />
+ */
+typedef xsltStyleBasicEmptyItem xsltStyleItemApplyImports;
+typedef xsltStyleItemApplyImports *xsltStyleItemApplyImportsPtr;
+
+/**
+ * xsltStyleItemApplyTemplates:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:apply-templates
+ *  select = node-set-expression
+ *  mode = qname>
+ *  <!-- Content: (xsl:sort | xsl:with-param)* -->
+ * </xsl:apply-templates>
+ */
+typedef struct _xsltStyleItemApplyTemplates xsltStyleItemApplyTemplates;
+typedef xsltStyleItemApplyTemplates *xsltStyleItemApplyTemplatesPtr;
+
+struct _xsltStyleItemApplyTemplates {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *mode;       /* apply-templates */
+    const xmlChar *modeURI;    /* apply-templates */
+    const xmlChar *select;     /* sort, copy-of, value-of, apply-templates */
+    xmlXPathCompExprPtr comp;  /* a precompiled XPath expression */
+    /* TODO: with-params */
+};
+
+/**
+ * xsltStyleItemCallTemplate:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:call-template
+ *  name = qname>
+ *  <!-- Content: xsl:with-param* -->
+ * </xsl:call-template>
+ */
+typedef struct _xsltStyleItemCallTemplate xsltStyleItemCallTemplate;
+typedef xsltStyleItemCallTemplate *xsltStyleItemCallTemplatePtr;
+
+struct _xsltStyleItemCallTemplate {
+    XSLT_ITEM_COMMON_FIELDS
+
+    xsltTemplatePtr templ;     /* call-template */
+    const xmlChar *name;       /* element, attribute, pi */
+    int      has_name;         /* element, attribute, pi */
+    const xmlChar *ns;         /* element */
+    int      has_ns;           /* element */
+    /* TODO: with-params */
+};
+
+/**
+ * xsltStyleItemCopy:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:copy
+ *  use-attribute-sets = qnames>
+ *  <!-- Content: template -->
+ * </xsl:copy>
+ */
+typedef struct _xsltStyleItemCopy xsltStyleItemCopy;
+typedef xsltStyleItemCopy *xsltStyleItemCopyPtr;
+
+struct _xsltStyleItemCopy {
+   XSLT_ITEM_COMMON_FIELDS
+    const xmlChar *use;                /* copy, element */
+    int      has_use;          /* copy, element */    
+};
+
+/**
+ * xsltStyleItemIf:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:if
+ *  test = boolean-expression>
+ *  <!-- Content: template -->
+ * </xsl:if>
+ */
+typedef struct _xsltStyleItemIf xsltStyleItemIf;
+typedef xsltStyleItemIf *xsltStyleItemIfPtr;
+
+struct _xsltStyleItemIf {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *test;       /* if */
+    xmlXPathCompExprPtr comp;  /* a precompiled XPath expression */
+};
+
+
+/**
+ * xsltStyleItemCopyOf:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:copy-of
+ *  select = expression />
+ */
+typedef xsltStyleBasicExpressionItem xsltStyleItemCopyOf;
+typedef xsltStyleItemCopyOf *xsltStyleItemCopyOfPtr;
+
+/**
+ * xsltStyleItemValueOf:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:value-of
+ *  select = string-expression
+ *  disable-output-escaping = "yes" | "no" />
+ */
+typedef struct _xsltStyleItemValueOf xsltStyleItemValueOf;
+typedef xsltStyleItemValueOf *xsltStyleItemValueOfPtr;
+
+struct _xsltStyleItemValueOf {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *select;
+    xmlXPathCompExprPtr comp;  /* a precompiled XPath expression */
+    int      noescape;
+};
+
+/**
+ * xsltStyleItemNumber:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:number
+ *  level = "single" | "multiple" | "any"
+ *  count = pattern
+ *  from = pattern
+ *  value = number-expression
+ *  format = { string }
+ *  lang = { nmtoken }
+ *  letter-value = { "alphabetic" | "traditional" }
+ *  grouping-separator = { char }
+ *  grouping-size = { number } />
+ */
+typedef struct _xsltStyleItemNumber xsltStyleItemNumber;
+typedef xsltStyleItemNumber *xsltStyleItemNumberPtr;
+
+struct _xsltStyleItemNumber {
+    XSLT_ITEM_COMMON_FIELDS
+    xsltNumberData numdata;    /* number */
+};
+
+/**
+ * xsltStyleItemChoose:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:choose>
+ *  <!-- Content: (xsl:when+, xsl:otherwise?) -->
+ * </xsl:choose>
+ */
+typedef xsltStyleBasicEmptyItem xsltStyleItemChoose;
+typedef xsltStyleItemChoose *xsltStyleItemChoosePtr;
+
+/**
+ * xsltStyleItemFallback:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:fallback>
+ *  <!-- Content: template -->
+ * </xsl:fallback>
+ */
+typedef xsltStyleBasicEmptyItem xsltStyleItemFallback;
+typedef xsltStyleItemFallback *xsltStyleItemFallbackPtr;
+
+/**
+ * xsltStyleItemForEach:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:for-each
+ *   select = node-set-expression>
+ *   <!-- Content: (xsl:sort*, template) -->
+ * </xsl:for-each>
+ */
+typedef xsltStyleBasicExpressionItem xsltStyleItemForEach;
+typedef xsltStyleItemForEach *xsltStyleItemForEachPtr;
+
+/**
+ * xsltStyleItemMessage:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:message
+ *   terminate = "yes" | "no">
+ *   <!-- Content: template -->
+ * </xsl:message>
+ */
+typedef struct _xsltStyleItemMessage xsltStyleItemMessage;
+typedef xsltStyleItemMessage *xsltStyleItemMessagePtr;
+
+struct _xsltStyleItemMessage {
+    XSLT_ITEM_COMMON_FIELDS    
+    int terminate;
+};
+
+/**
+ * xsltStyleItemDocument:
+ *
+ * NOTE: This is not an instruction of XSLT 1.0.
+ */
+typedef struct _xsltStyleItemDocument xsltStyleItemDocument;
+typedef xsltStyleItemDocument *xsltStyleItemDocumentPtr;
+
+struct _xsltStyleItemDocument {
+    XSLT_ITEM_COMMON_FIELDS
+    int      ver11;            /* assigned: in xsltDocumentComp;
+                                  read: nowhere;
+                                  TODO: Check if we need. */
+    const xmlChar *filename;   /* document URL */
+    int has_filename;
+};   
+
+/************************************************************************
+ *                                                                     *
+ * Non-instructions (actually properties of instructions/declarations)  *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltStyleBasicItemVariable:
+ *
+ * Basic struct for xsl:variable, xsl:param and xsl:with-param.
+ * It's currently important to have equal fields, since
+ * xsltParseStylesheetCallerParam() is used with xsl:with-param from
+ * the xslt side and with xsl:param from the exslt side (in
+ * exsltFuncFunctionFunction()).
+ *
+ * FUTURE NOTE: In XSLT 2.0 xsl:param, xsl:variable and xsl:with-param
+ *   have additional different fields.
+ */
+typedef struct _xsltStyleBasicItemVariable xsltStyleBasicItemVariable;
+typedef xsltStyleBasicItemVariable *xsltStyleBasicItemVariablePtr;
+
+struct _xsltStyleBasicItemVariable {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *select;
+    xmlXPathCompExprPtr comp;
+
+    const xmlChar *name;
+    int      has_name;
+    const xmlChar *ns;
+    int      has_ns;
+};
+
+/**
+ * xsltStyleItemVariable:
+ *
+ * <!-- Category: top-level-element -->
+ * <xsl:param
+ *   name = qname
+ *   select = expression>
+ *   <!-- Content: template -->
+ * </xsl:param>
+ */
+typedef xsltStyleBasicItemVariable xsltStyleItemVariable;
+typedef xsltStyleItemVariable *xsltStyleItemVariablePtr;
+
+/**
+ * xsltStyleItemParam:
+ *
+ * <!-- Category: top-level-element -->
+ * <xsl:param
+ *   name = qname
+ *   select = expression>
+ *   <!-- Content: template -->
+ * </xsl:param>
+ */
+typedef struct _xsltStyleItemParam xsltStyleItemParam;
+typedef xsltStyleItemParam *xsltStyleItemParamPtr;
+
+struct _xsltStyleItemParam {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *select;
+    xmlXPathCompExprPtr comp;
+
+    const xmlChar *name;
+    int      has_name;
+    const xmlChar *ns;
+    int      has_ns;    
+};
+
+/**
+ * xsltStyleItemWithParam:
+ *
+ * <xsl:with-param
+ *  name = qname
+ *  select = expression>
+ *  <!-- Content: template -->
+ * </xsl:with-param>
+ */
+typedef xsltStyleBasicItemVariable xsltStyleItemWithParam;
+typedef xsltStyleItemWithParam *xsltStyleItemWithParamPtr;
+
+/**
+ * xsltStyleItemSort:
+ *
+ * Reflects the XSLT xsl:sort item.
+ * Allowed parents: xsl:apply-templates, xsl:for-each
+ * <xsl:sort
+ *   select = string-expression
+ *   lang = { nmtoken }
+ *   data-type = { "text" | "number" | qname-but-not-ncname }
+ *   order = { "ascending" | "descending" }
+ *   case-order = { "upper-first" | "lower-first" } />
+ */
+typedef struct _xsltStyleItemSort xsltStyleItemSort;
+typedef xsltStyleItemSort *xsltStyleItemSortPtr;
+
+struct _xsltStyleItemSort {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *stype;       /* sort */
+    int      has_stype;                /* sort */
+    int      number;           /* sort */
+    const xmlChar *order;      /* sort */
+    int      has_order;                /* sort */
+    int      descending;       /* sort */
+    const xmlChar *lang;       /* sort */
+    int      has_lang;         /* sort */
+    const xmlChar *case_order; /* sort */
+    int      lower_first;      /* sort */
+
+    const xmlChar *use;
+    int      has_use;
+
+    const xmlChar *select;     /* sort, copy-of, value-of, apply-templates */
+
+    xmlXPathCompExprPtr comp;  /* a precompiled XPath expression */
+};
+
+
+/**
+ * xsltStyleItemWhen:
+ * 
+ * <xsl:when
+ *   test = boolean-expression>
+ *   <!-- Content: template -->
+ * </xsl:when>
+ * Allowed parent: xsl:choose
+ */
+typedef struct _xsltStyleItemWhen xsltStyleItemWhen;
+typedef xsltStyleItemWhen *xsltStyleItemWhenPtr;
+
+struct _xsltStyleItemWhen {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *test;
+    xmlXPathCompExprPtr comp;
+};
+
+/**
+ * xsltStyleItemOtherwise:
+ *
+ * Allowed parent: xsl:choose
+ * <xsl:otherwise>
+ *   <!-- Content: template -->
+ * </xsl:otherwise>
+ */
+typedef struct _xsltStyleItemOtherwise xsltStyleItemOtherwise;
+typedef xsltStyleItemOtherwise *xsltStyleItemOtherwisePtr;
+
+struct _xsltStyleItemOtherwise {
+    XSLT_ITEM_COMMON_FIELDS
+};
+
+typedef struct _xsltStyleItemInclude xsltStyleItemInclude;
+typedef xsltStyleItemInclude *xsltStyleItemIncludePtr;
+
+struct _xsltStyleItemInclude {
+    XSLT_ITEM_COMMON_FIELDS
+    xsltDocumentPtr include;
+};
+
+/************************************************************************
+ *                                                                     *
+ *  XSLT elements in forwards-compatible mode                           *
+ *                                                                     *
+ ************************************************************************/
+
+typedef struct _xsltStyleItemUknown xsltStyleItemUknown;
+typedef xsltStyleItemUknown *xsltStyleItemUknownPtr;
+struct _xsltStyleItemUknown {
+    XSLT_ITEM_COMMON_FIELDS
+};
+
+
+/************************************************************************
+ *                                                                     *
+ *  Extension elements                                                  *
+ *                                                                     *
+ ************************************************************************/
+
+/*
+ * xsltStyleItemExtElement:
+ *
+ * Reflects extension elements.
+ *
+ * NOTE: Due to the fact that the structure xsltElemPreComp is most
+ * probably already heavily in use out there by users, so we cannot
+ * easily change it, we'll create an intermediate structure which will
+ * hold an xsltElemPreCompPtr.
+ * BIG NOTE: The only problem I see here is that the user processes the
+ *  content of the stylesheet tree, possibly he'll lookup the node->psvi
+ *  fields in order to find subsequent extension functions.
+ *  In this case, the user's code will break, since the node->psvi
+ *  field will hold now the xsltStyleItemExtElementPtr and not
+ *  the xsltElemPreCompPtr.
+ *  However the place where the structure is anchored in the node-tree,
+ *  namely node->psvi, has beed already once been moved from node->_private
+ *  to node->psvi, so we have a precedent here, which, I think, should allow
+ *  us to change such semantics without headaches.
+ */
+typedef struct _xsltStyleItemExtElement xsltStyleItemExtElement;
+typedef xsltStyleItemExtElement *xsltStyleItemExtElementPtr;
+struct _xsltStyleItemExtElement {
+    XSLT_ITEM_COMMON_FIELDS
+    xsltElemPreCompPtr item;   
+};
+
+/************************************************************************
+ *                                                                     *
+ *  Literal result elements                                             *
+ *                                                                     *
+ ************************************************************************/
+
+typedef struct _xsltEffectiveNs xsltEffectiveNs;
+typedef xsltEffectiveNs *xsltEffectiveNsPtr;
+struct _xsltEffectiveNs {
+    xsltEffectiveNsPtr nextInStore; /* storage next */
+    xsltEffectiveNsPtr next; /* next item in the list */
+    const xmlChar *prefix;
+    const xmlChar *nsName;
+    /* 
+    * Indicates if eclared on the literal result element; dunno if really
+    * needed.
+    */
+    int holdByElem;
+};
+
+/*
+ * Info for literal result elements.
+ * This will be set on the elem->psvi field and will be
+ * shared by literal result elements, which have the same
+ * excluded result namespaces; i.e., this *won't* be created uniquely
+ * for every literal result element.
+ */
+typedef struct _xsltStyleItemLRElementInfo xsltStyleItemLRElementInfo;
+typedef xsltStyleItemLRElementInfo *xsltStyleItemLRElementInfoPtr;
+struct _xsltStyleItemLRElementInfo {
+    XSLT_ITEM_COMMON_FIELDS
+    /*
+    * @effectiveNs is the set of effective ns-nodes
+    *  on the literal result element, which will be added to the result
+    *  element if not already existing in the result tree.
+    *  This means that excluded namespaces (via exclude-result-prefixes,
+    *  extension-element-prefixes and the XSLT namespace) not added
+    *  to the set.
+    *  Namespace-aliasing was applied on the @effectiveNs.
+    */
+    xsltEffectiveNsPtr effectiveNs;
+
+};
+
+#ifdef XSLT_REFACTORED
+
+typedef struct _xsltNsAlias xsltNsAlias;
+typedef xsltNsAlias *xsltNsAliasPtr;
+struct _xsltNsAlias {
+    xsltNsAliasPtr next; /* next in the list */    
+    xmlNsPtr literalNs;
+    xmlNsPtr targetNs;
+    xmlDocPtr docOfTargetNs;
+};
+#endif
+
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+
+typedef struct _xsltNsMap xsltNsMap;
+typedef xsltNsMap *xsltNsMapPtr;
+struct _xsltNsMap {
+    xsltNsMapPtr next; /* next in the list */
+    xmlDocPtr doc;
+    xmlNodePtr elem; /* the element holding the ns-decl */
+    xmlNsPtr ns; /* the xmlNs structure holding the XML namespace name */
+    const xmlChar *origNsName; /* the original XML namespace name */
+    const xmlChar *newNsName; /* the mapped XML namespace name */    
+};
+#endif
+
+/************************************************************************
+ *                                                                     *
+ *  Compile-time structures for *internal* use only                     *
+ *                                                                     *
+ ************************************************************************/
+
+typedef struct _xsltPrincipalStylesheetData xsltPrincipalStylesheetData;
+typedef xsltPrincipalStylesheetData *xsltPrincipalStylesheetDataPtr;
+
+typedef struct _xsltNsList xsltNsList;
+typedef xsltNsList *xsltNsListPtr;
+struct _xsltNsList {
+    xsltNsListPtr next; /* next in the list */
+    xmlNsPtr ns;
+};
+
+/*
+* xsltVarInfo:
+*
+* Used at compilation time for parameters and variables.
+*/
+typedef struct _xsltVarInfo xsltVarInfo;
+typedef xsltVarInfo *xsltVarInfoPtr;
+struct _xsltVarInfo {
+    xsltVarInfoPtr next; /* next in the list */
+    xsltVarInfoPtr prev;
+    int depth; /* the depth in the tree */
+    const xmlChar *name;
+    const xmlChar *nsName;
+};
+
+#define XSLT_ELEMENT_CATEGORY_XSLT 0
+#define XSLT_ELEMENT_CATEGORY_EXTENSION 1
+#define XSLT_ELEMENT_CATEGORY_LRE 2
+
+/**
+ * xsltCompilerNodeInfo:
+ *
+ * Per-node information during compile-time.
+ */
+typedef struct _xsltCompilerNodeInfo xsltCompilerNodeInfo;
+typedef xsltCompilerNodeInfo *xsltCompilerNodeInfoPtr;
+struct _xsltCompilerNodeInfo {
+    xsltCompilerNodeInfoPtr next;
+    xsltCompilerNodeInfoPtr prev;
+    xmlNodePtr node;
+    int depth;
+    xsltTemplatePtr templ;   /* The owning template */
+    int category;           /* XSLT element, LR-element or
+                                extension element */
+    xsltStyleType type;
+    xsltElemPreCompPtr item; /* The compiled information */
+    /* The current in-scope namespaces */
+    xsltNsListContainerPtr inScopeNs;
+    /* The current excluded result namespaces */
+    xsltPointerListPtr exclResultNs; 
+    /* The current extension instruction namespaces */
+    xsltPointerListPtr extElemNs;
+
+    /* The current info for literal result elements. */
+    xsltStyleItemLRElementInfoPtr litResElemInfo;
+    /* 
+    * Set to 1 if in-scope namespaces changed,
+    *  or excluded result namespaces changed,
+    *  or extension element namespaces changed.
+    * This will trigger creation of new infos
+    *  for literal result elements.
+    */
+    int nsChanged;
+    int preserveWhitespace;
+    int stripWhitespace;
+    int isRoot; /* whether this is the stylesheet's root node */
+    int forwardsCompat; /* whether forwards-compatible mode is enabled */
+    /* whether the content of an extension element was processed */
+    int extContentHandled;
+    /* the type of the current child */
+    xsltStyleType curChildType;    
+};
+
+/**
+ * XSLT_CCTXT:
+ *
+ * get pointer to compiler context
+ */
+#define XSLT_CCTXT(style) ((xsltCompilerCtxtPtr) style->compCtxt) 
+
+typedef enum {
+    XSLT_ERROR_SEVERITY_ERROR = 0,
+    XSLT_ERROR_SEVERITY_WARNING
+} xsltErrorSeverityType;
+
+typedef struct _xsltCompilerCtxt xsltCompilerCtxt;
+typedef xsltCompilerCtxt *xsltCompilerCtxtPtr;
+struct _xsltCompilerCtxt {
+    void *errorCtxt;            /* user specific error context */
+    /*
+    * used for error/warning reports; e.g. XSLT_ERROR_SEVERITY_WARNING */
+    xsltErrorSeverityType errSeverity;         
+    int warnings;              /* TODO: number of warnings found at
+                                   compilation */
+    int errors;                        /* TODO: number of errors found at
+                                   compilation */
+    xmlDictPtr dict;
+    xsltStylesheetPtr style;
+    int simplified; /* whether this is a simplified stylesheet */
+    /* TODO: structured/unstructured error contexts. */
+    int depth; /* Current depth of processing */
+    
+    xsltCompilerNodeInfoPtr inode;
+    xsltCompilerNodeInfoPtr inodeList;
+    xsltCompilerNodeInfoPtr inodeLast;
+    xsltPointerListPtr tmpList; /* Used for various purposes */
+    /*
+    * The XSLT version as specified by the stylesheet's root element.
+    */
+    int isInclude;
+    int hasForwardsCompat; /* whether forwards-compatible mode was used
+                            in a parsing episode */
+    int maxNodeInfos; /* TEMP TODO: just for the interest */
+    int maxLREs;  /* TEMP TODO: just for the interest */
+    /* 
+    * In order to keep the old behaviour, applying strict rules of
+    * the spec can be turned off. This has effect only on special
+    * mechanisms like whitespace-stripping in the stylesheet.
+    */
+    int strict;
+    xsltPrincipalStylesheetDataPtr psData;
+#ifdef XSLT_REFACTORED_XPATHCOMP
+    xmlXPathContextPtr xpathCtxt;
+#endif
+    xsltStyleItemUknownPtr unknownItem;
+    int hasNsAliases; /* Indicator if there was an xsl:namespace-alias. */
+    xsltNsAliasPtr nsAliases;
+    xsltVarInfoPtr ivars; /* Storage of local in-scope variables/params. */
+    xsltVarInfoPtr ivar; /* topmost local variable/param. */
+};   
+
+#else /* XSLT_REFACTORED */
+/*
+* The old structures before refactoring.
+*/
+
+/**
+ * _xsltStylePreComp:
+ *
+ * The in-memory structure corresponding to XSLT stylesheet constructs
+ * precomputed data.
+ */
+struct _xsltStylePreComp {
+    xsltElemPreCompPtr next;   /* chained list */
+    xsltStyleType type;                /* type of the element */
+    xsltTransformFunction func; /* handling function */
+    xmlNodePtr inst;           /* the instruction */
+
+    /*
+     * Pre computed values.
+     */
+
+    const xmlChar *stype;       /* sort */
+    int      has_stype;                /* sort */
+    int      number;           /* sort */
+    const xmlChar *order;      /* sort */
+    int      has_order;                /* sort */
+    int      descending;       /* sort */
+    const xmlChar *lang;       /* sort */
+    int      has_lang;         /* sort */
+    const xmlChar *case_order; /* sort */
+    int      lower_first;      /* sort */
+
+    const xmlChar *use;                /* copy, element */
+    int      has_use;          /* copy, element */
+
+    int      noescape;         /* text */
+
+    const xmlChar *name;       /* element, attribute, pi */
+    int      has_name;         /* element, attribute, pi */
+    const xmlChar *ns;         /* element */
+    int      has_ns;           /* element */
+
+    const xmlChar *mode;       /* apply-templates */
+    const xmlChar *modeURI;    /* apply-templates */
+
+    const xmlChar *test;       /* if */
+
+    xsltTemplatePtr templ;     /* call-template */
+
+    const xmlChar *select;     /* sort, copy-of, value-of, apply-templates */
+
+    int      ver11;            /* document */
+    const xmlChar *filename;   /* document URL */
+    int      has_filename;     /* document */
+
+    xsltNumberData numdata;    /* number */
+
+    xmlXPathCompExprPtr comp;  /* a precompiled XPath expression */
+    xmlNsPtr *nsList;          /* the namespaces in scope */
+    int nsNr;                  /* the number of namespaces in scope */
+};
+
+#endif /* XSLT_REFACTORED */
+
+
+#define XSLT_VAR_GLOBAL 1<<0
+#define XSLT_VAR_IN_SELECT 1<<1
+#define XSLT_TCTXT_VARIABLE(c) ((xsltStackElemPtr) (c)->contextVariable)
+/*
+ * The in-memory structure corresponding to an XSLT Variable
+ * or Param.
+ */
+typedef struct _xsltStackElem xsltStackElem;
+typedef xsltStackElem *xsltStackElemPtr;
+struct _xsltStackElem {
+    struct _xsltStackElem *next;/* chained list */
+    xsltStylePreCompPtr comp;   /* the compiled form */
+    int computed;              /* was the evaluation done */
+    const xmlChar *name;       /* the local part of the name QName */
+    const xmlChar *nameURI;    /* the URI part of the name QName */
+    const xmlChar *select;     /* the eval string */
+    xmlNodePtr tree;           /* the sequence constructor if no eval
+                                   string or the location */
+    xmlXPathObjectPtr value;   /* The value if computed */
+    xmlDocPtr fragment;                /* The Result Tree Fragments (needed for XSLT 1.0)
+                                  which are bound to the variable's lifetime. */
+    int level;                  /* the depth in the tree;
+                                   -1 if persistent (e.g. a given xsl:with-param) */
+    xsltTransformContextPtr context; /* The transformation context; needed to cache
+                                        the variables */
+    int flags;
+};
+
+#ifdef XSLT_REFACTORED
+
+struct _xsltPrincipalStylesheetData {
+    /*
+    * Namespace dictionary for ns-prefixes and ns-names:
+    * TODO: Shared between stylesheets, and XPath mechanisms.
+    *   Not used yet.
+    */
+    xmlDictPtr namespaceDict;
+    /*
+    * Global list of in-scope namespaces.
+    */
+    xsltPointerListPtr inScopeNamespaces;
+    /*
+    * Global list of information for [xsl:]excluded-result-prefixes.
+    */
+    xsltPointerListPtr exclResultNamespaces;
+    /*
+    * Global list of information for [xsl:]extension-element-prefixes.
+    */
+    xsltPointerListPtr extElemNamespaces;
+    xsltEffectiveNsPtr effectiveNs;
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+    /*
+    * Namespace name map to get rid of string comparison of namespace names.
+    */
+    xsltNsMapPtr nsMap;
+#endif
+};
+
+    
+#endif
+/*
+ * Note that we added a @compCtxt field to anchor an stylesheet compilation
+ * context, since, due to historical reasons, various compile-time function
+ * take only the stylesheet as argument and not a compilation context.
+ */
+struct _xsltStylesheet {
+    /*
+     * The stylesheet import relation is kept as a tree.
+     */
+    struct _xsltStylesheet *parent;
+    struct _xsltStylesheet *next;
+    struct _xsltStylesheet *imports;
+
+    xsltDocumentPtr docList;           /* the include document list */
+
+    /*
+     * General data on the style sheet document.
+     */
+    xmlDocPtr doc;             /* the parsed XML stylesheet */
+    xmlHashTablePtr stripSpaces;/* the hash table of the strip-space and
+                                  preserve space elements */
+    int             stripAll;  /* strip-space * (1) preserve-space * (-1) */
+    xmlHashTablePtr cdataSection;/* the hash table of the cdata-section */
+
+    /*
+     * Global variable or parameters.
+     */
+    xsltStackElemPtr variables; /* linked list of param and variables */
+
+    /*
+     * Template descriptions.
+     */
+    xsltTemplatePtr templates; /* the ordered list of templates */
+    void *templatesHash;       /* hash table or wherever compiled templates
+                                  informations are stored */
+    void *rootMatch;           /* template based on / */
+    void *keyMatch;            /* template based on key() */
+    void *elemMatch;           /* template based on * */
+    void *attrMatch;           /* template based on @* */
+    void *parentMatch;         /* template based on .. */
+    void *textMatch;           /* template based on text() */
+    void *piMatch;             /* template based on processing-instruction() */
+    void *commentMatch;                /* template based on comment() */
+    
+    /*
+     * Namespace aliases.
+     * NOTE: Not used in the refactored code.
+     */
+    xmlHashTablePtr nsAliases; /* the namespace alias hash tables */
+
+    /*
+     * Attribute sets.
+     */
+    xmlHashTablePtr attributeSets;/* the attribute sets hash tables */
+
+    /*
+     * Namespaces.
+     * TODO: Eliminate this.
+     */
+    xmlHashTablePtr nsHash;     /* the set of namespaces in use:
+                                   ATTENTION: This is used for
+                                   execution of XPath expressions; unfortunately
+                                   it restricts the stylesheet to have distinct
+                                   prefixes.
+                                  TODO: We need to get rid of this.    
+                                */
+    void           *nsDefs;     /* ATTENTION TODO: This is currently used to store
+                                  xsltExtDefPtr (in extensions.c) and
+                                   *not* xmlNsPtr.
+                                */
+
+    /*
+     * Key definitions.
+     */
+    void *keys;                        /* key definitions */
+
+    /*
+     * Output related stuff.
+     */
+    xmlChar *method;           /* the output method */
+    xmlChar *methodURI;                /* associated namespace if any */
+    xmlChar *version;          /* version string */
+    xmlChar *encoding;         /* encoding string */
+    int omitXmlDeclaration;     /* omit-xml-declaration = "yes" | "no" */
+
+    /* 
+     * Number formatting.
+     */
+    xsltDecimalFormatPtr decimalFormat;
+    int standalone;             /* standalone = "yes" | "no" */
+    xmlChar *doctypePublic;     /* doctype-public string */
+    xmlChar *doctypeSystem;     /* doctype-system string */
+    int indent;                        /* should output being indented */
+    xmlChar *mediaType;                /* media-type string */
+
+    /*
+     * Precomputed blocks.
+     */
+    xsltElemPreCompPtr preComps;/* list of precomputed blocks */
+    int warnings;              /* number of warnings found at compilation */
+    int errors;                        /* number of errors found at compilation */
+
+    xmlChar  *exclPrefix;      /* last excluded prefixes */
+    xmlChar **exclPrefixTab;   /* array of excluded prefixes */
+    int       exclPrefixNr;    /* number of excluded prefixes in scope */
+    int       exclPrefixMax;   /* size of the array */
+
+    void     *_private;                /* user defined data */
+
+    /*
+     * Extensions.
+     */
+    xmlHashTablePtr extInfos;  /* the extension data */
+    int                    extrasNr;   /* the number of extras required */
+
+    /*
+     * For keeping track of nested includes
+     */
+    xsltDocumentPtr includes;  /* points to last nested include */
+
+    /*
+     * dictionary: shared between stylesheet, context and documents.
+     */
+    xmlDictPtr dict;
+    /*
+     * precompiled attribute value templates.
+     */
+    void *attVTs;
+    /*
+     * if namespace-alias has an alias for the default stylesheet prefix
+     * NOTE: Not used in the refactored code.
+     */
+    const xmlChar *defaultAlias;
+    /*
+     * bypass pre-processing (already done) (used in imports)
+     */
+    int nopreproc;
+    /*
+     * all document text strings were internalized
+     */
+    int internalized;
+    /*
+     * Literal Result Element as Stylesheet c.f. section 2.3
+     */
+    int literal_result;
+    /*
+    * The principal stylesheet
+    */
+    xsltStylesheetPtr principal;
+#ifdef XSLT_REFACTORED
+    /*
+    * Compilation context used during compile-time.
+    */
+    xsltCompilerCtxtPtr compCtxt; /* TODO: Change this to (void *). */
+
+    xsltPrincipalStylesheetDataPtr principalData;    
+#endif
+};
+
+typedef struct _xsltTransformCache xsltTransformCache;
+typedef xsltTransformCache *xsltTransformCachePtr;
+struct _xsltTransformCache {
+    xmlDocPtr RVT;
+    int nbRVT;
+    xsltStackElemPtr stackItems;
+    int nbStackItems;
+#ifdef XSLT_DEBUG_PROFILE_CACHE
+    int dbgCachedRVTs;
+    int dbgReusedRVTs;
+    int dbgCachedVars;
+    int dbgReusedVars;
+#endif
+};
+
+/*
+ * The in-memory structure corresponding to an XSLT Transformation.
+ */
+typedef enum {
+    XSLT_OUTPUT_XML = 0,
+    XSLT_OUTPUT_HTML,
+    XSLT_OUTPUT_TEXT
+} xsltOutputType;
+
+typedef enum {
+    XSLT_STATE_OK = 0,
+    XSLT_STATE_ERROR,
+    XSLT_STATE_STOPPED
+} xsltTransformState;
+
+struct _xsltTransformContext {
+    xsltStylesheetPtr style;           /* the stylesheet used */
+    xsltOutputType type;               /* the type of output */
+
+    xsltTemplatePtr  templ;            /* the current template */
+    int              templNr;          /* Nb of templates in the stack */
+    int              templMax;         /* Size of the templtes stack */
+    xsltTemplatePtr *templTab;         /* the template stack */
+
+    xsltStackElemPtr  vars;            /* the current variable list */
+    int               varsNr;          /* Nb of variable list in the stack */
+    int               varsMax;         /* Size of the variable list stack */
+    xsltStackElemPtr *varsTab;         /* the variable list stack */
+    int               varsBase;                /* the var base for current templ */
+
+    /*
+     * Extensions
+     */
+    xmlHashTablePtr   extFunctions;    /* the extension functions */
+    xmlHashTablePtr   extElements;     /* the extension elements */
+    xmlHashTablePtr   extInfos;                /* the extension data */
+
+    const xmlChar *mode;               /* the current mode */
+    const xmlChar *modeURI;            /* the current mode URI */
+
+    xsltDocumentPtr docList;           /* the document list */
+
+    xsltDocumentPtr document;          /* the current source document; can be NULL if an RTF */
+    xmlNodePtr node;                   /* the current node being processed */
+    xmlNodeSetPtr nodeList;            /* the current node list */
+    /* xmlNodePtr current;                     the node */
+
+    xmlDocPtr output;                  /* the resulting document */
+    xmlNodePtr insert;                 /* the insertion node */
+
+    xmlXPathContextPtr xpathCtxt;      /* the XPath context */
+    xsltTransformState state;          /* the current state */
+
+    /*
+     * Global variables
+     */
+    xmlHashTablePtr   globalVars;      /* the global variables and params */
+
+    xmlNodePtr inst;                   /* the instruction in the stylesheet */
+
+    int xinclude;                      /* should XInclude be processed */
+
+    const char *      outputFile;      /* the output URI if known */
+
+    int profile;                        /* is this run profiled */
+    long             prof;             /* the current profiled value */
+    int              profNr;           /* Nb of templates in the stack */
+    int              profMax;          /* Size of the templtaes stack */
+    long            *profTab;          /* the profile template stack */
+
+    void            *_private;         /* user defined data */
+
+    int              extrasNr;         /* the number of extras used */
+    int              extrasMax;                /* the number of extras allocated */
+    xsltRuntimeExtraPtr extras;                /* extra per runtime informations */
+
+    xsltDocumentPtr  styleList;                /* the stylesheet docs list */
+    void                 * sec;                /* the security preferences if any */
+
+    xmlGenericErrorFunc  error;                /* a specific error handler */
+    void              * errctx;                /* context for the error handler */
+
+    xsltSortFunc      sortfunc;                /* a ctxt specific sort routine */
+
+    /*
+     * handling of temporary Result Value Tree
+     * (XSLT 1.0 term: "Result Tree Fragment")
+     */
+    xmlDocPtr       tmpRVT;            /* list of RVT without persistance */
+    xmlDocPtr       persistRVT;                /* list of persistant RVTs */
+    int             ctxtflags;          /* context processing flags */
+
+    /*
+     * Speed optimization when coalescing text nodes
+     */
+    const xmlChar  *lasttext;          /* last text node content */
+    unsigned int    lasttsize;         /* last text node size */
+    unsigned int    lasttuse;          /* last text node use */
+    /*
+     * Per Context Debugging
+     */
+    int debugStatus;                   /* the context level debug status */
+    unsigned long* traceCode;          /* pointer to the variable holding the mask */
+
+    int parserOptions;                 /* parser options xmlParserOption */
+
+    /*
+     * dictionary: shared between stylesheet, context and documents.
+     */
+    xmlDictPtr dict;
+    xmlDocPtr          tmpDoc; /* Obsolete; not used in the library. */
+    /*
+     * all document text strings are internalized
+     */
+    int internalized;
+    int nbKeys;
+    int hasTemplKeyPatterns;
+    xsltTemplatePtr currentTemplateRule; /* the Current Template Rule */
+    xmlNodePtr initialContextNode;
+    xmlDocPtr initialContextDoc;
+    xsltTransformCachePtr cache;
+    void *contextVariable; /* the current variable item */
+    xmlDocPtr localRVT; /* list of local tree fragments; will be freed when
+                          the instruction which created the fragment
+                           exits */
+    xmlDocPtr localRVTBase;
+    int keyInitLevel;   /* Needed to catch recursive keys issues */
+};
+
+/**
+ * CHECK_STOPPED:
+ *
+ * Macro to check if the XSLT processing should be stopped.
+ * Will return from the function.
+ */
+#define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return;
+
+/**
+ * CHECK_STOPPEDE:
+ *
+ * Macro to check if the XSLT processing should be stopped.
+ * Will goto the error: label.
+ */
+#define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error;
+
+/**
+ * CHECK_STOPPED0:
+ *
+ * Macro to check if the XSLT processing should be stopped.
+ * Will return from the function with a 0 value.
+ */
+#define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);
+
+/*
+ * The macro XML_CAST_FPTR is a hack to avoid a gcc warning about
+ * possible incompatibilities between function pointers and object
+ * pointers.  It is defined in libxml/hash.h within recent versions
+ * of libxml2, but is put here for compatibility.
+ */
+#ifndef XML_CAST_FPTR
+/**
+ * XML_CAST_FPTR:
+ * @fptr:  pointer to a function
+ *
+ * Macro to do a casting from an object pointer to a
+ * function pointer without encountering a warning from
+ * gcc
+ *
+ * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))
+ * This macro violated ISO C aliasing rules (gcc4 on s390 broke)
+ * so it is disabled now
+ */
+
+#define XML_CAST_FPTR(fptr) fptr
+#endif
+/*
+ * Functions associated to the internal types
+xsltDecimalFormatPtr   xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,
+                                                  xmlChar *name);
+ */
+XSLTPUBFUN xsltStylesheetPtr XSLTCALL  
+                       xsltNewStylesheet       (void);
+XSLTPUBFUN xsltStylesheetPtr XSLTCALL  
+                       xsltParseStylesheetFile (const xmlChar* filename);
+XSLTPUBFUN void XSLTCALL                       
+                       xsltFreeStylesheet      (xsltStylesheetPtr style);
+XSLTPUBFUN int XSLTCALL                        
+                       xsltIsBlank             (xmlChar *str);
+XSLTPUBFUN void XSLTCALL                       
+                       xsltFreeStackElemList   (xsltStackElemPtr elem);
+XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL       
+                       xsltDecimalFormatGetByName(xsltStylesheetPtr style,
+                                                xmlChar *name);
+
+XSLTPUBFUN xsltStylesheetPtr XSLTCALL  
+                       xsltParseStylesheetProcess(xsltStylesheetPtr ret,
+                                                xmlDocPtr doc);
+XSLTPUBFUN void XSLTCALL                       
+                       xsltParseStylesheetOutput(xsltStylesheetPtr style,
+                                                xmlNodePtr cur);
+XSLTPUBFUN xsltStylesheetPtr XSLTCALL  
+                       xsltParseStylesheetDoc  (xmlDocPtr doc);
+XSLTPUBFUN xsltStylesheetPtr XSLTCALL  
+                       xsltParseStylesheetImportedDoc(xmlDocPtr doc,
+                                               xsltStylesheetPtr style);
+XSLTPUBFUN xsltStylesheetPtr XSLTCALL  
+                       xsltLoadStylesheetPI    (xmlDocPtr doc);
+XSLTPUBFUN void XSLTCALL                       
+                       xsltNumberFormat        (xsltTransformContextPtr ctxt,
+                                                xsltNumberDataPtr data,
+                                                xmlNodePtr node);
+XSLTPUBFUN xmlXPathError XSLTCALL               
+                       xsltFormatNumberConversion(xsltDecimalFormatPtr self,
+                                                xmlChar *format,
+                                                double number,
+                                                xmlChar **result);
+
+XSLTPUBFUN void XSLTCALL                       
+                       xsltParseTemplateContent(xsltStylesheetPtr style,
+                                                xmlNodePtr templ);
+XSLTPUBFUN int XSLTCALL                        
+                       xsltAllocateExtra       (xsltStylesheetPtr style);
+XSLTPUBFUN int XSLTCALL                        
+                       xsltAllocateExtraCtxt   (xsltTransformContextPtr ctxt);
+/*
+ * Extra functions for Result Value Trees
+ */
+XSLTPUBFUN xmlDocPtr XSLTCALL          
+                       xsltCreateRVT           (xsltTransformContextPtr ctxt);
+XSLTPUBFUN int XSLTCALL                        
+                       xsltRegisterTmpRVT      (xsltTransformContextPtr ctxt,
+                                                xmlDocPtr RVT);
+XSLTPUBFUN int XSLTCALL                        
+                       xsltRegisterLocalRVT    (xsltTransformContextPtr ctxt,
+                                                xmlDocPtr RVT);
+XSLTPUBFUN int XSLTCALL                        
+                       xsltRegisterPersistRVT  (xsltTransformContextPtr ctxt,
+                                                xmlDocPtr RVT);
+XSLTPUBFUN int XSLTCALL
+                       xsltExtensionInstructionResultRegister(
+                                                xsltTransformContextPtr ctxt,
+                                                xmlXPathObjectPtr obj);
+XSLTPUBFUN int XSLTCALL
+                       xsltExtensionInstructionResultFinalize(
+                                                xsltTransformContextPtr ctxt);
+XSLTPUBFUN void XSLTCALL
+                       xsltFreeRVTs            (xsltTransformContextPtr ctxt);
+XSLTPUBFUN void XSLTCALL
+                       xsltReleaseRVT          (xsltTransformContextPtr ctxt,
+                                                xmlDocPtr RVT);
+XSLTPUBFUN int XSLTCALL
+                       xsltTransStorageAdd     (xsltTransformContextPtr ctxt,
+                                                void *id,
+                                                void *data);
+XSLTPUBFUN void * XSLTCALL
+                       xsltTransStorageRemove  (xsltTransformContextPtr ctxt,
+                                                void *id);
+
+/*
+ * Extra functions for Attribute Value Templates
+ */
+XSLTPUBFUN void XSLTCALL
+                       xsltCompileAttr         (xsltStylesheetPtr style,
+                                                xmlAttrPtr attr);
+XSLTPUBFUN xmlChar * XSLTCALL
+                       xsltEvalAVT             (xsltTransformContextPtr ctxt,
+                                                void *avt,
+                                                xmlNodePtr node);
+XSLTPUBFUN void XSLTCALL
+                       xsltFreeAVTList         (void *avt);
+
+/*
+ * Extra function for successful xsltCleanupGlobals / xsltInit sequence.
+ */
+
+XSLTPUBFUN void XSLTCALL
+                       xsltUninit              (void);
+
+/************************************************************************
+ *                                                                     *
+ *  Compile-time functions for *internal* use only                      *
+ *                                                                     *
+ ************************************************************************/
+
+#ifdef XSLT_REFACTORED  
+XSLTPUBFUN void XSLTCALL
+                       xsltParseSequenceConstructor(
+                                                xsltCompilerCtxtPtr cctxt,
+                                                xmlNodePtr start);
+XSLTPUBFUN int XSLTCALL
+                       xsltParseAnyXSLTElem    (xsltCompilerCtxtPtr cctxt,
+                                                xmlNodePtr elem);
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+XSLTPUBFUN int XSLTCALL
+                       xsltRestoreDocumentNamespaces(
+                                                xsltNsMapPtr ns,
+                                                xmlDocPtr doc);
+#endif
+#endif /* XSLT_REFACTORED */
+
+/************************************************************************
+ *                                                                     *
+ *  Transformation-time functions for *internal* use only               *
+ *                                                                     *
+ ************************************************************************/
+XSLTPUBFUN int XSLTCALL
+                       xsltInitCtxtKey         (xsltTransformContextPtr ctxt,
+                                                xsltDocumentPtr doc,
+                                                xsltKeyDefPtr keyd);
+XSLTPUBFUN int XSLTCALL
+                       xsltInitAllDocKeys      (xsltTransformContextPtr ctxt);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_H__ */
+
diff --git a/reactos/dll/3rdparty/libxslt/xsltconfig.h b/reactos/dll/3rdparty/libxslt/xsltconfig.h
new file mode 100644 (file)
index 0000000..777e3ac
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * Summary: compile-time version informations for the XSLT engine
+ * Description: compile-time version informations for the XSLT engine
+ *              this module is autogenerated.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLTCONFIG_H__
+#define __XML_XSLTCONFIG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * LIBXSLT_DOTTED_VERSION:
+ *
+ * the version string like "1.2.3"
+ */
+#define LIBXSLT_DOTTED_VERSION "1.1.24"
+
+/**
+ * LIBXSLT_VERSION:
+ *
+ * the version number: 1.2.3 value is 10203
+ */
+#define LIBXSLT_VERSION 10124
+
+/**
+ * LIBXSLT_VERSION_STRING:
+ *
+ * the version number string, 1.2.3 value is "10203"
+ */
+#define LIBXSLT_VERSION_STRING "10124"
+
+/**
+ * LIBXSLT_VERSION_EXTRA:
+ *
+ * extra version information, used to show a CVS compilation
+ */
+#define        LIBXSLT_VERSION_EXTRA "-CVS1070"
+
+/**
+ * WITH_XSLT_DEBUG:
+ *
+ * Activate the compilation of the debug reporting. Speed penalty
+ * is insignifiant and being able to run xsltpoc -v is useful. On
+ * by default unless --without-debug is passed to configure
+ */
+#if 1
+#define WITH_XSLT_DEBUG
+#endif
+
+#if 1
+/**
+ * DEBUG_MEMORY:
+ *
+ * should be activated only when debugging libxslt. It replaces the
+ * allocator with a collect and debug shell to the libc allocator.
+ * Use configure --with-mem-debug to activate it on both library
+ */
+#define DEBUG_MEMORY
+
+/**
+ * DEBUG_MEMORY_LOCATION:
+ *
+ * should be activated only when debugging libxslt.
+ * DEBUG_MEMORY_LOCATION should be activated only when libxml has
+ * been configured with --with-debug-mem too
+ */
+#define DEBUG_MEMORY_LOCATION
+#endif
+
+/**
+ * XSLT_NEED_TRIO:
+ *
+ * should be activated if the existing libc library lacks some of the
+ * string formatting function, in that case reuse the Trio ones already
+ * compiled in the libxml2 library.
+ */
+
+#if 0
+#define XSLT_NEED_TRIO
+#endif
+#ifdef __VMS
+#define HAVE_MATH_H 1
+#define HAVE_SYS_STAT_H 1
+#ifndef XSLT_NEED_TRIO
+#define XSLT_NEED_TRIO
+#endif
+#endif
+
+#ifdef XSLT_NEED_TRIO
+#define        TRIO_REPLACE_STDIO
+#endif
+
+/**
+ * WITH_XSLT_DEBUGGER:
+ *
+ * Activate the compilation of the debugger support. Speed penalty
+ * is insignifiant.
+ * On by default unless --without-debugger is passed to configure
+ */
+#if 1
+#ifndef WITH_DEBUGGER
+#define WITH_DEBUGGER
+#endif
+#endif
+
+/**
+ * WITH_MODULES:
+ *
+ * Whether module support is configured into libxslt
+ * Note: no default module path for win32 platforms
+ */
+#if 0
+#ifndef WITH_MODULES
+#define WITH_MODULES
+#endif
+#define LIBXSLT_DEFAULT_PLUGINS_PATH() "/usr/lib/libxslt-plugins"
+#endif
+
+/**
+ * ATTRIBUTE_UNUSED:
+ *
+ * This macro is used to flag unused function parameters to GCC
+ */
+#ifdef __GNUC__
+#ifdef HAVE_ANSIDECL_H
+#include <ansidecl.h>
+#endif
+#ifndef ATTRIBUTE_UNUSED
+#define ATTRIBUTE_UNUSED __attribute__((unused))
+#endif
+#else
+#define ATTRIBUTE_UNUSED
+#endif
+
+/**
+ * LIBXSLT_PUBLIC:
+ *
+ * This macro is used to declare PUBLIC variables for Cygwin and for MSC on Windows
+ */
+#if !defined LIBXSLT_PUBLIC
+#if (defined(__CYGWIN__) || defined _MSC_VER) && !defined IN_LIBXSLT && !defined LIBXSLT_STATIC
+#define LIBXSLT_PUBLIC __declspec(dllimport)
+#else
+#define LIBXSLT_PUBLIC
+#endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLTCONFIG_H__ */
diff --git a/reactos/dll/3rdparty/libxslt/xsltconfig.h.in b/reactos/dll/3rdparty/libxslt/xsltconfig.h.in
new file mode 100644 (file)
index 0000000..a8b5acf
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * Summary: compile-time version informations for the XSLT engine
+ * Description: compile-time version informations for the XSLT engine
+ *              this module is autogenerated.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLTCONFIG_H__
+#define __XML_XSLTCONFIG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * LIBXSLT_DOTTED_VERSION:
+ *
+ * the version string like "1.2.3"
+ */
+#define LIBXSLT_DOTTED_VERSION "@VERSION@"
+
+/**
+ * LIBXSLT_VERSION:
+ *
+ * the version number: 1.2.3 value is 10203
+ */
+#define LIBXSLT_VERSION @LIBXSLT_VERSION_NUMBER@
+
+/**
+ * LIBXSLT_VERSION_STRING:
+ *
+ * the version number string, 1.2.3 value is "10203"
+ */
+#define LIBXSLT_VERSION_STRING "@LIBXSLT_VERSION_NUMBER@"
+
+/**
+ * LIBXSLT_VERSION_EXTRA:
+ *
+ * extra version information, used to show a CVS compilation
+ */
+#define        LIBXSLT_VERSION_EXTRA "@LIBXSLT_VERSION_EXTRA@"
+
+/**
+ * WITH_XSLT_DEBUG:
+ *
+ * Activate the compilation of the debug reporting. Speed penalty
+ * is insignifiant and being able to run xsltpoc -v is useful. On
+ * by default unless --without-debug is passed to configure
+ */
+#if @WITH_XSLT_DEBUG@
+#define WITH_XSLT_DEBUG
+#endif
+
+#if @WITH_MEM_DEBUG@
+/**
+ * DEBUG_MEMORY:
+ *
+ * should be activated only when debugging libxslt. It replaces the
+ * allocator with a collect and debug shell to the libc allocator.
+ * Use configure --with-mem-debug to activate it on both library
+ */
+#define DEBUG_MEMORY
+
+/**
+ * DEBUG_MEMORY_LOCATION:
+ *
+ * should be activated only when debugging libxslt.
+ * DEBUG_MEMORY_LOCATION should be activated only when libxml has
+ * been configured with --with-debug-mem too
+ */
+#define DEBUG_MEMORY_LOCATION
+#endif
+
+/**
+ * XSLT_NEED_TRIO:
+ *
+ * should be activated if the existing libc library lacks some of the
+ * string formatting function, in that case reuse the Trio ones already
+ * compiled in the libxml2 library.
+ */
+
+#if @WITH_TRIO@
+#define XSLT_NEED_TRIO
+#endif
+#ifdef __VMS
+#define HAVE_MATH_H 1
+#define HAVE_SYS_STAT_H 1
+#ifndef XSLT_NEED_TRIO
+#define XSLT_NEED_TRIO
+#endif
+#endif
+
+#ifdef XSLT_NEED_TRIO
+#define        TRIO_REPLACE_STDIO
+#endif
+
+/**
+ * WITH_XSLT_DEBUGGER:
+ *
+ * Activate the compilation of the debugger support. Speed penalty
+ * is insignifiant.
+ * On by default unless --without-debugger is passed to configure
+ */
+#if @WITH_DEBUGGER@
+#ifndef WITH_DEBUGGER
+#define WITH_DEBUGGER
+#endif
+#endif
+
+/**
+ * WITH_MODULES:
+ *
+ * Whether module support is configured into libxslt
+ * Note: no default module path for win32 platforms
+ */
+#if @WITH_MODULES@
+#ifndef WITH_MODULES
+#define WITH_MODULES
+#endif
+#define LIBXSLT_DEFAULT_PLUGINS_PATH() "@LIBXSLT_DEFAULT_PLUGINS_PATH@"
+#endif
+
+/**
+ * ATTRIBUTE_UNUSED:
+ *
+ * This macro is used to flag unused function parameters to GCC
+ */
+#ifdef __GNUC__
+#ifdef HAVE_ANSIDECL_H
+#include <ansidecl.h>
+#endif
+#ifndef ATTRIBUTE_UNUSED
+#define ATTRIBUTE_UNUSED __attribute__((unused))
+#endif
+#else
+#define ATTRIBUTE_UNUSED
+#endif
+
+/**
+ * LIBXSLT_PUBLIC:
+ *
+ * This macro is used to declare PUBLIC variables for Cygwin and for MSC on Windows
+ */
+#if !defined LIBXSLT_PUBLIC
+#if (defined(__CYGWIN__) || defined _MSC_VER) && !defined IN_LIBXSLT && !defined LIBXSLT_STATIC
+#define LIBXSLT_PUBLIC __declspec(dllimport)
+#else
+#define LIBXSLT_PUBLIC
+#endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLTCONFIG_H__ */
diff --git a/reactos/dll/3rdparty/libxslt/xsltexports.h b/reactos/dll/3rdparty/libxslt/xsltexports.h
new file mode 100644 (file)
index 0000000..825c122
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * Summary: macros for marking symbols as exportable/importable.
+ * Description: macros for marking symbols as exportable/importable.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Igor Zlatkovic <igor@zlatkovic.com>
+ */
+
+#ifndef __XSLT_EXPORTS_H__
+#define __XSLT_EXPORTS_H__
+
+/**
+ * XSLTPUBFUN:
+ * XSLTPUBFUN, XSLTPUBVAR, XSLTCALL
+ *
+ * Macros which declare an exportable function, an exportable variable and
+ * the calling convention used for functions.
+ *
+ * Please use an extra block for every platform/compiler combination when
+ * modifying this, rather than overlong #ifdef lines. This helps
+ * readability as well as the fact that different compilers on the same
+ * platform might need different definitions.
+ */
+
+/**
+ * XSLTPUBFUN:
+ *
+ * Macros which declare an exportable function
+ */
+#define XSLTPUBFUN
+/**
+ * XSLTPUBVAR:
+ *
+ * Macros which declare an exportable variable
+ */
+#define XSLTPUBVAR extern
+/**
+ * XSLTCALL:
+ *
+ * Macros which declare the called convention for exported functions
+ */
+#define XSLTCALL
+
+/** DOC_DISABLE */
+
+/* Windows platform with MS compiler */
+#if defined(_WIN32) && defined(_MSC_VER)
+  #undef XSLTPUBFUN
+  #undef XSLTPUBVAR
+  #undef XSLTCALL
+  #if defined(IN_LIBXSLT) && !defined(LIBXSLT_STATIC)
+    #define XSLTPUBFUN __declspec(dllexport)
+    #define XSLTPUBVAR __declspec(dllexport)
+  #else
+    #define XSLTPUBFUN
+    #if !defined(LIBXSLT_STATIC)
+      #define XSLTPUBVAR __declspec(dllimport) extern
+    #else
+      #define XSLTPUBVAR extern
+    #endif
+  #endif
+  #define XSLTCALL __cdecl
+  #if !defined _REENTRANT
+    #define _REENTRANT
+  #endif
+#endif
+
+/* Windows platform with Borland compiler */
+#if defined(_WIN32) && defined(__BORLANDC__)
+  #undef XSLTPUBFUN
+  #undef XSLTPUBVAR
+  #undef XSLTCALL
+  #if defined(IN_LIBXSLT) && !defined(LIBXSLT_STATIC)
+    #define XSLTPUBFUN __declspec(dllexport)
+    #define XSLTPUBVAR __declspec(dllexport) extern
+  #else
+    #define XSLTPUBFUN
+    #if !defined(LIBXSLT_STATIC)
+      #define XSLTPUBVAR __declspec(dllimport) extern
+    #else
+      #define XSLTPUBVAR extern
+    #endif
+  #endif
+  #define XSLTCALL __cdecl
+  #if !defined _REENTRANT
+    #define _REENTRANT
+  #endif
+#endif
+
+/* Windows platform with GNU compiler (Mingw) */
+#if defined(_WIN32) && defined(__MINGW32__)
+  #undef XSLTPUBFUN
+  #undef XSLTPUBVAR
+  #undef XSLTCALL
+/*
+  #if defined(IN_LIBXSLT) && !defined(LIBXSLT_STATIC)
+*/
+  #if !defined(LIBXSLT_STATIC)
+    #define XSLTPUBFUN __declspec(dllexport)
+    #define XSLTPUBVAR __declspec(dllexport) extern
+  #else
+    #define XSLTPUBFUN
+    #if !defined(LIBXSLT_STATIC)
+      #define XSLTPUBVAR __declspec(dllimport) extern
+    #else
+      #define XSLTPUBVAR extern
+    #endif
+  #endif
+  #define XSLTCALL __cdecl
+  #if !defined _REENTRANT
+    #define _REENTRANT
+  #endif
+#endif
+
+/* Cygwin platform, GNU compiler */
+#if defined(_WIN32) && defined(__CYGWIN__)
+  #undef XSLTPUBFUN
+  #undef XSLTPUBVAR
+  #undef XSLTCALL
+  #if defined(IN_LIBXSLT) && !defined(LIBXSLT_STATIC)
+    #define XSLTPUBFUN __declspec(dllexport)
+    #define XSLTPUBVAR __declspec(dllexport)
+  #else
+    #define XSLTPUBFUN
+    #if !defined(LIBXSLT_STATIC)
+      #define XSLTPUBVAR __declspec(dllimport) extern
+    #else
+      #define XSLTPUBVAR
+    #endif
+  #endif
+  #define XSLTCALL __cdecl
+#endif
+
+/* Compatibility */
+#if !defined(LIBXSLT_PUBLIC)
+#define LIBXSLT_PUBLIC XSLTPUBVAR
+#endif
+
+#endif /* __XSLT_EXPORTS_H__ */
+
+
diff --git a/reactos/dll/3rdparty/libxslt/xsltutils.c b/reactos/dll/3rdparty/libxslt/xsltutils.c
new file mode 100644 (file)
index 0000000..603b22e
--- /dev/null
@@ -0,0 +1,2265 @@
+/*
+ * xsltutils.c: Utilities for the XSL Transformation 1.0 engine
+ *
+ * Reference:
+ *   http://www.w3.org/TR/1999/REC-xslt-19991116
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXSLT
+#include "libxslt.h"
+
+#ifndef        XSLT_NEED_TRIO
+#include <stdio.h>
+#else
+#include <trio.h>
+#endif
+
+#include <string.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#include <stdarg.h>
+
+#include <libxml/xmlmemory.h>
+#include <libxml/tree.h>
+#include <libxml/HTMLtree.h>
+#include <libxml/xmlerror.h>
+#include <libxml/xmlIO.h>
+#include "xsltutils.h"
+#include "templates.h"
+#include "xsltInternals.h"
+#include "imports.h"
+#include "transform.h"
+
+/* gettimeofday on Windows ??? */
+#if defined(WIN32) && !defined(__CYGWIN__)
+#ifdef _MSC_VER
+#include <winsock2.h>
+#pragma comment(lib, "ws2_32.lib")
+#define gettimeofday(p1,p2)
+#define HAVE_GETTIMEOFDAY
+#define XSLT_WIN32_PERFORMANCE_COUNTER
+#endif /* _MS_VER */
+#endif /* WIN32 */
+
+/************************************************************************
+ *                                                                     *
+ *                     Convenience function                            *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltGetCNsProp:
+ * @style: the stylesheet
+ * @node:  the node
+ * @name:  the attribute name
+ * @nameSpace:  the URI of the namespace
+ *
+ * Similar to xmlGetNsProp() but with a slightly different semantic
+ *
+ * Search and get the value of an attribute associated to a node
+ * This attribute has to be anchored in the namespace specified,
+ * or has no namespace and the element is in that namespace.
+ *
+ * This does the entity substitution.
+ * This function looks in DTD attribute declaration for #FIXED or
+ * default declaration values unless DTD use has been turned off.
+ *
+ * Returns the attribute value or NULL if not found. The string is allocated
+ *         in the stylesheet dictionary.
+ */
+const xmlChar *
+xsltGetCNsProp(xsltStylesheetPtr style, xmlNodePtr node,
+              const xmlChar *name, const xmlChar *nameSpace) {
+    xmlAttrPtr prop;
+    xmlDocPtr doc;
+    xmlNsPtr ns;
+    xmlChar *tmp;
+    const xmlChar *ret;
+
+    if ((node == NULL) || (style == NULL) || (style->dict == NULL))
+       return(NULL);
+
+    prop = node->properties;
+    if (nameSpace == NULL) {
+        return xmlGetProp(node, name);
+    }
+    while (prop != NULL) {
+       /*
+        * One need to have
+        *   - same attribute names
+        *   - and the attribute carrying that namespace
+        */
+        if ((xmlStrEqual(prop->name, name)) &&
+           (((prop->ns == NULL) && (node->ns != NULL) &&
+             (xmlStrEqual(node->ns->href, nameSpace))) ||
+            ((prop->ns != NULL) &&
+             (xmlStrEqual(prop->ns->href, nameSpace))))) {
+
+           tmp = xmlNodeListGetString(node->doc, prop->children, 1);
+           if (tmp == NULL)
+               ret = xmlDictLookup(style->dict, BAD_CAST "", 0);
+           else {
+               ret = xmlDictLookup(style->dict, tmp, -1);
+               xmlFree(tmp);
+           }
+           return ret;
+        }
+       prop = prop->next;
+    }
+    tmp = NULL;
+    /*
+     * Check if there is a default declaration in the internal
+     * or external subsets
+     */
+    doc =  node->doc;
+    if (doc != NULL) {
+        if (doc->intSubset != NULL) {
+           xmlAttributePtr attrDecl;
+
+           attrDecl = xmlGetDtdAttrDesc(doc->intSubset, node->name, name);
+           if ((attrDecl == NULL) && (doc->extSubset != NULL))
+               attrDecl = xmlGetDtdAttrDesc(doc->extSubset, node->name, name);
+               
+           if ((attrDecl != NULL) && (attrDecl->prefix != NULL)) {
+               /*
+                * The DTD declaration only allows a prefix search
+                */
+               ns = xmlSearchNs(doc, node, attrDecl->prefix);
+               if ((ns != NULL) && (xmlStrEqual(ns->href, nameSpace)))
+                   return(xmlDictLookup(style->dict,
+                                        attrDecl->defaultValue, -1));
+           }
+       }
+    }
+    return(NULL);
+}
+/**
+ * xsltGetNsProp:
+ * @node:  the node
+ * @name:  the attribute name
+ * @nameSpace:  the URI of the namespace
+ *
+ * Similar to xmlGetNsProp() but with a slightly different semantic
+ *
+ * Search and get the value of an attribute associated to a node
+ * This attribute has to be anchored in the namespace specified,
+ * or has no namespace and the element is in that namespace.
+ *
+ * This does the entity substitution.
+ * This function looks in DTD attribute declaration for #FIXED or
+ * default declaration values unless DTD use has been turned off.
+ *
+ * Returns the attribute value or NULL if not found.
+ *     It's up to the caller to free the memory.
+ */
+xmlChar *
+xsltGetNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace) {
+    xmlAttrPtr prop;
+    xmlDocPtr doc;
+    xmlNsPtr ns;
+
+    if (node == NULL)
+       return(NULL);
+
+    prop = node->properties;
+    /*
+    * TODO: Substitute xmlGetProp() for xmlGetNsProp(), since the former
+    * is not namespace-aware and will return an attribute with equal
+    * name regardless of its namespace.
+    * Example:
+    *   <xsl:element foo:name="myName"/>
+    *   So this would return "myName" even if an attribute @name
+    *   in the XSLT was requested.
+    */
+    if (nameSpace == NULL)
+       return(xmlGetProp(node, name));
+    while (prop != NULL) {
+       /*
+        * One need to have
+        *   - same attribute names
+        *   - and the attribute carrying that namespace
+        */
+        if ((xmlStrEqual(prop->name, name)) &&
+           (((prop->ns == NULL) && (node->ns != NULL) &&
+             (xmlStrEqual(node->ns->href, nameSpace))) ||
+            ((prop->ns != NULL) &&
+             (xmlStrEqual(prop->ns->href, nameSpace))))) {
+           xmlChar *ret;
+
+           ret = xmlNodeListGetString(node->doc, prop->children, 1);
+           if (ret == NULL) return(xmlStrdup((xmlChar *)""));
+           return(ret);
+        }
+       prop = prop->next;
+    }
+
+    /*
+     * Check if there is a default declaration in the internal
+     * or external subsets
+     */
+    doc =  node->doc;
+    if (doc != NULL) {
+        if (doc->intSubset != NULL) {
+           xmlAttributePtr attrDecl;
+
+           attrDecl = xmlGetDtdAttrDesc(doc->intSubset, node->name, name);
+           if ((attrDecl == NULL) && (doc->extSubset != NULL))
+               attrDecl = xmlGetDtdAttrDesc(doc->extSubset, node->name, name);
+               
+           if ((attrDecl != NULL) && (attrDecl->prefix != NULL)) {
+               /*
+                * The DTD declaration only allows a prefix search
+                */
+               ns = xmlSearchNs(doc, node, attrDecl->prefix);
+               if ((ns != NULL) && (xmlStrEqual(ns->href, nameSpace)))
+                   return(xmlStrdup(attrDecl->defaultValue));
+           }
+       }
+    }
+    return(NULL);
+}
+
+/**
+ * xsltGetUTF8Char:
+ * @utf:  a sequence of UTF-8 encoded bytes
+ * @len:  a pointer to @bytes len
+ *
+ * Read one UTF8 Char from @utf
+ * Function copied from libxml2 xmlGetUTF8Char() ... to discard ultimately
+ * and use the original API
+ *
+ * Returns the char value or -1 in case of error and update @len with the
+ *        number of bytes used
+ */
+int
+xsltGetUTF8Char(const unsigned char *utf, int *len) {
+    unsigned int c;
+
+    if (utf == NULL)
+       goto error;
+    if (len == NULL)
+       goto error;
+    if (*len < 1)
+       goto error;
+
+    c = utf[0];
+    if (c & 0x80) {
+       if (*len < 2)
+           goto error;
+       if ((utf[1] & 0xc0) != 0x80)
+           goto error;
+       if ((c & 0xe0) == 0xe0) {
+           if (*len < 3)
+               goto error;
+           if ((utf[2] & 0xc0) != 0x80)
+               goto error;
+           if ((c & 0xf0) == 0xf0) {
+               if (*len < 4)
+                   goto error;
+               if ((c & 0xf8) != 0xf0 || (utf[3] & 0xc0) != 0x80)
+                   goto error;
+               *len = 4;
+               /* 4-byte code */
+               c = (utf[0] & 0x7) << 18;
+               c |= (utf[1] & 0x3f) << 12;
+               c |= (utf[2] & 0x3f) << 6;
+               c |= utf[3] & 0x3f;
+           } else {
+             /* 3-byte code */
+               *len = 3;
+               c = (utf[0] & 0xf) << 12;
+               c |= (utf[1] & 0x3f) << 6;
+               c |= utf[2] & 0x3f;
+           }
+       } else {
+         /* 2-byte code */
+           *len = 2;
+           c = (utf[0] & 0x1f) << 6;
+           c |= utf[1] & 0x3f;
+       }
+    } else {
+       /* 1-byte code */
+       *len = 1;
+    }
+    return(c);
+
+error:
+    if (len != NULL)
+       *len = 0;
+    return(-1);
+}
+
+#ifdef XSLT_REFACTORED
+
+/**
+ * xsltPointerListAddSize:
+ * @list: the pointer list structure
+ * @item: the item to be stored
+ * @initialSize: the initial size of the list
+ *
+ * Adds an item to the list.
+ *
+ * Returns the position of the added item in the list or
+ *         -1 in case of an error.
+ */
+int
+xsltPointerListAddSize(xsltPointerListPtr list,                       
+                      void *item,
+                      int initialSize)
+{
+    if (list->items == NULL) {
+       if (initialSize <= 0)
+           initialSize = 1;
+       list->items = (void **) xmlMalloc(
+           initialSize * sizeof(void *));
+       if (list->items == NULL) {
+           xsltGenericError(xsltGenericErrorContext,
+            "xsltPointerListAddSize: memory allocation failure.\n");
+           return(-1);
+       }
+       list->number = 0;
+       list->size = initialSize;
+    } else if (list->size <= list->number) {
+       list->size *= 2;
+       list->items = (void **) xmlRealloc(list->items,
+           list->size * sizeof(void *));
+       if (list->items == NULL) {
+           xsltGenericError(xsltGenericErrorContext,
+            "xsltPointerListAddSize: memory re-allocation failure.\n");
+           list->size = 0;
+           return(-1);
+       }
+    }
+    list->items[list->number++] = item;
+    return(0);
+}
+
+/**
+ * xsltPointerListCreate:
+ * @initialSize: the initial size for the list
+ *
+ * Creates an xsltPointerList structure.
+ *
+ * Returns a xsltPointerList structure or NULL in case of an error.
+ */
+xsltPointerListPtr
+xsltPointerListCreate(int initialSize)
+{
+    xsltPointerListPtr ret;
+
+    ret = xmlMalloc(sizeof(xsltPointerList));
+    if (ret == NULL) {
+       xsltGenericError(xsltGenericErrorContext,
+            "xsltPointerListCreate: memory allocation failure.\n");
+       return (NULL);
+    }
+    memset(ret, 0, sizeof(xsltPointerList));
+    if (initialSize > 0) {
+       xsltPointerListAddSize(ret, NULL, initialSize);
+       ret->number = 0;
+    }
+    return (ret);
+}
+
+/**
+ * xsltPointerListFree:
+ * @list: pointer to the list to be freed
+ *
+ * Frees the xsltPointerList structure. This does not free
+ * the content of the list.
+ */
+void
+xsltPointerListFree(xsltPointerListPtr list)
+{
+    if (list == NULL)
+       return;
+    if (list->items != NULL)
+       xmlFree(list->items);
+    xmlFree(list);
+}
+
+/**
+ * xsltPointerListClear:
+ * @list: pointer to the list to be cleared
+ *
+ * Resets the list, but does not free the allocated array
+ * and does not free the content of the list.
+ */
+void
+xsltPointerListClear(xsltPointerListPtr list)
+{
+    if (list->items != NULL) {
+       xmlFree(list->items);
+       list->items = NULL;
+    }
+    list->number = 0;
+    list->size = 0;
+}
+
+#endif /* XSLT_REFACTORED */
+
+/************************************************************************
+ *                                                                     *
+ *             Handling of XSLT stylesheets messages                   *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltMessage:
+ * @ctxt:  an XSLT processing context
+ * @node:  The current node
+ * @inst:  The node containing the message instruction
+ *
+ * Process and xsl:message construct
+ */
+void
+xsltMessage(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst) {
+    xmlGenericErrorFunc error = xsltGenericError;
+    void *errctx = xsltGenericErrorContext;
+    xmlChar *prop, *message;
+    int terminate = 0;
+
+    if ((ctxt == NULL) || (inst == NULL))
+       return;
+
+    if (ctxt->error != NULL) {
+       error = ctxt->error;
+       errctx = ctxt->errctx;
+    }
+
+    prop = xmlGetNsProp(inst, (const xmlChar *)"terminate", NULL);
+    if (prop != NULL) {
+       if (xmlStrEqual(prop, (const xmlChar *)"yes")) {
+           terminate = 1;
+       } else if (xmlStrEqual(prop, (const xmlChar *)"no")) {
+           terminate = 0;
+       } else {
+           error(errctx,
+               "xsl:message : terminate expecting 'yes' or 'no'\n");
+           ctxt->state = XSLT_STATE_ERROR;
+       }
+       xmlFree(prop);
+    }
+    message = xsltEvalTemplateString(ctxt, node, inst);
+    if (message != NULL) {
+       int len = xmlStrlen(message);
+
+       error(errctx, "%s", (const char *)message);
+       if ((len > 0) && (message[len - 1] != '\n'))
+           error(errctx, "\n");
+       xmlFree(message);
+    }
+    if (terminate)
+       ctxt->state = XSLT_STATE_STOPPED;
+}
+
+/************************************************************************
+ *                                                                     *
+ *             Handling of out of context errors                       *
+ *                                                                     *
+ ************************************************************************/
+
+#define XSLT_GET_VAR_STR(msg, str) {                           \
+    int       size;                                            \
+    int       chars;                                           \
+    char      *larger;                                         \
+    va_list   ap;                                              \
+                                                               \
+    str = (char *) xmlMalloc(150);                             \
+    if (str == NULL)                                           \
+       return;                                                 \
+                                                               \
+    size = 150;                                                        \
+                                                               \
+    while (size < 64000) {                                     \
+       va_start(ap, msg);                                      \
+       chars = vsnprintf(str, size, msg, ap);                  \
+       va_end(ap);                                             \
+       if ((chars > -1) && (chars < size))                     \
+           break;                                              \
+       if (chars > -1)                                         \
+           size += chars + 1;                                  \
+       else                                                    \
+           size += 100;                                        \
+       if ((larger = (char *) xmlRealloc(str, size)) == NULL) {\
+           xmlFree(str);                                       \
+           return;                                             \
+       }                                                       \
+       str = larger;                                           \
+    }                                                          \
+}
+/**
+ * xsltGenericErrorDefaultFunc:
+ * @ctx:  an error context
+ * @msg:  the message to display/transmit
+ * @...:  extra parameters for the message display
+ * 
+ * Default handler for out of context error messages.
+ */
+static void
+xsltGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
+    va_list args;
+
+    if (xsltGenericErrorContext == NULL)
+       xsltGenericErrorContext = (void *) stderr;
+
+    va_start(args, msg);
+    vfprintf((FILE *)xsltGenericErrorContext, msg, args);
+    va_end(args);
+}
+
+xmlGenericErrorFunc xsltGenericError = xsltGenericErrorDefaultFunc;
+void *xsltGenericErrorContext = NULL;
+
+
+/**
+ * xsltSetGenericErrorFunc:
+ * @ctx:  the new error handling context
+ * @handler:  the new handler function
+ *
+ * Function to reset the handler and the error context for out of
+ * context error messages.
+ * This simply means that @handler will be called for subsequent
+ * error messages while not parsing nor validating. And @ctx will
+ * be passed as first argument to @handler
+ * One can simply force messages to be emitted to another FILE * than
+ * stderr by setting @ctx to this file handle and @handler to NULL.
+ */
+void
+xsltSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
+    xsltGenericErrorContext = ctx;
+    if (handler != NULL)
+       xsltGenericError = handler;
+    else
+       xsltGenericError = xsltGenericErrorDefaultFunc;
+}
+
+/**
+ * xsltGenericDebugDefaultFunc:
+ * @ctx:  an error context
+ * @msg:  the message to display/transmit
+ * @...:  extra parameters for the message display
+ * 
+ * Default handler for out of context error messages.
+ */
+static void
+xsltGenericDebugDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
+    va_list args;
+
+    if (xsltGenericDebugContext == NULL)
+       return;
+
+    va_start(args, msg);
+    vfprintf((FILE *)xsltGenericDebugContext, msg, args);
+    va_end(args);
+}
+
+xmlGenericErrorFunc xsltGenericDebug = xsltGenericDebugDefaultFunc;
+void *xsltGenericDebugContext = NULL;
+
+
+/**
+ * xsltSetGenericDebugFunc:
+ * @ctx:  the new error handling context
+ * @handler:  the new handler function
+ *
+ * Function to reset the handler and the error context for out of
+ * context error messages.
+ * This simply means that @handler will be called for subsequent
+ * error messages while not parsing or validating. And @ctx will
+ * be passed as first argument to @handler
+ * One can simply force messages to be emitted to another FILE * than
+ * stderr by setting @ctx to this file handle and @handler to NULL.
+ */
+void
+xsltSetGenericDebugFunc(void *ctx, xmlGenericErrorFunc handler) {
+    xsltGenericDebugContext = ctx;
+    if (handler != NULL)
+       xsltGenericDebug = handler;
+    else
+       xsltGenericDebug = xsltGenericDebugDefaultFunc;
+}
+
+/**
+ * xsltPrintErrorContext:
+ * @ctxt:  the transformation context
+ * @style:  the stylesheet
+ * @node:  the current node being processed
+ *
+ * Display the context of an error.
+ */
+void
+xsltPrintErrorContext(xsltTransformContextPtr ctxt,
+                     xsltStylesheetPtr style, xmlNodePtr node) {
+    int line = 0;
+    const xmlChar *file = NULL;
+    const xmlChar *name = NULL;
+    const char *type = "error";
+    xmlGenericErrorFunc error = xsltGenericError;
+    void *errctx = xsltGenericErrorContext;
+
+    if (ctxt != NULL) {
+       ctxt->state = XSLT_STATE_ERROR;
+       if (ctxt->error != NULL) {
+           error = ctxt->error;
+           errctx = ctxt->errctx;
+       }
+    }
+    if ((node == NULL) && (ctxt != NULL))
+       node = ctxt->inst;
+
+    if (node != NULL)  {
+       if ((node->type == XML_DOCUMENT_NODE) ||
+           (node->type == XML_HTML_DOCUMENT_NODE)) {
+           xmlDocPtr doc = (xmlDocPtr) node;
+
+           file = doc->URL;
+       } else {
+           line = xmlGetLineNo(node);
+           if ((node->doc != NULL) && (node->doc->URL != NULL))
+               file = node->doc->URL;
+           if (node->name != NULL)
+               name = node->name;
+       }
+    } 
+    
+    if (ctxt != NULL)
+       type = "runtime error";
+    else if (style != NULL) {
+#ifdef XSLT_REFACTORED
+       if (XSLT_CCTXT(style)->errSeverity == XSLT_ERROR_SEVERITY_WARNING)
+           type = "compilation warning";
+       else
+           type = "compilation error";
+#else
+       type = "compilation error";
+#endif
+    }
+
+    if ((file != NULL) && (line != 0) && (name != NULL))
+       error(errctx, "%s: file %s line %d element %s\n",
+             type, file, line, name);
+    else if ((file != NULL) && (name != NULL))
+       error(errctx, "%s: file %s element %s\n", type, file, name);
+    else if ((file != NULL) && (line != 0))
+       error(errctx, "%s: file %s line %d\n", type, file, line);
+    else if (file != NULL)
+       error(errctx, "%s: file %s\n", type, file);
+    else if (name != NULL)
+       error(errctx, "%s: element %s\n", type, name);
+    else
+       error(errctx, "%s\n", type);
+}
+
+/**
+ * xsltSetTransformErrorFunc:
+ * @ctxt:  the XSLT transformation context
+ * @ctx:  the new error handling context
+ * @handler:  the new handler function
+ *
+ * Function to reset the handler and the error context for out of
+ * context error messages specific to a given XSLT transromation.
+ *
+ * This simply means that @handler will be called for subsequent
+ * error messages while running the transformation.
+ */
+void
+xsltSetTransformErrorFunc(xsltTransformContextPtr ctxt,
+                          void *ctx, xmlGenericErrorFunc handler)
+{
+    ctxt->error = handler;
+    ctxt->errctx = ctx;
+}
+
+/**
+ * xsltTransformError:
+ * @ctxt:  an XSLT transformation context
+ * @style:  the XSLT stylesheet used
+ * @node:  the current node in the stylesheet
+ * @msg:  the message to display/transmit
+ * @...:  extra parameters for the message display
+ *
+ * Display and format an error messages, gives file, line, position and
+ * extra parameters, will use the specific transformation context if available
+ */
+void
+xsltTransformError(xsltTransformContextPtr ctxt,
+                  xsltStylesheetPtr style,
+                  xmlNodePtr node,
+                  const char *msg, ...) {
+    xmlGenericErrorFunc error = xsltGenericError;
+    void *errctx = xsltGenericErrorContext;
+    char * str;
+
+    if (ctxt != NULL) {
+       ctxt->state = XSLT_STATE_ERROR;
+       if (ctxt->error != NULL) {
+           error = ctxt->error;
+           errctx = ctxt->errctx;
+       }
+    }
+    if ((node == NULL) && (ctxt != NULL))
+       node = ctxt->inst;
+    xsltPrintErrorContext(ctxt, style, node);
+    XSLT_GET_VAR_STR(msg, str);
+    error(errctx, "%s", str);
+    if (str != NULL)
+       xmlFree(str);
+}
+
+/************************************************************************
+ *                                                                     *
+ *                             QNames                                  *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltSplitQName:
+ * @dict: a dictionary
+ * @name:  the full QName
+ * @prefix: the return value
+ *
+ * Split QNames into prefix and local names, both allocated from a dictionary.
+ *
+ * Returns: the localname or NULL in case of error.
+ */
+const xmlChar *
+xsltSplitQName(xmlDictPtr dict, const xmlChar *name, const xmlChar **prefix) {
+    int len = 0;
+    const xmlChar *ret = NULL;
+
+    *prefix = NULL;
+    if ((name == NULL) || (dict == NULL)) return(NULL);
+    if (name[0] == ':')
+        return(xmlDictLookup(dict, name, -1));
+    while ((name[len] != 0) && (name[len] != ':')) len++;
+    if (name[len] == 0) return(xmlDictLookup(dict, name, -1));
+    *prefix = xmlDictLookup(dict, name, len);
+    ret = xmlDictLookup(dict, &name[len + 1], -1);
+    return(ret);
+}
+
+/**
+ * xsltGetQNameURI:
+ * @node:  the node holding the QName
+ * @name:  pointer to the initial QName value
+ *
+ * This function analyzes @name, if the name contains a prefix,
+ * the function seaches the associated namespace in scope for it.
+ * It will also replace @name value with the NCName, the old value being
+ * freed.
+ * Errors in the prefix lookup are signalled by setting @name to NULL.
+ *
+ * NOTE: the namespace returned is a pointer to the place where it is
+ *       defined and hence has the same lifespan as the document holding it.
+ *
+ * Returns the namespace URI if there is a prefix, or NULL if @name is
+ *         not prefixed.
+ */
+const xmlChar *
+xsltGetQNameURI(xmlNodePtr node, xmlChar ** name)
+{
+    int len = 0;
+    xmlChar *qname;
+    xmlNsPtr ns;
+
+    if (name == NULL)
+       return(NULL);
+    qname = *name;
+    if ((qname == NULL) || (*qname == 0))
+       return(NULL);
+    if (node == NULL) {
+       xsltGenericError(xsltGenericErrorContext,
+                        "QName: no element for namespace lookup %s\n",
+                        qname);
+       xmlFree(qname);
+       *name = NULL;
+       return(NULL);
+    }
+
+    /* nasty but valid */
+    if (qname[0] == ':')
+       return(NULL);
+
+    /*
+     * we are not trying to validate but just to cut, and yes it will
+     * work even if this is a set of UTF-8 encoded chars
+     */
+    while ((qname[len] != 0) && (qname[len] != ':')) 
+       len++;
+    
+    if (qname[len] == 0)
+       return(NULL);
+
+    /*
+     * handle xml: separately, this one is magical
+     */
+    if ((qname[0] == 'x') && (qname[1] == 'm') &&
+        (qname[2] == 'l') && (qname[3] == ':')) {
+       if (qname[4] == 0)
+           return(NULL);
+        *name = xmlStrdup(&qname[4]);
+       xmlFree(qname);
+       return(XML_XML_NAMESPACE);
+    }
+
+    qname[len] = 0;
+    ns = xmlSearchNs(node->doc, node, qname);
+    if (ns == NULL) {
+       xsltGenericError(xsltGenericErrorContext,
+               "%s:%s : no namespace bound to prefix %s\n",
+                        qname, &qname[len + 1], qname);
+       *name = NULL;
+       xmlFree(qname);
+       return(NULL);
+    }
+    *name = xmlStrdup(&qname[len + 1]);
+    xmlFree(qname);
+    return(ns->href);
+}
+
+/**
+ * xsltGetQNameURI2:
+ * @style:  stylesheet pointer
+ * @node:   the node holding the QName
+ * @name:   pointer to the initial QName value
+ *
+ * This function is similar to xsltGetQNameURI, but is used when
+ * @name is a dictionary entry.
+ *
+ * Returns the namespace URI if there is a prefix, or NULL if @name is
+ * not prefixed.
+ */
+const xmlChar *
+xsltGetQNameURI2(xsltStylesheetPtr style, xmlNodePtr node,
+                const xmlChar **name) {
+    int len = 0;
+    xmlChar *qname;
+    xmlNsPtr ns;
+
+    if (name == NULL)
+        return(NULL);
+    qname = (xmlChar *)*name;
+    if ((qname == NULL) || (*qname == 0))
+        return(NULL);
+    if (node == NULL) {
+        xsltGenericError(xsltGenericErrorContext,
+                         "QName: no element for namespace lookup %s\n",
+                          qname);
+       *name = NULL;
+       return(NULL);
+    }
+
+    /*
+     * we are not trying to validate but just to cut, and yes it will
+     * work even if this is a set of UTF-8 encoded chars
+     */
+    while ((qname[len] != 0) && (qname[len] != ':'))
+        len++;
+
+    if (qname[len] == 0)
+        return(NULL);
+
+    /*
+     * handle xml: separately, this one is magical
+     */
+    if ((qname[0] == 'x') && (qname[1] == 'm') &&
+        (qname[2] == 'l') && (qname[3] == ':')) {
+        if (qname[4] == 0)
+            return(NULL);
+        *name = xmlDictLookup(style->dict, &qname[4], -1);
+        return(XML_XML_NAMESPACE);
+    }
+
+    qname = xmlStrndup(*name, len);
+    ns = xmlSearchNs(node->doc, node, qname);
+    if (ns == NULL) {
+       if (style) {
+           xsltTransformError(NULL, style, node,
+               "No namespace bound to prefix '%s'.\n",
+               qname);
+           style->errors++;
+       } else {
+           xsltGenericError(xsltGenericErrorContext,
+                "%s : no namespace bound to prefix %s\n",
+               *name, qname);
+       }
+        *name = NULL;
+        xmlFree(qname);
+        return(NULL);
+    }
+    *name = xmlDictLookup(style->dict, (*name)+len+1, -1);
+    xmlFree(qname);
+    return(ns->href);
+}
+                                                                                     
+/************************************************************************
+ *                                                                     *
+ *                             Sorting                                 *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltDocumentSortFunction:
+ * @list:  the node set
+ *
+ * reorder the current node list @list accordingly to the document order
+ * This function is slow, obsolete and should not be used anymore.
+ */
+void
+xsltDocumentSortFunction(xmlNodeSetPtr list) {
+    int i, j;
+    int len, tst;
+    xmlNodePtr node;
+
+    if (list == NULL)
+       return;
+    len = list->nodeNr;
+    if (len <= 1)
+       return;
+    /* TODO: sort is really not optimized, does it needs to ? */
+    for (i = 0;i < len -1;i++) {
+       for (j = i + 1; j < len; j++) {
+           tst = xmlXPathCmpNodes(list->nodeTab[i], list->nodeTab[j]);
+           if (tst == -1) {
+               node = list->nodeTab[i];
+               list->nodeTab[i] = list->nodeTab[j];
+               list->nodeTab[j] = node;
+           }
+       }
+    }
+}
+
+/**
+ * xsltComputeSortResult:
+ * @ctxt:  a XSLT process context
+ * @sort:  node list
+ *
+ * reorder the current node list accordingly to the set of sorting
+ * requirement provided by the array of nodes.
+ *
+ * Returns a ordered XPath nodeset or NULL in case of error.
+ */
+xmlXPathObjectPtr *
+xsltComputeSortResult(xsltTransformContextPtr ctxt, xmlNodePtr sort) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemSortPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+    xmlXPathObjectPtr *results = NULL;
+    xmlNodeSetPtr list = NULL;
+    xmlXPathObjectPtr res;
+    int len = 0;
+    int i;    
+    xmlNodePtr oldNode;
+    xmlNodePtr oldInst;
+    int        oldPos, oldSize ;
+    int oldNsNr;
+    xmlNsPtr *oldNamespaces;
+
+    comp = sort->psvi;
+    if (comp == NULL) {
+       xsltGenericError(xsltGenericErrorContext,
+            "xsl:sort : compilation failed\n");
+       return(NULL);
+    }
+
+    if ((comp->select == NULL) || (comp->comp == NULL))
+       return(NULL);
+
+    list = ctxt->nodeList;
+    if ((list == NULL) || (list->nodeNr <= 1))
+       return(NULL);
+
+    len = list->nodeNr;
+
+    /* TODO: xsl:sort lang attribute */
+    /* TODO: xsl:sort case-order attribute */
+
+
+    results = xmlMalloc(len * sizeof(xmlXPathObjectPtr));
+    if (results == NULL) {
+       xsltGenericError(xsltGenericErrorContext,
+            "xsltComputeSortResult: memory allocation failure\n");
+       return(NULL);
+    }
+
+    oldNode = ctxt->node;
+    oldInst = ctxt->inst;
+    oldPos = ctxt->xpathCtxt->proximityPosition;
+    oldSize = ctxt->xpathCtxt->contextSize;
+    oldNsNr = ctxt->xpathCtxt->nsNr;
+    oldNamespaces = ctxt->xpathCtxt->namespaces;
+    for (i = 0;i < len;i++) {
+       ctxt->inst = sort;
+       ctxt->xpathCtxt->contextSize = len;
+       ctxt->xpathCtxt->proximityPosition = i + 1;
+       ctxt->node = list->nodeTab[i];
+       ctxt->xpathCtxt->node = ctxt->node;
+#ifdef XSLT_REFACTORED
+       if (comp->inScopeNs != NULL) {
+           ctxt->xpathCtxt->namespaces = comp->inScopeNs->list;
+           ctxt->xpathCtxt->nsNr = comp->inScopeNs->xpathNumber;
+       } else {
+           ctxt->xpathCtxt->namespaces = NULL;
+           ctxt->xpathCtxt->nsNr = 0;
+       }
+#else
+       ctxt->xpathCtxt->namespaces = comp->nsList;
+       ctxt->xpathCtxt->nsNr = comp->nsNr;
+#endif
+       res = xmlXPathCompiledEval(comp->comp, ctxt->xpathCtxt);
+       if (res != NULL) {
+           if (res->type != XPATH_STRING)
+               res = xmlXPathConvertString(res);
+           if (comp->number)
+               res = xmlXPathConvertNumber(res);
+           res->index = i;     /* Save original pos for dupl resolv */
+           if (comp->number) {
+               if (res->type == XPATH_NUMBER) {
+                   results[i] = res;
+               } else {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+                   xsltGenericDebug(xsltGenericDebugContext,
+                       "xsltComputeSortResult: select didn't evaluate to a number\n");
+#endif
+                   results[i] = NULL;
+               }
+           } else {
+               if (res->type == XPATH_STRING) {
+                   results[i] = res;
+               } else {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+                   xsltGenericDebug(xsltGenericDebugContext,
+                       "xsltComputeSortResult: select didn't evaluate to a string\n");
+#endif
+                   results[i] = NULL;
+               }
+           }
+       } else {
+           ctxt->state = XSLT_STATE_STOPPED;
+           results[i] = NULL;
+       }
+    }
+    ctxt->node = oldNode;
+    ctxt->inst = oldInst;
+    ctxt->xpathCtxt->contextSize = oldSize;
+    ctxt->xpathCtxt->proximityPosition = oldPos;
+    ctxt->xpathCtxt->nsNr = oldNsNr;
+    ctxt->xpathCtxt->namespaces = oldNamespaces;
+
+    return(results);
+}
+
+/**
+ * xsltDefaultSortFunction:
+ * @ctxt:  a XSLT process context
+ * @sorts:  array of sort nodes
+ * @nbsorts:  the number of sorts in the array
+ *
+ * reorder the current node list accordingly to the set of sorting
+ * requirement provided by the arry of nodes.
+ */
+void   
+xsltDefaultSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
+                  int nbsorts) {
+#ifdef XSLT_REFACTORED
+    xsltStyleItemSortPtr comp;
+#else
+    xsltStylePreCompPtr comp;
+#endif
+    xmlXPathObjectPtr *resultsTab[XSLT_MAX_SORT];
+    xmlXPathObjectPtr *results = NULL, *res;
+    xmlNodeSetPtr list = NULL;
+    int descending, number, desc, numb;
+    int len = 0;
+    int i, j, incr;
+    int tst;
+    int depth;
+    xmlNodePtr node;
+    xmlXPathObjectPtr tmp;    
+    int tempstype[XSLT_MAX_SORT], temporder[XSLT_MAX_SORT];
+
+    if ((ctxt == NULL) || (sorts == NULL) || (nbsorts <= 0) ||
+       (nbsorts >= XSLT_MAX_SORT))
+       return;
+    if (sorts[0] == NULL)
+       return;
+    comp = sorts[0]->psvi;
+    if (comp == NULL)
+       return;
+
+    list = ctxt->nodeList;
+    if ((list == NULL) || (list->nodeNr <= 1))
+       return; /* nothing to do */
+
+    for (j = 0; j < nbsorts; j++) {
+       comp = sorts[j]->psvi;
+       tempstype[j] = 0;
+       if ((comp->stype == NULL) && (comp->has_stype != 0)) {
+           comp->stype =
+               xsltEvalAttrValueTemplate(ctxt, sorts[j],
+                                         (const xmlChar *) "data-type",
+                                         XSLT_NAMESPACE);
+           if (comp->stype != NULL) {
+               tempstype[j] = 1;
+               if (xmlStrEqual(comp->stype, (const xmlChar *) "text"))
+                   comp->number = 0;
+               else if (xmlStrEqual(comp->stype, (const xmlChar *) "number"))
+                   comp->number = 1;
+               else {
+                   xsltTransformError(ctxt, NULL, sorts[j],
+                         "xsltDoSortFunction: no support for data-type = %s\n",
+                                    comp->stype);
+                   comp->number = 0; /* use default */
+               }
+           }
+       }
+       temporder[j] = 0;
+       if ((comp->order == NULL) && (comp->has_order != 0)) {
+           comp->order = xsltEvalAttrValueTemplate(ctxt, sorts[j],
+                                                   (const xmlChar *) "order",
+                                                   XSLT_NAMESPACE);
+           if (comp->order != NULL) {
+               temporder[j] = 1;
+               if (xmlStrEqual(comp->order, (const xmlChar *) "ascending"))
+                   comp->descending = 0;
+               else if (xmlStrEqual(comp->order,
+                                    (const xmlChar *) "descending"))
+                   comp->descending = 1;
+               else {
+                   xsltTransformError(ctxt, NULL, sorts[j],
+                            "xsltDoSortFunction: invalid value %s for order\n",
+                                    comp->order);
+                   comp->descending = 0; /* use default */
+               }
+           }
+       }
+    }
+
+    len = list->nodeNr;
+
+    resultsTab[0] = xsltComputeSortResult(ctxt, sorts[0]);
+    for (i = 1;i < XSLT_MAX_SORT;i++)
+       resultsTab[i] = NULL;
+
+    results = resultsTab[0];
+
+    comp = sorts[0]->psvi;
+    descending = comp->descending;
+    number = comp->number;
+    if (results == NULL)
+       return;
+
+    /* Shell's sort of node-set */
+    for (incr = len / 2; incr > 0; incr /= 2) {
+       for (i = incr; i < len; i++) {
+           j = i - incr;
+           if (results[i] == NULL)
+               continue;
+           
+           while (j >= 0) {
+               if (results[j] == NULL)
+                   tst = 1;
+               else {
+                   if (number) {
+                       /* We make NaN smaller than number in accordance
+                          with XSLT spec */
+                       if (xmlXPathIsNaN(results[j]->floatval)) {
+                           if (xmlXPathIsNaN(results[j + incr]->floatval))
+                               tst = 0;
+                           else
+                               tst = -1;
+                       } else if (xmlXPathIsNaN(results[j + incr]->floatval))
+                           tst = 1;
+                       else if (results[j]->floatval ==
+                               results[j + incr]->floatval)
+                           tst = 0;
+                       else if (results[j]->floatval > 
+                               results[j + incr]->floatval)
+                           tst = 1;
+                       else tst = -1;
+                   } else {
+                       tst = xmlStrcmp(results[j]->stringval,
+                                    results[j + incr]->stringval); 
+                   }
+                   if (descending)
+                       tst = -tst;
+               }
+               if (tst == 0) {
+                   /*
+                    * Okay we need to use multi level sorts
+                    */
+                   depth = 1;
+                   while (depth < nbsorts) {
+                       if (sorts[depth] == NULL)
+                           break;
+                       comp = sorts[depth]->psvi;
+                       if (comp == NULL)
+                           break;
+                       desc = comp->descending;
+                       numb = comp->number;
+
+                       /*
+                        * Compute the result of the next level for the
+                        * full set, this might be optimized ... or not
+                        */
+                       if (resultsTab[depth] == NULL) 
+                           resultsTab[depth] = xsltComputeSortResult(ctxt,
+                                                       sorts[depth]);
+                       res = resultsTab[depth];
+                       if (res == NULL) 
+                           break;
+                       if (res[j] == NULL) {
+                           if (res[j+incr] != NULL)
+                               tst = 1;
+                       } else {
+                           if (numb) {
+                               /* We make NaN smaller than number in
+                                  accordance with XSLT spec */
+                               if (xmlXPathIsNaN(res[j]->floatval)) {
+                                   if (xmlXPathIsNaN(res[j +
+                                               incr]->floatval))
+                                       tst = 0;
+                                   else
+                                       tst = -1;
+                               } else if (xmlXPathIsNaN(res[j + incr]->
+                                               floatval))
+                                   tst = 1;
+                               else if (res[j]->floatval == res[j + incr]->
+                                               floatval)
+                                   tst = 0;
+                               else if (res[j]->floatval > 
+                                       res[j + incr]->floatval)
+                                   tst = 1;
+                               else tst = -1;
+                           } else {
+                               tst = xmlStrcmp(res[j]->stringval,
+                                            res[j + incr]->stringval); 
+                           }
+                           if (desc)
+                               tst = -tst;
+                       }
+
+                       /*
+                        * if we still can't differenciate at this level
+                        * try one level deeper.
+                        */
+                       if (tst != 0)
+                           break;
+                       depth++;
+                   }
+               }
+               if (tst == 0) {
+                   tst = results[j]->index > results[j + incr]->index;
+               }
+               if (tst > 0) {
+                   tmp = results[j];
+                   results[j] = results[j + incr];
+                   results[j + incr] = tmp;
+                   node = list->nodeTab[j];
+                   list->nodeTab[j] = list->nodeTab[j + incr];
+                   list->nodeTab[j + incr] = node;
+                   depth = 1;
+                   while (depth < nbsorts) {
+                       if (sorts[depth] == NULL)
+                           break;
+                       if (resultsTab[depth] == NULL)
+                           break;
+                       res = resultsTab[depth];
+                       tmp = res[j];
+                       res[j] = res[j + incr];
+                       res[j + incr] = tmp;
+                       depth++;
+                   }
+                   j -= incr;
+               } else
+                   break;
+           }
+       }
+    }
+
+    for (j = 0; j < nbsorts; j++) {
+       comp = sorts[j]->psvi;
+       if (tempstype[j] == 1) {
+           /* The data-type needs to be recomputed each time */
+           xmlFree((void *)(comp->stype));
+           comp->stype = NULL;
+       }
+       if (temporder[j] == 1) {
+           /* The order needs to be recomputed each time */
+           xmlFree((void *)(comp->order));
+           comp->order = NULL;
+       }
+       if (resultsTab[j] != NULL) {
+           for (i = 0;i < len;i++)
+               xmlXPathFreeObject(resultsTab[j][i]);
+           xmlFree(resultsTab[j]);
+       }
+    }
+}
+
+
+static xsltSortFunc xsltSortFunction = xsltDefaultSortFunction;
+
+/**
+ * xsltDoSortFunction:
+ * @ctxt:  a XSLT process context
+ * @sorts:  array of sort nodes
+ * @nbsorts:  the number of sorts in the array
+ *
+ * reorder the current node list accordingly to the set of sorting
+ * requirement provided by the arry of nodes.
+ * This is a wrapper function, the actual function used is specified
+ * using xsltSetCtxtSortFunc() to set the context specific sort function,
+ * or xsltSetSortFunc() to set the global sort function.
+ * If a sort function is set on the context, this will get called.
+ * Otherwise the global sort function is called.
+ */
+void
+xsltDoSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr * sorts,
+                   int nbsorts)
+{
+    if (ctxt->sortfunc != NULL)
+       (ctxt->sortfunc)(ctxt, sorts, nbsorts);
+    else if (xsltSortFunction != NULL)
+        xsltSortFunction(ctxt, sorts, nbsorts);
+}
+
+/**
+ * xsltSetSortFunc:
+ * @handler:  the new handler function
+ *
+ * Function to reset the global handler for XSLT sorting.
+ * If the handler is NULL, the default sort function will be used.
+ */
+void
+xsltSetSortFunc(xsltSortFunc handler) {
+    if (handler != NULL)
+       xsltSortFunction = handler;
+    else
+       xsltSortFunction = xsltDefaultSortFunction;
+}
+
+/**
+ * xsltSetCtxtSortFunc:
+ * @ctxt:  a XSLT process context
+ * @handler:  the new handler function
+ *
+ * Function to set the handler for XSLT sorting
+ * for the specified context. 
+ * If the handler is NULL, then the global
+ * sort function will be called
+ */
+void 
+xsltSetCtxtSortFunc(xsltTransformContextPtr ctxt, xsltSortFunc handler) {
+    ctxt->sortfunc = handler;
+}
+
+/************************************************************************
+ *                                                                     *
+ *                             Parsing options                         *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltSetCtxtParseOptions:
+ * @ctxt:  a XSLT process context
+ * @options:  a combination of libxml2 xmlParserOption
+ * 
+ * Change the default parser option passed by the XSLT engine to the 
+ * parser when using document() loading.
+ *
+ * Returns the previous options or -1 in case of error
+ */
+int 
+xsltSetCtxtParseOptions(xsltTransformContextPtr ctxt, int options)
+{
+    int oldopts;
+
+    if (ctxt == NULL)
+        return(-1);
+    oldopts = ctxt->parserOptions;
+    if (ctxt->xinclude)
+        oldopts |= XML_PARSE_XINCLUDE;
+    ctxt->parserOptions = options;
+    if (options & XML_PARSE_XINCLUDE)
+        ctxt->xinclude = 1;
+    else
+        ctxt->xinclude = 0;
+    return(oldopts);
+}
+
+/************************************************************************
+ *                                                                     *
+ *                             Output                                  *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltSaveResultTo:
+ * @buf:  an output buffer
+ * @result:  the result xmlDocPtr
+ * @style:  the stylesheet
+ *
+ * Save the result @result obtained by applying the @style stylesheet
+ * to an I/O output channel @buf
+ *
+ * Returns the number of byte written or -1 in case of failure.
+ */
+int
+xsltSaveResultTo(xmlOutputBufferPtr buf, xmlDocPtr result,
+              xsltStylesheetPtr style) {
+    const xmlChar *encoding;
+    int base;
+    const xmlChar *method;
+    int indent;
+
+    if ((buf == NULL) || (result == NULL) || (style == NULL))
+       return(-1);
+    if ((result->children == NULL) ||
+       ((result->children->type == XML_DTD_NODE) &&
+        (result->children->next == NULL)))
+       return(0);
+
+    if ((style->methodURI != NULL) &&
+       ((style->method == NULL) ||
+        (!xmlStrEqual(style->method, (const xmlChar *) "xhtml")))) {
+        xsltGenericError(xsltGenericErrorContext,
+               "xsltSaveResultTo : unknown ouput method\n");
+        return(-1);
+    }
+
+    base = buf->written;
+
+    XSLT_GET_IMPORT_PTR(method, style, method)
+    XSLT_GET_IMPORT_PTR(encoding, style, encoding)
+    XSLT_GET_IMPORT_INT(indent, style, indent);
+
+    if ((method == NULL) && (result->type == XML_HTML_DOCUMENT_NODE))
+       method = (const xmlChar *) "html";
+
+    if ((method != NULL) &&
+       (xmlStrEqual(method, (const xmlChar *) "html"))) {
+       if (encoding != NULL) {
+           htmlSetMetaEncoding(result, (const xmlChar *) encoding);
+       } else {
+           htmlSetMetaEncoding(result, (const xmlChar *) "UTF-8");
+       }
+       if (indent == -1)
+           indent = 1;
+       htmlDocContentDumpFormatOutput(buf, result, (const char *) encoding,
+                                      indent);
+       xmlOutputBufferFlush(buf);
+    } else if ((method != NULL) &&
+       (xmlStrEqual(method, (const xmlChar *) "xhtml"))) {
+       if (encoding != NULL) {
+           htmlSetMetaEncoding(result, (const xmlChar *) encoding);
+       } else {
+           htmlSetMetaEncoding(result, (const xmlChar *) "UTF-8");
+       }
+       htmlDocContentDumpOutput(buf, result, (const char *) encoding);
+       xmlOutputBufferFlush(buf);
+    } else if ((method != NULL) &&
+              (xmlStrEqual(method, (const xmlChar *) "text"))) {
+       xmlNodePtr cur;
+
+       cur = result->children;
+       while (cur != NULL) {
+           if (cur->type == XML_TEXT_NODE)
+               xmlOutputBufferWriteString(buf, (const char *) cur->content);
+
+           /*
+            * Skip to next node
+            */
+           if (cur->children != NULL) {
+               if ((cur->children->type != XML_ENTITY_DECL) &&
+                   (cur->children->type != XML_ENTITY_REF_NODE) &&
+                   (cur->children->type != XML_ENTITY_NODE)) {
+                   cur = cur->children;
+                   continue;
+               }
+           }
+           if (cur->next != NULL) {
+               cur = cur->next;
+               continue;
+           }
+           
+           do {
+               cur = cur->parent;
+               if (cur == NULL)
+                   break;
+               if (cur == (xmlNodePtr) style->doc) {
+                   cur = NULL;
+                   break;
+               }
+               if (cur->next != NULL) {
+                   cur = cur->next;
+                   break;
+               }
+           } while (cur != NULL);
+       }
+       xmlOutputBufferFlush(buf);
+    } else {
+       int omitXmlDecl;
+       int standalone;
+
+       XSLT_GET_IMPORT_INT(omitXmlDecl, style, omitXmlDeclaration);
+       XSLT_GET_IMPORT_INT(standalone, style, standalone);
+
+       if (omitXmlDecl != 1) {
+           xmlOutputBufferWriteString(buf, "<?xml version=");
+           if (result->version != NULL) 
+               xmlBufferWriteQuotedString(buf->buffer, result->version);
+           else
+               xmlOutputBufferWriteString(buf, "\"1.0\"");
+           if (encoding == NULL) {
+               if (result->encoding != NULL)
+                   encoding = result->encoding;
+               else if (result->charset != XML_CHAR_ENCODING_UTF8)
+                   encoding = (const xmlChar *)
+                              xmlGetCharEncodingName((xmlCharEncoding)
+                                                     result->charset);
+           }
+           if (encoding != NULL) {
+               xmlOutputBufferWriteString(buf, " encoding=");
+               xmlBufferWriteQuotedString(buf->buffer, (xmlChar *) encoding);
+           }
+           switch (standalone) {
+               case 0:
+                   xmlOutputBufferWriteString(buf, " standalone=\"no\"");
+                   break;
+               case 1:
+                   xmlOutputBufferWriteString(buf, " standalone=\"yes\"");
+                   break;
+               default:
+                   break;
+           }
+           xmlOutputBufferWriteString(buf, "?>\n");
+       }
+       if (result->children != NULL) {
+           xmlNodePtr child = result->children;
+
+           while (child != NULL) {
+               xmlNodeDumpOutput(buf, result, child, 0, (indent == 1),
+                                 (const char *) encoding);
+               if ((child->type == XML_DTD_NODE) ||
+                   ((child->type == XML_COMMENT_NODE) &&
+                    (child->next != NULL)))
+                   xmlOutputBufferWriteString(buf, "\n");
+               child = child->next;
+           }
+           xmlOutputBufferWriteString(buf, "\n");
+       }
+       xmlOutputBufferFlush(buf);
+    }
+    return(buf->written - base);
+}
+
+/**
+ * xsltSaveResultToFilename:
+ * @URL:  a filename or URL
+ * @result:  the result xmlDocPtr
+ * @style:  the stylesheet
+ * @compression:  the compression factor (0 - 9 included)
+ *
+ * Save the result @result obtained by applying the @style stylesheet
+ * to a file or @URL
+ *
+ * Returns the number of byte written or -1 in case of failure.
+ */
+int
+xsltSaveResultToFilename(const char *URL, xmlDocPtr result,
+                        xsltStylesheetPtr style, int compression) {
+    xmlOutputBufferPtr buf;
+    const xmlChar *encoding;
+    int ret;
+
+    if ((URL == NULL) || (result == NULL) || (style == NULL))
+       return(-1);
+    if (result->children == NULL)
+       return(0);
+
+    XSLT_GET_IMPORT_PTR(encoding, style, encoding)
+    if (encoding != NULL) {
+       xmlCharEncodingHandlerPtr encoder;
+
+       encoder = xmlFindCharEncodingHandler((char *)encoding);
+       if ((encoder != NULL) &&
+           (xmlStrEqual((const xmlChar *)encoder->name,
+                        (const xmlChar *) "UTF-8")))
+           encoder = NULL;
+       buf = xmlOutputBufferCreateFilename(URL, encoder, compression);
+    } else {
+       buf = xmlOutputBufferCreateFilename(URL, NULL, compression);
+    }
+    if (buf == NULL)
+       return(-1);
+    xsltSaveResultTo(buf, result, style);
+    ret = xmlOutputBufferClose(buf);
+    return(ret);
+}
+
+/**
+ * xsltSaveResultToFile:
+ * @file:  a FILE * I/O
+ * @result:  the result xmlDocPtr
+ * @style:  the stylesheet
+ *
+ * Save the result @result obtained by applying the @style stylesheet
+ * to an open FILE * I/O.
+ * This does not close the FILE @file
+ *
+ * Returns the number of bytes written or -1 in case of failure.
+ */
+int
+xsltSaveResultToFile(FILE *file, xmlDocPtr result, xsltStylesheetPtr style) {
+    xmlOutputBufferPtr buf;
+    const xmlChar *encoding;
+    int ret;
+
+    if ((file == NULL) || (result == NULL) || (style == NULL))
+       return(-1);
+    if (result->children == NULL)
+       return(0);
+
+    XSLT_GET_IMPORT_PTR(encoding, style, encoding)
+    if (encoding != NULL) {
+       xmlCharEncodingHandlerPtr encoder;
+
+       encoder = xmlFindCharEncodingHandler((char *)encoding);
+       if ((encoder != NULL) &&
+           (xmlStrEqual((const xmlChar *)encoder->name,
+                        (const xmlChar *) "UTF-8")))
+           encoder = NULL;
+       buf = xmlOutputBufferCreateFile(file, encoder);
+    } else {
+       buf = xmlOutputBufferCreateFile(file, NULL);
+    }
+
+    if (buf == NULL)
+       return(-1);
+    xsltSaveResultTo(buf, result, style);
+    ret = xmlOutputBufferClose(buf);
+    return(ret);
+}
+
+/**
+ * xsltSaveResultToFd:
+ * @fd:  a file descriptor
+ * @result:  the result xmlDocPtr
+ * @style:  the stylesheet
+ *
+ * Save the result @result obtained by applying the @style stylesheet
+ * to an open file descriptor
+ * This does not close the descriptor.
+ *
+ * Returns the number of bytes written or -1 in case of failure.
+ */
+int
+xsltSaveResultToFd(int fd, xmlDocPtr result, xsltStylesheetPtr style) {
+    xmlOutputBufferPtr buf;
+    const xmlChar *encoding;
+    int ret;
+
+    if ((fd < 0) || (result == NULL) || (style == NULL))
+       return(-1);
+    if (result->children == NULL)
+       return(0);
+
+    XSLT_GET_IMPORT_PTR(encoding, style, encoding)
+    if (encoding != NULL) {
+       xmlCharEncodingHandlerPtr encoder;
+
+       encoder = xmlFindCharEncodingHandler((char *)encoding);
+       if ((encoder != NULL) &&
+           (xmlStrEqual((const xmlChar *)encoder->name,
+                        (const xmlChar *) "UTF-8")))
+           encoder = NULL;
+       buf = xmlOutputBufferCreateFd(fd, encoder);
+    } else {
+       buf = xmlOutputBufferCreateFd(fd, NULL);
+    }
+    if (buf == NULL)
+       return(-1);
+    xsltSaveResultTo(buf, result, style);
+    ret = xmlOutputBufferClose(buf);
+    return(ret);
+}
+
+/**
+ * xsltSaveResultToString:
+ * @doc_txt_ptr:  Memory pointer for allocated XML text
+ * @doc_txt_len:  Length of the generated XML text
+ * @result:  the result xmlDocPtr
+ * @style:  the stylesheet
+ *
+ * Save the result @result obtained by applying the @style stylesheet
+ * to a new allocated string.
+ *
+ * Returns 0 in case of success and -1 in case of error
+ */
+int
+xsltSaveResultToString(xmlChar **doc_txt_ptr, int * doc_txt_len, 
+                      xmlDocPtr result, xsltStylesheetPtr style) {
+    xmlOutputBufferPtr buf;
+    const xmlChar *encoding;
+
+    *doc_txt_ptr = NULL;
+    *doc_txt_len = 0;
+    if (result->children == NULL)
+       return(0);
+
+    XSLT_GET_IMPORT_PTR(encoding, style, encoding)
+    if (encoding != NULL) {
+       xmlCharEncodingHandlerPtr encoder;
+
+       encoder = xmlFindCharEncodingHandler((char *)encoding);
+       if ((encoder != NULL) &&
+           (xmlStrEqual((const xmlChar *)encoder->name,
+                        (const xmlChar *) "UTF-8")))
+           encoder = NULL;
+       buf = xmlAllocOutputBuffer(encoder);
+    } else {
+       buf = xmlAllocOutputBuffer(NULL);
+    }
+    if (buf == NULL)
+       return(-1);
+    xsltSaveResultTo(buf, result, style);
+    if (buf->conv != NULL) {
+       *doc_txt_len = buf->conv->use;
+       *doc_txt_ptr = xmlStrndup(buf->conv->content, *doc_txt_len);
+    } else {
+       *doc_txt_len = buf->buffer->use;
+       *doc_txt_ptr = xmlStrndup(buf->buffer->content, *doc_txt_len);
+    }
+    (void)xmlOutputBufferClose(buf);
+    return 0;
+}
+
+/************************************************************************
+ *                                                                     *
+ *             Generating profiling informations                       *
+ *                                                                     *
+ ************************************************************************/
+
+static long calibration = -1;
+
+/**
+ * xsltCalibrateTimestamps:
+ *
+ * Used for to calibrate the xsltTimestamp() function
+ * Should work if launched at startup and we don't loose our quantum :-)
+ *
+ * Returns the number of milliseconds used by xsltTimestamp()
+ */
+static long
+xsltCalibrateTimestamps(void) {
+    register int i;
+
+    for (i = 0;i < 999;i++)
+       xsltTimestamp();
+    return(xsltTimestamp() / 1000);
+}
+
+/**
+ * xsltCalibrateAdjust:
+ * @delta:  a negative dealy value found
+ *
+ * Used for to correct the calibration for xsltTimestamp()
+ */
+void
+xsltCalibrateAdjust(long delta) {
+    calibration += delta;
+}
+
+/**
+ * xsltTimestamp:
+ *
+ * Used for gathering profiling data
+ *
+ * Returns the number of tenth of milliseconds since the beginning of the
+ * profiling
+ */
+long
+xsltTimestamp(void)
+{
+#ifdef XSLT_WIN32_PERFORMANCE_COUNTER
+    BOOL ok;
+    LARGE_INTEGER performanceCount;
+    LARGE_INTEGER performanceFrequency;
+    LONGLONG quadCount;
+    double seconds;
+    static LONGLONG startupQuadCount = 0;
+    static LONGLONG startupQuadFreq = 0;
+
+    ok = QueryPerformanceCounter(&performanceCount);
+    if (!ok)
+        return 0;
+    quadCount = performanceCount.QuadPart;
+    if (calibration < 0) {
+        calibration = 0;
+        ok = QueryPerformanceFrequency(&performanceFrequency);
+        if (!ok)
+            return 0;
+        startupQuadFreq = performanceFrequency.QuadPart;
+        startupQuadCount = quadCount;
+        return (0);
+    }
+    if (startupQuadFreq == 0)
+        return 0;
+    seconds = (quadCount - startupQuadCount) / (double) startupQuadFreq;
+    return (long) (seconds * XSLT_TIMESTAMP_TICS_PER_SEC);
+
+#else /* XSLT_WIN32_PERFORMANCE_COUNTER */
+#ifdef HAVE_GETTIMEOFDAY
+    static struct timeval startup;
+    struct timeval cur;
+    long tics;
+
+    if (calibration < 0) {
+        gettimeofday(&startup, NULL);
+        calibration = 0;
+        calibration = xsltCalibrateTimestamps();
+        gettimeofday(&startup, NULL);
+        return (0);
+    }
+
+    gettimeofday(&cur, NULL);
+    tics = (cur.tv_sec - startup.tv_sec) * XSLT_TIMESTAMP_TICS_PER_SEC;
+    tics += (cur.tv_usec - startup.tv_usec) /
+                          (1000000l / XSLT_TIMESTAMP_TICS_PER_SEC);
+    
+    tics -= calibration;
+    return(tics);
+#else
+
+    /* Neither gettimeofday() nor Win32 performance counter available */
+
+    return (0);
+
+#endif /* HAVE_GETTIMEOFDAY */
+#endif /* XSLT_WIN32_PERFORMANCE_COUNTER */
+}
+
+#define MAX_TEMPLATES 10000
+
+/**
+ * xsltSaveProfiling:
+ * @ctxt:  an XSLT context
+ * @output:  a FILE * for saving the informations
+ *
+ * Save the profiling informations on @output
+ */
+void
+xsltSaveProfiling(xsltTransformContextPtr ctxt, FILE *output) {
+    int nb, i,j;
+    int max;
+    int total;
+    long totalt;
+    xsltTemplatePtr *templates;
+    xsltStylesheetPtr style;
+    xsltTemplatePtr template;
+
+    if ((output == NULL) || (ctxt == NULL))
+       return;
+    if (ctxt->profile == 0)
+       return;
+
+    nb = 0;
+    max = MAX_TEMPLATES;
+    templates = xmlMalloc(max * sizeof(xsltTemplatePtr));
+    if (templates == NULL)
+       return;
+
+    style = ctxt->style;
+    while (style != NULL) {
+       template = style->templates;
+       while (template != NULL) {
+           if (nb >= max)
+               break;
+
+           if (template->nbCalls > 0)
+               templates[nb++] = template;
+           template = template->next;
+       }
+
+       style = xsltNextImport(style);
+    }
+
+    for (i = 0;i < nb -1;i++) {
+       for (j = i + 1; j < nb; j++) {
+           if ((templates[i]->time <= templates[j]->time) ||
+               ((templates[i]->time == templates[j]->time) &&
+                (templates[i]->nbCalls <= templates[j]->nbCalls))) {
+               template = templates[j];
+               templates[j] = templates[i];
+               templates[i] = template;
+           }
+       }
+    }
+
+    fprintf(output, "%6s%20s%20s%10s  Calls Tot 100us Avg\n\n",
+           "number", "match", "name", "mode");
+    total = 0;
+    totalt = 0;
+    for (i = 0;i < nb;i++) {
+       fprintf(output, "%5d ", i);
+       if (templates[i]->match != NULL) {
+           if (xmlStrlen(templates[i]->match) > 20)
+               fprintf(output, "%s\n%26s", templates[i]->match, "");
+           else
+               fprintf(output, "%20s", templates[i]->match);
+       } else {
+           fprintf(output, "%20s", "");
+       }
+       if (templates[i]->name != NULL) {
+           if (xmlStrlen(templates[i]->name) > 20)
+               fprintf(output, "%s\n%46s", templates[i]->name, "");
+           else
+               fprintf(output, "%20s", templates[i]->name);
+       } else {
+           fprintf(output, "%20s", "");
+       }
+       if (templates[i]->mode != NULL) {
+           if (xmlStrlen(templates[i]->mode) > 10)
+               fprintf(output, "%s\n%56s", templates[i]->mode, "");
+           else
+               fprintf(output, "%10s", templates[i]->mode);
+       } else {
+           fprintf(output, "%10s", "");
+       }
+       fprintf(output, " %6d", templates[i]->nbCalls);
+       fprintf(output, " %6ld %6ld\n", templates[i]->time,
+               templates[i]->time / templates[i]->nbCalls);
+       total += templates[i]->nbCalls;
+       totalt += templates[i]->time;
+    }
+    fprintf(output, "\n%30s%26s %6d %6ld\n", "Total", "", total, totalt);
+
+    xmlFree(templates);
+}
+
+/************************************************************************
+ *                                                                     *
+ *             Fetching profiling informations                         *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltGetProfileInformation:
+ * @ctxt:  a transformation context
+ *
+ * This function should be called after the transformation completed
+ * to extract template processing profiling informations if availble.
+ * The informations are returned as an XML document tree like
+ * <?xml version="1.0"?>
+ * <profile>
+ * <template rank="1" match="*" name=""
+ *         mode="" calls="6" time="48" average="8"/>
+ * <template rank="2" match="item2|item3" name=""
+ *         mode="" calls="10" time="30" average="3"/>
+ * <template rank="3" match="item1" name=""
+ *         mode="" calls="5" time="17" average="3"/>
+ * </profile>
+ * The caller will need to free up the returned tree with xmlFreeDoc()
+ *
+ * Returns the xmlDocPtr corresponding to the result or NULL if not available.
+ */
+
+xmlDocPtr
+xsltGetProfileInformation(xsltTransformContextPtr ctxt)
+{
+    xmlDocPtr ret = NULL;
+    xmlNodePtr root, child;
+    char buf[100];
+
+    xsltStylesheetPtr style;
+    xsltTemplatePtr *templates;
+    xsltTemplatePtr templ;
+    int nb = 0, max = 0, i, j;
+
+    if (!ctxt)
+        return NULL;
+
+    if (!ctxt->profile)
+        return NULL;
+
+    nb = 0;
+    max = 10000;
+    templates =
+        (xsltTemplatePtr *) xmlMalloc(max * sizeof(xsltTemplatePtr));
+    if (templates == NULL)
+        return NULL;
+
+    /*
+     * collect all the templates in an array
+     */
+    style = ctxt->style;
+    while (style != NULL) {
+        templ = style->templates;
+        while (templ != NULL) {
+            if (nb >= max)
+                break;
+
+            if (templ->nbCalls > 0)
+                templates[nb++] = templ;
+            templ = templ->next;
+        }
+
+        style = (xsltStylesheetPtr) xsltNextImport(style);
+    }
+
+    /*
+     * Sort the array by time spent
+     */
+    for (i = 0; i < nb - 1; i++) {
+        for (j = i + 1; j < nb; j++) {
+            if ((templates[i]->time <= templates[j]->time) ||
+                ((templates[i]->time == templates[j]->time) &&
+                 (templates[i]->nbCalls <= templates[j]->nbCalls))) {
+                templ = templates[j];
+                templates[j] = templates[i];
+                templates[i] = templ;
+            }
+        }
+    }
+
+    /*
+     * Generate a document corresponding to the results.
+     */
+    ret = xmlNewDoc(BAD_CAST "1.0");
+    root = xmlNewDocNode(ret, NULL, BAD_CAST "profile", NULL);
+    xmlDocSetRootElement(ret, root);
+
+    for (i = 0; i < nb; i++) {
+        child = xmlNewChild(root, NULL, BAD_CAST "template", NULL);
+        sprintf(buf, "%d", i + 1);
+        xmlSetProp(child, BAD_CAST "rank", BAD_CAST buf);
+        xmlSetProp(child, BAD_CAST "match", BAD_CAST templates[i]->match);
+        xmlSetProp(child, BAD_CAST "name", BAD_CAST templates[i]->name);
+        xmlSetProp(child, BAD_CAST "mode", BAD_CAST templates[i]->mode);
+
+        sprintf(buf, "%d", templates[i]->nbCalls);
+        xmlSetProp(child, BAD_CAST "calls", BAD_CAST buf);
+
+        sprintf(buf, "%ld", templates[i]->time);
+        xmlSetProp(child, BAD_CAST "time", BAD_CAST buf);
+
+        sprintf(buf, "%ld", templates[i]->time / templates[i]->nbCalls);
+        xmlSetProp(child, BAD_CAST "average", BAD_CAST buf);
+    };
+
+    xmlFree(templates);
+
+    return ret;
+}
+
+/************************************************************************
+ *                                                                     *
+ *             Hooks for libxml2 XPath                                 *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltXPathCompile:
+ * @style: the stylesheet
+ * @str:  the XPath expression
+ *
+ * Compile an XPath expression
+ *
+ * Returns the xmlXPathCompExprPtr resulting from the compilation or NULL.
+ *         the caller has to free the object.
+ */
+xmlXPathCompExprPtr
+xsltXPathCompile(xsltStylesheetPtr style, const xmlChar *str) {
+    xmlXPathContextPtr xpathCtxt;
+    xmlXPathCompExprPtr ret;
+
+    if (style != NULL) {
+#ifdef XSLT_REFACTORED_XPATHCOMP
+       if (XSLT_CCTXT(style)) {
+           /*
+           * Proposed by Jerome Pesenti
+           * --------------------------
+           * For better efficiency we'll reuse the compilation
+           * context's XPath context. For the common stylesheet using
+           * XPath expressions this will reduce compilation time to
+           * about 50%.
+           *
+           * See http://mail.gnome.org/archives/xslt/2006-April/msg00037.html
+           */
+           xpathCtxt = XSLT_CCTXT(style)->xpathCtxt;
+           xpathCtxt->doc = style->doc;
+       } else
+           xpathCtxt = xmlXPathNewContext(style->doc);
+#else
+       xpathCtxt = xmlXPathNewContext(style->doc);
+#endif
+       if (xpathCtxt == NULL)
+           return NULL;
+       xpathCtxt->dict = style->dict;
+    } else {
+       xpathCtxt = xmlXPathNewContext(NULL);
+       if (xpathCtxt == NULL)
+           return NULL;
+    }
+    /*
+    * Compile the expression.
+    */
+    ret = xmlXPathCtxtCompile(xpathCtxt, str);
+
+#ifdef XSLT_REFACTORED_XPATHCOMP
+    if ((style == NULL) || (! XSLT_CCTXT(style))) {
+       xmlXPathFreeContext(xpathCtxt);
+    }
+#else
+    xmlXPathFreeContext(xpathCtxt);
+#endif
+    /*
+     * TODO: there is a lot of optimizations which should be possible
+     *       like variable slot precomputations, function precomputations, etc.
+     */
+
+    return(ret);
+}
+
+/************************************************************************
+ *                                                                     *
+ *             Hooks for the debugger                                  *
+ *                                                                     *
+ ************************************************************************/
+
+/*
+ * There is currently only 3 debugging callback defined
+ * Debugger callbacks are disabled by default
+ */
+#define XSLT_CALLBACK_NUMBER 3
+
+typedef struct _xsltDebuggerCallbacks xsltDebuggerCallbacks;
+typedef xsltDebuggerCallbacks *xsltDebuggerCallbacksPtr;
+struct _xsltDebuggerCallbacks {
+    xsltHandleDebuggerCallback handler;
+    xsltAddCallCallback add;
+    xsltDropCallCallback drop;
+};
+
+static xsltDebuggerCallbacks xsltDebuggerCurrentCallbacks = {
+    NULL, /* handler */
+    NULL, /* add */
+    NULL  /* drop */
+};
+
+int xslDebugStatus;
+
+/**
+ * xsltSetDebuggerStatus:
+ * @value : the value to be set
+ * 
+ * This function sets the value of xslDebugStatus.
+ */
+void
+xsltSetDebuggerStatus(int value)
+{
+    xslDebugStatus = value;    
+}
+
+/**
+ * xsltGetDebuggerStatus: 
+ * 
+ * Get xslDebugStatus.
+ *
+ * Returns the value of xslDebugStatus.
+ */
+int
+xsltGetDebuggerStatus(void)
+{
+    return(xslDebugStatus);    
+}
+
+/**
+ * xsltSetDebuggerCallbacks:
+ * @no : number of callbacks
+ * @block : the block of callbacks
+ * 
+ * This function allow to plug a debugger into the XSLT library
+ * @block points to a block of memory containing the address of @no 
+ * callback routines.
+ *
+ * Returns 0 in case of success and -1 in case of error
+ */
+int
+xsltSetDebuggerCallbacks(int no, void *block)
+{
+    xsltDebuggerCallbacksPtr callbacks;
+
+    if ((block == NULL) || (no != XSLT_CALLBACK_NUMBER))
+       return(-1);
+
+    callbacks = (xsltDebuggerCallbacksPtr) block;
+    xsltDebuggerCurrentCallbacks.handler = callbacks->handler;
+    xsltDebuggerCurrentCallbacks.add  = callbacks->add;
+    xsltDebuggerCurrentCallbacks.drop  = callbacks->drop;
+    return(0);
+}
+
+/**
+ * xslHandleDebugger:
+ * @cur : source node being executed
+ * @node : data node being processed
+ * @templ : temlate that applies to node
+ * @ctxt : the xslt transform context 
+ * 
+ * If either cur or node are a breakpoint, or xslDebugStatus in state 
+ *   where debugging must occcur at this time then transfer control
+ *   to the xslDebugBreak function
+ */
+void
+xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ,
+                 xsltTransformContextPtr ctxt)
+{
+    if (xsltDebuggerCurrentCallbacks.handler != NULL)
+       xsltDebuggerCurrentCallbacks.handler(cur, node, templ, ctxt);
+}
+
+/**
+ * xslAddCall:
+ * @templ : current template being applied
+ * @source : the source node being processed
+ *
+ * Add template "call" to call stack
+ * Returns : 1 on sucess 0 otherwise an error may be printed if 
+ *            WITH_XSLT_DEBUG_BREAKPOINTS is defined
+ */
+int
+xslAddCall(xsltTemplatePtr templ, xmlNodePtr source)
+{
+    if (xsltDebuggerCurrentCallbacks.add != NULL)
+       return(xsltDebuggerCurrentCallbacks.add(templ, source));
+    return(0);
+}
+
+/**
+ * xslDropCall:
+ *
+ * Drop the topmost item off the call stack
+ */
+void
+xslDropCall(void)
+{
+    if (xsltDebuggerCurrentCallbacks.drop != NULL)
+       xsltDebuggerCurrentCallbacks.drop();
+}
+
diff --git a/reactos/dll/3rdparty/libxslt/xsltutils.h b/reactos/dll/3rdparty/libxslt/xsltutils.h
new file mode 100644 (file)
index 0000000..3886be3
--- /dev/null
@@ -0,0 +1,309 @@
+/*
+ * Summary: set of utilities for the XSLT engine
+ * Description: interfaces for the utilities module of the XSLT engine.
+ *              things like message handling, profiling, and other
+ *              generally useful routines.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLTUTILS_H__
+#define __XML_XSLTUTILS_H__
+
+#include <libxslt/xsltconfig.h>
+#ifdef HAVE_STDARG_H
+#include <stdarg.h>
+#endif
+#include <libxml/xpath.h>
+#include <libxml/dict.h>
+#include <libxml/xmlerror.h>
+#include "xsltexports.h"
+#include "xsltInternals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * XSLT_TODO:
+ *
+ * Macro to flag unimplemented blocks.
+ */
+#define XSLT_TODO                                                      \
+    xsltGenericError(xsltGenericErrorContext,                          \
+           "Unimplemented block at %s:%d\n",                           \
+            __FILE__, __LINE__);
+
+/**
+ * XSLT_STRANGE:
+ *
+ * Macro to flag that a problem was detected internally.
+ */
+#define XSLT_STRANGE                                                   \
+    xsltGenericError(xsltGenericErrorContext,                          \
+           "Internal error at %s:%d\n",                                \
+            __FILE__, __LINE__);
+
+/**
+ * IS_XSLT_ELEM:
+ *
+ * Checks that the element pertains to XSLT namespace.
+ */
+#define IS_XSLT_ELEM(n)                                                        \
+    (((n) != NULL) && ((n)->ns != NULL) &&                             \
+     (xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))
+
+/**
+ * IS_XSLT_NAME:
+ *
+ * Checks the value of an element in XSLT namespace.
+ */
+#define IS_XSLT_NAME(n, val)                                           \
+    (xmlStrEqual((n)->name, (const xmlChar *) (val)))
+
+/**
+ * IS_XSLT_REAL_NODE:
+ *
+ * Check that a node is a 'real' one: document, element, text or attribute.
+ */
+#define IS_XSLT_REAL_NODE(n)                                           \
+    (((n) != NULL) &&                                                  \
+     (((n)->type == XML_ELEMENT_NODE) ||                               \
+      ((n)->type == XML_TEXT_NODE) ||                                  \
+      ((n)->type == XML_CDATA_SECTION_NODE) ||                         \
+      ((n)->type == XML_ATTRIBUTE_NODE) ||                             \
+      ((n)->type == XML_DOCUMENT_NODE) ||                              \
+      ((n)->type == XML_HTML_DOCUMENT_NODE) ||                         \
+      ((n)->type == XML_COMMENT_NODE) ||                               \
+      ((n)->type == XML_PI_NODE)))      
+
+/*
+ * Our own version of namespaced atributes lookup.
+ */
+XSLTPUBFUN xmlChar * XSLTCALL
+               xsltGetNsProp   (xmlNodePtr node,
+                                const xmlChar *name,
+                                const xmlChar *nameSpace);
+XSLTPUBFUN const xmlChar * XSLTCALL
+               xsltGetCNsProp  (xsltStylesheetPtr style,
+                                xmlNodePtr node,
+                                const xmlChar *name,
+                                const xmlChar *nameSpace);
+XSLTPUBFUN int XSLTCALL
+               xsltGetUTF8Char (const unsigned char *utf,
+                                int *len);
+
+/*
+ * XSLT Debug Tracing Tracing Types
+ */
+typedef enum {
+       XSLT_TRACE_ALL =                -1,
+       XSLT_TRACE_NONE =               0,
+       XSLT_TRACE_COPY_TEXT =          1<<0,
+       XSLT_TRACE_PROCESS_NODE =       1<<1,
+       XSLT_TRACE_APPLY_TEMPLATE =     1<<2,
+       XSLT_TRACE_COPY =               1<<3,
+       XSLT_TRACE_COMMENT =            1<<4,
+       XSLT_TRACE_PI =                 1<<5,
+       XSLT_TRACE_COPY_OF =            1<<6,
+       XSLT_TRACE_VALUE_OF =           1<<7,
+       XSLT_TRACE_CALL_TEMPLATE =      1<<8,
+       XSLT_TRACE_APPLY_TEMPLATES =    1<<9,
+       XSLT_TRACE_CHOOSE =             1<<10,
+       XSLT_TRACE_IF =                 1<<11,
+       XSLT_TRACE_FOR_EACH =           1<<12,
+       XSLT_TRACE_STRIP_SPACES =       1<<13,
+       XSLT_TRACE_TEMPLATES =          1<<14,
+       XSLT_TRACE_KEYS =               1<<15,
+       XSLT_TRACE_VARIABLES =          1<<16
+} xsltDebugTraceCodes;
+
+/**
+ * XSLT_TRACE:
+ *
+ * Control the type of xsl debugtrace messages emitted.
+ */
+#define XSLT_TRACE(ctxt,code,call)     \
+       if (ctxt->traceCode && (*(ctxt->traceCode) & code)) \
+           call
+
+XSLTPUBFUN void XSLTCALL
+               xsltDebugSetDefaultTrace(xsltDebugTraceCodes val);
+XSLTPUBFUN xsltDebugTraceCodes XSLTCALL
+               xsltDebugGetDefaultTrace(void);
+
+/*
+ * XSLT specific error and debug reporting functions.
+ */
+XSLTPUBVAR xmlGenericErrorFunc xsltGenericError;
+XSLTPUBVAR void *xsltGenericErrorContext;
+XSLTPUBVAR xmlGenericErrorFunc xsltGenericDebug;
+XSLTPUBVAR void *xsltGenericDebugContext;
+
+XSLTPUBFUN void XSLTCALL               
+               xsltPrintErrorContext           (xsltTransformContextPtr ctxt,
+                                                xsltStylesheetPtr style,
+                                                xmlNodePtr node);
+XSLTPUBFUN void XSLTCALL               
+               xsltMessage                     (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr node,
+                                                xmlNodePtr inst);
+XSLTPUBFUN void XSLTCALL               
+               xsltSetGenericErrorFunc         (void *ctx,
+                                                xmlGenericErrorFunc handler);
+XSLTPUBFUN void XSLTCALL               
+               xsltSetGenericDebugFunc         (void *ctx,
+                                                xmlGenericErrorFunc handler);
+XSLTPUBFUN void XSLTCALL               
+               xsltSetTransformErrorFunc       (xsltTransformContextPtr ctxt,
+                                                void *ctx,
+                                                xmlGenericErrorFunc handler);
+XSLTPUBFUN void XSLTCALL               
+               xsltTransformError              (xsltTransformContextPtr ctxt,
+                                                xsltStylesheetPtr style,
+                                                xmlNodePtr node,
+                                                const char *msg,
+                                                ...);
+
+XSLTPUBFUN int XSLTCALL
+               xsltSetCtxtParseOptions         (xsltTransformContextPtr ctxt,
+                                                int options);
+/*
+ * Sorting.
+ */
+
+XSLTPUBFUN void XSLTCALL               
+               xsltDocumentSortFunction        (xmlNodeSetPtr list);
+XSLTPUBFUN void XSLTCALL               
+               xsltSetSortFunc                 (xsltSortFunc handler);
+XSLTPUBFUN void XSLTCALL               
+               xsltSetCtxtSortFunc             (xsltTransformContextPtr ctxt,
+                                                xsltSortFunc handler);
+XSLTPUBFUN void XSLTCALL               
+               xsltDefaultSortFunction         (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr *sorts,
+                                                int nbsorts);
+XSLTPUBFUN void XSLTCALL               
+               xsltDoSortFunction              (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr * sorts,
+                                                int nbsorts);
+XSLTPUBFUN xmlXPathObjectPtr * XSLTCALL 
+               xsltComputeSortResult           (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr sort);
+
+/*
+ * QNames handling.
+ */
+
+XSLTPUBFUN const xmlChar * XSLTCALL
+               xsltSplitQName                  (xmlDictPtr dict,
+                                                const xmlChar *name,
+                                                const xmlChar **prefix);
+XSLTPUBFUN const xmlChar * XSLTCALL 
+               xsltGetQNameURI                 (xmlNodePtr node,
+                                                xmlChar **name);
+
+XSLTPUBFUN const xmlChar * XSLTCALL
+               xsltGetQNameURI2                (xsltStylesheetPtr style,
+                                                xmlNodePtr node,
+                                                const xmlChar **name);
+
+/*
+ * Output, reuse libxml I/O buffers.
+ */
+XSLTPUBFUN int XSLTCALL                
+               xsltSaveResultTo                (xmlOutputBufferPtr buf,
+                                                xmlDocPtr result,
+                                                xsltStylesheetPtr style);
+XSLTPUBFUN int XSLTCALL                
+               xsltSaveResultToFilename        (const char *URI,
+                                                xmlDocPtr result,
+                                                xsltStylesheetPtr style,
+                                                int compression);
+XSLTPUBFUN int XSLTCALL                
+               xsltSaveResultToFile            (FILE *file,
+                                                xmlDocPtr result,
+                                                xsltStylesheetPtr style);
+XSLTPUBFUN int XSLTCALL                
+               xsltSaveResultToFd              (int fd,
+                                                xmlDocPtr result,
+                                                xsltStylesheetPtr style);
+XSLTPUBFUN int XSLTCALL             
+               xsltSaveResultToString          (xmlChar **doc_txt_ptr, 
+                                                 int * doc_txt_len, 
+                                                 xmlDocPtr result, 
+                                                 xsltStylesheetPtr style);
+
+/*
+ * XPath interface
+ */
+XSLTPUBFUN xmlXPathCompExprPtr XSLTCALL
+               xsltXPathCompile                (xsltStylesheetPtr style,
+                                                const xmlChar *str);
+
+/*
+ * Profiling.
+ */
+XSLTPUBFUN void XSLTCALL               
+               xsltSaveProfiling               (xsltTransformContextPtr ctxt,
+                                                FILE *output);
+XSLTPUBFUN xmlDocPtr XSLTCALL  
+               xsltGetProfileInformation       (xsltTransformContextPtr ctxt);
+
+XSLTPUBFUN long XSLTCALL               
+               xsltTimestamp                   (void);
+XSLTPUBFUN void XSLTCALL               
+               xsltCalibrateAdjust             (long delta);
+
+/**
+ * XSLT_TIMESTAMP_TICS_PER_SEC:
+ *
+ * Sampling precision for profiling
+ */
+#define XSLT_TIMESTAMP_TICS_PER_SEC 100000l
+
+/*
+ * Hooks for the debugger.
+ */
+
+typedef enum {
+    XSLT_DEBUG_NONE = 0, /* no debugging allowed */
+    XSLT_DEBUG_INIT,
+    XSLT_DEBUG_STEP,
+    XSLT_DEBUG_STEPOUT,
+    XSLT_DEBUG_NEXT,
+    XSLT_DEBUG_STOP,
+    XSLT_DEBUG_CONT,
+    XSLT_DEBUG_RUN,
+    XSLT_DEBUG_RUN_RESTART,
+    XSLT_DEBUG_QUIT
+} xsltDebugStatusCodes;
+
+XSLTPUBVAR int xslDebugStatus;
+
+typedef void (*xsltHandleDebuggerCallback) (xmlNodePtr cur, xmlNodePtr node,
+                       xsltTemplatePtr templ, xsltTransformContextPtr ctxt);
+typedef int (*xsltAddCallCallback) (xsltTemplatePtr templ, xmlNodePtr source);
+typedef void (*xsltDropCallCallback) (void);
+
+XSLTPUBFUN void XSLTCALL
+               xsltSetDebuggerStatus           (int value);
+XSLTPUBFUN int XSLTCALL
+               xsltGetDebuggerStatus           (void);
+XSLTPUBFUN int XSLTCALL                
+               xsltSetDebuggerCallbacks        (int no, void *block);
+XSLTPUBFUN int XSLTCALL                
+               xslAddCall                      (xsltTemplatePtr templ,
+                                                xmlNodePtr source);
+XSLTPUBFUN void XSLTCALL               
+               xslDropCall                     (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLTUTILS_H__ */
+
+
diff --git a/reactos/dll/3rdparty/libxslt/xsltwin32config.h b/reactos/dll/3rdparty/libxslt/xsltwin32config.h
new file mode 100644 (file)
index 0000000..1016c1e
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Summary: compile-time version informations for the XSLT engine 
+ *          when compiled on windows
+ * Description: compile-time version informations for the XSLT engine
+ *              when compiled on windows. This file is generated.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLTWIN32CONFIG_H__
+#define __XML_XSLTWIN32CONFIG_H__
+
+#include "win32config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * LIBXSLT_DOTTED_VERSION:
+ *
+ * the version string like "1.2.3"
+ */
+#define LIBXSLT_DOTTED_VERSION "1.1.24"
+
+/**
+ * LIBXSLT_VERSION:
+ *
+ * the version number: 1.2.3 value is 1002003
+ */
+#define LIBXSLT_VERSION 10124
+
+/**
+ * LIBXSLT_VERSION_STRING:
+ *
+ * the version number string, 1.2.3 value is "1002003"
+ */
+#define LIBXSLT_VERSION_STRING "10124"
+
+/**
+ * LIBXSLT_VERSION_EXTRA:
+ *
+ * extra version information, used to show a CVS compilation
+ */
+#define LIBXSLT_VERSION_EXTRA "-win32"
+
+/**
+ * WITH_XSLT_DEBUG:
+ *
+ * Activate the compilation of the debug reporting. Speed penalty
+ * is insignifiant and being able to run xsltpoc -v is useful. On
+ * by default
+ */
+#if 0
+#define WITH_XSLT_DEBUG
+#endif
+
+/**
+ * WITH_MODULES:
+ *
+ * Whether module support is configured into libxslt
+ */
+#if 0
+#ifndef WITH_MODULES
+#define WITH_MODULES
+#endif
+#define LIBXSLT_PLUGINS_PATH() getenv("LIBXSLT_PLUGINS_PATH")
+#endif
+
+#if 0
+/**
+ * DEBUG_MEMORY:
+ *
+ * should be activated only when debugging libxslt. It replaces the
+ * allocator with a collect and debug shell to the libc allocator.
+ * Use configure --with-mem-debug to activate it on both library
+ */
+#define DEBUG_MEMORY
+
+/**
+ * DEBUG_MEMORY_LOCATION:
+ *
+ * should be activated only when debugging libxslt.
+ * DEBUG_MEMORY_LOCATION should be activated only when libxml has
+ * been configured with --with-debug-mem too
+ */
+#define DEBUG_MEMORY_LOCATION
+#endif
+
+/**
+ * ATTRIBUTE_UNUSED:
+ *
+ * This macro is used to flag unused function parameters to GCC, useless here
+ */
+#ifndef ATTRIBUTE_UNUSED
+#define ATTRIBUTE_UNUSED
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLTWIN32CONFIG_H__ */
diff --git a/reactos/dll/3rdparty/libxslt/xsltwin32config.h.in b/reactos/dll/3rdparty/libxslt/xsltwin32config.h.in
new file mode 100644 (file)
index 0000000..cceeb6b
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Summary: compile-time version informations for the XSLT engine 
+ *          when compiled on windows
+ * Description: compile-time version informations for the XSLT engine
+ *              when compiled on windows. This file is generated.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLTWIN32CONFIG_H__
+#define __XML_XSLTWIN32CONFIG_H__
+
+#include "win32config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * LIBXSLT_DOTTED_VERSION:
+ *
+ * the version string like "1.2.3"
+ */
+#define LIBXSLT_DOTTED_VERSION "@VERSION@"
+
+/**
+ * LIBXSLT_VERSION:
+ *
+ * the version number: 1.2.3 value is 1002003
+ */
+#define LIBXSLT_VERSION @LIBXSLT_VERSION_NUMBER@
+
+/**
+ * LIBXSLT_VERSION_STRING:
+ *
+ * the version number string, 1.2.3 value is "1002003"
+ */
+#define LIBXSLT_VERSION_STRING "@LIBXSLT_VERSION_NUMBER@"
+
+/**
+ * LIBXSLT_VERSION_EXTRA:
+ *
+ * extra version information, used to show a CVS compilation
+ */
+#define LIBXSLT_VERSION_EXTRA "-win32"
+
+/**
+ * WITH_XSLT_DEBUG:
+ *
+ * Activate the compilation of the debug reporting. Speed penalty
+ * is insignifiant and being able to run xsltpoc -v is useful. On
+ * by default
+ */
+#if 1
+#define WITH_XSLT_DEBUG
+#endif
+
+/**
+ * WITH_MODULES:
+ *
+ * Whether module support is configured into libxslt
+ */
+#if @WITH_MODULES@
+#ifndef WITH_MODULES
+#define WITH_MODULES
+#endif
+#define LIBXSLT_PLUGINS_PATH() getenv("LIBXSLT_PLUGINS_PATH")
+#endif
+
+#if 0
+/**
+ * DEBUG_MEMORY:
+ *
+ * should be activated only when debugging libxslt. It replaces the
+ * allocator with a collect and debug shell to the libc allocator.
+ * Use configure --with-mem-debug to activate it on both library
+ */
+#define DEBUG_MEMORY
+
+/**
+ * DEBUG_MEMORY_LOCATION:
+ *
+ * should be activated only when debugging libxslt.
+ * DEBUG_MEMORY_LOCATION should be activated only when libxml has
+ * been configured with --with-debug-mem too
+ */
+#define DEBUG_MEMORY_LOCATION
+#endif
+
+/**
+ * ATTRIBUTE_UNUSED:
+ *
+ * This macro is used to flag unused function parameters to GCC, useless here
+ */
+#ifndef ATTRIBUTE_UNUSED
+#define ATTRIBUTE_UNUSED
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLTWIN32CONFIG_H__ */
index 67dd3c3..9820eea 100644 (file)
@@ -10,7 +10,9 @@
        <define name="_WIN32_WINNT">0x601</define>
        <define name="LIBXML_STATIC" />
        <library>libxml2</library>
+       <library>libxslt</library>
        <library>wine</library>
+       <library>wineldr</library>
        <library>urlmon</library>
        <library>wininet</library>
        <library>ws2_32</library>
index 5a237a8..49d057c 100644 (file)
@@ -89,7 +89,7 @@ interface IMXWriter;
 cpp_quote("#define DOMDocument DOMDocument2")
 cpp_quote("#define CLSID_DOMDocument CLSID_DOMDocument2")
 
-cpp_quote("#ifndef __xmldom_h__")
+cpp_quote("#ifndef __WIDL_XMLDOM_H")
 typedef enum tagDOMNodeType 
 {  
     NODE_INVALID               = 0,
@@ -106,7 +106,7 @@ typedef enum tagDOMNodeType
     NODE_DOCUMENT_FRAGMENT     = 11,
     NODE_NOTATION              = 12
 } DOMNodeType;
-cpp_quote("#endif   /* __xmldom_h__ */")
+cpp_quote("#endif   /* __WIDL_XMLDOM_H */")
 
 [
 local,
index 24d5cf9..567addb 100644 (file)
@@ -594,7 +594,7 @@ typedef void (*cdataBlockSAXFunc) (
  * Display and format a warning messages, callback.
  */
 typedef void (XMLCDECL *warningSAXFunc) (void *ctx,
-                               const char *msg, ...);
+                               const char *msg, ...) ATTRIBUTE_PRINTF(2,3);
 /**
  * errorSAXFunc:
  * @ctx:  an XML parser context
@@ -604,7 +604,7 @@ typedef void (XMLCDECL *warningSAXFunc) (void *ctx,
  * Display and format an error messages, callback.
  */
 typedef void (XMLCDECL *errorSAXFunc) (void *ctx,
-                               const char *msg, ...);
+                               const char *msg, ...) ATTRIBUTE_PRINTF(2,3);
 /**
  * fatalErrorSAXFunc:
  * @ctx:  an XML parser context
@@ -616,7 +616,7 @@ typedef void (XMLCDECL *errorSAXFunc) (void *ctx,
  *       get all the callbacks for errors.
  */
 typedef void (XMLCDECL *fatalErrorSAXFunc) (void *ctx,
-                               const char *msg, ...);
+                               const char *msg, ...) ATTRIBUTE_PRINTF(2,3);
 /**
  * isStandaloneSAXFunc:
  * @ctx:  the user data (XML parser context)
@@ -1096,7 +1096,8 @@ typedef enum {
                                   crash if you try to modify the tree) */
     XML_PARSE_OLD10    = 1<<17,/* parse using XML-1.0 before update 5 */
     XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */
-    XML_PARSE_HUGE      = 1<<19 /* relax any hardcoded limit from the parser */
+    XML_PARSE_HUGE      = 1<<19, /* relax any hardcoded limit from the parser */
+    XML_PARSE_OLDSAX    = 1<<20 /* parse using SAX2 interface from before 2.7.0 */
 } xmlParserOption;
 
 XMLPUBFUN void XMLCALL
index fddcd27..a5e75b5 100644 (file)
@@ -24,18 +24,27 @@ extern "C" {
 /**
  * xmlParserMaxDepth:
  *
- * arbitrary depth limit for the XML documents that we allow to 
- * process. This is not a limitation of the parser but a safety 
- * boundary feature.
+ * arbitrary depth limit for the XML documents that we allow to
+ * process. This is not a limitation of the parser but a safety
+ * boundary feature, use XML_PARSE_HUGE option to override it.
  */
 XMLPUBVAR unsigned int xmlParserMaxDepth;
 
- /**
-  * XML_MAX_NAMELEN:
-  *
-  * Identifiers can be longer, but this will be more costly
-  * at runtime.
-  */
+/**
+ * XML_MAX_TEXT_LENGTH:
+ *
+ * Maximum size allowed for a single text node when building a tree.
+ * This is not a limitation of the parser but a safety boundary feature,
+ * use XML_PARSE_HUGE option to override it.
+ */
+#define XML_MAX_TEXT_LENGTH 10000000
+
+/**
+ * XML_MAX_NAMELEN:
+ *
+ * Identifiers can be longer, but this will be more costly
+ * at runtime.
+ */
 #define XML_MAX_NAMELEN 100
 
 /**
index 29c91c7..d3e39e0 100644 (file)
@@ -32,7 +32,7 @@ typedef xmlRelaxNG *xmlRelaxNGPtr;
  *
  * Signature of an error callback from a Relax-NG validation
  */
-typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx, const char *msg, ...);
+typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx, const char *msg, ...) ATTRIBUTE_PRINTF(2,3);
 
 /**
  * xmlRelaxNGValidityWarningFunc:
@@ -42,7 +42,7 @@ typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx, const char *msg
  *
  * Signature of a warning callback from a Relax-NG validation
  */
-typedef void (XMLCDECL *xmlRelaxNGValidityWarningFunc) (void *ctx, const char *msg, ...);
+typedef void (XMLCDECL *xmlRelaxNGValidityWarningFunc) (void *ctx, const char *msg, ...) ATTRIBUTE_PRINTF(2,3);
 
 /**
  * A schemas validation context
@@ -114,27 +114,27 @@ typedef enum {
 
 XMLPUBFUN int XMLCALL
                    xmlRelaxNGInitTypes         (void);
-XMLPUBFUN void XMLCALL                 
+XMLPUBFUN void XMLCALL
                    xmlRelaxNGCleanupTypes      (void);
 
 /*
  * Interfaces for parsing.
  */
-XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL 
+XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
                    xmlRelaxNGNewParserCtxt     (const char *URL);
-XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL 
+XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
                    xmlRelaxNGNewMemParserCtxt  (const char *buffer,
                                                 int size);
-XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL   
+XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
                    xmlRelaxNGNewDocParserCtxt  (xmlDocPtr doc);
 
 XMLPUBFUN int XMLCALL
                    xmlRelaxParserSetFlag       (xmlRelaxNGParserCtxtPtr ctxt,
-                                                int flag);
+                                                int flag);
 
-XMLPUBFUN void XMLCALL         
+XMLPUBFUN void XMLCALL
                    xmlRelaxNGFreeParserCtxt    (xmlRelaxNGParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL                 
+XMLPUBFUN void XMLCALL
                    xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt,
                                         xmlRelaxNGValidityErrorFunc err,
                                         xmlRelaxNGValidityWarningFunc warn,
@@ -149,12 +149,12 @@ XMLPUBFUN void XMLCALL
                                         xmlRelaxNGParserCtxtPtr ctxt,
                                         xmlStructuredErrorFunc serror,
                                         void *ctx);
-XMLPUBFUN xmlRelaxNGPtr XMLCALL        
+XMLPUBFUN xmlRelaxNGPtr XMLCALL
                    xmlRelaxNGParse             (xmlRelaxNGParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL         
+XMLPUBFUN void XMLCALL
                    xmlRelaxNGFree              (xmlRelaxNGPtr schema);
 #ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL         
+XMLPUBFUN void XMLCALL
                    xmlRelaxNGDump              (FILE *output,
                                         xmlRelaxNGPtr schema);
 XMLPUBFUN void XMLCALL
@@ -164,12 +164,12 @@ XMLPUBFUN void XMLCALL
 /*
  * Interfaces for validating
  */
-XMLPUBFUN void XMLCALL         
+XMLPUBFUN void XMLCALL
                    xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
                                         xmlRelaxNGValidityErrorFunc err,
                                         xmlRelaxNGValidityWarningFunc warn,
                                         void *ctx);
-XMLPUBFUN int XMLCALL  
+XMLPUBFUN int XMLCALL
                    xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
                                         xmlRelaxNGValidityErrorFunc *err,
                                         xmlRelaxNGValidityWarningFunc *warn,
@@ -177,29 +177,29 @@ XMLPUBFUN int XMLCALL
 XMLPUBFUN void XMLCALL
                        xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt,
                                          xmlStructuredErrorFunc serror, void *ctx);
-XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL       
+XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL
                    xmlRelaxNGNewValidCtxt      (xmlRelaxNGPtr schema);
-XMLPUBFUN void XMLCALL                 
+XMLPUBFUN void XMLCALL
                    xmlRelaxNGFreeValidCtxt     (xmlRelaxNGValidCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL                  
+XMLPUBFUN int XMLCALL
                    xmlRelaxNGValidateDoc       (xmlRelaxNGValidCtxtPtr ctxt,
-                                                xmlDocPtr doc);
+                                                xmlDocPtr doc);
 /*
  * Interfaces for progressive validation when possible
  */
-XMLPUBFUN int XMLCALL  
+XMLPUBFUN int XMLCALL
                    xmlRelaxNGValidatePushElement       (xmlRelaxNGValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlNodePtr elem);
-XMLPUBFUN int XMLCALL  
+XMLPUBFUN int XMLCALL
                    xmlRelaxNGValidatePushCData (xmlRelaxNGValidCtxtPtr ctxt,
                                         const xmlChar *data,
                                         int len);
-XMLPUBFUN int XMLCALL  
+XMLPUBFUN int XMLCALL
                    xmlRelaxNGValidatePopElement        (xmlRelaxNGValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlNodePtr elem);
-XMLPUBFUN int XMLCALL  
+XMLPUBFUN int XMLCALL
                    xmlRelaxNGValidateFullElement       (xmlRelaxNGValidCtxtPtr ctxt,
                                         xmlDocPtr doc,
                                         xmlNodePtr elem);
index 6a6a09d..b733589 100644 (file)
@@ -1225,6 +1225,22 @@ XMLPUBFUN int XMLCALL
                                         int deep,
                                         int options);
 
+#ifdef LIBXML_TREE_ENABLED
+/*
+ * 5 interfaces from DOM ElementTraversal, but different in entities
+ * traversal.
+ */
+XMLPUBFUN unsigned long XMLCALL
+            xmlChildElementCount        (xmlNodePtr parent);
+XMLPUBFUN xmlNodePtr XMLCALL
+            xmlNextElementSibling       (xmlNodePtr node);
+XMLPUBFUN xmlNodePtr XMLCALL
+            xmlFirstElementChild        (xmlNodePtr parent);
+XMLPUBFUN xmlNodePtr XMLCALL
+            xmlLastElementChild         (xmlNodePtr parent);
+XMLPUBFUN xmlNodePtr XMLCALL
+            xmlPreviousElementSibling   (xmlNodePtr node);
+#endif
 #ifdef __cplusplus
 }
 #endif
index 7492d28..f1892b0 100644 (file)
@@ -41,7 +41,7 @@ typedef xmlValidState *xmlValidStatePtr;
  */
 typedef void (XMLCDECL *xmlValidityErrorFunc) (void *ctx,
                             const char *msg,
-                            ...);
+                            ...) ATTRIBUTE_PRINTF(2,3);
 
 /**
  * xmlValidityWarningFunc:
@@ -56,7 +56,7 @@ typedef void (XMLCDECL *xmlValidityErrorFunc) (void *ctx,
  */
 typedef void (XMLCDECL *xmlValidityWarningFunc) (void *ctx,
                               const char *msg,
-                              ...);
+                              ...) ATTRIBUTE_PRINTF(2,3);
 
 #ifdef IN_LIBXML
 /**
index c9336b9..7cce9c3 100644 (file)
@@ -61,7 +61,7 @@ typedef enum {
     XML_FROM_CHECK,    /* The error checking module */
     XML_FROM_WRITER,   /* The xmlwriter module */
     XML_FROM_MODULE,   /* The dynamically loaded module module*/
-    XML_FROM_I18N,     /* The module handling character conversion */
+    XML_FROM_I18N,     /* The module handling character conversion */
     XML_FROM_SCHEMATRONV       /* The Schematron validator module */
 } xmlErrorDomain;
 
@@ -645,7 +645,7 @@ typedef enum {
     XML_SCHEMAV_CVC_ELT_4_3, /* 1852 */
     XML_SCHEMAV_CVC_ELT_5_1_1, /* 1853 */
     XML_SCHEMAV_CVC_ELT_5_1_2, /* 1854 */
-    XML_SCHEMAV_CVC_ELT_5_2_1, /* 1855 */  
+    XML_SCHEMAV_CVC_ELT_5_2_1, /* 1855 */
     XML_SCHEMAV_CVC_ELT_5_2_2_1, /* 1856 */
     XML_SCHEMAV_CVC_ELT_5_2_2_2_1, /* 1857 */
     XML_SCHEMAV_CVC_ELT_5_2_2_2_2, /* 1858 */
@@ -670,7 +670,7 @@ typedef enum {
     XML_SCHEMAV_CVC_IDC, /* 1877 */
     XML_SCHEMAV_CVC_WILDCARD, /* 1878 */
     XML_SCHEMAV_MISC, /* 1879 */
-    XML_XPTR_UNKNOWN_SCHEME = 1900, 
+    XML_XPTR_UNKNOWN_SCHEME = 1900,
     XML_XPTR_CHILDSEQ_START, /* 1901 */
     XML_XPTR_EVAL_FAILED, /* 1902 */
     XML_XPTR_EXTRA_OBJECTS, /* 1903 */
@@ -691,15 +691,15 @@ typedef enum {
     XML_SCHEMAP_SRC_SIMPLE_TYPE_2, /* 3001 */
     XML_SCHEMAP_SRC_SIMPLE_TYPE_3, /* 3002 */
     XML_SCHEMAP_SRC_SIMPLE_TYPE_4, /* 3003 */
-    XML_SCHEMAP_SRC_RESOLVE, /* 3004 */ 
+    XML_SCHEMAP_SRC_RESOLVE, /* 3004 */
     XML_SCHEMAP_SRC_RESTRICTION_BASE_OR_SIMPLETYPE, /* 3005 */
     XML_SCHEMAP_SRC_LIST_ITEMTYPE_OR_SIMPLETYPE, /* 3006 */
     XML_SCHEMAP_SRC_UNION_MEMBERTYPES_OR_SIMPLETYPES, /* 3007 */
     XML_SCHEMAP_ST_PROPS_CORRECT_1, /* 3008 */
     XML_SCHEMAP_ST_PROPS_CORRECT_2, /* 3009 */
-    XML_SCHEMAP_ST_PROPS_CORRECT_3, /* 3010 */     
+    XML_SCHEMAP_ST_PROPS_CORRECT_3, /* 3010 */
     XML_SCHEMAP_COS_ST_RESTRICTS_1_1, /* 3011 */
-    XML_SCHEMAP_COS_ST_RESTRICTS_1_2, /* 3012 */    
+    XML_SCHEMAP_COS_ST_RESTRICTS_1_2, /* 3012 */
     XML_SCHEMAP_COS_ST_RESTRICTS_1_3_1, /* 3013 */
     XML_SCHEMAP_COS_ST_RESTRICTS_1_3_2, /* 3014 */
     XML_SCHEMAP_COS_ST_RESTRICTS_2_1, /* 3015 */
@@ -718,7 +718,7 @@ typedef enum {
     XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3, /* 3028 */
     XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_4, /* 3029 */
     XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_5, /* 3030 */
-    XML_SCHEMAP_COS_ST_DERIVED_OK_2_1, /* 3031 */ 
+    XML_SCHEMAP_COS_ST_DERIVED_OK_2_1, /* 3031 */
     XML_SCHEMAP_COS_ST_DERIVED_OK_2_2, /* 3032 */
     XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED, /* 3033 */
     XML_SCHEMAP_S4S_ELEM_MISSING, /* 3034 */
@@ -737,14 +737,14 @@ typedef enum {
     XML_SCHEMAP_E_PROPS_CORRECT_4, /* 3047 */
     XML_SCHEMAP_E_PROPS_CORRECT_5, /* 3048 */
     XML_SCHEMAP_E_PROPS_CORRECT_6, /* 3049 */
-    XML_SCHEMAP_SRC_INCLUDE, /* 3050 */    
+    XML_SCHEMAP_SRC_INCLUDE, /* 3050 */
     XML_SCHEMAP_SRC_ATTRIBUTE_1, /* 3051 */
     XML_SCHEMAP_SRC_ATTRIBUTE_2, /* 3052 */
     XML_SCHEMAP_SRC_ATTRIBUTE_3_1, /* 3053 */
     XML_SCHEMAP_SRC_ATTRIBUTE_3_2, /* 3054 */
     XML_SCHEMAP_SRC_ATTRIBUTE_4, /* 3055 */
     XML_SCHEMAP_NO_XMLNS, /* 3056 */
-    XML_SCHEMAP_NO_XSI, /* 3057 */      
+    XML_SCHEMAP_NO_XSI, /* 3057 */
     XML_SCHEMAP_COS_VALID_DEFAULT_1, /* 3058 */
     XML_SCHEMAP_COS_VALID_DEFAULT_2_1, /* 3059 */
     XML_SCHEMAP_COS_VALID_DEFAULT_2_2_1, /* 3060 */
@@ -843,7 +843,7 @@ typedef enum {
  */
 typedef void (XMLCDECL *xmlGenericErrorFunc) (void *ctx,
                                 const char *msg,
-                                ...);
+                                ...) ATTRIBUTE_PRINTF(2,3);
 /**
  * xmlStructuredErrorFunc:
  * @userData:  user provided data for the error callback
@@ -858,38 +858,38 @@ typedef void (XMLCALL *xmlStructuredErrorFunc) (void *userData, xmlErrorPtr erro
  * Use the following function to reset the two global variables
  * xmlGenericError and xmlGenericErrorContext.
  */
-XMLPUBFUN void XMLCALL 
+XMLPUBFUN void XMLCALL
     xmlSetGenericErrorFunc     (void *ctx,
                                 xmlGenericErrorFunc handler);
-XMLPUBFUN void XMLCALL 
+XMLPUBFUN void XMLCALL
     initGenericErrorDefaultFunc        (xmlGenericErrorFunc *handler);
 
-XMLPUBFUN void XMLCALL 
+XMLPUBFUN void XMLCALL
     xmlSetStructuredErrorFunc  (void *ctx,
                                 xmlStructuredErrorFunc handler);
 /*
  * Default message routines used by SAX and Valid context for error
  * and warning reporting.
  */
-XMLPUBFUN void XMLCDECL        
+XMLPUBFUN void XMLCDECL
     xmlParserError             (void *ctx,
                                 const char *msg,
-                                ...);
-XMLPUBFUN void XMLCDECL        
+                                ...) ATTRIBUTE_PRINTF(2,3);
+XMLPUBFUN void XMLCDECL
     xmlParserWarning           (void *ctx,
                                 const char *msg,
-                                ...);
-XMLPUBFUN void XMLCDECL        
+                                ...) ATTRIBUTE_PRINTF(2,3);
+XMLPUBFUN void XMLCDECL
     xmlParserValidityError     (void *ctx,
                                 const char *msg,
-                                ...);
-XMLPUBFUN void XMLCDECL        
+                                ...) ATTRIBUTE_PRINTF(2,3);
+XMLPUBFUN void XMLCDECL
     xmlParserValidityWarning   (void *ctx,
                                 const char *msg,
-                                ...);
-XMLPUBFUN void XMLCALL 
+                                ...) ATTRIBUTE_PRINTF(2,3);
+XMLPUBFUN void XMLCALL
     xmlParserPrintFileInfo     (xmlParserInputPtr input);
-XMLPUBFUN void XMLCALL 
+XMLPUBFUN void XMLCALL
     xmlParserPrintFileContext  (xmlParserInputPtr input);
 
 /*
@@ -907,19 +907,19 @@ XMLPUBFUN void XMLCALL
     xmlResetError              (xmlErrorPtr err);
 XMLPUBFUN int XMLCALL
     xmlCopyError               (xmlErrorPtr from,
-                                xmlErrorPtr to);
+                                xmlErrorPtr to);
 
 #ifdef IN_LIBXML
 /*
  * Internal callback reporting routine
  */
-XMLPUBFUN void XMLCALL 
+XMLPUBFUN void XMLCALL
     __xmlRaiseError            (xmlStructuredErrorFunc schannel,
-                                xmlGenericErrorFunc channel,
-                                void *data,
+                                xmlGenericErrorFunc channel,
+                                void *data,
                                  void *ctx,
-                                void *node,
-                                int domain,
+                                void *node,
+                                int domain,
                                 int code,
                                 xmlErrorLevel level,
                                 const char *file,
@@ -930,10 +930,10 @@ XMLPUBFUN void XMLCALL
                                 int int1,
                                 int col,
                                 const char *msg,
-                                ...);
-XMLPUBFUN void XMLCALL 
+                                ...) ATTRIBUTE_PRINTF(16,17);
+XMLPUBFUN void XMLCALL
     __xmlSimpleError           (int domain,
-                                int code,
+                                int code,
                                 xmlNodePtr node,
                                 const char *msg,
                                 const char *extra);
index ee8328a..8f3b109 100644 (file)
@@ -63,7 +63,7 @@ typedef void (XMLCALL *xmlFreeFunc)(void *mem);
  *
  * Returns a pointer to the newly allocated block or NULL in case of error.
  */
-typedef void *(XMLCALL *xmlMallocFunc)(size_t size);
+typedef void *(ATTRIBUTE_ALLOC_SIZE(1) XMLCALL *xmlMallocFunc)(size_t size);
 
 /**
  * xmlReallocFunc:
@@ -150,7 +150,7 @@ XMLPUBFUN void XMLCALL
 XMLPUBFUN void XMLCALL
        xmlMemoryDump   (void);
 XMLPUBFUN void * XMLCALL
-       xmlMemMalloc    (size_t size);
+       xmlMemMalloc    (size_t size) ATTRIBUTE_ALLOC_SIZE(1);
 XMLPUBFUN void * XMLCALL
        xmlMemRealloc   (void *ptr,size_t size);
 XMLPUBFUN void XMLCALL
@@ -158,11 +158,11 @@ XMLPUBFUN void XMLCALL
 XMLPUBFUN char * XMLCALL
        xmlMemoryStrdup (const char *str);
 XMLPUBFUN void * XMLCALL
-       xmlMallocLoc    (size_t size, const char *file, int line);
+       xmlMallocLoc    (size_t size, const char *file, int line) ATTRIBUTE_ALLOC_SIZE(1);
 XMLPUBFUN void * XMLCALL
        xmlReallocLoc   (void *ptr, size_t size, const char *file, int line);
 XMLPUBFUN void * XMLCALL
-       xmlMallocAtomicLoc (size_t size, const char *file, int line);
+       xmlMallocAtomicLoc (size_t size, const char *file, int line) ATTRIBUTE_ALLOC_SIZE(1);
 XMLPUBFUN char * XMLCALL
        xmlMemStrdupLoc (const char *str, const char *file, int line);
 
index 556ef89..ebef3a7 100644 (file)
@@ -92,7 +92,7 @@ typedef xmlSchema *xmlSchemaPtr;
  *
  * Signature of an error callback from an XSD validation
  */
-typedef void (XMLCDECL *xmlSchemaValidityErrorFunc) (void *ctx, const char *msg, ...);
+typedef void (XMLCDECL *xmlSchemaValidityErrorFunc) (void *ctx, const char *msg, ...) ATTRIBUTE_PRINTF(2,3);
 
 /**
  * xmlSchemaValidityWarningFunc:
@@ -102,7 +102,7 @@ typedef void (XMLCDECL *xmlSchemaValidityErrorFunc) (void *ctx, const char *msg,
  *
  * Signature of a warning callback from an XSD validation
  */
-typedef void (XMLCDECL *xmlSchemaValidityWarningFunc) (void *ctx, const char *msg, ...);
+typedef void (XMLCDECL *xmlSchemaValidityWarningFunc) (void *ctx, const char *msg, ...) ATTRIBUTE_PRINTF(2,3);
 
 /**
  * A schemas validation context
index 6c5d342..e960f09 100644 (file)
@@ -29,21 +29,21 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
  *
  * the version string like "1.2.3"
  */
-#define LIBXML_DOTTED_VERSION "2.7.2"
+#define LIBXML_DOTTED_VERSION "2.7.3"
 
 /**
  * LIBXML_VERSION:
  *
  * the version number: 1.2.3 value is 10203
  */
-#define LIBXML_VERSION 20702
+#define LIBXML_VERSION 20703
 
 /**
  * LIBXML_VERSION_STRING:
  *
  * the version number string, 1.2.3 value is "10203"
  */
-#define LIBXML_VERSION_STRING "20702"
+#define LIBXML_VERSION_STRING "20703"
 
 /**
  * LIBXML_VERSION_EXTRA:
@@ -58,7 +58,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
  * Macro to check that the libxml version in use is compatible with
  * the version the software has been compiled against
  */
-#define LIBXML_TEST_VERSION xmlCheckVersion(20702);
+#define LIBXML_TEST_VERSION xmlCheckVersion(20703);
 
 #ifndef VMS
 #if 0
@@ -382,22 +382,74 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
 #define LIBXML_ZLIB_ENABLED
 #endif
 
+#ifdef __GNUC__
+#ifdef HAVE_ANSIDECL_H
+#include <ansidecl.h>
+#endif
+
 /**
  * ATTRIBUTE_UNUSED:
  *
  * Macro used to signal to GCC unused function parameters
  */
-#ifdef __GNUC__
-#ifdef HAVE_ANSIDECL_H
-#include <ansidecl.h>
-#endif
+
 #ifndef ATTRIBUTE_UNUSED
 #define ATTRIBUTE_UNUSED __attribute__((unused))
 #endif
+
+/**
+ * ATTRIBUTE_ALLOC_SIZE:
+ *
+ * Macro used to indicate to GCC this is an allocator function
+ */
+
+#ifndef ATTRIBUTE_ALLOC_SIZE
+# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
+#  define ATTRIBUTE_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
+# else
+#  define ATTRIBUTE_ALLOC_SIZE(x)
+# endif
 #else
-#define ATTRIBUTE_UNUSED
+# define ATTRIBUTE_ALLOC_SIZE(x)
+#endif
+
+/**
+ * ATTRIBUTE_PRINTF:
+ *
+ * Macro used to indicate to GCC the parameter are printf like
+ */
+
+#ifndef ATTRIBUTE_PRINTF
+# if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
+#  define ATTRIBUTE_PRINTF(fmt,args) __attribute__((__format__(__printf__,fmt,args)))
+# else
+#  define ATTRIBUTE_PRINTF(fmt,args)
+# endif
+#else
+# define ATTRIBUTE_PRINTF(fmt,args)
 #endif
 
+#else /* ! __GNUC__ */
+/**
+ * ATTRIBUTE_UNUSED:
+ *
+ * Macro used to signal to GCC unused function parameters
+ */
+#define ATTRIBUTE_UNUSED
+/**
+ * ATTRIBUTE_ALLOC_SIZE:
+ *
+ * Macro used to indicate to GCC this is an allocator function
+ */
+#define ATTRIBUTE_ALLOC_SIZE(x)
+/**
+ * ATTRIBUTE_PRINTF:
+ *
+ * Macro used to indicate to GCC the parameter are printf like
+ */
+#define ATTRIBUTE_PRINTF(fmt,args)
+#endif /* __GNUC__ */
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 29cef74..05c9f29 100644 (file)
@@ -382,22 +382,74 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
 #define LIBXML_ZLIB_ENABLED
 #endif
 
+#ifdef __GNUC__
+#ifdef HAVE_ANSIDECL_H
+#include <ansidecl.h>
+#endif
+
 /**
  * ATTRIBUTE_UNUSED:
  *
  * Macro used to signal to GCC unused function parameters
  */
-#ifdef __GNUC__
-#ifdef HAVE_ANSIDECL_H
-#include <ansidecl.h>
-#endif
+
 #ifndef ATTRIBUTE_UNUSED
 #define ATTRIBUTE_UNUSED __attribute__((unused))
 #endif
+
+/**
+ * ATTRIBUTE_ALLOC_SIZE:
+ *
+ * Macro used to indicate to GCC this is an allocator function
+ */
+
+#ifndef ATTRIBUTE_ALLOC_SIZE
+# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
+#  define ATTRIBUTE_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
+# else
+#  define ATTRIBUTE_ALLOC_SIZE(x)
+# endif
 #else
-#define ATTRIBUTE_UNUSED
+# define ATTRIBUTE_ALLOC_SIZE(x)
+#endif
+
+/**
+ * ATTRIBUTE_PRINTF:
+ *
+ * Macro used to indicate to GCC the parameter are printf like
+ */
+
+#ifndef ATTRIBUTE_PRINTF
+# if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
+#  define ATTRIBUTE_PRINTF(fmt,args) __attribute__((__format__(__printf__,fmt,args)))
+# else
+#  define ATTRIBUTE_PRINTF(fmt,args)
+# endif
+#else
+# define ATTRIBUTE_PRINTF(fmt,args)
 #endif
 
+#else /* ! __GNUC__ */
+/**
+ * ATTRIBUTE_UNUSED:
+ *
+ * Macro used to signal to GCC unused function parameters
+ */
+#define ATTRIBUTE_UNUSED
+/**
+ * ATTRIBUTE_ALLOC_SIZE:
+ *
+ * Macro used to indicate to GCC this is an allocator function
+ */
+#define ATTRIBUTE_ALLOC_SIZE(x)
+/**
+ * ATTRIBUTE_PRINTF:
+ *
+ * Macro used to indicate to GCC the parameter are printf like
+ */
+#define ATTRIBUTE_PRINTF(fmt,args)
+#endif /* __GNUC__ */
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 31ceb5f..df4509d 100644 (file)
@@ -69,11 +69,13 @@ extern "C" {
     XMLPUBFUN int XMLCALL xmlTextWriterEndComment(xmlTextWriterPtr writer);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer,
-                                        const char *format, ...);
+                                        const char *format, ...)
+                                       ATTRIBUTE_PRINTF(2,3);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer,
                                          const char *format,
-                                         va_list argptr);
+                                         va_list argptr)
+                                        ATTRIBUTE_PRINTF(2,0);
     XMLPUBFUN int XMLCALL xmlTextWriterWriteComment(xmlTextWriterPtr
                                                     writer,
                                                     const xmlChar *
@@ -102,12 +104,14 @@ extern "C" {
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer,
                                         const xmlChar * name,
-                                        const char *format, ...);
+                                        const char *format, ...)
+                                       ATTRIBUTE_PRINTF(3,4);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer,
                                          const xmlChar * name,
                                          const char *format,
-                                         va_list argptr);
+                                         va_list argptr)
+                                        ATTRIBUTE_PRINTF(3,0);
     XMLPUBFUN int XMLCALL xmlTextWriterWriteElement(xmlTextWriterPtr
                                                     writer,
                                                     const xmlChar * name,
@@ -118,14 +122,16 @@ extern "C" {
                                           const xmlChar * prefix,
                                           const xmlChar * name,
                                           const xmlChar * namespaceURI,
-                                          const char *format, ...);
+                                          const char *format, ...)
+                                         ATTRIBUTE_PRINTF(5,6);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer,
                                            const xmlChar * prefix,
                                            const xmlChar * name,
                                            const xmlChar * namespaceURI,
                                            const char *format,
-                                           va_list argptr);
+                                           va_list argptr)
+                                          ATTRIBUTE_PRINTF(5,0);
     XMLPUBFUN int XMLCALL xmlTextWriterWriteElementNS(xmlTextWriterPtr
                                                       writer,
                                                       const xmlChar *
@@ -141,10 +147,12 @@ extern "C" {
  */
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer,
-                                    const char *format, ...);
+                                    const char *format, ...)
+                                   ATTRIBUTE_PRINTF(2,3);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer,
-                                     const char *format, va_list argptr);
+                                     const char *format, va_list argptr)
+                                    ATTRIBUTE_PRINTF(2,0);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteRawLen(xmlTextWriterPtr writer,
                                  const xmlChar * content, int len);
@@ -154,12 +162,14 @@ extern "C" {
     XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatString(xmlTextWriterPtr
                                                          writer,
                                                          const char
-                                                         *format, ...);
+                                                         *format, ...)
+                                                        ATTRIBUTE_PRINTF(2,3);
     XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatString(xmlTextWriterPtr
                                                           writer,
                                                           const char
                                                           *format,
-                                                          va_list argptr);
+                                                          va_list argptr)
+                                                         ATTRIBUTE_PRINTF(2,0);
     XMLPUBFUN int XMLCALL xmlTextWriterWriteString(xmlTextWriterPtr writer,
                                                    const xmlChar *
                                                    content);
@@ -193,12 +203,14 @@ extern "C" {
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer,
                                           const xmlChar * name,
-                                          const char *format, ...);
+                                          const char *format, ...)
+                                         ATTRIBUTE_PRINTF(3,4);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer,
                                            const xmlChar * name,
                                            const char *format,
-                                           va_list argptr);
+                                           va_list argptr)
+                                          ATTRIBUTE_PRINTF(3,0);
     XMLPUBFUN int XMLCALL xmlTextWriterWriteAttribute(xmlTextWriterPtr
                                                       writer,
                                                       const xmlChar * name,
@@ -209,14 +221,16 @@ extern "C" {
                                             const xmlChar * prefix,
                                             const xmlChar * name,
                                             const xmlChar * namespaceURI,
-                                            const char *format, ...);
+                                            const char *format, ...)
+                                           ATTRIBUTE_PRINTF(5,6);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer,
                                              const xmlChar * prefix,
                                              const xmlChar * name,
                                              const xmlChar * namespaceURI,
                                              const char *format,
-                                             va_list argptr);
+                                             va_list argptr)
+                                            ATTRIBUTE_PRINTF(5,0);
     XMLPUBFUN int XMLCALL xmlTextWriterWriteAttributeNS(xmlTextWriterPtr
                                                         writer,
                                                         const xmlChar *
@@ -242,11 +256,13 @@ extern "C" {
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer,
                                    const xmlChar * target,
-                                   const char *format, ...);
+                                   const char *format, ...)
+                                  ATTRIBUTE_PRINTF(3,4);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer,
                                     const xmlChar * target,
-                                    const char *format, va_list argptr);
+                                    const char *format, va_list argptr)
+                                   ATTRIBUTE_PRINTF(3,0);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWritePI(xmlTextWriterPtr writer,
                              const xmlChar * target,
@@ -270,10 +286,12 @@ extern "C" {
  */
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer,
-                                      const char *format, ...);
+                                      const char *format, ...)
+                                     ATTRIBUTE_PRINTF(2,3);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer,
-                                       const char *format, va_list argptr);
+                                       const char *format, va_list argptr)
+                                      ATTRIBUTE_PRINTF(2,0);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteCDATA(xmlTextWriterPtr writer,
                                 const xmlChar * content);
@@ -296,13 +314,15 @@ extern "C" {
                                     const xmlChar * name,
                                     const xmlChar * pubid,
                                     const xmlChar * sysid,
-                                    const char *format, ...);
+                                    const char *format, ...)
+                                   ATTRIBUTE_PRINTF(5,6);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer,
                                      const xmlChar * name,
                                      const xmlChar * pubid,
                                      const xmlChar * sysid,
-                                     const char *format, va_list argptr);
+                                     const char *format, va_list argptr)
+                                    ATTRIBUTE_PRINTF(5,0);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteDTD(xmlTextWriterPtr writer,
                               const xmlChar * name,
@@ -332,12 +352,14 @@ extern "C" {
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer,
                                            const xmlChar * name,
-                                           const char *format, ...);
+                                           const char *format, ...)
+                                          ATTRIBUTE_PRINTF(3,4);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer,
                                             const xmlChar * name,
                                             const char *format,
-                                            va_list argptr);
+                                            va_list argptr)
+                                           ATTRIBUTE_PRINTF(3,0);
     XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDElement(xmlTextWriterPtr
                                                        writer,
                                                        const xmlChar *
@@ -360,12 +382,14 @@ extern "C" {
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer,
                                            const xmlChar * name,
-                                           const char *format, ...);
+                                           const char *format, ...)
+                                          ATTRIBUTE_PRINTF(3,4);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer,
                                             const xmlChar * name,
                                             const char *format,
-                                            va_list argptr);
+                                            va_list argptr)
+                                           ATTRIBUTE_PRINTF(3,0);
     XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr
                                                        writer,
                                                        const xmlChar *
@@ -389,13 +413,15 @@ extern "C" {
         xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer,
                                                   int pe,
                                                   const xmlChar * name,
-                                                  const char *format, ...);
+                                                  const char *format, ...)
+                                                 ATTRIBUTE_PRINTF(4,5);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer,
                                                    int pe,
                                                    const xmlChar * name,
                                                    const char *format,
-                                                   va_list argptr);
+                                                   va_list argptr)
+                                                  ATTRIBUTE_PRINTF(4,0);
     XMLPUBFUN int XMLCALL
         xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer,
                                             int pe,
diff --git a/reactos/include/reactos/libs/libxslt/extensions.h b/reactos/include/reactos/libs/libxslt/extensions.h
new file mode 100644 (file)
index 0000000..30b7d4c
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * Summary: interface for the extension support
+ * Description: This provide the API needed for simple and module
+ *              extension support.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_EXTENSION_H__
+#define __XML_XSLT_EXTENSION_H__
+
+#include <libxml/xpath.h>
+#include "xsltexports.h"
+#include "xsltInternals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Extension Modules API.
+ */
+
+/**
+ * xsltStyleExtInitFunction:
+ * @ctxt:  an XSLT stylesheet
+ * @URI:  the namespace URI for the extension
+ *
+ * A function called at initialization time of an XSLT extension module.
+ *
+ * Returns a pointer to the module specific data for this transformation.
+ */
+typedef void * (*xsltStyleExtInitFunction)     (xsltStylesheetPtr style,
+                                                const xmlChar *URI);
+
+/**
+ * xsltStyleExtShutdownFunction:
+ * @ctxt:  an XSLT stylesheet
+ * @URI:  the namespace URI for the extension
+ * @data:  the data associated to this module
+ *
+ * A function called at shutdown time of an XSLT extension module.
+ */
+typedef void (*xsltStyleExtShutdownFunction)   (xsltStylesheetPtr style,
+                                                const xmlChar *URI,
+                                                void *data);
+
+/**
+ * xsltExtInitFunction:
+ * @ctxt:  an XSLT transformation context
+ * @URI:  the namespace URI for the extension
+ *
+ * A function called at initialization time of an XSLT extension module.
+ *
+ * Returns a pointer to the module specific data for this transformation.
+ */
+typedef void * (*xsltExtInitFunction)  (xsltTransformContextPtr ctxt,
+                                        const xmlChar *URI);
+
+/**
+ * xsltExtShutdownFunction:
+ * @ctxt:  an XSLT transformation context
+ * @URI:  the namespace URI for the extension
+ * @data:  the data associated to this module
+ *
+ * A function called at shutdown time of an XSLT extension module.
+ */
+typedef void (*xsltExtShutdownFunction) (xsltTransformContextPtr ctxt,
+                                        const xmlChar *URI,
+                                        void *data);
+
+XSLTPUBFUN int XSLTCALL
+               xsltRegisterExtModule   (const xmlChar *URI,
+                                        xsltExtInitFunction initFunc,
+                                        xsltExtShutdownFunction shutdownFunc);
+XSLTPUBFUN int XSLTCALL
+               xsltRegisterExtModuleFull
+                                       (const xmlChar * URI,
+                                        xsltExtInitFunction initFunc,
+                                        xsltExtShutdownFunction shutdownFunc,
+                                        xsltStyleExtInitFunction styleInitFunc,
+                                        xsltStyleExtShutdownFunction styleShutdownFunc);
+
+XSLTPUBFUN int XSLTCALL
+               xsltUnregisterExtModule (const xmlChar * URI);
+
+XSLTPUBFUN void * XSLTCALL             
+               xsltGetExtData          (xsltTransformContextPtr ctxt,
+                                        const xmlChar *URI);
+
+XSLTPUBFUN void * XSLTCALL             
+               xsltStyleGetExtData     (xsltStylesheetPtr style,
+                                        const xmlChar *URI);
+#ifdef XSLT_REFACTORED
+XSLTPUBFUN void * XSLTCALL
+               xsltStyleStylesheetLevelGetExtData(
+                                        xsltStylesheetPtr style,
+                                        const xmlChar * URI);
+#endif
+XSLTPUBFUN void XSLTCALL               
+               xsltShutdownCtxtExts    (xsltTransformContextPtr ctxt);
+
+XSLTPUBFUN void XSLTCALL               
+               xsltShutdownExts        (xsltStylesheetPtr style);
+
+XSLTPUBFUN xsltTransformContextPtr XSLTCALL 
+               xsltXPathGetTransformContext
+                                       (xmlXPathParserContextPtr ctxt);
+
+/*
+ * extension functions
+*/
+XSLTPUBFUN int XSLTCALL        
+               xsltRegisterExtModuleFunction   
+                                       (const xmlChar *name,
+                                        const xmlChar *URI,
+                                        xmlXPathFunction function);
+XSLTPUBFUN xmlXPathFunction XSLTCALL
+       xsltExtFunctionLookup           (xsltTransformContextPtr ctxt,
+                                        const xmlChar *name,
+                                        const xmlChar *URI);
+XSLTPUBFUN xmlXPathFunction XSLTCALL
+       xsltExtModuleFunctionLookup     (const xmlChar *name,
+                                        const xmlChar *URI);
+XSLTPUBFUN int XSLTCALL        
+               xsltUnregisterExtModuleFunction 
+                                       (const xmlChar *name,
+                                        const xmlChar *URI);
+
+/*
+ * extension elements
+ */
+typedef xsltElemPreCompPtr (*xsltPreComputeFunction)
+                                       (xsltStylesheetPtr style,
+                                        xmlNodePtr inst,
+                                        xsltTransformFunction function);
+
+XSLTPUBFUN xsltElemPreCompPtr XSLTCALL
+               xsltNewElemPreComp      (xsltStylesheetPtr style,
+                                        xmlNodePtr inst,
+                                        xsltTransformFunction function);
+XSLTPUBFUN void XSLTCALL       
+               xsltInitElemPreComp     (xsltElemPreCompPtr comp,
+                                        xsltStylesheetPtr style,
+                                        xmlNodePtr inst,
+                                        xsltTransformFunction function,
+                                        xsltElemPreCompDeallocator freeFunc);
+
+XSLTPUBFUN int XSLTCALL        
+               xsltRegisterExtModuleElement    
+                                       (const xmlChar *name,
+                                        const xmlChar *URI,
+                                        xsltPreComputeFunction precomp,
+                                        xsltTransformFunction transform);
+XSLTPUBFUN xsltTransformFunction XSLTCALL 
+               xsltExtElementLookup    (xsltTransformContextPtr ctxt,
+                                        const xmlChar *name,
+                                        const xmlChar *URI);
+XSLTPUBFUN xsltTransformFunction XSLTCALL 
+               xsltExtModuleElementLookup
+                                       (const xmlChar *name,
+                                        const xmlChar *URI);
+XSLTPUBFUN xsltPreComputeFunction XSLTCALL 
+               xsltExtModuleElementPreComputeLookup 
+                                       (const xmlChar *name,
+                                        const xmlChar *URI);
+XSLTPUBFUN int XSLTCALL        
+               xsltUnregisterExtModuleElement  
+                                       (const xmlChar *name,
+                                        const xmlChar *URI);
+
+/*
+ * top-level elements
+ */
+typedef void (*xsltTopLevelFunction)   (xsltStylesheetPtr style,
+                                        xmlNodePtr inst);
+
+XSLTPUBFUN int XSLTCALL        
+               xsltRegisterExtModuleTopLevel
+                                       (const xmlChar *name,
+                                        const xmlChar *URI,
+                                        xsltTopLevelFunction function);
+XSLTPUBFUN xsltTopLevelFunction XSLTCALL 
+               xsltExtModuleTopLevelLookup 
+                                       (const xmlChar *name,
+                                        const xmlChar *URI);
+XSLTPUBFUN int XSLTCALL        
+               xsltUnregisterExtModuleTopLevel 
+                                       (const xmlChar *name,
+                                        const xmlChar *URI);
+
+
+/* These 2 functions are deprecated for use within modules. */
+XSLTPUBFUN int XSLTCALL                
+               xsltRegisterExtFunction (xsltTransformContextPtr ctxt,
+                                        const xmlChar *name,
+                                        const xmlChar *URI,
+                                        xmlXPathFunction function);
+XSLTPUBFUN int XSLTCALL                
+               xsltRegisterExtElement  (xsltTransformContextPtr ctxt,
+                                        const xmlChar *name,
+                                        const xmlChar *URI,
+                                        xsltTransformFunction function);
+
+/*
+ * Extension Prefix handling API.
+ * Those are used by the XSLT (pre)processor.
+ */
+
+XSLTPUBFUN int XSLTCALL                
+               xsltRegisterExtPrefix   (xsltStylesheetPtr style,
+                                        const xmlChar *prefix,
+                                        const xmlChar *URI);
+XSLTPUBFUN int XSLTCALL                
+               xsltCheckExtPrefix      (xsltStylesheetPtr style,
+                                        const xmlChar *URI);
+XSLTPUBFUN int XSLTCALL
+               xsltCheckExtURI         (xsltStylesheetPtr style,
+                                        const xmlChar *URI);
+XSLTPUBFUN int XSLTCALL                
+               xsltInitCtxtExts        (xsltTransformContextPtr ctxt);
+XSLTPUBFUN void XSLTCALL               
+               xsltFreeCtxtExts        (xsltTransformContextPtr ctxt);
+XSLTPUBFUN void XSLTCALL               
+               xsltFreeExts            (xsltStylesheetPtr style);
+
+XSLTPUBFUN xsltElemPreCompPtr XSLTCALL 
+               xsltPreComputeExtModuleElement
+                                       (xsltStylesheetPtr style,
+                                        xmlNodePtr inst);
+/*
+ * Extension Infos access.
+ * Used by exslt initialisation
+ */
+
+XSLTPUBFUN xmlHashTablePtr XSLTCALL 
+               xsltGetExtInfo          (xsltStylesheetPtr style, 
+                                        const xmlChar *URI);
+
+/**
+ * Test module http://xmlsoft.org/XSLT/
+ */
+XSLTPUBFUN void XSLTCALL       
+               xsltRegisterTestModule  (void);
+XSLTPUBFUN void XSLTCALL       
+               xsltDebugDumpExtensions (FILE * output);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_EXTENSION_H__ */
+
diff --git a/reactos/include/reactos/libs/libxslt/libxslt.h b/reactos/include/reactos/libs/libxslt/libxslt.h
new file mode 100644 (file)
index 0000000..903f900
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Summary: internal header only used during the compilation of libxslt
+ * Description: internal header only used during the compilation of libxslt
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XSLT_LIBXSLT_H__
+#define __XSLT_LIBXSLT_H__
+
+#if defined(WIN32) && !defined (__CYGWIN__) && !defined (__MINGW32__)
+#include <win32config.h>
+#else
+#include "config.h"
+#endif
+
+#include "xsltconfig.h"
+#include <libxml/xmlversion.h>
+
+#if !defined LIBXSLT_PUBLIC
+#if (defined (__CYGWIN__) || defined _MSC_VER) && !defined IN_LIBXSLT && !defined LIBXSLT_STATIC
+#define LIBXSLT_PUBLIC __declspec(dllimport)
+#else
+#define LIBXSLT_PUBLIC 
+#endif
+#endif
+
+#endif /* ! __XSLT_LIBXSLT_H__ */
diff --git a/reactos/include/reactos/libs/libxslt/numbersInternals.h b/reactos/include/reactos/libs/libxslt/numbersInternals.h
new file mode 100644 (file)
index 0000000..7b3cb17
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Summary: Implementation of the XSLT number functions
+ * Description: Implementation of the XSLT number functions
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Bjorn Reese <breese@users.sourceforge.net> and Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_NUMBERSINTERNALS_H__
+#define __XML_XSLT_NUMBERSINTERNALS_H__
+
+#include <libxml/tree.h>
+#include "xsltexports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * xsltNumberData:
+ *
+ * This data structure is just a wrapper to pass xsl:number data in.
+ */
+typedef struct _xsltNumberData xsltNumberData;
+typedef xsltNumberData *xsltNumberDataPtr;
+    
+struct _xsltNumberData {
+    const xmlChar *level;
+    const xmlChar *count;
+    const xmlChar *from;
+    const xmlChar *value;
+    const xmlChar *format;
+    int has_format;
+    int digitsPerGroup;
+    int groupingCharacter;
+    int groupingCharacterLen;
+    xmlDocPtr doc;
+    xmlNodePtr node;
+
+    /*
+     * accelerators
+     */
+};
+
+/**
+ * xsltFormatNumberInfo,:
+ *
+ * This data structure lists the various parameters needed to format numbers.
+ */
+typedef struct _xsltFormatNumberInfo xsltFormatNumberInfo;
+typedef xsltFormatNumberInfo *xsltFormatNumberInfoPtr;
+
+struct _xsltFormatNumberInfo {
+    int            integer_hash;       /* Number of '#' in integer part */
+    int            integer_digits;     /* Number of '0' in integer part */
+    int            frac_digits;        /* Number of '0' in fractional part */
+    int            frac_hash;          /* Number of '#' in fractional part */
+    int            group;              /* Number of chars per display 'group' */
+    int     multiplier;                /* Scaling for percent or permille */
+    char    add_decimal;       /* Flag for whether decimal point appears in pattern */
+    char    is_multiplier_set; /* Flag to catch multiple occurences of percent/permille */
+    char    is_negative_pattern;/* Flag for processing -ve prefix/suffix */
+};
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __XML_XSLT_NUMBERSINTERNALS_H__ */
diff --git a/reactos/include/reactos/libs/libxslt/pattern.h b/reactos/include/reactos/libs/libxslt/pattern.h
new file mode 100644 (file)
index 0000000..eb21be3
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Summary: interface for the pattern matching used in template matches.
+ * Description: the implementation of the lookup of the right template
+ *              for a given node must be really fast in order to keep
+ *              decent performances.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_PATTERN_H__
+#define __XML_XSLT_PATTERN_H__
+
+#include "xsltInternals.h"
+#include "xsltexports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * xsltCompMatch:
+ *
+ * Data structure used for the implementation of patterns.
+ * It is kept private (in pattern.c).
+ */
+typedef struct _xsltCompMatch xsltCompMatch;
+typedef xsltCompMatch *xsltCompMatchPtr;
+
+/*
+ * Pattern related interfaces.
+ */
+
+XSLTPUBFUN xsltCompMatchPtr XSLTCALL
+               xsltCompilePattern      (const xmlChar *pattern,
+                                        xmlDocPtr doc,
+                                        xmlNodePtr node,
+                                        xsltStylesheetPtr style,
+                                        xsltTransformContextPtr runtime);
+XSLTPUBFUN void XSLTCALL
+               xsltFreeCompMatchList   (xsltCompMatchPtr comp);
+XSLTPUBFUN int XSLTCALL
+               xsltTestCompMatchList   (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xsltCompMatchPtr comp);
+XSLTPUBFUN void XSLTCALL
+               xsltNormalizeCompSteps  (void *payload,
+                                        void *data,
+                                        const xmlChar *name);
+
+/*
+ * Template related interfaces.
+ */
+XSLTPUBFUN int XSLTCALL
+               xsltAddTemplate         (xsltStylesheetPtr style,
+                                        xsltTemplatePtr cur,
+                                        const xmlChar *mode,
+                                        const xmlChar *modeURI);
+XSLTPUBFUN xsltTemplatePtr XSLTCALL
+               xsltGetTemplate         (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xsltStylesheetPtr style);
+XSLTPUBFUN void XSLTCALL
+               xsltFreeTemplateHashes  (xsltStylesheetPtr style);
+XSLTPUBFUN void XSLTCALL
+               xsltCleanupTemplates    (xsltStylesheetPtr style);
+
+#if 0
+int            xsltMatchPattern        (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        const xmlChar *pattern,
+                                        xmlDocPtr ctxtdoc,
+                                        xmlNodePtr ctxtnode);
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_PATTERN_H__ */
+
diff --git a/reactos/include/reactos/libs/libxslt/transform.h b/reactos/include/reactos/libs/libxslt/transform.h
new file mode 100644 (file)
index 0000000..105ac2d
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ * Summary: the XSLT engine transformation part.
+ * Description: This module implements the bulk of the actual
+ *              transformation processing. Most of the xsl: element
+ *              constructs are implemented in this module.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_TRANSFORM_H__
+#define __XML_XSLT_TRANSFORM_H__
+
+#include <libxml/parser.h>
+#include <libxml/xmlIO.h>
+#include "xsltexports.h"
+#include <libxslt/xsltInternals.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * XInclude default processing.
+ */
+XSLTPUBFUN void XSLTCALL               
+               xsltSetXIncludeDefault  (int xinclude);
+XSLTPUBFUN int XSLTCALL                
+               xsltGetXIncludeDefault  (void);
+
+/**
+ * Export context to users.
+ */
+XSLTPUBFUN xsltTransformContextPtr XSLTCALL 
+               xsltNewTransformContext (xsltStylesheetPtr style,
+                                        xmlDocPtr doc);
+
+XSLTPUBFUN void XSLTCALL                       
+               xsltFreeTransformContext(xsltTransformContextPtr ctxt);
+
+XSLTPUBFUN xmlDocPtr XSLTCALL          
+               xsltApplyStylesheetUser (xsltStylesheetPtr style,
+                                        xmlDocPtr doc,
+                                        const char **params,
+                                        const char *output,
+                                        FILE * profile,
+                                        xsltTransformContextPtr userCtxt);
+/**
+ * Private Interfaces.
+ */
+XSLTPUBFUN void XSLTCALL               
+               xsltApplyStripSpaces    (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node);
+XSLTPUBFUN xmlDocPtr XSLTCALL  
+               xsltApplyStylesheet     (xsltStylesheetPtr style,
+                                        xmlDocPtr doc,
+                                        const char **params);
+XSLTPUBFUN xmlDocPtr XSLTCALL  
+               xsltProfileStylesheet   (xsltStylesheetPtr style,
+                                        xmlDocPtr doc,
+                                        const char **params,
+                                        FILE * output);
+XSLTPUBFUN int XSLTCALL                
+               xsltRunStylesheet       (xsltStylesheetPtr style,
+                                        xmlDocPtr doc,
+                                        const char **params,
+                                        const char *output,
+                                        xmlSAXHandlerPtr SAX,
+                                        xmlOutputBufferPtr IObuf);
+XSLTPUBFUN int XSLTCALL                
+               xsltRunStylesheetUser   (xsltStylesheetPtr style,
+                                        xmlDocPtr doc,
+                                        const char **params,
+                                        const char *output,
+                                        xmlSAXHandlerPtr SAX,
+                                        xmlOutputBufferPtr IObuf,
+                                        FILE * profile,
+                                        xsltTransformContextPtr userCtxt);
+XSLTPUBFUN void XSLTCALL               
+               xsltApplyOneTemplate    (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr list,
+                                        xsltTemplatePtr templ,
+                                        xsltStackElemPtr params);
+XSLTPUBFUN void XSLTCALL               
+               xsltDocumentElem        (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltSort                (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltCopy                (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltText                (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltElement             (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltComment             (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltAttribute           (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltProcessingInstruction(xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltCopyOf              (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltValueOf             (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltNumber              (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltApplyImports        (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltCallTemplate        (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltApplyTemplates      (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltChoose              (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltIf                  (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltForEach             (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr node,
+                                        xmlNodePtr inst,
+                                        xsltStylePreCompPtr comp);
+XSLTPUBFUN void XSLTCALL               
+               xsltRegisterAllElement  (xsltTransformContextPtr ctxt);
+
+XSLTPUBFUN xmlNodePtr XSLTCALL 
+               xsltCopyTextString      (xsltTransformContextPtr ctxt,
+                                        xmlNodePtr target,
+                                        const xmlChar *string,
+                                        int noescape);
+
+/* Following 2 functions needed for libexslt/functions.c */
+XSLTPUBFUN void XSLTCALL
+               xsltLocalVariablePop    (xsltTransformContextPtr ctxt,
+                                        int limitNr,
+                                        int level);
+XSLTPUBFUN int XSLTCALL
+               xsltLocalVariablePush   (xsltTransformContextPtr ctxt,
+                                        xsltStackElemPtr variable,
+                                        int level);
+/*
+ * Hook for the debugger if activated.
+ */
+XSLTPUBFUN void XSLTCALL               
+               xslHandleDebugger       (xmlNodePtr cur,
+                                        xmlNodePtr node,
+                                        xsltTemplatePtr templ,
+                                        xsltTransformContextPtr ctxt);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_TRANSFORM_H__ */
+
diff --git a/reactos/include/reactos/libs/libxslt/xslt.h b/reactos/include/reactos/libs/libxslt/xslt.h
new file mode 100644 (file)
index 0000000..849b03c
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Summary: Interfaces, constants and types related to the XSLT engine
+ * Description: Interfaces, constants and types related to the XSLT engine
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_H__
+#define __XML_XSLT_H__
+
+#include <libxml/tree.h>
+#include "xsltexports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * XSLT_DEFAULT_VERSION:
+ *
+ * The default version of XSLT supported.
+ */
+#define XSLT_DEFAULT_VERSION     "1.0"
+
+/**
+ * XSLT_DEFAULT_VENDOR:
+ *
+ * The XSLT "vendor" string for this processor.
+ */
+#define XSLT_DEFAULT_VENDOR      "libxslt"
+
+/**
+ * XSLT_DEFAULT_URL:
+ *
+ * The XSLT "vendor" URL for this processor.
+ */
+#define XSLT_DEFAULT_URL         "http://xmlsoft.org/XSLT/"
+
+/**
+ * XSLT_NAMESPACE:
+ *
+ * The XSLT specification namespace.
+ */
+#define XSLT_NAMESPACE ((xmlChar *) "http://www.w3.org/1999/XSL/Transform")
+
+/**
+ * XSLT_PARSE_OPTIONS:
+ *
+ * The set of options to pass to an xmlReadxxx when loading files for
+ * XSLT consumption.
+ */
+#define XSLT_PARSE_OPTIONS \
+ XML_PARSE_NOENT | XML_PARSE_DTDLOAD | XML_PARSE_DTDATTR | XML_PARSE_NOCDATA
+
+/**
+ * xsltMaxDepth:
+ *
+ * This value is used to detect templates loops.
+ */
+XSLTPUBVAR int xsltMaxDepth;
+
+/**
+ * xsltEngineVersion:
+ *
+ * The version string for libxslt.
+ */
+XSLTPUBVAR const char *xsltEngineVersion;
+
+/**
+ * xsltLibxsltVersion:
+ *
+ * The version of libxslt compiled.
+ */
+XSLTPUBVAR const int xsltLibxsltVersion;
+
+/**
+ * xsltLibxmlVersion:
+ *
+ * The version of libxml libxslt was compiled against.
+ */
+XSLTPUBVAR const int xsltLibxmlVersion;
+
+/*
+ * Global initialization function.
+ */
+
+XSLTPUBFUN void XSLTCALL
+               xsltInit                (void);
+
+/*
+ * Global cleanup function.
+ */
+XSLTPUBFUN void XSLTCALL       
+               xsltCleanupGlobals      (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_H__ */
+
diff --git a/reactos/include/reactos/libs/libxslt/xsltInternals.h b/reactos/include/reactos/libs/libxslt/xsltInternals.h
new file mode 100644 (file)
index 0000000..f176264
--- /dev/null
@@ -0,0 +1,1970 @@
+/*
+ * Summary: internal data structures, constants and functions
+ * Description: Internal data structures, constants and functions used
+ *              by the XSLT engine. 
+ *              They are not part of the API or ABI, i.e. they can change
+ *              without prior notice, use carefully.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLT_INTERNALS_H__
+#define __XML_XSLT_INTERNALS_H__
+
+#include <libxml/tree.h>
+#include <libxml/hash.h>
+#include <libxml/xpath.h>
+#include <libxml/xmlerror.h>
+#include <libxml/dict.h>
+#include <libxml/xmlstring.h>
+#include <libxslt/xslt.h>
+#include "xsltexports.h"
+#include "numbersInternals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* #define XSLT_DEBUG_PROFILE_CACHE */
+
+/**
+ * XSLT_IS_TEXT_NODE:
+ *
+ * check if the argument is a text node
+ */
+#define XSLT_IS_TEXT_NODE(n) ((n != NULL) && \
+    (((n)->type == XML_TEXT_NODE) || \
+     ((n)->type == XML_CDATA_SECTION_NODE)))
+
+
+/**
+ * XSLT_MARK_RES_TREE_FRAG:
+ *
+ * internal macro to set up tree fragments
+ */
+#define XSLT_MARK_RES_TREE_FRAG(n) \
+    (n)->name = (char *) xmlStrdup(BAD_CAST " fake node libxslt");
+
+/**
+ * XSLT_IS_RES_TREE_FRAG:
+ *
+ * internal macro to test tree fragments
+ */
+#define XSLT_IS_RES_TREE_FRAG(n) \
+    ((n != NULL) && ((n)->type == XML_DOCUMENT_NODE) && \
+     ((n)->name != NULL) && ((n)->name[0] == ' '))
+
+/**
+ * XSLT_REFACTORED_KEYCOMP:
+ *
+ * Internal define to enable on-demand xsl:key computation.
+ * That's the only mode now but the define is kept for compatibility
+ */
+#define XSLT_REFACTORED_KEYCOMP
+
+/**
+ * XSLT_FAST_IF:
+ *
+ * Internal define to enable usage of xmlXPathCompiledEvalToBoolean()
+ * for XSLT "tests"; e.g. in <xsl:if test="/foo/bar">
+ */
+#define XSLT_FAST_IF
+
+/**
+ * XSLT_REFACTORED:
+ *
+ * Internal define to enable the refactored parts of Libxslt.
+ */
+/* #define XSLT_REFACTORED */
+/* ==================================================================== */
+
+/**
+ * XSLT_REFACTORED_VARS:
+ *
+ * Internal define to enable the refactored variable part of libxslt
+ */
+#define XSLT_REFACTORED_VARS
+
+#ifdef XSLT_REFACTORED
+
+extern const xmlChar *xsltXSLTAttrMarker;
+
+
+/* TODO: REMOVE: #define XSLT_REFACTORED_EXCLRESNS */
+
+/* TODO: REMOVE: #define XSLT_REFACTORED_NSALIAS */
+
+/**
+ * XSLT_REFACTORED_XSLT_NSCOMP
+ *
+ * Internal define to enable the pointer-comparison of
+ * namespaces of XSLT elements. 
+ */
+/* #define XSLT_REFACTORED_XSLT_NSCOMP */
+
+/**
+ * XSLT_REFACTORED_XPATHCOMP:
+ *
+ * Internal define to enable the optimization of the
+ * compilation of XPath expressions.
+ */
+#define XSLT_REFACTORED_XPATHCOMP
+
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+
+extern const xmlChar *xsltConstNamespaceNameXSLT;
+
+/**
+ * IS_XSLT_ELEM_FAST:
+ *
+ * quick test to detect XSLT elements
+ */
+#define IS_XSLT_ELEM_FAST(n) \
+    (((n) != NULL) && ((n)->ns != NULL) && \
+    ((n)->ns->href == xsltConstNamespaceNameXSLT))
+
+/**
+ * IS_XSLT_ATTR_FAST:
+ *
+ * quick test to detect XSLT attributes
+ */
+#define IS_XSLT_ATTR_FAST(a) \
+    (((a) != NULL) && ((a)->ns != NULL) && \
+    ((a)->ns->href == xsltConstNamespaceNameXSLT))
+
+/**
+ * XSLT_HAS_INTERNAL_NSMAP:
+ *
+ * check for namespace mapping
+ */
+#define XSLT_HAS_INTERNAL_NSMAP(s) \
+    (((s) != NULL) && ((s)->principal) && \
+     ((s)->principal->principalData) && \
+     ((s)->principal->principalData->nsMap))
+
+/**
+ * XSLT_GET_INTERNAL_NSMAP:
+ *
+ * get pointer to namespace map
+ */
+#define XSLT_GET_INTERNAL_NSMAP(s) ((s)->principal->principalData->nsMap)
+
+#else /* XSLT_REFACTORED_XSLT_NSCOMP */
+
+/**
+ * IS_XSLT_ELEM_FAST:
+ *
+ * quick check whether this is an xslt element
+ */
+#define IS_XSLT_ELEM_FAST(n) \
+    (((n) != NULL) && ((n)->ns != NULL) && \
+     (xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))
+
+/**
+ * IS_XSLT_ATTR_FAST:
+ *
+ * quick check for xslt namespace attribute
+ */
+#define IS_XSLT_ATTR_FAST(a) \
+    (((a) != NULL) && ((a)->ns != NULL) && \
+     (xmlStrEqual((a)->ns->href, XSLT_NAMESPACE)))
+
+
+#endif /* XSLT_REFACTORED_XSLT_NSCOMP */
+
+
+/**
+ * XSLT_REFACTORED_MANDATORY_VERSION:
+ *
+ * TODO: Currently disabled to surpress regression test failures, since
+ *  the old behaviour was that a missing version attribute
+ *  produced a only a warning and not an error, which was incerrect.
+ *  So the regression tests need to be fixed if this is enabled.
+ */
+/* #define XSLT_REFACTORED_MANDATORY_VERSION */
+
+/**
+ * xsltPointerList:
+ *
+ * Pointer-list for various purposes.
+ */
+typedef struct _xsltPointerList xsltPointerList;
+typedef xsltPointerList *xsltPointerListPtr;
+struct _xsltPointerList {
+    void **items;
+    int number;
+    int size;
+};
+
+#endif
+
+/**
+ * XSLT_REFACTORED_PARSING:
+ *
+ * Internal define to enable the refactored parts of Libxslt
+ * related to parsing.
+ */
+/* #define XSLT_REFACTORED_PARSING */
+
+/**
+ * XSLT_MAX_SORT:
+ *
+ * Max number of specified xsl:sort on an element.
+ */
+#define XSLT_MAX_SORT 15
+
+/**
+ * XSLT_PAT_NO_PRIORITY:
+ *
+ * Specific value for pattern without priority expressed.
+ */
+#define XSLT_PAT_NO_PRIORITY -12345789
+
+/**
+ * xsltRuntimeExtra:
+ *
+ * Extra information added to the transformation context.
+ */
+typedef struct _xsltRuntimeExtra xsltRuntimeExtra;
+typedef xsltRuntimeExtra *xsltRuntimeExtraPtr;
+struct _xsltRuntimeExtra {
+    void       *info;          /* pointer to the extra data */
+    xmlFreeFunc deallocate;    /* pointer to the deallocation routine */
+    union {                    /* dual-purpose field */
+        void   *ptr;           /* data not needing deallocation */
+       int    ival;            /* integer value storage */
+    } val;
+};
+
+/**
+ * XSLT_RUNTIME_EXTRA_LST:
+ * @ctxt: the transformation context
+ * @nr: the index
+ *
+ * Macro used to access extra information stored in the context
+ */
+#define XSLT_RUNTIME_EXTRA_LST(ctxt, nr) (ctxt)->extras[(nr)].info
+/**
+ * XSLT_RUNTIME_EXTRA_FREE:
+ * @ctxt: the transformation context
+ * @nr: the index
+ *
+ * Macro used to free extra information stored in the context
+ */
+#define XSLT_RUNTIME_EXTRA_FREE(ctxt, nr) (ctxt)->extras[(nr)].deallocate
+/**
+ * XSLT_RUNTIME_EXTRA:
+ * @ctxt: the transformation context
+ * @nr: the index
+ *
+ * Macro used to define extra information stored in the context
+ */
+#define        XSLT_RUNTIME_EXTRA(ctxt, nr, typ) (ctxt)->extras[(nr)].val.typ
+
+/**
+ * xsltTemplate:
+ *
+ * The in-memory structure corresponding to an XSLT Template.
+ */
+typedef struct _xsltTemplate xsltTemplate;
+typedef xsltTemplate *xsltTemplatePtr;
+struct _xsltTemplate {
+    struct _xsltTemplate *next;/* chained list sorted by priority */
+    struct _xsltStylesheet *style;/* the containing stylesheet */
+    xmlChar *match;    /* the matching string */
+    float priority;    /* as given from the stylesheet, not computed */
+    const xmlChar *name; /* the local part of the name QName */
+    const xmlChar *nameURI; /* the URI part of the name QName */
+    const xmlChar *mode;/* the local part of the mode QName */
+    const xmlChar *modeURI;/* the URI part of the mode QName */
+    xmlNodePtr content;        /* the template replacement value */
+    xmlNodePtr elem;   /* the source element */
+
+    /*
+    * TODO: @inheritedNsNr and @inheritedNs won't be used in the
+    *  refactored code.
+    */
+    int inheritedNsNr;  /* number of inherited namespaces */
+    xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */
+
+    /* Profiling informations */
+    int nbCalls;        /* the number of time the template was called */
+    unsigned long time; /* the time spent in this template */
+    void *params;       /* xsl:param instructions */
+};
+
+/**
+ * xsltDecimalFormat:
+ *
+ * Data structure of decimal-format.
+ */
+typedef struct _xsltDecimalFormat xsltDecimalFormat;
+typedef xsltDecimalFormat *xsltDecimalFormatPtr;
+struct _xsltDecimalFormat {
+    struct _xsltDecimalFormat *next; /* chained list */
+    xmlChar *name;
+    /* Used for interpretation of pattern */
+    xmlChar *digit;
+    xmlChar *patternSeparator;
+    /* May appear in result */
+    xmlChar *minusSign;
+    xmlChar *infinity;
+    xmlChar *noNumber; /* Not-a-number */
+    /* Used for interpretation of pattern and may appear in result */
+    xmlChar *decimalPoint;
+    xmlChar *grouping;
+    xmlChar *percent;
+    xmlChar *permille;
+    xmlChar *zeroDigit;
+};
+
+/**
+ * xsltDocument:
+ *
+ * Data structure associated to a parsed document.
+ */
+typedef struct _xsltDocument xsltDocument;
+typedef xsltDocument *xsltDocumentPtr;
+struct _xsltDocument {
+    struct _xsltDocument *next;        /* documents are kept in a chained list */
+    int main;                  /* is this the main document */
+    xmlDocPtr doc;             /* the parsed document */
+    void *keys;                        /* key tables storage */
+    struct _xsltDocument *includes; /* subsidiary includes */
+    int preproc;               /* pre-processing already done */
+    int nbKeysComputed;
+};
+
+/**
+ * xsltKeyDef:
+ *
+ * Representation of an xsl:key.
+ */
+typedef struct _xsltKeyDef xsltKeyDef;
+typedef xsltKeyDef *xsltKeyDefPtr;
+struct _xsltKeyDef {
+    struct _xsltKeyDef *next;
+    xmlNodePtr inst;
+    xmlChar *name;
+    xmlChar *nameURI;
+    xmlChar *match;
+    xmlChar *use;
+    xmlXPathCompExprPtr comp;
+    xmlXPathCompExprPtr usecomp;
+    xmlNsPtr *nsList;           /* the namespaces in scope */
+    int nsNr;                   /* the number of namespaces in scope */
+};
+
+/**
+ * xsltKeyTable:
+ *
+ * Holds the computed keys for key definitions of the same QName.
+ * Is owned by an xsltDocument.
+ */
+typedef struct _xsltKeyTable xsltKeyTable;
+typedef xsltKeyTable *xsltKeyTablePtr;
+struct _xsltKeyTable {
+    struct _xsltKeyTable *next;
+    xmlChar *name;
+    xmlChar *nameURI;
+    xmlHashTablePtr keys;
+};
+
+/*
+ * The in-memory structure corresponding to an XSLT Stylesheet.
+ * NOTE: most of the content is simply linked from the doc tree
+ *       structure, no specific allocation is made.
+ */
+typedef struct _xsltStylesheet xsltStylesheet;
+typedef xsltStylesheet *xsltStylesheetPtr;
+
+typedef struct _xsltTransformContext xsltTransformContext;
+typedef xsltTransformContext *xsltTransformContextPtr;
+
+/**
+ * xsltElemPreComp:
+ *
+ * The in-memory structure corresponding to element precomputed data,
+ * designed to be extended by extension implementors.
+ */
+typedef struct _xsltElemPreComp xsltElemPreComp;
+typedef xsltElemPreComp *xsltElemPreCompPtr;
+
+/**
+ * xsltTransformFunction:
+ * @ctxt: the XSLT transformation context
+ * @node: the input node
+ * @inst: the stylesheet node
+ * @comp: the compiled information from the stylesheet
+ *
+ * Signature of the function associated to elements part of the
+ * stylesheet language like xsl:if or xsl:apply-templates.
+ */
+typedef void (*xsltTransformFunction) (xsltTransformContextPtr ctxt,
+                                      xmlNodePtr node,
+                                      xmlNodePtr inst,
+                                      xsltElemPreCompPtr comp);
+
+/**
+ * xsltSortFunc:
+ * @ctxt:    a transformation context
+ * @sorts:   the node-set to sort
+ * @nbsorts: the number of sorts
+ *
+ * Signature of the function to use during sorting
+ */
+typedef void (*xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
+                             int nbsorts);
+
+typedef enum {
+    XSLT_FUNC_COPY=1,
+    XSLT_FUNC_SORT,
+    XSLT_FUNC_TEXT,
+    XSLT_FUNC_ELEMENT,
+    XSLT_FUNC_ATTRIBUTE,
+    XSLT_FUNC_COMMENT,
+    XSLT_FUNC_PI,
+    XSLT_FUNC_COPYOF,
+    XSLT_FUNC_VALUEOF,
+    XSLT_FUNC_NUMBER,
+    XSLT_FUNC_APPLYIMPORTS,
+    XSLT_FUNC_CALLTEMPLATE,
+    XSLT_FUNC_APPLYTEMPLATES,
+    XSLT_FUNC_CHOOSE,
+    XSLT_FUNC_IF,
+    XSLT_FUNC_FOREACH,
+    XSLT_FUNC_DOCUMENT,
+    XSLT_FUNC_WITHPARAM,
+    XSLT_FUNC_PARAM,
+    XSLT_FUNC_VARIABLE,
+    XSLT_FUNC_WHEN,
+    XSLT_FUNC_EXTENSION
+#ifdef XSLT_REFACTORED
+    ,
+    XSLT_FUNC_OTHERWISE,
+    XSLT_FUNC_FALLBACK,
+    XSLT_FUNC_MESSAGE,
+    XSLT_FUNC_INCLUDE,
+    XSLT_FUNC_ATTRSET,
+    XSLT_FUNC_LITERAL_RESULT_ELEMENT,
+    XSLT_FUNC_UNKOWN_FORWARDS_COMPAT
+#endif
+} xsltStyleType;
+
+/**
+ * xsltElemPreCompDeallocator:
+ * @comp:  the #xsltElemPreComp to free up
+ *
+ * Deallocates an #xsltElemPreComp structure.
+ */
+typedef void (*xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp);
+
+/**
+ * xsltElemPreComp:
+ *
+ * The basic structure for compiled items of the AST of the XSLT processor.
+ * This structure is also intended to be extended by extension implementors.
+ * TODO: This is somehow not nice, since it has a "free" field, which
+ *   derived stylesheet-structs do not have.
+ */
+struct _xsltElemPreComp {
+    xsltElemPreCompPtr next;           /* next item in the global chained
+                                          list hold by xsltStylesheet. */
+    xsltStyleType type;                /* type of the element */
+    xsltTransformFunction func;        /* handling function */
+    xmlNodePtr inst;                   /* the node in the stylesheet's tree
+                                          corresponding to this item */
+
+    /* end of common part */
+    xsltElemPreCompDeallocator free;   /* the deallocator */
+};
+
+/**
+ * xsltStylePreComp:
+ *
+ * The abstract basic structure for items of the XSLT processor.
+ * This includes:
+ * 1) compiled forms of XSLT instructions (xsl:if, xsl:attribute, etc.)
+ * 2) compiled forms of literal result elements
+ * 3) compiled forms of extension elements
+ */
+typedef struct _xsltStylePreComp xsltStylePreComp;
+typedef xsltStylePreComp *xsltStylePreCompPtr;
+
+#ifdef XSLT_REFACTORED
+
+/*
+* Some pointer-list utility functions.
+*/
+XSLTPUBFUN xsltPointerListPtr XSLTCALL
+               xsltPointerListCreate           (int initialSize);
+XSLTPUBFUN void XSLTCALL
+               xsltPointerListFree             (xsltPointerListPtr list);
+XSLTPUBFUN void XSLTCALL
+               xsltPointerListClear            (xsltPointerListPtr list);
+XSLTPUBFUN int XSLTCALL
+               xsltPointerListAddSize          (xsltPointerListPtr list,                                                
+                                                void *item,
+                                                int initialSize);
+
+/************************************************************************
+ *                                                                     *
+ * Refactored structures                                                *
+ *                                                                     *
+ ************************************************************************/
+
+typedef struct _xsltNsListContainer xsltNsListContainer;
+typedef xsltNsListContainer *xsltNsListContainerPtr;
+struct _xsltNsListContainer {
+    xmlNsPtr *list;
+    int totalNumber;
+    int xpathNumber;    
+};
+
+/**
+ * XSLT_ITEM_COMPATIBILITY_FIELDS:
+ * 
+ * Fields for API compatibility to the structure
+ * _xsltElemPreComp which is used for extension functions.
+ * Note that @next is used for storage; it does not reflect a next
+ * sibling in the tree.
+ * TODO: Evaluate if we really need such a compatibility.
+ */
+#define XSLT_ITEM_COMPATIBILITY_FIELDS \
+    xsltElemPreCompPtr next;\
+    xsltStyleType type;\
+    xsltTransformFunction func;\
+    xmlNodePtr inst;
+
+/**
+ * XSLT_ITEM_NAVIGATION_FIELDS:
+ *
+ * Currently empty.
+ * TODO: It is intended to hold navigational fields in the future.
+ */
+#define XSLT_ITEM_NAVIGATION_FIELDS
+/*
+    xsltStylePreCompPtr parent;\
+    xsltStylePreCompPtr children;\
+    xsltStylePreCompPtr nextItem; 
+*/
+
+/**
+ * XSLT_ITEM_NSINSCOPE_FIELDS:
+ *
+ * The in-scope namespaces.
+ */
+#define XSLT_ITEM_NSINSCOPE_FIELDS xsltNsListContainerPtr inScopeNs;
+
+/**
+ * XSLT_ITEM_COMMON_FIELDS:
+ *
+ * Common fields used for all items.
+ */
+#define XSLT_ITEM_COMMON_FIELDS \
+    XSLT_ITEM_COMPATIBILITY_FIELDS \
+    XSLT_ITEM_NAVIGATION_FIELDS \
+    XSLT_ITEM_NSINSCOPE_FIELDS
+
+/**
+ * _xsltStylePreComp: 
+ *
+ * The abstract basic structure for items of the XSLT processor.
+ * This includes:
+ * 1) compiled forms of XSLT instructions (e.g. xsl:if, xsl:attribute, etc.)
+ * 2) compiled forms of literal result elements
+ * 3) various properties for XSLT instructions (e.g. xsl:when,
+ *    xsl:with-param)
+ *
+ * REVISIT TODO: Keep this structure equal to the fields
+ *   defined by XSLT_ITEM_COMMON_FIELDS
+ */
+struct _xsltStylePreComp {
+    xsltElemPreCompPtr next;    /* next item in the global chained
+                                  list hold by xsltStylesheet */
+    xsltStyleType type;         /* type of the item */ 
+    xsltTransformFunction func; /* handling function */
+    xmlNodePtr inst;           /* the node in the stylesheet's tree
+                                  corresponding to this item. */
+    /* Currently no navigational fields. */
+    xsltNsListContainerPtr inScopeNs;
+};
+
+/**
+ * xsltStyleBasicEmptyItem:
+ * 
+ * Abstract structure only used as a short-cut for
+ * XSLT items with no extra fields.
+ * NOTE that it is intended that this structure looks the same as
+ *  _xsltStylePreComp.
+ */
+typedef struct _xsltStyleBasicEmptyItem xsltStyleBasicEmptyItem;
+typedef xsltStyleBasicEmptyItem *xsltStyleBasicEmptyItemPtr;
+
+struct _xsltStyleBasicEmptyItem {
+    XSLT_ITEM_COMMON_FIELDS
+};
+
+/**
+ * xsltStyleBasicExpressionItem:
+ * 
+ * Abstract structure only used as a short-cut for
+ * XSLT items with just an expression.
+ */
+typedef struct _xsltStyleBasicExpressionItem xsltStyleBasicExpressionItem;
+typedef xsltStyleBasicExpressionItem *xsltStyleBasicExpressionItemPtr;
+
+struct _xsltStyleBasicExpressionItem {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *select; /* TODO: Change this to "expression". */
+    xmlXPathCompExprPtr comp; /* TODO: Change this to compExpr. */
+};
+
+/************************************************************************
+ *                                                                     *
+ * XSLT-instructions/declarations                                       *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltStyleItemElement:
+ * 
+ * <!-- Category: instruction -->
+ * <xsl:element
+ *  name = { qname }
+ *  namespace = { uri-reference }
+ *  use-attribute-sets = qnames>
+ *  <!-- Content: template -->
+ * </xsl:element>
+ */
+typedef struct _xsltStyleItemElement xsltStyleItemElement;
+typedef xsltStyleItemElement *xsltStyleItemElementPtr;
+
+struct _xsltStyleItemElement {
+    XSLT_ITEM_COMMON_FIELDS 
+
+    const xmlChar *use;
+    int      has_use;
+    const xmlChar *name;    
+    int      has_name;
+    const xmlChar *ns;
+    const xmlChar *nsPrefix;
+    int      has_ns;
+};
+
+/**
+ * xsltStyleItemAttribute:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:attribute
+ *  name = { qname }
+ *  namespace = { uri-reference }>
+ *  <!-- Content: template -->
+ * </xsl:attribute>
+ */
+typedef struct _xsltStyleItemAttribute xsltStyleItemAttribute;
+typedef xsltStyleItemAttribute *xsltStyleItemAttributePtr;
+
+struct _xsltStyleItemAttribute {
+    XSLT_ITEM_COMMON_FIELDS
+    const xmlChar *name;
+    int      has_name;
+    const xmlChar *ns;
+    const xmlChar *nsPrefix;
+    int      has_ns;
+};
+
+/**
+ * xsltStyleItemText:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:text
+ *  disable-output-escaping = "yes" | "no">
+ *  <!-- Content: #PCDATA -->
+ * </xsl:text>
+ */
+typedef struct _xsltStyleItemText xsltStyleItemText;
+typedef xsltStyleItemText *xsltStyleItemTextPtr;
+
+struct _xsltStyleItemText {
+    XSLT_ITEM_COMMON_FIELDS
+    int      noescape;         /* text */
+};
+
+/**
+ * xsltStyleItemComment:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:comment>
+ *  <!-- Content: template -->
+ * </xsl:comment>
+ */
+typedef xsltStyleBasicEmptyItem xsltStyleItemComment;
+typedef xsltStyleItemComment *xsltStyleItemCommentPtr;
+
+/**
+ * xsltStyleItemPI:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:processing-instruction
+ *  name = { ncname }>
+ *  <!-- Content: template -->
+ * </xsl:processing-instruction>
+ */
+typedef struct _xsltStyleItemPI xsltStyleItemPI;
+typedef xsltStyleItemPI *xsltStyleItemPIPtr;
+
+struct _xsltStyleItemPI {
+    XSLT_ITEM_COMMON_FIELDS
+    const xmlChar *name;
+    int      has_name;
+};
+
+/**
+ * xsltStyleItemApplyImports:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:apply-imports />
+ */
+typedef xsltStyleBasicEmptyItem xsltStyleItemApplyImports;
+typedef xsltStyleItemApplyImports *xsltStyleItemApplyImportsPtr;
+
+/**
+ * xsltStyleItemApplyTemplates:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:apply-templates
+ *  select = node-set-expression
+ *  mode = qname>
+ *  <!-- Content: (xsl:sort | xsl:with-param)* -->
+ * </xsl:apply-templates>
+ */
+typedef struct _xsltStyleItemApplyTemplates xsltStyleItemApplyTemplates;
+typedef xsltStyleItemApplyTemplates *xsltStyleItemApplyTemplatesPtr;
+
+struct _xsltStyleItemApplyTemplates {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *mode;       /* apply-templates */
+    const xmlChar *modeURI;    /* apply-templates */
+    const xmlChar *select;     /* sort, copy-of, value-of, apply-templates */
+    xmlXPathCompExprPtr comp;  /* a precompiled XPath expression */
+    /* TODO: with-params */
+};
+
+/**
+ * xsltStyleItemCallTemplate:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:call-template
+ *  name = qname>
+ *  <!-- Content: xsl:with-param* -->
+ * </xsl:call-template>
+ */
+typedef struct _xsltStyleItemCallTemplate xsltStyleItemCallTemplate;
+typedef xsltStyleItemCallTemplate *xsltStyleItemCallTemplatePtr;
+
+struct _xsltStyleItemCallTemplate {
+    XSLT_ITEM_COMMON_FIELDS
+
+    xsltTemplatePtr templ;     /* call-template */
+    const xmlChar *name;       /* element, attribute, pi */
+    int      has_name;         /* element, attribute, pi */
+    const xmlChar *ns;         /* element */
+    int      has_ns;           /* element */
+    /* TODO: with-params */
+};
+
+/**
+ * xsltStyleItemCopy:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:copy
+ *  use-attribute-sets = qnames>
+ *  <!-- Content: template -->
+ * </xsl:copy>
+ */
+typedef struct _xsltStyleItemCopy xsltStyleItemCopy;
+typedef xsltStyleItemCopy *xsltStyleItemCopyPtr;
+
+struct _xsltStyleItemCopy {
+   XSLT_ITEM_COMMON_FIELDS
+    const xmlChar *use;                /* copy, element */
+    int      has_use;          /* copy, element */    
+};
+
+/**
+ * xsltStyleItemIf:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:if
+ *  test = boolean-expression>
+ *  <!-- Content: template -->
+ * </xsl:if>
+ */
+typedef struct _xsltStyleItemIf xsltStyleItemIf;
+typedef xsltStyleItemIf *xsltStyleItemIfPtr;
+
+struct _xsltStyleItemIf {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *test;       /* if */
+    xmlXPathCompExprPtr comp;  /* a precompiled XPath expression */
+};
+
+
+/**
+ * xsltStyleItemCopyOf:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:copy-of
+ *  select = expression />
+ */
+typedef xsltStyleBasicExpressionItem xsltStyleItemCopyOf;
+typedef xsltStyleItemCopyOf *xsltStyleItemCopyOfPtr;
+
+/**
+ * xsltStyleItemValueOf:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:value-of
+ *  select = string-expression
+ *  disable-output-escaping = "yes" | "no" />
+ */
+typedef struct _xsltStyleItemValueOf xsltStyleItemValueOf;
+typedef xsltStyleItemValueOf *xsltStyleItemValueOfPtr;
+
+struct _xsltStyleItemValueOf {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *select;
+    xmlXPathCompExprPtr comp;  /* a precompiled XPath expression */
+    int      noescape;
+};
+
+/**
+ * xsltStyleItemNumber:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:number
+ *  level = "single" | "multiple" | "any"
+ *  count = pattern
+ *  from = pattern
+ *  value = number-expression
+ *  format = { string }
+ *  lang = { nmtoken }
+ *  letter-value = { "alphabetic" | "traditional" }
+ *  grouping-separator = { char }
+ *  grouping-size = { number } />
+ */
+typedef struct _xsltStyleItemNumber xsltStyleItemNumber;
+typedef xsltStyleItemNumber *xsltStyleItemNumberPtr;
+
+struct _xsltStyleItemNumber {
+    XSLT_ITEM_COMMON_FIELDS
+    xsltNumberData numdata;    /* number */
+};
+
+/**
+ * xsltStyleItemChoose:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:choose>
+ *  <!-- Content: (xsl:when+, xsl:otherwise?) -->
+ * </xsl:choose>
+ */
+typedef xsltStyleBasicEmptyItem xsltStyleItemChoose;
+typedef xsltStyleItemChoose *xsltStyleItemChoosePtr;
+
+/**
+ * xsltStyleItemFallback:
+ *
+ * <!-- Category: instruction -->
+ *  <xsl:fallback>
+ *  <!-- Content: template -->
+ * </xsl:fallback>
+ */
+typedef xsltStyleBasicEmptyItem xsltStyleItemFallback;
+typedef xsltStyleItemFallback *xsltStyleItemFallbackPtr;
+
+/**
+ * xsltStyleItemForEach:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:for-each
+ *   select = node-set-expression>
+ *   <!-- Content: (xsl:sort*, template) -->
+ * </xsl:for-each>
+ */
+typedef xsltStyleBasicExpressionItem xsltStyleItemForEach;
+typedef xsltStyleItemForEach *xsltStyleItemForEachPtr;
+
+/**
+ * xsltStyleItemMessage:
+ *
+ * <!-- Category: instruction -->
+ * <xsl:message
+ *   terminate = "yes" | "no">
+ *   <!-- Content: template -->
+ * </xsl:message>
+ */
+typedef struct _xsltStyleItemMessage xsltStyleItemMessage;
+typedef xsltStyleItemMessage *xsltStyleItemMessagePtr;
+
+struct _xsltStyleItemMessage {
+    XSLT_ITEM_COMMON_FIELDS    
+    int terminate;
+};
+
+/**
+ * xsltStyleItemDocument:
+ *
+ * NOTE: This is not an instruction of XSLT 1.0.
+ */
+typedef struct _xsltStyleItemDocument xsltStyleItemDocument;
+typedef xsltStyleItemDocument *xsltStyleItemDocumentPtr;
+
+struct _xsltStyleItemDocument {
+    XSLT_ITEM_COMMON_FIELDS
+    int      ver11;            /* assigned: in xsltDocumentComp;
+                                  read: nowhere;
+                                  TODO: Check if we need. */
+    const xmlChar *filename;   /* document URL */
+    int has_filename;
+};   
+
+/************************************************************************
+ *                                                                     *
+ * Non-instructions (actually properties of instructions/declarations)  *
+ *                                                                     *
+ ************************************************************************/
+
+/**
+ * xsltStyleBasicItemVariable:
+ *
+ * Basic struct for xsl:variable, xsl:param and xsl:with-param.
+ * It's currently important to have equal fields, since
+ * xsltParseStylesheetCallerParam() is used with xsl:with-param from
+ * the xslt side and with xsl:param from the exslt side (in
+ * exsltFuncFunctionFunction()).
+ *
+ * FUTURE NOTE: In XSLT 2.0 xsl:param, xsl:variable and xsl:with-param
+ *   have additional different fields.
+ */
+typedef struct _xsltStyleBasicItemVariable xsltStyleBasicItemVariable;
+typedef xsltStyleBasicItemVariable *xsltStyleBasicItemVariablePtr;
+
+struct _xsltStyleBasicItemVariable {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *select;
+    xmlXPathCompExprPtr comp;
+
+    const xmlChar *name;
+    int      has_name;
+    const xmlChar *ns;
+    int      has_ns;
+};
+
+/**
+ * xsltStyleItemVariable:
+ *
+ * <!-- Category: top-level-element -->
+ * <xsl:param
+ *   name = qname
+ *   select = expression>
+ *   <!-- Content: template -->
+ * </xsl:param>
+ */
+typedef xsltStyleBasicItemVariable xsltStyleItemVariable;
+typedef xsltStyleItemVariable *xsltStyleItemVariablePtr;
+
+/**
+ * xsltStyleItemParam:
+ *
+ * <!-- Category: top-level-element -->
+ * <xsl:param
+ *   name = qname
+ *   select = expression>
+ *   <!-- Content: template -->
+ * </xsl:param>
+ */
+typedef struct _xsltStyleItemParam xsltStyleItemParam;
+typedef xsltStyleItemParam *xsltStyleItemParamPtr;
+
+struct _xsltStyleItemParam {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *select;
+    xmlXPathCompExprPtr comp;
+
+    const xmlChar *name;
+    int      has_name;
+    const xmlChar *ns;
+    int      has_ns;    
+};
+
+/**
+ * xsltStyleItemWithParam:
+ *
+ * <xsl:with-param
+ *  name = qname
+ *  select = expression>
+ *  <!-- Content: template -->
+ * </xsl:with-param>
+ */
+typedef xsltStyleBasicItemVariable xsltStyleItemWithParam;
+typedef xsltStyleItemWithParam *xsltStyleItemWithParamPtr;
+
+/**
+ * xsltStyleItemSort:
+ *
+ * Reflects the XSLT xsl:sort item.
+ * Allowed parents: xsl:apply-templates, xsl:for-each
+ * <xsl:sort
+ *   select = string-expression
+ *   lang = { nmtoken }
+ *   data-type = { "text" | "number" | qname-but-not-ncname }
+ *   order = { "ascending" | "descending" }
+ *   case-order = { "upper-first" | "lower-first" } />
+ */
+typedef struct _xsltStyleItemSort xsltStyleItemSort;
+typedef xsltStyleItemSort *xsltStyleItemSortPtr;
+
+struct _xsltStyleItemSort {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *stype;       /* sort */
+    int      has_stype;                /* sort */
+    int      number;           /* sort */
+    const xmlChar *order;      /* sort */
+    int      has_order;                /* sort */
+    int      descending;       /* sort */
+    const xmlChar *lang;       /* sort */
+    int      has_lang;         /* sort */
+    const xmlChar *case_order; /* sort */
+    int      lower_first;      /* sort */
+
+    const xmlChar *use;
+    int      has_use;
+
+    const xmlChar *select;     /* sort, copy-of, value-of, apply-templates */
+
+    xmlXPathCompExprPtr comp;  /* a precompiled XPath expression */
+};
+
+
+/**
+ * xsltStyleItemWhen:
+ * 
+ * <xsl:when
+ *   test = boolean-expression>
+ *   <!-- Content: template -->
+ * </xsl:when>
+ * Allowed parent: xsl:choose
+ */
+typedef struct _xsltStyleItemWhen xsltStyleItemWhen;
+typedef xsltStyleItemWhen *xsltStyleItemWhenPtr;
+
+struct _xsltStyleItemWhen {
+    XSLT_ITEM_COMMON_FIELDS
+
+    const xmlChar *test;
+    xmlXPathCompExprPtr comp;
+};
+
+/**
+ * xsltStyleItemOtherwise:
+ *
+ * Allowed parent: xsl:choose
+ * <xsl:otherwise>
+ *   <!-- Content: template -->
+ * </xsl:otherwise>
+ */
+typedef struct _xsltStyleItemOtherwise xsltStyleItemOtherwise;
+typedef xsltStyleItemOtherwise *xsltStyleItemOtherwisePtr;
+
+struct _xsltStyleItemOtherwise {
+    XSLT_ITEM_COMMON_FIELDS
+};
+
+typedef struct _xsltStyleItemInclude xsltStyleItemInclude;
+typedef xsltStyleItemInclude *xsltStyleItemIncludePtr;
+
+struct _xsltStyleItemInclude {
+    XSLT_ITEM_COMMON_FIELDS
+    xsltDocumentPtr include;
+};
+
+/************************************************************************
+ *                                                                     *
+ *  XSLT elements in forwards-compatible mode                           *
+ *                                                                     *
+ ************************************************************************/
+
+typedef struct _xsltStyleItemUknown xsltStyleItemUknown;
+typedef xsltStyleItemUknown *xsltStyleItemUknownPtr;
+struct _xsltStyleItemUknown {
+    XSLT_ITEM_COMMON_FIELDS
+};
+
+
+/************************************************************************
+ *                                                                     *
+ *  Extension elements                                                  *
+ *                                                                     *
+ ************************************************************************/
+
+/*
+ * xsltStyleItemExtElement:
+ *
+ * Reflects extension elements.
+ *
+ * NOTE: Due to the fact that the structure xsltElemPreComp is most
+ * probably already heavily in use out there by users, so we cannot
+ * easily change it, we'll create an intermediate structure which will
+ * hold an xsltElemPreCompPtr.
+ * BIG NOTE: The only problem I see here is that the user processes the
+ *  content of the stylesheet tree, possibly he'll lookup the node->psvi
+ *  fields in order to find subsequent extension functions.
+ *  In this case, the user's code will break, since the node->psvi
+ *  field will hold now the xsltStyleItemExtElementPtr and not
+ *  the xsltElemPreCompPtr.
+ *  However the place where the structure is anchored in the node-tree,
+ *  namely node->psvi, has beed already once been moved from node->_private
+ *  to node->psvi, so we have a precedent here, which, I think, should allow
+ *  us to change such semantics without headaches.
+ */
+typedef struct _xsltStyleItemExtElement xsltStyleItemExtElement;
+typedef xsltStyleItemExtElement *xsltStyleItemExtElementPtr;
+struct _xsltStyleItemExtElement {
+    XSLT_ITEM_COMMON_FIELDS
+    xsltElemPreCompPtr item;   
+};
+
+/************************************************************************
+ *                                                                     *
+ *  Literal result elements                                             *
+ *                                                                     *
+ ************************************************************************/
+
+typedef struct _xsltEffectiveNs xsltEffectiveNs;
+typedef xsltEffectiveNs *xsltEffectiveNsPtr;
+struct _xsltEffectiveNs {
+    xsltEffectiveNsPtr nextInStore; /* storage next */
+    xsltEffectiveNsPtr next; /* next item in the list */
+    const xmlChar *prefix;
+    const xmlChar *nsName;
+    /* 
+    * Indicates if eclared on the literal result element; dunno if really
+    * needed.
+    */
+    int holdByElem;
+};
+
+/*
+ * Info for literal result elements.
+ * This will be set on the elem->psvi field and will be
+ * shared by literal result elements, which have the same
+ * excluded result namespaces; i.e., this *won't* be created uniquely
+ * for every literal result element.
+ */
+typedef struct _xsltStyleItemLRElementInfo xsltStyleItemLRElementInfo;
+typedef xsltStyleItemLRElementInfo *xsltStyleItemLRElementInfoPtr;
+struct _xsltStyleItemLRElementInfo {
+    XSLT_ITEM_COMMON_FIELDS
+    /*
+    * @effectiveNs is the set of effective ns-nodes
+    *  on the literal result element, which will be added to the result
+    *  element if not already existing in the result tree.
+    *  This means that excluded namespaces (via exclude-result-prefixes,
+    *  extension-element-prefixes and the XSLT namespace) not added
+    *  to the set.
+    *  Namespace-aliasing was applied on the @effectiveNs.
+    */
+    xsltEffectiveNsPtr effectiveNs;
+
+};
+
+#ifdef XSLT_REFACTORED
+
+typedef struct _xsltNsAlias xsltNsAlias;
+typedef xsltNsAlias *xsltNsAliasPtr;
+struct _xsltNsAlias {
+    xsltNsAliasPtr next; /* next in the list */    
+    xmlNsPtr literalNs;
+    xmlNsPtr targetNs;
+    xmlDocPtr docOfTargetNs;
+};
+#endif
+
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+
+typedef struct _xsltNsMap xsltNsMap;
+typedef xsltNsMap *xsltNsMapPtr;
+struct _xsltNsMap {
+    xsltNsMapPtr next; /* next in the list */
+    xmlDocPtr doc;
+    xmlNodePtr elem; /* the element holding the ns-decl */
+    xmlNsPtr ns; /* the xmlNs structure holding the XML namespace name */
+    const xmlChar *origNsName; /* the original XML namespace name */
+    const xmlChar *newNsName; /* the mapped XML namespace name */    
+};
+#endif
+
+/************************************************************************
+ *                                                                     *
+ *  Compile-time structures for *internal* use only                     *
+ *                                                                     *
+ ************************************************************************/
+
+typedef struct _xsltPrincipalStylesheetData xsltPrincipalStylesheetData;
+typedef xsltPrincipalStylesheetData *xsltPrincipalStylesheetDataPtr;
+
+typedef struct _xsltNsList xsltNsList;
+typedef xsltNsList *xsltNsListPtr;
+struct _xsltNsList {
+    xsltNsListPtr next; /* next in the list */
+    xmlNsPtr ns;
+};
+
+/*
+* xsltVarInfo:
+*
+* Used at compilation time for parameters and variables.
+*/
+typedef struct _xsltVarInfo xsltVarInfo;
+typedef xsltVarInfo *xsltVarInfoPtr;
+struct _xsltVarInfo {
+    xsltVarInfoPtr next; /* next in the list */
+    xsltVarInfoPtr prev;
+    int depth; /* the depth in the tree */
+    const xmlChar *name;
+    const xmlChar *nsName;
+};
+
+#define XSLT_ELEMENT_CATEGORY_XSLT 0
+#define XSLT_ELEMENT_CATEGORY_EXTENSION 1
+#define XSLT_ELEMENT_CATEGORY_LRE 2
+
+/**
+ * xsltCompilerNodeInfo:
+ *
+ * Per-node information during compile-time.
+ */
+typedef struct _xsltCompilerNodeInfo xsltCompilerNodeInfo;
+typedef xsltCompilerNodeInfo *xsltCompilerNodeInfoPtr;
+struct _xsltCompilerNodeInfo {
+    xsltCompilerNodeInfoPtr next;
+    xsltCompilerNodeInfoPtr prev;
+    xmlNodePtr node;
+    int depth;
+    xsltTemplatePtr templ;   /* The owning template */
+    int category;           /* XSLT element, LR-element or
+                                extension element */
+    xsltStyleType type;
+    xsltElemPreCompPtr item; /* The compiled information */
+    /* The current in-scope namespaces */
+    xsltNsListContainerPtr inScopeNs;
+    /* The current excluded result namespaces */
+    xsltPointerListPtr exclResultNs; 
+    /* The current extension instruction namespaces */
+    xsltPointerListPtr extElemNs;
+
+    /* The current info for literal result elements. */
+    xsltStyleItemLRElementInfoPtr litResElemInfo;
+    /* 
+    * Set to 1 if in-scope namespaces changed,
+    *  or excluded result namespaces changed,
+    *  or extension element namespaces changed.
+    * This will trigger creation of new infos
+    *  for literal result elements.
+    */
+    int nsChanged;
+    int preserveWhitespace;
+    int stripWhitespace;
+    int isRoot; /* whether this is the stylesheet's root node */
+    int forwardsCompat; /* whether forwards-compatible mode is enabled */
+    /* whether the content of an extension element was processed */
+    int extContentHandled;
+    /* the type of the current child */
+    xsltStyleType curChildType;    
+};
+
+/**
+ * XSLT_CCTXT:
+ *
+ * get pointer to compiler context
+ */
+#define XSLT_CCTXT(style) ((xsltCompilerCtxtPtr) style->compCtxt) 
+
+typedef enum {
+    XSLT_ERROR_SEVERITY_ERROR = 0,
+    XSLT_ERROR_SEVERITY_WARNING
+} xsltErrorSeverityType;
+
+typedef struct _xsltCompilerCtxt xsltCompilerCtxt;
+typedef xsltCompilerCtxt *xsltCompilerCtxtPtr;
+struct _xsltCompilerCtxt {
+    void *errorCtxt;            /* user specific error context */
+    /*
+    * used for error/warning reports; e.g. XSLT_ERROR_SEVERITY_WARNING */
+    xsltErrorSeverityType errSeverity;         
+    int warnings;              /* TODO: number of warnings found at
+                                   compilation */
+    int errors;                        /* TODO: number of errors found at
+                                   compilation */
+    xmlDictPtr dict;
+    xsltStylesheetPtr style;
+    int simplified; /* whether this is a simplified stylesheet */
+    /* TODO: structured/unstructured error contexts. */
+    int depth; /* Current depth of processing */
+    
+    xsltCompilerNodeInfoPtr inode;
+    xsltCompilerNodeInfoPtr inodeList;
+    xsltCompilerNodeInfoPtr inodeLast;
+    xsltPointerListPtr tmpList; /* Used for various purposes */
+    /*
+    * The XSLT version as specified by the stylesheet's root element.
+    */
+    int isInclude;
+    int hasForwardsCompat; /* whether forwards-compatible mode was used
+                            in a parsing episode */
+    int maxNodeInfos; /* TEMP TODO: just for the interest */
+    int maxLREs;  /* TEMP TODO: just for the interest */
+    /* 
+    * In order to keep the old behaviour, applying strict rules of
+    * the spec can be turned off. This has effect only on special
+    * mechanisms like whitespace-stripping in the stylesheet.
+    */
+    int strict;
+    xsltPrincipalStylesheetDataPtr psData;
+#ifdef XSLT_REFACTORED_XPATHCOMP
+    xmlXPathContextPtr xpathCtxt;
+#endif
+    xsltStyleItemUknownPtr unknownItem;
+    int hasNsAliases; /* Indicator if there was an xsl:namespace-alias. */
+    xsltNsAliasPtr nsAliases;
+    xsltVarInfoPtr ivars; /* Storage of local in-scope variables/params. */
+    xsltVarInfoPtr ivar; /* topmost local variable/param. */
+};   
+
+#else /* XSLT_REFACTORED */
+/*
+* The old structures before refactoring.
+*/
+
+/**
+ * _xsltStylePreComp:
+ *
+ * The in-memory structure corresponding to XSLT stylesheet constructs
+ * precomputed data.
+ */
+struct _xsltStylePreComp {
+    xsltElemPreCompPtr next;   /* chained list */
+    xsltStyleType type;                /* type of the element */
+    xsltTransformFunction func; /* handling function */
+    xmlNodePtr inst;           /* the instruction */
+
+    /*
+     * Pre computed values.
+     */
+
+    const xmlChar *stype;       /* sort */
+    int      has_stype;                /* sort */
+    int      number;           /* sort */
+    const xmlChar *order;      /* sort */
+    int      has_order;                /* sort */
+    int      descending;       /* sort */
+    const xmlChar *lang;       /* sort */
+    int      has_lang;         /* sort */
+    const xmlChar *case_order; /* sort */
+    int      lower_first;      /* sort */
+
+    const xmlChar *use;                /* copy, element */
+    int      has_use;          /* copy, element */
+
+    int      noescape;         /* text */
+
+    const xmlChar *name;       /* element, attribute, pi */
+    int      has_name;         /* element, attribute, pi */
+    const xmlChar *ns;         /* element */
+    int      has_ns;           /* element */
+
+    const xmlChar *mode;       /* apply-templates */
+    const xmlChar *modeURI;    /* apply-templates */
+
+    const xmlChar *test;       /* if */
+
+    xsltTemplatePtr templ;     /* call-template */
+
+    const xmlChar *select;     /* sort, copy-of, value-of, apply-templates */
+
+    int      ver11;            /* document */
+    const xmlChar *filename;   /* document URL */
+    int      has_filename;     /* document */
+
+    xsltNumberData numdata;    /* number */
+
+    xmlXPathCompExprPtr comp;  /* a precompiled XPath expression */
+    xmlNsPtr *nsList;          /* the namespaces in scope */
+    int nsNr;                  /* the number of namespaces in scope */
+};
+
+#endif /* XSLT_REFACTORED */
+
+
+#define XSLT_VAR_GLOBAL 1<<0
+#define XSLT_VAR_IN_SELECT 1<<1
+#define XSLT_TCTXT_VARIABLE(c) ((xsltStackElemPtr) (c)->contextVariable)
+/*
+ * The in-memory structure corresponding to an XSLT Variable
+ * or Param.
+ */
+typedef struct _xsltStackElem xsltStackElem;
+typedef xsltStackElem *xsltStackElemPtr;
+struct _xsltStackElem {
+    struct _xsltStackElem *next;/* chained list */
+    xsltStylePreCompPtr comp;   /* the compiled form */
+    int computed;              /* was the evaluation done */
+    const xmlChar *name;       /* the local part of the name QName */
+    const xmlChar *nameURI;    /* the URI part of the name QName */
+    const xmlChar *select;     /* the eval string */
+    xmlNodePtr tree;           /* the sequence constructor if no eval
+                                   string or the location */
+    xmlXPathObjectPtr value;   /* The value if computed */
+    xmlDocPtr fragment;                /* The Result Tree Fragments (needed for XSLT 1.0)
+                                  which are bound to the variable's lifetime. */
+    int level;                  /* the depth in the tree;
+                                   -1 if persistent (e.g. a given xsl:with-param) */
+    xsltTransformContextPtr context; /* The transformation context; needed to cache
+                                        the variables */
+    int flags;
+};
+
+#ifdef XSLT_REFACTORED
+
+struct _xsltPrincipalStylesheetData {
+    /*
+    * Namespace dictionary for ns-prefixes and ns-names:
+    * TODO: Shared between stylesheets, and XPath mechanisms.
+    *   Not used yet.
+    */
+    xmlDictPtr namespaceDict;
+    /*
+    * Global list of in-scope namespaces.
+    */
+    xsltPointerListPtr inScopeNamespaces;
+    /*
+    * Global list of information for [xsl:]excluded-result-prefixes.
+    */
+    xsltPointerListPtr exclResultNamespaces;
+    /*
+    * Global list of information for [xsl:]extension-element-prefixes.
+    */
+    xsltPointerListPtr extElemNamespaces;
+    xsltEffectiveNsPtr effectiveNs;
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+    /*
+    * Namespace name map to get rid of string comparison of namespace names.
+    */
+    xsltNsMapPtr nsMap;
+#endif
+};
+
+    
+#endif
+/*
+ * Note that we added a @compCtxt field to anchor an stylesheet compilation
+ * context, since, due to historical reasons, various compile-time function
+ * take only the stylesheet as argument and not a compilation context.
+ */
+struct _xsltStylesheet {
+    /*
+     * The stylesheet import relation is kept as a tree.
+     */
+    struct _xsltStylesheet *parent;
+    struct _xsltStylesheet *next;
+    struct _xsltStylesheet *imports;
+
+    xsltDocumentPtr docList;           /* the include document list */
+
+    /*
+     * General data on the style sheet document.
+     */
+    xmlDocPtr doc;             /* the parsed XML stylesheet */
+    xmlHashTablePtr stripSpaces;/* the hash table of the strip-space and
+                                  preserve space elements */
+    int             stripAll;  /* strip-space * (1) preserve-space * (-1) */
+    xmlHashTablePtr cdataSection;/* the hash table of the cdata-section */
+
+    /*
+     * Global variable or parameters.
+     */
+    xsltStackElemPtr variables; /* linked list of param and variables */
+
+    /*
+     * Template descriptions.
+     */
+    xsltTemplatePtr templates; /* the ordered list of templates */
+    void *templatesHash;       /* hash table or wherever compiled templates
+                                  informations are stored */
+    void *rootMatch;           /* template based on / */
+    void *keyMatch;            /* template based on key() */
+    void *elemMatch;           /* template based on * */
+    void *attrMatch;           /* template based on @* */
+    void *parentMatch;         /* template based on .. */
+    void *textMatch;           /* template based on text() */
+    void *piMatch;             /* template based on processing-instruction() */
+    void *commentMatch;                /* template based on comment() */
+    
+    /*
+     * Namespace aliases.
+     * NOTE: Not used in the refactored code.
+     */
+    xmlHashTablePtr nsAliases; /* the namespace alias hash tables */
+
+    /*
+     * Attribute sets.
+     */
+    xmlHashTablePtr attributeSets;/* the attribute sets hash tables */
+
+    /*
+     * Namespaces.
+     * TODO: Eliminate this.
+     */
+    xmlHashTablePtr nsHash;     /* the set of namespaces in use:
+                                   ATTENTION: This is used for
+                                   execution of XPath expressions; unfortunately
+                                   it restricts the stylesheet to have distinct
+                                   prefixes.
+                                  TODO: We need to get rid of this.    
+                                */
+    void           *nsDefs;     /* ATTENTION TODO: This is currently used to store
+                                  xsltExtDefPtr (in extensions.c) and
+                                   *not* xmlNsPtr.
+                                */
+
+    /*
+     * Key definitions.
+     */
+    void *keys;                        /* key definitions */
+
+    /*
+     * Output related stuff.
+     */
+    xmlChar *method;           /* the output method */
+    xmlChar *methodURI;                /* associated namespace if any */
+    xmlChar *version;          /* version string */
+    xmlChar *encoding;         /* encoding string */
+    int omitXmlDeclaration;     /* omit-xml-declaration = "yes" | "no" */
+
+    /* 
+     * Number formatting.
+     */
+    xsltDecimalFormatPtr decimalFormat;
+    int standalone;             /* standalone = "yes" | "no" */
+    xmlChar *doctypePublic;     /* doctype-public string */
+    xmlChar *doctypeSystem;     /* doctype-system string */
+    int indent;                        /* should output being indented */
+    xmlChar *mediaType;                /* media-type string */
+
+    /*
+     * Precomputed blocks.
+     */
+    xsltElemPreCompPtr preComps;/* list of precomputed blocks */
+    int warnings;              /* number of warnings found at compilation */
+    int errors;                        /* number of errors found at compilation */
+
+    xmlChar  *exclPrefix;      /* last excluded prefixes */
+    xmlChar **exclPrefixTab;   /* array of excluded prefixes */
+    int       exclPrefixNr;    /* number of excluded prefixes in scope */
+    int       exclPrefixMax;   /* size of the array */
+
+    void     *_private;                /* user defined data */
+
+    /*
+     * Extensions.
+     */
+    xmlHashTablePtr extInfos;  /* the extension data */
+    int                    extrasNr;   /* the number of extras required */
+
+    /*
+     * For keeping track of nested includes
+     */
+    xsltDocumentPtr includes;  /* points to last nested include */
+
+    /*
+     * dictionary: shared between stylesheet, context and documents.
+     */
+    xmlDictPtr dict;
+    /*
+     * precompiled attribute value templates.
+     */
+    void *attVTs;
+    /*
+     * if namespace-alias has an alias for the default stylesheet prefix
+     * NOTE: Not used in the refactored code.
+     */
+    const xmlChar *defaultAlias;
+    /*
+     * bypass pre-processing (already done) (used in imports)
+     */
+    int nopreproc;
+    /*
+     * all document text strings were internalized
+     */
+    int internalized;
+    /*
+     * Literal Result Element as Stylesheet c.f. section 2.3
+     */
+    int literal_result;
+    /*
+    * The principal stylesheet
+    */
+    xsltStylesheetPtr principal;
+#ifdef XSLT_REFACTORED
+    /*
+    * Compilation context used during compile-time.
+    */
+    xsltCompilerCtxtPtr compCtxt; /* TODO: Change this to (void *). */
+
+    xsltPrincipalStylesheetDataPtr principalData;    
+#endif
+};
+
+typedef struct _xsltTransformCache xsltTransformCache;
+typedef xsltTransformCache *xsltTransformCachePtr;
+struct _xsltTransformCache {
+    xmlDocPtr RVT;
+    int nbRVT;
+    xsltStackElemPtr stackItems;
+    int nbStackItems;
+#ifdef XSLT_DEBUG_PROFILE_CACHE
+    int dbgCachedRVTs;
+    int dbgReusedRVTs;
+    int dbgCachedVars;
+    int dbgReusedVars;
+#endif
+};
+
+/*
+ * The in-memory structure corresponding to an XSLT Transformation.
+ */
+typedef enum {
+    XSLT_OUTPUT_XML = 0,
+    XSLT_OUTPUT_HTML,
+    XSLT_OUTPUT_TEXT
+} xsltOutputType;
+
+typedef enum {
+    XSLT_STATE_OK = 0,
+    XSLT_STATE_ERROR,
+    XSLT_STATE_STOPPED
+} xsltTransformState;
+
+struct _xsltTransformContext {
+    xsltStylesheetPtr style;           /* the stylesheet used */
+    xsltOutputType type;               /* the type of output */
+
+    xsltTemplatePtr  templ;            /* the current template */
+    int              templNr;          /* Nb of templates in the stack */
+    int              templMax;         /* Size of the templtes stack */
+    xsltTemplatePtr *templTab;         /* the template stack */
+
+    xsltStackElemPtr  vars;            /* the current variable list */
+    int               varsNr;          /* Nb of variable list in the stack */
+    int               varsMax;         /* Size of the variable list stack */
+    xsltStackElemPtr *varsTab;         /* the variable list stack */
+    int               varsBase;                /* the var base for current templ */
+
+    /*
+     * Extensions
+     */
+    xmlHashTablePtr   extFunctions;    /* the extension functions */
+    xmlHashTablePtr   extElements;     /* the extension elements */
+    xmlHashTablePtr   extInfos;                /* the extension data */
+
+    const xmlChar *mode;               /* the current mode */
+    const xmlChar *modeURI;            /* the current mode URI */
+
+    xsltDocumentPtr docList;           /* the document list */
+
+    xsltDocumentPtr document;          /* the current source document; can be NULL if an RTF */
+    xmlNodePtr node;                   /* the current node being processed */
+    xmlNodeSetPtr nodeList;            /* the current node list */
+    /* xmlNodePtr current;                     the node */
+
+    xmlDocPtr output;                  /* the resulting document */
+    xmlNodePtr insert;                 /* the insertion node */
+
+    xmlXPathContextPtr xpathCtxt;      /* the XPath context */
+    xsltTransformState state;          /* the current state */
+
+    /*
+     * Global variables
+     */
+    xmlHashTablePtr   globalVars;      /* the global variables and params */
+
+    xmlNodePtr inst;                   /* the instruction in the stylesheet */
+
+    int xinclude;                      /* should XInclude be processed */
+
+    const char *      outputFile;      /* the output URI if known */
+
+    int profile;                        /* is this run profiled */
+    long             prof;             /* the current profiled value */
+    int              profNr;           /* Nb of templates in the stack */
+    int              profMax;          /* Size of the templtaes stack */
+    long            *profTab;          /* the profile template stack */
+
+    void            *_private;         /* user defined data */
+
+    int              extrasNr;         /* the number of extras used */
+    int              extrasMax;                /* the number of extras allocated */
+    xsltRuntimeExtraPtr extras;                /* extra per runtime informations */
+
+    xsltDocumentPtr  styleList;                /* the stylesheet docs list */
+    void                 * sec;                /* the security preferences if any */
+
+    xmlGenericErrorFunc  error;                /* a specific error handler */
+    void              * errctx;                /* context for the error handler */
+
+    xsltSortFunc      sortfunc;                /* a ctxt specific sort routine */
+
+    /*
+     * handling of temporary Result Value Tree
+     * (XSLT 1.0 term: "Result Tree Fragment")
+     */
+    xmlDocPtr       tmpRVT;            /* list of RVT without persistance */
+    xmlDocPtr       persistRVT;                /* list of persistant RVTs */
+    int             ctxtflags;          /* context processing flags */
+
+    /*
+     * Speed optimization when coalescing text nodes
+     */
+    const xmlChar  *lasttext;          /* last text node content */
+    unsigned int    lasttsize;         /* last text node size */
+    unsigned int    lasttuse;          /* last text node use */
+    /*
+     * Per Context Debugging
+     */
+    int debugStatus;                   /* the context level debug status */
+    unsigned long* traceCode;          /* pointer to the variable holding the mask */
+
+    int parserOptions;                 /* parser options xmlParserOption */
+
+    /*
+     * dictionary: shared between stylesheet, context and documents.
+     */
+    xmlDictPtr dict;
+    xmlDocPtr          tmpDoc; /* Obsolete; not used in the library. */
+    /*
+     * all document text strings are internalized
+     */
+    int internalized;
+    int nbKeys;
+    int hasTemplKeyPatterns;
+    xsltTemplatePtr currentTemplateRule; /* the Current Template Rule */
+    xmlNodePtr initialContextNode;
+    xmlDocPtr initialContextDoc;
+    xsltTransformCachePtr cache;
+    void *contextVariable; /* the current variable item */
+    xmlDocPtr localRVT; /* list of local tree fragments; will be freed when
+                          the instruction which created the fragment
+                           exits */
+    xmlDocPtr localRVTBase;
+    int keyInitLevel;   /* Needed to catch recursive keys issues */
+};
+
+/**
+ * CHECK_STOPPED:
+ *
+ * Macro to check if the XSLT processing should be stopped.
+ * Will return from the function.
+ */
+#define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return;
+
+/**
+ * CHECK_STOPPEDE:
+ *
+ * Macro to check if the XSLT processing should be stopped.
+ * Will goto the error: label.
+ */
+#define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error;
+
+/**
+ * CHECK_STOPPED0:
+ *
+ * Macro to check if the XSLT processing should be stopped.
+ * Will return from the function with a 0 value.
+ */
+#define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);
+
+/*
+ * The macro XML_CAST_FPTR is a hack to avoid a gcc warning about
+ * possible incompatibilities between function pointers and object
+ * pointers.  It is defined in libxml/hash.h within recent versions
+ * of libxml2, but is put here for compatibility.
+ */
+#ifndef XML_CAST_FPTR
+/**
+ * XML_CAST_FPTR:
+ * @fptr:  pointer to a function
+ *
+ * Macro to do a casting from an object pointer to a
+ * function pointer without encountering a warning from
+ * gcc
+ *
+ * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))
+ * This macro violated ISO C aliasing rules (gcc4 on s390 broke)
+ * so it is disabled now
+ */
+
+#define XML_CAST_FPTR(fptr) fptr
+#endif
+/*
+ * Functions associated to the internal types
+xsltDecimalFormatPtr   xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,
+                                                  xmlChar *name);
+ */
+XSLTPUBFUN xsltStylesheetPtr XSLTCALL  
+                       xsltNewStylesheet       (void);
+XSLTPUBFUN xsltStylesheetPtr XSLTCALL  
+                       xsltParseStylesheetFile (const xmlChar* filename);
+XSLTPUBFUN void XSLTCALL                       
+                       xsltFreeStylesheet      (xsltStylesheetPtr style);
+XSLTPUBFUN int XSLTCALL                        
+                       xsltIsBlank             (xmlChar *str);
+XSLTPUBFUN void XSLTCALL                       
+                       xsltFreeStackElemList   (xsltStackElemPtr elem);
+XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL       
+                       xsltDecimalFormatGetByName(xsltStylesheetPtr style,
+                                                xmlChar *name);
+
+XSLTPUBFUN xsltStylesheetPtr XSLTCALL  
+                       xsltParseStylesheetProcess(xsltStylesheetPtr ret,
+                                                xmlDocPtr doc);
+XSLTPUBFUN void XSLTCALL                       
+                       xsltParseStylesheetOutput(xsltStylesheetPtr style,
+                                                xmlNodePtr cur);
+XSLTPUBFUN xsltStylesheetPtr XSLTCALL  
+                       xsltParseStylesheetDoc  (xmlDocPtr doc);
+XSLTPUBFUN xsltStylesheetPtr XSLTCALL  
+                       xsltParseStylesheetImportedDoc(xmlDocPtr doc,
+                                               xsltStylesheetPtr style);
+XSLTPUBFUN xsltStylesheetPtr XSLTCALL  
+                       xsltLoadStylesheetPI    (xmlDocPtr doc);
+XSLTPUBFUN void XSLTCALL                       
+                       xsltNumberFormat        (xsltTransformContextPtr ctxt,
+                                                xsltNumberDataPtr data,
+                                                xmlNodePtr node);
+XSLTPUBFUN xmlXPathError XSLTCALL               
+                       xsltFormatNumberConversion(xsltDecimalFormatPtr self,
+                                                xmlChar *format,
+                                                double number,
+                                                xmlChar **result);
+
+XSLTPUBFUN void XSLTCALL                       
+                       xsltParseTemplateContent(xsltStylesheetPtr style,
+                                                xmlNodePtr templ);
+XSLTPUBFUN int XSLTCALL                        
+                       xsltAllocateExtra       (xsltStylesheetPtr style);
+XSLTPUBFUN int XSLTCALL                        
+                       xsltAllocateExtraCtxt   (xsltTransformContextPtr ctxt);
+/*
+ * Extra functions for Result Value Trees
+ */
+XSLTPUBFUN xmlDocPtr XSLTCALL          
+                       xsltCreateRVT           (xsltTransformContextPtr ctxt);
+XSLTPUBFUN int XSLTCALL                        
+                       xsltRegisterTmpRVT      (xsltTransformContextPtr ctxt,
+                                                xmlDocPtr RVT);
+XSLTPUBFUN int XSLTCALL                        
+                       xsltRegisterLocalRVT    (xsltTransformContextPtr ctxt,
+                                                xmlDocPtr RVT);
+XSLTPUBFUN int XSLTCALL                        
+                       xsltRegisterPersistRVT  (xsltTransformContextPtr ctxt,
+                                                xmlDocPtr RVT);
+XSLTPUBFUN int XSLTCALL
+                       xsltExtensionInstructionResultRegister(
+                                                xsltTransformContextPtr ctxt,
+                                                xmlXPathObjectPtr obj);
+XSLTPUBFUN int XSLTCALL
+                       xsltExtensionInstructionResultFinalize(
+                                                xsltTransformContextPtr ctxt);
+XSLTPUBFUN void XSLTCALL
+                       xsltFreeRVTs            (xsltTransformContextPtr ctxt);
+XSLTPUBFUN void XSLTCALL
+                       xsltReleaseRVT          (xsltTransformContextPtr ctxt,
+                                                xmlDocPtr RVT);
+XSLTPUBFUN int XSLTCALL
+                       xsltTransStorageAdd     (xsltTransformContextPtr ctxt,
+                                                void *id,
+                                                void *data);
+XSLTPUBFUN void * XSLTCALL
+                       xsltTransStorageRemove  (xsltTransformContextPtr ctxt,
+                                                void *id);
+
+/*
+ * Extra functions for Attribute Value Templates
+ */
+XSLTPUBFUN void XSLTCALL
+                       xsltCompileAttr         (xsltStylesheetPtr style,
+                                                xmlAttrPtr attr);
+XSLTPUBFUN xmlChar * XSLTCALL
+                       xsltEvalAVT             (xsltTransformContextPtr ctxt,
+                                                void *avt,
+                                                xmlNodePtr node);
+XSLTPUBFUN void XSLTCALL
+                       xsltFreeAVTList         (void *avt);
+
+/*
+ * Extra function for successful xsltCleanupGlobals / xsltInit sequence.
+ */
+
+XSLTPUBFUN void XSLTCALL
+                       xsltUninit              (void);
+
+/************************************************************************
+ *                                                                     *
+ *  Compile-time functions for *internal* use only                      *
+ *                                                                     *
+ ************************************************************************/
+
+#ifdef XSLT_REFACTORED  
+XSLTPUBFUN void XSLTCALL
+                       xsltParseSequenceConstructor(
+                                                xsltCompilerCtxtPtr cctxt,
+                                                xmlNodePtr start);
+XSLTPUBFUN int XSLTCALL
+                       xsltParseAnyXSLTElem    (xsltCompilerCtxtPtr cctxt,
+                                                xmlNodePtr elem);
+#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+XSLTPUBFUN int XSLTCALL
+                       xsltRestoreDocumentNamespaces(
+                                                xsltNsMapPtr ns,
+                                                xmlDocPtr doc);
+#endif
+#endif /* XSLT_REFACTORED */
+
+/************************************************************************
+ *                                                                     *
+ *  Transformation-time functions for *internal* use only               *
+ *                                                                     *
+ ************************************************************************/
+XSLTPUBFUN int XSLTCALL
+                       xsltInitCtxtKey         (xsltTransformContextPtr ctxt,
+                                                xsltDocumentPtr doc,
+                                                xsltKeyDefPtr keyd);
+XSLTPUBFUN int XSLTCALL
+                       xsltInitAllDocKeys      (xsltTransformContextPtr ctxt);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLT_H__ */
+
diff --git a/reactos/include/reactos/libs/libxslt/xsltconfig.h b/reactos/include/reactos/libs/libxslt/xsltconfig.h
new file mode 100644 (file)
index 0000000..94d4391
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * Summary: compile-time version informations for the XSLT engine
+ * Description: compile-time version informations for the XSLT engine
+ *              this module is autogenerated.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLTCONFIG_H__
+#define __XML_XSLTCONFIG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * LIBXSLT_DOTTED_VERSION:
+ *
+ * the version string like "1.2.3"
+ */
+#define LIBXSLT_DOTTED_VERSION "1.1.24"
+
+/**
+ * LIBXSLT_VERSION:
+ *
+ * the version number: 1.2.3 value is 10203
+ */
+#define LIBXSLT_VERSION 10124
+
+/**
+ * LIBXSLT_VERSION_STRING:
+ *
+ * the version number string, 1.2.3 value is "10203"
+ */
+#define LIBXSLT_VERSION_STRING "10124"
+
+/**
+ * LIBXSLT_VERSION_EXTRA:
+ *
+ * extra version information, used to show a CVS compilation
+ */
+#define        LIBXSLT_VERSION_EXTRA "-CVS1070"
+
+/**
+ * WITH_XSLT_DEBUG:
+ *
+ * Activate the compilation of the debug reporting. Speed penalty
+ * is insignifiant and being able to run xsltpoc -v is useful. On
+ * by default unless --without-debug is passed to configure
+ */
+#if 1
+#define WITH_XSLT_DEBUG
+#endif
+
+#if 1
+/**
+ * DEBUG_MEMORY:
+ *
+ * should be activated only when debugging libxslt. It replaces the
+ * allocator with a collect and debug shell to the libc allocator.
+ * Use configure --with-mem-debug to activate it on both library
+ */
+#define DEBUG_MEMORY
+
+/**
+ * DEBUG_MEMORY_LOCATION:
+ *
+ * should be activated only when debugging libxslt.
+ * DEBUG_MEMORY_LOCATION should be activated only when libxml has
+ * been configured with --with-debug-mem too
+ */
+#define DEBUG_MEMORY_LOCATION
+#endif
+
+/**
+ * XSLT_NEED_TRIO:
+ *
+ * should be activated if the existing libc library lacks some of the
+ * string formatting function, in that case reuse the Trio ones already
+ * compiled in the libxml2 library.
+ */
+
+#if 0
+#define XSLT_NEED_TRIO
+#endif
+#ifdef __VMS
+#define HAVE_MATH_H 1
+#define HAVE_SYS_STAT_H 1
+#ifndef XSLT_NEED_TRIO
+#define XSLT_NEED_TRIO
+#endif
+#endif
+
+#ifdef XSLT_NEED_TRIO
+#define        TRIO_REPLACE_STDIO
+#endif
+
+/**
+ * WITH_XSLT_DEBUGGER:
+ *
+ * Activate the compilation of the debugger support. Speed penalty
+ * is insignifiant.
+ * On by default unless --without-debugger is passed to configure
+ */
+#if 1
+#ifndef WITH_DEBUGGER
+#define WITH_DEBUGGER
+#endif
+#endif
+
+/**
+ * WITH_MODULES:
+ *
+ * Whether module support is configured into libxslt
+ * Note: no default module path for win32 platforms
+ */
+#if 1
+#ifndef WITH_MODULES
+#define WITH_MODULES
+#endif
+#define LIBXSLT_DEFAULT_PLUGINS_PATH() "/usr/lib/libxslt-plugins"
+#endif
+
+/**
+ * ATTRIBUTE_UNUSED:
+ *
+ * This macro is used to flag unused function parameters to GCC
+ */
+#ifdef __GNUC__
+#ifdef HAVE_ANSIDECL_H
+#include <ansidecl.h>
+#endif
+#ifndef ATTRIBUTE_UNUSED
+#define ATTRIBUTE_UNUSED __attribute__((unused))
+#endif
+#else
+#define ATTRIBUTE_UNUSED
+#endif
+
+/**
+ * LIBXSLT_PUBLIC:
+ *
+ * This macro is used to declare PUBLIC variables for Cygwin and for MSC on Windows
+ */
+#if !defined LIBXSLT_PUBLIC
+#if (defined(__CYGWIN__) || defined _MSC_VER) && !defined IN_LIBXSLT && !defined LIBXSLT_STATIC
+#define LIBXSLT_PUBLIC __declspec(dllimport)
+#else
+#define LIBXSLT_PUBLIC
+#endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLTCONFIG_H__ */
diff --git a/reactos/include/reactos/libs/libxslt/xsltexports.h b/reactos/include/reactos/libs/libxslt/xsltexports.h
new file mode 100644 (file)
index 0000000..825c122
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * Summary: macros for marking symbols as exportable/importable.
+ * Description: macros for marking symbols as exportable/importable.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Igor Zlatkovic <igor@zlatkovic.com>
+ */
+
+#ifndef __XSLT_EXPORTS_H__
+#define __XSLT_EXPORTS_H__
+
+/**
+ * XSLTPUBFUN:
+ * XSLTPUBFUN, XSLTPUBVAR, XSLTCALL
+ *
+ * Macros which declare an exportable function, an exportable variable and
+ * the calling convention used for functions.
+ *
+ * Please use an extra block for every platform/compiler combination when
+ * modifying this, rather than overlong #ifdef lines. This helps
+ * readability as well as the fact that different compilers on the same
+ * platform might need different definitions.
+ */
+
+/**
+ * XSLTPUBFUN:
+ *
+ * Macros which declare an exportable function
+ */
+#define XSLTPUBFUN
+/**
+ * XSLTPUBVAR:
+ *
+ * Macros which declare an exportable variable
+ */
+#define XSLTPUBVAR extern
+/**
+ * XSLTCALL:
+ *
+ * Macros which declare the called convention for exported functions
+ */
+#define XSLTCALL
+
+/** DOC_DISABLE */
+
+/* Windows platform with MS compiler */
+#if defined(_WIN32) && defined(_MSC_VER)
+  #undef XSLTPUBFUN
+  #undef XSLTPUBVAR
+  #undef XSLTCALL
+  #if defined(IN_LIBXSLT) && !defined(LIBXSLT_STATIC)
+    #define XSLTPUBFUN __declspec(dllexport)
+    #define XSLTPUBVAR __declspec(dllexport)
+  #else
+    #define XSLTPUBFUN
+    #if !defined(LIBXSLT_STATIC)
+      #define XSLTPUBVAR __declspec(dllimport) extern
+    #else
+      #define XSLTPUBVAR extern
+    #endif
+  #endif
+  #define XSLTCALL __cdecl
+  #if !defined _REENTRANT
+    #define _REENTRANT
+  #endif
+#endif
+
+/* Windows platform with Borland compiler */
+#if defined(_WIN32) && defined(__BORLANDC__)
+  #undef XSLTPUBFUN
+  #undef XSLTPUBVAR
+  #undef XSLTCALL
+  #if defined(IN_LIBXSLT) && !defined(LIBXSLT_STATIC)
+    #define XSLTPUBFUN __declspec(dllexport)
+    #define XSLTPUBVAR __declspec(dllexport) extern
+  #else
+    #define XSLTPUBFUN
+    #if !defined(LIBXSLT_STATIC)
+      #define XSLTPUBVAR __declspec(dllimport) extern
+    #else
+      #define XSLTPUBVAR extern
+    #endif
+  #endif
+  #define XSLTCALL __cdecl
+  #if !defined _REENTRANT
+    #define _REENTRANT
+  #endif
+#endif
+
+/* Windows platform with GNU compiler (Mingw) */
+#if defined(_WIN32) && defined(__MINGW32__)
+  #undef XSLTPUBFUN
+  #undef XSLTPUBVAR
+  #undef XSLTCALL
+/*
+  #if defined(IN_LIBXSLT) && !defined(LIBXSLT_STATIC)
+*/
+  #if !defined(LIBXSLT_STATIC)
+    #define XSLTPUBFUN __declspec(dllexport)
+    #define XSLTPUBVAR __declspec(dllexport) extern
+  #else
+    #define XSLTPUBFUN
+    #if !defined(LIBXSLT_STATIC)
+      #define XSLTPUBVAR __declspec(dllimport) extern
+    #else
+      #define XSLTPUBVAR extern
+    #endif
+  #endif
+  #define XSLTCALL __cdecl
+  #if !defined _REENTRANT
+    #define _REENTRANT
+  #endif
+#endif
+
+/* Cygwin platform, GNU compiler */
+#if defined(_WIN32) && defined(__CYGWIN__)
+  #undef XSLTPUBFUN
+  #undef XSLTPUBVAR
+  #undef XSLTCALL
+  #if defined(IN_LIBXSLT) && !defined(LIBXSLT_STATIC)
+    #define XSLTPUBFUN __declspec(dllexport)
+    #define XSLTPUBVAR __declspec(dllexport)
+  #else
+    #define XSLTPUBFUN
+    #if !defined(LIBXSLT_STATIC)
+      #define XSLTPUBVAR __declspec(dllimport) extern
+    #else
+      #define XSLTPUBVAR
+    #endif
+  #endif
+  #define XSLTCALL __cdecl
+#endif
+
+/* Compatibility */
+#if !defined(LIBXSLT_PUBLIC)
+#define LIBXSLT_PUBLIC XSLTPUBVAR
+#endif
+
+#endif /* __XSLT_EXPORTS_H__ */
+
+
diff --git a/reactos/include/reactos/libs/libxslt/xsltutils.h b/reactos/include/reactos/libs/libxslt/xsltutils.h
new file mode 100644 (file)
index 0000000..3886be3
--- /dev/null
@@ -0,0 +1,309 @@
+/*
+ * Summary: set of utilities for the XSLT engine
+ * Description: interfaces for the utilities module of the XSLT engine.
+ *              things like message handling, profiling, and other
+ *              generally useful routines.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XSLTUTILS_H__
+#define __XML_XSLTUTILS_H__
+
+#include <libxslt/xsltconfig.h>
+#ifdef HAVE_STDARG_H
+#include <stdarg.h>
+#endif
+#include <libxml/xpath.h>
+#include <libxml/dict.h>
+#include <libxml/xmlerror.h>
+#include "xsltexports.h"
+#include "xsltInternals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * XSLT_TODO:
+ *
+ * Macro to flag unimplemented blocks.
+ */
+#define XSLT_TODO                                                      \
+    xsltGenericError(xsltGenericErrorContext,                          \
+           "Unimplemented block at %s:%d\n",                           \
+            __FILE__, __LINE__);
+
+/**
+ * XSLT_STRANGE:
+ *
+ * Macro to flag that a problem was detected internally.
+ */
+#define XSLT_STRANGE                                                   \
+    xsltGenericError(xsltGenericErrorContext,                          \
+           "Internal error at %s:%d\n",                                \
+            __FILE__, __LINE__);
+
+/**
+ * IS_XSLT_ELEM:
+ *
+ * Checks that the element pertains to XSLT namespace.
+ */
+#define IS_XSLT_ELEM(n)                                                        \
+    (((n) != NULL) && ((n)->ns != NULL) &&                             \
+     (xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))
+
+/**
+ * IS_XSLT_NAME:
+ *
+ * Checks the value of an element in XSLT namespace.
+ */
+#define IS_XSLT_NAME(n, val)                                           \
+    (xmlStrEqual((n)->name, (const xmlChar *) (val)))
+
+/**
+ * IS_XSLT_REAL_NODE:
+ *
+ * Check that a node is a 'real' one: document, element, text or attribute.
+ */
+#define IS_XSLT_REAL_NODE(n)                                           \
+    (((n) != NULL) &&                                                  \
+     (((n)->type == XML_ELEMENT_NODE) ||                               \
+      ((n)->type == XML_TEXT_NODE) ||                                  \
+      ((n)->type == XML_CDATA_SECTION_NODE) ||                         \
+      ((n)->type == XML_ATTRIBUTE_NODE) ||                             \
+      ((n)->type == XML_DOCUMENT_NODE) ||                              \
+      ((n)->type == XML_HTML_DOCUMENT_NODE) ||                         \
+      ((n)->type == XML_COMMENT_NODE) ||                               \
+      ((n)->type == XML_PI_NODE)))      
+
+/*
+ * Our own version of namespaced atributes lookup.
+ */
+XSLTPUBFUN xmlChar * XSLTCALL
+               xsltGetNsProp   (xmlNodePtr node,
+                                const xmlChar *name,
+                                const xmlChar *nameSpace);
+XSLTPUBFUN const xmlChar * XSLTCALL
+               xsltGetCNsProp  (xsltStylesheetPtr style,
+                                xmlNodePtr node,
+                                const xmlChar *name,
+                                const xmlChar *nameSpace);
+XSLTPUBFUN int XSLTCALL
+               xsltGetUTF8Char (const unsigned char *utf,
+                                int *len);
+
+/*
+ * XSLT Debug Tracing Tracing Types
+ */
+typedef enum {
+       XSLT_TRACE_ALL =                -1,
+       XSLT_TRACE_NONE =               0,
+       XSLT_TRACE_COPY_TEXT =          1<<0,
+       XSLT_TRACE_PROCESS_NODE =       1<<1,
+       XSLT_TRACE_APPLY_TEMPLATE =     1<<2,
+       XSLT_TRACE_COPY =               1<<3,
+       XSLT_TRACE_COMMENT =            1<<4,
+       XSLT_TRACE_PI =                 1<<5,
+       XSLT_TRACE_COPY_OF =            1<<6,
+       XSLT_TRACE_VALUE_OF =           1<<7,
+       XSLT_TRACE_CALL_TEMPLATE =      1<<8,
+       XSLT_TRACE_APPLY_TEMPLATES =    1<<9,
+       XSLT_TRACE_CHOOSE =             1<<10,
+       XSLT_TRACE_IF =                 1<<11,
+       XSLT_TRACE_FOR_EACH =           1<<12,
+       XSLT_TRACE_STRIP_SPACES =       1<<13,
+       XSLT_TRACE_TEMPLATES =          1<<14,
+       XSLT_TRACE_KEYS =               1<<15,
+       XSLT_TRACE_VARIABLES =          1<<16
+} xsltDebugTraceCodes;
+
+/**
+ * XSLT_TRACE:
+ *
+ * Control the type of xsl debugtrace messages emitted.
+ */
+#define XSLT_TRACE(ctxt,code,call)     \
+       if (ctxt->traceCode && (*(ctxt->traceCode) & code)) \
+           call
+
+XSLTPUBFUN void XSLTCALL
+               xsltDebugSetDefaultTrace(xsltDebugTraceCodes val);
+XSLTPUBFUN xsltDebugTraceCodes XSLTCALL
+               xsltDebugGetDefaultTrace(void);
+
+/*
+ * XSLT specific error and debug reporting functions.
+ */
+XSLTPUBVAR xmlGenericErrorFunc xsltGenericError;
+XSLTPUBVAR void *xsltGenericErrorContext;
+XSLTPUBVAR xmlGenericErrorFunc xsltGenericDebug;
+XSLTPUBVAR void *xsltGenericDebugContext;
+
+XSLTPUBFUN void XSLTCALL               
+               xsltPrintErrorContext           (xsltTransformContextPtr ctxt,
+                                                xsltStylesheetPtr style,
+                                                xmlNodePtr node);
+XSLTPUBFUN void XSLTCALL               
+               xsltMessage                     (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr node,
+                                                xmlNodePtr inst);
+XSLTPUBFUN void XSLTCALL               
+               xsltSetGenericErrorFunc         (void *ctx,
+                                                xmlGenericErrorFunc handler);
+XSLTPUBFUN void XSLTCALL               
+               xsltSetGenericDebugFunc         (void *ctx,
+                                                xmlGenericErrorFunc handler);
+XSLTPUBFUN void XSLTCALL               
+               xsltSetTransformErrorFunc       (xsltTransformContextPtr ctxt,
+                                                void *ctx,
+                                                xmlGenericErrorFunc handler);
+XSLTPUBFUN void XSLTCALL               
+               xsltTransformError              (xsltTransformContextPtr ctxt,
+                                                xsltStylesheetPtr style,
+                                                xmlNodePtr node,
+                                                const char *msg,
+                                                ...);
+
+XSLTPUBFUN int XSLTCALL
+               xsltSetCtxtParseOptions         (xsltTransformContextPtr ctxt,
+                                                int options);
+/*
+ * Sorting.
+ */
+
+XSLTPUBFUN void XSLTCALL               
+               xsltDocumentSortFunction        (xmlNodeSetPtr list);
+XSLTPUBFUN void XSLTCALL               
+               xsltSetSortFunc                 (xsltSortFunc handler);
+XSLTPUBFUN void XSLTCALL               
+               xsltSetCtxtSortFunc             (xsltTransformContextPtr ctxt,
+                                                xsltSortFunc handler);
+XSLTPUBFUN void XSLTCALL               
+               xsltDefaultSortFunction         (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr *sorts,
+                                                int nbsorts);
+XSLTPUBFUN void XSLTCALL               
+               xsltDoSortFunction              (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr * sorts,
+                                                int nbsorts);
+XSLTPUBFUN xmlXPathObjectPtr * XSLTCALL 
+               xsltComputeSortResult           (xsltTransformContextPtr ctxt,
+                                                xmlNodePtr sort);
+
+/*
+ * QNames handling.
+ */
+
+XSLTPUBFUN const xmlChar * XSLTCALL
+               xsltSplitQName                  (xmlDictPtr dict,
+                                                const xmlChar *name,
+                                                const xmlChar **prefix);
+XSLTPUBFUN const xmlChar * XSLTCALL 
+               xsltGetQNameURI                 (xmlNodePtr node,
+                                                xmlChar **name);
+
+XSLTPUBFUN const xmlChar * XSLTCALL
+               xsltGetQNameURI2                (xsltStylesheetPtr style,
+                                                xmlNodePtr node,
+                                                const xmlChar **name);
+
+/*
+ * Output, reuse libxml I/O buffers.
+ */
+XSLTPUBFUN int XSLTCALL                
+               xsltSaveResultTo                (xmlOutputBufferPtr buf,
+                                                xmlDocPtr result,
+                                                xsltStylesheetPtr style);
+XSLTPUBFUN int XSLTCALL                
+               xsltSaveResultToFilename        (const char *URI,
+                                                xmlDocPtr result,
+                                                xsltStylesheetPtr style,
+                                                int compression);
+XSLTPUBFUN int XSLTCALL                
+               xsltSaveResultToFile            (FILE *file,
+                                                xmlDocPtr result,
+                                                xsltStylesheetPtr style);
+XSLTPUBFUN int XSLTCALL                
+               xsltSaveResultToFd              (int fd,
+                                                xmlDocPtr result,
+                                                xsltStylesheetPtr style);
+XSLTPUBFUN int XSLTCALL             
+               xsltSaveResultToString          (xmlChar **doc_txt_ptr, 
+                                                 int * doc_txt_len, 
+                                                 xmlDocPtr result, 
+                                                 xsltStylesheetPtr style);
+
+/*
+ * XPath interface
+ */
+XSLTPUBFUN xmlXPathCompExprPtr XSLTCALL
+               xsltXPathCompile                (xsltStylesheetPtr style,
+                                                const xmlChar *str);
+
+/*
+ * Profiling.
+ */
+XSLTPUBFUN void XSLTCALL               
+               xsltSaveProfiling               (xsltTransformContextPtr ctxt,
+                                                FILE *output);
+XSLTPUBFUN xmlDocPtr XSLTCALL  
+               xsltGetProfileInformation       (xsltTransformContextPtr ctxt);
+
+XSLTPUBFUN long XSLTCALL               
+               xsltTimestamp                   (void);
+XSLTPUBFUN void XSLTCALL               
+               xsltCalibrateAdjust             (long delta);
+
+/**
+ * XSLT_TIMESTAMP_TICS_PER_SEC:
+ *
+ * Sampling precision for profiling
+ */
+#define XSLT_TIMESTAMP_TICS_PER_SEC 100000l
+
+/*
+ * Hooks for the debugger.
+ */
+
+typedef enum {
+    XSLT_DEBUG_NONE = 0, /* no debugging allowed */
+    XSLT_DEBUG_INIT,
+    XSLT_DEBUG_STEP,
+    XSLT_DEBUG_STEPOUT,
+    XSLT_DEBUG_NEXT,
+    XSLT_DEBUG_STOP,
+    XSLT_DEBUG_CONT,
+    XSLT_DEBUG_RUN,
+    XSLT_DEBUG_RUN_RESTART,
+    XSLT_DEBUG_QUIT
+} xsltDebugStatusCodes;
+
+XSLTPUBVAR int xslDebugStatus;
+
+typedef void (*xsltHandleDebuggerCallback) (xmlNodePtr cur, xmlNodePtr node,
+                       xsltTemplatePtr templ, xsltTransformContextPtr ctxt);
+typedef int (*xsltAddCallCallback) (xsltTemplatePtr templ, xmlNodePtr source);
+typedef void (*xsltDropCallCallback) (void);
+
+XSLTPUBFUN void XSLTCALL
+               xsltSetDebuggerStatus           (int value);
+XSLTPUBFUN int XSLTCALL
+               xsltGetDebuggerStatus           (void);
+XSLTPUBFUN int XSLTCALL                
+               xsltSetDebuggerCallbacks        (int no, void *block);
+XSLTPUBFUN int XSLTCALL                
+               xslAddCall                      (xsltTemplatePtr templ,
+                                                xmlNodePtr source);
+XSLTPUBFUN void XSLTCALL               
+               xslDropCall                     (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLTUTILS_H__ */
+
+
index 125807f..f3939e3 100644 (file)
 /* #undef HAVE_LIBXSLT */
 
 /* Define to 1 if you have the <libxslt/pattern.h> header file. */
-/* #undef HAVE_LIBXSLT_PATTERN_H */
+#define HAVE_LIBXSLT_PATTERN_H
 
 /* Define to 1 if you have the <libxslt/transform.h> header file. */
-/* #undef HAVE_LIBXSLT_TRANSFORM_H */
+#define HAVE_LIBXSLT_TRANSFORM_H
 
 /* Define if you have the Xxf86dga library version 2 */
 /* #undef HAVE_LIBXXF86DGA2 */
 /* Define to the soname of the libXrender library. */
 /* #undef SONAME_LIBXRENDER */
 
+/* Define to the soname of the libxslt library. */
+#define SONAME_LIBXSLT "libxslt"
+
 /* Define if the struct statfs is defined by <sys/mount.h> */
 /* #undef STATFS_DEFINED_BY_SYS_MOUNT */
 
index 8c4fb0a..f423ba3 100644 (file)
@@ -42,9 +42,9 @@ extern void wine_exec_wine_binary( const char *name, char **argv, char **envp, i
 
 typedef void (*load_dll_callback_t)( void *, const char * );
 
-extern void *wine_dlopen( const char *filename, int flag, char *error, int errorsize );
-extern void *wine_dlsym( void *handle, const char *symbol, char *error, int errorsize );
-extern int wine_dlclose( void *handle, char *error, int errorsize );
+extern void *wine_dlopen( const char *filename, int flag, char *error, size_t errorsize );
+extern void *wine_dlsym( void *handle, const char *symbol, char *error, size_t errorsize );
+extern int wine_dlclose( void *handle, char *error, size_t errorsize );
 extern void wine_dll_set_callback( load_dll_callback_t load );
 extern void *wine_dll_load( const char *filename, char *error, int errorsize, int *file_exists );
 extern void *wine_dll_load_main_exe( const char *name, char *error, int errorsize,
index 9ab8901..f12b530 100644 (file)
@@ -1,10 +1,19 @@
 <?xml version="1.0"?>
 <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
+<group>
 <module name="wine" type="staticlibrary">
        <include base="ReactOS">include/reactos/wine</include>
        <define name="_DISABLE_TIDENTS" />
        <define name="__WINESRC__" />
        <file>config.c</file>
        <file>debug_ros.c</file>
+       <file>loader.c</file>
        <file>string.c</file>
 </module>
+<module name="wineldr" type="staticlibrary">
+       <include base="ReactOS">include/reactos/wine</include>
+       <define name="_DISABLE_TIDENTS" />
+       <define name="__WINESRC__" />
+       <file>loader.c</file>
+</module>
+</group>
\ No newline at end of file
diff --git a/reactos/lib/3rdparty/libwine/loader.c b/reactos/lib/3rdparty/libwine/loader.c
new file mode 100644 (file)
index 0000000..bb6d4b0
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Win32 builtin dlls support
+ *
+ * Copyright 2000 Alexandre Julliard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#include <assert.h>
+#include <ctype.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+#ifdef HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+#include "windef.h"
+#include "winbase.h"
+#include "wine/library.h"
+
+void *wine_dlsym( void *handle, const char *symbol, char *error, size_t errorsize )
+{
+    return GetProcAddress(handle, symbol);
+}
+
+void *wine_dlopen( const char *filename, int flag, char *error, size_t errorsize )
+{
+    return LoadLibraryA(filename);
+}
+
+int wine_dlclose( void *handle, char *error, size_t errorsize )
+{
+    return FreeLibrary(handle);
+}
index a37871e..5b64949 100644 (file)
@@ -1,3 +1,92 @@
+Sun Jan 18 22:37:59 CET 2009 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in doc/xml.html doc/*: preparing 0.7.3 release
+       * include/libxml/parserInternals.h SAX2.c: fix a typo in an name
+
+Sun Jan 18 21:48:28 CET 2009 Daniel Veillard <daniel@veillard.com>
+
+       * include/libxml/parser.h include/libxml/xmlwriter.h
+         include/libxml/relaxng.h include/libxml/xmlversion.h.in
+         include/libxml/xmlwin32version.h.in include/libxml/valid.h
+         include/libxml/xmlschemas.h include/libxml/xmlerror.h:
+         port patch from Marcus Meissner to add gcc checking for
+         printf like functions parameters, should fix #65068
+       * doc/apibuild.py doc/*: modified the script accordingly
+         and regenerated
+       * xpath.c xmlmemory.c threads.c: fix a few warnings
+
+Sun Jan 18 20:40:42 CET 2009 Daniel Veillard <daniel@veillard.com>
+
+       * include/libxml/xmlwin32version.h.in: windows header should
+         get the same define
+
+Sun Jan 18 18:22:33 CET 2009 Daniel Veillard <daniel@veillard.com>
+
+       * include/libxml/xmlversion.h.in include/libxml/xmlmemory.h:
+         apply patch from Marcus Meissner to add gcc attribute alloc_size
+         should fix #552505
+       * doc/apibuild.py doc/* testapi.c: regenerate the API
+       * include/libxml/parserInternals.h: fix a comment problem raised
+         by apibuild.py
+
+Sun Jan 18 16:39:01 CET 2009 Daniel Veillard <daniel@veillard.com>
+
+       * threads.c: also remove pthread key when stopping thread
+         support, patch based on Alex Ott one should fix #564723
+
+Sun Jan 18 15:55:18 CET 2009 Daniel Veillard <daniel@veillard.com>
+
+       * threads.c: patch from Daniel Zimmermann fixing a memory leak
+         in an edge case, solves #562230
+
+Sun Jan 18 15:06:05 CET 2009 Daniel Veillard <daniel@veillard.com>
+
+       * include/libxml/parserInternals.h SAX2.c: add a new define
+         XML_MAX_TEXT_LENGTH limiting the maximum size of a single text
+         node, the defaultis 10MB and can be removed with the HUGE
+         parsing option
+
+Mon Jan 05 18:28:41 CET 2009 Rob Richards <rrichards@cdatazone.org>
+
+       * include/libxml/parser.h parser.c: add XML_PARSE_OLDSAX parser 
+         option to enable pre 2.7 SAX behavior.
+
+Wed Dec 31 23:11:37 CET 2008 Rob Richards <rrichards@cdatazone.org>
+
+       * tree.c: set doc on last child tree in xmlAddChildList for 
+         bug #546772. Fix problem adding an attribute via with xmlAddChild 
+         reported by Kris Breuker.
+
+Sun Dec 27 14:16:13 CET 2008 Rob Richards <rrichards@cdatazone.org>
+
+       * xmlwriter.c: fix indenting in xmlTextWriterFullEndElement for 
+         bug# 554353.
+
+Thu Nov 27 16:24:52 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+       * include/libxml/tree.h tree.c python/generator.py: adds
+         element traversal support
+       * valid.c: avoid a warning
+       * doc/*: regenerated
+
+Mon Nov 17 16:56:18 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+       * SAX2.c parser.c: fix for CVE-2008-4226, a memory overflow
+         when building gigantic text nodes, and a bit of cleanup
+         to better handled out of memory problem in that code.
+       * tree.c: fix for CVE-2008-4225, lack of testing leads to
+         a busy loop test assuming one have enough core memory.
+
+Thu Nov  6 14:34:35 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+       * xmllint.c: Matthias Kaehlcke reported a build problem when
+         not compiling HTML support in.
+
+Fri Oct 17 15:24:08 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in doc/Makefile.am: patch from Adrian Bunk which
+         adds --disable-rebuild-docs to avoid rebuilding them
+
 Fri Oct  3 09:43:45 CEST 2008 Daniel Veillard <daniel@veillard.com>
 
        * configure.in doc/* NEWS: preparing the release of 2.7.2
index 80cd1bd..164409c 100644 (file)
@@ -11,6 +11,7 @@
 #include "libxml.h"
 #include <stdlib.h>
 #include <string.h>
+#include <limits.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/tree.h>
 #include <libxml/parser.h>
 #include <libxml/HTMLtree.h>
 #include <libxml/globals.h>
 
+/* Define SIZE_T_MAX unless defined through <limits.h>. */
+#ifndef SIZE_T_MAX
+# define SIZE_T_MAX     ((size_t)-1)
+#endif /* !SIZE_T_MAX */
+
 /* #define DEBUG_SAX2 */
 /* #define DEBUG_SAX2_TREE */
 
@@ -2455,9 +2461,19 @@ xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
                       (xmlDictOwns(ctxt->dict, lastChild->content))) {
                lastChild->content = xmlStrdup(lastChild->content);
            }
+            if (((size_t)ctxt->nodelen + (size_t)len > XML_MAX_TEXT_LENGTH) &&
+                ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+                xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: huge text node");
+                return;
+            }
+           if ((size_t)ctxt->nodelen > SIZE_T_MAX - (size_t)len || 
+               (size_t)ctxt->nodemem + (size_t)len > SIZE_T_MAX / 2) {
+                xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters overflow prevented");
+                return;
+           }
            if (ctxt->nodelen + len >= ctxt->nodemem) {
                xmlChar *newbuf;
-               int size;
+               size_t size;
 
                size = ctxt->nodemem + len;
                size *= 2;
index fa9aa59..b6a50ee 100644 (file)
@@ -889,6 +889,8 @@ FFLAGS
 ac_ct_F77
 LIBTOOL
 HTML_DIR
+REBUILD_DOCS_TRUE
+REBUILD_DOCS_FALSE
 Z_CFLAGS
 Z_LIBS
 WITH_ZLIB
@@ -1585,6 +1587,7 @@ Optional Features:
   --enable-fast-install[=PKGS]
                           optimize for fast installation [default=yes]
   --disable-libtool-lock  avoid locking (might break parallel builds)
+  --enable-rebuild-docs[=yes/no]  rebuild some generated docs [default=yes]
   --enable-ipv6[=yes/no]  enables compilation of IPv6 code [default=yes]
 
 Optional Packages:
@@ -2191,7 +2194,7 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
 
 LIBXML_MAJOR_VERSION=2
 LIBXML_MINOR_VERSION=7
-LIBXML_MICRO_VERSION=2
+LIBXML_MICRO_VERSION=3
 LIBXML_MICRO_VERSION_SUFFIX=
 LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION$LIBXML_MICRO_VERSION_SUFFIX
 LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION
@@ -5508,7 +5511,7 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 5511 "configure"' > conftest.$ac_ext
+  echo '#line 5514 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -8062,11 +8065,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8065: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8068: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8069: \$? = $ac_status" >&5
+   echo "$as_me:8072: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8352,11 +8355,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8355: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8358: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8359: \$? = $ac_status" >&5
+   echo "$as_me:8362: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8456,11 +8459,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8459: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8462: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8463: \$? = $ac_status" >&5
+   echo "$as_me:8466: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -10807,7 +10810,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 10810 "configure"
+#line 10813 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10907,7 +10910,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 10910 "configure"
+#line 10913 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13327,11 +13330,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13330: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:13333: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:13334: \$? = $ac_status" >&5
+   echo "$as_me:13337: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -13431,11 +13434,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13434: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:13437: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:13438: \$? = $ac_status" >&5
+   echo "$as_me:13441: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -14995,11 +14998,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14998: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15001: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:15002: \$? = $ac_status" >&5
+   echo "$as_me:15005: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -15099,11 +15102,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15102: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15105: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:15106: \$? = $ac_status" >&5
+   echo "$as_me:15109: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -17288,11 +17291,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:17291: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:17294: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:17295: \$? = $ac_status" >&5
+   echo "$as_me:17298: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -17578,11 +17581,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:17581: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:17584: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:17585: \$? = $ac_status" >&5
+   echo "$as_me:17588: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -17682,11 +17685,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:17685: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:17688: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:17689: \$? = $ac_status" >&5
+   echo "$as_me:17692: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -20588,6 +20591,20 @@ if test "${with_coverage+set}" = set; then
 fi
 
 
+# Check whether --enable-rebuild-docs was given.
+if test "${enable_rebuild_docs+set}" = set; then
+  enableval=$enable_rebuild_docs;
+fi
+
+ if test "$enable_rebuild_docs" = "no"; then
+  REBUILD_DOCS_TRUE=
+  REBUILD_DOCS_FALSE='#'
+else
+  REBUILD_DOCS_TRUE='#'
+  REBUILD_DOCS_FALSE=
+fi
+
+
 if test "$with_schemas" = "yes"
 then
     with_pattern=yes
@@ -26662,7 +26679,7 @@ fi
 { echo "$as_me:$LINENO: checking for type of socket length (socklen_t)" >&5
 echo $ECHO_N "checking for type of socket length (socklen_t)... $ECHO_C" >&6; }
 cat > conftest.$ac_ext <<EOF
-#line 26665 "configure"
+#line 26682 "configure"
 #include "confdefs.h"
 
 #include <stddef.h>
@@ -26673,7 +26690,7 @@ int main(void) {
 (void)getsockopt (1, 1, 1, NULL, (socklen_t *)NULL)
 ; return 0; }
 EOF
-if { (eval echo configure:26676: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; _out=`eval $ac_compile 2>&1` && test "x$_out" = x; }; then
+if { (eval echo configure:26693: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; _out=`eval $ac_compile 2>&1` && test "x$_out" = x; }; then
   rm -rf conftest*
 
   { echo "$as_me:$LINENO: result: socklen_t *" >&5
@@ -26685,7 +26702,7 @@ else
   rm -rf conftest*
 
   cat > conftest.$ac_ext <<EOF
-#line 26688 "configure"
+#line 26705 "configure"
 #include "confdefs.h"
 
 #include <stddef.h>
@@ -26696,7 +26713,7 @@ int main(void) {
 (void)getsockopt (1, 1, 1, NULL, (size_t *)NULL)
 ; return 0; }
 EOF
-if { (eval echo configure:26699: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; _out=`eval $ac_compile 2>&1` && test "x$_out" = x; }; then
+if { (eval echo configure:26716: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; _out=`eval $ac_compile 2>&1` && test "x$_out" = x; }; then
   rm -rf conftest*
 
     { echo "$as_me:$LINENO: result: size_t *" >&5
@@ -26708,7 +26725,7 @@ else
   rm -rf conftest*
 
     cat > conftest.$ac_ext <<EOF
-#line 26711 "configure"
+#line 26728 "configure"
 #include "confdefs.h"
 
 #include <stddef.h>
@@ -26719,7 +26736,7 @@ int main(void) {
 (void)getsockopt (1, 1, 1, NULL, (int *)NULL)
 ; return 0; }
 EOF
-if { (eval echo configure:26722: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; _out=`eval $ac_compile 2>&1` && test "x$_out" = x; }; then
+if { (eval echo configure:26739: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; _out=`eval $ac_compile 2>&1` && test "x$_out" = x; }; then
   rm -rf conftest*
 
       { echo "$as_me:$LINENO: result: int *" >&5
@@ -29703,6 +29720,13 @@ echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${REBUILD_DOCS_TRUE}" && test -z "${REBUILD_DOCS_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"REBUILD_DOCS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"REBUILD_DOCS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 if test -z "${WITH_PYTHON_TRUE}" && test -z "${WITH_PYTHON_FALSE}"; then
   { { echo "$as_me:$LINENO: error: conditional \"WITH_PYTHON\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
@@ -30427,6 +30451,8 @@ FFLAGS!$FFLAGS$ac_delim
 ac_ct_F77!$ac_ct_F77$ac_delim
 LIBTOOL!$LIBTOOL$ac_delim
 HTML_DIR!$HTML_DIR$ac_delim
+REBUILD_DOCS_TRUE!$REBUILD_DOCS_TRUE$ac_delim
+REBUILD_DOCS_FALSE!$REBUILD_DOCS_FALSE$ac_delim
 Z_CFLAGS!$Z_CFLAGS$ac_delim
 Z_LIBS!$Z_LIBS$ac_delim
 WITH_ZLIB!$WITH_ZLIB$ac_delim
@@ -30497,8 +30523,6 @@ WITH_SCHEMAS!$WITH_SCHEMAS$ac_delim
 TEST_SCHEMAS!$TEST_SCHEMAS$ac_delim
 WITH_REGEXPS!$WITH_REGEXPS$ac_delim
 TEST_REGEXPS!$TEST_REGEXPS$ac_delim
-WITH_DEBUG!$WITH_DEBUG$ac_delim
-DEBUG_OBJ!$DEBUG_OBJ$ac_delim
 _ACEOF
 
   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -30540,6 +30564,8 @@ _ACEOF
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   cat >conf$$subs.sed <<_ACEOF
+WITH_DEBUG!$WITH_DEBUG$ac_delim
+DEBUG_OBJ!$DEBUG_OBJ$ac_delim
 TEST_DEBUG!$TEST_DEBUG$ac_delim
 WITH_MEM_DEBUG!$WITH_MEM_DEBUG$ac_delim
 WITH_RUN_DEBUG!$WITH_RUN_DEBUG$ac_delim
@@ -30566,7 +30592,7 @@ LIBOBJS!$LIBOBJS$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 24; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 26; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
index 04f363f..1ac2316 100644 (file)
@@ -5,7 +5,7 @@ AC_CANONICAL_HOST
 
 LIBXML_MAJOR_VERSION=2
 LIBXML_MINOR_VERSION=7
-LIBXML_MICRO_VERSION=2
+LIBXML_MICRO_VERSION=3
 LIBXML_MICRO_VERSION_SUFFIX=
 LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION$LIBXML_MICRO_VERSION_SUFFIX
 LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION
@@ -166,6 +166,10 @@ AC_ARG_WITH(zlib,
 AC_ARG_WITH(coverage,
 [  --with-coverage         build for code coverage with GCC (off)])
 
+AC_ARG_ENABLE(rebuild-docs,
+[  --enable-rebuild-docs[[=yes/no]]  rebuild some generated docs [[default=yes]]])
+AM_CONDITIONAL([REBUILD_DOCS], [test "$enable_rebuild_docs" = "no"])
+
 dnl
 dnl hard dependancies on options
 dnl
index a747fca..14cad6d 100644 (file)
@@ -1991,6 +1991,18 @@ extern __typeof (xmlCheckVersion) xmlCheckVersion__internal_alias __attribute((v
 #endif
 #endif
 
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlChildElementCount
+extern __typeof (xmlChildElementCount) xmlChildElementCount __attribute((alias("xmlChildElementCount__internal_alias")));
+#else
+#ifndef xmlChildElementCount
+extern __typeof (xmlChildElementCount) xmlChildElementCount__internal_alias __attribute((visibility("hidden")));
+#define xmlChildElementCount xmlChildElementCount__internal_alias
+#endif
+#endif
+#endif
+
 #ifdef bottom_encoding
 #undef xmlCleanupCharEncodingHandlers
 extern __typeof (xmlCleanupCharEncodingHandlers) xmlCleanupCharEncodingHandlers __attribute((alias("xmlCleanupCharEncodingHandlers__internal_alias")));
@@ -3419,6 +3431,18 @@ extern __typeof (xmlFindCharEncodingHandler) xmlFindCharEncodingHandler__interna
 #endif
 #endif
 
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlFirstElementChild
+extern __typeof (xmlFirstElementChild) xmlFirstElementChild __attribute((alias("xmlFirstElementChild__internal_alias")));
+#else
+#ifndef xmlFirstElementChild
+extern __typeof (xmlFirstElementChild) xmlFirstElementChild__internal_alias __attribute((visibility("hidden")));
+#define xmlFirstElementChild xmlFirstElementChild__internal_alias
+#endif
+#endif
+#endif
+
 #ifdef bottom_valid
 #undef xmlFreeAttributeTable
 extern __typeof (xmlFreeAttributeTable) xmlFreeAttributeTable __attribute((alias("xmlFreeAttributeTable__internal_alias")));
@@ -4759,6 +4783,18 @@ extern __typeof (xmlKeepBlanksDefault) xmlKeepBlanksDefault__internal_alias __at
 #endif
 #endif
 
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlLastElementChild
+extern __typeof (xmlLastElementChild) xmlLastElementChild __attribute((alias("xmlLastElementChild__internal_alias")));
+#else
+#ifndef xmlLastElementChild
+extern __typeof (xmlLastElementChild) xmlLastElementChild__internal_alias __attribute((visibility("hidden")));
+#define xmlLastElementChild xmlLastElementChild__internal_alias
+#endif
+#endif
+#endif
+
 #ifdef bottom_parserInternals
 #undef xmlLineNumbersDefault
 extern __typeof (xmlLineNumbersDefault) xmlLineNumbersDefault __attribute((alias("xmlLineNumbersDefault__internal_alias")));
@@ -5161,6 +5197,16 @@ extern __typeof (xmlMemDisplay) xmlMemDisplay__internal_alias __attribute((visib
 #endif
 #endif
 
+#ifdef bottom_xmlmemory
+#undef xmlMemDisplayLast
+extern __typeof (xmlMemDisplayLast) xmlMemDisplayLast __attribute((alias("xmlMemDisplayLast__internal_alias")));
+#else
+#ifndef xmlMemDisplayLast
+extern __typeof (xmlMemDisplayLast) xmlMemDisplayLast__internal_alias __attribute((visibility("hidden")));
+#define xmlMemDisplayLast xmlMemDisplayLast__internal_alias
+#endif
+#endif
+
 #ifdef bottom_xmlmemory
 #undef xmlMemFree
 extern __typeof (xmlMemFree) xmlMemFree __attribute((alias("xmlMemFree__internal_alias")));
@@ -6043,6 +6089,16 @@ extern __typeof (xmlNewElementContent) xmlNewElementContent__internal_alias __at
 #endif
 #endif
 
+#ifdef bottom_entities
+#undef xmlNewEntity
+extern __typeof (xmlNewEntity) xmlNewEntity __attribute((alias("xmlNewEntity__internal_alias")));
+#else
+#ifndef xmlNewEntity
+extern __typeof (xmlNewEntity) xmlNewEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlNewEntity xmlNewEntity__internal_alias
+#endif
+#endif
+
 #ifdef bottom_parserInternals
 #undef xmlNewEntityInputStream
 extern __typeof (xmlNewEntityInputStream) xmlNewEntityInputStream __attribute((alias("xmlNewEntityInputStream__internal_alias")));
@@ -6367,6 +6423,18 @@ extern __typeof (xmlNextChar) xmlNextChar__internal_alias __attribute((visibilit
 #endif
 #endif
 
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlNextElementSibling
+extern __typeof (xmlNextElementSibling) xmlNextElementSibling __attribute((alias("xmlNextElementSibling__internal_alias")));
+#else
+#ifndef xmlNextElementSibling
+extern __typeof (xmlNextElementSibling) xmlNextElementSibling__internal_alias __attribute((visibility("hidden")));
+#define xmlNextElementSibling xmlNextElementSibling__internal_alias
+#endif
+#endif
+#endif
+
 #ifdef bottom_xmlIO
 #undef xmlNoNetExternalEntityLoader
 extern __typeof (xmlNoNetExternalEntityLoader) xmlNoNetExternalEntityLoader __attribute((alias("xmlNoNetExternalEntityLoader__internal_alias")));
@@ -7769,6 +7837,18 @@ extern __typeof (xmlPopInputCallbacks) xmlPopInputCallbacks__internal_alias __at
 #endif
 #endif
 
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlPreviousElementSibling
+extern __typeof (xmlPreviousElementSibling) xmlPreviousElementSibling __attribute((alias("xmlPreviousElementSibling__internal_alias")));
+#else
+#ifndef xmlPreviousElementSibling
+extern __typeof (xmlPreviousElementSibling) xmlPreviousElementSibling__internal_alias __attribute((visibility("hidden")));
+#define xmlPreviousElementSibling xmlPreviousElementSibling__internal_alias
+#endif
+#endif
+#endif
+
 #ifdef bottom_uri
 #undef xmlPrintURI
 extern __typeof (xmlPrintURI) xmlPrintURI __attribute((alias("xmlPrintURI__internal_alias")));
index dd4338a..14d3f8a 100644 (file)
@@ -7,7 +7,6 @@
        <define name="_MBCS" />
        <define name="HAVE_WIN32_THREADS" />
        <define name="_REENTRANT" />
-       <define name="_WINSOCKAPI_" />
        <define name="LIBXML_STATIC" />
        <include base="libxml2">include</include>
        <include base="libxml2">.</include>
index a6da308..ace05f6 100644 (file)
@@ -1,6 +1,6 @@
 Summary: Library providing XML and HTML support
 Name: libxml2
-Version: 2.7.2
+Version: 2.7.3
 Release: 1
 License: MIT
 Group: Development/Libraries
@@ -128,6 +128,6 @@ rm -fr %{buildroot}
 %doc doc/python.html
 
 %changelog
-* Fri Oct  3 2008 Daniel Veillard <veillard@redhat.com>
-- upstream release 2.7.2 see http://xmlsoft.org/news.html
+* Sun Jan 18 2009 Daniel Veillard <veillard@redhat.com>
+- upstream release 2.7.3 see http://xmlsoft.org/news.html
 
index 4b7b758..9db664f 100644 (file)
@@ -4142,6 +4142,9 @@ get_more:
                     line = ctxt->input->line;
                     col = ctxt->input->col;
                }
+                /* something really bad happened in the SAX callback */
+                if (ctxt->instate != XML_PARSER_CONTENT)
+                    return;
            }
            ctxt->input->cur = in;
            if (*in == 0xD) {
@@ -4222,6 +4225,9 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) {
                }
            }
            nbchar = 0;
+            /* something really bad happened in the SAX callback */
+            if (ctxt->instate != XML_PARSER_CONTENT)
+                return;
        }
        count++;
        if (count > 50) {
@@ -7041,9 +7047,11 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
     /*
      * Predefined entites override any extra definition
      */
-    ent = xmlGetPredefinedEntity(name);
-    if (ent != NULL)
-        return(ent);
+    if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {
+        ent = xmlGetPredefinedEntity(name);
+        if (ent != NULL)
+            return(ent);
+    }
 
     /*
      * Increate the number of entity references parsed
@@ -7057,6 +7065,9 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
     if (ctxt->sax != NULL) {
        if (ctxt->sax->getEntity != NULL)
            ent = ctxt->sax->getEntity(ctxt->userData, name);
+       if ((ctxt->wellFormed == 1 ) && (ent == NULL) && 
+           (ctxt->options & XML_PARSE_OLDSAX))
+           ent = xmlGetPredefinedEntity(name);
        if ((ctxt->wellFormed == 1 ) && (ent == NULL) &&
            (ctxt->userData==ctxt)) {
            ent = xmlSAX2GetEntity(ctxt, name);
@@ -7129,6 +7140,7 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
      */
     else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
             (ent != NULL) && (ent->content != NULL) &&
+            (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
             (xmlStrchr(ent->content, '<'))) {
        xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
     "'<' in entity '%s' is not allowed in attributes values\n", name);
@@ -7225,11 +7237,13 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
     /*
      * Predefined entites override any extra definition
      */
-    ent = xmlGetPredefinedEntity(name);
-    if (ent != NULL) {
-        xmlFree(name);
-        *str = ptr;
-        return(ent);
+    if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {
+        ent = xmlGetPredefinedEntity(name);
+        if (ent != NULL) {
+            xmlFree(name);
+            *str = ptr;
+            return(ent);
+        }
     }
 
     /*
@@ -7244,6 +7258,8 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
     if (ctxt->sax != NULL) {
        if (ctxt->sax->getEntity != NULL)
            ent = ctxt->sax->getEntity(ctxt->userData, name);
+       if ((ent == NULL) && (ctxt->options & XML_PARSE_OLDSAX))
+           ent = xmlGetPredefinedEntity(name);
        if ((ent == NULL) && (ctxt->userData==ctxt)) {
            ent = xmlSAX2GetEntity(ctxt, name);
        }
@@ -7312,6 +7328,7 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
      */
     else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
             (ent != NULL) && (ent->content != NULL) &&
+            (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
             (xmlStrchr(ent->content, '<'))) {
        xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
      "'<' in entity '%s' is not allowed in attributes values\n",
@@ -14205,6 +14222,10 @@ xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encodi
        ctxt->options |= XML_PARSE_HUGE;
         options -= XML_PARSE_HUGE;
     }
+    if (options & XML_PARSE_OLDSAX) {
+       ctxt->options |= XML_PARSE_OLDSAX;
+        options -= XML_PARSE_OLDSAX;
+    }
     ctxt->linenumbers = 1;
     return (options);
 }
index 6f85910..7a6ba3a 100644 (file)
@@ -19056,6 +19056,40 @@ test_xmlBuildQName(void) {
 }
 
 
+static int
+test_xmlChildElementCount(void) {
+    int test_ret = 0;
+
+#if defined(LIBXML_TREE_ENABLED)
+    int mem_base;
+    unsigned long ret_val;
+    xmlNodePtr parent; /* the parent node */
+    int n_parent;
+
+    for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) {
+        mem_base = xmlMemBlocks();
+        parent = gen_xmlNodePtr(n_parent, 0);
+
+        ret_val = xmlChildElementCount(parent);
+        desret_unsigned_long(ret_val);
+        call_tests++;
+        des_xmlNodePtr(n_parent, parent, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlChildElementCount",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_parent);
+            printf("\n");
+        }
+    }
+    function_tests++;
+#endif
+
+    return(test_ret);
+}
+
+
 static int
 test_xmlCopyDoc(void) {
     int test_ret = 0;
@@ -20170,6 +20204,40 @@ test_xmlElemDump(void) {
 }
 
 
+static int
+test_xmlFirstElementChild(void) {
+    int test_ret = 0;
+
+#if defined(LIBXML_TREE_ENABLED)
+    int mem_base;
+    xmlNodePtr ret_val;
+    xmlNodePtr parent; /* the parent node */
+    int n_parent;
+
+    for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) {
+        mem_base = xmlMemBlocks();
+        parent = gen_xmlNodePtr(n_parent, 0);
+
+        ret_val = xmlFirstElementChild(parent);
+        desret_xmlNodePtr(ret_val);
+        call_tests++;
+        des_xmlNodePtr(n_parent, parent, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlFirstElementChild",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_parent);
+            printf("\n");
+        }
+    }
+    function_tests++;
+#endif
+
+    return(test_ret);
+}
+
+
 static int
 test_xmlGetBufferAllocationScheme(void) {
     int test_ret = 0;
@@ -20672,6 +20740,40 @@ test_xmlIsXHTML(void) {
 }
 
 
+static int
+test_xmlLastElementChild(void) {
+    int test_ret = 0;
+
+#if defined(LIBXML_TREE_ENABLED)
+    int mem_base;
+    xmlNodePtr ret_val;
+    xmlNodePtr parent; /* the parent node */
+    int n_parent;
+
+    for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) {
+        mem_base = xmlMemBlocks();
+        parent = gen_xmlNodePtr(n_parent, 0);
+
+        ret_val = xmlLastElementChild(parent);
+        desret_xmlNodePtr(ret_val);
+        call_tests++;
+        des_xmlNodePtr(n_parent, parent, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlLastElementChild",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_parent);
+            printf("\n");
+        }
+    }
+    function_tests++;
+#endif
+
+    return(test_ret);
+}
+
+
 static int
 test_xmlNewCDataBlock(void) {
     int test_ret = 0;
@@ -21831,6 +21933,40 @@ test_xmlNewTextLen(void) {
 }
 
 
+static int
+test_xmlNextElementSibling(void) {
+    int test_ret = 0;
+
+#if defined(LIBXML_TREE_ENABLED)
+    int mem_base;
+    xmlNodePtr ret_val;
+    xmlNodePtr node; /* the current node */
+    int n_node;
+
+    for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) {
+        mem_base = xmlMemBlocks();
+        node = gen_xmlNodePtr(n_node, 0);
+
+        ret_val = xmlNextElementSibling(node);
+        desret_xmlNodePtr(ret_val);
+        call_tests++;
+        des_xmlNodePtr(n_node, node, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlNextElementSibling",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_node);
+            printf("\n");
+        }
+    }
+    function_tests++;
+#endif
+
+    return(test_ret);
+}
+
+
 static int
 test_xmlNodeAddContent(void) {
     int test_ret = 0;
@@ -22580,6 +22716,40 @@ test_xmlNodeSetSpacePreserve(void) {
 }
 
 
+static int
+test_xmlPreviousElementSibling(void) {
+    int test_ret = 0;
+
+#if defined(LIBXML_TREE_ENABLED)
+    int mem_base;
+    xmlNodePtr ret_val;
+    xmlNodePtr node; /* the current node */
+    int n_node;
+
+    for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) {
+        mem_base = xmlMemBlocks();
+        node = gen_xmlNodePtr(n_node, 0);
+
+        ret_val = xmlPreviousElementSibling(node);
+        desret_xmlNodePtr(ret_val);
+        call_tests++;
+        des_xmlNodePtr(n_node, node, 0);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in xmlPreviousElementSibling",
+                  xmlMemBlocks() - mem_base);
+           test_ret++;
+            printf(" %d", n_node);
+            printf("\n");
+        }
+    }
+    function_tests++;
+#endif
+
+    return(test_ret);
+}
+
+
 static int
 test_xmlReconciliateNs(void) {
     int test_ret = 0;
@@ -23845,7 +24015,7 @@ static int
 test_tree(void) {
     int test_ret = 0;
 
-    if (quiet == 0) printf("Testing tree : 133 of 152 functions ...\n");
+    if (quiet == 0) printf("Testing tree : 138 of 157 functions ...\n");
     test_ret += test_xmlAddChild();
     test_ret += test_xmlAddChildList();
     test_ret += test_xmlAddNextSibling();
@@ -23870,6 +24040,7 @@ test_tree(void) {
     test_ret += test_xmlBufferWriteChar();
     test_ret += test_xmlBufferWriteQuotedString();
     test_ret += test_xmlBuildQName();
+    test_ret += test_xmlChildElementCount();
     test_ret += test_xmlCopyDoc();
     test_ret += test_xmlCopyDtd();
     test_ret += test_xmlCopyNamespace();
@@ -23895,6 +24066,7 @@ test_tree(void) {
     test_ret += test_xmlDocGetRootElement();
     test_ret += test_xmlDocSetRootElement();
     test_ret += test_xmlElemDump();
+    test_ret += test_xmlFirstElementChild();
     test_ret += test_xmlGetBufferAllocationScheme();
     test_ret += test_xmlGetCompressMode();
     test_ret += test_xmlGetDocCompressMode();
@@ -23910,6 +24082,7 @@ test_tree(void) {
     test_ret += test_xmlHasProp();
     test_ret += test_xmlIsBlankNode();
     test_ret += test_xmlIsXHTML();
+    test_ret += test_xmlLastElementChild();
     test_ret += test_xmlNewCDataBlock();
     test_ret += test_xmlNewCharRef();
     test_ret += test_xmlNewChild();
@@ -23936,6 +24109,7 @@ test_tree(void) {
     test_ret += test_xmlNewText();
     test_ret += test_xmlNewTextChild();
     test_ret += test_xmlNewTextLen();
+    test_ret += test_xmlNextElementSibling();
     test_ret += test_xmlNodeAddContent();
     test_ret += test_xmlNodeAddContentLen();
     test_ret += test_xmlNodeBufGetContent();
@@ -23954,6 +24128,7 @@ test_tree(void) {
     test_ret += test_xmlNodeSetLang();
     test_ret += test_xmlNodeSetName();
     test_ret += test_xmlNodeSetSpacePreserve();
+    test_ret += test_xmlPreviousElementSibling();
     test_ret += test_xmlReconciliateNs();
     test_ret += test_xmlRemoveProp();
     test_ret += test_xmlReplaceNode();
@@ -25969,9 +26144,9 @@ test_xmlValidateAttributeValue(void) {
 #if defined(LIBXML_VALID_ENABLED)
     int mem_base;
     int ret_val;
-    xmlAttributeType type; /*  */
+    xmlAttributeType type; /* an attribute type */
     int n_type;
-    xmlChar * value; /*  */
+    xmlChar * value; /* an attribute value */
     int n_value;
 
     for (n_type = 0;n_type < gen_nb_xmlAttributeType;n_type++) {
index e7dd417..1fd67b3 100644 (file)
@@ -63,6 +63,8 @@ extern int pthread_setspecific (pthread_key_t __key,
 extern int pthread_key_create (pthread_key_t *__key,
                                void (*__destr_function) (void *))
           __attribute((weak));
+extern int pthread_key_delete (pthread_key_t __key)
+          __attribute((weak));
 extern int pthread_mutex_init ()
           __attribute((weak));
 extern int pthread_mutex_destroy ()
@@ -83,6 +85,8 @@ extern pthread_t pthread_self ()
           __attribute((weak));
 extern int pthread_key_create ()
           __attribute((weak));
+extern int pthread_key_delete ()
+          __attribute((weak));
 extern int pthread_cond_signal ()
           __attribute((weak));
 #endif
@@ -698,6 +702,7 @@ xmlGetGlobalState(void)
        if (p == NULL) {
             xmlGenericError(xmlGenericErrorContext,
                             "xmlGetGlobalState: out of memory\n");
+            xmlFreeGlobalState(tsd);
            return(NULL);
        }
         p->memory = tsd;
@@ -859,6 +864,7 @@ xmlInitThreads(void)
             (pthread_getspecific != NULL) &&
             (pthread_setspecific != NULL) &&
             (pthread_key_create != NULL) &&
+            (pthread_key_delete != NULL) &&
             (pthread_mutex_init != NULL) &&
             (pthread_mutex_destroy != NULL) &&
             (pthread_mutex_lock != NULL) &&
@@ -912,6 +918,9 @@ xmlCleanupThreads(void)
         globalkey = TLS_OUT_OF_INDEXES;
     }
     DeleteCriticalSection(&cleanup_helpers_cs);
+#elif defined HAVE_PTHREAD_H
+    if ((libxml_is_threaded)  && (pthread_key_delete != NULL))
+        pthread_key_delete(globalkey);
 #endif
 }
 
index 76926fd..8e393da 100644 (file)
@@ -14,7 +14,7 @@
 #include "libxml.h"
 
 #include <string.h> /* for memset() only ! */
-
+#include <limits.h>
 #ifdef HAVE_CTYPE_H
 #include <ctype.h>
 #endif
@@ -3216,7 +3216,10 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
         cur = cur->next;
     }
     cur->parent = parent;
-    cur->doc = parent->doc; /* the parent may not be linked to a doc ! */
+    /* the parent may not be linked to a doc ! */
+    if (cur->doc != parent->doc) {
+        xmlSetTreeDoc(cur, parent->doc);
+    }
     parent->last = cur;
 
     return(cur);
@@ -3309,9 +3312,7 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
     if (cur->type == XML_ATTRIBUTE_NODE) {
                if (parent->type != XML_ELEMENT_NODE)
                        return(NULL);
-       if (parent->properties == NULL) {
-           parent->properties = (xmlAttrPtr) cur;
-       } else {
+       if (parent->properties != NULL) {
            /* check if an attribute with the same name exists */
            xmlAttrPtr lastattr;
 
@@ -3326,8 +3327,13 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
            }
                if (lastattr == (xmlAttrPtr) cur)
                        return(cur);
+
+       }
+       if (parent->properties == NULL) {
+           parent->properties = (xmlAttrPtr) cur;
+       } else {
            /* find the end */
-           lastattr = parent->properties;
+           xmlAttrPtr lastattr = parent->properties;
            while (lastattr->next != NULL) {
                lastattr = lastattr->next;
            }
@@ -3367,6 +3373,199 @@ xmlGetLastChild(xmlNodePtr parent) {
     return(parent->last);
 }
 
+#ifdef LIBXML_TREE_ENABLED
+/*
+ * 5 interfaces from DOM ElementTraversal
+ */
+
+/**
+ * xmlChildElementCount:
+ * @parent: the parent node
+ *
+ * Finds the current number of child nodes of that element which are
+ * element nodes.
+ * Note the handling of entities references is different than in
+ * the W3C DOM element traversal spec since we don't have back reference
+ * from entities content to entities references.
+ *
+ * Returns the count of element child or 0 if not available
+ */
+unsigned long
+xmlChildElementCount(xmlNodePtr parent) {
+    unsigned long ret = 0;
+    xmlNodePtr cur = NULL;
+
+    if (parent == NULL)
+        return(0);
+    switch (parent->type) {
+        case XML_ELEMENT_NODE:
+        case XML_ENTITY_NODE:
+        case XML_DOCUMENT_NODE:
+        case XML_HTML_DOCUMENT_NODE:
+            cur = parent->children;
+            break;
+        default:
+            return(0);
+    }
+    while (cur != NULL) {
+        if (cur->type == XML_ELEMENT_NODE)
+            ret++;
+        cur = cur->next;
+    }
+    return(ret);
+}
+
+/**
+ * xmlFirstElementChild:
+ * @parent: the parent node
+ *
+ * Finds the first child node of that element which is a Element node
+ * Note the handling of entities references is different than in
+ * the W3C DOM element traversal spec since we don't have back reference
+ * from entities content to entities references.
+ *
+ * Returns the first element child or NULL if not available
+ */
+xmlNodePtr
+xmlFirstElementChild(xmlNodePtr parent) {
+    xmlNodePtr cur = NULL;
+
+    if (parent == NULL)
+        return(NULL);
+    switch (parent->type) {
+        case XML_ELEMENT_NODE:
+        case XML_ENTITY_NODE:
+        case XML_DOCUMENT_NODE:
+        case XML_HTML_DOCUMENT_NODE:
+            cur = parent->children;
+            break;
+        default:
+            return(NULL);
+    }
+    while (cur != NULL) {
+        if (cur->type == XML_ELEMENT_NODE)
+            return(cur);
+        cur = cur->next;
+    }
+    return(NULL);
+}
+
+/**
+ * xmlLastElementChild:
+ * @parent: the parent node
+ *
+ * Finds the last child node of that element which is a Element node
+ * Note the handling of entities references is different than in
+ * the W3C DOM element traversal spec since we don't have back reference
+ * from entities content to entities references.
+ *
+ * Returns the last element child or NULL if not available
+ */
+xmlNodePtr
+xmlLastElementChild(xmlNodePtr parent) {
+    xmlNodePtr cur = NULL;
+
+    if (parent == NULL)
+        return(NULL);
+    switch (parent->type) {
+        case XML_ELEMENT_NODE:
+        case XML_ENTITY_NODE:
+        case XML_DOCUMENT_NODE:
+        case XML_HTML_DOCUMENT_NODE:
+            cur = parent->last;
+            break;
+        default:
+            return(NULL);
+    }
+    while (cur != NULL) {
+        if (cur->type == XML_ELEMENT_NODE)
+            return(cur);
+        cur = cur->prev;
+    }
+    return(NULL);
+}
+
+/**
+ * xmlPreviousElementSibling:
+ * @node: the current node
+ *
+ * Finds the first closest previous sibling of the node which is an
+ * element node.
+ * Note the handling of entities references is different than in
+ * the W3C DOM element traversal spec since we don't have back reference
+ * from entities content to entities references.
+ *
+ * Returns the previous element sibling or NULL if not available
+ */
+xmlNodePtr
+xmlPreviousElementSibling(xmlNodePtr node) {
+    if (node == NULL)
+        return(NULL);
+    switch (node->type) {
+        case XML_ELEMENT_NODE:
+        case XML_TEXT_NODE:
+        case XML_CDATA_SECTION_NODE:
+        case XML_ENTITY_REF_NODE:
+        case XML_ENTITY_NODE:
+        case XML_PI_NODE:
+        case XML_COMMENT_NODE:
+        case XML_XINCLUDE_START:
+        case XML_XINCLUDE_END:
+            node = node->prev;
+            break;
+        default:
+            return(NULL);
+    }
+    while (node != NULL) {
+        if (node->type == XML_ELEMENT_NODE)
+            return(node);
+        node = node->next;
+    }
+    return(NULL);
+}
+
+/**
+ * xmlNextElementSibling:
+ * @node: the current node
+ *
+ * Finds the first closest next sibling of the node which is an
+ * element node.
+ * Note the handling of entities references is different than in
+ * the W3C DOM element traversal spec since we don't have back reference
+ * from entities content to entities references.
+ *
+ * Returns the next element sibling or NULL if not available
+ */
+xmlNodePtr
+xmlNextElementSibling(xmlNodePtr node) {
+    if (node == NULL)
+        return(NULL);
+    switch (node->type) {
+        case XML_ELEMENT_NODE:
+        case XML_TEXT_NODE:
+        case XML_CDATA_SECTION_NODE:
+        case XML_ENTITY_REF_NODE:
+        case XML_ENTITY_NODE:
+        case XML_PI_NODE:
+        case XML_COMMENT_NODE:
+        case XML_DTD_NODE:
+        case XML_XINCLUDE_START:
+        case XML_XINCLUDE_END:
+            node = node->next;
+            break;
+        default:
+            return(NULL);
+    }
+    while (node != NULL) {
+        if (node->type == XML_ELEMENT_NODE)
+            return(node);
+        node = node->next;
+    }
+    return(NULL);
+}
+
+#endif /* LIBXML_TREE_ENABLED */
+
 /**
  * xmlFreeNodeList:
  * @cur:  the first node in the list
@@ -6996,7 +7195,13 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
        case XML_BUFFER_ALLOC_DOUBLEIT:
            /*take care of empty case*/
            newSize = (buf->size ? buf->size*2 : size + 10);
-           while (size > newSize) newSize *= 2;
+           while (size > newSize) {
+               if (newSize > UINT_MAX / 2) {
+                   xmlTreeErrMemory("growing buffer");
+                   return 0;
+               }
+               newSize *= 2;
+           }
            break;
        case XML_BUFFER_ALLOC_EXACT:
            newSize = size+10;
index 49fb720..9baba3b 100644 (file)
@@ -3792,27 +3792,13 @@ xmlValidateNotationDecl(xmlValidCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlDocPtr doc ATT
 }
 
 /**
- * xmlValidateAttributeValue:
+ * xmlValidateAttributeValueInternal:
+ * @doc: the document
  * @type:  an attribute type
  * @value:  an attribute value
  *
  * Validate that the given attribute value match  the proper production
  *
- * [ VC: ID ]
- * Values of type ID must match the Name production....
- *
- * [ VC: IDREF ]
- * Values of type IDREF must match the Name production, and values
- * of type IDREFS must match Names ...
- *
- * [ VC: Entity Name ]
- * Values of type ENTITY must match the Name production, values
- * of type ENTITIES must match Names ...
- *
- * [ VC: Name Token ]
- * Values of type NMTOKEN must match the Nmtoken production; values
- * of type NMTOKENS must match Nmtokens. 
- *
  * returns 1 if valid or 0 otherwise
  */
 
@@ -3839,6 +3825,30 @@ xmlValidateAttributeValueInternal(xmlDocPtr doc, xmlAttributeType type,
     return(1);
 }
 
+/**
+ * xmlValidateAttributeValue:
+ * @type:  an attribute type
+ * @value:  an attribute value
+ *
+ * Validate that the given attribute value match  the proper production
+ *
+ * [ VC: ID ]
+ * Values of type ID must match the Name production....
+ *
+ * [ VC: IDREF ]
+ * Values of type IDREF must match the Name production, and values
+ * of type IDREFS must match Names ...
+ *
+ * [ VC: Entity Name ]
+ * Values of type ENTITY must match the Name production, values
+ * of type ENTITIES must match Names ...
+ *
+ * [ VC: Name Token ]
+ * Values of type NMTOKEN must match the Nmtoken production; values
+ * of type NMTOKENS must match Nmtokens. 
+ *
+ * returns 1 if valid or 0 otherwise
+ */
 int
 xmlValidateAttributeValue(xmlAttributeType type, const xmlChar *value) {
     return(xmlValidateAttributeValueInternal(NULL, type, value));
index 6955fde..77c1e62 100644 (file)
@@ -2753,8 +2753,10 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
 #endif
 
 #ifdef LIBXML_DEBUG_ENABLED
+#if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED)
     if ((debugent) && (!html))
        xmlDebugDumpEntities(stderr, doc);
+#endif
 #endif
 
     /*
index 69d4b85..b88de3a 100644 (file)
@@ -1240,8 +1240,16 @@ xmlTextWriterFullEndElement(xmlTextWriterPtr writer)
             if (count < 0)
                 return -1;
             sum += count;
+            if (writer->indent)
+                writer->doindent = 0;
             /* fallthrough */
         case XML_TEXTWRITER_TEXT:
+            if ((writer->indent) && (writer->doindent)) {
+                count = xmlTextWriterWriteIndent(writer);
+                sum += count;
+                writer->doindent = 1;
+            } else
+                writer->doindent = 1;
             count = xmlOutputBufferWriteString(writer->out, "</");
             if (count < 0)
                 return -1;
index 514262f..57442e6 100644 (file)
@@ -13329,8 +13329,8 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
                     URI = xmlXPathNsLookup(ctxt->context, op->value5);
                     if (URI == NULL) {
                         xmlGenericError(xmlGenericErrorContext,
-                                        "xmlXPathCompOpEval: variable %s bound to undefined prefix %s\n",
-                                        op->value4, op->value5);
+            "xmlXPathCompOpEval: variable %s bound to undefined prefix %s\n",
+                                    (char *) op->value4, (char *)op->value5);
                         return (total);
                     }
                    val = xmlXPathVariableLookupNS(ctxt->context,
@@ -13377,8 +13377,8 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
                         URI = xmlXPathNsLookup(ctxt->context, op->value5);
                         if (URI == NULL) {
                             xmlGenericError(xmlGenericErrorContext,
-                                            "xmlXPathCompOpEval: function %s bound to undefined prefix %s\n",
-                                            op->value4, op->value5);
+            "xmlXPathCompOpEval: function %s bound to undefined prefix %s\n",
+                                    (char *)op->value4, (char *)op->value5);
                             return (total);
                         }
                         func = xmlXPathFunctionLookupNS(ctxt->context,
@@ -13386,8 +13386,8 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
                     }
                     if (func == NULL) {
                         xmlGenericError(xmlGenericErrorContext,
-                                        "xmlXPathCompOpEval: function %s not found\n",
-                                        op->value4);
+                                "xmlXPathCompOpEval: function %s not found\n",
+                                        (char *)op->value4);
                         XP_ERROR0(XPATH_UNKNOWN_FUNC_ERROR);
                     }
                     op->cache = XML_CAST_FPTR(func);