This commit was manufactured by cvs2svn to create tag
'BEFORE_ITERATOR_CHANGES'.

git-svn-id: https://svn.apache.org/repos/asf/xalan/java/tags/BEFORE_ITERATOR_CHANGES@334817 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/KEYS b/KEYS
deleted file mode 100644
index c8683c8..0000000
--- a/KEYS
+++ /dev/null
@@ -1,73 +0,0 @@
-This file contains the PGP keys of various Xalan developers.
-Please don't use them for email unless you have to. Their main
-purpose is code signing.
-
-Xalan users: pgp < KEYS
-Xalan developers: pgp -kxa <your name> and append it to this file.
-
-
-Type Bits/KeyID    Date       User ID
-pub  1024/30A21D55 1999/11/04 Shane Curcuru <shane_curcuru@lotus.com>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: PGP Personal Privacy 6.5.3
-
-mQGiBDghjNIRBADXB4UY4YfZ2DmbSushlzPZCkY00iDPUB+GkW6FQhgnGCLZovgy
-FhCnCsKdN1xyHFq/Ns3PV3HPrMGxFKgVOfRuxREbF8CoXAa/u0qR1WoAm+rlyC9l
-OVsHdXxyOpZ8e4SPGne8LQYZwr2q+LsHiXOZktkaBo8ua8F4EJYkBMFhZQCg/4Iw
-jXmfpt661Essmf8d05cMdAcEAL0r+PrFxCmrU8Ok+r74+eqyclxVbiDbOf7Uef6N
-fEJmC5ihX7p8k8eEf2XepeAo6N0gdOxYVXVwcoRCmqPy7SSg1jnXqKOnA87ylv16
-lOiJ5WUkiVX96WOWEsbbYKuggmWeDL+6iFc9hp6oEP2sf/geC8AEAEHTPfneJzpo
-3z28A/9iX41r4K0iRx5eIJu2KUrjdpPxhn0JPe9dz2XzWZIciNeki+ThrcarEj9h
-lmfvcGLifXbQfXuFid3btMsBRI8dqAbbXmyfvCYYSHDOkXEmoMW66AWfeF4hgfHF
-SA5lmcpH4mtHU69uC0+cvYlRROP+HaeOepYbriA+9A9Qq4MAW7QnU2hhbmUgQ3Vy
-Y3VydSA8c2hhbmVfY3VyY3VydUBsb3R1cy5jb20+iQBOBBARAgAOBQI4IYzSBAsD
-AgECGQEACgkQMuwXWTCiHVXQIQCg1Q1MKkWygIsDGAOhiPaM09pTdlUAniTeCkoO
-I0+2IgD/NtqnGDaSvNDniQBGBBARAgAGBQI4qZk/AAoJEFHrPvFXdlryVbIAoO/e
-gti1esgRI6GErIhICg3IoctfAKDlpw6NWq/WTxk1Aa0pN/1b6fmD5LkCDQQ4IYzS
-EAgA9kJXtwh/CBdyorrWqULzBej5UxE5T7bxbrlLOCDaAadWoxTpj0BV89AHxstD
-qZSt90xkhkn4DIO9ZekX1KHTUPj1WV/cdlJPPT2N286Z4VeSWc39uK50T8X8dryD
-xUcwYc58yWb/Ffm7/ZFexwGq01uejaClcjrUGvC/RgBYK+X0iP1YTknbzSC0neSR
-BzZrM2w4DUUdD3yIsxx8Wy2O9vPJI8BD8KVbGI2Ou1WMuF040zT9fBdXQ6MdGGze
-MyEstSr/POGxKUAYEY18hKcKctaGxAMZyAcpesqVDNmWn6vQClCbAkbTCD1mpF1B
-n5x8vYlLIhkmuquiXsNV6TILOwACAggAzu/QObuykLGwPLCoSQEKfeNSGPOr7wK2
-XSp8c8DS1B2jrVL4oH+PYb6wVhcNd3+Xt4+P/BfllemRU80GD6t/RHoTEZhIhp/3
-8erBLJfLPqFDYdjKf30EMMjFWIhecg9QnZSXU2f7EJ24L+/vnotjAz6hZfJvjb1b
-1tX3PQ1W2e+lTFhSz1RYSKx4msEcez3Z0wValNqWlet3t78cCZRT4fPOkyM4C7Fb
-tK6csvFUXkIfu3qgx4aVk8HUIwXkHZD2W7XiFSPhMtgcPeUAb3AIeYJs/iqP4H4N
-4oJ8B6tXxmpDm3P85PhC4gJOFUThnZKGkLtWwdUago8XSKB5VUA/UIkARgQYEQIA
-BgUCOCGM0gAKCRAy7BdZMKIdVXS+AKDhyJwx048+c7ATINSGf6IxiXQyYQCg46pJ
-/fc0HVWUvHfjioDRaLQUIv8=
-=ut/M
------END PGP PUBLIC KEY BLOCK-----
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: PGP 6.5.8
-
-mQGiBDnjTUMRBADGzi7y1XiTty/HZ1QhRQxMkyf7JD/E5dGXCVLRoSQV9/hdKPtF
-OGzjZQt6DssPnisgrW6hSLEs8GrZKHCZE6z8h5Yekg+WJTs3K0LNJ3X/tStVe/fU
-DarLM7u0qwtcsaISWFMRoy1xbrxBkpFBeNkD+FRUk8sXTVXoOGvm3Fw/8wCg/+pg
-Y7XD6ZIA0m/CxrxR+xTBri8D/Rk4/5rzsT42AImJwAweJidzlmmvWcDGjZolDxrH
-TlVpIXFjGFJBj9tg1Xz+3/w9zKyk900gcwlHU7uz28xPylishgd8DyAb/enSXsEy
-NC1EagypAbMpEhTAdBaUNPb6t8yOX3dHUki5yuZ+PryOyKWTaiHyhHLwJ5vZi9xm
-o+/ZBACqjUqAL27JOC1qw1zrWCQQzEJIeIIdGFEGoMBiFC425vh/1dJA1LUICHSZ
-bZvg7VlvAMErnZb/IcVx4LX4R8Uergh0E/4Xi6krTYZvDuI4RmP5Jn/7IaK2c27I
-lCx7I0hj4CQIWVIEVCDAGjJk9E38VahJYHySHzjMdhXSjTbqW7QnTG90dXN4c2wg
-VGVhbSA8TG90dXN4c2xfVGVhbUBsb3R1cy5jb20+iQBOBBARAgAOBQI5401DBAsD
-AgECGQEACgkQGbnBi2RCw9yVZwCgjxC/ie5/GhPLZyQhMSQvJuDJP8kAn17UNfN/
-tRtFfcJDrNcC7P21ut+VuQINBDnjTUMQCAD2Qle3CH8IF3KiutapQvMF6PlTETlP
-tvFuuUs4INoBp1ajFOmPQFXz0AfGy0OplK33TGSGSfgMg71l6RfUodNQ+PVZX9x2
-Uk89PY3bzpnhV5JZzf24rnRPxfx2vIPFRzBhznzJZv8V+bv9kV7HAarTW56NoKVy
-OtQa8L9GAFgr5fSI/VhOSdvNILSd5JEHNmszbDgNRR0PfIizHHxbLY7288kjwEPw
-pVsYjY67VYy4XTjTNP18F1dDox0YbN4zISy1Kv884bEpQBgRjXyEpwpy1obEAxnI
-Byl6ypUM2Zafq9AKUJsCRtMIPWakXUGfnHy9iUsiGSa6q6Jew1XpMgs7AAICB/9g
-5aR6mWbvaZAwN/IFwIC9cd54cDAW6pvowo6/gkgLfwULI7iGR8jrHHs9rSu968fV
-3L7ys3pFLR93/22mJR1InTp+qQdUntcnh5fwbAd9Z8NoM2QEuY4c7cVjobazOgPf
-C6XZkS1C3tHcvUedzR8kmf1hiRtILWW2pF7A9JbJB3RHcuBut3cS3eME2+s+dCSl
-SugZKyVFuiDoKO59TD7OIn9dwipVhX7UgG0uLDlZzCd9dHLsrlr75LDxIZyiifDB
-1oa+xM5smFYEqux+3lf/UNGhpxcaGDJM09UUpOVv8yVz+FZQilZ7Bu0XKvnj1p91
-YFVAiQvQHijya+kMy6MCiQBGBBgRAgAGBQI5401DAAoJEBm5wYtkQsPcPlUAoNkm
-fMB0HL71h5QYfB/NRJupWsWUAKCi2UETq9cwA7QtuMyQ1cjvkA1mnQ==
-=lNZ2
------END PGP PUBLIC KEY BLOCK-----
-
diff --git a/License b/License
deleted file mode 100644
index 21156a6..0000000
--- a/License
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 207f367..0000000
--- a/Makefile
+++ /dev/null
@@ -1,92 +0,0 @@
-###########################################################
-# Makefile for xml-xalan, an XSLT Processor
-#
-# Please note the following assumptions!
-#  - See make.include for system tools definitions. We assume
-#    that each of these tools are on the path and properly setup.
-#  
-#  - Use GNU make or an equivalent.  On Win32, you can see
-#    http://sourceware.cygnus.com/cygwin for a port. 
-#  
-#  - With JDK 1.1.7B or earlier, a 'make all' may fail the first
-#    time. Try running it again twice, and everything should work.
-#    Note that when using JDK 1.2.x, it all works fine. We'll work on it.
-#  
-#  - Note the several attempts to determine if we're on WinXX or Unix:
-#    ifeq (,$(findstring usr,$(PATH)))
-#    Feel free to modify to work for your machine, and suggest a better
-#    way to create a platform-independent makefile.
-#  
-#  - The docs directory currently requires javadoc from the JDK 1.2.x
-#    You may need to edit make.include 'JAVADOC12' for your system.
-#
-#  - Yes, we plan to move to an 'Ant' based make system soon
-#    (Ant is from jakarta.apache.org and is a Java-based make)
-###########################################################
-
-include make.include
-
-SUBDIRS = src
-
-###########################################################
-# Main targets definitions
-#
-# Note that make.include also defines common targets
-###########################################################
-all: makesubdirs jars makesamples makedocs
-
-build: makesubdirs jars
-# To change debug/release options, see make.include for JAVADEBUG flag
-
-# Create a distribution module
-dist: makedist
-
-docs: makedocs
-
-samples: makesamples
-
-jars: makesubdirs $(JARNAME)
-
-compat: makecompat compatjars
-
-PROPPATH = org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)res
-$(JARNAME)::
-	-mkdir src/$(CLASS_DIR)/META-INF;
-	-mkdir src/$(CLASS_DIR)/META-INF/services;
-	$(CP) src/$(PROPPATH)/*.properties src/$(CLASS_DIR)/$(PROPPATH)/.; \
-	$(CP) src/org/apache/serialize/*.properties src/$(CLASS_DIR)/org/apache/serialize/.; \
-	$(CPR) src/META-INF/* src/$(CLASS_DIR)/META-INF/.; \
-	echo -n "Jarring ../bin/$@ .. "; \
-	cd src/$(CLASS_DIR); $(JAR) $(JARFLAGS) ../../bin/$@ META-INF javax org; \
-	echo "done"
-
-compatjars:
-	echo -n "Jarring ../bin/$@ .. "; \
-	cd src/$(CLASS_DIR); $(JAR) $(JARFLAGS) ../../bin/$@.jar org/apache/xalan/xslt org/apache/xalan/xpath; \
-	echo "done"
-
-# Note: When making dist, copy the built docs up one level
-# Note: Create both a super-jar and a tar.gz archive
-DISTDIR  = $(PRODUCT_NAME)$(VERSION)
-.PHONY: makedist
-makedist:
-	echo Prepare creating $(DIST_NAME)
-	-mkdir $(DISTDIR)
-	$(CP) * $(DISTDIR);\
-	$(CPR) xdocs $(DISTDIR);\
-	$(CPR) samples $(DISTDIR);\
-	$(CPR) src $(DISTDIR);\
-	$(CPR) build/docs $(DISTDIR);\
-	echo Create $(JARDISTNAME);\
-	$(JAR) -cf $(JARDISTNAME) $(DISTDIR);\
-	echo Create $(TARDISTNAME);\
-	$(TARGZ) $(TARDISTNAME) $(DISTDIR);\
-	echo Create $(ZIPDISTNAME);\
-	$(JAR) -cMf $(ZIPDISTNAME) $(DISTDIR);\
-	echo Done creating $(JARDISTNAME) etc., you should sign this with PGP before posting
-
-# Subsidiary targets are defined in make.include
-clean:: cleansubdirs cleandocs cleansamples
-
-compatclean:: cleancompat
-
diff --git a/bin/ant.jar b/bin/ant.jar
deleted file mode 100644
index e4efab3..0000000
--- a/bin/ant.jar
+++ /dev/null
Binary files differ
diff --git a/bin/antRun b/bin/antRun
deleted file mode 100644
index f0a18f1..0000000
--- a/bin/antRun
+++ /dev/null
@@ -1,9 +0,0 @@
-#! /bin/sh
-
-# Args: DIR command
-cd "$1"
-CMD="$2"
-shift
-shift
-
-exec $CMD "$@"
diff --git a/bin/antRun.bat b/bin/antRun.bat
deleted file mode 100755
index 816cb60..0000000
--- a/bin/antRun.bat
+++ /dev/null
@@ -1,20 +0,0 @@
-@echo off
-
-# Change drive and directory to %1 (Win9X only for NT/2K use "cd /d")
-cd %1
-%1\
-set ANT_RUN_CMD=%2
-shift
-shift
-
-set PARAMS=
-:loop
-if ""%1 == "" goto runCommand
-set PARAMS=%PARAMS% %1
-shift
-goto loop
-
-:runCommand
-rem echo %ANT_RUN_CMD% %PARAMS%
-%ANT_RUN_CMD% %PARAMS%
-
diff --git a/bin/bsf.jar b/bin/bsf.jar
deleted file mode 100644
index 19036c1..0000000
--- a/bin/bsf.jar
+++ /dev/null
Binary files differ
diff --git a/bin/stylebook-1.0-b3_xalan-2.jar b/bin/stylebook-1.0-b3_xalan-2.jar
deleted file mode 100644
index 2b640e9..0000000
--- a/bin/stylebook-1.0-b3_xalan-2.jar
+++ /dev/null
Binary files differ
diff --git a/bin/xalan2jdoc.jar b/bin/xalan2jdoc.jar
deleted file mode 100644
index 484b47b..0000000
--- a/bin/xalan2jdoc.jar
+++ /dev/null
Binary files differ
diff --git a/bin/xerces.jar b/bin/xerces.jar
deleted file mode 100644
index 3c7d18a..0000000
--- a/bin/xerces.jar
+++ /dev/null
Binary files differ
diff --git a/build.bat b/build.bat
deleted file mode 100755
index 6c91b9d..0000000
--- a/build.bat
+++ /dev/null
@@ -1,56 +0,0 @@
-@echo off
-rem Prerequisites: user must set JAVA_HOME
-if "%JAVA_HOME%" == "" goto error
-echo.
-echo Xalan-J 2.x Build
-echo -------------
-
-rem Default ANT_HOME if not set
-set SAVEANTHOME=%ANT_HOME%
-if "%ANT_HOME%" == "" set ANT_HOME=.
-
-rem This automatically adds system classes to CLASSPATH
-set SAVECP=%CLASSPATH%
-if exist "%JAVA_HOME%\lib\tools.jar" set CLASSPATH=%CLASSPATH%;%JAVA_HOME%\lib\tools.jar
-if exist "%JAVA_HOME%\lib\classes.zip" set CLASSPATH=%CLASSPATH%;%JAVA_HOME%\lib\classes.zip
-
-rem Default locations of jars we depend on 
-set ANT=bin\ant.jar
-set XERCES=bin\xerces.jar
-set BSF=bin\bsf.jar
-set BSFENGINES=bin\bsfengines.jar
-set DOCGENERATOR=bin\stylebook-1.0-b3_xalan-2.jar
-set DOCLET=bin\xalanjdoc.jar
-
-rem DOCLET must be on system CLASSPATH for javadocs task to work. Just including it in
-rem -classpath arg for java or javadoc call doesn't work....
-rem set CLASSPATH=%ANT%;%XERCES%;%BSF%;%BSFENGINES%;%DOCGENERATOR%;%DOCLET%;%CLASSPATH%
-set CLASSPATH=%ANT%;%XERCES%;%DOCGENERATOR%;%DOCLET%;%CLASSPATH%
-echo.
-echo Building with classpath %CLASSPATH%
-echo Starting Ant...
-
-rem Temporarily, up the -mx memory since we compile a really big glob of files
-echo %JAVA_HOME%\bin\java.exe -mx64m -Dant.home="%ANT_HOME%" -classpath "%CLASSPATH%" org.apache.tools.ant.Main %1 %2 %3 %4 %5 %6 %7 %8 %9
-"%JAVA_HOME%\bin\java.exe" -mx64m -Dant.home="%ANT_HOME%" -classpath "%CLASSPATH%" org.apache.tools.ant.Main %1 %2 %3 %4 %5 %6 %7 %8 %9
-
-goto end
-
-:error
-
-echo "ERROR: JAVA_HOME not found in your environment."
-echo.
-echo "Please, set the JAVA_HOME environment variable to match the"
-echo "root directory of the Java Virtual Machine you want to use."
-
-:end
-rem Cleanup environment variables
-set CLASSPATH=%SAVECP%
-set SAVECP=
-set ANT_HOME=%SAVEANTHOME%
-set SAVEANTHOME=
-set XERCES=
-set BSF=
-set BSFENGINES=
-set DOCLET=
-set ANT=
diff --git a/build.sh b/build.sh
deleted file mode 100755
index 7949501..0000000
--- a/build.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/sh
-#	Name:   build.sh
-#	Author: Shane Curcuru
-
-echo "build.sh beginning..."
-
-if [ "$JAVA_HOME" = "" ] ; then
-    echo "You must set JAVA_HOME, sorry; also JDK 1.1x add classes.zip to CLASSPATH!"
-    exit 1
-fi
-
-# Default to UNIX-style pathing
-CLPATHSEP=:
-# if we're on a Windows box make it ;
-uname | grep WIN && CLPATHSEP=\;
-
-# Update SERVLET to point to JAR containing javax.servlet and javax.servlet.http
-#    packages; alternately include this in the classpath yourself
-SERVLET=/jswdk-1.0.1/lib/servlet.jar
-
-# Default locations for each of our jars; change as needed
-BINDIR=./bin
-ANT=$BINDIR/ant.jar
-TOOLS_JAR=$JAVA_HOME/lib/tools.jar
-XERCES=$BINDIR/xerces.jar
-BSF=$BINDIR/bsf.jar
-BSFENGINES=$BINDIR/bsfengines.jar
-DOCGENERATOR=$BINDIR/stylebook-1.0-b3_xalan-2.jar
-DOCLET=$BINDIR/xalanjdoc.jar
-
-# Make sure this classpath scheme works. I.e., can javadoc find xalanjdoc.Standard?
-TEMP_CP="$ANT${CLPATHSEP}$TOOLS_JAR${CLPATHSEP}$XERCES${CLPATHSEP}$BSF${CLPATHSEP}$BSFENGINES${CLPATHSEP}$DOCGENERATOR${CLPATHSEP}$DOCLET${CLPATHSEP}$CLASSPATH"
-
-echo "Starting Ant with targets: $@"
-echo "        ...with classpath: $TEMP_CP"
-
-"$JAVA_HOME"/bin/java -Dant.home=. -classpath "$TEMP_CP" org.apache.tools.ant.Main $@
-
-echo "build.sh complete!"
-
-
-
diff --git a/build.xml b/build.xml
deleted file mode 100644
index 19a237a..0000000
--- a/build.xml
+++ /dev/null
@@ -1,732 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- ===================================================================
-
-   Build file for Xalan-J 2.x - for use with the Jakarta Ant java build tool
-   
-Setup instructions: 
-   Before running an Ant build, you must
-   
-     - set the JAVA_HOME environment variable to the JDK root directory
-     - To build 'servlet' sample: Include Servlet SDK in your classpath
-     - To build docs/javadocs: use JDK 1.2.x or higher
-     
-   
-Build Instructions:   
-   To build, run
-     build.bat (win32) or build.sh (unix) - optionally with a target arg as indicated below -
-   in the directory where this file is located.
-   
-   The batch/shell file sets up your classpath and calls java org.apache.tools.ant.Main
-   
-Build targets
-    This build file supports the following targets:
-    - compile  compiles Xalan-J in ./build/classes.
-    - jar      creates ./build/xalan.jar [the default target]
-    - samples  compiles samples and puts classes in ./build/xalanxamples.jar
-    - servlet compiles sample servlets and puts classes in ./build/xalanservlet.jar
-    - docs     generates the human-written documentation in ./build/docs
-    - javadocs [or apidocs] generates the API documentation in ./build/docs/apidocs
-    - compat.jar compiles compatibility tree and creates ./build/xalanj1compat.jar
-    - compat.apidocs generates javadoc for the compatibility jar
-    - clean    purges the build tree.
-    - dist     creates a complete distribution in ./xalan-j_x_x_x
-    - auto*    targets used by automated build programs, without dependencies
-    - minitest compile and run the minitest in xml-xalan\test
-    - conftest compile and run the conftest in xml-xalan\test
-    - smoketest run a pre-checkin smoketest (5 to 10 minutes).
-    - print.docs create PDF documentation (requires fop.jar and w3c.jar).
-        
-If you build a target that depends on other targets, those other targets are created in 
-the correct order.
-
-Authors:
-  Shane Curcuru <shane_curcuru@lotus.com>
-  Don Leslie <donald_leslie@lotus.com>
-
-Copyright:
-  Copyright (c) 1999-2000 The Apache Software Foundation.
-  
-  - Much of this file stolen from Stefano's xml-xerces build.xml  
-  
-   $Id$
-   
-==================================================================== -->
-
-<project name="Xalan" default="jar" basedir=".">
-  <!-- =================================================================== -->
-  <!-- Defines variables used by the other targets                         -->
-  <!-- =================================================================== -->
-  <property name="version" value="2_0_1"/>
-  <property name="name" value="xalan"/>
-  <property name="Name" value="Xalan-Java"/>
-  <property name="year" value="2000"/>
-
-
-  <property name="build.compiler" value="classic"/>
-  <property name="debug" value="off"/>
-
-  <property name="mfinf.dir" value="./src/META-INF"/>
-  <property name="src.dir" value="./src"/>
-  <property name="xpath.reldir" value="org/apache/xpath"/>
-  <property name="xalan.reldir" value="org/apache/xalan"/>
-  <property name="trax.reldir" value="javax/xml/transform"/>
-  <property name="serialize.reldir" value="org/apache/serialize"/>
-  <property name="serializer.reldir" value="org/apache/xalan/serialize"/>
-  <property name="jaxp.reldir" value="javax/xml/parsers"/>
-  <property name="sax.reldir" value="org/xml/sax"/>
-  <property name="w3c.reldir" value="org/w3c"/>    
-  <property name="build.dir" value="./build"/>
-  <!-- Where we put the xalan.jar we compile by default -->
-  <property name="build.xalan.jar" value="${build.dir}/xalan.jar"/>
-  <property name="build.classes" value="${build.dir}/classes"/>
-  <property name="build.docs" value="${build.dir}/docs"/>
-  <property name="build.samples" value="${build.dir}/samples"/>
-  <property name="build.apidocs" value="${build.docs}/apidocs"/>
-  
-  <!-- Xalan-J1 compatability stuff.  -->
-  <property name="compat.jar" value="xalanj1compat.jar"/>
-  <property name="compat.src.dir" value="./compat_src"/>
-  <property name="build.compat.classes" value="${build.dir}/compat_classes"/>
-  <property name="build.compat.jar" value="${build.dir}/${compat.jar}"/>
-  <property name="build.compat.apidocs" value="${build.docs}/compat_apidocs"/>        
-
-  <!-- Reference to the top level of the test source code area. -->
-  <property name="tests.dir" value="../test/java/"/>
-  <property name="samples.dir" value="./samples"/>
-  <property name="bin.dir" value="./bin"/>
-  <property name="xerces.jar" value="${bin.dir}/xerces.jar"/>
-  <property name="bsf.jar" value="${bin.dir}/bsf.jar"/>
-
-  <property name="dist.file" value="${name}-j_${version}"/>
-  <property name="dist.dir" value="${build.dir}/${dist.file}"/>
-
-  <property name="xdocs.dir" value="./xdocs"/>
-  <property name="version.file" value="org/apache/xalan/processor/XSLProcessorVersion.java"/>
-  <property name="xdocs.book" value="${xdocs.dir}/sources/xalan-jlocal.xml"/>
-  <property name="xdocs.style" value="${xdocs.dir}/style"/>
-  <property name="xalanonly-styledocs"
-            value="dtd/xsl-html40s.dtd,dtd/spec.dtd,stylesheets/patterns.xsl,stylesheets/notice.xsl,stylesheets/spec.xsl,stylesheets/done.xsl,loaderdesign.xml,stylesheets/design2project.xsl,stylesheets/designdoc2html.xsl,stylesheets/xml2fo.xsl"/>
-  <property name="doc.generator" value="org.apache.stylebook.StyleBook"/>
-  <property name="doc.generator.styletargz" value="${xdocs.dir}/xml-site-style.tar.gz"/>
-  <property name="doc.generator.styletar" value="${xdocs.dir}/xml-site-style.tar"/>
-  
-  <property name="site.root" value="./xml-site"/>
-  <property name="site.dir" value="${site.root}/target/xalan-j"/>
-  <property name="site.book" value="${xdocs.dir}/sources/xalan-jsite.xml"/>
-
-  <property name="test.loggingLevel" value="5"/>
-  <!-- The excluded lre tests are at issue or are new bugs, and should be 
-       included as soon as they are resolved.  -->
-  <property name="test.excludes" value="impincl12.xsl;lre02.xsl;lre03.xsl;lre07.xsl;lre10.xsl;lre12.xsl;lre21.xsl"/>
-  <property name="test.embedded" value="embed01.xsl;embed02.xsl;embed07.xsl"/>
-
-  <!-- =================================================================== -->
-  <!-- Prepares the xdocs/style and the build directories                  -->
-  <!-- =================================================================== -->
-  <target name="prepare">
-    <mkdir dir="${build.dir}"/>
-    <mkdir dir="${build.classes}"/>
-    <!-- Note that all testing-related targets *must* depend on 
-         this target, either directly or indirectly, to get 
-         the tests-available property set for them.
-    -->
-    <available file="${tests.dir}" property="tests-available" />
-  </target>
-  <target name="prepare.docs" depends="prepare">
-    <gunzip src="${doc.generator.styletargz}"/>
-    <untar src="${doc.generator.styletar}" dest="${xdocs.dir}"/>
-        <delete file="${doc.generator.styletar}"/>
-    <mkdir dir="${build.docs}"/> <!-- transform todo.xml and put the result in build/docs -->
-    <java fork="yes" classname="org.apache.xalan.xslt.Process" classpath="${java.class.path}:${build.dir}/$xalan.jar">
-      <arg line="-in todo.xml -xsl todo.xsl -out ${build.docs}/todo.html"/>
-    </java> 
-    <!-- We use a Notes agent to extract Xalan-Java 2 commits from our team database into commits.xml.  The following operation 
-    transforms commits.xml (just including source code commits) and puts the result in xdocs/sources/xalan for inclusion in the 
-    readme.xml -->      
-    <java fork="yes" classname="org.apache.xalan.xslt.Process" classpath="${java.class.path}:${build.dir}/$xalan.jar">
-      <arg line="-in commits.xml -xsl ${xdocs.style}/stylesheets/done.xsl -out ${xdocs.dir}/sources/xalan/DONE"/>
-    </java>
-    <!-- Generate the Xalan-J2 design document -->
-    <java fork="yes" classname="${doc.generator}"
-          classpath="${java.class.path}:${build.dir}/xalan.jar"> 
-          <arg line="loaderConfig=sbk:/style/loaderdesign.xml targetDirectory=./build/docs/design/
-                     ./xdocs/sources/xalandesign.xml ./xdocs/style"/>
-    </java>
-           
-    <mkdir dir="${build.apidocs}"/>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Copy over the source code                                           -->
-  <!-- We're currently skipping this step, since it seems extraneous if
-       you're not going to be using the filtering stuff. -->
-  <!-- =================================================================== -->
-
-  <!-- =================================================================== -->
-  <!-- Compiles the source tree - xpath (independent xpath engine)         -->
-  <!-- =================================================================== -->
-  <!-- Note: Still too many cross-dependencies to do this separately -->
-  <target name="compile.xpath" depends="prepare">
-    <javac srcdir="${src.dir}/${xpath.reldir}" 
-           destdir="${build.classes}"
-           debug="${debug}" />
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Compiles the source tree - xalan (the processor)                    -->
-  <!-- =================================================================== -->
-  <!-- Note: Still too many cross-dependencies to do this separately -->
-  <target name="compile.xalan" depends="compile.xpath">
-    <javac srcdir="${src.dir}/${xalan.reldir}" 
-           destdir="${build.classes}" 
-           debug="${debug}"/>
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Compile entire source tree - except Xalan-J 1 compatability classes -->
-  <!-- =================================================================== -->
-  <target name="compile" depends="prepare"
-    description="Compile Xalan the normal way" >
-    <echo message="compile entire source tree and copy .properties and .res files to build tree."/>
-    <!-- Note: split compile into separate javac steps to avoid JDK 1.1.8 bug reported at:
-         http://developer.java.sun.com/developer/bugParade/bugs/4043508.html
-         which causes an error like:
-         [javac] E:\builds\xml-xalan\java\src\org\apache\xalan\templates\ElemTemplate.java:108: Cyclic class inheritance or scoping.
-    --> 
-    <javac srcdir="${src.dir}" 
-           destdir="${build.classes}"
-           includes="javax/**/*.java"
-           debug="${debug}"/>
-    <javac srcdir="${src.dir}" 
-           destdir="${build.classes}"
-           includes="org/w3c/**/*.java,org/w3c/**/*.java"
-           debug="${debug}"/>
-    <javac srcdir="${src.dir}" 
-           destdir="${build.classes}"
-           includes="org/apache/xml/**/*.java,org/apache/xpath/**/*.java"
-           debug="${debug}"/>
-    <javac srcdir="${src.dir}" 
-           destdir="${build.classes}"
-           includes="org/apache/xalan/**/*.java"
-           debug="${debug}"/>
-    <copy todir="${build.classes}">
-          <fileset dir="${src.dir}" includes="**/*.properties,**/*.res,**/javax.xml.parsers.*,**/javax.xml.transform.*"/>
-        </copy>  
-  </target>
-    
-  <!-- =================================================================== -->
-  <!-- Compiles other source trees                                         -->
-  <!-- =================================================================== -->
-  <target name="compile.trax" depends="prepare">
-    <javac srcdir="${src.dir}"
-           destdir="${build.classes}" 
-           includes="${trax.reldir}/**"
-           debug="${debug}"/>
-  </target>
-  <target name="compile.serialize" depends="prepare">
-    <javac srcdir="${src.dir}" 
-           destdir="${build.classes}"
-           includes="${serialize.reldir}/**" 
-           debug="${debug}"/>
-  </target>
-  <target name="compile.sax" depends="prepare">
-    <javac srcdir="${src.dir}/${sax.reldir}" 
-           destdir="${build.classes}" 
-           debug="${debug}"/>
-  </target>
-    <target name="compile.w3c" depends="prepare">
-    <javac srcdir="${src.dir}/${w3c.reldir}" 
-           destdir="${build.classes}" 
-           debug="${debug}"/>
-  </target>
-    <target name="compile.jaxp" depends="prepare">
-    <javac srcdir="${src.dir}/${jaxp.reldir}" 
-           destdir="${build.classes}" 
-           debug="${debug}"/>
-  </target>
-  
-  <!-- =================================================================== -->
-  <!-- Creates the xalan JAR                                               -->
-  <!-- =================================================================== -->
-  <target name="jar" depends="compile"
-    description="Jar up xalan.jar" >
-    <jar jarfile="${build.xalan.jar}" manifest="src\MANIFEST.MF" basedir="${build.classes}"/>
-  </target>
-  <target name="package" depends="jar">
-    <!-- OK, what are the 'Apache-standard' names for various targets? -->
-    <echo message="package is an alias for jar"/>  
-  </target>
-  
-  <!-- =================================================================== -->
-  <!-- Creates the Xalan-J1 compatability JAR                              -->
-  <!-- =================================================================== -->
-  <target name="compat.jar" depends="jar">
-    <echo message="compile and JAR Xalan-J 1 compability API."/>
-    <mkdir dir="${build.compat.classes}"/>
-    <javac srcdir="${compat.src.dir}" classpath="${java.class.path}:${build.xalan.jar}" 
-           destdir="${build.compat.classes}"
-           includes="**/*.java"
-           debug="${debug}"/>
-    <copy todir="${build.compat.classes}">
-          <fileset dir="${compat.src.dir}" includes="**/*.properties,**/*.res"/>
-    </copy>  
-    <jar jarfile="${build.compat.jar}" manifest="src\MANIFEST.MF" basedir="${build.compat.classes}"/>
-  </target>
-  <target name="compat.package" depends="compat.jar">
-    <echo message="compat.package is an alias for compat.jar"/>  
-  </target>
-  
-  <!-- =================================================================== -->
-  <!-- Creates the Xalan-J1 compatability javadoc                          -->
-  <!-- =================================================================== -->
-  <target name="compat.javadocs" depends="jar">
-    <mkdir dir="${build.compat.apidocs}"/>
-    <javadoc
-         classpath="${java.class.path}"
-         public="true"
-         sourcepath="${compat.src.dir}"
-         overview="${compat.src.dir}/compatOverview.html"         
-         packagenames="org.apache.xalan.xslt,org.apache.xalan.xpath,org.apache.xalan.xpath.xml"
-         author="true"
-         version="true"
-         use="true"
-         destdir="${build.compat.apidocs}"
-         windowtitle="Xalan-Java 1 Compatability" 
-         doctitle="Xalan-Java 1 Compatability"
-         bottom="Copyright &#169; ${year} Apache XML Project. All Rights Reserved.">
-    </javadoc>
-  </target>
-    <target name="compat.apidocs" depends="compat.javadocs">
-    <echo message="compat.apidocs is an alias for compat.javadocs"/>  
-  </target>
-    
-
-  <!-- =================================================================== -->
-  <!-- Compiles the samples (servlet excluded) and jars the class files    -->  
-  <!-- =================================================================== -->
-  <target name="samples" depends="jar"
-    description="Compile and jar the samples (except servlet)" >
-    <property name="exclude" value="*.xml,*.xsl,*.txt,*.html,*.properties,*.out"/>
-    <mkdir dir="${build.samples}"/>
-    <!-- Since the samples are packageless, they must be compiled separately. -->   
-    <javac srcdir="${samples.dir}/SimpleTransform" classpath="${java.class.path}:${build.xalan.jar}" 
-           destdir="${build.samples}"  excludes="${exclude}"
-           debug="${debug}"/>
-    <javac srcdir="${samples.dir}/UseStylesheetPI" classpath="${java.class.path}:${build.xalan.jar}"  
-           destdir="${build.samples}"  excludes="${exclude}"
-           debug="${debug}"/>
-    <javac srcdir="${samples.dir}/UseStylesheetParam" classpath="${java.class.path}:${build.xalan.jar}"
-           destdir="${build.samples}"  excludes="${exclude}"
-           debug="${debug}"/>           
-    <javac srcdir="${samples.dir}/SAX2SAX" classpath="${java.class.path}:${build.xalan.jar}" 
-           destdir="${build.samples}"  excludes="${exclude}"
-           debug="${debug}"/>           
-    <javac srcdir="${samples.dir}/DOM2DOM" classpath="${java.class.path}:${build.xalan.jar}" 
-           destdir="${build.samples}"  excludes="${exclude}"
-           debug="${debug}"/>
-    <javac srcdir="${samples.dir}/Pipe" classpath="${java.class.path}:${build.xalan.jar}" 
-           destdir="${build.samples}"  excludes="${exclude}"
-           debug="${debug}"/>           
-    <javac srcdir="${samples.dir}/UseXMLFilters" classpath="${java.class.path}:${build.xalan.jar}" 
-           destdir="${build.samples}"  excludes="${exclude}"
-           debug="${debug}"/>
-    <javac srcdir="${samples.dir}/Trace" classpath="${java.class.path}:${build.xalan.jar}"  
-           destdir="${build.samples}"  excludes="${exclude}"
-           debug="${debug}"/>
-   <javac srcdir="${samples.dir}/ApplyXPath" classpath="${java.class.path}:${build.xalan.jar}" 
-           destdir="${build.samples}" excludes="${exclude}" 
-           debug="${debug}"/>
-   <javac srcdir="${samples.dir}/trax" classpath="${java.class.path}:${build.xalan.jar}" 
-           destdir="${build.samples}" excludes="${exclude}" 
-           debug="${debug}"/>
-   <javac srcdir="${samples.dir}/extensions" classpath="${java.class.path}:${build.xalan.jar}" 
-           destdir="${build.samples}" excludes="${exclude}" 
-           debug="${debug}"/> 
-    <jar jarfile="${build.dir}/xalansamples.jar" basedir="${build.samples}"
-         includes="*.class"/>
-                   
-  </target>
-  
-  <!-- =================================================================== -->
-  <!-- Compiles the sample servlet and jars the class files.                -->  
-  <!-- The javax.servlet and javax.servlet.http packages                    -->
-  <!-- must be on the classpath                                             -->
-  <!-- =================================================================== -->
- <target name="servlet" depends="jar"
-    description="Compile and jar the servlet samples" >
-     <echo message="To compile the sample servlets, javax.servlet and javax.servlet.http must be on the classpath"/>   
-     <mkdir dir="${build.samples}/servlet"/>
-     <javac srcdir="${samples.dir}/servlet" classpath="${java.class.path}:${build.xalan.jar}" 
-           destdir="${build.samples}"
-           debug="${debug}"/>
-      <copy todir="${build.samples}/servlet">
-          <fileset dir="${samples.dir}/servlet" 
-                includes="media.properties,default.xsl,default2.xsl"/>
-        </copy>  		         
-    <jar jarfile="${build.dir}/xalanservlet.jar" 
-         basedir="${build.samples}" 
-         includes="servlet/**"/>
- </target>
- 
-  <!-- =================================================================== -->
-  <!-- Generate HTML docs                                                  -->
-  <!-- =================================================================== -->
-  <target name="docs" depends="jar,prepare.docs,autodocs"
-    description="Build the framework documentation (overview, readme, etc.)" >
-    <echo message="docs is human-usable target with dependencies"/>  
-  </target>
-  
-  <target name="autodocs">
-    <echo message="autodocs is for automated build process, without dependencies"/>   
-    <java fork="yes" classname="${doc.generator}" classpath="${java.class.path}:${build.xalan.jar}">
-       <arg line="targetDirectory=${build.docs} ${xdocs.book} ${xdocs.style}"/>
-        </java>	 
-  </target>
-  
-  <!-- =================================================================== -->
-  <!-- Creates the API documentation                                       -->
-  <!-- =================================================================== -->
-  <target name="javadocs" depends="prepare.docs,autojavadocs"
-    description="Build the Javadocs for Xalan sources" >
-    <echo message="javadocs is human-usable target with dependencies"/>  
-  </target>
-
-  <target name="autojavadocs">
-    <echo message="autojavadocs is for automated build process, without dependencies"/>
-    
-    <!-- generate trax.html, a TRaX overview document, and a package.html for each trax package
-         (the latter are generated with the the Redirect extension -->
-    <mkdir dir="${build.apidocs}/javax/xml/transform"/>         
-    <java fork="yes" classname="org.apache.xalan.xslt.Process" classpath="${java.class.path}:${build.xalan.jar}">
-      <arg line="-in ${xdocs.dir}/sources/trax/trax.xml
-                 -param package-root '../../../src/'
-                 -xsl ${xdocs.style}/stylesheets/spec.xsl 
-                 -out ${build.apidocs}/javax/xml/transform/trax.html"/>
-    </java>   
-    
-    <!-- Ant 1.2 ignores destdir arg if doclet is set, so must send to doclet in doclet subelement-->
-    <javadoc
-         classpath="${java.class.path}"
-         public="true"
-         sourcepath="${src.dir}"
-         overview="${src.dir}/javadocOverview.html"
-         packagenames="org.apache.*,org.xml.*,org.w3c.*,javax.xml.*"
-         author="true"
-         version="true"
-         use="true"
-         windowtitle="${Name} 2" 
-         doctitle="${Name} 2"
-         bottom="Copyright &#169; ${year} Apache XML Project. All Rights Reserved.">
-          <doclet name="xalanjdoc.Standard" path="${bin.dir}/xalan2jdoc.jar">
-            <param name="-d" value="${build.apidocs}"/>
-          </doclet>
-          <group title="Transformations API for XML (TrAX)" packages="javax.xml.transform*"/>
-          <group title="Java API for XML Parsing" packages="javax.xml.parsers"/>
-          <group title="Xalan Core"
-                 packages="org.apache.xalan.processor:org.apache.xalan.templates:org.apache.xalan.transformer"/>
-          <group title="XPath" packages="org.apache.xpath*"/>
-          <group title="Utilities" packages="org.apache.xml.utils*"/>
-          <group title="Xalan Other" packages="org.apache.xalan.client:org:org.apache.xalan.extensions:org.apache.xalan.res:org.apache.xalan.stree:org.apache.xalan.trace:org.apache.xalan.xslt"/>
-          <group title="Xalan Extensions" packages="org.apache.xalan.lib*"/>
-          <group title="Serializers" packages="org.apache.xalan.serialize"/>
-          <group title="SAX 2" packages="org.xml.sax*"/>
-          <group title="DOM 2" packages="org.w3c.dom*"/>
-    </javadoc>
-    
-  </target>
-
-  <!-- =================================================================== -->
-  <!-- Cleans everything: build tree, site tree, style docs in             -->
-  <!--         - build tree                                                -->
-  <!--         - distribution tree                                         -->
-  <!--         - site tree                                                 -->
-  <!--         - style docs expanded from xml-site-style.tar.gz.           -->
-  <!--           (MUST update contents of ${xalanonly-styledocs}           -->
-  <!--            if change contents of xml-site-style.tar.gz)             -->
-  <!--         - Javadoc overview and packqage-level html docs placed      -->
-  <!--           in the source tree                                        -->
-  <!-- =================================================================== -->
-  <target name="clean"
-    description="Clean up the build" >
-    <delete dir="${build.dir}"/>
-    <delete dir="${site.root}"/>
-    <delete>
-      <fileset dir="${xdocs.style}" excludes="${xalanonly-styledocs}"/>
-    </delete>
-  </target>
- 
-  <!-- =================================================================== -->
-  <!-- Creates the distribution                                            -->
-  <!-- =================================================================== -->
-  <target name="dist" depends="jar,docs,javadocs,samples,servlet,compat.jar,compat.javadocs,autodist"
-    description="Create a .zip/.tar.gz distribution module" >
-    <echo message="dist is human-useable target for distribution, with all dependencies"/>
-  </target>
-  <target name="autodist">
-    <echo message="autodist is for automated build processes, without dependencies"/>
-    <mkdir dir="${dist.dir}"/>
-    <mkdir dir="${dist.dir}/bin"/>    
-    <mkdir dir="${dist.dir}/src"/>
-    <mkdir dir="${dist.dir}/compat_src"/>    
-    <mkdir dir="${dist.dir}/xdocs"/>
-    <mkdir dir="${dist.dir}/docs"/>
-    <mkdir dir="${dist.dir}/docs/apidocs"/>
-    <mkdir dir="${dist.dir}/docs/compat_apidocs"/>    
-    <mkdir dir="${dist.dir}/samples"/>
-        
-        <!-- Copy bin directory -->
-    <copy todir="${dist.dir}/bin">
-          <fileset dir="${bin.dir}"/>
-        </copy>  
-
-    <!-- Copy sources and source documentation -->
-    <copy todir="${dist.dir}/src">
-      <fileset dir="${src.dir}"/>
-    </copy>
-    <copy todir="${dist.dir}/compat_src">
-      <fileset dir="${compat.src.dir}"/>
-    </copy>    
-    <copy todir="${dist.dir}/xdocs">
-      <fileset dir="${xdocs.dir}"/>
-    </copy>
-    
-    <!-- Copy built documentation and javadoc, and samples src and jars -->
-    <copy todir="${dist.dir}/docs">
-      <fileset dir="${build.docs}"/>
-    </copy>  
-    <copy todir="${dist.dir}/samples">
-      <fileset dir="${samples.dir}"/>
-    </copy>   
-    <copy file="${build.dir}/xalansamples.jar" todir="${dist.dir}/bin"/>
-    <copy file="${build.dir}/xalanservlet.jar" todir="${dist.dir}/bin"/>
-
-    <!-- Copy xalan jar and compability into the bin directory (subject to change) -->
-    <copy file="${build.xalan.jar}" todir="${dist.dir}/bin"/>
-    <copy file="${build.compat.jar}" todir="${dist.dir}/bin"/>    
-
-    <copy todir="${dist.dir}">
-      <fileset dir="." includes="readme.html,KEYS,License,build.xml,build.sh,build.bat,todo.xml,todo.xsl,commits.xml"/>
-    </copy>
-          
-    <zip zipfile="${build.dir}/${dist.file}.zip" basedir="${build.dir}" includes="${dist.file}/**"/>
-    <tar tarfile="${build.dir}/${dist.file}.tar" basedir="${build.dir}" includes="${dist.file}/**"/>
-    <gzip src="${build.dir}/${dist.file}.tar" zipfile="${build.dir}/${dist.file}.tar.gz"/>
-  </target>
-  
-  <!-- =================================================================== -->
-  <!-- Creates the documentation tree for the org.apache.xml website       -->
-  <!-- =================================================================== -->
-  <target name="site" depends="prepare.docs">
- 
-    <mkdir dir="${site.dir}/apidocs"/>
-    <mkdir dir="${site.dir}/compat_apidocs"/>
-    <mkdir dir="${site.dir}/design"/>
-    <java fork="yes" classname="${doc.generator}" classpath="${java.class.path}:${build.dir}/$xalan.jar"> 
-       <arg line="targetDirectory=${site.dir} ${site.book} ${xdocs.style}"/>
-        </java>
-
-        <!-- put todo.html in the site directory -->     
-    <copy file="${build.docs}/todo.html" todir="${site.dir}"/>
-     <!-- put xalan design doc in the site design subdir -->
-    <copy todir="${site.dir}/design">
-      <fileset dir="${build.docs}/design"/>
-    </copy>  
-    <!-- put in the javadoc -->
-    <copy todir="${site.dir}/apidocs">
-      <fileset dir="${build.apidocs}"/>
-    </copy>
-    <copy todir="${site.dir}/compat_apidocs">
-      <fileset dir="${build.compat.apidocs}"/>
-    </copy>  
-      
-  </target>
-   
-  <!-- =================================================================== -->
-  <!-- Compiles and runs the minitest from xml-xalan\test, if present      -->
-  <!-- =================================================================== -->
-  <path id="minitest.class.path">
-    <pathelement location="${xerces.jar}" />
-    <pathelement location="${build.xalan.jar}" />
-    <pathelement location="${bsf.jar}" />
-    <pathelement path="${java.class.path}" />
-  </path>
-
-  <!-- Reference from the testing directory back to our directory, 
-       used when calling testing targets to set the classpath for 
-       the tests to include jars we just compiled.
-  -->
-  <property name="tests.backref" value="../../java/"/>
-
-  <target name="minitest" depends="prepare,jar,minitest-run,tests-not-available" 
-    description="Run the Minitest from xml-xalan/test/java" >
-    <!-- This target explicitly depends on the jar target, since 
-         without xalan.jar the tests won't compile/run.
-         We then call the worker target minitest-run to do 
-         the work of running the minitest.
-         We finally call a helper target tests-not-available 
-         to notify users that they need to checkout the tests 
-         explicitly from CVS - but this only runs if needed.
-    -->
-  </target>
-  <target name="minitest-run" if="tests-available" depends="prepare" >
-    <echo message=" [minitest] Calling ${tests.dir}build.xml now to run minitest.xalan2" />
-    <ant dir="${tests.dir}" antfile="build.xml" target="minitest.xalan2" >
-      <!-- Set the below testxsl.jar.name so that it will create 
-           minitest.jar instead of testxsl.jar; we only do this here 
-           since this is a commonly-called developer target, and it's 
-           good to differentiate this jar from the regular testing jar 
-           (which has many more test classes in it).
-      -->
-      <property name="testxsl.jar.name" value="minitest.jar" />
-      <property name="prepend.class.path"
-                value="${tests.backref}${xerces.jar}:${tests.backref}${build.xalan.jar}:${tests.backref}${bsf.jar}" />
-    <!-- Why doesn't the following refid work? I get an error referencing it.
-      <property name="prepend.class.path" refid="minitest.class.path" />
-    -->
-    </ant>
-  </target>
-
-  <!-- Called from various testing targets if the test dir doesn't exist. -->
-  <target name="tests-not-available" unless="tests-available" >
-    <echo message=" [tests] The tests do not seem to be present!" />
-    <echo message=" [tests] You must have checked out from CVS to run the tests," />
-    <echo message=" [tests]   it is not included in binary distributions." />
-    <echo message=" [tests] See http://xml.apache.org/xalan-j/test/ for more info." />
-  </target>
-  
-  <!-- =================================================================== -->
-  <!-- Compiles and runs the conformance test from xml-xalan\test, if present      -->
-  <!-- =================================================================== -->
-  <!-- We should have a duplicate of minitest.class.path that
-       in the future this may need to include references to dirs 
-       where Java-based extension tests keep their .classes.
-  -->
-
-  <target name="conftest" depends="prepare,jar,conftest-run,tests-not-available" 
-    description="Run the ConformanceTest from xml-xalan/test/java" >
-  </target>
-  <target name="conftest-run" if="tests-available" depends="prepare" >
-    <echo message=" [conftest] Calling ${tests.dir}build.xml now to run conftest.xalan2" />
-    <ant dir="${tests.dir}" antfile="build.xml" target="conftest.xalan2" >
-      <property name="testxsl.jar.name" value="conftest.jar" /> 
-      <!-- Set name above so that it will create conftest.jar instead 
-           of testxsl.jar - but, since the "ConformanceTest" depends 
-           on so many testing classes, it may not be worth calling 
-           this a different name from the default 'testxsl.jar'.  It 
-           does reduce confusion, however, for people who build and 
-           run the tests directly from the testing directory, instead 
-           of doing it from this directory.
-      -->
-      <property name="prepend.class.path"
-                value="${tests.backref}${xerces.jar}:${tests.backref}${build.xalan.jar}:${tests.backref}${bsf.jar}" />
-    </ant>
-  </target>
-  
-  <!-- =================================================================== -->
-  <!-- Compiles and runs the smoke test from xml-xalan\test, if present      -->
-  <!-- =================================================================== -->
-  <target name="smoketest" depends="prepare,jar,smoketest-run,tests-not-available" 
-    description="Run the smoke test - to be defined." >
-  </target>
-  <target name="smoketest-run" if="tests-available" depends="prepare" >
-    <ant dir="${tests.dir}" antfile="build.xml" target="smoketest-xalan2" >
-      <property name="prepend.class.path"
-                value="${tests.backref}${xerces.jar}:${tests.backref}${build.xalan.jar}:${tests.backref}${bsf.jar}" />
-    </ant>
-  </target>
-  
-  <!-- =================================================================== -->
-  <!-- Creates the todo list for the org.apache.xml website                -->
-  <!-- =================================================================== -->
-  <target name="todo">
-    <java fork="yes" classname="org.apache.xalan.xslt.Process" classpath="${java.class.path}:${build.dir}/$xalan.jar">
-      <arg line="-in todo.xml -xsl todo.xsl -out todo.html"/>
-    </java>   
-  </target>  
-
-  <!-- =================================================================== -->
-  <!-- Creates the xalan design document                                   -->
-  <!-- =================================================================== -->
-    <target name="xalan-j2-design">
-    <java fork="yes" classname="${doc.generator}" classpath="${java.class.path}:${build.dir}/xalan.jar"> 
-      <arg line="loaderConfig=sbk:/style/loaderdesign.xml targetDirectory=${build.dir}/docs/design/
-      ${xdocs.dir}/sources/xalandesign.xml ${xdocs.style}"/>
-    </java>
-  </target>
-  
-  <!-- =================================================================== -->
-  <!-- Use FOP to create preliminary print (pdf) doc                       -->
-  <!-- Note: fop.jar and xml.jar (from xml-fop) must be on classpath       -->
-
-  <!-- This is VERY preliminary, not yet for inclusion in distribution     -->
-  <!-- =================================================================== -->
-
-  <!--Collate the xml sources into a single xml source with a litle extra structure -->
-  <target name="print.docs" depends="prepare.docs">
-    <echo message="fop.jar and xml.jar must be on the classpath"/>
-    <java fork="yes" classname="org.apache.xalan.xslt.Process"
-      classpath="${java.class.path}:${build.dir}/xalan.jar">
-      <arg line="-xsl ${xdocs.dir}/sources/xalan-collate.xsl 
-                 -out ${xdocs.dir}/sources/xalan/xalan-collate.xml"/>
-    </java>
-    
-    <!-- Transform collation into Formatting Objects 
-         (with a little work on links along the way) -->    
-    <java fork="yes" classname="org.apache.xalan.xslt.Process"
-      classpath="${java.class.path}:${build.dir}/xalan.jar">
-      <arg line="-in  ${xdocs.dir}/sources/xalan/xalan-collate.xml
-                 -param resourceFile '../../sources/xalan/resources.xml'
-                 -param project ${Name}      
-                 -xsl ${xdocs.style}/stylesheets/xml2fo.xsl 
-                 -out ${build.docs}/xalan-collate.fo"/>
-    </java>
-    
-    <!-- Use FOP to generate a pdf file -->
-    <java fork="yes" classname="org.apache.fop.apps.CommandLine"
-      classpath="${java.class.path}:${build.dir}/xalan.jar:${bin.dir}/fop.jar:${bin.dir}/w3c.jar">
-      <arg line="${build.docs}/xalan-collate.fo build/docs/xalan.pdf"/>
-    </java>
-  </target>
-
-  <!-- =================================================================== -->  
-   <!-- for developers only; compiles xalan-j1 samples with compat jar and xalan-j2 xalan.jar-->
-   <target name="compat.samples" description="Compile XalanJ1 samples" >
-     <property name="exclude" value="*.xml,*.xsl,*.txt,*.html.*.properties"/>
-     <property name="samplesj1.dir" value="/xml-xalan/samples"/>
-     <property name="build.compat.samples" value="./build/compat_samples"/>
-     <mkdir dir="${build.compat.samples}"/>     
-
-    <!--need to use the XalanJ2 XPathAPI, so cannot compile ApplyXPath as is -->   
-    <javac srcdir="${samplesj1.dir}/Pipe" classpath="${build.compat.jar}:${build.xalan.jar}:${java.class.path}" 
-           destdir="${build.compat.samples}"  excludes="${exclude}"
-           debug="${debug}"/> 
-    <javac srcdir="${samplesj1.dir}/SimpleTransform" classpath="${build.compat.jar}:${build.xalan.jar}:${java.class.path}" 
-           destdir="${build.compat.samples}"  excludes="${exclude}"
-           debug="${debug}"/>
-    <javac srcdir="${samplesj1.dir}/TransformToDom" classpath="${build.compat.jar}:${build.xalan.jar}:${java.class.path}" 
-           destdir="${build.compat.samples}"  excludes="${exclude}"
-           debug="${debug}"/>
-    <javac srcdir="${samplesj1.dir}/PureSAX" classpath="${build.compat.jar}:${build.xalan.jar}:${java.class.path}" 
-           destdir="${build.compat.samples}"  excludes="${exclude}"
-           debug="${debug}"/>          
-    <javac srcdir="${samplesj1.dir}/UseStylesheetParam" classpath="${build.compat.jar}:${build.xalan.jar}:${java.class.path}" 
-           destdir="${build.compat.samples}"  excludes="${exclude}"
-           debug="${debug}"/>
-    <javac srcdir="${samplesj1.dir}/Servlet" classpath="${build.compat.jar}:${build.xalan.jar}:${java.class.path}" 
-           destdir="${build.compat.samples}" excludes="${exclude}"
-           debug="${debug}"/>
-    <jar   jarfile="${build.compat.samples}/xalanjcompatsamples.jar" basedir="${build.compat.samples}"
-            includes="*.class"/> 
-     <!--put the servlet in a separate jar -->
-     <javac srcdir="${samplesj1.dir}/Servlet" classpath="${build.compat.jar}:${build.xalan.jar}:${java.class.path}" 
-           destdir="${build.compat.samples}"
-           debug="${debug}"/>
-      <copy todir="${build.compat.samples}/servlet">
-          <fileset dir="${samplesj1.dir}/Servlet" 
-                includes="media.properties,default.xsl,default2.xsl"/>
-        </copy>  		         
-    <jar jarfile="${build.compat.samples}/xalancompatservlet.jar" basedir="${build.compat.samples}"
-         includes="servlet/**"/>
- </target>
- 
-</project>
diff --git a/commits.xml b/commits.xml
deleted file mode 100644
index b43e8f4..0000000
--- a/commits.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0"?>
-<Commits>
-<Commit category="core">
-<Who>costin@apache.org</Who>
-<DateCommitted>03/16/2001</DateCommitted>
-<Modified>java/src/org/apache/xalan/processor StylesheetHandler.java
- java/src/org/apache/xpath Expression.java XPath.java
- XPathContext.java
- java/src/org/apache/xpath/compiler Compiler.java
- XPathParser.java</Modified>
-<Log>Renamed "assert()" to "assertion()".
-
- Assert can be a keyword, and brake the compilation.</Log>
-</Commit>
-<Commit category="core">
-<Who>mmidy@apache.org</Who>
-<DateCommitted>03/19/2001</DateCommitted>
-<Modified>java/src/org/apache/xalan/transformer KeyWalker.java</Modified>
-<Log>Throw an error message if the key name in a key function was not defined</Log>
-</Commit>
-<Commit category="core">
-<Who>jkesselm@apache.org</Who>
-<DateCommitted>03/20/2001</DateCommitted>
-<Modified>java/src/org/apache/xml/utils FastStringBuffer.java</Modified>
-<Log>Reworked "chunk growth" algorithm again. Growing mode not
- yet adequately tested, but fixed-size mode (which is what Xalan
- is currently using) is simpler code and shows improved performance.</Log>
-</Commit>
-<Commit category="core">
-<Who>curcuru@apache.org</Who>
-<DateCommitted>03/20/2001</DateCommitted>
-<Added>java/src/org/apache/xalan/xslt EnvironmentCheck.java</Added>
-<Log>Utility class to check your JVM environment for common problems</Log>
-</Commit>
-<Commit category="compat">
-<Who>jkesselm@apache.org</Who>
-<DateCommitted>03/20/2001</DateCommitted>
-<Modified>java/compat_src/org/apache/xalan/xpath XNumber.java</Modified>
-<Log>Double-semicolon fixed so Henri's compiler stops complaining about an 
-unreachable statement. &lt;grin/&gt;</Log>
-</Commit>
-</Commits>
diff --git a/compat_src/compatOverview.html b/compat_src/compatOverview.html
deleted file mode 100644
index cf64817..0000000
--- a/compat_src/compatOverview.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<HTML><HEAD></HEAD><BODY>
-    <P>This compatibility API supports limited use of the Xalan-Java 1 API in the Xalan-Java 2 environment. For the Xalan-Java 2 API, see <A href="../apidocs/index.html" target="_top">Xalan-Java 2 API</A>.</P>
-  
-     <P><B>Basic procedure for performing transformations:</B></P>
-    <OL>
-      <LI>Use one of the {@link org.apache.xalan.xslt.XSLTProcessorFactory} static getProcessor methods to
-      instantiate an {@link org.apache.xalan.xslt.XSLTProcessor}.<BR><BR>
-       The XSLT and XPath engines are independent from any given DOM or XML implementation. All parser-dependent
-       calls are funneled through the {@link org.apache.xalan.xpath.xml.XMLParserLiaison}.<BR><BR></LI>     
-       <LI>Set up {@link org.apache.xalan.xslt.XSLTInputSource} objects for the XML input and XSL stylesheet. 
-       You can use a file name or URL, character stream, byte stream, or SAX input stream to instantiate an
-       XSLTInputSource object.<BR><BR>
-       If the XML document contains a stylesheet Processing Instruction (PI), you do not need to create a separate
-       XSLTInputSource object for an XSL stylesheet.<BR><BR>
-       <B>Note:</B> For improved performance with a series of transformations, use the XSLTProcessor
-       processStylesheet method to compile the XSL stylesheet. The result is a 
-       {@link org.apache.xalan.xslt.StylesheetRoot} object with its own process() method for performing transformations.
-        Compiling the stylesheet is also useful when you need to get information from the
-       stylesheet before the transformation occurs. You also must compile the stylesheet if you are using the
-        XSLTProcessor as a SAX document handler.<BR><BR></LI>
-       <LI>Set up an {@link org.apache.xalan.xslt.XSLTResultTarget} for the transformation output. You can use a
-       file name or URL, character stream, byte stream, or SAX document handler to instantiate an XSLTResultTarget
-       object.<BR><BR></LI>
-       <LI>Use the XSLTProcessor or (if you have compiled the stylesheet) the(@link org.apache.xalan.xslt.StylesheetRoot}
-       process method to perform the transformation.<BR><BR>
-        Xalan-Java is thread-safe for one instance per thread. If you are using the same instance of XSLTProcessor to
-         perform more than one transformation, call the reset method between transformations.</LI>
-    </OL>
-  </BODY></HTML>
\ No newline at end of file
diff --git a/compat_src/org/apache/xalan/xpath/XBoolean.java b/compat_src/org/apache/xalan/xpath/XBoolean.java
deleted file mode 100644
index a1395bb..0000000
--- a/compat_src/org/apache/xalan/xpath/XBoolean.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath;
-
-import org.w3c.dom.*;
-
-/**
- * <meta name="usage" content="advanced"/>
- * This class represents an XPath boolean object, and is capable of 
- * converting the boolean to other types, such as a string.
- */
-public class XBoolean extends XObject
-{
-  org.apache.xpath.objects.XBoolean m_xboolean;
-  
-  /**
-   * Construct a XBoolean object.
-   */
-  public XBoolean(boolean b)
-  {
-    super(); 
-     m_xboolean = new org.apache.xpath.objects.XBoolean(b);
-  }
-  
-  /**
-   * Tell that this is a CLASS_BOOLEAN.
-   */
-  public int getType()
-  {
-    return m_xboolean.getType();
-  }
-  
-  /**
-   * Given a request type, return the equivalent string. 
-   * For diagnostic purposes.
-   */
-  public String getTypeString() // PR:DMAN4MBJ4D Submitted by:<garyp@firstech.com> change to protected
-  {
-    return m_xboolean.getTypeString();
-  }
-  
-  /**
-   * Cast result object to a number.
-   */
-  public double num()
-  {
-    return m_xboolean.num();
-  }
-
-  /**
-   * Cast result object to a boolean.
-   */
-  public boolean bool()
-  {
-    return m_xboolean.bool();
-  }
-
-  /**
-   * Cast result object to a string.
-   */
-  public String str()
-  {
-    return m_xboolean.str();
-  }
-  
-  /**
-   * Return a java object that's closes to the represenation 
-   * that should be handed to an extension.
-   */
-  public Object object()
-  {
-    return m_xboolean.object();
-  }
-
-  /**
-   * Tell if two objects are functionally equal.
-   */
-  public boolean equals(XObject obj2)
-    throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
-  {    
-    return m_xboolean.equals(obj2);
-  }
-  
-  
-}
-
diff --git a/compat_src/org/apache/xalan/xpath/XBooleanStatic.java b/compat_src/org/apache/xalan/xpath/XBooleanStatic.java
deleted file mode 100644
index 9639687..0000000
--- a/compat_src/org/apache/xalan/xpath/XBooleanStatic.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath;
-
-import org.w3c.dom.*;
-
-/**
- * <meta name="usage" content="internal"/>
- * This class doesn't have any XPathSupport, so override 
- * whatever to ensure it works OK.
- */
-public class XBooleanStatic extends XBoolean
-{
-  org.apache.xpath.objects.XBooleanStatic m_xboolean;
-  
-  /**
-   * Construct a XNodeSet object.
-   */
-  public XBooleanStatic(boolean b)
-  {
-    super(b); 
-    m_xboolean = new org.apache.xpath.objects.XBooleanStatic(b);
-  } 
-  
-  /**
-   * Tell if two objects are functionally equal.
-   */
-  public boolean equals(XObject obj2)
-    throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
-  {
-    return m_xboolean.equals(obj2);
-  }
-
-}
-
diff --git a/compat_src/org/apache/xalan/xpath/XNodeSet.java b/compat_src/org/apache/xalan/xpath/XNodeSet.java
deleted file mode 100644
index 019ffee..0000000
--- a/compat_src/org/apache/xalan/xpath/XNodeSet.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath;
-
-import org.w3c.dom.*;
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.traversal.NodeFilter;
-import java.text.*;
-
-import org.apache.xpath.XPathContext;
-import org.apache.xpath.NodeSet;
-
-/**
- * <meta name="usage" content="general"/>
- * This class represents an XPath nodeset object, and is capable of 
- * converting the nodeset to other types, such as a string.
- */
-public class XNodeSet extends XObject  
-{
-  org.apache.xpath.objects.XNodeSet m_xnodeset;
-  
-  /**
-   * Construct a XNodeSet object.
-   */
-  public XNodeSet(NodeList val)
-  {
-    super();
-    m_xnodeset = new org.apache.xpath.objects.XNodeSet(new NodeIteratorWrapper(val)) ;
-  }
-  
-  /**
-   * Construct an empty XNodeSet object.
-   */
-  public XNodeSet()
-  {
-    super();
-    m_xnodeset = new org.apache.xpath.objects.XNodeSet();
-  }
-
-  /**
-   * Construct a XNodeSet object for one node.
-   */
-  public XNodeSet(Node n)
-  {
-    super(n); 
-    m_xnodeset = new org.apache.xpath.objects.XNodeSet(n);
-  }
-  
-  
-  /**
-   * Tell that this is a CLASS_NODESET.
-   */
-  public int getType()
-  {
-    return m_xnodeset.getType();
-  }
-  
-  /**
-   * Given a request type, return the equivalent string. 
-   * For diagnostic purposes.
-   */
-  public String getTypeString() // PR:DMAN4MBJ4D Submitted by:<garyp@firstech.com> change to protected
-  {
-    return m_xnodeset.getTypeString();
-  }
-  
-  /**
-   * Get the string conversion from a single node.
-   */
-  double getNumberFromNode(Node n)
-  {
-    return m_xnodeset.getNumberFromNode(n);
-  }
-
-  /**
-   * Cast result object to a number.
-   */
-  public double num()
-  {
-    return m_xnodeset.num();
-  }
-
-  /**
-   * Cast result object to a boolean.
-   */
-  public boolean bool()
-  {
-    return m_xnodeset.bool();
-  }
-  
-
-  /**
-   * Get the string conversion from a single node.
-   */
-  static String getStringFromNode(Node n)
-  {
-    return org.apache.xpath.objects.XNodeSet.getStringFromNode(n);
-  }
-
-  /**
-   * Cast result object to a string.
-   */
-  public String str()
-  {
-    return m_xnodeset.str();
-  }
-  
-  /**
-   * Cast result object to a result tree fragment.
-   */
-  public DocumentFragment rtree(XPathSupport support)
-  {    
-    return m_xnodeset.rtree((XPathContext) support);
-  }
-  
-  /**
-   * Cast result object to a result tree fragment.
-   *
-   * @param support The XPath context to use for the conversion 
-   *
-   * @return the nodeset as a result tree fragment.
-   */
-  public DocumentFragment rtree(XPathContext support)
-  {
-    return m_xnodeset.rtree(support);
-  }
-
-  /**
-   * Cast result object to a nodelist.
-   */
-  public NodeIterator nodeset()
-  {
-    return m_xnodeset.nodeset();
-  }  
-
-  /**
-   * Cast result object to a nodelist.
-   */
-  public NodeSet mutableNodeset()
-  {
-   return m_xnodeset.mutableNodeset();
-  }  
-  
-  /**
-   * Tell if one object is less than the other.
-   */
-  public boolean lessThan(XObject obj2)
-    throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
-  {
-    return m_xnodeset.lessThan(obj2);
-  }
-  
-  /**
-   * Tell if one object is less than or equal to the other.
-   */
-  public boolean lessThanOrEqual(XObject obj2)
-    throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
-  {
-    return m_xnodeset.lessThanOrEqual(obj2);
-  }
-  
-  /**
-   * Tell if one object is greater than the other.
-   */
-  public boolean greaterThan(XObject obj2)
-    throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
-  {
-    return m_xnodeset.greaterThan(obj2);
-  }
-  
-  /**
-   * Tell if one object is greater than the other.
-   */
-  public boolean greaterThanOrEqual(XObject obj2)
-    throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
-  {
-    return m_xnodeset.greaterThanOrEqual(obj2);
-  }   
-  
-  /**
-   * Tell if two objects are functionally equal.
-   */
-  public boolean equals(XObject obj2)
-    throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
-  {
-    return m_xnodeset.equals(obj2);
-  }  
-  
-  /**
-   * Tell if two objects are functionally not equal.
-   */
-  public boolean notEquals(XObject obj2)
-    throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
-  {
-    return m_xnodeset.notEquals(obj2);
-  }  
- 
- static class NodeIteratorWrapper implements NodeIterator
-  {
-
-    /** Position of next node          */
-    private int m_pos = 0;
-
-    /** Document fragment instance this will wrap         */
-    private NodeList m_list;
-
-    /**
-     * Constructor NodeIteratorWrapper
-     *
-     *
-     * @param df Document fragment instance this will wrap
-     */
-    NodeIteratorWrapper(NodeList list)
-    {
-      m_list = list;
-    }
-
-    /**
-     *  The root node of the Iterator, as specified when it was created.
-     *
-     * @return null
-     */
-    public Node getRoot()
-    {
-      return null;
-    }
-
-    /**
-     *  This attribute determines which node types are presented via the
-     * iterator. The available set of constants is defined in the
-     * <code>NodeFilter</code> interface.
-     *
-     * @return All node types
-     */
-    public int getWhatToShow()
-    {
-      return NodeFilter.SHOW_ALL;
-    }
-
-    /**
-     *  The filter used to screen nodes.
-     *
-     * @return null
-     */
-    public NodeFilter getFilter()
-    {
-      return null;
-    }
-
-    /**
-     *  The value of this flag determines whether the children of entity
-     * reference nodes are visible to the iterator. If false, they will be
-     * skipped over.
-     * <br> To produce a view of the document that has entity references
-     * expanded and does not expose the entity reference node itself, use the
-     * whatToShow flags to hide the entity reference node and set
-     * expandEntityReferences to true when creating the iterator. To produce
-     * a view of the document that has entity reference nodes but no entity
-     * expansion, use the whatToShow flags to show the entity reference node
-     * and set expandEntityReferences to false.
-     *
-     * @return true
-     */
-    public boolean getExpandEntityReferences()
-    {
-      return true;
-    }
-
-    /**
-     *  Returns the next node in the set and advances the position of the
-     * iterator in the set. After a NodeIterator is created, the first call
-     * to nextNode() returns the first node in the set.
-     * @return  The next <code>Node</code> in the set being iterated over, or
-     *   <code>null</code> if there are no more members in that set.
-     * @throws DOMException
-     *    INVALID_STATE_ERR: Raised if this method is called after the
-     *   <code>detach</code> method was invoked.
-     */
-    public Node nextNode() throws DOMException
-    {
-
-      if (m_pos < m_list.getLength())
-      {
-        return m_list.item(m_pos++);
-      }
-      else
-        return null;
-    }
-
-    /**
-     *  Returns the previous node in the set and moves the position of the
-     * iterator backwards in the set.
-     * @return  The previous <code>Node</code> in the set being iterated over,
-     *   or<code>null</code> if there are no more members in that set.
-     * @throws DOMException
-     *    INVALID_STATE_ERR: Raised if this method is called after the
-     *   <code>detach</code> method was invoked.
-     */
-    public Node previousNode() throws DOMException
-    {
-
-      if (m_pos >0)
-      {
-        return m_list.item(m_pos-1);
-      }
-      else
-        return null;
-    }
-
-    /**
-     *  Detaches the iterator from the set which it iterated over, releasing
-     * any computational resources and placing the iterator in the INVALID
-     * state. After<code>detach</code> has been invoked, calls to
-     * <code>nextNode</code> or<code>previousNode</code> will raise the
-     * exception INVALID_STATE_ERR.
-     */
-    public void detach(){}
-  }
-  
-
-}
diff --git a/compat_src/org/apache/xalan/xpath/XNull.java b/compat_src/org/apache/xalan/xpath/XNull.java
deleted file mode 100644
index 473a658..0000000
--- a/compat_src/org/apache/xalan/xpath/XNull.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath;
-
-import org.w3c.dom.*;
-import org.w3c.dom.traversal.NodeIterator;
-
-import org.apache.xpath.XPathContext;
-
-/**
- * <meta name="usage" content="general"/>
- * This class represents an XPath null object, and is capable of 
- * converting the null to other types, such as a string.
- */
-public class XNull extends XObject
-{
-  org.apache.xpath.objects.XNull m_xnull;
-  /**
-   * Create an XObject.
-   */
-  public XNull()
-  {
-    super();
-    m_xnull = new org.apache.xpath.objects.XNull() ;
-  }
-  
-  /**
-   * Tell what kind of class this is.
-   */
-  public int getType()
-  {
-    return m_xnull.getType();
-  }
-
-  /**
-   * Given a request type, return the equivalent string. 
-   * For diagnostic purposes.
-   */
-  public String getTypeString() // PR:DMAN4MBJ4D Submitted by:<garyp@firstech.com> change to protected
-  {
-    return m_xnull.getTypeString();
-  }
-  
-  /**
-   * Cast result object to a number.
-   */
-  public double num()
-  {
-    return m_xnull.num();
-  }
-
-  /**
-   * Cast result object to a boolean.
-   */
-  public boolean bool()
-  {
-    return m_xnull.bool();
-  }
-
-  /**
-   * Cast result object to a string.
-   */
-  public String str()
-  {
-    return m_xnull.str();
-  }
-  
-  /**
-   * Cast result object to a result tree fragment.
-   */
-  public DocumentFragment rtree(XPathSupport support)
-  {
-    return m_xnull.rtree((XPathContext)support);
-  }
-  
-  /**
-   * Cast result object to a result tree fragment.
-   *
-   * @param support XPath context to use for the conversion
-   *
-   * @return The object as a result tree fragment.
-   */
-  public DocumentFragment rtree(XPathContext support)
-  {
-    return m_xnull.rtree(support);
-  }
-
-
-  /**
-   * Cast result object to a nodelist.
-   */
-  public NodeIterator nodeset()
-  {
-    return null;
-  }  
-   
-  /**
-   * Tell if two objects are functionally equal.
-   */
-  public boolean equals(XObject obj2)
-  {
-    return m_xnull.equals(obj2);
-  }
-
-  
-}
diff --git a/compat_src/org/apache/xalan/xpath/XNumber.java b/compat_src/org/apache/xalan/xpath/XNumber.java
deleted file mode 100644
index bf8e286..0000000
--- a/compat_src/org/apache/xalan/xpath/XNumber.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath;
-
-import org.w3c.dom.*;
-import java.text.DecimalFormat;
-
-/**
- * <meta name="usage" content="general"/>
- * This class represents an XPath number, and is capable of 
- * converting the number to other types, such as a string.
- */
-public class XNumber extends XObject
-{
-  
-  org.apache.xpath.objects.XNumber m_xnumber;
-  /**
-   * Construct a XNodeSet object.
-   */
-  public XNumber(double d)
-  {
-    super();
-    m_xnumber = new org.apache.xpath.objects.XNumber(d);
-  }
-  
-  /**
-   * Tell that this is a CLASS_NUMBER.
-   */
-  public int getType()
-  {
-    return m_xnumber.getType();
-  }
-  
-  /**
-   * Given a request type, return the equivalent string. 
-   * For diagnostic purposes.
-   */
-  public String getTypeString() // PR:DMAN4MBJ4D Submitted by:<garyp@firstech.com> change to protected
-  {
-    return m_xnumber.getTypeString();
-  }
-  
-  /**
-   * Cast result object to a number.
-   */
-  public double num()
-  {
-    return m_xnumber.num();
-  }
-
-  /**
-   * Cast result object to a boolean.
-   */
-  public boolean bool()
-  {
-    return m_xnumber.bool();
-  }
-  
-  /**
-   * Cast result object to a string.
-   */
-  public String str()
-  {
-    return m_xnumber.str();
-  }
-  
-  /**
-   * Return a java object that's closes to the represenation 
-   * that should be handed to an extension.
-   */
-  public Object object()
-  {
-    return m_xnumber.object();
-  }
-
-  /**
-   * Tell if two objects are functionally equal.
-   */
-  public boolean equals(XObject obj2)
-    throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
-  {
-    return m_xnumber.equals(obj2);
-  }
-  
-  
-}
-
diff --git a/compat_src/org/apache/xalan/xpath/XObject.java b/compat_src/org/apache/xalan/xpath/XObject.java
deleted file mode 100644
index f0cb33e..0000000
--- a/compat_src/org/apache/xalan/xpath/XObject.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * The Apache Software License, Version 1.1 
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>. 
- */
-package org.apache.xalan.xpath;
-
-
-/**
- * <meta name="usage" content="general"/>
- * This class represents an XPath object, and is capable of 
- * converting the object to various types, such as a string.
- * This class acts as the base class to other XPath type objects, 
- * such as XString, and provides polymorphic casting capabilities.
- */
-public class XObject extends org.apache.xpath.objects.XObject
-{
-  
-  
-  /**
-   * Create an XObject.
-   */
-  public XObject()
-  {
-    super();
-  }
-
-  /**
-   * Create an XObject.
-   */
-  public XObject(Object obj)
-  {
-    super(obj);
-  }   
-
-}
diff --git a/compat_src/org/apache/xalan/xpath/XPathSupport.java b/compat_src/org/apache/xalan/xpath/XPathSupport.java
deleted file mode 100644
index 0a98708..0000000
--- a/compat_src/org/apache/xalan/xpath/XPathSupport.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath;
-
-import org.w3c.dom.*;
-import java.util.*;
-import java.net.URL;
-import org.xml.sax.*;
-
-
-
-
-/**
- * <meta name="usage" content="advanced"/>
- * Provides basic support for independent use of XPath.  This interface 
- * is used in order that there may be loose coupling between the 
- * XPath package and the support services, such as the variable store, 
- * parser services, DOM implementation, etc.  Most if all implementations
- * of this should derive from XPathSupportDefault (hence, it should 
- * probably be an abstract class instead of an interface).
- */
-public interface XPathSupport extends org.apache.xalan.extensions.ExpressionContext
-{
-  
-}
diff --git a/compat_src/org/apache/xalan/xpath/XPathSupportDefault.java b/compat_src/org/apache/xalan/xpath/XPathSupportDefault.java
deleted file mode 100644
index c291d19..0000000
--- a/compat_src/org/apache/xalan/xpath/XPathSupportDefault.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath;
-
-import java.util.*;
-import org.w3c.dom.*;
-
-
-
-/**
- * <meta name="usage" content="advanced"/>
- * Default class for execution context when XPath is used by itself. Many 
- * of the functions in this class need to be overridden in order to 
- * perform correct execution of the XPath (for instance, variable 
- * execution).  This class will likely eventually replace XMLParserLiaisons.
- */
-public class XPathSupportDefault extends org.apache.xpath.XPathContext implements XPathSupport 
-{
-  
-}
diff --git a/compat_src/org/apache/xalan/xpath/XRTreeFrag.java b/compat_src/org/apache/xalan/xpath/XRTreeFrag.java
deleted file mode 100644
index a08cf18..0000000
--- a/compat_src/org/apache/xalan/xpath/XRTreeFrag.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath;
-
-import org.w3c.dom.*;
-
-/**
- * <meta name="usage" content="general"/>
- * This class represents an XPath result tree fragment object, and is capable of 
- * converting the RTF to other types, such as a string.
- */
-public class XRTreeFrag extends XObject 
-{ 
-  
-  org.apache.xpath.objects.XRTreeFrag m_xrtreefrag;
-  
-  /**
-   * Create an XObject.
-   */
-  public XRTreeFrag(DocumentFragment frag)
-  {
-    super(frag);
-    m_xrtreefrag = new org.apache.xpath.objects.XRTreeFrag(frag); 
-  }
-  
-  /**
-   * Tell what kind of class this is.
-   */
-  public int getType()
-  {
-    return m_xrtreefrag.getType();
-  }
-
-  /**
-   * Given a request type, return the equivalent string. 
-   * For diagnostic purposes.
-   */
-  public String getTypeString() // PR:DMAN4MBJ4D Submitted by:<garyp@firstech.com> change to protected
-  {
-    return m_xrtreefrag.getTypeString();
-  }
-  
-  /**
-   * Cast result object to a number.
-   */
-  public double num()
-  {    
-    return m_xrtreefrag.num();
-  }
-
-  /**
-   * Cast result object to a boolean.
-   */
-  public boolean bool()
-  {
-    return m_xrtreefrag.bool();
-  }
-
-  /**
-   * Cast result object to a string.
-   */
-  public String str()
-  {
-    return m_xrtreefrag.str();
-  }
-  
-  /**
-   * Cast result object to a result tree fragment.
-   */
-  public DocumentFragment rtree()
-  {
-    return m_xrtreefrag.rtree();
-  }
-  
-  /**
-   * Cast result object to a nodelist. (special function).
-   */
-  public NodeList convertToNodeset()
-  {
-    return m_xrtreefrag.convertToNodeset();
-  }  
-  
-  /**
-   * Tell if two objects are functionally equal.
-   */
-  public boolean equals(XObject obj2)
-    throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
-  {   
-      return m_xrtreefrag.equals(obj2);    
-  }
-  
-  
-}
diff --git a/compat_src/org/apache/xalan/xpath/XString.java b/compat_src/org/apache/xalan/xpath/XString.java
deleted file mode 100644
index 9d2dc6e..0000000
--- a/compat_src/org/apache/xalan/xpath/XString.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath;
-
-
-import org.w3c.dom.*;
-
-import org.apache.xpath.XPathContext;
-/**
- * <meta name="usage" content="general"/>
- * This class represents an XPath string object, and is capable of 
- * converting the string to other types, such as a number.
- */
-public class XString extends XObject
-{
-  
-  org.apache.xpath.objects.XString m_xstring;
-  
-  /**
-   * Construct a XString object.
-   */
-  public XString(String val)
-  {
-    super(val);
-    m_xstring = new org.apache.xpath.objects.XString(val);
-  }
-  
-   /**
-   * Tell that this is a CLASS_STRING.
-   */
-  public int getType()
-  {
-    return m_xstring.getType();
-  }
-  
-  /**
-   * Given a request type, return the equivalent string. 
-   * For diagnostic purposes.
-   */
-  public String getTypeString() // PR:DMAN4MBJ4D Submitted by:<garyp@firstech.com> change to protected
-  {
-    return m_xstring.getTypeString();
-  }
-  
-  /**
-   * Cast a string to a number.
-   */
-  public static double castToNum(String s)
-  {  
-    return org.apache.xpath.objects.XString.castToNum(s);    
-  }
-  
-  /**
-   * Cast result object to a number.
-   */
-  public double num()
-  {
-    return m_xstring.num();
-  }
-
-  /**
-   * Cast result object to a boolean.
-   */
-  public boolean bool()
-  {
-    return m_xstring.bool();
-  }
-
-  /**
-   * Cast result object to a string.
-   */
-  public String str()
-  {
-    return m_xstring.str();
-  }
-  
-  /**
-   * Cast result object to a result tree fragment.
-   */
-  public DocumentFragment rtree(XPathSupport support)
-  {    
-    return m_xstring.rtree((XPathContext)support);
-  }
-  
-  
-  /**
-   * Cast result object to a result tree fragment.
-   *
-   * @param support Xpath context to use for the conversion 
-   *
-   * @return A document fragment with this string as a child node
-   */
-  public DocumentFragment rtree(XPathContext support)
-  {      
-    return m_xstring.rtree(support);
-  }
-  
-  /**
-   * Tell if two objects are functionally equal.
-   */
-  public boolean equals(XObject obj2)
-    throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
-  {
-    return m_xstring.equals(obj2);
-  }
-
-  
-}
diff --git a/compat_src/org/apache/xalan/xpath/package.html b/compat_src/org/apache/xalan/xpath/package.html
deleted file mode 100644
index 29a55da..0000000
--- a/compat_src/org/apache/xalan/xpath/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<HTML><HEAD></HEAD><BODY>
-     <P>Infrastructure for processing XPATH expressions</P>
-   
-     <P></P>
-   </BODY></HTML>
\ No newline at end of file
diff --git a/compat_src/org/apache/xalan/xpath/xdom/XercesLiaison.java b/compat_src/org/apache/xalan/xpath/xdom/XercesLiaison.java
deleted file mode 100644
index 5622796..0000000
--- a/compat_src/org/apache/xalan/xpath/xdom/XercesLiaison.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath.xdom;
-
-import java.net.*;
-import java.io.*;
-import java.util.*;
-import org.apache.xerces.dom.*;
-import org.apache.xerces.parsers.*;
-import org.apache.xerces.framework.*;
-import org.xml.sax.*;
-import org.w3c.dom.*;
-import org.apache.xalan.xpath.xml.*;
-import org.apache.xalan.xpath.*;
-import org.apache.xpath.res.XPATHErrorResources;
-import org.apache.xalan.res.XSLMessages;
-
-import javax.xml.transform.TransformerException;
-import javax.xml.parsers.*;
-
-
-/**
- * <meta name="usage" content="general"/>
- * Provides XSLTProcessor an interface to the Xerces XML parser.  This 
- * liaison should be used if Xerces DOM nodes are being process as 
- * the source tree or as the result tree.
- * @see org.apache.xalan.xslt.XSLTProcessor
- * @see org.apache.xml.parsers
- */
-public class XercesLiaison extends XMLParserLiaisonDefault //implements XPathSupport
-{
-  /**
-   * Return a string suitible for telling the user what parser is being used.
-   */
-  public String getParserDescription()
-  {
-    return "XML4J Version "+ getXML4JVersionString();
-  }
-
-	private org.xml.sax.ErrorHandler m_errorHandler;
-  /**
-   * Constructor that takes SAX ErrorHandler as an argument. The error handler
-   * is registered with the XML Parser. Any XML-related errors will be reported
-   * to the calling application using this error handler.
-   *
-   * @param	errorHandler SAX ErrorHandler instance.
-   */
-  public XercesLiaison(org.xml.sax.ErrorHandler errorHandler)
-  {
-    m_errorHandler = errorHandler;
-  }
-
-  /**
-   * Construct an instance.
-   *
-  public XercesLiaison(XPathEnvSupport envSupport)
-  {
-    m_envSupport = envSupport;
-  }*/
-
-  /**
-   * Construct an instance.
-   */
-  public XercesLiaison()
-  {
-  }
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Check node to see if it matches this liaison.
-   */
-  public void checkNode(Node node)
-    throws TransformerException
-  {
-    if(!(node instanceof org.apache.xerces.dom.NodeImpl))
-      throw new TransformerException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_XERCES_CANNOT_HANDLE_NODES, new Object[]{((Object)node).getClass()})); //"XercesLiaison can not handle nodes of type"
-        //+((Object)node).getClass());
-  }
-
-  /**
-   * Returns true that this implementation does support
-   * the SAX DocumentHandler interface.
-   */
-  public boolean supportsSAX()
-  {
-    return true;
-  }
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Get Xerces version field... we have to do this 'cause
-   * the "public static final" fields seem to get bound
-   * at compile time otherwise.
-   */
-  private String getXML4JVersionString()
-  {
-    // return Version.fVersion;
-    String version = "";
-    try
-    {
-      java.lang.reflect.Field versionField = Version.class.getField("fVersion");
-      version = (String)versionField.get(null);
-    }
-    catch(Exception e)
-    {
-    }
-    return version;
-  }
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Get one of the Xerces version numbers...
-   * we have to do this 'cause the "public static final"
-   * fields seem to get bound at compile time otherwise.
-   */
-  private int getXML4JVersionNum(int field)
-  {
-    int versionNum = 0;
-    String ver = getXML4JVersionString();
-    StringTokenizer tokenizer = new StringTokenizer(ver, " .");
-    for(int i = 0; tokenizer.hasMoreTokens(); i++)
-    {
-      String tok = tokenizer.nextToken();
-      if(field == i)
-      {
-        versionNum = Integer.parseInt(tok);
-      }
-    }
-    return versionNum;
-  }
-  
-  /**
-   * Pool the DOM parsers for reuse.
-   *
-  private ObjectPool m_domParserPool = new ObjectPool(DOMParser.class);
-  
-  /**
-   * Pool the SAX parsers for reuse.
-   *
-  private ObjectPool m_saxParserPool = new ObjectPool(SAXParser.class);
- 
-  /**
-   * Count the parses since the last garbage collection.  GC every 
-   * 10 parses or so.  (This might be a bad idea, but it seems to 
-   * help...)
-   *
-  protected int m_parseCountSinceGC = 0;
-*/
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Parse an XML document.
-   *
-   * <p>The application can use this method to instruct the SAX parser
-   * to begin parsing an XML document from any valid input
-   * source (a character stream, a byte stream, or a URI).</p>
-   *
-   * <p>Applications may not invoke this method while a parse is in
-   * progress (they should create a new Parser instead for each
-   * additional XML document).  Once a parse is complete, an
-   * application may reuse the same Parser object, possibly with a
-   * different input source.</p>
-   *
-   * @param source The input source for the top-level of the
-   *        XML document.
-   * @exception org.xml.sax.SAXException Any SAX exception, possibly
-   *            wrapping another exception.
-   * @exception java.io.IOException An IO exception from the parser,
-   *            possibly from a byte stream or character stream
-   *            supplied by the application.
-   * @see org.xml.sax.InputSource
-   * @see #parse(java.lang.String)
-   * @see #setEntityResolver
-   * @see #setDTDHandler
-   * @see #setDocumentHandler
-   * @see #setErrorHandler
-   */
-  public void parse (InputSource source)
-    throws javax.xml.transform.TransformerException
-  {
-   try
-    {
-
-      // I guess I should use JAXP factory here... when it's legal.
-      // org.apache.xerces.parsers.DOMParser parser 
-      //  = new org.apache.xerces.parsers.DOMParser();
-      DocumentBuilderFactory builderFactory =
-        DocumentBuilderFactory.newInstance();
-
-      builderFactory.setNamespaceAware(true);      
-
-      DocumentBuilder parser = builderFactory.newDocumentBuilder();
-			if (m_errorHandler == null)
-				parser.setErrorHandler(new org.apache.xml.utils.DefaultErrorHandler());
-			else
-				parser.setErrorHandler(m_errorHandler);
-
-      // if(null != m_entityResolver)
-      // {
-      // System.out.println("Setting the entity resolver.");
-      //  parser.setEntityResolver(m_entityResolver);
-      // }
-      setDocument(parser.parse(source));
-    }
-    catch (org.xml.sax.SAXException se)
-    {
-      throw new TransformerException(se);
-    }
-    catch (ParserConfigurationException pce)
-    {
-      throw new TransformerException(pce);
-    }
-    catch (IOException ioe)
-    {
-      throw new TransformerException(ioe);
-    }
-  }
-  
-  public void copyFromOtherLiaison(XMLParserLiaisonDefault from)
-    throws SAXException
-  {
-    //super.copyFromOtherLiaison(from);
-    if(null != from) // defensive
-    {
-      if(from instanceof XercesLiaison)
-        this.m_useDOM2getNamespaceURI = ((XercesLiaison)from).m_useDOM2getNamespaceURI;
-    }
- }
-
-
-  /**
-   * Create an empty DOM Document.  Mainly used for creating an
-   * output document.  Implementation of XMLParserLiaison
-   * interface method.
-   */
-  public Document createDocument()
-  {
-    org.apache.xerces.dom.DocumentImpl doc = new org.apache.xerces.dom.DocumentImpl();
-    return doc;
-  }
-
-  /**
-   * Given an ID, return the element.
-   */
-  public Element getElementByID(String id, Document doc)
-  {
-    return ((DocumentImpl)doc).getIdentifier(id);
-  }
-
-  /**
-   * Tell if the node is ignorable whitespace.
-   * @deprecated
-   */
-  public boolean isIgnorableWhitespace(Text node)
-  {
-    boolean isIgnorable;
-    if( node instanceof org.apache.xerces.dom.TextImpl)
-    {
-      isIgnorable = ((org.apache.xerces.dom.TextImpl)node).isIgnorableWhitespace();
-    }
-    else
-    {
-      isIgnorable = false;
-    }
-    return isIgnorable;
-  }
-  
-  protected boolean m_useDOM2getNamespaceURI = true;
-  
-  /**
-   * Set whether or not getNamespaceOfNode should use the Xerces/DOM2
-   * getNamespaceURI.  This has to be set to true if the 
-   * http://xml.org/sax/features/namespaces is set to false, or if 
-   * the tree is mutated.
-   */
-  public void setUseDOM2getNamespaceURI(boolean b)
-  {
-    m_useDOM2getNamespaceURI = b;
-  }
-
-  
-  /**
-   * Get the namespace of the node.  Calls org.apache.xerces.dom.NodeImpl's
-   * getNamespaceURI() if setUseDOM2getNamespaceURI(true) has been called.
-   */
-  public String getNamespaceOfNode(Node n)
-  {
-    return(m_useDOM2getNamespaceURI) ?
-          ((org.apache.xerces.dom.NodeImpl)n).getNamespaceURI()
-          : super.getNamespaceOfNode(n);
-  }
-  
-
-  /**
-  * Returns the local name of the given node.
-  */
-  // public String getLocalNameOfNode(Node n)
-  // {
-  //   return ((org.apache.xerces.dom.NodeImpl)n).getLocalName();
-  // }
-
-  /**
-  * Returns the element name with the namespace expanded.
-  */
-  // public String getExpandedElementName(Element elem)
-  // {
-  //  String namespace = getNamespaceOfNode(elem);
-  //   return (null != namespace) ? namespace+":"+ getLocalNameOfNode(elem)
-  //                                : getLocalNameOfNode(elem);
-  // }
-
-  /**
-  * Returns the attribute name with the namespace expanded.
-  */
-  // public String getExpandedAttributeName(Attr attr)
-  // {
-  //  String namespace = getNamespaceOfNode(attr);
-  //   return (null != namespace) ? namespace+":"+ getLocalNameOfNode(attr)
-  //                               : getLocalNameOfNode(attr);
-  // }
-
-  /**
-   * Get the parent of a node.
-   */
-  public Node getParentOfNode(Node node)
-    throws RuntimeException
-  {
-    return (Node.ATTRIBUTE_NODE == node.getNodeType())
-           ? ((Attr)node).getOwnerElement() : node.getParentNode();
-  }
-
-}
-
-
diff --git a/compat_src/org/apache/xalan/xpath/xml/FormatterToDOM.java b/compat_src/org/apache/xalan/xpath/xml/FormatterToDOM.java
deleted file mode 100644
index 9c1e25a..0000000
--- a/compat_src/org/apache/xalan/xpath/xml/FormatterToDOM.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath.xml;
-
-import org.w3c.dom.*;
-import org.apache.xalan.serialize.Serializer;
-import org.apache.xalan.serialize.SerializerFactory;
-//import org.apache.xml.serialize.BaseMarkupSerializer;
-import org.apache.xalan.serialize.DOMSerializer;
-import org.apache.xalan.serialize.SerializerToXML;
-import org.xml.sax.helpers.ParserAdapter;
-import org.xml.sax.SAXException;
-
-
-/**
- * <meta name="usage" content="general"/>
- * This class takes SAX events (in addition to some extra events 
- * that SAX doesn't handle yet) and adds the result to a document 
- * or document fragment.
- */
-public class FormatterToDOM extends ParserAdapter
-{ 
-  DOMSerializer m_serializer;
-    
-  /**
-   * FormatterToDOM instance constructor... it will add the DOM nodes 
-   * to the document fragment.
-   */
-  public FormatterToDOM(Document doc, Element elem) throws SAXException
-  {
-    super(new org.apache.xerces.parsers.SAXParser());
-    try{
-      m_serializer = (new SerializerToXML()).asDOMSerializer();
-      this.setContentHandler((SerializerToXML)m_serializer);
-    }
-    catch (java.io.IOException ioe)
-    {}
-  }
-
-  /**
-   * FormatterToDOM instance constructor... it will add the DOM nodes 
-   * to the document fragment.
-   */
-  public FormatterToDOM(Document doc, DocumentFragment docFrag) throws SAXException
-  {
-    super(new org.apache.xerces.parsers.SAXParser()); 
-    try{
-      m_serializer = (new SerializerToXML()).asDOMSerializer();
-      this.setContentHandler((SerializerToXML)m_serializer);
-    }
-    catch (java.io.IOException ioe)
-    {}
-  }
-
-  /**
-   * FormatterToDOM instance constructor... it will add the DOM nodes 
-   * to the document.
-   */
-  public FormatterToDOM(Document doc) throws SAXException
-  {
-    super(new org.apache.xerces.parsers.SAXParser());
-    try{
-      m_serializer = (new SerializerToXML()).asDOMSerializer();
-      this.setContentHandler((SerializerToXML)m_serializer);
-    }
-    catch (java.io.IOException ioe)
-    {}
-  }
-  
-  public SerializerToXML getSerializerObject()
-  {
-    return (SerializerToXML)m_serializer;
-  }
-
-}
diff --git a/compat_src/org/apache/xalan/xpath/xml/FormatterToHTML.java b/compat_src/org/apache/xalan/xpath/xml/FormatterToHTML.java
deleted file mode 100644
index b0621b2..0000000
--- a/compat_src/org/apache/xalan/xpath/xml/FormatterToHTML.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath.xml;
-
-import java.io.Writer;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-
-import org.apache.xalan.serialize.Serializer;
-import org.apache.xalan.serialize.SerializerFactory;
-import org.apache.xalan.serialize.SerializerToHTML;
-import org.xml.sax.helpers.ParserAdapter;
-import org.xml.sax.SAXException;
-//import org.apache.xml.serialize.OutputFormat;
-
-/**
- * <meta name="usage" content="general"/>
- * FormatterToHTML formats SAX-style events into XML.
- * Warning: this class will be replaced by the Xerces Serializer classes.
- */
-public class FormatterToHTML extends ParserAdapter
-{ 
-  
-  SerializerToHTML m_serializer;
-  
-  public FormatterToHTML() throws SAXException 
-  {
-    super(new org.apache.xerces.parsers.SAXParser());
-    m_serializer = new SerializerToHTML();
-    this.setContentHandler(m_serializer);  
-  }
-  
-  /**
-   * Constructor using a writer.
-   * @param writer        The character output stream to use.
-   */
-  public FormatterToHTML(Writer writer) throws SAXException  
-  {
-    super(new org.apache.xerces.parsers.SAXParser());
-    m_serializer = new SerializerToHTML();
-    m_serializer.setWriter(writer);
-    this.setContentHandler(m_serializer);    
-  }
-  
-  /**
-   * Constructor using an output stream, and a simple OutputFormat.
-   * @param writer        The character output stream to use.
-   */
-  public FormatterToHTML(java.io.OutputStream os)  
-    throws UnsupportedEncodingException, SAXException 
-  {
-    super(new org.apache.xerces.parsers.SAXParser());
-    m_serializer = new SerializerToHTML();
-    m_serializer.setOutputStream(os);
-    this.setContentHandler(m_serializer);
-    
-  }
-  
-  /**
-   * Constructor using a writer.
-   * @param writer        The character output stream to use.
-   */
-  public FormatterToHTML(FormatterToXML xmlListener) throws SAXException 
-  {
-    super(new org.apache.xerces.parsers.SAXParser());
-    m_serializer = new SerializerToHTML();
-    m_serializer.CopyFrom(xmlListener.m_serializer);
-    this.setContentHandler(m_serializer);
-  }
-  
-  public SerializerToHTML getSerializerObject()
-  {
-    return m_serializer;
-  }
-  
-}
-
diff --git a/compat_src/org/apache/xalan/xpath/xml/FormatterToText.java b/compat_src/org/apache/xalan/xpath/xml/FormatterToText.java
deleted file mode 100644
index 2292679..0000000
--- a/compat_src/org/apache/xalan/xpath/xml/FormatterToText.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath.xml;
-
-import java.io.Writer;
-
-import org.apache.xalan.serialize.Serializer;
-import org.apache.xalan.serialize.SerializerFactory;
-import org.apache.xalan.serialize.SerializerToText;
-import org.xml.sax.helpers.ParserAdapter;
-import org.xml.sax.SAXException;
-
-/**
- * <meta name="usage" content="general"/>
- * This class takes SAX events (in addition to some extra events 
- * that SAX doesn't handle yet) and produces simple text only.
- * Warning: this class will be replaced by the Xerces Serializer classes.
- */
-public class FormatterToText extends ParserAdapter
-{
-  
-  private SerializerToText m_serializer;
-  /**
-   * FormatterToText instance constructor... it will add the DOM nodes 
-   * to the document fragment.
-   */
-  public FormatterToText(Writer pw) throws SAXException
-  {
-    super(new org.apache.xerces.parsers.SAXParser());
-    m_serializer = new SerializerToText(); 
-    m_serializer.setWriter(pw);
-    this.setContentHandler(m_serializer);
-  }
-  
-  public SerializerToText getSerializerObject()
-  {
-    return m_serializer;
-  }
-
-
-}
diff --git a/compat_src/org/apache/xalan/xpath/xml/FormatterToXML.java b/compat_src/org/apache/xalan/xpath/xml/FormatterToXML.java
deleted file mode 100644
index ea0d032..0000000
--- a/compat_src/org/apache/xalan/xpath/xml/FormatterToXML.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath.xml;
-
-import java.io.Writer;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-
-import org.apache.xalan.serialize.Serializer;
-import org.apache.xalan.serialize.SerializerFactory;
-import org.apache.xalan.serialize.SerializerToXML;
-//import org.apache.xml.serialize.BaseMarkupSerializer;
-import org.apache.xalan.serialize.Method;
-import org.xml.sax.helpers.ParserAdapter;
-import org.xml.sax.SAXException;
-
-
-/**
- * <meta name="usage" content="general"/>
- * FormatterToXML formats SAX-style events into XML.
- * Warning: this class will be replaced by the Xerces Serializer classes.
- */
-public class FormatterToXML extends ParserAdapter
-{
-  SerializerToXML m_serializer;
-  
-  public FormatterToXML()
-  {
-    super(new org.apache.xerces.parsers.SAXParser());
-    m_serializer = new SerializerToXML();
-    this.setContentHandler(m_serializer);
-    //super( new OutputFormat( Method.XML, null, false ) );     
-  }
-  
-  /**
-   * Constructor using a writer.
-   * @param writer        The character output stream to use.
-   */
-  public FormatterToXML(Writer writer) throws SAXException 
-  {
-    super(new org.apache.xerces.parsers.SAXParser());
-    m_serializer = new SerializerToXML();
-   // super( format != null ? format : new OutputFormat( Method.XML, null, false ) );
-    //_format.setMethod( Method.XML );
-    m_serializer.setWriter( writer );
-    this.setContentHandler(m_serializer);
-  }
-  
-  /**
-   * Constructor using an output stream, and a simple OutputFormat.
-   * @param writer        The character output stream to use.
-   */
-  public FormatterToXML(java.io.OutputStream os) 
-    throws UnsupportedEncodingException , SAXException 
-  {
-    super(new org.apache.xerces.parsers.SAXParser());
-    m_serializer = new SerializerToXML();
-    //super( format != null ? format : new OutputFormat( Method.XML, null, false ) );
-    //_format.setMethod( Method.XML );
-    m_serializer.setOutputStream( os );
-    this.setContentHandler(m_serializer);
-  }
-  
-  /**
-   * Constructor using a writer.
-   * @param writer        The character output stream to use.
-   */
-  public FormatterToXML(FormatterToXML xmlListener) throws SAXException 
-  {
-    super(new org.apache.xerces.parsers.SAXParser());
-    m_serializer = new SerializerToXML();
-    m_serializer.CopyFrom(xmlListener.m_serializer);
-    //super( new OutputFormat( Method.XML, null, false ) );
-    this.setContentHandler(m_serializer);
-  }
-  
-  public SerializerToXML getSerializerObject()
-  {
-    return m_serializer;
-  }
-  
-
-}  //ToXMLStringVisitor
diff --git a/compat_src/org/apache/xalan/xpath/xml/ProblemListener.java b/compat_src/org/apache/xalan/xpath/xml/ProblemListener.java
deleted file mode 100644
index 0bf4137..0000000
--- a/compat_src/org/apache/xalan/xpath/xml/ProblemListener.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath.xml;
-
-import org.w3c.dom.*;
-
-/**
- * <meta name="usage" content="general"/>
- * This is the interface that the XSL processor calls when it 
- * has a problem of some kind, either an error or a warning.
- * Users should ass the XSLTEngineImpl class to setProblemListener
- * if they wish an object instance to be called when a problem
- * event occurs.
- */
-public interface ProblemListener
-{
-  public static final short    WARNING         = 1;
-  public static final short    ERROR           = 2;
-  public static final short    MESSAGE         = 3;
-
-  public static final short    XMLPARSER       = 1;
-  public static final short    XSLPROCESSOR    = 2;
-  public static final short    QUERYENGINE     = 3;
-  public static final short    XPATHPROCESSOR  = 4;
-  public static final short    XPATHPARSER  = 5;
-
-  /**
-   * Function that is called when a problem event occurs.
-   * 
-   * @param   where             Either and XMLPARSER, XSLPROCESSOR, or QUERYENGINE.
-   * @param   classification    Either ERROR or WARNING.
-   * @param   styleNode         The style tree node where the problem
-   *                            occurred.  May be null.
-   * @param   sourceNode        The source tree node where the problem
-   *                            occurred.  May be null.
-   * @param   msg               A string message explaining the problem.
-   * @param   lineNo            The line number where the problem occurred,  
-   *                            if it is known. May be zero.
-   * @param   charOffset        The character offset where the problem,  
-   *                            occurred if it is known. May be zero.
-   * 
-   * @return  true if the return is an ERROR, in which case
-   *          exception will be thrown.  Otherwise the processor will 
-   *          continue to process.
-   */
-  public boolean problem(short where, short classification, 
-                       Object styleNode, Node sourceNode,
-                       String msg, String id, int lineNo, int charOffset)
-    throws org.xml.sax.SAXException  ;
-  
-  /**
-   * Function that is called to issue a message.
-   * @param   msg               A string message to output.
-   */
-  public boolean message(String msg);
-
-}
diff --git a/compat_src/org/apache/xalan/xpath/xml/ProblemListenerDefault.java b/compat_src/org/apache/xalan/xpath/xml/ProblemListenerDefault.java
deleted file mode 100644
index ebc3927..0000000
--- a/compat_src/org/apache/xalan/xpath/xml/ProblemListenerDefault.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath.xml;
-
-import org.w3c.dom.*;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.SAXException;
-import javax.xml.transform.TransformerException;
-
-/**
- * <meta name="usage" content="general"/>
- * This is the interface that the XSL processor calls when it 
- * has a problem of some kind, either an error or a warning.
- * Users should ass the XSLTEngineImpl class to setProblemListener
- * if they wish an object instance to be called when a problem
- * event occurs.
- */
-public class ProblemListenerDefault extends org.apache.xml.utils.DefaultErrorHandler implements ProblemListener 
-{
-  //ErrorHandler m_errorHandler = null;
-  ProblemListener m_problemListener = null;
-  
-  public ProblemListenerDefault()
-  {
-    super();    
-  }
-  
-  public ProblemListenerDefault(ProblemListener l)
-  { 
-    //m_errorHandler = handler;
-    m_problemListener = l;
-  }
-  /*
-  public void setErrorHandler (ErrorHandler handler)
-  {
-    m_errorHandler = handler;
-  }
-  */
-  public void setProblemListener (ProblemListener l)
-  {
-    m_problemListener = l;
-  }
-  
-  public ErrorHandler getErrorHandler ()
-  {
-    return this; // m_errorHandler;
-  }
-  
-  public ProblemListener getProblemListener ()
-  {
-    if (m_problemListener != null)
-      return m_problemListener;
-    else
-      return this;
-  }
-  
-  /**
-   * Function that is called to issue a message.
-   * @param   msg               A string message to output.
-   */
-  public boolean message(String msg)
-  {
-      if (m_problemListener != null)
-        m_problemListener.message(msg);
-      synchronized (this)
-      {  
-        new java.io.PrintWriter(  System.err, true ).println( msg );
-      } 
-   
-    return false;                    // we don't know this is an error 
-  }
-  
-  public boolean problem(short where, short classification, 
-                       Object styleNode, Node sourceNode,
-                       String msg, String id, int lineNo, int charOffset)
-  throws org.xml.sax.SAXException   
-  {
-    if (m_problemListener != null)
-      return m_problemListener.problem(where, classification, styleNode, sourceNode, msg, id, lineNo, charOffset);
-    else
-    {  
-      this.error(new SAXParseException(msg, null, id, lineNo, charOffset));
-      return false;   
-    }
-  } 
-  
-  public void warning(SAXParseException exception) throws SAXException
-  {
-    if (m_problemListener == null)
-    {
-      super.warning(exception);    
-    }
-    else
-    {
-      boolean shouldthrow = m_problemListener.problem(XSLPROCESSOR, WARNING,
-                                null, null,
-                                exception.getMessage(),
-                                exception.getSystemId(),
-                                exception.getLineNumber(),  
-                                exception.getColumnNumber()); 
-      if (shouldthrow)
-        throw new SAXException(exception);
-    }
-  }
-  
-  public void error(SAXParseException exception) throws SAXException
-  {
-    if (m_problemListener == null)
-    {
-      super.error(exception);    
-    }
-    else
-    {
-      boolean shouldthrow = m_problemListener.problem(XSLPROCESSOR, ERROR,
-                                null, null,
-                                exception.getMessage(),
-                                exception.getSystemId(),
-                                exception.getLineNumber(),  
-                                exception.getColumnNumber()); 
-      if (shouldthrow)
-        throw new SAXException(exception);
-    }
-  }
-  
-  public void fatalError(SAXParseException exception) throws SAXException
-  {
-    if (m_problemListener == null)
-    {
-      super.fatalError(exception);    
-    }
-    else
-    {
-      boolean shouldthrow = m_problemListener.problem(XSLPROCESSOR, ERROR,
-                                null, null,
-                                exception.getMessage(),
-                                exception.getSystemId(),
-                                exception.getLineNumber(),  
-                                exception.getColumnNumber()); 
-      if (shouldthrow)
-        throw new SAXException(exception);
-    }
-  }
-  
-  public void warning(TransformerException exception) throws TransformerException
-  {
-    if (m_problemListener == null)
-    {
-      super.warning(exception);    
-    }
-    else
-    {
-      boolean shouldthrow = true;
-      try{
-        javax.xml.transform.SourceLocator locator = exception.getLocator();
-        if (locator != null)
-        {
-          shouldthrow = m_problemListener.problem(XSLPROCESSOR, WARNING,
-                                                  null, null,
-                                                  exception.getMessage(),
-                                                  locator.getSystemId(),
-                                                  locator.getLineNumber(),  
-                                                  locator.getColumnNumber());
-        }
-        else 
-        {
-          shouldthrow = m_problemListener.problem(XSLPROCESSOR, MESSAGE,
-                                                  null, null,
-                                                  exception.getMessage(),
-                                                  null,
-                                                  0,  
-                                                  0);
-        }
-      }
-      catch (SAXException se)
-      {
-        throw new TransformerException(se);
-      }
-      if (shouldthrow)
-        throw new TransformerException(exception);
-    }
-  }
-  
-  public void error(TransformerException exception) throws TransformerException
-  {
-    if (m_problemListener == null)
-    {
-      super.error(exception);    
-    }
-    else
-    {
-      boolean shouldthrow = true;
-      try{
-        javax.xml.transform.SourceLocator locator = exception.getLocator();
-        if (locator != null)
-        {
-          shouldthrow = m_problemListener.problem(XSLPROCESSOR, ERROR,
-                                                  null, null,
-                                                  exception.getMessage(),
-                                                  locator.getSystemId(),
-                                                  locator.getLineNumber(),  
-                                                  locator.getColumnNumber());
-        }
-        else 
-        {
-          shouldthrow = m_problemListener.problem(XSLPROCESSOR, ERROR,
-                                                  null, null,
-                                                  exception.getMessage(),
-                                                  null,
-                                                  0,  
-                                                  0);
-        }
-      }
-      catch (SAXException se)
-      {
-        throw new TransformerException(se);
-      }
-      if (shouldthrow)
-        throw new TransformerException(exception);
-    }
-  }
-  
-  public void fatalError(TransformerException exception) throws TransformerException
-  {
-    if (m_problemListener == null)
-    {
-      super.fatalError(exception);    
-    }
-    else
-    {
-      boolean shouldthrow = true;
-      try{
-        javax.xml.transform.SourceLocator locator = exception.getLocator();
-        if (locator != null)
-        {
-          shouldthrow = m_problemListener.problem(XSLPROCESSOR, ERROR,
-                                                  null, null,
-                                                  exception.getMessage(),
-                                                  locator.getSystemId(),
-                                                  locator.getLineNumber(),  
-                                                  locator.getColumnNumber());
-        }
-        else 
-        {
-          shouldthrow = m_problemListener.problem(XSLPROCESSOR, ERROR,
-                                                  null, null,
-                                                  exception.getMessage(),
-                                                  null,
-                                                  0,  
-                                                  0);
-        }
-      }
-      catch (SAXException se)
-      {
-        throw new TransformerException(se);
-      }
-      if (shouldthrow)
-        throw new TransformerException(exception);
-    }
-  }
-  /*
-  private class MessageMgr extends org.apache.xalan.transformer.MsgMgr 
-  {
-    void MessageMgr()
-    {}
-  }*/
-
-}
diff --git a/compat_src/org/apache/xalan/xpath/xml/TreeWalker.java b/compat_src/org/apache/xalan/xpath/xml/TreeWalker.java
deleted file mode 100644
index 50cbfb6..0000000
--- a/compat_src/org/apache/xalan/xpath/xml/TreeWalker.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * The Apache Software License, Version 1.1 
- * 
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath.xml;
-
-import org.w3c.dom.*;
-import org.xml.sax.*;
-import org.xml.sax.ext.LexicalHandler;
-
-import org.apache.xml.utils.AttList;
-
-/**
- * <meta name="usage" content="advanced"/>
- * This class does a pre-order walk of the DOM tree, calling the FormatterListener
- * interface as it goes.
- */
-public class TreeWalker //extends org.apache.xml.utils.TreeWalker
-{
-  
-  org.apache.xml.utils.TreeWalker m_walker; 
-  
-  /**
-   * Constructor.
-   * @param   formatterListener The implemention of the 
-   * FormatterListener operation (toXMLString, digest, ...)
-   */
-  public TreeWalker(DocumentHandler formatterListener) 
-  {
-    if(formatterListener instanceof FormatterToXML)
-      m_walker = new org.apache.xml.utils.TreeWalker(((FormatterToXML)formatterListener).getSerializerObject(), new org.apache.xpath.DOM2Helper());
-    //super(formatterListener);
-  } 
- 
-  /**
-   * Perform a pre-order traversal non-recursive style.
-   */
-  public void traverse(Node pos) throws SAXException 
-  {
-    m_walker.traverse(pos);
-  }
-  
-  /**
-   * Perform a pre-order traversal non-recursive style.
-   */
-  public void traverse(Node pos, Node top) throws SAXException 
-  {
-    m_walker.traverse(pos, top);
-  }
-  
-  
-  
-}  //TreeWalker
diff --git a/compat_src/org/apache/xalan/xpath/xml/XMLParserLiaison.java b/compat_src/org/apache/xalan/xpath/xml/XMLParserLiaison.java
deleted file mode 100644
index 952708f..0000000
--- a/compat_src/org/apache/xalan/xpath/xml/XMLParserLiaison.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath.xml;
-
-import org.w3c.dom.*;
-import org.apache.xpath.DOM2Helper;
-
-/**
- * <meta name="usage" content="general"/>
- * This is the interface that the XSL processor calls when it 
- * has a problem of some kind, either an error or a warning.
- * Users should ass the XSLTEngineImpl class to setProblemListener
- * if they wish an object instance to be called when a problem
- * event occurs.
- */
-public class XMLParserLiaison extends DOM2Helper
-{
-  
-
-}
diff --git a/compat_src/org/apache/xalan/xpath/xml/XMLParserLiaisonDefault.java b/compat_src/org/apache/xalan/xpath/xml/XMLParserLiaisonDefault.java
deleted file mode 100644
index a3a239f..0000000
--- a/compat_src/org/apache/xalan/xpath/xml/XMLParserLiaisonDefault.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xpath.xml;
-
-import javax.xml.parsers.*;
-import java.net.*;
-import java.io.*;
-import java.util.*;
-import org.xml.sax.*;
-import org.w3c.dom.*;
-
-import org.apache.xalan.xpath.xml.*;
-import org.apache.xalan.xpath.*;
-import org.apache.xpath.*;
-import org.apache.xalan.xpath.xml.XMLParserLiaison;
-
-/**
- * A class that handles interfacing IBM's XML4J2 to the 
- * Lotus XSL Processor.
- */
-public class XMLParserLiaisonDefault extends XMLParserLiaison 
-{
-  
-}
-
-
diff --git a/compat_src/org/apache/xalan/xpath/xml/package.html b/compat_src/org/apache/xalan/xpath/xml/package.html
deleted file mode 100644
index 57ee7d1..0000000
--- a/compat_src/org/apache/xalan/xpath/xml/package.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<HTML><HEAD></HEAD><BODY>
-     <P>Infrastructure for working with an XML parser.</P>
-   
-      <P>An implementation of the {@link org.apache.xalan.xpath.xml.XMLParserLiaison} interface provides a liaison
-     between the XSLT processor and an XML parser. Unless you specify an XML parser and your own implementation of 
-     the XMLParserLiaison interface, Xalan-Java uses the 
-     {@link org.apache.xalan.xpath.xml.XMLParserLiaisonDefault}:</P>
-     <P>This package also includes four implementations of the <A href="http://www.megginson.com/SAX/sax.html" target="_top">SAX</A> <A href="http://www.megginson.com/SAX/javadoc/org.xml.sax.DocumentHandler.html#_top" target="_top">org.xml.sax.DocumentHandler</A> interface:</P>
-     <UL>
-     <LI>{@link org.apache.xalan.xpath.xml.FormatterToDOM}</LI>
-     <LI>{@link org.apache.xalan.xpath.xml.FormatterToXML}</LI>
-     <LI>{@link org.apache.xalan.xpath.xml.FormatterToHTML} (an extension of FormatterToXML)</LI>
-     <LI>{@link org.apache.xalan.xpath.xml.FormatterToText}</LI>
-     </UL>
-   </BODY></HTML>
\ No newline at end of file
diff --git a/compat_src/org/apache/xalan/xslt/Stylesheet.java b/compat_src/org/apache/xalan/xslt/Stylesheet.java
deleted file mode 100644
index 1998464..0000000
--- a/compat_src/org/apache/xalan/xslt/Stylesheet.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-package org.apache.xalan.xslt;
-
-import java.net.*;
-import java.io.*;
-import org.xml.sax.*;
-
-
-/**
- * Represents the base stylesheet or an
- * "import" stylesheet; "include" stylesheets are
- * combined with the including stylesheet.
- * At the moment these stylesheets can not be reused within the
- * stylesheet tree or between trees.  This needs to be fixed
- * in the future.
- */
-public class Stylesheet  extends org.apache.xalan.templates.Stylesheet
-{ 
-	
-	 /**
-   * Constructor for a Stylesheet needs a Document.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public Stylesheet(StylesheetRoot root,
-                    XSLTEngineImpl processor,
-                    String baseIdentifier)
-    throws XSLProcessorException,
-           MalformedURLException,
-           FileNotFoundException,
-           IOException,
-           SAXException
-  {
-		super(root.getObject());    
-  }
-	
-	/**
-   * Constructor using an org.apache.xalan.templates.StylesheetRoot.
-   * 
-   * @param s an org.apache.xalan.templates.Stylesheet object
-   */
-  public Stylesheet(org.apache.xalan.templates.Stylesheet s)    
-  { 
-		super(s);
-       
-  }
-	
-}
diff --git a/compat_src/org/apache/xalan/xslt/StylesheetHandler.java b/compat_src/org/apache/xalan/xslt/StylesheetHandler.java
deleted file mode 100644
index 040fb35..0000000
--- a/compat_src/org/apache/xalan/xslt/StylesheetHandler.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xslt;
-
-import java.util.*;
-import org.xml.sax.*;
-import org.xml.sax.helpers.AttributesImpl;
-import org.xml.sax.helpers.ParserAdapter;
-import org.w3c.dom.*;
-import java.util.Vector;
-import java.io.*;
-import java.net.*;
-
-import org.apache.xalan.templates.Stylesheet; 
-
-/**
- * <meta name="usage" content="advanced"/>
- * Initializes and processes a stylesheet via SAX events.
- * If you need to alter the code in here,
- * it is not for the faint-of-heart, due to the state tracking
- * that has to be done due to the SAX event model.
- */
-public class StylesheetHandler extends ParserAdapter
-  
-{
-  
-  /**
-   * Instance constructor... 
-   * @param processor  The XSLTProcessor implementation.
-   * @param stylesheet The root stylesheet.
-   *    
-   */
-  public StylesheetHandler(XSLTEngineImpl processor, Stylesheet stylesheetTree)    
-    throws javax.xml.transform.TransformerConfigurationException, SAXException 
-  {
-    
-      super(new org.apache.xerces.parsers.SAXParser());
-      //try{
-      org.apache.xalan.processor.StylesheetHandler handler = 
-            new org.apache.xalan.processor.StylesheetHandler(processor.getTransformerFactory());
-      handler.pushStylesheet(stylesheetTree);
-      this.setContentHandler(handler);
-    //}
-    //catch (javax.xml.transform.TransformerConfigurationException tce)
-    //{}
-  } 
-  
-  /**
-   * Instance constructor... 
-   * @param processor  The XSLTProcessor implementation.
-   * @param stylesheet The root stylesheet. 
-   * @exception TransformerConfigurationException  
-   */
-  public StylesheetHandler(XSLTEngineImpl processor, StylesheetRoot stylesheetTree)    
-    throws javax.xml.transform.TransformerConfigurationException, SAXException 
-  {
-    //try{
-      super(new org.apache.xerces.parsers.SAXParser());
-      org.apache.xalan.processor.StylesheetHandler handler = 
-            new org.apache.xalan.processor.StylesheetHandler(processor.getTransformerFactory());
-      handler.pushStylesheet(stylesheetTree.getObject());
-      this.setContentHandler(handler);
-    //}
-    //catch (javax.xml.transform.TransformerConfigurationException tce)
-    //{}
-  } 
-  
-  
-}
diff --git a/compat_src/org/apache/xalan/xslt/StylesheetRoot.java b/compat_src/org/apache/xalan/xslt/StylesheetRoot.java
deleted file mode 100644
index 892c31a..0000000
--- a/compat_src/org/apache/xalan/xslt/StylesheetRoot.java
+++ /dev/null
@@ -1,581 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xslt;
-
-import org.w3c.dom.*;
-import java.util.*;
-import java.net.*;
-import java.io.*;
-import org.xml.sax.*;
-import org.xml.sax.helpers.*;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import org.apache.xml.serialize.*;
-import org.apache.xalan.serialize.*;
-import org.apache.xalan.templates.ElemTemplate;
-import org.apache.xalan.templates.OutputProperties;
-import javax.xml.transform.OutputKeys;
-import org.apache.xalan.xpath.xml.FormatterToXML;
-import org.apache.xalan.xpath.xml.FormatterToHTML;
-import org.apache.xalan.xpath.xml.FormatterToText;
-import org.apache.xalan.xpath.xml.FormatterToDOM;
-import org.apache.xalan.res.XSLTErrorResources;
-
-/**
- * <meta name="usage" content="general"/> 
- * Binary representation of a stylesheet -- use the {@link org.apache.xalan.xslt.XSLTProcessor} ProcessStylesheet
- * method to create a StylesheetRoot and improve performance for a stylesheet performing multiple transformations.
- * Also required for XSLTProcessor to function as SAX DocumentHandler.
- */
-public class StylesheetRoot extends Stylesheet
-{
-  
-  private String m_liaisonClassUsedToCreate = null;
-  private org.apache.xalan.templates.StylesheetRoot m_sRootObject;
-  
-  /**
-   * Uses an XSL stylesheet document.
-   * @param processor  The XSLTProcessor implementation.
-   * @param baseIdentifier The file name or URL for the XSL stylesheet.
-   * @exception TransformerConfigurationException thrown 
-   */
-  public StylesheetRoot(XSLTEngineImpl processor,
-                        String baseIdentifier)
-    throws TransformerConfigurationException
-  { 
-		super(null);
-    m_sRootObject = new org.apache.xalan.templates.StylesheetRoot(processor.getTransformerFactory().getErrorListener()); 
-    if (processor.getXMLProcessorLiaison()!= null)
-      m_liaisonClassUsedToCreate = ((Object)processor.getXMLProcessorLiaison()).getClass().getName();
-    
-  }  
-
-
-  /**
-   * Constructor using an org.apache.xalan.templates.StylesheetRoot.
-   * 
-   * @param s an org.apache.xalan.templates.StylesheetRoot object
-   */
-  public StylesheetRoot(org.apache.xalan.templates.StylesheetRoot s)    
-  { 
-		super(null);
-    m_sRootObject = s;     
-  }
-  
-  /**
-   * Return the org.apache.xalan.templates.StylesheetRoot object
-   * associated with this stylesheet root.
-   *  
-   * @return an org.apache.xalan.templates.StylesheetRoot object
-   */
-  public org.apache.xalan.templates.StylesheetRoot getObject()
-  {
-    return m_sRootObject;
-  }  
-  
-  /**
-   * Transform the XML source tree and place the output in the result tree target.
-   * This method uses a new XSLTProcessor instance to track the running state.
-   * @param xmlSource  The XML input source tree.
-   * @param outputTarget The output result tree.
-   * @exception SAXException
-   * @see org.apache.xalan.xslt.XSLTProcessor#process(org.apache.xalan.xslt.XSLTInputSource, org.apache.xalan.xslt.XSLTInputSource, org.apache.xalan.xslt.XSLTResultTarget)
-   */
-  public void process( XSLTInputSource xmlSource,
-                       XSLTResultTarget outputTarget)
-    throws SAXException,
-           MalformedURLException,
-           FileNotFoundException,
-           IOException
-  {
-    XSLTProcessor iprocessor =
-                              (null != m_liaisonClassUsedToCreate) ?
-                              new XSLTProcessorFactory().getProcessorUsingLiaisonName(m_liaisonClassUsedToCreate)
-                              : new XSLTProcessorFactory().getProcessor();
-    process(iprocessor, iprocessor.getSourceTreeFromInput(xmlSource), outputTarget);
-    // System.out.println("Number counters made: "+
-    //                   ((XSLTEngineImpl)iprocessor).getCountersTable().m_countersMade);
-  }
-
-  /**
-   * Transform the XML source tree and place the output in the result tree target.
-   * Use this version of the StylesheetRoot process() method if you have used an
-   * XSLTProcessor object to set a stylesheet parameter. That object is now the iprocessor parameter.
-   * @param iprocessor  The XSLTProcessor that will track the running state.
-   * @param xmlSource  The XML input source tree.
-   * @param outputTarget The output result tree.
-   * @exception SAXException
-   * @see org.apache.xalan.xslt.XSLTProcessor#process(org.apache.xalan.xslt.XSLTInputSource, org.apache.xalan.xslt.XSLTInputSource, org.apache.xalan.xslt.XSLTResultTarget)
-   */
-  public void process( XSLTProcessor iprocessor, XSLTInputSource xmlSource,
-                       XSLTResultTarget outputTarget)
-    throws SAXException,
-           MalformedURLException,
-           FileNotFoundException,
-           IOException
-  {
-    process(iprocessor, iprocessor.getSourceTreeFromInput(xmlSource), outputTarget);
-  }
-
-  /**
-   * Transform the XML source tree (a DOM Node) and place the output in the result tree target.
-   * This is a convenience method. You can also use a DOM Node to instantiate an XSLTInputSource object,
-   * and call {@link #process(org.apache.xalan.xslt.XSLTProcessor, org.apache.xalan.xslt.XSLTInputSource, org.apache.xalan.xslt.XSLTResultTarget)} or
-   * {@link org.apache.xalan.xslt.XSLTProcessor#process(org.apache.xalan.xslt.XSLTInputSource, org.apache.xalan.xslt.XSLTInputSource, org.apache.xalan.xslt.XSLTResultTarget)}.
-   * @param iprocessor  The processor that will track the running state.
-   * @param sourceTree  The input source tree in the form of a DOM Node.
-   * @param outputTarget The output result tree.
-   * @exception SAXException
-   */
-  public void process( XSLTProcessor iprocessor, Node sourceTree,
-                       XSLTResultTarget outputTarget)
-    throws SAXException,
-           MalformedURLException,
-           FileNotFoundException,
-           IOException
-  {
-    XSLTEngineImpl processor = (XSLTEngineImpl)iprocessor; // TODO: Check for class cast exception
-		//checkInit(processor);
-    synchronized(processor)
-    {
-      //processor.switchLiaisonsIfNeeded(sourceTree, outputTarget.getNode());
-
-      processor.setStylesheet(this);
-
-      OutputStream ostream = null;
-
-      try
-      {
-        // Double-check the node to make sure it matches the processor liaison.
-        //processor.getXMLProcessorLiaison().checkNode(sourceTree);
-
-        // Needs work: We have to put the extension namespaces
-        // into the liaison's table.  We wouldn't have to do this
-        // if the stylesheet handled it's own extensions, which
-        // I'll fix on a later date.
-  /*      Enumeration keys = m_extensionNamespaces.keys();
-        while(keys.hasMoreElements())
-        {
-          Object key = keys.nextElement();
-          // System.out.println("Putting ext namespace: "+key);
-          processor.getExecContext().addExtensionNamespace ((String)key,
-                                                            (ExtensionFunctionHandler)m_extensionNamespaces.get(key));
-        }*/
-
-        // Find the root pattern in the XSL.
-        ElemTemplate rootRule = m_sRootObject.getTemplateComposed(processor.getTransformer().getXPathContext(), sourceTree, null, -1, false);
-                               //this.findTemplate(processor, sourceTree, sourceTree);
-
-        if(null == rootRule)
-        {
-          rootRule = m_sRootObject.getDefaultRootRule();
-        }
-
-        DocumentHandler docHandler = outputTarget.getDocumentHandler();
-
-        OutputFormat formatter = getOutputFormat();
-
-        if(null != outputTarget.getEncoding())
-          formatter.setEncoding(outputTarget.getEncoding());
-
-        if(null != docHandler)
-        {
-          processor.setDocumentHandler(docHandler);
-        }
-        else if(null != outputTarget.getByteStream())
-        {
-         /* if (!(processor.getXMLProcessorLiaison()..getIndent() < 0))
-          {
-            // This is to get around differences between Xalan and Xerces.
-            // Xalan uses -1 as default for no indenting, Xerces uses 0.
-            // So we just bump up the indent value here because we will
-            // subtract from it at output time (FormatterToXML.init());
-            formatter.setIndent(processor.m_parserLiaison.getIndent() + 1);
-          }*/
-          processor.setDocumentHandler(makeSAXSerializer(outputTarget.getByteStream(),
-                                                               formatter));
-        }
-        else if(null != outputTarget.getCharacterStream())
-        {
-        /*  if (!(processor.m_parserLiaison.getIndent() < 0))
-          {
-            formatter.setIndent(processor.m_parserLiaison.getIndent() + 1);
-          }*/
-          processor.setDocumentHandler(makeSAXSerializer(outputTarget.getCharacterStream(),
-                                                               formatter));
-        }
-        else if(null != outputTarget.getFileName())
-        {
-          /*if (!(processor.m_parserLiaison.getIndent() < 0))
-          {
-            formatter.setIndent(processor.m_parserLiaison.getIndent() + 1);
-          }*/
-          ostream = new FileOutputStream(outputTarget.getFileName());
-          processor.setDocumentHandler( makeSAXSerializer(ostream, formatter));
-        }
-        else if(null != outputTarget.getNode())
-        {
-          ParserAdapter handler = new ParserAdapter(new org.apache.xerces.parsers.SAXParser());
-          // Patch from Costin Manolache
-//          if( "org.apache.xalan.xpath.dtm.DTMLiaison".equals( processor.getXMLProcessorLiaison().getClass().getName()))
-//            processor.error(XSLTErrorResources.ER_CANT_USE_DTM_FOR_OUTPUT); //Can't use a DTMLiaison for an output DOM node... pass a org.apache.xalan.xpath.xdom.XercesLiaison instead!");
-          
-          switch(outputTarget.getNode().getNodeType())
-          {
-          case Node.DOCUMENT_NODE:            
-            handler.setContentHandler(new FormatterToDOM((Document)outputTarget.getNode()).getSerializerObject());
-            processor.setDocumentHandler(handler);
-            break;
-          case Node.DOCUMENT_FRAGMENT_NODE:
-            handler.setContentHandler(new FormatterToDOM(outputTarget.getNode().getOwnerDocument(), // PR:DMAN4M6PK5 Submitted by:<bk@viae.de>
-                                                       (DocumentFragment)outputTarget.getNode()).getSerializerObject());
-            processor.setDocumentHandler(handler);
-            break;
-          case Node.ELEMENT_NODE:
-            handler.setContentHandler(new FormatterToDOM(outputTarget.getNode().getOwnerDocument(), // PR:DMAN4M6PK5 Submitted by:<bk@viae.de>
-                                                       (Element)outputTarget.getNode()).getSerializerObject());
-            processor.setDocumentHandler(handler);
-            break;
-          default:
-            m_sRootObject.error(XSLTErrorResources.ER_CAN_ONLY_OUTPUT_TO_ELEMENT); //"Can only output to an Element, DocumentFragment, Document, or PrintWriter.");
-          }
-        }
-        else
-        {
-          ParserAdapter handler = new ParserAdapter(new org.apache.xerces.parsers.SAXParser());
-          outputTarget.setNode(processor.getXMLProcessorLiaison().createDocument());
-          handler.setContentHandler(new FormatterToDOM((Document)outputTarget.getNode()).getSerializerObject());
-          processor.setDocumentHandler(handler);
-        }
-
-       // processor.resetCurrentState(sourceTree);
-       // processor.m_rootDoc = sourceTree;
-
-        if(null != processor.m_diagnosticsPrintWriter)
-        {
-          processor.diag("=============================");
-          processor.diag("Transforming...");
-          processor.pushTime(sourceTree);
-        }
-
-       // processor.getVarStack().pushContextMarker();
-      //  try
-      //  {
-      //    processor.resolveTopLevelParams();
-      //  }
-      //  catch(Exception e)
-      //  {
-      //    throw new SAXException(XSLMessages.createMessage(XSLTErrorResources.ER_PROCESS_ERROR, null), e); //"StylesheetRoot.process error", e);
-      //  }
-
-        processor.getTransformer().getResultTreeHandler().startDocument();
-
-        // Output the action of the found root rule.  All processing
-        // occurs from here.  buildResultFromTemplate is highly recursive.
-        rootRule.execute(processor.getTransformer(), sourceTree, null);
-
-         processor.getTransformer().getResultTreeHandler().endDocument();
-
-        // Reset the top-level params for the next round.
-        // processor.m_topLevelParams = new Vector();
-
-        if(null != processor.m_diagnosticsPrintWriter)
-        {
-          processor.displayDuration("transform", sourceTree);
-        }
-      }
-      catch(TransformerException te)
-      {
-        throw new SAXException(te);
-      }  
-      finally
-      {
-        if (null != ostream)
-        {
-          ostream.close();
-        }
-      }
-    }
-
-  }
-  
-  /**
-   * Creates a compatible SAX serializer for the specified writer
-   * and output format. If the output format is missing, the default
-   * is an XML format with UTF8 encoding.
-   *
-   * @param writer The writer
-   * @param format The output format
-   * @return A compatible SAX serializer
-   */
-  public DocumentHandler makeSAXSerializer( Writer writer, OutputFormat format )
-    throws IOException, SAXException 
-  {
-    DocumentHandler handler;
-    if ( format == null )
-    {
-      format = new OutputFormat( "xml", "UTF-8", false );
-      handler = null;
-    }
-    else 
-    {
-      handler = new ParserAdapter(new org.apache.xerces.parsers.SAXParser());
-      OutputProperties props = m_sRootObject.getOutputComposed();
-      
-      if ( format.getMethod().equalsIgnoreCase( "html" ) )
-      {
-        FormatterToHTML serializer = new FormatterToHTML(writer);
-        serializer.getSerializerObject().setOutputFormat(props.getProperties());
-        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
-      }
-      else if ( format.getMethod().equalsIgnoreCase( "xml" ) )
-      {
-        FormatterToXML serializer = new FormatterToXML(writer);
-        serializer.getSerializerObject().setOutputFormat(props.getProperties());
-        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
-      }
-      else if ( format.getMethod().equalsIgnoreCase( "text" ) )
-      {
-        FormatterToText serializer = new FormatterToText(writer); 
-        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
-      }
-      else
-      {
-        handler = null;
-      }
-    }
-    
-    if(null == handler)
-    {
-      String method = format.getMethod();
-      org.apache.xml.serialize.SerializerFactory factory = org.apache.xml.serialize.SerializerFactory.getSerializerFactory(method);
-      org.apache.xml.serialize.Serializer serializer = factory.makeSerializer(writer, format);
-      handler = serializer.asDocumentHandler();
-    }
-
-    return handler;
-  }
-  
-  /**
-   * Creates a compatible SAX serializer for the specified output stream
-   * and output format. If the output format is missing, the default
-   * is an XML format with UTF8 encoding.
-   *
-   * @param ostream The output stream.
-   * @param format The output format
-   * @return A compatible SAX serializer
-   */
-  public DocumentHandler makeSAXSerializer( OutputStream ostream, OutputFormat format )
-    throws UnsupportedEncodingException, IOException, SAXException
-  {
-    DocumentHandler handler;
-    OutputProperties props;
-        
-    if ( format == null )
-    {
-      props = new OutputProperties();
-      handler = null;
-    }
-    else
-    { 
-      handler = new ParserAdapter(new org.apache.xerces.parsers.SAXParser());
-      props = m_sRootObject.getOutputComposed();
-      if ( format.getMethod().equalsIgnoreCase( "html" ) )
-      {
-        FormatterToHTML serializer = new FormatterToHTML(ostream);
-        serializer.getSerializerObject().setOutputFormat(props.getProperties());
-        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
-      }
-      else if ( format.getMethod().equalsIgnoreCase( "xml" ) )
-      {
-        FormatterToXML serializer = new FormatterToXML(ostream);
-        serializer.getSerializerObject().setOutputFormat(props.getProperties());
-        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
-      }
-      else if ( format.getMethod().equalsIgnoreCase( "text" ) )
-      {
-        String encoding = format.getEncoding();
-        if(null == encoding)
-        {
-          try
-          {
-            encoding = System.getProperty("file.encoding");
-            encoding = (null != encoding) ?
-                       org.apache.xalan.serialize.Encodings.convertJava2MimeEncoding( encoding ) : "ASCII";
-            if(null == encoding)
-            {
-              encoding = "ASCII";
-            }
-          }
-          catch(SecurityException se)
-          {
-            encoding = "ASCII";
-          }
-        }
-
-        //this.m_encoding =   encoding;
-
-        String javaEncoding = org.apache.xalan.serialize.Encodings.convertMime2JavaEncoding(encoding);
-
-        Writer w = new OutputStreamWriter( ostream, javaEncoding );
-        ((ParserAdapter)handler).setContentHandler(new FormatterToText(w).getSerializerObject());
-      }
-      else if ( format.getMethod().equalsIgnoreCase( "xhtml" ) )
-      {
-        handler = new XMLSerializer(ostream, format);
-        //handler = Serializer.makeSAXSerializer(ostream, format);
-      }
-      else
-      {
-        handler = new XMLSerializer(ostream, format);
-        //handler = Serializer.makeSAXSerializer(ostream, format);
-      }
-    }
-    if(null == handler)
-    {
-      String method = props.getProperty(OutputKeys.METHOD);
-      org.apache.xml.serialize.SerializerFactory factory = org.apache.xml.serialize.SerializerFactory.getSerializerFactory(method);
-      org.apache.xml.serialize.Serializer serializer = factory.makeSerializer(ostream, format);
-      handler = serializer.asDocumentHandler();
-    }
-
-    return handler;
-  }
-
-  /**
-   * Creates a compatible SAX serializer for the specified output stream
-   * and output format. If the output format is missing, the default
-   * is an XML format with UTF8 encoding.
-   *
-   * @param ostream The output stream.
-   * @return A compatible SAX serializer
-   */
-  public DocumentHandler getSAXSerializer( OutputStream ostream )
-    throws UnsupportedEncodingException, IOException, SAXException
-  {
-   return makeSAXSerializer(ostream, getOutputFormat());
-  }
-  
-  /**
-   * Get a new OutputFormat object according to the xsl:output attributes.
-   */
-  public OutputFormat getOutputFormat()
-  {
-    OutputProperties outputFormat = m_sRootObject.getOutputComposed();
-    if (outputFormat == null)
-      return null;
-    OutputFormat formatter = new OutputFormat(outputFormat.getProperty(OutputKeys.METHOD),
-                                              outputFormat.getProperty(OutputKeys.ENCODING),
-                                              OutputProperties.getBooleanProperty(OutputKeys.INDENT, outputFormat.getProperties()));
-    formatter.setDoctype(outputFormat.getProperty(OutputKeys.DOCTYPE_PUBLIC), 
-                         outputFormat.getProperty(OutputKeys.DOCTYPE_SYSTEM));
-    formatter.setOmitXMLDeclaration(OutputProperties.getBooleanProperty(OutputKeys.OMIT_XML_DECLARATION, outputFormat.getProperties()));
-    formatter.setStandalone(OutputProperties.getBooleanProperty(OutputKeys.STANDALONE, outputFormat.getProperties()));
-    formatter.setMediaType(outputFormat.getProperty(OutputKeys.MEDIA_TYPE));
-    formatter.setVersion(outputFormat.getProperty(OutputKeys.VERSION));
-    // This is to get around differences between Xalan and Xerces.
-    // Xalan uses -1 as default for no indenting, Xerces uses 0.
-    // So we just bump up the indent value here because we will
-    // subtract from it at output time (FormatterToXML.init());
-   // if (getOutputIndent())
-   //   formatter.setIndent(formatter.getIndent()+1);
-
-    
-    return formatter;
-  }
-  
-  /** 
-   * Get the encoding string that was specified in the stylesheet. 
-   */
-  public String getOutputEncoding()
-  {
-    return m_sRootObject.getOutputComposed().getProperty(OutputKeys.ENCODING);
-  }
-
-  /** 
-   * Get the media-type string that was specified in the stylesheet. 
-   */
-  public String getOutputMediaType() 
-  { 
-    return m_sRootObject.getOutputComposed().getProperty(OutputKeys.MEDIA_TYPE); 
-  }
-  
-  /** 
-   * Get the output method that was specified in the stylesheet. 
-   */
-  public String getOutputMethod() 
-  { 
-    return m_sRootObject.getOutputComposed().getProperty(OutputKeys.METHOD); 
-  }
-  
-  /**
-   * Get the base identifier with which this stylesheet is associated.
-   */
-  public String getBaseIdentifier()
-  {
-    return m_sRootObject.getBaseIdentifier();
-  }
-
-  /**
-   * Get the base identifier with which this stylesheet is associated.
-   */
-  public void setBaseIdentifier(String baseIdent)
-  {
-    m_sRootObject.setHref(baseIdent);
-  }
-  
-}
diff --git a/compat_src/org/apache/xalan/xslt/StylesheetSpec.java b/compat_src/org/apache/xalan/xslt/StylesheetSpec.java
deleted file mode 100644
index ea5d837..0000000
--- a/compat_src/org/apache/xalan/xslt/StylesheetSpec.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xslt;
-
-import javax.xml.transform.stream.StreamSource;
-
-/**
- * <meta name="usage" content="general"/>
- * This class implements the representation of a stylesheet 
- * specification via xml-stylesheet in an XML document.
- */
-public class StylesheetSpec extends StreamSource
-{
-  String type; // CDATA #REQUIRED
-  String title; // CDATA #IMPLIED
-  String media; // CDATA #IMPLIED
-  String encoding; // CDATA #IMPLIED
-  boolean alternate; // (yes|no) "no"
-  
-  /**
-   * Create a StylesheetSpec object.
-   */
-  public StylesheetSpec(String href, String type, String title, 
-                        String media, boolean alternate,
-                        String encoding)
-  {
-    this.setSystemId(href);
-    this.encoding = encoding;
-    this.type = type;
-    this.title = title;
-    this.media = media;
-    this.alternate = alternate;
-  }
-  
-  /**
-   * Get the encoding of the stylesheet.
-   */
-  public String       getEncoding()
-  {
-    return encoding;
-  }
-
-  /**
-   * Get the type of the stylesheet, i.e. "text/xsl".
-   */
-  public String       getType()
-  {
-    return type;
-  }
-  
-  /**
-   * Get the title of the element (in other words, the 
-   * item to be presented to the user agent).
-   */
-  public String       getTitle()
-  {
-    return title;
-  }
-  
-  /**
-   * Get the media attribute of the stylesheet.
-   */
-  public String       getMedia()
-  {
-    return media;
-  }
-  /**
-   * Get whether or not the stylesheet is specified as 
-   * an alternate.
-   */
-  public boolean    getIsAlternate()
-  {
-    return alternate;
-  }
-}
diff --git a/compat_src/org/apache/xalan/xslt/XSLProcessorContext.java b/compat_src/org/apache/xalan/xslt/XSLProcessorContext.java
deleted file mode 100644
index c6a2294..0000000
--- a/compat_src/org/apache/xalan/xslt/XSLProcessorContext.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xslt;
-
-import org.w3c.dom.*;
-import org.apache.xalan.templates.Stylesheet;
-import org.apache.xml.utils.QName;
-import org.apache.xalan.transformer.TransformerImpl;
-
-// import org.apache.xalan.xslt.*;
-
-/**
- * <meta name="usage" content="general"/>
- * Captures processor context to be
- * passed to an extension element.
- *
- * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
- */
-public class XSLProcessorContext extends org.apache.xalan.extensions.XSLProcessorContext
-{ 
-  public XSLProcessorContext (XSLTEngineImpl processor,
-			      Stylesheet stylesheetTree,
-			      Node sourceTree, Node sourceNode, QName mode) 
-    
-  {
-    super((TransformerImpl)(processor.getTransformer()),
-          stylesheetTree, 
-          sourceTree, sourceNode, mode);
-  }
-
-  
-}
diff --git a/compat_src/org/apache/xalan/xslt/XSLTEngineImpl.java b/compat_src/org/apache/xalan/xslt/XSLTEngineImpl.java
deleted file mode 100644
index 7f00511..0000000
--- a/compat_src/org/apache/xalan/xslt/XSLTEngineImpl.java
+++ /dev/null
@@ -1,2426 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xslt;
-
-import org.apache.xpath.*;
-import org.apache.xpath.compiler.XPathParser;
-import org.apache.xpath.compiler.Compiler;
-import org.apache.xalan.xpath.XObject;
-import org.apache.xalan.xpath.XString;
-import org.apache.xalan.xpath.XNodeSet;
-import org.apache.xalan.xpath.XBoolean;
-import org.apache.xalan.xpath.XNumber;
-import org.apache.xalan.xpath.XNull;
-
-import org.w3c.dom.*;
-import org.w3c.dom.traversal.NodeIterator;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.*;
-import org.xml.sax.helpers.*;
-import org.xml.sax.ext.*;
-import org.xml.sax.helpers.ParserAdapter;
-import org.apache.xml.serialize.XMLSerializer;
-
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.Templates;
-import javax.xml.transform.Source;
-import javax.xml.transform.SourceLocator;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.ErrorListener;
-
-import java.util.*;
-import java.net.*;
-import java.io.*;
-import java.lang.reflect.*;
-
-import org.apache.xalan.templates.Stylesheet;
-//import org.apache.xalan.templates.StylesheetRoot;
-import org.apache.xalan.xpath.xml.XMLParserLiaison;
-import org.apache.xalan.xpath.xml.ProblemListenerDefault;
-import org.apache.xalan.xpath.xml.ProblemListener;
-import org.apache.xalan.templates.StylesheetComposed;
-import org.apache.xalan.transformer.TransformerImpl;
-import org.apache.xalan.processor.StylesheetHandler;
-import org.apache.xalan.processor.TransformerFactoryImpl;
-//import org.apache.xalan.processor.ProcessorStylesheet;
-//import org.apache.xalan.xslt.StylesheetSpec;
-import org.apache.xalan.trace.*;
-import org.apache.xalan.res.XSLTErrorResources;
-import org.apache.xalan.res.XSLMessages;
-import org.apache.xml.utils.PrefixResolverDefault;
-import org.apache.xml.utils.TreeWalker;
-import org.apache.xml.utils.QName;
-import org.apache.xml.utils.DefaultErrorHandler;
-import org.apache.xalan.stree.SourceTreeHandler;
-
-
-/**
- * <meta name="usage" content="advanced"/>
- * The Xalan workhorse -- Collaborates with the XML parser liaison, the DOM,
- * and the XPath engine, to transform a source tree of nodes into a result tree
- * according to instructions and templates specified by a stylesheet tree.
- * We suggest you use one of the
- * static XSLTProcessorFactory getProcessor() methods to instantiate the processor
- * and return an interface that greatly simplifies the process of manipulating
- * XSLTEngineImpl.
- *
- * <p>The methods <code>process(...)</code> are the primary public entry points.
- * The best way to perform transformations is to use the
- * {@link org.apache.xalan.xslt.XSLTProcessor#process(org.apache.xalan.xslt.XSLTInputSource, org.apache.xalan.xslt.XSLTInputSource, org.apache.xalan.xslt.XSLTResultTarget)} method,
- * but you may use any of process methods defined in XSLTEngineImpl.</p>
- * 
- * <p>Please note that this class is not safe per instance over multiple 
- * threads.  If you are in a multithreaded environment, you should 
- * keep a pool of these objects, or create a new one each time.  In a 
- * multithreaded environment, the right way to do things is to create a 
- * StylesheetRoot via processStylesheet, and then reuse this object 
- * over multiple threads.</p>
- *
- * <p>If you reuse the processor instance, you should call reset() between transformations.</p>
- * @see XSLTProcessorFactory
- * @see XSLTProcessor
- */
-public class XSLTEngineImpl implements  XSLTProcessor
-{
-  //private Processor m_processor;
-  private TransformerFactory m_tfactory;
-  private TransformerImpl m_transformerImpl;
-  private DOM2Helper m_liaison;
-  private String m_outputFileName;
-  private DocumentHandler m_documentHandler = null;
-  private ProblemListenerDefault m_problemListener;
-  private Hashtable m_stylesheetParams;
-  StylesheetRoot m_stylesheetRoot = null;
-  
-  Vector m_evalList = null;
-  boolean m_needToEval = false;
-  
-  /*
-  * If this is true, then the diag function will
-  * be called.
-  */
-  private boolean m_traceTemplateChildren = false;
-
-  /*
-  * If this is true, then the simple tracing of templates
-  * will be performed.
-  */
-  private boolean m_traceTemplates = false;
-  
-  /*
-  * If this is true, then diagnostics of each select
-  * will be performed.
-  */
-  boolean m_traceSelects = false;
-
-  /*
-  * A stream to print diagnostics to.
-  */
-  java.io.PrintWriter m_diagnosticsPrintWriter = null;
-
-  /* For diagnostics */
-  Hashtable m_durationsTable = new Hashtable();
-  
-  /**
-   * A XSLMessages instance capable of producing user messages.
-   */
-  private static XSLMessages m_XSLMessages = new XSLMessages();
-  
-    
- /**
-   * Construct an XSLT processor that uses the default DTM (Document Table Model) liaison
-   * and XML parser. As a general rule, you should use XSLTProcessorFactory to create an
-   * instance of this class and provide access to the instance via the XSLTProcessor interface.
-   *
-   * @see XSLTProcessorFactory
-   * @see XSLTProcessor
-   */
-  protected XSLTEngineImpl()
-    throws org.xml.sax.SAXException
-  {    
-    m_tfactory = TransformerFactory.newInstance();
-    m_problemListener = new ProblemListenerDefault();
-    //m_liaison =  (DOM2Helper)createLiaison();
-  }
-
-  /**
-   * Construct an XSLT processor that uses the the given parser liaison.
-   * As a general rule, you should use XSLTProcessorFactory to create an
-   * instance of this class and provide access to the instance via the XSLTProcessor interface.
-   *
-   * @see XSLTProcessorFactory
-   * @see XSLTProcessor
-   */
-  public XSLTEngineImpl(String liaisonClassName)
-    throws SAXException 
-  {   
-    m_tfactory = TransformerFactory.newInstance();
-    m_problemListener = new ProblemListenerDefault();
-    
-    try 
-      {
-        m_liaison =  (DOM2Helper)(Class.forName(liaisonClassName).newInstance());
-        //org.apache.xpath.XPathContext xctxt = this.getTransformer().getXPathContext();
-
-        //xctxt.setDOMHelper(m_liaison);        
-      } 
-      catch (ClassNotFoundException e1) 
-      {
-        throw new SAXException("XML Liaison class " + liaisonClassName +
-          " specified but not found", e1);
-      } 
-      catch (IllegalAccessException e2) 
-      {
-          throw new SAXException("XML Liaison class " + liaisonClassName +
-            " found but cannot be loaded", e2);
-      } 
-      catch (InstantiationException e3) 
-      {
-          throw new SAXException("XML Liaison class " + liaisonClassName +
-            " loaded but cannot be instantiated (no empty public constructor?)",
-            e3);
-      } 
-      catch (ClassCastException e4) 
-      {
-          throw new SAXException("XML Liaison class " + liaisonClassName +
-            " does not implement DOM2Helper", e4);
-      }
-   
-  }
-    
-    
-
-  /**
-   * Construct an XSL processor that uses the the given parser liaison.
-   * As a general rule, you should use XSLTProcessorFactory to create an
-   * instance of this class and provide access to the instance via the XSLTProcessor interface.
-   *
-   * @param XMLParserLiaison A liaison to an XML parser.
-   *
-   * @see org.apache.xalan.xpath.xml.XMLParserLiaison
-   * @see XSLTProcessorFactory
-   * @see XSLTProcessor
-   */
-  public XSLTEngineImpl(XMLParserLiaison parserLiaison)
-    throws org.xml.sax.SAXException
-  {
-    m_tfactory = TransformerFactory.newInstance();
-    m_problemListener = new ProblemListenerDefault();
-    
-    m_liaison =  (DOM2Helper)parserLiaison;
-   // org.apache.xpath.XPathContext xctxt = this.getTransformer().getXPathContext();
-
-    //xctxt.setDOMHelper(m_liaison);    
-  }
-
-  /**
-   * Construct an XSLT processor that can call back to the XML parser, in order to handle
-   * included files and the like.
-   *
-   * @param XMLParserLiaison A liaison to an XML parser.
-   *
-   * @see org.apache.xalan.xpath.xml.XMLParserLiaison
-   * @see XSLTProcessorFactory
-   * @see XSLTProcessor
-   */
-  XSLTEngineImpl(XMLParserLiaison parserLiaison, XPathFactory xpathFactory)    
-    throws SAXException
-  {   
-    m_tfactory = TransformerFactory.newInstance();
-    m_problemListener = new ProblemListenerDefault();
-    
-    m_liaison =  (DOM2Helper)parserLiaison;
-   // org.apache.xpath.XPathContext xctxt = this.getTransformer().getXPathContext();
-
-    //xctxt.setDOMHelper(m_liaison);    
-  }
-  
-  /** 
-   * Get a Liaison class
-   */
-  public XMLParserLiaison createLiaison()
-    throws org.xml.sax.SAXException
-  {
-    return new org.apache.xalan.xpath.xml.XMLParserLiaisonDefault();    
-  }
- 
-  /**
-   * Reset the state.  This needs to be called after a process() call
-   * is invoked, if the processor is to be used again.
-   */
-  public void reset()
-  {
-    if (m_transformerImpl != null)
-      m_transformerImpl.reset(); 
-    m_stylesheetParams = null;
-  }
-  
- 
-
-  /**
-   * Transform the source tree to the output in the given
-   * result tree target. As a general rule, we recommend you use the
-   * {@link org.apache.xalan.xslt.XSLTProcessor#process(org.apache.xalan.xslt.XSLTInputSource, org.apache.xalan.xslt.XSLTInputSource, org.apache.xalan.xslt.XSLTResultTarget)} method.
-   * @param inputSource  The input source.
-   * @param stylesheetSource  The stylesheet source.  May be null if source has a xml-stylesheet PI.
-   * @param outputTarget The output source tree.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public void process( XSLTInputSource inputSource,
-                       XSLTInputSource stylesheetSource,
-                       XSLTResultTarget outputTarget)
-    throws SAXException
-  {
-    try
-    {
-      Boolean totalTimeID = new Boolean(true);
-      pushTime(totalTimeID);
-      Node sourceTree = null;
-      
-      Templates templates = null;
-      if (m_needToEval)
-      {
-        Node node = null;
-        if (null != stylesheetSource)
-        {
-          Source ssSource = stylesheetSource.getSourceObject();
-          if(ssSource instanceof DOMSource)
-          {
-            node = ((DOMSource)ssSource).getNode();
-          }
-        }
-        if (null == node)
-        {
-          node = new DOM2Helper().createDocument() ; 
-        }
-        for (int i=0; i< m_evalList.size(); i++)
-        {
-          String name = (String)m_evalList.elementAt(i);
-          String expression = (String)m_stylesheetParams.get(name);
-          try{
-            org.apache.xpath.objects.XObject val = org.apache.xpath.XPathAPI.eval(node, expression);
-            
-            m_stylesheetParams.put(name, val);
-          }
-          catch(TransformerException te)
-          {
-            throw new SAXException(te);
-          }
-        }
-        m_needToEval = false;
-        m_evalList = null;
-      }
-      
-      sourceTree = getSourceTreeFromInput(inputSource);
-      
-      if(null != stylesheetSource)
-      {
-        try{
-        templates = m_tfactory.newTemplates(stylesheetSource.getSourceObject());
-        }
-        catch (TransformerConfigurationException tce)
-        {
-          throw new SAXException(tce);
-        }  
-        
-      }      
-      else if( null != inputSource)
-      { 
-        if(null != sourceTree)
-        {
-          String stylesheetURI = null;
-          Stack hrefs = new Stack();
-          for(Node child=sourceTree.getFirstChild(); null != child; child=child.getNextSibling())
-          {
-            if(Node.PROCESSING_INSTRUCTION_NODE == child.getNodeType())
-            {
-              ProcessingInstruction pi = (ProcessingInstruction)child;
-              if(pi.getNodeName().equals("xml-stylesheet")
-                 || pi.getNodeName().equals("xml:stylesheet"))
-              {
-                boolean isOK = true;
-                StringTokenizer tokenizer = new StringTokenizer(pi.getNodeValue(), " \t=");
-                while(tokenizer.hasMoreTokens())
-                {
-                  if(tokenizer.nextToken().equals("type"))
-                  {
-                    String typeVal = tokenizer.nextToken();
-                    typeVal = typeVal.substring(1, typeVal.length()-1);
-                    if(!typeVal.equals("text/xsl") && !typeVal.equals("text/xml") && !typeVal.equals("application/xml+xslt"))
-                    {
-                      isOK = false;
-                    }
-                  }
-                }
-
-                if(isOK)
-                {
-                  tokenizer = new StringTokenizer(pi.getNodeValue(), " \t=");
-                  while(tokenizer.hasMoreTokens())
-                  {
-                    if(tokenizer.nextToken().equals("href"))
-                    {
-                      stylesheetURI = tokenizer.nextToken();
-                      stylesheetURI = stylesheetURI.substring(1, stylesheetURI.length()-1);
-                      hrefs.push(stylesheetURI);
-                    }
-                  }                
-                }
-              }
-            }
-          } // end for(int i = 0; i < nNodes; i++)
-          boolean isRoot = true;
-          Stylesheet prevStylesheet = null;
-          while(!hrefs.isEmpty())
-          {
-            Stylesheet stylesheet = getStylesheetFromPIURL((String)hrefs.pop(), sourceTree,
-                                                           (null != inputSource)
-                                                           ? inputSource.getSystemId() : null,
-                                                           isRoot);
-            if(false == isRoot)
-            {
-              prevStylesheet.setImport((StylesheetComposed)stylesheet);
-            }
-            prevStylesheet = stylesheet;
-            isRoot = false;
-          }
-        }        
-      }
-      else
-      {
-        error(XSLTErrorResources.ER_NO_INPUT_STYLESHEET); //"Stylesheet input was not specified!");
-      }
-      
-     
-      if(null == templates)
-      {
-        if (m_stylesheetRoot != null)
-          templates = m_stylesheetRoot.getObject();
-        else
-        {  
-          error(XSLTErrorResources.ER_FAILED_PROCESS_STYLESHEET); //"Failed to process stylesheet!");
-          return;
-        }  
-      }
-
-      if(null != templates)
-      {
-        try{
-          m_transformerImpl = (TransformerImpl)templates.newTransformer(); 
-          if (m_problemListener != null)
-            m_transformerImpl.setErrorListener(m_problemListener);
-          if (m_liaison != null)
-            m_transformerImpl.getXPathContext().setDOMHelper(m_liaison);
-   
-        }
-        catch (TransformerConfigurationException tce)
-        {
-          throw new SAXException(tce);
-        }  
-        
-        if (m_stylesheetParams != null)
-        {
-          Enumeration keys = m_stylesheetParams.keys();
-          while (keys.hasMoreElements())
-          {
-            String name = (String)keys.nextElement();
-            Object value = m_stylesheetParams.get(name); 
-            m_transformerImpl.setParameter(name, null, value);
-          } 
-        }  
-        
-        try{
-          m_transformerImpl.transform(new DOMSource(sourceTree),
-                    outputTarget.getResultObject());
-        }
-        catch (TransformerException te)
-        {
-          throw new SAXException(te);
-        }  
-        if(null != m_diagnosticsPrintWriter)
-        {
-          displayDuration("Total time", totalTimeID);
-        }
-      }
-    }
-    catch(MalformedURLException mue)
-    {
-      error(XSLTErrorResources.ERROR0000, new Object[] {mue.getMessage()}, mue);
-      // throw se;
-    }
-    catch(FileNotFoundException fnfe)
-    {
-      error(XSLTErrorResources.ERROR0000, new Object[] {fnfe.getMessage()}, fnfe);
-      // throw se;
-    }
-    catch(IOException ioe)
-    {
-      error(XSLTErrorResources.ERROR0000, new Object[] {ioe.getMessage()}, ioe);
-      // throw se;
-    }
-    catch(SAXException se)
-    {
-      error(XSLTErrorResources.ER_SAX_EXCEPTION, se); //"SAX Exception", se);
-      // throw se;
-    }
-  }
-
-  /**
-   * Bottleneck the creation of the stylesheet for derivation purposes.
-   */
-  public StylesheetRoot createStylesheetRoot(String baseIdentifier)
-    throws MalformedURLException, FileNotFoundException,
-           IOException, SAXException
-  {
-    try{
-      if (baseIdentifier == null)
-        return new StylesheetRoot(this, baseIdentifier); 
-      
-      Source inSource = new XSLTInputSource(baseIdentifier).getSourceObject();
-      Templates templates = m_tfactory.newTemplates(inSource);
-      StylesheetRoot stylesheet = new StylesheetRoot((org.apache.xalan.templates.StylesheetRoot)templates);      
-      return stylesheet;      
-    }
-    catch (TransformerConfigurationException tce)
-    {
-      throw new SAXException(tce);
-    }
-  }
-  
-  /**
-   * Bottleneck the creation of the stylesheet for derivation purposes.
-   */
-  StylesheetRoot createStylesheetRoot(String baseIdentifier, XSLTInputSource source)
-    throws MalformedURLException, FileNotFoundException,
-           IOException, SAXException
-  {
-    try{
-      Source inSource = source.getSourceObject();
-      Templates templates = m_tfactory.newTemplates(inSource);
-      StylesheetRoot stylesheet = new StylesheetRoot((org.apache.xalan.templates.StylesheetRoot)templates);      
-      return stylesheet;      
-    }
-    catch (TransformerConfigurationException tce)
-    {
-      throw new SAXException(tce);
-    }
-  }
-
-  /**
-   * Given a URI to an XSL stylesheet,
-   * Compile the stylesheet into an internal representation.
-   * This calls reset() before processing if the stylesheet root has been set
-   * to non-null.
-   * @param xmldocURLString  The URL to the input XML document.
-   * @return The compiled stylesheet object.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public StylesheetRoot processStylesheet(XSLTInputSource stylesheetSource)
-    throws SAXException
-  {
-    try{
-      if(null != ((TransformerFactoryImpl)m_tfactory).newTemplatesHandler().getTemplates())
-        reset();
-    }
-    catch (TransformerConfigurationException tce)
-    {
-      throw new SAXException(tce);
-    }
-
-    String xslIdentifier = ((null == stylesheetSource) ||
-                            (null == stylesheetSource.getSystemId()))
-                           ? "Input XSL" : stylesheetSource.getSystemId();
-
-    // In case we have a fragment identifier, go ahead and
-    // try and parse the XML here.
-    m_stylesheetRoot = null;
-    try
-    {
-      StylesheetHandler stylesheetProcessor
-          = new StylesheetHandler((TransformerFactoryImpl)m_tfactory); //this, m_stylesheetRoot); 
-        
-      Source ssSource = stylesheetSource.getSourceObject();
-      if(ssSource instanceof DOMSource)
-      {
-        if(((DOMSource)ssSource).getNode() instanceof StylesheetRoot)
-        {
-          m_stylesheetRoot = (StylesheetRoot)((DOMSource)ssSource).getNode();
-        }
-        else
-        {
-          stylesheetProcessor.setSystemId(stylesheetSource.getSystemId());
-          TreeWalker tw = new TreeWalker(stylesheetProcessor, new org.apache.xpath.DOM2Helper());
-          tw.traverse(((DOMSource)ssSource).getNode());
-          m_stylesheetRoot = new StylesheetRoot(stylesheetProcessor.getStylesheetRoot());
-        }
-      }
-      else
-      {
-				if(null != m_liaison)
-        {
-         // DOM2Helper liaison =  (DOM2Helper)(Class.forName(liaisonClassName).newInstance());
-          m_liaison.parse(SAXSource.sourceToInputSource(ssSource));
-					DOMSource source = new DOMSource(m_liaison.getDocument());
-					Templates templates = m_tfactory.newTemplates(source);
-					m_stylesheetRoot = new StylesheetRoot(
-																(org.apache.xalan.templates.StylesheetRoot)templates);																 
-        }  
-				else
-				{
-					m_stylesheetRoot = createStylesheetRoot(stylesheetSource.getSystemId(), stylesheetSource);
-				}
-        addTraceListenersToStylesheet();
-        
-        
-        stylesheetProcessor.pushStylesheet(m_stylesheetRoot.getObject());      
-        diag("========= Parsing "+xslIdentifier+" ==========");
-        pushTime(xslIdentifier);
-        //String liaisonClassName = System.getProperty("org.apache.xalan.source.liaison");
-
-        
-        if(null != m_diagnosticsPrintWriter)
-          displayDuration("Parse of "+xslIdentifier, xslIdentifier);
-      }
-    }
-    catch(Exception e)
-    {
-      error(XSLTErrorResources.ER_COULDNT_PARSE_DOC, new Object[] {xslIdentifier}, e); //"Could not parse "+xslIdentifier+" document!", e);
-    }
-    return m_stylesheetRoot;
-  }
-
-  /**
-   * Given a URI to an XSL stylesheet,
-   * Compile the stylesheet into an internal representation.
-   * This calls reset() before processing if the stylesheet root has been set
-   * to non-null.
-   * @param xmldocURLString  The URL to the input XML document.
-   * @return The compiled stylesheet object.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public StylesheetRoot processStylesheet(String xsldocURLString)
-    throws SAXException
-  {
-    try
-    {
-      XSLTInputSource input = new XSLTInputSource(getURLFromString(xsldocURLString, null).toString());
-      return processStylesheet(input);
-    }
-    catch(SAXException se)
-    {
-      error(XSLTErrorResources.ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, se); //"processStylesheet not succesfull!", se);
-      return null; // shut up compiler
-    }
-  }
-
-  /**
-   * Set the stylesheet for this processor.  If this is set, then the
-   * process calls that take only the input .xml will use
-   * this instead of looking for a stylesheet PI.  Also,
-   * setting the stylesheet is needed if you are going
-   * to use the processor as a SAX DocumentHandler.
-   */
-  public void setStylesheet(StylesheetRoot stylesheetRoot)
-  {
-    m_stylesheetRoot = stylesheetRoot;
-    org.apache.xalan.templates.StylesheetRoot sr = stylesheetRoot.getObject();
-    if (m_transformerImpl == null)
-      m_transformerImpl = (TransformerImpl)sr.newTransformer();
-    m_transformerImpl.setStylesheet(sr);
-    if (m_problemListener != null)
-      m_transformerImpl.setErrorListener(m_problemListener);
-  }
-
-  /**
-   * Get the current stylesheet for this processor.
-   */
-  public StylesheetRoot getStylesheet()    
-  {
-    return m_stylesheetRoot;
-  }
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Get the filename of the output document, if it was set.
-   * This is for use by multiple output documents, to determine
-   * the base directory for the output document.  It needs to
-   * be set by the caller.
-   */
-  public String getOutputFileName()
-  {
-    return m_outputFileName;
-  }
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Set the filename of the output document.
-   * This is for use by multiple output documents, to determine
-   * the base directory for the output document.  It needs to
-   * be set by the caller.
-   */
-  public void setOutputFileName(String filename)
-  {
-    m_outputFileName = filename;
-  }
-
-  
-
-  /**
-   * Given an input source, get the source tree.
-   */
-  public Node getSourceTreeFromInput(XSLTInputSource inputSource)
-    throws org.xml.sax.SAXException
-  {
-    Node sourceTree = null;
-    String xmlIdentifier = ((null == inputSource) ||
-                            (null == inputSource.getSystemId()))
-                           ? "Input XML" : inputSource.getSystemId();
-    
-    Source iSource = inputSource.getSourceObject(); 
-
-    if(iSource instanceof DOMSource)
-    {
-      //if(getXMLProcessorLiaison() instanceof org.apache.xalan.xpath.dtm.DTMLiaison)
-       // error(XSLTErrorResources.ER_CANT_USE_DTM_FOR_INPUT);
-
-      sourceTree = ((DOMSource)iSource).getNode();
-    }
-    else
-    {
-      // In case we have a fragment identifier, go ahead and
-      // try and parse the XML here.
-      try
-      {
-        diag("========= Parsing "+xmlIdentifier+" ==========");
-        pushTime(xmlIdentifier);
-        
-        //String liaisonClassName = System.getProperty("org.apache.xalan.source.liaison");
-
-        if(null != m_liaison)
-        {
-          //DOM2Helper liaison =  (DOM2Helper)(Class.forName(liaisonClassName).newInstance());
-          m_liaison.parse(SAXSource.sourceToInputSource(iSource));
-          if(null != m_diagnosticsPrintWriter)
-            displayDuration("Parse of "+xmlIdentifier, xmlIdentifier);
-          sourceTree = m_liaison.getDocument();
-        }
-        else
-        {      
-          XMLReader reader = XMLReaderFactory.createXMLReader();        
-          try
-          {
-            reader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
-          }
-          catch(SAXException se)
-          {
-          // What can we do?
-          // TODO: User diagnostics.
-          }
-        
-          // Get the input content handler, which will handle the 
-          // parse events and create the source tree.          
-          //StylesheetHandler inputHandler = (StylesheetHandler)m_processor.getTemplatesBuilder();
-          //reader.setContentHandler( inputHandler );
-          
-          SourceTreeHandler handler = new SourceTreeHandler();
-          reader.setContentHandler(handler);
-          reader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
-        
-          // Kick off the parse.  When the ContentHandler gets 
-          // the startDocument event, it will call transformNode( node ).
-          reader.parse( SAXSource.sourceToInputSource(iSource));
-          sourceTree = handler.getRoot();
-        }
-      }
-      catch(Exception e)
-      {
-        // Unwrap exception
-        if((e instanceof SAXException) && (null != ((SAXException)e).getException()))
-        {
-          // ((SAXException)e).getException().printStackTrace();
-          e = ((SAXException)e).getException();
-        }
-        sourceTree = null; // shutup compiler
-        error(XSLTErrorResources.ER_COULDNT_PARSE_DOC, new Object[] {xmlIdentifier}, e); //"Could not parse "+xmlIdentifier+" document!", e);
-      }
-    }
-
-    return sourceTree;
-  }
-
-  /**
-   * Get Stylesheet from PI URL
-   * 
-   * @param xslURLString a valid URI to an XSL stylesheet.
-   * @param fragbase Document fragment Node.
-   * @param xmlBaseIdent Base URI to resolve stylesheet URL 
-   * @param isRoot Flag indicating if root node
-   */
-  Stylesheet getStylesheetFromPIURL(String xslURLString, Node fragBase,
-                                    String xmlBaseIdent, boolean isRoot)
-    throws SAXException,
-    MalformedURLException,
-    FileNotFoundException,
-    IOException
-  {
-    Stylesheet stylesheet = null;
-    String[] stringHolder =
-    {
-      null};
-    xslURLString = xslURLString.trim();
-    int fragIndex = xslURLString.indexOf('#');
-    String fragID = null;
-    Document stylesheetDoc;
-    if(fragIndex == 0)
-    {
-      diag("Locating stylesheet from fragment identifier...");
-      fragID = xslURLString.substring(1);
-      
-      // Try a bunch of really ugly stuff to find the fragment.
-      // What's the right way to do this?
-
-      // Create a XPath parser.
-      XPathParser parser = new XPathParser((ErrorListener)m_problemListener.getErrorHandler(), null);
-      XPathContext xpathContext = new XPathContext();
-      PrefixResolverDefault nsNode = new PrefixResolverDefault(fragBase); //xpathContext.getNamespaceContext();
-
-      NodeIterator nl = null;
-      // Create the XPath object.
-      try{
-      XPath xpath = new XPath(fragID, null, nsNode, XPath.MATCH);
-      Compiler compiler = new Compiler();
-      // Parse the xpath
-      parser.initXPath(compiler, "id("+fragID+")", nsNode);
-      org.apache.xpath.objects.XObject xobj = xpath.execute(xpathContext, fragBase, nsNode);
-
-      nl = xobj.nodeset();
-      if(nl.nextNode() == null)
-      {
-        // xobj = Stylesheet.evalXPathStr(getExecContext(), "//*[@id='"+fragID+"']", fragBase, nsNode);
-        // Create the XPath object.
-        xpath = new XPath(fragID, null, nsNode, XPath.MATCH);
-
-        // Parse the xpath
-        parser.initXPath(compiler, "//*[@id='"+fragID+"']", nsNode);
-        xobj = xpath.execute(xpathContext, fragBase, nsNode);
-
-        nl = xobj.nodeset();
-        if(nl.nextNode() == null)
-        {
-          // xobj = Stylesheet.evalXPathStr(getExecContext(), "//*[@name='"+fragID+"']", fragBase, nsNode);
-          // Create the XPath object.
-          xpath = new XPath(fragID, null, nsNode, XPath.MATCH);
-
-          // Parse the xpath
-          parser.initXPath(compiler, "//*[@name='"+fragID+"']", nsNode);
-          xobj = xpath.execute(xpathContext, fragBase, nsNode);
-          nl = xobj.nodeset();
-          if(nl.nextNode() == null)
-          {
-            // Well, hell, maybe it's an XPath...
-            // xobj = Stylesheet.evalXPathStr(getExecContext(), fragID, fragBase, nsNode);
-            // Create the XPath object.
-            //((StylesheetHandler)( m_processor.getTemplatesBuilder())).getLocator()
-            xpath = new XPath(fragID, null, nsNode, XPath.MATCH);
-
-            // Parse the xpath
-            parser.initXPath(compiler, fragID, nsNode);
-            xobj = xpath.execute(xpathContext, fragBase, nsNode);
-            nl = xobj.nodeset();
-          }
-        }
-      }
-      }
-      catch (TransformerException te)
-      {
-        throw new SAXException(te);
-      }
-      if(nl.nextNode() == null)
-      {
-        error(XSLTErrorResources.ER_COULDNT_FIND_FRAGMENT, new Object[] {fragID}); //"Could not find fragment: "+fragID);
-      }
-      // Use previous because the previous call moved the pointer.
-      // or should we use getRoot??
-      Node frag = nl.previousNode(); //.item(0);
-
-      if(Node.ELEMENT_NODE == frag.getNodeType())
-      {
-        pushTime(frag);
-        if(isRoot)
-        {
-          m_stylesheetRoot = createStylesheetRoot(stringHolder[0]);
-          stylesheet = m_stylesheetRoot.getObject();
-        }
-        else
-        {
-          //stylesheet = new Stylesheet(m_stylesheetRoot);
-          // stylesheet = ((StylesheetHandler)(m_processor.getTemplatesBuilder())).getStylesheetRoot();
-          try{
-            Source source = new XSLTInputSource(fragID).getSourceObject(); 
-            Templates templates = m_tfactory.newTemplates(source);
-            stylesheet = (org.apache.xalan.templates.StylesheetRoot)templates;
-          }
-          catch (TransformerConfigurationException tce)
-          {
-            throw new SAXException(tce);
-          }
-        }
-        addTraceListenersToStylesheet();
-
-        try{
-        StylesheetHandler stylesheetProcessor
-          = new StylesheetHandler((TransformerFactoryImpl)m_tfactory);
-           
-        stylesheetProcessor.pushStylesheet(stylesheet);
-        TreeWalker tw = new TreeWalker(stylesheetProcessor, new org.apache.xpath.DOM2Helper());
-        tw.traverse(frag);
-
-        displayDuration("Setup of "+xslURLString, frag);
-        }
-        catch (TransformerConfigurationException tce)
-        {
-          throw new SAXException(tce);
-        }
-      }
-      else
-      {
-        stylesheetDoc = null;
-        error(XSLTErrorResources.ER_NODE_NOT_ELEMENT, new Object[] {fragID}); //"Node pointed to by fragment identifier was not an element: "+fragID);
-      }
-    }
-    else
-    {
-      // TODO: Use Reader here??
-      // hmmm.. for now I'll rely on the XML parser to handle
-      // fragment URLs.
-      diag(XSLMessages.createMessage(XSLTErrorResources.WG_PARSING_AND_PREPARING, new Object[] {xslURLString})); //"========= Parsing and preparing "+xslURLString+" ==========");
-      pushTime(xslURLString);
-
-			URL xslURL = getURLFromString(xslURLString, xmlBaseIdent);
-
-      XSLTInputSource inputSource = new XSLTInputSource(xslURL.toString());
-      
-			if(isRoot)
-			{				
-				if(null != m_liaison)
-				{
-					try{
-						m_liaison.parse(SAXSource.sourceToInputSource(inputSource.getSourceObject()));
-						DOMSource source = new DOMSource(m_liaison.getDocument());
-						Templates templates = m_tfactory.newTemplates(source);
-						m_stylesheetRoot = new StylesheetRoot(
-																		(org.apache.xalan.templates.StylesheetRoot)templates);
-					}					
-					catch (TransformerException tce)
-					{
-						throw new SAXException(tce);
-					}
-				}
-				else
-				{
-					m_stylesheetRoot = createStylesheetRoot(xslURLString);
-				}
-				stylesheet = m_stylesheetRoot.getObject();
-			}
-      else
-      {
-        stylesheet = new Stylesheet(m_stylesheetRoot.getObject());
-      }
-      addTraceListenersToStylesheet();
-
-      try{
-      org.apache.xalan.processor.StylesheetHandler stylesheetProcessor
-        = new StylesheetHandler((TransformerFactoryImpl)m_tfactory); //this, stylesheet); 
-      stylesheetProcessor.pushStylesheet(stylesheet);
-         // new StylesheetHandler(this, stylesheet);
-      }
-      catch (TransformerConfigurationException tce)
-      {
-        throw new SAXException(tce);
-      }
-      
-       
-      //m_parserLiaison.setDocumentHandler(stylesheetProcessor);
-      //m_parserLiaison.parse(inputSource);
-
-      displayDuration("Parsing and init of "+xslURLString, xslURLString);
-    }
-    return stylesheet;
-  }
-
-        
-  /**
-   * Take a user string and try and parse XML, and also return 
-   * the url.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XPathContext decide 
-   * the error condition is severe enough to halt processing.
-   */
-  public static URL getURLFromString(String urlString, String base)
-    throws SAXException 
-  {
-    String origURLString = urlString;
-    String origBase = base;
-    
-    // System.out.println("getURLFromString - urlString: "+urlString+", base: "+base);
-    Object doc;
-    URL url = null;
-    int fileStartType = 0;
-    try
-    {
-      
-      if(null != base)
-      {
-        if(base.toLowerCase().startsWith("file:/"))
-        {
-          fileStartType = 1;
-        }
-        else if(base.toLowerCase().startsWith("file:"))
-        {
-          fileStartType = 2;
-        }
-      }
-      
-      boolean isAbsoluteURL;
-      
-      // From http://www.ics.uci.edu/pub/ietf/uri/rfc1630.txt
-      // A partial form can be distinguished from an absolute form in that the
-      // latter must have a colon and that colon must occur before any slash
-      // characters. Systems not requiring partial forms should not use any
-      // unencoded slashes in their naming schemes.  If they do, absolute URIs
-      // will still work, but confusion may result.
-      int indexOfColon = urlString.indexOf(':');
-      int indexOfSlash = urlString.indexOf('/');
-      if((indexOfColon != -1) && (indexOfSlash != -1) && (indexOfColon < indexOfSlash))
-      {
-        // The url (or filename, for that matter) is absolute.
-        isAbsoluteURL = true;
-      }
-      else
-      {
-        isAbsoluteURL = false;
-      }
-      
-      if(isAbsoluteURL || (null == base) || (base.length() == 0))
-      {
-        try 
-        {
-          url = new URL(urlString);
-        }
-        catch (MalformedURLException e) {}
-      }
-      // The Java URL handling doesn't seem to handle relative file names.
-      else if(!((urlString.charAt(0) == '.') || (fileStartType > 0)))
-      {
-        try 
-        {
-          URL baseUrl = new URL(base);
-          url = new URL(baseUrl, urlString);
-        }
-        catch (MalformedURLException e) 
-        {
-        }
-      }
-      
-      if(null == url)
-      {
-        // Then we're going to try and make a file URL below, so strip 
-        // off the protocol header.
-        if(urlString.toLowerCase().startsWith("file:/"))
-        {
-          urlString = urlString.substring(6);
-        }
-        else if(urlString.toLowerCase().startsWith("file:"))
-        {
-          urlString = urlString.substring(5);
-        }
-      }
-      
-      if((null == url) && ((null == base) || (fileStartType > 0)))
-      {
-        if(1 == fileStartType)
-        {
-          if(null != base)
-            base = base.substring(6);
-          fileStartType = 1;
-        }
-        else if(2 == fileStartType)
-        {
-          if(null != base)
-            base = base.substring(5);
-          fileStartType = 2;
-        }
-        
-        File f = new File(urlString);
-        
-        if(!f.isAbsolute() && (null != base))
-        {
-          // String dir = f.isDirectory() ? f.getAbsolutePath() : f.getParent();
-          // System.out.println("prebuiltUrlString (1): "+base);
-          StringTokenizer tokenizer = new StringTokenizer(base, "\\/");
-          String fixedBase = null;
-          while(tokenizer.hasMoreTokens())
-          {
-            String token = tokenizer.nextToken();
-            if (null == fixedBase) 
-            {
-              // Thanks to Rick Maddy for the bug fix for UNIX here.
-              if (base.charAt(0) == '\\' || base.charAt(0) == '/') 
-              {
-                fixedBase = File.separator + token;
-              }
-              else 
-              {
-                fixedBase = token;
-              }
-            }
-            else 
-            {
-              fixedBase+= File.separator + token;
-            }
-          }
-          // System.out.println("rebuiltUrlString (1): "+fixedBase);
-          f = new File(fixedBase);
-          String dir = f.isDirectory() ? f.getAbsolutePath() : f.getParent();
-          // System.out.println("dir: "+dir);
-          // System.out.println("urlString: "+urlString);
-          // f = new File(dir, urlString);
-          // System.out.println("f (1): "+f.toString());
-          // urlString = f.getAbsolutePath();
-          f = new File(urlString); 
-          boolean isAbsolute =  f.isAbsolute() 
-                                || (urlString.charAt( 0 ) == '\\')
-                                || (urlString.charAt( 0 ) == '/');
-          if(!isAbsolute)
-          {
-            // Getting more and more ugly...
-            if(dir.charAt( dir.length()-1 ) != File.separator.charAt(0) && 
-               urlString.charAt( 0 ) != File.separator.charAt(0))
-            {
-              urlString = dir + File.separator + urlString;
-            }
-            else
-            {
-              urlString = dir + urlString;
-            }
-
-            // System.out.println("prebuiltUrlString (2): "+urlString);
-            tokenizer = new StringTokenizer(urlString, "\\/");
-            String rebuiltUrlString = null;
-            while(tokenizer.hasMoreTokens())
-            {
-              String token = tokenizer.nextToken();
-              if (null == rebuiltUrlString) 
-              {
-                // Thanks to Rick Maddy for the bug fix for UNIX here.
-                if (urlString.charAt(0) == '\\' || urlString.charAt(0) == '/') 
-                {
-                  rebuiltUrlString = File.separator + token;
-                }
-                else 
-                {
-                  rebuiltUrlString = token;
-                }
-              }
-              else 
-              {
-                rebuiltUrlString+= File.separator + token;
-              }
-            }
-            // System.out.println("rebuiltUrlString (2): "+rebuiltUrlString);
-            if(null != rebuiltUrlString)
-              urlString = rebuiltUrlString;
-          }
-          // System.out.println("fileStartType: "+fileStartType);
-          if(1 == fileStartType)
-          {
-            if (urlString.charAt(0) == '/') 
-            {
-              urlString = "file://"+urlString;
-            }
-            else
-            {
-              urlString = "file:/"+urlString;
-            }
-          }
-          else if(2 == fileStartType)
-          {
-            urlString = "file:"+urlString;
-          }
-          try 
-          {
-            // System.out.println("Final before try: "+urlString);
-            url = new URL(urlString);
-          }
-          catch (MalformedURLException e) 
-          {
-            // System.out.println("Error trying to make URL from "+urlString);
-          }
-        }
-      }
-      if(null == url)
-      {
-        // The sun java VM doesn't do this correctly, but I'll 
-        // try it here as a second-to-last resort.
-        if((null != origBase) && (origBase.length() > 0))
-        {
-          try 
-          {
-            URL baseURL = new URL(origBase);
-            // System.out.println("Trying to make URL from "+origBase+" and "+origURLString);
-            url = new URL(baseURL, origURLString);
-            // System.out.println("Success! New URL is: "+url.toString());
-          }
-          catch (MalformedURLException e) 
-          {
-            // System.out.println("Error trying to make URL from "+origBase+" and "+origURLString);
-          }
-        }
-        
-        if(null == url)
-        {
-          try 
-          {
-            String lastPart;
-            if(null != origBase)
-            {
-              File baseFile = new File(origBase);
-              if(baseFile.isDirectory())
-              {
-                lastPart = new File(baseFile, urlString).getAbsolutePath ();
-              }
-              else
-              {
-                String parentDir = baseFile.getParent();
-                lastPart = new File(parentDir, urlString).getAbsolutePath ();
-              }
-            }
-            else
-            {
-              lastPart = new File (urlString).getAbsolutePath ();
-            }
-            // Hack
-            // if((lastPart.charAt(0) == '/') && (lastPart.charAt(2) == ':'))
-            //   lastPart = lastPart.substring(1, lastPart.length() - 1);
-            
-            String fullpath;
-            if (lastPart.charAt(0) == '\\' || lastPart.charAt(0) == '/') 
-            {
-              fullpath = "file://" + lastPart;
-            }
-            else
-            {
-              fullpath = "file:" + lastPart;
-            }
-            url = new URL(fullpath);
-          }
-          catch (MalformedURLException e2)
-          {
-            throw new SAXException("Cannot create url for: " + urlString, e2 ); 
-              //XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANNOT_CREATE_URL, new Object[]{urlString}),e2); //"Cannot create url for: " + urlString, e2 );
-          }
-        }
-      }
-    }
-    catch(SecurityException se)
-    {
-      try
-      {
-        url = new URL("http://xml.apache.org/xslt/"+java.lang.Math.random()); // dummy
-      }
-      catch (MalformedURLException e2)
-      {
-        // I give up
-      }
-    }
-    // System.out.println("url: "+url.toString());
-    return url;
-  }
-
-   /**
-   * Add a trace listener for the purposes of debugging and diagnosis.
-   * @param tl Trace listener to be added.
-   */
-  void addTraceListenersToStylesheet()
-    throws SAXException
-  {
-    /*try
-    {
-      TraceManager tm = m_transformerImpl.getTraceManager();
-      if(tm.hasTraceListeners)
-      {
-        int nListeners = tm.size();
-        for(int i = 0; i < nListeners; i++)
-        {
-          TraceListener tl = (TraceListener)m_traceListeners.elementAt(i);
-          if(null != m_stylesheetRoot)
-            m_stylesheetRoot.addTraceListener(tl);
-        }
-      }
-    }
-    catch(TooManyListenersException tmle)
-    {
-      throw new SAXException(XSLMessages.createMessage(XSLTErrorResources.ER_TOO_MANY_LISTENERS, null),tmle ); //"addTraceListenersToStylesheet - TooManyListenersException", tmle);
-    }*/
-  }
-  
-  /**
-   * Warn the user of an problem.
-   * This is public for access by extensions.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public void message(String msg)
-    throws SAXException
-  {
-    message(null, null, msg);
-  }
-
-
-
-  /**
-   * Warn the user of an problem.
-   * This is public for access by extensions.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public void message(Node styleNode, Node sourceNode, String msg)
-    throws SAXException
-  {
-    m_problemListener.message(msg);
-  }
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Warn the user of an problem.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public void warn(int msg)
-    throws SAXException
-  {
-    warn(null, null, msg, null);
-  }
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Warn the user of an problem.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public void warn(int msg, Object[] args)
-    throws SAXException
-  {
-    warn(null, null, msg, args);
-  }
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Warn the user of an problem.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public void warn(Node styleNode, Node sourceNode, int msg)
-    throws SAXException
-  {
-    warn(styleNode, sourceNode, msg, null);
-  }
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Warn the user of an problem.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public void warn(Node styleNode, Node sourceNode, int msg, Object args[])
-    throws SAXException
-  {
-    Exception e = null;
-    String fmsg = m_XSLMessages.createWarning(msg, args);
-    SourceLocator locator = null;
-    try{
-     locator = ((StylesheetHandler)(((TransformerFactoryImpl)this.m_tfactory).newTemplatesHandler())).getLocator();
-    }
-    catch (TransformerConfigurationException tce)
-    {
-    }
-    
-    DefaultErrorHandler handler;
-    if (m_problemListener == null)
-      handler = (DefaultErrorHandler)m_tfactory.getErrorListener();
-    else
-      handler = (DefaultErrorHandler)m_problemListener.getErrorHandler();
-    TransformerException te = (null == e) ? new TransformerException(fmsg, locator) :
-                                          new TransformerException(fmsg, locator, e);
-    if(null != handler)
-    {
-      try{
-      handler.warning(te);
-      }
-      catch (TransformerException te2)
-      {
-        throw new SAXException(te2);
-      } 
-    }
-    else
-      throw new SAXException(te);
-  }
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Tell the user of an error, and probably throw an
-   * exception.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public void error(String msg)
-    throws SAXException
-  {
-    Exception e = null;
-    SourceLocator locator = null;
-    try{
-    locator = ((StylesheetHandler)(((TransformerFactoryImpl)this.m_tfactory).newTemplatesHandler())).getLocator();
-    }
-    catch (TransformerConfigurationException tce)
-    {
-    }
-    DefaultErrorHandler handler;
-    if (m_problemListener == null)
-      handler = (DefaultErrorHandler)m_tfactory.getErrorListener();
-    else
-      handler = (DefaultErrorHandler)m_problemListener.getErrorHandler();
-    TransformerException te = (null == e) ? new TransformerException(msg, locator) :
-                                          new TransformerException(msg, locator, e);
-    if(null != handler)
-    {  
-      try{
-      handler.fatalError(te);
-    }
-      catch (TransformerException te2)
-      {
-        throw new SAXException(te2);
-      } 
-    }
-    else
-      throw new SAXException(te);
-  }
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Tell the user of an error, and probably throw an
-   * exception.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public void error(int msg)
-    throws SAXException
-  {
-    error(null, null, msg, null);
-  }
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Tell the user of an error, and probably throw an
-   * exception.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public void error(int msg, Object[] args)
-    throws SAXException
-  {
-    error(null, null, msg, args);
-  }
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Tell the user of an error, and probably throw an
-   * exception.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public void error(int msg, Exception e)
-    throws SAXException
-  {
-    error(msg, null, e);
-  }
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Tell the user of an error, and probably throw an
-   * exception.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public void error(int msg, Object args[], Exception e)
-    throws SAXException
-  {
-    String fmsg = m_XSLMessages.createMessage(msg, args);
-    SourceLocator locator = null;
-    try{
-      locator = ((StylesheetHandler)(((TransformerFactoryImpl)this.m_tfactory).newTemplatesHandler())).getLocator();
-    }
-    catch (TransformerConfigurationException tce)
-    {
-    }
-    DefaultErrorHandler handler;
-    if (m_problemListener == null)
-      handler = (DefaultErrorHandler)m_tfactory.getErrorListener();
-    else
-      handler = (DefaultErrorHandler)m_problemListener.getErrorHandler();
-    TransformerException te = (null == e) ? new TransformerException(fmsg, locator) :
-                                          new TransformerException(fmsg, locator, e);
-    if(null != handler)
-    {
-      try{
-      handler.fatalError(te);
-    }
-      catch (TransformerException te2)
-      {
-        throw new SAXException(te2);
-      } 
-    }
-    else
-      throw new SAXException(te);
-  }
-
-  /**
-    * <meta name="usage" content="internal"/>
-  * Tell the user of an error, and probably throw an
-   * exception.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public void error(Node styleNode, Node sourceNode, int msg)
-    throws SAXException
-  {
-    error(styleNode, sourceNode, msg, null);
-  }
-
-  /**
-   * <meta name="usage" content="internal"/>
-   * Tell the user of an error, and probably throw an
-   * exception.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public void error(Node styleNode, Node sourceNode, int msg, Object args[])
-    throws SAXException
-  {
-    Exception e = null;
-    String fmsg = m_XSLMessages.createMessage(msg, args);
-    SourceLocator locator = null;
-    try{
-     locator = ((StylesheetHandler)(((TransformerFactoryImpl)this.m_tfactory).newTemplatesHandler())).getLocator();
-    }
-    catch (TransformerConfigurationException tce)
-    {
-    }
-    DefaultErrorHandler handler;
-    if (m_problemListener == null)
-      handler = (DefaultErrorHandler)m_tfactory.getErrorListener();
-    else
-      handler = (DefaultErrorHandler)m_problemListener.getErrorHandler();
-    TransformerException te = (null == e) ? new TransformerException(fmsg, locator) :
-                                          new TransformerException(fmsg, locator, e);
-    if(null != handler)
-    {  
-      try{
-       handler.fatalError(te);
-      }
-      catch (TransformerException te2)
-      {
-        throw new SAXException(te2);
-      }
-    }
-    else
-      throw new SAXException(te);
-    
-   
-  }
-  
-  /**
-   * Mark the time, so that displayDuration can later
-   * display the elapse.
-   */
-  void pushTime(Object key)
-  {
-    if(null != key)
-    {
-      m_durationsTable.put(key, new Long(System.currentTimeMillis()));
-    }
-  }
-
-  /**
-   * Returns the duration since pushTime was called,
-   * in milliseconds.
-   */
-  long popDuration(Object key)
-  {
-    long millisecondsDuration = 0;
-    if(null != key)
-    {
-      long start = ((Long)m_durationsTable.get(key)).longValue();
-      long stop = System.currentTimeMillis();
-      millisecondsDuration = stop - start;
-      m_durationsTable.remove(key);
-    }
-    return millisecondsDuration;
-  }
-  
-   /**
-   * Display the duration since pushTime was called.
-   */
-  protected void displayDuration(String info, Object key)
-  {
-    long millisecondsDuration = 0;
-    if(null != key)
-    {
-      long start = ((Long)m_durationsTable.get(key)).longValue();
-      long stop = System.currentTimeMillis();
-      millisecondsDuration = stop - start;
-      if(null != m_diagnosticsPrintWriter)
-      {
-        m_diagnosticsPrintWriter.println(info + " took " + millisecondsDuration + " milliseconds");
-      }
-      m_durationsTable.remove(key);
-    }
-  }
-  
-  /**
-   * If this is set, diagnostics will be
-   * written to the m_diagnosticsPrintWriter stream. If
-   * the value is null, then diagnostics will be turned
-   * off.
-   */
-  public void setDiagnosticsOutput(java.io.OutputStream out)
-  {
-    setDiagnosticsOutput(new PrintWriter(out));
-  }
-
-  /**
-   * If this is set, diagnostics will be
-   * written to the m_diagnosticsPrintWriter stream. If
-   * the value is null, then diagnostics will be turned
-   * off.
-   */
-  public void setDiagnosticsOutput(java.io.PrintWriter pw)
-  {
-    m_diagnosticsPrintWriter = pw;
-   /* if(getProblemListener() instanceof ProblemListenerDefault)
-    {
-      ((ProblemListenerDefault)getProblemListener()).setDiagnosticsOutput(pw);
-    }*/
-  }
-
-  /**
-   * Bottleneck output of diagnostics.
-   */
-  protected void diag(String s)
-  {
-    if(null != m_diagnosticsPrintWriter)
-    {
-      m_diagnosticsPrintWriter.println(s);
-    }
-  }
-
-  /**
-   * If this is set to true, simple traces of
-   * template calls are made.
-   */
-  public void setTraceTemplates(boolean b)
-  {
-    m_traceTemplates = b;
-  }
-
-  /**
-   * If this is set to true, simple traces of
-   * template calls are made.
-   */
-  public void setTraceSelect(boolean b)
-  {
-    m_traceSelects = b;
-  }
-
-  /**
-   * If this is set to true, debug diagnostics about
-   * template children as they are being constructed
-   * will be written to the m_diagnosticsPrintWriter
-   * stream.  diagnoseTemplateChildren is false by
-   * default.
-   */
-  public void setTraceTemplateChildren(boolean b)
-  {
-    m_traceTemplateChildren = b;
-  }
-  
-  //
-  // Lexical handler interface
-  //
-
-    /**
-     * Report the start of DTD declarations, if any.
-     *
-     * <p>Any declarations are assumed to be in the internal subset
-     * unless otherwise indicated by a {@link #startEntity startEntity}
-     * event.</p>
-     *
-     * <p>Note that the start/endDTD events will appear within
-     * the start/endDocument events from ContentHandler and
-     * before the first startElement event.</p>
-     *
-     * @param name The document type name.
-     * @param publicId The declared public identifier for the
-     *        external DTD subset, or null if none was declared.
-     * @param systemId The declared system identifier for the
-     *        external DTD subset, or null if none was declared.
-     * @exception SAXException The application may raise an
-     *            exception.
-     * @see #endDTD
-     * @see #startEntity
-     */
-    public void startDTD (String name, String publicId, String systemId)
-	throws SAXException
-    {
-      if (m_transformerImpl != null && m_transformerImpl.getInputLexicalHandler() != null)
-        m_transformerImpl.getInputLexicalHandler().startDTD(name, publicId, systemId);
-    }
-
-
-    /**
-     * Report the end of DTD declarations.
-     *
-     * @exception SAXException The application may raise an exception.
-     * @see #startDTD
-     */
-    public void endDTD ()
-	throws SAXException
-    {
-      if (m_transformerImpl != null && m_transformerImpl.getInputLexicalHandler() != null)
-        m_transformerImpl.getInputLexicalHandler().endDTD();
-    }
-    
-    public void startEntity (String name)
-	throws SAXException
-    {
-      if (m_transformerImpl != null && m_transformerImpl.getInputLexicalHandler() != null)
-        m_transformerImpl.getInputLexicalHandler().startEntity (name);
-    }
-
-
-    /**
-     * Report the end of an entity.
-     *
-     * @param name The name of the entity that is ending.
-     * @exception SAXException The application may raise an exception.
-     * @see #startEntity
-     */
-    public void endEntity (String name)
-	throws SAXException
-      {
-      if (m_transformerImpl != null && m_transformerImpl.getInputLexicalHandler() != null)
-        m_transformerImpl.getInputLexicalHandler().endEntity (name);
-    }
-
-
-    /**
-     * Report the start of a CDATA section.
-     *
-     * <p>The contents of the CDATA section will be reported through
-     * the regular {@link org.xml.sax.ContentHandler#characters
-     * characters} event.</p>
-     *
-     * @exception SAXException The application may raise an exception.
-     * @see #endCDATA
-     */
-    public  void startCDATA ()
-	throws SAXException
-    { 
-      if (m_transformerImpl != null && m_transformerImpl.getInputLexicalHandler() != null)
-        m_transformerImpl.getInputLexicalHandler().startCDATA();
-    }
-
-
-    /**
-     * Report the end of a CDATA section.
-     *
-     * @exception SAXException The application may raise an exception.
-     * @see #startCDATA
-     */
-    public void endCDATA ()
-	throws SAXException
-    {
-      if (m_transformerImpl != null && m_transformerImpl.getInputLexicalHandler() != null)
-        m_transformerImpl.getInputLexicalHandler().endCDATA();
-    }
-
-
-    /**
-     * Report an XML comment anywhere in the document.
-     *
-     * <p>This callback will be used for comments inside or outside the
-     * document element, including comments in the external DTD
-     * subset (if read).</p>
-     *
-     * @param ch An array holding the characters in the comment.
-     * @param start The starting position in the array.
-     * @param length The number of characters to use from the array.
-     * @exception SAXException The application may raise an exception.
-     */
-    public  void comment (char ch[], int start, int length)
-	throws SAXException
-      {
-      if (m_transformerImpl != null && m_transformerImpl.getInputLexicalHandler() != null)
-        m_transformerImpl.getInputLexicalHandler().comment (ch, start, length);
-    }
-    
-    // DocumentHandler interface
-    
-        /**
-     * Receive an object for locating the origin of SAX document events.
-     *
-     * <p>SAX parsers are strongly encouraged (though not absolutely
-     * required) to supply a locator: if it does so, it must supply
-     * the locator to the application by invoking this method before
-     * invoking any of the other methods in the DocumentHandler
-     * interface.</p>
-     *
-     * <p>The locator allows the application to determine the end
-     * position of any document-related event, even if the parser is
-     * not reporting an error.  Typically, the application will
-     * use this information for reporting its own errors (such as
-     * character content that does not match an application's
-     * business rules).  The information returned by the locator
-     * is probably not sufficient for use with a search engine.</p>
-     *
-     * <p>Note that the locator will return correct information only
-     * during the invocation of the events in this interface.  The
-     * application should not attempt to use it at any other time.</p>
-     *
-     * @param locator An object that can return the location of
-     *                any SAX document event.
-     * @see org.xml.sax.Locator
-     */
-    public void setDocumentLocator (Locator locator)
-    {}
-    
-    
-    /**
-     * Receive notification of the beginning of a document.
-     *
-     * <p>The SAX parser will invoke this method only once, before any
-     * other methods in this interface or in DTDHandler (except for
-     * setDocumentLocator).</p>
-     *
-     * @exception org.xml.sax.SAXException Any SAX exception, possibly
-     *            wrapping another exception.
-     */
-    public void startDocument ()
-	throws SAXException
-    {
-      if (m_documentHandler != null)
-        m_documentHandler.startDocument();
-      else if (m_transformerImpl != null)
-        m_transformerImpl.getInputContentHandler().startDocument();
-      //m_transformerImpl.getResultTreeHandler().startDocument();
-      
-    }
-    
-    
-    /**
-     * Receive notification of the end of a document.
-     *
-     * <p>The SAX parser will invoke this method only once, and it will
-     * be the last method invoked during the parse.  The parser shall
-     * not invoke this method until it has either abandoned parsing
-     * (because of an unrecoverable error) or reached the end of
-     * input.</p>
-     *
-     * @exception org.xml.sax.SAXException Any SAX exception, possibly
-     *            wrapping another exception.
-     */
-    public void endDocument ()
-	throws SAXException
-    {
-      if (m_documentHandler != null)
-        m_documentHandler.endDocument();
-      else if (m_transformerImpl != null)
-        m_transformerImpl.getInputContentHandler().endDocument();
-      //m_transformerImpl.getResultTreeHandler().endDocument();
-    }
-    
-    
-    /**
-     * Receive notification of the beginning of an element.
-     *
-     * <p>The Parser will invoke this method at the beginning of every
-     * element in the XML document; there will be a corresponding
-     * endElement() event for every startElement() event (even when the
-     * element is empty). All of the element's content will be
-     * reported, in order, before the corresponding endElement()
-     * event.</p>
-     *
-     * <p>If the element name has a namespace prefix, the prefix will
-     * still be attached.  Note that the attribute list provided will
-     * contain only attributes with explicit values (specified or
-     * defaulted): #IMPLIED attributes will be omitted.</p>
-     *
-     * @param name The element type name.
-     * @param atts The attributes attached to the element, if any.
-     * @exception org.xml.sax.SAXException Any SAX exception, possibly
-     *            wrapping another exception.
-     * @see #endElement
-     * @see org.xml.sax.AttributeList 
-     */
-    public void startElement (String name, AttributeList atts)
-	throws SAXException
-    {
-      if (m_documentHandler == null)       
-      { 
-        m_documentHandler = new ParserAdapter(new org.apache.xerces.parsers.SAXParser());
-        if (m_transformerImpl != null)
-        {  
-          ((ParserAdapter)m_documentHandler).setContentHandler(m_transformerImpl.getInputContentHandler());
-        }
-        /* else if (m_transformerImpl != null)
-        {
-        int index = name.indexOf(":");
-        if (index < 0 )
-        m_transformerImpl.getInputContentHandler().startElement(null, name, name, (Attributes)atts);
-        //getResultTreeHandler().startElement(null, name, name, (Attributes)atts);
-        else
-        m_transformerImpl.getInputContentHandler().startElement(name.substring(0,index), name.substring(index+1), name, (Attributes)atts);        
-        //m_transformerImpl.getResultTreeHandler().startElement(name.substring(0,index), name.substring(index+1), name, (Attributes)atts);
-        */ 
-      } 
-      m_documentHandler.startElement(name, atts);
-    }   
-    
-    /**
-     * Receive notification of the end of an element.
-     *
-     * <p>The SAX parser will invoke this method at the end of every
-     * element in the XML document; there will be a corresponding
-     * startElement() event for every endElement() event (even when the
-     * element is empty).</p>
-     *
-     * <p>If the element name has a namespace prefix, the prefix will
-     * still be attached to the name.</p>
-     *
-     * @param name The element type name
-     * @exception org.xml.sax.SAXException Any SAX exception, possibly
-     *            wrapping another exception.
-     */
-    public void endElement (String name)
-	throws SAXException
-    {
-      if (m_documentHandler == null)        
-      {         
-        m_documentHandler = new ParserAdapter(new org.apache.xerces.parsers.SAXParser());
-        if (m_transformerImpl != null)
-        {
-          ((ParserAdapter)m_documentHandler).setContentHandler(m_transformerImpl.getInputContentHandler());
-        }
-     /* else if (m_transformerImpl != null)
-      {
-        int index = name.indexOf(":");
-        if (index < 0 )
-          m_transformerImpl.getInputContentHandler().endElement(null, name, name);
-          //m_transformerImpl.getResultTreeHandler().endElement(null, name, name);        
-        else
-          m_transformerImpl.getInputContentHandler().endElement(name.substring(0,index), name.substring(index+1), name);
-          //m_transformerImpl.getResultTreeHandler().endElement(name.substring(0,index), name.substring(index+1), name);
-        */
-      } 
-      m_documentHandler.endElement(name);      
-    }     
-    
-    
-    /**
-     * Receive notification of character data.
-     *
-     * <p>The Parser will call this method to report each chunk of
-     * character data.  SAX parsers may return all contiguous character
-     * data in a single chunk, or they may split it into several
-     * chunks; however, all of the characters in any single event
-     * must come from the same external entity, so that the Locator
-     * provides useful information.</p>
-     *
-     * <p>The application must not attempt to read from the array
-     * outside of the specified range.</p>
-     *
-     * <p>Note that some parsers will report whitespace using the
-     * ignorableWhitespace() method rather than this one (validating
-     * parsers must do so).</p>
-     *
-     * @param ch The characters from the XML document.
-     * @param start The start position in the array.
-     * @param length The number of characters to read from the array.
-     * @exception org.xml.sax.SAXException Any SAX exception, possibly
-     *            wrapping another exception.
-     * @see #ignorableWhitespace 
-     * @see org.xml.sax.Locator
-     */
-    public void characters (char ch[], int start, int length)
-	throws SAXException
-    {
-      if (m_documentHandler != null)
-        m_documentHandler.characters(ch, start, length);
-      else if (m_transformerImpl != null)
-      m_transformerImpl.getInputContentHandler().characters(ch, start, length);
-      //m_transformerImpl.getResultTreeHandler().characters(ch, start, length);
-    }  
-    
-    
-    /**
-     * Receive notification of ignorable whitespace in element content.
-     *
-     * <p>Validating Parsers must use this method to report each chunk
-     * of ignorable whitespace (see the W3C XML 1.0 recommendation,
-     * section 2.10): non-validating parsers may also use this method
-     * if they are capable of parsing and using content models.</p>
-     *
-     * <p>SAX parsers may return all contiguous whitespace in a single
-     * chunk, or they may split it into several chunks; however, all of
-     * the characters in any single event must come from the same
-     * external entity, so that the Locator provides useful
-     * information.</p>
-     *
-     * <p>The application must not attempt to read from the array
-     * outside of the specified range.</p>
-     *
-     * @param ch The characters from the XML document.
-     * @param start The start position in the array.
-     * @param length The number of characters to read from the array.
-     * @exception org.xml.sax.SAXException Any SAX exception, possibly
-     *            wrapping another exception.
-     * @see #characters
-     */
-    public void ignorableWhitespace (char ch[], int start, int length)
-	throws SAXException
-    {
-      if (m_documentHandler != null)
-        m_documentHandler.ignorableWhitespace(ch, start, length);
-      else if (m_transformerImpl != null)
-      m_transformerImpl.getInputContentHandler().ignorableWhitespace(ch, start, length);
-      //m_transformerImpl.getResultTreeHandler().ignorableWhitespace(ch, start, length);
-    }
-    
-    
-    /**
-     * Receive notification of a processing instruction.
-     *
-     * <p>The Parser will invoke this method once for each processing
-     * instruction found: note that processing instructions may occur
-     * before or after the main document element.</p>
-     *
-     * <p>A SAX parser should never report an XML declaration (XML 1.0,
-     * section 2.8) or a text declaration (XML 1.0, section 4.3.1)
-     * using this method.</p>
-     *
-     * @param target The processing instruction target.
-     * @param data The processing instruction data, or null if
-     *        none was supplied.
-     * @exception org.xml.sax.SAXException Any SAX exception, possibly
-     *            wrapping another exception.
-     */
-    public  void processingInstruction (String target, String data)
-	throws SAXException
-    {
-      if (m_documentHandler != null)
-        m_documentHandler.processingInstruction(target, data);
-      else if (m_transformerImpl != null)
-      m_transformerImpl.getInputContentHandler().processingInstruction(target, data);
-      //m_transformerImpl.getResultTreeHandler().processingInstruction(target, data);
-    }
-    
-    // Implement XSLTProcessor
-    
-    /**
-   * Set the output stream. Required when the XSLTProcessor is being used
-   * as a SAX DocumentHandler.
-   */
-  public void setOutputStream(java.io.OutputStream os)
-  {
-    SourceTreeHandler handler = new SourceTreeHandler(m_transformerImpl);
-    handler.setResult(new StreamResult(os));   
-  }
-  
-  /**
-   * Convenience function to create an XString.
-   * @param s A valid string.
-   * @return An XString object.
-   */
-  public XString createXString(String s)
-  {
-    return new XString(s);
-  }
-
-  /**
-   * Convenience function to create an XObject.
-   * @param o Any java object.
-   * @return An XObject object.
-   */
-  public XObject createXObject(Object o)
-  {
-    return new XObject(o);
-  }
-
-  /**
-   * Convenience function to create an XNumber.
-   * @param d Any double number.
-   * @return An XNumber object.
-   */
-  public XNumber createXNumber(double d)
-  {
-    return new XNumber(d);
-  }
-
-  /**
-   * Convenience function to create an XBoolean.
-   * @param b boolean value.
-   * @return An XBoolean object.
-   */
-  public XBoolean createXBoolean(boolean b)
-  {
-    return new XBoolean(b);
-  }
-
-  /**
-   * Convenience function to create an XNodeSet.
-   * @param nl A NodeList object.
-   * @return An XNodeSet object.
-   */
-  public XNodeSet createXNodeSet(NodeList nl)
-  {
-    return new XNodeSet(nl);
-  }
-
-  /**
-   * Convenience function to create an XNodeSet from a node.
-   * @param n A DOM node.
-   * @return An XNodeSet object.
-   */
-  public XNodeSet createXNodeSet(Node n)
-  {
-    return new XNodeSet(n);
-  }
-
-  /**
-   * Convenience function to create an XNull.
-   * @return An XNull object.
-   */
-  public XNull createXNull()
-  {
-    return new XNull();
-  }
-  
-  /**
-   * Get the XMLParserLiaison that this processor uses.
-   */
-  public XMLParserLiaison getXMLProcessorLiaison()
-  {
-    return (XMLParserLiaison)m_liaison;
-  }
-
-  /**
-   * Get the preferred stylesheet for the XSLTInputSource XML document,
-   * as identified by the xml-stylesheet PI, and matching the media and
-   * charset criteria. See <a href="http://www.w3.org/TR/xml-stylesheet/">
-   * Associating Style Sheets with XML documents</a>.
-   * Does not yet handle the LINK REL="stylesheet" syntax.
-   *
-   * @param media The media attribute to be matched.  May be null, in which
-   *              case the prefered stylesheet will be used (i.e., alternate = no).
-   * @param title The value of the title attribute to match.  May be null.
-   * @param charset The value of the charset attribute to match.  May be null.
-   * @returns StylesheetSpec extends XSLTInputSource extedns SAX InputSource; the return value
-   * can be passed to the processStylesheet method.
-   */
-  public StylesheetSpec getAssociatedStylesheet(XSLTInputSource source,
-                                                      String media,
-                                                      String charset)
-    throws SAXException
-  {
-    /*InputSource[]in = m_processor.getAssociatedStylesheets(source, media, null, charset);
-    if (in.length >0)
-      return (StylesheetSpec)in[0];
-    else 
-      return null; */
-    try{
-    Source s = m_tfactory.getAssociatedStylesheet(source.getSourceObject(), media, null, charset);
-    return (StylesheetSpec)s; 
-    }
-    catch (TransformerConfigurationException tce) 
-    {
-      throw new SAXException(tce); 
-    }
-  }
-
-  /**
-   * Get a list of stylesheet specifications for the XSLTInputSource XML document,
-   * as identified by the xml-stylesheet PI, and matching the media and
-   * charset criteria. See <a href="http://www.w3.org/TR/xml-stylesheet/">
-   * Associating Style Sheets with XML documents</a>.
-   * Does not yet handle the LINK REL="stylesheet" syntax.
-   *
-   * @param media The media attribute to be matched.  May be null, in which
-   *              case the prefered stylesheet will be used (i.e., alternate = no).
-   * @param title The value of the title attribute to match.  May be null.
-   * @param charset The value of the charset attribute to match.  May be null.
-   * @returns list of StylesheetSpecs (extend XSLTInputSources extend SAX InputSources; a
-   * list member may be passsed to the processStylesheet method.
-   */
-  public Vector getAssociatedStylesheets(XSLTInputSource source,
-                                                      String media,
-                                                      String charset)
-    throws SAXException
-  {
-    try{
-      Source s = m_tfactory.getAssociatedStylesheet(source.getSourceObject(), media, null, charset);
-      Vector v = new Vector();
-      //for (int i = 0; i< in.length; i++)
-      v.addElement((StylesheetSpec)s);
-      return v;
-    }
-    catch (TransformerConfigurationException tce)
-    {
-      throw new SAXException(tce);
-    }                                              
-  }
-  
-  /**
-   * Submit a top-level stylesheet parameter.  This value can
-   * be evaluated in the stylesheet via xsl:param-variable.
-   * @param key The name of the param.
-   * @param value An XObject that will be used.
-   */
-  public void setStylesheetParam(String key, XObject value)
-  {
-    setParameter(key, value);
-  }
-
-  /**
-   * Set a top-level stylesheet parameter.  This value can
-   * be evaluated via xsl:param-variable.  Note that the value
-   * passed is an expression, and not a string.  This means that
-   * setStylesheetParam("foo", "hello"); will look for the
-   * element "hello".  If you want to pass a string, you'll
-   * need to put quotes around it:
-   * setStylesheetParam("foo", "'hello'"); will look for the
-   * @param key The name of the param.
-   * @param expression An expression that will be evaluated.
-   */
-  public void setStylesheetParam(String key, String expression)
-  {    
-    if (m_evalList == null)
-      m_evalList = new Vector();
-    if (!m_evalList.contains(key))
-      m_evalList.addElement(key);
-    setParameter(key, expression);
-    m_needToEval = true;
-  }
-  
-  /**
-   * Set a top-level stylesheet parameter.  This value can
-   * be evaluated via xsl:param-variable.  Note that the value
-   * passed is an expression, and not a string.  This means that
-   * setStylesheetParam("foo", "hello"); will look for the
-   * element "hello".  If you want to pass a string, you'll
-   * need to put quotes around it:
-   * setStylesheetParam("foo", "'hello'"); will look for the
-   * @param key The name of the param.
-   * @param expression An expression that will be evaluated.
-   */
-  public void setParameter(String key,  Object value)
-  {
-    if (m_stylesheetParams == null)
-      m_stylesheetParams = new Hashtable();
-    m_stylesheetParams.put(key, value); 
-  }
-
-  /**
-   * Get the current FormatterListener (SAX DocumentHandler), or null if none has been set.
-   */
-  public DocumentHandler getFormatterListener()
-  {
-    return m_documentHandler;
-    
-  }
-
-  /**
-   * Set the FormatterListener (the SAX DocumentHandler).
-   */
-  public void setFormatterListener(DocumentHandler flistener)
-  {
-    m_documentHandler = flistener;
-  }
-
-  /**
-   * Get the current SAX DocumentHandler (the same object as the FormatterListener), or null if none has been set.
-   */
-  public DocumentHandler getDocumentHandler()
-  {
-    return m_documentHandler;
-  }
-
-  /**
-   * Set the current SAX DocumentHandler (the same
-   * object as the FormatterListener).
-   */
-  public void setDocumentHandler(DocumentHandler listener)
-  {
-    if (listener instanceof ParserAdapter)      
-      m_transformerImpl.setContentHandler(((ParserAdapter)listener).getContentHandler());
-    else if (listener instanceof XSLTEngineImpl)
-      m_transformerImpl.setContentHandler(((XSLTEngineImpl)listener).getTransformer().getContentHandler());
-    else if (listener instanceof XMLSerializer)
-    {
-      try{
-        m_transformerImpl.setContentHandler(((XMLSerializer)listener).asContentHandler());
-      }
-      catch (IOException ioe)
-      {}
-    }
-    m_documentHandler = listener;
-  }
-
-  /**
-   * Add a trace listener for the purposes of debugging and diagnosis.
-   * @param tl Trace listener to be added.
-   */
-  public void addTraceListener(TraceListener tl)
-    throws TooManyListenersException
-  {
-    if (m_transformerImpl != null)
-      m_transformerImpl.getTraceManager().addTraceListener(tl);
-  }
-  
-  /**
-   * If set to true (the default), pattern conflict warnings are not printed to the diagnostics stream.
-   * @param b true if conflict warnings should be suppressed.
-   */
-  public void setQuietConflictWarnings(boolean b)
-  {
-    if (m_transformerImpl != null)
-      m_transformerImpl.setQuietConflictWarnings(b);
-  }
-
-  /**
-   * Remove a trace listener.
-   * @param tl Trace listener to be removed.
-   */
-  public void removeTraceListener(TraceListener tl)
-  {
-    if (m_transformerImpl != null)
-      m_transformerImpl.getTraceManager().removeTraceListener(tl);
-  }
-  
-  /**
-   * Set the problem listener property.
-   * The XSL class can have a single listener to be informed
-   * of errors and warnings. The problem listener normally controls whether an exception
-   * is thrown or not (or the problem listeners can throw its own RuntimeException).
-   * @param l A ProblemListener interface.
-   */
-  public void setProblemListener(ProblemListener l)
-  {
-    if (l instanceof ProblemListenerDefault)
-      m_problemListener = (ProblemListenerDefault)l;
-    else
-      m_problemListener = new ProblemListenerDefault(l); 
-    if (m_transformerImpl != null)
-      m_transformerImpl.setErrorListener(m_problemListener);
-    m_tfactory.setErrorListener(m_problemListener);
-  }
-
-  /**
-   * Get the problem listener property.
-   * The XSL class can have a single listener to be informed
-   * of errors and warnings. The problem listener normally controls whether an exception
-   * is thrown or not (or the problem listener can throw its own RuntimeException).
-   * @return A ProblemListener interface.
-   */
-  public ProblemListener getProblemListener()
-  {
-    if (m_problemListener.getProblemListener() != null)
-      return m_problemListener.getProblemListener();
-    else
-      return m_problemListener;
-  }
-  
-  public TransformerImpl getTransformer()
-  {
-    return m_transformerImpl;  
-    //return (StylesheetProcessor)m_processor;
-  }  
-
-  public TransformerFactoryImpl getTransformerFactory()
-  {
-    return (TransformerFactoryImpl)m_tfactory;    
-  } 
-
-  
-} // end XSLTEngineImpl class
diff --git a/compat_src/org/apache/xalan/xslt/XSLTInputSource.java b/compat_src/org/apache/xalan/xslt/XSLTInputSource.java
deleted file mode 100644
index 1fe47cb..0000000
--- a/compat_src/org/apache/xalan/xslt/XSLTInputSource.java
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xslt;
-
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-import javax.xml.transform.Source;
-import org.w3c.dom.Node;
-import java.io.InputStream;
-import java.io.Reader;
-import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.dom.DOMSource;
-
-/**
- * <meta name="usage" content="general"/>
- * Represents an XML source document or XSL stylesheet.
- * Use XSLTInputSource objects to provide input to the XSLTProcessor process() method
- * for a transformation. This class extends the SAX input source to handle
- * DOM nodes as input as well as files, character streams, byte streams and SAX DocumentHandlers.
- *
- * @see XSLTProcessor#process(XSLTInputSource, XSLTInputSource, XSLTResultTarget)
- */
-public class XSLTInputSource //extends SAXSource 
-{
-  
-  private StreamSource streamSource = null;
-  private SAXSource saxSource = null;
-  private DOMSource domSource = null;
-  
-  /**
-    * Zero-argument default constructor -- Before you can use the new XSLTInputSource object in a transformation,
-    * you must define the document source with setSystemId(), setNode(), setInputStream(), or setCharacterStream().
-    *
-    * @see #setSystemId(String)
-    * @see #setNode(Node)
-    * @see #setInputStream
-    * @see #setCharacterStream
-    * @see #setEncoding(String)
-    */
-  public XSLTInputSource ()
-  {
-    saxSource = new SAXSource();
-  }
-
-  /**
-    * Create a new input source with a system identifier (for a URL or file name) --
-    * the equivalent of creating an input source with the zero-argument
-    * constructor and setting the new object's SystemId property.
-
-    * If the system identifier is a URL, it must be fully resolved.
-    *
-    * If the system identifier is a URL, it must be fully resolved.
-    *
-    * @param systemId The system identifier (URI).
-    * @see #setSystemId(String)
-    * @see #setNode(Node)
-    * @see #setInputStream
-    * @see #setEncoding(String)
-    * @see #setCharacterStream
-    */
-  public XSLTInputSource (String systemId)
-  {
-    saxSource = new SAXSource();
-    this.setSystemId(systemId);
-  }
-
-
-  /**
-    * Create a new input source with a byte stream -- the equivalent of creating an input source
-    * with the zero-argument constructor and setting the new object's ByteStream property.
-    *
-    * @param byteStream The raw byte stream containing the document.
-    * @see #setInputStream
-    * @see #setSystemId(String)
-    * @see #setNode(Node)
-    * @see #setEncoding(String)
-    * @see #setCharacterStream
-    */
-  public XSLTInputSource (InputStream byteStream)
-  {
-    streamSource = new StreamSource();
-    streamSource.setInputStream(byteStream);
-  }
-
-  /**
-    * Create a new input source with a character stream -- the equivalent of creating an input source
-    * with the zero-argument constructor and setting the new object's CharacterStream property.
-    * <p>The character stream shall not include a byte order mark.</p>
-    *
-    * @param characterStream The character stream containing the document.
-    * @see #setCharacterStream
-    * @see #setInputStream
-    * @see #setSystemId(String)
-    * @see #setNode(Node)
-    * @see #setEncoding(String)
-    */
-  public XSLTInputSource (Reader characterStream)
-  {
-    streamSource = new StreamSource();
-    streamSource.setReader(characterStream);
-  }
-
-  /**
-    * Create a new input source with a DOM Node -- the equivalent of creating an input source
-    * with the zero-argument constructor and setting the new object's Node property.
-    *
-    * @param node The DOM Node containing the document.
-    * @see #setNode(Node)
-    * @see #setCharacterStream
-    * @see #setInputStream
-    * @see #setSystemId(String)
-    * @see #setEncoding(String)
-    */
-  public XSLTInputSource (Node node)
-  {
-    domSource = new DOMSource();
-    domSource.setNode(node);
-  }
-
-  /**
-    * Create a new XSLTInputSource source from a SAX input source.
-    * This operation sets the ByteStream, CharacterStream, SystemId, PublicID, and Encoding properties.
-    *
-   * @param isource The SAX input source.
-    * @see #setCharacterStream
-    * @see #setInputStream
-    * @see #setSystemId(String)
-    * @see #setEncoding(String)
-    * @see #setNode(Node)
-    */
-  public XSLTInputSource (InputSource isource)
-  {
-    saxSource = new SAXSource();
-    saxSource.setInputSource(isource);
-    //saxSource.setXMLReader(isource.getCharacterStream());
-    this.setEncoding(isource.getEncoding());
-    this.setSystemId(isource.getSystemId());
-  }
-
-  /**
-    * Set the DOM Node for this input source.
-    *
-    * @param node The DOM node containing the
-    *        XML document or XSL stylesheet.
-    * @see #XSLTInputSource(Node)
-    * @see #getCharacterStream()    * 
-    * @see java.io.Reader
-    */
-  public void setNode (Node node)
-  {
-    if (domSource == null)
-      domSource = new DOMSource();
-    domSource.setNode(node);
-  }
-
-  /**
-    * Get the DOM Node for this input source.
-    *
-    * @return The DOM node containing the document, or null if none was supplied.
-    * @see #XSLTInputSource(Node)
-    * @see #setNode(Node)
-    */
-  public Node getNode ()
-  {
-    if (domSource != null)
-      return domSource.getNode();
-    else
-      return null;
-  }
-
-  
-  
-   /** 
-     * Set the character encoding, if known.
-     *
-     * <p>The encoding must be a string acceptable for an
-     * XML encoding declaration (see section 4.3.3 of the XML 1.0
-     * recommendation).</p>
-     *
-     * <p>This method has no effect when the application provides a
-     * character stream.</p>
-     *
-     * @param encoding A string describing the character encoding.
-     * @see #setSystemId
-     * @see #getEncoding
-     */
-    public void setEncoding (String encoding)
-    {
-	this.encoding = encoding;
-    }
-    
-    
-    /**
-     * Get the character encoding for a byte stream or URI.
-     *
-     * @return The encoding, or null if none was supplied.
-     * @see #getSystemId
-     */
-    public String getEncoding ()
-    {
-	return encoding;
-    }
-    
-    private String encoding = null;
-    
-    /**
-     * Set the character stream for this input source.
-     *
-     * <p>If there is a character stream specified, the SAX parser
-     * will ignore any byte stream and will not attempt to open
-     * a URI connection to the system identifier.</p>
-     *
-     * @param characterStream The character stream containing the
-     *        XML document or other entity.
-     * @see java.io.Reader
-     */
-    public void setCharacterStream (Reader characterStream)
-    {
-      if (streamSource == null)
-	      streamSource = new StreamSource();
-      streamSource.setReader(characterStream);
-    }
-    
-    
-    /**
-     * Get the character stream for this input source.
-     *
-     * @return The character stream, or null if none was supplied.
-     */
-    public Reader getCharacterStream ()
-    {
-      if (streamSource != null)
-        return streamSource.getReader();
-      else
-        return null;
-    }
-    
-    
-    
-    /**
-     * Set the base ID (URL or system ID) from where URLs
-     * will be resolved.
-     *
-     * @param baseID Base URL for this.
-     */
-    public void setSystemId(String baseID) 
-    {
-      this.baseID = baseID;
-      
-      if (saxSource != null)
-        saxSource.setSystemId(baseID);
-      else if (domSource != null)
-        domSource.setSystemId(baseID);
-      else if (streamSource != null)
-        streamSource.setSystemId(baseID);      
-    }
-
-    /**
-     * Get the base ID (URL or system ID) from where URLs
-     * will be resolved.
-     *
-     * @return Base URL for this.
-     */
-    public String getSystemId() {
-        return this.baseID;
-    }
-    
-    private String baseID = null;
-
-    
-    /**
-     * Set the byte stream to be used as input.  Normally,
-     * a stream should be used rather than a reader, so that
-     * the XML parser can resolve character encoding specified
-     * by the XML declaration.
-     *
-     * <p>If this Source object is used to process a stylesheet, normally
-     * setSystemId should also be called, so that relative URL references
-     * can be resolved.</p>
-     *
-     * @param inputStream A valid InputStream reference to an XML stream.
-     */
-    public void setInputStream(InputStream inputStream) 
-    {
-      if (streamSource == null)
-        streamSource = new StreamSource();
-      streamSource.setInputStream(inputStream);
-    }
-
-    /**
-     * Get the byte stream that was set with setInputStream.
-     *
-     * @return The byte stream that was set with setInputStream, or null
-     * if setByteStream or the ByteStream constructor was not called.
-     */
-    public InputStream getInputStream() {
-      if (streamSource != null)
-        return streamSource.getInputStream();
-      else
-        return null;
-    }
-    
-    
-     /**
-     * Get the Result object associated with this XSLTResultTarget object .
-     *
-     * @return The Result object associated with this XSLTResultTarget object
-     * 
-     */
-    public Source getSourceObject() 
-    {
-      if (streamSource != null)        
-        return streamSource;
-      else if (domSource != null)
-        return domSource;
-      else 
-        return saxSource;
-    } 
-}
diff --git a/compat_src/org/apache/xalan/xslt/XSLTProcessor.java b/compat_src/org/apache/xalan/xslt/XSLTProcessor.java
deleted file mode 100644
index b2e5cc5..0000000
--- a/compat_src/org/apache/xalan/xslt/XSLTProcessor.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xslt;
-
-import java.util.TooManyListenersException;
-import java.util.Vector;
-
-import org.apache.xalan.xpath.XObject;
-import org.apache.xalan.xpath.XNodeSet;
-import org.apache.xalan.xpath.XBoolean;
-import org.apache.xalan.xpath.XNumber;
-import org.apache.xalan.xpath.XNull;
-import org.apache.xalan.xpath.XString;
-import org.apache.xalan.xpath.xml.XMLParserLiaison;
-import org.apache.xalan.xpath.xml.ProblemListener;
-
-import org.apache.xalan.templates.Stylesheet;
-//import org.apache.xalan.templates.StylesheetRoot;
-//import org.apache.xalan.xslt.StylesheetSpec;
-import org.apache.xalan.trace.*;
-
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Node;
-import org.xml.sax.DocumentHandler;
-import org.xml.sax.SAXException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import org.apache.xml.serialize.OutputFormat;
-import org.xml.sax.ext.LexicalHandler;
-
-/**
- * <meta name="usage" content="general"/>
- * The transformation processor -- use {@link org.apache.xalan.xslt.XSLTProcessorFactory} to instantiate an implementation of this interface.
- * It's the responsibility of the implementation (XSLTEngineImpl),
- * collaborating with a XMLParserLiaison, the DOM,
- * and the XPath engine, to transform a source tree
- * of nodes into a result tree according to instructions
- * and templates specified by a stylesheet tree.
- * Use the <code>process(...)</code> are the primary
- * public entry points.
- *
- * Look at the Process class main() method for
- * for an advanced usage example.
- *
- * <p>If you reuse the processor instance, you should call reset() between transformations.</p>
- */
-public interface XSLTProcessor extends DocumentHandler, LexicalHandler
-{
-  /**
-   * Use the XSL stylesheet to transform the XML input, placing the result in the result tree.
-   * @param xmlSource  The XML input to be transformed.
-   * @param xslStylesheet  The XSL stylesheet to be used for the transformation.  May be null if XML input
-   * has an XSL stylesheet PI.
-   * @param resultTree The tree where the result of the transformation is placed.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public void process( XSLTInputSource xmlSource,
-                       XSLTInputSource xslStylesheet,
-                       XSLTResultTarget resultTree)
-    throws SAXException;
-
-  /**
-   * Compile the XSL stylesheet represented by an XSLTInputSource object into an internal representation,
-   * and use it to set the XSLTProcessor Stylesheet property.
-   * This operation is required if the XSLTProcessor is to function as a
-   * SAX DocumentHandler.
-   * If the Stylesheet property has already been set to non-null, this operation
-   * calls reset() before a transformation is performed.
-   *
-   * @param stylesheetSource  The XSL stylesheet.
-   * @return The compiled stylesheet object.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public StylesheetRoot processStylesheet(XSLTInputSource stylesheetSource)
-    throws SAXException;
-
-  /**
-   * Given a URL to (or file name of) an XSL stylesheet,
-   * Compile the stylesheet into an internal representation, and use it to
-   * set the XSLTProcessor Stylesheet property.
-   * This operation is required if the XSLTProcessor is to function as a
-   * SAX DocumentHandler.
-   * If the Stylesheet property has already been set to non-null, this operation
-   * calls reset() before a transformation is performed.
-   *
-   * @param xsldocURLString  The URL to the XSL stylesheet.
-   * @return The compiled stylesheet object.
-   * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
-   * the error condition is severe enough to halt processing.
-   */
-  public StylesheetRoot processStylesheet(String xsldocURLString)
-    throws SAXException;
-
-  /**
-   * Set the output stream. Required when the XSLTProcessor is being used
-   * as a SAX DocumentHandler.
-   */
-  public void setOutputStream(java.io.OutputStream os);
-
-  /**
-   * Reset the XSLTProcessor state.  Must be used after a process() call
-   * if the XSLTProcessor instance is to be used again.
-   */
-  public void reset();
-
-  /**
-   * Get the DOM Node from the XSLTInputSource object. Returns null if the XSLTInputSource
-   * object does not contain a Node (it may, for example, contain an input stream).
-   */
-  public Node getSourceTreeFromInput(XSLTInputSource inputSource)
-    throws org.xml.sax.SAXException;
-
-  /**
-   * Use a compiled stylesheet to set the Stylesheet property for this processor.
-   * When this property is set, the process method uses this stylesheet rather than
-   * looking for a stylesheet PI if the stylesheet parameter is null.  Also required
-   * if you are going to use the XSLTProcessor as a SAX DocumentHandler.
-   */
-  public void setStylesheet(StylesheetRoot stylesheetRoot);
-
-  /**
-   * Get the current Stylesheet setting for this XSLTProcessor.
-   */
-  public StylesheetRoot getStylesheet();
-
-  /**
-   * Get the XMLParserLiaison that this processor uses.
-   */
-  public XMLParserLiaison getXMLProcessorLiaison();
-
-  /**
-   * Get the preferred stylesheet for the XSLTInputSource XML document,
-   * as identified by the xml-stylesheet PI, and matching the media and
-   * charset criteria. See <a href="http://www.w3.org/TR/xml-stylesheet/">
-   * Associating Style Sheets with XML documents</a>.
-   * Does not yet handle the LINK REL="stylesheet" syntax.
-   *
-   * @param media The media attribute to be matched.  May be null, in which
-   *              case the prefered stylesheet will be used (i.e., alternate = no).
-   * @param title The value of the title attribute to match.  May be null.
-   * @param charset The value of the charset attribute to match.  May be null.
-   * @returns StylesheetSpec extends XSLTInputSource extends SAX InputSource; the return value
-   * can be passed to the processStylesheet method.
-   */
-  public StylesheetSpec getAssociatedStylesheet(XSLTInputSource source,
-                                                      String media,
-                                                      String charset)
-    throws SAXException;
-
-  /**
-   * Get a list of stylesheet specifications for the XSLTInputSource XML document,
-   * as identified by the xml-stylesheet PI, and matching the media and
-   * charset criteria. See <a href="http://www.w3.org/TR/xml-stylesheet/">
-   * Associating Style Sheets with XML documents</a>.
-   * Does not yet handle the LINK REL="stylesheet" syntax.
-   *
-   * @param media The media attribute to be matched.  May be null, in which
-   *              case the prefered stylesheet will be used (i.e., alternate = no).
-   * @param title The value of the title attribute to match.  May be null.
-   * @param charset The value of the charset attribute to match.  May be null.
-   * @returns list of StylesheetSpecs (extend XSLTInputSources extend SAX InputSources; a
-   * list member may be passsed to the processStylesheet method.
-   */
-  public Vector getAssociatedStylesheets(XSLTInputSource source,
-                                                      String media,
-                                                      String charset)
-    throws SAXException;
-
-
-  /**
-   * Convenience function to create an XString.
-   * @param s A valid string.
-   * @return An XString object.
-   */
-  public XString createXString(String s);
-
-  /**
-   * Convenience function to create an XObject.
-   * @param o Any java object.
-   * @return An XObject object.
-   */
-  public XObject createXObject(Object o);
-
-  /**
-   * Convenience function to create an XNumber.
-   * @param d Any double number.
-   * @return An XNumber object.
-   */
-  public XNumber createXNumber(double d);
-
-  /**
-   * Convenience function to create an XBoolean.
-   * @param b boolean value.
-   * @return An XBoolean object.
-   */
-  public XBoolean createXBoolean(boolean b);
-
-  /**
-   * Convenience function to create an XNodeSet.
-   * @param nl A NodeList object.
-   * @return An XNodeSet object.
-   */
-  public XNodeSet createXNodeSet(NodeList nl);
-
-  /**
-   * Convenience function to create an XNodeSet from a node.
-   * @param n A DOM node.
-   * @return An XNodeSet object.
-   */
-  public XNodeSet createXNodeSet(Node n);
-
-  /**
-   * Convenience function to create an XNull.
-   * @return An XNull object.
-   */
-  public XNull createXNull();
-
-  /**
-   * Submit a top-level stylesheet parameter.  This value can
-   * be evaluated in the stylesheet via xsl:param-variable.
-   * @param key The name of the param.
-   * @param value An XObject that will be used.
-   */
-  public void setStylesheetParam(String key, XObject value);
-
-  /**
-   * Set a top-level stylesheet parameter.  This value can
-   * be evaluated via xsl:param-variable.  Note that the value
-   * passed is an expression, and not a string.  This means that
-   * setStylesheetParam("foo", "hello"); will look for the
-   * element "hello".  If you want to pass a string, you'll
-   * need to put quotes around it:
-   * setStylesheetParam("foo", "'hello'"); will look for the
-   * @param key The name of the param.
-   * @param expression An expression that will be evaluated.
-   */
-  public void setStylesheetParam(String key, String expression);
-
-  /**
-   * Get the current FormatterListener (SAX DocumentHandler), or null if none has been set.
-   */
-  public DocumentHandler getFormatterListener();
-
-  /**
-   * Set the FormatterListener (the SAX DocumentHandler).
-   */
-  public void setFormatterListener(DocumentHandler flistener);
-
-  /**
-   * Get the current SAX DocumentHandler (the same object as the FormatterListener), or null if none has been set.
-   */
-  public DocumentHandler getDocumentHandler();
-
-  /**
-   * Set the current SAX DocumentHandler (the same
-   * object as the FormatterListener).
-   */
-  public void setDocumentHandler(DocumentHandler listener);
-
-  /**
-   * Add a trace listener for the purposes of debugging and diagnosis.
-   * @param tl Trace listener to be added.
-   */
-  public void addTraceListener(TraceListener tl)
-    throws TooManyListenersException;
-
-  /**
-   * If set to true, template calls are traced.
-   */
-  public void setTraceTemplates(boolean b);
-
-  /**
-   * If set to true, selection events are traced.
-   */
-  public void setTraceSelect(boolean b);
-
-  /**
-   * If set to true (the default is false), as template children are being constructed, debug diagnostics
-   * are written to the m_diagnosticsPrintWriter
-   * stream.
-   */
-  public void setTraceTemplateChildren(boolean b);
-
-  /**
-   * If set to true (the default), pattern conflict warnings are not printed to the diagnostics stream.
-   * @param b true if conflict warnings should be suppressed.
-   */
-  public void setQuietConflictWarnings(boolean b);
-
-  /**
-   * Remove a trace listener.
-   * @param tl Trace listener to be removed.
-   */
-  public void removeTraceListener(TraceListener tl);
-
-  /**
-   * If set, diagnostics will be
-   * written to the m_diagnosticsPrintWriter stream. If
-   * null, diagnostics are turned off. This convenience method calls
-   * {@link #setDiagnosticsOutput(java.io.PrintWriter)}.
-   */
-  public void setDiagnosticsOutput(java.io.OutputStream out);
-
-  /**
-   * If set, diagnostics will be
-   * written to the m_diagnosticsPrintWriter stream. If
-   * null, diagnostics are turned off.
-   */
-  public void setDiagnosticsOutput(java.io.PrintWriter pw);
-
-  /**
-   * Set the problem listener property.
-   * The XSL class can have a single listener to be informed
-   * of errors and warnings. The problem listener normally controls whether an exception
-   * is thrown or not (or the problem listeners can throw its own RuntimeException).
-   * @param l A ProblemListener interface.
-   */
-  public void setProblemListener(ProblemListener l);
-
-  /**
-   * Get the problem listener property.
-   * The XSL class can have a single listener to be informed
-   * of errors and warnings. The problem listener normally controls whether an exception
-   * is thrown or not (or the problem listener can throw its own RuntimeException).
-   * @return A ProblemListener interface.
-   */
-  public ProblemListener getProblemListener();
-
-}
diff --git a/compat_src/org/apache/xalan/xslt/XSLTProcessorFactory.java b/compat_src/org/apache/xalan/xslt/XSLTProcessorFactory.java
deleted file mode 100644
index c295028..0000000
--- a/compat_src/org/apache/xalan/xslt/XSLTProcessorFactory.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xslt;
-
-import org.apache.xalan.xpath.xml.XMLParserLiaison;
-import org.apache.xpath.XPathFactory;
-//import javax.xml.transform.Processor;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.Templates;
-import org.apache.xml.utils.TreeWalker;
-
-/**
- * <meta name="usage" content="general"/>
- * Manufactures the processor for performing transformations. Use one of the static getProcessor methods
- * to create an XSLTProcessor object.
- */
-public class XSLTProcessorFactory
-{
-  /**
-   * Get a new XSLTProcessor.
-   */
-  public static XSLTProcessor getProcessor()
-    throws org.xml.sax.SAXException
-  {
-    //Processor processor = Processor.newInstance("xslt"); 
-    return new XSLTEngineImpl();
-  }
-
-  /**
-   * Get a new XSLTProcessor (parserLiaisonClassName no longre used).
-   * *
-   * @see #getProcessor()
-   * @see org.apache.xalan.xpath.xml.XMLParserLiaison
-   */
-  public static XSLTProcessor getProcessorUsingLiaisonName(String parserLiaisonClassName)
-    throws org.xml.sax.SAXException
-  {
-    //return new XSLTEngineImpl(parserLiaisonClassName);
-    //Processor processor = Processor.newInstance("xslt"); 
-    return new XSLTEngineImpl();
-  }
-
-  /**
-   * Get a new XSLTProcessor (XMLParserLiaison no longer used).
-   *
-   * @param parserLiaison the XMLParserLiaison set up to interact with a given XML parser.
-   * @return An implementation of the XSLTProcessor interface with which you can perform transformations.
-   *
-   * @see #getProcessor()
-   * @see org.apache.xalan.xpath.xml.XMLParserLiaison
-   */
-  public static XSLTProcessor getProcessor(XMLParserLiaison parserLiaison)
-  {
-    //return new XSLTEngineImpl(parserLiaison);
-    try{
-      //Processor processor = Processor.newInstance("xslt"); 
-      return new XSLTEngineImpl();
-    }
-   /* catch (TransformerConfigurationException tce)
-    {
-      return null;
-    }*/
-    catch (org.xml.sax.SAXException e)
-    {
-      return null;
-    }
-    
-  }
-
-  /**
-   * Get a new XSLTProcessor (XMLParserLiaison and XPathFactory no longer used).
-   *
-   * @param parserLiaison the XMLParserLiaison set up to interact with a given XML parser.
-   * @param xpathFactory A custom XPathFactory.
-   * @return An implentation of the XSLTProcessor interface with which you
-   * can perform transformations.
-   *
-   * @see #getProcessor()
-   * @see org.apache.xalan.xpath.xml.XMLParserLiaison
-   */
-  public static XSLTProcessor getProcessor(XMLParserLiaison parserLiaison,
-                                                  XPathFactory xpathFactory)
-  {
-    //return new XSLTEngineImpl(parserLiaison, xpathFactory);
-    try{
-      //Processor processor = Processor.newInstance("xslt"); 
-      return new XSLTEngineImpl();
-    }
-  /*  catch (TransformerConfigurationException pe)
-    {
-      return null;
-    }*/
-    catch (org.xml.sax.SAXException e)
-    {
-      return null;
-    }
-  }
-}
diff --git a/compat_src/org/apache/xalan/xslt/XSLTResultTarget.java b/compat_src/org/apache/xalan/xslt/XSLTResultTarget.java
deleted file mode 100644
index 4d8e398..0000000
--- a/compat_src/org/apache/xalan/xslt/XSLTResultTarget.java
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * The Apache Software License, Version 1.1  
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xalan.xslt;
-
-import org.w3c.dom.Node;
-import java.io.OutputStream;
-import java.io.Writer;
-import org.xml.sax.DocumentHandler;
-import org.xml.sax.helpers.DefaultHandler;
-import org.xml.sax.helpers.ParserAdapter;
-import javax.xml.transform.Result;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.sax.SAXResult;
-
-
-/**
- * <meta name="usage" content="general"/>
- * Contains the result of a transformation that you perform with the
- * XSLTProcessor process() method or one of the StylesheetRoot process() methods.
- * Create an instance of this class to provide the process() method a container
- * for the transformation result tree.
- * You can use a file name or URL, character stream, byte stream, DOM Node, or SAX DocumentHandler
- * to instantiate an XSLTResultTarget object.
- *
- * @see XSLTProcessor#process(XSLTInputSource, XSLTInputSource, XSLTResultTarget)
- * @see StylesheetRoot
- */
-public class XSLTResultTarget //implements Result //extends StreamResult
-{
-  
-  private StreamResult sr = null;
-  private SAXResult saxResult = null;
-  private DOMResult dr = null;
-  
-  
-  /**
-    * Zero-argument default constructor  -- Before you can use the new XSLTResultTarget object in a transformation,
-    * you must define the output container by setting its FileName, CharacterStrea, ByteStream, or Node property.
-    *
-    * @see #setFileName(String)
-    * @see #setCharacterStream(Writer)
-    * @see #setByteStream(OutputStream)
-    * @see #setNode(Node)
-    * @see #setDocumentHandler(DocumentHandler)
-    * @see #setEncoding(String)
-    */
-  public XSLTResultTarget ()
-  {
-     sr = new StreamResult();
-  }
-
-  /**
-   * Create a new output target with a file name -- the equivalent of creating an output target
-   * with the zero-argument constructor and setting the new object's FileName property.
-   *
-   * @param fileName Identifies the file that will contain the transformation result (must be a valid system file name).
-   *
-   * @see #setFileName(String)
-   * @see #setCharacterStream(Writer)
-   * @see #setByteStream(OutputStream)
-   * @see #setNode(Node)
-   * @see #setDocumentHandler(DocumentHandler)
-   * @see #setEncoding(String)
-   */
-  public XSLTResultTarget (String fileName) // File?
-  {
-    sr = new StreamResult();
-    sr.setSystemId(fileName);
-  }
-
-
-  /**
-   * Create a new output target with a byte stream -- the equivalent of creating an output target
-   * with the zero-argument constructor and setting the new object's ByteStream property.
-   *
-   * @param byteStream The raw byte stream that will contain the transformation result.
-   *
-   * @see #setByteStream(OutputStream)
-   * @see #setFileName(String)
-   * @see #setCharacterStream(Writer)
-   * @see #setNode(Node)
-   * @see #setDocumentHandler(DocumentHandler)
-   * @see #setEncoding(String)
-   */
-
-  public XSLTResultTarget (OutputStream byteStream)
-  {
-    sr = new StreamResult();
-    sr.setOutputStream(byteStream);
-  }
-
-
-  /**
-   * Create a new output target with a character stream -- the equivalent of creating an output target
-   * with the zero-argument constructor and setting the new object's CharacterStream property.
-   *
-   * @param characterStream The character stream where the transformation result is written.
-   *
-   * @see #setCharacterStream(Writer)
-   * @see #setByteStream(OutputStream)
-   * @see #setFileName(String)
-   * @see #setNode(Node)
-   * @see #setDocumentHandler(DocumentHandler)
-   * @see #setEncoding(String)
-   */
-  public XSLTResultTarget (Writer characterStream)
-  {
-    sr = new StreamResult();
-    sr.setWriter(characterStream);
-  }    
-
-  /**
-   * Create a new output target with a DOM Node -- the equivalent of creating an output target
-   * with the zero-argument constructor and setting the new object's Node property.
-   *
-   * @param node The DOM Node that will contain the transformation result.
-   *
-  * @see #setNode(Node)
-   * @see #setCharacterStream(Writer)
-   * @see #setByteStream(OutputStream)
-   * @see #setFileName(String)
-   * @see #setDocumentHandler(DocumentHandler)
-   * @see #setEncoding(String)
-   */
-  public XSLTResultTarget (Node n)
-  {
-    dr = new DOMResult();
-    dr.setNode(n);
-  }    
-
-  /**
-   * Create a new output target with a SAX Document handler, which
-   * will handle result events -- the equivalent of creating an output target with the
-   * zero-argument constructor and setting the new object's DocyumentHandler property.
-   *
-   * @param handler The SAX Document handler to which the result is written.
-   *
-  * @see #setDocumentHandler(DocumentHandler)
-   * @see #setNode(Node)
-   * @see #setCharacterStream(Writer)
-   * @see #setByteStream(OutputStream)
-   * @see #setFileName(String)
-   * @see #setEncoding(String)
-   */
-  public XSLTResultTarget(DocumentHandler handler)
-  { 
-    SAXResult saxResult = new SAXResult();    
-    setDocumentHandler(handler);
-  }
-    
-
-  /**
-   * Set the file name or URL where the transformation result will be written.
-   *
-   * @param fileName The system identifier as a string.
-   *
-   * @see #XSLTResultTarget(String)
-   * @see #getFileName
-   */
-  public void setFileName (String fileName) // File?
-  {
-    if (sr == null)
-      sr = new StreamResult();
-    sr.setSystemId(fileName);
-  }
-
-
-  /**
-   * Get the file name where the results are or will be written, or null if none was supplied.
-   *
-   * @return The file name or URL.
-   *
-   * @see #XSLTResultTarget(String)
-   * @see #setFileName(String)
-   */
-  public String getFileName ()
-  {
-    if (sr != null)
-      return sr.getSystemId();
-    else
-      return null;
-  } 
-
-
-
-  /**
-   * Set the character encoding, if known.
-   *
-   * @param encoding The character encoding.
-   */
-  public void setEncoding (String encoding)
-  {
-    this.encoding = encoding;
-  }
-
-
-  /**
-   * Get the character encoding that was used.
-   *
-   * @return The encoding, or null if none was supplied.
-   */
-  public String getEncoding ()
-  {
-    return encoding;
-  }
-  
-  private String encoding;
-
-
-  /**
-   * Set a SAX DocumentHandler to process the result tree events.
-   * You can process events as they occur
-   * rather than waiting for the transformation to be completed.
-   *
-   * @param handler The SAX DocumentHandler to process result tree events.
-   *
-   * @see #XSLTResultTarget(DocumentHandler)
-   * @see #getDocumentHandler()
-   */
-  public void setDocumentHandler (DocumentHandler handler)
-  {
-    this.formatterListener = handler;
-    if (handler instanceof ParserAdapter)
-    {
-      if (saxResult == null)
-        saxResult = new SAXResult();
-      saxResult.setHandler(((ParserAdapter)handler).getContentHandler());
-    }  
-  }
-
-  /**
-   * Get the SAX DocumentHandler that processes the result tree events.
-   * You can use the DocumentHandler to process events as they occur
-   * rather than waiting for the transformation to be completed.
-   *
-   * @return The SAX DocumentHandler that processes result tree events.
-   *
-   * @see #XSLTResultTarget(DocumentHandler)
-   * @see #setDocumentHandler(DocumentHandler)
-   */
-  public DocumentHandler getDocumentHandler ()
-  {
-    return formatterListener;
-  }
-  
-  private DocumentHandler formatterListener = null;
-  
-  /**
-     * Set the node that will contain the result DOM tree.  In practice,
-     * the node should be a {@link org.w3c.dom.Document} node,
-     * a {@link org.w3c.dom.DocumentFragment} node, or a
-     * {@link org.w3c.dom.Element} node.  In other words, a node
-     * that accepts children.
-     *
-     * @param node The node to which the transformation
-     * will be appended.
-     */
-    public void setNode(Node node) {
-      if (dr == null)
-        dr = new DOMResult();
-      dr.setNode(node);
-    }
-
-    /**
-     * Get the node that will contain the result DOM tree.
-     * If no node was set via setNode, the node will be
-     * set by the transformation, and may be obtained from
-     * this method once the transformation is complete.
-     *
-     * @return The node to which the transformation
-     * will be appended.
-     */
-    public Node getNode() {
-      if (dr != null)
-        return dr.getNode();
-      else
-        return null;
-    }
-    
- /**
-   * Set the byte stream to contain the transformation result.
-   *
-   * @param byteStream A byte stream that will contain the transformation result.
-   *
-   * @see #XSLTResultTarget(OutputStream)
-   * @see #setByteStream(OutputStream)
-   */
-    public void setByteStream(OutputStream byteStrm) {
-        if (sr == null)
-          sr = new StreamResult();
-        sr.setOutputStream(byteStrm);
-    }
-
- /**
-   * Get the byte stream that contains or will contain the transformation result.
-   *
-   * @return The byte stream, or null if none was supplied.
-   *
-   * @see #XSLTResultTarget(OutputStream)
-   * @see #setByteStream(OutputStream)
-   */
-    public OutputStream getByteStream() {
-      if (sr != null)
-        return sr.getOutputStream();
-      else
-        return null;
-    }
-    
-    /**
-     * Set the system identifier for this Result.
-     *
-     * <p>If the Result is not to be written to a file, the system identifier is optional.
-     * The application may still want to provide one, however, for use in error messages
-     * and warnings, or to resolve relative output identifiers.</p>
-     *
-     * @param systemId The system identifier as a URI string.
-     */
-    public void setSystemId(String systemID)
-    {
-      if (sr != null)
-        sr.setSystemId(systemID);
-      else if (dr != null)
-        dr.setSystemId(systemID);
-      else if (saxResult != null)
-        saxResult.setSystemId(systemID);
-    }
-
-    /**
-     * Get the system identifier that was set with setSystemId.
-     *
-     * @return The system identifier that was set with setSystemId,
-     * or null if setSystemId was not called.
-     */
-    public String getSystemId()
-    {
-      if (sr != null)
-        return sr.getSystemId();
-      else if (dr != null)
-        dr.getSystemId();
-      else if (saxResult != null)
-        saxResult.getSystemId();
-      
-      return null;
-    }
-    
-     /**
-     * Set the writer that is to receive the result.  Normally,
-     * a stream should be used rather than a writer, so that
-     * the transformer may use instructions contained in the
-     * transformation instructions to control the encoding.  However,
-     * there are times when it is useful to write to a writer,
-     * such as when using a StringWriter.
-     *
-     * @param writer  A valid Writer reference.
-     */
-    public void setCharacterStream(Writer writer) {      
-      if (sr == null)
-        sr = new StreamResult();
-      sr.setWriter(writer);
-    }
-
-    /**
-     * Get the character stream that was set with setWriter.
-     *
-     * @return The character stream that was set with setWriter, or null
-     * if setWriter or the Writer constructor was not called.
-     */
-    public Writer getCharacterStream() {
-      if (sr != null)
-        return sr.getWriter();
-      else
-        return null;
-    }
-  
-  
-    /**
-     * Get the Result object associated with this XSLTResultTarget object .
-     *
-     * @return The Result object associated with this XSLTResultTarget object
-     * 
-     */
-    public Result getResultObject() 
-    {
-      if (sr != null)        
-        return sr;
-      else if (dr != null)
-        return dr;
-      else 
-        return saxResult;
-    } 
-    
-}
diff --git a/compat_src/org/apache/xalan/xslt/package.html b/compat_src/org/apache/xalan/xslt/package.html
deleted file mode 100644
index 76e39f2..0000000
--- a/compat_src/org/apache/xalan/xslt/package.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<HTML><HEAD></HEAD><BODY>
-     <P><B>The main Xalan-Java 1 compatability package</B> -- facilities for setting up and performing XSL transformations.</P>
-   
-     <P>Use one of the {@link org.apache.xalan.xslt.XSLTProcessorFactory} static getProcessor methods to
-      instantiate an {@link org.apache.xalan.xslt.XSLTProcessor}. The XSLTProcessor interface defines the 
-      XSLT processor API. You should never need to call the underlying implementation 
-      ({@link org.apache.xalan.xslt.XSLTEngineImpl}) directly.</P>
-      
-      <P>Instantiate {@link org.apache.xalan.xslt.XSLTInputSource} objects for the XML input and the XSL
-      stylesheet, and an {@link org.apache.xalan.xslt.XSLTResultTarget} object for the transformation output. 
-      You may construct these objects with a variety of containers/formats, including files or URLs, character
-      streams,byte streams, SAX input streams or document handlers, and a DOM tree.</P>
-      <P>As a general rule, use the XSLTProcessor process method to perform a transformation, thereby filling the
-      XSLTResultTarget object. For repeated transformations, to gather information from the stylesheet before you
-      perform the transformation, or to set up the processor to function as a SAX document handler, use the
-       XSLTProcessor processStylesheet method to compile the XSL stylesheet, which returns a 
-       {@link org.apache.xalan.xslt.StylesheetRoot} object with its own process method.</P>
-   </BODY></HTML>
\ No newline at end of file
diff --git a/make.include b/make.include
deleted file mode 100644
index d971ce9..0000000
--- a/make.include
+++ /dev/null
@@ -1,168 +0,0 @@
-###########################################################
-# Common variables and targets for XPath and xslt4j
-#
-# See Makefile for important environment notes
-#
-###########################################################
-
-###########################################################
-# Project-specific variables and rules
-#
-# You should not need to edit these
-###########################################################
-JAVAX = .java
-CLASSX = .class
-JARX  = .jar
-TARX  = .tar.gz
-ZIPX  = .zip
-OBJS  = $(SRCS:%.java=%.class)
-
-# A simple marker file created to show last compile time
-# Note subdirectories may reset the name!
-SINCE_FILE       = since.last
-
-# Relative directory (usually from ./src/.) where class files are to go
-CLASS_DIR        = classes
-
-CURRENT_DIR      = .
-
-###########################################################
-# Build-specific tools and flags definitions
-###########################################################
-PRODUCT_NAME := xalan
-VERSION      = _1_1_D01
-JARNAME      = $(PRODUCT_NAME)$(JARX)
-JARDISTNAME  = $(PRODUCT_NAME)-j$(VERSION)$(JARX)
-TARDISTNAME  = $(PRODUCT_NAME)-j$(VERSION)$(TARX)
-ZIPDISTNAME  = $(PRODUCT_NAME)-j$(VERSION)$(ZIPX)
-
-###########################################################
-# Environment-specific tools and flags definitions
-#
-# You may need to edit these if you're not using
-# a standard JDK or the tools aren't on the path.
-###########################################################
-# References to default tools
-JAVA       = java
-JAVAC      = javac
-JAVADOC    = javadoc
-JAR        = jar
-# References to JDK 1.2-only tools; required for xdocs build
-# While the code compiles under 1.1.8 or 1.2.2, the docs require 1.2.2
-# Thus, you can install both JDK's, set 1.1.8 up as default,
-# then call us like 'make -f Makefile JAVAC12=c:/jdk122/bin/javac.exe ...'
-#    This should compile the sources with 1.1.8, but the doc with 1.2.2
-JAVA12     = java
-JAVAC12    = javac
-JAVADOC12  = javadoc
-
-# Setting flags for various tools
-# You can override these on the make command line as well
-#    Call us like 'make -f Makefile JAVADEBUG=-g:none ...'
-JAVADEBUG   = -g
-# JAVADEBUG   = -g:none -O
-JAVADESTDIR = -d $(CLASS_DIR)
-JAVACFLAGS  = $(JAVADEBUG) $(JAVADESTDIR)
-JARFLAGS    = Mcf0
-
-# References to other tools
-RM         = rm -f
-RM-RF      = rm -rf
-CP         = cp -f
-CPR        = cp -Rvf
-UPDIR      := ..
-
-# References to standard UNIX or Cygwin tar utility, filtering through gzip
-TARGZ      = tar cvzf
-UNTARGZ      = tar xvzf 
-
-# Decide if we're on unix or DOS
-ifeq (,$(findstring usr,$(PATH)))
-# DOS
-PATHSEP := \\
-CLPATHSEP := ;
-else 
-# UNIX
-PATHSEP := /
-CLPATHSEP := :
-endif
-
-###########################################################
-# Main targets definitions
-###########################################################
-.PHONY: makeall
-makeall: all
-
-.PHONY: clean
-clean::
-	$(RM) *.class $(JARNAME) *~ *.bak *.o *.obj *.dll $(SINCE_FILE)
-
-.PHONY: makesubdirs
-makesubdirs:
-	@for i in $(SUBDIRS) ; \
-	do \
-	(cd $$i; echo making xpath engine in "$(CURRENT_DIR)/$$i..."; \
-	$(MAKE) CURRENT_DIR=$(CURRENT_DIR)/$$i $(MFLAGS) -f makexpath4j JAVACFLAGS="$(JAVACFLAGS)" all); \
-	(cd $$i; echo making xslt engine in "$(CURRENT_DIR)/$$i..."; \
-	$(MAKE) CURRENT_DIR=$(CURRENT_DIR)/$$i $(MFLAGS) -f makexslt4j JAVACFLAGS="$(JAVACFLAGS)" all); \
-	done
-
-.PHONY: makecompat
-makecompat:
-	@for i in $(SUBDIRS) ; \
-	do \
-	(cd $$i; echo making compat engine in "$(CURRENT_DIR)/$$i...";pwd; \
-	$(MAKE) CURRENT_DIR=$(CURRENT_DIR)/$$i $(MFLAGS) -f makecompat JAVACFLAGS="$(JAVACFLAGS)" all); \
-	done
-
-.PHONY: makedocs
-makedocs:
-	@for i in xdocs ; \
-	do \
-	(cd $$i; echo making x-docs in "$(CURRENT_DIR)/$$i..."; \
-	$(MAKE) CURRENT_DIR=$(CURRENT_DIR)/$$i $(MFLAGS) -f Makefile all); \
-	done
-
-.PHONY: makesamples
-makesamples:
-	@for i in samples ; \
-	do \
-	(cd $$i; echo making samples in "$(CURRENT_DIR)/$$i..."; \
-	$(MAKE) CURRENT_DIR=$(CURRENT_DIR)/$$i $(MFLAGS) -f Makefile all); \
-	done
-
-.PHONY: cleansubdirs 
-cleansubdirs:
-	-@for i in $(SUBDIRS) ; \
-	do \
-	(cd $$i; echo cleaning in "$(CURRENT_DIR)/$$i..."; \
-	$(MAKE) CURRENT_DIR=$(CURRENT_DIR)/$$i -f makexpath4j $(MFLAGS) clean); \
-	(cd $$i; echo cleaning in "$(CURRENT_DIR)/$$i..."; \
-	$(MAKE) CURRENT_DIR=$(CURRENT_DIR)/$$i -f makexslt4j $(MFLAGS) clean); \
-	done
-
-.PHONY: cleancompat
-cleancompat:
-	-@for i in $(SUBDIRS) ; \
-	do \
-	(cd $$i; echo cleaning in "$(CURRENT_DIR)/$$i..."; \
-	$(MAKE) CURRENT_DIR=$(CURRENT_DIR)/$$i -f makecompat $(MFLAGS) clean); \
-	done
-
-.PHONY: cleandocs
-cleandocs:
-	@for i in xdocs ; \
-	do \
-	(cd $$i; echo cleaning up x-docs "$(CURRENT_DIR)/$$i..."; \
-	$(MAKE) CURRENT_DIR=$(CURRENT_DIR)/$$i $(MFLAGS) -f Makefile clean); \
-	done
-
-.PHONY: cleansamples
-cleansamples:
-	@for i in samples ; \
-	do \
-	(cd $$i; echo cleaning up samples "$(CURRENT_DIR)/$$i..."; \
-	$(MAKE) CURRENT_DIR=$(CURRENT_DIR)/$$i $(MFLAGS) -f Makefile clean); \
-	done
-
-# End of file
\ No newline at end of file
diff --git a/make.include2 b/make.include2
deleted file mode 100644
index abb866f..0000000
--- a/make.include2
+++ /dev/null
@@ -1,23 +0,0 @@
-###########################################################
-# Common definitions and main 'compile' rule for xpath and xslt.
-#
-# See Makefile for important environment notes
-# 
-###########################################################
-
-# Note this is separate from the variable in make.include
-CLASSESDIR = classes
-
-# Add other required dirs to the classpath
-XML4J_CLASSPATH := ..$(PATHSEP)..$(PATHSEP)..$(PATHSEP)xml-xerces$(PATHSEP)java$(PATHSEP)bin$(PATHSEP)xerces.jar
-BSF_CLASSPATH := ..$(PATHSEP)bin$(PATHSEP)bsf.jar
-# Add . (current dir) to end of classpath to help 1.1.x compilers find all the source files, thanks to Sean Timm
-EXTRA_CLASSPATH := $(XML4J_CLASSPATH)$(CLPATHSEP)$(BSF_CLASSPATH)$(CLPATHSEP)$(CLASSESDIR)$(CLPATHSEP)$(CLASSPATH)$(CLPATHSEP).
-
-sincelast: $(SINCE_FILE)
-$(SINCE_FILE): $(SRCS)
-	-mkdir $(CLASSESDIR)
-	$(JAVAC) $(JAVACFLAGS) -classpath "$(EXTRA_CLASSPATH)" $?
-	touch $(SINCE_FILE)
-
-
diff --git a/readme.html b/readme.html
deleted file mode 100644
index dae48ad..0000000
--- a/readme.html
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-<html>
-<head>
-<title>
-</title>
-</head>
-<body>
-<meta content="0; URL=docs/whatsnew.html" http-equiv="Refresh">
-      Redirecting to <a href="docs/whatsnew.html">What's New in Xalan_Java 2</a>
-</body>
-</html>
-
-
-
-
-            
-            
-
-
-
-
-            
-   
diff --git a/samples/AppletXMLtoHTML/README.html b/samples/AppletXMLtoHTML/README.html
deleted file mode 100644
index c0b584d..0000000
--- a/samples/AppletXMLtoHTML/README.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
-	<title></title>Xalan Sample Applets</title>
-</head>
-<body bgcolor="#808080" text="#ffffff">
-  <table>
-    <tr>
-      <td><img border="0" hspace="0" vspace="0" align="left" src="rabbitwhorn.jpg"></td>
-      <td><h2>&nbsp;Running the Xalan sample applets</h2></td>
-    </tr>
-  </table>
-  <hr>
-  <ul>
-  <li>appletXMLtoHTML.html transforms XML into HTML, and displays the XML document and XSL stylesheet as well as the HTML transformation result.<br/><br/></li>
-  <li>get-todo-list.html uses todo.xsl to transform todo.xml and display the transformation result. The XML source is a snapshot of todo.xml in the xml-xalan CVS repository, an ongoing list of tasks and task completions for the Xalan-Java 2 development project.</li>
-  <p>Both applets look for xalan.jar and xerces.jar in the bin directory. If the JAR files are elsewhere, you must move them or adjust the applet archive setting in client.html and get-todo-list.html.</p>
-</ul>
-<p>For information about the samples (what they illustrate and how to run them), see <a href="../../docs/samples.html">Samples</a>.</p>
-
-
-</body>
-</html>
diff --git a/samples/AppletXMLtoHTML/appletXMLtoHTML.html b/samples/AppletXMLtoHTML/appletXMLtoHTML.html
deleted file mode 100644
index 0aaa900..0000000
--- a/samples/AppletXMLtoHTML/appletXMLtoHTML.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
-	<title>Using an applet to perform XSL transformations</title>
-</head>
-  <FRAMESET ROWS="125,*" >
-    <FRAME NAME="processor" SRC="client.html" SCROLLING="auto" >
-      <frameset cols="33%, 33%, *">
-        <FRAME NAME="targetArea0" SRC="target.html" >
-        <FRAME NAME="targetArea1" SRC="target.html" >
-        <FRAME NAME="targetArea2" SRC="target.html" >        
-      </frameset>
-  </FRAMESET>
-
-</html>
diff --git a/samples/AppletXMLtoHTML/client.html b/samples/AppletXMLtoHTML/client.html
deleted file mode 100644
index 00a4382..0000000
--- a/samples/AppletXMLtoHTML/client.html
+++ /dev/null
@@ -1,121 +0,0 @@
-<!doctype HTML public "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-  <head>
-	  <title>Untitled</title>
-  </head>
-  <script language="JavaScript">
-
-    
-    function writeSource(sourceString)
-    {
-
-      var escString=document.xslControl.escapeString(sourceString);
-      var title="XML Source Doc";
-      var doc=top.frames[1].document;      
-      doc.open();
-      doc.write("<h3>" + title + "</h3>");
-      doc.write("<PRE>");
-      doc.write(escString);
-      doc.write("</PRE>");
-      doc.close();    
-    }
-  
-    function writeStylesheet(styleString)
-    {
-      var escString=document.xslControl.escapeString(styleString);
-      var title="XSL Stylesheet";
-      var doc=top.frames[2].document;          
-      doc.open();
-      doc.write("<h3>" + title + "</h3>");
-      doc.write("<PRE>");
-      doc.write(escString);
-      doc.write("</PRE>");
-      doc.close();     
-    } 
-
-    function writeTarget(targetString)
-    {
-      var doc=top.frames[3].document;
-      doc.open();
-      var title="HTML Output";      
-      doc.write("<h3>" + title + "</h3>");
-      if (document.xmlTransform.displayMode[0].checked) //display HTML
-      {
-        doc.write(targetString);
-      }
-      else // display source
-      {
-        var escString=document.xslControl.escapeString(targetString);
-        doc.write("<PRE>");
-        doc.write(escString);
-        doc.write("</PRE>");
-      }
-      doc.close();    
-    }
-  
-    function clearFrames()
-    {
-      document.xslControl.freeCache();
-      for (i=1; i<4; i++)
-        {
-        var doc=top.frames[i].document;
-        doc.open();
-        doc.clear();
-        doc.close();
-        }
-    }
-  
-    function transform()
-    {  
-      clearFrames();
-      var xmlSource=document.xmlTransform.xmlSourceList.options[document.xmlTransform.xmlSourceList.selectedIndex].value;
-      document.xslControl.setDocumentURL(xmlSource);
-      var sourceString=document.xslControl.getSourceTreeAsText();
-      var styleString=document.xslControl.getStyleTreeAsText();
-      var targetString=document.xslControl.getHtmlText();      
-      writeSource(sourceString);
-      writeStylesheet(styleString);
-      writeTarget(targetString);
-    }
-  </script>
-  <body onLoad="clearFrames();" bgcolor="#808080" text="#ffffff">
-    <form name="xmlTransform" action="" method="POST">
-      <h2><img border="0" hspace="0" vspace="0" align="left" src="rabbitwhorn.jpg">&nbsp;Transform XML Document</h2>
-        <table>
-          <tr>
-            <td width="50"></td>
-            <td align="center"><i>Document to transform</i></td>
-            <td align="center"><i>Display output as</i></td>
-          </tr>
-          <tr>
-          <td></td>
-          <td align="center">
-            <select name="xmlSourceList">
-              <option value="xalanApplets.xml" selected>&nbsp;xalanApplets.xml&nbsp;
-              <option value="foo-s1.xml">&nbsp;foo-s1.xml&nbsp;
-            </select>
-          </td>
-          <td align="center">
-            <input type="radio" name="displayMode" checked>HTML&nbsp;&nbsp;
-            <input type="radio" name="displayMode">HTML Source
-          </td>
-          <td>&nbsp;&nbsp;&nbsp;&nbsp;
-            <input type="button" name="transformButton" value="Transform" 
-            onClick="transform();">
-          </td>
-        </tr>
-      </table>
-    </form>
-    <!-- Be sure you have applet archive attribute set
-         so the applet can find xalan.jar and xerces.jar -->  
-    <applet  
-      name="xslControl"
-      code="org.apache.xalan.client.XSLTProcessorApplet.class"
-      archive="../../bin/xalan.jar,../../bin/xerces.jar"
-      height="0"
-      width"0">
-      <param name="documentURL" value="xalanApplets.xml"/>  <!--default setting-->
-      <param name="styleURL" value="s1ToHTML.xsl"/> <!--doesn't change-->
-    </applet>
-  </body>
-</html>
diff --git a/samples/AppletXMLtoHTML/foo-s1.xml b/samples/AppletXMLtoHTML/foo-s1.xml
deleted file mode 100644
index e8ce033..0000000
--- a/samples/AppletXMLtoHTML/foo-s1.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?>
-<s1 title="s1 foo">
-  <s2 title="Foo">
-    <p>Hello</p>
-  </s2>
-</s1>
\ No newline at end of file
diff --git a/samples/AppletXMLtoHTML/get-todo-list.html b/samples/AppletXMLtoHTML/get-todo-list.html
deleted file mode 100644
index 30d9073..0000000
--- a/samples/AppletXMLtoHTML/get-todo-list.html
+++ /dev/null
@@ -1,26 +0,0 @@
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-  <head>
-	<title>Xalan-Java 2 "to do" list</title>
-  </head>
-  <script language="JavaScript">
- 
-    function transform()
-    { 
-      var todolist = xslControl.getHtmlText();
-      document.write(todolist);
-    }
-  </script>
-  <body onLoad="transform();">
-    <applet  
-      name="xslControl"
-      code="org.apache.xalan.client.XSLTProcessorApplet.class"
-      archive="../../bin/xalan.jar,../../bin/xerces.jar"
-      height="0"
-      width="0">
-      <param name="documentURL" value="../../todo.xml"/> 
-      <param name="styleURL" value="../../todo.xsl"/>
-    </applet>
-  </body>
-</html>
diff --git a/samples/AppletXMLtoHTML/lts3611beac.jpg b/samples/AppletXMLtoHTML/lts3611beac.jpg
deleted file mode 100644
index c249149..0000000
--- a/samples/AppletXMLtoHTML/lts3611beac.jpg
+++ /dev/null
@@ -1 +0,0 @@
-OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
\ No newline at end of file
diff --git a/samples/AppletXMLtoHTML/rabbitwhorn.jpg b/samples/AppletXMLtoHTML/rabbitwhorn.jpg
deleted file mode 100644
index 4544a38..0000000
--- a/samples/AppletXMLtoHTML/rabbitwhorn.jpg
+++ /dev/null
Binary files differ
diff --git a/samples/AppletXMLtoHTML/s1ToHTML.xsl b/samples/AppletXMLtoHTML/s1ToHTML.xsl
deleted file mode 100644
index 2605e6f..0000000
--- a/samples/AppletXMLtoHTML/s1ToHTML.xsl
+++ /dev/null
@@ -1,141 +0,0 @@
-<?xml version="1.0"?>
-
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:output method="html" indent="yes"/>
-    
-  <xsl:template match="/">
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <xsl:template match="s1">
-    <html>
-      <head><title><xsl:value-of select="@title"/></title></head>
-      <body  bgcolor="#ffffff" text="#000000">
-        <xsl:apply-templates select="s2"/>
-      </body>
-    </html>
-  </xsl:template>
-
-  <xsl:template match="s2">
-    <table width="100%" border="0" cellspacing="0" cellpadding="4">
-      <tr>
-        <td bgcolor="#006699">
-          <font color="#ffffff" size="+1">
-            <b><xsl:value-of select="@title"/></b>
-          </font>
-        </td>
-      </tr>
-    </table>
-    <xsl:apply-templates/>
-    <br/>
-  </xsl:template>
-
-  <xsl:template match="p">
-    <p><xsl:apply-templates/></p>
-  </xsl:template>
-
-  <xsl:template match="note">
-    <table border="0" width="100%">
-      <tr>
-        <td width="20">&#160;</td>
-        <td bgcolor="#88aacc">
-          <font size="-1"><i>NOTE: <xsl:apply-templates/></i></font>
-        </td>
-        <td width="20">&#160;</td>
-      </tr>
-    </table>
-  </xsl:template>
-  
-  <xsl:template match="ul">
-    <ul><xsl:apply-templates/></ul>
-  </xsl:template>
-
-  <xsl:template match="ol">
-    <ol><xsl:apply-templates/></ol>
-  </xsl:template>
-  
-  <xsl:template match="gloss">
-    <dl><xsl:apply-templates/></dl>
-  </xsl:template>
-   <!-- <term> contains a single-word, multi-word or symbolic 
-       designation which is regarded as a technical term. --> 
-  <xsl:template match="term">
-    <dfn><xsl:apply-templates/></dfn>
-  </xsl:template>
-
-  <xsl:template match="label" priority="1">
-    <dt><xsl:apply-templates/></dt>
-  </xsl:template>
-
-  <xsl:template match="item" priority="2">
-    <dd>
-      <xsl:apply-templates/>
-    </dd>
-  </xsl:template>
-
-  <xsl:template match="table">
-    <p align="center"><table border="0"><xsl:apply-templates/></table></p>
-  </xsl:template>
-
-  <xsl:template match="source">
-    <table border="0" width="100%">
-      <tr>
-        <td width="20">&#160;</td>
-        <td bgcolor="#88aacc"><pre><xsl:apply-templates/></pre></td>
-        <td width="20">&#160;</td>
-      </tr>
-    </table>
-  </xsl:template>
-
-  <xsl:template match="li">
-    <li><xsl:apply-templates/></li>
-  </xsl:template>
-
-  <xsl:template match="tr">
-    <tr><xsl:apply-templates/></tr>
-  </xsl:template>
-
-  <xsl:template match="th">
-    <td bgcolor="#006699" align="center">
-      <font color="#ffffff"><b><xsl:apply-templates/></b></font>
-    </td>
-  </xsl:template>
-
-  <xsl:template match="td">
-    <td bgcolor="#88aacc"><xsl:apply-templates/>&#160;</td>
-  </xsl:template>
-
-  <xsl:template match="tn">
-    <td>&#160;</td>
-  </xsl:template>
-
-  <xsl:template match="em">
-    <b><xsl:apply-templates/></b>
-  </xsl:template>
-
-  <xsl:template match="ref">
-    <i><xsl:apply-templates/></i>
-  </xsl:template>
-
-  <xsl:template match="code">
-    <code><xsl:apply-templates/></code>
-  </xsl:template>
-
-  <xsl:template match="br">
-    <br/>
-  </xsl:template>
-
-
-  <xsl:template match="jump">
-    <a href="{@href}" target="_top"><xsl:apply-templates/></a>
-  </xsl:template>  
-
-  <xsl:template match="anchor">
-    <a name="{@id}"> </a>
-  </xsl:template>
-
-  <xsl:template match="img">
-    <img src="{@src}" align="right" border="0" vspace="4" hspace="4"/>
-  </xsl:template>
-  
-</xsl:stylesheet>
\ No newline at end of file
diff --git a/samples/AppletXMLtoHTML/target.html b/samples/AppletXMLtoHTML/target.html
deleted file mode 100644
index ea8545c..0000000
--- a/samples/AppletXMLtoHTML/target.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-  <head>
-    <title>Untitled</title>
-  </head>
-  <body>&nbsp;</body>
-</html>
diff --git a/samples/AppletXMLtoHTML/xalanApplets.xml b/samples/AppletXMLtoHTML/xalanApplets.xml
deleted file mode 100644
index ef86fc1..0000000
--- a/samples/AppletXMLtoHTML/xalanApplets.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0"?> 
-<s1 title="About Xalan Applets">
-  <s2 title="Transforming XML to HTML in an Applet">
-    <ol> 
-      <li>
-        <p>Include
-        org.apache.xalan.xslt.client.XSLTProcessorApplet
-        in an HTML client.</p>
-      </li>
-      <li>
-        <p>Specify the XML source document and XSL
-        stylesheet.</p>
-        <p>You can use the DocumentURL and StyleURL PARAM tags 
-        or the setDocumentURL() and setStyleURL() methods. 
-        If the XML document contains a stylesheet Processing
-        Instruction (PI), you do not need to specify an XSL
-        stylesheet.</p>
-      </li>
-      <li>
-        <p>Call the getHtmlText() method, which performs
-        the transformation and returns the new document as a
-        String.</p>
-      </li>
-    </ol>
-  </s2>
-</s1>
\ No newline at end of file
diff --git a/samples/ApplyXPath/ApplyXPath.java b/samples/ApplyXPath/ApplyXPath.java
deleted file mode 100644
index b9635f2..0000000
--- a/samples/ApplyXPath/ApplyXPath.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-// This file uses 4 space indents, no tabs.
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.util.Properties;
-import org.apache.xerces.parsers.DOMParser;
-import org.apache.xpath.XPathAPI;
-import org.apache.xml.utils.TreeWalker;
-import org.apache.xml.utils.DOMBuilder;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.traversal.NodeIterator;
-import org.xml.sax.SAXException;
-import org.xml.sax.InputSource;
-
-// Imported JAVA API for XML Parsing 1.0 classes
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException; 
-
-// Imported Serializer classes
-import javax.xml.transform.*;
-import javax.xml.transform.stream.*;
-import javax.xml.transform.dom.*;
-
-/**
- *  Very basic utility for applying an XPath epxression to an xml file and printing information
- /  about the execution of the XPath object and the nodes it finds.
- *  Takes 2 arguments:
- *     (1) an xml filename
- *     (2) an XPath expression to apply to the file
- *  Examples:
- *     java ApplyXPath foo.xml /
- *     java ApplyXPath foo.xml /doc/name[1]/@last
- * @see XPathAPI
- */
-public class ApplyXPath
-{
-  protected String filename = null;
-  protected String xpath = null;
-
-  /** Process input args and execute the XPath.  */
-  public void doMain(String[] args)
-    throws Exception
-  {
-    filename = args[0];
-    xpath = args[1];
-
-    if ((filename != null) && (filename.length() > 0)
-        && (xpath != null) && (xpath.length() > 0))
-    {
-      // Tell that we're loading classes and parsing, so the time it 
-      // takes to do this doesn't get confused with the time to do 
-      // the actual query and serialization.
-      System.out.println("Loading classes, parsing "+filename+", and setting up serializer");
-      
-      // Set up a DOM tree to query.
-      InputSource in = new InputSource(new FileInputStream(filename));
-      DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
-      Document doc = dfactory.newDocumentBuilder().parse(in);
-      
-      // Set up an identity transformer to use as serializer.
-      Transformer serializer = TransformerFactory.newInstance().newTransformer();
-      serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
-
-      // Use the simple XPath API to select a nodeIterator.
-      System.out.println("Querying DOM using "+xpath);
-      NodeIterator nl = XPathAPI.selectNodeIterator(doc, xpath);
-
-      // Serialize the found nodes to System.out.
-      System.out.println("<output>");
-                  
-      Node n;
-      while ((n = nl.nextNode())!= null)
-      {         
-        serializer.transform(new DOMSource(n), new StreamResult(System.out));
-        System.out.println();
-      }
-      System.out.println("</output>");
-    }
-    else
-    {
-      System.out.println("Bad input args: " + filename + ", " + xpath);
-    }
-  }
-  
-  /** Main method to run from the command line.    */
-  public static void main (String[] args)
-    throws Exception
-  {
-    if (args.length != 2)
-    {
-      System.out.println("java ApplyXPath filename.xml xpath\n"
-                         + "Reads filename.xml and applies the xpath; prints the nodelist found.");
-      return;
-    }
-        
-    ApplyXPath app = new ApplyXPath();
-    app.doMain(args);
-  }	
-  
-} // end of class ApplyXPath
-
diff --git a/samples/ApplyXPath/foo.xml b/samples/ApplyXPath/foo.xml
deleted file mode 100644
index 0423708..0000000
--- a/samples/ApplyXPath/foo.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0"?>
-<doc>
-  <name first="David" last="Marston"/>
-  <name first="David" last="Bertoni"/>
-  <name first="Donald" last="Leslie"/>
-  <name first="Emily" last="Farmer"/>
-  <name first="Joseph" last="Kesselman"/>
-  <name first="Myriam" last="Midy"/>
-  <name first="Paul" last="Dick"/>
-  <name first="Stephen" last="Auriemma"/>
-  <name first="Scott" last="Boag"/>
-  <name first="Shane" last="Curcuru"/>
-</doc>
\ No newline at end of file
diff --git a/samples/ApplyXPath/readme.html b/samples/ApplyXPath/readme.html
deleted file mode 100644
index ec8936f..0000000
--- a/samples/ApplyXPath/readme.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
-	<title>Xalan Samples</title>
-</head>
-<body>
-<h2>Xalan Samples</h2>
-<p>For information about the samples (what they illustrate and how to run them), see <a href="../../docs/samples.html">Samples</a>.</p>
-
-
-</body>
-</html>
diff --git a/samples/DOM2DOM/DOM2DOM.java b/samples/DOM2DOM/DOM2DOM.java
deleted file mode 100644
index 98c3269..0000000
--- a/samples/DOM2DOM/DOM2DOM.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-// Imported TraX classes
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.dom.DOMResult;
-
-// Imported java.io classes
-import java.io.IOException;
-import java.io.FileNotFoundException;
-
-// Imported SAX classes
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-// Imported DOM classes
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-// Imported Serializer classes
-import org.apache.xalan.serialize.Serializer;
-import org.apache.xalan.serialize.SerializerFactory;
-
-import org.apache.xalan.templates.OutputProperties;
-
-// Imported JAVA API for XML Parsing classes
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException; 
-
-  /**
-   * Show how to transform a DOM tree into another DOM tree.  
-   * This uses the javax.xml.parsers to parse both an XSL file 
-   * and the XML file into a DOM, and create an output DOM.
-   */
-public class DOM2DOM
-{
-	public static void main(String[] args)
-    throws TransformerException, TransformerConfigurationException, FileNotFoundException,
-           ParserConfigurationException, SAXException, IOException
-  {    
-	  TransformerFactory tFactory = TransformerFactory.newInstance();
-
-    if(tFactory.getFeature(DOMSource.FEATURE) && tFactory.getFeature(DOMResult.FEATURE))
-    {
-      //Instantiate a DocumentBuilderFactory.
-      DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
-
-      // And setNamespaceAware, which is required when parsing xsl files
-      dFactory.setNamespaceAware(true);
-      
-      //Use the DocumentBuilderFactory to create a DocumentBuilder.
-      DocumentBuilder dBuilder = dFactory.newDocumentBuilder();
-      
-      //Use the DocumentBuilder to parse the XSL stylesheet.
-      Document xslDoc = dBuilder.parse("birds.xsl");
-
-      // Use the DOM Document to define a DOMSource object.
-      DOMSource xslDomSource = new DOMSource(xslDoc);
-
-      // Set the systemId: note this is actually a URL, not a local filename
-      xslDomSource.setSystemId("birds.xsl");
-
-      // Process the stylesheet DOMSource and generate a Transformer.
-      Transformer transformer = tFactory.newTransformer(xslDomSource);
-
-      //Use the DocumentBuilder to parse the XML input.
-      Document xmlDoc = dBuilder.parse("birds.xml");
-      
-      // Use the DOM Document to define a DOMSource object.
-      DOMSource xmlDomSource = new DOMSource(xmlDoc);
-      
-      // Set the base URI for the DOMSource so any relative URIs it contains can
-      // be resolved.
-      xmlDomSource.setSystemId("birds.xml");
-      
-      // Create an empty DOMResult for the Result.
-      DOMResult domResult = new DOMResult();
-  
-  	  // Perform the transformation, placing the output in the DOMResult.
-      transformer.transform(xmlDomSource, domResult);
-	  
-	    //Instantiate an Xalan XML serializer and use it to serialize the output DOM to System.out
-	    // using a default output format.
-      Serializer serializer = SerializerFactory.getSerializer
-                                   (OutputProperties.getDefaultMethodProperties("xml"));
-      serializer.setOutputStream(System.out);
-      serializer.asDOMSerializer().serialize(domResult.getNode());
-	}
-    else
-    {
-      throw new org.xml.sax.SAXNotSupportedException("DOM node processing not supported!");
-    }
-  }
-}
diff --git a/samples/DOM2DOM/birds.xml b/samples/DOM2DOM/birds.xml
deleted file mode 100644
index 7027642..0000000
--- a/samples/DOM2DOM/birds.xml
+++ /dev/null
@@ -1,136 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Class>
-<Order Name="TINAMIFORMES">
-        <Family Name="TINAMIDAE">
-            <Species Scientific_Name="Tinamus major">  Great Tinamou.</Species>
-            <Species Scientific_Name="Nothocercus">Highland Tinamou.</Species>
-            <Species Scientific_Name="Crypturellus soui">Little Tinamou.</Species>
-            <Species Scientific_Name="Crypturellus cinnamomeus">Thicket Tinamou.</Species>
-            <Species Scientific_Name="Crypturellus boucardi">Slaty-breasted Tinamou.</Species>
-            <Species Scientific_Name="Crypturellus kerriae">Choco Tinamou.</Species>
-        </Family>
-    </Order>
-<Order Name="GAVIIFORMES">
-        <Family Name="GAVIIDAE">
-            <Species Scientific_Name="Gavia stellata">Red-throated Loon.</Species>
-            <Species Scientific_Name="Gavia arctica">Arctic Loon.</Species>
-            <Species Scientific_Name="Gavia pacifica">Pacific Loon.</Species>
-            <Species Scientific_Name="Gavia immer">Common Loon.</Species>
-            <Species Scientific_Name="Gavia adamsii">Yellow-billed Loon.</Species>
-        </Family>
-    </Order>
-
-
-<Order Name="PODICIPEDIFORMES">
-        <Family Name="PODICIPEDIDAE">
-            <Species Scientific_Name="Tachybaptus dominicus">Least Grebe.</Species>
-            <Species Scientific_Name="Podilymbus podiceps">Pied-billed Grebe.</Species>
-            <Species Scientific_Name="">Atitlan Grebe.</Species>
-            <Species Scientific_Name="">Horned Grebe.</Species>
-            <Species Scientific_Name="">Red-necked Grebe.</Species>
-            <Species Scientific_Name="">Eared Grebe.</Species>
-            <Species Scientific_Name="">Western Grebe.</Species>
-            <Species Scientific_Name="">Clark's Grebe.</Species>
-            <Species Scientific_Name=""/>
-        </Family>
-    </Order>
-
-
-<Order Name="PROCELLARIIFORMES">
-        <Family Name="DIOMEDEIDAE">
-            <Species Scientific_Name="Thalassarche chlororhynchos">Yellow-nosed Albatross. (A)</Species>
-            <Species Scientific_Name="Thalassarche cauta">Shy Albatross. (A)</Species>
-            <Species Scientific_Name="Thalassarche melanophris">Black-browed Albatross. (A)</Species>
-            <Species Scientific_Name="Phoebetria palpebrata">Light-mantled Albatross. (A)</Species>
-            <Species Scientific_Name="Diomedea exulans">Wandering Albatross. (A)</Species>
-            <Species Scientific_Name="Phoebastria immutabilis">Laysan Albatross.</Species>
-            <Species Scientific_Name="Phoebastria nigripes">Black-footed Albatross.</Species>
-            <Species Scientific_Name="Phoebastria albatrus">Short-tailed Albatross. (N)</Species>
-        </Family>
-        <Family Name="PROCELLARIIDAE">
-            <Species Scientific_Name="Fulmarus glacialis">Northern Fulmar.</Species>
-            <Species Scientific_Name="Pterodroma neglecta">Kermadec Petrel. (A)</Species>
-            <Species Scientific_Name="Pterodroma arminjoniana">Herald Petrel. (A)</Species>
-            <Species Scientific_Name="Pterodroma ultima">Murphy's Petrel. (N)</Species>
-            <Species Scientific_Name="Pterodroma inexpectata">Mottled Petrel. (A)</Species>
-            <Species Scientific_Name="Pterodroma cahow">Bermuda Petrel.</Species>
-            <Species Scientific_Name="Pterodroma hasitata">Black-capped Petrel.</Species>
-            <Species Scientific_Name="Pterodroma externa">Juan Fernandez Petrel. (N)</Species>
-            <Species Scientific_Name="Pterodroma phaeopygia">Dark-rumped Petrel.</Species>
-            <Species Scientific_Name="Pterodroma cervicalis">White-necked Petrel. (H)</Species>
-            <Species Scientific_Name="Pterodroma hypoleuca">Bonin Petrel. (H)</Species>
-            <Species Scientific_Name="Pterodroma nigripennis">Black-winged Petrel. (H, A)</Species>
-            <Species Scientific_Name="Pterodroma cookii">Cook's Petrel. (N)</Species>
-            <Species Scientific_Name="Pterodroma longirostris">Stejneger's Petrel. (A)</Species>
-            <Species Scientific_Name="Bulweria bulwerii">Bulwer's Petrel. (H)</Species>
-            <Species Scientific_Name="Bulweria fallax">Jouanin's Petrel. (H, A)</Species>
-            <Species Scientific_Name="Procellaria parkinsoni">Parkinson's Petrel. (N)</Species>
-            <Species Scientific_Name="Calonectris leucomelas">Streaked Shearwater. (A)</Species>
-            <Species Scientific_Name="Calonectris diomedea">Cory's Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus creatopus">Pink-footed Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus carneipes">Flesh-footed Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus gravis">Greater Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus pacificus">Wedge-tailed Shearwater.</Species>
-            <Species Scientific_Name="Puffinus bulleri">Buller's Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus griseus">Sooty Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus tenuirostris">Short-tailed Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus nativitatis">Christmas Shearwater. (H)</Species>
-            <Species Scientific_Name="Puffinus puffinus">Manx Shearwater.</Species>
-            <Species Scientific_Name="Puffinus auricularis">Townsend's Shearwater.</Species>
-            <Species Scientific_Name="Puffinus opisthomelas">Black-vented Shearwater.</Species>
-            <Species Scientific_Name="Puffinus lherminieri">Audubon's Shearwater.</Species>
-            <Species Scientific_Name="Puffinus assimilis">Little Shearwater. (A)</Species>
-        </Family>
-        <Family Name="HYDROBATIDAE">
-            <Species Scientific_Name="Oceanites oceanicus">Wilson's Storm-Petrel. (N)</Species>
-            <Species Scientific_Name="Pelagodroma marina">White-faced Storm-Petrel. (A)</Species>
-            <Species Scientific_Name="Hydrobates pelagicus">European Storm-Petrel. (A)</Species>
-            <Species Scientific_Name="Oceanodroma furcata">Fork-tailed Storm-Petrel.</Species>
-            <Species Scientific_Name="Oceanodroma leucorhoa">Leach's Storm-Petrel.</Species>
-            <Species Scientific_Name="Oceanodroma homochroa">Ashy Storm-Petrel.</Species>
-            <Species Scientific_Name="Oceanodroma castro">Band-rumped Storm-Petrel. (N)</Species>
-            <Species Scientific_Name="Oceanodroma tethys">Wedge-rumped Storm-Petrel. (N)</Species>
-            <Species Scientific_Name="Oceanodroma melania">Black Storm-Petrel.</Species>
-            <Species Scientific_Name="Oceanodroma macrodactyla">Guadalupe Storm-Petrel.</Species>
-            <Species Scientific_Name="Oceanodroma markhami">Markham's Storm-Petrel. (A)</Species>
-            <Species Scientific_Name="Oceanodroma tristrami">Tristram's Storm-Petrel. (H)</Species>
-            <Species Scientific_Name="Oceanodroma microsoma">Least Storm-Petrel.</Species>
-        </Family>
-    </Order>
-
-<Order Name="PELECANIFORMES">
-        <Family Name="PHAETHONTIDAE">
-            <Species Scientific_Name="Phaethon lepturus">White-tailed Tropicbird.</Species>
-            <Species Scientific_Name="Phaethon aethereus">Red-billed Tropicbird.</Species>
-            <Species Scientific_Name="Phaethon rubricauda">Red-tailed Tropicbird.</Species>
-        </Family>
-        <Family Name="SULIDAE">
-            <Species Scientific_Name="Sula dactylatra">Masked Booby.</Species>
-            <Species Scientific_Name="Sula nebouxii">Blue-footed Booby.</Species>
-            <Species Scientific_Name="Sula variegata">Peruvian Booby. (A)</Species>
-            <Species Scientific_Name="Sula leucogaster">Brown Booby.</Species>
-            <Species Scientific_Name="Sula sula">Red-footed Booby.</Species>
-            <Species Scientific_Name="Morus bassanus">Northern Gannet.</Species>
-        </Family>
-        <Family Name="PELECANIDAE">
-            <Species Scientific_Name="Pelecanus erythrorhynchos">American White Pelican.</Species>
-            <Species Scientific_Name="Pelecanus occidentalis">Brown Pelican.</Species>
-        </Family>
-        <Family Name="PHALACROCORACIDAE">
-            <Species Scientific_Name="Phalacrocorax penicillatus">Brandt's Cormorant.</Species>
-            <Species Scientific_Name="Phalacrocorax brasilianus">Neotropic Cormorant.</Species>
-            <Species Scientific_Name="Phalacrocorax auritus">Double-crested Cormorant.</Species>
-            <Species Scientific_Name="Phalacrocorax carbo">Great Cormorant.</Species>
-            <Species Scientific_Name="Phalacrocorax urile">Red-faced Cormorant.</Species>
-            <Species Scientific_Name="Phalacrocorax pelagicus">Pelagic Cormorant.</Species>
-        </Family>
-        <Family Name="ANHINGIDAE">
-            <Species Scientific_Name="Anhinga anhinga">Anhinga.</Species>
-        </Family>
-        <Family Name="FREGATIDAE">
-            <Species Scientific_Name="Fregata magnificens">Magnificent Frigatebird.</Species>
-            <Species Scientific_Name="Fregata minor">Great Frigatebird.</Species>
-            <Species Scientific_Name="Fregata ariel">Lesser Frigatebird. (A)</Species>
-        </Family>
-    </Order>
-</Class>
diff --git a/samples/DOM2DOM/birds.xsl b/samples/DOM2DOM/birds.xsl
deleted file mode 100644
index 4d6f8e1..0000000
--- a/samples/DOM2DOM/birds.xsl
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:output method="xml" indent="yes"/>
-
-<xsl:template match="Class">
-<BirdInfo>
-	<xsl:apply-templates select="Order"/>
-</BirdInfo>
-</xsl:template>
-
-<xsl:template match="Order">
-Order is:  <xsl:value-of select="@Name"/>
-	<xsl:apply-templates select="Family"/><xsl:text>
-</xsl:text>
-</xsl:template>
-
-<xsl:template match="Family">
-	Family is:  <xsl:value-of select="@Name"/>
-	<xsl:apply-templates select="Species | SubFamily | text()"/>
-</xsl:template>
-
-<xsl:template match="SubFamily">
-		SubFamily is <xsl:value-of select="@Name"/>
-    <xsl:apply-templates select="Species | text()"/>
-</xsl:template>
-
-<xsl:template match="Species">
-	<xsl:choose>
-	  <xsl:when test="name(..)='SubFamily'">
-		<xsl:text>	</xsl:text><xsl:value-of select="."/><xsl:text> </xsl:text><xsl:value-of select="@Scientific_Name"/>
-	  </xsl:when>
-	  <xsl:otherwise>
-		<xsl:value-of select="."/><xsl:text> </xsl:text><xsl:value-of select="@Scientific_Name"/>
-	  </xsl:otherwise>
-	</xsl:choose>
-</xsl:template>
-
-</xsl:stylesheet>
diff --git a/samples/DOM2DOM/readme.html b/samples/DOM2DOM/readme.html
deleted file mode 100644
index ec8936f..0000000
--- a/samples/DOM2DOM/readme.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
-	<title>Xalan Samples</title>
-</head>
-<body>
-<h2>Xalan Samples</h2>
-<p>For information about the samples (what they illustrate and how to run them), see <a href="../../docs/samples.html">Samples</a>.</p>
-
-
-</body>
-</html>
diff --git a/samples/Pipe/Pipe.java b/samples/Pipe/Pipe.java
deleted file mode 100644
index 40e25da..0000000
--- a/samples/Pipe/Pipe.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-// Imported TraX classes
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.sax.SAXResult;
-import javax.xml.transform.dom.DOMResult;
-
-// Imported SAX classes
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.Parser;
-import org.xml.sax.helpers.ParserAdapter;
-import org.xml.sax.helpers.XMLReaderFactory;
-import org.xml.sax.XMLReader;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.ext.LexicalHandler;
-
-// Imported DOM classes
-import org.w3c.dom.Node;
-
-// Imported Serializer classes
-import org.apache.xalan.serialize.Serializer;
-import org.apache.xalan.serialize.SerializerFactory;
-import org.apache.xalan.templates.OutputProperties;
-
-// Imported JAVA API for XML Parsing 1.0 classes
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException; 
-
-// Imported java.io classes
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.IOException;
-
-import org.apache.xalan.transformer.TransformerImpl;
-
-  /**
-   * This example shows how to chain a series of transformations by
-   * piping SAX events from one Transformer to another. Each Transformer
-   * operates as a SAX2 XMLFilter/XMLReader.
-   */
-public class Pipe
-{
-	public static void main(String[] args)
-	throws TransformerException, TransformerConfigurationException, 
-         SAXException, IOException	   
-	{
-    // Instantiate  a TransformerFactory.
-  	TransformerFactory tFactory = TransformerFactory.newInstance();
-    // Determine whether the TransformerFactory supports The use uf SAXSource 
-    // and SAXResult
-    if (tFactory.getFeature(SAXSource.FEATURE) && tFactory.getFeature(SAXResult.FEATURE))
-    { 
-      // Cast the TransformerFactory to SAXTransformerFactory.
-      SAXTransformerFactory saxTFactory = ((SAXTransformerFactory) tFactory);	  
-      // Create a TransformerHandler for each stylesheet.
-      TransformerHandler tHandler1 = saxTFactory.newTransformerHandler(new StreamSource("foo1.xsl"));
-      TransformerHandler tHandler2 = saxTFactory.newTransformerHandler(new StreamSource("foo2.xsl"));
-      TransformerHandler tHandler3 = saxTFactory.newTransformerHandler(new StreamSource("foo3.xsl"));
-    
-      // Create an XMLReader.
-	    XMLReader reader = XMLReaderFactory.createXMLReader();
-      reader.setContentHandler(tHandler1);
-      reader.setProperty("http://xml.org/sax/properties/lexical-handler", tHandler1);
-
-      tHandler1.setResult(new SAXResult(tHandler2));
-      tHandler2.setResult(new SAXResult(tHandler3));
-
-      // transformer3 outputs SAX events to the serializer.
-      Serializer serializer = SerializerFactory.getSerializer
-                                   (OutputProperties.getDefaultMethodProperties("xml"));        
-      serializer.setOutputStream(System.out);
-      tHandler3.setResult(new SAXResult(serializer.asContentHandler()));
-
-	    // Parse the XML input document. The input ContentHandler and output ContentHandler
-      // work in separate threads to optimize performance.   
-      reader.parse("foo.xml");
-    }
-  }
-}
\ No newline at end of file
diff --git a/samples/Pipe/foo.xml b/samples/Pipe/foo.xml
deleted file mode 100644
index da9f79b..0000000
--- a/samples/Pipe/foo.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0"?>
-<doc>Hello</doc>
\ No newline at end of file
diff --git a/samples/Pipe/foo1.xsl b/samples/Pipe/foo1.xsl
deleted file mode 100644
index 5da8d5e..0000000
--- a/samples/Pipe/foo1.xsl
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:template match="doc">
-    <out><xsl:value-of select="."/></out>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/samples/Pipe/foo2.xsl b/samples/Pipe/foo2.xsl
deleted file mode 100644
index 67cd197..0000000
--- a/samples/Pipe/foo2.xsl
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:template match="out">
-    <out><xsl:value-of select="."/> ...good to see you again!</out>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/samples/Pipe/foo3.xsl b/samples/Pipe/foo3.xsl
deleted file mode 100644
index 83cfaa6..0000000
--- a/samples/Pipe/foo3.xsl
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:template match="out">
-    <out><xsl:value-of select="."/> ...and goodby!</out>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/samples/Pipe/readme.html b/samples/Pipe/readme.html
deleted file mode 100644
index ec8936f..0000000
--- a/samples/Pipe/readme.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
-	<title>Xalan Samples</title>
-</head>
-<body>
-<h2>Xalan Samples</h2>
-<p>For information about the samples (what they illustrate and how to run them), see <a href="../../docs/samples.html">Samples</a>.</p>
-
-
-</body>
-</html>
diff --git a/samples/SAX2SAX/SAX2SAX.java b/samples/SAX2SAX/SAX2SAX.java
deleted file mode 100644
index 7d208ab..0000000
--- a/samples/SAX2SAX/SAX2SAX.java
+++ /dev/null
@@ -1,148 +0,0 @@
-
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-/**
- *  Replicate the SimpleTransform sample, explicitly using the SAX model to handle the
- *  stylesheet, the XML input, and the transformation.
- */
-
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.Templates;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.Result;
-import javax.xml.transform.sax.SAXResult;
-import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TemplatesHandler;
-import javax.xml.transform.sax.TransformerHandler;              
-
-import org.xml.sax.XMLReader;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.XMLReaderFactory;
-
-import org.apache.xalan.serialize.SerializerFactory;
-import org.apache.xalan.serialize.Serializer;
-import org.apache.xalan.templates.OutputProperties;
-
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-
-public class SAX2SAX
-{
-  public static void main(String[] args)
-	throws TransformerException, TransformerConfigurationException, 
-         SAXException, IOException	   
-	{
-
-    // Instantiate a TransformerFactory.
-  	TransformerFactory tFactory = TransformerFactory.newInstance();
-    // Determine whether the TransformerFactory supports The use of SAXSource 
-    // and SAXResult
-    if (tFactory.getFeature(SAXSource.FEATURE) && tFactory.getFeature(SAXResult.FEATURE))
-    { 
-      // Cast the TransformerFactory.
-      SAXTransformerFactory saxTFactory = ((SAXTransformerFactory) tFactory);
-      // Create a ContentHandler to handle parsing of the stylesheet.
-      TemplatesHandler templatesHandler = saxTFactory.newTemplatesHandler();
-
-      // Create an XMLReader and set its ContentHandler.
-      XMLReader reader = XMLReaderFactory.createXMLReader();
-      reader.setContentHandler(templatesHandler);
-    
-      // Parse the stylesheet.                       
-      reader.parse("birds.xsl");
-
-      //Get the Templates object from the ContentHandler.
-      Templates templates = templatesHandler.getTemplates();
-      // Create a ContentHandler to handle parsing of the XML source.  
-      TransformerHandler handler 
-        = saxTFactory.newTransformerHandler(templates);
-      // Reset the XMLReader's ContentHandler.
-      reader.setContentHandler(handler);  
-
-      // Set the ContentHandler to also function as a LexicalHandler, which
-      // includes "lexical" events (e.g., comments and CDATA). 
-      reader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
-      
-   	  FileOutputStream fos = new FileOutputStream("birds.out");
-      
-      Serializer serializer = SerializerFactory.getSerializer
-                              (OutputProperties.getDefaultMethodProperties("xml"));
-      serializer.setOutputStream(fos);
-   
-      
-      // Set the result handling to be a serialization to the file output stream.
-      Result result = new SAXResult(serializer.asContentHandler());
-      handler.setResult(result);
-      
-      // Parse the XML input document.
-      reader.parse("birds.xml");
-      
-    	System.out.println("************* The result is in birds.out *************");	
-    }	
-    else
-      System.out.println("The TransformerFactory does not support SAX input and SAX output");
-  }
-}
\ No newline at end of file
diff --git a/samples/SAX2SAX/birds.xml b/samples/SAX2SAX/birds.xml
deleted file mode 100644
index 7027642..0000000
--- a/samples/SAX2SAX/birds.xml
+++ /dev/null
@@ -1,136 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Class>
-<Order Name="TINAMIFORMES">
-        <Family Name="TINAMIDAE">
-            <Species Scientific_Name="Tinamus major">  Great Tinamou.</Species>
-            <Species Scientific_Name="Nothocercus">Highland Tinamou.</Species>
-            <Species Scientific_Name="Crypturellus soui">Little Tinamou.</Species>
-            <Species Scientific_Name="Crypturellus cinnamomeus">Thicket Tinamou.</Species>
-            <Species Scientific_Name="Crypturellus boucardi">Slaty-breasted Tinamou.</Species>
-            <Species Scientific_Name="Crypturellus kerriae">Choco Tinamou.</Species>
-        </Family>
-    </Order>
-<Order Name="GAVIIFORMES">
-        <Family Name="GAVIIDAE">
-            <Species Scientific_Name="Gavia stellata">Red-throated Loon.</Species>
-            <Species Scientific_Name="Gavia arctica">Arctic Loon.</Species>
-            <Species Scientific_Name="Gavia pacifica">Pacific Loon.</Species>
-            <Species Scientific_Name="Gavia immer">Common Loon.</Species>
-            <Species Scientific_Name="Gavia adamsii">Yellow-billed Loon.</Species>
-        </Family>
-    </Order>
-
-
-<Order Name="PODICIPEDIFORMES">
-        <Family Name="PODICIPEDIDAE">
-            <Species Scientific_Name="Tachybaptus dominicus">Least Grebe.</Species>
-            <Species Scientific_Name="Podilymbus podiceps">Pied-billed Grebe.</Species>
-            <Species Scientific_Name="">Atitlan Grebe.</Species>
-            <Species Scientific_Name="">Horned Grebe.</Species>
-            <Species Scientific_Name="">Red-necked Grebe.</Species>
-            <Species Scientific_Name="">Eared Grebe.</Species>
-            <Species Scientific_Name="">Western Grebe.</Species>
-            <Species Scientific_Name="">Clark's Grebe.</Species>
-            <Species Scientific_Name=""/>
-        </Family>
-    </Order>
-
-
-<Order Name="PROCELLARIIFORMES">
-        <Family Name="DIOMEDEIDAE">
-            <Species Scientific_Name="Thalassarche chlororhynchos">Yellow-nosed Albatross. (A)</Species>
-            <Species Scientific_Name="Thalassarche cauta">Shy Albatross. (A)</Species>
-            <Species Scientific_Name="Thalassarche melanophris">Black-browed Albatross. (A)</Species>
-            <Species Scientific_Name="Phoebetria palpebrata">Light-mantled Albatross. (A)</Species>
-            <Species Scientific_Name="Diomedea exulans">Wandering Albatross. (A)</Species>
-            <Species Scientific_Name="Phoebastria immutabilis">Laysan Albatross.</Species>
-            <Species Scientific_Name="Phoebastria nigripes">Black-footed Albatross.</Species>
-            <Species Scientific_Name="Phoebastria albatrus">Short-tailed Albatross. (N)</Species>
-        </Family>
-        <Family Name="PROCELLARIIDAE">
-            <Species Scientific_Name="Fulmarus glacialis">Northern Fulmar.</Species>
-            <Species Scientific_Name="Pterodroma neglecta">Kermadec Petrel. (A)</Species>
-            <Species Scientific_Name="Pterodroma arminjoniana">Herald Petrel. (A)</Species>
-            <Species Scientific_Name="Pterodroma ultima">Murphy's Petrel. (N)</Species>
-            <Species Scientific_Name="Pterodroma inexpectata">Mottled Petrel. (A)</Species>
-            <Species Scientific_Name="Pterodroma cahow">Bermuda Petrel.</Species>
-            <Species Scientific_Name="Pterodroma hasitata">Black-capped Petrel.</Species>
-            <Species Scientific_Name="Pterodroma externa">Juan Fernandez Petrel. (N)</Species>
-            <Species Scientific_Name="Pterodroma phaeopygia">Dark-rumped Petrel.</Species>
-            <Species Scientific_Name="Pterodroma cervicalis">White-necked Petrel. (H)</Species>
-            <Species Scientific_Name="Pterodroma hypoleuca">Bonin Petrel. (H)</Species>
-            <Species Scientific_Name="Pterodroma nigripennis">Black-winged Petrel. (H, A)</Species>
-            <Species Scientific_Name="Pterodroma cookii">Cook's Petrel. (N)</Species>
-            <Species Scientific_Name="Pterodroma longirostris">Stejneger's Petrel. (A)</Species>
-            <Species Scientific_Name="Bulweria bulwerii">Bulwer's Petrel. (H)</Species>
-            <Species Scientific_Name="Bulweria fallax">Jouanin's Petrel. (H, A)</Species>
-            <Species Scientific_Name="Procellaria parkinsoni">Parkinson's Petrel. (N)</Species>
-            <Species Scientific_Name="Calonectris leucomelas">Streaked Shearwater. (A)</Species>
-            <Species Scientific_Name="Calonectris diomedea">Cory's Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus creatopus">Pink-footed Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus carneipes">Flesh-footed Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus gravis">Greater Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus pacificus">Wedge-tailed Shearwater.</Species>
-            <Species Scientific_Name="Puffinus bulleri">Buller's Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus griseus">Sooty Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus tenuirostris">Short-tailed Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus nativitatis">Christmas Shearwater. (H)</Species>
-            <Species Scientific_Name="Puffinus puffinus">Manx Shearwater.</Species>
-            <Species Scientific_Name="Puffinus auricularis">Townsend's Shearwater.</Species>
-            <Species Scientific_Name="Puffinus opisthomelas">Black-vented Shearwater.</Species>
-            <Species Scientific_Name="Puffinus lherminieri">Audubon's Shearwater.</Species>
-            <Species Scientific_Name="Puffinus assimilis">Little Shearwater. (A)</Species>
-        </Family>
-        <Family Name="HYDROBATIDAE">
-            <Species Scientific_Name="Oceanites oceanicus">Wilson's Storm-Petrel. (N)</Species>
-            <Species Scientific_Name="Pelagodroma marina">White-faced Storm-Petrel. (A)</Species>
-            <Species Scientific_Name="Hydrobates pelagicus">European Storm-Petrel. (A)</Species>
-            <Species Scientific_Name="Oceanodroma furcata">Fork-tailed Storm-Petrel.</Species>
-            <Species Scientific_Name="Oceanodroma leucorhoa">Leach's Storm-Petrel.</Species>
-            <Species Scientific_Name="Oceanodroma homochroa">Ashy Storm-Petrel.</Species>
-            <Species Scientific_Name="Oceanodroma castro">Band-rumped Storm-Petrel. (N)</Species>
-            <Species Scientific_Name="Oceanodroma tethys">Wedge-rumped Storm-Petrel. (N)</Species>
-            <Species Scientific_Name="Oceanodroma melania">Black Storm-Petrel.</Species>
-            <Species Scientific_Name="Oceanodroma macrodactyla">Guadalupe Storm-Petrel.</Species>
-            <Species Scientific_Name="Oceanodroma markhami">Markham's Storm-Petrel. (A)</Species>
-            <Species Scientific_Name="Oceanodroma tristrami">Tristram's Storm-Petrel. (H)</Species>
-            <Species Scientific_Name="Oceanodroma microsoma">Least Storm-Petrel.</Species>
-        </Family>
-    </Order>
-
-<Order Name="PELECANIFORMES">
-        <Family Name="PHAETHONTIDAE">
-            <Species Scientific_Name="Phaethon lepturus">White-tailed Tropicbird.</Species>
-            <Species Scientific_Name="Phaethon aethereus">Red-billed Tropicbird.</Species>
-            <Species Scientific_Name="Phaethon rubricauda">Red-tailed Tropicbird.</Species>
-        </Family>
-        <Family Name="SULIDAE">
-            <Species Scientific_Name="Sula dactylatra">Masked Booby.</Species>
-            <Species Scientific_Name="Sula nebouxii">Blue-footed Booby.</Species>
-            <Species Scientific_Name="Sula variegata">Peruvian Booby. (A)</Species>
-            <Species Scientific_Name="Sula leucogaster">Brown Booby.</Species>
-            <Species Scientific_Name="Sula sula">Red-footed Booby.</Species>
-            <Species Scientific_Name="Morus bassanus">Northern Gannet.</Species>
-        </Family>
-        <Family Name="PELECANIDAE">
-            <Species Scientific_Name="Pelecanus erythrorhynchos">American White Pelican.</Species>
-            <Species Scientific_Name="Pelecanus occidentalis">Brown Pelican.</Species>
-        </Family>
-        <Family Name="PHALACROCORACIDAE">
-            <Species Scientific_Name="Phalacrocorax penicillatus">Brandt's Cormorant.</Species>
-            <Species Scientific_Name="Phalacrocorax brasilianus">Neotropic Cormorant.</Species>
-            <Species Scientific_Name="Phalacrocorax auritus">Double-crested Cormorant.</Species>
-            <Species Scientific_Name="Phalacrocorax carbo">Great Cormorant.</Species>
-            <Species Scientific_Name="Phalacrocorax urile">Red-faced Cormorant.</Species>
-            <Species Scientific_Name="Phalacrocorax pelagicus">Pelagic Cormorant.</Species>
-        </Family>
-        <Family Name="ANHINGIDAE">
-            <Species Scientific_Name="Anhinga anhinga">Anhinga.</Species>
-        </Family>
-        <Family Name="FREGATIDAE">
-            <Species Scientific_Name="Fregata magnificens">Magnificent Frigatebird.</Species>
-            <Species Scientific_Name="Fregata minor">Great Frigatebird.</Species>
-            <Species Scientific_Name="Fregata ariel">Lesser Frigatebird. (A)</Species>
-        </Family>
-    </Order>
-</Class>
diff --git a/samples/SAX2SAX/birds.xsl b/samples/SAX2SAX/birds.xsl
deleted file mode 100644
index 4d6f8e1..0000000
--- a/samples/SAX2SAX/birds.xsl
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:output method="xml" indent="yes"/>
-
-<xsl:template match="Class">
-<BirdInfo>
-	<xsl:apply-templates select="Order"/>
-</BirdInfo>
-</xsl:template>
-
-<xsl:template match="Order">
-Order is:  <xsl:value-of select="@Name"/>
-	<xsl:apply-templates select="Family"/><xsl:text>
-</xsl:text>
-</xsl:template>
-
-<xsl:template match="Family">
-	Family is:  <xsl:value-of select="@Name"/>
-	<xsl:apply-templates select="Species | SubFamily | text()"/>
-</xsl:template>
-
-<xsl:template match="SubFamily">
-		SubFamily is <xsl:value-of select="@Name"/>
-    <xsl:apply-templates select="Species | text()"/>
-</xsl:template>
-
-<xsl:template match="Species">
-	<xsl:choose>
-	  <xsl:when test="name(..)='SubFamily'">
-		<xsl:text>	</xsl:text><xsl:value-of select="."/><xsl:text> </xsl:text><xsl:value-of select="@Scientific_Name"/>
-	  </xsl:when>
-	  <xsl:otherwise>
-		<xsl:value-of select="."/><xsl:text> </xsl:text><xsl:value-of select="@Scientific_Name"/>
-	  </xsl:otherwise>
-	</xsl:choose>
-</xsl:template>
-
-</xsl:stylesheet>
diff --git a/samples/SAX2SAX/foo.xml b/samples/SAX2SAX/foo.xml
deleted file mode 100644
index da9f79b..0000000
--- a/samples/SAX2SAX/foo.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0"?>
-<doc>Hello</doc>
\ No newline at end of file
diff --git a/samples/SAX2SAX/foo.xsl b/samples/SAX2SAX/foo.xsl
deleted file mode 100644
index 5da8d5e..0000000
--- a/samples/SAX2SAX/foo.xsl
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:template match="doc">
-    <out><xsl:value-of select="."/></out>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/samples/SQLExtension/ConnectionPools.htm b/samples/SQLExtension/ConnectionPools.htm
deleted file mode 100644
index af6e746..0000000
--- a/samples/SQLExtension/ConnectionPools.htm
+++ /dev/null
@@ -1,80 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
-	<title>SQL Extension; DB Connection Pools</title>
-</head>
-<body>
-<hr />
-<h2>Overview</h2> 
-<hr />
-<p>
-   Database connection pools have been added to the Xalan SQL Extension 
-   for two reasons. 
-<ol>
- <li>A performance enhancement where consecutive transformation can reused
- databse connections without reallocating resources from the JDBC Driver. 
- </li>
- <li>A method to share databse connections created outside the scope of the
- Xalan XSLT process with the stylesheets that use the SQL extensions
- <li>
-</ol>
-</p>
-
- <hr /> 
- <h2>Requirments</h2>
- <hr />
- <p>
- <DL>
-  <DT><i>Named Connection Pools</i></DT>
-   <DD>Connection Pools will be refered to by name to provide a linkage to
-   connection pools created outside the scope of the Xalan Processor. Named
-   Connection Pools will also provide a mechinsim to support non-native
-   connection used in JDBC 1.0 and JNDI references in JDBC 2.0
-   </DD>
-  <DT><i>Backwards Compatibility</i><DT>
-   <DD>If the existing connection mechinsim is used (constructors in
-   XConnection), crreate a connection pool on its behalf. The name of the 
-   connecton pool will be the concatenation of the Driver name, DB URL, 
-   User name and password.
-   </DD>
-  <DT><i>Connection Pool Wrapppers</i><DT>
-   <DD>Implement a connection pool interface that defines the required
-   beahvoiur for connection pools. This interface will be used to adapt
-   other connection mechinsims to the Xalan SQL Extensions
-   </DD>
-  <DT><i>Minimal Dependancies</i></DT>
-   <DD>The SQL Extension will implement a minimal default connection pool 
-   mechinism. This will reduce the dependancy of third party libraries to 
-   build and use the Xalan SQL Processor. Other wrappers can be written
-   to adapt third party connection pools to the processor. A sample of the
-   Apache Turbine project is planned as a sample for the project.
-   </DD>
-  </DL>
- </p>
-
- <hr />
- <h2>Examples of Use</h2>
- <hr />
- <UL>
- <li>Establishing a basic connection</li><br />
- <code> Some code text</code>
- <li>Establishing a connection by suppliying the connection information
-     in the XML </li><br />
- <code> Some code text</code>
- <li>Using a connecction that has been established outside the Xalan
-     Processor</li><br />
- <code> Some code text</code>
- </UL>
-  
- <hr />
- <h2>SQL Results</h2>
- <hr />
-
- <hr />
- <h2>Error Control</h2>
- <hr />
-
-
-</body>
-</html>
diff --git a/samples/SQLExtension/README b/samples/SQLExtension/README
deleted file mode 100644
index bb7d302..0000000
--- a/samples/SQLExtension/README
+++ /dev/null
@@ -1,22 +0,0 @@
-Samples
- Static login, Static Query
- Login with XML Data, Static Query
- Login with Ext Param, Static Query
- Login with Ext Pool, Static Query
- 
- Login with XML Data,PQuery - Type with data, Data in XML
- Login with XML Data, PQuery - Type with query, Data in XML
- 
- Login with XML Data, PQuery - Type with query, Data Ext Param
- 
- To Do,
-  Single XConnection constructor
-  Make a connect method that returns a NodeIterator
-  Create a Exception that will serianlze itself as a stree Node
-  
- Docs
-  How to Connect
-  How to execute a query
- 
- 
- 
diff --git a/samples/SQLExtension/basic-connection/dbinfo.xml b/samples/SQLExtension/basic-connection/dbinfo.xml
deleted file mode 100644
index e57d25f..0000000
--- a/samples/SQLExtension/basic-connection/dbinfo.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<dbtest>
- <description>This file contains information required to make a connection to the DBMS</description>
-
- <DBINFO>
-   <dbdriver>com.sybase.jdbc2.jdbc.SybDriver</dbdriver>
-   <dburl>jdbc:sybase:Tds:localhost:5000/smart911</dburl>
-   <user>sa</user>
-   <password/>
- </DBINFO>
- 
-
-</dbtest>
diff --git a/samples/SQLExtension/basic-connection/dbtest-cinfo.xsl b/samples/SQLExtension/basic-connection/dbtest-cinfo.xsl
deleted file mode 100644
index d3d5c26..0000000
--- a/samples/SQLExtension/basic-connection/dbtest-cinfo.xsl
+++ /dev/null
@@ -1,48 +0,0 @@
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                version="1.0"
-                xmlns:sql="/org.apache.xalan.lib.sql.XConnection"
-                extension-element-prefixes="sql">
-  <xsl:output method="html" indent="yes"/>
-  <xsl:param name="query" select="&quot;SELECT FirstName, LastName, Street1, City, Zip  FROM Account where AcctID='2019001010'&quot;"/>
- 
-  <xsl:template match="/">
-    <!-- 1. Make the connection -->
-    <xsl:param name="cinfo" select="//DBINFO" />
-    <xsl:variable name="accounts"
-                  select='sql:new($cinfo)'/>
-    <HTML>
-      <HEAD>
-      </HEAD>
-      <BODY>
-        <TABLE border="1">
-        <!--2. Execute the query -->
-        <xsl:variable name="table" select='sql:query($accounts, $query)'/>
-          <TR>
-          <!-- Get column-label attribute from each column-header-->
-          <xsl:for-each select="$table/row-set/column-header">
-            <TH><xsl:value-of select="@column-label"/></TH>
-          </xsl:for-each>
-          </TR>
-          <xsl:apply-templates select="$table/row-set/row"/>
-          <xsl:text>&#10;</xsl:text>
-        </TABLE>
-      </BODY>
-    </HTML> 
-    <!-- 3. Close the connection -->
-    <xsl:value-of select="sql:close($accounts)"/>
-  </xsl:template>
-
-  <xsl:template match="row">
-        <TR>
-          <xsl:apply-templates select="col"/>
-        </TR>
-  </xsl:template>
-
-  <xsl:template match="col">
-    <TD>
-      <!-- Here is the column data -->
-      <xsl:value-of select="text()"/>
-    </TD>
-  </xsl:template>
-
-</xsl:stylesheet>
diff --git a/samples/SQLExtension/basic-connection/dbtest.xsl b/samples/SQLExtension/basic-connection/dbtest.xsl
deleted file mode 100644
index 1fc6db5..0000000
--- a/samples/SQLExtension/basic-connection/dbtest.xsl
+++ /dev/null
@@ -1,49 +0,0 @@
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                version="1.0"
-                xmlns:sql="org.apache.xalan.lib.sql.XConnection"
-                extension-element-prefixes="sql">
-  <xsl:output method="html" indent="yes"/>
-  <xsl:param name="query" select="&quot;SELECT FirstName, LastName, Street1, City, Zip  FROM Account where AcctID='2019002010'&quot;"/>
- 
-  <xsl:template match="/">
-    <!-- 1. Make the connection -->
-    <xsl:variable name="accounts"
-                  select="sql:new('com.sybase.jdbc2.jdbc.SybDriver',
-                                'jdbc:sybase:Tds:localhost:5000/smart911', 'sa',
-                                '')"/>
-    <HTML>
-      <HEAD>
-      </HEAD>
-      <BODY>
-        <TABLE border="1">
-        <!--2. Execute the query -->
-        <xsl:variable name="table" select='sql:query($accounts, $query)'/>
-          <TR>
-          <!-- Get column-label attribute from each column-header-->
-          <xsl:for-each select="$table/row-set/column-header">
-            <TH><xsl:value-of select="@column-label"/></TH>
-          </xsl:for-each>
-          </TR>
-          <xsl:apply-templates select="$table/row-set/row"/>
-          <xsl:text>&#10;</xsl:text>
-        </TABLE>
-      </BODY>
-    </HTML> 
-    <!-- 3. Close the connection -->
-    <xsl:value-of select="sql:close($accounts)"/>
-  </xsl:template>
-
-  <xsl:template match="row">
-        <TR>
-          <xsl:apply-templates select="col"/>
-        </TR>
-  </xsl:template>
-
-  <xsl:template match="col">
-    <TD>
-      <!-- Here is the column data -->
-      <xsl:value-of select="text()"/>
-    </TD>
-  </xsl:template>
-
-</xsl:stylesheet>
diff --git a/samples/SQLExtension/ext-connection/ExternalConnection.java b/samples/SQLExtension/ext-connection/ExternalConnection.java
deleted file mode 100644
index 41a108d..0000000
--- a/samples/SQLExtension/ext-connection/ExternalConnection.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "XSLT4J" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-// Imported TraX classes
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerConfigurationException;
-
-import org.apache.xalan.lib.sql.DefaultConnectionPool;
-import org.apache.xalan.lib.sql.XConnectionPoolManager;
-
-
-// Imported java classes
-import java.io.FileOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-/**
- *  Use the TraX interface to perform a transformation in the simplest manner possible
- *  (3 statements).
- */
-public class ExternalConnection
-{
-	public static void main(String[] args)
-    throws TransformerException, TransformerConfigurationException,
-           FileNotFoundException, IOException
-  {
-
-  // Create a connection to the database server
-  // Up the connection pool count for testing
-  DefaultConnectionPool cp = new DefaultConnectionPool();
-  cp.setDriver("com.sybase.jdbc2.jdbc.SybDriver");
-  cp.setURL("jdbc:sybase:Tds:localhost:5000/smart911");
-  cp.setUser("sa");
-  cp.setPassword("");
-  cp.setMinConnections(10);
-  cp.setActive(true);
-
-  // Now let's register our connection pool so we can use
-  // in a stylesheet
-  XConnectionPoolManager pm = new XConnectionPoolManager();
-  pm.registerPool("sybase", cp);
-
-
-  // Use the static TransformerFactory.newInstance() method to instantiate
-  // a TransformerFactory. The javax.xml.transform.TransformerFactory
-  // system property setting determines the actual class to instantiate --
-  // org.apache.xalan.transformer.TransformerImpl.
-	TransformerFactory tFactory = TransformerFactory.newInstance();
-
-	// Use the TransformerFactory to instantiate a Transformer that will work with
-	// the stylesheet you specify. This method call also processes the stylesheet
-  // into a compiled Templates object.
-	Transformer transformer = tFactory.newTransformer(
-        new StreamSource("dbtest.xsl"));
-
-	// Use the Transformer to apply the associated Templates object to an XML document
-	// (foo.xml) and write the output to a file (foo.out).
-	transformer.transform(
-        new StreamSource("dbtest.xml"),
-        new StreamResult(new FileOutputStream("dbtest.out")));
-
-	System.out.println("************* The result is in dbtest.out *************");
-  }
-}
\ No newline at end of file
diff --git a/samples/SQLExtension/ext-connection/dbtest.out b/samples/SQLExtension/ext-connection/dbtest.out
deleted file mode 100644
index 5614dca..0000000
--- a/samples/SQLExtension/ext-connection/dbtest.out
+++ /dev/null
@@ -1,19 +0,0 @@
-<HTML>
-<HEAD>
-<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
-</HEAD>
-<BODY>
-<TABLE border="1">
-<TR>
-<TH>FirstName</TH><TH>LastName</TH><TH>Street1</TH><TH>City</TH><TH>Zip</TH>
-</TR>
-<TR>
-<TD></TD><TD></TD><TD></TD><TD></TD><TD></TD>
-</TR>
-<TR>
-<TD>Lawrence                      </TD><TD>Friesen                                      </TD><TD>4010 Santa Rosa Ave                     </TD><TD>Tulare                        </TD><TD>92313</TD>
-</TR>
-
-</TABLE>
-</BODY>
-</HTML>
diff --git a/samples/SQLExtension/ext-connection/dbtest.xml b/samples/SQLExtension/ext-connection/dbtest.xml
deleted file mode 100644
index e57d25f..0000000
--- a/samples/SQLExtension/ext-connection/dbtest.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<dbtest>
- <description>This file contains information required to make a connection to the DBMS</description>
-
- <DBINFO>
-   <dbdriver>com.sybase.jdbc2.jdbc.SybDriver</dbdriver>
-   <dburl>jdbc:sybase:Tds:localhost:5000/smart911</dburl>
-   <user>sa</user>
-   <password/>
- </DBINFO>
- 
-
-</dbtest>
diff --git a/samples/SQLExtension/ext-connection/dbtest.xsl b/samples/SQLExtension/ext-connection/dbtest.xsl
deleted file mode 100644
index b8d7179..0000000
--- a/samples/SQLExtension/ext-connection/dbtest.xsl
+++ /dev/null
@@ -1,47 +0,0 @@
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                version="1.0"
-                xmlns:sql="org.apache.xalan.lib.sql.XConnection"
-                extension-element-prefixes="sql">
-  <xsl:output method="html" indent="yes"/>
-  <xsl:param name="query" select="&quot;SELECT FirstName, LastName, Street1, City, Zip  FROM Account where AcctID='2019990000'&quot;"/>
- 
-  <xsl:template match="/">
-    <!-- 1. Make the connection -->
-    <xsl:variable name="accounts"
-                  select="sql:new('sybase')"/>
-    <HTML>
-      <HEAD>
-      </HEAD>
-      <BODY>
-        <TABLE border="1">
-        <!--2. Execute the query -->
-        <xsl:variable name="table" select='sql:query($accounts, $query)'/>
-          <TR>
-          <!-- Get column-label attribute from each column-header-->
-          <xsl:for-each select="$table/row-set/column-header">
-            <TH><xsl:value-of select="@column-label"/></TH>
-          </xsl:for-each>
-          </TR>
-          <xsl:apply-templates select="$table/row-set/row"/>
-          <xsl:text>&#10;</xsl:text>
-        </TABLE>
-      </BODY>
-    </HTML> 
-    <!-- 3. Close the connection -->
-    <xsl:value-of select="sql:close($accounts)"/>
-  </xsl:template>
-
-  <xsl:template match="row">
-        <TR>
-          <xsl:apply-templates select="col"/>
-        </TR>
-  </xsl:template>
-
-  <xsl:template match="col">
-    <TD>
-      <!-- Here is the column data -->
-      <xsl:value-of select="text()"/>
-    </TD>
-  </xsl:template>
-
-</xsl:stylesheet>
diff --git a/samples/SQLExtension/pquery/dbinfo.xml b/samples/SQLExtension/pquery/dbinfo.xml
deleted file mode 100644
index 98d1c1a..0000000
--- a/samples/SQLExtension/pquery/dbinfo.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<XMLSTORE>
-
- <QUERY>
-   <ACCTID>2019990000</ACCTID>
- </QUERY>
-  
- <DBINFO>
-   <dbdriver>com.sybase.jdbc2.jdbc.SybDriver</dbdriver>
-   <dburl>jdbc:sybase:Tds:localhost:5000/smart911</dburl>
-   <user>sa</user>
-   <password/>
- </DBINFO>
-
-</XMLSTORE>
diff --git a/samples/SQLExtension/pquery/dbtest-pquery.xsl b/samples/SQLExtension/pquery/dbtest-pquery.xsl
deleted file mode 100644
index cac98dc..0000000
--- a/samples/SQLExtension/pquery/dbtest-pquery.xsl
+++ /dev/null
@@ -1,51 +0,0 @@
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                version="1.0"
-                xmlns:sql="/org.apache.xalan.lib.sql.XConnection"
-                extension-element-prefixes="sql">
-  <xsl:output method="html" indent="yes"/>
-  <xsl:param name="q1" select="&quot;SELECT FirstName, LastName, Street1, City, Zip  FROM Account where AcctID= ? &quot;"/>
-  <xsl:param name="q1type" select="string"/>
- 
-  <xsl:template match="/">
-    <!-- 1. Make the connection -->
-    <xsl:param name="cinfo" select="//DBINFO" />
-    <xsl:variable name="accounts"
-                  select='sql:new($cinfo)'/>
-    <HTML>
-      <HEAD>
-      </HEAD>
-      <BODY>
-        <TABLE border="1">
-        <!--2. Execute the query -->
-	<xsl:param name="q1param" select="//QUERY" />
-        <xsl:variable name="foo" select='sql:addParameterFromElement($accounts, $q1param)' />
-	<xsl:variable name="table" select='sql:pquery($accounts, $q1, $q1type)'/>
-          <TR>
-          <!-- Get column-label attribute from each column-header-->
-          <xsl:for-each select="$table/row-set/column-header">
-            <TH><xsl:value-of select="@column-label"/></TH>
-          </xsl:for-each>
-          </TR>
-          <xsl:apply-templates select="$table/row-set/row"/>
-          <xsl:text>&#10;</xsl:text>
-        </TABLE>
-      </BODY>
-    </HTML> 
-    <!-- 3. Close the connection -->
-    <xsl:value-of select="sql:close($accounts)"/>
-  </xsl:template>
-
-  <xsl:template match="row">
-        <TR>
-          <xsl:apply-templates select="col"/>
-        </TR>
-  </xsl:template>
-
-  <xsl:template match="col">
-    <TD>
-      <!-- Here is the column data -->
-      <xsl:value-of select="text()"/>
-    </TD>
-  </xsl:template>
-
-</xsl:stylesheet>
diff --git a/samples/SQLExtension/show-error/dbinfo.xml b/samples/SQLExtension/show-error/dbinfo.xml
deleted file mode 100644
index 8dc2dda..0000000
--- a/samples/SQLExtension/show-error/dbinfo.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<XMLSTORE>
-
- <USERPROFILE>
-  <USERNAME>gentijo</USERNAME>
-  <PASSWD>drowssap</PASSWD>
- </USERPROFILE>
-
- <QUERY>
-   <ACCTID>2019990000</ACCTID>
- </QUERY>
-  
- <DBINFO>
-   <dbdriver>com.sybase.jdbc2.jdbc.SybDriver</dbdriver>
-   <dburl>jdbc:sybase:Tds:localhost:5000/smart911</dburl>
-   <user>sa</user>
-   <password/>
- </DBINFO>
-
-</XMLSTORE>
diff --git a/samples/SQLExtension/show-error/dbtest.xsl b/samples/SQLExtension/show-error/dbtest.xsl
deleted file mode 100644
index 4813a08..0000000
--- a/samples/SQLExtension/show-error/dbtest.xsl
+++ /dev/null
@@ -1,65 +0,0 @@
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                version="1.0"
-                xmlns:sql="/org.apache.xalan.lib.sql.XConnection"
-                extension-element-prefixes="sql">
-  <xsl:output method="html" indent="yes"/>
-  <xsl:param name="query" select="&quot;SELEC FirstName, LastName, Street1, City, Zip  FROM Account where AcctID='2019990000'&quot;"/>
- 
-  <xsl:template match="/">
-    <!-- 1. Make the connection -->
-    <xsl:variable name="accounts"
-                  select="sql:new('com.sybase.jdbc2.jdbc.SybDriver',
-                                'jdbc:sybase:Tds:localhost:5000/smart911', 'sa',
-                               '')"/>
-    <!--2. Execute the query -->
-    <xsl:variable name="table" select='sql:query($accounts, $query)'/>
-                               
-    
-   	<xsl:apply-templates select="$table/row-set" />
- 		<xsl:apply-templates select="$table/ext-error" />
-    
-    <!-- 3. Close the connection -->
-    <xsl:value-of select="sql:close($accounts)"/>
-
-  </xsl:template>
-
-  <xsl:template match="row-set">
-    
-    <HTML>
-      <HEAD>
-      </HEAD>
-      <BODY>
-        <TABLE border="1">
-          <TR>
-          <!-- Get column-label attribute from each column-header-->
-          <xsl:for-each select="row-set/column-header">
-            <TH><xsl:value-of select="@column-label"/></TH>
-          </xsl:for-each>
-          </TR>
-          <xsl:apply-templates select="/row-set/row"/>
-          <xsl:text>&#10;</xsl:text>
-        </TABLE>
-      </BODY>
-    </HTML> 
-  </xsl:template>
-
-  <xsl:template match="row">
-        <TR>
-          <xsl:apply-templates select="col"/>
-        </TR>
-  </xsl:template>
-
-  <xsl:template match="col">
-    <TD>
-      <!-- Here is the column data -->
-      <xsl:value-of select="text()"/>
-    </TD>
-  </xsl:template>
-
-  <xsl:template match="//ext-error">
-    <xsl:text>Woops, an error occured: </xsl:text>
-  	<xsl:apply-templates />
-  </xsl:template>
-
-
-</xsl:stylesheet>
diff --git a/samples/SimpleTransform/SimpleTransform.java b/samples/SimpleTransform/SimpleTransform.java
deleted file mode 100644
index 0b46a25..0000000
--- a/samples/SimpleTransform/SimpleTransform.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "XSLT4J" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-// Imported TraX classes
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerConfigurationException;
-
-
-// Imported java classes
-import java.io.FileOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-/**
- *  Use the TraX interface to perform a transformation in the simplest manner possible
- *  (3 statements).
- */
-public class SimpleTransform
-{
-	public static void main(String[] args)
-    throws TransformerException, TransformerConfigurationException, 
-           FileNotFoundException, IOException
-  {  
-  // Use the static TransformerFactory.newInstance() method to instantiate 
-  // a TransformerFactory. The javax.xml.transform.TransformerFactory 
-  // system property setting determines the actual class to instantiate --
-  // org.apache.xalan.transformer.TransformerImpl.
-	TransformerFactory tFactory = TransformerFactory.newInstance();
-	
-	// Use the TransformerFactory to instantiate a Transformer that will work with  
-	// the stylesheet you specify. This method call also processes the stylesheet
-  // into a compiled Templates object.
-	Transformer transformer = tFactory.newTransformer(new StreamSource("birds.xsl"));
-
-	// Use the Transformer to apply the associated Templates object to an XML document
-	// (foo.xml) and write the output to a file (foo.out).
-	transformer.transform(new StreamSource("birds.xml"), new StreamResult(new FileOutputStream("birds.out")));
-	
-	System.out.println("************* The result is in birds.out *************");
-  }
-}
\ No newline at end of file
diff --git a/samples/SimpleTransform/birds.xml b/samples/SimpleTransform/birds.xml
deleted file mode 100644
index 7027642..0000000
--- a/samples/SimpleTransform/birds.xml
+++ /dev/null
@@ -1,136 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Class>
-<Order Name="TINAMIFORMES">
-        <Family Name="TINAMIDAE">
-            <Species Scientific_Name="Tinamus major">  Great Tinamou.</Species>
-            <Species Scientific_Name="Nothocercus">Highland Tinamou.</Species>
-            <Species Scientific_Name="Crypturellus soui">Little Tinamou.</Species>
-            <Species Scientific_Name="Crypturellus cinnamomeus">Thicket Tinamou.</Species>
-            <Species Scientific_Name="Crypturellus boucardi">Slaty-breasted Tinamou.</Species>
-            <Species Scientific_Name="Crypturellus kerriae">Choco Tinamou.</Species>
-        </Family>
-    </Order>
-<Order Name="GAVIIFORMES">
-        <Family Name="GAVIIDAE">
-            <Species Scientific_Name="Gavia stellata">Red-throated Loon.</Species>
-            <Species Scientific_Name="Gavia arctica">Arctic Loon.</Species>
-            <Species Scientific_Name="Gavia pacifica">Pacific Loon.</Species>
-            <Species Scientific_Name="Gavia immer">Common Loon.</Species>
-            <Species Scientific_Name="Gavia adamsii">Yellow-billed Loon.</Species>
-        </Family>
-    </Order>
-
-
-<Order Name="PODICIPEDIFORMES">
-        <Family Name="PODICIPEDIDAE">
-            <Species Scientific_Name="Tachybaptus dominicus">Least Grebe.</Species>
-            <Species Scientific_Name="Podilymbus podiceps">Pied-billed Grebe.</Species>
-            <Species Scientific_Name="">Atitlan Grebe.</Species>
-            <Species Scientific_Name="">Horned Grebe.</Species>
-            <Species Scientific_Name="">Red-necked Grebe.</Species>
-            <Species Scientific_Name="">Eared Grebe.</Species>
-            <Species Scientific_Name="">Western Grebe.</Species>
-            <Species Scientific_Name="">Clark's Grebe.</Species>
-            <Species Scientific_Name=""/>
-        </Family>
-    </Order>
-
-
-<Order Name="PROCELLARIIFORMES">
-        <Family Name="DIOMEDEIDAE">
-            <Species Scientific_Name="Thalassarche chlororhynchos">Yellow-nosed Albatross. (A)</Species>
-            <Species Scientific_Name="Thalassarche cauta">Shy Albatross. (A)</Species>
-            <Species Scientific_Name="Thalassarche melanophris">Black-browed Albatross. (A)</Species>
-            <Species Scientific_Name="Phoebetria palpebrata">Light-mantled Albatross. (A)</Species>
-            <Species Scientific_Name="Diomedea exulans">Wandering Albatross. (A)</Species>
-            <Species Scientific_Name="Phoebastria immutabilis">Laysan Albatross.</Species>
-            <Species Scientific_Name="Phoebastria nigripes">Black-footed Albatross.</Species>
-            <Species Scientific_Name="Phoebastria albatrus">Short-tailed Albatross. (N)</Species>
-        </Family>
-        <Family Name="PROCELLARIIDAE">
-            <Species Scientific_Name="Fulmarus glacialis">Northern Fulmar.</Species>
-            <Species Scientific_Name="Pterodroma neglecta">Kermadec Petrel. (A)</Species>
-            <Species Scientific_Name="Pterodroma arminjoniana">Herald Petrel. (A)</Species>
-            <Species Scientific_Name="Pterodroma ultima">Murphy's Petrel. (N)</Species>
-            <Species Scientific_Name="Pterodroma inexpectata">Mottled Petrel. (A)</Species>
-            <Species Scientific_Name="Pterodroma cahow">Bermuda Petrel.</Species>
-            <Species Scientific_Name="Pterodroma hasitata">Black-capped Petrel.</Species>
-            <Species Scientific_Name="Pterodroma externa">Juan Fernandez Petrel. (N)</Species>
-            <Species Scientific_Name="Pterodroma phaeopygia">Dark-rumped Petrel.</Species>
-            <Species Scientific_Name="Pterodroma cervicalis">White-necked Petrel. (H)</Species>
-            <Species Scientific_Name="Pterodroma hypoleuca">Bonin Petrel. (H)</Species>
-            <Species Scientific_Name="Pterodroma nigripennis">Black-winged Petrel. (H, A)</Species>
-            <Species Scientific_Name="Pterodroma cookii">Cook's Petrel. (N)</Species>
-            <Species Scientific_Name="Pterodroma longirostris">Stejneger's Petrel. (A)</Species>
-            <Species Scientific_Name="Bulweria bulwerii">Bulwer's Petrel. (H)</Species>
-            <Species Scientific_Name="Bulweria fallax">Jouanin's Petrel. (H, A)</Species>
-            <Species Scientific_Name="Procellaria parkinsoni">Parkinson's Petrel. (N)</Species>
-            <Species Scientific_Name="Calonectris leucomelas">Streaked Shearwater. (A)</Species>
-            <Species Scientific_Name="Calonectris diomedea">Cory's Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus creatopus">Pink-footed Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus carneipes">Flesh-footed Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus gravis">Greater Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus pacificus">Wedge-tailed Shearwater.</Species>
-            <Species Scientific_Name="Puffinus bulleri">Buller's Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus griseus">Sooty Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus tenuirostris">Short-tailed Shearwater. (N)</Species>
-            <Species Scientific_Name="Puffinus nativitatis">Christmas Shearwater. (H)</Species>
-            <Species Scientific_Name="Puffinus puffinus">Manx Shearwater.</Species>
-            <Species Scientific_Name="Puffinus auricularis">Townsend's Shearwater.</Species>
-            <Species Scientific_Name="Puffinus opisthomelas">Black-vented Shearwater.</Species>
-            <Species Scientific_Name="Puffinus lherminieri">Audubon's Shearwater.</Species>
-            <Species Scientific_Name="Puffinus assimilis">Little Shearwater. (A)</Species>
-        </Family>
-        <Family Name="HYDROBATIDAE">
-            <Species Scientific_Name="Oceanites oceanicus">Wilson's Storm-Petrel. (N)</Species>
-            <Species Scientific_Name="Pelagodroma marina">White-faced Storm-Petrel. (A)</Species>
-            <Species Scientific_Name="Hydrobates pelagicus">European Storm-Petrel. (A)</Species>
-            <Species Scientific_Name="Oceanodroma furcata">Fork-tailed Storm-Petrel.</Species>
-            <Species Scientific_Name="Oceanodroma leucorhoa">Leach's Storm-Petrel.</Species>
-            <Species Scientific_Name="Oceanodroma homochroa">Ashy Storm-Petrel.</Species>
-            <Species Scientific_Name="Oceanodroma castro">Band-rumped Storm-Petrel. (N)</Species>
-            <Species Scientific_Name="Oceanodroma tethys">Wedge-rumped Storm-Petrel. (N)</Species>
-            <Species Scientific_Name="Oceanodroma melania">Black Storm-Petrel.</Species>
-            <Species Scientific_Name="Oceanodroma macrodactyla">Guadalupe Storm-Petrel.</Species>
-            <Species Scientific_Name="Oceanodroma markhami">Markham's Storm-Petrel. (A)</Species>
-            <Species Scientific_Name="Oceanodroma tristrami">Tristram's Storm-Petrel. (H)</Species>
-            <Species Scientific_Name="Oceanodroma microsoma">Least Storm-Petrel.</Species>
-        </Family>
-    </Order>
-
-<Order Name="PELECANIFORMES">
-        <Family Name="PHAETHONTIDAE">
-            <Species Scientific_Name="Phaethon lepturus">White-tailed Tropicbird.</Species>
-            <Species Scientific_Name="Phaethon aethereus">Red-billed Tropicbird.</Species>
-            <Species Scientific_Name="Phaethon rubricauda">Red-tailed Tropicbird.</Species>
-        </Family>
-        <Family Name="SULIDAE">
-            <Species Scientific_Name="Sula dactylatra">Masked Booby.</Species>
-            <Species Scientific_Name="Sula nebouxii">Blue-footed Booby.</Species>
-            <Species Scientific_Name="Sula variegata">Peruvian Booby. (A)</Species>
-            <Species Scientific_Name="Sula leucogaster">Brown Booby.</Species>
-            <Species Scientific_Name="Sula sula">Red-footed Booby.</Species>
-            <Species Scientific_Name="Morus bassanus">Northern Gannet.</Species>
-        </Family>
-        <Family Name="PELECANIDAE">
-            <Species Scientific_Name="Pelecanus erythrorhynchos">American White Pelican.</Species>
-            <Species Scientific_Name="Pelecanus occidentalis">Brown Pelican.</Species>
-        </Family>
-        <Family Name="PHALACROCORACIDAE">
-            <Species Scientific_Name="Phalacrocorax penicillatus">Brandt's Cormorant.</Species>
-            <Species Scientific_Name="Phalacrocorax brasilianus">Neotropic Cormorant.</Species>
-            <Species Scientific_Name="Phalacrocorax auritus">Double-crested Cormorant.</Species>
-            <Species Scientific_Name="Phalacrocorax carbo">Great Cormorant.</Species>
-            <Species Scientific_Name="Phalacrocorax urile">Red-faced Cormorant.</Species>
-            <Species Scientific_Name="Phalacrocorax pelagicus">Pelagic Cormorant.</Species>
-        </Family>
-        <Family Name="ANHINGIDAE">
-            <Species Scientific_Name="Anhinga anhinga">Anhinga.</Species>
-        </Family>
-        <Family Name="FREGATIDAE">
-            <Species Scientific_Name="Fregata magnificens">Magnificent Frigatebird.</Species>
-            <Species Scientific_Name="Fregata minor">Great Frigatebird.</Species>
-            <Species Scientific_Name="Fregata ariel">Lesser Frigatebird. (A)</Species>
-        </Family>
-    </Order>
-</Class>
diff --git a/samples/SimpleTransform/birds.xsl b/samples/SimpleTransform/birds.xsl
deleted file mode 100644
index 4d6f8e1..0000000
--- a/samples/SimpleTransform/birds.xsl
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:output method="xml" indent="yes"/>
-
-<xsl:template match="Class">
-<BirdInfo>
-	<xsl:apply-templates select="Order"/>
-</BirdInfo>
-</xsl:template>
-
-<xsl:template match="Order">
-Order is:  <xsl:value-of select="@Name"/>
-	<xsl:apply-templates select="Family"/><xsl:text>
-</xsl:text>
-</xsl:template>
-
-<xsl:template match="Family">
-	Family is:  <xsl:value-of select="@Name"/>
-	<xsl:apply-templates select="Species | SubFamily | text()"/>
-</xsl:template>
-
-<xsl:template match="SubFamily">
-		SubFamily is <xsl:value-of select="@Name"/>
-    <xsl:apply-templates select="Species | text()"/>
-</xsl:template>
-
-<xsl:template match="Species">
-	<xsl:choose>
-	  <xsl:when test="name(..)='SubFamily'">
-		<xsl:text>	</xsl:text><xsl:value-of select="."/><xsl:text> </xsl:text><xsl:value-of select="@Scientific_Name"/>
-	  </xsl:when>
-	  <xsl:otherwise>
-		<xsl:value-of select="."/><xsl:text> </xsl:text><xsl:value-of select="@Scientific_Name"/>
-	  </xsl:otherwise>
-	</xsl:choose>
-</xsl:template>
-
-</xsl:stylesheet>
diff --git a/samples/SimpleTransform/foo.xml b/samples/SimpleTransform/foo.xml
deleted file mode 100644
index da9f79b..0000000
--- a/samples/SimpleTransform/foo.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0"?>
-<doc>Hello</doc>
\ No newline at end of file
diff --git a/samples/SimpleTransform/foo.xsl b/samples/SimpleTransform/foo.xsl
deleted file mode 100644
index 5da8d5e..0000000
--- a/samples/SimpleTransform/foo.xsl
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:template match="doc">
-    <out><xsl:value-of select="."/></out>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/samples/SimpleTransform/readme.html b/samples/SimpleTransform/readme.html
deleted file mode 100644
index ec8936f..0000000
--- a/samples/SimpleTransform/readme.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
-	<title>Xalan Samples</title>
-</head>
-<body>
-<h2>Xalan Samples</h2>
-<p>For information about the samples (what they illustrate and how to run them), see <a href="../../docs/samples.html">Samples</a>.</p>
-
-
-</body>
-</html>
diff --git a/samples/Trace/Trace.java b/samples/Trace/Trace.java
deleted file mode 100644
index d059e4b..0000000
--- a/samples/Trace/Trace.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.stream.StreamResult;
-import org.apache.xalan.transformer.TransformerImpl;
-import org.apache.xalan.trace.TraceManager;
-import org.apache.xalan.trace.PrintTraceListener;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerConfigurationException;
-
-public class Trace
-{	
-  public static void main (String[] args)
-	  throws java.io.IOException, 
-			 TransformerException, TransformerConfigurationException,
-			 java.util.TooManyListenersException, 
-			 org.xml.sax.SAXException			 
-  {
-    // Set up a PrintTraceListener object to print to a file.
-    java.io.FileWriter fw = new java.io.FileWriter("events.log");  
-    java.io.PrintWriter pw = new java.io.PrintWriter(fw, true);
-    PrintTraceListener ptl = new PrintTraceListener(pw);
-
-    // Print information as each node is 'executed' in the stylesheet.
-    ptl.m_traceElements = true;
-    // Print information after each result-tree generation event.
-    ptl.m_traceGeneration = true;
-    // Print information after each selection event.
-    ptl.m_traceSelection = true;
-    // Print information whenever a template is invoked.
-    ptl.m_traceTemplates = true;
-
-    // Set up the transformation    
-   	TransformerFactory tFactory = TransformerFactory.newInstance();
-    Transformer transformer = tFactory.newTransformer(new StreamSource("foo.xsl"));
-
-    // Cast the Transformer object to TransformerImpl.
-    if (transformer instanceof TransformerImpl) 
-	  {
-      TransformerImpl transformerImpl = (TransformerImpl)transformer;
-      // Register the TraceListener with a TraceManager associated 
-      // with the TransformerImpl.
-      TraceManager trMgr = transformerImpl.getTraceManager();
-      trMgr.addTraceListener(ptl);
-                     
-      // Perform the transformation --printing information to
-      // the events log during the process.
-      transformer.transform
-                         ( new StreamSource("foo.xml"), 
-                           new StreamResult(new java.io.FileWriter("foo.out")) );
-    }
-    // Close the PrintWriter and FileWriter.
-    pw.close();
-    fw.close();
-   	System.out.println("**The output is in foo.out; the log is in events.log ****");	
-    
-  }
-}
\ No newline at end of file
diff --git a/samples/Trace/foo.xml b/samples/Trace/foo.xml
deleted file mode 100644
index 5e72e15..0000000
--- a/samples/Trace/foo.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<upload>
-  <day>
-    <dow>tue</dow>
-    <order>
-      <line>
-         <product>Belt</product>
-         <price>5.54</price>
-      </line>
-    </order>
-  </day>
-  <day>
-    <dow>wed</dow>
-  </day>
-  <day>
-    <dow>thu</dow>
-    <order>
-      <line>
-         <product>Boots</product>
-         <price>9.23</price>
-      </line>
-    </order>
-  </day>
-  <day>
-    <dow>fri</dow>
-    <order>
-    </order>
-    <order>
-    </order>
-  </day>
-  <day>
-    <dow>sat</dow>
-    <order>
-      <line>
-         <product>Jacket</product>
-         <price>9.84</price>
-      </line>
-    </order>
-  </day>
-  <day>
-    <dow>mon</dow>
-    <order>
-    </order>
-    <order>
-      <line>
-         <product>Tie</product>
-         <price>5.37</price>
-      </line>
-    </order>
-  </day>
-  <day>
-    <dow>tue</dow>
-  </day>
-  <day>
-    <dow>wed</dow>
-    <order>
-    </order>
-  </day>
-  <day>
-    <dow>thu</dow>
-    <order>
-      <line>
-         <product>Overalls</product>
-         <price>3.16</price>
-      </line>
-    </order>
-  </day>
-</upload>
diff --git a/samples/Trace/foo.xsl b/samples/Trace/foo.xsl
deleted file mode 100644
index 2775ee7..0000000
--- a/samples/Trace/foo.xsl
+++ /dev/null
@@ -1,69 +0,0 @@
-<xsl:stylesheet
-  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
-  xmlns="http://www.w3.org/TR/REC-html40">
-
-  <!-- FileName: misc-evans -->
-  <!-- Document: http://www.w3.org/TR/xslt -->
-  <!-- DocVersion: 19991116 -->
-  <!-- Purpose: COPY of perf test;"A Practical Suggestion for XSLT Performance Improvement" by Clark Evans. -->
-
-   <xsl:variable name="day-list" 
-     select="//dow[not(.=following::dow)]" />
-
-   <xsl:variable name="product-list" 
-            select="//product[not(.=following::product)]" />
-     
-<xsl:template match="/">
-  <xsl:variable name="my-test"><a><b/></a></xsl:variable>
-  <html>
-    <xsl:copy-of select="$my-test"/>
-    <body>
-    <table>
-      <tr>
-        <td><xsl:text> </xsl:text></td>
-        <xsl:for-each select="$day-list">
-          <xsl:sort order="ascending" select="." />
-          <th><xsl:value-of select="."/></th>
-        </xsl:for-each>
-      </tr>
-      <xsl:for-each select="$product-list">
-        <xsl:sort    order="ascending" select="." />
-        <xsl:variable name="product" select="." />
-        <tr>
-          <td>
-            <xsl:value-of select="$product" />
-          </td>
-          <xsl:for-each select="$day-list">
-            <xsl:sort order="ascending" select="." />
-            <xsl:variable name="day" select="." />
-            <td>
-              <xsl:value-of 
-             select="sum(//price[../product=$product][../../../dow=$day])"
-/> .
-            </td>
-          </xsl:for-each>
-          <td>
-            <xsl:value-of 
-              select="sum(//price[../product=$product])" /> .
-           </td>
-        </tr>
-      </xsl:for-each>
-      <tr>
-        <td><xsl:text> </xsl:text></td>
-        <xsl:for-each select="$day-list">
-          <xsl:sort    order="ascending" select="." />
-          <xsl:variable name="day" select="." />
-          <td>
-            <xsl:value-of 
-              select="sum(//price[../../../dow=$day])" />
-          </td>
-        </xsl:for-each>
-        <td>
-          <xsl:value-of select="sum(//price)" />
-        </td>
-      </tr>
-    </table>
-    </body>
-  </html>
-</xsl:template>
-</xsl:stylesheet>
diff --git a/samples/UseStylesheetPI/UseStylesheetPI.java b/samples/UseStylesheetPI/UseStylesheetPI.java
deleted file mode 100644
index aa0c714..0000000
--- a/samples/UseStylesheetPI/UseStylesheetPI.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-// Imported TraX classes
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerConfigurationException;
-
-// Imported java.io classes
-import java.io.FileOutputStream;
-import java.io.IOException;	
-
-public class UseStylesheetPI
-{
-  public static void main(String[] args)
-	  throws TransformerException, TransformerConfigurationException
-	{
-	  String media= null , title = null, charset = null;
-	  try
-	  {	
-    	TransformerFactory tFactory = TransformerFactory.newInstance();
-      Source stylesheet = tFactory.getAssociatedStylesheet
-        (new StreamSource("fooX.xml"),media, title, charset);
-      
-      Transformer transformer = tFactory.newTransformer(stylesheet);
-        
-		   transformer.transform(new StreamSource("fooX.xml"), 
-                             new StreamResult(new java.io.FileOutputStream("foo.out")));
-       
-      System.out.println("************* The result is in foo.out *************");
-       
-	  }
-  	  catch (Exception e)
-	  {
-	    e.printStackTrace();
-	  }
-  }
-}
diff --git a/samples/UseStylesheetPI/foo.xsl b/samples/UseStylesheetPI/foo.xsl
deleted file mode 100644
index 5da8d5e..0000000
--- a/samples/UseStylesheetPI/foo.xsl
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:template match="doc">
-    <out><xsl:value-of select="."/></out>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/samples/UseStylesheetPI/fooX.xml b/samples/UseStylesheetPI/fooX.xml
deleted file mode 100644
index cd4b743..0000000
--- a/samples/UseStylesheetPI/fooX.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type="text/xsl" href="foo.xsl"?>
-<doc>Hello</doc>
\ No newline at end of file
diff --git a/samples/UseStylesheetParam/UseStylesheetParam.java b/samples/UseStylesheetParam/UseStylesheetParam.java
deleted file mode 100644
index a8b3c91..0000000
--- a/samples/UseStylesheetParam/UseStylesheetParam.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "XSLT4J" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-// Imported TraX classes
-// Imported TraX classes
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerConfigurationException;
-
-// Imported SAX classes
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-// Imported java classes
-import java.io.IOException;
-
-  /**
-   * Use command-line input as a stylesheet parameter.
-   */
-
-public class UseStylesheetParam
-{
-  public static void main(String[] args)
-	throws TransformerException, TransformerConfigurationException, 
-         SAXException, IOException	   
-	{
-    if(args.length != 1)
-    {
-      System.err.println("Please pass one string to this program");
-      return;
-    }
-  	// Get the parameter value from the command line.
-    String paramValue = args[0];
-	
-   	TransformerFactory tFactory = TransformerFactory.newInstance();
-    Transformer transformer = tFactory.newTransformer(new StreamSource("foo.xsl"));
-
-	// Set the parameter. I can't get non-null namespaces to work!!
-    transformer.setParameter("param1",	/* parameter name */
-               							 paramValue /* parameter value */ );
-    
-    transformer.transform(new StreamSource("foo.xml"), new StreamResult(System.out));
-  }   
-}
\ No newline at end of file
diff --git a/samples/UseStylesheetParam/foo.xml b/samples/UseStylesheetParam/foo.xml
deleted file mode 100644
index 03c32b5..0000000
--- a/samples/UseStylesheetParam/foo.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0"?>
-<doc>Hello</doc>
diff --git a/samples/UseStylesheetParam/foo.xsl b/samples/UseStylesheetParam/foo.xsl
deleted file mode 100644
index 5ee19dc..0000000
--- a/samples/UseStylesheetParam/foo.xsl
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:param name="param1" select="'default value'"/>
-  <xsl:template match="doc">
-    <out><xsl:value-of select="$param1"/></out>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/samples/UseStylesheetParam/readme.html b/samples/UseStylesheetParam/readme.html
deleted file mode 100644
index ec8936f..0000000
--- a/samples/UseStylesheetParam/readme.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
-	<title>Xalan Samples</title>
-</head>
-<body>
-<h2>Xalan Samples</h2>
-<p>For information about the samples (what they illustrate and how to run them), see <a href="../../docs/samples.html">Samples</a>.</p>
-
-
-</body>
-</html>
diff --git a/samples/UseXMLFilters/UseXMLFilters.java b/samples/UseXMLFilters/UseXMLFilters.java
deleted file mode 100644
index 2fe78fd..0000000
--- a/samples/UseXMLFilters/UseXMLFilters.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-// Imported TraX classes
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.Templates;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.Result;
-import javax.xml.transform.sax.SAXResult;
-import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TemplatesHandler;
-import javax.xml.transform.sax.TransformerHandler;              
-
-// Imported SAX classes
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.Parser;
-import org.xml.sax.helpers.ParserAdapter;
-import org.xml.sax.helpers.XMLReaderFactory;
-import org.xml.sax.XMLReader;
-import org.xml.sax.XMLFilter;
-import org.xml.sax.ContentHandler;
-
-// Imported DOM classes
-import org.w3c.dom.Node;
-
-// Imported Serializer classes
-import org.apache.xalan.serialize.Serializer;
-import org.apache.xalan.serialize.SerializerFactory;
-import org.apache.xalan.templates.OutputProperties;
-
-// Imported JAVA API for XML Parsing classes
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException; 
-
-// Imported java.io classes
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.IOException;
-
-  /**
-   * This example shows how to chain a series of transformations by
-   * piping SAX events from one Transformer to another. Each Transformer
-   * operates as a SAX2 XMLFilter/XMLReader.
-   */
-public class UseXMLFilters
-{
-  public static void main(String[] args)
-	throws TransformerException, TransformerConfigurationException, 
-         SAXException, IOException	   
-	{
-    // Instantiate  a TransformerFactory.
-  	TransformerFactory tFactory = TransformerFactory.newInstance();
-    // Determine whether the TransformerFactory supports The use uf SAXSource 
-    // and SAXResult
-    if (tFactory.getFeature(SAXSource.FEATURE) && tFactory.getFeature(SAXResult.FEATURE))
-    { 
-      // Cast the TransformerFactory to SAXTransformerFactory.
-      SAXTransformerFactory saxTFactory = ((SAXTransformerFactory) tFactory);
-  	  // Create an XMLFilter for each stylesheet.
-      XMLFilter xmlFilter1 = saxTFactory.newXMLFilter(new StreamSource("foo1.xsl"));
-      XMLFilter xmlFilter2 = saxTFactory.newXMLFilter(new StreamSource("foo2.xsl"));
-      XMLFilter xmlFilter3 = saxTFactory.newXMLFilter(new StreamSource("foo3.xsl"));
-    
-      // Create an XMLReader.
-	    XMLReader reader = XMLReaderFactory.createXMLReader();
-    
-      // xmlFilter1 uses the XMLReader as its reader.
-      xmlFilter1.setParent(reader);
-    
-      // xmlFilter2 uses xmlFilter1 as its reader.
-      xmlFilter2.setParent(xmlFilter1);
-    
-      // xmlFilter3 uses xmlFilter2 as its reader.
-      xmlFilter3.setParent(xmlFilter2);
-    
-      // xmlFilter3 outputs SAX events to the serializer.
-      Serializer serializer = SerializerFactory.getSerializer
-                                   (OutputProperties.getDefaultMethodProperties("xml"));        
-      serializer.setOutputStream(System.out);
-      xmlFilter3.setContentHandler(serializer.asContentHandler());
-
-  	  // Perform the series of transformations as follows:
-	    //   - transformer3 gets its parent (transformer2) as the XMLReader/XMLFilter
-	    //     and calls transformer2.parse(new InputSource("foo.xml")).
-      //   - transformer2 gets its parent (transformer1) as the XMLReader/XMLFilter
-	    //     and calls transformer1.parse(new InputSource("foo.xml")). 
-      //   - transformer1 gets its parent (reader, a SAXParser) as the XMLReader 
-      //     and calls reader.parse(new InputSource("foo.xml")).
-	    //   - reader parses the XML document and sends the SAX parse events to transformer1, 
-	    //     which performs transformation 1 and sends the output to transformer2.
-  	  //   - transformer2 parses the transformation 1 output, performs transformation 2, and 
-	    //     sends the output to transformer3.
-	    //   - transformer3 parses the transformation 2 output, performs transformation 3,
-  	  //     and sends the output to the serializer.
-      xmlFilter3.parse(new InputSource("foo.xml"));
-    }
-  }
-}
\ No newline at end of file
diff --git a/samples/UseXMLFilters/foo.xml b/samples/UseXMLFilters/foo.xml
deleted file mode 100644
index da9f79b..0000000
--- a/samples/UseXMLFilters/foo.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0"?>
-<doc>Hello</doc>
\ No newline at end of file
diff --git a/samples/UseXMLFilters/foo1.xsl b/samples/UseXMLFilters/foo1.xsl
deleted file mode 100644
index 5da8d5e..0000000
--- a/samples/UseXMLFilters/foo1.xsl
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:template match="doc">
-    <out><xsl:value-of select="."/></out>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/samples/UseXMLFilters/foo2.xsl b/samples/UseXMLFilters/foo2.xsl
deleted file mode 100644
index 67cd197..0000000
--- a/samples/UseXMLFilters/foo2.xsl
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:template match="out">
-    <out><xsl:value-of select="."/> ...good to see you again!</out>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/samples/UseXMLFilters/foo3.xsl b/samples/UseXMLFilters/foo3.xsl
deleted file mode 100644
index 83cfaa6..0000000
--- a/samples/UseXMLFilters/foo3.xsl
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:template match="out">
-    <out><xsl:value-of select="."/> ...and goodby!</out>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/samples/UseXMLFilters/readme.html b/samples/UseXMLFilters/readme.html
deleted file mode 100644
index ec8936f..0000000
--- a/samples/UseXMLFilters/readme.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
-	<title>Xalan Samples</title>
-</head>
-<body>
-<h2>Xalan Samples</h2>
-<p>For information about the samples (what they illustrate and how to run them), see <a href="../../docs/samples.html">Samples</a>.</p>
-
-
-</body>
-</html>
diff --git a/samples/extensions/1-redir.xml b/samples/extensions/1-redir.xml
deleted file mode 100644
index e99f05a..0000000
--- a/samples/extensions/1-redir.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0"?> 
-<doc>
-  <foo file="1-redir.out">
-    Testing Redirect extension:
-    <bar>A foo subelement text node</bar>
-  </foo>
-  <main>
-    Everything else
-  </main>  
-</doc>
diff --git a/samples/extensions/1-redir.xsl b/samples/extensions/1-redir.xsl
deleted file mode 100644
index b3e69c2..0000000
--- a/samples/extensions/1-redir.xsl
+++ /dev/null
@@ -1,43 +0,0 @@
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-    version="1.0"
-    xmlns:lxslt="http://xml.apache.org/xslt"
-    xmlns:redirect="org.apache.xalan.lib.Redirect"
-    extension-element-prefixes="redirect">
-
-  <lxslt:component prefix="redirect" elements="write open close" functions="">
-    <lxslt:script lang="javaclass" src="org.apache.xalan.lib.Redirect"/>
-  </lxslt:component>  
-    
-  <xsl:template match="/">
-    <standard-out>
-      Standard output:
-      <xsl:apply-templates/>
-    </standard-out>
-  </xsl:template>
-
-  <!-- not redirected -->
-  <xsl:template match="doc/main">
-    <main>
-    -- look in <xsl:value-of select="/doc/foo/@file"/> for the redirected output --
-      <xsl:apply-templates/>
-    </main>
-  </xsl:template>
-  
-  <!-- redirected -->
-  <xsl:template match="doc/foo">
-    <!-- get redirect file name from XML input -->
-    <redirect:write select="@file">
-      <foo-out>
-        <xsl:apply-templates/>
-      </foo-out>
-    </redirect:write>
-  </xsl:template>
-  
-<!-- redirected (from the xsl:apply-templates above. I.e., bar is in /doc/foo -->  
-  <xsl:template match="bar">
-    <foobar-out>
-      <xsl:apply-templates/>
-    </foobar-out>
-  </xsl:template>
-  
-</xsl:stylesheet>
diff --git a/samples/extensions/2-basicJscript.xml b/samples/extensions/2-basicJscript.xml
deleted file mode 100644
index 9c66ca1..0000000
--- a/samples/extensions/2-basicJscript.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0"?>
-<doc>
-  <deadline numdays="2"/>
-</doc>  
- 
\ No newline at end of file
diff --git a/samples/extensions/2-basicJscript.xsl b/samples/extensions/2-basicJscript.xsl
deleted file mode 100644
index a219cf7..0000000
--- a/samples/extensions/2-basicJscript.xsl
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0"?>
-<!--Namespaces are global if you set them in the stylesheet element-->
-<xsl:stylesheet 
-    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
-    version="1.0"   
-    xmlns:lxslt="http://xml.apache.org/xslt"
-    xmlns:my-ext="ext2"
-    extension-element-prefixes="my-ext">
-    
-  <!--The component and its script are in the lxslt namespace and define the implementation-->
-  <lxslt:component prefix="my-ext" elements="timelapse" functions="getdate">
-    <lxslt:script lang="javascript">
-      var multiplier=1;
-      // Extension element implementations always take two arguments. The first
-      // argument is the XSL Processor context; the second argument is the element.
-      function timelapse(xslProcessorContext, elem)
-      {
-        multiplier=parseInt(elem.getAttribute("multiplier"));
-        // The element return value is placed in the result tree.
-        // If you do not want a return value, return null.
-        return null;
-      }
-      function getdate(numdays)
-      {
-        var d = new Date();
-        d.setDate(d.getDate() + parseInt(numdays*multiplier));
-        return d.toLocaleString();
-      }
-    </lxslt:script>
-  </lxslt:component>
-      
-  <xsl:template match="deadline">
-    <p><my-ext:timelapse multiplier="2"/>We have received your enquiry and will 
-      respond by <xsl:value-of select="my-ext:getdate(string(@numdays))"/></p>
-  </xsl:template>
-
-</xsl:stylesheet>
\ No newline at end of file
diff --git a/samples/extensions/3-java-namespace.xml b/samples/extensions/3-java-namespace.xml
deleted file mode 100644
index 6f2eb44..0000000
--- a/samples/extensions/3-java-namespace.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?> 
-<doc>
-   <date
-    year="2001" month="5" day="27"
-    format="EEEE, MMM dd, yyyy"/>
-</doc>
\ No newline at end of file
diff --git a/samples/extensions/3-java-namespace.xsl b/samples/extensions/3-java-namespace.xsl
deleted file mode 100644
index 45b6e59..0000000
--- a/samples/extensions/3-java-namespace.xsl
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                xmlns:java="http://xml.apache.org/xslt/java"
-                version="1.0">
-                
-  <xsl:template match="/">
-    <xsl:apply-templates select="/doc/date"/> 
-  </xsl:template>
- 
-  <xsl:template match="date">
-    <xsl:variable name="year" select="string(@year)"/>
-    <xsl:variable name="month" select="string(@month)"/> 
-    <xsl:variable name="day" select="string(@day)"/>          
-    <xsl:variable name="format" select="string(@format)"/>
-    <xsl:variable name="formatter"       
-         select="java:java.text.SimpleDateFormat.new($format)"/>
-    <xsl:variable name="date" 
-         select="java:IntDate.getDate($year,$month,$day)"/>
-    <p>Date: <xsl:value-of select="java:format($formatter, $date)"/></p>
-  </xsl:template>
- 
-</xsl:stylesheet>
diff --git a/samples/extensions/4-numlistJava.xsl b/samples/extensions/4-numlistJava.xsl
deleted file mode 100644
index bff9924..0000000
--- a/samples/extensions/4-numlistJava.xsl
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                xmlns:lxslt="http://xml.apache.org/xslt"
-                xmlns:counter="MyCounter"
-                extension-element-prefixes="counter"
-                version="1.0">
-
-
-  <lxslt:component prefix="counter"
-                   elements="init incr" functions="read">
-    <lxslt:script lang="javaclass" src="MyCounter"/>
-  </lxslt:component>
-
-  <xsl:template match="/">
-    <HTML>
-      <H1>Java Example</H1>
-      <counter:init name="index" value="1"/>
-      <p>Here are the names in alphabetical order by last name:</p>
-      <xsl:for-each select="doc/name">
-        <xsl:sort select="@last"/>
-        <xsl:sort select="@first"/>
-        <p>
-        <xsl:text>[</xsl:text>
-        <xsl:value-of select="counter:read('index')"/>
-        <xsl:text>]. </xsl:text>
-        <xsl:value-of select="@last"/>
-        <xsl:text>, </xsl:text>
-        <xsl:value-of select="@first"/>
-        </p>
-        <counter:incr name="index"/>
-      </xsl:for-each>
-    </HTML>
-  </xsl:template>
- 
-</xsl:stylesheet>
diff --git a/samples/extensions/5-numlistJscript.xsl b/samples/extensions/5-numlistJscript.xsl
deleted file mode 100644
index 0f351cb..0000000
--- a/samples/extensions/5-numlistJscript.xsl
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                xmlns:lxslt="http://xml.apache.org/xslt"
-                xmlns:counter="MyCounter"
-                extension-element-prefixes="counter"
-                version="1.0">
-
-  <lxslt:component prefix="counter"
-                   elements="init incr" functions="read">
-    <lxslt:script lang="javascript">
-      var counters = new Array();
-
-      function init (xslproc, elem) {
-        name = elem.getAttribute ("name");
-        value = parseInt(elem.getAttribute ("value"));
-        counters[name] = value;
-        return null;
-      }
-
-      function read (name) {
-        return "" + (counters[name]);
-      }
-
-      function incr (xslproc, elem)
-      {
-        name = elem.getAttribute ("name");
-        counters[name]++;
-        return null;
-      }
-    </lxslt:script>
-  </lxslt:component>
-
-  <xsl:template match="/">
-    <HTML>
-      <H1>JavaScript Example.</H1>
-      <counter:init name="index" value="1"/>
-      <p>Here are the names in alphabetical order by last name:</p>
-      <xsl:for-each select="doc/name">
-        <xsl:sort select="@last"/>
-        <xsl:sort select="@first"/>
-        <p>
-        <xsl:text>[</xsl:text>
-        <xsl:value-of select="counter:read('index')"/>
-        <xsl:text>]. </xsl:text>
-        <xsl:value-of select="@last"/>
-        <xsl:text>, </xsl:text>
-        <xsl:value-of select="@first"/>
-        </p>
-        <counter:incr name="index"/>
-      </xsl:for-each>
-    </HTML>
-  </xsl:template>
- 
-</xsl:stylesheet>
diff --git a/samples/extensions/6-sqllib-instantdb.xsl b/samples/extensions/6-sqllib-instantdb.xsl
deleted file mode 100644
index 7e5359d..0000000
--- a/samples/extensions/6-sqllib-instantdb.xsl
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                version="1.0"
-                xmlns:sql="org.apache.xalan.lib.sql.XConnection"
-                extension-element-prefixes="sql">
-  <xsl:output method="html" indent="yes"/>
-  <xsl:param name="query" select="'SELECT * FROM import1'"/>
- 
-  <xsl:template match="/">
-    <!-- 1. Make the connection -->
-    <xsl:variable name="products"
-                  select="sql:new('org.enhydra.instantdb.jdbc.idbDriver',
-                                'jdbc:idb:./instantdb/sample.prp')"/>
-    <HTML>
-      <HEAD>
-      </HEAD>
-      <BODY>
-        <TABLE border="1">
-        <!--2. Execute the query -->
-        <xsl:variable name="table" select='sql:query($products, $query)'/>
-          <TR>
-          <!-- Get column-label attribute from each column-header-->
-          <xsl:for-each select="$table/row-set/column-header">
-            <TH><xsl:value-of select="@column-label"/></TH>
-          </xsl:for-each>
-          </TR>
-          <xsl:apply-templates select="$table/row-set/row"/>
-          <xsl:text>&#10;</xsl:text>
-        </TABLE>
-      </BODY>
-    </HTML> 
-    <!-- 3. Close the connection -->
-    <xsl:value-of select="sql:close($products)"/>
-  </xsl:template>
-
-  <xsl:template match="row">
-        <TR>
-          <xsl:apply-templates select="col"/>
-        </TR>
-  </xsl:template>
-
-  <xsl:template match="col">
-    <TD>
-      <!-- Here is the column data -->
-      <xsl:value-of select="text()"/>
-    </TD>
-  </xsl:template>
-
-</xsl:stylesheet>
\ No newline at end of file
diff --git a/samples/extensions/IntDate.java b/samples/extensions/IntDate.java
deleted file mode 100644
index cc9c6c3..0000000
--- a/samples/extensions/IntDate.java
+++ /dev/null
@@ -1,17 +0,0 @@
-
-import java.util.Date;
-import java.util.Calendar;
-
-public class IntDate
-{
-  public static Date getDate(String year, String month, String day)
-    {
-      // Date(int, int, int) has been deprecated, so use Calendar to
-      // set the year, month, and day.
-      Calendar c = Calendar.getInstance();
-      // Convert each argument to int.
-      c.set(Integer.parseInt(year),Integer.parseInt(month),Integer.parseInt(day));
-      return c.getTime();
-    }
-}
-
diff --git a/samples/extensions/MyCounter.java b/samples/extensions/MyCounter.java
deleted file mode 100644
index 2b5f54a..0000000
--- a/samples/extensions/MyCounter.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-import java.util.Hashtable;
-
-public class MyCounter {
-  static Hashtable counters = new Hashtable ();
-
-
-  public void init(org.apache.xalan.extensions.XSLProcessorContext context, 
-                   org.w3c.dom.Element elem) 
-  {
-    String name = elem.getAttribute("name");
-    String value = elem.getAttribute("value");
-    int val;
-    try 
-    {
-      val = Integer.parseInt (value);
-    } 
-    catch (NumberFormatException e) 
-    {
-      e.printStackTrace ();
-      val = 0;
-    }
-    counters.put (name, new Integer (val));
-  }
-
-  public int read(String name) 
-  { 
-    Integer cval = (Integer)counters.get(name);
-    return (cval == null) ? 0 : cval.intValue();
-  }
-
-  public void incr(org.apache.xalan.extensions.XSLProcessorContext context,  
-                   org.w3c.dom.Element elem) {
-    String name = elem.getAttribute("name");
-    Integer cval = (Integer) counters.get(name);
-    int nval = (cval == null) ? 0 : (cval.intValue () + 1);
-    counters.put (name, new Integer (nval));
-  }
-}
\ No newline at end of file
diff --git a/samples/extensions/instantdb/idb.jar b/samples/extensions/instantdb/idb.jar
deleted file mode 100644
index b501833..0000000
--- a/samples/extensions/instantdb/idb.jar
+++ /dev/null
Binary files differ
diff --git a/samples/extensions/instantdb/sample.prp b/samples/extensions/instantdb/sample.prp
deleted file mode 100644
index 9d5b246..0000000
--- a/samples/extensions/instantdb/sample.prp
+++ /dev/null
@@ -1,316 +0,0 @@
-!---------------------------------------------------------------------
-!
-! BASIC PROPERTIES
-!
-!---------------------------------------------------------------------
-
-!
-! Path where index tables are held. Can be absolute or relative 
-! to the properties file. Defaults to tablePath.
-!
-!indexPath=./indexes
-!
-! Path where system tables are held. Can be absolute or relative to 
-! the properties file. Defaults to tablePath.
-!
-!systemPath=./system
-!
-! Path where database tables are held. Can be absolute or relative 
-! to the properties file. Defaults to "current" directory.
-!
-tablePath=./tables
-!
-! Path where results set tables are held. Can be absolute or relative 
-! to the properties file. Defaults to tablePath.
-!
-!tmpPath=./tmp
-!
-! Non-zero means paths are relative to the properties file. 
-! Default is absolute paths for files.
-!
-relativeToProperties=1
-!
-! Alternative partitions can be defined so that tables can be placed
-! in multiple locations. Each partition is numbered: 1, 2, 3,... Tables
-! can be created on partitions using the syntax 
-!
-!   CREATE TABLE <name> ON PARTITION <number>...
-!
-! The partition count has to be supplied.
-!
-!partitionCount=2
-!
-! The locations of each partition must be supplied. These are always
-! absolute path names.
-!
-!partition1=d:/petes
-!partition2=c:/temp
-
-
-!---------------------------------------------------------------------
-!
-! TUNING PROPERTIES
-!
-!---------------------------------------------------------------------
-
-!
-! The amount of each column to cache, expressed either as an absolute 
-! number of rows or as a percentage figure. Defaults to 256 or 10 respectively.
-!
-! This value applies only when tables are first created. It has no effect
-! when a table is being re-opened.
-!
-cacheAmount=512
-!
-! CACHE_ROWS Must be one of CACHE_ROWS or CACHE_PERCENT. Determines whether 
-! to cache columns in tables based on an absolute number of rows, or the 
-! percentage number of rows in the table. 
-!
-! This value applies only when tables are first created. It has no effect
-! when a table is being re-opened.
-!
-cacheCondition=CACHE_ROWS
-!
-! The amount of the system tables to be cached. Defaults to 100.
-!
-! This value applies only when tables are first created. It has no effect
-! when a table is being re-opened.
-!
-!systemCacheSize=10
-!
-! Similar to cacheCondition, but applies only to the system tables.
-!
-! This value applies only when tables are first created. It has no effect
-! when a table is being re-opened.
-!
-!systemCacheCondition=CACHE_ROWS
-!
-! The percentage cache hit improvement required in order to move the 
-! cache to a new location in a column. 
-!
-! (Currently not implemented).
-!
-cacheResetPercent=10
-!
-! Non-zero means that database changes do not get written to the 
-! database immediately. See tuning.html. 
-!
-fastUpdate=0
-!
-! Percentage of free space in an index that must be present before 
-! the index reorganises itself. High values means frequent index
-! reorganisation. Low values means slow index inserts.
-!
-indexLoad=5
-!
-! The number of cache misses to include in calculations of the next 
-! base for the cache. 
-!
-! (Currently not implemented).
-!
-missesInCacheStats=100
-!
-! Non-zero means that results sets get instantiated on disk. By default
-! InstantDB holds results sets emtirely in memory (apart from Binary
-! columns). For large results sets this can be a problem. This property
-! forces all results sets to be held on disk.
-!
-resultsOnDisk=0
-!
-! Similar to cacheCondition but applies only to disk based
-! results sets. Default is CACHE_ROWS.
-!
-resultsSetCache=CACHE_ROWS
-!
-! Similar to cacheAmount but applies only to disk based
-! results sets. Default is 100.
-!
-resultsSetCacheAmount=100
-!
-! Number of rows to read into the disk read ahead buffer. 
-! Recommended to be set somewhere around 128 to 256. 
-! Default is 20.
-!
-rowCacheSize=128
-!
-! The read ahead buffer is effective at speeding up full
-! table scans. However for indexed lookups or multiple
-! simultaneous scans it is better to read a single row at
-! a time. Each table holds a small number of single row
-! buffers to improve such operations. Default is 8.
-!
-!singleRowCount=4
-!
-! Sometimes the look ahead buffer can be held by a single
-! thread even though it is not retrieveing many values from it.
-! If too many lookups retrieve data from the single row
-! buffers then it is better to flush the look ahead buffer and
-! make it available for re-use. Default is 128.
-!
-!flushAfterCacheMisses=64
-!
-! Number of rows to read ahead for system tables. By default
-! system tables cache everything, so it is wasteful to have large
-! read ahead buffers since they will very rarely be used. This
-! allows the size of the system read ahead buffers to be reduced
-! if necessary. Defaults to rowCacheSize.
-!
-!systemRows=20
-!
-! The control column in all tables normally has a large cache
-! since this speeds up all operation on that table. This can be
-! varied to either improve performance or to reduce space.
-! default is 8192.
-!
-! This value applies only when tables are first created. It has no effect
-! when a table is being re-opened.
-!
-!controlColCacheSize=512
-!
-! By default, InstantDB only does a cursory search for deleted rows during 
-! UPDATE statements. Setting searchDeletes=1 causes more detailed searches 
-! for deleted rows. This slows down UPDATE executions, but reults in more 
-! compact tables.  Default is 0.
-!
-searchDeletes=0
-!
-! The interval, in milliseconds, between checks for statement execution
-! timeouts. Default is 5000.
-!
-!timerCheck=5000
-
-!---------------------------------------------------------------------
-!
-! LOGGING AND DEBUGGING PROPERTIES
-!
-!---------------------------------------------------------------------
-
-!
-! Non-zero means include SQL statements in the export file. 
-!
-exportSQL=0
-!
-! Non-zero means trace output also directed to console. 
-! Defaults to 0.
-!
-traceConsole=1
-!
-! Relative or absolute path where exporting and tracing goes.
-!
-traceFile=./trace.log
-!
-! Bitmap of various items that can be traced. See debug.html. 
-! Defaults to 0.
-!
-traceLevel=2
-
-!---------------------------------------------------------------------
-!
-! TRANSACTION AND RECOVERY PROPERTIES
-!
-!---------------------------------------------------------------------
-
-!
-! 0 means do not perform recovery on startup.
-! 1 means perform automatic recovery
-! 2 (default) means prompt the user using standard in 
-!
-recoveryPolicy=2
-!
-! Sets the level of transaction journalling. See trans.html.
-! Defaults to 1.
-!
-! 0 - No journalling takes place.
-! 1 - Normal journalling (default).
-! 2 - Full journalling.
-!
-transLevel=1
-!
-! When doing an import, defines the number of rows imported 
-! before the transaction is committed. Recommended value 8192.
-! defaults to 100.
-!
-transImports=100
-
-!---------------------------------------------------------------------
-!
-! DATE, TIME AND CURRENCY PROPERTIES
-!
-!---------------------------------------------------------------------
-
-!
-! Number of digits after decimal point in currency outputs. Defaults to 2.
-!
-currencyDecimal=2
-!
-! Currency symbol used in currency outputs. Defaults to $.
-!
-currencySymbol=$
-!
-! Default format for date columns. Defaults to "yyyy-mm-dd".
-!
-dateFormat=yyyy-mm-dd
-!
-! Default format for timestamp columns. Defaults to "yyyy-mm-dd hh:mm:ss.lll".
-!
-dateTimeFormat=yyyy-mm-dd hh:mm:ss.lll
-!
-! If set, then all two digit dates less than its value are interpreted 
-! as 21st century dates. 
-!
-!milleniumBoundary=50
-!
-! Set to 1 causes the date string "now" to store a full timestamp. 
-! Default is to store only the date for fields with now hour in the 
-! format string.
-!
-nowMeansTime=0
-
-!---------------------------------------------------------------------
-!
-! STRING HANDLING PROPERTIES
-!
-!---------------------------------------------------------------------
-
-!
-! If set to 1 then String hashes use the JDK Object.hashCode() function.
-! By default, uses InstantDB's String hashing.
-!
-altStringHashing=0
-!
-! Set to 1 to cause LIKE clauses to always perform case insensitive 
-! comparisons. 
-!
-likeIgnoreCase=0
-!
-! Same as SET LITERAL STRICT_ON. Prevents string literals being interpreted
-! as column names or numbers. Default is 0.
-!
-strictLiterals=0
-!
-! Set this value to 1 (one) if you would like PreparedStatement.setString()
-! to ignore "\" (backslash) characters when proceesing string constants.
-! When set, InstantDB will not attempt to interpret \ as the start of an
-! escape sequence. Default is 0.
-!
-!prepareIgnoresEscapes=1
-
-!---------------------------------------------------------------------
-!
-! MISCELLANEOUS PROPERTIES
-!
-!---------------------------------------------------------------------
-
-!
-! Allows selected InstantDB keywords to be un-reserved. 
-! e.g. ignoreKeywords=url,quote would allow the keywords 
-! url and quote to be used as table or column names. 
-!
-! This faciliy is provided for compatatbility reasons only.
-! It's use is not recommended AND IS NOT SUPPORTED.
-!
-!ignoreKeywords
-!
-! Non-zero means database is opened in read only mode.
-!
-readOnly=0
diff --git a/samples/extensions/instantdb/tables/$db$types.tbl b/samples/extensions/instantdb/tables/$db$types.tbl
deleted file mode 100644
index 8e78192..0000000
--- a/samples/extensions/instantdb/tables/$db$types.tbl
+++ /dev/null
Binary files differ
diff --git a/samples/extensions/instantdb/tables/import1.tbl b/samples/extensions/instantdb/tables/import1.tbl
deleted file mode 100644
index cb20871..0000000
--- a/samples/extensions/instantdb/tables/import1.tbl
+++ /dev/null
Binary files differ
diff --git a/samples/extensions/instantdb/tables/sample$db$Cols$pKey.tbl b/samples/extensions/instantdb/tables/sample$db$Cols$pKey.tbl
deleted file mode 100644
index c23982a..0000000
--- a/samples/extensions/instantdb/tables/sample$db$Cols$pKey.tbl
+++ /dev/null
Binary files differ
diff --git a/samples/extensions/instantdb/tables/sample$db$Cols.tbl b/samples/extensions/instantdb/tables/sample$db$Cols.tbl
deleted file mode 100644
index 3092d01..0000000
--- a/samples/extensions/instantdb/tables/sample$db$Cols.tbl
+++ /dev/null
Binary files differ
diff --git a/samples/extensions/instantdb/tables/sample$db$Indexes.tbl b/samples/extensions/instantdb/tables/sample$db$Indexes.tbl
deleted file mode 100644
index 3aa1517..0000000
--- a/samples/extensions/instantdb/tables/sample$db$Indexes.tbl
+++ /dev/null
Binary files differ
diff --git a/samples/extensions/instantdb/tables/sample$db$Tables$pKey.tbl b/samples/extensions/instantdb/tables/sample$db$Tables$pKey.tbl
deleted file mode 100644
index 28f0c09..0000000
--- a/samples/extensions/instantdb/tables/sample$db$Tables$pKey.tbl
+++ /dev/null
Binary files differ
diff --git a/samples/extensions/instantdb/tables/sample$db$Tables.tbl b/samples/extensions/instantdb/tables/sample$db$Tables.tbl
deleted file mode 100644
index 744194d..0000000
--- a/samples/extensions/instantdb/tables/sample$db$Tables.tbl
+++ /dev/null
Binary files differ
diff --git a/samples/extensions/instantdb/tables/sample.jrl b/samples/extensions/instantdb/tables/sample.jrl
deleted file mode 100644
index 78bef4f..0000000
--- a/samples/extensions/instantdb/tables/sample.jrl
+++ /dev/null
Binary files differ
diff --git a/samples/extensions/numlist.xml b/samples/extensions/numlist.xml
deleted file mode 100644
index 76d41c2..0000000
--- a/samples/extensions/numlist.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0"?>
-<doc>
-  <name first="Sanjiva" last="Weerawarana"/>
-  <name first="Joseph" last="Kesselman"/>
-  <name first="Stephen" last="Auriemma"/>
-  <name first="Igor" last="Belakovskiy"/>    
-  <name first="David" last="Marston"/>
-  <name first="David" last="Bertoni"/>
-  <name first="Donald" last="Leslie"/>
-  <name first="Emily" last="Farmer"/>
-  <name first="Myriam" last="Midy"/>
-  <name first="Paul" last="Dick"/>
-  <name first="Scott" last="Boag"/>
-  <name first="Shane" last="Curcuru"/>
-  <name first="Marcia" last="Hoffman"/>
-  <name first="Noah" last="Mendelsohn"/>
-  <name first="Alex" last="Morrow"/>    
-</doc>
\ No newline at end of file
diff --git a/samples/extensions/readme.html b/samples/extensions/readme.html
deleted file mode 100644
index ec8936f..0000000
--- a/samples/extensions/readme.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
-	<title>Xalan Samples</title>
-</head>
-<body>
-<h2>Xalan Samples</h2>
-<p>For information about the samples (what they illustrate and how to run them), see <a href="../../docs/samples.html">Samples</a>.</p>
-
-
-</body>
-</html>
diff --git a/samples/servlet/ApplyXSLT.java b/samples/servlet/ApplyXSLT.java
deleted file mode 100644
index 472e326..0000000
--- a/samples/servlet/ApplyXSLT.java
+++ /dev/null
@@ -1,889 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package servlet;
-
-import java.io.*;
-import java.util.*;
-import javax.servlet.*;
-import javax.servlet.http.*;
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.net.URLConnection;
-import javax.xml.transform.OutputKeys;
-
-import org.apache.xalan.templates.Constants;
-import org.apache.xalan.templates.StylesheetRoot;
-// SAX2 Imports
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.Locator;
-import org.xml.sax.helpers.XMLReaderFactory;
-import org.xml.sax.ext.DeclHandler;
-import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.SAXNotRecognizedException;
-import org.xml.sax.SAXNotSupportedException;
-
-import org.w3c.dom.*;
-import javax.xml.transform.*;
-import javax.xml.transform.stream.*;
-import org.apache.xalan.transformer.TransformerImpl;
-import org.apache.xalan.stree.SourceTreeHandler;
-import org.apache.xpath.objects.XObject;
-import org.apache.xpath.objects.XString;
-import org.apache.xalan.processor.*;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-import org.xml.sax.helpers.XMLFilterImpl;
-
-/*****************************************************************************************************
- *
- * ApplyXSLT supplies the basic
- * functions for transforming XML data using XSL stylesheets.
- *
- * @author Spencer Shepard (sshepard@us.ibm.com)
- * @author R. Adam King (rak@us.ibm.com)
- * @author Tom Rowe (trowe@us.ibm.com)
- * @author Don Leslie (donald_leslie@lotus.com)
- *
- *****************************************************************************************************/
-
-public class ApplyXSLT extends HttpServlet
-{
-
-  /**
-   * Operational parameters for this class.
-   * <p>Request-time values override init-time values which override class defaults.</p>
-   * @see #init
-   * @serial
-   */
-  protected ApplyXSLTProperties ourDefaultParameters = null;
-
-  /**
-   * String representing the end of line characters for the System.
-   */
-  public final static String EOL = System.getProperty("line.separator");
-
-  /**
-   * String representing the file separator characters for the System.
-   */
-  public final static String FS = System.getProperty("file.separator");
-
-   /**
-   * String representing the current directory for properties files. See init().
-   */
-  public final static String ROOT = System.getProperty("server.root");
-  public static String CURRENTDIR;
-
-  /**
-   * Initialize operational parameters from the configuration.
-   * @param config Configuration
-   * @exception ServletException Never thrown
-   */
-  public void init(ServletConfig config)
-    throws ServletException
-  {
-    super.init(config);
-    // If the server.root property --see above-- is null, use current working directory
-    // as default location for media.properties.
-    if (ROOT != null)
-      CURRENTDIR= ROOT + FS + "servlets" + FS;
-    else
-      CURRENTDIR = System.getProperty("user.dir")+ FS;
-    
-	setDefaultParameters(config);
-	
-    setMediaProps(config.getInitParameter("mediaURL"));	
-  }
-  
- /**
-   * Sets the default parameters for the servlet from the configuration.
-   * Also sets required system properties until we figure out why servlet 
-   * sometimess fails to read properties from properties files.
-   * @param config Configuration
-   */
-  protected void setDefaultParameters(ServletConfig config)
-  {
-    ourDefaultParameters = new DefaultApplyXSLTProperties(config);
-  }
-  
-  /**
-   *	Loads the media properties file specified by the given string.
-   * @param mediaURLstring Location of the media properties file.  Can be either a full URL or a path relative
-   * to the System's server.root /servlets directory.  If this parameter is null,
-   * server.root/servlets/media.properties will be used.
-   * @see ApplyXSL#CURRENTDIR
-   */
-  protected void setMediaProps(String mediaURLstring)
-  {
-    if (mediaURLstring != null)
-    {
-      URL url = null;
-      try
-      {
-        url = new URL(mediaURLstring);
-      }
-      catch (MalformedURLException mue1)
-      {
-        try
-        {
-          url = new URL("file", "", CURRENTDIR + mediaURLstring);
-        }
-        catch (MalformedURLException mue2)
-        {
-          writeLog("Unable to find the media properties file based on parameter 'mediaURL' = "
-                   + mediaURLstring, HttpServletResponse.SC_ACCEPTED, mue2);
-          url = null;
-        }
-      }
-      if (url != null)
-      {
-        try
-        {
-          ourMediaProps = new OrderedProps(url.openStream());
-        }
-        catch (IOException ioe1)
-        {
-          writeLog("Exception occurred while opening media properties file: " + mediaURLstring +
-                   ".  Media table may be invalid.", HttpServletResponse.SC_ACCEPTED, ioe1);
-        }
-      }
-    }
-    else
-    {
-      String defaultProp = CURRENTDIR + "media.properties";
-      try
-      {
-        ourMediaProps = new OrderedProps(new FileInputStream(defaultProp));
-      }
-      catch (IOException ioe2)
-      {
-        writeLog("Default media properties file " + defaultProp + " not found.",
-                 HttpServletResponse.SC_ACCEPTED, ioe2);
-      }
-    }
-  }
-
-  public String getMedia(HttpServletRequest request)
-  {
-    return ourMediaProps.getValue(request.getHeader(HEADER_NAME));
-  }
-  
-  // doPost removed for security reasons due to the possibility of sending
-  // unsecure XML and XSL XSLTInputSources through the request input stream
-
-  /**
-   * HTTP Get method passed on to process().
-   * @param request The request
-   * @param response The response
-   * @see #process
-   * @exception ServletException Never thrown
-   * @exception IOException Never thrown
-   */
-  public void doGet (HttpServletRequest request,
-                     HttpServletResponse response)
-    throws ServletException, IOException
-  {
-    try
-    {	
-      TransformerFactory tFactory = TransformerFactory.newInstance();
-      process(tFactory, request, response);
-    }
-    catch (Exception e)
-    {
-    }
-  }
-  
-  /**
-   * Coordinates applying an XSL stylesheet to XML data using operational parameters.
-   * <p>If successfully applied, the result tree will be streamed to the response object
-   * and the content type set according to the XSL stylesheet's &lt;xsl:output> element(s).</p>
-   * <p>If there is a problem in parsing the XML/XSL or if there is a problem in applying
-   * the XSL to the XML, an exception will be streamed to the response object.  The detail
-   * of the information returned in the response object will depend on whether we're
-   * running in debug mode or not.</p>
-   * @param processor implementation of TRaX processor
-   * @param request  May contain information relevant to creating XML and XSL XSLTInputSource's
-   * @param response Where to write the transformation result
-   * @see #getDocument
-   * @see #getStylesheet
-   * @see #getContentType
-   * @see #displayException
-   * @see #setStylesheetParams
-   * @exception ServletException Never thrown
-   * @exception IOException Never thrown
-   */
-  
-  public void process(TransformerFactory tFactory, 
-					  HttpServletRequest request,
-                      HttpServletResponse response)
-    throws ServletException, IOException, SAXException
-  {
-    boolean debug = ourDefaultParameters.isDebug(request);
-
-    long time = 0;
-    if (debug)
-      time = System.currentTimeMillis();
-
-    // Listener to be used for all reporting
-    ApplyXSLTListener listener = new ApplyXSLTListener();
-	listener.out.println("debug is " + debug);
-
-    StreamSource xmlSource = null;
-	StreamSource xslSource = null;
-    try
-    {
-      if ((xmlSource = getDocument(request, listener)) == null)
-        throw new ApplyXSLTException("getDocument() returned null",
-                                     new NullPointerException(),
-                                     response.SC_NOT_FOUND);
-    }
-    catch (ApplyXSLTException axe)
-    {
-      axe.appendMessage(EOL + "getDocument() resulted in ApplyXSLTException" + EOL
-                        + listener.getMessage());
-      if (debug) writeLog(axe);
-      displayException(response, axe, debug);
-      xmlSource = null;
-    }
-    // creating XSL Stylesheet
-    if (xmlSource != null)
-	{
-      try
-      {
-	    if ((xslSource = getStylesheet(tFactory, request, xmlSource, listener)) == null)
-		{
-          throw new ApplyXSLTException("getStylesheet() returned null",
-                                       new NullPointerException(),
-                                       response.SC_NOT_FOUND);
-        }
-        // For time being, must "reset" xmlSource after extracting stylesheet PI
-		xmlSource = getDocument(request, listener); 
-      }
-      catch (ApplyXSLTException axe)
-      {
-        axe.appendMessage(EOL + "getStylesheet() resulted in ApplyXSLTException" + EOL
-                          + listener.getMessage());
-        if (debug) writeLog(axe);
-        displayException(response, axe, debug);
-        xslSource = null;
-      }
-    // perform Transformation
-	  
-    if ((xmlSource != null) && (xslSource != null))
-    {
-	  try
-	  {
-        listener.out.println("Performing transformation...");
-		
-        Templates templates = tFactory.newTemplates(xslSource);
-        Transformer transformer = templates.newTransformer();
-        {
-          try
-          {
-            String contentType = null;
-			      contentType = getContentType(templates);
-            if (contentType != null);
-              response.setContentType(contentType);
-
-			      if (transformer instanceof TransformerImpl)
-			      {
-			        TransformerImpl transformerImpl = (TransformerImpl)transformer;
-              transformerImpl.setQuietConflictWarnings(ourDefaultParameters.isNoCW(request));
-			      }
-			
-			      setStylesheetParams(transformer, request);			
-	          transformer.transform(xmlSource, new StreamResult(response.getOutputStream()));
-			
-			      if (debug)              
-              writeLog(listener.getMessage(), response.SC_OK);
-          }
-          catch (Exception exc)
-          {
-            ApplyXSLTException axe = new ApplyXSLTException
-				                     ("Exception occurred during Transformation:"
-                                          + EOL + listener.getMessage() + EOL
-                                          + exc.getMessage(), 
-									              exc,
-                                response.SC_INTERNAL_SERVER_ERROR);
-            if (debug) writeLog(axe);
-            displayException(response, axe, debug);
-          }
-          finally
-          {
-            // transformer.reset();
-          } // end of try ... catch ... finally
-		}
-	  }
-      catch (/*org.xml.sax.SAX*/Exception saxExc)
-      {
-        ApplyXSLTException axe = new ApplyXSLTException
-			                     ("Exception occurred during ctor/Transformation:"
-                                             + EOL + listener.getMessage() + EOL
-                                             + saxExc.getMessage(), 
-			                					  saxExc,
-                                  response.SC_INTERNAL_SERVER_ERROR);
-        if (debug) writeLog(axe);
-        displayException(response, axe, debug);
-      } // end of new try ... catch
-    } // end of if((stylesheetRoot != null) ...
-    if (debug)
-    {
-      time = System.currentTimeMillis() - time;
-      writeLog("  No Conflict Warnings = " + ourDefaultParameters.isNoCW(request) +
-               "  Transformation time: " + time + " ms", response.SC_OK);
-    }
-  }
-  }  
-
-  /**
-   * Returns an XML XSLTInputSource DOM.  Attempts will be make to create the DOM from the following
-   * sources:
-   * <ol>
-   * <li>A relative URL specified in the HTTP request's path information. This capability is intended
-   * for use by <b>servlet engines that map</b> some or all XML data to be processed at the server.</li>
-   * <li>A URL specified in the HTTP request's <code>URL=</code> parameter.  This capability
-   * is intended for <b>clients wishing to selectively process</b> XML data at the server.  For
-   * security reasons, this URL will be forced to the local IP host.</li>
-   * <li>The HTTP request's XML input stream. This capability is intended for use by chained servlets.</li>
-   * </ol>
-   * @param request May contain or point to the XML XSLTInputSource
-   * @param listener To record detailed parsing messages for possible return to requestor
-   * @return XML XSLTInputSource DOM, or null if the XSLTInputSource could not be parsed
-   * @exception ApplyXSLTException Thrown if exception occurs while handling request
-   */
-  protected StreamSource getDocument(HttpServletRequest request,
-                                     ApplyXSLTListener listener)
-    throws ApplyXSLTException
-  {
-    try
-    {
-      String xmlURL = null;
-      // document from PathInfo
-      if ((xmlURL = request.getPathInfo()) != null)
-      {
-        listener.out.println("Parsing XML Document from PathInfo: " + xmlURL);
-        return new StreamSource(new URL("http", ((DefaultApplyXSLTProperties)
-                                         ourDefaultParameters).getLocalHost(),
-                                         xmlURL.replace('\\', '/')).openStream());		
-      }
-      // document from Request parameter
-      if ((xmlURL = ourDefaultParameters.getXMLurl(request)) != null)
-      {
-        listener.out.println("Parsing XML Document from request parameter: " + xmlURL);
-        return new StreamSource(new URL(xmlURL).openStream());
-      }
-      // document from chain
-      String contentType = request.getContentType();
-      if ((contentType != null) && contentType.startsWith("text/xml"))
-      {
-        listener.out.println("Parsing XML Document from request chain");
-        return new StreamSource(request.getInputStream());
-      }
-    }
-    catch (IOException ioe)
-    {
-      throw new ApplyXSLTException(ioe, HttpServletResponse.SC_NOT_FOUND);
-    }
-    catch (Exception e)
-    {
-      throw new ApplyXSLTException(e, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-    }
-    return null;
-  }
-
-  /**
-   * Returns a Templates (StylesheetRoot) object.  Attempts will be make to create the Stylesheet 
-   * from the followingsources:
-   * <ol>
-   * <li>A URL specified in the HTTP request's <code>xslURL=</code> parameter.  This capability
-   * is intended for clients wishing to selectively override the server algorithm for applying XSL
-   * stylesheets.  For security reasons, this URL will be forced to the local IP host.</li>
-   * <li>XML association.  XML documents may contain references to one or more stylesheets using
-   * <a HREF="http://www.w3.org/TR/1999/PR-xml-stylesheet-19990114">this</a> W3C proposed recommendation.
-   * If the XML document does contain such references, a best match will be chosen based on the browser
-   * type making the request and the default association.  This capability enables relationships to be
-   * defined between client capabilities and stylesheets capable of acting on these capabilities.</li>
-   * <li>A configured default stylesheet URL</li>
-   * </ol>
-   * @param request May contain or point to the XSL XSLTInputSource
-   * @param xmlSource  May point to the XSL XSLTInputSource
-   * @param listener To record detailed parsing messages for possible return to requestor
-   * @return XSL XSLTInputSource, or null if the request could not be parsed
-   * @see #makeDocument
-   * @see #getMedia
-   * @see #STYLESHEET_ATTRIBUTE
-   * @see #getXSLURLfromDoc
-   * @see #toAcceptLanguageConnection
-   * @exception ApplyXSLTException Thrown if exception occurs while handling request
-   */
-  protected StreamSource getStylesheet(TransformerFactory tFactory,
-				   		  			   HttpServletRequest request,
-                                       StreamSource xmlSource,
-                                       ApplyXSLTListener listener)
-    throws ApplyXSLTException
-  {
-    try
-    {
-      //stylesheet URL from request
-      String xslURL = ((DefaultApplyXSLTProperties) ourDefaultParameters).getXSLRequestURL(request);
-
-      if (xslURL != null)
-        listener.out.println("Parsing XSL Stylesheet Document from request parameter: "
-                             + xslURL);
-      else
-      {
-        // find stylesheet from XML Document, Media tag preference
-        if (xmlSource != null){
-          listener.out.println("calling getXSLURLfromDoc and getMedia " + getMedia(request) );
-          xslURL = getXSLURLfromDoc(xmlSource, STYLESHEET_ATTRIBUTE, getMedia(request), tFactory);
-        }
-        if (xslURL != null)
-          listener.out.println("Parsing XSL Stylesheet Document from XML Document tag: " + xslURL);
-        else
-          // Configuration Default
-          if ((xslURL = ourDefaultParameters.getXSLurl(null)) != null)
-            listener.out.println("Parsing XSL Stylesheet Document from configuration: " + xslURL);
-      }
-      return new StreamSource(xslURL);
-    }
-    catch (IOException ioe)
-    {
-      throw new ApplyXSLTException(ioe, HttpServletResponse.SC_NOT_FOUND);
-    }
-    catch (Exception e)
-    {
-      throw new ApplyXSLTException(e, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-    }
-  }
-
-  /**
-   * Returns the response content type specified by the media-type and encoding attributes of
-   * the &lt;xsl:output> element(s) of the stylesheet.
-   * @param xslSourceRoot XSL Stylesheet to be examined for &lt;xsl:output> elements.
-   * @return The response content type (MIME type and charset) of the stylesheet output
-   * @see #process
-   */
-  public String getContentType(Templates templates)
-  {
-    Properties oprops = templates.getOutputProperties();
-    String encoding = oprops.getProperty(OutputKeys.ENCODING);  
-          String media = oprops.getProperty(OutputKeys.MEDIA_TYPE);
-          if (media != null)
-          {
-      if (encoding != null)
-        return media + "; charset=" + encoding;
-      return media;
-          }
-          else
-          {
-            String method = oprops.getProperty(OutputKeys.METHOD);
-            if (method.equals("html"))
-                    return "text/html";
-            else if (method.equals("text"))
-                    return "text/plain";
-            else 
-                    return "text/xml";
-          }
-  }  
-  
-
-  /**
-   * Defines and sets select top-level XSL stylesheet variables from the HTTP request, which
-   * can be evaluated using &lt;xsl:param-variable&gt;.  The following variables will be
-   * automatically set:
-   * <dl>
-   * <dt><i>ParameterName</i></dt>
-   * <dd>Each non-reserved request parameter returned from request.getParameterNames().  If a
-   *     parameter contains more than a single value, only the first value is available.</dd>
-   * <dt>servlet-RemoteAddr</dt>
-   * <dd>Contains String output from request.getRemoteAddr(), which is the IP address
-   *     of the client machine.</dd>
-   * <dt>servlet-RemoteHost</dt>
-   * <dd>Contains String output from request.getRemoteHost(), which is the host name
-   *     of the client machine.</dd>
-   * <dt>servlet-RemoteUser</dt>
-   * <dd>Contains String output from request.getRemoteUser(), which was the user name
-   *     accepted by the server to grant access to this servlet.</dd>
-   * <dt>servlet-Request</dt>
-   * <dd>Contains the request object.</dd>
-   * </dl>
-   * @param xslprocessor Where to register parameters to be set
-   * @param request Provides access to all meaningful parameters to set
-   * @see #process
-   */
-  public void setStylesheetParams(Transformer transformer, HttpServletRequest request)
-  {
-    Enumeration paramNames = request.getParameterNames();
-    while (paramNames.hasMoreElements())
-    {
-      String paramName = (String) paramNames.nextElement();
-      try
-      {
-        String[] paramVals = request.getParameterValues(paramName);
-        if (paramVals != null)
-            transformer.setParameter(paramName, new XString(paramVals[0]));
-                                            
-      }
-      catch (Exception e)
-      {
-      }
-    }
-    try
-    {
-      transformer.setParameter("servlet-RemoteAddr", new XString(request.getRemoteAddr()));
-                                      
-    }
-    catch (Exception e)
-    {
-    }
-    try
-    {
-      transformer.setParameter("servlet-RemoteHost", new XString(request.getRemoteHost()));
-                                      
-    }
-    catch (Exception e)
-    {
-    }
-    try
-    {
-      transformer.setParameter("servlet-RemoteUser", new XString(request.getRemoteUser()));
-                                      
-    }
-    catch (Exception e)
-    {
-    }
-  }
-
-
-  /**
-   * Writes the following information to the servlet log:
-   * <ol>
-   * <li>HTTP status code</li>
-   * <li>Message</li>
-   * <li>Stack trace</li>
-   * </ol>
-   * @param axe Contains valid HTTP status code, message, and stack trace (optional)
-   */
-  protected void writeLog(ApplyXSLTException axe)
-  {
-    writeLog(axe.getMessage(), axe.getStatusCode(), axe.getException());
-  }
-
-  /**
-   * Writes the following information to the servlet log:
-   * <ol>
-   * <li>HTTP status code</li>
-   * <li>Message</li>
-   * <li>Stack trace</li>
-   * </ol>
-   * @param msg Message to be logged
-   * @param statusCode Valid status code from javax.servlet.http.HttpServletResponse
-   * @param t Used to generate stack trace (may be =null to suppress stack trace)
-   */
-  protected void writeLog(String msg, int statusCode, Throwable t)
-  {
-    if (t == null)
-      writeLog(msg, statusCode);
-    else
-    {
-      ByteArrayOutputStream bytes = new ByteArrayOutputStream();
-      PrintWriter writer = new PrintWriter(bytes, true);
-      System.out.println("Exception is " + t.getClass().getName());
-      t.printStackTrace(writer);
-      log("HTTP Status Code: " + statusCode + " - " + msg + EOL + bytes.toString());
-    }
-  }
-
-  /**
-   * Writes the following information to the servlet log:
-   * <ol>
-   * <li>HTTP status code</li>
-   * <li>Message</li>
-   * </ol>
-   * @param msg Message to be logged
-   * @param statusCode Valid status code from javax.servlet.http.HttpServletResponse
-   */
-  protected void writeLog(String msg, int statusCode)
-  {
-    log("HTTP Status Code: " + statusCode + " - " + msg);
-  }
-
-  /**
-   * Invokes response.sendError setting an HTTP status code and optionally an error message
-   * as an HTML page.
-   * <p>If running in debug mode, also try to return a stack trace of the exception and
-   * and xml/xsl processor messages.</p>
-   * @param response Where to stream the exception to
-   * @param xse The wrapper which contains the exception and its HTTP status code
-   * @param debug Indicates whether to include stack trace, etc.
-   */
-  protected void displayException(HttpServletResponse response, ApplyXSLTException xse, boolean debug)
-  {
-    String mesg = xse.getMessage();
-    if (mesg == null)
-      mesg = "";
-    else mesg = "<B>" + mesg + "</B>";
-    StringTokenizer tokens = new StringTokenizer(mesg, EOL);
-    StringBuffer strBuf = new StringBuffer();
-    while (tokens.hasMoreTokens())
-      strBuf.append(tokens.nextToken() + EOL + "<BR>");
-    mesg = strBuf.toString();
-    if (debug)
-    {
-      ByteArrayOutputStream bytes = new ByteArrayOutputStream();
-      PrintWriter writer = new PrintWriter(bytes, true);
-      xse.getException().printStackTrace(writer);
-      mesg += " <PRE> " + bytes.toString() + " </PRE> ";
-    }
-    response.setContentType("text/html");
-    try
-    {
-      response.sendError(xse.getStatusCode(), mesg);
-    }
-    catch (IOException ioe)
-    {
-      System.err.println("IOException is occurring when sendError is called");
-    }
-  }
-
-  /**
-   * Mapping of HTTP request's user-Agent values to stylesheet media= values.
-   * <p>This mapping is defined by a file pointed to by the operational parameter "mediaURL" which can
-   *  either contain a full URL or a path relative to the System's server.root /servlets directory.</p>
-   * @see #setMediaProps
-   * @see #getMedia
-   * @serial
-   */
-  protected OrderedProps ourMediaProps = null;
-
-  /**
-   * Returns a connection which respects the Accept-Language header of the HTTP request.  This
-   * is useful when XSL files are internationalized for use with Web servers which respect this
-   * header.
-   * <p>For example, Apache 1.3.6 may be configured for multiviews.  Under this configuration,
-   * requests for http://myhost/index.html would return http://myhost/index.html.fr to French browsers
-   * and http://myhost/index.html.en to English browsers.</p>
-   * @param url Location to connect to
-   * @param request Could contain an Accept-Language header
-   * @return An Accept-Language-enabled URL connection
-   * @see #getStylesheet
-   */
-  protected URLConnection toAcceptLanguageConnection(URL url, HttpServletRequest request)
-    throws Exception
-  {
-    URLConnection tempConnection = url.openConnection();
-    tempConnection.setRequestProperty("Accept-Language", request.getHeader("Accept-Language"));
-    return tempConnection;
-  }
-
-
-  /**
-   * Returns the XSL stylesheet URL associated with the specified XML document.  If multiple XSL
-   * stylesheets are associated with the XML document, preference will be given to the stylesheet
-   * which contains an attribute name/value pair that corresponds to the specified attributeName
-   * and attributeValue.
-   * @param xmlSource XML XSLTInputSource to be searched for associated XSL stylesheets
-   * @param attributeName  Attribute name to provide preferential matching
-   * @param attributeValue Attribute value to provide preferential matching
-   * @return The preferred XSL stylesheet URL, or null if no XSL stylesheet association is found
-   * @see #getStylesheet
-   */
-  public static String getXSLURLfromDoc(StreamSource xmlSource,
-                                        String attributeName,
-                                        String attributeValue,
-                                        TransformerFactory tFactory)
-  {
-    String tempURL = null, returnURL = null;
-    try
-    {
-	  DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
-      DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
-      Node sourceTree = docBuilder.parse(xmlSource.getInputStream());
-      for(Node child=sourceTree.getFirstChild(); null != child; child=child.getNextSibling())
-      {
-        if(Node.PROCESSING_INSTRUCTION_NODE == child.getNodeType())
-        {
-          ProcessingInstruction pi = (ProcessingInstruction)child;
-          if(pi.getNodeName().equals("xml-stylesheet"))
-          {
-            PIA pia = new PIA(pi);
-            if("text/xsl".equals(pia.getAttribute("type")))
-            {
-              tempURL = pia.getAttribute("href");
-              String attribute = pia.getAttribute(attributeName);
-              if ((attribute != null) && (attribute.indexOf(attributeValue) > -1))
-                return tempURL;
-              if (!"yes".equals(pia.getAttribute("alternate")))
-                returnURL = tempURL;
-            }
-          }
-        }
-      }
-    }
-    catch(Exception saxExc)
-    {
-    }
-    return returnURL;
-  }  
-
- /**
-   * The attribute name in the <?xml-stylesheet> tag used in stylesheet selection.
-   */
-  protected static final String STYLESHEET_ATTRIBUTE = "media";
-
-  /**
-   *	The HTTP Header used for matching the Stylesheet attribute via the
-   * media properties file selected.
-   */
-  protected static final String HEADER_NAME = "user-Agent";
-}
-
-/**
- *  Stores the keys and values from a file (similar to a properties file) and
- *  can return the first value which has a key contained in its string.
- *  File can have comment lines starting with '#" and for each line the entries are
- *  separated by tabs and '=' char.
- */
-class OrderedProps
-{
-
-  /**
-   * Stores the Key and Values as an array of Strings
-   */
-  private Vector attVec = new Vector(15);
-
-  /**
-   * Constructor.
-   * @param inputStream Stream containing the properties file.
-   * @exception IOException Thrown if unable to read from stream
-   */
-  OrderedProps(InputStream inputStream)
-    throws IOException
-  {
-    BufferedReader input  = new BufferedReader(new InputStreamReader(inputStream));
-    String currentLine, Key = null;
-    StringTokenizer currentTokens;
-    while ((currentLine = input.readLine()) != null)
-    {
-      currentTokens = new StringTokenizer(currentLine, "=\t\r\n");
-      if (currentTokens.hasMoreTokens()) Key = currentTokens.nextToken().trim();
-      if ((Key != null) && !Key.startsWith("#") && currentTokens.hasMoreTokens())
-      {
-        String temp[] = new String[2];
-        temp[0] = Key; temp[1] = currentTokens.nextToken().trim();
-        attVec.addElement(temp);
-      }
-    }
-  }
-
-  /**
-   * Iterates through the Key list and returns the first value for whose
-   * key the given string contains.  Returns "unknown" if no key is contained
-   * in the string.
-   * @param s String being searched for a key.
-   * @return Value for key found in string, otherwise "unknown"
-   */
-  String getValue(String s)
-  {
-    int i, j = attVec.size();
-    for (i = 0; i < j; i++)
-    {
-      String temp[] = (String[]) attVec.elementAt(i);
-      if (s.indexOf(temp[0]) > -1)
-        return temp[1];
-    }
-    return "unknown";
-  }
-}
-
-/**
- * Parses a processing instruction's (PI) attributes for easy retrieval.
- */
-class PIA
-{
-
-  private Hashtable piAttributes = null;
-
-  /**
-   * Constructor.
-   * @param pi The processing instruction whose attributes are to be parsed
-   */
-  PIA(ProcessingInstruction pi)
-  {
-    piAttributes = new Hashtable();
-    StringTokenizer tokenizer = new StringTokenizer(pi.getNodeValue(), "=\"");
-    while(tokenizer.hasMoreTokens())
-    {
-      piAttributes.put(tokenizer.nextToken().trim(), tokenizer.nextToken().trim());
-    }
-  }
-
-  /**
-   * Returns value of specified attribute.
-   *  @param name Attribute name
-   *  @return Attribute value, or null if the attribute name does not exist
-   */
-  String getAttribute(String name)
-  {
-    return (String) piAttributes.get(name);
-  }  
-}
\ No newline at end of file
diff --git a/samples/servlet/ApplyXSLTException.java b/samples/servlet/ApplyXSLTException.java
deleted file mode 100644
index f63c6a1..0000000
--- a/samples/servlet/ApplyXSLTException.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- * 
-/*****************************************************************************************************
- *
- * Wrapper for exceptions occurring during apply XSL processing.  
- * Allows for exceptions to be returned with an associated HTTP Status Code.
- *
- * @author Spencer Shepard (sshepard@us.ibm.com)
- * @author R. Adam King (rak@us.ibm.com)
- * @author Tom Rowe (trowe@us.ibm.com)
- *
- *****************************************************************************************************/
-package servlet;
-
-public class ApplyXSLTException extends Exception {
-
-    /**
-      * Exception Message.
-      * @serial
-      */ 
-    private String myMessage = "";
-
-    /**
-      * HTTP Status Code. Default= internal server error.
-      * @serial
-      */
-    private int  myHttpStatusCode = javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR; 
-
-    /**
-      * Wrapped exception
-      * @serial
-      */
-    private Exception myException = null;
-
-    /**
-      * Constructor for exception with no additional detail.
-      */
-    public ApplyXSLTException() 
-    { 
-        super(); 
-    }
-
-    /**
-      * Constructor for exception with message.
-      * @param s Exception message
-      */
-    public ApplyXSLTException(String s) 
-    { 
-        super(); 
-	myMessage = s;
-    }
-
-    /**
-      * Constructor for exception with HTTP status code.
-      * @param hsc Valid status code from javax.servlet.http.HttpServletResponse
-      */
-    public ApplyXSLTException(int hsc) 
-    {
-	super();
-	myHttpStatusCode = hsc;
-    }
-
-    /**
-      * Constructor for exception with message and HTTP status code.
-      * @param s Exception message
-      * @param hsc Valid status code from javax.servlet.http.HttpServletResponse
-      */
-    public ApplyXSLTException(String s, int hsc)
-    {
-	super();
-	myHttpStatusCode = hsc;
-    }
-
-    /**
-      * Constructor for exception.
-      * @param e Exception to be wrapped.
-      */
-    public ApplyXSLTException(Exception e)
-    {
-	super();
-	myMessage = e.getMessage();
-	myException = e;
-    }
-
-    /**
-      * Constructor for passed exception with message.
-      * @param s Exception message
-      * @param e Exception to be wrapped.
-      */
-    public ApplyXSLTException (String s, Exception e)
-    {
-	super();
-	myMessage = s;
-	myException = e;
-    }
-
-    /**
-      * Constructor for passed exception with HTTP status code.
-      * @param e Exception to be wrapped.
-      * @param hsc Valid status code from javax.servlet.http.HttpServletResponse
-      */
-    public ApplyXSLTException(Exception e, int hsc)
-    {
-	super();
-	myMessage = e.getMessage();
-	myException = e;
-	myHttpStatusCode = hsc;
-    }
-
-    /**
-      * Constructor for passed exception with HTTP status code and message.
-      * @param s Exception message
-      * @param e Exception to be wrapped.
-      * @param hsc Valid status code from javax.servlet.http.HttpServletResponse
-      */
-    public ApplyXSLTException(String s, Exception e, int hsc)
-    {
-	super();
-	myMessage = s;
-	myException = e;
-	myHttpStatusCode = hsc;
-    }
-
-    /**
-      * Returns exception message.
-      * @return exception message
-      */
-    public String getMessage()
-    {
-	return myMessage;
-    }
-
-    /**
-      * Appends string to exception message.
-      * @param s String to be added to message
-      */
-    public void appendMessage(String s)
-    {
-	myMessage += s;
-    }
-
-    /**
-      * Returns the wrapped exception.
-      * @return Wrapped exception
-      */
-    public Exception getException()
-    {
-	return myException;
-    }
-
-    /**
-      * Returns the HTTP status code associated with the exception.
-      * @return Valid status code from javax.servlet.http.HttpServletResponse
-      */
-    public int getStatusCode()
-    {
-	return myHttpStatusCode;
-    }
-}
-
diff --git a/samples/servlet/ApplyXSLTListener.java b/samples/servlet/ApplyXSLTListener.java
deleted file mode 100644
index 2e46e26..0000000
--- a/samples/servlet/ApplyXSLTListener.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package servlet;
-
-import java.io.*;
-import org.xml.sax.*;
-import org.apache.xml.utils.DefaultErrorHandler;
-
-/*****************************************************************************************************
- * ApplyXSLTListener provides a buffered listener essential for capturing, and then subsequently
- * reporting, XML and XSL processor messages which may be of use in debugging XML+XSL processed at
- * the server.
- *
- * @author Spencer Shepard (sshepard@us.ibm.com)
- * @author R. Adam King (rak@us.ibm.com)
- * @author Tom Rowe (trowe@us.ibm.com)
- *
- *****************************************************************************************************/
-
-public class ApplyXSLTListener extends DefaultErrorHandler implements ErrorHandler
-{
-
-    /**
-      * Output stream
-      */
-    private ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-
-    /**
-      * Buffered output stream
-      */
-    public PrintWriter out = null;
-
-    /**
-      * Constructor.
-      */
-    public ApplyXSLTListener()
-    {
-      out = new PrintWriter(new BufferedOutputStream(outStream), true);
-    }
-
-    /**
-      * Receive notification of a warning.
-      *
-      * @param spe The warning information encapsulated in a SAX parse exception.
-      */
-    public void warning(SAXParseException spe)
-    {
-	out.println("Parser Warning: " + spe.getMessage());
-    }
-
-    /**
-      * Receive notification of a recoverable error.
-      *
-      * @param spe The error information encapsulated in a SAX parse exception.
-      */
-    public void error(SAXParseException spe)
-    {
-	out.println("Parser Error: " + spe.getMessage());
-    }
-
-    /**
-      * Receive notification of a non-recoverable error.
-      *
-      * @param spe The error information encapsulated in a SAX parse exception.
-      * @exception SAXException Always thrown
-      */
-    public void fatalError(SAXParseException spe)
-    throws SAXException
-    {
-	out.println("Parser Fatal Error: " + spe.getMessage());
-	throw spe;
-    }
-
-    /**
-      * Returns the buffered processing message(s).
-      * @return Buffered processing message(s)
-      */
-    public String getMessage()
-    {
-	return outStream.toString();
-    }
-}
-
diff --git a/samples/servlet/ApplyXSLTProperties.java b/samples/servlet/ApplyXSLTProperties.java
deleted file mode 100644
index 69e0ed4..0000000
--- a/samples/servlet/ApplyXSLTProperties.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package servlet;
-
-import java.net.MalformedURLException;
-import javax.servlet.*;
-import javax.servlet.http.*;
-
-/*****************************************************************************************************
- * 
- * ApplyXSLTProperties contains operational parameters for ApplyXSLT based 
- * on program defaults and configuration.  
- * <p>This class is also used to return values for request-time parameters.</p>
- *
- * @author Spencer Shepard (sshepard@us.ibm.com)
- * @author R. Adam King (rak@us.ibm.com)
- * @author Tom Rowe (trowe@us.ibm.com)
- *
- *****************************************************************************************************/
-
-public class ApplyXSLTProperties {
-
-    /**
-      * Program default for parameter "URL"
-      */
-    private final String DEFAULT_URL;
-
-    /**
-      * Program default for parameter "xslURL"
-      */
-    private final String DEFAULT_xslURL;
-    
-    /**
-      * Program default for parameter "debug"
-      */
-    private final boolean DEFAULT_debug;
-
-    /**
-      * Program default for parameter "noConflictWarnings"
-      */
-    private final boolean DEFAULT_noCW;
-    
-    /**
-      * Constructor to use program defaults.
-      */
-    public ApplyXSLTProperties() 
-    {
-	DEFAULT_URL = null;
-	DEFAULT_xslURL = null;
-	DEFAULT_debug = false;
-	DEFAULT_noCW = false;
-    }
-
-    /**
-      * Constructor to use to override program defaults.
-      * @param config Servlet configuration
-      */
-    public ApplyXSLTProperties(ServletConfig config)
-    {
-	String xm = config.getInitParameter("URL"),
-	       xu = config.getInitParameter("xslURL"),
-	       db = config.getInitParameter("debug"),
-	       cw = config.getInitParameter("noConflictWarnings");
-	       
-	if (xm != null) DEFAULT_URL = xm;
-	else DEFAULT_URL = null;
-	if (xu != null) DEFAULT_xslURL = xu;
-	else DEFAULT_xslURL = null;
-	if (db != null) DEFAULT_debug = new Boolean(db).booleanValue();
-	else DEFAULT_debug = false;
-	if (cw != null) DEFAULT_noCW = new Boolean(cw).booleanValue();
-	else DEFAULT_noCW = false;
-    }
-   
-    /**
-      * Given a parameter name, returns the HTTP request's String value; 
-      * if not present in request, returns default String value.
-      * @param request Request to check for default override
-      * @param param Name of the parameter
-      * @return String value of named parameter
-      */
-    public String getRequestParmString(HttpServletRequest request, String param)
-    {
-	if (request != null) { 
-	    String[] paramVals = request.getParameterValues(param); 
-	    if (paramVals != null) 
-		return paramVals[0];
-	}
-	return null;
-    }
-
-    /**
-      * Returns the current setting for "URL".
-      * @param request Request to check for parameter value
-      * @return String value for "URL"
-      * @exception MalformedURLException Will not be thrown
-      */
-    public String getXMLurl(HttpServletRequest request)
-    throws MalformedURLException
-    {
-	String temp = getRequestParmString(request, "URL");
-	if (temp != null)
-	    return temp;
-	return DEFAULT_URL;
-    }     
-    
-    /**
-      * Returns the current setting for "xslURL".
-      * @param request Request to check for parameter value
-      * @return String value for "xslURL"
-      * @exception MalformedURLException Will not be thrown
-      */
-    public String getXSLurl(HttpServletRequest request)
-    throws MalformedURLException
-    {  
-	String temp = getRequestParmString(request, "xslURL");
-	if (temp != null)
-	    return temp;
-	return DEFAULT_xslURL;
-    }
-    
-    /**
-      * Returns the current setting for "debug".
-      * @param request Request to check for parameter value
-      * @return Boolean value for "debug"
-      */
-    public boolean isDebug(HttpServletRequest request)
-    {
-	String temp = getRequestParmString(request, "debug");
-	if (temp != null)
-	    return new Boolean(temp).booleanValue();
-	return DEFAULT_debug;
-    }
-
-    /**
-      * Returns the current setting for "noConflictWarnings".
-      * @param request Request to check for parameter value
-      * @return Boolean value for "noConflictWarnings"
-      */
-    boolean isNoCW(HttpServletRequest request)
-    {
-	String temp = getRequestParmString(request, "noConflictWarnings");
-	if (temp != null)
-	    return new Boolean(temp).booleanValue();
-	return DEFAULT_noCW;
-    }    
-}
\ No newline at end of file
diff --git a/samples/servlet/DefaultApplyXSLTProperties.java b/samples/servlet/DefaultApplyXSLTProperties.java
deleted file mode 100644
index 1fdb967..0000000
--- a/samples/servlet/DefaultApplyXSLTProperties.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package servlet;
-
-import java.net.*;
-import javax.servlet.*;
-import javax.servlet.http.*;
-import java.util.Enumeration;
-import java.util.Properties;
-
-/*****************************************************************************************************
- * 
- * DefaultApplyXSLTProperties contains operational parameters for DefaultApplyXSLT based 
- * on program defaults and configuration.  
- * <p>This class is also used to return values for request-time parameters.</p>
- *
- * @author Spencer Shepard (sshepard@us.ibm.com)
- * @author R. Adam King (rak@us.ibm.com)
- * @author Tom Rowe (trowe@us.ibm.com)
- *
- *****************************************************************************************************/
-
-public class DefaultApplyXSLTProperties extends ApplyXSLTProperties {
-    
-    /**
-      * Program default for parameter "catalog".
-      * @see #getCatalog
-      */
-    private final String DEFAULT_catalog;
-
-    /**
-      * Host used for local context comparisons.
-      * @see #getLocalHost
-      * @see #setLocalHost
-      */
-    protected transient String localHost = null;
-    
-    /**
-     * Server port. Used in toSafeURL() -- fix submitted by Ritesh Kumar.
-     */
-    protected static int port =0;
-
-    /**
-      * Constructor to use program defaults.
-      */
-    public DefaultApplyXSLTProperties()
-    {
-	super();
-	DEFAULT_catalog = null;
-	setLocalHost();
-	// setSystemProperties();
-    }
-
-    /**
-      * Constructor to use to override program defaults.
-      * @param config Servlet configuration
-      * @see #setLocalHost
-      */
-    public DefaultApplyXSLTProperties(ServletConfig config)
-    {
-	    super(config);
-	    String cat = config.getInitParameter("catalog");
-	    if (cat != null) DEFAULT_catalog = cat;
-	    else DEFAULT_catalog = null;
-	    setLocalHost();
-	    setSystemProperties();
-    }
-
-    /**
-      * Sets the name of the local IP host name; this value will be used to constrain untrusted 
-      * XML document and XSL stylesheet URLs to this trusted host.
-      * @see #getLocalHost
-      */
-    protected void setLocalHost()
-    {
-	    try 
-	    { 
-	        localHost = InetAddress.getLocalHost().getHostName();
-	    } 
-	    catch (Exception uhe) 
-	    {
-	      localHost = null;
-	    }
-    }
-
-    /**
-      * Returns the name of trusted IP host.
-      * @return Name of trusted host
-      * @see #setLocalHost
-      */
-    public String getLocalHost()
-    {
-	    return localHost;
-    }
-
-    /**
-      * Returns a URL which is constrained to a trusted IP host.
-      * @param xURL URL or file path to be made safe 
-      * @return Safe URL
-      * @exception MalformedURLException Thrown when xURL is not a valid URL
-      * @see #setLocalHost
-      * @see #getLocalHost
-      */
-    public URL toSafeURL(String xURL, HttpServletRequest request)
-    throws MalformedURLException
-    {
-      // Fix submitted by Ritesh Kumar. Port is included in construction of URL that is returned.
-      if (port == 0)
-        port = request.getServerPort();
-      
-	    if (xURL == null)
-	      return null;
-
-	    if (xURL.startsWith("/")) 
-      {
-	      try 
-        {
-		      return new URL("http", localHost, port, xURL);
-	      }
-        catch (MalformedURLException mue) 
-        {
-	        throw new MalformedURLException("toSafeURL(): " + xURL + 
-					                                " did not map to local");
-	      }
-	    }
-	    URL tempURL = null;
-	    try 
-      { 
-	      tempURL = new URL(xURL);
-	    } 
-      catch (MalformedURLException mue) 
-      {
-	      throw new MalformedURLException("toSafeURL(): " + xURL + 
-					                              " not a valid URL"); 
-	    }
-	    try 
-      { 
-	      return new URL(tempURL.getProtocol(), localHost, 
-			                 port, tempURL.getFile());
-	    } 
-      catch (MalformedURLException mue) 
-      {
-	      throw new MalformedURLException("toSafeURL(): " + xURL + 
-				                          	    " could not be converted to local host");
-	    }
-    }
-
-    /**
-      *	Returns a string representing the constrained URL for the XML document.
-      * If there is no request parameter for the XML document, return the configured default.
-      * @param request May contain an XML document URL parameter
-      * @return String form of XML URL
-      * @exception MalformedURLException Thrown when request URL is not a valid URL or path
-      * @see #toSafeURL
-      */
-    public String getXMLurl(HttpServletRequest request)
-    throws MalformedURLException
-    {
-	    URL url = toSafeURL(getRequestParmString(request, "URL"),request);
-	    if (url == null)
-	      return super.getXMLurl(null);
-	    return url.toExternalForm();
-    }
-
-    /**
-      * Returns a string representing the constrained URL for the XSL stylesheet 
-      * from the request.
-      * @param request May contain an XSL stylesheet URL parameter
-      * @return String form of request XSL URL, or null if request contains no xslURL parameter
-      * @exception MalformedURLException Thrown when request URL is not a valid URL or path
-      * @see #toSafeURL
-      */
-    public String getXSLRequestURL(HttpServletRequest request)
-    throws MalformedURLException
-    {
-	    URL url = toSafeURL(getRequestParmString(request, "xslURL"),request);
-	    if (url == null)
-	        return null;
-	    return url.toExternalForm();
-    }
-
-    /**
-      * Returns a string representing the constrained request URL for the XSL stylesheet.
-      * If there is no request parameter for the XSL stylesheet, return the configured default.
-      * @param request May contain an XSL stylesheet URL parameter
-      * @return String form of XSL URL
-      * @exception MalformedURLException Thrown when request URL is not a valid URL or path
-      * @see #toSafeURL
-      */
-    public String getXSLurl(HttpServletRequest request)
-    throws MalformedURLException
-    {
-	    String reqURL = getXSLRequestURL(request);
-	    if (reqURL != null)
-	        return reqURL;
-	    return super.getXSLurl(null);
-    }
-
-    /**
-      * Returns URLs for all <a href="http://www.ccil.org/~cowan/XML/XCatalog.html">XCatalogs</a> 
-      * that are to be used to process the request.  Catalogs are used to resolve XML public identifiers
-      * into system identifiers.
-      * <p>A single XCatalog can be configured as a default,
-      * but multiple XCatalogs can be specified at request time to augment the configured default.
-      * @param request May contain one or more XCatalog parameters
-      * @return Array of strings for all catalog URLs
-      */
-    public String[] getCatalog(HttpServletRequest request)
-    {
-	    String temp[] = request.getParameterValues("catalog");
-	    if (DEFAULT_catalog == null)
-	        return temp;
-	    if (temp == null) 
-      {
-	      String defaultArray[] = new String [1];
-	      defaultArray[0] = DEFAULT_catalog;
-	      return defaultArray;
-	    }
-	    int i, len = temp.length + 1;
-	    String newCatalogs[] = new String[len];
-	    newCatalogs[0] = DEFAULT_catalog;
-	    for (i=1; i < len; i++) 
-      {
-	      newCatalogs[i] = temp[i-1];
-	    }
-	    return newCatalogs;
-    }
-	
-	 /**
-   * I think we no longer need this. Sets the 3 jaxp core system properties.
-   */	
-    protected void setSystemProperties()
-	{
-	  Properties props = new Properties();
-    props.put("javax.xml.transform.TransformerFactory", 
-              "org.apache.xalan.processor.TransformerFactoryImpl");
-    props.put("javax.xml.parsers.DocumentBuilderFactory", 
-              "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
-    props.put("javax.xml.parsers.SAXParserFactory", 
-              "org.apache.xerces.jaxp.SAXParserFactoryImpl");
-    
-      Properties systemProps = System.getProperties();
-      Enumeration propEnum = props.propertyNames();
-      while(propEnum.hasMoreElements())
-      {
-        String prop = (String)propEnum.nextElement();
-        if(!systemProps.containsKey(prop))
-          systemProps.put(prop, props.getProperty(prop));
-      }
-      System.setProperties(systemProps);
-	}
-
-}
diff --git a/samples/servlet/SimpleXSLTServlet.java b/samples/servlet/SimpleXSLTServlet.java
deleted file mode 100644
index c7c0822..0000000
--- a/samples/servlet/SimpleXSLTServlet.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package servlet;
-
-import javax.servlet.*;
-import javax.servlet.http.*;
-import java.io.*;
-import java.net.URL;
-
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.stream.StreamResult;
-
-/*
- * This sample applies the todo.xsl stylesheet to the
- * todo.xml XML document, and returns the transformation
- * output (HTML) to the client browser.
- *
- * IMPORTANT: For this to work, you must place todo.xsl and todo.xml 
- * in the servlet root directory for documents.
- *
- */
-
-public class SimpleXSLTServlet extends HttpServlet {
-
-  public void init(ServletConfig config) throws ServletException
-  {
-    super.init(config);
-  }
-
-  public void doGet (HttpServletRequest request,
-                     HttpServletResponse response)
-    throws ServletException, IOException
-  {
-    // Output goes in the response stream.
-    PrintWriter out = new PrintWriter (response.getOutputStream());
-    // The servlet returns HTML.
-    response.setContentType("text/html");    
-    try
-    {	
-      TransformerFactory tFactory = TransformerFactory.newInstance();
-      // Get the XML input document and the stylesheet.
-      Source xmlSource = new StreamSource(new URL("file:todo.xml").openStream());
-      Source xslSource = new StreamSource(new URL("file:todo.xsl").openStream());
-      // Generate the transformer.
-      Transformer transformer = tFactory.newTransformer(xslSource);
-      // Perform the transformation, sending the output to the response.
-      transformer.transform(xmlSource, new StreamResult(out));
-    }
-    catch (Exception e)
-    {
-      out.write(e.getMessage());
-      e.printStackTrace(out);    
-    }
-    out.close();
-  }
-  
-}
diff --git a/samples/servlet/UseStylesheetParamServlet.java b/samples/servlet/UseStylesheetParamServlet.java
deleted file mode 100644
index c3840bb..0000000
--- a/samples/servlet/UseStylesheetParamServlet.java
+++ /dev/null
@@ -1,71 +0,0 @@
-
-/*
-Simple Servlet Example using a stylesheet parameter
- */
-package servlet;
-// Imported TraX classes
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerConfigurationException;
-
-// Imported SAX classes
-import org.xml.sax.SAXException;
-
-// Imported java.io and javax.servlet classes
-import java.io.*;
-import javax.servlet.*;
-import javax.servlet.http.*;
-
-public class UseStylesheetParamServlet extends HttpServlet {
-	
-	PrintWriter out;
-	String xslFile, xmlFile, paramValue;
-	public void doGet(HttpServletRequest req,
-		HttpServletResponse res)
-			throws ServletException, IOException {
-		try {
-			res.setContentType("text/html");
-			out = res.getWriter();
-
-      paramValue = req.getParameter("PVAL");
-			xmlFile    = req.getParameter("XML");
-			xslFile    = req.getParameter("XSL");
- 		if (paramValue == null) {
-			out.println(
-			"<h1>No input for paramValue</h1>");
-			return;
-		}
- 		if ( xmlFile == null) {
-			out.println(
-			"<h1>No input for xmlFile</h1>");
-			return;
-		}	
-		if ( xslFile == null) {
-			out.println(
-			"<h1>No input for xslFile</h1>");
-			return;
-		}
-		TransformerFactory tFactory =
-			TransformerFactory.newInstance();
-		Transformer transformer =
-			tFactory.newTransformer(new StreamSource(xslFile));
-
-    // Set the stylesheet parameter (named param1).
-			transformer.setParameter("param1", paramValue);
-    // Perform the transformation.
-			transformer.transform(new StreamSource(xmlFile),
-					                  new StreamResult(out));
-		}		
-    catch (IOException e) {			
-			e.printStackTrace();
-			System.exit(-1);
-		}
-		catch (TransformerException e) {
-      e.printStackTrace(out);
-			return;
-		}
-	}
-}
diff --git a/samples/servlet/XSLTServletWithParams.java b/samples/servlet/XSLTServletWithParams.java
deleted file mode 100644
index 32e73f9..0000000
--- a/samples/servlet/XSLTServletWithParams.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package servlet;
-import javax.servlet.*;
-import javax.servlet.http.*;
-import java.io.*;
-import java.util.Enumeration;
-import java.net.URL;
-
-import org.xml.sax.*;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.stream.StreamResult;
-
-/*
- * This sample takes input parameters in the request URL: a URL
- * parameter for the XML input, an xslURL parameter for the stylesheet,
- * and optional stylesheet parameters.
- * To run the equivalent of SimplestXSLServlet (with the documents in the
- * servlet document root directory), the request URL is
- * http://<server/servletpath>servlet.SimpleXSLServlet?URL=file:todo.xml&xslURL=file:todo.xsl
- *
- * Using a stylesheet Processing Instruction:
- * If the XML document includes a stylesheet PI that you want to use, 
- * omit the xslURL parameter.
- *
- * Sending stylesheet parameters: 
- * If, for example, a servlet takes a stylesheet parameter named param1
- * param1 that you want to set to foo, include param1=foo in the URL.
- */
-
-public class XSLTServletWithParams extends HttpServlet {
-
-  public void init(ServletConfig config) throws ServletException
-  {
-    super.init(config);
-  }
-
-  public void doGet (HttpServletRequest request,
-                     HttpServletResponse response)
-    throws ServletException, IOException
-  {
-    // Output goes in the response stream.
-    PrintWriter out = new PrintWriter (response.getOutputStream());
-    // This servlet is intended to return HTML.
-    response.setContentType("text/html");    
-    try
-    {	
-      TransformerFactory tFactory = TransformerFactory.newInstance();
-      // Get params from URL.
-      String xml = getRequestParam(request, "URL");
-      String xsl = getRequestParam(request, "xslURL");
-      Source xmlSource = null;
-      Source xslSource = null;
-      Transformer transformer = null;
-      // Get the XML input document.
-      if (xml != null && xml.length()> 0)
-        xmlSource = new StreamSource(new URL(xml).openStream());
-      // Get the stylesheet.
-      if (xsl != null && xsl.length()> 0)
-        xslSource = new StreamSource(new URL(xsl).openStream());
-      if (xmlSource != null) // We have an XML input document.
-      {
-        if (xslSource == null) // If no stylesheet, look for PI in XML input document.
-        {
-     	    String media= null , title = null, charset = null;
-          xslSource = tFactory.getAssociatedStylesheet(xmlSource,media, title, charset);
-        }
-        if (xslSource != null) // Now do we have a stylesheet?
-        {
-          transformer = tFactory.newTransformer(xslSource);
-          setParameters(transformer, request); // Set stylesheet params.
-          transformer.transform(xmlSource, new StreamResult(out)); // Perform the transformation.
-        }
-        else
-          out.write("No Stylesheet!");
-      }
-      else
-        out.write("No XML Input Document!");
-    }
-    catch (Exception e)
-    {
-      out.write(e.getMessage());
-      e.printStackTrace(out);    
-    }
-    out.close();
-  }
-  
-  // Get parameters from the request URL.
-  String getRequestParam(HttpServletRequest request, String param)
-  {
-	  if (request != null) 
-    { 
-	    String paramVal = request.getParameter(param); 
-		  return paramVal;
-	  }
-	  return null;
-  }
-  
-  // Set stylesheet parameters from the request URL.
-  void setParameters(Transformer transformer, HttpServletRequest request)
-  {
-    Enumeration paramNames = request.getParameterNames();
-    while (paramNames.hasMoreElements())
-    {
-      String paramName = (String) paramNames.nextElement();
-      try
-      {
-        String paramVal = request.getParameter(paramName);
-        if (paramVal != null)
-          transformer.setParameter(paramName, paramVal);                                            
-      }
-      catch (Exception e)
-      {
-      }
-    }
-  }  
-}
diff --git a/samples/servlet/default.xsl b/samples/servlet/default.xsl
deleted file mode 100644
index e1a85e0..0000000
--- a/samples/servlet/default.xsl
+++ /dev/null
@@ -1,276 +0,0 @@
-<?xml version="1.0"?>
-
-<!--                                                                                -->
-<!--  Default XSL stylesheet for use by com.lotus.xsl.server#DefaultApplyXSL.       -->
-<!--                                                                                -->
-<!--  This stylesheet mimics the default behavior of IE when XML data is displayed  -->
-<!--  without a corresponding XSL stylesheet.  This stylesheet uses JavaScript      -->
-<!--  to accommodate node expansion and contraction.                                -->
-<!--                                                                                -->
-
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
-                xmlns="http://www.w3.org/TR/REC-html40">
-                
-<xsl:output method="html" indent="no"/>
-<xsl:strip-space elements="*"/>
-
-<xsl:template match="/">
-  <HTML>
-    <HEAD>
-      <STYLE type="text/css">
-        BODY {font:x-small 'Verdana'; margin-right:1.5em}
-      <!-- container for expanding/collapsing content -->
-        .c  {cursor:hand}
-      <!-- button - contains +/-/nbsp -->
-        .b  {color:red; font-family:'Courier New'; font-weight:bold; text-decoration:none}
-      <!-- element container -->
-        .e  {margin-left:1em; text-indent:-1em; margin-right:1em}
-      <!-- comment or cdata -->
-        .k  {margin-left:1em; text-indent:-1em; margin-right:1em}
-      <!-- tag -->
-        .t  {color:#990000}
-      <!-- tag in xsl namespace -->
-        .xt {color:#990099}
-      <!-- attribute in xml or xmlns namespace -->
-        .ns {color:red}
-      <!-- markup characters -->
-        .m  {color:blue}
-      <!-- text node -->
-        .tx {font-weight:bold}
-      <!-- multi-line (block) cdata -->
-        .db {text-indent:0px; margin-left:1em; margin-top:0px; margin-bottom:0px;
-             padding-left:.3em; border-left:1px solid #CCCCCC; font:small Courier}
-      <!-- single-line (inline) cdata -->
-        .di {font:small Courier}
-      <!-- DOCTYPE declaration -->
-        .d  {color:blue}
-      <!-- pi -->
-        .pi {color:blue}
-      <!-- multi-line (block) comment -->
-        .cb {text-indent:0px; margin-left:1em; margin-top:0px; margin-bottom:0px;
-             padding-left:.3em; font:small Courier; color:#888888}
-      <!-- single-line (inline) comment -->
-        .ci {font:small Courier; color:#888888}
-        PRE {margin:0px; display:inline}
-      </STYLE>
-
-      <SCRIPT type="text/javascript"><xsl:comment><![CDATA[
-        // Detect and switch the display of CDATA and comments from an inline view
-        //  to a block view if the comment or CDATA is multi-line.
-        function f(e)
-        {
-          // if this element is an inline comment, and contains more than a single
-          //  line, turn it into a block comment.
-          if (e.className == "ci") {
-            if (e.children(0).innerText.indexOf("\n") > 0)
-              fix(e, "cb");
-          }
-          
-          // if this element is an inline cdata, and contains more than a single
-          //  line, turn it into a block cdata.
-          if (e.className == "di") {
-            if (e.children(0).innerText.indexOf("\n") > 0)
-              fix(e, "db");
-          }
-          
-          // remove the id since we only used it for cleanup
-          e.id = "";
-        }
-        
-        // Fix up the element as a "block" display and enable expand/collapse on it
-        function fix(e, cl)
-        {
-          // change the class name and display value
-          e.className = cl;
-          e.style.display = "block";
-          
-          // mark the comment or cdata display as a expandable container
-          j = e.parentElement.children(0);
-          j.className = "c";
-
-          // find the +/- symbol and make it visible - the dummy link enables tabbing
-          k = j.children(0);
-          k.style.visibility = "visible";
-          k.href = "#";
-        }
-
-        // Change the +/- symbol and hide the children.  This function works on "element"
-        //  displays
-        function ch(e)
-        {
-          // find the +/- symbol
-          mark = e.children(0).children(0);
-          
-          // if it is already collapsed, expand it by showing the children
-          if (mark.innerText == "+")
-          {
-            mark.innerText = "-";
-            for (var i = 1; i < e.children.length; i++)
-              e.children(i).style.display = "block";
-          }
-          
-          // if it is expanded, collapse it by hiding the children
-          else if (mark.innerText == "-")
-          {
-            mark.innerText = "+";
-            for (var i = 1; i < e.children.length; i++)
-              e.children(i).style.display="none";
-          }
-        }
-        
-        // Change the +/- symbol and hide the children.  This function work on "comment"
-        //  and "cdata" displays
-        function ch2(e)
-        {
-          // find the +/- symbol, and the "PRE" element that contains the content
-          mark = e.children(0).children(0);
-          contents = e.children(1);
-          
-          // if it is already collapsed, expand it by showing the children
-          if (mark.innerText == "+")
-          {
-            mark.innerText = "-";
-            // restore the correct "block"/"inline" display type to the PRE
-            if (contents.className == "db" || contents.className == "cb")
-              contents.style.display = "block";
-            else contents.style.display = "inline";
-          }
-          
-          // if it is expanded, collapse it by hiding the children
-          else if (mark.innerText == "-")
-          {
-            mark.innerText = "+";
-            contents.style.display = "none";
-          }
-        }
-        
-        // Handle a mouse click
-        function cl()
-        {
-          e = window.event.srcElement;
-          
-          // make sure we are handling clicks upon expandable container elements
-          if (e.className != "c")
-          {
-            e = e.parentElement;
-            if (e.className != "c")
-            {
-              return;
-            }
-          }
-          e = e.parentElement;
-          
-          // call the correct funtion to change the collapse/expand state and display
-          if (e.className == "e")
-            ch(e);
-          if (e.className == "k")
-            ch2(e);
-        }
-        
-        // Erase bogus link info from the status window
-        function h()
-        {
-          window.status=" ";
-        }
-
-        // Set the onclick handler
-        document.onclick = cl;
-        
-      ]]>//</xsl:comment></SCRIPT>
-    </HEAD>
-
-    <BODY class="st"><xsl:apply-templates/></BODY>
-
-  </HTML>
-</xsl:template>
-
-<!-- Templates for each node type follows.  The output of each template has a similar structure
-  to enable script to walk the result tree easily for handling user interaction. -->
-  
-<!-- Template for pis not handled elsewhere -->
-<xsl:template match="processing-instruction()">
-  <DIV class="e">
-  <SPAN class="b">&#160;</SPAN>
-  <SPAN class="m">&lt;?</SPAN><SPAN class="pi"><xsl:value-of select="name(.)"/> <xsl:value-of select="."/></SPAN><SPAN class="m">?&gt;</SPAN>
-  </DIV>
-</xsl:template>
-
-<!-- Template for the XML declaration.  Need a separate template because the pseudo-attributes
-    are actually exposed as attributes instead of just element content, as in other pis 
-<xsl:template match="processing-instruction('xml')">
-  <DIV class="e">
-  <SPAN class="b">&#160;</SPAN>
-  <SPAN class="m">&lt;?</SPAN><SPAN class="pi">xml <xsl:for-each select="@*"><xsl:value-of select="name(.)"/>="<xsl:value-of select="."/>" </xsl:for-each></SPAN><SPAN class="m">?&gt;</SPAN>
-  </DIV>
-</xsl:template>
--->
-
-<!-- Template for attributes not handled elsewhere -->
-<xsl:template match="@*"><SPAN class="t"><xsl:text> </xsl:text><xsl:value-of select="name(.)"/></SPAN><SPAN class="m">="</SPAN><B><xsl:value-of select="."/></B><SPAN class="m">"</SPAN></xsl:template>
-
-<!-- Template for attributes in the xmlns or xml namespace
-<xsl:template match="@xmlns:*|@xmlns|@xml:*"><SPAN class="ns"> <xsl:value-of select="name(.)"/></SPAN><SPAN class="m">="</SPAN><B class="ns"><xsl:value-of select="."/></B><SPAN class="m">"</SPAN></xsl:template>
--->
-
-<!-- Template for text nodes -->
-<xsl:template match="text()">
-  <xsl:choose><xsl:when test="name(.) = '#cdata-section'"><xsl:call-template name="cdata"/></xsl:when>
-  <xsl:otherwise><DIV class="e">
-  <SPAN class="b">&#160;</SPAN>
-  <SPAN class="tx"><xsl:value-of select="."/></SPAN>
-  </DIV></xsl:otherwise></xsl:choose>
-</xsl:template>
-  
-<!-- Template for comment nodes -->
-<xsl:template match="comment()">
-  <DIV class="k">
-  <SPAN><A class="b" onclick="return false" onfocus="h()" STYLE="visibility:hidden">-</A> <SPAN class="m">&lt;!--</SPAN></SPAN>
-  <SPAN id="clean" class="ci"><PRE><xsl:value-of select="."/></PRE></SPAN>
-  <SPAN class="b">&#160;</SPAN> <SPAN class="m">--&gt;</SPAN>
-  <SCRIPT>f(clean);</SCRIPT></DIV>
-</xsl:template>
-
-<!-- Template for cdata nodes -->
-<xsl:template name="cdata">
-  <DIV class="k">
-  <SPAN><A class="b" onclick="return false" onfocus="h()" STYLE="visibility:hidden">-</A> <SPAN class="m">&lt;![CDATA[</SPAN></SPAN>
-  <SPAN id="clean" class="di"><PRE><xsl:value-of select="."/></PRE></SPAN>
-  <SPAN class="b">&#160;</SPAN> <SPAN class="m">]]&gt;</SPAN>
-  <SCRIPT>f(clean);</SCRIPT></DIV>
-</xsl:template>
-
-<!-- Template for elements not handled elsewhere (leaf nodes) -->
-<xsl:template match="*">
-  <DIV class="e"><DIV STYLE="margin-left:1em;text-indent:-2em">
-  <SPAN class="b">&#160;</SPAN>
-  <SPAN class="m">&lt;</SPAN><SPAN class="t"><xsl:value-of select="name(.)"/></SPAN> <xsl:apply-templates select="@*"/><SPAN class="m"> /&gt;</SPAN>
-  </DIV></DIV>
-</xsl:template>
-  
-<!-- Template for elements with comment, pi and/or cdata children
-<xsl:template match="*[comment() or processing-instruction() or cdata()]">
-  <DIV class="e">
-  <DIV class="c"><A href="#" onclick="return false" onfocus="h()" class="b">-</A> <SPAN class="m">&lt;</SPAN><SPAN><xsl:attribute name="class"><xsl:if test="xsl:*">x</xsl:if>t</xsl:attribute><xsl:value-of select="name(.)"/></SPAN><xsl:apply-templates select="@*"/> <SPAN class="m">&gt;</SPAN></DIV>
-  <DIV><xsl:apply-templates/>
-  <DIV><SPAN class="b">&#160;</SPAN> <SPAN class="m">&lt;/</SPAN><SPAN><xsl:attribute name="class"><xsl:if test="xsl:*">x</xsl:if>t</xsl:attribute><xsl:value-of select="name(.)"/></SPAN><SPAN class="m">&gt;</SPAN></DIV>
-  </DIV></DIV>
-</xsl:template> -->
-
-<!-- Template for elements with only text children -->
-<xsl:template match="*[text() and not(comment() or processing-instruction() or *)]">
-  <DIV class="e"><DIV STYLE="margin-left:1em;text-indent:-2em">
-  <SPAN class="b">&#160;</SPAN> <SPAN class="m">&lt;</SPAN><SPAN class="t"><xsl:value-of select="name(.)"/></SPAN><xsl:apply-templates select="@*"/>
-  <SPAN class="m">&gt;</SPAN><SPAN class="tx"><xsl:value-of select="."/></SPAN><SPAN class="m">&lt;/</SPAN><SPAN class="t"><xsl:value-of select="name(.)"/></SPAN><SPAN class="m">&gt;</SPAN>
-  </DIV></DIV>
-</xsl:template>
-
-<!-- Template for elements with element children -->
-<xsl:template match="*[*]">
-  <DIV class="e">
-  <DIV class="c" STYLE="margin-left:1em;text-indent:-2em"><A href="#" onclick="return false" onfocus="h()" class="b">-</A> <SPAN class="m">&lt;</SPAN><SPAN class="t"><xsl:value-of select="name(.)"/></SPAN><xsl:apply-templates select="@*"/><SPAN class="m">&gt;</SPAN></DIV>
-  <DIV><xsl:apply-templates/>
-  <DIV><SPAN class="b">&#160;</SPAN><SPAN class="m">&lt;/</SPAN><SPAN class="t"><xsl:value-of select="name(.)"/></SPAN><SPAN class="m">&gt;</SPAN></DIV>
-  </DIV></DIV>
-</xsl:template>
-
-</xsl:stylesheet>
\ No newline at end of file
diff --git a/samples/servlet/default2.xsl b/samples/servlet/default2.xsl
deleted file mode 100644
index 1619f3f..0000000
--- a/samples/servlet/default2.xsl
+++ /dev/null
@@ -1,152 +0,0 @@
-<?xml version="1.0"?>
-
-<!--                                                                                -->
-<!--  Default XSL stylesheet for use by com.lotus.xsl.server#DefaultApplyXSL.       -->
-<!--                                                                                -->
-<!--  This stylesheet mimics the default behavior of IE when XML data is displayed  -->
-<!--  without a corresponding XSL stylesheet.  This stylesheet uses no JavaScript   -->
-<!--  and displays all nodes as fully expanded.                                     -->
-<!--                                                                                -->
-
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
-                xmlns="http://www.w3.org/TR/REC-html40">
-                
-<xsl:output method="html" indent="no"/>
-<xsl:strip-space elements="*"/>
-
-<xsl:template match="/">
-  <HTML>
-    <HEAD>
-      <STYLE type="text/css">
-        BODY {font:x-small 'Verdana'; margin-right:1.5em}
-      <!-- container for expanding/collapsing content -->
-        .c  {cursor:hand}
-      <!-- button - contains +/-/nbsp -->
-        .b  {color:red; font-family:'Courier New'; font-weight:bold; text-decoration:none}
-      <!-- element container -->
-        .e  {margin-left:1em; text-indent:-1em; margin-right:1em}
-      <!-- comment or cdata -->
-        .k  {margin-left:1em; text-indent:-1em; margin-right:1em}
-      <!-- tag -->
-        .t  {color:#990000}
-      <!-- tag in xsl namespace -->
-        .xt {color:#990099}
-      <!-- attribute in xml or xmlns namespace -->
-        .ns {color:red}
-      <!-- markup characters -->
-        .m  {color:blue}
-      <!-- text node -->
-        .tx {font-weight:bold}
-      <!-- multi-line (block) cdata -->
-        .db {text-indent:0px; margin-left:1em; margin-top:0px; margin-bottom:0px;
-             padding-left:.3em; border-left:1px solid #CCCCCC; font:small Courier}
-      <!-- single-line (inline) cdata -->
-        .di {font:small Courier}
-      <!-- DOCTYPE declaration -->
-        .d  {color:blue}
-      <!-- pi -->
-        .pi {color:blue}
-      <!-- multi-line (block) comment -->
-        .cb {text-indent:0px; margin-left:1em; margin-top:0px; margin-bottom:0px;
-             padding-left:.3em; font:small Courier; color:#888888}
-      <!-- single-line (inline) comment -->
-        .ci {font:small Courier; color:#888888}
-        PRE {margin:0px; display:inline}
-      </STYLE>
-    </HEAD>
-
-    <BODY class="st"><xsl:apply-templates/></BODY>
-
-  </HTML>
-</xsl:template>
-
-<!-- Templates for each node type follows.  The output of each template has a similar structure
-  to enable script to walk the result tree easily for handling user interaction. -->
-  
-<!-- Template for pis not handled elsewhere -->
-<xsl:template match="processing-instruction()">
-  <DIV class="e">
-  <SPAN class="b">&#160;</SPAN>
-  <SPAN class="m">&lt;?</SPAN><SPAN class="pi"><xsl:value-of select="name(.)"/> <xsl:value-of select="."/></SPAN><SPAN class="m">?&gt;</SPAN>
-  </DIV>
-</xsl:template>
-
-<!-- Template for the XML declaration.  Need a separate template because the pseudo-attributes
-    are actually exposed as attributes instead of just element content, as in other pis 
-<xsl:template match="processing-instruction('xml')">
-  <DIV class="e">
-  <SPAN class="b">&#160;</SPAN>
-  <SPAN class="m">&lt;?</SPAN><SPAN class="pi">xml <xsl:for-each select="@*"><xsl:value-of select="name(.)"/>="<xsl:value-of select="."/>" </xsl:for-each></SPAN><SPAN class="m">?&gt;</SPAN>
-  </DIV>
-</xsl:template>
--->
-
-<!-- Template for attributes not handled elsewhere -->
-<xsl:template match="@*"><SPAN class="t"><xsl:text> </xsl:text><xsl:value-of select="name(.)"/></SPAN><SPAN class="m">="</SPAN><B><xsl:value-of select="."/></B><SPAN class="m">"</SPAN></xsl:template>
-
-<!-- Template for attributes in the xmlns or xml namespace
-<xsl:template match="@xmlns:*|@xmlns|@xml:*"><SPAN class="ns"> <xsl:value-of select="name(.)"/></SPAN><SPAN class="m">="</SPAN><B class="ns"><xsl:value-of select="."/></B><SPAN class="m">"</SPAN></xsl:template>
--->
-
-<!-- Template for text nodes -->
-<xsl:template match="text()">
-  <xsl:choose><xsl:when test="name(.) = '#cdata-section'"><xsl:call-template name="cdata"/></xsl:when>
-  <xsl:otherwise><DIV class="e">
-  <SPAN class="b">&#160;</SPAN>
-  <SPAN class="tx"><xsl:value-of select="."/></SPAN>
-  </DIV></xsl:otherwise></xsl:choose>
-</xsl:template>
-  
-<!-- Template for comment nodes -->
-<xsl:template match="comment()">
-  <DIV class="k">
-  <SPAN><SPAN class="b" STYLE="visibility:hidden">-</SPAN> <SPAN class="m">&lt;!--</SPAN></SPAN>
-  <SPAN class="cb"><PRE><xsl:value-of select="."/></PRE></SPAN>
-  <SPAN class="b">&#160;</SPAN> <SPAN class="m">--&gt;</SPAN>
-  </DIV>
-</xsl:template>
-
-<!-- Template for cdata nodes -->
-<xsl:template name="cdata">
-  <DIV class="k">
-  <SPAN><SPAN class="b" STYLE="visibility:hidden">-</SPAN> <SPAN class="m">&lt;![CDATA[</SPAN></SPAN>
-  <SPAN class="db"><PRE><xsl:value-of select="."/></PRE></SPAN>
-  <SPAN class="b">&#160;</SPAN> <SPAN class="m">]]&gt;</SPAN>
-  </DIV>
-</xsl:template>
-
-<!-- Template for elements not handled elsewhere (leaf nodes) -->
-<xsl:template match="*">
-  <DIV class="e"><DIV STYLE="margin-left:1em;text-indent:-2em">
-  <SPAN class="b">&#160;</SPAN>
-  <SPAN class="m">&lt;</SPAN><SPAN class="t"><xsl:value-of select="name(.)"/></SPAN> <xsl:apply-templates select="@*"/><SPAN class="m"> /&gt;</SPAN>
-  </DIV></DIV>
-</xsl:template>
-  
-<!-- Template for elements with comment, pi and/or cdata children
-<xsl:template match="*[comment() or processing-instruction() or cdata()]">
-  <DIV class="e">
-  <DIV class="c"><A href="#" onclick="return false" onfocus="h()" class="b">-</A> <SPAN class="m">&lt;</SPAN><SPAN><xsl:attribute name="class"><xsl:if test="xsl:*">x</xsl:if>t</xsl:attribute><xsl:value-of select="name(.)"/></SPAN><xsl:apply-templates select="@*"/> <SPAN class="m">&gt;</SPAN></DIV>
-  <DIV><xsl:apply-templates/>
-  <DIV><SPAN class="b">&#160;</SPAN> <SPAN class="m">&lt;/</SPAN><SPAN><xsl:attribute name="class"><xsl:if test="xsl:*">x</xsl:if>t</xsl:attribute><xsl:value-of select="name(.)"/></SPAN><SPAN class="m">&gt;</SPAN></DIV>
-  </DIV></DIV>
-</xsl:template> -->
-
-<!-- Template for elements with only text children -->
-<xsl:template match="*[text() and not(comment() or processing-instruction() or *)]">
-  <DIV class="e"><DIV STYLE="margin-left:1em;text-indent:-2em">
-  <SPAN class="b">&#160;</SPAN> <SPAN class="m">&lt;</SPAN><SPAN class="t"><xsl:value-of select="name(.)"/></SPAN><xsl:apply-templates select="@*"/>
-  <SPAN class="m">&gt;</SPAN><SPAN class="tx"><xsl:value-of select="."/></SPAN><SPAN class="m">&lt;/</SPAN><SPAN class="t"><xsl:value-of select="name(.)"/></SPAN><SPAN class="m">&gt;</SPAN>
-  </DIV></DIV>
-</xsl:template>
-
-<!-- Template for elements with element children -->
-<xsl:template match="*[*]">
-  <DIV class="e">
-  <DIV class="c" STYLE="margin-left:1em;text-indent:-2em"><SPAN class="b">-</SPAN><SPAN class="m">&lt;</SPAN><SPAN class="t"><xsl:value-of select="name(.)"/></SPAN><xsl:apply-templates select="@*"/> <SPAN class="m">&gt;</SPAN></DIV>
-  <DIV><xsl:apply-templates/>
-  <DIV><SPAN class="b">&#160;</SPAN> <SPAN class="m">&lt;/</SPAN><SPAN class="t"><xsl:value-of select="name(.)"/></SPAN><SPAN class="m">&gt;</SPAN></DIV>
-  </DIV></DIV>
-</xsl:template>
-
-</xsl:stylesheet>
\ No newline at end of file
diff --git a/samples/servlet/fooparam.xml b/samples/servlet/fooparam.xml
deleted file mode 100644
index 03c32b5..0000000
--- a/samples/servlet/fooparam.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0"?>
-<doc>Hello</doc>
diff --git a/samples/servlet/fooparam.xsl b/samples/servlet/fooparam.xsl
deleted file mode 100644
index a6691d1..0000000
--- a/samples/servlet/fooparam.xsl
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:param name="param1" select="'default value'"/>
-  <xsl:template match="doc">
-    <html><body><p><xsl:value-of select="$param1"/></p></body></html>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/samples/servlet/media.properties b/samples/servlet/media.properties
deleted file mode 100644
index 1b3cf45..0000000
--- a/samples/servlet/media.properties
+++ /dev/null
@@ -1,40 +0,0 @@
-# This property file is used by com.lotus.xsl.server.DefaultApplyXSL.
-#
-# Each line below specifies a mapping rule between a value contained in the HTTP request's user-Agent 
-# field and a value to be scanned for in XSL stylesheet(s) associated with the XML data. This mapping 
-# enables relationships to be defined between client capabilities and stylesheets capable of acting 
-# on these capabilities.
-#
-# The rules defined below are order-significant.  In other words, if the first rule is unsuccessful,
-# the second rule will be tried, etc.  The media value "unknown" will be used when no rules are
-# satisfied.
-#
-# Example: 
-#
-# Mapping rules of...
-#
-#   MSIE=explorer
-#   MSPIE=pocketexplorer
-#
-# ...and XML data that contains XSL stylesheet associations of...
-#
-# <?xml-stylesheet                 media="explorer"       href="alldata.xsl"  type="text/xsl"?>
-# <?xml-stylesheet alternate="yes" media="pocketexplorer" href="somedata.xsl" type="text/xsl"?>
-#
-# ...and an HTTP request that contains a user-Agent value of...
-#    
-#   foo MSPIE bar
-#
-# ...will apply the XSL stylesheet somedata.xsl.
-#
-MSIE=explorer
-MSPIE=pocketexplorer
-HandHTTP=handweb
-Mozilla=netscape
-Lynx=lynx
-Opera=opera
-Java=java
-AvantGo=avantgo
-Nokia=nokia
-UP.Browser=up
-DoCoMo=imode
diff --git a/samples/servlet/readme.html b/samples/servlet/readme.html
deleted file mode 100644
index ec8936f..0000000
--- a/samples/servlet/readme.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
-	<title>Xalan Samples</title>
-</head>
-<body>
-<h2>Xalan Samples</h2>
-<p>For information about the samples (what they illustrate and how to run them), see <a href="../../docs/samples.html">Samples</a>.</p>
-
-
-</body>
-</html>
diff --git a/samples/trax/ExampleContentHandler.java b/samples/trax/ExampleContentHandler.java
deleted file mode 100644
index 3e308f4..0000000
--- a/samples/trax/ExampleContentHandler.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.Locator;
-
-public class ExampleContentHandler implements ContentHandler
-{
-  public void setDocumentLocator (Locator locator)
-  {
-    System.out.println("setDocumentLocator");
-  }
-
-
-  public void startDocument ()
-    throws SAXException
-  {
-    System.out.println("startDocument");
-  }
-
-
-  public void endDocument()
-    throws SAXException
-  {
-    System.out.println("endDocument");
-  }
-
-
-  public void startPrefixMapping (String prefix, String uri)
-    throws SAXException
-  {
-    System.out.println("startPrefixMapping: "+prefix+", "+uri);
-  }
-
-
-  public void endPrefixMapping (String prefix)
-    throws SAXException
-  {
-    System.out.println("endPrefixMapping: "+prefix);
-  }
-
-
-  public void startElement (String namespaceURI, String localName,
-                            String qName, Attributes atts)
-    throws SAXException
-  {
-    System.out.print("startElement: "+namespaceURI+", "+namespaceURI+
-                       ", "+qName);
-    int n = atts.getLength();
-    for(int i = 0; i < n; i++)
-    {
-      System.out.print(", "+atts.getQName(i));
-    }
-    System.out.println("");
-  }
-
-
-  public void endElement (String namespaceURI, String localName,
-                          String qName)
-    throws SAXException
-  {
-    System.out.println("endElement: "+namespaceURI+", "+namespaceURI+
-                       ", "+qName);
-  }
-
-
-  public void characters (char ch[], int start, int length)
-    throws SAXException
-  {
-    String s = new String(ch, start, (length > 30) ? 30 : length);
-    if(length > 30)
-      System.out.println("characters: \""+s+"\"...");
-    else
-      System.out.println("characters: \""+s+"\"");
-  }
-
-
-  public void ignorableWhitespace (char ch[], int start, int length)
-    throws SAXException
-  {
-    System.out.println("ignorableWhitespace");
-  }
-
-
-  public void processingInstruction (String target, String data)
-    throws SAXException
-  {
-    System.out.println("processingInstruction: "+target+", "+target);
-  }
-
-
-  public void skippedEntity (String name)
-    throws SAXException
-  {
-    System.out.println("skippedEntity: "+name);
-  }
-
-}
diff --git a/samples/trax/Examples.java b/samples/trax/Examples.java
deleted file mode 100644
index e8efecc..0000000
--- a/samples/trax/Examples.java
+++ /dev/null
@@ -1,880 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-import javax.xml.transform.*;
-import javax.xml.transform.sax.*;
-import javax.xml.transform.dom.*;
-import javax.xml.transform.stream.*;
-
-// Needed java classes
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.IOException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileReader;
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
-
-import java.util.Properties;
-
-// Needed SAX classes
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.Parser;
-import org.xml.sax.helpers.ParserAdapter;
-import org.xml.sax.helpers.XMLReaderFactory;
-import org.xml.sax.XMLReader;
-import org.xml.sax.XMLFilter;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.ext.DeclHandler;
-
-// Needed DOM classes
-import org.w3c.dom.Node;
-
-// Needed JAXP classes
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import java.io.BufferedInputStream;    // dml
-
-/**
- * Some examples to show how the Simple API for Transformations
- * could be used.
- * 
- * Xalan Developers: please see 
- * xml-xalan/test/java/src/org/apache/qetest/trax/ExamplesTest.java
- * when updating this file, and update that test file as well.
- *
- * @author <a href="mailto:scott_boag@lotus.com">Scott Boag</a>
- */
-public class Examples
-{
-  /**
-   * Method main
-   */
-  public static void main(String argv[])
-          throws TransformerException, TransformerConfigurationException, IOException, SAXException,
-                 ParserConfigurationException, FileNotFoundException
-  {
-    System.out.println("\n\n==== exampleSimple ====");
-    try {
-        exampleSimple1("xml/foo.xml", "xsl/foo.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleSimple2 ====");
-    try {
-        exampleSimple2("xml/foo.xml", "xsl/foo.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleFromStream ====");
-    try {
-        exampleFromStream("xml/foo.xml", "xsl/foo.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleFromReader ====");
-    try {
-        exampleFromReader("xml/foo.xml", "xsl/foo.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleUseTemplatesObj ====");
-    try {
-        exampleUseTemplatesObj("xml/foo.xml", "xml/baz.xml", "xsl/foo.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleContentHandlerToContentHandler ====");
-    try {
-        exampleContentHandlerToContentHandler("xml/foo.xml", "xsl/foo.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleXMLReader ====");
-    try {
-        exampleXMLReader("xml/foo.xml", "xsl/foo.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleXMLFilter ====");
-    try {
-        exampleXMLFilter("xml/foo.xml", "xsl/foo.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleXMLFilterChain ====");
-    try {
-        exampleXMLFilterChain("xml/foo.xml", "xsl/foo.xsl", "xsl/foo2.xsl", "xsl/foo3.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleDOM2DOM ====");
-    try {
-        exampleDOM2DOM("xml/foo.xml", "xsl/foo.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleParam ====");
-    try {
-        exampleParam("xml/foo.xml", "xsl/foo.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleTransformerReuse ====");
-    try {
-        exampleTransformerReuse("xml/foo.xml", "xsl/foo.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleOutputProperties ====");
-    try {
-        exampleOutputProperties("xml/foo.xml", "xsl/foo.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleUseAssociated ====");
-    try {
-        exampleUseAssociated("xml/foo.xml");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleContentHandler2DOM ====");
-    try {
-        exampleContentHandler2DOM("xml/foo.xml", "xsl/foo.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleAsSerializer ====");
-    try {
-        exampleAsSerializer("xml/foo.xml", "xsl/foo.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-    
-    System.out.println("\n\n==== exampleContentHandler2DOM ====");
-    try {
-        exampleContentHandler2DOM("xml/foo.xml", "xsl/foo.xsl");
-    } catch( Exception ex ) { 
-        handleException(ex);
-    } 
-
-    System.out.println("\n==== done! ====");
-  }
-  
-  /**
-   * Show the simplest possible transformation from system id 
-   * to output stream.
-   */
-  public static void exampleSimple1(String sourceID, String xslID)
-    throws TransformerException, TransformerConfigurationException
-  {
-    // Create a transform factory instance.
-    TransformerFactory tfactory = TransformerFactory.newInstance();
-    
-    // Create a transformer for the stylesheet.
-    Transformer transformer 
-      = tfactory.newTransformer(new StreamSource(xslID));
-    
-    // Transform the source XML to System.out.
-    transformer.transform( new StreamSource(sourceID),
-                           new StreamResult(System.out));
-  }
-  
-  /**
-   * Show the simplest possible transformation from File 
-   * to a File.
-   */
-  public static void exampleSimple2(String sourceID, String xslID)
-    throws TransformerException, TransformerConfigurationException
-  {
-    // Create a transform factory instance.
-    TransformerFactory tfactory = TransformerFactory.newInstance();
-    
-    // Create a transformer for the stylesheet.
-    Transformer transformer 
-      = tfactory.newTransformer(new StreamSource(xslID));
-    
-    // Transform the source XML to System.out.
-    transformer.transform( new StreamSource(new File(sourceID)),
-                           new StreamResult(new File("foo.out")));
-  }
-
-  
-  /**
-   * Show simple transformation from input stream to output stream.
-   */
-  public static void exampleFromStream(String sourceID, String xslID)
-    throws TransformerException, TransformerConfigurationException,
-           FileNotFoundException
-  {
-    // Create a transform factory instance.
-    TransformerFactory tfactory = TransformerFactory.newInstance();
-
-    InputStream xslIS = new BufferedInputStream(new FileInputStream(xslID));
-    StreamSource xslSource = new StreamSource(xslIS);
-    // Note that if we don't do this, relative URLs can not be resolved correctly!
-    xslSource.setSystemId(xslID);
-
-    // Create a transformer for the stylesheet.
-    Transformer transformer = tfactory.newTransformer(xslSource);
-    
-    InputStream xmlIS = new BufferedInputStream(new FileInputStream(sourceID));
-    StreamSource xmlSource = new StreamSource(xmlIS);
-    // Note that if we don't do this, relative URLs can not be resolved correctly!
-    xmlSource.setSystemId(sourceID);
-    
-    // Transform the source XML to System.out.
-    transformer.transform( xmlSource, new StreamResult(System.out));
-  }
-  
-  /**
-   * Show simple transformation from reader to output stream.  In general 
-   * this use case is discouraged, since the XML encoding can not be 
-   * processed.
-   */
-  public static void exampleFromReader(String sourceID, String xslID)
-    throws TransformerException, TransformerConfigurationException,
-           FileNotFoundException
-  {
-    // Create a transform factory instance.
-    TransformerFactory tfactory = TransformerFactory.newInstance();
-
-    // Note that in this case the XML encoding can not be processed!
-    Reader xslReader = new BufferedReader(new FileReader(xslID));
-    StreamSource xslSource = new StreamSource(xslReader);
-    // Note that if we don't do this, relative URLs can not be resolved correctly!
-    xslSource.setSystemId(xslID);
-
-    // Create a transformer for the stylesheet.
-    Transformer transformer = tfactory.newTransformer(xslSource);
-    
-    // Note that in this case the XML encoding can not be processed!
-    Reader xmlReader = new BufferedReader(new FileReader(sourceID));
-    StreamSource xmlSource = new StreamSource(xmlReader);
-    // Note that if we don't do this, relative URLs can not be resolved correctly!
-    xmlSource.setSystemId(sourceID);
-    
-    // Transform the source XML to System.out.
-    transformer.transform( xmlSource, new StreamResult(System.out));
-  }
-
-
- 
-  /**
-   * Show the simplest possible transformation from system id to output stream.
-   */
-  public static void exampleUseTemplatesObj(String sourceID1, 
-                                    String sourceID2, 
-                                    String xslID)
-          throws TransformerException, TransformerConfigurationException
-  {
-
-    TransformerFactory tfactory = TransformerFactory.newInstance();
-    
-    // Create a templates object, which is the processed, 
-    // thread-safe representation of the stylesheet.
-    Templates templates = tfactory.newTemplates(new StreamSource(xslID));
-
-    // Illustrate the fact that you can make multiple transformers 
-    // from the same template.
-    Transformer transformer1 = templates.newTransformer();
-    Transformer transformer2 = templates.newTransformer();
-    
-    System.out.println("\n\n----- transform of "+sourceID1+" -----");
-    
-    transformer1.transform(new StreamSource(sourceID1),
-                          new StreamResult(System.out));
-    
-    System.out.println("\n\n----- transform of "+sourceID2+" -----");
-    
-    transformer2.transform(new StreamSource(sourceID2),
-                          new StreamResult(System.out));
-  }
-  
-
-
-  /**
-   * Show the Transformer using SAX events in and SAX events out.
-   */
-  public static void exampleContentHandlerToContentHandler(String sourceID, 
-                                                           String xslID)
-          throws TransformerException, 
-                 TransformerConfigurationException, 
-                 SAXException, IOException
-  {
-    TransformerFactory tfactory = TransformerFactory.newInstance();
-
-    // Does this factory support SAX features?
-    if (tfactory.getFeature(SAXSource.FEATURE))
-    {
-      // If so, we can safely cast.
-      SAXTransformerFactory stfactory = ((SAXTransformerFactory) tfactory);
-      
-      // A TransformerHandler is a ContentHandler that will listen for 
-      // SAX events, and transform them to the result.
-      TransformerHandler handler 
-        = stfactory.newTransformerHandler(new StreamSource(xslID));
-
-      // Set the result handling to be a serialization to System.out.
-      Result result = new SAXResult(new ExampleContentHandler());
-      handler.setResult(result);
-      
-      // Create a reader, and set it's content handler to be the TransformerHandler.
-      XMLReader reader=null;
-
-      // Use JAXP1.1 ( if possible )
-      try {
-	  javax.xml.parsers.SAXParserFactory factory=
-	      javax.xml.parsers.SAXParserFactory.newInstance();
-	  factory.setNamespaceAware( true );
-	  javax.xml.parsers.SAXParser jaxpParser=
-	      factory.newSAXParser();
-	  reader=jaxpParser.getXMLReader();
-	  
-      } catch( javax.xml.parsers.ParserConfigurationException ex ) {
-	  throw new org.xml.sax.SAXException( ex );
-      } catch( javax.xml.parsers.FactoryConfigurationError ex1 ) {
-	  throw new org.xml.sax.SAXException( ex1.toString() );
-      } catch( NoSuchMethodError ex2 ) {
-      }
-      if( reader==null ) reader = XMLReaderFactory.createXMLReader();
-      reader.setContentHandler(handler);
-      
-      // It's a good idea for the parser to send lexical events.
-      // The TransformerHandler is also a LexicalHandler.
-      reader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
-      
-      // Parse the source XML, and send the parse events to the TransformerHandler.
-      reader.parse(sourceID);
-    }
-    else
-    {
-      System.out.println(
-        "Can't do exampleContentHandlerToContentHandler because tfactory is not a SAXTransformerFactory");
-    }
-  }
-  
-  /**
-   * Show the Transformer as a SAX2 XMLReader.  An XMLFilter obtained 
-   * from newXMLFilter should act as a transforming XMLReader if setParent is not
-   * called.  Internally, an XMLReader is created as the parent for the XMLFilter.
-   */
-  public static void exampleXMLReader(String sourceID, String xslID)
-          throws TransformerException, TransformerConfigurationException, SAXException, IOException    // , ParserConfigurationException
-  {
-    TransformerFactory tfactory = TransformerFactory.newInstance();
-    if(tfactory.getFeature(SAXSource.FEATURE))
-    {
-      XMLReader reader 
-        = ((SAXTransformerFactory) tfactory).newXMLFilter(new StreamSource(xslID));
-      
-      reader.setContentHandler(new ExampleContentHandler());
-
-      reader.parse(new InputSource(sourceID));
-    }
-    else
-      System.out.println("tfactory does not support SAX features!");
-  }
-
-  /**
-   * Show the Transformer as a simple XMLFilter.  This is pretty similar
-   * to exampleXMLReader, except that here the parent XMLReader is created 
-   * by the caller, instead of automatically within the XMLFilter.  This 
-   * gives the caller more direct control over the parent reader.
-   */
-  public static void exampleXMLFilter(String sourceID, String xslID)
-          throws TransformerException, TransformerConfigurationException, SAXException, IOException    // , ParserConfigurationException
-  {
-    TransformerFactory tfactory = TransformerFactory.newInstance();
-
-    XMLReader reader=null;
-    
-    // Use JAXP1.1 ( if possible )
-    try {
-	javax.xml.parsers.SAXParserFactory factory=
-	    javax.xml.parsers.SAXParserFactory.newInstance();
-	  factory.setNamespaceAware( true );
-	  javax.xml.parsers.SAXParser jaxpParser=
-	    factory.newSAXParser();
-	reader=jaxpParser.getXMLReader();
-	
-    } catch( javax.xml.parsers.ParserConfigurationException ex ) {
-	throw new org.xml.sax.SAXException( ex );
-    } catch( javax.xml.parsers.FactoryConfigurationError ex1 ) {
-	throw new org.xml.sax.SAXException( ex1.toString() );
-    } catch( NoSuchMethodError ex2 ) {
-    }
-    if( reader==null ) reader = XMLReaderFactory.createXMLReader();
-    // The transformer will use a SAX parser as it's reader.    
-    reader.setContentHandler(new ExampleContentHandler());
-    try
-    {
-      reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
-                        true);
-      reader.setFeature("http://apache.org/xml/features/validation/dynamic",
-                        true);
-    }
-    catch (SAXException se)
-    {
-
-      // What can we do?
-      // TODO: User diagnostics.
-    }
-
-    XMLFilter filter 
-      = ((SAXTransformerFactory) tfactory).newXMLFilter(new StreamSource(xslID));
-
-    filter.setParent(reader);
-
-    // Now, when you call transformer.parse, it will set itself as 
-    // the content handler for the parser object (it's "parent"), and 
-    // will then call the parse method on the parser.
-    filter.parse(new InputSource(sourceID));
-  }
-
-  /**
-   * This example shows how to chain events from one Transformer
-   * to another transformer, using the Transformer as a
-   * SAX2 XMLFilter/XMLReader.
-   */
-  public static void exampleXMLFilterChain(
-                                           String sourceID, String xslID_1, 
-                                           String xslID_2, String xslID_3)
-    throws TransformerException, TransformerConfigurationException, SAXException, IOException
-  {
-    TransformerFactory tfactory = TransformerFactory.newInstance();
-    
-    Templates stylesheet1 = tfactory.newTemplates(new StreamSource(xslID_1));
-    Transformer transformer1 = stylesheet1.newTransformer();
-    
-     // If one success, assume all will succeed.
-    if (tfactory.getFeature(SAXSource.FEATURE))
-    {
-      SAXTransformerFactory stf = (SAXTransformerFactory)tfactory;
-      XMLReader reader=null;
-
-      // Use JAXP1.1 ( if possible )
-      try {
-	  javax.xml.parsers.SAXParserFactory factory=
-	      javax.xml.parsers.SAXParserFactory.newInstance();
-	  factory.setNamespaceAware( true );
-	  javax.xml.parsers.SAXParser jaxpParser=
-	      factory.newSAXParser();
-	  reader=jaxpParser.getXMLReader();
-	  
-      } catch( javax.xml.parsers.ParserConfigurationException ex ) {
-	  throw new org.xml.sax.SAXException( ex );
-      } catch( javax.xml.parsers.FactoryConfigurationError ex1 ) {
-	  throw new org.xml.sax.SAXException( ex1.toString() );
-      } catch( NoSuchMethodError ex2 ) {
-      }
-      if( reader==null ) reader = XMLReaderFactory.createXMLReader();
-
-      XMLFilter filter1 = stf.newXMLFilter(new StreamSource(xslID_1));
-      XMLFilter filter2 = stf.newXMLFilter(new StreamSource(xslID_2));
-      XMLFilter filter3 = stf.newXMLFilter(new StreamSource(xslID_3));
-
-      if (null != filter1) // If one success, assume all were success.
-      {
-        // transformer1 will use a SAX parser as it's reader.    
-        filter1.setParent(reader);
-
-        // transformer2 will use transformer1 as it's reader.
-        filter2.setParent(filter1);
-
-        // transform3 will use transform2 as it's reader.
-        filter3.setParent(filter2);
-
-        filter3.setContentHandler(new ExampleContentHandler());
-        // filter3.setContentHandler(new org.xml.sax.helpers.DefaultHandler());
-
-        // Now, when you call transformer3 to parse, it will set  
-        // itself as the ContentHandler for transform2, and 
-        // call transform2.parse, which will set itself as the 
-        // content handler for transform1, and call transform1.parse, 
-        // which will set itself as the content listener for the 
-        // SAX parser, and call parser.parse(new InputSource("xml/foo.xml")).
-        filter3.parse(new InputSource(sourceID));
-      }
-      else
-      {
-        System.out.println(
-                           "Can't do exampleXMLFilter because "+
-                           "tfactory doesn't support asXMLFilter()");
-      }
-    }
-    else
-    {
-      System.out.println(
-                         "Can't do exampleXMLFilter because "+
-                         "tfactory is not a SAXTransformerFactory");
-    }
-  }
-
-  /**
-   * Show how to transform a DOM tree into another DOM tree.
-   * This uses the javax.xml.parsers to parse an XML file into a
-   * DOM, and create an output DOM.
-   */
-  public static Node exampleDOM2DOM(String sourceID, String xslID)
-    throws TransformerException, TransformerConfigurationException, SAXException, IOException,
-    ParserConfigurationException
-  {
-    TransformerFactory tfactory = TransformerFactory.newInstance();
-
-    if (tfactory.getFeature(DOMSource.FEATURE))
-    {
-      Templates templates;
-
-      {
-        DocumentBuilderFactory dfactory =
-          DocumentBuilderFactory.newInstance();
-        dfactory.setNamespaceAware(true);
-        DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
-        org.w3c.dom.Document outNode = docBuilder.newDocument();
-        Node doc = docBuilder.parse(new InputSource(xslID));
- 
-        DOMSource dsource = new DOMSource(doc);
-        // If we don't do this, the transformer won't know how to 
-        // resolve relative URLs in the stylesheet.
-        dsource.setSystemId(xslID);
-
-        templates = tfactory.newTemplates(dsource);
-      }
-
-      Transformer transformer = templates.newTransformer();
-      DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
-      DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
-      org.w3c.dom.Document outNode = docBuilder.newDocument();
-      Node doc = docBuilder.parse(new InputSource(sourceID));
-
-      transformer.transform(new DOMSource(doc), new DOMResult(outNode));
-      
-      Transformer serializer = tfactory.newTransformer();
-      serializer.transform(new DOMSource(outNode), new StreamResult(System.out));
-
-      return outNode;
-    }
-    else
-    {
-      throw new org.xml.sax
-        .SAXNotSupportedException("DOM node processing not supported!");
-    }
-  } 
-
-  /**
-   * This shows how to set a parameter for use by the templates. Use 
-   * two transformers to show that different parameters may be set 
-   * on different transformers.
-   */
-  public static void exampleParam(String sourceID, 
-                                  String xslID)
-    throws TransformerException, TransformerConfigurationException
-  {
-    TransformerFactory tfactory = TransformerFactory.newInstance();
-    Templates templates = tfactory.newTemplates(new StreamSource(xslID));
-    Transformer transformer1 = templates.newTransformer();
-    Transformer transformer2 = templates.newTransformer();
-
-    transformer1.setParameter("a-param",
-                              "hello to you!");
-    transformer1.transform(new StreamSource(sourceID),
-                           new StreamResult(System.out));
-    
-    System.out.println("\n=========");
-    
-    transformer2.setOutputProperty(OutputKeys.INDENT, "yes");
-    transformer2.transform(new StreamSource(sourceID),
-                           new StreamResult(System.out));
-  }
-  
-  /**
-   * Show the that a transformer can be reused, and show resetting 
-   * a parameter on the transformer.
-   */
-  public static void exampleTransformerReuse(String sourceID, String xslID)
-    throws TransformerException, TransformerConfigurationException
-  {
-    // Create a transform factory instance.
-    TransformerFactory tfactory = TransformerFactory.newInstance();
-    
-    // Create a transformer for the stylesheet.
-    Transformer transformer 
-      = tfactory.newTransformer(new StreamSource(xslID));
-    
-    transformer.setParameter("a-param",
-                              "hello to you!");
-    
-    // Transform the source XML to System.out.
-    transformer.transform( new StreamSource(sourceID),
-                           new StreamResult(System.out));
-
-    System.out.println("\n=========\n");
-
-    transformer.setParameter("a-param",
-                              "hello to me!");
-    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
-
-    // Transform the source XML to System.out.
-    transformer.transform( new StreamSource(sourceID),
-                           new StreamResult(System.out));
-  }
-
-  /**
-   * Show how to override output properties.
-   */
-  public static void exampleOutputProperties(String sourceID, String xslID)
-    throws TransformerException, TransformerConfigurationException
-  {
-
-    TransformerFactory tfactory = TransformerFactory.newInstance();
-    Templates templates = tfactory.newTemplates(new StreamSource(xslID));
-    Properties oprops = templates.getOutputProperties();
-
-    oprops.put(OutputKeys.INDENT, "yes");
-
-    Transformer transformer = templates.newTransformer();
-
-    transformer.setOutputProperties(oprops);
-    transformer.transform(new StreamSource(sourceID),
-                          new StreamResult(System.out));
-  }
-
-  /**
-   * Show how to get stylesheets that are associated with a given
-   * xml document via the xml-stylesheet PI (see http://www.w3.org/TR/xml-stylesheet/).
-   */
-  public static void exampleUseAssociated(String sourceID)
-    throws TransformerException, TransformerConfigurationException
-  {
-    TransformerFactory tfactory = TransformerFactory.newInstance();
-
-    // The DOM tfactory will have it's own way, based on DOM2, 
-    // of getting associated stylesheets.
-    if (tfactory instanceof SAXTransformerFactory)
-    {
-      SAXTransformerFactory stf = ((SAXTransformerFactory) tfactory);
-      Source sources =
-        stf.getAssociatedStylesheet(new StreamSource(sourceID),
-          null, null, null);
-
-      if(null != sources)
-      {
-        Transformer transformer = tfactory.newTransformer(sources);
-
-        transformer.transform(new StreamSource(sourceID),
-                              new StreamResult(System.out));
-      }
-      else
-      {
-        System.out.println("Can't find the associated stylesheet!");
-      }
-    }
-  }
-  
-  /**
-   * Show the Transformer using SAX events in and DOM nodes out.
-   */
-  public static void exampleContentHandler2DOM(String sourceID, String xslID)
-          throws TransformerException, TransformerConfigurationException, SAXException, IOException, ParserConfigurationException
-  {
-    TransformerFactory tfactory = TransformerFactory.newInstance();
-
-    // Make sure the transformer factory we obtained supports both
-    // DOM and SAX.
-    if (tfactory.getFeature(SAXSource.FEATURE)
-        && tfactory.getFeature(DOMSource.FEATURE))
-    {
-      // We can now safely cast to a SAXTransformerFactory.
-      SAXTransformerFactory sfactory = (SAXTransformerFactory) tfactory;
-      
-      // Create an Document node as the root for the output.
-      DocumentBuilderFactory dfactory 
-        = DocumentBuilderFactory.newInstance();
-      DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
-      org.w3c.dom.Document outNode = docBuilder.newDocument();
-      
-      // Create a ContentHandler that can liston to SAX events 
-      // and transform the output to DOM nodes.
-      TransformerHandler handler 
-        = sfactory.newTransformerHandler(new StreamSource(xslID));
-      handler.setResult(new DOMResult(outNode));
-      
-      // Create a reader and set it's ContentHandler to be the 
-      // transformer.
-      XMLReader reader=null;
-
-      // Use JAXP1.1 ( if possible )
-      try {
-	  javax.xml.parsers.SAXParserFactory factory=
-	      javax.xml.parsers.SAXParserFactory.newInstance();
-	  factory.setNamespaceAware( true );
-	  javax.xml.parsers.SAXParser jaxpParser=
-	      factory.newSAXParser();
-	  reader=jaxpParser.getXMLReader();
-	  
-      } catch( javax.xml.parsers.ParserConfigurationException ex ) {
-	  throw new org.xml.sax.SAXException( ex );
-      } catch( javax.xml.parsers.FactoryConfigurationError ex1 ) {
-	  throw new org.xml.sax.SAXException( ex1.toString() );
-      } catch( NoSuchMethodError ex2 ) {
-      }
-      if( reader==null ) reader= XMLReaderFactory.createXMLReader();
-      reader.setContentHandler(handler);
-      reader.setProperty("http://xml.org/sax/properties/lexical-handler",
-                         handler);
-      
-      // Send the SAX events from the parser to the transformer,
-      // and thus to the DOM tree.
-      reader.parse(sourceID);
-      
-      // Serialize the node for diagnosis.
-      exampleSerializeNode(outNode);
-    }
-    else
-    {
-      System.out.println(
-        "Can't do exampleContentHandlerToContentHandler because tfactory is not a SAXTransformerFactory");
-    }
-  }
-  
-  /**
-   * Serialize a node to System.out.
-   */
-  public static void exampleSerializeNode(Node node)
-    throws TransformerException, TransformerConfigurationException, SAXException, IOException,
-    ParserConfigurationException
-  {
-    TransformerFactory tfactory = TransformerFactory.newInstance(); 
-    
-    // This creates a transformer that does a simple identity transform, 
-    // and thus can be used for all intents and purposes as a serializer.
-    Transformer serializer = tfactory.newTransformer();
-    
-    serializer.setOutputProperty(OutputKeys.INDENT, "yes");
-    serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
-    serializer.transform(new DOMSource(node), 
-                         new StreamResult(System.out));
-  }  
-  
-  /**
-   * A fuller example showing how the TrAX interface can be used 
-   * to serialize a DOM tree.
-   */
-  public static void exampleAsSerializer(String sourceID, String xslID)
-    throws TransformerException, TransformerConfigurationException, SAXException, IOException,
-    ParserConfigurationException
-  {
-    DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
-    DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
-    org.w3c.dom.Document outNode = docBuilder.newDocument();
-    Node doc = docBuilder.parse(new InputSource(sourceID));
-
-    TransformerFactory tfactory = TransformerFactory.newInstance(); 
-    
-    // This creates a transformer that does a simple identity transform, 
-    // and thus can be used for all intents and purposes as a serializer.
-    Transformer serializer = tfactory.newTransformer();
-    
-    Properties oprops = new Properties();
-    oprops.put("method", "html");
-    oprops.put("indent-amount", "2");
-    serializer.setOutputProperties(oprops);
-    serializer.transform(new DOMSource(doc), 
-                         new StreamResult(System.out));
-  }
-  
-
-  private static void  handleException( Exception ex ) {
-    System.out.println("EXCEPTION: " );
-    ex.printStackTrace();
-    
-    if( ex instanceof TransformerConfigurationException ) {
-      System.out.println();
-      System.out.println("Internal exception: " );
-      Throwable ex1=((TransformerConfigurationException)ex).getException();
-      ex1.printStackTrace();
-
-      if( ex1 instanceof SAXException ) {
-	  Exception ex2=((SAXException)ex1).getException();
-	  System.out.println("Internal sub-exception: " );
-	  ex2.printStackTrace();
-      }
-    }
-  }
-
-}
diff --git a/samples/trax/xml/baz.xml b/samples/trax/xml/baz.xml
deleted file mode 100644
index 9ecf473..0000000
--- a/samples/trax/xml/baz.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version='1.0'?>
-<foo:document 
-		  xmlns:foo="http://apache.org/foo"
-		  xmlns:bar="http://apache.org/bar">
-<bar:element>MyBaz</bar:element>
-</foo:document>
\ No newline at end of file
diff --git a/samples/trax/xml/foo.xml b/samples/trax/xml/foo.xml
deleted file mode 100644
index 79597ab..0000000
--- a/samples/trax/xml/foo.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version='1.0'?>
-<?xml-stylesheet type="text/xsl" href="../xsl/foo.xsl"?>
-<foo:document 
-		  xmlns:foo="http://apache.org/foo"
-		  xmlns:bar="http://apache.org/bar"
-		  file-name="test"
-         file-path="work"
-		  creation-date="971255692078">
-<bar:element>MyBar</bar:element>
-</foo:document>
\ No newline at end of file
diff --git a/samples/trax/xml/subdir1/foo2.xml b/samples/trax/xml/subdir1/foo2.xml
deleted file mode 100644
index 5708ae4..0000000
--- a/samples/trax/xml/subdir1/foo2.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version='1.0'?>
-<doc>text in foo2.xml</doc>
\ No newline at end of file
diff --git a/samples/trax/xml/subdir1/subdir2/foo3.xml b/samples/trax/xml/subdir1/subdir2/foo3.xml
deleted file mode 100644
index 77da1f0..0000000
--- a/samples/trax/xml/subdir1/subdir2/foo3.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version='1.0'?>
-<doc>text in foo3.xml</doc>
\ No newline at end of file
diff --git a/samples/trax/xsl/baz.xsl b/samples/trax/xsl/baz.xsl
deleted file mode 100644
index c1843b3..0000000
--- a/samples/trax/xsl/baz.xsl
+++ /dev/null
@@ -1,18 +0,0 @@
-<xsl:stylesheet 
-      xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
-    
-  <!-- same as foo.xsl but doesn't include the param because of a bug -->  
-  <xsl:template match="/">
-    <out>
-      <xsl:apply-templates/>
-    </out>
-  </xsl:template>
-      
-  <xsl:template 
-      match="@*|*|text()|processing-instruction()">
-    <xsl:copy>
-      <xsl:apply-templates 
-         select="@*|*|text()|processing-instruction()"/>
-    </xsl:copy>
-  </xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
diff --git a/samples/trax/xsl/foo.xsl b/samples/trax/xsl/foo.xsl
deleted file mode 100644
index b13b945..0000000
--- a/samples/trax/xsl/foo.xsl
+++ /dev/null
@@ -1,27 +0,0 @@
-<xsl:stylesheet 
-      xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'
-      xmlns:bar="http://apache.org/bar"
-      exclude-result-prefixes="bar">
-      
-  <xsl:include href="inc1/inc1.xsl"/>
-      
-  <xsl:param name="a-param">default param value</xsl:param>
-  
-  <xsl:template match="bar:element">
-    <bar>
-      <param-val>
-        <xsl:value-of select="$a-param"/><xsl:text>, </xsl:text>
-        <xsl:value-of select="$my-var"/>
-      </param-val>
-      <data><xsl:apply-templates/></data>
-    </bar>
-  </xsl:template>
-      
-  <xsl:template 
-      match="@*|*|text()|processing-instruction()">
-    <xsl:copy>
-      <xsl:apply-templates 
-         select="@*|*|text()|processing-instruction()"/>
-    </xsl:copy>
-  </xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
diff --git a/samples/trax/xsl/foo2.xsl b/samples/trax/xsl/foo2.xsl
deleted file mode 100644
index b04f5f0..0000000
--- a/samples/trax/xsl/foo2.xsl
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
-                xmlns:bar="http://apache.org/bar">
-  
-  <xsl:template match="bar">
-    <out>
-      <xsl:value-of select="."/>
-    </out>
-  </xsl:template>
-  
-  <xsl:template match="text()">
-  </xsl:template>  
- 
-</xsl:stylesheet>
diff --git a/samples/trax/xsl/foo3.xsl b/samples/trax/xsl/foo3.xsl
deleted file mode 100644
index a1bf42a..0000000
--- a/samples/trax/xsl/foo3.xsl
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0"?> 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  
-  <xsl:template match="out">
-    <out>
-      <xsl:apply-templates/>
-    </out>
-  </xsl:template>
-  
-  <xsl:template match="text()">
-    <some-text><xsl:value-of select="."/></some-text>
-  </xsl:template>  
-   
-</xsl:stylesheet>
diff --git a/samples/trax/xsl/inc1/inc1.xsl b/samples/trax/xsl/inc1/inc1.xsl
deleted file mode 100644
index 04ebb25..0000000
--- a/samples/trax/xsl/inc1/inc1.xsl
+++ /dev/null
@@ -1,6 +0,0 @@
-<xsl:stylesheet 
-      xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
-      
-  <xsl:include href="inc2/inc2.xsl"/>
-  
-</xsl:stylesheet>
\ No newline at end of file
diff --git a/samples/trax/xsl/inc1/inc2/inc2.xsl b/samples/trax/xsl/inc1/inc2/inc2.xsl
deleted file mode 100644
index 36728eb..0000000
--- a/samples/trax/xsl/inc1/inc2/inc2.xsl
+++ /dev/null
@@ -1,4 +0,0 @@
-<xsl:stylesheet 
-      xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
-  <xsl:variable name="my-var" select="'text from my-var in inc2.xsl'"/>
-</xsl:stylesheet>
\ No newline at end of file
diff --git a/src/ComposeDTM.java b/src/ComposeDTM.java
new file mode 100644
index 0000000..01b37a9
--- /dev/null
+++ b/src/ComposeDTM.java
@@ -0,0 +1,167 @@
+/**
+ * A simple testcase used to test DTM
+ *   - construct a DTM document
+ *   - set DTMStringPool pointers
+ *   - create element and text nodes with default append
+ *   - dump the content of the DTM document created
+ *
+ * Rewritten to create the document via a simulated SAX2 stream rather than
+ * using "internal" DTM interfaces.
+ *
+ *<P>Status - work in progress</p>
+ */
+import org.apache.xml.dtm.CustomStringPool;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMDocumentImpl;
+import org.apache.xml.dtm.DTMStringPool;
+
+public class ComposeDTM {
+	DTMDocumentImpl newDoc;
+
+        // %REVIEW% Justify why CustomStringPool rather than DTMStringPool.
+        // (See %REVIEW% issue in CustomStringPool's comments.)
+	DTMStringPool symbolTable = new CustomStringPool();
+
+	public ComposeDTM() {};
+
+	public static void main(String[] argv) {
+		//try {
+		ComposeDTM cdtm = new ComposeDTM();
+		cdtm.constructDoc();
+
+		cdtm.newDoc.setNsNameTable(cdtm.symbolTable);
+		cdtm.newDoc.setLocalNameTable(cdtm.symbolTable);
+		cdtm.newDoc.setPrefixNameTable(cdtm.symbolTable);
+		cdtm.composeDoc();
+
+		cdtm.treeDump();
+		/*} catch (Exception e) {
+			 System.out.println("DOMCompose::Exception: " + e);
+		}*/
+	}
+
+	public void printNode(int nodeHandle, java.io.PrintWriter pw)
+	{
+		pw.print("Node " + nodeHandle +" ) ");
+		int type = newDoc.getNodeType(nodeHandle);
+		pw.print("[type: "+ type +" (");
+
+		switch (type) {
+		case DTM.ATTRIBUTE_NODE: pw.print("ATTRIBUTE_NODE"); break;
+		case DTM.CDATA_SECTION_NODE: pw.print("CDATA_SECTION_NODE"); break;
+		case DTM.COMMENT_NODE: pw.print("COMMENT_NODE"); break;
+		case DTM.DOCUMENT_FRAGMENT_NODE: pw.print("DOCUMENT_FRAGMENT_NODE"); break;
+		case DTM.DOCUMENT_NODE: pw.print("DOCUMENT_NODE"); break;
+		case DTM.DOCUMENT_TYPE_NODE: pw.print("DOCUMENT_TYPE_NODE"); break;
+		case DTM.ELEMENT_NODE: pw.print("ELEMENT_NODE"); break;
+		case DTM.ENTITY_NODE: pw.print("ENTITY_NODE"); break;
+		case DTM.ENTITY_REFERENCE_NODE: pw.print("ENTITY_REFERENCE_NODE"); break;
+		case DTM.NOTATION_NODE: pw.print("NOTATION_NODE"); break;
+		case DTM.PROCESSING_INSTRUCTION_NODE: pw.print("PROCESSING_INSTRUCTION_NODE"); break;
+		case DTM.TEXT_NODE: pw.print("TEXT_NODE"); break;
+		default: pw.print("???");
+		}
+		pw.print(")]");
+		pw.print("[node name: " + newDoc.getNodeName(nodeHandle)+"]");
+		pw.print("[node value: " + newDoc.getNodeValue(nodeHandle)+"]");
+		pw.println("");
+	}
+
+	// instantiate a DTM document
+	public void constructDoc() {
+
+		newDoc = new DTMDocumentImpl(0);
+
+	}
+
+	// compose a PurchaseOrder document
+	public void composeDoc() {
+		int root, h, c1, c2, c3, c4, c1_text, c2_text, c3_text, c4_text;
+		String text;
+		
+		try 
+		  {
+		    
+		    newDoc.startDocument();
+
+		    newDoc.startElement(null,"PurchaseOrderList","PurchaseOrderList", null);
+		    // root.createAttribute("version", "1.1"));
+
+		    for (int i = 0; i < 10; i++) {
+
+		      newDoc.startElement(null,"PurchaseOrder","PurchaseOrder", null);
+
+		      newDoc.startElement(null,"Item","Item", null);
+		      // c1.createAttribute();
+		      text="Basketball" + " - " + i;
+		      newDoc.characters(text.toCharArray(),0,text.length());
+		      newDoc.endElement(null, "Item", "Item");
+
+		      newDoc.startElement(null,"Description","Description", null);
+		      // c2.createAttribute();
+		      text="Professional Leather Michael Jordan Signatured Basketball";
+		      newDoc.characters(text.toCharArray(),0,text.length());
+		      newDoc.endElement(null, "Description", "Description");
+
+		      newDoc.startElement(null,"UnitPrice","UnitPrice", null);
+		      text="$12.99";
+		      newDoc.characters(text.toCharArray(),0,text.length());
+		      newDoc.endElement(null, "UnitPrice", "UnitPrice");
+
+		      newDoc.startElement(null,"Quantity","Quantity", null);
+		      text="50";
+		      newDoc.characters(text.toCharArray(),0,text.length());
+		      newDoc.endElement(null, "Quantity", "Quantity");
+
+		      newDoc.endElement(null, "PurchaseOrder", "PurchaseOrder");
+		    }
+
+		    newDoc.endElement(null, "PurchaseOrderList", "PurchaseOrderList");
+
+		    newDoc.endDocument();
+		  }
+		catch(org.xml.sax.SAXException e)
+		  {
+		    e.printStackTrace();
+		  }
+	}
+
+	// traverse the PurchaseOrder document and print out the content
+	public void treeDump()
+	{
+		int root, node, node_child, node_sibling, node_name, node_value, node_type;
+ 
+		java.io.PrintWriter pwrt = null;
+		try {
+			java.io.FileOutputStream os = new java.io.FileOutputStream("dtmTreeDump.txt");
+			pwrt = new java.io.PrintWriter(os);
+
+			root = newDoc.getDocumentRoot();
+			System.out.println("Print out the document root element");
+			printNode(root, pwrt);
+
+			// root has children
+			if (newDoc.hasChildNodes(root)) {
+				// traverse through all children of the root
+				System.out.println("Print out first generation children");
+				node = newDoc.getFirstChild(root);
+				node_sibling = node;
+				int i= 1;
+				while (node_sibling != -1) {
+					System.out.println("Child " + i + " is:");
+					printNode(node_sibling, pwrt);
+					node_sibling = newDoc.getNextSibling(node_sibling);
+					i++;
+				}
+				// traverse through all descendant of the root, do this later after more generations
+				// of children are added to the root
+			}
+		} catch (java.io.IOException ioe) {
+			System.out.println("Could not dump DTM");
+		} finally {
+			pwrt.close();
+		}
+	}
+
+}
+
diff --git a/src/org/apache/xalan/extensions/ExtensionHandler.java b/src/org/apache/xalan/extensions/ExtensionHandler.java
index 7e44462..7c11240 100644
--- a/src/org/apache/xalan/extensions/ExtensionHandler.java
+++ b/src/org/apache/xalan/extensions/ExtensionHandler.java
@@ -67,6 +67,7 @@
 import org.w3c.dom.Node;
 
 import org.apache.xalan.templates.Stylesheet;
+import org.apache.xalan.templates.ElemTemplateElement;
 import org.apache.xml.utils.QName;
 
 // Temp??
@@ -216,7 +217,6 @@
    * @throws TransformerException          if parsing trouble
    */
   public abstract void processElement(
-    String localPart, Element element, TransformerImpl transformer,
-      Stylesheet stylesheetTree, Node sourceTree, Node sourceNode,
-        QName mode, Object methodKey) throws TransformerException, IOException;
+    String localPart, ElemTemplateElement element, TransformerImpl transformer,
+      Stylesheet stylesheetTree, Object methodKey) throws TransformerException, IOException;
 }
diff --git a/src/org/apache/xalan/extensions/ExtensionHandlerGeneral.java b/src/org/apache/xalan/extensions/ExtensionHandlerGeneral.java
index 50d6980..6dab82a 100644
--- a/src/org/apache/xalan/extensions/ExtensionHandlerGeneral.java
+++ b/src/org/apache/xalan/extensions/ExtensionHandlerGeneral.java
@@ -61,11 +61,13 @@
 
 import java.io.IOException;
 
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
+//import org.w3c.dom.Element;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xalan.templates.Stylesheet;
+import org.apache.xalan.templates.ElemTemplateElement;
 import org.apache.xml.utils.QName;
 
 import javax.xml.transform.TransformerException;
@@ -345,30 +347,33 @@
    * @throws TransformerException          if parsing trouble
    */
   public void processElement(
-          String localPart, Element element, TransformerImpl transformer, Stylesheet stylesheetTree, Node sourceTree, Node sourceNode, QName mode, Object methodKey)
+          String localPart, ElemTemplateElement element, TransformerImpl transformer, 
+          Stylesheet stylesheetTree, Object methodKey)
             throws TransformerException, IOException
   {
 
     Object result = null;
-    XSLProcessorContext xpc = new XSLProcessorContext(transformer,
-                                stylesheetTree, sourceTree, sourceNode, mode);
+    XSLProcessorContext xpc = new XSLProcessorContext(transformer, stylesheetTree);
 
-    try
+    // %DTBD%
+//    try
     {
       Vector argv = new Vector(2);
 
       argv.addElement(xpc);
       argv.addElement(element);
 
-      result = callFunction(localPart, argv, methodKey,
-                            transformer.getXPathContext());
+      // %DTBD% This wants an ExpressionContext.
+//      result = callFunction(localPart, argv, methodKey,
+//                            transformer.getXPathContext());
     }
-    catch (XPathProcessorException e)
-    {
-
-      // e.printStackTrace ();
-      throw new TransformerException(e.getMessage(), e);
-    }
+    // %DTBD%
+//    catch (XPathProcessorException e)
+//    {
+//
+//      // e.printStackTrace ();
+//      throw new TransformerException(e.getMessage(), e);
+//    }
 
     if (result != null)
     {
diff --git a/src/org/apache/xalan/extensions/ExtensionHandlerJavaClass.java b/src/org/apache/xalan/extensions/ExtensionHandlerJavaClass.java
index f20b3a6..67effd3 100644
--- a/src/org/apache/xalan/extensions/ExtensionHandlerJavaClass.java
+++ b/src/org/apache/xalan/extensions/ExtensionHandlerJavaClass.java
@@ -64,10 +64,11 @@
 import java.lang.reflect.InvocationTargetException;
 import java.io.IOException;
 
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
+//import org.w3c.dom.Element;
+//import org.w3c.dom.Node;
 import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xalan.templates.Stylesheet;
+import org.apache.xalan.templates.ElemTemplateElement;
 import org.apache.xml.utils.QName;
 
 import org.apache.xpath.objects.XObject;
@@ -379,12 +380,9 @@
    */
 
   public void processElement(String localPart,
-                             Element element,
+                             ElemTemplateElement element,
                              TransformerImpl transformer,
                              Stylesheet stylesheetTree,
-                             Node sourceTree,
-                             Node sourceNode,
-                             QName mode,
                              Object methodKey)
     throws TransformerException, IOException
   {
@@ -408,10 +406,7 @@
     }
 
     XSLProcessorContext xpc = new XSLProcessorContext(transformer, 
-                                                      stylesheetTree,
-                                                      sourceTree, 
-                                                      sourceNode, 
-                                                      mode);
+                                                      stylesheetTree);
 
     try
     {
diff --git a/src/org/apache/xalan/extensions/ExtensionHandlerJavaPackage.java b/src/org/apache/xalan/extensions/ExtensionHandlerJavaPackage.java
index 5050d4e..43e8d10 100644
--- a/src/org/apache/xalan/extensions/ExtensionHandlerJavaPackage.java
+++ b/src/org/apache/xalan/extensions/ExtensionHandlerJavaPackage.java
@@ -64,10 +64,14 @@
 import java.lang.reflect.InvocationTargetException;
 import java.io.IOException;
 
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
+//import org.w3c.dom.Element;
+//import org.w3c.dom.Node;
+
+import org.apache.xml.dtm.DTM;
+
 import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xalan.templates.Stylesheet;
+import org.apache.xalan.templates.ElemTemplateElement;
 import org.apache.xml.utils.QName;
 
 import org.apache.xpath.objects.XObject;
@@ -411,12 +415,9 @@
    */
 
   public void processElement (String localPart,
-                              Element element,
+                              ElemTemplateElement element,
                               TransformerImpl transformer,
                               Stylesheet stylesheetTree,
-                              Node sourceTree,
-                              Node sourceNode,
-                              QName mode,
                               Object methodKey)
     throws TransformerException, IOException
   {
@@ -454,10 +455,7 @@
     }
 
     XSLProcessorContext xpc = new XSLProcessorContext(transformer, 
-                                                      stylesheetTree,
-                                                      sourceTree, 
-                                                      sourceNode, 
-                                                      mode);
+                                                      stylesheetTree);
 
     try
     {
diff --git a/src/org/apache/xalan/extensions/ExtensionsTable.java b/src/org/apache/xalan/extensions/ExtensionsTable.java
index 95297cd..2a9de27 100644
--- a/src/org/apache/xalan/extensions/ExtensionsTable.java
+++ b/src/org/apache/xalan/extensions/ExtensionsTable.java
@@ -226,7 +226,8 @@
    * @throws javax.xml.transform.TransformerException
    */
   public Object extFunction(
-          String ns, String funcName, Vector argVec, Object methodKey, ExpressionContext exprContext)
+          String ns, String funcName, Vector argVec, Object methodKey, 
+          ExpressionContext exprContext)
             throws javax.xml.transform.TransformerException
   {
 
diff --git a/src/org/apache/xalan/extensions/MethodResolver.java b/src/org/apache/xalan/extensions/MethodResolver.java
index ae9fb0b..a97a63d 100644
--- a/src/org/apache/xalan/extensions/MethodResolver.java
+++ b/src/org/apache/xalan/extensions/MethodResolver.java
@@ -732,16 +732,18 @@
           {
             return ((XRTreeFrag) xobj).asNodeIterator();
           }
-          else if (javaClass == NodeList.class)
-          {
-            return ((XRTreeFrag) xobj).convertToNodeset();
-          }
+          // %DTBD%
+//          else if (javaClass == NodeList.class)
+//          {
+//            return ((XRTreeFrag) xobj).convertToNodeset();
+//          }
           // Same comment as above
           // else if(Node.class.isAssignableFrom(javaClass))
-          else if(javaClass == Node.class)
-          {
-            return xobj.rtree().getFirstChild();
-          }
+          // %DTBD%
+//          else if(javaClass == Node.class)
+//          {
+//            return xobj.rtree().getFirstChild();
+//          }
           else if(javaClass == java.lang.String.class)
           {
             return xobj.str();
@@ -754,14 +756,15 @@
           {
             return convertDoubleToNumber(xobj.num(), javaClass);
           }
-          else
-          {
-            Node child = xobj.rtree().getFirstChild();
-            if(javaClass.isAssignableFrom(child.getClass()))
-              return child;
-            else
-              return null;
-          }
+          // %DTBD%
+//          else
+//          {
+//            Node child = xobj.rtree().getFirstChild();
+//            if(javaClass.isAssignableFrom(child.getClass()))
+//              return child;
+//            else
+//              return null;
+//          }
         }
         // break; Unreachable
         
@@ -790,8 +793,9 @@
           {
             // Xalan ensures that nodeset() always returns an
             // iterator positioned at the beginning.
-            NodeIterator ni = xobj.nodeset();
-            return ni.nextNode(); // may be null.
+            // %DTBD%
+//            NodeIterator ni = xobj.nodeset();
+//            return ni.nextNode(); // may be null.
           }
           else if(javaClass == java.lang.String.class)
           {
@@ -805,14 +809,15 @@
           {
             return convertDoubleToNumber(xobj.num(), javaClass);
           }
-          else
-          {
-            Node child = xobj.nodeset().nextNode();
-            if(javaClass.isAssignableFrom(child.getClass()))
-              return child;
-            else
-              return null;
-          }
+          // %DTBD%
+//          else
+//          {
+//            Node child = xobj.nodeset().nextNode();
+//            if(javaClass.isAssignableFrom(child.getClass()))
+//              return child;
+//            else
+//              return null;
+//          }
         }
         // break; Unreachable
         
diff --git a/src/org/apache/xalan/extensions/XSLProcessorContext.java b/src/org/apache/xalan/extensions/XSLProcessorContext.java
index 9338e9c..b8df188 100644
--- a/src/org/apache/xalan/extensions/XSLProcessorContext.java
+++ b/src/org/apache/xalan/extensions/XSLProcessorContext.java
@@ -56,9 +56,11 @@
  */
 package org.apache.xalan.extensions;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.DocumentFragment;
+//import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xalan.transformer.ResultTreeHandler;
@@ -75,6 +77,8 @@
 import org.apache.xpath.objects.XNodeSet;
 import org.apache.xpath.XPathContext;
 
+import org.apache.xml.dtm.DTM;
+
 // import org.apache.xalan.xslt.*;
 
 /**
@@ -97,15 +101,16 @@
    * @param mode the current mode being executed.
    */
   public XSLProcessorContext(TransformerImpl transformer,
-                             Stylesheet stylesheetTree, Node sourceTree,
-                             Node sourceNode, QName mode)
+                             Stylesheet stylesheetTree)
   {
 
     this.transformer = transformer;
     this.stylesheetTree = stylesheetTree;
-    this.mode = mode;
-    this.sourceTree = sourceTree;
-    this.sourceNode = sourceNode;
+    // %TBD%
+    org.apache.xpath.XPathContext xctxt = transformer.getXPathContext();
+    this.mode = transformer.getMode();
+    this.sourceNode = xctxt.getCurrentNode();
+    this.sourceTree = xctxt.getDTM(this.sourceNode);
   }
 
   /** An instance of a transformer          */
@@ -135,29 +140,29 @@
   }
 
   /**  The root of the source tree being executed.        */
-  private Node sourceTree;
+  private org.apache.xml.dtm.DTM sourceTree;
 
   /**
    * Get the root of the source tree being executed.
    *
    * @return the root of the source tree being executed.
    */
-  public Node getSourceTree()
+  public org.w3c.dom.Node getSourceTree()
   {
-    return sourceTree;
+    return sourceTree.getNode(sourceTree.getDocument());
   }
 
   /** the current context node.          */
-  private Node sourceNode;
+  private int sourceNode;
 
   /**
    * Get the current context node.
    *
    * @return the current context node.
    */
-  public Node getContextNode()
+  public org.w3c.dom.Node getContextNode()
   {
-    return sourceNode;
+    return sourceTree.getNode(sourceNode);
   }
 
   /** the current mode being executed.         */
@@ -217,18 +222,19 @@
       {
         value = new XNumber(((Double) obj).doubleValue());
       }
-      else if (obj instanceof DocumentFragment)
-      {
-        value = new XRTreeFrag((DocumentFragment) obj);
-      }
-      else if (obj instanceof Node)
-      {
-        value = new XNodeSet((Node) obj);
-      }
-      else if (obj instanceof NodeIterator)
-      {
-        value = new XNodeSet((NodeIterator) obj);
-      }
+      // %TDM%
+//      else if (obj instanceof DocumentFragment)
+//      {
+//        value = new XRTreeFrag((DocumentFragment) obj);
+//      }
+//      else if (obj instanceof Node)
+//      {
+//        value = new XNodeSet((Node) obj);
+//      }
+//      else if (obj instanceof NodeIterator)
+//      {
+//        value = new XNodeSet((NodeIterator) obj);
+//      }
       else
       {
         value = new XString(obj.toString());
@@ -246,45 +252,48 @@
 
         rtreeHandler.characters(s.toCharArray(), 0, s.length());
         break;
+
       case XObject.CLASS_NODESET :  // System.out.println(value);
-        NodeIterator nl = value.nodeset();
-        Node pos;
+        DTMIterator nl = value.nodeset();
+        
+        int pos;
 
-        while (null != (pos = nl.nextNode()))
+        while (DTM.NULL != (pos = nl.nextNode()))
         {
-          Node top = pos;
+          DTM dtm = nl.getDTM(pos);
+          int top = pos;
 
-          while (null != pos)
+          while (DTM.NULL != pos)
           {
             rtreeHandler.flushPending();
             rtreeHandler.cloneToResultTree(pos, true);
 
-            Node nextNode = pos.getFirstChild();
+            int nextNode = dtm.getFirstChild(pos);
 
-            while (null == nextNode)
+            while (DTM.NULL == nextNode)
             {
-              if (Node.ELEMENT_NODE == pos.getNodeType())
+              if (DTM.ELEMENT_NODE == dtm.getNodeType(pos))
               {
-                rtreeHandler.endElement("", "", pos.getNodeName());
+                rtreeHandler.endElement("", "", dtm.getNodeName(pos));
               }
 
               if (top == pos)
                 break;
 
-              nextNode = pos.getNextSibling();
+              nextNode = dtm.getNextSibling(pos);
 
-              if (null == nextNode)
+              if (DTM.NULL == nextNode)
               {
-                pos = pos.getParentNode();
+                pos = dtm.getParent(pos);
 
                 if (top == pos)
                 {
-                  if (Node.ELEMENT_NODE == pos.getNodeType())
+                  if (DTM.ELEMENT_NODE == dtm.getNodeType(pos))
                   {
-                    rtreeHandler.endElement("", "", pos.getNodeName());
+                    rtreeHandler.endElement("", "", dtm.getNodeName(pos));
                   }
 
-                  nextNode = null;
+                  nextNode = DTM.NULL;
 
                   break;
                 }
diff --git a/src/org/apache/xalan/lib/Extensions.java b/src/org/apache/xalan/lib/Extensions.java
index fa6bd01..df8523b 100644
--- a/src/org/apache/xalan/lib/Extensions.java
+++ b/src/org/apache/xalan/lib/Extensions.java
@@ -89,234 +89,234 @@
 
   private Extensions() {}	// Make sure class cannot be instantiated
 
-  /**
-   * This method is an extension that implements as a Xalan extension
-   * the node-set function also found in xt and saxon.
-   * If the argument is a Result Tree Fragment, then <code>nodeset</code>
-   * returns a node-set consisting of a single root node as described in
-   * section 11.1 of the XSLT 1.0 Recommendation.  If the argument is a 
-   * node-set, <code>nodeset</code> returns a node-set.  If the argument
-   * is a string, number, or boolean, then <code>nodeset</code> returns
-   * a node-set consisting of a single root node with a single text node
-   * child that is the result of calling the XPath string() function on the 
-   * passed parameter.  If the argument is anything else, then a node-set
-   * is returned consisting of a single root node with a single text node
-   * child that is the result of calling the java <code>toString()</code>
-   * method on the passed argument.
-   * Most of the
-   * actual work here is done in <code>MethodResolver</code> and
-   * <code>XRTreeFrag</code>.
-   * @param myProcessor Context passed by the extension processor
-   * @param rtf Argument in the stylesheet to the nodeset extension function
-   */
-
-  public static NodeSet nodeset(ExpressionContext myProcessor, Object rtf) {
-
-    String textNodeValue;
-
-    if (rtf instanceof NodeIterator)
-    {
-      return new NodeSet((NodeIterator) rtf);
-    }
-    else
-    {
-      if (rtf instanceof String)
-      {
-        textNodeValue = (String) rtf;
-      }
-      else if (rtf instanceof Boolean)
-      {
-        textNodeValue = new XBoolean(((Boolean) rtf).booleanValue()).str();
-      }
-      else if (rtf instanceof Double)
-      {
-        textNodeValue = new XNumber(((Double) rtf).doubleValue()).str();
-      }
-      else
-      {
-        textNodeValue = rtf.toString();
-      }
-      Document myDoc = myProcessor.getContextNode().getOwnerDocument();
-      Text textNode = myDoc.createTextNode(textNodeValue);
-      DocumentFragment docFrag = myDoc.createDocumentFragment();
-      docFrag.appendChild(textNode);
-      return new NodeSet(docFrag);
-    }
-  }
-  
-	/**
-	 * Returns the intersection of two node-sets.
-	 * @param n1 NodeIterator for first node-set
-	 * @param ni2 NodeIterator for second node-set
-	 * @return a NodeSet containing the nodes in ni1 that are also
-	 * in ni2
-	 */	
-	public static NodeSet intersection(NodeIterator ni1, NodeIterator ni2)
-			throws javax.xml.transform.TransformerException
-	{
-		NodeSet ns1 = new NodeSet(ni1);
-		NodeSet ns2 = new NodeSet(ni2);
-		NodeSet inter= new NodeSet();
-		inter.setShouldCacheNodes(true);
-		for (int i=0; i < ns1.getLength(); i++)
-		{
-			Node n = ns1.elementAt(i);
-			if(ns2.contains(n))
-				inter.addElement(n);
-		}
-		return inter;
-	}
-	
-	/**
-	 * Returns the difference between two node-sets.
-	 * @param n1 NodeIterator for first node-set
-	 * @param ni2 NodeIterator for second node-set
-	 * @return a NodeSet containing the nodes in ni1 that are not
-	 * in ni2
-	 */	
-	public static NodeSet difference(NodeIterator ni1, NodeIterator ni2)
-			throws javax.xml.transform.TransformerException	
-	{
-		NodeSet ns1 = new NodeSet(ni1);
-		NodeSet ns2 = new NodeSet(ni2);
-		// NodeSet inter= new NodeSet();
-		NodeSet diff = new NodeSet();
-		diff.setShouldCacheNodes(true);		
-		for (int i = 0; i < ns1.getLength(); i++)
-		{
-			Node n = ns1.elementAt(i);
-			if(!ns2.contains(n))
-				diff.addElement(n);
-		}
-		return diff;
-	}
-
-	/**
-	 * Returns node-set containing distinct string values.
-	 * @param ni NodeIterator for node-set
-	 * @return a NodeSet with nodes from ni containing distinct string values. 
-	 * In other words, if more than one node in ni contains the same string value, 
-	 * only include the first such node found.
-	 */	
-	public static NodeSet distinct(NodeIterator ni)
-			throws javax.xml.transform.TransformerException	
-	{
-		NodeSet ns = new NodeSet(ni);
-		NodeSet dist = new NodeSet();
-		dist.setShouldCacheNodes(true);		
-		Hashtable stringTable = new Hashtable();
-		for (int i = 0; i < ns.getLength(); i++)
-		{
-			Node n = ns.elementAt(i);
-      String key = DOMHelper.getNodeData(n);
-      if (!stringTable.containsKey(key))
-			{
-        stringTable.put(key, n);
-        dist.addElement(n);
-			}
-		}
-		return dist;
-	}
-
-	/**
-	 * Returns true of both node-sets contain the same set of nodes.
-	 * @param n1 NodeIterator for first node-set
-	 * @param ni2 NodeIterator for second node-set
-	 * @return true if ni1 and ni2 contain exactly the same set of nodes.
-	 */	
-	public static boolean hasSameNodes(NodeIterator ni1, NodeIterator ni2)
-	{
-		NodeSet ns1 = new NodeSet(ni1);
-		NodeSet ns2 = new NodeSet(ni2);		
-		if (ns1.getLength() != ns2.getLength())
-			return false;
-		for (int i = 0; i < ns1.getLength(); i++)
-		{
-			Node n = ns1.elementAt(i);
-			if(!ns2.contains(n))
-				return false;
-		}
-		return true;
-	}  
-
-	/**
-	 * Returns the result of evaluating the argument as a string containing
-   * an XPath expression.  Used where the XPath expression is not known until
-   * run-time.  The expression is evaluated as if the run-time value of the
-   * argument appeared in place of the evaluate function call at compile time.
-	 * @param myContext an <code>ExpressionContext</code> passed in by the
-   *                  extension mechanism.  This must be an XPathContext.
-	 * @param xpathExtr The XPath expression to be evaluated.
-	 * @return the XObject resulting from evaluating the XPath
-	 */	
-	public static XObject evaluate(ExpressionContext myContext, String xpathExpr)
-                  throws SAXNotSupportedException, Exception
-	{
-    if (myContext instanceof XPathContext)
-    {
-      try
-      {
-        XPathContext xctxt = (XPathContext) myContext;
-        XPath dynamicXPath = new XPath(xpathExpr,
-                                  xctxt.getSAXLocator(),
-                                  xctxt.getNamespaceContext(),
-                                  XPath.SELECT);
-        return dynamicXPath.execute(xctxt,
-                                    myContext.getContextNode(),
-                                    xctxt.getNamespaceContext());
-      }
-      catch (Exception e)
-      {
-        throw e;
-      }
-    }
-    else
-      throw new SAXNotSupportedException("Invalid context passed to evaluate " + myContext);
-	}  
-
-	/**
-	 * Returns a NodeSet containing one text node for each token in the first argument.
-   * Delimiters are specified in the second argument.
-   * Tokens are determined by a call to <code>StringTokenizer</code>.
-   * If the first argument is an empty string or contains only delimiters, the result
-   * will be an empty NodeSet.
-   * Contributed to XalanJ1 by <a href="mailto:benoit.cerrina@writeme.com">Benoit Cerrina</a>.  
-	 * @param myContext an <code>ExpressionContext</code> passed in by the
-   *                  extension mechanism.  This must be an XPathContext.
-	 * @param toTokenize The string to be split into text tokens.
-   * @param delims The delimiters to use.
-	 * @return a NodeSet as described above.
-   *
-	 */	
-	public static NodeSet tokenize(ExpressionContext myContext, String toTokenize, String delims)
-	{
-    Document lDoc = myContext.getContextNode().getOwnerDocument();
-    StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims);
-    NodeSet resultSet = new NodeSet();
-    while (lTokenizer.hasMoreTokens())
-    {
-      resultSet.addNode(lDoc.createTextNode(lTokenizer.nextToken()));
-    }
-    return resultSet;
-}  
-
-	/**
-	 * Returns a NodeSet containing one text node for each token in the first argument.
-   * Delimiters are whitespace.  That is, the delimiters that are used are tab (&#x09),
-   * linefeed (&#x0A), return (&#x0D), and space (&#x20).
-   * Tokens are determined by a call to <code>StringTokenizer</code>.
-   * If the first argument is an empty string or contains only delimiters, the result
-   * will be an empty NodeSet.
-   * Contributed to XalanJ1 by <a href="mailto:benoit.cerrina@writeme.com">Benoit Cerrina</a>.  
-	 * @param myContext an <code>ExpressionContext</code> passed in by the
-   *                  extension mechanism.  This must be an XPathContext.
-	 * @param toTokenize The string to be split into text tokens.
-	 * @return a NodeSet as described above.
-   *
-	 */	
-	public static NodeSet tokenize(ExpressionContext myContext, String toTokenize)
-	{
-    return tokenize(myContext, toTokenize, " \t\n\r");
-  }  
+//  /**
+//   * This method is an extension that implements as a Xalan extension
+//   * the node-set function also found in xt and saxon.
+//   * If the argument is a Result Tree Fragment, then <code>nodeset</code>
+//   * returns a node-set consisting of a single root node as described in
+//   * section 11.1 of the XSLT 1.0 Recommendation.  If the argument is a 
+//   * node-set, <code>nodeset</code> returns a node-set.  If the argument
+//   * is a string, number, or boolean, then <code>nodeset</code> returns
+//   * a node-set consisting of a single root node with a single text node
+//   * child that is the result of calling the XPath string() function on the 
+//   * passed parameter.  If the argument is anything else, then a node-set
+//   * is returned consisting of a single root node with a single text node
+//   * child that is the result of calling the java <code>toString()</code>
+//   * method on the passed argument.
+//   * Most of the
+//   * actual work here is done in <code>MethodResolver</code> and
+//   * <code>XRTreeFrag</code>.
+//   * @param myProcessor Context passed by the extension processor
+//   * @param rtf Argument in the stylesheet to the nodeset extension function
+//   */
+//
+//  public static NodeSet nodeset(ExpressionContext myProcessor, Object rtf) {
+//
+//    String textNodeValue;
+//
+//    if (rtf instanceof NodeIterator)
+//    {
+//      return new NodeSet((NodeIterator) rtf);
+//    }
+//    else
+//    {
+//      if (rtf instanceof String)
+//      {
+//        textNodeValue = (String) rtf;
+//      }
+//      else if (rtf instanceof Boolean)
+//      {
+//        textNodeValue = new XBoolean(((Boolean) rtf).booleanValue()).str();
+//      }
+//      else if (rtf instanceof Double)
+//      {
+//        textNodeValue = new XNumber(((Double) rtf).doubleValue()).str();
+//      }
+//      else
+//      {
+//        textNodeValue = rtf.toString();
+//      }
+//      Document myDoc = myProcessor.getContextNode().getOwnerDocument();
+//      Text textNode = myDoc.createTextNode(textNodeValue);
+//      DocumentFragment docFrag = myDoc.createDocumentFragment();
+//      docFrag.appendChild(textNode);
+//      return new NodeSet(docFrag);
+//    }
+//  }
+//  
+//	/**
+//	 * Returns the intersection of two node-sets.
+//	 * @param n1 NodeIterator for first node-set
+//	 * @param ni2 NodeIterator for second node-set
+//	 * @return a NodeSet containing the nodes in ni1 that are also
+//	 * in ni2
+//	 */	
+//	public static NodeSet intersection(NodeIterator ni1, NodeIterator ni2)
+//			throws javax.xml.transform.TransformerException
+//	{
+//		NodeSet ns1 = new NodeSet(ni1);
+//		NodeSet ns2 = new NodeSet(ni2);
+//		NodeSet inter= new NodeSet();
+//		inter.setShouldCacheNodes(true);
+//		for (int i=0; i < ns1.getLength(); i++)
+//		{
+//			Node n = ns1.elementAt(i);
+//			if(ns2.contains(n))
+//				inter.addElement(n);
+//		}
+//		return inter;
+//	}
+//	
+//	/**
+//	 * Returns the difference between two node-sets.
+//	 * @param n1 NodeIterator for first node-set
+//	 * @param ni2 NodeIterator for second node-set
+//	 * @return a NodeSet containing the nodes in ni1 that are not
+//	 * in ni2
+//	 */	
+//	public static NodeSet difference(NodeIterator ni1, NodeIterator ni2)
+//			throws javax.xml.transform.TransformerException	
+//	{
+//		NodeSet ns1 = new NodeSet(ni1);
+//		NodeSet ns2 = new NodeSet(ni2);
+//		// NodeSet inter= new NodeSet();
+//		NodeSet diff = new NodeSet();
+//		diff.setShouldCacheNodes(true);		
+//		for (int i = 0; i < ns1.getLength(); i++)
+//		{
+//			Node n = ns1.elementAt(i);
+//			if(!ns2.contains(n))
+//				diff.addElement(n);
+//		}
+//		return diff;
+//	}
+//
+//	/**
+//	 * Returns node-set containing distinct string values.
+//	 * @param ni NodeIterator for node-set
+//	 * @return a NodeSet with nodes from ni containing distinct string values. 
+//	 * In other words, if more than one node in ni contains the same string value, 
+//	 * only include the first such node found.
+//	 */	
+//	public static NodeSet distinct(NodeIterator ni)
+//			throws javax.xml.transform.TransformerException	
+//	{
+//		NodeSet ns = new NodeSet(ni);
+//		NodeSet dist = new NodeSet();
+//		dist.setShouldCacheNodes(true);		
+//		Hashtable stringTable = new Hashtable();
+//		for (int i = 0; i < ns.getLength(); i++)
+//		{
+//			Node n = ns.elementAt(i);
+//      String key = DOMHelper.getNodeData(n);
+//      if (!stringTable.containsKey(key))
+//			{
+//        stringTable.put(key, n);
+//        dist.addElement(n);
+//			}
+//		}
+//		return dist;
+//	}
+//
+//	/**
+//	 * Returns true of both node-sets contain the same set of nodes.
+//	 * @param n1 NodeIterator for first node-set
+//	 * @param ni2 NodeIterator for second node-set
+//	 * @return true if ni1 and ni2 contain exactly the same set of nodes.
+//	 */	
+//	public static boolean hasSameNodes(NodeIterator ni1, NodeIterator ni2)
+//	{
+//		NodeSet ns1 = new NodeSet(ni1);
+//		NodeSet ns2 = new NodeSet(ni2);		
+//		if (ns1.getLength() != ns2.getLength())
+//			return false;
+//		for (int i = 0; i < ns1.getLength(); i++)
+//		{
+//			Node n = ns1.elementAt(i);
+//			if(!ns2.contains(n))
+//				return false;
+//		}
+//		return true;
+//	}  
+//
+//	/**
+//	 * Returns the result of evaluating the argument as a string containing
+//   * an XPath expression.  Used where the XPath expression is not known until
+//   * run-time.  The expression is evaluated as if the run-time value of the
+//   * argument appeared in place of the evaluate function call at compile time.
+//	 * @param myContext an <code>ExpressionContext</code> passed in by the
+//   *                  extension mechanism.  This must be an XPathContext.
+//	 * @param xpathExtr The XPath expression to be evaluated.
+//	 * @return the XObject resulting from evaluating the XPath
+//	 */	
+//	public static XObject evaluate(ExpressionContext myContext, String xpathExpr)
+//                  throws SAXNotSupportedException, Exception
+//	{
+//    if (myContext instanceof XPathContext)
+//    {
+//      try
+//      {
+//        XPathContext xctxt = (XPathContext) myContext;
+//        XPath dynamicXPath = new XPath(xpathExpr,
+//                                  xctxt.getSAXLocator(),
+//                                  xctxt.getNamespaceContext(),
+//                                  XPath.SELECT);
+//        return dynamicXPath.execute(xctxt,
+//                                    myContext.getContextNode(),
+//                                    xctxt.getNamespaceContext());
+//      }
+//      catch (Exception e)
+//      {
+//        throw e;
+//      }
+//    }
+//    else
+//      throw new SAXNotSupportedException("Invalid context passed to evaluate " + myContext);
+//	}  
+//
+//	/**
+//	 * Returns a NodeSet containing one text node for each token in the first argument.
+//   * Delimiters are specified in the second argument.
+//   * Tokens are determined by a call to <code>StringTokenizer</code>.
+//   * If the first argument is an empty string or contains only delimiters, the result
+//   * will be an empty NodeSet.
+//   * Contributed to XalanJ1 by <a href="mailto:benoit.cerrina@writeme.com">Benoit Cerrina</a>.  
+//	 * @param myContext an <code>ExpressionContext</code> passed in by the
+//   *                  extension mechanism.  This must be an XPathContext.
+//	 * @param toTokenize The string to be split into text tokens.
+//   * @param delims The delimiters to use.
+//	 * @return a NodeSet as described above.
+//   *
+//	 */	
+//	public static NodeSet tokenize(ExpressionContext myContext, String toTokenize, String delims)
+//	{
+//    Document lDoc = myContext.getContextNode().getOwnerDocument();
+//    StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims);
+//    NodeSet resultSet = new NodeSet();
+//    while (lTokenizer.hasMoreTokens())
+//    {
+//      resultSet.addNode(lDoc.createTextNode(lTokenizer.nextToken()));
+//    }
+//    return resultSet;
+//}  
+//
+//	/**
+//	 * Returns a NodeSet containing one text node for each token in the first argument.
+//   * Delimiters are whitespace.  That is, the delimiters that are used are tab (&#x09),
+//   * linefeed (&#x0A), return (&#x0D), and space (&#x20).
+//   * Tokens are determined by a call to <code>StringTokenizer</code>.
+//   * If the first argument is an empty string or contains only delimiters, the result
+//   * will be an empty NodeSet.
+//   * Contributed to XalanJ1 by <a href="mailto:benoit.cerrina@writeme.com">Benoit Cerrina</a>.  
+//	 * @param myContext an <code>ExpressionContext</code> passed in by the
+//   *                  extension mechanism.  This must be an XPathContext.
+//	 * @param toTokenize The string to be split into text tokens.
+//	 * @return a NodeSet as described above.
+//   *
+//	 */	
+//	public static NodeSet tokenize(ExpressionContext myContext, String toTokenize)
+//	{
+//    return tokenize(myContext, toTokenize, " \t\n\r");
+//  }  
 
 }
diff --git a/src/org/apache/xalan/lib/Redirect.java b/src/org/apache/xalan/lib/Redirect.java
index f34858d..25619ee 100644
--- a/src/org/apache/xalan/lib/Redirect.java
+++ b/src/org/apache/xalan/lib/Redirect.java
@@ -75,6 +75,8 @@
 import javax.xml.transform.Result;
 import javax.xml.transform.TransformerException;
 
+import org.w3c.dom.*;
+
 /**
  * Implements three extension elements to allow an XSLT transformation to
  * redirect its output to multiple output files.
@@ -363,7 +365,7 @@
       // Result was supplied, the filename is relative to the source document.
       // When transforming with a SAXResult or DOMResult, call
       // TransformerImpl.setOutputTarget() to set the desired Result base.
-//      String base = urlToFileName(elem.getStylesheet().getSystemId());
+  //      String base = urlToFileName(elem.getStylesheet().getSystemId());
 
       Result outputTarget = transformer.getOutputTarget();
       if ( (null != outputTarget) && ((base = outputTarget.getSystemId()) != null) ) {
diff --git a/src/org/apache/xalan/lib/sql/ExtensionError.java b/src/org/apache/xalan/lib/sql/ExtensionError.java
index 708ad60..6bf7e0e 100644
--- a/src/org/apache/xalan/lib/sql/ExtensionError.java
+++ b/src/org/apache/xalan/lib/sql/ExtensionError.java
@@ -70,7 +70,6 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
-import org.apache.xalan.stree.DocumentImpl;
 import org.w3c.dom.traversal.NodeFilter;
 import org.w3c.dom.traversal.NodeIterator;
 
diff --git a/src/org/apache/xalan/lib/sql/XConnection.java b/src/org/apache/xalan/lib/sql/XConnection.java
index e437367..a85e983 100644
--- a/src/org/apache/xalan/lib/sql/XConnection.java
+++ b/src/org/apache/xalan/lib/sql/XConnection.java
@@ -72,8 +72,6 @@
 import org.w3c.dom.NodeList;
 import org.w3c.dom.Node;
 
-import org.apache.xalan.stree.ElementImpl;
-
 /**
  * An XSLT extension that allows a stylesheet to
  * access JDBC data. From the stylesheet perspective,
diff --git a/src/org/apache/xalan/processor/CompilingStylesheetHandler.java b/src/org/apache/xalan/processor/CompilingStylesheetHandler.java
index 1fbb8b3..4a18dd4 100644
--- a/src/org/apache/xalan/processor/CompilingStylesheetHandler.java
+++ b/src/org/apache/xalan/processor/CompilingStylesheetHandler.java
@@ -107,12 +107,12 @@
 public class CompilingStylesheetHandler
   extends StylesheetHandler
 {
-	/** Constants for the "maythrow" field (gates whether catch
-	 * statements are generated):
-	 */
-	final int MAY_THROW_SAX_EXCEPTION=0x01;
-	
-	
+        /** Constants for the "maythrow" field (gates whether catch
+         * statements are generated):
+         */
+        final int MAY_THROW_SAX_EXCEPTION=0x01;
+        
+        
   /**
    * Create a StylesheetHandler object, creating a root stylesheet 
    * as the target.
@@ -137,63 +137,63 @@
   public void endDocument ()
     throws org.xml.sax.SAXException
   {
-	  
+          
 //    try
 //    {
-	  
-	  // Perform normal end-of-parse operations -- in particular, 
-	  // the "composition" process which performs data gathering
-	  // and optimization of the interpretable tree.
+          
+          // Perform normal end-of-parse operations -- in particular, 
+          // the "composition" process which performs data gathering
+          // and optimization of the interpretable tree.
       super.endDocument();
       
       if(isStylesheetParsingComplete())
       {    
         Stylesheet current=getStylesheet();
 
-		// Record the Templates as we compile them; this list gets
-		// passed into the "bundling" code to copy their excutable code
-		// into the .xsb file.
-		// TODO: Can we just use the StylesheetRoot's list?
+                // Record the Templates as we compile them; this list gets
+                // passed into the "bundling" code to copy their excutable code
+                // into the .xsb file.
+                // TODO: Can we just use the StylesheetRoot's list?
         Vector compiledTemplates=new Vector();
 
-		// cache the typecast
+                // cache the typecast
         StylesheetRoot root=(StylesheetRoot)getStylesheetRoot();
         
-		// For all templates used in this stylesheet (including
-		// those from imported and included stylesheets), 
-		// compile to Java. (Takes advantage of the fact that
-		// ComposedStylesheet processing has already gathered
-		// these and reconciled conflicts.)
-		
-		// New TemplateList being generated
-		org.apache.xalan.templates.TemplateList newTl 
-			= new org.apache.xalan.templates.TemplateList();
-		// Iterate over contents of old TemplateList
-		org.apache.xalan.templates.TemplateList.TemplateWalker tw
-			=root.getTemplateListComposed().getWalker();
-		
-		// Scan all templates in old list, compile, insert into new
-		ElemTemplate et;
-		while ( null != (et = tw.next()) )
-		{
-			ElemTemplate ct = compileTemplate(et);
-			
-			// If compilation succeeds, use it; else fall back on interp
-			newTl.setTemplate( (ct!=null) ? ct : et);
-		}
-		// Postprocess/reconcile list
-		newTl.compose();
-		// And make it active
-		root.setTemplateListComposed(newTl);
+                // For all templates used in this stylesheet (including
+                // those from imported and included stylesheets), 
+                // compile to Java. (Takes advantage of the fact that
+                // ComposedStylesheet processing has already gathered
+                // these and reconciled conflicts.)
+                
+                // New TemplateList being generated
+                org.apache.xalan.templates.TemplateList newTl 
+                        = new org.apache.xalan.templates.TemplateList();
+                // Iterate over contents of old TemplateList
+                org.apache.xalan.templates.TemplateList.TemplateWalker tw
+                        =root.getTemplateListComposed().getWalker();
+                
+                // Scan all templates in old list, compile, insert into new
+                ElemTemplate et;
+                while ( null != (et = tw.next()) )
+                {
+                        ElemTemplate ct = compileTemplate(et);
+                        
+                        // If compilation succeeds, use it; else fall back on interp
+                        newTl.setTemplate( (ct!=null) ? ct : et);
+                }
+                // Postprocess/reconcile list
+                newTl.compose();
+                // And make it active
+                root.setTemplateListComposed(newTl);
 
-		// TODO: Theoretically, we can now discard imports/includes
-		// -- they're no longer pointing at the right ElemTemplates
-		// anyway. There's discussion of doing so in any case when
-		// they aren't needed for tooling support. Always do it here,
-		// leave it to be handled there, or other?
+                // TODO: Theoretically, we can now discard imports/includes
+                // -- they're no longer pointing at the right ElemTemplates
+                // anyway. There's discussion of doing so in any case when
+                // they aren't needed for tooling support. Always do it here,
+                // leave it to be handled there, or other?
 
 /****** OLD APPROACH
-		int nImports = root.getGlobalImportCount();
+                int nImports = root.getGlobalImportCount();
         for(int imp = 0; imp < nImports; imp++)
         {
           org.apache.xalan.templates.StylesheetComposed
@@ -235,16 +235,16 @@
         root.recomposeTemplates(true); 
  ****** OLD APPROACH */
 
-		// TODO: Theoretically, we no longer need the Imported trees.
-		// Eliminating them would save some bytes in memory and in the
-		// .xsb bundle file. (They should be needed only for tooling 
-		// support, which doesn't seem to apply to compiled operation.)
-		// Try that _AFTER_ the compile loop has been revived!
-		
+                // TODO: Theoretically, we no longer need the Imported trees.
+                // Eliminating them would save some bytes in memory and in the
+                // .xsb bundle file. (They should be needed only for tooling 
+                // support, which doesn't seem to apply to compiled operation.)
+                // Try that _AFTER_ the compile loop has been revived!
+                
         // TODO: Should bundling occur elsewhere or be optional?
         CompiledStylesheetBundle.createBundle(root,compiledTemplates);
       }
-	  
+          
 //    }
 //    catch(TransformerException te)
 //    {
@@ -394,8 +394,8 @@
         }
         
         // Compile the new java class. Note that any existing class
-		// by the same name will be walked upon... which is why I'm
-		// going to the trouble of generating unique classnames.
+                // by the same name will be walked upon... which is why I'm
+                // going to the trouble of generating unique classnames.
         // TODO: ***** ISSUE: Where write out the class? Parameterize.
         // Needs to be somewhere on the classpath, or we need a classloader.
         Class realclass=compileSyntheticClass(tClass,".");
@@ -440,18 +440,18 @@
   
   int compileElemTemplateElement(ElemTemplateElement kid,StringBuffer body,Vector interpretVector)
   {
-	int maythrow=0;  
+        int maythrow=0;  
     ++uniqueVarSuffix; // Maintain unique variable naming
       
         switch(kid.getXSLToken())
         {
         case Constants.ELEMNAME_LITERALRESULT:
-			maythrow=compileElemLiteralResult((ElemLiteralResult)kid,body,interpretVector);
+                        maythrow=compileElemLiteralResult((ElemLiteralResult)kid,body,interpretVector);
             break;
 
-	// TODO: ***** Redirection of attr value not working yet.
-	// TODO: ***** Attrs should be preprocessed (SAX-ordered)
-	//case Constants.ELEMNAME_ATTRIBUTE:
+        // TODO: ***** Redirection of attr value not working yet.
+        // TODO: ***** Attrs should be preprocessed (SAX-ordered)
+        //case Constants.ELEMNAME_ATTRIBUTE:
         //    compileElemAttribute((ElemAttribute)kid,body,interpretVector);
         //    break;
                 
@@ -466,14 +466,14 @@
             );
                 break;
         }
-		
-		return maythrow;
+                
+                return maythrow;
   }  
   
   int compileElemLiteralResult(ElemLiteralResult ele,StringBuffer body,Vector interpretVector)
   {
-	int maythrow=0;
-	
+        int maythrow=0;
+        
     ++uniqueVarSuffix; // Maintain unique variable naming
       
     body.append("rhandler.startElement(\""
@@ -532,13 +532,14 @@
             {
                 // Literal value, can fully resolve at compile time.
                 // Exception won't be thrown, but we've gotta catch
-                try{
-                    avtValueExpression=makeQuotedString(
-                        avt.evaluate(null,null,null)
-                        );
-                }catch(TransformerException e)
-                {
-                }
+//                try{
+                  // %XTBD% ??
+//                    avtValueExpression=makeQuotedString(
+//                        avt.evaluate(null,null,null)
+//                        );
+//                }catch(TransformerException e)
+//                {
+//                }
             }
             else
             {
@@ -573,8 +574,8 @@
     // Process children
     // TODO:***** "Process m_extensionElementPrefixes && m_attributeSetsNames"
 
-	// TODO: Should maythrow be passed outward, unwinding try/catch?
-	// maythrow !=
+        // TODO: Should maythrow be passed outward, unwinding try/catch?
+        // maythrow !=
     compileChildTemplates(ele,body,interpretVector);
 
     // Close the patient
@@ -584,8 +585,8 @@
                 +ele.getRawName()+"\");\n");
     if(newNSlevel)
         body.append("nsSupport.popContext();\n");
-	
-	return maythrow | MAY_THROW_SAX_EXCEPTION;
+        
+        return maythrow | MAY_THROW_SAX_EXCEPTION;
   }
 
   // Detect and report AttributeSet loops.
@@ -630,13 +631,14 @@
 
                 // Recurse, since attrsets can reference attrsets
                 compileUseAttrSet(attrSet,body,interpretVector);
-                        
-                ElemAttribute attr = (ElemAttribute)attrSet.getFirstChild();
-                while(null != attr)
-                {
-                    compileElemTemplateElement(attr,body,interpretVector);
-                    attr = (ElemAttribute)attr.getNextSibling();
-                }
+                    
+                // %XTBD%    
+//                ElemAttribute attr = (ElemAttribute)attrSet.getFirstChild();
+//                while(null != attr)
+//                {
+//                    compileElemTemplateElement(attr,body,interpretVector);
+//                    attr = (ElemAttribute)attr.getNextSibling();
+//                }
                     
                 attrSetStack.pop();
             }
@@ -647,18 +649,19 @@
   String compileAVTvalue(org.apache.xalan.templates.AVT avt,StringBuffer body,Vector interpretVector)
   {
       // Literal string is easy -- except for potential of " within "".
-      if(avt.isContextInsensitive())
-          try
-          {
-            return makeQuotedString(avt.evaluate(null,null,null));
-          } catch(TransformerException e)
-          {
-              // Should never arise
-              String s=">UNEXPECTED ERROR evaluating context-insensitive AVT<";
-              System.err.println(s);
-              e.printStackTrace();
-              return "\""+s+'"';
-          }
+      // %XTBD%
+//      if(avt.isContextInsensitive())
+//          try
+//          {
+//            return makeQuotedString(avt.evaluate(null,null,null));
+//          } catch(TransformerException e)
+//          {
+//              // Should never arise
+//              String s=">UNEXPECTED ERROR evaluating context-insensitive AVT<";
+//              System.err.println(s);
+//              e.printStackTrace();
+//              return "\""+s+'"';
+//          }
       
       // Otherwise no compilation yet, just reference and return expression.
       // Note that we do _not_ code-gen directly into the body, due to
@@ -668,8 +671,8 @@
       interpretVector.addElement(avt);
       return 
           "( ((org.apache.xalan.templates.AVT)m_interpretArray["
-		  +offset
-		  +"]).evaluate(transformer.getXPathContext(),sourceNode,this,new StringBuffer()) )"
+                  +offset
+                  +"]).evaluate(transformer.getXPathContext(),sourceNode,this,new StringBuffer()) )"
           ;
   }
   
@@ -866,7 +869,7 @@
   void compileChildTemplates(ElemTemplateElement source,StringBuffer body,Vector interpretVector)
   {      
     int maythrow=0;
-	
+        
     ++uniqueVarSuffix; // Maintain unique variable naming
       
     // If no kids, no code gen.
@@ -896,25 +899,25 @@
           kid!=null;
           kid=kid.getNextSiblingElem())
          {
-			//TODO: NEED EQUIVALENT? This Node is Going Away...
-			// body.append("transformer.pushElemTemplateElement(kid);\n");
-		  
-			maythrow|=compileElemTemplateElement(kid,body,interpretVector);
+                        //TODO: NEED EQUIVALENT? This Node is Going Away...
+                        // body.append("transformer.pushElemTemplateElement(kid);\n");
+                  
+                        maythrow|=compileElemTemplateElement(kid,body,interpretVector);
 
-			//TODO: NEED EQUIVALENT? This Node is Going Away...
-			// body.append("transformer.popElemTemplateElement(kid);\n");
+                        //TODO: NEED EQUIVALENT? This Node is Going Away...
+                        // body.append("transformer.popElemTemplateElement(kid);\n");
          }
 
-	  // End the class wrapper. 
-	  // TODO: Should "maythrow" be returned and processed @ outermost compile?
-	  body.append("\n\n}\n");
-	  if(0!=(maythrow & MAY_THROW_SAX_EXCEPTION))
-		body.append("catch(org.xml.sax.SAXException se) {\n"
-					+"  throw new javax.xml.transform.TransformerException(se);\n"
-					+"}\n"
-					);
+          // End the class wrapper. 
+          // TODO: Should "maythrow" be returned and processed @ outermost compile?
+          body.append("\n\n}\n");
+          if(0!=(maythrow & MAY_THROW_SAX_EXCEPTION))
+                body.append("catch(org.xml.sax.SAXException se) {\n"
+                                        +"  throw new javax.xml.transform.TransformerException(se);\n"
+                                        +"}\n"
+                                        );
       body.append(
-		"finally {\n"
+                "finally {\n"
         +"  xctxt.setSAXLocator("+savedLocatorName+");\n"
         +"  // Pop all the variables in this element frame.\n"
         +"  "+varstackName+".popElemFrame();\n"
@@ -983,13 +986,13 @@
     // Try to pick up the same classpath we're executing under. That
     // ought to include everything in Xalan and the standard libraries.
     String classpath=System.getProperty ("java.class.path");
-	
+        
     // If compiling with the -g switch (Java debugging), we should retain 
     // the Java source code to support debugging into the synthesized class.
     // Some additional diagnostics are also turned on as a side effect.
     // TODO: Find a better place to put the debugging control. Property? Parm?
     String javac_options=
-	System.getProperty("org.apache.xalan.processor.CompilingStylesheetHandler.options","");
+        System.getProperty("org.apache.xalan.processor.CompilingStylesheetHandler.options","");
     boolean debug=(javac_options.indexOf("-g")>=0);
 
     // Run the compilation. Encapsulates the fallbacks and
@@ -1078,8 +1081,8 @@
     long templateNumber;
     synchronized(this)
     {   // Atomic get-next-count -- last-ditch protection against
-		// the risk of multiple threads trying to process the same
-		// stylesheet at the same instant on the same machine.
+                // the risk of multiple threads trying to process the same
+                // stylesheet at the same instant on the same machine.
         templateNumber = ++templateCounter;
     }
     
diff --git a/src/org/apache/xalan/processor/TransformerFactoryImpl.java b/src/org/apache/xalan/processor/TransformerFactoryImpl.java
index deb6a39..dabd07f 100644
--- a/src/org/apache/xalan/processor/TransformerFactoryImpl.java
+++ b/src/org/apache/xalan/processor/TransformerFactoryImpl.java
@@ -147,7 +147,7 @@
         {
           Properties props = new Properties();
 
-          is = Process.class.getResourceAsStream(file);
+          is = TransformerFactoryImpl.class.getResourceAsStream(file);
 
           // get a buffered version
           BufferedInputStream bis = new BufferedInputStream(is);
diff --git a/src/org/apache/xalan/stree/Parent.java b/src/org/apache/xalan/stree/Parent.java
index c7ff3f2..f53a57f 100644
--- a/src/org/apache/xalan/stree/Parent.java
+++ b/src/org/apache/xalan/stree/Parent.java
@@ -360,49 +360,6 @@
 
     m_last = child;
 
-    // getDocumentImpl().getLevelIndexer().insertNode(child);
-    if (Node.ELEMENT_NODE == child.getNodeType())
-    {
-      SourceTreeHandler sh = doc.getSourceTreeHandler();
-
-      if ((null != sh) && sh.m_shouldCheckWhitespace)
-      {
-        TransformerImpl transformer = sh.getTransformerImpl();
-
-        if (null != transformer)
-        {
-          StylesheetRoot stylesheet = transformer.getStylesheet();
-
-          try
-          {
-            ElementImpl elem = (ElementImpl) child;
-            if(null == doc.m_xpathContext)
-              doc.m_xpathContext = new org.apache.xpath.XPathContext(doc);
-            WhiteSpaceInfo info =
-              stylesheet.getWhiteSpaceInfo(doc.m_xpathContext,
-                                           elem);
-            boolean shouldStrip;
-
-            if (null == info)
-            {
-              shouldStrip = sh.getShouldStripWhitespace();
-            }
-            else
-            {
-              shouldStrip = info.getShouldStripSpace();
-            }
-
-            sh.setShouldStripWhitespace(shouldStrip);
-          }
-          catch (TransformerException se)
-          {
-
-            // TODO: Diagnostics
-          }
-        }
-      }
-    }
-
     return newChild;
   }
 
diff --git a/src/org/apache/xalan/stree/SourceTreeHandler.java b/src/org/apache/xalan/stree/SourceTreeHandler.java
index e2fd2e2..efaccc6 100644
--- a/src/org/apache/xalan/stree/SourceTreeHandler.java
+++ b/src/org/apache/xalan/stree/SourceTreeHandler.java
@@ -64,6 +64,8 @@
 
 import org.xml.sax.ContentHandler;
 
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMManager;
 import org.apache.xml.utils.DOMBuilder;
 import org.apache.xml.utils.XMLCharacterRecognizer;
 import org.apache.xml.utils.BoolStack;
@@ -92,6 +94,7 @@
 import javax.xml.transform.sax.TransformerHandler;
 import javax.xml.transform.Result;
 import javax.xml.transform.ErrorListener;
+import javax.xml.transform.dom.DOMSource;
 
 
 /**
@@ -110,9 +113,9 @@
    * @param transformer The transformer this will use to transform a
    * source tree into a result tree.
    */
-  public SourceTreeHandler(TransformerImpl transformer)
+  public SourceTreeHandler(TransformerImpl transformer, String baseSystemID)
   {
-    this(transformer, false);
+    this(transformer, false, baseSystemID);
   }
 
   /**
@@ -122,7 +125,8 @@
    * @param transformer The transformer this will use to transform a
    * source tree into a result tree.
    */
-  public SourceTreeHandler(TransformerImpl transformer, boolean doFragment)
+  public SourceTreeHandler(TransformerImpl transformer, boolean doFragment, 
+                           String baseSystemID)
   {
 //    m_id = m_idCount++;
     m_transformer = transformer;
@@ -131,6 +135,8 @@
 
     xctxt.setDOMHelper(new StreeDOMHelper());
     
+    DTMManager mgr = m_transformer.getXPathContext().getDTMManager();
+    DTM dtm;
     if(doFragment)
     {
       m_root = new DocumentFragmentImpl(1024);
@@ -140,6 +146,41 @@
     {
       m_root = new DocumentImpl(this);
     }
+    DOMSource ds = new DOMSource(m_root, baseSystemID);
+    dtm = mgr.getDTM(ds, false, transformer, false);
+    
+    m_DTMroot = dtm.getDocument();
+
+    m_initedRoot = false;
+    m_shouldCheckWhitespace =
+      transformer.getStylesheet().shouldCheckWhitespace();
+  }
+  
+  /**
+   * Create a SourceTreeHandler that will start a transformation as
+   * soon as a startDocument occurs.
+   *
+   * @param transformer The transformer this will use to transform a
+   * source tree into a result tree.
+   */
+  public SourceTreeHandler(TransformerImpl transformer, DTMManager dtm, 
+                           boolean doFragment)
+  {
+//    m_id = m_idCount++;
+    m_transformer = transformer;
+
+    XPathContext xctxt = transformer.getXPathContext();
+    xctxt.setDOMHelper(new StreeDOMHelper());
+    
+     if(doFragment)
+    {
+      m_root = new DocumentFragmentImpl(1024);
+      m_docFrag = (DocumentFragmentImpl)m_root;
+    }
+    else
+    {
+      m_root = new DocumentImpl(this);
+    }
 
     m_initedRoot = false;
     m_shouldCheckWhitespace =
@@ -171,6 +212,21 @@
   /** The root of the source document          */
   private DocImpl m_root;
 
+  /** The DTM root for the DTM2DOM **/
+  private int m_DTMroot;
+  
+  /** Get the DTM root for the DTM2DOM **/
+  public int getDTMRoot()
+  {
+    return m_DTMroot;
+  }
+
+  /** Set the DTM root for the DTM2DOM **/
+  public void setDTMRoot(int root)
+  {
+    root = m_DTMroot;
+  }
+
   /** If this is non-null, the fragment where the nodes will be added. */
   private DocumentFragment m_docFrag;
 
@@ -403,10 +459,7 @@
           }
         } 
         
-        if(null != m_docFrag)
-          m_transformer.setSourceTreeDocForThread(m_docFrag);
-        else
-          m_transformer.setSourceTreeDocForThread(m_root);
+        m_transformer.setSourceTreeDocForThread(m_DTMroot);
 
         Thread t = m_transformer.createTransformThread();
 
@@ -414,7 +467,7 @@
 
         int cpriority = Thread.currentThread().getPriority();
 
-        // t.setPriority(cpriority-1);
+        t.setPriority(cpriority-1);
         t.setPriority(cpriority);
         t.start();
       }
@@ -450,7 +503,7 @@
       {
         try
         {
-          m_transformer.transformNode(m_root);
+          m_transformer.transformNode(m_DTMroot);
         }
         catch(TransformerException te)
         {
@@ -1009,7 +1062,7 @@
     
     m_inputSource = new StreamSource(baseID);
     
-    stm.putDocumentInCache(m_root, m_inputSource);
+    stm.putDocumentInCache(m_DTMroot, m_inputSource);
   }
   
   /**
diff --git a/src/org/apache/xalan/stree/StreeDOMBuilder.java b/src/org/apache/xalan/stree/StreeDOMBuilder.java
index d02e6cb..bb589a8 100644
--- a/src/org/apache/xalan/stree/StreeDOMBuilder.java
+++ b/src/org/apache/xalan/stree/StreeDOMBuilder.java
@@ -217,7 +217,6 @@
     }
     
     append(elem);
-
     m_elemStack.push(elem);
 
     m_currentNode = elem;
diff --git a/src/org/apache/xalan/stree/StreeDTMManager.java b/src/org/apache/xalan/stree/StreeDTMManager.java
new file mode 100644
index 0000000..b6ae056
--- /dev/null
+++ b/src/org/apache/xalan/stree/StreeDTMManager.java
@@ -0,0 +1,305 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xalan.stree;
+
+import org.apache.xml.dtm.DTMManagerDefault;
+import org.apache.xml.dtm.DTMWSFilter;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMException;
+import org.apache.xml.dtm.dom2dtm.DOM2DTM;
+import org.apache.xml.utils.SystemIDResolver;
+import org.apache.xalan.transformer.TransformerImpl;
+import org.apache.xpath.SourceTreeManager;
+import org.apache.xpath.XPathContext;
+
+import java.util.Properties;
+import java.util.Enumeration;
+
+import org.apache.xml.utils.PrefixResolver;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.SourceLocator;
+import javax.xml.transform.Source;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.TransformerException;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.helpers.XMLReaderFactory;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.EntityResolver;
+
+/**
+ * <meta name="usage" content="internal"/>
+ * NEEDSDOC Class StreeDTMManager <needs-comment/>
+ */
+public class StreeDTMManager extends DTMManagerDefault
+{
+
+  /**
+   * Get an instance of a DTM, loaded with the content from the
+   * specified source.  If the unique flag is true, a new instance will
+   * always be returned.  Otherwise it is up to the DTMManager to return a
+   * new instance or an instance that it already created and may be being used
+   * by someone else.
+   * (I think more parameters will need to be added for error handling, and entity
+   * resolution).
+   *
+   * @param source the specification of the source object.
+   * @param unique true if the returned DTM must be unique, probably because it
+   * is going to be mutated.
+   * @param whiteSpaceFilter Enables filtering of whitespace nodes, and may
+   *                         be null.
+   *
+   * @return a non-null DTM reference.
+   */
+  public DTM getDTM(Source source, boolean unique,
+                    DTMWSFilter whiteSpaceFilter)
+  {
+
+    // System.out.println("In StreeDTMManager");
+    if (source instanceof DOMSource)
+    {
+      return super.getDTM(source, unique, whiteSpaceFilter, false);
+    }
+    else if (whiteSpaceFilter instanceof TransformerImpl)
+    {
+      TransformerImpl transformer = (TransformerImpl) whiteSpaceFilter;
+      XPathContext xctxt = transformer.getXPathContext();
+      XMLReader reader = getXMLReader(source, xctxt.getSAXLocator());
+
+      // Get the input content handler, which will handle the 
+      // parse events and create the source tree. 
+      // ContentHandler inputHandler = transformer.getInputContentHandler();
+      // SourceTreeHandler sth = new SourceTreeHandler(transformer, this, false);
+      // sth.setUseMultiThreading(true);
+      SourceTreeHandler sth = new SourceTreeHandler();
+      sth.setUseMultiThreading(false);
+      
+      // transformer.setIsTransformDone(false);
+      InputSource xmlSource = SAXSource.sourceToInputSource(source);
+
+      String urlOfSource = xmlSource.getSystemId();
+
+      if (null != urlOfSource)
+      {
+        try
+        {
+          urlOfSource = SystemIDResolver.getAbsoluteURI(urlOfSource);
+        }
+        catch (Exception e)
+        {
+
+          // %REVIEW% Is there a better way to send a warning?
+          System.err.println("Can not absolutize URL: " + urlOfSource);
+        }
+
+        xmlSource.setSystemId(urlOfSource);
+      }
+
+      int documentID = m_dtms.size() << 20;
+      DOMSource ds = new DOMSource(sth.getRoot(), xmlSource.getSystemId());
+      DTM dtm = new DOM2DTM(this, ds, documentID, whiteSpaceFilter, 
+                      org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());
+      int doc = sth.getDTMRoot();
+      m_dtms.add(dtm);
+      reader.setContentHandler(sth);
+
+      if (sth instanceof org.xml.sax.DTDHandler)
+        reader.setDTDHandler(sth);
+
+      try
+      {
+        reader.setProperty("http://xml.org/sax/properties/lexical-handler",
+                           sth);
+      }
+      catch (org.xml.sax.SAXException snre){}
+
+      try
+      {
+        reader.setProperty(
+          "http://xml.org/sax/properties/declaration-handler", sth);
+      }
+      catch (org.xml.sax.SAXException se){}
+
+      try
+      {
+        reader.setProperty("http://xml.org/sax/handlers/LexicalHandler", sth);
+      }
+      catch (org.xml.sax.SAXException se){}
+
+      try
+      {
+        reader.setProperty("http://xml.org/sax/handlers/DeclHandler", sth);
+      }
+      catch (org.xml.sax.SAXException se){}
+
+      // Set the reader for cloning purposes.
+      // transformer.getXPathContext().setPrimaryReader(reader);
+      // transformer.setExceptionThrown(null);
+      
+      sth.setInputSource(source);
+
+      if (DTM.NULL != doc)
+      {
+        SourceTreeManager stm =
+          transformer.getXPathContext().getSourceTreeManager();
+
+        // stm.putDocumentInCache(doc, source);
+        // transformer.setXMLSource(source);
+
+        if (null == xmlSource)
+        {
+          throw new DTMException("Not supported: " + source);
+        }
+
+
+        try
+        {
+          reader.parse(xmlSource);
+
+          return dtm;
+        }
+        catch (Exception e)
+        {
+          e.printStackTrace();
+        }
+      }
+    }
+    else
+    {
+      throw new DTMException("Not supported: " + source);
+    }
+
+    return null;
+
+  }
+
+  /**
+   * This method returns the SAX2 parser to use with the InputSource
+   * obtained from this URI.
+   * It may return null if any SAX2-conformant XML parser can be used,
+   * or if getInputSource() will also return null. The parser must
+   * be free for use (i.e.
+   * not currently in use for another parse().
+   *
+   * @param inputSource The value returned from the URIResolver.
+   * @returns a SAX2 XMLReader to use to resolve the inputSource argument.
+   * @param locator The location of the original caller, for diagnostic purposes.
+   *
+   * @return non-null XMLReader reference ready to parse.
+   */
+  public XMLReader getXMLReader(Source inputSource, SourceLocator locator)
+  {
+
+    try
+    {
+      XMLReader reader = (inputSource instanceof SAXSource)
+                         ? ((SAXSource) inputSource).getXMLReader() : null;
+
+      if (null == reader)
+      {
+        try
+        {
+          javax.xml.parsers.SAXParserFactory factory =
+            javax.xml.parsers.SAXParserFactory.newInstance();
+
+          factory.setNamespaceAware(true);
+
+          javax.xml.parsers.SAXParser jaxpParser = factory.newSAXParser();
+
+          reader = jaxpParser.getXMLReader();
+        }
+        catch (javax.xml.parsers.ParserConfigurationException ex)
+        {
+          throw new org.xml.sax.SAXException(ex);
+        }
+        catch (javax.xml.parsers.FactoryConfigurationError ex1)
+        {
+          throw new org.xml.sax.SAXException(ex1.toString());
+        }
+        catch (NoSuchMethodError ex2){}
+        catch (AbstractMethodError ame){}
+
+        if (null == reader)
+          reader = XMLReaderFactory.createXMLReader();
+      }
+
+      try
+      {
+        reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
+                          true);
+        reader.setFeature("http://apache.org/xml/features/validation/dynamic",
+                          true);
+      }
+      catch (org.xml.sax.SAXException se)
+      {
+
+        // What can we do?
+        // TODO: User diagnostics.
+      }
+
+      return reader;
+    }
+    catch (org.xml.sax.SAXException se)
+    {
+      throw new DTMException(se.getMessage(), locator, se);
+    }
+  }
+}
diff --git a/src/org/apache/xalan/templates/AVT.java b/src/org/apache/xalan/templates/AVT.java
index 569cc06..64ca1b4 100644
--- a/src/org/apache/xalan/templates/AVT.java
+++ b/src/org/apache/xalan/templates/AVT.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 import java.util.Vector;
 import java.util.StringTokenizer;
@@ -498,7 +498,7 @@
    * @throws javax.xml.transform.TransformerException
    */
   public String evaluate(
-          XPathContext xctxt, Node context, org.apache.xml.utils.PrefixResolver nsNode)
+          XPathContext xctxt, int context, org.apache.xml.utils.PrefixResolver nsNode)
             throws javax.xml.transform.TransformerException
   {
 
diff --git a/src/org/apache/xalan/templates/AVTPart.java b/src/org/apache/xalan/templates/AVTPart.java
index 1db8872..4f8b879 100644
--- a/src/org/apache/xalan/templates/AVTPart.java
+++ b/src/org/apache/xalan/templates/AVTPart.java
@@ -56,7 +56,8 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
+import org.apache.xml.dtm.DTM;
 
 import org.apache.xpath.XPathContext;
 import org.apache.xml.utils.FastStringBuffer;
@@ -94,7 +95,7 @@
    * @throws javax.xml.transform.TransformerException
    */
   public abstract void evaluate(
-    XPathContext xctxt, FastStringBuffer buf, Node context,
+    XPathContext xctxt, FastStringBuffer buf, int context,
       org.apache.xml.utils.PrefixResolver nsNode)
         throws javax.xml.transform.TransformerException;
 
diff --git a/src/org/apache/xalan/templates/AVTPartSimple.java b/src/org/apache/xalan/templates/AVTPartSimple.java
index 2a0459a..d5625fb 100644
--- a/src/org/apache/xalan/templates/AVTPartSimple.java
+++ b/src/org/apache/xalan/templates/AVTPartSimple.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
 
 import org.apache.xpath.XPathContext;
 import org.apache.xml.utils.FastStringBuffer;
@@ -106,7 +106,7 @@
    * @param NodeList The current Context Node List.
    */
   public void evaluate(XPathContext xctxt, FastStringBuffer buf,
-                       Node context,
+                       int context,
                        org.apache.xml.utils.PrefixResolver nsNode)
   {
     buf.append(m_val);
diff --git a/src/org/apache/xalan/templates/AVTPartXPath.java b/src/org/apache/xalan/templates/AVTPartXPath.java
index 97bc718..837ae08 100644
--- a/src/org/apache/xalan/templates/AVTPartXPath.java
+++ b/src/org/apache/xalan/templates/AVTPartXPath.java
@@ -62,7 +62,8 @@
 import org.apache.xpath.compiler.XPathParser;
 import org.apache.xml.utils.FastStringBuffer;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
+import org.apache.xml.dtm.DTM;
 
 /**
  * <meta name="usage" content="internal"/>
@@ -150,7 +151,7 @@
    * @throws javax.xml.transform.TransformerException
    */
   public void evaluate(
-          XPathContext xctxt, FastStringBuffer buf, Node context, org.apache.xml.utils.PrefixResolver nsNode)
+          XPathContext xctxt, FastStringBuffer buf, int context, org.apache.xml.utils.PrefixResolver nsNode)
             throws javax.xml.transform.TransformerException
   {
 
@@ -158,7 +159,7 @@
 
     if (null != xobj)
     {
-      buf.append(xobj.str());
+      xobj.appendToFsb(buf);
     }
   }
 }
diff --git a/src/org/apache/xalan/templates/ElemApplyImport.java b/src/org/apache/xalan/templates/ElemApplyImport.java
index be0fcd0..453743e 100644
--- a/src/org/apache/xalan/templates/ElemApplyImport.java
+++ b/src/org/apache/xalan/templates/ElemApplyImport.java
@@ -56,8 +56,9 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.DOMException;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.DOMException;
+import org.apache.xml.dtm.DTM;
 
 import javax.xml.transform.TransformerException;
 
@@ -107,7 +108,7 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
@@ -118,14 +119,15 @@
     }
 
     if (TransformerImpl.S_DEBUG)
-      transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+      transformer.getTraceManager().fireTraceEvent(this);
 
-    if (null != sourceNode)
+    int sourceNode = transformer.getXPathContext().getCurrentNode();
+    if (DTM.NULL != sourceNode)
     {
 
       // This will have to change to current template, (which will have 
       // to be the top of a current template stack).
-      transformer.applyTemplateToNode(this, null, sourceNode, mode);
+      transformer.applyTemplateToNode(this, null, sourceNode);
     }
     else  // if(null == sourceNode)
     {
@@ -141,10 +143,8 @@
    * @param newChild New element to append to this element's children list
    *
    * @return null, xsl:apply-Imports cannot have children 
-   *
-   * @throws DOMException
    */
-  public Node appendChild(Node newChild) throws DOMException
+  public ElemTemplateElement appendChild(ElemTemplateElement newChild)
   {
 
     error(XSLTErrorResources.ER_CANNOT_ADD,
diff --git a/src/org/apache/xalan/templates/ElemApplyTemplates.java b/src/org/apache/xalan/templates/ElemApplyTemplates.java
index 86a1d0a..fbd535b 100644
--- a/src/org/apache/xalan/templates/ElemApplyTemplates.java
+++ b/src/org/apache/xalan/templates/ElemApplyTemplates.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
 
 import org.xml.sax.*;
 
@@ -170,36 +170,47 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
     transformer.pushCurrentTemplateRuleIsNull(false);
 
+    boolean pushMode = false;
+    
     try
     {
       if (TransformerImpl.S_DEBUG)
-        transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
-
-      if (null != sourceNode)
-      {
-
+        transformer.getTraceManager().fireTraceEvent(this);
+        
+        // %REVIEW% Do we need this check??
+//      if (null != sourceNode)
+//      {
+          
         // boolean needToTurnOffInfiniteLoopCheck = false;
+        QName mode = transformer.getMode();
         if (!m_isDefaultTemplate)
         {
-          mode = m_mode;
+          if(((null == mode) && (null != m_mode) ) ||
+              ((null != mode) && !mode.equals(m_mode)))
+          {
+            pushMode = true;
+            transformer.pushMode(m_mode);
+          }
         }
 
-        transformSelectedNodes(transformer, sourceNode, null, mode);
-      }
-      else  // if(null == sourceNode)
-      {
-        transformer.getMsgMgr().error(this,
-          XSLTErrorResources.ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES);  //"sourceNode is null in handleApplyTemplatesInstruction!");
-      }
+        transformSelectedNodes(transformer, null);
+//      }
+//      else  // if(null == sourceNode)
+//      {
+//        transformer.getMsgMgr().error(this,
+//          XSLTErrorResources.ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES);  //"sourceNode is null in handleApplyTemplatesInstruction!");
+//      }
     }
     finally
     {
+      if(pushMode)
+        transformer.popMode();
       transformer.popCurrentTemplateRuleIsNull();
     }
   }
@@ -231,7 +242,7 @@
    * @throws TransformerException
    */
   int pushParams(
-          TransformerImpl transformer, XPathContext xctxt, Node sourceNode, QName mode)
+          TransformerImpl transformer, XPathContext xctxt)
             throws TransformerException
   {
 
@@ -240,8 +251,8 @@
     
     if (null != m_paramElems)
     {  
-      transformer.pushParams(xctxt, this, sourceNode, mode);
-     }  
+      transformer.pushParams(xctxt, this);
+    }  
     else
       vars.pushContextMarker();
     
diff --git a/src/org/apache/xalan/templates/ElemAttribute.java b/src/org/apache/xalan/templates/ElemAttribute.java
index 1f98bbb..e36b888 100644
--- a/src/org/apache/xalan/templates/ElemAttribute.java
+++ b/src/org/apache/xalan/templates/ElemAttribute.java
@@ -56,8 +56,9 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.DOMException;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.DOMException;
+import org.apache.xml.dtm.DTM;
 
 import javax.xml.transform.TransformerException;
 
@@ -118,7 +119,7 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
     ResultTreeHandler rhandler = transformer.getResultTreeHandler();
@@ -129,9 +130,10 @@
     {
       // Make sure the trace event is sent.
       if (TransformerImpl.S_DEBUG)
-        transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+        transformer.getTraceManager().fireTraceEvent(this);
 
       XPathContext xctxt = transformer.getXPathContext();
+      int sourceNode = xctxt.getCurrentNode();
       String attrName = m_name_avt.evaluate(xctxt, sourceNode, this);
       transformer.getMsgMgr().warn(this,
                                    XSLTErrorResources.WG_ILLEGAL_ATTRIBUTE,
@@ -142,7 +144,7 @@
       // warn(templateChild, sourceNode, "Trying to add attribute after element child has been added, ignoring...");
     }
     
-    super.execute(transformer, sourceNode, mode);
+    super.execute(transformer);
     
   }
   
@@ -211,7 +213,7 @@
    * @throws TransformerException
    */
   void constructNode(
-          String nodeName, String prefix, String nodeNamespace, TransformerImpl transformer, Node sourceNode, QName mode)
+          String nodeName, String prefix, String nodeNamespace, TransformerImpl transformer)
             throws TransformerException
   {
 
@@ -229,7 +231,7 @@
           throw new TransformerException(se);
         }
       }
-      String val = transformer.transformToString(this, sourceNode, mode);
+      String val = transformer.transformToString(this);
       String localName = QName.getLocalPart(nodeName);
       rhandler.addAttribute(nodeNamespace, localName, nodeName, "CDATA", val);
     }
@@ -251,7 +253,7 @@
    *
    * @throws DOMException
    */
-  public Node appendChild(Node newChild) throws DOMException
+  public ElemTemplateElement appendChild(ElemTemplateElement newChild)
   {
 
     int type = ((ElemTemplateElement) newChild).getXSLToken();
diff --git a/src/org/apache/xalan/templates/ElemAttributeSet.java b/src/org/apache/xalan/templates/ElemAttributeSet.java
index a1f6218..d39fe35 100644
--- a/src/org/apache/xalan/templates/ElemAttributeSet.java
+++ b/src/org/apache/xalan/templates/ElemAttributeSet.java
@@ -143,7 +143,7 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
@@ -156,15 +156,15 @@
     }
 
     transformer.pushElemAttributeSet(this);
-    super.execute(transformer, sourceNode, mode);
+    super.execute(transformer);
 
-    ElemAttribute attr = (ElemAttribute) getFirstChild();
+    ElemAttribute attr = (ElemAttribute) getFirstChildElem();
 
     while (null != attr)
     {
-      attr.execute(transformer, sourceNode, mode);
+      attr.execute(transformer);
 
-      attr = (ElemAttribute) attr.getNextSibling();
+      attr = (ElemAttribute) attr.getNextSiblingElem();
     }
 
     transformer.popElemAttributeSet();
@@ -184,7 +184,7 @@
    *
    * @throws DOMException
    */
-  public Node appendChild(Node newChild) throws DOMException
+  public ElemTemplateElement appendChildElem(ElemTemplateElement newChild)
   {
 
     int type = ((ElemTemplateElement) newChild).getXSLToken();
diff --git a/src/org/apache/xalan/templates/ElemCallTemplate.java b/src/org/apache/xalan/templates/ElemCallTemplate.java
index 6c7c088..d3ba271 100644
--- a/src/org/apache/xalan/templates/ElemCallTemplate.java
+++ b/src/org/apache/xalan/templates/ElemCallTemplate.java
@@ -170,12 +170,12 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
     if (TransformerImpl.S_DEBUG)
-      transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+      transformer.getTraceManager().fireTraceEvent(this);
 
     if (null != m_template)
     {
@@ -185,7 +185,7 @@
       int savedSearchStart = vars.getSearchStart();
 
       if (null != m_paramElems)
-        transformer.pushParams(xctxt, this, sourceNode, mode);
+        transformer.pushParams(xctxt, this);
       else
         vars.pushContextMarker();
       
@@ -199,7 +199,7 @@
 
         // template.executeChildTemplates(transformer, sourceNode, mode, true);
         transformer.pushElemTemplateElement(m_template);
-        m_template.execute(transformer, sourceNode, mode);
+        m_template.execute(transformer);
       }
       finally
       {
@@ -269,7 +269,7 @@
    *
    * @throws DOMException
    */
-  public Node appendChild(Node newChild) throws DOMException
+  public ElemTemplateElement appendChild(ElemTemplateElement newChild)
   {
 
     int type = ((ElemTemplateElement) newChild).getXSLToken();
diff --git a/src/org/apache/xalan/templates/ElemChoose.java b/src/org/apache/xalan/templates/ElemChoose.java
index 6ca2009..8a7b225 100644
--- a/src/org/apache/xalan/templates/ElemChoose.java
+++ b/src/org/apache/xalan/templates/ElemChoose.java
@@ -56,7 +56,8 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
+import org.apache.xml.dtm.DTM;
 
 import org.xml.sax.*;
 
@@ -119,12 +120,12 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
     if (TransformerImpl.S_DEBUG)
-      transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+      transformer.getTraceManager().fireTraceEvent(this);
 
     boolean found = false;
 
@@ -140,6 +141,8 @@
         ElemWhen when = (ElemWhen) childElem;
 
         // must be xsl:when
+        XPathContext xctxt = transformer.getXPathContext();
+        int sourceNode = xctxt.getCurrentNode();
         XObject test = when.getTest().execute(transformer.getXPathContext(),
                                               sourceNode, this);
 
@@ -149,7 +152,7 @@
 
         if ((null != test) && test.bool())
         {
-          transformer.executeChildTemplates(when, sourceNode, mode, true);
+          transformer.executeChildTemplates(when, true);
 
           return;
         }
@@ -159,7 +162,7 @@
         found = true;
 
         // xsl:otherwise                
-        transformer.executeChildTemplates(childElem, sourceNode, mode, true);
+        transformer.executeChildTemplates(childElem, true);
 
         return;
       }
@@ -179,7 +182,7 @@
    *
    * @throws DOMException
    */
-  public Node appendChild(Node newChild) throws DOMException
+  public ElemTemplateElement appendChild(ElemTemplateElement newChild)
   {
 
     int type = ((ElemTemplateElement) newChild).getXSLToken();
diff --git a/src/org/apache/xalan/templates/ElemComment.java b/src/org/apache/xalan/templates/ElemComment.java
index fc1e7cd..196f8ab 100644
--- a/src/org/apache/xalan/templates/ElemComment.java
+++ b/src/org/apache/xalan/templates/ElemComment.java
@@ -56,7 +56,8 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
+import org.apache.xml.dtm.DTM;
 
 import org.xml.sax.*;
 
@@ -111,13 +112,13 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
     try
     {
       if (TransformerImpl.S_DEBUG)
-        transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+        transformer.getTraceManager().fireTraceEvent(this);
 
       // Note the content model is:
       // <!ENTITY % instructions "
@@ -127,7 +128,7 @@
       // | xsl:element
       // | xsl:attribute
       // ">
-      String data = transformer.transformToString(this, sourceNode, mode);
+      String data = transformer.transformToString(this);
 
       transformer.getResultTreeHandler().comment(data);
     }
@@ -146,7 +147,7 @@
    *
    * @throws DOMException
    */
-  public Node appendChild(Node newChild) throws DOMException
+  public ElemTemplateElement appendChild(ElemTemplateElement newChild)
   {
 
     int type = ((ElemTemplateElement) newChild).getXSLToken();
diff --git a/src/org/apache/xalan/templates/ElemCopy.java b/src/org/apache/xalan/templates/ElemCopy.java
index 53ca79b..ded798f 100644
--- a/src/org/apache/xalan/templates/ElemCopy.java
+++ b/src/org/apache/xalan/templates/ElemCopy.java
@@ -56,7 +56,8 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
+import org.apache.xml.dtm.DTM;
 
 import org.xml.sax.*;
 
@@ -130,46 +131,47 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
     try
     {
-      short nodeType = sourceNode.getNodeType();
+      XPathContext xctxt = transformer.getXPathContext();
+      int sourceNode = xctxt.getCurrentNode();
+      DTM dtm = xctxt.getDTM(sourceNode);
+      short nodeType = dtm.getNodeType(sourceNode);
 
-      if ((Node.DOCUMENT_NODE != nodeType) && (Node.DOCUMENT_FRAGMENT_NODE != nodeType))
+      if ((DTM.DOCUMENT_NODE != nodeType) && (DTM.DOCUMENT_FRAGMENT_NODE != nodeType))
       {
         ResultTreeHandler rthandler = transformer.getResultTreeHandler();
 
         // TODO: Process the use-attribute-sets stuff
         rthandler.cloneToResultTree(sourceNode, false);
 
-        if (Node.ELEMENT_NODE == nodeType)
+        if (DTM.ELEMENT_NODE == nodeType)
         {
-          super.execute(transformer, sourceNode, mode);
+          super.execute(transformer);
           rthandler.processNSDecls(sourceNode);
-          transformer.executeChildTemplates(this, sourceNode, mode, true);
+          transformer.executeChildTemplates(this, true);
           
-          DOMHelper dhelper = transformer.getXPathContext().getDOMHelper();
-          String ns = dhelper.getNamespaceOfNode(sourceNode);
-          String localName = dhelper.getLocalNameOfNode(sourceNode);
+          String ns = dtm.getNamespaceURI(sourceNode);
+          String localName = dtm.getLocalName(sourceNode);
           transformer.getResultTreeHandler().endElement(ns, localName,
-                                                        sourceNode.getNodeName());
+                                                        dtm.getNodeName(sourceNode));
         }
         else
         {
           if (TransformerImpl.S_DEBUG)
-            transformer.getTraceManager().fireTraceEvent(sourceNode, mode,
-                                                         this);
+            transformer.getTraceManager().fireTraceEvent(this);
         }
       }
       else
       {
         if (TransformerImpl.S_DEBUG)
-          transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+          transformer.getTraceManager().fireTraceEvent(this);
 
-        super.execute(transformer, sourceNode, mode);
-        transformer.executeChildTemplates(this, sourceNode, mode, true);
+        super.execute(transformer);
+        transformer.executeChildTemplates(this, true);
       }
     }
     catch(org.xml.sax.SAXException se)
diff --git a/src/org/apache/xalan/templates/ElemCopyOf.java b/src/org/apache/xalan/templates/ElemCopyOf.java
index 5e6a08f..d6c0df1 100644
--- a/src/org/apache/xalan/templates/ElemCopyOf.java
+++ b/src/org/apache/xalan/templates/ElemCopyOf.java
@@ -56,8 +56,11 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.*;
+//import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMTreeWalker;
 
 import org.xml.sax.*;
 
@@ -146,16 +149,17 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
     try
     {
       if (TransformerImpl.S_DEBUG)
-        transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+        transformer.getTraceManager().fireTraceEvent(this);
 
       XPathContext xctxt = transformer.getXPathContext();
+      int sourceNode = xctxt.getCurrentNode();
       XObject value = m_selectExpression.execute(xctxt, sourceNode, this);
 
       if (TransformerImpl.S_DEBUG)
@@ -181,30 +185,30 @@
         case XObject.CLASS_NODESET :
 
           // System.out.println(value);
-          NodeIterator nl = value.nodeset();
+          DTMIterator nl = value.nodeset();
 
           // Copy the tree.
-          org.apache.xml.utils.TreeWalker tw =
-                                                new TreeWalker2Result(transformer, handler);
-          Node pos;
+          DTMTreeWalker tw = new TreeWalker2Result(transformer, handler);
+          int pos;
 
-          while (null != (pos = nl.nextNode()))
+          while (DTM.NULL != (pos = nl.nextNode()))
           {
-            short t = pos.getNodeType();
+            DTM dtm = xctxt.getDTMManager().getDTM(pos);
+            short t = dtm.getNodeType(pos);
 
             // If we just copy the whole document, a startDoc and endDoc get 
             // generated, so we need to only walk the child nodes.
-            if (t == Node.DOCUMENT_NODE)
+            if (t == DTM.DOCUMENT_NODE)
             {
-              for (Node child = pos.getFirstChild(); child != null;
-                   child = child.getNextSibling())
+              for (int child = dtm.getFirstChild(pos); child != DTM.NULL;
+                   child = dtm.getNextSibling(child))
               {
                 tw.traverse(child);
               }
             }
-            else if (t == Node.ATTRIBUTE_NODE)
+            else if (t == DTM.ATTRIBUTE_NODE)
             {
-              handler.addAttribute((Attr) pos);
+              handler.addAttribute(pos);
             }
             else
             {
@@ -218,6 +222,7 @@
                                            transformer.getXPathContext());
           break;
         default :
+          
           s = value.str();
 
           handler.characters(s.toCharArray(), 0, s.length());
@@ -238,10 +243,8 @@
    * @param newChild Child to add to this node's child list
    *
    * @return Child just added to child list
-   *
-   * @throws DOMException
    */
-  public Node appendChild(Node newChild) throws DOMException
+  public ElemTemplateElement appendChild(ElemTemplateElement newChild)
   {
 
     error(XSLTErrorResources.ER_CANNOT_ADD,
diff --git a/src/org/apache/xalan/templates/ElemElement.java b/src/org/apache/xalan/templates/ElemElement.java
index 1669647..974bb8c 100644
--- a/src/org/apache/xalan/templates/ElemElement.java
+++ b/src/org/apache/xalan/templates/ElemElement.java
@@ -56,7 +56,8 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
+import org.apache.xml.dtm.DTM;
 
 import org.xml.sax.*;
 
@@ -256,12 +257,13 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
     ResultTreeHandler rhandler = transformer.getResultTreeHandler();
     XPathContext xctxt = transformer.getXPathContext();
+    int sourceNode = xctxt.getCurrentNode();
     String nodeName = m_name_avt.evaluate(xctxt, sourceNode, this);
 
     // make sure that if a prefix is specified on the attribute name, it is valid
@@ -275,10 +277,11 @@
     if ((null != nodeName) /* && (indexOfNSSep >= 0) */)
     {
       prefix = (indexOfNSSep > 0) ? nodeName.substring(0, indexOfNSSep) : "";
-
+      
       // Catch the exception this may cause. We don't want to stop processing.
       try
       {
+        // Maybe temporary, until I get this worked out.  test: axes59
         nodeNamespace = getNamespaceForPrefix(prefix);
 
         if (null == nodeNamespace && indexOfNSSep <= 0)
@@ -351,8 +354,7 @@
       }
     }
 
-    constructNode(nodeName, prefix, nodeNamespace, transformer, sourceNode,
-                  mode);
+    constructNode(nodeName, prefix, nodeNamespace, transformer);
   }
   
   /**
@@ -369,7 +371,7 @@
    * @throws TransformerException
    */
   void constructNode(
-          String nodeName, String prefix, String nodeNamespace, TransformerImpl transformer, Node sourceNode, QName mode)
+          String nodeName, String prefix, String nodeNamespace, TransformerImpl transformer)
             throws TransformerException
   {
 
@@ -395,10 +397,9 @@
       boolean shouldAddAttrs = (null != nodeName);
 
       if (shouldAddAttrs)
-        super.execute(transformer, sourceNode, mode);
+        super.execute(transformer);
 
-      transformer.executeChildTemplates(this, sourceNode, mode,
-                                        shouldAddAttrs);
+      transformer.executeChildTemplates(this, shouldAddAttrs);
 
       // Now end the element if name was valid
       if (null != nodeName)
diff --git a/src/org/apache/xalan/templates/ElemExtensionCall.java b/src/org/apache/xalan/templates/ElemExtensionCall.java
index d50018c..f227169 100644
--- a/src/org/apache/xalan/templates/ElemExtensionCall.java
+++ b/src/org/apache/xalan/templates/ElemExtensionCall.java
@@ -60,7 +60,7 @@
 
 import java.util.*;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
 
 import org.xml.sax.*;
 import org.xml.sax.helpers.*;
@@ -81,6 +81,8 @@
 
 import javax.xml.transform.TransformerException;
 
+import org.apache.xml.dtm.DTM;
+
 /**
  * <meta name="usage" content="advanced"/>
  * Implement an extension element.
@@ -238,7 +240,7 @@
    * @throws TransformerException
    */
   public void executeFallbacks(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
     for (ElemTemplateElement child = m_firstChild; child != null;
@@ -249,7 +251,7 @@
         try
         {
           transformer.pushElemTemplateElement(child);
-          ((ElemFallback) child).executeFallback(transformer, sourceNode, mode);
+          ((ElemFallback) child).executeFallback(transformer);
         }
         finally
         {
@@ -271,7 +273,7 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
@@ -294,7 +296,7 @@
           etable.addExtensionNamespace(m_extns, nsh);
         else
         {
-          executeFallbacks(transformer, sourceNode, mode);
+          executeFallbacks(transformer);
           return;
         }
 
@@ -303,8 +305,7 @@
       try
       {
         nsh.processElement(this.getLocalName(), this, transformer,
-                           getStylesheet(), sourceNode.getOwnerDocument(),
-                           sourceNode, mode, this);
+                           getStylesheet(), this);
       }
       catch (Exception e)
       {
@@ -344,7 +345,7 @@
           transformer.getErrorListener().error(te); // ??
 
         executeFallbacks(
-          transformer, sourceNode, mode);
+          transformer);
       }
     }
     catch(org.xml.sax.SAXException se)
@@ -387,7 +388,7 @@
    * @throws TransformerException
    */
   public String getAttribute(
-          String rawName, Node sourceNode, TransformerImpl transformer)
+          String rawName, org.w3c.dom.Node sourceNode, TransformerImpl transformer)
             throws TransformerException
   {
 
@@ -397,9 +398,12 @@
     {
       XPathContext xctxt = transformer.getXPathContext();
 
-      return avt.evaluate(xctxt, sourceNode, this);
+      return avt.evaluate(xctxt, 
+            xctxt.getDTMHandleFromNode(sourceNode), 
+            this);
     }
 
     return null;
   }
+  
 }
diff --git a/src/org/apache/xalan/templates/ElemFallback.java b/src/org/apache/xalan/templates/ElemFallback.java
index 5a782c2..4cd6691 100644
--- a/src/org/apache/xalan/templates/ElemFallback.java
+++ b/src/org/apache/xalan/templates/ElemFallback.java
@@ -113,7 +113,7 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
   }
@@ -134,7 +134,7 @@
    * @throws TransformerException
    */
   public void executeFallback(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
@@ -142,10 +142,9 @@
     {
 
       if (TransformerImpl.S_DEBUG)
-        transformer.getTraceManager().fireTraceEvent(sourceNode, mode,
-                this);
+        transformer.getTraceManager().fireTraceEvent(this);
 
-      transformer.executeChildTemplates(this, sourceNode, mode, true);
+      transformer.executeChildTemplates(this, true);
 
     }
     else
diff --git a/src/org/apache/xalan/templates/ElemForEach.java b/src/org/apache/xalan/templates/ElemForEach.java
index 7c17e1f..899b3ff 100644
--- a/src/org/apache/xalan/templates/ElemForEach.java
+++ b/src/org/apache/xalan/templates/ElemForEach.java
@@ -56,8 +56,11 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.*;
+//import org.w3c.dom.traversal.NodeIterator;
+
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import org.xml.sax.*;
 
@@ -74,7 +77,6 @@
 import org.apache.xalan.transformer.NodeSorter;
 import org.apache.xalan.transformer.ResultTreeHandler;
 import org.apache.xalan.transformer.StackGuard;
-import org.apache.xalan.stree.SaxEventDispatch;
 
 import javax.xml.transform.SourceLocator;
 import javax.xml.transform.TransformerException;
@@ -206,15 +208,12 @@
   /**
    * Execute the xsl:for-each transformation 
    *
-   *
    * @param transformer non-null reference to the the current transform-time state.
-   * @param sourceNode non-null reference to the <a href="http://www.w3.org/TR/xslt#dt-current-node">current source node</a>.
-   * @param mode reference, which may be null, to the <a href="http://www.w3.org/TR/xslt#modes">current mode</a>.
    *
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
@@ -223,9 +222,9 @@
     try
     {
       if (TransformerImpl.S_DEBUG)
-        transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+        transformer.getTraceManager().fireTraceEvent(this);
 
-      transformSelectedNodes(transformer, sourceNode, this, mode);
+      transformSelectedNodes(transformer, this);
     }
     finally
     {
@@ -256,35 +255,22 @@
    *
    * @throws TransformerException
    */
-  protected NodeIterator sortNodes(
-          XPathContext xctxt, Vector keys, NodeIterator sourceNodes)
+  protected DTMIterator sortNodes(
+          XPathContext xctxt, Vector keys, DTMIterator sourceNodes)
             throws TransformerException
   {
 
     NodeSorter sorter = new NodeSorter(xctxt);
-    NodeSet nodeList;
+    
+    sourceNodes.setShouldCacheNodes(true);
+    sourceNodes.runTo(-1);
 
-    if (sourceNodes instanceof NodeSet)
-    {
-      nodeList = ((NodeSet) sourceNodes);
-
-      nodeList.setShouldCacheNodes(true);
-      nodeList.runTo(-1);
-    }
-    else
-    {
-      nodeList = new NodeSet(sourceNodes);
-      sourceNodes = nodeList;
-
-      ((ContextNodeList) sourceNodes).setCurrentPos(0);
-    }
-
-    xctxt.pushContextNodeList((ContextNodeList) sourceNodes);
+    xctxt.pushContextNodeList(sourceNodes);
 
     try
     {
-      sorter.sort(nodeList, keys, xctxt);
-      nodeList.setCurrentPos(0);
+      sorter.sort(sourceNodes, keys, xctxt);
+      sourceNodes.setCurrentPos(0);
     }
     finally
     {
@@ -321,7 +307,7 @@
    * @throws TransformerException
    */
   int pushParams(
-          TransformerImpl transformer, XPathContext xctxt, Node sourceNode, QName mode)
+          TransformerImpl transformer, XPathContext xctxt)
             throws TransformerException
   {
 
@@ -359,25 +345,13 @@
    * <meta name="usage" content="advanced"/>
    * Perform a query if needed, and call transformNode for each child.
    *
-   *
    * @param transformer non-null reference to the the current transform-time state.
-   * @param sourceNode non-null reference to the <a href="http://www.w3.org/TR/xslt#dt-current-node">current source node</a>.
-   * @throws TransformerException Thrown in a variety of circumstances.
-   * @param stylesheetTree The owning stylesheet tree.
-   * @param xslInstruction The stylesheet element context (depricated -- I do
-   *      not think we need this).
    * @param template The owning template context.
-   * @param sourceNodeContext The current source node context.
-   * @param mode The current mode.
-   * @param selectPattern The XPath with which to perform the selection.
-   * @param xslToken The current XSLT instruction (depricated -- I do not
-   *     think we want this).
-   * @param tcontext The TransformerImpl context.
-   * @param selectStackFrameIndex The stack frame context for executing the
-   *                              select statement.
+   * 
+   * @throws TransformerException Thrown in a variety of circumstances.
    */
   public void transformSelectedNodes(
-          TransformerImpl transformer, Node sourceNode, ElemTemplateElement template, QName mode)
+          TransformerImpl transformer, ElemTemplateElement template)
             throws TransformerException
   {
     try
@@ -385,6 +359,7 @@
       boolean rdebug = TransformerImpl.S_DEBUG;
       XPathContext xctxt = transformer.getXPathContext();
       XPath selectPattern = getSelectOrDefault();
+      int sourceNode = xctxt.getCurrentNode();
       XObject selectResult = selectPattern.execute(xctxt, sourceNode, this);
       
       if (rdebug)
@@ -392,7 +367,7 @@
                                                         "test", selectPattern, selectResult);
       
       Vector keys = transformer.processSortKeys(this, sourceNode);
-      NodeIterator sourceNodes = selectResult.nodeset();
+      DTMIterator sourceNodes = selectResult.nodeset();
 
       // Sort if we need to.
       if (null != keys)
@@ -401,14 +376,14 @@
       // The returned value is only relevant for ElemApplyTemplates.
       // This value needs to be passed to popParams which will
       // restore it in the variable stack.
-      int savedSearchStart = pushParams(transformer, xctxt, sourceNode, mode);
+      int savedSearchStart = pushParams(transformer, xctxt);
 
       // Push the ContextNodeList on a stack, so that select="position()"
       // and the like will work.
       // System.out.println("pushing context node list...");
       SourceLocator savedLocator = xctxt.getSAXLocator();
 
-      xctxt.pushContextNodeList((ContextNodeList) sourceNodes);
+      xctxt.pushContextNodeList(sourceNodes);
       transformer.pushElemTemplateElement(null);
 
       ResultTreeHandler rth = transformer.getResultTreeHandler();
@@ -423,38 +398,34 @@
       
       try
       {
-        Node child;
+        int child;
 
-        while (null != (child = sourceNodes.nextNode()))
+        while (DTM.NULL != (child = sourceNodes.nextNode()))
         {
+          // System.out.println("child: "+child);
+          DTM dtm = xctxt.getDTM(child);
           if (needToFindTemplate)
           {
+            QName mode = transformer.getMode();
+            
             template = tl.getTemplate(xctxt, child, mode, -1, quiet);
 
             // If that didn't locate a node, fall back to a default template rule.
             // See http://www.w3.org/TR/xslt#built-in-rule.
             if (null == template)
             {
-              switch (child.getNodeType())
+              switch (dtm.getNodeType(child))
               {
-              case Node.DOCUMENT_FRAGMENT_NODE :
-              case Node.ELEMENT_NODE :
+              case DTM.DOCUMENT_FRAGMENT_NODE :
+              case DTM.ELEMENT_NODE :
                 template = sroot.getDefaultRule();
                 break;
-              case Node.ATTRIBUTE_NODE :
-              case Node.CDATA_SECTION_NODE :
-              case Node.TEXT_NODE :
-                if (child.isSupported(SaxEventDispatch.SUPPORTSINTERFACE, "1.0"))
-                {
-                  ((SaxEventDispatch) child).dispatchCharactersEvent(rth);
-                }
-                else
-                {
-                  String data = child.getNodeValue();
-                  rth.characters(data.toCharArray(), 0, data.length());
-                }
+              case DTM.ATTRIBUTE_NODE :
+              case DTM.CDATA_SECTION_NODE :
+              case DTM.TEXT_NODE :
+                dtm.dispatchCharactersEvents(child, rth);
                 continue;
-              case Node.DOCUMENT_NODE :
+              case DTM.DOCUMENT_NODE :
                 template = sroot.getDefaultRootRule();
                 break;
               default :
@@ -480,13 +451,13 @@
 
             // Fire a trace event for the template.
             if (rdebug)
-              transformer.getTraceManager().fireTraceEvent(child, mode,
-                                                           template);
+              transformer.getTraceManager().fireTraceEvent(template);
 
             // And execute the child templates.
-            if (template.isCompiledTemplate())
-              template.execute(transformer, child, mode);
-            else
+            // %XTBD% ???
+//            if (template.isCompiledTemplate())
+//              template.execute(transformer, child, mode);
+//            else
             {
 
               // Loop through the children of the template, calling execute on 
@@ -496,7 +467,7 @@
               {
                 xctxt.setSAXLocator(t);
                 transformer.setCurrentElement(t);
-                t.execute(transformer, child, mode);
+                t.execute(transformer);
               }
             }
             reMarkParams(xctxt);
@@ -539,10 +510,8 @@
    * @param newChild Child to add to child list
    *
    * @return Child just added to child list
-   *
-   * @throws DOMException
    */
-  public Node appendChild(Node newChild) throws DOMException
+  public ElemTemplateElement appendChild(ElemTemplateElement newChild)
   {
 
     int type = ((ElemTemplateElement) newChild).getXSLToken();
diff --git a/src/org/apache/xalan/templates/ElemIf.java b/src/org/apache/xalan/templates/ElemIf.java
index 2e9343d..a0bb69e 100644
--- a/src/org/apache/xalan/templates/ElemIf.java
+++ b/src/org/apache/xalan/templates/ElemIf.java
@@ -56,7 +56,8 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
+import org.apache.xml.dtm.DTM;
 
 import org.xml.sax.*;
 
@@ -147,23 +148,24 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
     if (TransformerImpl.S_DEBUG)
-      transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+      transformer.getTraceManager().fireTraceEvent(this);
 
     XPathContext xctxt = transformer.getXPathContext();
+    
+    int sourceNode = xctxt.getCurrentNode();
     XObject test = m_test.execute(xctxt, sourceNode, this);
-
     if (TransformerImpl.S_DEBUG)
       transformer.getTraceManager().fireSelectedEvent(sourceNode, this,
               "test", m_test, test);
 
     if (test.bool())
     {
-      transformer.executeChildTemplates(this, sourceNode, mode, true);
+      transformer.executeChildTemplates(this, true);
     }
   }
 }
diff --git a/src/org/apache/xalan/templates/ElemLiteralResult.java b/src/org/apache/xalan/templates/ElemLiteralResult.java
index 02e0d4b..9388442 100644
--- a/src/org/apache/xalan/templates/ElemLiteralResult.java
+++ b/src/org/apache/xalan/templates/ElemLiteralResult.java
@@ -56,7 +56,8 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
+import org.apache.xml.dtm.DTM;
 
 import org.xml.sax.*;
 import org.xml.sax.helpers.*;
@@ -589,7 +590,7 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
@@ -605,7 +606,7 @@
       {
 
         // Process any possible attributes from xsl:use-attribute-sets first
-        super.execute(transformer, sourceNode, mode);
+        super.execute(transformer);
 
         //xsl:version, excludeResultPrefixes???
         // Process the list of avts next
@@ -617,6 +618,7 @@
           {
             AVT avt = (AVT) m_avts.elementAt(i);
             XPathContext xctxt = transformer.getXPathContext();
+            int sourceNode = xctxt.getCurrentNode();
             String stringedValue = avt.evaluate(xctxt, sourceNode, this);
 
             if (null != stringedValue)
@@ -634,7 +636,7 @@
 
         // Now process all the elements in this subtree
         // TODO: Process m_extensionElementPrefixes && m_attributeSetsNames
-        transformer.executeChildTemplates(this, sourceNode, mode, true);
+        transformer.executeChildTemplates(this, true);
       }
       finally
       {
diff --git a/src/org/apache/xalan/templates/ElemMessage.java b/src/org/apache/xalan/templates/ElemMessage.java
index e8db2a0..47492ac 100644
--- a/src/org/apache/xalan/templates/ElemMessage.java
+++ b/src/org/apache/xalan/templates/ElemMessage.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
 
 import org.xml.sax.*;
 
@@ -152,14 +152,14 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
     if (TransformerImpl.S_DEBUG)
-      transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+      transformer.getTraceManager().fireTraceEvent(this);
 
-    String data = transformer.transformToString(this, sourceNode, mode);
+    String data = transformer.transformToString(this);
 
     transformer.getMsgMgr().message(this, data, m_terminate);
     
diff --git a/src/org/apache/xalan/templates/ElemNumber.java b/src/org/apache/xalan/templates/ElemNumber.java
index 1f67495..1b12c95 100644
--- a/src/org/apache/xalan/templates/ElemNumber.java
+++ b/src/org/apache/xalan/templates/ElemNumber.java
@@ -58,8 +58,10 @@
 
 import org.apache.xml.utils.res.XResourceBundle;
 
-import org.w3c.dom.*;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.*;
+//import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import org.xml.sax.*;
 
@@ -508,13 +510,14 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
     if (TransformerImpl.S_DEBUG)
-      transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+      transformer.getTraceManager().fireTraceEvent(this);
 
+    int sourceNode = transformer.getXPathContext().getCurrentNode();
     String countString = getCountString(transformer, sourceNode);
 
     try
@@ -537,7 +540,7 @@
    *
    * @throws DOMException
    */
-  public Node appendChild(Node newChild) throws DOMException
+  public ElemTemplateElement appendChild(ElemTemplateElement newChild)
   {
 
     error(XSLTErrorResources.ER_CANNOT_ADD,
@@ -564,12 +567,13 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  Node findAncestor(
-          XPathContext xctxt, XPath fromMatchPattern, XPath countMatchPattern, Node context, Element namespaceContext)
+  int findAncestor(
+          XPathContext xctxt, XPath fromMatchPattern, XPath countMatchPattern, 
+          int context, ElemNumber namespaceContext)
             throws javax.xml.transform.TransformerException
   {
-
-    while (null != context)
+    DTM dtm = xctxt.getDTM(context);
+    while (DTM.NULL != context)
     {
       if (null != fromMatchPattern)
       {
@@ -591,7 +595,7 @@
         }
       }
 
-      context = xctxt.getDOMHelper().getParentOfNode(context);
+      context = dtm.getParent(context);
     }
 
     return context;
@@ -613,19 +617,20 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  private Node findPrecedingOrAncestorOrSelf(
-          XPathContext xctxt, XPath fromMatchPattern, XPath countMatchPattern, Node context, Element namespaceContext)
+  private int findPrecedingOrAncestorOrSelf(
+          XPathContext xctxt, XPath fromMatchPattern, XPath countMatchPattern, 
+          int context, ElemNumber namespaceContext)
             throws javax.xml.transform.TransformerException
   {
-
-    while (null != context)
+    DTM dtm = xctxt.getDTM(context);
+    while (DTM.NULL != context)
     {
       if (null != fromMatchPattern)
       {
         if (fromMatchPattern.getMatchScore(xctxt, context)
                 != XPath.MATCH_SCORE_NONE)
         {
-          context = null;
+          context = DTM.NULL;
 
           break;
         }
@@ -640,19 +645,19 @@
         }
       }
 
-      Node prevSibling = context.getPreviousSibling();
+      int prevSibling = dtm.getPreviousSibling(context);
 
-      if (null == prevSibling)
+      if (DTM.NULL == prevSibling)
       {
-        context = xctxt.getDOMHelper().getParentOfNode(context);
+        context = dtm.getParent(context);
       }
       else
       {
 
         // Now go down the chain of children of this sibling 
-        context = prevSibling.getLastChild();
+        context = dtm.getLastChild(prevSibling);
 
-        if (context == null)
+        if (context == DTM.NULL)
           context = prevSibling;
       }
     }
@@ -670,48 +675,48 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  XPath getCountMatchPattern(XPathContext support, Node contextNode)
+  XPath getCountMatchPattern(XPathContext support, int contextNode)
           throws javax.xml.transform.TransformerException
   {
 
     XPath countMatchPattern = m_countMatchPattern;
-
+    DTM dtm = support.getDTM(contextNode);
     if (null == countMatchPattern)
     {
-      switch (contextNode.getNodeType())
+      switch (dtm.getNodeType(contextNode))
       {
-      case Node.ELEMENT_NODE :
+      case DTM.ELEMENT_NODE :
 
         // countMatchPattern = m_stylesheet.createMatchPattern(contextNode.getNodeName(), this);
-        countMatchPattern = new XPath(contextNode.getNodeName(), this, this,
+        countMatchPattern = new XPath(dtm.getNodeName(contextNode), this, this,
                                       XPath.MATCH, support.getErrorListener());
         break;
-      case Node.ATTRIBUTE_NODE :
+      case DTM.ATTRIBUTE_NODE :
 
         // countMatchPattern = m_stylesheet.createMatchPattern("@"+contextNode.getNodeName(), this);
-        countMatchPattern = new XPath("@" + contextNode.getNodeName(), this,
+        countMatchPattern = new XPath("@" + dtm.getNodeName(contextNode), this,
                                       this, XPath.MATCH, support.getErrorListener());
         break;
-      case Node.CDATA_SECTION_NODE :
-      case Node.TEXT_NODE :
+      case DTM.CDATA_SECTION_NODE :
+      case DTM.TEXT_NODE :
 
         // countMatchPattern = m_stylesheet.createMatchPattern("text()", this);
         countMatchPattern = new XPath("text()", this, this, XPath.MATCH, support.getErrorListener());
         break;
-      case Node.COMMENT_NODE :
+      case DTM.COMMENT_NODE :
 
         // countMatchPattern = m_stylesheet.createMatchPattern("comment()", this);
         countMatchPattern = new XPath("comment()", this, this, XPath.MATCH, support.getErrorListener());
         break;
-      case Node.DOCUMENT_NODE :
+      case DTM.DOCUMENT_NODE :
 
         // countMatchPattern = m_stylesheet.createMatchPattern("/", this);
         countMatchPattern = new XPath("/", this, this, XPath.MATCH, support.getErrorListener());
         break;
-      case Node.PROCESSING_INSTRUCTION_NODE :
+      case DTM.PROCESSING_INSTRUCTION_NODE :
 
         // countMatchPattern = m_stylesheet.createMatchPattern("pi("+contextNode.getNodeName()+")", this);
-        countMatchPattern = new XPath("pi(" + contextNode.getNodeName()
+        countMatchPattern = new XPath("pi(" + dtm.getNodeName(contextNode)
                                       + ")", this, this, XPath.MATCH, support.getErrorListener());
         break;
       default :
@@ -732,7 +737,7 @@
    *
    * @throws TransformerException
    */
-  String getCountString(TransformerImpl transformer, Node sourceNode)
+  String getCountString(TransformerImpl transformer, int sourceNode)
           throws TransformerException
   {
 
@@ -768,7 +773,7 @@
 
           for (int i = lastIndex; i >= 0; i--)
           {
-            Node target = ancestors.elementAt(i);
+            int target = ancestors.elementAt(i);
 
             list[lastIndex - i] = ctable.countNode(xctxt, this, target);
           }
@@ -790,11 +795,12 @@
    *
    * @throws TransformerException
    */
-  public Node getPreviousNode(XPathContext xctxt, Node pos)
+  public int getPreviousNode(XPathContext xctxt, int pos)
           throws TransformerException
   {
 
     XPath countMatchPattern = getCountMatchPattern(xctxt, pos);
+    DTM dtm = xctxt.getDTM(pos);
 
     if (Constants.NUMBERLEVEL_ANY == m_level)
     {
@@ -803,22 +809,23 @@
       // Do a backwards document-order walk 'till a node is found that matches 
       // the 'from' pattern, or a node is found that matches the 'count' pattern, 
       // or the top of the tree is found.
-      while (null != pos)
+      while (DTM.NULL != pos)
       {
 
         // Get the previous sibling, if there is no previous sibling, 
         // then count the parent, but if there is a previous sibling, 
         // dive down to the lowest right-hand (last) child of that sibling.
-        Node next = pos.getPreviousSibling();
+        int next = dtm.getPreviousSibling(pos);
 
-        if (null == next)
+        if (DTM.NULL == next)
         {
-          next = pos.getParentNode();
+          next = dtm.getParent(pos);
 
-          if ((null != next) && ((((null != fromMatchPattern) && (fromMatchPattern.getMatchScore(
-                  xctxt, next) != XPath.MATCH_SCORE_NONE))) || (next.getNodeType() == Node.DOCUMENT_NODE)))
+          if ((DTM.NULL != next) && ((((null != fromMatchPattern) && (fromMatchPattern.getMatchScore(
+                  xctxt, next) != XPath.MATCH_SCORE_NONE))) 
+              || (dtm.getNodeType(next) == DTM.DOCUMENT_NODE)))
           {
-            pos = null;  // return null from function.
+            pos = DTM.NULL;  // return null from function.
 
             break;  // from while loop
           }
@@ -827,20 +834,20 @@
         {
 
           // dive down to the lowest right child.
-          Node child = next;
+          int child = next;
 
-          while (null != child)
+          while (DTM.NULL != child)
           {
-            child = next.getLastChild();
+            child = dtm.getLastChild(next);
 
-            if (null != child)
+            if (DTM.NULL != child)
               next = child;
           }
         }
 
         pos = next;
 
-        if ((null != pos)
+        if ((DTM.NULL != pos)
                 && ((null == countMatchPattern)
                     || (countMatchPattern.getMatchScore(xctxt, pos)
                         != XPath.MATCH_SCORE_NONE)))
@@ -851,11 +858,11 @@
     }
     else  // NUMBERLEVEL_MULTI or NUMBERLEVEL_SINGLE
     {
-      while (null != pos)
+      while (DTM.NULL != pos)
       {
-        pos = pos.getPreviousSibling();
+        pos = dtm.getPreviousSibling(pos);
 
-        if ((null != pos)
+        if ((DTM.NULL != pos)
                 && ((null == countMatchPattern)
                     || (countMatchPattern.getMatchScore(xctxt, pos)
                         != XPath.MATCH_SCORE_NONE)))
@@ -878,11 +885,11 @@
    *
    * @throws TransformerException
    */
-  public Node getTargetNode(XPathContext xctxt, Node sourceNode)
+  public int getTargetNode(XPathContext xctxt, int sourceNode)
           throws TransformerException
   {
 
-    Node target = null;
+    int target = DTM.NULL;
     XPath countMatchPattern = getCountMatchPattern(xctxt, sourceNode);
 
     if (Constants.NUMBERLEVEL_ANY == m_level)
@@ -916,14 +923,15 @@
    * @throws javax.xml.transform.TransformerException
    */
   NodeVector getMatchingAncestors(
-          XPathContext xctxt, Node node, boolean stopAtFirstFound)
+          XPathContext xctxt, int node, boolean stopAtFirstFound)
             throws javax.xml.transform.TransformerException
   {
 
     NodeSet ancestors = new NodeSet();
     XPath countMatchPattern = getCountMatchPattern(xctxt, node);
+    DTM dtm = xctxt.getDTM(node);
 
-    while (null != node)
+    while (DTM.NULL != node)
     {
       if ((null != m_fromMatchPattern)
               && (m_fromMatchPattern.getMatchScore(xctxt, node)
@@ -953,7 +961,7 @@
           break;
       }
 
-      node = xctxt.getDOMHelper().getParentOfNode(node);
+      node = dtm.getParent(node);
     }
 
     return ancestors;
@@ -970,7 +978,7 @@
    *
    * @throws TransformerException
    */
-  Locale getLocale(TransformerImpl transformer, Node contextNode)
+  Locale getLocale(TransformerImpl transformer, int contextNode)
           throws TransformerException
   {
 
@@ -992,9 +1000,10 @@
         //Locale.getDefault().getDisplayCountry());
         if (null == locale)
         {
-          transformer.getMsgMgr().warn(this, null, contextNode,
-                                       XSLTErrorResources.WG_LOCALE_NOT_FOUND,
-                                       new Object[]{ langValue });  //"Warning: Could not find locale for xml:lang="+langValue);
+          // %DTBD%
+//          transformer.getMsgMgr().warn(this, null, contextNode,
+//                                       XSLTErrorResources.WG_LOCALE_NOT_FOUND,
+//                                       new Object[]{ langValue });  //"Warning: Could not find locale for xml:lang="+langValue);
 
           locale = Locale.getDefault();
         }
@@ -1019,7 +1028,7 @@
    * @throws TransformerException
    */
   private DecimalFormat getNumberFormatter(
-          TransformerImpl transformer, Node contextNode) throws TransformerException
+          TransformerImpl transformer, int contextNode) throws TransformerException
   {
     // Patch from Steven Serocki
     // Maybe we really want to do the clone in getLocale() and return  
@@ -1078,7 +1087,7 @@
    * @throws TransformerException
    */
   String formatNumberList(
-          TransformerImpl transformer, int[] list, Node contextNode)
+          TransformerImpl transformer, int[] list, int contextNode)
             throws TransformerException
   {
 
@@ -1235,7 +1244,7 @@
    * @throws javax.xml.transform.TransformerException
    */
   private void getFormattedNumber(
-          TransformerImpl transformer, Node contextNode, 
+          TransformerImpl transformer, int contextNode, 
           char numberType, int numberWidth, int listElement, 
           FastStringBuffer formattedNumber)
             throws javax.xml.transform.TransformerException
diff --git a/src/org/apache/xalan/templates/ElemPI.java b/src/org/apache/xalan/templates/ElemPI.java
index 4785100..7480624 100644
--- a/src/org/apache/xalan/templates/ElemPI.java
+++ b/src/org/apache/xalan/templates/ElemPI.java
@@ -56,7 +56,8 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
+import org.apache.xml.dtm.DTM;
 
 import org.xml.sax.*;
 
@@ -147,19 +148,21 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
     if (TransformerImpl.S_DEBUG)
-      transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+      transformer.getTraceManager().fireTraceEvent(this);
 
-    String piName = m_name_atv.evaluate(transformer.getXPathContext(),
-                                        sourceNode, this);
+    XPathContext xctxt = transformer.getXPathContext();
+    int sourceNode = xctxt.getCurrentNode();
+    String piName = m_name_atv.evaluate(xctxt, sourceNode, this);
 
     if (piName.equalsIgnoreCase("xml"))
     {
-      error(XSLTErrorResources.ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML);  //"processing-instruction name can not be 'xml'");
+      // %DTBD%
+//      error(XSLTErrorResources.ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML);  //"processing-instruction name can not be 'xml'");
     }
     else if (!isValidNCName(piName))
     {
@@ -175,7 +178,7 @@
     // | xsl:element
     // | xsl:attribute
     // ">
-    String data = transformer.transformToString(this, sourceNode, mode);
+    String data = transformer.transformToString(this);
 
     try
     {
@@ -196,7 +199,7 @@
    *
    * @throws DOMException
    */
-  public Node appendChild(Node newChild) throws DOMException
+  public ElemTemplateElement appendChild(ElemTemplateElement newChild)
   {
 
     int type = ((ElemTemplateElement) newChild).getXSLToken();
diff --git a/src/org/apache/xalan/templates/ElemParam.java b/src/org/apache/xalan/templates/ElemParam.java
index 5c5cbd5..b63be1f 100644
--- a/src/org/apache/xalan/templates/ElemParam.java
+++ b/src/org/apache/xalan/templates/ElemParam.java
@@ -136,7 +136,7 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
@@ -145,13 +145,13 @@
 
     if (null == arg)
     {
-      super.execute(transformer, sourceNode, mode);
+      super.execute(transformer);
     }
     else
     {
       arg.setIsVisible(true);
       if (TransformerImpl.S_DEBUG)
-        transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+        transformer.getTraceManager().fireTraceEvent(this);
     }
   }
 }
diff --git a/src/org/apache/xalan/templates/ElemTemplate.java b/src/org/apache/xalan/templates/ElemTemplate.java
index ac69dc5..89b8f28 100644
--- a/src/org/apache/xalan/templates/ElemTemplate.java
+++ b/src/org/apache/xalan/templates/ElemTemplate.java
@@ -368,25 +368,25 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
-
     if (TransformerImpl.S_DEBUG)
-      transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+      transformer.getTraceManager().fireTraceEvent(this);
 
-    if (null != sourceNode)
-    {
-      transformer.executeChildTemplates(this, sourceNode, mode, true);
-    }
-    else  // if(null == sourceNode)
-    {
-      transformer.getMsgMgr().error(this,
-        this, sourceNode,
-        XSLTErrorResources.ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES);
-
-      //"sourceNode is null in handleApplyTemplatesInstruction!");
-    }
+      // %REVIEW% commenting out of the code below.
+//    if (null != sourceNode)
+//    {
+      transformer.executeChildTemplates(this, true);
+//    }
+//    else  // if(null == sourceNode)
+//    {
+//      transformer.getMsgMgr().error(this,
+//        this, sourceNode,
+//        XSLTErrorResources.ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES);
+//
+//      //"sourceNode is null in handleApplyTemplatesInstruction!");
+//    }
   }
 
   /**
diff --git a/src/org/apache/xalan/templates/ElemTemplateElement.java b/src/org/apache/xalan/templates/ElemTemplateElement.java
index 15eadec..50ae702 100644
--- a/src/org/apache/xalan/templates/ElemTemplateElement.java
+++ b/src/org/apache/xalan/templates/ElemTemplateElement.java
@@ -82,10 +82,11 @@
 import javax.xml.transform.SourceLocator;
 
 // DOM Imports
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.NodeList;
+//import org.w3c.dom.DOMException;
+//import org.w3c.dom.Document;
+import org.apache.xml.dtm.DTM;
 
 // SAX Imports
 import org.xml.sax.Locator;
@@ -175,7 +176,7 @@
    * @throws TransformerException if any checked exception occurs.
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException{}
 
   /**
@@ -283,6 +284,18 @@
   }
   
   /**
+   * Throw an error.
+   *
+   * @param msg Message code for the error
+   */
+  public void error(int msg)
+  {
+    error(
+      XSLMessages.createMessage(
+        XSLTErrorResources.ER_ELEMTEMPLATEELEM_ERR, null));
+  }
+  
+  /**
    * Throw a template element runtime error.  (Note: should we throw a TransformerException instead?)
    *
    * @param msg Description of the error that occured.
@@ -295,6 +308,45 @@
   
 
   // Implemented DOM Element methods.
+// %DTBD%
+//  /**
+//   * Add a child to the child list.
+//   * NOTE: This presumes the child did not previously have a parent.
+//   * Making that assumption makes this a less expensive operation -- but
+//   * requires that if you *do* want to reparent a node, you use removeChild()
+//   * first to remove it from its previous context. Failing to do so will
+//   * damage the tree.
+//   *
+//   * @param newChild Child to be added to child list
+//   *
+//   * @return Child just added to the child list
+//   * @throws DOMException
+//   */
+//  public Node appendChild(Node newChild) throws DOMException
+//  {
+//
+//    if (null == newChild)
+//    {
+//      error(XSLTErrorResources.ER_NULL_CHILD, null);  //"Trying to add a null child!");
+//    }
+//
+//    ElemTemplateElement elem = (ElemTemplateElement) newChild;
+//
+//    if (null == m_firstChild)
+//    {
+//      m_firstChild = elem;
+//    }
+//    else
+//    {
+//      ElemTemplateElement last = (ElemTemplateElement) getLastChild();
+//
+//      last.m_nextSibling = elem;
+//    }
+//
+//    elem.m_parentNode = this;
+//
+//    return newChild;
+//  }
 
   /**
    * Add a child to the child list.
@@ -307,34 +359,32 @@
    * @param newChild Child to be added to child list
    *
    * @return Child just added to the child list
-   * @throws DOMException
    */
-  public Node appendChild(Node newChild) throws DOMException
+  public ElemTemplateElement appendChild(ElemTemplateElement elem)
   {
 
-    if (null == newChild)
+    if (null == elem)
     {
       error(XSLTErrorResources.ER_NULL_CHILD, null);  //"Trying to add a null child!");
     }
 
-    ElemTemplateElement elem = (ElemTemplateElement) newChild;
-
     if (null == m_firstChild)
     {
       m_firstChild = elem;
     }
     else
     {
-      ElemTemplateElement last = (ElemTemplateElement) getLastChild();
+      ElemTemplateElement last = getLastChildElem();
 
       last.m_nextSibling = elem;
     }
 
     elem.m_parentNode = this;
 
-    return newChild;
+    return elem;
   }
 
+
   /**
    * Tell if there are child nodes.
    *
@@ -352,18 +402,19 @@
    */
   public short getNodeType()
   {
-    return Node.ELEMENT_NODE;
+    return org.w3c.dom.Node.ELEMENT_NODE;
   }
 
-  /**
-   * Return the nodelist (same reference).
-   *
-   * @return The nodelist containing the child nodes (this)
-   */
-  public NodeList getChildNodes()
-  {
-    return this;
-  }
+  // %DTBD%
+//  /**
+//   * Return the nodelist (same reference).
+//   *
+//   * @return The nodelist containing the child nodes (this)
+//   */
+//  public NodeList getChildNodes()
+//  {
+//    return this;
+//  }
 
   /**
    * Remove a child.
@@ -378,10 +429,8 @@
    *
    * @return the removed child, or null if the specified
    * node was not a child of this element.
-   *
-   * @throws DOMException
    */
-  public Node removeChild(ElemTemplateElement childETE) throws DOMException
+  public ElemTemplateElement removeChild(ElemTemplateElement childETE)
   {
 
     if (childETE == null || childETE.m_parentNode != this)
@@ -392,8 +441,7 @@
       m_firstChild = childETE.m_nextSibling;
     else
     {
-      ElemTemplateElement prev =
-        (ElemTemplateElement) (childETE.getPreviousSibling());
+      ElemTemplateElement prev = childETE.getPreviousSiblingElem();
 
       prev.m_nextSibling = childETE.m_nextSibling;
     }
@@ -405,6 +453,47 @@
     return childETE;
   }
 
+  // %DTBD%
+//  /**
+//   * Replace the old child with a new child.
+//   *
+//   * @param newChild New child to replace with
+//   * @param oldChild Old child to be replaced
+//   *
+//   * @return The new child
+//   *
+//   * @throws DOMException
+//   */
+//  public Node replaceChild(Node newChild, Node oldChild) throws DOMException
+//  {
+//
+//    if (oldChild == null || oldChild.getParentNode() != this)
+//      return null;
+//
+//    ElemTemplateElement newChildElem = ((ElemTemplateElement) newChild);
+//    ElemTemplateElement oldChildElem = ((ElemTemplateElement) oldChild);
+//
+//    // Fix up previous sibling.
+//    ElemTemplateElement prev =
+//      (ElemTemplateElement) oldChildElem.getPreviousSibling();
+//
+//    if (null != prev)
+//      prev.m_nextSibling = newChildElem;
+//
+//    // Fix up parent (this)
+//    if (m_firstChild == oldChildElem)
+//      m_firstChild = newChildElem;
+//
+//    newChildElem.m_parentNode = this;
+//    oldChildElem.m_parentNode = null;
+//    newChildElem.m_nextSibling = oldChildElem.m_nextSibling;
+//    oldChildElem.m_nextSibling = null;
+//
+//    // newChildElem.m_stylesheet = oldChildElem.m_stylesheet;
+//    // oldChildElem.m_stylesheet = null;
+//    return newChildElem;
+//  }
+
   /**
    * Replace the old child with a new child.
    *
@@ -415,18 +504,16 @@
    *
    * @throws DOMException
    */
-  public Node replaceChild(Node newChild, Node oldChild) throws DOMException
+  public ElemTemplateElement replaceChild(ElemTemplateElement newChildElem, 
+                                          ElemTemplateElement oldChildElem)
   {
 
-    if (oldChild == null || oldChild.getParentNode() != this)
+    if (oldChildElem == null || oldChildElem.getParentElem() != this)
       return null;
 
-    ElemTemplateElement newChildElem = ((ElemTemplateElement) newChild);
-    ElemTemplateElement oldChildElem = ((ElemTemplateElement) oldChild);
-
     // Fix up previous sibling.
     ElemTemplateElement prev =
-      (ElemTemplateElement) oldChildElem.getPreviousSibling();
+      oldChildElem.getPreviousSiblingElem();
 
     if (null != prev)
       prev.m_nextSibling = newChildElem;
@@ -467,38 +554,40 @@
     return count;
   }  // getLength():int
 
-  /**
-   * NodeList method: Return the Nth immediate child of this node, or
-   * null if the index is out of bounds.
-   *
-   * @param index Index of child to find
-   * @return org.w3c.dom.Node: the child node at given index
-   */
-  public Node item(int index)
-  {
+  // %TDB%
+//  /**
+//   * NodeList method: Return the Nth immediate child of this node, or
+//   * null if the index is out of bounds.
+//   *
+//   * @param index Index of child to find
+//   * @return org.w3c.dom.Node: the child node at given index
+//   */
+//  public Node item(int index)
+//  {
+//
+//    // It is assumed that the getChildNodes call synchronized
+//    // the children. Therefore, we can access the first child
+//    // reference directly.
+//    ElemTemplateElement node = m_firstChild;
+//
+//    for (int i = 0; i < index && node != null; i++)
+//    {
+//      node = node.m_nextSibling;
+//    }
+//
+//    return node;
+//  }  // item(int):Node
 
-    // It is assumed that the getChildNodes call synchronized
-    // the children. Therefore, we can access the first child
-    // reference directly.
-    ElemTemplateElement node = m_firstChild;
-
-    for (int i = 0; i < index && node != null; i++)
-    {
-      node = node.m_nextSibling;
-    }
-
-    return node;
-  }  // item(int):Node
-
-  /**
-   * Get the stylesheet owner.
-   *
-   * @return The stylesheet owner
-   */
-  public Document getOwnerDocument()
-  {
-    return getStylesheet();
-  }
+  // %DTBD%
+//  /**
+//   * Get the stylesheet owner.
+//   *
+//   * @return The stylesheet owner
+//   */
+//  public Document getOwnerDocument()
+//  {
+//    return getStylesheet();
+//  }
 
   /**
    * Return the element name.
@@ -734,6 +823,10 @@
    */
   public String getNamespaceForPrefix(String prefix)
   {
+//    if (null != prefix && prefix.equals("xmlns"))
+//    {
+//      return Constants.S_XMLNAMESPACEURI;
+//    }
 
     Vector nsDecls = m_declaredPrefixes;
 
@@ -885,7 +978,7 @@
       }
     }
 
-    ElemTemplateElement parent = (ElemTemplateElement) this.getParentNode();
+    ElemTemplateElement parent = this.getParentNodeElem();
 
     if (null != parent)
     {
@@ -1039,15 +1132,16 @@
    */
   protected ElemTemplateElement m_parentNode;
 
-  /**
-   * Get the parent as a Node.
-   *
-   * @return This node's parent node
-   */
-  public Node getParentNode()
-  {
-    return m_parentNode;
-  }
+  // %DTBD%
+//  /**
+//   * Get the parent as a Node.
+//   *
+//   * @return This node's parent node
+//   */
+//  public Node getParentNode()
+//  {
+//    return m_parentNode;
+//  }
 
   /**
    * Get the parent as an ElemTemplateElement.
@@ -1065,15 +1159,42 @@
    */
   ElemTemplateElement m_nextSibling;
 
-  /**
-   * Get the next sibling (as a Node) or return null.
-   *
-   * @return this node's next sibling or null
-   */
-  public Node getNextSibling()
-  {
-    return m_nextSibling;
-  }
+  // %DTBD%
+//  /**
+//   * Get the next sibling (as a Node) or return null.
+//   *
+//   * @return this node's next sibling or null
+//   */
+//  public Node getNextSibling()
+//  {
+//    return m_nextSibling;
+//  }
+
+  // %DTBD%
+//  /**
+//   * Get the previous sibling (as a Node) or return null.
+//   * Note that this may be expensive if the parent has many kids;
+//   * we accept that price in exchange for avoiding the prev pointer
+//   * TODO: If we were sure parents and sibs are always ElemTemplateElements,
+//   * we could hit the fields directly rather than thru accessors.
+//   *
+//   * @return This node's previous sibling or null
+//   */
+//  public Node getPreviousSibling()
+//  {
+//
+//    Node walker = getParentNode(), prev = null;
+//
+//    if (walker != null)
+//      for (walker = walker.getFirstChild(); walker != null;
+//              prev = walker, walker = walker.getNextSibling())
+//      {
+//        if (walker == this)
+//          return prev;
+//      }
+//
+//    return null;
+//  }
 
   /**
    * Get the previous sibling (as a Node) or return null.
@@ -1084,14 +1205,15 @@
    *
    * @return This node's previous sibling or null
    */
-  public Node getPreviousSibling()
+  public ElemTemplateElement getPreviousSiblingElem()
   {
 
-    Node walker = getParentNode(), prev = null;
+    ElemTemplateElement walker = getParentNodeElem();
+    ElemTemplateElement prev = null;
 
     if (walker != null)
-      for (walker = walker.getFirstChild(); walker != null;
-              prev = walker, walker = walker.getNextSibling())
+      for (walker = walker.getFirstChildElem(); walker != null;
+              prev = walker, walker = walker.getNextSiblingElem())
       {
         if (walker == this)
           return prev;
@@ -1100,6 +1222,7 @@
     return null;
   }
 
+
   /**
    * Get the next sibling (as a ElemTemplateElement) or return null.
    *
@@ -1109,6 +1232,17 @@
   {
     return m_nextSibling;
   }
+  
+  /**
+   * Get the parent element.
+   *
+   * @return This node's next parent (as a ElemTemplateElement) or null 
+   */
+  public ElemTemplateElement getParentNodeElem()
+  {
+    return m_parentNode;
+  }
+
 
   /**
    * First child.
@@ -1116,15 +1250,16 @@
    */
   ElemTemplateElement m_firstChild;
 
-  /**
-   * Get the first child as a Node.
-   *
-   * @return This node's first child or null
-   */
-  public Node getFirstChild()
-  {
-    return m_firstChild;
-  }
+  // %DTBD%
+//  /**
+//   * Get the first child as a Node.
+//   *
+//   * @return This node's first child or null
+//   */
+//  public Node getFirstChild()
+//  {
+//    return m_firstChild;
+//  }
 
   /**
    * Get the first child as a ElemTemplateElement.
@@ -1136,12 +1271,32 @@
     return m_firstChild;
   }
 
+  // %DTBD%
+//  /**
+//   * Get the last child.
+//   *
+//   * @return This node's last child
+//   */
+//  public Node getLastChild()
+//  {
+//
+//    ElemTemplateElement lastChild = null;
+//
+//    for (ElemTemplateElement node = m_firstChild; node != null;
+//            node = node.m_nextSibling)
+//    {
+//      lastChild = node;
+//    }
+//
+//    return lastChild;
+//  }
+
   /**
    * Get the last child.
    *
    * @return This node's last child
    */
-  public Node getLastChild()
+  public ElemTemplateElement getLastChildElem()
   {
 
     ElemTemplateElement lastChild = null;
@@ -1155,8 +1310,9 @@
     return lastChild;
   }
 
+
   /** DOM backpointer that this element originated from.          */
-  transient private Node m_DOMBackPointer;
+  transient private org.w3c.dom.Node m_DOMBackPointer;
 
   /**
    * If this stylesheet was created from a DOM, get the
@@ -1165,7 +1321,7 @@
    *
    * @return DOM backpointer that this element originated from or null.
    */
-  public Node getDOMBackPointer()
+  public org.w3c.dom.Node getDOMBackPointer()
   {
     return m_DOMBackPointer;
   }
@@ -1177,7 +1333,7 @@
    *
    * @param n DOM backpointer that this element originated from.
    */
-  public void setDOMBackPointer(Node n)
+  public void setDOMBackPointer(org.w3c.dom.Node n)
   {
     m_DOMBackPointer = n;
   }
diff --git a/src/org/apache/xalan/templates/ElemText.java b/src/org/apache/xalan/templates/ElemText.java
index d789fad..30d435b 100644
--- a/src/org/apache/xalan/templates/ElemText.java
+++ b/src/org/apache/xalan/templates/ElemText.java
@@ -56,7 +56,8 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
+import org.apache.xml.dtm.DTM;
 
 import org.xml.sax.*;
 
@@ -170,7 +171,7 @@
    *
    * @throws DOMException
    */
-  public Node appendChild(Node newChild) throws DOMException
+  public ElemTemplateElement appendChild(ElemTemplateElement newChild)
   {
 
     int type = ((ElemTemplateElement) newChild).getXSLToken();
diff --git a/src/org/apache/xalan/templates/ElemTextLiteral.java b/src/org/apache/xalan/templates/ElemTextLiteral.java
index fb0246c..97ab9d9 100644
--- a/src/org/apache/xalan/templates/ElemTextLiteral.java
+++ b/src/org/apache/xalan/templates/ElemTextLiteral.java
@@ -56,8 +56,8 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
-
+//import org.w3c.dom.*;
+ 
 import org.xml.sax.*;
 
 import org.apache.xml.utils.QName;
@@ -216,13 +216,13 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
     try
     {
       if (TransformerImpl.S_DEBUG)
-        transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+        transformer.getTraceManager().fireTraceEvent(this);
 
       ResultTreeHandler rth = transformer.getResultTreeHandler();
       if (m_disableOutputEscaping)
diff --git a/src/org/apache/xalan/templates/ElemUnknown.java b/src/org/apache/xalan/templates/ElemUnknown.java
index a217e8b..1225c61 100644
--- a/src/org/apache/xalan/templates/ElemUnknown.java
+++ b/src/org/apache/xalan/templates/ElemUnknown.java
@@ -96,6 +96,6 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException{}
 }
diff --git a/src/org/apache/xalan/templates/ElemUse.java b/src/org/apache/xalan/templates/ElemUse.java
index 0cfbd2e..f869cde 100644
--- a/src/org/apache/xalan/templates/ElemUse.java
+++ b/src/org/apache/xalan/templates/ElemUse.java
@@ -58,7 +58,7 @@
 
 import java.util.Vector;
 
-import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 import javax.xml.transform.TransformerException;
 
@@ -160,7 +160,7 @@
    * @throws TransformerException
    */
   private void applyAttrSets(
-          TransformerImpl transformer, StylesheetRoot stylesheet, QName attributeSetsNames[], Node sourceNode, QName mode)
+          TransformerImpl transformer, StylesheetRoot stylesheet, QName attributeSetsNames[])
             throws TransformerException
   {
 
@@ -182,7 +182,7 @@
             ElemAttributeSet attrSet =
               (ElemAttributeSet) attrSets.elementAt(k);
 
-            attrSet.execute(transformer, sourceNode, mode);
+            attrSet.execute(transformer);
           }
         }
       }
@@ -207,17 +207,16 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
-
     if (TransformerImpl.S_DEBUG)
-      transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+      transformer.getTraceManager().fireTraceEvent(this);
 
     if (null != m_attributeSetsNames)
     {
       applyAttrSets(transformer, getStylesheetRoot(),
-                    m_attributeSetsNames, sourceNode, mode);
+                    m_attributeSetsNames);
     }
   }
 }
diff --git a/src/org/apache/xalan/templates/ElemValueOf.java b/src/org/apache/xalan/templates/ElemValueOf.java
index 08d38a9..df5753a 100644
--- a/src/org/apache/xalan/templates/ElemValueOf.java
+++ b/src/org/apache/xalan/templates/ElemValueOf.java
@@ -56,7 +56,9 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import org.xml.sax.*;
 
@@ -65,13 +67,14 @@
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.objects.XNodeSet;
 import org.apache.xalan.trace.SelectionEvent;
-import org.apache.xml.utils.QName;
 import org.apache.xalan.res.XSLTErrorResources;
 import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xalan.transformer.ResultTreeHandler;
 
+import org.apache.xml.utils.QName;
+import org.apache.xml.utils.XMLString;
+
 import javax.xml.transform.TransformerException;
-import org.apache.xalan.stree.SaxEventDispatch;
 
 /**
  * <meta name="usage" content="advanced"/>
@@ -227,16 +230,18 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
     try
     {
       if (TransformerImpl.S_DEBUG)
-        transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+        transformer.getTraceManager().fireTraceEvent(this);
 
-      Node child;
+      XPathContext xctxt = transformer.getXPathContext();
+      int sourceNode = xctxt.getCurrentNode();
+      int child;
       XObject value;
       
       // Optimize for "."
@@ -251,42 +256,37 @@
                                                  sourceNode, this);
         if(value.getType() == XObject.CLASS_NODESET)
         {
-          org.w3c.dom.traversal.NodeIterator iterator = value.nodeset();
+          DTMIterator iterator = value.nodeset();
           child = iterator.nextNode();
-          if(null == child)
+          if(DTM.NULL == child)
             return;
         }
         else
-          child = null;
+          child = DTM.NULL;
         if (TransformerImpl.S_DEBUG)
           transformer.getTraceManager().fireSelectedEvent(sourceNode, this,
                                                           "select", m_selectExpression, value);
       }
          
-      String s;                                                                                             
-      if(null != child)
+      XMLString s;                                                                                             
+      if(DTM.NULL != child)
       {
-        if (child.isSupported(SaxEventDispatch.SUPPORTSINTERFACE, "1.0"))
+        DTM dtm = xctxt.getDTM(child);
+        ResultTreeHandler rth = transformer.getResultTreeHandler();
+        if (m_disableOutputEscaping)
         {
-          if (m_disableOutputEscaping)
-          {
-            ResultTreeHandler rth = transformer.getResultTreeHandler();
-            rth.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
-            ((SaxEventDispatch) child).dispatchCharactersEvent(rth);
-            rth.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
-          }
-          else
-            ((SaxEventDispatch) child).dispatchCharactersEvent(transformer.getResultTreeHandler());
-          return;
+          rth.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
+          dtm.dispatchCharactersEvents(child, rth);
+          rth.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
         }
         else
-        {
-          s = XNodeSet.getStringFromNode(child);
-        }
+          dtm.dispatchCharactersEvents(child, rth);
+        return;
       }
       else
-        s = value.str();
-
+      {
+        s = value.xstr();
+      }
       
       int len = (null != s) ? s.length() : 0;
       if(len > 0)
@@ -296,11 +296,11 @@
         if (m_disableOutputEscaping)
         {
           rth.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
-          rth.characters(s.toCharArray(), 0, len);
+          s.dispatchCharactersEvents(rth);
           rth.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
         }
         else
-          rth.characters(s.toCharArray(), 0, len);
+          s.dispatchCharactersEvents(rth);
       }
     }
     catch(SAXException se)
@@ -318,7 +318,7 @@
    *
    * @throws DOMException
    */
-  public Node appendChild(Node newChild) throws DOMException
+  public ElemTemplateElement appendChild(ElemTemplateElement newChild)
   {
 
     error(XSLTErrorResources.ER_CANNOT_ADD,
diff --git a/src/org/apache/xalan/templates/ElemVariable.java b/src/org/apache/xalan/templates/ElemVariable.java
index 85eb501..53c218c 100644
--- a/src/org/apache/xalan/templates/ElemVariable.java
+++ b/src/org/apache/xalan/templates/ElemVariable.java
@@ -56,7 +56,8 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
+import org.apache.xml.dtm.DTM;
 
 import org.xml.sax.*;
 
@@ -245,13 +246,14 @@
    * @throws TransformerException
    */
   public void execute(
-          TransformerImpl transformer, Node sourceNode, QName mode)
+          TransformerImpl transformer)
             throws TransformerException
   {
 
     if (TransformerImpl.S_DEBUG)
-      transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
+      transformer.getTraceManager().fireTraceEvent(this);
 
+    int sourceNode = transformer.getXPathContext().getCurrentNode();
     XObject var = getValue(transformer, sourceNode);
 
     transformer.getXPathContext().getVarStack().pushVariable(m_qname, var);
@@ -267,33 +269,38 @@
    *
    * @throws TransformerException
    */
-  public XObject getValue(TransformerImpl transformer, Node sourceNode)
+  public XObject getValue(TransformerImpl transformer, int sourceNode)
           throws TransformerException
   {
 
     XObject var;
+    XPathContext xctxt = transformer.getXPathContext();
+    xctxt.pushCurrentNode(sourceNode);
 
-    if (null != m_selectPattern)
+    try
     {
-      XPathContext xctxt = transformer.getXPathContext();
-
-      var = m_selectPattern.execute(xctxt, sourceNode, this);
-      if(TransformerImpl.S_DEBUG)
-        transformer.getTraceManager().fireSelectedEvent(sourceNode, this, 
-                                      "select", m_selectPattern, var);
+      if (null != m_selectPattern)
+      { 
+        var = m_selectPattern.execute(xctxt, sourceNode, this);
+        if(TransformerImpl.S_DEBUG)
+          transformer.getTraceManager().fireSelectedEvent(sourceNode, this, 
+                                        "select", m_selectPattern, var);
+      }
+      else if (null == getFirstChildElem())
+      {
+        var = XString.EMPTYSTRING;
+      }
+      else
+      {
+  
+        // Use result tree fragment
+        int df = transformer.transformToRTF(this);
+        var = new XRTreeFrag(df, xctxt);
+      }
     }
-    else if (null == getFirstChild())
+    finally
     {
-      var = XString.EMPTYSTRING;
-    }
-    else
-    {
-
-      // Use result tree fragment
-      DocumentFragment df = transformer.transformToRTF(this, sourceNode,
-                              null);
-
-      var = new XRTreeFrag(df);
+      xctxt.popCurrentNode();
     }
 
     return var;
diff --git a/src/org/apache/xalan/templates/FuncDocument.java b/src/org/apache/xalan/templates/FuncDocument.java
index ab97065..49b396e 100644
--- a/src/org/apache/xalan/templates/FuncDocument.java
+++ b/src/org/apache/xalan/templates/FuncDocument.java
@@ -62,9 +62,9 @@
 import java.io.PrintWriter;
 import java.io.IOException;
 
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMManager;
 
 import org.apache.xpath.NodeSet;
 import org.apache.xpath.functions.Function;
@@ -74,7 +74,6 @@
 import org.apache.xpath.objects.XNodeSet;
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
-import org.apache.xpath.DOMHelper;
 import org.apache.xpath.SourceTreeManager;
 import org.apache.xpath.Expression;
 import org.apache.xpath.XPathContext;
@@ -89,9 +88,11 @@
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.SourceLocator;
 import javax.xml.transform.ErrorListener;
-import org.apache.xml.utils.SAXSourceLocator;
 import javax.xml.transform.Source;
 
+import org.apache.xml.utils.SAXSourceLocator;
+import org.apache.xml.utils.XMLString;
+
 /**
  * <meta name="usage" content="advanced"/>
  * Execute the Doc() function.
@@ -121,9 +122,10 @@
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
 
-    Node context = xctxt.getCurrentNode();
-    Document docContext = (Node.DOCUMENT_NODE == context.getNodeType())
-                          ? (Document) context : context.getOwnerDocument();
+    int context = xctxt.getCurrentNode();
+    DTM dtm = xctxt.getDTM(context);
+    
+    int docContext = dtm.getDocument();
     XObject arg = (XObject) this.getArg0().execute(xctxt);
     String base = "";
     Expression arg1Expr = this.getArg1();
@@ -139,25 +141,26 @@
 
       if (XObject.CLASS_NODESET == arg2.getType())
       {
-        Node baseNode = arg2.nodeset().nextNode();
+        int baseNode = arg2.nodeset().nextNode();
 
-        if (baseNode == null)
+        if (baseNode == DTM.NULL)
           warn(xctxt, XSLTErrorResources.WG_EMPTY_SECOND_ARG, null);
+        
+        DTM baseDTM = xctxt.getDTM(baseNode);
+        base = baseDTM.getDocumentBaseURI();
 
-        Document baseDoc = (baseNode == null
-                            ? null
-                            : (Node.DOCUMENT_NODE == baseNode.getNodeType())
-                              ? (Document) baseNode
-                              : baseNode.getOwnerDocument());
-
-        if (baseDoc == null || baseDoc instanceof Stylesheet)
-        {
-
-          // base = ((Stylesheet)baseDoc).getBaseIdentifier();
-          base = xctxt.getNamespaceContext().getBaseIdentifier();
-        }
-        else
-          base = xctxt.getSourceTreeManager().findURIFromDoc(baseDoc);
+        // %REVIEW% This doesn't seem to be a problem with the conformance
+        // suite, but maybe it's just not doing a good test?
+//        int baseDoc = baseDTM.getDocument();
+//
+//        if (baseDoc == DTM.NULL /* || baseDoc instanceof Stylesheet  -->What to do?? */)
+//        {
+//
+//          // base = ((Stylesheet)baseDoc).getBaseIdentifier();
+//          base = xctxt.getNamespaceContext().getBaseIdentifier();
+//        }
+//        else
+//          base = xctxt.getSourceTreeManager().findURIFromDoc(baseDoc);
       }
       else
       {
@@ -179,21 +182,21 @@
       base = xctxt.getNamespaceContext().getBaseIdentifier();
     }
 
-    XNodeSet nodes = new XNodeSet();
+    XNodeSet nodes = new XNodeSet(xctxt.getDTMManager());
     NodeSet mnl = nodes.mutableNodeset();
-    NodeIterator iterator = (XObject.CLASS_NODESET == arg.getType())
+    DTMIterator iterator = (XObject.CLASS_NODESET == arg.getType())
                             ? arg.nodeset() : null;
-    Node pos = null;
+    int pos = DTM.NULL;
 
-    while ((null == iterator) || (null != (pos = iterator.nextNode())))
+    while ((null == iterator) || (DTM.NULL != (pos = iterator.nextNode())))
     {
-      String ref = (null != iterator)
-                   ? DOMHelper.getNodeData(pos) : arg.str();
+      XMLString ref = (null != iterator)
+                   ? xctxt.getDTM(pos).getStringValue(pos) : arg.xstr();
 
       if (null == ref)
         continue;
 
-      if (null == docContext)
+      if (DTM.NULL == docContext)
       {
         error(xctxt, XSLTErrorResources.ER_NO_CONTEXT_OWNERDOC, null);  //"context does not have an owner document!");
       }
@@ -215,18 +218,19 @@
         base = null;
       }
 
-      Node newDoc = getDoc(xctxt, context, ref, base);
+      int newDoc = getDoc(xctxt, context, ref.toString(), base);
 
       // nodes.mutableNodeset().addNode(newDoc);  
-      if (null != newDoc)
+      if (DTM.NULL != newDoc)
       {
-
         // TODO: mnl.addNodeInDocOrder(newDoc, true, xctxt); ??
         if (!mnl.contains(newDoc))
+        {
           mnl.addElement(newDoc);
+        }
       }
 
-      if (null == iterator || newDoc == null)
+      if (null == iterator || newDoc == DTM.NULL)
         break;
     }
 
@@ -246,14 +250,14 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  Node getDoc(XPathContext xctxt, Node context, String uri, String base)
+  int getDoc(XPathContext xctxt, int context, String uri, String base)
           throws javax.xml.transform.TransformerException
   {
 
     // System.out.println("base: "+base+", uri: "+uri);
     SourceTreeManager treeMgr = xctxt.getSourceTreeManager();
     
-    Node newDoc;
+    int newDoc;
     try
     {
       Source source = treeMgr.resolveURI(base, uri, xctxt.getSAXLocator());
@@ -269,7 +273,7 @@
       throw new TransformerException(te);
     }
 
-    if (null != newDoc)
+    if (DTM.NULL != newDoc)
       return newDoc;
 
     // If the uri length is zero, get the uri of the stylesheet.
@@ -282,7 +286,7 @@
     {
       if ((null != uri) && (uri.toString().length() > 0))
       {
-        newDoc = treeMgr.getSourceTree(base, uri, xctxt.getSAXLocator());
+        newDoc = treeMgr.getSourceTree(base, uri, xctxt.getSAXLocator(), xctxt);
 
         // System.out.println("newDoc: "+((Document)newDoc).getDocumentElement().getNodeName());
       }
@@ -294,7 +298,7 @@
     {
 
       // throwable.printStackTrace();
-      newDoc = null;
+      newDoc = DTM.NULL;
 
       // path.warn(XSLTErrorResources.WG_ENCODING_NOT_SUPPORTED_USING_JAVA, new Object[]{((base == null) ? "" : base )+uri}); //"Can not load requested doc: "+((base == null) ? "" : base )+uri);
       while (throwable
@@ -359,7 +363,7 @@
       diagnosticsString = throwable.getMessage(); //sw.toString();
     }
 
-    if (null == newDoc)
+    if (DTM.NULL == newDoc)
     {
 
       // System.out.println("what?: "+base+", uri: "+uri);
@@ -376,7 +380,7 @@
     }
     else
     {
-
+      // %REVIEW%
       // TBD: What to do about XLocator?
       // xctxt.getSourceTreeManager().associateXLocatorToNode(newDoc, url, null);
     }
diff --git a/src/org/apache/xalan/templates/FuncKey.java b/src/org/apache/xalan/templates/FuncKey.java
index 4556fbc..eb04b33 100644
--- a/src/org/apache/xalan/templates/FuncKey.java
+++ b/src/org/apache/xalan/templates/FuncKey.java
@@ -64,7 +64,6 @@
 import org.apache.xpath.XPath;
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.objects.XNodeSet;
-import org.apache.xpath.DOMHelper;
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.axes.LocPathIterator;
 import org.apache.xpath.axes.UnionPathIterator;
@@ -74,10 +73,10 @@
 import org.apache.xpath.res.XPATHErrorResources;
 import org.apache.xpath.XPathContext;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+
+import org.apache.xml.utils.XMLString;
 
 /**
  * <meta name="usage" content="advanced"/>
@@ -103,11 +102,11 @@
     // TransformerImpl transformer = (TransformerImpl)xctxt;
     TransformerImpl transformer = (TransformerImpl) xctxt.getOwnerObject();
     XNodeSet nodes = null;
-    Node context = xctxt.getCurrentNode();
-    Document docContext = (Node.DOCUMENT_NODE == context.getNodeType())
-                          ? (Document) context : context.getOwnerDocument();
+    int context = xctxt.getCurrentNode();
+    DTM dtm = xctxt.getDTM(context);
+    int docContext = dtm.getDocument();
 
-    if (null == docContext)
+    if (DTM.NULL == docContext)
     {
 
       // path.error(context, XPATHErrorResources.ER_CONTEXT_HAS_NO_OWNERDOC); //"context does not have an owner document!");
@@ -122,13 +121,14 @@
     if (argIsNodeSet)
     {
       Hashtable usedrefs = null;
-      NodeIterator ni = arg.nodeset();
-      Node pos;
+      DTMIterator ni = arg.nodeset();
+      int pos;
       UnionPathIterator upi = new UnionPathIterator();
 
-      while (null != (pos = ni.nextNode()))
+      while (DTM.NULL != (pos = ni.nextNode()))
       {
-        String ref = DOMHelper.getNodeData(pos);
+        dtm = xctxt.getDTM(pos);
+        XMLString ref = dtm.getStringValue(pos);
 
         if (null == ref)
           continue;
@@ -168,7 +168,7 @@
     }
     else
     {
-      String ref = arg.str();
+      XMLString ref = arg.xstr();
       LocPathIterator nl = kmgr.getNodeSetByKey(xctxt, docContext, keyname,
                                                 ref,
                                                 xctxt.getNamespaceContext());
diff --git a/src/org/apache/xalan/templates/Stylesheet.java b/src/org/apache/xalan/templates/Stylesheet.java
index ca01027..8665a78 100644
--- a/src/org/apache/xalan/templates/Stylesheet.java
+++ b/src/org/apache/xalan/templates/Stylesheet.java
@@ -74,8 +74,9 @@
 import org.apache.xpath.XPath;
 
 // DOM Imports
-import org.w3c.dom.Node;
-import org.w3c.dom.Document;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.Document;
+import org.apache.xml.dtm.DTM;
 
 // SAX2 Imports
 import javax.xml.transform.TransformerException;
@@ -127,7 +128,7 @@
  * @see <a href="http://www.w3.org/TR/xslt#section-Stylesheet-Structure">section-Stylesheet-Structure in XSLT Specification</a>
  */
 public class Stylesheet extends ElemTemplateElement
-        implements java.io.Serializable, Document
+        implements java.io.Serializable /* , Document */
 {
 
   /**
@@ -1351,7 +1352,7 @@
    */
   public short getNodeType()
   {
-    return Node.DOCUMENT_NODE;
+    return DTM.DOCUMENT_NODE;
   }
 
   /**
@@ -1394,7 +1395,7 @@
     if (null == m_templates)
       throw new ArrayIndexOutOfBoundsException();
 
-    replaceChild(v, (Node) m_templates.elementAt(i));
+    replaceChild(v, (ElemTemplateElement)m_templates.elementAt(i));
     m_templates.setElementAt(v, i);
     v.setStylesheet(this);
   }
diff --git a/src/org/apache/xalan/templates/StylesheetRoot.java b/src/org/apache/xalan/templates/StylesheetRoot.java
index f683976..56c8827 100644
--- a/src/org/apache/xalan/templates/StylesheetRoot.java
+++ b/src/org/apache/xalan/templates/StylesheetRoot.java
@@ -56,7 +56,8 @@
  */
 package org.apache.xalan.templates;
 
-import org.w3c.dom.*;
+// import org.w3c.dom.*;
+import org.apache.xml.dtm.DTM;
 
 import java.util.*;
 
@@ -698,7 +699,7 @@
    * @throws TransformerException
    */
   public ElemTemplate getTemplateComposed(XPathContext xctxt,
-                                          Node targetNode,
+                                          int targetNode,
                                           QName mode,
                                           int maxImportLevel,
                                           boolean quietConflictWarnings)
@@ -820,7 +821,7 @@
    * @throws TransformerException
    */
   public WhiteSpaceInfo getWhiteSpaceInfo(
-          XPathContext support, Element targetElement) throws TransformerException
+          XPathContext support, int targetElement) throws TransformerException
   {
 
     if (null != m_whiteSpaceInfoList)
@@ -842,22 +843,23 @@
    * @throws TransformerException
    */
   public boolean shouldStripWhiteSpace(
-          XPathContext support, Element targetElement) throws TransformerException
+          XPathContext support, int targetElement) throws TransformerException
   {
     if (null != m_whiteSpaceInfoList)
     {
-      while(null != targetElement)
+      while(DTM.NULL != targetElement)
       {
         WhiteSpaceInfo info = (WhiteSpaceInfo) m_whiteSpaceInfoList.getTemplate(support,
                 targetElement, null, -1, false);
         if(null != info)
           return info.getShouldStripSpace();
-          
-        Node parent = targetElement.getParentNode();
-        if(null != parent && Node.ELEMENT_NODE == parent.getNodeType())
-          targetElement = (Element)parent;
+        
+        DTM dtm = support.getDTM(targetElement);
+        int parent = dtm.getParent(targetElement);
+        if(DTM.NULL != parent && DTM.ELEMENT_NODE == dtm.getNodeType(parent))
+          targetElement = parent;
         else
-          targetElement = null;
+          targetElement = DTM.NULL;
       }
     }
     return false;
diff --git a/src/org/apache/xalan/templates/TemplateList.java b/src/org/apache/xalan/templates/TemplateList.java
index f6a4c9f..0869bec 100644
--- a/src/org/apache/xalan/templates/TemplateList.java
+++ b/src/org/apache/xalan/templates/TemplateList.java
@@ -62,7 +62,8 @@
 
 import java.io.Serializable;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 import javax.xml.transform.TransformerException;
 
@@ -457,43 +458,44 @@
    * @return The head of a linked list that contains all possible match pattern to 
    * template associations.
    */
-  public TemplateSubPatternAssociation getHead(XPathContext xctxt, Node targetNode)
+  public TemplateSubPatternAssociation getHead(XPathContext xctxt, int targetNode)
   {
 
-    short targetNodeType = targetNode.getNodeType();
+    DTM dtm = xctxt.getDTM(targetNode);
+    short targetNodeType = dtm.getNodeType(targetNode);
     TemplateSubPatternAssociation head;
 
     switch (targetNodeType)
     {
-    case Node.ELEMENT_NODE :
-    case Node.ATTRIBUTE_NODE :
+    case DTM.ELEMENT_NODE :
+    case DTM.ATTRIBUTE_NODE :
       head = (TemplateSubPatternAssociation) m_patternTable.get(
-        xctxt.getDOMHelper().getLocalNameOfNode(targetNode));
+        dtm.getLocalName(targetNode));
       break;
-    case Node.TEXT_NODE :
-    case Node.CDATA_SECTION_NODE :
+    case DTM.TEXT_NODE :
+    case DTM.CDATA_SECTION_NODE :
       head = m_textPatterns;
       break;
-    case Node.ENTITY_REFERENCE_NODE :
-    case Node.ENTITY_NODE :
+    case DTM.ENTITY_REFERENCE_NODE :
+    case DTM.ENTITY_NODE :
       head = (TemplateSubPatternAssociation) m_patternTable.get(
-        targetNode.getNodeName());
+        dtm.getNodeName(targetNode)); // %REVIEW% I think this is right
       break;
-    case Node.PROCESSING_INSTRUCTION_NODE :
+    case DTM.PROCESSING_INSTRUCTION_NODE :
       head = (TemplateSubPatternAssociation) m_patternTable.get(
-        xctxt.getDOMHelper().getLocalNameOfNode(targetNode));
+        dtm.getLocalName(targetNode));
       break;
-    case Node.COMMENT_NODE :
+    case DTM.COMMENT_NODE :
       head = m_commentPatterns;
       break;
-    case Node.DOCUMENT_NODE :
-    case Node.DOCUMENT_FRAGMENT_NODE :
+    case DTM.DOCUMENT_NODE :
+    case DTM.DOCUMENT_FRAGMENT_NODE :
       head = m_docPatterns;
       break;
-    case Node.NOTATION_NODE :
+    case DTM.NOTATION_NODE :
     default :
       head = (TemplateSubPatternAssociation) m_patternTable.get(
-        targetNode.getNodeName());
+        dtm.getNodeName(targetNode)); // %REVIEW% I think this is right
     }
 
     return (null == head) ? m_wildCardPatterns : head;
@@ -518,7 +520,7 @@
    * @throws TransformerException
    */
   public ElemTemplate getTemplate(XPathContext xctxt,
-                                Node targetNode,
+                                int targetNode,
                                 QName mode,
                                 int maxImportLevel,
                                 boolean quietConflictWarnings)
@@ -585,7 +587,7 @@
    * @param mode reference, which may be null, to the <a href="http://www.w3.org/TR/xslt#modes">current mode</a>.
    */
   private void checkConflicts(TemplateSubPatternAssociation head,
-                              XPathContext xctxt, Node targetNode, QName mode)
+                              XPathContext xctxt, int targetNode, QName mode)
   {
 
     // TODO: Check for conflicts.
diff --git a/src/org/apache/xalan/templates/TemplateSubPatternAssociation.java b/src/org/apache/xalan/templates/TemplateSubPatternAssociation.java
index aeee5a6..22837f1 100644
--- a/src/org/apache/xalan/templates/TemplateSubPatternAssociation.java
+++ b/src/org/apache/xalan/templates/TemplateSubPatternAssociation.java
@@ -58,7 +58,7 @@
 
 import java.io.Serializable;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import javax.xml.transform.TransformerException;
 
@@ -185,7 +185,7 @@
    *
    * @throws TransformerException
    */
-  public boolean matches(XPathContext xctxt, Node targetNode, QName mode)
+  public boolean matches(XPathContext xctxt, int targetNode, QName mode)
           throws TransformerException
   {
 
diff --git a/src/org/apache/xalan/templates/XUnresolvedVariable.java b/src/org/apache/xalan/templates/XUnresolvedVariable.java
index f3cd6bd..bb2b3cc 100644
--- a/src/org/apache/xalan/templates/XUnresolvedVariable.java
+++ b/src/org/apache/xalan/templates/XUnresolvedVariable.java
@@ -66,8 +66,9 @@
 import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xalan.res.XSLMessages;
 import org.apache.xalan.res.XSLTErrorResources;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Node;
+//import org.w3c.dom.DocumentFragment;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 /**
  * An instance of this class holds unto a variable until 
@@ -77,7 +78,7 @@
 public class XUnresolvedVariable extends XObject
 {  
   /** The node context for execution. */
-  transient private Node m_context;
+  transient private int m_context;
   
   /** The transformer context for execution. */
   transient private TransformerImpl m_transformer;
@@ -116,7 +117,7 @@
    * ends, i.e. at the point we should terminate the search.
    * @param isGlobal true if this is a global variable.
    */
-  public XUnresolvedVariable(ElemVariable obj, Node sourceNode, 
+  public XUnresolvedVariable(ElemVariable obj, int sourceNode, 
                              TransformerImpl transformer,
                              int varStackPos, int varStackContext,
                              boolean isGlobal)
diff --git a/src/org/apache/xalan/trace/PrintTraceListener.java b/src/org/apache/xalan/trace/PrintTraceListener.java
index b1bd98a..0bd2d73 100644
--- a/src/org/apache/xalan/trace/PrintTraceListener.java
+++ b/src/org/apache/xalan/trace/PrintTraceListener.java
@@ -186,7 +186,7 @@
         // You may not have line numbers if the selection is occuring from a
         // default template.
         ElemTemplateElement parent =
-          (ElemTemplateElement) ete.getParentNode();
+          (ElemTemplateElement) ete.getParentElem();
 
         if (parent == ete.getStylesheetRoot().getDefaultRootRule())
         {
@@ -215,36 +215,36 @@
       if (ev.m_selection.getType() == ev.m_selection.CLASS_NODESET)
       {
         m_pw.println();
-
-        NodeIterator nl = ev.m_selection.nodeset();
-        if(nl instanceof ContextNodeList)
-        {
-          try
-          {
-            nl = ((ContextNodeList)nl).cloneWithReset();
-          }
-          catch(CloneNotSupportedException cnse)
-          {
-            m_pw.println("     [Can't trace nodelist because it it threw a CloneNotSupportedException]");
-            return;
-          }
-          Node pos = nl.nextNode();
-
-          if (null == pos)
-          {
-            m_pw.println("     [empty node list]");
-          }
-          else
-          {
-            while (null != pos)
-            {
-              m_pw.println("     " + pos);
-
-              pos = nl.nextNode();
-            }
-          }
-        }
-        else
+        // %DTBD%
+//        NodeIterator nl = ev.m_selection.nodeset();
+//        if(nl instanceof ContextNodeList)
+//        {
+//          try
+//          {
+//            nl = ((ContextNodeList)nl).cloneWithReset();
+//          }
+//          catch(CloneNotSupportedException cnse)S
+//          {
+//            m_pw.println("     [Can't trace nodelist because it it threw a CloneNotSupportedException]");
+//            return;
+//          }
+//          Node pos = nl.nextNode();
+//
+//          if (null == pos)
+//          {
+//            m_pw.println("     [empty node list]");
+//          }
+//          else
+//          {
+//            while (null != pos)
+//            {
+//              m_pw.println("     " + pos);
+//
+//              pos = nl.nextNode();
+//            }
+//          }
+//        }
+//        else
         {
             m_pw.println("     [Can't trace nodelist because it isn't a ContextNodeList]");
         }
diff --git a/src/org/apache/xalan/trace/TraceManager.java b/src/org/apache/xalan/trace/TraceManager.java
index 1dab49d..ad7568b 100644
--- a/src/org/apache/xalan/trace/TraceManager.java
+++ b/src/org/apache/xalan/trace/TraceManager.java
@@ -162,15 +162,15 @@
    * @param mode Template mode
    * @param styleNode Stylesheet template node
    */
-  public void fireTraceEvent(Node sourceNode, QName mode,
-                             ElemTemplateElement styleNode)
+  public void fireTraceEvent(ElemTemplateElement styleNode)
   {
 
-    if (hasTraceListeners())
-    {
-      fireTraceEvent(new TracerEvent(m_transformer, sourceNode, mode,
-                                     styleNode));
-    }
+  // %DTBD%
+//    if (hasTraceListeners())
+//    {
+//      fireTraceEvent(new TracerEvent(m_transformer, sourceNode, mode,
+//                                     styleNode));
+//    }
   }
 
   /**
@@ -206,14 +206,15 @@
    * @throws javax.xml.transform.TransformerException
    */
   public void fireSelectedEvent(
-          Node sourceNode, ElemTemplateElement styleNode, String attributeName, XPath xpath, XObject selection)
+          int sourceNode, ElemTemplateElement styleNode, String attributeName, XPath xpath, XObject selection)
             throws javax.xml.transform.TransformerException
   {
 
-    if (hasTraceListeners())
-      fireSelectedEvent(new SelectionEvent(m_transformer, sourceNode,
-                                           styleNode, attributeName, xpath,
-                                           selection));
+  // %DTBD%
+//    if (hasTraceListeners())
+//      fireSelectedEvent(new SelectionEvent(m_transformer, sourceNode,
+//                                           styleNode, attributeName, xpath,
+//                                           selection));
   }
 
   /**
diff --git a/src/org/apache/xalan/transformer/ClonerToResultTree.java b/src/org/apache/xalan/transformer/ClonerToResultTree.java
index 321e0d2..1a90023 100644
--- a/src/org/apache/xalan/transformer/ClonerToResultTree.java
+++ b/src/org/apache/xalan/transformer/ClonerToResultTree.java
@@ -58,13 +58,10 @@
 
 import org.apache.xalan.templates.Stylesheet;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Comment;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.EntityReference;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMFilter;
+import org.apache.xml.utils.XMLString;
 
 import javax.xml.transform.TransformerException;
 import org.xml.sax.Attributes;
@@ -112,94 +109,27 @@
    * 
    * @throws TransformerException
    */
-  public void cloneToResultTree(Node node, boolean shouldCloneAttributes)
+  public void cloneToResultTree(int node, boolean shouldCloneAttributes)
     throws TransformerException
   {
 
     try
     {
-      boolean stripWhiteSpace = false;
       XPathContext xctxt = m_transformer.getXPathContext();
-      DOMHelper dhelper = xctxt.getDOMHelper();
+      DTM dtm = xctxt.getDTM(node);
 
-      switch (node.getNodeType())
+      switch (dtm.getNodeType(node))
       {
-      case Node.TEXT_NODE :
-        {
-          Text tx = (Text) node;
-          String data = null;
-
-          // System.out.println("stripWhiteSpace = "+stripWhiteSpace+", "+tx.getData());
-          if (stripWhiteSpace)
-          {
-            if (!dhelper.isIgnorableWhitespace(tx))
-            {
-              data = tx.getData();
-
-              if ((null != data) && (0 == data.trim().length()))
-              {
-                data = null;
-              }
-            }
-          }
-          else
-          {
-            Node parent = node.getParentNode();
-
-            if (null != parent)
-            {
-              if (Node.DOCUMENT_NODE != parent.getNodeType())
-              {
-                data = tx.getData();
-
-                if ((null != data) && (0 == data.length()))
-                {
-                  data = null;
-                }
-              }
-            }
-            else
-            {
-              data = tx.getData();
-
-              if ((null != data) && (0 == data.length()))
-              {
-                data = null;
-              }
-            }
-          }
-
-          if (null != data)
-          {
-
-            // TODO: Hack around the issue of comments next to literals.
-            // This would be, when a comment is present, the whitespace
-            // after the comment must be added to the literal.  The
-            // parser should do this, but XML4J doesn't seem to.
-            // <foo>some lit text
-            //     <!-- comment -->
-            //     </foo>
-            // Loop through next siblings while they are comments, then,
-            // if the node after that is a ignorable text node, append
-            // it to the text node just added.
-            if (dhelper.isIgnorableWhitespace(tx))
-            {
-              m_rth.ignorableWhitespace(data.toCharArray(), 0, data.length());
-            }
-            else
-            {
-              m_rth.characters(data.toCharArray(), 0, data.length());
-            }
-          }
-        }
+      case DTM.TEXT_NODE :
+        dtm.dispatchCharactersEvents(node, m_rth);
         break;
-      case Node.DOCUMENT_FRAGMENT_NODE :
-      case Node.DOCUMENT_NODE :
+      case DTM.DOCUMENT_FRAGMENT_NODE :
+      case DTM.DOCUMENT_NODE :
 
         // Can't clone a document, but refrain from throwing an error
         // so that copy-of will work
         break;
-      case Node.ELEMENT_NODE :
+      case DTM.ELEMENT_NODE :
         {
           Attributes atts;
 
@@ -209,56 +139,39 @@
             m_rth.processNSDecls(node);
           }
 
-          String ns = dhelper.getNamespaceOfNode(node);
-          String localName = dhelper.getLocalNameOfNode(node);
+          String ns = dtm.getNamespaceURI(node);
+          String localName = dtm.getLocalName(node);
 
-          m_rth.startElement(ns, localName, node.getNodeName(), null);
+          m_rth.startElement(ns, localName, dtm.getNodeNameX(node), null);
         }
         break;
-      case Node.CDATA_SECTION_NODE :
-        {
-          m_rth.startCDATA();
-
-          String data = ((CDATASection) node).getData();
-
-          m_rth.characters(data.toCharArray(), 0, data.length());
-          m_rth.endCDATA();
-        }
+      case DTM.CDATA_SECTION_NODE :
+        m_rth.startCDATA();          
+        dtm.dispatchCharactersEvents(node, m_rth);
+        m_rth.endCDATA();
         break;
-      case Node.ATTRIBUTE_NODE :
-        {
-          if (m_rth.isDefinedNSDecl((Attr) node))
-            break;
-
-          String ns = dhelper.getNamespaceOfNode(node);
-          String localName = dhelper.getLocalNameOfNode(node);
-
-          m_rth.addAttribute(ns, localName, node.getNodeName(), "CDATA",
-                             ((Attr) node).getValue());
-        }
+      case DTM.ATTRIBUTE_NODE :
+        m_rth.addAttribute(node);
         break;
-      case Node.COMMENT_NODE :
-        {
-          m_rth.comment(((Comment) node).getData());
-        }
+      case DTM.COMMENT_NODE :
+        XMLString xstr = dtm.getStringValue (node);
+        xstr.dispatchAsComment(m_rth);
         break;
-      case Node.ENTITY_REFERENCE_NODE :
-        {
-          EntityReference er = (EntityReference) node;
-
-          m_rth.entityReference(er.getNodeName());
-        }
+      case DTM.ENTITY_REFERENCE_NODE :
+        m_rth.entityReference(dtm.getNodeNameX(node));
         break;
-      case Node.PROCESSING_INSTRUCTION_NODE :
+      case DTM.PROCESSING_INSTRUCTION_NODE :
         {
-          ProcessingInstruction pi = (ProcessingInstruction) node;
-
-          m_rth.processingInstruction(pi.getTarget(), pi.getData());
+          // %REVIEW% Is the node name the same as the "target"?
+          m_rth.processingInstruction(dtm.getNodeNameX(node), 
+                                      dtm.getNodeValue(node));
         }
         break;
       default :
-        m_transformer.getMsgMgr().error(null, XSLTErrorResources.ER_CANT_CREATE_ITEM,
-                                        new Object[]{ node.getNodeName() });  //"Can not create item in result tree: "+node.getNodeName());
+        //"Can not create item in result tree: "+node.getNodeName());
+        m_transformer.getMsgMgr().error(null, 
+                         XSLTErrorResources.ER_CANT_CREATE_ITEM,
+                         new Object[]{ dtm.getNodeName(node) });  
       }
     }
     catch(org.xml.sax.SAXException se)
diff --git a/src/org/apache/xalan/transformer/Counter.java b/src/org/apache/xalan/transformer/Counter.java
index ee2596a..b3bd993 100644
--- a/src/org/apache/xalan/transformer/Counter.java
+++ b/src/org/apache/xalan/transformer/Counter.java
@@ -56,7 +56,8 @@
  */
 package org.apache.xalan.transformer;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 import org.apache.xml.utils.NodeVector;
 import org.apache.xpath.NodeSet;  // for isNodeAfter support
@@ -102,7 +103,7 @@
    * find a counter if the node being counted is not immediatly
    * found in the m_countNodes vector.
    */
-  Node m_fromNode = null;
+  int m_fromNode = DTM.NULL;
 
   /**
    * The owning xsl:number element.
@@ -151,7 +152,7 @@
    * 
    * @return The count of the node, or -1 if not found.
    */
-  int getPreviouslyCounted(XPathContext support, Node node)
+  int getPreviouslyCounted(XPathContext support, int node)
   {
 
     int n = m_countNodes.size();
@@ -160,9 +161,9 @@
 
     for (int i = n - 1; i >= 0; i--)
     {
-      Node countedNode = (Node) m_countNodes.elementAt(i);
+      int countedNode = m_countNodes.elementAt(i);
 
-      if (node.equals(countedNode))
+      if (node == countedNode)
       {
 
         // Since the list is in backwards order, the count is 
@@ -171,10 +172,12 @@
 
         break;
       }
+      
+      DTM dtm = support.getDTM(countedNode);
 
       // Try to see if the given node falls after the counted node...
       // if it does, don't keep searching backwards.
-      if (support.getDOMHelper().isNodeAfter(countedNode, node))
+      if (dtm.isNodeAfter(countedNode, node))
         break;
     }
 
@@ -186,11 +189,11 @@
    *
    * @return the last node in the list.
    */
-  Node getLast()
+  int getLast()
   {
 
     int size = m_countNodes.size();
 
-    return (size > 0) ? m_countNodes.elementAt(size - 1) : null;
+    return (size > 0) ? m_countNodes.elementAt(size - 1) : DTM.NULL;
   }
 }
diff --git a/src/org/apache/xalan/transformer/CountersTable.java b/src/org/apache/xalan/transformer/CountersTable.java
index 264e709..eba0838 100644
--- a/src/org/apache/xalan/transformer/CountersTable.java
+++ b/src/org/apache/xalan/transformer/CountersTable.java
@@ -59,7 +59,8 @@
 import java.util.Hashtable;
 import java.util.Vector;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 import javax.xml.transform.TransformerException;
 
@@ -160,7 +161,7 @@
    *
    * @throws TransformerException
    */
-  public int countNode(XPathContext support, ElemNumber numberElem, Node node)
+  public int countNode(XPathContext support, ElemNumber numberElem, int node)
           throws TransformerException
   {
 
@@ -170,9 +171,9 @@
 
     // XPath countMatchPattern = numberElem.getCountMatchPattern(support, node);
     // XPath fromMatchPattern = numberElem.m_fromMatchPattern;
-    Node target = numberElem.getTargetNode(support, node);
+    int target = numberElem.getTargetNode(support, node);
 
-    if (null != target)
+    if (DTM.NULL != target)
     {
       for (int i = 0; i < nCounters; i++)
       {
@@ -192,7 +193,7 @@
       // the backwards list (m_newFound) to the forwards list (counter.m_countNodes).
       count = 0;
 
-      for (; null != target;
+      for (; DTM.NULL != target;
               target = numberElem.getPreviousNode(support, target))
       {
 
@@ -207,8 +208,8 @@
             int cacheLen = counter.m_countNodes.size();
 
             if ((cacheLen > 0)
-                    && counter.m_countNodes.elementAt(cacheLen
-                                                      - 1).equals(target))
+                    && (counter.m_countNodes.elementAt(cacheLen
+                                                      - 1) == target))
             {
               count += (cacheLen + counter.m_countNodesStartCount);
 
diff --git a/src/org/apache/xalan/transformer/KeyIterator.java b/src/org/apache/xalan/transformer/KeyIterator.java
index 7b32eea..50fb1f5 100644
--- a/src/org/apache/xalan/transformer/KeyIterator.java
+++ b/src/org/apache/xalan/transformer/KeyIterator.java
@@ -60,6 +60,7 @@
 
 import org.apache.xpath.axes.LocPathIterator;
 import org.apache.xml.utils.PrefixResolver;
+import org.apache.xml.utils.XMLString;
 import org.apache.xml.utils.QName;
 import org.apache.xalan.templates.KeyDeclaration;
 import org.apache.xpath.XPathContext;
@@ -67,11 +68,12 @@
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.XPath;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.DOMException;
+//import org.w3c.dom.NamedNodeMap;
+//import org.w3c.dom.traversal.NodeFilter;
+//import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
 
 import javax.xml.transform.TransformerException;
 
@@ -135,7 +137,7 @@
    * @param keyDeclarations The key declarations from the stylesheet 
    * @param xctxt The XPath runtime state
    */
-  public KeyIterator(Node doc, PrefixResolver nscontext, QName name,
+  public KeyIterator(int doc, PrefixResolver nscontext, QName name,
                      Vector keyDeclarations, XPathContext xctxt)
   {
 
@@ -157,15 +159,13 @@
    * 
    * @return  The next <code>Node</code> in the set being iterated over, or
    *   <code>null</code> if there are no more members in that set.
-   *
-   * @throws DOMException
    */
-  public Node nextNode() throws DOMException
+  public int nextNode()
   {
 
     // If the cache is on, and the node has already been found, then 
     // just return from the list.
-    Node n = super.nextNode();
+    int n = super.nextNode();
 
     // System.out.println("--> "+((null == n) ? "null" : n.getNodeName()));
     return n;
@@ -177,15 +177,15 @@
    *
    * @param lookupKey value of the key to look for
    */
-  public void setLookupKey(String lookupKey)
+  public void setLookupKey(XMLString lookupKey)
   {
 
     // System.out.println("setLookupKey - lookupKey: "+lookupKey);
     ((KeyWalker) m_firstWalker).m_lookupKey = lookupKey;
 
-    m_firstWalker.setRoot(
-      (this.getContext().getNodeType() == Node.DOCUMENT_NODE)
-      ? this.getContext() : this.getContext().getOwnerDocument());
+    int context = getContext();
+    DTM dtm = this.getDTM(context);
+    m_firstWalker.setRoot(dtm.getDocument());
     this.setLastUsedWalker(m_firstWalker);
     this.setNextPosition(0);
   }
@@ -208,7 +208,7 @@
    * @param ref Key value(ref)(from key use field)
    * @param node Node matching that ref 
    */
-  void addRefNode(String ref, Node node)
+  void addRefNode(XMLString ref, int node)
   {
     m_keyTable.addRefNode(ref, node);
   }
diff --git a/src/org/apache/xalan/transformer/KeyManager.java b/src/org/apache/xalan/transformer/KeyManager.java
index e4a1548..3a217fd 100644
--- a/src/org/apache/xalan/transformer/KeyManager.java
+++ b/src/org/apache/xalan/transformer/KeyManager.java
@@ -58,12 +58,14 @@
 
 import java.util.Vector;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.NodeList;
+import org.apache.xml.dtm.DTM;
 
 import org.apache.xalan.templates.ElemTemplateElement;
 import org.apache.xml.utils.QName;
 import org.apache.xml.utils.PrefixResolver;
+import org.apache.xml.utils.XMLString;
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.axes.LocPathIterator;
 
@@ -93,7 +95,7 @@
    * @throws javax.xml.transform.TransformerException
    */
   public LocPathIterator getNodeSetByKey(
-          XPathContext xctxt, Node doc, QName name, String ref, PrefixResolver nscontext)
+          XPathContext xctxt, int doc, QName name, XMLString ref, PrefixResolver nscontext)
             throws javax.xml.transform.TransformerException
   {
 
diff --git a/src/org/apache/xalan/transformer/KeyRefIterator.java b/src/org/apache/xalan/transformer/KeyRefIterator.java
index 61be7e3..4bad64a 100644
--- a/src/org/apache/xalan/transformer/KeyRefIterator.java
+++ b/src/org/apache/xalan/transformer/KeyRefIterator.java
@@ -60,12 +60,15 @@
 
 import org.apache.xpath.axes.LocPathIterator;
 import org.apache.xml.utils.QName;
+import org.apache.xml.utils.XMLString;
 import org.apache.xalan.templates.KeyDeclaration;
 import org.apache.xpath.NodeSet;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.DOMException;
+//import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 /**
  * <meta name="usage" content="internal"/>
@@ -83,7 +86,7 @@
   
   /** Use field of key function.
    *  @serial         */
-  private String m_lookupKey;  
+  private XMLString m_lookupKey;  
   
   /** Main Key iterator for this iterator.
    *  @serial    */
@@ -109,7 +112,7 @@
    * @param ref Key value to match
    * @param ki The main key iterator used to walk the source tree 
    */
-  public KeyRefIterator(String ref, KeyIterator ki)
+  public KeyRefIterator(XMLString ref, KeyIterator ki)
   {
 
     super(ki.getPrefixResolver());
@@ -128,16 +131,12 @@
    * 
    * @return  The next <code>Node</code> in the set being iterated over, or
    *   <code>null</code> if there are no more members in that set.
-   * 
-   * @throws DOMException
-   *    INVALID_STATE_ERR: Raised if this method is called after the
-   *   <code>detach</code> method was invoked.
    */
-  public Node nextNode() throws DOMException
+  public int nextNode()
   {
 
    if (m_foundLast)
-      return null;
+      return DTM.NULL;
     
     // If the cache is on, and the node has already been found, then 
     // just return from the list.
@@ -150,21 +149,21 @@
     if ((null != m_cachedNodes)
             && (m_next < m_cachedNodes.size()))        
     {
-      Node next = m_cachedNodes.elementAt(m_next); 
+      int next = m_cachedNodes.elementAt(m_next); 
       this.setCurrentPos(++m_next); 
       m_lastFetched = next;
       
       return next;
     }    
 
-    Node next = null;       
+    int next = DTM.NULL;       
     if ( m_ki.getLookForMoreNodes()) 
     {
       ((KeyWalker)m_ki.getFirstWalker()).m_lookupKey = m_lookupKey;
       next = m_ki.nextNode();        
     }
     
-    if (null != next)
+    if (DTM.NULL != next)
     {  
       m_lastFetched = next;
       this.setCurrentPos(++m_next);
@@ -173,8 +172,8 @@
     else
       m_foundLast = true;                      
     
-    m_lastFetched = null;
-    return null;
+    m_lastFetched = DTM.NULL;
+    return DTM.NULL;
   }
   
   /**
@@ -225,7 +224,7 @@
    *
    * @param node Node to add to cached nodes
    */
-  public void addNode(Node node) 
+  public void addNode(int node) 
   {
     NodeSet m_cachedNodes = getCachedNodes();
     if (null != m_cachedNodes)
diff --git a/src/org/apache/xalan/transformer/KeyTable.java b/src/org/apache/xalan/transformer/KeyTable.java
index 6fe655d..bae9c3e 100644
--- a/src/org/apache/xalan/transformer/KeyTable.java
+++ b/src/org/apache/xalan/transformer/KeyTable.java
@@ -56,10 +56,11 @@
  */
 package org.apache.xalan.transformer;
 
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
+//import org.w3c.dom.Element;
+//import org.w3c.dom.NamedNodeMap;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.NodeList;
+import org.apache.xml.dtm.DTM;
 
 import java.util.Hashtable;
 import java.util.Vector;
@@ -69,11 +70,12 @@
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.XPathContext;
-import org.apache.xpath.DOMHelper;
+//import org.apache.xpath.DOMHelper;
 import org.apache.xml.utils.QName;
 import org.apache.xalan.templates.KeyDeclaration;
 import org.apache.xpath.XPathContext;
 import org.apache.xml.utils.PrefixResolver;
+import org.apache.xml.utils.XMLString;
 import org.apache.xpath.axes.LocPathIterator;
 
 // import org.apache.xalan.dtm.*;
@@ -92,7 +94,7 @@
    * The document key.  This table should only be used with contexts
    * whose Document roots match this key.
    */
-  private Node m_docKey;
+  private int m_docKey;
 
   /**
    * Get the document root matching this key.  
@@ -100,7 +102,7 @@
    *
    * @return the document root matching this key
    */
-  public Node getDocKey()
+  public int getDocKey()
   {
     return m_docKey;
   }
@@ -131,7 +133,7 @@
    * @throws javax.xml.transform.TransformerException
    */
   public KeyTable(
-          Node doc, PrefixResolver nscontext, QName name, Vector keyDeclarations, XPathContext xmlLiaison)
+          int doc, PrefixResolver nscontext, QName name, Vector keyDeclarations, XPathContext xmlLiaison)
             throws javax.xml.transform.TransformerException
   {
 
@@ -150,7 +152,7 @@
    * if the identifier is not found, it will return null,
    * otherwise it will return a LocPathIterator instance.
    */
-  public LocPathIterator getNodeSetByKey(QName name, String ref)
+  public LocPathIterator getNodeSetByKey(QName name, XMLString ref)
   {
 
     KeyIterator ki;
@@ -190,7 +192,7 @@
         refsTable = new Hashtable();
       
       // initialize walker only once!
-      if (m_keyIter.getFirstWalker().getRoot() == null)
+      if (m_keyIter.getFirstWalker().getRoot() == DTM.NULL)
         m_keyIter.setLookupKey(ref);
       else
         ((KeyWalker)m_keyIter.getFirstWalker()).m_lookupKey = ref;
@@ -220,7 +222,7 @@
    * @param ref Key ref(from key use field)
    * @param node Node matching that ref 
    */
-  void addRefNode(String ref, Node node)
+  void addRefNode(XMLString ref, int node)
   {
     KeyRefIterator kiRef = null;
     Hashtable refsTable = null;
diff --git a/src/org/apache/xalan/transformer/KeyWalker.java b/src/org/apache/xalan/transformer/KeyWalker.java
index 42eadf9..4cb2e7b 100644
--- a/src/org/apache/xalan/transformer/KeyWalker.java
+++ b/src/org/apache/xalan/transformer/KeyWalker.java
@@ -61,6 +61,7 @@
 import org.apache.xpath.axes.LocPathIterator;
 import org.apache.xml.utils.PrefixResolver;
 import org.apache.xml.utils.QName;
+import org.apache.xml.utils.XMLString;
 import org.apache.xalan.templates.KeyDeclaration;
 import org.apache.xalan.res.XSLMessages;
 import org.apache.xalan.res.XSLTErrorResources;
@@ -69,11 +70,9 @@
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.XPath;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMFilter;
 
 import javax.xml.transform.TransformerException;
 
@@ -99,58 +98,52 @@
    *
    * @param root Document root node
    */
-  public void setRoot(Node root)
+  public void setRoot(int root)
   {
 
-    m_attrs = null;
+    m_nextAttr = DTM.NULL;
     m_foundAttrs = false;
-    m_attrPos = 0;
 
     super.setRoot(root);
   }
 
-  /** List of attribute nodes of the current node      */
-  transient NamedNodeMap m_attrs;
+  /** First attribute of the current node.      */
+  transient int m_nextAttr;
 
   /** Flag indicating that attibute nodes were found for the current node    */
   transient boolean m_foundAttrs;
 
-  /** Current position in the attribute nodes list         */
-  transient int m_attrPos;
-
   /** Key value that this is looking for.
    *  @serial           */
-  String m_lookupKey;
+  XMLString m_lookupKey;
 
   /**
    * Get the next node in document order on the axes.
    *
    * @return The next node found or null.
    */
-  protected Node getNextNode()
+  protected int getNextNode()
   {
 
+    int currentNode = getCurrentNode();
+    DTM dtm = this.m_lpi.getXPathContext().getDTM(currentNode);
     if (!m_foundAttrs)
     {
-      m_attrs = getCurrentNode().getAttributes();
+      m_nextAttr = dtm.getFirstAttribute(currentNode);
       m_foundAttrs = true;
+      if (DTM.NULL != m_nextAttr)
+        return m_nextAttr;
     }
-
-    if (null != m_attrs)
+    else if (DTM.NULL != m_nextAttr)
     {
-      if (m_attrPos < m_attrs.getLength())
-      {
-        return m_attrs.item(m_attrPos++);
-      }
-      else
-      {
-        m_attrs = null;
-      }
+      m_nextAttr = dtm.getNextAttribute(m_nextAttr);
+      if (DTM.NULL != m_nextAttr)
+        return m_nextAttr;
     }
 
-    Node next = super.getNextNode();
+    int next = super.getNextNode();
 
-    if (null != next)
+    if (DTM.NULL != next)
       m_foundAttrs = false;
 
     return next;
@@ -167,16 +160,16 @@
    * @return  a constant to determine whether the node is accepted,
    *   rejected, or skipped, as defined  above .
    */
-  public short acceptNode(Node testNode)
+  public short acceptNode(int testNode)
   {
-		boolean foundKey = false;
+    boolean foundKey = false;
     KeyIterator ki = (KeyIterator) m_lpi;
     Vector keys = ki.getKeyDeclarations();
 
     QName name = ki.getName();
     try
     {
-      String lookupKey = m_lookupKey;
+      XMLString lookupKey = m_lookupKey;
 
       // System.out.println("lookupKey: "+lookupKey);
       int nDeclarations = keys.size();
@@ -191,7 +184,7 @@
         if(!kd.getName().equals(name)) 
           continue;
         
-				foundKey = true;
+                                foundKey = true;
         ki.getXPathContext().setNamespaceContext(ki.getPrefixResolver());
 
         // See if our node matches the given key declaration according to 
@@ -209,16 +202,16 @@
 
         if (xuse.getType() != xuse.CLASS_NODESET)
         {
-          String exprResult = xuse.str();
+          XMLString exprResult = xuse.xstr();
           ((KeyIterator)m_lpi).addRefNode(exprResult, testNode);
           
           if (lookupKey.equals(exprResult))
-            return this.FILTER_ACCEPT;
+            return DTMIterator.FILTER_ACCEPT;
         }
         else
         {
-          NodeIterator nl = xuse.nodeset();
-          Node useNode;
+          DTMIterator nl = xuse.nodeset();
+          int useNode;
           short result = -1;
           /*
           We are walking through all the nodes in this nodeset
@@ -232,14 +225,15 @@
           matches. What if the next call is for the same match+use 
           combination??
           */
-          while (null != (useNode = nl.nextNode()))
+          while (DTM.NULL != (useNode = nl.nextNode()))
           {
-            String exprResult = m_lpi.getDOMHelper().getNodeData(useNode);
+            DTM dtm = getDTM(useNode);
+            XMLString exprResult = dtm.getStringValue(useNode);
             ((KeyIterator)m_lpi).addRefNode(exprResult, testNode); 
             
             if ((null != exprResult) && lookupKey.equals(exprResult))
-              result = this.FILTER_ACCEPT;
-              //return this.FILTER_ACCEPT;
+              result = DTMIterator.FILTER_ACCEPT;
+              //return DTMIterator.FILTER_ACCEPT;
           }
           if (-1 != result)
             return result;
@@ -253,10 +247,10 @@
       // TODO: What to do?
     }
 
-		if (!foundKey)
-			throw new RuntimeException
-				(XSLMessages.createMessage(XSLTErrorResources.ER_NO_XSLKEY_DECLARATION, new Object[]{name.getLocalName()}));
-    return this.FILTER_REJECT;
+                if (!foundKey)
+                        throw new RuntimeException
+                                (XSLMessages.createMessage(XSLTErrorResources.ER_NO_XSLKEY_DECLARATION, new Object[]{name.getLocalName()}));
+    return DTMIterator.FILTER_REJECT;
   }
   
    /**
@@ -269,13 +263,13 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   next node  in the TreeWalker's logical view.
    */
-  public Node nextNode()
+  public int nextNode()
   {
-    Node node = super.nextNode();
+    int node = super.nextNode();
     // If there is no next node, we have walked the whole source tree.
     // Notify the iterator of that so that its callers know that there
     // are no more nodes to be found.
-    if (node == null)
+    if (node == DTM.NULL)
       ((KeyIterator)m_lpi).setLookForMoreNodes(false);
     return node;
   }
diff --git a/src/org/apache/xalan/transformer/NodeSortKey.java b/src/org/apache/xalan/transformer/NodeSortKey.java
index 6b3698c..130b506 100644
--- a/src/org/apache/xalan/transformer/NodeSortKey.java
+++ b/src/org/apache/xalan/transformer/NodeSortKey.java
@@ -110,7 +110,9 @@
    * @throws javax.xml.transform.TransformerException
    */
   NodeSortKey(
-          TransformerImpl transformer, XPath selectPat, boolean treatAsNumbers, boolean descending, String langValue, boolean caseOrderUpper, org.apache.xml.utils.PrefixResolver namespaceContext)
+          TransformerImpl transformer, XPath selectPat, boolean treatAsNumbers, 
+          boolean descending, String langValue, boolean caseOrderUpper, 
+          org.apache.xml.utils.PrefixResolver namespaceContext)
             throws javax.xml.transform.TransformerException
   {
 
diff --git a/src/org/apache/xalan/transformer/NodeSorter.java b/src/org/apache/xalan/transformer/NodeSorter.java
index 20f3a7c..ead62eb 100644
--- a/src/org/apache/xalan/transformer/NodeSorter.java
+++ b/src/org/apache/xalan/transformer/NodeSorter.java
@@ -61,8 +61,10 @@
 import java.text.NumberFormat;
 import java.text.CollationKey;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import org.apache.xpath.axes.ContextNodeList;
 import org.apache.xpath.XPathContext;
@@ -112,22 +114,26 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  public void sort(NodeVector v, Vector keys, XPathContext support)
+  public void sort(DTMIterator v, Vector keys, XPathContext support)
           throws javax.xml.transform.TransformerException
   {
 
     m_keys = keys;
 
     // QuickSort2(v, 0, v.size() - 1 );
-    int n = v.size();
+    int n = v.getLength();
 
+    // %OPT% Change mergesort to just take a DTMIterator?
+    // We would also have to adapt DTMIterator to have the function 
+    // of NodeCompareElem.
+    
     // Create a vector of node compare elements
     // based on the input vector of nodes
     Vector nodes = new Vector();
 
     for (int i = 0; i < n; i++)
     {
-      NodeCompareElem elem = new NodeCompareElem((Node) v.elementAt(i));
+      NodeCompareElem elem = new NodeCompareElem(v.item(i));
 
       nodes.addElement(elem);
     }
@@ -139,8 +145,9 @@
     // return sorted vector of nodes
     for (int i = 0; i < n; i++)
     {
-      v.setElementAt(((NodeCompareElem) nodes.elementAt(i)).m_node, i);
+      v.setItem(((NodeCompareElem) nodes.elementAt(i)).m_node, i);
     }
+    v.setCurrentPos(0);
 
     // old code...
     //NodeVector scratchVector = new NodeVector(n);
@@ -294,8 +301,8 @@
       // be a glitch in the mergesort
       // if(r1.getType() == r1.CLASS_NODESET)
       // {
-      result = support.getDOMHelper().isNodeAfter(n1.m_node, n2.m_node)
-               ? -1 : 1;
+      DTM dtm = support.getDTM(n1.m_node); // %OPT%
+      result = dtm.isNodeAfter(n1.m_node, n2.m_node) ? -1 : 1;
 
       // }
     }
@@ -462,22 +469,22 @@
       }
     } // end QuickSort2  */
 
-  /**
-   * Simple function to swap two elements in
-   * a vector.
-   * 
-   * @param v Vector of nodes to swap
-   * @param i Index of first node to swap
-   * @param i Index of second node to swap
-   */
-  private void swap(Vector v, int i, int j)
-  {
-
-    Node node = (Node) v.elementAt(i);
-
-    v.setElementAt(v.elementAt(j), i);
-    v.setElementAt(node, j);
-  }
+//  /**
+//   * Simple function to swap two elements in
+//   * a vector.
+//   * 
+//   * @param v Vector of nodes to swap
+//   * @param i Index of first node to swap
+//   * @param i Index of second node to swap
+//   */
+//  private void swap(Vector v, int i, int j)
+//  {
+//
+//    int node = (Node) v.elementAt(i);
+//
+//    v.setElementAt(v.elementAt(j), i);
+//    v.setElementAt(node, j);
+//  }
 
   /**
    * <meta name="usage" content="internal"/>
@@ -488,7 +495,7 @@
   {
 
     /** Current node          */
-    Node m_node;
+    int m_node;
 
     /** This maxkey value was chosen arbitrarily. We are assuming that the    
     // maxkey + 1 keys will only hit fairly rarely and therefore, we
@@ -514,7 +521,7 @@
      *
      * @throws javax.xml.transform.TransformerException
      */
-    NodeCompareElem(Node node) throws javax.xml.transform.TransformerException
+    NodeCompareElem(int node) throws javax.xml.transform.TransformerException
     {
 
       boolean tryNextKey = true;
@@ -546,10 +553,14 @@
 
         if (r.getType() == XObject.CLASS_NODESET)
         {
-          NodeIterator ni = (NodeIterator) r.object();
+          // %REVIEW%
+          DTMIterator ni = (DTMIterator)r.object();
+          int current = ni.getCurrentNode();
+          if(DTM.NULL == current)
+            current = ni.nextNode();
 
-          if (ni instanceof ContextNodeList)
-            tryNextKey = (((ContextNodeList) ni).getCurrentNode() != null);
+          // if (ni instanceof ContextNodeList) // %REVIEW%
+          tryNextKey = (DTM.NULL != current);
 
           // else abdicate... should never happen, but... -sb
         }
diff --git a/src/org/apache/xalan/transformer/QueuedStartElement.java b/src/org/apache/xalan/transformer/QueuedStartElement.java
index 83f894c..676cf27 100644
--- a/src/org/apache/xalan/transformer/QueuedStartElement.java
+++ b/src/org/apache/xalan/transformer/QueuedStartElement.java
@@ -72,13 +72,16 @@
 import org.apache.xalan.templates.ElemTemplateElement;
 import org.apache.xalan.templates.ElemTemplate;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 /**
  * Tracks the state of a queued element event.
  */
-public class QueuedStartElement extends QueuedSAXEvent implements TransformState
+public class QueuedStartElement extends QueuedSAXEvent
 {
 
   /**
@@ -124,7 +127,7 @@
   /**
    * The current context node in the source tree.
    */
-  private Node m_currentNode;
+  private int m_currentNode;
   
   /**
    * The xsl:template that is in effect, which may be a matched template
@@ -141,12 +144,12 @@
    * The node in the source tree that matched
    * the template obtained via getMatchedTemplate().
    */
-  private Node m_matchedNode;
+  private int m_matchedNode;
   
   /**
    * The current context node list.
    */
-  private NodeIterator m_contextNodeList;
+  private DTMIterator m_contextNodeList;
   
   /**
    * Clear the pending event.
@@ -158,10 +161,10 @@
     if(m_isTransformClient)
     {
       m_currentElement = null;
-      m_currentNode = null;
+      m_currentNode = DTM.NULL;
       m_currentTemplate = null;
       m_matchedTemplate = null;
-      m_matchedNode = null;
+      m_matchedNode = DTM.NULL;
       m_contextNodeList = null; // TODO: Need to clone
     }
   }
@@ -190,9 +193,9 @@
     if(m_isTransformClient && (null != m_transformer))
     {
       m_currentElement = m_transformer.getCurrentElement();
-      m_currentNode = m_transformer.getCurrentNode();
       m_currentTemplate = m_transformer.getCurrentTemplate();
       m_matchedTemplate = m_transformer.getMatchedTemplate();
+      m_currentNode = m_transformer.getCurrentNode();
       m_matchedNode = m_transformer.getMatchedNode();
       m_contextNodeList = m_transformer.getContextNodeList(); // TODO: Need to clone
     }
@@ -301,6 +304,7 @@
    */
   void setNSDeclsHaveBeenAdded(boolean b)
   {
+    // System.out.println("setNSDeclsHaveBeenAdded: "+b);
     m_nsDeclsHaveBeenAdded = b;
   }
 
@@ -390,9 +394,9 @@
    *
    * @return the current context node in the source tree.
    */
-  public Node getCurrentNode()
+  public int getCurrentNode()
   {
-    return m_currentTemplate;
+    return m_currentNode;
   }
   
   /**
@@ -436,7 +440,7 @@
    * @return the node in the source tree that matched
    * the template obtained via getMatchedTemplate().
    */
-  public Node getMatchedNode()
+  public int getMatchedNode()
   {
     return m_matchedNode;
   }
@@ -446,7 +450,7 @@
    *
    * @return the current context node list.
    */
-  public NodeIterator getContextNodeList()
+  public DTMIterator getContextNodeList()
   {
     return m_contextNodeList;
   }
diff --git a/src/org/apache/xalan/transformer/ResultTreeHandler.java b/src/org/apache/xalan/transformer/ResultTreeHandler.java
index 05d2a88..9af9496 100644
--- a/src/org/apache/xalan/transformer/ResultTreeHandler.java
+++ b/src/org/apache/xalan/transformer/ResultTreeHandler.java
@@ -73,12 +73,15 @@
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.XPathContext;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.NamedNodeMap;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Attr;
+//import org.w3c.dom.DocumentFragment;
+//import org.w3c.dom.NodeList;
+//import org.w3c.dom.NamedNodeMap;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMFilter;
 
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
@@ -231,10 +234,10 @@
                            + qse.getLocalName());
 
       System.out.println("ResultTreeHandler#startElement: " + ns + "#" + localName);
-      if(null == ns)
-      {
-        (new RuntimeException(localName+" has a null namespace!")).printStackTrace();
-      }
+//      if(null == ns)
+//      {
+//        (new RuntimeException(localName+" has a null namespace!")).printStackTrace();
+//      }
     }
 
     checkForSerializerSwitch(ns, localName);
@@ -275,7 +278,7 @@
 
       System.out.println("ResultTreeHandler#endElement: " + ns + "#" + localName);
     }
-
+  
     flushPending(EVT_ENDELEMENT);
     m_contentHandler.endElement(ns, localName, name);
 
@@ -725,6 +728,23 @@
    *            wrapping another exception.
    */
   public void skippedEntity(String name) throws org.xml.sax.SAXException{}
+  
+  /**
+   * Set whether Namespace declarations have been added to 
+   * this element
+   *
+   *
+   * @param b Flag indicating whether Namespace declarations 
+   * have been added to this element
+   */
+  public void setNSDeclsHaveBeenAdded(boolean b)
+  {
+    QueuedStartElement qe = getQueuedElem();
+    if (null != qe) 
+    {
+      qe.setNSDeclsHaveBeenAdded(b);
+    }
+  }
 
   /**
    * Flush the pending element.
@@ -791,15 +811,13 @@
   public void outputResultTreeFragment(XObject obj, XPathContext support)
           throws org.xml.sax.SAXException
   {
-
-    DocumentFragment docFrag = obj.rtree(support);
-    TreeWalker tw = new TreeWalker(this, support.getDOMHelper());
-
-    Node n;
-    for (n = docFrag.getFirstChild(); null != n; n = n.getNextSibling())
+    int doc = obj.rtree();
+    DTM dtm = support.getDTM(doc);
+  
+    for (int n = dtm.getFirstChild(doc); DTM.NULL != n; n = dtm.getNextSibling(n))
     {
       flushPending(EVT_NODE);  // I think.
-      tw.traverse(n);
+      dtm.dispatchToEvents(n, this);
     }
   }
 
@@ -811,7 +829,7 @@
    *
    * @throws org.xml.sax.SAXException
    */
-  public void cloneToResultTree(Node node, boolean shouldCloneAttributes)
+  public void cloneToResultTree(int node, boolean shouldCloneAttributes)
           throws org.xml.sax.SAXException
   {
     try
@@ -843,7 +861,7 @@
    *
    * @throws org.xml.sax.SAXException
    */
-  void ensurePrefixIsDeclared(String ns, String rawName) throws org.xml.sax.SAXException
+  public void ensurePrefixIsDeclared(String ns, String rawName) throws org.xml.sax.SAXException
   {
 
     if (ns != null && ns.length() > 0)
@@ -856,8 +874,39 @@
       {
         String foundURI = m_nsSupport.getURI(prefix);
 
-        if ((null == foundURI) ||!foundURI.equals(ns))
+        if ((null == foundURI) || !foundURI.equals(ns))
+        {
+          
           startPrefixMapping(prefix, ns, false);
+        }
+      }
+    }
+  }
+  
+  /**
+   * This function checks to make sure a given prefix is really
+   * declared.  It might not be, because it may be an excluded prefix.
+   * If it's not, it still needs to be declared at this point.
+   * TODO: This needs to be done at an earlier stage in the game... -sb
+   *
+   * @param ns Namespace URI of the element 
+   * @param rawName Raw name of element (with prefix)
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public void ensureNamespaceDeclDeclared(DTM dtm, int namespace) throws org.xml.sax.SAXException
+  {
+    String uri = dtm.getNodeValue(namespace);
+    String prefix = dtm.getNodeNameX(namespace);
+
+    if ((uri != null && uri.length() > 0) && (null != prefix))
+    {
+      String foundURI = m_nsSupport.getURI(prefix);
+
+      if ((null == foundURI) || !foundURI.equals(uri))
+      {
+        
+        startPrefixMapping(prefix, uri, false);
       }
     }
   }
@@ -934,7 +983,7 @@
    * Add the attributes that have been declared to the attribute list.
    * (Seems like I shouldn't have to do this...)
    */
-  protected void addNSDeclsToAttrs()
+  public void addNSDeclsToAttrs()
   {
 
     Enumeration prefixes = m_nsSupport.getDeclaredPrefixes();
@@ -974,43 +1023,39 @@
    *
    * @throws TransformerException
    */
-  public void processNSDecls(Node src) throws TransformerException
+  public void processNSDecls(int src) throws TransformerException
   {
 
     try
     {
       int type;
+      DTM dtm = m_transformer.getXPathContext().getDTM(src);
 
       // Vector nameValues = null;
       // Vector alreadyProcessedPrefixes = null;
-      Node parent;
+      int parent;
 
-      if (((type = src.getNodeType()) == Node.ELEMENT_NODE || (type == Node.ENTITY_REFERENCE_NODE))
-          && (parent = src.getParentNode()) != null)
+      if (((type = dtm.getNodeType(src)) == DTM.ELEMENT_NODE || 
+           (type == DTM.ENTITY_REFERENCE_NODE))
+          && (parent = dtm.getParent(src)) != DTM.NULL)
       {
         processNSDecls(parent);
       }
 
-      if (type == Node.ELEMENT_NODE)
+      if (type == DTM.ELEMENT_NODE)
       {
-        NamedNodeMap nnm = src.getAttributes();
-        int nAttrs = nnm.getLength();
 
-        for (int i = 0; i < nAttrs; i++)
+        for (int namespace = dtm.getFirstNamespaceNode(src, true);
+             DTM.NULL != namespace; namespace = dtm.getNextNamespaceNode(src, namespace, true))
         {
-          Node attr = nnm.item(i);
-          String aname = attr.getNodeName();
+          // String prefix = dtm.getPrefix(namespace);
+          String prefix = dtm.getNodeNameX(namespace);
+          String desturi = getURI(prefix);
+          String srcURI = dtm.getNodeValue(namespace);
 
-          if (QName.isXMLNSDecl(aname))
+          if (!srcURI.equalsIgnoreCase(desturi))
           {
-            String prefix = QName.getPrefixFromXMLNSDecl(aname);
-            String desturi = getURI(prefix);
-            String srcURI = attr.getNodeValue();
-
-            if (!srcURI.equalsIgnoreCase(desturi))
-            {
-              this.startPrefixMapping(prefix, srcURI, false);
-            }
+            this.startPrefixMapping(prefix, srcURI, false);
           }
         }
       }
@@ -1243,24 +1288,47 @@
    * @return True if the namespace is already defined in 
    * list of namespaces
    */
-  public boolean isDefinedNSDecl(Attr attr)
+  public boolean isDefinedNSDecl(int attr)
   {
-
-    String rawName = attr.getNodeName();
-
-    if (rawName.equals("xmlns") || rawName.startsWith("xmlns:"))
+    DTM dtm = m_transformer.getXPathContext().getDTM(attr);
+    if(DTM.NAMESPACE_NODE == dtm.getNodeType(attr))
     {
-      int index;
-      String prefix = (index = rawName.indexOf(":")) < 0
-                      ? "" : rawName.substring(0, index);
+      // String prefix = dtm.getPrefix(attr);
+      String prefix = dtm.getNodeNameX(attr);
       String uri = getURI(prefix);
-
-      if ((null != uri) && uri.equals(attr.getValue()))
+  
+      if ((null != uri) && uri.equals(dtm.getStringValue(attr)))
         return true;
     }
 
     return false;
   }
+  
+  /**
+   * Returns whether a namespace is defined 
+   *
+   *
+   * @param attr Namespace attribute node
+   * @param dtm The DTM that owns attr.
+   *
+   * @return True if the namespace is already defined in 
+   * list of namespaces
+   */
+  public boolean isDefinedNSDecl(int attr, DTM dtm)
+  {
+    if(DTM.NAMESPACE_NODE == dtm.getNodeType(attr))
+    {
+      // String prefix = dtm.getPrefix(attr);
+      String prefix = dtm.getNodeNameX(attr);
+      String uri = getURI(prefix);
+  
+      if ((null != uri) && uri.equals(dtm.getStringValue(attr)))
+        return true;
+    }
+
+    return false;
+  }
+
 
   /**
    * Copy an DOM attribute to the created output element, executing
@@ -1271,21 +1339,21 @@
    *
    * @throws TransformerException
    */
-  public void addAttribute(Attr attr) throws TransformerException
+  public void addAttribute(int attr) throws TransformerException
   {
+    DTM dtm = m_transformer.getXPathContext().getDTM(attr);
 
-    if (isDefinedNSDecl(attr))
+    if (isDefinedNSDecl(attr, dtm))
       return;
-
-    DOMHelper helper = m_transformer.getXPathContext().getDOMHelper();
     
-    String ns = helper.getNamespaceOfNode(attr);
+    String ns = dtm.getNamespaceURI(attr);
     if(ns == null)
       ns = "";
 
+    // %OPT% ...can I just store the node handle?    
     addAttribute(ns,
-                 helper.getLocalNameOfNode(attr), attr.getNodeName(),
-                 "CDATA", attr.getValue());
+                 dtm.getLocalName(attr), dtm.getNodeName(attr),
+                 "CDATA", dtm.getNodeValue(attr));
   }  // end copyAttributeToTarget method
 
   /**
@@ -1295,16 +1363,13 @@
    *
    * @throws TransformerException
    */
-  public void addAttributes(Node src) throws TransformerException
+  public void addAttributes(int src) throws TransformerException
   {
+    DTM dtm = m_transformer.getXPathContext().getDTM(src);
 
-    NamedNodeMap nnm = src.getAttributes();
-    int nAttrs = nnm.getLength();
-
-    for (int i = 0; i < nAttrs; i++)
+    for (int node = dtm.getFirstAttribute(src); DTM.NULL != node; 
+         node = dtm.getNextAttribute(node))
     {
-      Attr node = (Attr) nnm.item(i);
-
       addAttribute(node);
     }
   }
@@ -1347,13 +1412,15 @@
    *
    * @return the current context node in the source tree.
    */
-  public Node getCurrentNode()
+  public org.w3c.dom.Node getCurrentNode()
   {
-    QueuedStartElement qe = getQueuedElem();
-    if(null != qe && qe.isPending)
-      return qe.getCurrentNode();
-    else
-      return m_transformer.getCurrentNode();
+    // %DTBD% Need DTM2DOM stuff
+    return null;
+//    QueuedStartElement qe = getQueuedElem();
+//    if(null != qe && qe.isPending)
+//      return qe.getCurrentNode();
+//    else
+//      return m_transformer.getCurrentNode();
   }
 
   /**
@@ -1405,13 +1472,15 @@
    * @return the node in the source tree that matched
    * the template obtained via getMatchedTemplate().
    */
-  public Node getMatchedNode()
+  public org.w3c.dom.Node getMatchedNode()
   {
-    QueuedStartElement qe = getQueuedElem();
-    if(null != qe && qe.isPending)
-      return qe.getMatchedNode();
-    else
-      return m_transformer.getMatchedNode();
+    // %DTBD% Need DTM2DOM stuff
+    return null;
+//    QueuedStartElement qe = getQueuedElem();
+//    if(null != qe && qe.isPending)
+//      return qe.getMatchedNode();
+//    else
+//      return m_transformer.getMatchedNode();
   }
 
   /**
@@ -1419,13 +1488,15 @@
    *
    * @return the current context node list.
    */
-  public NodeIterator getContextNodeList()
+  public org.w3c.dom.traversal.NodeIterator getContextNodeList()
   {
-    QueuedStartElement qe = getQueuedElem();
-    if(null != qe && qe.isPending)
-      return qe.getContextNodeList();
-    else
-      return m_transformer.getContextNodeList();
+    // %DTBD% Need DTM2DOM stuff
+    return null;
+//    QueuedStartElement qe = getQueuedElem();
+//    if(null != qe && qe.isPending)
+//      return qe.getContextNodeList();
+//    else
+//      return m_transformer.getContextNodeList();
   }
 
   /**
diff --git a/src/org/apache/xalan/transformer/StackGuard.java b/src/org/apache/xalan/transformer/StackGuard.java
index 68989df..ae2799c 100644
--- a/src/org/apache/xalan/transformer/StackGuard.java
+++ b/src/org/apache/xalan/transformer/StackGuard.java
@@ -56,9 +56,10 @@
  */
 package org.apache.xalan.transformer;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-import org.w3c.dom.Element;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.Text;
+//import org.w3c.dom.Element;
+import org.apache.xml.dtm.DTM;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
@@ -119,10 +120,10 @@
   }
 
   /** Stylesheet Template node          */
-  Node m_xslRule;
+  ElemTemplateElement m_xslRule;
 
   /** Source node          */
-  Node m_sourceXML;
+  int m_sourceXML;
 
   /** Stack where ElemTempalteElements will be pushed          */
   java.util.Stack stack = new java.util.Stack();
@@ -140,7 +141,7 @@
    * @param xslTemplate Current template node
    * @param sourceXML Source Node
    */
-  public StackGuard(ElemTemplateElement xslTemplate, Node sourceXML)
+  public StackGuard(ElemTemplateElement xslTemplate, int sourceXML)
   {
     m_xslRule = xslTemplate;
     m_sourceXML = sourceXML;
@@ -158,7 +159,7 @@
   {
 
     if (((StackGuard) obj).m_xslRule.equals(m_xslRule)
-            && ((StackGuard) obj).m_sourceXML.equals(m_sourceXML))
+            && ((StackGuard) obj).m_sourceXML == m_sourceXML)
     {
       return true;
     }
@@ -176,18 +177,19 @@
   {
 
     // for the moment, these diagnostics are really bad...
-    if (m_sourceXML instanceof Text)
-    {
-      Text tx = (Text) m_sourceXML;
-
-      pw.println(tx.getData());
-    }
-    else if (m_sourceXML instanceof Element)
-    {
-      Element elem = (Element) m_sourceXML;
-
-      pw.println(elem.getNodeName());
-    }
+    // %DTBD% We need an execution context.
+//    if (m_sourceXML instanceof Text)
+//    {
+//      Text tx = (Text) m_sourceXML;
+//
+//      pw.println(tx.getData());
+//    }
+//    else if (m_sourceXML instanceof Element)
+//    {
+//      Element elem = (Element) m_sourceXML;
+//
+//      pw.println(elem.getNodeName());
+//    }
   }
 
   /**
@@ -249,7 +251,7 @@
    *
    * @throws TransformerException
    */
-  public void push(ElemTemplateElement xslTemplate, Node sourceXML)
+  public void push(ElemTemplateElement xslTemplate, int sourceXML)
           throws TransformerException
   {
 
diff --git a/src/org/apache/xalan/transformer/TrAXFilter.java b/src/org/apache/xalan/transformer/TrAXFilter.java
index 9a4d3fc..5d2efef 100644
--- a/src/org/apache/xalan/transformer/TrAXFilter.java
+++ b/src/org/apache/xalan/transformer/TrAXFilter.java
@@ -17,8 +17,6 @@
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.ErrorListener;
 
-import org.apache.xalan.stree.SourceTreeHandler;
-
 public class TrAXFilter extends XMLFilterImpl
 {
   private Templates m_templates;
@@ -171,8 +169,8 @@
     }
     
     ContentHandler ch = m_transformer.getInputContentHandler();
-    if(ch instanceof SourceTreeHandler)
-      ((SourceTreeHandler)ch).setUseMultiThreading(true);
+//    if(ch instanceof SourceTreeHandler)
+//      ((SourceTreeHandler)ch).setUseMultiThreading(true);
     p.setContentHandler(ch);
 
     if(ch instanceof EntityResolver)
diff --git a/src/org/apache/xalan/transformer/TransformSnapshotImpl.java b/src/org/apache/xalan/transformer/TransformSnapshotImpl.java
index f2a2881..3ea5d7d 100644
--- a/src/org/apache/xalan/transformer/TransformSnapshotImpl.java
+++ b/src/org/apache/xalan/transformer/TransformSnapshotImpl.java
@@ -56,7 +56,15 @@
    * org.apache.xalan.transformer.TransformState interface,  
    * so a tool can discover the matched template, and matched 
    * node. */
-  private NodeVector m_currentMatchTemplates = new NodeVector();
+  private Stack m_currentMatchTemplates = new Stack();
+
+  /** A node vector used as a stack to track the current 
+   * ElemTemplate that was matched, as well as the node that 
+   * was matched.  Needed for the 
+   * org.apache.xalan.transformer.TransformState interface,  
+   * so a tool can discover the matched template, and matched 
+   * node. */
+  private NodeVector m_currentMatchNodes = new NodeVector();
 
   /**
    * The table of counters for xsl:number support.
@@ -121,7 +129,8 @@
   
       m_currentTemplateRuleIsNull = (BoolStack)transformer.m_currentTemplateRuleIsNull.clone();
       m_currentTemplateElements = (NodeVector)transformer.m_currentTemplateElements.clone();
-      m_currentMatchTemplates = (NodeVector)transformer.m_currentMatchTemplates.clone();
+      m_currentMatchTemplates = (Stack)transformer.m_currentMatchTemplates.clone();
+      m_currentMatchNodes = (NodeVector)transformer.m_currentMatchedNodes.clone();
       m_countersTable = (CountersTable)transformer.m_countersTable.clone();
       m_attrSetStack = (Stack)transformer.m_attrSetStack.clone();
     }
@@ -164,8 +173,9 @@
       xpc.setAxesIteratorStackStacks((Stack)m_axesIteratorStack.clone());
   
       transformer.m_currentTemplateRuleIsNull = (BoolStack)m_currentTemplateRuleIsNull.clone();
-      transformer.m_currentTemplateElements = (NodeVector)m_currentTemplateElements.clone();
-      transformer.m_currentMatchTemplates = (NodeVector)m_currentMatchTemplates.clone();
+      transformer.m_currentTemplateElements = (Stack)m_currentTemplateElements.clone();
+      transformer.m_currentMatchTemplates = (Stack)m_currentMatchTemplates.clone();
+      transformer.m_currentMatchedNodes = (NodeVector)m_currentMatchNodes.clone();
       transformer.m_countersTable = (CountersTable)m_countersTable.clone();
       transformer.m_attrSetStack = (Stack)m_attrSetStack.clone();
     }
diff --git a/src/org/apache/xalan/transformer/TransformerHandlerImpl.java b/src/org/apache/xalan/transformer/TransformerHandlerImpl.java
new file mode 100644
index 0000000..58f62b8
--- /dev/null
+++ b/src/org/apache/xalan/transformer/TransformerHandlerImpl.java
@@ -0,0 +1,998 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xalan.transformer;
+
+import java.io.IOException;
+
+import org.xml.sax.XMLReader;
+import org.xml.sax.XMLFilter;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.Attributes;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.ext.DeclHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.ext.LexicalHandler;
+
+import org.apache.xpath.objects.XString;
+
+// import org.xml.sax.ext.DeclHandler;
+import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.Result;
+
+import org.apache.xpath.XPathContext;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMManager;
+
+import org.apache.xml.dtm.CoroutineManager;
+import org.apache.xml.dtm.CoroutineSAXParser;
+import org.apache.xml.dtm.sax2dtm.SAX2DTM;
+
+/**
+ * A TransformerHandler
+ * listens for SAX ContentHandler parse events and transforms
+ * them to a Result.
+ */
+public class TransformerHandlerImpl
+        implements EntityResolver, DTDHandler, ContentHandler, ErrorHandler,
+                   LexicalHandler, TransformerHandler, DeclHandler
+{
+  
+  private boolean m_insideParse = false;
+
+  ////////////////////////////////////////////////////////////////////
+  // Constructors.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Construct a TransformerHandlerImpl.
+   *
+   * @param transformer Non-null reference to the Xalan transformer impl.
+   * @param doFragment True if the result should be a document fragement.
+   * @param baseSystemID  The system ID to use as the base for relative URLs.
+   */
+  public TransformerHandlerImpl(TransformerImpl transformer,
+                                boolean doFragment, String baseSystemID)
+  {
+
+    super();
+
+    m_transformer = transformer;
+    m_baseSystemID = baseSystemID;
+
+    XPathContext xctxt = transformer.getXPathContext();
+    DTM dtm = xctxt.getDTM(null, true, transformer, true);
+    
+    m_dtm = dtm;
+    dtm.setDocumentBaseURI(baseSystemID);
+
+    m_contentHandler = dtm.getContentHandler();
+    m_dtdHandler = dtm.getDTDHandler();
+    m_entityResolver = dtm.getEntityResolver();
+    m_errorHandler = dtm.getErrorHandler();
+    m_lexicalHandler = dtm.getLexicalHandler();
+  }
+  
+  /** 
+   * Do what needs to be done to shut down the CoRoutine management.
+   */
+  protected void clearCoRoutine()
+  {
+    
+    if(m_dtm instanceof SAX2DTM)
+    {
+      if(DEBUG)
+        System.out.println("In clearCoRoutine...");
+      SAX2DTM sax2dtm = ((SAX2DTM)m_dtm);
+      if(null != m_contentHandler 
+         && m_contentHandler instanceof CoroutineSAXParser)
+      {
+        CoroutineSAXParser sp = (CoroutineSAXParser)m_contentHandler;
+
+        if(m_insideParse)
+            sp.doMore(false, sax2dtm.getAppCoroutineID());      
+      }
+      
+      sax2dtm.clearCoRoutine(true);
+      m_contentHandler = null;
+      m_dtdHandler = null;
+      m_entityResolver = null;
+      m_errorHandler = null;
+      m_lexicalHandler = null;
+      if(DEBUG)
+        System.out.println("...exiting clearCoRoutine");
+    }
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of javax.xml.transform.sax.TransformerHandler.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Enables the user of the TransformerHandler to set the
+   * to set the Result for the transformation.
+   *
+   * @param result A Result instance, should not be null.
+   *
+   * @throws IllegalArgumentException if result is invalid for some reason.
+   */
+  public void setResult(Result result) throws IllegalArgumentException
+  {
+
+    if (null == result)
+      throw new IllegalArgumentException("result should not be null");
+
+    try
+    {
+      ContentHandler handler =
+        m_transformer.createResultContentHandler(result);
+
+      m_transformer.setContentHandler(handler);
+    }
+    catch (javax.xml.transform.TransformerException te)
+    {
+      throw new IllegalArgumentException("result could not be set");
+    }
+
+    m_result = result;
+  }
+
+  /**
+   * Set the base ID (URI or system ID) from where relative
+   * URLs will be resolved.
+   * @param systemID Base URI for the source tree.
+   */
+  public void setSystemId(String systemID)
+  {
+    m_baseSystemID = systemID;
+    m_dtm.setDocumentBaseURI(systemID);
+  }
+
+  /**
+   * Get the base ID (URI or system ID) from where relative
+   * URLs will be resolved.
+   * @return The systemID that was set with {@link #setSystemId}.
+   */
+  public String getSystemId()
+  {
+    return m_baseSystemID;
+  }
+
+  /**
+   * Get the Transformer associated with this handler, which
+   * is needed in order to set parameters and output properties.
+   *
+   * @return The Transformer associated with this handler
+   */
+  public Transformer getTransformer()
+  {
+    return m_transformer;
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of org.xml.sax.EntityResolver.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Filter an external entity resolution.
+   *
+   * @param publicId The entity's public identifier, or null.
+   * @param systemId The entity's system identifier.
+   * @return A new InputSource or null for the default.
+   *
+   * @throws IOException
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @throws java.io.IOException The client may throw an
+   *            I/O-related exception while obtaining the
+   *            new InputSource.
+   * @see org.xml.sax.EntityResolver#resolveEntity
+   */
+  public InputSource resolveEntity(String publicId, String systemId)
+          throws SAXException, IOException
+  {
+
+    if (m_entityResolver != null)
+    {
+      return m_entityResolver.resolveEntity(publicId, systemId);
+    }
+    else
+    {
+      return null;
+    }
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of org.xml.sax.DTDHandler.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Filter a notation declaration event.
+   *
+   * @param name The notation name.
+   * @param publicId The notation's public identifier, or null.
+   * @param systemId The notation's system identifier, or null.
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @see org.xml.sax.DTDHandler#notationDecl
+   */
+  public void notationDecl(String name, String publicId, String systemId)
+          throws SAXException
+  {
+
+    if (m_dtdHandler != null)
+    {
+      m_dtdHandler.notationDecl(name, publicId, systemId);
+    }
+  }
+
+  /**
+   * Filter an unparsed entity declaration event.
+   *
+   * @param name The entity name.
+   * @param publicId The entity's public identifier, or null.
+   * @param systemId The entity's system identifier, or null.
+   * @param notationName The name of the associated notation.
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @see org.xml.sax.DTDHandler#unparsedEntityDecl
+   */
+  public void unparsedEntityDecl(
+          String name, String publicId, String systemId, String notationName)
+            throws SAXException
+  {
+
+    if (m_dtdHandler != null)
+    {
+      m_dtdHandler.unparsedEntityDecl(name, publicId, systemId, notationName);
+    }
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of org.xml.sax.ContentHandler.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Filter a new document locator event.
+   *
+   * @param locator The document locator.
+   * @see org.xml.sax.ContentHandler#setDocumentLocator
+   */
+  public void setDocumentLocator(Locator locator)
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#setDocumentLocator: "
+                         + locator.getSystemId());
+
+    this.m_locator = locator;
+    
+    if(null == m_baseSystemID)
+    {
+      setSystemId(locator.getSystemId());
+    }
+
+    if (m_contentHandler != null)
+    {
+      m_contentHandler.setDocumentLocator(locator);
+    }
+  }
+
+  /**
+   * Filter a start document event.
+   *
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @see org.xml.sax.ContentHandler#startDocument
+   */
+  public void startDocument() throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#startDocument");
+      
+    m_insideParse = true;
+
+    Thread listener = new Thread(m_transformer);
+
+    m_transformer.setTransformThread(listener);
+    listener.setDaemon(false);
+    listener.start();
+
+    if (m_contentHandler != null)
+    {
+      m_contentHandler.startDocument();
+    }
+  }
+
+  /**
+   * Filter an end document event.
+   *
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @see org.xml.sax.ContentHandler#endDocument
+   */
+  public void endDocument() throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#endDocument");
+
+    m_insideParse = false;
+    
+    if (m_contentHandler != null)
+    {
+      m_contentHandler.endDocument();
+    }
+    
+    Thread transformThread = m_transformer.getTransformThread();
+
+    if (null != transformThread)
+    {
+      try
+      {
+
+        // This should wait until the transformThread is considered not alive.
+        transformThread.join();
+
+        if (!m_transformer.hasTransformThreadErrorCatcher())
+        {
+          Exception e = m_transformer.getExceptionThrown();
+
+          if (null != e)
+            throw new org.xml.sax.SAXException(e);
+        }
+
+        m_transformer.setTransformThread(null);
+      }
+      catch (InterruptedException ie){}
+    }
+  }
+
+  /**
+   * Filter a start Namespace prefix mapping event.
+   *
+   * @param prefix The Namespace prefix.
+   * @param uri The Namespace URI.
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @see org.xml.sax.ContentHandler#startPrefixMapping
+   */
+  public void startPrefixMapping(String prefix, String uri)
+          throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#startPrefixMapping: "
+                         + prefix + ", " + uri);
+
+    if (m_contentHandler != null)
+    {
+      m_contentHandler.startPrefixMapping(prefix, uri);
+    }
+  }
+
+  /**
+   * Filter an end Namespace prefix mapping event.
+   *
+   * @param prefix The Namespace prefix.
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @see org.xml.sax.ContentHandler#endPrefixMapping
+   */
+  public void endPrefixMapping(String prefix) throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#endPrefixMapping: "
+                         + prefix);
+
+    if (m_contentHandler != null)
+    {
+      m_contentHandler.endPrefixMapping(prefix);
+    }
+  }
+
+  /**
+   * Filter a start element event.
+   *
+   * @param uri The element's Namespace URI, or the empty string.
+   * @param localName The element's local name, or the empty string.
+   * @param qName The element's qualified (prefixed) name, or the empty
+   *        string.
+   * @param atts The element's attributes.
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @see org.xml.sax.ContentHandler#startElement
+   */
+  public void startElement(
+          String uri, String localName, String qName, Attributes atts)
+            throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#startElement: " + qName);
+
+    if (m_contentHandler != null)
+    {
+      m_contentHandler.startElement(uri, localName, qName, atts);
+    }
+  }
+
+  /**
+   * Filter an end element event.
+   *
+   * @param uri The element's Namespace URI, or the empty string.
+   * @param localName The element's local name, or the empty string.
+   * @param qName The element's qualified (prefixed) name, or the empty
+   *        string.
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @see org.xml.sax.ContentHandler#endElement
+   */
+  public void endElement(String uri, String localName, String qName)
+          throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#endElement: " + qName);
+
+    if (m_contentHandler != null)
+    {
+      m_contentHandler.endElement(uri, localName, qName);
+    }
+  }
+
+  /**
+   * Filter a character data event.
+   *
+   * @param ch An array of characters.
+   * @param start The starting position in the array.
+   * @param length The number of characters to use from the array.
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @see org.xml.sax.ContentHandler#characters
+   */
+  public void characters(char ch[], int start, int length) throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#characters: " + start + ", "
+                         + length);
+
+    if (m_contentHandler != null)
+    {
+      m_contentHandler.characters(ch, start, length);
+    }
+  }
+
+  /**
+   * Filter an ignorable whitespace event.
+   *
+   * @param ch An array of characters.
+   * @param start The starting position in the array.
+   * @param length The number of characters to use from the array.
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @see org.xml.sax.ContentHandler#ignorableWhitespace
+   */
+  public void ignorableWhitespace(char ch[], int start, int length)
+          throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#ignorableWhitespace: "
+                         + start + ", " + length);
+
+    if (m_contentHandler != null)
+    {
+      m_contentHandler.ignorableWhitespace(ch, start, length);
+    }
+  }
+
+  /**
+   * Filter a processing instruction event.
+   *
+   * @param target The processing instruction target.
+   * @param data The text following the target.
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @see org.xml.sax.ContentHandler#processingInstruction
+   */
+  public void processingInstruction(String target, String data)
+          throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#processingInstruction: "
+                         + target + ", " + data);
+
+    if (m_contentHandler != null)
+    {
+      m_contentHandler.processingInstruction(target, data);
+    }
+  }
+
+  /**
+   * Filter a skipped entity event.
+   *
+   * @param name The name of the skipped entity.
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @see org.xml.sax.ContentHandler#skippedEntity
+   */
+  public void skippedEntity(String name) throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#skippedEntity: " + name);
+
+    if (m_contentHandler != null)
+    {
+      m_contentHandler.skippedEntity(name);
+    }
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of org.xml.sax.ErrorHandler.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Filter a warning event.
+   *
+   * @param e The nwarning as an exception.
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @see org.xml.sax.ErrorHandler#warning
+   */
+  public void warning(SAXParseException e) throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#warning: " + e);
+
+    if (m_errorHandler != null)
+    {
+      m_errorHandler.warning(e);
+    }
+  }
+
+  /**
+   * Filter an error event.
+   *
+   * @param e The error as an exception.
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @see org.xml.sax.ErrorHandler#error
+   */
+  public void error(SAXParseException e) throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#error: " + e);
+
+    if (m_errorHandler != null)
+    {
+      m_errorHandler.error(e);
+    }
+  }
+
+  /**
+   * Filter a fatal error event.
+   *
+   * @param e The error as an exception.
+   * @throws SAXException The client may throw
+   *            an exception during processing.
+   * @see org.xml.sax.ErrorHandler#fatalError
+   */
+  public void fatalError(SAXParseException e) throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#fatalError: " + e);
+
+    if (m_errorHandler != null)
+    {
+      m_errorHandler.fatalError(e);
+    }
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of org.xml.sax.ext.LexicalHandler.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Report the start of DTD declarations, if any.
+   *
+   * <p>Any declarations are assumed to be in the internal subset
+   * unless otherwise indicated by a {@link #startEntity startEntity}
+   * event.</p>
+   *
+   * <p>Note that the start/endDTD events will appear within
+   * the start/endDocument events from ContentHandler and
+   * before the first startElement event.</p>
+   *
+   * @param name The document type name.
+   * @param publicId The declared public identifier for the
+   *        external DTD subset, or null if none was declared.
+   * @param systemId The declared system identifier for the
+   *        external DTD subset, or null if none was declared.
+   * @throws SAXException The application may raise an
+   *            exception.
+   * @see #endDTD
+   * @see #startEntity
+   */
+  public void startDTD(String name, String publicId, String systemId)
+          throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#startDTD: " + name + ", "
+                         + publicId + ", " + systemId);
+
+    if (null != m_lexicalHandler)
+    {
+      m_lexicalHandler.startDTD(name, publicId, systemId);
+    }
+  }
+
+  /**
+   * Report the end of DTD declarations.
+   *
+   * @throws SAXException The application may raise an exception.
+   * @see #startDTD
+   */
+  public void endDTD() throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#endDTD");
+
+    if (null != m_lexicalHandler)
+    {
+      m_lexicalHandler.endDTD();
+    }
+  }
+
+  /**
+   * Report the beginning of an entity in content.
+   *
+   * <p><strong>NOTE:</entity> entity references in attribute
+   * values -- and the start and end of the document entity --
+   * are never reported.</p>
+   *
+   * <p>The start and end of the external DTD subset are reported
+   * using the pseudo-name "[dtd]".  All other events must be
+   * properly nested within start/end entity events.</p>
+   *
+   * <p>Note that skipped entities will be reported through the
+   * {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity}
+   * event, which is part of the ContentHandler interface.</p>
+   *
+   * @param name The name of the entity.  If it is a parameter
+   *        entity, the name will begin with '%'.
+   * @throws SAXException The application may raise an exception.
+   * @see #endEntity
+   * @see org.xml.sax.ext.DeclHandler#internalEntityDecl
+   * @see org.xml.sax.ext.DeclHandler#externalEntityDecl
+   */
+  public void startEntity(String name) throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#startEntity: " + name);
+
+    if (null != m_lexicalHandler)
+    {
+      m_lexicalHandler.startEntity(name);
+    }
+  }
+
+  /**
+   * Report the end of an entity.
+   *
+   * @param name The name of the entity that is ending.
+   * @throws SAXException The application may raise an exception.
+   * @see #startEntity
+   */
+  public void endEntity(String name) throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#endEntity: " + name);
+
+    if (null != m_lexicalHandler)
+    {
+      m_lexicalHandler.endEntity(name);
+    }
+  }
+
+  /**
+   * Report the start of a CDATA section.
+   *
+   * <p>The contents of the CDATA section will be reported through
+   * the regular {@link org.xml.sax.ContentHandler#characters
+   * characters} event.</p>
+   *
+   * @throws SAXException The application may raise an exception.
+   * @see #endCDATA
+   */
+  public void startCDATA() throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#startCDATA");
+
+    if (null != m_lexicalHandler)
+    {
+      m_lexicalHandler.startCDATA();
+    }
+  }
+
+  /**
+   * Report the end of a CDATA section.
+   *
+   * @throws SAXException The application may raise an exception.
+   * @see #startCDATA
+   */
+  public void endCDATA() throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#endCDATA");
+
+    if (null != m_lexicalHandler)
+    {
+      m_lexicalHandler.endCDATA();
+    }
+  }
+
+  /**
+   * Report an XML comment anywhere in the document.
+   *
+   * <p>This callback will be used for comments inside or outside the
+   * document element, including comments in the external DTD
+   * subset (if read).</p>
+   *
+   * @param ch An array holding the characters in the comment.
+   * @param start The starting position in the array.
+   * @param length The number of characters to use from the array.
+   * @throws SAXException The application may raise an exception.
+   */
+  public void comment(char ch[], int start, int length) throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#comment: " + start + ", "
+                         + length);
+
+    if (null != m_lexicalHandler)
+    {
+      m_lexicalHandler.comment(ch, start, length);
+    }
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of org.xml.sax.ext.DeclHandler.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Report an element type declaration.
+   *
+   * <p>The content model will consist of the string "EMPTY", the
+   * string "ANY", or a parenthesised group, optionally followed
+   * by an occurrence indicator.  The model will be normalized so
+   * that all whitespace is removed,and will include the enclosing
+   * parentheses.</p>
+   *
+   * @param name The element type name.
+   * @param model The content model as a normalized string.
+   * @throws SAXException The application may raise an exception.
+   */
+  public void elementDecl(String name, String model) throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#elementDecl: " + name + ", "
+                         + model);
+
+    if (null != m_declHandler)
+    {
+      m_declHandler.elementDecl(name, model);
+    }
+  }
+
+  /**
+   * Report an attribute type declaration.
+   *
+   * <p>Only the effective (first) declaration for an attribute will
+   * be reported.  The type will be one of the strings "CDATA",
+   * "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY",
+   * "ENTITIES", or "NOTATION", or a parenthesized token group with
+   * the separator "|" and all whitespace removed.</p>
+   *
+   * @param eName The name of the associated element.
+   * @param aName The name of the attribute.
+   * @param type A string representing the attribute type.
+   * @param valueDefault A string representing the attribute default
+   *        ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
+   *        none of these applies.
+   * @param value A string representing the attribute's default value,
+   *        or null if there is none.
+   * @throws SAXException The application may raise an exception.
+   */
+  public void attributeDecl(
+          String eName, String aName, String type, String valueDefault, String value)
+            throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#attributeDecl: " + eName
+                         + ", " + aName + ", etc...");
+
+    if (null != m_declHandler)
+    {
+      m_declHandler.attributeDecl(eName, aName, type, valueDefault, value);
+    }
+  }
+
+  /**
+   * Report an internal entity declaration.
+   *
+   * <p>Only the effective (first) declaration for each entity
+   * will be reported.</p>
+   *
+   * @param name The name of the entity.  If it is a parameter
+   *        entity, the name will begin with '%'.
+   * @param value The replacement text of the entity.
+   * @throws SAXException The application may raise an exception.
+   * @see #externalEntityDecl
+   * @see org.xml.sax.DTDHandler#unparsedEntityDecl
+   */
+  public void internalEntityDecl(String name, String value)
+          throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#internalEntityDecl: " + name
+                         + ", " + value);
+
+    if (null != m_declHandler)
+    {
+      m_declHandler.internalEntityDecl(name, value);
+    }
+  }
+
+  /**
+   * Report a parsed external entity declaration.
+   *
+   * <p>Only the effective (first) declaration for each entity
+   * will be reported.</p>
+   *
+   * @param name The name of the entity.  If it is a parameter
+   *        entity, the name will begin with '%'.
+   * @param publicId The declared public identifier of the entity, or
+   *        null if none was declared.
+   * @param systemId The declared system identifier of the entity.
+   * @throws SAXException The application may raise an exception.
+   * @see #internalEntityDecl
+   * @see org.xml.sax.DTDHandler#unparsedEntityDecl
+   */
+  public void externalEntityDecl(
+          String name, String publicId, String systemId) throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("TransformerHandlerImpl#externalEntityDecl: " + name
+                         + ", " + publicId + ", " + systemId);
+
+    if (null != m_declHandler)
+    {
+      m_declHandler.externalEntityDecl(name, publicId, systemId);
+    }
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Internal state.
+  ////////////////////////////////////////////////////////////////////
+
+  /** Set to true for diagnostics output.         */
+  private static boolean DEBUG = false;
+
+  /**
+   * The transformer this will use to transform a
+   * source tree into a result tree.
+   */
+  private TransformerImpl m_transformer;
+
+  /** The system ID to use as a base for relative URLs. */
+  private String m_baseSystemID;
+
+  /** The result for the transformation. */
+  private Result m_result = null;
+
+  /** The locator for this TransformerHandler. */
+  private Locator m_locator = null;
+
+  /** The entity resolver to aggregate to. */
+  private EntityResolver m_entityResolver = null;
+
+  /** The DTD handler to aggregate to. */
+  private DTDHandler m_dtdHandler = null;
+
+  /** The content handler to aggregate to. */
+  private ContentHandler m_contentHandler = null;
+
+  /** The error handler to aggregate to. */
+  private ErrorHandler m_errorHandler = null;
+
+  /** The lexical handler to aggregate to. */
+  private LexicalHandler m_lexicalHandler = null;
+
+  /** The decl handler to aggregate to. */
+  private DeclHandler m_declHandler = null;
+  
+  /** The Document Table Instance we are transforming. */
+  DTM m_dtm;
+}
diff --git a/src/org/apache/xalan/transformer/TransformerImpl.java b/src/org/apache/xalan/transformer/TransformerImpl.java
index 650e42a..b695f98 100644
--- a/src/org/apache/xalan/transformer/TransformerImpl.java
+++ b/src/org/apache/xalan/transformer/TransformerImpl.java
@@ -70,9 +70,6 @@
 // Xalan imports
 import org.apache.xalan.res.XSLTErrorResources;
 import org.apache.xalan.res.XSLMessages;
-import org.apache.xalan.stree.SourceTreeHandler;
-import org.apache.xalan.stree.DocumentImpl;
-import org.apache.xalan.stree.DocImpl;
 import org.apache.xalan.templates.Constants;
 import org.apache.xalan.templates.ElemAttributeSet;
 import org.apache.xalan.templates.ElemTemplateElement;
@@ -121,11 +118,15 @@
 import org.apache.xalan.serialize.Method;
 
 // DOM Imports
-import org.w3c.dom.Attr;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Document;
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.Node;
+//import org.w3c.dom.Attr;
+//import org.w3c.dom.DocumentFragment;
+//import org.w3c.dom.Document;
+//import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMManager;
+import org.apache.xml.dtm.DTMWSFilter;
 
 // SAX2 Imports
 import org.xml.sax.ContentHandler;
@@ -169,7 +170,7 @@
  * representation of the transformation execution.</p>
  */
 public class TransformerImpl extends Transformer
-        implements Runnable, TransformState
+        implements Runnable, DTMWSFilter
 {
   // Synch object to gaurd against setting values from the TrAX interface 
   // or reentry while the transform is going on.
@@ -254,15 +255,23 @@
    * ElemTemplateElement.  Needed for the 
    * org.apache.xalan.transformer.TransformState interface,  
    * so a tool can discover the calling template. */
-  NodeVector m_currentTemplateElements = new NodeVector(64);
+  Stack m_currentTemplateElements = new Stack();
 
   /** A node vector used as a stack to track the current 
-   * ElemTemplate that was matched, as well as the node that 
-   * was matched.  Needed for the 
+   * ElemTemplate that was matched.
+   * Needed for the 
    * org.apache.xalan.transformer.TransformState interface,  
-   * so a tool can discover the matched template, and matched 
+   * so a tool can discover the matched template
+   */
+  Stack m_currentMatchTemplates = new Stack();
+  
+  /** A node vector used as a stack to track the current 
+   * node that was matched.
+   * Needed for the 
+   * org.apache.xalan.transformer.TransformState interface,  
+   * so a tool can discover the matched 
    * node. */
-  NodeVector m_currentMatchTemplates = new NodeVector();
+  NodeVector m_currentMatchedNodes = new NodeVector();
 
   /**
    * The root of a linked set of stylesheets.
@@ -347,7 +356,7 @@
   /** This is needed for support of setSourceTreeDocForThread(Node doc),
    * which must be called in order for the transform thread's run 
    * method to obtain the root of the source tree to be transformed.     */
-  private Node m_doc;
+  private int m_doc;
 
   /**
    * If the the transform is on the secondary thread, we
@@ -355,8 +364,14 @@
    */
   private boolean m_isTransformDone = false;
   
+  /** Flag to to tell if the tranformer needs to be reset. */
   private boolean m_hasBeenReset = false;
   
+  /**
+   * A stack of current template modes.
+   */
+  private Stack m_modes = new Stack();
+  
   //==========================================================
   // SECTION: Constructors
   //==========================================================
@@ -403,6 +418,7 @@
       getXPathContext().getVarStack().setSize(1);
       m_currentTemplateElements.removeAllElements();
       m_currentMatchTemplates.removeAllElements();
+      m_currentMatchedNodes.removeAllElements();
   
       m_resultTreeHandler = null;
       m_outputTarget = null;
@@ -411,9 +427,9 @@
       m_countersTable = null;
       m_currentTemplateRuleIsNull = new BoolStack();
       m_xmlSource = null;
-      m_doc = null;
+      m_doc = DTM.NULL;
       m_isTransformDone = false;
-      m_inputContentHandler = null;
+      // m_inputContentHandler = null;
       
       // For now, reset the document cache each time.
       getXPathContext().getSourceTreeManager().reset();
@@ -479,155 +495,19 @@
   public void transform(Source source) 
     throws TransformerException
   {
-    if(source instanceof DOMSource)
-    {
-      DOMSource dsource = (DOMSource)source;
-      m_urlOfSource = dsource.getSystemId();
-      Node dNode = dsource.getNode();
-      if (null != dNode)
-      {  
-        if(null != m_urlOfSource)
-        {
-          // System.out.println("Putting document in cache: "+m_urlOfSource);
-          this.getXPathContext().getSourceTreeManager().putDocumentInCache(dNode, dsource);
-        }
-        this.transformNode(dsource.getNode());
-        return;
-      }
-      else
-      {
-        String messageStr = XSLMessages.createMessage(XSLTErrorResources.ER_ILLEGAL_DOMSOURCE_INPUT, null);
-        throw new IllegalArgumentException(messageStr);
-      } 
-    }
-    InputSource xmlSource = SAXSource.sourceToInputSource(source);
-    if(null == xmlSource)
-    {
-      m_errorHandler.fatalError(new TransformerException("Can't transform a Source of type "+
-        source.getClass().getName()+"!"));
-    }
-    
-    if (null != xmlSource.getSystemId())
-    {     
-      m_urlOfSource = org.apache.xml.utils.SystemIDResolver.getAbsoluteURI(xmlSource.getSystemId());
-      xmlSource.setSystemId(m_urlOfSource);
-    }
-
     try
     {
-      m_hasTransformThreadErrorCatcher = true;
-      XMLReader reader = null;
-      if(source instanceof SAXSource)
-        reader = ((SAXSource)source).getXMLReader();
-
-      if (null == reader)
-      {
-      // Use JAXP1.1 ( if possible )      
-        try {
-          javax.xml.parsers.SAXParserFactory factory=
-                                                     javax.xml.parsers.SAXParserFactory.newInstance();
-          factory.setNamespaceAware( true );
-          javax.xml.parsers.SAXParser jaxpParser=
-                                                 factory.newSAXParser();
-          reader=jaxpParser.getXMLReader();
-          
-        } catch( javax.xml.parsers.ParserConfigurationException ex ) {
-          throw new org.xml.sax.SAXException( ex );
-        } catch( javax.xml.parsers.FactoryConfigurationError ex1 ) {
-            throw new org.xml.sax.SAXException( ex1.toString() );
-        } catch( NoSuchMethodError ex2 ) {
-        }
-        catch (AbstractMethodError ame){}
-      }
-      if (null == reader)
-      {        
-        reader = XMLReaderFactory.createXMLReader();
-      }
-
+      DTMManager mgr = this.getXPathContext().getDTMManager();
+      DTM dtm = mgr.getDTM(source, false, this, true);
+      
+      boolean hardDelete = true;  // %REVIEW% I have to think about this. -sb
       try
       {
-        reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
-                          true);
-        reader.setFeature("http://apache.org/xml/features/validation/dynamic",
-                          true);
+        this.transformNode(dtm.getDocument());
       }
-      catch (org.xml.sax.SAXException se)
+      finally
       {
-        // We don't care.
-      }
-
-      // Get the input content handler, which will handle the 
-      // parse events and create the source tree. 
-      ContentHandler inputHandler = getInputContentHandler();
-
-      reader.setContentHandler(inputHandler);
-      if(inputHandler instanceof org.xml.sax.DTDHandler)
-        reader.setDTDHandler((org.xml.sax.DTDHandler)inputHandler);
-      try
-      {
-        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
-          reader.setProperty("http://xml.org/sax/properties/lexical-handler",
-                             inputHandler);
-        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
-          reader.setProperty("http://xml.org/sax/properties/declaration-handler",
-                             inputHandler);
-      }
-      catch(org.xml.sax.SAXException se) {}
-      try
-      {
-        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
-          reader.setProperty("http://xml.org/sax/handlers/LexicalHandler",
-                             inputHandler);
-        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
-          reader.setProperty("http://xml.org/sax/handlers/DeclHandler",
-                             inputHandler);
-      }
-      catch(org.xml.sax.SAXNotRecognizedException snre)
-      {
-      }
-
-      // Set the reader for cloning purposes.
-      getXPathContext().setPrimaryReader(reader);
-
-      this.m_exceptionThrown = null;
-
-      if (inputHandler instanceof SourceTreeHandler)
-      {
-        SourceTreeHandler sth = (SourceTreeHandler) inputHandler;
-
-        sth.setInputSource(source);
-        sth.setUseMultiThreading(true);
-
-        Node doc = sth.getRoot();
-
-        if (null != doc)
-        {
-          SourceTreeManager stm = getXPathContext().getSourceTreeManager();
-          stm.putDocumentInCache(doc, source);
-
-          m_xmlSource = source;
-          m_doc = doc;
-
-          if (isParserEventsOnMain())
-          {
-            m_isTransformDone = false;
-
-            getXPathContext().getPrimaryReader().parse(xmlSource);
-          }
-          else
-          {
-            Thread t = createTransformThread();
-//            m_reportInPostExceptionFromThread = false;
-            t.start();
-            transformNode(doc);
-          }
-        }
-      }
-      else
-      {
-
-        // ??
-        reader.parse(xmlSource);
+        mgr.release(dtm, hardDelete);
       }
 
       // Kick off the parse.  When the ContentHandler gets 
@@ -682,10 +562,6 @@
     {
       m_errorHandler.fatalError(new TransformerException( se ));
     }
-    catch (IOException ioe)
-    {
-      m_errorHandler.fatalError(new TransformerException( ioe ));
-    }
     finally
     {
       m_hasTransformThreadErrorCatcher = false;
@@ -880,148 +756,149 @@
     return (Properties)getOutputFormat().getProperties().clone();  
   }
 
-  /**
-   * <meta name="usage" content="internal"/>
-   * Process the an input source to a DOM node.  FOR INTERNAL USE ONLY.
-   * 
-   * @param xmlSource  The input for the source tree.
-   *
-   * @return The Node result of the parse, never null.
-   *
-   * @throws TransformerException
-   */
-  public Node parseToNode(Source source) throws TransformerException
-  {
-    if(source instanceof DOMSource)
-      return ((DOMSource)source).getNode();
-    
-    InputSource xmlSource = SAXSource.sourceToInputSource(source);
-    if(null == xmlSource)
-    {
-      throw new TransformerException("Can't transform a Source of type "+
-        source.getClass().getName()+"!");
-    }
-
-    // Duplicate code from above... but slightly different.  
-    // TODO: Work on this...
-    if (null != xmlSource.getSystemId())
-      m_urlOfSource = xmlSource.getSystemId();
-
-    Node doc = null;
-    try
-    {
-      // Get an already set XMLReader, or create one.
-      XMLReader reader = null;
-      if(source instanceof SAXSource)
-        reader = ((SAXSource)source).getXMLReader();
-
-      if (null == reader)
-      {
-        // Use JAXP1.1 ( if possible )
-        try {
-          javax.xml.parsers.SAXParserFactory factory=
-                                                     javax.xml.parsers.SAXParserFactory.newInstance();
-          factory.setNamespaceAware( true );
-          javax.xml.parsers.SAXParser jaxpParser=
-                                                 factory.newSAXParser();
-          reader=jaxpParser.getXMLReader();
-          
-        } catch( javax.xml.parsers.ParserConfigurationException ex ) {
-          throw new org.xml.sax.SAXException( ex );
-        } catch( javax.xml.parsers.FactoryConfigurationError ex1 ) {
-            throw new org.xml.sax.SAXException( ex1.toString() );
-        } catch( NoSuchMethodError ex2 ) {
-        }
-        catch (AbstractMethodError ame){}
-      }
-
-      if (null == reader)
-      {
-        reader = XMLReaderFactory.createXMLReader();
-      }
-
-      try
-      {
-        reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
-                          true);
-        reader.setFeature(
-                          "http://apache.org/xml/features/validation/dynamic", true);
-      }
-      catch (org.xml.sax.SAXException se)
-      {
-
-        // What can we do?
-        // TODO: User diagnostics.
-      }
-
-      // TODO: Handle Xerces DOM parser.
-      // Get the input content handler, which will handle the 
-      // parse events and create the source tree.
-      ContentHandler inputHandler = getInputContentHandler();
-      Class inputHandlerClass = ((Object) inputHandler).getClass();
-
-      inputHandler = (ContentHandler) inputHandlerClass.newInstance();
-
-      reader.setContentHandler(inputHandler);
-      if(inputHandler instanceof org.xml.sax.DTDHandler)
-        reader.setDTDHandler((org.xml.sax.DTDHandler)inputHandler);
-      try
-      {
-        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
-          reader.setProperty("http://xml.org/sax/properties/lexical-handler",
-                             inputHandler);
-        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
-          reader.setProperty("http://xml.org/sax/properties/declaration-handler",
-                             inputHandler);
-      }
-      catch(SAXNotRecognizedException snre){}
-      try
-      {
-        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
-          reader.setProperty("http://xml.org/sax/handlers/LexicalHandler",
-                             inputHandler);
-        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
-          reader.setProperty("http://xml.org/sax/handlers/DeclHandler",
-                             inputHandler);
-      }
-      catch(org.xml.sax.SAXNotRecognizedException snre)
-      {
-      }
-      getXPathContext().setPrimaryReader(reader);
-
-      // ...and of course I need a standard way to get a node...
-      if (inputHandler instanceof org.apache.xalan.stree.SourceTreeHandler)
-      {
-
-        // Kick off the parse.  When the ContentHandler gets 
-        // the startDocument event, it will call transformNode( node ).
-        reader.parse(xmlSource);
-
-        doc =
-             ((org.apache.xalan.stree.SourceTreeHandler) inputHandler).getRoot();
-      }
-
-    }
-    catch (java.lang.IllegalAccessException iae)
-    {
-      throw new TransformerException(iae);
-    }
-    catch (InstantiationException ie)
-    {
-      throw new TransformerException(ie);
-    }
-    catch(org.xml.sax.SAXException se)
-    {
-      throw new TransformerException(se);
-    }
-    catch (IOException ioe)
-    {
-      throw new TransformerException(ioe);
-    }
-
-
-    return doc;
-  }
+  // %REVIEW% OK to delete?  Who needs this?
+//  /**
+//   * <meta name="usage" content="internal"/>
+//   * Process the an input source to a DOM node.  FOR INTERNAL USE ONLY.
+//   * 
+//   * @param xmlSource  The input for the source tree.
+//   *
+//   * @return The Node result of the parse, never null.
+//   *
+//   * @throws TransformerException
+//   */
+//  public Node parseToNode(Source source) throws TransformerException
+//  {
+//    if(source instanceof DOMSource)
+//      return ((DOMSource)source).getNode();
+//    
+//    InputSource xmlSource = SAXSource.sourceToInputSource(source);
+//    if(null == xmlSource)
+//    {
+//      throw new TransformerException("Can't transform a Source of type "+
+//        source.getClass().getName()+"!");
+//    }
+//
+//    // Duplicate code from above... but slightly different.  
+//    // TODO: Work on this...
+//    if (null != xmlSource.getSystemId())
+//      m_urlOfSource = xmlSource.getSystemId();
+//
+//    Node doc = null;
+//    try
+//    {
+//      // Get an already set XMLReader, or create one.
+//      XMLReader reader = null;
+//      if(source instanceof SAXSource)
+//        reader = ((SAXSource)source).getXMLReader();
+//
+//      if (null == reader)
+//      {
+//        // Use JAXP1.1 ( if possible )
+//        try {
+//          javax.xml.parsers.SAXParserFactory factory=
+//                                                     javax.xml.parsers.SAXParserFactory.newInstance();
+//          factory.setNamespaceAware( true );
+//          javax.xml.parsers.SAXParser jaxpParser=
+//                                                 factory.newSAXParser();
+//          reader=jaxpParser.getXMLReader();
+//          
+//        } catch( javax.xml.parsers.ParserConfigurationException ex ) {
+//          throw new org.xml.sax.SAXException( ex );
+//        } catch( javax.xml.parsers.FactoryConfigurationError ex1 ) {
+//            throw new org.xml.sax.SAXException( ex1.toString() );
+//        } catch( NoSuchMethodError ex2 ) {
+//        }
+//        catch (AbstractMethodError ame){}
+//      }
+//
+//      if (null == reader)
+//      {
+//        reader = XMLReaderFactory.createXMLReader();
+//      }
+//
+//      try
+//      {
+//        reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
+//                          true);
+//        reader.setFeature(
+//                          "http://apache.org/xml/features/validation/dynamic", true);
+//      }
+//      catch (org.xml.sax.SAXException se)
+//      {
+//
+//        // What can we do?
+//        // TODO: User diagnostics.
+//      }
+//
+//      // TODO: Handle Xerces DOM parser.
+//      // Get the input content handler, which will handle the 
+//      // parse events and create the source tree.
+//      ContentHandler inputHandler = getInputContentHandler();
+//      Class inputHandlerClass = ((Object) inputHandler).getClass();
+//
+//      inputHandler = (ContentHandler) inputHandlerClass.newInstance();
+//
+//      reader.setContentHandler(inputHandler);
+//      if(inputHandler instanceof org.xml.sax.DTDHandler)
+//        reader.setDTDHandler((org.xml.sax.DTDHandler)inputHandler);
+//      try
+//      {
+//        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
+//          reader.setProperty("http://xml.org/sax/properties/lexical-handler",
+//                             inputHandler);
+//        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
+//          reader.setProperty("http://xml.org/sax/properties/declaration-handler",
+//                             inputHandler);
+//      }
+//      catch(SAXNotRecognizedException snre){}
+//      try
+//      {
+//        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
+//          reader.setProperty("http://xml.org/sax/handlers/LexicalHandler",
+//                             inputHandler);
+//        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
+//          reader.setProperty("http://xml.org/sax/handlers/DeclHandler",
+//                             inputHandler);
+//      }
+//      catch(org.xml.sax.SAXNotRecognizedException snre)
+//      {
+//      }
+//      getXPathContext().setPrimaryReader(reader);
+//
+//      // ...and of course I need a standard way to get a node...
+//      if (inputHandler instanceof org.apache.xalan.stree.SourceTreeHandler)
+//      {
+//
+//        // Kick off the parse.  When the ContentHandler gets 
+//        // the startDocument event, it will call transformNode( node ).
+//        reader.parse(xmlSource);
+//
+//        doc =
+//             ((org.apache.xalan.stree.SourceTreeHandler) inputHandler).getRoot();
+//      }
+//
+//    }
+//    catch (java.lang.IllegalAccessException iae)
+//    {
+//      throw new TransformerException(iae);
+//    }
+//    catch (InstantiationException ie)
+//    {
+//      throw new TransformerException(ie);
+//    }
+//    catch(org.xml.sax.SAXException se)
+//    {
+//      throw new TransformerException(se);
+//    }
+//    catch (IOException ioe)
+//    {
+//      throw new TransformerException(ioe);
+//    }
+//
+//
+//    return doc;
+//  }
 
   /**
    * Create a result ContentHandler from a Result object, based 
@@ -1057,22 +934,23 @@
   public ContentHandler createResultContentHandler(
           Result outputTarget, OutputProperties format) throws TransformerException
   {    
-    ContentHandler handler;
+    ContentHandler handler = null;
     
     // If the Result object contains a Node, then create 
     // a ContentHandler that will add nodes to the input node.
-    Node outputNode = null;
+    org.w3c.dom.Node outputNode = null;
     if(outputTarget instanceof DOMResult)
     {
       outputNode = ((DOMResult)outputTarget).getNode();
 
-      Document doc;
+      org.w3c.dom.Document doc;
       short type;
       if (null != outputNode)
       {
         type = outputNode.getNodeType();
-        doc = (Node.DOCUMENT_NODE == type)
-                       ? (Document) outputNode : outputNode.getOwnerDocument();
+        doc = (org.w3c.dom.Node.DOCUMENT_NODE == type)
+                       ? (org.w3c.dom.Document) outputNode 
+                       : outputNode.getOwnerDocument();
       }
       else
       {
@@ -1082,8 +960,8 @@
         ((DOMResult)outputTarget).setNode(outputNode);
       }
       
-      handler = (Node.DOCUMENT_FRAGMENT_NODE == type)
-                ? new DOMBuilder(doc, (DocumentFragment) outputNode)
+      handler = (org.w3c.dom.Node.DOCUMENT_FRAGMENT_NODE == type)
+                ? new DOMBuilder(doc, (org.w3c.dom.DocumentFragment) outputNode)
                   : new DOMBuilder(doc, outputNode);
     }
     else if(outputTarget instanceof SAXResult)
@@ -1165,12 +1043,13 @@
    * Process the source node to the output result, if the
    * processor supports the "http://xml.org/trax/features/dom/input"
    * feature.
-   * @param node  The input source node, which can be any valid DOM node.
+   * %REVIEW% Do we need a Node version of this?
+   * @param node  The input source node, which can be any valid DTM node.
    * @param outputTarget The output source target.
    *
    * @throws TransformerException
    */
-  public void transformNode(Node node, Result outputTarget)
+  public void transformNode(int node, Result outputTarget)
           throws TransformerException
   {
 
@@ -1185,12 +1064,13 @@
    * Process the source node to the output result, if the
    * processor supports the "http://xml.org/trax/features/dom/input"
    * feature.
-   * @param node  The input source node, which can be any valid DOM node.
+   * %REVIEW% Do we need a Node version of this?
+   * @param node  The input source node, which can be any valid DTM node.
    * @param outputTarget The output source target.
    *
    * @throws TransformerException
    */
-  public void transformNode(Node node) throws TransformerException
+  public void transformNode(int node) throws TransformerException
   {
     // Make sure we're not writing to the same output content handler.
     synchronized(m_outputContentHandler)
@@ -1229,7 +1109,7 @@
   
         // ===========
         // System.out.println("Calling applyTemplateToNode - "+Thread.currentThread().getName());
-        this.applyTemplateToNode(null, null, node, null);
+        this.applyTemplateToNode(null, null, node);
         // System.out.println("Done with applyTemplateToNode - "+Thread.currentThread().getName());
   
         if (null != m_resultTreeHandler)
@@ -1288,8 +1168,9 @@
 
     if (null == m_inputContentHandler)
     {
-      m_inputContentHandler = new SourceTreeHandler(this, doDocFrag);
-      ((SourceTreeHandler)m_inputContentHandler).setUseMultiThreading(true);
+      //      if(null == m_urlOfSource && null != m_stylesheetRoot)
+      //        m_urlOfSource = m_stylesheetRoot.getBaseIdentifier();
+      m_inputContentHandler = new TransformerHandlerImpl(this, doDocFrag, m_urlOfSource);
     }
 
     return m_inputContentHandler;
@@ -1562,7 +1443,7 @@
    * @throws TransformerException
    */
   public void pushParams(
-          XPathContext xctxt, ElemCallTemplate xslCallTemplateElement, Node sourceNode, QName mode)
+          XPathContext xctxt, ElemCallTemplate xslCallTemplateElement)
             throws TransformerException
   {
 
@@ -1587,20 +1468,22 @@
 
       if (null != param)
       {
+        int sourceNode = xctxt.getCurrentNode();
         var = param.execute(getXPathContext(), sourceNode, xslParamElement);
       }
-      else if (null == xslParamElement.getFirstChild())
+      else if (null == xslParamElement.getFirstChildElem())
       {
         var = XString.EMPTYSTRING;
       }
       else
       {
 
-        // Use result tree fragment
-        DocumentFragment df = transformToRTF(xslParamElement, sourceNode,
-                                             mode);
+         int sourceNode = xctxt.getCurrentNode();
+       // Use result tree fragment
+       // %REVIEW% Make sure current node is pushed.
+        int df = transformToRTF(xslParamElement);
 
-        var = new XRTreeFrag(df);
+        var = new XRTreeFrag(df, xctxt);
       }
 
       vars.setSearchStart(paramReferenceContext);
@@ -1641,7 +1524,7 @@
    *
    * @throws TransformerException
    */
-  protected void pushGlobalVars(Node contextNode) throws TransformerException
+  protected void pushGlobalVars(int contextNode) throws TransformerException
   {
 
     // I'm a little unhappy with this, as it seems like 
@@ -1767,56 +1650,17 @@
    *
    * @throws TransformerException
    */
-  public DocumentFragment transformToRTF(
-          ElemTemplateElement templateParent, Node sourceNode, QName mode)
+  public int transformToRTF(
+          ElemTemplateElement templateParent)
             throws TransformerException
   {
-
-    // XPathContext xctxt = getXPathContext();
-    // Document docFactory = xctxt.getDOMHelper().getDOMFactory();
-    ContentHandler rtfHandler;
-    DocumentFragment resultFragment;
+    XPathContext xctxt = getXPathContext();
     
-    // If this is an Stree instance, handle it with SourceTreeHandler
-    // and bypass the whole DOM process.
-    boolean isSTree = (sourceNode instanceof org.apache.xalan.stree.Child);
-    if (isSTree)
-    {      
-      rtfHandler = new SourceTreeHandler(this, true);
-      ((SourceTreeHandler)rtfHandler).setUseMultiThreading(false);
-      ((SourceTreeHandler)rtfHandler).setShouldTransformAtEnd(false);
-      // Create a ResultTreeFrag object.
-      resultFragment = (DocumentFragment)((SourceTreeHandler)rtfHandler).getRoot();
-      // ((org.apache.xalan.stree.DocumentFragmentImpl)resultFragment).setComplete(true);     
-    }     
-    else
-    {
-      if (null == m_docBuilder)
-      {
-        try
-        {
-          DocumentBuilderFactory dfactory =
-                                 DocumentBuilderFactory.newInstance();
+    DTM dtmFrag = xctxt.getDTM(null, true, this, false);
+    ContentHandler rtfHandler = dtmFrag.getContentHandler();
 
-          dfactory.setNamespaceAware(true);
-          dfactory.setValidating(true);
-
-          m_docBuilder = dfactory.newDocumentBuilder();
-        }
-        catch (ParserConfigurationException pce)
-        {
-          throw new TransformerException(pce);  //"createDocument() not supported in XPathContext!");
-
-          // return null;
-        }
-      }     
-      Document docFactory = m_docBuilder.newDocument();
-      // Create a ResultTreeFrag object.
-      resultFragment = docFactory.createDocumentFragment();           
-      // Create a DOMBuilder object that will handle the SAX events 
-      // and build the ResultTreeFrag nodes.
-      rtfHandler = new DOMBuilder(docFactory, resultFragment);
-    }
+    // Create a ResultTreeFrag object.
+    int resultFragment = resultFragment = dtmFrag.getDocument();
 
     // Save the current result tree handler.
     ResultTreeHandler savedRTreeHandler = this.m_resultTreeHandler;
@@ -1832,7 +1676,7 @@
       try
       {
         // Do the transformation of the child elements.
-        executeChildTemplates(templateParent, sourceNode, mode, true);
+        executeChildTemplates(templateParent, true);
         
         // Make sure everything is flushed!
         rth.flushPending();
@@ -1849,8 +1693,8 @@
 
     finally
     {
-    // Restore the previous result tree handler.
-    this.m_resultTreeHandler = savedRTreeHandler;
+      // Restore the previous result tree handler.
+      this.m_resultTreeHandler = savedRTreeHandler;
     }
     
     return resultFragment;
@@ -1885,7 +1729,7 @@
    * @throws TransformerException
    */
   public String transformToString(
-          ElemTemplateElement elem, Node sourceNode, QName mode)
+          ElemTemplateElement elem)
             throws TransformerException
   {
 
@@ -1916,7 +1760,7 @@
       }
       else
       {
-
+        // Leave Commented.  -sb
         // serializer.setWriter(sw);
         // serializer.setOutputFormat(m_textformat);
         // ContentHandler shandler = serializer.asContentHandler();
@@ -1935,7 +1779,7 @@
       this.m_resultTreeHandler.startDocument();
 
       // Do the transformation of the child elements.
-      executeChildTemplates(elem, sourceNode, mode, true);
+      executeChildTemplates(elem, true);
       this.m_resultTreeHandler.endDocument();
 
       result = sw.toString();
@@ -1978,12 +1822,11 @@
    * @return true if applied a template, false if not.
    */
   public boolean applyTemplateToNode(ElemTemplateElement xslInstruction,  // xsl:apply-templates or xsl:for-each
-                                     ElemTemplateElement template,  // may be null
-                                             Node child, QName mode)
+                                     ElemTemplateElement template, int child)
                                                      throws TransformerException
   {
-
-    short nodeType = child.getNodeType();
+    DTM dtm = m_xcontext.getDTM(child);
+    short nodeType =  dtm.getNodeType(child);
     boolean isDefaultTextRule = false;
 
     if (null == template)
@@ -2011,6 +1854,8 @@
       try
       {
         xctxt.setNamespaceContext(xslInstruction);
+
+        QName mode = this.getMode();
         template = m_stylesheetRoot.getTemplateComposed(xctxt, child, mode, maxImportLevel,
                                   m_quietConflictWarnings);
       }
@@ -2025,17 +1870,17 @@
       {
         switch (nodeType)
         {
-        case Node.DOCUMENT_FRAGMENT_NODE :
-        case Node.ELEMENT_NODE :
+        case DTM.DOCUMENT_FRAGMENT_NODE :
+        case DTM.ELEMENT_NODE :
           template = m_stylesheetRoot.getDefaultRule();
           break;
-        case Node.CDATA_SECTION_NODE :
-        case Node.TEXT_NODE :
-        case Node.ATTRIBUTE_NODE :
+        case DTM.CDATA_SECTION_NODE :
+        case DTM.TEXT_NODE :
+        case DTM.ATTRIBUTE_NODE :
           template = m_stylesheetRoot.getDefaultTextRule();
           isDefaultTextRule = true;
           break;
-        case Node.DOCUMENT_NODE :
+        case DTM.DOCUMENT_NODE :
           template = m_stylesheetRoot.getDefaultRootRule();
           break;
         default :
@@ -2058,27 +1903,22 @@
       {
         switch (nodeType)
         {
-        case Node.CDATA_SECTION_NODE :
-        case Node.TEXT_NODE :
+        case DTM.CDATA_SECTION_NODE :
+        case DTM.TEXT_NODE :
           m_resultTreeHandler.m_cloner.cloneToResultTree(child, false);
           break;
-        case Node.ATTRIBUTE_NODE :
-        {
-          String val = ((Attr) child).getValue();
-
-          getResultTreeHandler().characters(val.toCharArray(), 0,
-                                            val.length());
-        }
-        break;
+        case DTM.ATTRIBUTE_NODE :
+          dtm.dispatchCharactersEvents(child, getResultTreeHandler());
+          break;
         }
       }
       else
       {
 
         // Fire a trace event for the template.
-
-        if (TransformerImpl.S_DEBUG)
-          getTraceManager().fireTraceEvent(child, mode, template);
+        // 
+//        if (TransformerImpl.S_DEBUG)
+//          getTraceManager().fireTraceEvent(child, mode, template);
 
         // And execute the child templates.
         // 9/11/00: If template has been compiled, hand off to it
@@ -2092,10 +1932,7 @@
 
         m_xcontext.setSAXLocator(template);
 
-        if (template.isCompiledTemplate())
-          template.execute(this, child, mode);
-        else
-          executeChildTemplates(template, child, mode, true);
+        executeChildTemplates(template, true);
       }
     }
     catch(org.xml.sax.SAXException se)
@@ -2111,10 +1948,11 @@
 
     return true;
   }
-
+  
   /**
    * <meta name="usage" content="advanced"/>
-   * Execute each of the children of a template element.
+   * Execute each of the children of a template element.  This method 
+   * is only for extension use.
    *
    * @param elem The ElemTemplateElement that contains the children 
    * that should execute.
@@ -2126,7 +1964,39 @@
    * @throws TransformerException
    */
   public void executeChildTemplates(
-          ElemTemplateElement elem, Node sourceNode, QName mode, ContentHandler handler)
+          ElemTemplateElement elem, org.w3c.dom.Node context, QName mode, 
+           ContentHandler handler)
+            throws TransformerException
+  {
+    XPathContext xctxt = getXPathContext();
+    try
+    {
+      xctxt.pushCurrentNode(
+           xctxt.getDTMHandleFromNode(context));
+             
+      executeChildTemplates( elem, handler);
+    }
+    finally
+    {
+      xctxt.popCurrentNode();
+      if(null != mode)
+        popMode();
+    }
+  }
+
+  /**
+   * <meta name="usage" content="advanced"/>
+   * Execute each of the children of a template element.
+   *
+   * @param elem The ElemTemplateElement that contains the children 
+   * that should execute.
+   * @param handler The ContentHandler to where the result events 
+   * should be fed.
+   * 
+   * @throws TransformerException
+   */
+  public void executeChildTemplates(
+          ElemTemplateElement elem, ContentHandler handler)
             throws TransformerException
   {
 
@@ -2142,7 +2012,8 @@
     {
       getResultTreeHandler().flushPending();
       this.setContentHandler(handler);
-      executeChildTemplates(elem, sourceNode, mode, true);
+      // %REVIEW% Make sure current node is being pushed.
+      executeChildTemplates(elem, true);
     }
     catch(org.xml.sax.SAXException se)
     {
@@ -2173,7 +2044,7 @@
    * @throws TransformerException
    */
   public void executeChildTemplates(
-          ElemTemplateElement elem, Node sourceNode, QName mode, boolean shouldAddAttrs)
+          ElemTemplateElement elem, boolean shouldAddAttrs)
             throws TransformerException
   {
 
@@ -2189,7 +2060,7 @@
     boolean check = (m_stackGuard.m_recursionLimit > -1);
 
     if (check)
-      getStackGuard().push(elem, sourceNode);
+      getStackGuard().push(elem, xctxt.getCurrentNode());
 
     // We need to push an element frame in the variables stack, 
     // so all the variables can be popped at once when we're done.
@@ -2211,8 +2082,8 @@
         if(!shouldAddAttrs && t.getXSLToken() == Constants.ELEMNAME_ATTRIBUTE)
           continue;
         xctxt.setSAXLocator(t);
-        m_currentTemplateElements.setTail(t);
-        t.execute(this, sourceNode, mode);
+        m_currentTemplateElements.setElementAt(t, m_currentTemplateElements.size()-1);
+        t.execute(this);
       }
     }
     finally
@@ -2243,7 +2114,7 @@
    * @throws TransformerException
    */
   public Vector processSortKeys(
-                                ElemForEach foreach, Node sourceNodeContext)
+                                ElemForEach foreach, int sourceNodeContext)
     throws TransformerException
   {
 
@@ -2338,7 +2209,7 @@
    */
   public void pushElemTemplateElement(ElemTemplateElement elem)
   {
-    m_currentTemplateElements.push(elem);
+     m_currentTemplateElements.push(elem);
   }
 
   /**
@@ -2358,7 +2229,7 @@
    */
   public void setCurrentElement(ElemTemplateElement e)
   {
-    m_currentTemplateElements.setTail(e);
+    m_currentTemplateElements.setElementAt(e, m_currentTemplateElements.size()-1);
   }
 
   /**
@@ -2370,7 +2241,7 @@
    */
   public ElemTemplateElement getCurrentElement()
   {
-    return (ElemTemplateElement) m_currentTemplateElements.peepTail();
+    return (ElemTemplateElement) m_currentTemplateElements.peek();
   }
 
   /**
@@ -2379,7 +2250,7 @@
    *
    * @return The current context node (should never be null?).
    */
-  public Node getCurrentNode()
+  public int getCurrentNode()
   {
     return m_xcontext.getCurrentNode();
   }
@@ -2416,9 +2287,10 @@
    * @param template xsl:template or xsl:for-each.
    * @param child The child that was matched.
    */
-  public void pushPairCurrentMatched(ElemTemplateElement template, Node child)
+  public void pushPairCurrentMatched(ElemTemplateElement template, int child)
   {
-    m_currentMatchTemplates.pushPair(template, child);
+    m_currentMatchTemplates.push(template);
+    m_currentMatchedNodes.push(child);
   }
 
   /**
@@ -2426,7 +2298,8 @@
    */
   public void popCurrentMatched()
   {
-    m_currentMatchTemplates.popPair();
+    m_currentMatchTemplates.pop();
+    m_currentMatchedNodes.pop();
   }
 
   /**
@@ -2440,7 +2313,7 @@
    */
   public ElemTemplate getMatchedTemplate()
   {
-    return (ElemTemplate) m_currentMatchTemplates.peepTailSub1();
+    return (ElemTemplate) m_currentMatchTemplates.peek();
   }
 
   /**
@@ -2450,9 +2323,9 @@
    * @return The matched node that corresponds to the 
    * match attribute of the current xsl:template.
    */
-  public Node getMatchedNode()
+  public int getMatchedNode()
   {
-    return m_currentMatchTemplates.peepTail();
+    return m_currentMatchedNodes.peepTail();
   }
 
   /**
@@ -2460,7 +2333,7 @@
    *
    * @return A reset clone of the context node list.
    */
-  public NodeIterator getContextNodeList()
+  public DTMIterator getContextNodeList()
   {
 
     try
@@ -2825,6 +2698,25 @@
 
     throw new SAXNotRecognizedException(name);
   }
+  
+  // %TODO% Doc
+  public QName getMode()
+  {
+    return m_modes.isEmpty() ? null : (QName)m_modes.peek();
+  }
+  
+  // %TODO% Doc
+  public void pushMode(QName mode)
+  {
+    m_modes.push(mode);
+  }
+  
+  // %TODO% Doc
+  public void popMode()
+  {
+    m_modes.pop();
+  }
+
 
   ////////////////////////
   // Implement Runnable //  
@@ -2857,15 +2749,39 @@
   }
 
   /**
+   * Set the exception thrown by the secondary thread (normally 
+   * the transform thread).
+   *
+   * @param e The thrown exception, or null if no exception was 
+   * thrown.
+   */
+  public void setExceptionThrown(Exception e)
+  {
+    m_exceptionThrown = e;
+  }
+
+  /**
    * This is just a way to set the document for run().
    *
    * @param doc A non-null reference to the root of the 
    * tree to be transformed.
    */
-  public void setSourceTreeDocForThread(Node doc)
+  public void setSourceTreeDocForThread(int doc)
   {
     m_doc = doc;
   }
+  
+  
+  /** Set the input source for the source tree, which is needed if the 
+   * parse thread is not the main thread, in order for the parse 
+   * thread's run method to get to the input source.  
+   * 
+   * @param source The input source for the source tree.
+   */
+  public void setXMLSource(Source source)
+  {
+    m_xmlSource = source;
+  }
 
   /**
    * Tell if the transform method is completed.
@@ -2882,6 +2798,20 @@
   }
 
   /**
+   * Set if the transform method is completed.
+   *
+   * @param done True if transformNode has completed, or 
+   * an exception was thrown.
+   */
+  public void setIsTransformDone(boolean done)
+  {
+    synchronized(this)
+    {
+      m_isTransformDone = done;
+    }
+  }
+
+  /**
    * From a secondary thread, post the exception, so that
    * it can be picked up from the main thread.
    *
@@ -2895,19 +2825,20 @@
 //      // Consider re-throwing the exception if this flag is set.
 //      e.printStackTrace();
 //    }
-      
-    if (m_inputContentHandler instanceof SourceTreeHandler)
-    {
-      SourceTreeHandler sth = (SourceTreeHandler) m_inputContentHandler;
-
-      sth.setExceptionThrown(e);
-    }
+  
+    // %REVIEW Need DTM equivelent?    
+//    if (m_inputContentHandler instanceof SourceTreeHandler)
+//    {
+//      SourceTreeHandler sth = (SourceTreeHandler) m_inputContentHandler;
+//
+//      sth.setExceptionThrown(e);
+//    }
     ContentHandler ch = getContentHandler();
-    if(ch instanceof SourceTreeHandler)
-    {
-      SourceTreeHandler sth = (SourceTreeHandler) ch;
-      ((TransformerImpl)(sth.getTransformer())).postExceptionFromThread(e);
-    }
+//    if(ch instanceof SourceTreeHandler)
+//    {
+//      SourceTreeHandler sth = (SourceTreeHandler) ch;
+//      ((TransformerImpl)(sth.getTransformer())).postExceptionFromThread(e);
+//    }
 
     m_isTransformDone = true;
     m_exceptionThrown = e;
@@ -2943,39 +2874,38 @@
 
     try
     {
-      // Node n = ((SourceTreeHandler)getInputContentHandler()).getRoot();
+      // int n = ((SourceTreeHandler)getInputContentHandler()).getDTMRoot();
       // transformNode(n);
-      if (isParserEventsOnMain())
+      try
       {
-        try
-        {
-          m_isTransformDone = false;
-
-          transformNode(m_doc);
-        }
-        catch (Exception e)
-        {
-          // Strange that the other catch won't catch this...
-          postExceptionFromThread(e);
-        }
-        finally
-        {
-          m_isTransformDone = true;
-
-          synchronized (this)
-          {
-            notifyAll();
-          }
-        }
+        m_isTransformDone = false;
+        
+        transformNode(m_doc);
       }
-      else
+      catch (Exception e)
       {
-        InputSource isource = SAXSource.sourceToInputSource(m_xmlSource);
-        getXPathContext().getPrimaryReader().parse(isource);
+        e.printStackTrace();
+        // Strange that the other catch won't catch this...
+        postExceptionFromThread(e);
+      }
+      finally
+      {
+        m_isTransformDone = true;
+
+        if(m_inputContentHandler instanceof TransformerHandlerImpl)
+        {
+          ((TransformerHandlerImpl)m_inputContentHandler).clearCoRoutine();
+        }
+
+//        synchronized (this)
+//        {
+//          notifyAll();
+//        }
       }
     }
     catch (Exception e)
     {
+      // e.printStackTrace();
       postExceptionFromThread(e);
     }
   }
@@ -3000,5 +2930,40 @@
   {
   }
   
+  /**
+   * Test whether whitespace-only text nodes are visible in the logical 
+   * view of <code>DTM</code>. Normally, this function
+   * will be called by the implementation of <code>DTM</code>; 
+   * it is not normally called directly from
+   * user code.
+   * 
+   * @param elementHandle int Handle of the element.
+   * @return one of NOTSTRIP, STRIP, or INHERIT.
+   */
+  public short getShouldStripSpace(int elementHandle)
+  {
+    try
+    {      
+      org.apache.xalan.templates.WhiteSpaceInfo info = 
+        m_stylesheetRoot.getWhiteSpaceInfo(m_xcontext, elementHandle);
+         
+      if (null == info)
+      {
+        return DTMWSFilter.INHERIT;
+      }
+      else
+      {
+        // System.out.println("getShouldStripSpace: "+info.getShouldStripSpace());
+        return info.getShouldStripSpace() ? DTMWSFilter.STRIP : DTMWSFilter.NOTSTRIP;
+      }
+    }
+    catch (TransformerException se)
+    {
+      return DTMWSFilter.INHERIT;
+    }
+
+  }
+
+  
 }  // end TransformerImpl class
 
diff --git a/src/org/apache/xalan/transformer/TreeWalker2Result.java b/src/org/apache/xalan/transformer/TreeWalker2Result.java
index 23ee50d..117752e 100644
--- a/src/org/apache/xalan/transformer/TreeWalker2Result.java
+++ b/src/org/apache/xalan/transformer/TreeWalker2Result.java
@@ -56,11 +56,12 @@
  */
 package org.apache.xalan.transformer;
 
-import org.w3c.dom.*;
+//import org.w3c.dom.*;
+import org.apache.xml.dtm.DTM;
 
 import org.xml.sax.*;
 
-import org.apache.xml.utils.TreeWalker;
+import org.apache.xml.dtm.DTMTreeWalker;
 import org.apache.xml.utils.MutableAttrListImpl;
 import org.apache.xalan.templates.ElemTemplateElement;
 import org.apache.xpath.DOMHelper;
@@ -70,7 +71,7 @@
  * Handle a walk of a tree, but screen out attributes for
  * the result tree.
  */
-public class TreeWalker2Result extends TreeWalker
+public class TreeWalker2Result extends DTMTreeWalker
 {
 
   /** The transformer instance          */
@@ -80,7 +81,7 @@
   ResultTreeHandler m_handler;
 
   /** Node where to start the tree walk           */
-  Node m_startNode;
+  int m_startNode;
 
   /**
    * Constructor.
@@ -92,7 +93,7 @@
                            ResultTreeHandler handler)
   {
 
-    super(handler, transformer.getXPathContext().getDOMHelper());
+    super(handler, null);
 
     m_transformer = transformer;
     m_handler = handler;
@@ -105,9 +106,9 @@
    *
    * @throws TransformerException
    */
-  public void traverse(Node pos) throws org.xml.sax.SAXException
+  public void traverse(int pos) throws org.xml.sax.SAXException
   {
-
+    m_dtm = m_transformer.getXPathContext().getDTM(pos);
     m_startNode = pos;
 
     super.traverse(pos);
@@ -121,95 +122,42 @@
    *
    * @throws TransformerException
    */
-  protected void startNode(Node node) throws org.xml.sax.SAXException
+  protected void startNode(int node) throws org.xml.sax.SAXException
   {
 
     try
     {
-      if ((Node.ELEMENT_NODE == node.getNodeType()) && (m_startNode == node))
+      
+      if (DTM.ELEMENT_NODE == m_dtm.getNodeType(node))
       {
-        DOMHelper dhelper = m_transformer.getXPathContext().getDOMHelper();
-        String elemName = node.getNodeName();
-        String localName = dhelper.getLocalNameOfNode(node);
-        String namespace = dhelper.getNamespaceOfNode(node);
-
+        String elemName = m_dtm.getNodeName(node);
+        String localName = m_dtm.getLocalName(node);
+        String namespace = m_dtm.getNamespaceURI(node);
+        
         m_handler.startElement(namespace, localName, elemName, null);
 
-        for (Node parent = node; parent != null;
-             parent = parent.getParentNode())
+        if (DTM.ELEMENT_NODE == m_dtm.getNodeType(node))
         {
-          if (Node.ELEMENT_NODE != parent.getNodeType())
-            continue;
-
-          NamedNodeMap atts = ((Element) parent).getAttributes();
-          int n = atts.getLength();
-
-          for (int i = 0; i < n; i++)
+          boolean hasNSDecls = false;
+          DTM dtm = m_dtm;
+          for (int ns = dtm.getFirstNamespaceNode(node, true); 
+               DTM.NULL != ns; ns = dtm.getNextNamespaceNode(node, ns, true))
           {
-            String nsDeclPrefix = null;
-            Attr attr = (Attr) atts.item(i);
-            String name = attr.getName();
-            String value = attr.getValue();
-
-            if (name.startsWith("xmlns:"))
-            {
-
-              // get the namespace prefix 
-              nsDeclPrefix = name.substring(name.indexOf(":") + 1);
-            }
-            else if (name.equals("xmlns"))
-            {
-              nsDeclPrefix = "";
-            }
-
-            if ((nsDeclPrefix == null) && (node != parent))
-              continue;
-
-            /*
-            else if(nsDeclPrefix != null)
-            {
-            String desturi = m_processor.getURI(nsDeclPrefix);
-            // Look for an alias for this URI. If one is found, use it as the result URI
-            String aliasURI = m_elem.m_stylesheet.lookForAlias(value);
-            if(aliasURI.equals(desturi)) // TODO: Check for extension namespaces
-            {
-            continue;
-            }
-            }
-            */
-            m_handler.addAttribute(dhelper.getNamespaceOfNode(attr),
-                                   dhelper.getLocalNameOfNode(attr), name,
-                                   "CDATA", value);
-
-            // Make sure namespace is not in the excluded list then
-            // add to result tree
-
-            /*
-            if(!m_handler.getPendingAttributes().contains(name))
-            {
-            if(nsDeclPrefix == null)
-            {
-            m_handler.addAttribute(name, "CDATA", value);
-            }
-            else
-            {
-            String desturi
-            = m_handler.getURI(nsDeclPrefix);
-            if(null == desturi)
-            {
-            m_handler.addAttribute(name, "CDATA", value);
-            }
-            else if(!desturi.equals(value))
-            {
-            m_handler.addAttribute(name, "CDATA", value);
-            }
-            }
-            }
-            */
+            m_handler.ensureNamespaceDeclDeclared(dtm, ns);
           }
+          
+          if(hasNSDecls)
+          {
+            m_handler.addNSDeclsToAttrs();
+          }
+          
+          for (int attr = dtm.getFirstAttribute(node); 
+               DTM.NULL != attr; attr = dtm.getNextAttribute(attr))
+          {
+            m_handler.addAttribute(attr);
+          }
+          
         }
-
-        // m_handler.processResultNS(m_elem);           
       }
       else
       {
diff --git a/src/org/apache/xalan/xslt/Process.java b/src/org/apache/xalan/xslt/Process.java
index 1553e4d..ce988e6 100644
--- a/src/org/apache/xalan/xslt/Process.java
+++ b/src/org/apache/xalan/xslt/Process.java
@@ -105,12 +105,13 @@
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.URIResolver;
-
 import javax.xml.transform.dom.*;
 import javax.xml.transform.sax.*;
 import javax.xml.parsers.*;
+
 import org.w3c.dom.Node;
 import org.w3c.dom.Document;
+
 import org.xml.sax.InputSource;
 import org.xml.sax.EntityResolver;
 import org.xml.sax.ContentHandler;
@@ -144,6 +145,7 @@
     // System.out.println(resbundle.getString("optionE")); //"   [-E (Do not expand entity refs)]");
     System.out.println(resbundle.getString("optionV"));  //"   [-V (Version info)]");
     System.out.println(resbundle.getString("optionQC"));  //"   [-QC (Quiet Pattern Conflicts Warnings)]");
+
     // System.out.println(resbundle.getString("optionQ"));  //"   [-Q  (Quiet Mode)]"); // sc 28-Feb-01 commented out
     System.out.println(resbundle.getString("optionTT"));  //"   [-TT (Trace the templates as they are being called.)]");
     System.out.println(resbundle.getString("optionTG"));  //"   [-TG (Trace each generation event.)]");
@@ -157,19 +159,20 @@
     System.out.println(resbundle.getString("optionTEXT"));  //"   [-TEXT (Use simple Text formatter.)]");
     System.out.println(resbundle.getString("optionHTML"));  //"   [-HTML (Use HTML formatter.)]");
     System.out.println(resbundle.getString("optionPARAM"));  //"   [-PARAM name expression (Set a stylesheet parameter)]");
+
     // sc 28-Feb-01 these below should really be added as resources
     System.out.println(
       "   [-MEDIA mediaType (use media attribute to find stylesheet associated with a document.)]");
     System.out.println(
-      "   [-FLAVOR flavorName (Explicitly use s2s=SAX or d2d=DOM to do transform.)]"); // Added by sboag/scurcuru; experimental
+      "   [-FLAVOR flavorName (Explicitly use s2s=SAX or d2d=DOM to do transform.)]");  // Added by sboag/scurcuru; experimental
     System.out.println(
       "   [-DIAG (Print overall milliseconds transform took.)]");
-		System.out.println(resbundle.getString("optionURIRESOLVER"));  //"   [-URIRESOLVER full class name (URIResolver to be used to resolve URIs)]");
-		System.out.println(resbundle.getString("optionENTITYRESOLVER"));  //"   [-ENTITYRESOLVER full class name (EntityResolver to be used to resolve entities)]");
-		System.out.println(resbundle.getString("optionCONTENTHANDLER"));  //"   [-CONTENTHANDLER full class name (ContentHandler to be used to serialize output)]");
+    System.out.println(resbundle.getString("optionURIRESOLVER"));  //"   [-URIRESOLVER full class name (URIResolver to be used to resolve URIs)]");
+    System.out.println(resbundle.getString("optionENTITYRESOLVER"));  //"   [-ENTITYRESOLVER full class name (EntityResolver to be used to resolve entities)]");
+    System.out.println(resbundle.getString("optionCONTENTHANDLER"));  //"   [-CONTENTHANDLER full class name (ContentHandler to be used to serialize output)]");
   }
 
-  /** Default properties file          */
+  /** Default properties file */
   static String XSLT_PROPERTIES = "/org/apache/xalan/res/XSLTInfo.properties";
 
   /**
@@ -199,7 +202,6 @@
     XSLTErrorResources resbundle =
       (XSLTErrorResources) (XSLMessages.loadResourceBundle(
         org.apache.xml.utils.res.XResourceBundle.ERROR_RESOURCES));
-        
     String flavor = "s2s";
 
     // loadPropertyFileToSystem(XSLT_PROPERTIES);
@@ -238,9 +240,9 @@
       String media = null;
       Vector params = new Vector();
       boolean quietConflictWarnings = false;
-			URIResolver uriResolver = null;
-			EntityResolver entityResolver = null;
-			ContentHandler contentHandler = null;
+      URIResolver uriResolver = null;
+      EntityResolver entityResolver = null;
+      ContentHandler contentHandler = null;
 
       for (int i = 0; i < argv.length; i++)
       {
@@ -366,7 +368,7 @@
                 XSLTErrorResources.ER_MISSING_ARG_FOR_OPTION,
                 new Object[]{ "-PARAM" }));  //"Missing argument for);
         }
-        else if ("-treedump".equalsIgnoreCase(argv[i])) // sc 28-Feb-01 appears to be unused; can we remove?
+        else if ("-treedump".equalsIgnoreCase(argv[i]))  // sc 28-Feb-01 appears to be unused; can we remove?
         {
           if (i + 1 < argv.length)
             treedumpFileName = argv[++i];
@@ -376,7 +378,7 @@
                 XSLTErrorResources.ER_MISSING_ARG_FOR_OPTION,
                 new Object[]{ "-treedump" }));  //"Missing argument for);
         }
-        else if ("-F".equalsIgnoreCase(argv[i])) // sc 28-Feb-01 appears to be unused; can we remove?
+        else if ("-F".equalsIgnoreCase(argv[i]))  // sc 28-Feb-01 appears to be unused; can we remove?
         {
           formatOutput = true;
         }
@@ -444,81 +446,88 @@
             dumpFileName = argv[++i];
           }
         }
-				else if ("-URIRESOLVER".equalsIgnoreCase(argv[i])) 
+        else if ("-URIRESOLVER".equalsIgnoreCase(argv[i]))
         {
           if (i + 1 < argv.length)
-					{	
-						try{
-							uriResolver = (URIResolver)Class.forName(argv[++i]).newInstance();
-							tfactory.setURIResolver(uriResolver);
-						}
-						catch(Exception cnfe)
-						{
-							System.err.println(
-              XSLMessages.createMessage(
-                XSLTErrorResources.ER_CLASS_NOT_FOUND_FOR_OPTION,
-                new Object[]{ "-URIResolver" })); 
-							System.exit(-1);
-						}
-					}
-					else
-					{
+          {
+            try
+            {
+              uriResolver =
+                (URIResolver) Class.forName(argv[++i]).newInstance();
+
+              tfactory.setURIResolver(uriResolver);
+            }
+            catch (Exception cnfe)
+            {
+              System.err.println(
+                XSLMessages.createMessage(
+                  XSLTErrorResources.ER_CLASS_NOT_FOUND_FOR_OPTION,
+                  new Object[]{ "-URIResolver" }));
+              System.exit(-1);
+            }
+          }
+          else
+          {
             System.err.println(
               XSLMessages.createMessage(
                 XSLTErrorResources.ER_MISSING_ARG_FOR_OPTION,
                 new Object[]{ "-URIResolver" }));  //"Missing argument for);
-						System.exit(-1);
-					}
-				}
-				else if ("-ENTITYRESOLVER".equalsIgnoreCase(argv[i])) 
+            System.exit(-1);
+          }
+        }
+        else if ("-ENTITYRESOLVER".equalsIgnoreCase(argv[i]))
         {
           if (i + 1 < argv.length)
-					{	
-						try{
-							entityResolver = (EntityResolver)Class.forName(argv[++i]).newInstance();							
-						}
-						catch(Exception cnfe)
-						{
-							System.err.println(
-              XSLMessages.createMessage(
-                XSLTErrorResources.ER_CLASS_NOT_FOUND_FOR_OPTION,
-                new Object[]{ "-EntityResolver" }));
-							System.exit(-1);
-						}
-					}
+          {
+            try
+            {
+              entityResolver =
+                (EntityResolver) Class.forName(argv[++i]).newInstance();
+            }
+            catch (Exception cnfe)
+            {
+              System.err.println(
+                XSLMessages.createMessage(
+                  XSLTErrorResources.ER_CLASS_NOT_FOUND_FOR_OPTION,
+                  new Object[]{ "-EntityResolver" }));
+              System.exit(-1);
+            }
+          }
           else
-					{
+          {
             System.err.println(
               XSLMessages.createMessage(
                 XSLTErrorResources.ER_MISSING_ARG_FOR_OPTION,
                 new Object[]{ "-EntityResolver" }));  //"Missing argument for);
-						System.exit(-1);
-					}
+            System.exit(-1);
+          }
         }
-				else if ("-CONTENTHANDLER".equalsIgnoreCase(argv[i])) 
+        else if ("-CONTENTHANDLER".equalsIgnoreCase(argv[i]))
         {
           if (i + 1 < argv.length)
-					{	
-						try{
-							contentHandler = (ContentHandler)Class.forName(argv[++i]).newInstance();							
-						}
-						catch(Exception cnfe)
-						{
-							System.err.println(
-              XSLMessages.createMessage(
-                XSLTErrorResources.ER_CLASS_NOT_FOUND_FOR_OPTION,
-                new Object[]{ "-ContentHandler" }));
-							System.exit(-1);
-						}
-					}
+          {
+            try
+            {
+              contentHandler =
+                (ContentHandler) Class.forName(argv[++i]).newInstance();
+            }
+            catch (Exception cnfe)
+            {
+              System.err.println(
+                XSLMessages.createMessage(
+                  XSLTErrorResources.ER_CLASS_NOT_FOUND_FOR_OPTION,
+                  new Object[]{ "-ContentHandler" }));
+              System.exit(-1);
+            }
+          }
           else
-					{
+          {
             System.err.println(
               XSLMessages.createMessage(
                 XSLTErrorResources.ER_MISSING_ARG_FOR_OPTION,
                 new Object[]{ "-ContentHandler" }));  //"Missing argument for);
-						System.exit(-1);
-					}
+            System.exit(-1);
+          }
         }
         else
           System.err.println(
@@ -536,26 +545,37 @@
         {
           dumpWriter = new PrintWriter(new FileWriter(dumpFileName));
         }
+
         Templates stylesheet = null;
-        if(null != xslFileName)
+
+        if (null != xslFileName)
         {
-          if(flavor.equals("d2d"))
+          if (flavor.equals("d2d"))
           {
+
             // Parse in the xml data into a DOM
-            DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
+            DocumentBuilderFactory dfactory =
+              DocumentBuilderFactory.newInstance();
+
             dfactory.setNamespaceAware(true);
+
             DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
-						Node xslDOM = docBuilder.parse(new InputSource(xslFileName));
-            stylesheet = tfactory.newTemplates(new DOMSource(xslDOM, xslFileName));
+            Node xslDOM = docBuilder.parse(new InputSource(xslFileName));
+
+            stylesheet = tfactory.newTemplates(new DOMSource(xslDOM,
+                    xslFileName));
           }
           else
-          { 
+          {
+            System.out.println("Calling newTemplates: "+xslFileName);
             stylesheet = tfactory.newTemplates(new StreamSource(xslFileName));
+            System.out.println("Done calling newTemplates: "+xslFileName);
           }
         }
-          
+
         PrintWriter resultWriter;
         StreamResult strResult;
+
         if (null != outFileName)
         {
           strResult = new StreamResult(new File(outFileName));
@@ -565,39 +585,38 @@
           strResult = new StreamResult(System.out);
         }
 
-
-        SAXTransformerFactory stf = (SAXTransformerFactory)tfactory;
+        SAXTransformerFactory stf = (SAXTransformerFactory) tfactory;
 
         // Did they pass in a stylesheet, or should we get it from the 
         // document?
         if (null == stylesheet)
         {
           Source source =
-            stf.getAssociatedStylesheet(new StreamSource(inFileName),
-                                               media, null, null);
+            stf.getAssociatedStylesheet(new StreamSource(inFileName), media,
+                                        null, null);
 
           if (null != source)
             stylesheet = tfactory.newTemplates(source);
           else
           {
             if (null != media)
-              throw new TransformerException("No stylesheet found in: " + inFileName
-                                     + ", media=" + media);
+              throw new TransformerException("No stylesheet found in: "
+                                             + inFileName + ", media="
+                                             + media);
             else
               throw new TransformerException("No xml-stylesheet PI found in: "
-                                     + inFileName);
+                                             + inFileName);
           }
         }
 
         if (null != stylesheet)
         {
-          Transformer transformer = stylesheet.newTransformer();
+          Transformer transformer = flavor.equals("th") ? null : stylesheet.newTransformer();
 
           // Override the output format?
           if (null != outputType)
           {
-            transformer.setOutputProperty(OutputKeys.METHOD,
-                                          outputType);
+            transformer.setOutputProperty(OutputKeys.METHOD, outputType);
           }
 
           if (transformer instanceof TransformerImpl)
@@ -621,84 +640,200 @@
             transformer.setParameter((String) params.elementAt(i),
                                      (String) params.elementAt(i + 1));
           }
-					if (uriResolver != null)
-						transformer.setURIResolver(uriResolver);
+
+          if (uriResolver != null)
+            transformer.setURIResolver(uriResolver);
 
           if (null != inFileName)
           {
-            if(flavor.equals("d2d"))
+            if (flavor.equals("d2d"))
             {
+
               // Parse in the xml data into a DOM
-              DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
+              DocumentBuilderFactory dfactory =
+                DocumentBuilderFactory.newInstance();
+
               dfactory.setCoalescing(true);
               dfactory.setNamespaceAware(true);
+
               DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
-							if (entityResolver != null)
-								docBuilder.setEntityResolver(entityResolver);
+
+              if (entityResolver != null)
+                docBuilder.setEntityResolver(entityResolver);
+
               Node xmlDoc = docBuilder.parse(new InputSource(inFileName));
               Document doc = docBuilder.newDocument();
-              org.w3c.dom.DocumentFragment outNode = doc.createDocumentFragment();
-              transformer.transform(new DOMSource(xmlDoc, inFileName), 
+              org.w3c.dom.DocumentFragment outNode =
+                doc.createDocumentFragment();
+
+              transformer.transform(new DOMSource(xmlDoc, inFileName),
                                     new DOMResult(outNode));
-                                    
+
               // Now serialize output to disk with identity transformer
               Transformer serializer = stf.newTransformer();
-              Properties serializationProps = stylesheet.getOutputProperties();
+              Properties serializationProps =
+                stylesheet.getOutputProperties();
+
               serializer.setOutputProperties(serializationProps);
-							if (contentHandler != null)
-							{
-								SAXResult result = new SAXResult(contentHandler);
-								serializer.transform(new DOMSource(outNode), result);
-							}
-							else
-								serializer.transform(new DOMSource(outNode), strResult);
-           }
+
+              if (contentHandler != null)
+              {
+                SAXResult result = new SAXResult(contentHandler);
+
+                serializer.transform(new DOMSource(outNode), result);
+              }
+              else
+                serializer.transform(new DOMSource(outNode), strResult);
+            }
+            else if (flavor.equals("th"))
+            {
+              System.out.println("Testing the TransformerHandler...");
+
+              // ===============
+              XMLReader reader = null;
+
+              // Use JAXP1.1 ( if possible )      
+              try
+              {
+                javax.xml.parsers.SAXParserFactory factory =
+                  javax.xml.parsers.SAXParserFactory.newInstance();
+
+                factory.setNamespaceAware(true);
+
+                javax.xml.parsers.SAXParser jaxpParser =
+                  factory.newSAXParser();
+
+                reader = jaxpParser.getXMLReader();
+              }
+              catch (javax.xml.parsers.ParserConfigurationException ex)
+              {
+                throw new org.xml.sax.SAXException(ex);
+              }
+              catch (javax.xml.parsers.FactoryConfigurationError ex1)
+              {
+                throw new org.xml.sax.SAXException(ex1.toString());
+              }
+              catch (NoSuchMethodError ex2){}
+              catch (AbstractMethodError ame){}
+
+              if (null == reader)
+              {
+                reader = XMLReaderFactory.createXMLReader();
+              }
+              
+              TransformerHandler th = stf.newTransformerHandler(stylesheet);
+              
+              reader.setContentHandler(th);
+              reader.setDTDHandler(th);
+              
+              if(th instanceof org.xml.sax.ErrorHandler)
+                reader.setErrorHandler((org.xml.sax.ErrorHandler)th);
+              
+              try
+              {
+                reader.setProperty(
+                  "http://xml.org/sax/properties/lexical-handler", th);
+              }
+              catch (org.xml.sax.SAXNotRecognizedException e){}
+              catch (org.xml.sax.SAXNotSupportedException e){}
+              try
+              {
+                reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
+                                  true);
+              } catch (org.xml.sax.SAXException se) {}
+        
+              try
+              {
+                reader.setFeature("http://apache.org/xml/features/validation/dynamic",
+                                  true);
+              } catch (org.xml.sax.SAXException se) {}
+              
+              th.setResult(strResult);
+              
+              // System.out.println("sending parse events to the handler...");
+              reader.parse(new InputSource(inFileName));
+
+//              if (contentHandler != null)
+//              {
+//                SAXResult result = new SAXResult(contentHandler);
+//
+//                transformer.transform(
+//                  new SAXSource(reader, new InputSource(inFileName)), result);
+//              }
+//              else
+//              {
+//                transformer.transform(
+//                  new SAXSource(reader, new InputSource(inFileName)),
+//                  strResult);
+//              }
+
+              // ===============
+            }
             else
             {
-		if (entityResolver != null)
-		    {
-			XMLReader reader=null;
-			// Use JAXP1.1 ( if possible )      
-			try {
-			    javax.xml.parsers.SAXParserFactory factory=
-				javax.xml.parsers.SAXParserFactory.newInstance();
-			    factory.setNamespaceAware( true );
-			    javax.xml.parsers.SAXParser jaxpParser=
-				factory.newSAXParser();
-			    reader=jaxpParser.getXMLReader();
-			    
-			} catch( javax.xml.parsers.ParserConfigurationException ex ) {
-			    throw new org.xml.sax.SAXException( ex );
-			} catch( javax.xml.parsers.FactoryConfigurationError ex1 ) {
-			    throw new org.xml.sax.SAXException( ex1.toString() );
-			} catch( NoSuchMethodError ex2 ) {
-			}
-			catch (AbstractMethodError ame){}
-			if (null == reader) {
-			    reader = XMLReaderFactory.createXMLReader();
-			}
+              if (entityResolver != null)
+              {
+                XMLReader reader = null;
 
-			reader.setEntityResolver(entityResolver);
-			if (contentHandler != null)
-			    {
-				SAXResult result = new SAXResult(contentHandler);
-				transformer.transform(new SAXSource(reader, new InputSource(inFileName)),
-						      result);
-			    }
-			else
-			    {
-				transformer.transform(new SAXSource(reader, new InputSource(inFileName)),
-						      strResult);
-			    }
-		    }
-		else if (contentHandler != null)
-		    {
-			SAXResult result = new SAXResult(contentHandler);
-			transformer.transform(new StreamSource(inFileName),
-					      result);
-		    }
-		else
-		    transformer.transform(new StreamSource(inFileName), strResult);
+                // Use JAXP1.1 ( if possible )      
+                try
+                {
+                  javax.xml.parsers.SAXParserFactory factory =
+                    javax.xml.parsers.SAXParserFactory.newInstance();
+
+                  factory.setNamespaceAware(true);
+
+                  javax.xml.parsers.SAXParser jaxpParser =
+                    factory.newSAXParser();
+
+                  reader = jaxpParser.getXMLReader();
+                }
+                catch (javax.xml.parsers.ParserConfigurationException ex)
+                {
+                  throw new org.xml.sax.SAXException(ex);
+                }
+                catch (javax.xml.parsers.FactoryConfigurationError ex1)
+                {
+                  throw new org.xml.sax.SAXException(ex1.toString());
+                }
+                catch (NoSuchMethodError ex2){}
+                catch (AbstractMethodError ame){}
+
+                if (null == reader)
+                {
+                  reader = XMLReaderFactory.createXMLReader();
+                }
+
+                reader.setEntityResolver(entityResolver);
+
+                if (contentHandler != null)
+                {
+                  SAXResult result = new SAXResult(contentHandler);
+
+                  transformer.transform(
+                    new SAXSource(reader, new InputSource(inFileName)),
+                    result);
+                }
+                else
+                {
+                  transformer.transform(
+                    new SAXSource(reader, new InputSource(inFileName)),
+                    strResult);
+                }
+              }
+              else if (contentHandler != null)
+              {
+                SAXResult result = new SAXResult(contentHandler);
+
+                transformer.transform(new StreamSource(inFileName), result);
+              }
+              else
+              {
+                System.out.println("Starting transform");
+                transformer.transform(new StreamSource(inFileName),
+                                      strResult);
+                System.out.println("Done with transform");
+              }
             }
           }
           else
@@ -740,7 +875,8 @@
           doStackDumpOnError = true;
 
         diagnosticsWriter.println();
-        if (doStackDumpOnError)          
+
+        if (doStackDumpOnError)
           throwable.printStackTrace(dumpWriter);
         else
           diagnosticsWriter.println(
@@ -774,5 +910,4 @@
       diagnosticsWriter.println("");  //"Xalan: done");
     }
   }
-  
 }
diff --git a/src/org/apache/xml/dtm/ChunkedIntArray.java b/src/org/apache/xml/dtm/ChunkedIntArray.java
new file mode 100644
index 0000000..3385cc6
--- /dev/null
+++ b/src/org/apache/xml/dtm/ChunkedIntArray.java
@@ -0,0 +1,342 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xml.dtm;
+ 
+import org.w3c.dom.*;
+
+
+/**
+ * <code>ChunkedIntArray</code> is an extensible array of blocks of integers.
+ * (I'd consider Vector, but it's unable to handle integers except by
+ * turning them into Objects.)
+
+ * <p>Making this a separate class means some call-and-return overhead. But
+ * doing it all inline tends to be fragile and expensive in coder time,
+ * not to mention driving up code size. If you want to inline it, feel free.
+ * The Java text suggest that private and Final methods may be inlined, 
+ * and one can argue that this beast need not be made subclassable...</p>
+ *
+ * <p>%REVIEW% This has strong conceptual overlap with the IntVector class.
+ * It would probably be a good thing to merge the two, when time permits.<p>
+ */
+final class ChunkedIntArray
+{
+  final int slotsize=4; // Locked, MUST be power of two in current code
+  // Debugging tip: Cranking lowbits down to 4 or so is a good
+  // way to pound on the array addressing code.
+  static final int lowbits=10; // How many bits address within chunks
+  static final int chunkalloc=1<<lowbits;
+  static final int lowmask=chunkalloc-1;
+  
+  ChunksVector chunks=new ChunksVector();
+  final int fastArray[] = new int[chunkalloc];
+  int lastUsed=0;
+
+  /**
+   * Create a new CIA with specified record size. Currently record size MUST
+   * be a power of two... and in fact is hardcoded to 4.
+   */
+  ChunkedIntArray(int slotsize)
+  {
+    if(this.slotsize<slotsize)
+      throw new ArrayIndexOutOfBoundsException("ChunkedIntArray("+slotsize+") not currently supported");
+    else if (this.slotsize>slotsize)
+      System.out.println("*****WARNING: ChunkedIntArray("+slotsize+") wasting "+(this.slotsize-slotsize)+" words per slot");
+    chunks.addElement(fastArray);
+  }
+  /**
+   * Append a 4-integer record to the CIA, starting with record 1. (Since
+   * arrays are initialized to all-0, 0 has been reserved as the "unknown"
+   * value in DTM.)
+   * @return the index at which this record was inserted.
+   */
+  int appendSlot(int w0, int w1, int w2, int w3)
+  {
+    /*
+    try
+    {
+      int newoffset = (lastUsed+1)*slotsize;
+      fastArray[newoffset] = w0;
+      fastArray[newoffset+1] = w1;
+      fastArray[newoffset+2] = w2;
+      fastArray[newoffset+3] = w3;
+      return ++lastUsed;
+    }
+    catch(ArrayIndexOutOfBoundsException aioobe)
+    */
+    {
+      final int slotsize=4;
+      int newoffset = (lastUsed+1)*slotsize;
+      int chunkpos = newoffset >> lowbits;
+      int slotpos = (newoffset & lowmask);
+
+      // Grow if needed
+      if (chunkpos > chunks.size() - 1)
+        chunks.addElement(new int[chunkalloc]);
+      int[] chunk = chunks.elementAt(chunkpos);
+      chunk[slotpos] = w0;
+      chunk[slotpos+1] = w1;
+      chunk[slotpos+2] = w2;
+      chunk[slotpos+3] = w3;
+
+      return ++lastUsed;
+    }
+  }
+  /**
+   * Retrieve an integer from the CIA by record number and column within
+   * the record, both 0-based (though position 0 is reserved for special
+   * purposes).
+   * @param position int Record number
+   * @param slotpos int Column number
+   */
+  int readEntry(int position, int offset) throws ArrayIndexOutOfBoundsException
+  {
+    /*
+    try
+    {
+      return fastArray[(position*slotsize)+offset];
+    }
+    catch(ArrayIndexOutOfBoundsException aioobe)
+    */
+    {
+      // System.out.println("Using slow read (1)");
+      if (offset>=slotsize)
+        throw new ArrayIndexOutOfBoundsException("Offset bigger than slot");
+      position*=slotsize;
+      int chunkpos = position >> lowbits;
+      int slotpos = position & lowmask;
+      int[] chunk = chunks.elementAt(chunkpos);
+      return chunk[slotpos + offset];
+    }
+  }
+  
+  // Check that the node at index "position" is not an ancestor
+  // of the node at index "startPos". IF IT IS, DO NOT ACCEPT IT AND
+  // RETURN -1. If position is NOT an ancestor, return position.
+  // Special case: The Document node (position==0) is acceptable.
+  //
+  // This test supports DTM.getNextPreceding.
+  int specialFind(int startPos, int position)
+  {
+	  // We have to look all the way up the ancestor chain
+	  // to make sure we don't have an ancestor.
+	  int ancestor = startPos;
+	  while(ancestor > 0)
+	  {
+	        // Get the node whose index == ancestor
+		ancestor*=slotsize;
+		int chunkpos = ancestor >> lowbits;
+		int slotpos = ancestor & lowmask;
+		int[] chunk = chunks.elementAt(chunkpos);
+							
+		// Get that node's parent (Note that this assumes w[1]
+		// is the parent node index. That's really a DTM feature
+		// rather than a ChunkedIntArray feature.)
+		ancestor = chunk[slotpos + 1];
+
+		if(ancestor == position)
+			 break;
+	  }
+
+	  if (ancestor <= 0) 
+	  {
+		  return position;
+	  }
+	  return -1;
+  }
+  
+  /**
+   * @return int index of highest-numbered record currently in use
+   */
+  int slotsUsed()
+  {
+    return lastUsed;
+  }
+
+  /** Disard the highest-numbered record. This is used in the string-buffer
+   CIA; when only a single characters() chunk has been recieved, its index
+   is moved into the Text node rather than being referenced by indirection
+   into the text accumulator.
+   */
+  void discardLast()
+  {
+    --lastUsed;
+  }
+
+  /**
+   * Overwrite the integer found at a specific record and column.
+   * Used to back-patch existing records, most often changing their
+   * "next sibling" reference from 0 (unknown) to something meaningful
+   * @param position int Record number
+   * @param offset int Column number
+   * @param value int New contents
+   */
+  void writeEntry(int position, int offset, int value) throws ArrayIndexOutOfBoundsException
+  {
+    /*
+    try
+    {
+      fastArray[( position*slotsize)+offset] = value;
+    }
+    catch(ArrayIndexOutOfBoundsException aioobe)
+    */
+    {
+      if (offset >= slotsize)
+        throw new ArrayIndexOutOfBoundsException("Offset bigger than slot");
+      position*=slotsize;
+      int chunkpos = position >> lowbits;
+      int slotpos = position & lowmask;
+      int[] chunk = chunks.elementAt(chunkpos);
+      chunk[slotpos + offset] = value; // ATOMIC!
+    }
+  }
+
+  /**
+   * Overwrite an entire (4-integer) record at the specified index.
+   * Mostly used to create record 0, the Document node.
+   * @param position integer Record number
+   * @param w0 int 
+   * @param w1 int
+   * @param w2 int
+   * @param w3 int
+   */
+  void writeSlot(int position, int w0, int w1, int w2, int w3)
+  {
+      position *= slotsize;
+      int chunkpos = position >> lowbits;
+      int slotpos = (position & lowmask);
+
+    // Grow if needed
+    if (chunkpos > chunks.size() - 1)
+      chunks.addElement(new int[chunkalloc]);
+    int[] chunk = chunks.elementAt(chunkpos);
+    chunk[slotpos] = w0;
+    chunk[slotpos + 1] = w1;
+    chunk[slotpos + 2] = w2;
+    chunk[slotpos + 3] = w3;
+  }
+
+  /**
+   * Retrieve the contents of a record into a user-supplied buffer array.
+   * Used to reduce addressing overhead when code will access several
+   * columns of the record.
+   * @param position int Record number
+   * @param buffer int[] Integer array provided by user, must be large enough
+   * to hold a complete record.
+   */
+  void readSlot(int position, int[] buffer)
+  {
+    /*
+    try
+    {
+      System.arraycopy(fastArray, position*slotsize, buffer, 0, slotsize);
+    }
+    catch(ArrayIndexOutOfBoundsException aioobe)
+    */
+    {
+      // System.out.println("Using slow read (2): "+position);
+      position *= slotsize;
+      int chunkpos = position >> lowbits;
+      int slotpos = (position & lowmask);
+
+      // Grow if needed
+      if (chunkpos > chunks.size() - 1)
+        chunks.addElement(new int[chunkalloc]);
+      int[] chunk = chunks.elementAt(chunkpos);
+      System.arraycopy(chunk,slotpos,buffer,0,slotsize);
+    }
+  }
+
+  class ChunksVector
+  {
+    final int BLOCKSIZE = 64;
+    int[] m_map[] = new int[BLOCKSIZE][];
+    int m_mapSize = BLOCKSIZE;
+    int pos = 0;
+    
+    ChunksVector()
+    {
+    }
+    
+    final int size()
+    {
+      return pos;
+    }
+    
+    void addElement(int[] value)
+    {
+      if(pos >= m_mapSize)
+      {
+        int orgMapSize = m_mapSize;
+        while(pos >= m_mapSize)
+          m_mapSize+=BLOCKSIZE;
+        int[] newMap[] = new int[m_mapSize][];
+        System.arraycopy(m_map, 0, newMap, 0, orgMapSize);
+        m_map = newMap;
+      }
+      // For now, just do a simple append.  A sorted insert only 
+      // makes sense if we're doing an binary search or some such.
+      m_map[pos] = value;
+      pos++;
+    }
+    
+    final int[] elementAt(int pos)
+    {
+      return m_map[pos];
+    }
+  }
+}
diff --git a/src/org/apache/xml/dtm/CoroutineManager.java b/src/org/apache/xml/dtm/CoroutineManager.java
new file mode 100644
index 0000000..51144b7
--- /dev/null
+++ b/src/org/apache/xml/dtm/CoroutineManager.java
@@ -0,0 +1,374 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xml.dtm;
+
+import java.util.*;
+
+/**
+ * <meta name="usage" content="internal"/>
+ * <p>Support the coroutine design pattern.</p>
+ * 
+ * <p>A coroutine set is a very simple cooperative non-preemptive
+ * multitasking model, where the switch from one task to another is
+ * performed via an explicit request. Coroutines interact according to
+ * the following rules:</p>
+ *
+ * <ul>
+ * <li>One coroutine in the set has control, which it retains until it
+ * either exits or resumes another coroutine.</li>
+ * <li>A coroutine is activated when it is resumed by some other coroutine
+ * for the first time.</li>
+ * <li>An active coroutine that gives up control by resuming another in
+ * the set retains its context -- including call stack and local variables
+ * -- so that if/when it is resumed, it will proceed from the point at which
+ * it last gave up control.</li>
+ * </ul>
+ *
+ * <p>Coroutines can be thought of as falling somewhere between pipes and
+ * subroutines. Like call/return, there is an explicit flow of control
+ * from one coroutine to another. Like pipes, neither coroutine is
+ * actually "in charge", and neither must exit in order to transfer
+ * control to the other. </p>
+ * 
+ * <p>One classic application of coroutines is in compilers, where both
+ * the parser and the lexer are maintaining complex state
+ * information. The parser resumes the lexer to process incoming
+ * characters into lexical tokens, and the lexer resumes the parser
+ * when it has reached a point at which it has a reliably interpreted
+ * set of tokens available for semantic processing. Structuring this
+ * as call-and-return would require saving and restoring a
+ * considerable amount of state each time. Structuring it as two tasks
+ * connected by a queue may involve higher overhead (in systems which
+ * can optimize the coroutine metaphor), isn't necessarily as clear in
+ * intent, may have trouble handling cases where data flows in both
+ * directions, and may not handle some of the more complex cases where
+ * more than two coroutines are involved.</p>
+ * 
+ * <p>Most coroutine systems also provide a way to pass data between the
+ * source and target of a resume operation; this is sometimes referred
+ * to as "yielding" a value.  Others rely on the fact that, since only
+ * one member of a coroutine set is running at a time and does not
+ * lose control until it chooses to do so, data structures may be
+ * directly shared between them with only minimal precautions.</p>
+ * 
+ * <p>"Note: This should not be taken to mean that producer/consumer
+ * problems should be always be done with coroutines." Queueing is
+ * often a better solution when only two threads of execution are
+ * involved and full two-way handshaking is not required. It's a bit
+ * difficult to find short pedagogical examples that require
+ * coroutines for a clear solution.</p>
+ * 
+ * <p>The fact that only one of a group of coroutines is running at a
+ * time, and the control transfer between them is explicit, simplifies
+ * their possible interactions, and in some implementations permits
+ * them to be implemented more efficiently than general multitasking.
+ * In some situations, coroutines can be compiled out entirely;
+ * in others, they may only require a few instructions more than a
+ * simple function call.</p>
+ *
+ * <p>This version is built on top of standard Java threading, since
+ * that's all we have available right now. It's been encapsulated for
+ * code clarity and possible future optimization.</p>
+ * 
+ * <p>(Two possible approaches: wait-notify based and queue-based. Some
+ * folks think that a one-item queue is a cleaner solution because it's
+ * more abstract -- but since coroutine _is_ an abstraction I'm not really
+ * worried about that; folks should be able to switch this code without
+ * concern.)</p>
+ * 
+ * <p>%TBD% THIS SHOULD BE AN INTERFACE, to facilitate building other
+ * implementations... perhaps including a true coroutine system
+ * someday, rather than controlled threading. Arguably Coroutine
+ * itself should be an interface much like Runnable, but I think that
+ * can be built on top of this.</p>
+ * */
+public class CoroutineManager
+{
+  /** "Is this coroutine ID number already in use" lookup table.
+   * Currently implemented as a bitset as a compromise between
+   * compactness and speed of access, but obviously other solutions
+   * could be applied.
+   * */
+  BitSet m_activeIDs=new BitSet();
+
+  /** Limit on the coroutine ID numbers accepted. I didn't want the
+   * in-use table to grow without bound. If we switch to a more efficient
+   * sparse-array mechanism, it may be possible to raise or eliminate
+   * this boundary.
+   */
+  static int m_unreasonableId=1024;
+
+  /** Internal field used to hold the data being explicitly passed
+   * from one coroutine to another during a co_resume() operation.
+   * (Of course implicit data sharing may also occur; one of the reasons
+   * for using coroutines is that you're guaranteed that none of the
+   * other coroutines in your set are using shared structures at the time
+   * you access them.)
+   *
+   * %REVIEW% It's been proposed that we be able to pass types of data
+   * other than Object -- more specific object types, or
+   * lighter-weight primitives.  This would seem to create a potential
+   * explosion of "pass x recieve y back" methods (or require
+   * fracturing resume into two calls, resume-other and
+   * wait-to-be-resumed), and the weight issue could be managed by
+   * reusing a mutable buffer object to contain the primitive
+   * (remember that only one coroutine runs at a time, so once the
+   * buffer's set it won't be walked on). Typechecking objects is
+   * interesting from a code-robustness point of view, but it's
+   * unclear whether it makes sense to encapsulate that in the
+   * coroutine code or let the callers do it, since it depends on RTTI
+   * either way. Restricting the parameters to objects implementing a
+   * specific CoroutineParameter interface does _not_ seem to be a net
+   * win; applications can do so if they want via front-end code, but
+   * there seem to be too many use cases involving passing an existing
+   * object type that you may not have the freedom to alter and may
+   * not want to spend time wrapping another object around.
+   * */
+  Object m_yield=null;
+
+  // Expose???
+  final static int NOBODY=-1;
+  final static int ANYBODY=-1;
+
+  /** Internal field used to confirm that the coroutine now waking up is
+   * in fact the one we intended to resume. Some such selection mechanism
+   * is needed when more that two coroutines are operating within the same
+   * group.
+   */
+  int m_nextCoroutine=NOBODY;
+  
+  /** <p>Each coroutine in the set managed by a single
+   * CoroutineManager is identified by a small positive integer. This
+   * brings up the question of how to manage those integers to avoid
+   * reuse... since if two coroutines use the same ID number, resuming
+   * that ID could resume either. I can see arguments for either
+   * allowing applications to select their own numbers (they may want
+   * to declare mnemonics via manefest constants) or generating
+   * numbers on demand.  This routine's intended to support both
+   * approaches.</p>
+   *
+   * <p>%REVIEW% We could use an object as the identifier. Not sure
+   * it's a net gain, though it would allow the thread to be its own
+   * ID. Ponder.</p>
+   *
+   * @param coroutineID: If >=0, requests that we reserve this number.
+   * If <0, requests that we find, reserve, and return an available ID
+   * number.
+   *
+   * @return If >=0, the ID number to be used by this coroutine. If <0,
+   * an error occurred -- the ID requested was already in use, or we
+   * couldn't assign one without going over the "unreasonable value" mark
+   * */
+  public synchronized int co_joinCoroutineSet(int coroutineID)
+  {
+    if(coroutineID>=0)
+      {
+        if(coroutineID>=m_unreasonableId || m_activeIDs.get(coroutineID))
+          return -1;
+      }
+    else
+      {
+        // What I want is "Find first clear bit". That doesn't exist.
+        // JDK1.2 added "find last set bit", but that doesn't help now.
+        coroutineID=0;
+        while(coroutineID<m_unreasonableId)
+          {
+            if(m_activeIDs.get(coroutineID))
+              ++coroutineID;
+            else
+              break;
+          }
+        if(coroutineID>=m_unreasonableId)
+          return -1;
+      }
+
+    m_activeIDs.set(coroutineID);
+    return coroutineID;
+  }
+
+  /** In the standard coroutine architecture, coroutines are
+   * identified by their method names and are launched and run up to
+   * their first yield by simply resuming them; its's presumed that
+   * this recognizes the not-already-running case and does the right
+   * thing. We seem to need a way to achieve that same threadsafe
+   * run-up...  eg, start the coroutine with a wait.
+   *
+   * %TBD% whether this makes any sense...
+   *
+   * @param thisCoroutine the identifier of this coroutine, so we can
+   * recognize when we are being resumed.
+   * @exception java.lang.NoSuchMethodException if thisCoroutine isn't
+   * a registered member of this group. %REVIEW% whether this is the
+   * best choice.
+   * */
+  public synchronized Object co_entry_pause(int thisCoroutine) throws java.lang.NoSuchMethodException
+  {
+    if(!m_activeIDs.get(thisCoroutine))
+      throw new java.lang.NoSuchMethodException();
+
+    while(m_nextCoroutine != thisCoroutine)
+      {
+        try 
+          {
+            wait();
+          }
+        catch(java.lang.InterruptedException e)
+          {
+            // %TBD% -- Declare? Encapsulate? Ignore? Or
+            // dance widdershins about the instruction cache?
+          }
+      }
+    
+    return m_yield;
+  }
+
+  /** Transfer control to another coroutine which has already been started and
+   * is waiting on this CoroutineManager. We won't return from this call
+   * until that routine has relinquished control.
+   *
+   * %TBD% What should we do if toCoroutine isn't registered? Exception?
+   *
+   * @param arg_object A value to be passed to the other coroutine.
+   * @param thisCoroutine Integer identifier for this coroutine. This is the
+   * ID we watch for to see if we're the ones being resumed.
+   * @param toCoroutine. Integer identifier for the coroutine we wish to
+   * invoke. 
+   * @exception java.lang.NoSuchMethodException if toCoroutine isn't a
+   * registered member of this group. %REVIEW% whether this is the best choice.
+   * */
+  public synchronized Object co_resume(Object arg_object,int thisCoroutine,int toCoroutine) throws java.lang.NoSuchMethodException
+  {
+    if(!m_activeIDs.get(toCoroutine))
+      throw new java.lang.NoSuchMethodException("Coroutine not available, id="+toCoroutine);
+
+    // We expect these values to be overwritten during the notify()/wait()
+    // periods, as other coroutines in this set get their opportunity to run.
+    m_yield=arg_object;
+    m_nextCoroutine=toCoroutine;
+
+    notify();
+    while(m_nextCoroutine != thisCoroutine || m_nextCoroutine==ANYBODY || m_nextCoroutine==NOBODY)
+      {
+        try 
+          {
+            // System.out.println("waiting...");
+            wait();
+          }
+        catch(java.lang.InterruptedException e)
+          {
+            // %TBD% -- Declare? Encapsulate? Ignore? Or
+            // dance deasil about the program counter?
+          }
+      }
+
+    if(m_nextCoroutine==NOBODY)
+      {
+        // Pass it along
+        co_exit(thisCoroutine);
+        // And inform this coroutine that its partners are Going Away
+        // %REVIEW% Should this throw/return something more useful?
+        throw new java.lang.NoSuchMethodException("CoroutineManager recieved co_exit() request");
+      }
+    
+    return m_yield;
+  }
+  
+  /** Terminate this entire set of coroutines. The others will be
+   * deregistered and have exceptions thrown at them. Note that this
+   * is intended as a panic-shutdown operation; under normal
+   * circumstances a coroutine should always end with co_exit_to() in
+   * order to politely inform at least one of its partners that it is
+   * going away.
+   *
+   * %TBD% This may need significantly more work. 
+   *
+   * %TBD% Should this just be co_exit_to(,,CoroutineManager.PANIC)?
+   *
+   * @param thisCoroutine Integer identifier for the coroutine requesting exit.
+   * */
+  public synchronized void co_exit(int thisCoroutine)
+  {
+    m_activeIDs.clear(thisCoroutine);
+    m_nextCoroutine=NOBODY; // %REVIEW%
+    notify();
+  }
+
+  /** Make the ID available for reuse and terminate this coroutine,
+   * transferring control to the specified coroutine.
+   *
+   * @param arg_object A value to be passed to the other coroutine.
+   * @param thisCoroutine Integer identifier for the coroutine leaving the set.
+   * @param toCoroutine. Integer identifier for the coroutine we wish to
+   * invoke. 
+   * @exception java.lang.NoSuchMethodException if toCoroutine isn't a
+   * registered member of this group. %REVIEW% whether this is the best choice.
+   * */
+  public synchronized void co_exit_to(Object arg_object,int thisCoroutine,int toCoroutine) throws java.lang.NoSuchMethodException
+  {
+    if(!m_activeIDs.get(toCoroutine))
+      throw new java.lang.NoSuchMethodException("Coroutine not available, id="+toCoroutine);
+    
+    // We expect these values to be overwritten during the notify()/wait()
+    // periods, as other coroutines in this set get their opportunity to run.
+    m_yield=arg_object;
+    m_nextCoroutine=toCoroutine;
+
+    m_activeIDs.clear(thisCoroutine);
+
+    notify();
+  }
+}
diff --git a/src/org/apache/xml/dtm/CoroutineParser.java b/src/org/apache/xml/dtm/CoroutineParser.java
new file mode 100644
index 0000000..23f5fad
--- /dev/null
+++ b/src/org/apache/xml/dtm/CoroutineParser.java
@@ -0,0 +1,170 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999,2000 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xerces" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.apache.org.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.xml.dtm;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import java.io.IOException;
+import org.apache.xml.dtm.CoroutineManager;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.ContentHandler;
+
+/** <p>CoroutineParser is an API for parser threads that operate as
+ * coroutines. See CoroutineSAXParser and CoroutineSAXParser_Xerces
+ * for examples.</p>
+ *
+ * <p>&lt;grumble&gt; I'd like the interface to require a specific form
+ * for either the base constructor or a static factory method. Java
+ * doesn't allow us to specify either, so I'll just document them
+ * here:
+ *
+ * <ul>
+ * <li>public CoroutineParser(CoroutineManager co, int appCoroutine);</li>
+ * <li>public CoroutineParser createCoroutineParser(CoroutineManager co, int appCoroutine);</li>
+ * </ul>
+ *
+ * &lt;/grumble&gt;</p>
+ *
+ * <p>Status: In progress</p>
+ * */
+public interface CoroutineParser {
+
+    /** @return the coroutine ID number for this CoroutineParser object.
+     * Note that this isn't useful unless you know which CoroutineManager
+     * you're talking to. Also note that the do...() methods encapsulate
+     * the common transactions with the CoroutineParser, so you shouldn't
+     * need this in most cases.
+     * */
+    public int getParserCoroutineID();
+
+    /** @return the CoroutineManager for this CoroutineParser object.
+     * If you're using the do...() methods, applications should only
+     * need to talk to the CoroutineManager once, to obtain the
+     * application's Coroutine ID.
+     * */
+    public CoroutineManager getCoroutineManager();
+
+  /** Register a SAX-style content handler for us to output to */
+  public void setContentHandler(ContentHandler handler);
+
+  /**  Register a SAX-style lexical handler for us to output to
+   *  Not all parsers support this...
+   *
+   * %REVIEW% Not called setLexicalHandler because Xalan uses that name
+   * internally, which causes subclassing nuisances. 
+   */
+  public void setLexHandler(org.xml.sax.ext.LexicalHandler handler);
+
+  /* The run() method is required in CoroutineParsers that run as
+   * threads (of course)... but it isn't part of our API, and
+   * shouldn't be declared here.
+   * */
+
+  //================================================================
+  /** doParse() is a simple API which tells the coroutine parser
+   * to begin reading from a file.  This is intended to be called from one
+   * of our partner coroutines, and serves both to encapsulate the
+   * communication protocol and to avoid having to explicitly use the
+   * CoroutineParser's coroutine ID number.
+   *
+   * %REVIEW% Can/should this unify with doMore? (if URI hasn't changed,
+   * parse more from same file, else end and restart parsing...?
+   *
+   * @param source The InputSource to parse from.
+   * @param appCoroutine The coroutine ID number of the coroutine invoking
+   * this method, so it can be resumed after the parser has responded to the
+   * request.
+   * @return Boolean.TRUE if the CoroutineParser believes more data may be available
+   * for further parsing. Boolean.FALSE if parsing ran to completion.
+   * Exception if the parser objected for some reason.
+   * */
+  public Object doParse(InputSource source, int appCoroutine);
+
+  /** doMore() is a simple API which tells the coroutine parser
+   * that we need more nodes.  This is intended to be called from one
+   * of our partner coroutines, and serves both to encapsulate the
+   * communication protocol and to avoid having to explicitly use the
+   * CoroutineParser's coroutine ID number.
+   *
+   * @param parsemore If true, tells the incremental parser to generate
+   * another chunk of output. If false, tells the parser that we're
+   * satisfied and it can terminate parsing of this document.
+   * @param appCoroutine The coroutine ID number of the coroutine invoking
+   * this method, so it can be resumed after the parser has responded to the
+   * request.
+   * @return Boolean.TRUE if the CoroutineParser believes more data may be available
+   * for further parsing. Boolean.FALSE if parsing ran to completion.
+   * Exception if the parser objected for some reason.
+   * */
+  public Object doMore (boolean parsemore, int appCoroutine);
+
+  /** doTerminate() is a simple API which tells the coroutine
+   * parser to terminate itself.  This is intended to be called from
+   * one of our partner coroutines, and serves both to encapsulate the
+   * communication protocol and to avoid having to explicitly use the
+   * CoroutineParser's coroutine ID number.
+   *
+   * Returns only after the CoroutineParser has acknowledged the request.
+   *
+   * @param appCoroutine The coroutine ID number of the coroutine invoking
+   * this method, so it can be resumed after the parser has responded to the
+   * request.
+   * */
+  public void doTerminate(int appCoroutine);
+
+} // class CoroutineParser
diff --git a/src/org/apache/xml/dtm/CoroutineSAXFilterTest.java b/src/org/apache/xml/dtm/CoroutineSAXFilterTest.java
new file mode 100644
index 0000000..71ad4a0
--- /dev/null
+++ b/src/org/apache/xml/dtm/CoroutineSAXFilterTest.java
@@ -0,0 +1,143 @@
+package org.apache.xml.dtm;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.Attributes;
+import org.xml.sax.XMLReader;
+import java.io.IOException;
+import org.apache.xml.dtm.CoroutineManager;
+
+
+/** Primitive unit test for CoroutineSAXParser in filtering mode:
+ * Attempt coroutine parsing of documents indicated by arguments (as
+ * URIs), report progress. If a URI is followed by "!" as the next
+ * argument, we cancel the parse early.
+ *
+ * This version tests the filtering mode, where the CoroutineParser
+ * is managing a SAX stream generated by other code. Normally this
+ * would be used when you've launched the consumer in a secondary
+ * thread and are running the SAX event generation in the primary
+ * thread. Of course it could be used the other way round as well.
+ *
+ * Note that unlike the fully-encapsulated version (see the inline
+ * test in CoroutineSAXParser), this version does _not_ have a
+ * dialog for starting the parse, or for restarting it with a new
+ * file.
+ * */
+class CoroutineSAXFilterTest implements Runnable
+{
+  // Statics are a sloppy way of passing data to the test thread,
+  // but for this quick-hack I don't much care.
+  static boolean TEST_EARLY_STOP=false;
+  static int appCoroutineID=-1;
+  static CoroutineSAXParser filter;
+
+  public static void main(String args[])
+  {
+    System.out.println("Starting in Filtering mode...");
+
+    org.xml.sax.XMLReader theSAXParser=
+      new org.apache.xerces.parsers.SAXParser();
+    
+    CoroutineManager co = new CoroutineManager();
+
+    appCoroutineID = co.co_joinCoroutineSet(appCoroutineID);
+    if (appCoroutineID == -1)
+      {
+        System.out.println("ERROR: Couldn't allocate coroutine number.\n");
+        return;
+      }
+
+    // Note that this is a global -- sloppy connection to the thread.
+    filter=new CoroutineSAXParser(co, appCoroutineID);
+
+    // Convenience function... Set handlers
+    filter.setXMLReader(theSAXParser);
+    
+    // Use a serializer as our sample output
+    org.apache.xml.serialize.XMLSerializer trace;
+    trace=new org.apache.xml.serialize.XMLSerializer(System.out,null);
+    filter.setContentHandler(trace);
+    filter.setLexHandler(trace);
+
+    // Launch the listener.
+    Thread listener=new Thread(new CoroutineSAXFilterTest());
+    listener.setDaemon(false);
+    listener.start();
+    
+    // Check stop-early flag
+    if(args.length>1 && "!".equals(args[1]))
+      TEST_EARLY_STOP=true;
+
+    // Run the parser
+    System.out.println("*** Parser start ***");
+    try
+      {
+	theSAXParser.parse(new InputSource(args[0]));
+      }
+    catch(java.io.IOException e)
+      {
+	e.printStackTrace();
+      }
+    catch(org.xml.sax.SAXException e)
+      {
+	e.printStackTrace();
+
+	// %REVIEW% We'll should probably expose these special types,
+	// if we might be testing them outside the filtering code...
+
+	Exception embedded=e.getException();
+	if(embedded!=null && embedded.getClass().getName().equals("org.apache.xml.dtm.CoroutineSAXParser$UserRequestedStopException"))
+	  System.out.println("... NORMAL response to doTerminate().");
+      }
+    System.out.println("*** Parser end ***");
+    filter.doTerminate(appCoroutineID);
+  }
+  
+  // Issue coroutine transactions to simulate dialog with the parser
+  // for a single file.  Note that the sequence of calls here is
+  // identical to that when talking to the fully encapsulated
+  // parser... though doParse() will be a no-op since the parse
+  // is launched separately.
+  public void run() {
+  {
+    // %TBD% PROBLEM: Parser error hangs this process...
+
+    Object result;
+    boolean more=true;
+
+    for(result = filter.doParse(null, appCoroutineID);
+	(result instanceof Boolean && ((Boolean)result)==Boolean.TRUE);
+	result = filter.doMore(more, appCoroutineID))
+      {
+	// Special test: Terminate parsing early.
+	if(TEST_EARLY_STOP)
+	  {
+	    System.out.println("\nSome parsing successful, trying to stop.\n");
+	    more=false;
+	  }
+	else
+	  System.out.println("\nSome parsing successful, trying more.\n");
+      }
+    
+    if (result instanceof Boolean && ((Boolean)result)==Boolean.FALSE)
+      {
+	System.out.println("\nfilter ended (EOF or on request).\n");
+      }
+    else if (result == null) {
+      System.out.println("\nUNEXPECTED: filter says shut down prematurely.\n");
+    }
+    else if (result instanceof Exception) {
+      System.out.println("\nfilter threw exception:");
+      ((Exception)result).printStackTrace();
+    }
+    
+  }
+  
+  filter.doTerminate(appCoroutineID);
+  }
+  
+}
diff --git a/src/org/apache/xml/dtm/CoroutineSAXParser.java b/src/org/apache/xml/dtm/CoroutineSAXParser.java
new file mode 100644
index 0000000..ed6a7e3
--- /dev/null
+++ b/src/org/apache/xml/dtm/CoroutineSAXParser.java
@@ -0,0 +1,1064 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999,2000 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xerces" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.apache.org.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.xml.dtm;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.Attributes;
+import org.xml.sax.XMLReader;
+import java.io.IOException;
+import org.apache.xml.dtm.CoroutineManager;
+
+/** <p>CoroutineSAXParser runs a SAX2 parser in a coroutine to achieve
+ * incremental parsing. Output from the parser will still be issued
+ * via callbacks, which will need to be recieved and acted upon by an
+ * appopriate handler. But those callbacks will pass through a
+ * counting stage which periodically yields control back to the other
+ * coroutines in this set.</p>
+ *
+ * <p>For a brief usage example, see the unit-test main() method.</p>
+ *
+ * <p>Status: Passes simple unit-tests in main().
+ * FAILS CoroutineSaxFilterTest termination in the doMore(false) case
+ * NEEDS JAVADOC!</p>
+ *
+ * %TBD% MAJOR ISSUE: In filtering mode, where we aren't the ones who invoked
+ * the XMLHandler's parse() operation, we have no way to capture
+ * exceptions thrown by the ContentHandler -- and thus no way to complete
+ * the doMore(false) dialog in its usual sense, or to be informed if
+ * the XMLHandler crashes for other reasons. Two possible solutions:
+ *	In this mode, conduct the whole dialog within doMore(). Ugh.
+ * Or:
+ *	Change the dialogs -- cut over to pure filtering mode, where
+ *		we only process one file and doMore(false) can respond with
+ *		co_exit_to().
+ *
+ * */
+public class CoroutineSAXParser
+implements CoroutineParser, Runnable, ContentHandler, LexicalHandler, ErrorHandler
+{
+
+  boolean DEBUG=false; //Internal status report
+
+  //
+  // Data
+  //
+
+  private CoroutineManager fCoroutineManager = null;
+  private int fAppCoroutineID = -1;
+  private int fParserCoroutineID = -1;
+  private boolean fParseInProgress=false;
+  private XMLReader fXMLReader=null;
+  private boolean fRunningInThread=false;
+  private ContentHandler clientContentHandler=null; // %REVIEW% support multiple?
+  private LexicalHandler clientLexicalHandler=null; // %REVIEW% support multiple?
+  private ErrorHandler clientErrorHandler=null; // %REVIEW% support multiple?
+  private int eventcounter;
+  private int frequency=10;
+
+  // Horrendous kluge to run filter to completion. See co_yield()'s
+  // internal comments for details. "Is this any way to run a railroad?"
+  private boolean fNeverYieldAgain=false;
+  
+
+  //
+  // Constructors
+  //
+
+  /** Create a CoroutineSAXParser which is not yet bound to a specific
+   * SAX event source.
+   *
+   * THIS VERSION DOES NOT LAUNCH A THREAD! It is presumed that the
+   * application coroutine will be started in a secondary thread and
+   * will be waiting for our first yield(), and that the parser will
+   * be run in the main thread.
+   * 
+   * Status: Experimental
+   * 
+   * @see setXMLReader
+   * */
+  public CoroutineSAXParser(CoroutineManager co, int appCoroutineID)
+  {
+    fXMLReader=null;    // No reader yet
+
+    eventcounter=frequency;
+
+    fCoroutineManager = co;
+    fAppCoroutineID = appCoroutineID;
+    fParserCoroutineID = co.co_joinCoroutineSet(-1);
+    if (fParserCoroutineID == -1)
+      throw new RuntimeException("co_joinCoroutineSet() failed");
+
+    fRunningInThread=false; // Unless overridden by the other constructor
+  }
+
+  /** Wrap a SAX2 XMLReader (parser or other event source)
+   * in a CoroutineSAXParser. This version launches the CoroutineSAXParser
+   * in a thread, and prepares it to invoke the parser from that thread
+   * upon request.
+   *
+   * @see doParse
+   */
+  public CoroutineSAXParser(CoroutineManager co, int appCoroutineID,
+                            XMLReader parser) {
+    this(co,appCoroutineID);
+    setXMLReader(parser);
+
+    fRunningInThread=true;
+    Thread t = new Thread(this);
+    t.setDaemon(false);
+    t.start();
+  }
+
+  //
+  // Public methods
+  //
+
+  /** Bind to the XMLReader. This operation is ignored if the reader has
+   * previously been set.
+   *
+   * Just a convenience routine; obviously you can explicitly register
+   * this as a listener with the same effect.
+   *
+   * %REVIEW% Should it unbind from the previous reader if there is one?
+   * %REVIEW% Do we really need to set fXMLReader???
+   *
+   * %TBD% This is a quick-hack solution. I'm not convinced that it's
+   * adequate. In particular, since in this model parser.parse() is
+   * invoked from outside rather than from our run() loop, I'm not
+   * sure the end-of-file response is being delivered properly.
+   * (There were questions of double-yields in earlier versions of the code.)
+   * */
+  public void setXMLReader(XMLReader parser)
+  {
+    if(fXMLReader!=null) return;
+    
+    fXMLReader=parser;
+    fXMLReader.setContentHandler(this);
+    fXMLReader.setErrorHandler(this); // to report fatal errors in filtering mode
+
+    // Not supported by all SAX2 parsers:
+    try 
+      {
+        fXMLReader.setProperty("http://xml.org/sax/properties/lexical-handler",
+                              this);
+      }
+    catch(SAXNotRecognizedException e)
+      {
+        // Nothing we can do about it
+      }
+    catch(SAXNotSupportedException e)
+      {
+        // Nothing we can do about it
+      }
+
+    // Should we also bind as other varieties of handler?
+    // (DTDHandler and so on)
+  }
+
+  // Register a content handler for us to output to
+  public void setContentHandler(ContentHandler handler)
+  {
+    clientContentHandler=handler;
+  }
+  // Register a lexical handler for us to output to
+  // Not all parsers support this...
+  // ??? Should we register directly on the parser?
+  // NOTE NAME -- subclassing issue in the Xerces version
+  public void setLexHandler(LexicalHandler handler)
+  {
+    clientLexicalHandler=handler;
+  }
+  // Register an error handler for us to output to
+  // NOTE NAME -- subclassing issue in the Xerces version
+  public void setErrHandler(ErrorHandler handler)
+  {
+    clientErrorHandler=handler;
+  }
+
+  // Set the number of events between resumes of our coroutine
+  // Immediately resets number of events before _next_ resume as well.
+  public void setReturnFrequency(int events)
+  {
+    if(events<1) events=1;
+    frequency=eventcounter=events;
+  }
+  
+  //
+  // ContentHandler methods
+  // These  pass the data to our client ContentHandler...
+  // but they also count the number of events passing through,
+  // and resume our coroutine each time that counter hits zero and
+  // is reset.
+  //
+  // Note that for everything except endDocument, we do the count-and-yield
+  // BEFORE passing the call along. I'm hoping that this will encourage JIT
+  // compilers to realize that these are tail-calls, reducing the expense of
+  // the additional layer of data flow.
+  //
+  // %REVIEW% Glenn suggests that pausing after endElement, endDocument,
+  // and characters may be sufficient. I actually may not want to
+  // stop after characters, since in our application these wind up being
+  // concatenated before they're processed... but that risks huge blocks of
+  // text causing greater than usual readahead. (Unlikely? Consider the
+  // possibility of a large base-64 block in a SOAP stream.)
+  //
+  public void characters(char[] ch, int start, int length)
+       throws org.xml.sax.SAXException
+  {
+    if(--eventcounter<=0)
+      {
+        co_yield(true);
+        eventcounter=frequency;
+      }
+    if(clientContentHandler!=null)
+      clientContentHandler.characters(ch,start,length);
+  }
+  public void endDocument() 
+       throws org.xml.sax.SAXException
+  {
+    // EXCEPTION: In this case we need to run the event BEFORE we yield.
+    if(clientContentHandler!=null)
+      clientContentHandler.endDocument();
+
+    eventcounter=0;	
+    co_yield(false);
+  }
+  public void endElement(java.lang.String namespaceURI, java.lang.String localName,
+      java.lang.String qName) 
+       throws org.xml.sax.SAXException
+  {
+    if(--eventcounter<=0)
+      {
+        co_yield(true);
+        eventcounter=frequency;
+      }
+    if(clientContentHandler!=null)
+      clientContentHandler.endElement(namespaceURI,localName,qName);
+  }
+  public void endPrefixMapping(java.lang.String prefix) 
+       throws org.xml.sax.SAXException
+  {
+    if(--eventcounter<=0)
+      {
+        co_yield(true);
+        eventcounter=frequency;
+      }
+    if(clientContentHandler!=null)
+      clientContentHandler.endPrefixMapping(prefix);
+  }
+  public void ignorableWhitespace(char[] ch, int start, int length) 
+       throws org.xml.sax.SAXException
+  {
+    if(--eventcounter<=0)
+      {
+        co_yield(true);
+        eventcounter=frequency;
+      }
+    if(clientContentHandler!=null)
+      clientContentHandler.ignorableWhitespace(ch,start,length);
+  }
+  public void processingInstruction(java.lang.String target, java.lang.String data) 
+       throws org.xml.sax.SAXException
+  {
+    if(--eventcounter<=0)
+      {
+        co_yield(true);
+        eventcounter=frequency;
+      }
+    if(clientContentHandler!=null)
+      clientContentHandler.processingInstruction(target,data);
+  }
+  public void setDocumentLocator(Locator locator) 
+  {
+    if(--eventcounter<=0)
+      {
+        co_yield(true);
+        eventcounter=frequency;
+      }
+    if(clientContentHandler!=null)
+      clientContentHandler.setDocumentLocator(locator);
+  }
+  public void skippedEntity(java.lang.String name) 
+       throws org.xml.sax.SAXException
+  {
+    if(--eventcounter<=0)
+      {
+        co_yield(true);
+        eventcounter=frequency;
+      }
+    if(clientContentHandler!=null)
+      clientContentHandler.skippedEntity(name);
+  }
+  public void startDocument() 
+       throws org.xml.sax.SAXException
+  {
+    if(--eventcounter<=0)
+      {
+        co_yield(true);
+        eventcounter=frequency;
+      }
+    if(clientContentHandler!=null)
+      clientContentHandler.startDocument();
+  }
+  public void startElement(java.lang.String namespaceURI, java.lang.String localName,
+      java.lang.String qName, Attributes atts) 
+       throws org.xml.sax.SAXException
+  {
+    if(--eventcounter<=0)
+      {
+        co_yield(true);
+        eventcounter=frequency;
+      }
+    if(clientContentHandler!=null)
+      clientContentHandler.startElement(namespaceURI, localName, qName, atts);
+  }
+  public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) 
+       throws org.xml.sax.SAXException
+  {
+    if(--eventcounter<=0)
+      {
+        co_yield(true);
+        eventcounter=frequency;
+      }
+    if(clientContentHandler!=null)
+      clientContentHandler.startPrefixMapping(prefix,uri);
+  }
+
+  //
+  // LexicalHandler support. Not all SAX2 parsers support these events
+  // but we may want to pass them through when they exist...
+  //
+  // %REVIEW% These do NOT currently affect the eventcounter; I'm asserting
+  // that they're rare enough that it makes little or no sense to
+  // pause after them. As such, it may make more sense for folks who
+  // actually want to use them to register directly with the parser.
+  // But I want 'em here for now, to remind us to recheck this assertion!
+  //
+  public void comment(char[] ch, int start, int length) 
+       throws org.xml.sax.SAXException
+  {
+    if(null!=clientLexicalHandler)
+      clientLexicalHandler.comment(ch,start,length);
+  }
+  public void endCDATA() 
+       throws org.xml.sax.SAXException
+  {
+    if(null!=clientLexicalHandler)
+      clientLexicalHandler.endCDATA();
+  }
+  public void endDTD() 
+       throws org.xml.sax.SAXException
+  {
+    if(null!=clientLexicalHandler)
+      clientLexicalHandler.endDTD();
+  }
+  public void endEntity(java.lang.String name) 
+       throws org.xml.sax.SAXException
+  {
+    if(null!=clientLexicalHandler)
+      clientLexicalHandler.endEntity(name);
+  }
+  public void startCDATA() 
+       throws org.xml.sax.SAXException
+  {
+    if(null!=clientLexicalHandler)
+      clientLexicalHandler.startCDATA();
+  }
+  public void startDTD(java.lang.String name, java.lang.String publicId,
+      java.lang.String systemId) 
+       throws org.xml.sax.SAXException
+  {
+    if(null!=clientLexicalHandler)
+      clientLexicalHandler. startDTD(name, publicId, systemId);
+  }
+  public void startEntity(java.lang.String name) 
+       throws org.xml.sax.SAXException
+  {
+    if(null!=clientLexicalHandler)
+      clientLexicalHandler.startEntity(name);
+  }
+
+  //
+  // ErrorHandler support.
+  //
+  // PROBLEM: Xerces is apparently _not_ calling the ErrorHandler for
+  // exceptions thrown by the ContentHandler, which prevents us from
+  // handling this properly when running in filtering mode with Xerces
+  // as our event source.  It's unclear whether this is a Xerces bug
+  // or a SAX design flaw.
+  // 
+  // %REVIEW% Current solution: In filtering mode, it is REQUIRED that
+  // event source make sure this method is invoked if the event stream
+  // abends before endDocument is delivered. If that means explicitly calling
+  // us in the exception handling code because it won't be delivered as part
+  // of the normal SAX ErrorHandler stream, that's fine; Not Our Problem.
+  //
+  public void error(SAXParseException exception) throws SAXException
+  {
+    if(null!=clientErrorHandler)
+      clientErrorHandler.error(exception);
+  }
+  
+  public void fatalError(SAXParseException exception) throws SAXException
+  {
+    // When we're in filtering mode we need to make sure that
+    // we terminate the parsing coroutine transaction -- announce
+    // the problem and shut down the dialog.
+
+    // PROBLEM: Xerces is apparently _not_ calling the ErrorHandler for
+    // exceptions thrown by the ContentHandler... specifically, doTerminate.
+    // %TBD% NEED A SOLUTION!
+    
+    if(!fRunningInThread)
+      {
+        try
+          {
+            fCoroutineManager.co_exit_to(exception,
+                                         fParserCoroutineID,fAppCoroutineID);
+            // %TBD% Do we need to wait for terminate?
+          }
+        catch(NoSuchMethodException e)
+          {
+            // Shouldn't happen unless we've miscoded our coroutine logic
+            // "Shut down the garbage smashers on the detention level!"
+            e.printStackTrace(System.err);
+            fCoroutineManager.co_exit(fParserCoroutineID);
+
+            // No need to throw shutdownException; we're already
+            // in the process of murdering the parser.
+          }
+      }
+
+    if(null!=clientErrorHandler)
+      clientErrorHandler.error(exception);
+  }
+  
+  public void warning(SAXParseException exception) throws SAXException
+  {
+    if(null!=clientErrorHandler)
+      clientErrorHandler.error(exception);
+  }
+  
+
+  //
+  // coroutine support
+  //
+
+  public int getParserCoroutineID() {
+    return fParserCoroutineID;
+  }
+
+  /** @return the CoroutineManager this CoroutineParser object is bound to.
+   * If you're using the do...() methods, applications should only
+   * need to talk to the CoroutineManager once, to obtain the
+   * application's Coroutine ID.
+   * */
+  public CoroutineManager getCoroutineManager()
+  {
+    return fCoroutineManager;
+  }
+
+  /** <p>In the SAX delegation code, I've inlined the count-down in
+   * the hope of encouraging compilers to deliver better
+   * performance. However, if we subclass (eg to directly connect the
+   * output to a DTM builder), that would require calling super in
+   * order to run that logic... which seems inelegant.  Hence this
+   * routine for the convenience of subclasses: every [frequency]
+   * invocations, issue a co_yield.</p>
+   *
+   * @param moreExepcted Should always be true unless this is being called
+   * at the end of endDocument() handling.
+   * */
+  void count_and_yield(boolean moreExpected)
+  {
+    if(!moreExpected) eventcounter=0;
+    
+    if(--eventcounter<=0)
+      {
+        co_yield(true);
+        eventcounter=frequency;
+      }
+  }
+  
+
+  /**
+   * Co_Yield handles coroutine interactions while a parse is in progress.
+   * It will resume with 
+   *   co_resume(Boolean.TRUE, ...) on success with more to parse.
+   *   co_resume(Boolean.FALSE, ...) on success after endDocument.
+   *
+   * When control is passed back it may indicate
+   *
+   *      null            terminate this coroutine.
+   *                      Issues
+   *                          co_exit_to(null, ...)
+   *			  and throws UserRequestedShutdownException
+   *
+   *      Boolean.TRUE    indication to continue parsing the current document.
+   *			  Resumes normal SAX parsing.
+   *
+   *      Boolean.FALSE   indication to discontinue parsing and reset.
+   *			  Throws UserRequestedStopException
+   *			  to return control to the run() loop.
+   */
+  private void co_yield(boolean moreRemains)
+  {
+    // Horrendous kluge to run filter to completion. See below.
+    if(fNeverYieldAgain)
+      return;
+    
+    Object arg= moreRemains ? Boolean.TRUE : Boolean.FALSE;
+    
+    // %REVIEW% End-of-file behavior. When moreRemains==false, we have
+    // just ended parsing the document and are about to return
+    // from the parser.
+    //
+    // If we were invoked from the run() loop, we have to provide
+    // the coroutine argument returned above as the next command
+    // to be processed in that loop.
+    //
+    // Conversely, if we've been running in response to
+    // fXMLReader.parse() invoked directly, we will not be returning
+    // to that loop. In that case, the question becomes one of what we
+    // should do instead. The simplest answer would seem to be to do a
+    // co_exit_to immediately, since we don't have a command loop to
+    // continue to talk to.
+    if(!moreRemains)
+      {
+        if(fRunningInThread)
+          {
+            // Just return. The command loop in run() will send the
+            // "we're done" announcement and request the next command.
+            return; // let the parser terminate itself
+          }
+          
+        else try 
+          {
+            // Forced Termination dialog. Say we're done, wait for a
+            // termination request (don't accept anything else), and
+            // shut down.
+            arg = fCoroutineManager.co_resume(Boolean.FALSE, fParserCoroutineID,
+                                              fAppCoroutineID);
+            while(arg!=null)
+              {
+                System.err.println(
+                  "Filtering CoroutineSAXParser: unexpected resume parameter, "
+                  +arg.getClass()+" with value=\""+arg+'"');
+                // If you don't do this, it can loop forever with the above
+                // error printing out.  -sb
+                arg = new RuntimeException(
+                  "Filtering CoroutineSAXParser: unexpected resume parameter, "
+                  +arg.getClass()+" with value=\""+arg+'"');
+                arg = fCoroutineManager.co_resume(arg, fParserCoroutineID,
+                                                  fAppCoroutineID);
+              }
+            
+            fCoroutineManager.co_exit_to(arg, fParserCoroutineID, fAppCoroutineID);
+            return; // let the parser return
+          }
+        catch(java.lang.NoSuchMethodException e)
+          {
+            // Shouldn't happen unless we've miscoded our coroutine logic
+            // "Shut down the garbage smashers on the detention level!"
+            e.printStackTrace(System.err);
+            fCoroutineManager.co_exit(fParserCoroutineID);
+            throw shutdownException;
+          }
+      } // if moreRemains
+
+
+    else try
+      {
+        arg = fCoroutineManager.co_resume(arg, fParserCoroutineID, fAppCoroutineID);
+
+        // %REVIEW% I'm really not happy with the following:
+        //
+        // If we're running in filter mode, driven by an external SAX
+        // event source, and have been been yielded back to with
+        // Boolean.FALSE (doMore(false)) there are two additional
+        // problems.
+        // 
+        // First: Scott tells me that our technique of throwing an
+        // exception from the ContentHandler to terminate SAX parsing,
+        // while almost a universal practice in the SAX community, is not
+        // acceptable because we can't force this contract upon the event
+        // generator. (Though he feels we _can_ force them to accept a
+        // contract to explicitly send us a fatalError event if parsing
+        // terminates due to some other SAXException... basically, it's
+        // the old "this is a normal condition so it shouldn't be an
+        // exception" rationalle, which has some validity to it.)
+        // Instead, and despite the wasted cycles, he wants me to simply
+        // let the event stream run to completion without passing the
+        // events along to our own client. That requires disabling
+        // co_yeild() as well. IF AND WHEN SAX ADDS AN OFFICIAL
+        // STOP-PARSING-EARLY OPERATION, we can leverage that.
+        //
+        // Second: The current architecture of CoroutineSAXParser's
+        // coroutine transactions assumes that doMore(false) will be
+        // followed by either doParse(newInputSource), or
+        // doTerminate(). We must complete that coroutine dialog.
+        // 
+        // "Black magic is a matter of symbolism and intent."
+        // -- Randall Garrett
+        //
+        // %TBD% We _MUST_ get away from this architecture and switch
+        // to CoroutineSAXFilter, just so we don't have to go through
+        // this "no, I don't want another file, thank you very much"
+        // transaction. In our application we should never need it,
+        // and the only justification for running the parse within a
+        // coroutine request -- capturing SAXExceptions -- could be
+        // handled per the above discussion.
+        // 
+        if(!fRunningInThread && arg==Boolean.FALSE)
+          {
+            clientContentHandler=null;
+            clientLexicalHandler=null;
+            // Anyone else?
+        
+            fNeverYieldAgain=true; // Horrendous kluge parsing to completion:
+
+            // Forced Termination dialog. Say we're done, wait for a
+            // termination request (don't accept anything else), and
+            // shut down.
+            arg = fCoroutineManager.co_resume(Boolean.FALSE, fParserCoroutineID,
+                                              fAppCoroutineID);
+            while(arg!=null)
+              {
+                String msg="Filtering CoroutineSAXParser: "+
+                  "unexpected resume parameter, "+
+                  arg.getClass()+" with value=\""+arg+'"';
+                System.err.println(msg);
+                // If you don't do this, it can loop forever with the above
+                // error printing out.  -sb
+                arg = new RuntimeException(msg);
+                arg = fCoroutineManager.co_resume(arg, fParserCoroutineID,
+                                                  fAppCoroutineID);
+              }
+            
+            fCoroutineManager.co_exit_to(arg, fParserCoroutineID, fAppCoroutineID);
+            return; // let the parser run to completion and return
+          }
+
+        if (arg == null) {
+          fCoroutineManager.co_exit_to(arg, fParserCoroutineID, fAppCoroutineID);
+          throw shutdownException;
+        }
+
+
+        else if (arg instanceof Boolean) {
+          boolean keepgoing = ((Boolean)arg).booleanValue();
+          if (!keepgoing)
+            throw stopException;
+          }
+
+        else // Unexpected!
+          {
+            System.err.println(
+                  "Active CoroutineSAXParser: unexpected resume parameter, "
+                  +arg.getClass
+                  ()+" with value=\""+arg+'"');
+            System.err.println("\tStopping parser rather than risk deadlock");
+            throw new RuntimeException("Coroutine parameter error ("+arg+')');
+          }
+
+      }
+    catch(java.lang.NoSuchMethodException e)
+      {
+        // Shouldn't happen unless we've miscoded our coroutine logic
+        // "Shut down the garbage smashers on the detention level!"
+        e.printStackTrace(System.err);
+        fCoroutineManager.co_exit(fParserCoroutineID);
+        throw shutdownException;
+      }
+  }
+
+
+  /** Between parser executions, wait for our partner to resume us and
+   * tell us what to do:
+   *
+   *      null            terminate this coroutine.
+   *                      exits with:
+   *                          co_exit_to(null, ...)
+   *                      expects next:
+   *                          nothing, we have terminated the thread.
+   *
+   *      InputSource     setup to read from this source.
+   *                      resumes with:
+   *                          co_resume(Boolean.TRUE, ...) on partial parse
+   *                          co_resume(Boolean.FALSE, ...) on complete parse
+   *                          co_resume(Exception, ...) on error.
+   *
+   * %REVEIW% Should this be able to set listeners? Partner coroutine ID?
+   * */
+  public void run() {
+    try 
+      {
+        for(Object arg=fCoroutineManager.co_entry_pause(fParserCoroutineID);
+            true;
+            arg=fCoroutineManager.co_resume(arg, fParserCoroutineID, fAppCoroutineID))
+          {
+            
+            // Shut down requested.
+            if (arg == null) {
+              if(DEBUG)System.out.println("CoroutineSAXParser at-rest shutdown requested");
+              fCoroutineManager.co_exit_to(arg, fParserCoroutineID, fAppCoroutineID);
+              break;
+            }
+            
+            // Start-Parse requested
+            // For the duration of this operation, all coroutine handshaking
+            // will occur in the co_yield method. That's the nice thing about
+            // coroutines; they give us a way to hand off control from the
+            // middle of a synchronous method.
+            if (arg instanceof InputSource) {
+              try {
+              if(DEBUG)System.out.println("Inactive CoroutineSAXParser new parse "+arg);
+                fXMLReader.parse((InputSource)arg);
+                // Tell caller we returned from parsing
+                arg=Boolean.FALSE;
+              }
+
+              catch (SAXException ex) {
+                Exception inner=ex.getException();
+                if(inner instanceof UserRequestedStopException){
+                  if(DEBUG)System.out.println("Active CoroutineSAXParser user stop exception");
+                  arg=Boolean.FALSE;
+                }
+                else if(inner instanceof UserRequestedShutdownException){
+                  if(DEBUG)System.out.println("Active CoroutineSAXParser user shutdown exception");
+                  break;
+                }
+                else {
+                  if(DEBUG)System.out.println("Active CoroutineSAXParser UNEXPECTED SAX exception: "+ex);
+                  arg=ex;		  
+                }
+                
+              }
+              catch(Exception ex)
+                {
+                  if(DEBUG)System.out.println("Active CoroutineSAXParser non-SAX exception: "+ex);
+                  arg = ex;
+                }
+              
+            }
+
+            else // Unexpected!
+              {
+                System.err.println(
+                  "Inactive CoroutineSAXParser: unexpected resume parameter, "
+                  +arg.getClass()+" with value=\""+arg+'"');
+                  
+                // If you don't do this, it can loop forever with the above
+                // error printing out.  -sb
+                arg = new RuntimeException(
+                  "Inactive CoroutineSAXParser: unexpected resume parameter, "
+                  +arg.getClass()+" with value=\""+arg+'"');
+              }
+
+          } // end while
+      } // end try
+    catch(java.lang.NoSuchMethodException e)
+      {
+        // Shouldn't happen unless we've miscoded our coroutine logic
+        // "CPO, shut down the garbage smashers on the detention level!"
+        e.printStackTrace(System.err);
+        fCoroutineManager.co_exit(fParserCoroutineID);
+      }
+  }
+
+  /** Used so co_yield can return control to run for early parse
+   * termination.  */
+  class UserRequestedStopException extends RuntimeException
+  {
+  }
+  
+  /** %REVIEW% Should be static, but can't be because internal class */
+  final UserRequestedStopException stopException=new UserRequestedStopException();
+
+  /** Used so co_yield can return control to run for coroutine thread
+   * termination.  */
+  class UserRequestedShutdownException extends RuntimeException
+  {
+  }
+
+  /** %REVIEW% Should be static, but can't be because internal class */
+  final UserRequestedShutdownException shutdownException = new UserRequestedShutdownException();
+
+  //================================================================
+  /** doParse() is a simple API which tells the coroutine parser
+   * to begin reading from a file.  This is intended to be called from one
+   * of our partner coroutines, and serves both to encapsulate the
+   * communication protocol and to avoid having to explicitly use the
+   * CoroutineParser's coroutine ID number.
+   *
+   * %REVIEW%: If we are NOT running in a thread (if we bound to an
+   * externally invoked XMLReader), this operation is a no-op. I don't
+   * _think_ it can safely synchronously invoke that reader's parse()
+   * operation, or doMore(), which would be the obvious alternatives....
+   *
+   * %REVIEW% Can/should this unify with doMore? (if URI hasn't changed,
+   * parse more from same file, else end and restart parsing...?
+   *
+   * @param source The InputSource to parse from.
+   * @param appCoroutineID The coroutine ID number of the coroutine invoking
+   * this method, so it can be resumed after the parser has responded to the
+   * request.
+   * @return Boolean.TRUE if the CoroutineParser believes more data may be available
+   * for further parsing. Boolean.FALSE if parsing ran to completion.
+   * Exception if the parser objected for some reason.
+   * */
+  public Object doParse(InputSource source, int appCoroutineID)
+  {
+    // %REVIEW% I'm not wild about this solution...
+    if(!fRunningInThread)
+      return Boolean.TRUE; // "Yes, we expect to deliver events."
+
+    try 
+      {
+        Object result=    
+          fCoroutineManager.co_resume(source, appCoroutineID, fParserCoroutineID);
+        
+        // %REVIEW% Better error reporting needed... though most of these
+        // should never arise during normal operation.
+        // Should this rethrow the parse exception?
+        if (result instanceof Exception) {
+          if(result instanceof SAXException)
+          {
+            SAXException se = (SAXException)result;
+            Exception e = se.getException();
+            if(null != e)
+            {
+              e.printStackTrace();
+            }
+            else
+            {
+              System.out.println("\nParser threw exception:");
+              se.printStackTrace();
+            }
+          }
+          else
+          {
+            System.out.println("\nParser threw exception:");
+            ((Exception)result).printStackTrace();
+          }
+        }
+
+        return result;
+      }
+
+    // SHOULD NEVER OCCUR, since the coroutine number and coroutine manager
+    // are those previously established for this CoroutineSAXParser...
+    // So I'm just going to return it as a parsing exception, for now.
+    catch(NoSuchMethodException e)
+      {
+        return e;
+      }
+  }
+  
+  
+  /** doMore() is a simple API which tells the coroutine parser
+   * that we need more nodes.  This is intended to be called from one
+   * of our partner coroutines, and serves both to encapsulate the
+   * communication protocol and to avoid having to explicitly use the
+   * CoroutineParser's coroutine ID number.
+   *
+   * @param parsemore If true, tells the incremental parser to generate
+   * another chunk of output. If false, tells the parser that we're
+   * satisfied and it can terminate parsing of this document.
+   * @param appCoroutineID The coroutine ID number of the coroutine invoking
+   * this method, so it can be resumed after the parser has responded to the
+   * request.
+   * @return Boolean.TRUE if the CoroutineParser believes more data may be available
+   * for further parsing. Boolean.FALSE if parsing ran to completion.
+   * Exception if the parser objected for some reason.
+   * */
+  public Object doMore(boolean parsemore, int appCoroutineID)
+  {
+    try 
+      {
+        Object result =
+          fCoroutineManager.co_resume(parsemore?Boolean.TRUE:Boolean.FALSE,
+                                      appCoroutineID, fParserCoroutineID);
+        
+        // %REVIEW% Better error reporting needed
+        if (result == null)
+          {
+            System.out.println("\nUNEXPECTED: Parser doMore says shut down prematurely.\n");
+          }
+        else if (result instanceof Exception) {
+          System.out.println("\nParser threw exception:");
+          ((Exception)result).printStackTrace();
+        }
+        
+        return result;
+      }
+  
+    // SHOULD NEVER OCCUR, since the coroutine number and coroutine manager
+    // are those previously established for this CoroutineSAXParser...
+    // So I'm just going to return it as a parsing exception, for now.
+    catch(NoSuchMethodException e)
+      {
+        return e;
+      }
+  }
+  
+  
+  /** doTerminate() is a simple API which tells the coroutine
+   * parser to terminate itself.  This is intended to be called from
+   * one of our partner coroutines, and serves both to encapsulate the
+   * communication protocol and to avoid having to explicitly use the
+   * CoroutineParser's coroutine ID number.
+   *
+   * Returns only after the CoroutineParser has acknowledged the request.
+   *
+   * @param appCoroutineID The coroutine ID number of the coroutine invoking
+   * this method, so it can be resumed after the parser has responded to the
+   * request.
+   * */
+  public void doTerminate(int appCoroutineID)
+  {
+    try
+      {
+        Object result =
+          fCoroutineManager.co_resume(null, appCoroutineID, fParserCoroutineID);
+
+        // Debugging; shouldn't arise in normal operation
+        if(result!=null)
+          System.out.println("\nUNEXPECTED: Parser doTerminate answers "+result);
+      }
+    catch(java.lang.NoSuchMethodException e)
+      {
+        // That's OK; if it doesn't exist, we don't need to terminate it
+      }
+  }
+
+//  //================================================================
+//  /** Simple unit test. Attempt coroutine parsing of document indicated
+//   * by first argument (as a URI), report progress.
+//   */
+//  public static void main(String args[])
+//  {
+//    System.out.println("Starting...");
+//
+//    org.xml.sax.XMLReader theSAXParser=
+//      new org.apache.xerces.parsers.SAXParser();
+//    
+//    CoroutineManager co = new CoroutineManager();
+//    int appCoroutineID = co.co_joinCoroutineSet(-1);
+//    if (appCoroutineID == -1)
+//      {
+//        System.out.println("ERROR: Couldn't allocate coroutine number.\n");
+//        return;
+//      }
+//    CoroutineSAXParser parser=
+//      new CoroutineSAXParser(co, appCoroutineID, theSAXParser);
+//    int parserCoroutineID = parser.getParserCoroutineID();
+//
+//    // Use a serializer as our sample output
+//    org.apache.xml.serialize.XMLSerializer trace;
+//    trace=new org.apache.xml.serialize.XMLSerializer(System.out,null);
+//    parser.setContentHandler(trace);
+//    parser.setLexHandler(trace);
+//
+//    // Tell coroutine to begin parsing, run while parsing is in progress
+//    for(int arg=0;arg<args.length;++arg)
+//      {
+//        InputSource source = new InputSource(args[arg]);
+//        Object result=null;
+//        boolean more=true;
+//        for(result = parser.doParse(source, appCoroutineID);
+//            (result instanceof Boolean && ((Boolean)result)==Boolean.TRUE);
+//            result = parser.doMore(more, appCoroutineID))
+//          {
+//            System.out.println("\nSome parsing successful, trying more.\n");
+//            
+//            // Special test: Terminate parsing early.
+//            if(arg+1<args.length && "!".equals(args[arg+1]))
+//              {
+//                ++arg;
+//                more=false;
+//              }
+//            
+//          }
+//        
+//        if (result instanceof Boolean && ((Boolean)result)==Boolean.FALSE)
+//          {
+//            System.out.println("\nParser ended (EOF or on request).\n");
+//          }
+//        else if (result == null) {
+//          System.out.println("\nUNEXPECTED: Parser says shut down prematurely.\n");
+//        }
+//        else if (result instanceof Exception) {
+//          System.out.println("\nParser threw exception:");
+//          ((Exception)result).printStackTrace();
+//        }
+//        
+//      }
+//
+//    parser.doTerminate(appCoroutineID);
+//  }
+  
+} // class CoroutineSAXParser
diff --git a/src/org/apache/xml/dtm/CoroutineSAXParser_Xerces.java b/src/org/apache/xml/dtm/CoroutineSAXParser_Xerces.java
new file mode 100644
index 0000000..b279f98
--- /dev/null
+++ b/src/org/apache/xml/dtm/CoroutineSAXParser_Xerces.java
@@ -0,0 +1,334 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999,2000 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xerces" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.apache.org.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+//package org.apache.xerces.parsers;
+package org.apache.xml.dtm;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import java.io.IOException;
+//import org.apache.xml.dtm.CoroutineManager;
+import org.apache.xerces.parsers.SAXParser;
+
+/** <p>CoroutineSAXParser_Xerces takes advantage of the fact that Xerces
+ * incremental mode is already a coroutine of sorts, and just wraps our
+ * CoroutineParser API around it.</p>
+ *
+ * NOTE that this requires access to a few features which are not yet
+ * part of the public Xerces API. Glenn solved that by making this class
+ * a subclass of xerces.parsers.SAXParser. A better solution may be to
+ * make a separate subclass thereof which exposes the relevant methods as
+ * public -- both because it provides more explicit control over what
+ * is and isn't exposed, and because it holds out the hope of dropping that
+ * subclass and plugging in a normal instance of Xerces if/when these methods
+ * become official API calls.
+ *
+ * <p>Usage example: See main().</p>
+ *
+ * <p>Status: Passes simple main() unit-test. NEEDS JAVADOC.</p>
+ * */
+public class CoroutineSAXParser_Xerces
+// extends org.apache.xerces.parsers.SAXParser
+implements CoroutineParser
+{
+  // IncrementalXercesSaxParser incrementalParser;
+  SAXParser incrementalParser;
+
+    //
+    // Data
+    //
+
+    private boolean fParseInProgress=false;
+
+    //
+    // Constructors
+    //
+
+    public CoroutineSAXParser_Xerces(CoroutineManager co, int appCoroutineID) {
+      this(null,co,appCoroutineID);
+    }
+
+    public CoroutineSAXParser_Xerces(SAXParser ixsp, CoroutineManager co, int appCoroutineID) {
+
+      if(ixsp!=null)
+        incrementalParser=ixsp;
+      else
+        incrementalParser=new SAXParser();
+      
+      // incrementalParser.initHandlers(true, incrementalParser, incrementalParser);
+    }
+
+    //
+    // Factories
+    //
+    static public CoroutineParser createCoroutineParser(CoroutineManager co, int appCoroutineID) {
+      return new CoroutineSAXParser_Xerces(co, appCoroutineID);
+    }
+
+    //
+    // Public methods
+    //
+
+    // coroutine support
+
+    public int getParserCoroutineID() {
+      // return fParserCoroutineID;
+      return -1;
+    }
+
+  /** @return the CoroutineManager this CoroutineParser object is bound to.
+   * If you're using the do...() methods, applications should only
+   * need to talk to the CoroutineManager once, to obtain the
+   * application's Coroutine ID.
+   * */
+  public CoroutineManager getCoroutineManager()
+  {
+    // return fCoroutineManager;
+    return null;
+  }
+
+  // Register handler directly with the incremental parser
+  public void setContentHandler(org.xml.sax.ContentHandler handler)
+  {
+    incrementalParser.setContentHandler(handler);
+  }
+
+  // Note name, needed to dodge the inherited Xerces setLexicalHandler
+  // which isn't public.
+  public void setLexHandler(org.xml.sax.ext.LexicalHandler handler)
+  {
+    // Not supported by all SAX2 parsers but should work in Xerces:
+    try 
+      {
+        incrementalParser.setProperty("http://xml.org/sax/properties/lexical-handler",
+                    handler);
+      }
+    catch(org.xml.sax.SAXNotRecognizedException e)
+      {
+        // Nothing we can do about it
+      }
+    catch(org.xml.sax.SAXNotSupportedException e)
+      {
+        // Nothing we can do about it
+      }
+  }
+  
+  //================================================================
+  /** doParse() is a simple API which tells the coroutine parser
+   * to begin reading from a file.  This is intended to be called from one
+   * of our partner coroutines, and serves both to encapsulate the
+   * communication protocol and to avoid having to explicitly use the
+   * CoroutineParser's coroutine ID number.
+   *
+   * %REVIEW% Can/should this unify with doMore? (if URI hasn't changed,
+   * parse more from same file, else end and restart parsing...?
+   *
+   * @param source The InputSource to parse from.
+   * @param appCoroutineID The coroutine ID number of the coroutine invoking
+   * this method, so it can be resumed after the parser has responded to the
+   * request.
+   * @return Boolean.TRUE if the CoroutineParser believes more data may be available
+   * for further parsing. Boolean.FALSE if parsing ran to completion.
+   * Exception if the parser objected for some reason.
+   * */
+  public Object doParse(InputSource source, int appCoroutineID)
+  {
+    if (fParseInProgress) {
+      // %review% -- We never set this flag in the previous version of
+      // this class, we still don't set it here... Discard, or fix?
+      return new SAXException("parse may not be called while parsing.");
+    }
+    
+    Object arg;
+    try {
+      boolean ok = incrementalParser.parseSomeSetup(source);
+      arg = ok ? Boolean.TRUE : Boolean.FALSE;
+    }
+    catch (Exception ex) {
+      arg = ex;
+    }
+    return arg;
+  }
+
+  
+  /** doMore() is a simple API which tells the coroutine parser
+   * that we need more nodes.  This is intended to be called from one
+   * of our partner coroutines, and serves both to encapsulate the
+   * communication protocol and to avoid having to explicitly use the
+   * CoroutineParser's coroutine ID number.
+   *
+   * @param parsemore If true, tells the incremental parser to generate
+   * another chunk of output. If false, tells the parser that we're
+   * satisfied and it can terminate parsing of this document.
+   * @param appCoroutineID The coroutine ID number of the coroutine invoking
+   * this method, so it can be resumed after the parser has responded to the
+   * request.
+   * @return Boolean.TRUE if the CoroutineParser believes more data may be available
+   * for further parsing. Boolean.FALSE if parsing ran to completion.
+   * Exception if the parser objected for some reason.
+   * */
+  public Object doMore (boolean parsemore, int appCoroutineID)
+  {
+    if(!parsemore)
+      {
+        fParseInProgress=false;
+        return Boolean.FALSE;
+      }
+
+    Object arg;
+    try {
+      boolean keepgoing = incrementalParser.parseSome();
+      arg = keepgoing ? Boolean.TRUE : Boolean.FALSE;
+    } catch (SAXException ex) {
+      arg = ex;
+    } catch (IOException ex) {
+      arg = ex;
+    } catch (Exception ex) {
+      arg = new SAXException(ex);
+    }
+    return arg;
+  }
+  
+  /** doTerminate() is a simple API which tells the coroutine
+   * parser to terminate itself.  This is intended to be called from
+   * one of our partner coroutines, and serves both to encapsulate the
+   * communication protocol and to avoid having to explicitly use the
+   * CoroutineParser's coroutine ID number.
+   *
+   * Returns only after the CoroutineParser has acknowledged the request.
+   *
+   * @param appCoroutineID The coroutine ID number of the coroutine invoking
+   * this method, so it can be resumed after the parser has responded to the
+   * request.
+   * */
+  public void doTerminate(int appCoroutineID)
+  {
+    // No-op in IncrementalXerces?
+
+    // Could release some data structures to promote garbage collection...
+    incrementalParser=null;
+  }
+
+  //================================================================
+  /** Simple unit test. Attempt coroutine parsing of document indicated
+   * by first argument (as a URI), report progress.
+   */
+  public static void main(String args[])
+  {
+    System.out.println("Starting...");
+
+    CoroutineManager co = new CoroutineManager();
+    int appCoroutineID = co.co_joinCoroutineSet(-1);
+    if (appCoroutineID == -1)
+      {
+        System.out.println("ERROR: Couldn't allocate coroutine number.\n");
+        return;
+      }
+    CoroutineSAXParser_Xerces parser=
+      new CoroutineSAXParser_Xerces(co, appCoroutineID);
+    int parserCoroutineID = parser.getParserCoroutineID();
+
+    // Use a serializer as our sample output
+    org.apache.xml.serialize.XMLSerializer trace;
+    trace=new org.apache.xml.serialize.XMLSerializer(System.out,null);
+    parser.setContentHandler(trace);
+    parser.setLexHandler(trace);
+
+    // Tell coroutine to begin parsing, run while parsing is in progress
+    for(int arg=0;arg<args.length;++arg)
+      {
+        InputSource source = new InputSource(args[arg]);
+        Object result=null;
+        boolean more=true;
+        /**    
+          for(result = co.co_resume(source, appCoroutineID, parserCoroutineID);
+          (result instanceof Boolean && ((Boolean)result)==Boolean.TRUE);
+          result = co.co_resume(more, appCoroutineID, parserCoroutineID))
+          **/
+        for(result = parser.doParse(source, appCoroutineID);
+            (result instanceof Boolean && ((Boolean)result)==Boolean.TRUE);
+            result = parser.doMore(more, appCoroutineID))
+          {
+            System.out.println("\nSome parsing successful, trying more.\n");
+            
+            // Special test: Terminate parsing early.
+            if(arg+1<args.length && "!".equals(args[arg+1]))
+              {
+                ++arg;
+                more=false;
+              }
+            
+          }
+        
+        if (result instanceof Boolean && ((Boolean)result)==Boolean.FALSE)
+          {
+            System.out.println("\nParser ended (EOF or on request).\n");
+          }
+        else if (result == null) {
+          System.out.println("\nUNEXPECTED: Parser says shut down prematurely.\n");
+        }
+        else if (result instanceof Exception) {
+          System.out.println("\nParser threw exception:");
+          ((Exception)result).printStackTrace();
+        }
+        
+      }
+
+    parser.doTerminate(appCoroutineID);
+  }
+  
+} // class CoroutineSAXParser
diff --git a/src/org/apache/xml/dtm/CustomStringPool.java b/src/org/apache/xml/dtm/CustomStringPool.java
new file mode 100644
index 0000000..cdc0325
--- /dev/null
+++ b/src/org/apache/xml/dtm/CustomStringPool.java
@@ -0,0 +1,125 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999,2000 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xerces" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.apache.org.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.xml.dtm;
+import java.util.Vector;
+import java.util.Hashtable;
+
+/** <p>CustomStringPool is an example of appliction provided data structure
+ * for a DTM implementation to hold symbol references, e.g. elelment names.
+ * It will follow the DTMDStringPool interface and use two simple methods
+ * indexToString(int i) and stringToIndex(Sring s) to map between a set of
+ * string values and a set of integer index values.  Therefore, an application
+ * may improve DTM processing speed by substituting the DTM symbol resolution
+ * tables with application specific quick symbol resolution tables.</p>
+ *
+ * %REVIEW% The only difference between this an DTMStringPool seems to be that
+ * it uses a java.lang.Hashtable full of Integers rather than implementing its
+ * own hashing. Joe deliberately avoided that approach when writing
+ * DTMStringPool, since it is both much more memory-hungry and probably slower
+ * -- especially in JDK 1.1.x, where Hashtable is synchronized. We need to
+ * either justify this implementation or discard it.
+ *
+ * <p>Status: In progress, under discussion.</p>
+ * */
+public class CustomStringPool extends DTMStringPool {
+	//final Vector m_intToString;
+	//static final int HASHPRIME=101;
+	//int[] m_hashStart=new int[HASHPRIME];
+	final Hashtable m_stringToInt = new Hashtable();
+	public static final int NULL=-1;
+
+	public CustomStringPool()
+	{
+		super();
+		/*m_intToString=new Vector();
+		System.out.println("In constructor m_intToString is " + 
+											 ((null == m_intToString) ? "null" : "not null"));*/
+		//m_stringToInt=new Hashtable();
+		//removeAllElements();
+	}
+
+	public void removeAllElements()
+	{
+		m_intToString.removeAllElements();
+		if (m_stringToInt != null) 
+			m_stringToInt.clear();
+	}
+
+	/** @return string whose value is uniquely identified by this integer index.
+	 * @throws java.lang.ArrayIndexOutOfBoundsException
+	 *  if index doesn't map to a string.
+	 * */
+	public String indexToString(int i)
+	throws java.lang.ArrayIndexOutOfBoundsException
+	{
+		return(String) m_intToString.elementAt(i);
+	}
+
+	/** @return integer index uniquely identifying the value of this string. */
+	public int stringToIndex(String s)
+	{
+		if (s==null) return NULL;
+		Integer iobj=(Integer)m_stringToInt.get(s);
+		if (iobj==null) {
+			m_intToString.addElement(s);
+			iobj=new Integer(m_intToString.size());
+			m_stringToInt.put(s,iobj);
+		}
+		return iobj.intValue();
+	}
+}
diff --git a/src/org/apache/xml/dtm/DTM.java b/src/org/apache/xml/dtm/DTM.java
new file mode 100644
index 0000000..7968a68
--- /dev/null
+++ b/src/org/apache/xml/dtm/DTM.java
@@ -0,0 +1,894 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xml.dtm;
+
+import org.apache.xml.utils.XMLString;
+
+/**
+ * <code>DTM</code> is an XML document model expressed as a table
+ * rather than an object tree. It attempts to provide an interface to
+ * a parse tree that has very little object creation. (DTM
+ * implementations may also support incremental construction of the
+ * model, but that's hidden from the DTM API.)
+ *
+ * <p>Nodes in the DTM are identified by integer "handles".  A handle must
+ * be unique within a process, and carries both node identification and
+ * document identification.  It must be possible to compare two handles
+ * (and thus their nodes) for identity with "==".</p>
+ *
+ * <p>Namespace URLs, local-names, and expanded-names can all be
+ * represented by and tested as integer ID values.  An expanded name
+ * represents (and may or may not directly contain) a combination of
+ * the URL ID, and the local-name ID.  Note that the namespace URL id
+ * can be 0, which should have the meaning that the namespace is null.
+ * For consistancy, zero should not be used for a local-name index. </p>
+ *
+ * <p>Text content of a node is represented by an index and length,
+ * permitting efficient storage such as a shared FastStringBuffer.</p>
+ *
+ * <p>The model of the tree, as well as the general navigation model,
+ * is that of XPath 1.0, for the moment.  The model will eventually be
+ * adapted to match the XPath 2.0 data model, XML Schema, and
+ * InfoSet.</p>
+ *
+ * <p>DTM does _not_ directly support the W3C's Document Object
+ * Model. However, it attempts to come close enough that an
+ * implementation of DTM can be created that wraps a DOM and vice
+ * versa.</p>
+ *
+ * <p>State: In progress!!</p> 
+ */
+public interface DTM
+{
+
+  /**
+   * Null node handles are represented by this value.
+   */
+  public static final int NULL = -1;
+
+  // These nodeType mnemonics and values are deliberately the same as those
+  // used by the DOM, for convenient mapping
+  //
+  // %REVIEW% Should we actually define these as initialized to,
+  // eg. org.w3c.dom.Document.ELEMENT_NODE?
+
+  /**
+   * The node is an <code>Element</code>.
+   */
+  public static final short ELEMENT_NODE = 1;
+
+  /**
+   * The node is an <code>Attr</code>.
+   */
+  public static final short ATTRIBUTE_NODE = 2;
+
+  /**
+   * The node is a <code>Text</code> node.
+   */
+  public static final short TEXT_NODE = 3;
+
+  /**
+   * The node is a <code>CDATASection</code>.
+   */
+  public static final short CDATA_SECTION_NODE = 4;
+
+  /**
+   * The node is an <code>EntityReference</code>.
+   */
+  public static final short ENTITY_REFERENCE_NODE = 5;
+
+  /**
+   * The node is an <code>Entity</code>.
+   */
+  public static final short ENTITY_NODE = 6;
+
+  /**
+   * The node is a <code>ProcessingInstruction</code>.
+   */
+  public static final short PROCESSING_INSTRUCTION_NODE = 7;
+
+  /**
+   * The node is a <code>Comment</code>.
+   */
+  public static final short COMMENT_NODE = 8;
+
+  /**
+   * The node is a <code>Document</code>.
+   */
+  public static final short DOCUMENT_NODE = 9;
+
+  /**
+   * The node is a <code>DocumentType</code>.
+   */
+  public static final short DOCUMENT_TYPE_NODE = 10;
+
+  /**
+   * The node is a <code>DocumentFragment</code>.
+   */
+  public static final short DOCUMENT_FRAGMENT_NODE = 11;
+
+  /**
+   * The node is a <code>Notation</code>.
+   */
+  public static final short NOTATION_NODE = 12;
+
+  /**
+   * The node is a <code>namespace node</code>. Note that this is not
+   * currently a node type defined by the DOM API.
+   */
+  public static final short NAMESPACE_NODE = 13;
+
+  // ========= DTM Implementation Control Functions. ==============
+  // %TBD% RETIRED -- do via setFeature if needed. Remove from impls.
+  // public void setParseBlockSize(int blockSizeSuggestion);
+
+  /**
+   * Set an implementation dependent feature.
+   * <p>
+   * %REVIEW% Do we really expect to set features on DTMs?
+   *
+   * @param featureId A feature URL.
+   * @param state true if this feature should be on, false otherwise.
+   */
+  public void setFeature(String featureId, boolean state);
+
+  // ========= Document Navigation Functions =========
+
+  /**
+   * Given a node handle, test if it has child nodes.
+   * <p> %REVIEW% This is obviously useful at the DOM layer, where it
+   * would permit testing this without having to create a proxy
+   * node. It's less useful in the DTM API, where
+   * (dtm.getFirstChild(nodeHandle)!=DTM.NULL) is just as fast and
+   * almost as self-evident. But it's a convenience, and eases porting
+   * of DOM code to DTM.  </p>
+   *
+   * @param nodeHandle int Handle of the node.
+   * @return int true if the given node has child nodes.
+   */
+  public boolean hasChildNodes(int nodeHandle);
+
+  /**
+   * Given a node handle, get the handle of the node's first child.
+   *
+   * @param nodeHandle int Handle of the node.
+   * @return int DTM node-number of first child,
+   * or DTM.NULL to indicate none exists.
+   */
+  public int getFirstChild(int nodeHandle);
+
+  /**
+   * Given a node handle, get the handle of the node's last child.
+   *
+   * @param nodeHandle int Handle of the node.
+   * @return int Node-number of last child,
+   * or DTM.NULL to indicate none exists.
+   */
+  public int getLastChild(int nodeHandle);
+
+  /**
+   * Retrieves an attribute node by local name and namespace URI
+   *
+   * %TBD% Note that we currently have no way to support
+   * the DOM's old getAttribute() call, which accesses only the qname.
+   *
+   * @param elementHandle Handle of the node upon which to look up this attribute.
+   * @param namespaceURI The namespace URI of the attribute to
+   *   retrieve, or null.
+   * @param name The local name of the attribute to
+   *   retrieve.
+   * @return The attribute node handle with the specified name (
+   *   <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such
+   *   attribute.
+   */
+  public int getAttributeNode(int elementHandle, String namespaceURI,
+                              String name);
+
+  /**
+   * Given a node handle, get the index of the node's first attribute.
+   *
+   * @param nodeHandle int Handle of the node.
+   * @return Handle of first attribute, or DTM.NULL to indicate none exists.
+   */
+  public int getFirstAttribute(int nodeHandle);
+
+  /**
+   * Given a node handle, get the index of the node's first namespace node.
+   *
+   * @param nodeHandle handle to node, which should probably be an element
+   *                   node, but need not be.
+   *
+   * @param inScope true if all namespaces in scope should be
+   *                   returned, false if only the node's own
+   *                   namespace declarations should be returned.
+   * @return handle of first namespace,
+   * or DTM.NULL to indicate none exists.
+   */
+  public int getFirstNamespaceNode(int nodeHandle, boolean inScope);
+
+  /**
+   * Given a node handle, advance to its next sibling.
+   * @param nodeHandle int Handle of the node.
+   * @return int Node-number of next sibling,
+   * or DTM.NULL to indicate none exists.
+   */
+  public int getNextSibling(int nodeHandle);
+
+  /**
+   * Given a node handle, find its preceeding sibling.
+   * WARNING: DTM implementations may be asymmetric; in some,
+   * this operation has been resolved by search, and is relatively expensive.
+   *
+   * @param nodeHandle the id of the node.
+   * @return int Node-number of the previous sib,
+   * or DTM.NULL to indicate none exists.
+   */
+  public int getPreviousSibling(int nodeHandle);
+
+  /**
+   * Given a node handle, advance to the next attribute. If an
+   * element, we advance to its first attribute; if an attr, we advance to
+   * the next attr of the same element.
+   *
+   * @param nodeHandle int Handle of the node.
+   * @return int DTM node-number of the resolved attr,
+   * or DTM.NULL to indicate none exists.
+   */
+  public int getNextAttribute(int nodeHandle);
+
+  /**
+   * Given a namespace handle, advance to the next namespace in the same scope
+   * (local or local-plus-inherited, as selected by getFirstNamespaceNode)
+   *
+   * @param baseHandle handle to original node from where the first child
+   * was relative to (needed to return nodes in document order).
+   * @param namespaceHandle handle to node which must be of type
+   * NAMESPACE_NODE.
+   * NEEDSDOC @param inScope
+   * @return handle of next namespace,
+   * or DTM.NULL to indicate none exists.
+   */
+  public int getNextNamespaceNode(int baseHandle, int namespaceHandle,
+                                  boolean inScope);
+
+  /**
+   * Given a node handle, find its parent node.
+   *
+   * @param nodeHandle the id of the node.
+   * @return int Node handle of parent,
+   * or DTM.NULL to indicate none exists.
+   */
+  public int getParent(int nodeHandle);
+
+  /**
+   * Given a node handle, find the owning document node. Note that
+   * the reason this can't just return 0 is that it needs to include the
+   * document number portion of the node handle.
+   *
+   * @param nodeHandle the id of the node.
+   * @return int Node handle of document, which should always be valid.
+   */
+  public int getDocument();
+
+  /**
+   * Given a node handle, find the owning document node.  This has the exact
+   * same semantics as the DOM Document method of the same name, in that if
+   * the nodeHandle is a document node, it will return NULL.
+   *
+   * @param nodeHandle the id of the node.
+   * @return int Node handle of owning document,
+   * or DTM.NULL if the nodeHandle is a document.
+   */
+  public int getOwnerDocument(int nodeHandle);
+
+  /**
+   * Get the string-value of a node as a String object
+   * (see http://www.w3.org/TR/xpath#data-model
+   * for the definition of a node's string-value).
+   *
+   * @param nodeHandle The node ID.
+   *
+   * @return A string object that represents the string-value of the given node.
+   */
+  public XMLString getStringValue(int nodeHandle);
+
+  /**
+   * Get number of character array chunks in
+   * the string-value of a node.
+   * (see http://www.w3.org/TR/xpath#data-model
+   * for the definition of a node's string-value).
+   * Note that a single text node may have multiple text chunks.
+   *
+   * @param nodeHandle The node ID.
+   *
+   * @return number of character array chunks in
+   *         the string-value of a node.
+   */
+  public int getStringValueChunkCount(int nodeHandle);
+
+  /**
+   * Get a character array chunk in the string-value of a node.
+   * (see http://www.w3.org/TR/xpath#data-model
+   * for the definition of a node's string-value).
+   * Note that a single text node may have multiple text chunks.
+   *
+   * @param nodeHandle The node ID.
+   * @param chunkIndex Which chunk to get.
+   * @param startAndLen  A two-integer array which, upon return, WILL
+   * BE FILLED with values representing the chunk's start position
+   * within the returned character buffer and the length of the chunk.
+   * @return The character array buffer within which the chunk occurs,
+   * setting startAndLen's contents as a side-effect.
+   */
+  public char[] getStringValueChunk(int nodeHandle, int chunkIndex,
+                                    int[] startAndLen);
+
+  /**
+   * Given a node handle, return an ID that represents the node's expanded name.
+   *
+   * @param nodeHandle The handle to the node in question.
+   *
+   * @return the expanded-name id of the node.
+   */
+  public int getExpandedNameID(int nodeHandle);
+
+  /**
+   * Given an expanded name, return an ID.  If the expanded-name does not
+   * exist in the internal tables, the entry will be created, and the ID will
+   * be returned.  Any additional nodes that are created that have this
+   * expanded name will use this ID.
+   *
+   * @param nodeHandle The handle to the node in question.
+   *
+   * NEEDSDOC @param namespace
+   * NEEDSDOC @param localName
+   * NEEDSDOC @param type
+   *
+   * @return the expanded-name id of the node.
+   */
+  public int getExpandedNameID(String namespace, String localName, int type);
+
+  /**
+   * Given an expanded-name ID, return the local name part.
+   *
+   * @param ExpandedNameID an ID that represents an expanded-name.
+   * @return String Local name of this node.
+   */
+  public String getLocalNameFromExpandedNameID(int ExpandedNameID);
+
+  /**
+   * Given an expanded-name ID, return the namespace URI part.
+   *
+   * @param ExpandedNameID an ID that represents an expanded-name.
+   * @return String URI value of this node's namespace, or null if no
+   * namespace was resolved.
+   */
+  public String getNamespaceFromExpandedNameID(int ExpandedNameID);
+
+  /**
+   * Given a node handle, return its DOM-style node name. This will
+   * include names such as #text or #document.
+   *
+   * @param nodeHandle the id of the node.
+   * @return String Name of this node, which may be an empty string.
+   * %REVIEW% Document when empty string is possible...
+   */
+  public String getNodeName(int nodeHandle);
+
+  /**
+   * Given a node handle, return the XPath node name.  This should be
+   * the name as described by the XPath data model, NOT the DOM-style
+   * name.
+   *
+   * @param nodeHandle the id of the node.
+   * @return String Name of this node.
+   */
+  public String getNodeNameX(int nodeHandle);
+
+  /**
+   * Given a node handle, return its DOM-style localname.
+   * (As defined in Namespaces, this is the portion of the name after the
+   * prefix, if present, or the whole node name if no prefix exists)
+   *
+   * @param nodeHandle the id of the node.
+   * @return String Local name of this node.
+   */
+  public String getLocalName(int nodeHandle);
+
+  /**
+   * Given a namespace handle, return the prefix that the namespace decl is
+   * mapping.
+   * Given a node handle, return the prefix used to map to the namespace.
+   * (As defined in Namespaces, this is the portion of the name before any
+   * colon character).
+   * @param postition int Handle of the node.
+   *
+   * <p> %REVIEW% Are you sure you want "" for no prefix?  </p>
+   *
+   * @param nodeHandle the id of the node.
+   * @return String prefix of this node's name, or "" if no explicit
+   * namespace prefix was given.
+   */
+  public String getPrefix(int nodeHandle);
+
+  /**
+   * Given a node handle, return its DOM-style namespace URI
+   * (As defined in Namespaces, this is the declared URI which this node's
+   * prefix -- or default in lieu thereof -- was mapped to.)
+   * @param postition int Handle of the node.
+   *
+   * @param nodeHandle the id of the node.
+   * @return String URI value of this node's namespace, or null if no
+   * namespace was resolved.
+   */
+  public String getNamespaceURI(int nodeHandle);
+
+  /**
+   * Given a node handle, return its node value. This is mostly
+   * as defined by the DOM, but may ignore some conveniences.
+   * <p>
+   * @param nodeHandle The node id.
+   * @return String Value of this node, or null if not
+   * meaningful for this node type.
+   */
+  public String getNodeValue(int nodeHandle);
+
+  /**
+   * Given a node handle, return its DOM-style node type.
+   *
+   * <p>%REVIEW% Generally, returning short is false economy. Return int?</p>
+   *
+   * @param nodeHandle The node id.
+   * @return int Node type, as per the DOM's Node._NODE constants.
+   */
+  public short getNodeType(int nodeHandle);
+
+  /**
+   * <meta name="usage" content="internal"/>
+   * Get the depth level of this node in the tree (equals 1 for
+   * a parentless node).
+   *
+   * @param nodeHandle The node id.
+   * @return the number of ancestors, plus one
+   */
+  public short getLevel(int nodeHandle);
+
+  // ============== Document query functions ============== 
+
+  /**
+   * Tests whether DTM DOM implementation implements a specific feature and
+   * that feature is supported by this node.
+   * @param feature The name of the feature to test.
+   * @param version This is the version number of the feature to test.
+   *   If the version is not
+   *   specified, supporting any version of the feature will cause the
+   *   method to return <code>true</code>.
+   * @return Returns <code>true</code> if the specified feature is
+   *   supported on this node, <code>false</code> otherwise.
+   */
+  public boolean isSupported(String feature, String version);
+
+  /**
+   * Return the base URI of the document entity. If it is not known
+   * (because the document was parsed from a socket connection or from
+   * standard input, for example), the value of this property is unknown.
+   *
+   * @return the document base URI String object or null if unknown.
+   */
+  public String getDocumentBaseURI();
+
+  /**
+   * Set the base URI of the document entity.
+   *
+   * @param baseURI the document base URI String object or null if unknown.
+   */
+  public void setDocumentBaseURI(String baseURI);
+
+  /**
+   * Return the system identifier of the document entity. If
+   * it is not known, the value of this property is null.
+   *
+   * @param nodeHandle The node id, which can be any valid node handle.
+   * @return the system identifier String object or null if unknown.
+   */
+  public String getDocumentSystemIdentifier(int nodeHandle);
+
+  /**
+   * Return the name of the character encoding scheme
+   *        in which the document entity is expressed.
+   *
+   * @param nodeHandle The node id, which can be any valid node handle.
+   * @return the document encoding String object.
+   */
+  public String getDocumentEncoding(int nodeHandle);
+
+  /**
+   * Return an indication of the standalone status of the document,
+   *        either "yes" or "no". This property is derived from the optional
+   *        standalone document declaration in the XML declaration at the
+   *        beginning of the document entity, and has no value if there is no
+   *        standalone document declaration.
+   *
+   * @param nodeHandle The node id, which can be any valid node handle.
+   * @return the document standalone String object, either "yes", "no", or null.
+   */
+  public String getDocumentStandalone(int nodeHandle);
+
+  /**
+   * Return a string representing the XML version of the document. This
+   * property is derived from the XML declaration optionally present at the
+   * beginning of the document entity, and has no value if there is no XML
+   * declaration.
+   *
+   * @param the document handle
+   *
+   * NEEDSDOC @param documentHandle
+   *
+   * @return the document version String object
+   */
+  public String getDocumentVersion(int documentHandle);
+
+  /**
+   * Return an indication of
+   * whether the processor has read the complete DTD. Its value is a
+   * boolean. If it is false, then certain properties (indicated in their
+   * descriptions below) may be unknown. If it is true, those properties
+   * are never unknown.
+   *
+   * @return <code>true</code> if all declarations were processed;
+   *         <code>false</code> otherwise.
+   */
+  public boolean getDocumentAllDeclarationsProcessed();
+
+  /**
+   *   A document type declaration information item has the following properties:
+   *
+   *     1. [system identifier] The system identifier of the external subset, if
+   *        it exists. Otherwise this property has no value.
+   *
+   * @return the system identifier String object, or null if there is none.
+   */
+  public String getDocumentTypeDeclarationSystemIdentifier();
+
+  /**
+   * Return the public identifier of the external subset,
+   * normalized as described in 4.2.2 External Entities [XML]. If there is
+   * no external subset or if it has no public identifier, this property
+   * has no value.
+   *
+   * @param the document type declaration handle
+   *
+   * @return the public identifier String object, or null if there is none.
+   */
+  public String getDocumentTypeDeclarationPublicIdentifier();
+
+  /**
+   * Returns the <code>Element</code> whose <code>ID</code> is given by
+   * <code>elementId</code>. If no such element exists, returns
+   * <code>DTM.NULL</code>. Behavior is not defined if more than one element
+   * has this <code>ID</code>. Attributes (including those
+   * with the name "ID") are not of type ID unless so defined by DTD/Schema
+   * information available to the DTM implementation.
+   * Implementations that do not know whether attributes are of type ID or
+   * not are expected to return <code>DTM.NULL</code>.
+   *
+   * <p>%REVIEW% Presumably IDs are still scoped to a single document,
+   * and this operation searches only within a single document, right?
+   * Wouldn't want collisions between DTMs in the same process.</p>
+   *
+   * @param elementId The unique <code>id</code> value for an element.
+   * @return The handle of the matching element.
+   */
+  public int getElementById(String elementId);
+
+  /**
+   * The getUnparsedEntityURI function returns the URI of the unparsed
+   * entity with the specified name in the same document as the context
+   * node (see [3.3 Unparsed Entities]). It returns the empty string if
+   * there is no such entity.
+   * <p>
+   * XML processors may choose to use the System Identifier (if one
+   * is provided) to resolve the entity, rather than the URI in the
+   * Public Identifier. The details are dependent on the processor, and
+   * we would have to support some form of plug-in resolver to handle
+   * this properly. Currently, we simply return the System Identifier if
+   * present, and hope that it a usable URI or that our caller can
+   * map it to one.
+   * %REVIEW% Resolve Public Identifiers... or consider changing function name.
+   * <p>
+   * If we find a relative URI
+   * reference, XML expects it to be resolved in terms of the base URI
+   * of the document. The DOM doesn't do that for us, and it isn't
+   * entirely clear whether that should be done here; currently that's
+   * pushed up to a higher level of our application. (Note that DOM Level
+   * 1 didn't store the document's base URI.)
+   * %REVIEW% Consider resolving Relative URIs.
+   * <p>
+   * (The DOM's statement that "An XML processor may choose to
+   * completely expand entities before the structure model is passed
+   * to the DOM" refers only to parsed entities, not unparsed, and hence
+   * doesn't affect this function.)
+   *
+   * @param name A string containing the Entity Name of the unparsed
+   * entity.
+   *
+   * @return String containing the URI of the Unparsed Entity, or an
+   * empty string if no such entity exists.
+   */
+  public String getUnparsedEntityURI(String name);
+
+  // ============== Boolean methods ================
+
+  /**
+   * Return true if the xsl:strip-space or xsl:preserve-space was processed
+   * during construction of the document contained in this DTM.
+   *
+   * NEEDSDOC ($objectName$) @return
+   */
+  public boolean supportsPreStripping();
+
+  /**
+   * Figure out whether nodeHandle2 should be considered as being later
+   * in the document than nodeHandle1, in Document Order as defined
+   * by the XPath model. This may not agree with the ordering defined
+   * by other XML applications.
+   * <p>
+   * There are some cases where ordering isn't defined, and neither are
+   * the results of this function -- though we'll generally return true.
+   * <p>
+   * %REVIEW% Make sure this does the right thing with attribute nodes!!!
+   * <p>
+   * %REVIEW% Consider renaming for clarity. Perhaps isDocumentOrder(a,b)?
+   *
+   * @param firstNodeHandle DOM Node to perform position comparison on.
+   * @param secondNodeHandle DOM Node to perform position comparison on.
+   *
+   * @return false if secondNode comes before firstNode, otherwise return true.
+   * You can think of this as
+   * <code>(firstNode.documentOrderPosition &lt;= secondNode.documentOrderPosition)</code>.  
+   */
+  public boolean isNodeAfter(int firstNodeHandle, int secondNodeHandle);
+
+  /**
+   * 2. [element content whitespace] A boolean indicating whether a
+   * text node represents white space appearing within element content
+   * (see [XML], 2.10 "White Space Handling").  Note that validating
+   * XML processors are required by XML 1.0 to provide this
+   * information... but that DOM Level 2 did not support it, since it
+   * depends on knowledge of the DTD which DOM2 could not guarantee
+   * would be available.
+   * <p>
+   * If there is no declaration for the containing element, an XML
+   * processor must assume that the whitespace could be meaningful and
+   * return false. If no declaration has been read, but the [all
+   * declarations processed] property of the document information item
+   * is false (so there may be an unread declaration), then the value
+   * of this property is indeterminate for white space characters and
+   * should probably be reported as false. It is always false for text
+   * nodes that contain anything other than (or in addition to) white
+   * space.
+   * <p>
+   * Note too that it always returns false for non-Text nodes.
+   * <p>
+   * %REVIEW% Joe wants to rename this isWhitespaceInElementContent() for clarity
+   *
+   * @param nodeHandle the node ID.
+   * @return <code>true</code> if the node definitely represents whitespace in
+   * element content; <code>false</code> otherwise.
+   */
+  public boolean isCharacterElementContentWhitespace(int nodeHandle);
+
+  /**
+   *    10. [all declarations processed] This property is not strictly speaking
+   *        part of the infoset of the document. Rather it is an indication of
+   *        whether the processor has read the complete DTD. Its value is a
+   *        boolean. If it is false, then certain properties (indicated in their
+   *        descriptions below) may be unknown. If it is true, those properties
+   *        are never unknown.
+   *
+   *
+   * @param the document handle
+   *
+   * @param documentHandle A node handle that must identify a document.
+   * @return <code>true</code> if all declarations were processed;
+   *         <code>false</code> otherwise.
+   */
+  public boolean isDocumentAllDeclarationsProcessed(int documentHandle);
+
+  /**
+   *     5. [specified] A flag indicating whether this attribute was actually
+   *        specified in the start-tag of its element, or was defaulted from the
+   *        DTD (or schema).
+   *
+   * @param the attribute handle
+   *
+   * NEEDSDOC @param attributeHandle
+   * @return <code>true</code> if the attribute was specified;
+   *         <code>false</code> if it was defaulted or the handle doesn't
+   *            refer to an attribute node.
+   */
+  public boolean isAttributeSpecified(int attributeHandle);
+
+  // ========== Direct SAX Dispatch, for optimization purposes ========
+
+  /**
+   * Directly call the
+   * characters method on the passed ContentHandler for the
+   * string-value of the given node (see http://www.w3.org/TR/xpath#data-model
+   * for the definition of a node's string-value). Multiple calls to the
+   * ContentHandler's characters methods may well occur for a single call to
+   * this method.
+   *
+   * @param nodeHandle The node ID.
+   * @param ch A non-null reference to a ContentHandler.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public void dispatchCharactersEvents(
+    int nodeHandle, org.xml.sax.ContentHandler ch)
+      throws org.xml.sax.SAXException;
+
+  /**
+   * Directly create SAX parser events representing the XML content of
+   * a DTM subtree. This is a "serialize" operation.
+   *
+   * @param nodeHandle The node ID.
+   * @param ch A non-null reference to a ContentHandler.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch)
+    throws org.xml.sax.SAXException;
+    
+  /**
+   * Return an DOM node for the given node.
+   * 
+   * @param nodeHandle The node ID.
+   * 
+   * @return A node representation of the DTM node.
+   */
+   public org.w3c.dom.Node getNode(int nodeHandle);
+
+  // ==== Construction methods (may not be supported by some implementations!) =====
+  // %REVIEW% What response occurs if not supported?
+
+  /**
+   * @return true iff we're building this model incrementally (eg
+   * we're partnered with a CoroutineParser) and thus require that the
+   * transformation and the parse run simultaneously. Guidance to the
+   * DTMManager.
+   */
+  public boolean needsTwoThreads();
+
+  // %REVIEW% Do these appends make any sense, should we support a
+  // wider set of methods (like the "append" methods in the
+  // current DTMDocumentImpl draft), or should we just support SAX
+  // listener interfaces?  Should it be a separate interface to
+  // make that distinction explicit?
+
+  /**
+   * Return this DTM's content handler, if it has one.
+   *
+   * @return null if this model doesn't respond to SAX events.
+   */
+  public org.xml.sax.ContentHandler getContentHandler();
+
+  /**
+   * Return this DTM's lexical handler, if it has one.
+   *
+   * %REVIEW% Should this return null if constrution already done/begun?
+   *
+   * @return null if this model doesn't respond to lexical SAX events.
+   */
+  public org.xml.sax.ext.LexicalHandler getLexicalHandler();
+
+  /**
+   * Return this DTM's EntityResolver, if it has one.
+   *
+   * @return null if this model doesn't respond to SAX entity ref events.
+   */
+  public org.xml.sax.EntityResolver getEntityResolver();
+
+  /**
+   * Return this DTM's DTDHandler, if it has one.
+   *
+   * @return null if this model doesn't respond to SAX dtd events.
+   */
+  public org.xml.sax.DTDHandler getDTDHandler();
+
+  /**
+   * Return this DTM's ErrorHandler, if it has one.
+   *
+   * @return null if this model doesn't respond to SAX error events.
+   */
+  public org.xml.sax.ErrorHandler getErrorHandler();
+
+  /**
+   * Return this DTM's DeclHandler, if it has one.
+   *
+   * @return null if this model doesn't respond to SAX Decl events.
+   */
+  public org.xml.sax.ext.DeclHandler getDeclHandler();
+
+  /**
+   * Append a child to "the end of the document". Please note that
+   * the node is always cloned in a base DTM, since our basic behavior
+   * is immutable so nodes can't be removed from their previous
+   * location.
+   *
+   * <p> %REVIEW%  DTM maintains an insertion cursor which
+   * performs a depth-first tree walk as nodes come in, and this operation
+   * is really equivalent to:
+   *    insertionCursor.appendChild(document.importNode(newChild)))
+   * where the insert point is the last element that was appended (or
+   * the last one popped back to by an end-element operation).</p>
+   *
+   * @param newChild Must be a valid new node handle.
+   * @param clone true if the child should be cloned into the document.
+   * @param cloneDepth if the clone argument is true, specifies that the
+   *                   clone should include all it's children.  
+   */
+  public void appendChild(int newChild, boolean clone, boolean cloneDepth);
+
+  /**
+   * Append a text node child that will be constructed from a string,
+   * to the end of the document. Behavior is otherwise like appendChild().
+   *
+   * @param str Non-null reference to a string.
+   */
+  public void appendTextChild(String str);
+}
diff --git a/src/org/apache/xml/dtm/DTMBuilder.java b/src/org/apache/xml/dtm/DTMBuilder.java
new file mode 100644
index 0000000..d1573c3
--- /dev/null
+++ b/src/org/apache/xml/dtm/DTMBuilder.java
@@ -0,0 +1,476 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999,2000 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xerces" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.apache.org.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+//package org.apache.xerces.parsers;
+package org.apache.xml.dtm;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.Attributes;
+import org.xml.sax.ext.LexicalHandler;
+import java.io.IOException;
+import org.apache.xml.dtm.CoroutineManager;
+import org.apache.xml.utils.FastStringBuffer;
+
+
+/** <p>DTMBuilder is a glue layer which accepts input from the
+ * CoroutineParser and issues calls to construct DTM nodes.</p>
+ *
+ * <p>We're not really delighted with this; it's an extra layer of
+ * call-and-return per node created. A better approach, since this is
+ * so specific to DTM, might be to give it direct ("friend") access to
+ * DTM's storage... or to fold it directly into the DTM class. We've
+ * broken it out primarily to allow parallel development of the
+ * builder and the DTM model. (Or, in fact, to make it a subclass
+ * of CoroutineParser to avoid _that_ layer of call-and-return... though
+ * I think tail-call optimization will help us in that case.</p>
+ *
+ * <p>In its current form, this is basically a SAX-to-DTM call adapter.
+ * SAX events coming in are restructured -- primarily by having their strings
+ * and text content copied into appropriate storage and re-expressed as
+ * index numbers. Note that this requires some negotiation between the DTM
+ * and the builder to agree on which string pools this content will be placed
+ * into.</p>
+ *
+ * <p>We also restructure the call sequence somewhat, by merging
+ * successive characters() calls into a single text-node creation, and
+ * by breaking the attributes out of the SAX createEvent call and generating
+ * create-attribute (and create-namespace-declaration) calls.</p>
+ *
+ * <p>Status: MOSTLY DEAD CODE -- Merged into DTM implementations; this
+ * class is being retained just for reference and can probably be discarded
+ * some time soon -- Check with Joe.</p>
+ * */
+public class DTMBuilder
+implements ContentHandler, LexicalHandler
+{
+
+  //
+  // Data
+  //
+
+  /** Document being built.
+   *
+   * <p>%TBD% The DTM API doesn't currently have construction calls,
+   * so this is explicitly defined as a DTMDocumentImpl. That needs to
+   * be fixed.</p>
+   * */
+  private DTMDocumentImpl m_dtm;
+
+  private CoroutineManager fCoroutineManager = null;
+  private int fAppCoroutine = -1;
+  private int fParserCoroutine = -1;
+
+  private CoroutineParser co_parser;
+
+  // Scott suggests sharing pools between DTMs. Note that this will require
+  // threadsafety at the pool level.
+  private static DTMStringPool commonLocalNames=new DTMSafeStringPool();
+  private static DTMStringPool commonNamespaceNames=new DTMSafeStringPool();
+  private static DTMStringPool commonPrefixes=new DTMSafeStringPool();
+
+  private DTMStringPool localNames; // For this DTM, may be common
+  private DTMStringPool namespaceNames; // For this DTM, may be common
+  private DTMStringPool prefixes; 
+  private FastStringBuffer content; // Unique per DTM
+  int contentStart=0;
+
+  // %TBD% The whole startup sequence has to be resolved --
+  // How much is passed builder-to-DTM and how much the other way?
+  // Who decides whether we're sharing string pools or creating new ones?
+  // When do we hook up to the coroutine parser system?
+
+  //
+  // Constructors
+  //
+
+  /*
+   * @param dtm DTM object to be written into
+   * <p>%TBD% The DTM API doesn't currently have construction calls,
+   * so this is explicitly defined as a DTMDocumentImpl. That needs to
+   * be fixed.</p>
+   * @param source SAX InputSource to read the XML document from.
+   * @param parser SAX XMLReader to be used to parse source into dtm
+   * */
+  public DTMBuilder(DTMDocumentImpl dtm, InputSource source, org.xml.sax.XMLReader parser)
+  {
+    m_dtm=dtm;
+    
+    // Start with persistant shared pools unless the DTM expresses
+    // other preferences
+    localNames=m_dtm.getLocalNameTable();
+    if(localNames==null)
+      m_dtm.setLocalNameTable(localNames=commonLocalNames);
+
+    namespaceNames=m_dtm.getNsNameTable();
+    if(namespaceNames==null)
+      m_dtm.setNsNameTable(namespaceNames=commonNamespaceNames);
+
+    prefixes=m_dtm.getPrefixNameTable();
+    if(prefixes==null)
+      m_dtm.setPrefixNameTable(prefixes=commonPrefixes);
+
+    // Unlike the other strings, which may be shared and thus should be
+    // reset elsewhere (if at all), content starts empty each time we parse.
+    content=m_dtm.getContentBuffer();
+    if(content==null)
+      m_dtm.setContentBuffer(content=new FastStringBuffer());
+    else
+      content.reset();
+    contentStart=0;
+
+    // Establish incremental parsing hookups
+    fCoroutineManager=new CoroutineManager();
+    fAppCoroutine = fCoroutineManager.co_joinCoroutineSet(-1);
+    // %TBD% parser should be passed in so we can plug in the
+    // Xalan version of other specific instances.
+    co_parser=new CoroutineSAXParser(fCoroutineManager,fAppCoroutine,parser);
+    fParserCoroutine=co_parser.getParserCoroutineID();
+    co_parser.setContentHandler(this);
+    co_parser.setLexHandler(this); // Needed for comments, I think.
+    
+    // %TBD% MAJOR CONCERN: Are we sure we'll have reached the
+    // startup point before we start the call? CHECK THIS!
+
+    // Begin incremental parsing
+    // Note that this doesn't return until the first chunk of parsing
+    // has been completed and the parser coroutine yields.
+    try
+      {
+	fCoroutineManager.co_resume(source,fAppCoroutine,fParserCoroutine);
+      }
+    catch(NoSuchMethodException e)
+      {
+	// Shouldn't happen unless we've miscoded our coroutine logic
+	// "Shut down the garbage smashers on the detention level!"
+	e.printStackTrace(System.err);
+	fCoroutineManager.co_exit(fAppCoroutine);
+      }
+  }
+  
+  //
+  // Public methods
+  //
+  
+  // String accumulator support
+  private void processAccumulatedText()
+  {
+    int len=content.length();
+    if(len!=contentStart)
+      {
+	// The FastStringBuffer has been previously agreed upon
+	m_dtm.appendTextChild(contentStart,len-contentStart);
+	contentStart=len;
+      }
+  }
+
+  //
+  // ContentHandler methods
+  // Accept SAX events, reformat as DTM construction calls
+  public void characters(char[] ch, int start, int length)
+       throws org.xml.sax.SAXException
+  {
+    // Actually creating the text node is handled by
+    // processAccumulatedText(); here we just accumulate the
+    // characters into the buffer.
+    content.append(ch,start,length);
+  }
+  public void endDocument() 
+       throws org.xml.sax.SAXException
+  {
+    // May need to tell the low-level builder code to pop up a level.
+    // There _should't_ be any significant pending text at this point.
+    m_dtm.appendEndDocument();
+  }
+  public void endElement(java.lang.String namespaceURI, java.lang.String localName,
+      java.lang.String qName) 
+       throws org.xml.sax.SAXException
+  {
+    processAccumulatedText();
+    // No args but we do need to tell the low-level builder code to
+    // pop up a level.
+    m_dtm.appendEndElement();
+  }
+  public void endPrefixMapping(java.lang.String prefix) 
+       throws org.xml.sax.SAXException
+  {
+    // No-op
+  }
+  public void ignorableWhitespace(char[] ch, int start, int length) 
+       throws org.xml.sax.SAXException
+  {
+    // %TBD% I believe ignorable text isn't part of the DTM model...?
+  }
+  public void processingInstruction(java.lang.String target, java.lang.String data) 
+       throws org.xml.sax.SAXException
+  {
+    processAccumulatedText();
+    // %TBD% Which pools do target and data go into?
+  }
+  public void setDocumentLocator(Locator locator) 
+  {
+    // No-op for DTM
+  }
+  public void skippedEntity(java.lang.String name) 
+       throws org.xml.sax.SAXException
+  {
+    processAccumulatedText();
+    //%TBD%
+  }
+  public void startDocument() 
+       throws org.xml.sax.SAXException
+  {
+    // No-op for DTM?
+    //m_dtm.startDocument();
+  }
+  public void startElement(java.lang.String namespaceURI, java.lang.String localName,
+      java.lang.String qName, Attributes atts) 
+       throws org.xml.sax.SAXException
+  {
+    processAccumulatedText();
+
+    // %TBD% Split prefix off qname
+    String prefix=null;
+    int colon=qName.indexOf(':');
+    if(colon>0)
+      prefix=qName.substring(0,colon);
+
+    // %TBD% Where do we pool expandedName, or is it just the union, or...
+    m_dtm.appendStartElement(namespaceNames.stringToIndex(namespaceURI),
+		     localNames.stringToIndex(localName),
+		     prefixes.stringToIndex(prefix)); /////// %TBD%
+
+    // %TBD% I'm assuming that DTM will require resequencing of
+    // NS decls before other attrs, hence two passes are taken.
+    // %TBD% Is there an easier way to test for NSDecl?
+    int nAtts=atts.getLength();
+    // %TBD% Countdown is more efficient if nobody cares about sequence.
+    for(int i=nAtts-1;i>=0;--i)	
+      {
+	qName=atts.getQName(i);
+	if(qName.startsWith("xmlns:") || "xmlns".equals(qName))
+	  {
+	    prefix=null;
+	    colon=qName.indexOf(':');
+	    if(colon>0)
+	      {
+		prefix=qName.substring(0,colon);
+	      }
+	    else
+	      {
+		prefix=""; // Default prefix
+	      }
+	    
+
+	    m_dtm.appendNSDeclaration(
+				    prefixes.stringToIndex(prefix),
+				    namespaceNames.stringToIndex(atts.getValue(i)),
+				    atts.getType(i).equalsIgnoreCase("ID"));
+	  }
+      }
+    
+    for(int i=nAtts-1;i>=0;--i)	
+      {
+	qName=atts.getQName(i);
+	if(qName.startsWith("xmlns:") || "xmlns".equals(qName))
+	  {
+	    // %TBD% I hate having to extract the prefix into a new
+	    // string when we may never use it. Consider pooling whole
+	    // qNames, which are already strings?
+	    prefix=null;
+	    colon=qName.indexOf(':');
+	    if(colon>0)
+	      {
+		prefix=qName.substring(0,colon);
+		localName=qName.substring(colon+1);
+	      }
+	    else
+	      {
+		prefix=""; // Default prefix
+		localName=qName;
+	      }
+	    
+	    
+	    content.append(atts.getValue(i)); // Single-string value
+	    int contentEnd=content.length();
+	    
+	    if(!("xmlns".equals(prefix) || "xmlns".equals(qName)))
+	      m_dtm.appendAttribute(namespaceNames.stringToIndex(atts.getURI(i)),
+				  localNames.stringToIndex(localName),
+				  prefixes.stringToIndex(prefix),
+				  atts.getType(i).equalsIgnoreCase("ID"),
+				  contentStart, contentEnd-contentStart);
+	    contentStart=contentEnd;
+	  }
+      }
+  }
+  public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) 
+       throws org.xml.sax.SAXException
+  {
+    // No-op in DTM, handled during element/attr processing?
+  }
+
+  //
+  // LexicalHandler support. Not all SAX2 parsers support these events
+  // but we may want to pass them through when they exist...
+  //
+  public void comment(char[] ch, int start, int length) 
+       throws org.xml.sax.SAXException
+  {
+    processAccumulatedText();
+
+    content.append(ch,start,length); // Single-string value
+    m_dtm.appendComment(contentStart,length);
+    contentStart+=length;    
+  }
+  public void endCDATA() 
+       throws org.xml.sax.SAXException
+  {
+    // No-op in DTM
+  }
+  public void endDTD() 
+       throws org.xml.sax.SAXException
+  {
+    // No-op in DTM
+  }
+  public void endEntity(java.lang.String name) 
+       throws org.xml.sax.SAXException
+  {
+    // No-op in DTM
+  }
+  public void startCDATA() 
+       throws org.xml.sax.SAXException
+  {
+    // No-op in DTM
+  }
+  public void startDTD(java.lang.String name, java.lang.String publicId,
+      java.lang.String systemId) 
+       throws org.xml.sax.SAXException
+  {
+    // No-op in DTM
+  }
+  public void startEntity(java.lang.String name) 
+       throws org.xml.sax.SAXException
+  {
+    // No-op in DTM
+  }
+
+  //
+  // coroutine support
+  //
+
+  public int getAppCoroutine() {
+    return fAppCoroutine;
+  }
+  
+  /**
+   * getMoreNodes() tells the coroutine parser that we need more nodes.
+   *
+   * Parameter may be:
+   *
+   *      null            terminate the parser coroutine.
+   *
+   *      Boolean.TRUE    indication to continue parsing the current document.
+   *			  Resumes normal SAX parsing.
+   *
+   *      Boolean.FALSE   indication to discontinue parsing and reset.
+   *			  Throws UserRequestedStopException
+   *			  to return control to the run() loop.
+   *
+   * We will be resumed with 
+   *   co_resume(Boolean.TRUE, ...) on success with more remaining to parse.
+   *   co_resume(Boolean.FALSE, ...) on success after endDocument.
+   */
+  private boolean co_yield(boolean getmore, boolean shutdown)
+  {
+    Object arg=null;
+    if(!shutdown)
+      arg= getmore ? Boolean.TRUE : Boolean.FALSE;
+    try
+      {
+	arg = fCoroutineManager.co_resume(arg,fAppCoroutine,fParserCoroutine);
+	if (arg instanceof Boolean) {
+	  return ((Boolean)arg).booleanValue();
+	  }
+
+	else // Unexpected!
+	  {
+	    System.err.println(
+		  "Active CoroutineSAXParser: unexpected resume parameter, "
+		  +arg.getClass
+		  ()+" with value=\""+arg+'"');
+	    System.err.println("\tStopping parser rather than risk deadlock");
+	    throw new RuntimeException("Coroutine parameter error ("+arg+')');
+	  }
+      }
+    catch(java.lang.NoSuchMethodException e)
+      {
+	// Shouldn't happen unless we've miscoded our coroutine logic
+	// "Shut down the garbage smashers on the detention level!"
+	e.printStackTrace(System.err);
+	fCoroutineManager.co_exit(fAppCoroutine);
+      }
+
+    // Only reached if NoSuchMethodException was thrown (no coroutine)
+    return(false); 
+  }
+
+} // class DTMBuilder
diff --git a/src/org/apache/xml/dtm/DTMConfigurationException.java b/src/org/apache/xml/dtm/DTMConfigurationException.java
new file mode 100644
index 0000000..2fd150d
--- /dev/null
+++ b/src/org/apache/xml/dtm/DTMConfigurationException.java
@@ -0,0 +1,80 @@
+package org.apache.xml.dtm;
+
+import javax.xml.transform.SourceLocator;
+
+/**
+ * Indicates a serious configuration error.
+ */
+public class DTMConfigurationException extends DTMException {
+
+    /**
+     * Create a new <code>DTMConfigurationException</code> with no
+     * detail mesage.
+     */
+    public DTMConfigurationException() {
+        super("Configuration Error");
+    }
+
+    /**
+     * Create a new <code>DTMConfigurationException</code> with
+     * the <code>String </code> specified as an error message.
+     *
+     * @param msg The error message for the exception.
+     */
+    public DTMConfigurationException(String msg) {
+        super(msg);
+    }
+
+    /**
+     * Create a new <code>DTMConfigurationException</code> with a
+     * given <code>Exception</code> base cause of the error.
+     *
+     * @param e The exception to be encapsulated in a
+     * DTMConfigurationException.
+     */
+    public DTMConfigurationException(Throwable e) {
+        super(e);
+    }
+
+    /**
+     * Create a new <code>DTMConfigurationException</code> with the
+     * given <code>Exception</code> base cause and detail message.
+     *
+     * @param e The exception to be encapsulated in a
+     * DTMConfigurationException
+     * @param msg The detail message.
+     * @param e The exception to be wrapped in a DTMConfigurationException
+     */
+    public DTMConfigurationException(String msg, Throwable e) {
+        super(msg, e);
+    }
+
+    /**
+     * Create a new DTMConfigurationException from a message and a Locator.
+     *
+     * <p>This constructor is especially useful when an application is
+     * creating its own exception from within a DocumentHandler
+     * callback.</p>
+     *
+     * @param message The error or warning message.
+     * @param locator The locator object for the error or warning.
+     */
+    public DTMConfigurationException(String message,
+                                             SourceLocator locator) {
+        super(message, locator);
+    }
+
+    /**
+     * Wrap an existing exception in a DTMConfigurationException.
+     *
+     * @param message The error or warning message, or null to
+     *                use the message from the embedded exception.
+     * @param locator The locator object for the error or warning.
+     * @param e Any exception.
+     */
+    public DTMConfigurationException(String message,
+                                             SourceLocator locator,
+                                             Throwable e) {
+        super(message, locator, e);
+    }
+}
\ No newline at end of file
diff --git a/src/org/apache/xml/dtm/DTMDefaultBase.java b/src/org/apache/xml/dtm/DTMDefaultBase.java
new file mode 100644
index 0000000..0d1360a
--- /dev/null
+++ b/src/org/apache/xml/dtm/DTMDefaultBase.java
@@ -0,0 +1,1541 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xml.dtm;
+
+import org.apache.xml.dtm.*;
+import org.apache.xml.utils.IntVector;
+import org.apache.xml.utils.IntStack;
+import org.apache.xml.utils.BoolStack;
+import org.apache.xml.utils.StringBufferPool;
+import org.apache.xml.utils.FastStringBuffer;
+import org.apache.xml.utils.TreeWalker;
+import org.apache.xml.utils.QName;
+import org.apache.xml.utils.XMLCharacterRecognizer;
+
+import java.util.Vector;
+
+import org.xml.sax.ContentHandler;
+
+import org.apache.xml.utils.NodeVector;
+
+import javax.xml.transform.Source;
+
+import org.apache.xml.utils.XMLString;
+import org.apache.xml.utils.XMLStringFactory;
+
+/**
+ * The <code>DTMDefaultBase</code> class serves as a helper base for DTMs.
+ * It sets up structures for navigation and type, while leaving data
+ * management and construction to the derived classes.
+ */
+public abstract class DTMDefaultBase implements DTM
+{
+
+  /**
+   * This is extra information about the node objects.  Each information
+   * block is composed of several array members.  The size of this will always
+   * be (m_nodes.size() * NODEINFOBLOCKSIZE).
+   */
+  protected IntVector m_info = new IntVector();
+
+  // Offsets into each set of integers in the <code>m_info</code> table.
+
+  /** %TBD% Doc */
+  protected static final int OFFSET_EXPANDEDNAMEID = 0;
+
+  /** %TBD% Doc */
+  protected static final int OFFSET_TYPE = 1;
+
+  /** %TBD% Doc */
+  protected static final int OFFSET_LEVEL = 2;
+
+  /** %TBD% Doc */
+  protected static final int OFFSET_FIRSTCHILD = 3;
+
+  /** %TBD% Doc */
+  protected static final int OFFSET_NEXTSIBLING = 4;
+
+  /** %TBD% Doc */
+  protected static final int OFFSET_PREVSIBLING = 5;
+
+  /** %TBD% Doc */
+  protected static final int OFFSET_PARENT = 6;
+
+  /**
+   * This represents the number of integers per node in the
+   * <code>m_info</code> member variable, if the derived class
+   * does not add information.
+   */
+  protected static final int DEFAULTNODEINFOBLOCKSIZE = 7;
+
+  /**
+   * The value to use when the information has not been built yet.
+   */
+  protected static final int NOTPROCESSED = DTM.NULL - 1;
+
+  /** Not sure if this is used? */
+  protected static final int NODEIDENTITYBITS = 0x000FFFFF;
+
+  /**
+   * The DTM manager who "owns" this DTM.
+   */
+  protected DTMManager m_mgr;
+
+  /** %TBD% Doc */
+  protected int m_dtmIdent;
+
+  /** %TBD% Doc */
+  protected int m_mask;
+
+  /** %TBD% Doc */
+  protected String m_documentBaseURI;
+
+  /**
+   * The whitespace filter that enables elements to strip whitespace or not.
+   */
+  protected DTMWSFilter m_wsfilter;
+
+  /** Flag indicating whether to strip whitespace nodes */
+  protected boolean m_shouldStripWS = false;
+
+  /** Stack of flags indicating whether to strip whitespace nodes */
+  protected BoolStack m_shouldStripWhitespaceStack;
+  
+  /** The XMLString factory for creating XMLStrings. */
+  protected XMLStringFactory m_xstrf;
+
+  /**
+   * Construct a DTMDefaultBase object from a DOM node.
+   *
+   * @param mgr The DTMManager who owns this DTM.
+   * @param domSource the DOM source that this DTM will wrap.
+   * NEEDSDOC @param source
+   * @param dtmIdentity The DTM identity ID for this DTM.
+   * @param whiteSpaceFilter The white space filter for this DTM, which may
+   *                         be null.
+   */
+  public DTMDefaultBase(DTMManager mgr, Source source, int dtmIdentity,
+                        DTMWSFilter whiteSpaceFilter,
+                        XMLStringFactory xstringfactory)
+  {
+
+    m_mgr = mgr;
+    m_documentBaseURI = (null != source) ? source.getSystemId() : null;
+    m_dtmIdent = dtmIdentity;
+    m_mask = mgr.getNodeIdentityMask();
+    m_wsfilter = whiteSpaceFilter;
+    m_xstrf = xstringfactory;
+
+    if (null != whiteSpaceFilter)
+    {
+      m_shouldStripWhitespaceStack = new BoolStack();
+
+      pushShouldStripWhitespace(false);
+    }
+  }
+
+  /**
+   * Get the next node identity value in the list, and call the iterator
+   * if it hasn't been added yet.
+   *
+   * @param identity The node identity (index).
+   * @return identity+1, or DTM.NULL.
+   */
+  protected abstract int getNextNodeIdentity(int identity);
+
+  /**
+   * This method should try and build one or more nodes in the table.
+   *
+   * @return The true if a next node is found or false if
+   *         there are no more nodes.
+   */
+  protected abstract boolean nextNode();
+
+  /**
+   * Return the number of integers in each node info block.
+   *
+   * NEEDSDOC ($objectName$) @return
+   */
+  protected int getNodeInfoBlockSize()
+  {
+    return DEFAULTNODEINFOBLOCKSIZE;
+  }
+
+  /**
+   * Get the number of nodes that have been added.
+   *
+   * NEEDSDOC ($objectName$) @return
+   */
+  protected abstract int getNumberOfNodes();
+
+  /**
+   * Get a node handle that is relative to the given node.
+   *
+   * @param identity The node identity.
+   * @param offsetValue One of OFFSET_XXX values.
+   * @return The relative node handle.
+   */
+  protected int getNodeInfo(int identity, int offsetValue)
+  {
+
+    int base = (identity * getNodeInfoBlockSize());
+    int info = (identity >= getNumberOfNodes())
+               ? NOTPROCESSED : m_info.elementAt(base + offsetValue);
+
+    // Check to see if the information requested has been processed, and, 
+    // if not, advance the iterator until we the information has been 
+    // processed.
+    while (info == NOTPROCESSED)
+    {
+      boolean isMore = nextNode();
+
+      if (identity >= getNumberOfNodes())
+      {
+        info = NOTPROCESSED;
+      }
+      else
+        info = m_info.elementAt(base + offsetValue);
+
+      if (!isMore && NOTPROCESSED == info)
+        return DTM.NULL;
+    }
+
+    return info;
+  }
+
+  /**
+   * Get a node handle that is relative to the given node, but don't check for
+   * the NOTPROCESSED flag.  A class will need to use this call to get values
+   * that may be negative.  Also, it's a tiny bit faster than getNodeInfo if
+   * you know that NOTPROCESSED is not a possibility.
+   *
+   * @param identity The node identity.
+   * @param offsetValue One of OFFSET_XXX values.
+   * @return The relative node handle.
+   */
+  protected int getNodeInfoNoWait(int identity, int offsetValue)
+  {
+    return m_info.elementAt((identity * getNodeInfoBlockSize())
+                            + offsetValue);
+  }
+
+  /**
+   * Diagnostics function to dump the DTM.
+   */
+  public void dumpDTM()
+  {
+
+    while (nextNode()){}
+
+    int sizePerRecord = getNodeInfoBlockSize();
+    int nRecords = m_info.size() / sizePerRecord;
+
+    System.out.println("Total nodes: " + nRecords);
+
+    for (int i = 0; i < nRecords; i++)
+    {
+      int offset = i * sizePerRecord;
+
+      System.out.println("=========== " + i + " ===========");
+      System.out.println("NodeName: " + getNodeName(i));
+      System.out.println("NodeNameX: " + getNodeNameX(i));
+      System.out.println("LocalName: " + getLocalName(i));
+      System.out.println("NamespaceURI: " + getNamespaceURI(i));
+      System.out.println("Prefix: " + getPrefix(i));
+
+      int exTypeID = getExpandedNameID(i);
+
+      System.out.println("Expanded Type ID: "
+                         + Integer.toHexString(exTypeID));
+
+      int type = getNodeType(i);
+      String typestring;
+
+      switch (type)
+      {
+      case DTM.ATTRIBUTE_NODE :
+        typestring = "ATTRIBUTE_NODE";
+        break;
+      case DTM.CDATA_SECTION_NODE :
+        typestring = "CDATA_SECTION_NODE";
+        break;
+      case DTM.COMMENT_NODE :
+        typestring = "COMMENT_NODE";
+        break;
+      case DTM.DOCUMENT_FRAGMENT_NODE :
+        typestring = "DOCUMENT_FRAGMENT_NODE";
+        break;
+      case DTM.DOCUMENT_NODE :
+        typestring = "DOCUMENT_NODE";
+        break;
+      case DTM.DOCUMENT_TYPE_NODE :
+        typestring = "DOCUMENT_NODE";
+        break;
+      case DTM.ELEMENT_NODE :
+        typestring = "ELEMENT_NODE";
+        break;
+      case DTM.ENTITY_NODE :
+        typestring = "ENTITY_NODE";
+        break;
+      case DTM.ENTITY_REFERENCE_NODE :
+        typestring = "ENTITY_REFERENCE_NODE";
+        break;
+      case DTM.NAMESPACE_NODE :
+        typestring = "NAMESPACE_NODE";
+        break;
+      case DTM.NOTATION_NODE :
+        typestring = "NOTATION_NODE";
+        break;
+      case DTM.NULL :
+        typestring = "NULL";
+        break;
+      case DTM.PROCESSING_INSTRUCTION_NODE :
+        typestring = "PROCESSING_INSTRUCTION_NODE";
+        break;
+      case DTM.TEXT_NODE :
+        typestring = "TEXT_NODE";
+        break;
+      default :
+        typestring = "Unknown!";
+        break;
+      }
+
+      System.out.println("Type: " + typestring);
+
+      int firstChild = m_info.elementAt(offset + OFFSET_FIRSTCHILD);
+
+      if (DTM.NULL == firstChild)
+        System.out.println("First child: DTM.NULL");
+      else if (NOTPROCESSED == firstChild)
+        System.out.println("First child: NOTPROCESSED");
+      else
+        System.out.println("First child: " + firstChild);
+
+      int prevSibling = m_info.elementAt(offset + OFFSET_PREVSIBLING);
+
+      if (DTM.NULL == prevSibling)
+        System.out.println("Prev sibling: DTM.NULL");
+      else if (NOTPROCESSED == prevSibling)
+        System.out.println("Prev sibling: NOTPROCESSED");
+      else
+        System.out.println("Prev sibling: " + prevSibling);
+
+      int nextSibling = m_info.elementAt(offset + OFFSET_NEXTSIBLING);
+
+      if (DTM.NULL == nextSibling)
+        System.out.println("Next sibling: DTM.NULL");
+      else if (NOTPROCESSED == nextSibling)
+        System.out.println("Next sibling: NOTPROCESSED");
+      else
+        System.out.println("Next sibling: " + nextSibling);
+
+      int parent = m_info.elementAt(offset + OFFSET_PARENT);
+
+      if (DTM.NULL == parent)
+        System.out.println("Parent: DTM.NULL");
+      else if (NOTPROCESSED == parent)
+        System.out.println("Parent: NOTPROCESSED");
+      else
+        System.out.println("Parent: " + parent);
+
+      int level = m_info.elementAt(offset + OFFSET_LEVEL);
+
+      System.out.println("Level: " + level);
+      System.out.println("Node Value: " + getNodeValue(i));
+      System.out.println("String Value: " + getStringValue(i));
+    }
+  }
+
+  // ========= DTM Implementation Control Functions. ==============
+
+  /**
+   * Set an implementation dependent feature.
+   * <p>
+   * %REVIEW% Do we really expect to set features on DTMs?
+   *
+   * @param featureId A feature URL.
+   * @param state true if this feature should be on, false otherwise.
+   */
+  public void setFeature(String featureId, boolean state){}
+
+  // ========= Document Navigation Functions =========
+
+  /**
+   * Given a node handle, test if it has child nodes.
+   * <p> %REVIEW% This is obviously useful at the DOM layer, where it
+   * would permit testing this without having to create a proxy
+   * node. It's less useful in the DTM API, where
+   * (dtm.getFirstChild(nodeHandle)!=DTM.NULL) is just as fast and
+   * almost as self-evident. But it's a convenience, and eases porting
+   * of DOM code to DTM.  </p>
+   *
+   * @param nodeHandle int Handle of the node.
+   * @return int true if the given node has child nodes.
+   */
+  public boolean hasChildNodes(int nodeHandle)
+  {
+
+    int identity = nodeHandle & m_mask;
+    int firstChild = getNodeInfo(identity, OFFSET_FIRSTCHILD);
+
+    return firstChild != DTM.NULL;
+  }
+
+  /**
+   * Given a node handle, get the handle of the node's first child.
+   * If not yet resolved, waits for more nodes to be added to the document and
+   * tries again.
+   *
+   * @param nodeHandle int Handle of the node.
+   * @return int DTM node-number of first child, or DTM.NULL to indicate none exists.
+   */
+  public int getFirstChild(int nodeHandle)
+  {
+
+    int identity = nodeHandle & m_mask;
+    int firstChild = getNodeInfo(identity, OFFSET_FIRSTCHILD);
+
+    return firstChild | m_dtmIdent;
+  }
+
+  /**
+   * Given a node handle, advance to its last child.
+   * If not yet resolved, waits for more nodes to be added to the document and
+   * tries again.
+   *
+   * @param nodeHandle int Handle of the node.
+   * @return int Node-number of last child,
+   * or DTM.NULL to indicate none exists.
+   */
+  public int getLastChild(int nodeHandle)
+  {
+
+    int identity = nodeHandle & m_mask;
+    int child = getNodeInfo(identity, OFFSET_FIRSTCHILD);
+    int lastChild = DTM.NULL;
+
+    while (child != DTM.NULL)
+    {
+      lastChild = child;
+      child = getNodeInfo(child, OFFSET_NEXTSIBLING);
+    }
+
+    return lastChild | m_dtmIdent;
+  }
+
+  /**
+   * Retrieves an attribute node by by qualified name and namespace URI.
+   *
+   * @param nodeHandle int Handle of the node upon which to look up this attribute..
+   * @param namespaceURI The namespace URI of the attribute to
+   *   retrieve, or null.
+   * @param name The local name of the attribute to
+   *   retrieve.
+   * @return The attribute node handle with the specified name (
+   *   <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such
+   *   attribute.
+   */
+  public abstract int getAttributeNode(int nodeHandle, String namespaceURI,
+                                       String name);
+
+  /**
+   * Given a node handle, get the index of the node's first attribute.
+   *
+   * @param nodeHandle int Handle of the node.
+   * @return Handle of first attribute, or DTM.NULL to indicate none exists.
+   */
+  public int getFirstAttribute(int nodeHandle)
+  {
+
+    int type = getNodeType(nodeHandle);
+
+    if (DTM.ELEMENT_NODE == type)
+    {
+
+      // Assume that attributes and namespaces immediately follow the element.
+      int identity = nodeHandle & m_mask;
+
+      while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
+      {
+
+        // Assume this can not be null.
+        type = getNodeType(identity);
+
+        if (type == DTM.ATTRIBUTE_NODE)
+        {
+          return identity | m_dtmIdent;
+        }
+        else if (DTM.NAMESPACE_NODE != type)
+        {
+          break;
+        }
+      }
+    }
+
+    return DTM.NULL;
+  }
+
+  /**
+   * Given a node handle, advance to its next sibling.
+   * If not yet resolved, waits for more nodes to be added to the document and
+   * tries again.
+   * @param nodeHandle int Handle of the node.
+   * @return int Node-number of next sibling,
+   * or DTM.NULL to indicate none exists.
+   */
+  public int getNextSibling(int nodeHandle)
+  {
+
+    int identity = nodeHandle & m_mask;
+    int nextSibling = getNodeInfo(identity, OFFSET_NEXTSIBLING);
+
+    return nextSibling | m_dtmIdent;
+  }
+
+  /**
+   * Given a node handle, find its preceeding sibling.
+   * WARNING: DTM is asymmetric; this operation is resolved by search, and is
+   * relatively expensive.
+   *
+   * @param nodeHandle the id of the node.
+   * @return int Node-number of the previous sib,
+   * or DTM.NULL to indicate none exists.
+   */
+  public int getPreviousSibling(int nodeHandle)
+  {
+
+    int firstChild = getNodeInfo(nodeHandle & m_mask, OFFSET_PREVSIBLING);
+
+    return firstChild | m_dtmIdent;
+  }
+
+  /**
+   * Given a node handle, advance to the next attribute. If an
+   * element, we advance to its first attribute; if an attr, we advance to
+   * the next attr on the same node.
+   *
+   * @param nodeHandle int Handle of the node.
+   * @return int DTM node-number of the resolved attr,
+   * or DTM.NULL to indicate none exists.
+   */
+  public int getNextAttribute(int nodeHandle)
+  {
+
+    int type = getNodeType(nodeHandle);
+
+    if (DTM.ATTRIBUTE_NODE == type)
+    {
+
+      // Assume that attributes and namespace nodes immediately follow the element.
+      int identity = nodeHandle & m_mask;
+
+      while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
+      {
+        type = getNodeType(identity);
+
+        if (type == DTM.ATTRIBUTE_NODE)
+        {
+          return identity | m_dtmIdent;
+        }
+        else if (type != DTM.NAMESPACE_NODE)
+        {
+          break;
+        }
+      }
+    }
+
+    return DTM.NULL;
+  }
+
+  /** NEEDSDOC Field m_namespaceLists */
+  private Vector m_namespaceLists = null;  // on demand
+
+  /**
+   * NEEDSDOC Method getNamespaceList
+   *
+   *
+   * NEEDSDOC @param baseHandle
+   *
+   * NEEDSDOC (getNamespaceList) @return
+   */
+  protected NodeVector getNamespaceList(int baseHandle)
+  {
+
+    if (null == m_namespaceLists)
+      m_namespaceLists = new Vector();
+    else
+    {
+      int n = m_namespaceLists.size();
+
+      for (int i = (n - 1); i >= 0; i--)
+      {
+        NodeVector ivec = (NodeVector) m_namespaceLists.elementAt(i);
+
+        if (ivec.elementAt(0) == baseHandle)
+          return ivec;
+      }
+    }
+
+    NodeVector ivec = buildNamespaceList(baseHandle);
+
+    m_namespaceLists.addElement(ivec);
+
+    return ivec;
+  }
+
+  /**
+   * NEEDSDOC Method buildNamespaceList
+   *
+   *
+   * NEEDSDOC @param baseHandle
+   *
+   * NEEDSDOC (buildNamespaceList) @return
+   */
+  private NodeVector buildNamespaceList(int baseHandle)
+  {
+
+    NodeVector ivec = new NodeVector(7);
+
+    ivec.addElement(-1);  // for base handle.
+
+    int nodeHandle = baseHandle;
+    int type = getNodeType(baseHandle);
+    int namespaceHandle = DTM.NULL;
+
+    if (DTM.ELEMENT_NODE == type)
+    {
+
+      // We have to return in document order, so we actually want to find the 
+      // first namespace decl of the last element that has a namespace decl.
+      // Assume that attributes and namespaces immediately follow the element.
+      int identity = nodeHandle & m_mask;
+
+      while (DTM.NULL != identity)
+      {
+        identity = getNextNodeIdentity(identity);
+        type = (DTM.NULL == identity) ? -1 : getNodeType(identity);
+
+        if (type == DTM.NAMESPACE_NODE)
+        {
+          namespaceHandle = identity | m_dtmIdent;
+
+          ivec.insertInOrder(namespaceHandle);
+        }
+        else if (DTM.ATTRIBUTE_NODE != type)
+        {
+          if (identity > 0)
+          {
+            nodeHandle = getParent(nodeHandle);
+
+            if (nodeHandle == DTM.NULL)
+              break;
+
+            identity = nodeHandle & m_mask;
+
+            if (identity == 0)
+              break;
+          }
+          else
+            break;
+        }
+      }
+    }
+
+    ivec.setElementAt(baseHandle, 0);
+
+    return ivec;
+  }
+
+  /**
+   * Given a node handle, get the index of the node's first child.
+   * If not yet resolved, waits for more nodes to be added to the document and
+   * tries again
+   *
+   * @param nodeHandle handle to node, which should probably be an element
+   *                   node, but need not be.
+   *
+   * @param inScope    true if all namespaces in scope should be returned,
+   *                   false if only the namespace declarations should be
+   *                   returned.
+   * @return handle of first namespace, or DTM.NULL to indicate none exists.
+   */
+  public int getFirstNamespaceNode(int nodeHandle, boolean inScope)
+  {
+
+    int type = getNodeType(nodeHandle);
+
+    if (DTM.ELEMENT_NODE == type)
+    {
+      if (inScope)
+      {
+        NodeVector namespaces = getNamespaceList(nodeHandle);
+        int n = namespaces.size();
+
+        if (n > 1)
+          return namespaces.elementAt(1);
+      }
+      else
+      {
+
+        // Assume that attributes and namespaces immediately follow the element.
+        int identity = nodeHandle & m_mask;
+
+        while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
+        {
+
+          // Assume this can not be null.
+          type = getNodeType(identity);
+
+          if (type == DTM.NAMESPACE_NODE)
+          {
+            return identity | m_dtmIdent;
+          }
+          else if (DTM.ATTRIBUTE_NODE != type)
+          {
+            break;
+          }
+        }
+      }
+    }
+
+    return DTM.NULL;
+  }
+
+  /**
+   * Given a namespace handle, advance to the next namespace.
+   *
+   * @param baseHandle handle to original node from where the first namespace
+   * was relative to (needed to return nodes in document order).
+   * @param namespaceHandle handle to node which must be of type
+   * NAMESPACE_NODE.
+   * NEEDSDOC @param nodeHandle
+   * NEEDSDOC @param inScope
+   * @return handle of next namespace, or DTM.NULL to indicate none exists.
+   */
+  public int getNextNamespaceNode(int baseHandle, int nodeHandle,
+                                  boolean inScope)
+  {
+
+    int type = getNodeType(nodeHandle);
+
+    if (DTM.NAMESPACE_NODE == type)
+    {
+      if (inScope)
+      {
+        NodeVector namespaces = getNamespaceList(baseHandle);
+        int n = namespaces.size();
+
+        for (int i = 1; i < n; i++)  // start from 1 on purpose 
+        {
+          if (nodeHandle == namespaces.elementAt(i))
+          {
+            if (i + 1 < n)
+              return namespaces.elementAt(i + 1);
+          }
+        }
+      }
+      else
+      {
+
+        // Assume that attributes and namespace nodes immediately follow the element.
+        int identity = nodeHandle & m_mask;
+
+        while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
+        {
+          type = getNodeType(identity);
+
+          if (type == DTM.NAMESPACE_NODE)
+          {
+            return identity | m_dtmIdent;
+          }
+          else if (type != DTM.ATTRIBUTE_NODE)
+          {
+            break;
+          }
+        }
+      }
+    }
+
+    return DTM.NULL;
+  }
+
+  /**
+   * Given a node handle, find its parent node.
+   *
+   * @param nodeHandle the id of the node.
+   * @return int Node-number of parent,
+   * or DTM.NULL to indicate none exists.
+   */
+  public int getParent(int nodeHandle)
+  {
+
+    int identity = nodeHandle & m_mask;
+
+    if (identity > 0)
+    {
+      int parent = getNodeInfo(identity, OFFSET_PARENT);
+
+      return parent | m_dtmIdent;
+    }
+    else
+      return DTM.NULL;
+  }
+
+  /**
+   *  Given a node handle, find the owning document node.
+   *
+   *  @param nodeHandle the id of the node.
+   *  @return int Node handle of document, which should always be valid.
+   */
+  public int getDocument()
+  {
+    return m_dtmIdent;
+  }
+
+  /**
+   * Given a node handle, find the owning document node.  This has the exact
+   * same semantics as the DOM Document method of the same name, in that if
+   * the nodeHandle is a document node, it will return NULL.
+   *
+   * <p>%REVIEW% Since this is DOM-specific, it may belong at the DOM
+   * binding layer. Included here as a convenience function and to
+   * aid porting of DOM code to DTM.</p>
+   *
+   * @param nodeHandle the id of the node.
+   * @return int Node handle of owning document, or -1 if the nodeHandle is
+   *             a document.
+   */
+  public int getOwnerDocument(int nodeHandle)
+  {
+
+    int type = getNodeType(nodeHandle);
+
+    if (DTM.DOCUMENT_NODE == type)
+    {
+      return DTM.NULL;
+    }
+
+    return getDocument();
+  }
+
+  /**
+   * Get the string-value of a node as a String object
+   * (see http://www.w3.org/TR/xpath#data-model
+   * for the definition of a node's string-value).
+   *
+   * @param nodeHandle The node ID.
+   *
+   * @return A string object that represents the string-value of the given node.
+   */
+  public abstract XMLString getStringValue(int nodeHandle);
+
+  /**
+   * Get number of character array chunks in
+   * the string-value of a node.
+   * (see http://www.w3.org/TR/xpath#data-model
+   * for the definition of a node's string-value).
+   * Note that a single text node may have multiple text chunks.
+   *
+   * @param nodeHandle The node ID.
+   *
+   * @return number of character array chunks in
+   *         the string-value of a node.
+   */
+  public int getStringValueChunkCount(int nodeHandle)
+  {
+
+    // %TBD%
+    error("getStringValueChunkCount not yet supported!");
+
+    return 0;
+  }
+
+  /**
+   * Get a character array chunk in the string-value of a node.
+   * (see http://www.w3.org/TR/xpath#data-model
+   * for the definition of a node's string-value).
+   * Note that a single text node may have multiple text chunks.
+   *
+   * @param nodeHandle The node ID.
+   * @param chunkIndex Which chunk to get.
+   * @param startAndLen An array of 2 where the start position and length of
+   *                    the chunk will be returned.
+   *
+   * @return The character array reference where the chunk occurs.
+   */
+  public char[] getStringValueChunk(int nodeHandle, int chunkIndex,
+                                    int[] startAndLen)
+  {
+
+    // %TBD%
+    error("getStringValueChunk not yet supported!");
+
+    return null;
+  }
+
+  /**
+   * Given a node handle, return an ID that represents the node's expanded name.
+   *
+   * @param nodeHandle The handle to the node in question.
+   *
+   * @return the expanded-name id of the node.
+   */
+  public int getExpandedNameID(int nodeHandle)
+  {
+
+    int identity = nodeHandle & m_mask;
+    int expandedNameID = getNodeInfo(identity, OFFSET_EXPANDEDNAMEID);
+
+    return expandedNameID;
+  }
+
+  /**
+   * Given an expanded name, return an ID.  If the expanded-name does not
+   * exist in the internal tables, the entry will be created, and the ID will
+   * be returned.  Any additional nodes that are created that have this
+   * expanded name will use this ID.
+   *
+   * @param nodeHandle The handle to the node in question.
+   * NEEDSDOC @param type
+   *
+   * NEEDSDOC @param namespace
+   * NEEDSDOC @param localName
+   *
+   * @return the expanded-name id of the node.
+   */
+  public int getExpandedNameID(String namespace, String localName, int type)
+  {
+
+    ExpandedNameTable ent = m_mgr.getExpandedNameTable(this);
+
+    return ent.getExpandedNameID(namespace, localName, type);
+  }
+
+  /**
+   * Given an expanded-name ID, return the local name part.
+   *
+   * @param ExpandedNameID an ID that represents an expanded-name.
+   * @return String Local name of this node.
+   */
+  public String getLocalNameFromExpandedNameID(int ExpandedNameID)
+  {
+
+    ExpandedNameTable ent = m_mgr.getExpandedNameTable(this);
+
+    return ent.getLocalName(ExpandedNameID);
+  }
+
+  /**
+   * Given an expanded-name ID, return the namespace URI part.
+   *
+   * @param ExpandedNameID an ID that represents an expanded-name.
+   * @return String URI value of this node's namespace, or null if no
+   * namespace was resolved.
+   */
+  public String getNamespaceFromExpandedNameID(int ExpandedNameID)
+  {
+
+    ExpandedNameTable ent = m_mgr.getExpandedNameTable(this);
+
+    return ent.getNamespace(ExpandedNameID);
+  }
+
+  /**
+   * Given a node handle, return its DOM-style node name. This will
+   * include names such as #text or #document.
+   *
+   * @param nodeHandle the id of the node.
+   * @return String Name of this node, which may be an empty string.
+   * %REVIEW% Document when empty string is possible...
+   * %REVIEW-COMMENT% It should never be empty, should it?
+   */
+  public abstract String getNodeName(int nodeHandle);
+
+  /**
+   * Given a node handle, return the XPath node name.  This should be
+   * the name as described by the XPath data model, NOT the DOM-style
+   * name.
+   *
+   * @param nodeHandle the id of the node.
+   * @return String Name of this node, which may be an empty string.
+   */
+  public String getNodeNameX(int nodeHandle)
+  {
+
+    /** @todo: implement this org.apache.xml.dtm.DTMDefaultBase abstract method */
+    error("Not yet supported!");
+
+    return null;
+  }
+
+  /**
+   * Given a node handle, return its XPath-style localname.
+   * (As defined in Namespaces, this is the portion of the name after any
+   * colon character).
+   *
+   * @param nodeHandle the id of the node.
+   * @return String Local name of this node.
+   */
+  public abstract String getLocalName(int nodeHandle);
+
+  /**
+   * Given a namespace handle, return the prefix that the namespace decl is
+   * mapping.
+   * Given a node handle, return the prefix used to map to the namespace.
+   *
+   * <p> %REVIEW% Are you sure you want "" for no prefix?  </p>
+   * <p> %REVIEW-COMMENT% I think so... not totally sure. -sb  </p>
+   *
+   * @param nodeHandle the id of the node.
+   * @return String prefix of this node's name, or "" if no explicit
+   * namespace prefix was given.
+   */
+  public abstract String getPrefix(int nodeHandle);
+
+  /**
+   * Given a node handle, return its DOM-style namespace URI
+   * (As defined in Namespaces, this is the declared URI which this node's
+   * prefix -- or default in lieu thereof -- was mapped to.)
+   *
+   * <p>%REVIEW% Null or ""? -sb</p>
+   *
+   * @param nodeHandle the id of the node.
+   * @return String URI value of this node's namespace, or null if no
+   * namespace was resolved.
+   */
+  public abstract String getNamespaceURI(int nodeHandle);
+
+  /**
+   * Given a node handle, return its node value. This is mostly
+   * as defined by the DOM, but may ignore some conveniences.
+   * <p>
+   *
+   * @param nodeHandle The node id.
+   * @return String Value of this node, or null if not
+   * meaningful for this node type.
+   */
+  public abstract String getNodeValue(int nodeHandle);
+
+  /**
+   * Given a node handle, return its DOM-style node type.
+   * <p>
+   * %REVIEW% Generally, returning short is false economy. Return int?
+   *
+   * @param nodeHandle The node id.
+   * @return int Node type, as per the DOM's Node._NODE constants.
+   */
+  public short getNodeType(int nodeHandle)
+  {
+
+    int identity = nodeHandle & m_mask;
+    short type = (short) getNodeInfo(identity, OFFSET_TYPE);
+
+    return type;
+  }
+
+  /**
+   * <meta name="usage" content="internal"/>
+   * Get the depth level of this node in the tree (equals 1 for
+   * a parentless node).
+   *
+   * @param nodeHandle The node id.
+   * @return the number of ancestors, plus one
+   */
+  public short getLevel(int nodeHandle)
+  {
+
+    int identity = nodeHandle & m_mask;
+
+    // Apparently, the axis walker stuff requires levels to count from 1.
+    return (short) (getNodeInfo(identity, OFFSET_LEVEL) + 1);
+  }
+
+  // ============== Document query functions ============== 
+
+  /**
+   * Tests whether DTM DOM implementation implements a specific feature and
+   * that feature is supported by this node.
+   *
+   * @param feature The name of the feature to test.
+   * @param versionThis is the version number of the feature to test.
+   *   If the version is not
+   *   specified, supporting any version of the feature will cause the
+   *   method to return <code>true</code>.
+   * NEEDSDOC @param version
+   * @return Returns <code>true</code> if the specified feature is
+   *   supported on this node, <code>false</code> otherwise.
+   */
+  public boolean isSupported(String feature, String version)
+  {
+
+    // %TBD%
+    return false;
+  }
+
+  /**
+   * Return the base URI of the document entity. If it is not known
+   * (because the document was parsed from a socket connection or from
+   * standard input, for example), the value of this property is unknown.
+   *
+   * @return the document base URI String object or null if unknown.
+   */
+  public String getDocumentBaseURI()
+  {
+    return m_documentBaseURI;
+  }
+
+  /**
+   * Set the base URI of the document entity.
+   *
+   * @param baseURI the document base URI String object or null if unknown.
+   */
+  public void setDocumentBaseURI(String baseURI)
+  {
+    m_documentBaseURI = baseURI;
+  }
+
+  /**
+   * Return the system identifier of the document entity. If
+   * it is not known, the value of this property is unknown.
+   *
+   * @param nodeHandle The node id, which can be any valid node handle.
+   * @return the system identifier String object or null if unknown.
+   */
+  public String getDocumentSystemIdentifier(int nodeHandle)
+  {
+
+    // %REVIEW%  OK? -sb
+    return m_documentBaseURI;
+  }
+
+  /**
+   * Return the name of the character encoding scheme
+   *        in which the document entity is expressed.
+   *
+   * @param nodeHandle The node id, which can be any valid node handle.
+   * @return the document encoding String object.
+   */
+  public String getDocumentEncoding(int nodeHandle)
+  {
+
+    // %REVIEW%  OK??  -sb
+    return "UTF-8";
+  }
+
+  /**
+   * Return an indication of the standalone status of the document,
+   *        either "yes" or "no". This property is derived from the optional
+   *        standalone document declaration in the XML declaration at the
+   *        beginning of the document entity, and has no value if there is no
+   *        standalone document declaration.
+   *
+   * @param nodeHandle The node id, which can be any valid node handle.
+   * @return the document standalone String object, either "yes", "no", or null.
+   */
+  public String getDocumentStandalone(int nodeHandle)
+  {
+    return null;
+  }
+
+  /**
+   * Return a string representing the XML version of the document. This
+   * property is derived from the XML declaration optionally present at the
+   * beginning of the document entity, and has no value if there is no XML
+   * declaration.
+   *
+   * @param the document handle
+   *
+   * NEEDSDOC @param documentHandle
+   *
+   * @return the document version String object.
+   */
+  public String getDocumentVersion(int documentHandle)
+  {
+    return null;
+  }
+
+  /**
+   * Return an indication of
+   * whether the processor has read the complete DTD. Its value is a
+   * boolean. If it is false, then certain properties (indicated in their
+   * descriptions below) may be unknown. If it is true, those properties
+   * are never unknown.
+   *
+   * @return <code>true</code> if all declarations were processed;
+   *         <code>false</code> otherwise.
+   */
+  public boolean getDocumentAllDeclarationsProcessed()
+  {
+
+    // %REVIEW% OK?
+    return true;
+  }
+
+  /**
+   *   A document type declaration information item has the following properties:
+   *
+   *     1. [system identifier] The system identifier of the external subset, if
+   *        it exists. Otherwise this property has no value.
+   *
+   * @return the system identifier String object, or null if there is none.
+   */
+  public abstract String getDocumentTypeDeclarationSystemIdentifier();
+
+  /**
+   * Return the public identifier of the external subset,
+   * normalized as described in 4.2.2 External Entities [XML]. If there is
+   * no external subset or if it has no public identifier, this property
+   * has no value.
+   *
+   * @param the document type declaration handle
+   *
+   * @return the public identifier String object, or null if there is none.
+   */
+  public abstract String getDocumentTypeDeclarationPublicIdentifier();
+
+  /**
+   * Returns the <code>Element</code> whose <code>ID</code> is given by
+   * <code>elementId</code>. If no such element exists, returns
+   * <code>DTM.NULL</code>. Behavior is not defined if more than one element
+   * has this <code>ID</code>. Attributes (including those
+   * with the name "ID") are not of type ID unless so defined by DTD/Schema
+   * information available to the DTM implementation.
+   * Implementations that do not know whether attributes are of type ID or
+   * not are expected to return <code>DTM.NULL</code>.
+   *
+   * <p>%REVIEW% Presumably IDs are still scoped to a single document,
+   * and this operation searches only within a single document, right?
+   * Wouldn't want collisions between DTMs in the same process.</p>
+   *
+   * @param elementId The unique <code>id</code> value for an element.
+   * @return The handle of the matching element.
+   */
+  public abstract int getElementById(String elementId);
+
+  /**
+   * The getUnparsedEntityURI function returns the URI of the unparsed
+   * entity with the specified name in the same document as the context
+   * node (see [3.3 Unparsed Entities]). It returns the empty string if
+   * there is no such entity.
+   * <p>
+   * XML processors may choose to use the System Identifier (if one
+   * is provided) to resolve the entity, rather than the URI in the
+   * Public Identifier. The details are dependent on the processor, and
+   * we would have to support some form of plug-in resolver to handle
+   * this properly. Currently, we simply return the System Identifier if
+   * present, and hope that it a usable URI or that our caller can
+   * map it to one.
+   * TODO: Resolve Public Identifiers... or consider changing function name.
+   * <p>
+   * If we find a relative URI
+   * reference, XML expects it to be resolved in terms of the base URI
+   * of the document. The DOM doesn't do that for us, and it isn't
+   * entirely clear whether that should be done here; currently that's
+   * pushed up to a higher level of our application. (Note that DOM Level
+   * 1 didn't store the document's base URI.)
+   * TODO: Consider resolving Relative URIs.
+   * <p>
+   * (The DOM's statement that "An XML processor may choose to
+   * completely expand entities before the structure model is passed
+   * to the DOM" refers only to parsed entities, not unparsed, and hence
+   * doesn't affect this function.)
+   *
+   * @param name A string containing the Entity Name of the unparsed
+   * entity.
+   *
+   * @return String containing the URI of the Unparsed Entity, or an
+   * empty string if no such entity exists.
+   */
+  public abstract String getUnparsedEntityURI(String name);
+
+  // ============== Boolean methods ================
+
+  /**
+   * Return true if the xsl:strip-space or xsl:preserve-space was processed
+   * during construction of the DTM document.
+   *
+   * @return true if this DTM supports prestripping.
+   */
+  public boolean supportsPreStripping()
+  {
+    return true;
+  }
+
+  /**
+   * Figure out whether nodeHandle2 should be considered as being later
+   * in the document than nodeHandle1, in Document Order as defined
+   * by the XPath model. This may not agree with the ordering defined
+   * by other XML applications.
+   * <p>
+   * There are some cases where ordering isn't defined, and neither are
+   * the results of this function -- though we'll generally return true.
+   *
+   * TODO: Make sure this does the right thing with attribute nodes!!!
+   *
+   * @param node1 DOM Node to perform position comparison on.
+   * @param node2 DOM Node to perform position comparison on .
+   *
+   * NEEDSDOC @param nodeHandle1
+   * NEEDSDOC @param nodeHandle2
+   *
+   * @return false if node2 comes before node1, otherwise return true.
+   * You can think of this as
+   * <code>(node1.documentOrderPosition &lt;= node2.documentOrderPosition)</code>.
+   */
+  public boolean isNodeAfter(int nodeHandle1, int nodeHandle2)
+  {
+
+    int index1 = nodeHandle1 & m_mask;
+    int index2 = nodeHandle2 & m_mask;
+
+    return index1 <= index2;
+  }
+
+  /**
+   *     2. [element content whitespace] A boolean indicating whether the
+   *        character is white space appearing within element content (see [XML],
+   *        2.10 "White Space Handling"). Note that validating XML processors are
+   *        required by XML 1.0 to provide this information. If there is no
+   *        declaration for the containing element, this property has no value for
+   *        white space characters. If no declaration has been read, but the [all
+   *        declarations processed] property of the document information item is
+   *        false (so there may be an unread declaration), then the value of this
+   *        property is unknown for white space characters. It is always false for
+   *        characters that are not white space.
+   *
+   * @param nodeHandle the node ID.
+   * @return <code>true</code> if the character data is whitespace;
+   *         <code>false</code> otherwise.
+   */
+  public boolean isCharacterElementContentWhitespace(int nodeHandle)
+  {
+
+    // %TBD%
+    return false;
+  }
+
+  /**
+   *    10. [all declarations processed] This property is not strictly speaking
+   *        part of the infoset of the document. Rather it is an indication of
+   *        whether the processor has read the complete DTD. Its value is a
+   *        boolean. If it is false, then certain properties (indicated in their
+   *        descriptions below) may be unknown. If it is true, those properties
+   *        are never unknown.
+   *
+   * @param the document handle
+   *
+   * @param documentHandle A node handle that must identify a document.
+   * @return <code>true</code> if all declarations were processed;
+   *         <code>false</code> otherwise.
+   */
+  public boolean isDocumentAllDeclarationsProcessed(int documentHandle)
+  {
+    return true;
+  }
+
+  /**
+   *     5. [specified] A flag indicating whether this attribute was actually
+   *        specified in the start-tag of its element, or was defaulted from the
+   *        DTD.
+   *
+   * @param the attribute handle
+   *
+   * NEEDSDOC @param attributeHandle
+   * @return <code>true</code> if the attribute was specified;
+   *         <code>false</code> if it was defaulted.
+   */
+  public abstract boolean isAttributeSpecified(int attributeHandle);
+
+  // ========== Direct SAX Dispatch, for optimization purposes ========
+
+  /**
+   * Directly call the
+   * characters method on the passed ContentHandler for the
+   * string-value of the given node (see http://www.w3.org/TR/xpath#data-model
+   * for the definition of a node's string-value). Multiple calls to the
+   * ContentHandler's characters methods may well occur for a single call to
+   * this method.
+   *
+   * @param nodeHandle The node ID.
+   * @param ch A non-null reference to a ContentHandler.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public abstract void dispatchCharactersEvents(
+    int nodeHandle, org.xml.sax.ContentHandler ch)
+      throws org.xml.sax.SAXException;
+
+  /**
+   * Directly create SAX parser events from a subtree.
+   *
+   * @param nodeHandle The node ID.
+   * @param ch A non-null reference to a ContentHandler.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public abstract void dispatchToEvents(
+    int nodeHandle, org.xml.sax.ContentHandler ch)
+      throws org.xml.sax.SAXException;
+
+  /**
+   * Return an DOM node for the given node.
+   *
+   * @param nodeHandle The node ID.
+   *
+   * @return A node representation of the DTM node.
+   */
+  public org.w3c.dom.Node getNode(int nodeHandle)
+  {
+    return new DTMNodeProxy(this, nodeHandle);
+  }
+
+  // ==== Construction methods (may not be supported by some implementations!) =====
+
+  /**
+   * Append a child to the end of the document. Please note that the node
+   * is always cloned if it is owned by another document.
+   *
+   * <p>%REVIEW% "End of the document" needs to be defined more clearly.
+   * Does it become the last child of the Document? Of the root element?</p>
+   *
+   * @param newChild Must be a valid new node handle.
+   * @param clone true if the child should be cloned into the document.
+   * @param cloneDepth if the clone argument is true, specifies that the
+   *                   clone should include all it's children.
+   */
+  public void appendChild(int newChild, boolean clone, boolean cloneDepth)
+  {
+    error("appendChild not yet supported!");
+  }
+
+  /**
+   * Append a text node child that will be constructed from a string,
+   * to the end of the document.
+   *
+   * <p>%REVIEW% "End of the document" needs to be defined more clearly.
+   * Does it become the last child of the Document? Of the root element?</p>
+   *
+   * @param str Non-null reverence to a string.
+   */
+  public void appendTextChild(String str)
+  {
+    error("appendTextChild not yet supported!");
+  }
+
+  /**
+   * Simple error for asserts and the like.
+   *
+   * NEEDSDOC @param msg
+   */
+  protected void error(String msg)
+  {
+    throw new DTMException(msg);
+  }
+
+  /**
+   * Find out whether or not to strip whispace nodes.
+   *
+   *
+   * @return whether or not to strip whispace nodes.
+   */
+  protected boolean getShouldStripWhitespace()
+  {
+    return m_shouldStripWS;
+  }
+
+  /**
+   * Set whether to strip whitespaces and push in current value of
+   * m_shouldStripWS in m_shouldStripWhitespaceStack.
+   *
+   * @param shouldStrip Flag indicating whether to strip whitespace nodes
+   */
+  protected void pushShouldStripWhitespace(boolean shouldStrip)
+  {
+
+    m_shouldStripWS = shouldStrip;
+
+    if (null != m_shouldStripWhitespaceStack)
+      m_shouldStripWhitespaceStack.push(shouldStrip);
+  }
+
+  /**
+   * Set whether to strip whitespaces at this point by popping out
+   * m_shouldStripWhitespaceStack.
+   *
+   */
+  protected void popShouldStripWhitespace()
+  {
+    if (null != m_shouldStripWhitespaceStack)
+      m_shouldStripWS = m_shouldStripWhitespaceStack.popAndTop();
+  }
+
+  /**
+   * Set whether to strip whitespaces and set the top of the stack to
+   * the current value of m_shouldStripWS.
+   *
+   *
+   * @param shouldStrip Flag indicating whether to strip whitespace nodes
+   */
+  protected void setShouldStripWhitespace(boolean shouldStrip)
+  {
+
+    m_shouldStripWS = shouldStrip;
+
+    if (null != m_shouldStripWhitespaceStack)
+      m_shouldStripWhitespaceStack.setTop(shouldStrip);
+  }
+}
diff --git a/src/org/apache/xml/dtm/DTMDocumentImpl.java b/src/org/apache/xml/dtm/DTMDocumentImpl.java
new file mode 100644
index 0000000..892c680
--- /dev/null
+++ b/src/org/apache/xml/dtm/DTMDocumentImpl.java
@@ -0,0 +1,2363 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xml.dtm;
+
+import java.util.Hashtable;
+//import java.util.Stack;
+import java.util.Vector;
+
+import org.apache.xml.dtm.ChunkedIntArray;
+import org.apache.xml.utils.FastStringBuffer;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.Attributes;
+import org.xml.sax.ext.LexicalHandler;
+
+import org.apache.xml.utils.XMLString;
+import org.apache.xml.utils.XMLStringFactory;
+
+/**
+ * This is the implementation of the DTM document interface.  It receives
+ * requests from an XML content handler similar to that of an XML DOM or SAX parser
+ * to store information from the xml document in an array based
+ * dtm table structure.  This informtion is used later for document navigation,
+ * query, and SAX event dispatch functions. The DTM can also be used directly as a
+ * document composition model for an application.  The requests received are:
+ * <ul>
+ * <li>initiating DTM to set the doc handle</li>
+ * <li>resetting DTM for data structure reuse</li>
+ * <li>hinting the end of document to adjust the end of data structure pointers</li>
+ * <li>createnodes (element, comment, text, attribute, ....)</li>
+ * <li>hinting the end of an element to patch parent and siblings<li>
+ * <li>setting application provided symbol name stringpool data structures</li>
+ * </ul>
+ * <p>State: In progress!!</p>
+ *
+ * %REVIEW% I _think_ the SAX convention is that "no namespace" is expressed
+ * as "" rather than as null (which is the DOM's convention). What should 
+ * DTM expect? What should it do with the other?
+ *
+ * <p>Origin: the implemention is a composite logic based on the DTM of XalanJ1 and
+ *     DocImpl, DocumentImpl, ElementImpl, TextImpl, etc. of XalanJ2</p>
+ */
+public class DTMDocumentImpl
+implements DTM, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler
+{
+
+        // Number of lower bits used to represent node index.
+        protected static final byte DOCHANDLE_SHIFT = 20;
+        // Masks the lower order of node handle.
+        // Same as {@link DTMConstructor.IDENT_NODE_DEFAULT}
+        protected static final int NODEHANDLE_MASK = (1 << (DOCHANDLE_SHIFT + 1)) - 1; 
+        // Masks the higher order Document handle
+        // Same as {@link DTMConstructor.IDENT_DOC_DEFAULT}
+        protected static final int DOCHANDLE_MASK = -1 - NODEHANDLE_MASK;
+
+        int m_docHandle = NULL;		 // masked document handle for this dtm document
+        int m_docElement = NULL;	 // nodeHandle to the root of the actual dtm doc content
+
+        // Context for parse-and-append operations
+        int currentParent = 0;			// current parent - default is document root
+        int previousSibling = 0;		// previous sibling - no previous sibling
+        protected int m_currentNode = -1;		// current node
+
+        // The tree under construction can itself be used as
+        // the element stack, so m_elemStack isn't needed.
+        //protected Stack m_elemStack = new Stack();	 // element stack
+
+        private boolean previousSiblingWasParent = false;
+        // Local cache for record-at-a-time fetch
+        int gotslot[] = new int[4];
+
+        // endDocument recieved?
+        private boolean done = false;
+        boolean m_isError = false;
+
+        private final boolean DEBUG = false;
+        
+        /** The document base URI. */
+        protected String m_documentBaseURI;
+
+  /** If we're building the model incrementally on demand, we need to
+   * be able to tell the source when to send us more data.
+   *
+   * Note that if this has not been set, and you attempt to read ahead
+   * of the current build point, we'll probably throw a null-pointer
+   * exception. We could try to wait-and-retry instead, as a very poor
+   * fallback, but that has all the known problems with multithreading
+   * on multiprocessors and we Don't Want to Go There.
+   * 
+   * @see setCoroutineParser
+   */
+  private CoroutineParser m_coroutineParser=null;
+
+  /** If we're building the model incrementally on demand, we need to
+   * be able to tell the source who to return the data to.
+   *
+   * Note that if this has not been set, and you attempt to read ahead
+   * of the current build point, we'll probably throw a MethodNotFound
+   * exception. We could try to wait-and-retry instead, as a very poor
+   * fallback, but that has all the known problems with multithreading
+   * on multiprocessors and we Don't Want to Go There.
+   * 
+   * @see setCoroutineParser
+   */
+  private int m_appCoroutineID=-1;
+
+        // ========= DTM data structure declarations. ==============
+
+        // nodes array: integer array blocks to hold the first level reference of the nodes,
+        // each reference slot is addressed by a nodeHandle index value.
+        // Assumes indices are not larger than {@link NODEHANDLE_MASK}
+        // ({@link DOCHANDLE_SHIFT} bits).
+        ChunkedIntArray nodes = new ChunkedIntArray(4);
+
+        // text/comment table: string buffer to hold the text string values of the document,
+        // each of which is addressed by the absolute offset and length in the buffer
+        private FastStringBuffer m_char = new FastStringBuffer();
+        // Start of string currently being accumulated into m_char;
+        // needed because the string may be appended in several chunks.
+        private int m_char_current_start=0;
+
+        // %TBD% INITIALIZATION/STARTUP ISSUES
+        // -- Should we really be creating these, or should they be
+        // passed in from outside? Scott want to be able to share
+        // pools across multiple documents, so setting them here is
+        // probably not the right default.
+        private DTMStringPool m_localNames = new DTMStringPool();
+        private DTMStringPool m_nsNames = new DTMStringPool();
+        private DTMStringPool m_prefixNames = new DTMStringPool();
+
+        // %TBD% If we use the current ExpandedNameTable mapper, it
+        // needs to be bound to the NS and local name pools. Which
+        // means it needs to attach to them AFTER we've resolved their
+        // startup. Or it needs to attach to this document and
+        // retrieve them each time. Or this needs to be
+        // an interface _implemented_ by this class... which might be simplest!
+        private ExpandedNameTable m_expandedNames=
+                new ExpandedNameTable(m_localNames,m_nsNames);
+                
+        private XMLStringFactory m_xsf;
+  
+
+        /**
+         * Construct a DTM.
+         *
+         * @param documentNumber the ID number assigned to this document.
+         * It will be shifted up into the high bits and returned as part of
+         * all node ID numbers, so those IDs indicate which document they
+         * came from as well as a location within the document. It is the
+         * DTMManager's responsibility to assign a unique number to each
+         * document.
+         */
+        public DTMDocumentImpl(DTMManager mgr, int documentNumber, 
+                               DTMWSFilter whiteSpaceFilter,
+                               XMLStringFactory xstringfactory){
+                initDocument(documentNumber);	 // clear nodes and document handle
+                m_xsf = xstringfactory;
+        }
+
+  /** Bind a CoroutineParser to this DTM. If we discover we need nodes
+   * that have not yet been built, we will ask this object to send us more
+   * events, and it will manage interactions with its data sources.
+   *
+   * Note that we do not actually build the CoroutineParser, since we don't
+   * know what source it's reading from, what thread that source will run in,
+   * or when it will run.
+   *
+   * @param coroutineParser The parser that we want to recieve events from
+   * on demand.
+   */
+  public void setCoroutineParser(CoroutineParser coroutineParser)
+  {
+    // Establish coroutine link so we can request more data
+    //
+    // Note: It's possible that some versions of CoroutineParser may
+    // not actually use a CoroutineManager, and hence may not require
+    // that we obtain an Application Coroutine ID. (This relies on the
+    // coroutine transaction details having been encapsulated in the
+    // CoroutineParser.do...() methods.)
+    m_coroutineParser=coroutineParser;
+    CoroutineManager cm=coroutineParser.getCoroutineManager();
+    if(cm!=null)
+      m_appCoroutineID=cm.co_joinCoroutineSet(-1);
+
+    // Establish SAX-stream link so we can receive the requested data
+    coroutineParser.setContentHandler(this);
+    coroutineParser.setLexHandler(this);
+
+    // Are the following really needed? coroutineParser doesn't yet
+    // support them, and they're mostly no-ops here...
+    //coroutineParser.setErrorHandler(this);
+    //coroutineParser.setDTDHandler(this);
+    //coroutineParser.setDeclHandler(this);
+  }
+  
+        /**
+         * Wrapper for ChunkedIntArray.append, to automatically update the
+         * previous sibling's "next" reference (if necessary) and periodically
+         * wake a reader who may have encountered incomplete data and entered
+         * a wait state.
+         * @param w0 int As in ChunkedIntArray.append
+         * @param w1 int As in ChunkedIntArray.append
+         * @param w2 int As in ChunkedIntArray.append
+         * @param w3 int As in ChunkedIntArray.append
+         * @return int As in ChunkedIntArray.append
+         * @see ChunkedIntArray.append
+         */
+        private final int appendNode(int w0, int w1, int w2, int w3)
+        {
+                // A decent compiler may inline this.
+                int slotnumber = nodes.appendSlot(w0, w1, w2, w3);
+
+                if (DEBUG) System.out.println(slotnumber+": "+w0+" "+w1+" "+w2+" "+w3);
+
+                if (previousSiblingWasParent)
+                        nodes.writeEntry(previousSibling,2,slotnumber);
+
+                previousSiblingWasParent = false;	// Set the default; endElement overrides
+
+                return slotnumber;
+        }
+
+        // ========= DTM Implementation Control Functions. ==============
+
+        /**
+         * Set an implementation dependent feature.
+         * <p>
+         * %REVIEW% Do we really expect to set features on DTMs?
+         *
+         * @param featureId A feature URL.
+         * @param state true if this feature should be on, false otherwise.
+         */
+        public void setFeature(String featureId, boolean state) {};
+
+        /**
+         * Set a reference pointer to the element name symbol table.
+         * %REVIEW% Should this really be Public? Changing it while
+         * DTM is in use would be a disaster.
+         *
+         * @param poolRef DTMStringPool reference to an instance of table.
+         */
+        public void setLocalNameTable(DTMStringPool poolRef) {
+                m_localNames = poolRef;
+        }
+
+        /**
+         * Get a reference pointer to the element name symbol table.
+         *
+         * @return DTMStringPool reference to an instance of table.
+         */
+        public DTMStringPool getLocalNameTable() {
+                 return m_localNames;
+         }
+
+        /**
+         * Set a reference pointer to the namespace URI symbol table.
+         * %REVIEW% Should this really be Public? Changing it while
+         * DTM is in use would be a disaster.
+         *
+         * @param poolRef DTMStringPool reference to an instance of table.
+         */
+        public void setNsNameTable(DTMStringPool poolRef) {
+                m_nsNames = poolRef;
+        }
+
+        /**
+         * Get a reference pointer to the namespace URI symbol table.
+         *
+         * @return DTMStringPool reference to an instance of table.
+         */
+        public DTMStringPool getNsNameTable() {
+                 return m_nsNames;
+         }
+
+        /**
+         * Set a reference pointer to the prefix name symbol table.
+         * %REVIEW% Should this really be Public? Changing it while
+         * DTM is in use would be a disaster.
+         *
+         * @param poolRef DTMStringPool reference to an instance of table.
+         */
+        public void setPrefixNameTable(DTMStringPool poolRef) {
+                m_prefixNames = poolRef;
+        }
+
+        /**
+         * Get a reference pointer to the prefix name symbol table.
+         *
+         * @return DTMStringPool reference to an instance of table.
+         */
+        public DTMStringPool getPrefixNameTable() {
+                return m_prefixNames;
+        }
+
+         /**
+          * Set a reference pointer to the content-text repository
+          *
+          * @param bufferRef FastStringBuffer reference to an instance of
+          * buffer
+          */
+         void setContentBuffer(FastStringBuffer buffer) {
+                 m_char = buffer;
+         }
+ 
+         /**
+          * Get a reference pointer to the content-text repository
+          *
+          * @return FastStringBuffer reference to an instance of buffer
+          */
+         FastStringBuffer getContentBuffer() {
+                 return m_char;
+         }
+
+  /** getContentHandler returns "our SAX builder" -- the thing that
+   * someone else should send SAX events to in order to extend this
+   * DTM model.
+   *
+   * @return null if this model doesn't respond to SAX events,
+   * "this" if the DTM object has a built-in SAX ContentHandler,
+   * the CoroutineParser if we're bound to one and should receive
+   * the SAX stream via it for incremental build purposes...
+   * */
+  public org.xml.sax.ContentHandler getContentHandler()
+  {
+    if (m_coroutineParser instanceof CoroutineSAXParser)
+      return (ContentHandler) m_coroutineParser;
+    else
+      return this;
+  }
+  
+  /**
+   * Return this DTM's lexical handler.
+   *
+   * %REVIEW% Should this return null if constrution already done/begun?
+   *
+   * @return null if this model doesn't respond to lexical SAX events,
+   * "this" if the DTM object has a built-in SAX ContentHandler,
+   * the CoroutineParser if we're bound to one and should receive
+   * the SAX stream via it for incremental build purposes...
+   */
+  public LexicalHandler getLexicalHandler()
+  {
+
+    if (m_coroutineParser instanceof CoroutineSAXParser)
+      return (LexicalHandler) m_coroutineParser;
+    else
+      return this;
+  }
+  
+  /**
+   * Return this DTM's EntityResolver.
+   *
+   * @return null if this model doesn't respond to SAX entity ref events.
+   */
+  public org.xml.sax.EntityResolver getEntityResolver()
+  {
+
+    return null;
+  }
+  
+  /**
+   * Return this DTM's DTDHandler.
+   *
+   * @return null if this model doesn't respond to SAX dtd events.
+   */
+  public org.xml.sax.DTDHandler getDTDHandler()
+  {
+
+    return null;
+  }
+
+  /**
+   * Return this DTM's ErrorHandler.
+   *
+   * @return null if this model doesn't respond to SAX error events.
+   */
+  public org.xml.sax.ErrorHandler getErrorHandler()
+  {
+
+    return null;
+  }
+  
+  /**
+   * Return this DTM's DeclHandler.
+   *
+   * @return null if this model doesn't respond to SAX Decl events.
+   */
+  public org.xml.sax.ext.DeclHandler getDeclHandler()
+  {
+
+    return null;
+  }  
+  
+  /** @return true iff we're building this model incrementally (eg
+   * we're partnered with a CoroutineParser) and thus require that the
+   * transformation and the parse run simultaneously. Guidance to the
+   * DTMManager.
+   * */
+  public boolean needsTwoThreads()
+  {
+    return null!=m_coroutineParser;
+  }
+
+  //================================================================
+  // ========= SAX2 ContentHandler methods =========
+  // Accept SAX events, use them to build/extend the DTM tree.
+  // Replaces the deprecated DocumentHandler interface.
+
+  public void characters(char[] ch, int start, int length)
+       throws org.xml.sax.SAXException
+  {
+    // Actually creating the text node is handled by
+    // processAccumulatedText(); here we just accumulate the
+    // characters into the buffer.
+    m_char.append(ch,start,length);
+  }
+
+  // Flush string accumulation into a text node
+  private void processAccumulatedText()
+  {
+    int len=m_char.length();
+    if(len!=m_char_current_start)
+      {
+        // The FastStringBuffer has been previously agreed upon
+        appendTextChild(m_char_current_start,len-m_char_current_start);
+        m_char_current_start=len;
+      }
+  }
+  public void endDocument() 
+       throws org.xml.sax.SAXException
+  {
+    // May need to tell the low-level builder code to pop up a level.
+    // There _should't_ be any significant pending text at this point.
+    appendEndDocument();
+  }
+  public void endElement(java.lang.String namespaceURI, java.lang.String localName,
+      java.lang.String qName) 
+       throws org.xml.sax.SAXException
+  {
+    processAccumulatedText();
+    // No args but we do need to tell the low-level builder code to
+    // pop up a level.
+    appendEndElement();
+  }
+  public void endPrefixMapping(java.lang.String prefix) 
+       throws org.xml.sax.SAXException
+  {
+    // No-op
+  }
+  public void ignorableWhitespace(char[] ch, int start, int length) 
+       throws org.xml.sax.SAXException
+  {
+    // %TBD% I believe ignorable text isn't part of the DTM model...?
+  }
+  public void processingInstruction(java.lang.String target, java.lang.String data) 
+       throws org.xml.sax.SAXException
+  {
+    processAccumulatedText();
+    // %TBD% Which pools do target and data go into?
+  }
+  public void setDocumentLocator(Locator locator) 
+  {
+    // No-op for DTM
+  }
+  public void skippedEntity(java.lang.String name) 
+       throws org.xml.sax.SAXException
+  {
+    processAccumulatedText();
+    //%TBD%
+  }
+  public void startDocument() 
+       throws org.xml.sax.SAXException
+  {
+    appendStartDocument();
+  }
+  public void startElement(java.lang.String namespaceURI, java.lang.String localName,
+      java.lang.String qName, Attributes atts) 
+       throws org.xml.sax.SAXException
+  {
+    processAccumulatedText();
+
+    // %TBD% Split prefix off qname
+    String prefix=null;
+    int colon=qName.indexOf(':');
+    if(colon>0)
+      prefix=qName.substring(0,colon);
+
+    // %TBD% Where do we pool expandedName, or is it just the union, or...
+    /**/System.out.println("Prefix="+prefix+" index="+m_prefixNames.stringToIndex(prefix));
+    appendStartElement(m_nsNames.stringToIndex(namespaceURI),
+                     m_localNames.stringToIndex(localName),
+                     m_prefixNames.stringToIndex(prefix)); /////// %TBD%
+
+    // %TBD% I'm assuming that DTM will require resequencing of
+    // NS decls before other attrs, hence two passes are taken.
+    // %TBD% Is there an easier way to test for NSDecl?
+    int nAtts=(atts==null) ? 0 : atts.getLength();
+    // %TBD% Countdown is more efficient if nobody cares about sequence.
+    for(int i=nAtts-1;i>=0;--i)	
+      {
+        qName=atts.getQName(i);
+        if(qName.startsWith("xmlns:") || "xmlns".equals(qName))
+          {
+            prefix=null;
+            colon=qName.indexOf(':');
+            if(colon>0)
+              {
+                prefix=qName.substring(0,colon);
+              }
+            else
+              {
+                // %REVEIW% Null or ""?
+                prefix=null; // Default prefix
+              }
+            
+
+            appendNSDeclaration(
+                                    m_prefixNames.stringToIndex(prefix),
+                                    m_nsNames.stringToIndex(atts.getValue(i)),
+                                    atts.getType(i).equalsIgnoreCase("ID"));
+          }
+      }
+    
+    for(int i=nAtts-1;i>=0;--i)	
+      {
+        qName=atts.getQName(i);
+        if(!(qName.startsWith("xmlns:") || "xmlns".equals(qName)))
+          {
+            // %TBD% I hate having to extract the prefix into a new
+            // string when we may never use it. Consider pooling whole
+            // qNames, which are already strings?
+            prefix=null;
+            colon=qName.indexOf(':');
+            if(colon>0)
+              {
+                prefix=qName.substring(0,colon);
+                localName=qName.substring(colon+1);
+              }
+            else
+              {
+                prefix=""; // Default prefix
+                localName=qName;
+              }
+            
+            
+            m_char.append(atts.getValue(i)); // Single-string value
+            int contentEnd=m_char.length();
+            
+            if(!("xmlns".equals(prefix) || "xmlns".equals(qName)))
+              appendAttribute(m_nsNames.stringToIndex(atts.getURI(i)),
+                                  m_localNames.stringToIndex(localName),
+                                  m_prefixNames.stringToIndex(prefix),
+                                  atts.getType(i).equalsIgnoreCase("ID"),
+                                  m_char_current_start, contentEnd-m_char_current_start);
+            m_char_current_start=contentEnd;
+          }
+      }
+  }
+  public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) 
+       throws org.xml.sax.SAXException
+  {
+    // No-op in DTM, handled during element/attr processing?
+  }
+
+  //
+  // LexicalHandler support. Not all SAX2 parsers support these events
+  // but we may want to pass them through when they exist...
+  //
+  public void comment(char[] ch, int start, int length) 
+       throws org.xml.sax.SAXException
+  {
+    processAccumulatedText();
+
+    m_char.append(ch,start,length); // Single-string value
+    appendComment(m_char_current_start,length);
+    m_char_current_start+=length;    
+  }
+  public void endCDATA() 
+       throws org.xml.sax.SAXException
+  {
+    // No-op in DTM
+  }
+  public void endDTD() 
+       throws org.xml.sax.SAXException
+  {
+    // No-op in DTM
+  }
+  public void endEntity(java.lang.String name) 
+       throws org.xml.sax.SAXException
+  {
+    // No-op in DTM
+  }
+  public void startCDATA() 
+       throws org.xml.sax.SAXException
+  {
+    // No-op in DTM
+  }
+  public void startDTD(java.lang.String name, java.lang.String publicId,
+      java.lang.String systemId) 
+       throws org.xml.sax.SAXException
+  {
+    // No-op in DTM
+  }
+  public void startEntity(java.lang.String name) 
+       throws org.xml.sax.SAXException
+  {
+    // No-op in DTM
+  }
+
+
+  //================================================================
+  // ========= Document Handler Functions =========
+  // %REVIEW% jjk -- DocumentHandler is  SAX Level 1, and deprecated....
+  // and this wasn't a fully compliant or declared implementation of that API
+  // in any case. Phase out in favor of SAX2 ContentHandler/LexicalHandler
+
+        /**
+         * Reset a dtm document to its initial (empty) state.
+         *
+         * The DTMManager will invoke this method when the dtm is created.
+         *
+         * @param docHandle int the handle for the DTM document.
+         */
+        final void initDocument(int documentNumber)
+        {
+                // save masked DTM document handle
+                m_docHandle = documentNumber<<DOCHANDLE_SHIFT;
+
+                // Initialize the doc -- no parent, no next-sib
+                nodes.writeSlot(0,DOCUMENT_NODE,-1,-1,0);
+                // wait for the first startElement to create the doc root node
+                done = false;
+        }
+
+// 	/**
+// 	 * Receive hint of the end of a document.
+// 	 *
+// 	 * <p>The content handler will invoke this method only once, and it will
+// 	 * be the last method invoked during the parse.  The handler shall not
+// 	 * not invoke this method until it has either abandoned parsing
+// 	 * (because of an unrecoverable error) or reached the end of
+// 	 * input.</p>
+// 	 */
+// 	public void documentEnd()
+// 	{
+// 		done = true;
+// 		// %TBD% may need to notice the last slot number and slot count to avoid
+// 		// residual data from provious use of this DTM
+// 	}
+
+// 	/**
+// 	 * Receive notification of the beginning of a document.
+// 	 *
+// 	 * <p>The SAX parser will invoke this method only once, before any
+// 	 * other methods in this interface.</p>
+// 	 */
+// 	public void reset()
+// 	{
+
+// 		// %TBD% reset slot 0 to indicate ChunkedIntArray reuse or wait for
+// 		//       the next initDocument().
+// 		m_docElement = NULL;	 // reset nodeHandle to the root of the actual dtm doc content
+// 		initDocument(0);
+// 	}
+
+// 	/**
+// 	 * Factory method; creates an Element node in this document.
+// 	 *
+// 	 * The node created will be chained according to its natural order of request
+// 	 * received.  %TBD% It can be rechained later via the optional DTM writable interface.
+// 	 *
+// 	 * <p>The XML content handler will invoke endElement() method after all
+// 	 * of the element's content are processed in order to give DTM the indication
+// 	 * to prepare and patch up parent and sibling node pointers.</p>
+// 	 *
+// 	 * <p>The following interface for createElement will use an index value corresponds
+// 	 * to the symbol entry in the DTMDStringPool based symbol tables.</p>
+// 	 *
+// 	 * @param nsIndex The namespace of the node
+// 	 * @param nameIndex The element name.
+// 	 * @see #endElement
+// 	 * @see org.xml.sax.Attributes
+// 	 * @return nodeHandle int of the element created
+// 	 */
+// 	public int createElement(int nsIndex, int nameIndex, Attributes atts)
+// 	{
+// 		// do document root node creation here on the first element, create nodes for
+// 		// this element and its attributes, store the element, namespace, and attritute
+// 		// name indexes to the nodes array, keep track of the current node and parent
+// 		// element used
+
+// 		// W0  High:  Namespace  Low:  Node Type
+// 		int w0 = (nsIndex << 16) | ELEMENT_NODE;
+// 		// W1: Parent
+// 		int w1 = currentParent;
+// 		// W2: Next  (initialized as 0)
+// 		int w2 = 0;
+// 		// W3: Tagname
+// 		int w3 = nameIndex;
+// 		//int ourslot = nodes.appendSlot(w0, w1, w2, w3);
+// 		int ourslot = appendNode(w0, w1, w2, w3);
+// 		currentParent = ourslot;
+// 		previousSibling = 0;
+// 		setAttributes(atts);
+
+// 		// set the root element pointer when creating the first element node
+// 		if (m_docElement == NULL)
+// 			m_docElement = ourslot;
+// 		return (m_docHandle | ourslot);
+// 	}
+
+// 	// Factory method to create an Element node not associated with a given name space
+// 	// using String value parameters passed in from a content handler or application
+// 	/**
+// 	 * Factory method; creates an Element node not associated with a given name space in this document.
+// 	 *
+// 	 * The node created will be chained according to its natural order of request
+// 	 * received.  %TBD% It can be rechained later via the optional DTM writable interface.
+// 	 *
+// 	 * <p>The XML content handler or application will invoke endElement() method after all
+// 	 * of the element's content are processed in order to give DTM the indication
+// 	 * to prepare and patch up parent and sibling node pointers.</p>
+// 	 *
+// 	 * <p>The following parameters for createElement contains raw string values for name
+// 	 * symbols used in an Element node.</p>
+// 	 *
+// 	 * @param name String the element name, including the prefix if any.
+// 	 * @param atts The attributes attached to the element, if any.
+// 	 * @see #endElement
+// 	 * @see org.xml.sax.Attributes
+// 	 */
+// 	public int createElement(String name, Attributes atts)
+// 	{
+// 		// This method wraps around the index valued interface of the createElement interface.
+// 		// The raw string values are stored into the current DTM name symbol tables.  The method
+// 		// method will then use the index values returned to invoke the other createElement()
+// 		// onverted to index values modified to match a
+// 		// method.
+// 		int nsIndex = NULL;
+// 		int nameIndex = m_localNames.stringToIndex(name);
+// 		// note - there should be no prefix separator in the name because it is not associated
+// 		// with a name space
+
+// 		return createElement(nsIndex, nameIndex, atts);
+// 	}
+
+// 	// Factory method to create an Element node associated with a given name space
+// 	// using String value parameters passed in from a content handler or application
+// 	/**
+// 	 * Factory method; creates an Element node associated with a given name space in this document.
+// 	 *
+// 	 * The node created will be chained according to its natural order of request
+// 	 * received.  %TBD% It can be rechained later via the optional DTM writable interface.
+// 	 *
+// 	 * <p>The XML content handler or application will invoke endElement() method after all
+// 	 * of the element's content are processed in order to give DTM the indication
+// 	 * to prepare and patch up parent and sibling node pointers.</p>
+// 	 *
+// 	 * <p>The following parameters for createElementNS contains raw string values for name
+// 	 * symbols used in an Element node.</p>
+// 	 *
+// 	 * @param ns String the namespace of the node
+// 	 * @param name String the element name, including the prefix if any.
+// 	 * @param atts The attributes attached to the element, if any.
+// 	 * @see #endElement
+// 	 * @see org.xml.sax.Attributes
+// 	 */
+// 	public int createElementNS(String ns, String name, Attributes atts)
+// 	{
+// 		// This method wraps around the index valued interface of the createElement interface.
+// 		// The raw string values are stored into the current DTM name symbol tables.  The method
+// 		// method will then use the index values returned to invoke the other createElement()
+// 		// onverted to index values modified to match a
+// 		// method.
+// 		int nsIndex = m_nsNames.stringToIndex(ns);
+// 		int nameIndex = m_localNames.stringToIndex(name);
+// 		// The prefixIndex is not needed by the indexed interface of the createElement method
+// 		int prefixSep = name.indexOf(":");
+// 		int prefixIndex = m_prefixNames.stringToIndex(name.substring(0, prefixSep));
+// 		return createElement(nsIndex, nameIndex, atts);
+// 	}
+
+// 	/**
+// 	 * Receive an indication for the end of an element.
+// 	 *
+// 	 * <p>The XML content handler will invoke this method at the end of every
+// 	 * element in the XML document to give hint its time to pop up the current
+// 	 * element and parent and patch up parent and sibling pointers if necessary
+// 	 *
+// 	 * <p>%tbd% The following interface may need to be modified to match a
+// 	 * coordinated access to the DTMDStringPool based symbol tables.</p>
+// 		 *
+// 	 * @param ns the namespace of the element
+// 	 * @param localName The local part of the qualified name of the element
+// 	 * @param name The element name
+// 	 */
+// 	public void endElement(String ns, String name)
+// 	{ 
+// 		// pop up the stacks
+
+// 		// 
+// 		if (previousSiblingWasParent)
+// 			nodes.writeEntry(previousSibling, 2, NULL);
+
+// 		// Pop parentage 
+// 		previousSibling = currentParent;
+// 		nodes.readSlot(currentParent, gotslot);
+// 		currentParent = gotslot[1] & 0xFFFF;
+
+// 		// The element just being finished will be
+// 		// the previous sibling for the next operation
+// 		previousSiblingWasParent = true;
+
+// 		// Pop a level of namespace table
+// 		// namespaceTable.removeLastElem();
+// 	}
+
+// 	/**
+// 	 * Creates attributes for the current node.
+// 	 *
+// 	 * @param atts Attributes to be created.
+// 	 */
+// 	void setAttributes(Attributes atts) {
+// 		int atLength = (null == atts) ? 0 : atts.getLength();
+// 		for (int i=0; i < atLength; i++) {
+// 			String qname = atts.getQName(i);
+// 			createAttribute(atts.getQName(i), atts.getValue(i));
+// 		}
+// 	}
+
+// 	/**
+// 	 * Appends an attribute to the document.
+// 	 * @param qname Qualified Name of the attribute
+// 	 * @param value Value of the attribute
+// 	 * @return Handle of node
+// 	 */
+// 	public int createAttribute(String qname, String value) {
+// 		int colonpos = qname.indexOf(":");
+// 		String attName = qname.substring(colonpos+1);
+// 		int w0 = 0;
+// 		if (colonpos > 0) {
+// 			String prefix = qname.substring(0, colonpos);
+// 			if (prefix.equals("xml")) {
+// 				//w0 = ATTRIBUTE_NODE | 
+// 				//	(org.apache.xalan.templates.Constants.S_XMLNAMESPACEURI << 16);
+// 			} else {
+// 				//w0 = ATTRIBUTE_NODE | 
+// 			}
+// 		} else {
+// 			w0 = ATTRIBUTE_NODE;
+// 		}
+// 		// W1:  Parent
+// 		int w1 = currentParent;
+// 		// W2:  Next (not yet resolved)
+// 		int w2 = 0;
+// 		// W3:  Tag name
+// 		int w3 = m_localNames.stringToIndex(attName);
+// 		// Add node
+// 		int ourslot = appendNode(w0, w1, w2, w3);
+// 		previousSibling = ourslot;	// Should attributes be previous siblings
+
+// 		// W0: Node Type
+// 		w0 = TEXT_NODE;
+// 		// W1: Parent
+// 		w1 = ourslot;
+// 		// W2: Start Position within buffer
+// 		w2 = m_char.length();
+// 		m_char.append(value);
+// 		// W3: Length
+// 		w3 = m_char.length() - w2;
+// 		appendNode(w0, w1, w2, w3);
+// 		charStringStart=m_char.length();
+// 		charStringLength = 0;
+// 		//previousSibling = ourslot;
+// 		// Attrs are Parents
+// 		previousSiblingWasParent = true;
+// 		return (m_docHandle | ourslot);
+// 	}
+
+// 	/**
+// 	 * Factory method; creates a Text node in this document.
+// 	 *
+// 	 * The node created will be chained according to its natural order of request
+// 	 * received.  %TBD% It can be rechained later via the optional DTM writable interface.
+// 	 *
+// 	 * @param text String The characters text string from the XML document.
+// 	 * @return int DTM node-number of the text node created
+// 	 */
+// 	public int createTextNode(String text)
+// 	throws DTMException
+// 	{ 
+// 		// wraps around the index value based createTextNode method
+// 		return createTextNode(text.toCharArray(), 0, text.length());
+// 	}
+
+// 	/**
+// 	 * Factory method; creates a Text node in this document.
+// 	 *
+// 	 * The node created will be chained according to its natural order of request
+// 	 * received.  %TBD% It can be rechained later via the optional DTM writable interface.
+// 	 *
+// 	 * %REVIEW% for text normalization issues, unless we are willing to
+// 	 * insist that all adjacent text must be merged before this method
+// 	 * is called.
+// 	 *
+// 	 * @param ch The characters from the XML document.
+// 	 * @param start The start position in the array.
+// 	 * @param length The number of characters to read from the array.
+// 	 */
+// 	public int createTextNode(char ch[], int start, int length)
+// 	throws DTMException
+// 	{
+// 		m_char.append(ch, start, length);		// store the chunk to the text/comment string table
+
+// 		// create a Text Node
+// 		// %TBD% may be possible to combine with appendNode()to replace the next chunk of code
+// 		int w0 = TEXT_NODE;
+// 		// W1: Parent
+// 		int w1 = currentParent;
+// 		// W2: Start position within m_char
+// 		int w2 = charStringStart;
+// 		// W3: Length of the full string
+// 		int w3 = length;
+// 		int ourslot = appendNode(w0, w1, w2, w3);
+// 		previousSibling = ourslot;
+
+// 		charStringStart=m_char.length();
+// 		charStringLength = 0;
+// 		return (m_docHandle | ourslot);
+// 	}
+
+// 	/**
+// 	 * Factory method; creates a Comment node in this document.
+// 	 *
+// 	 * The node created will be chained according to its natural order of request
+// 	 * received.  %TBD% It can be rechained later via the optional DTM writable interface.
+// 	 *
+// 	 * @param text String The characters text string from the XML document.
+// 	 * @return int DTM node-number of the text node created
+// 	 */
+// 	public int createComment(String text)
+// 	throws DTMException
+// 	{
+// 		// wraps around the index value based createTextNode method
+// 		return createComment(text.toCharArray(), 0, text.length());
+// 	}
+
+// 	/**
+// 	 * Factory method; creates a Comment node in this document.
+// 	 *
+// 	 * The node created will be chained according to its natural order of request
+// 	 * received.  %TBD% It can be rechained later via the optional DTM writable interface.
+// 	 *
+// 	 * @param ch An array holding the characters in the comment.
+// 	 * @param start The starting position in the array.
+// 	 * @param length The number of characters to use from the array.
+// 	 * @see DTMException
+// 	 */
+// 	public int createComment(char ch[], int start, int length)
+// 	throws DTMException
+// 	{
+// 		m_char.append(ch, start, length);		// store the comment string to the text/comment string table
+
+// 		// create a Comment Node
+// 		// %TBD% may be possible to combine with appendNode()to replace the next chunk of code
+// 		int w0 = COMMENT_NODE;
+// 		// W1: Parent
+// 		int w1 = currentParent;
+// 		// W2: Start position within m_char
+// 		int w2 = charStringStart;
+// 		// W3: Length of the full string
+// 		int w3 = length;
+// 		int ourslot = appendNode(w0, w1, w2, w3);
+// 		previousSibling = ourslot;
+
+// 		charStringStart=m_char.length();
+// 		charStringLength = 0;
+// 		return (m_docHandle | ourslot);
+// 	}
+
+// 	// Counters to keep track of the current text string being accumulated with respect
+// 	// to the text/comment string table: charStringStart should point to the starting
+// 	// offset of the string in the table and charStringLength the acccumulated length when
+// 	// appendAccumulatedText starts, and reset to the end of the table and 0 at the end
+// 	// of appendAccumulatedText for the next set of characters receives
+// 	int charStringStart=0,charStringLength=0;
+
+        // ========= Document Navigation Functions =========
+
+        /** Given a node handle, test if it has child nodes.
+         * <p> %REVIEW% This is obviously useful at the DOM layer, where it
+         * would permit testing this without having to create a proxy
+         * node. It's less useful in the DTM API, where
+         * (dtm.getFirstChild(nodeHandle)!=DTM.NULL) is just as fast and
+         * almost as self-evident. But it's a convenience, and eases porting
+         * of DOM code to DTM.  </p>
+         *
+         * @param nodeHandle int Handle of the node.
+         * @return int true if the given node has child nodes.
+         */
+        public boolean hasChildNodes(int nodeHandle) {
+                return(getFirstChild(nodeHandle) != NULL);
+        }
+
+        /**
+         * Given a node handle, get the handle of the node's first child.
+         * If not yet resolved, waits for more nodes to be added to the document and
+         * tries again.
+         *
+         * @param nodeHandle int Handle of the node.
+         * @return int DTM node-number of first child, or DTM.NULL to indicate none exists.
+         */
+        public int getFirstChild(int nodeHandle) {
+                
+                // ###shs worry about tracing/debug later
+                nodeHandle &= NODEHANDLE_MASK;
+                // Read node into variable
+                nodes.readSlot(nodeHandle, gotslot);
+
+                // type is the last half of first slot
+                short type = (short) (gotslot[0] & 0xFFFF);
+
+                // Check to see if Element or Document node
+                if ((type == ELEMENT_NODE) || (type == DOCUMENT_NODE) || 
+                                (type == ENTITY_REFERENCE_NODE)) {
+
+                        // In case when Document root is given
+                        //	if (nodeHandle == 0) nodeHandle = 1;
+                        // %TBD% Probably was a mistake.
+                        // If someone explicitly asks for first child
+                        // of Document, I would expect them to want
+                        // that and only that.
+
+                        int kid = nodeHandle + 1;
+                        nodes.readSlot(kid, gotslot);
+                        while (ATTRIBUTE_NODE == (gotslot[0] & 0xFFFF)) {
+                                // points to next sibling
+                                kid = gotslot[2];
+                                // Return NULL if node has only attributes
+                                if (kid == NULL) return NULL; 
+                                nodes.readSlot(kid, gotslot);
+                        }
+                        // If parent slot matches given parent, return kid
+                        if (gotslot[1] == nodeHandle)	
+                        {
+                          int firstChild = kid | m_docHandle;
+                          
+                          return firstChild;
+                        }
+                }
+                // No child found
+                
+                return NULL;
+        }
+
+        /**
+        * Given a node handle, advance to its last child.
+        * If not yet resolved, waits for more nodes to be added to the document and
+        * tries again.
+        *
+        * @param nodeHandle int Handle of the node.
+        * @return int Node-number of last child,
+        * or DTM.NULL to indicate none exists.
+        */
+        public int getLastChild(int nodeHandle) {
+                // ###shs put trace/debug later
+                nodeHandle &= NODEHANDLE_MASK;
+                // do not need to test node type since getFirstChild does that
+                int lastChild = NULL;
+                for (int nextkid = getFirstChild(nodeHandle); nextkid != NULL;
+                                nextkid = getNextSibling(nextkid)) {
+                        lastChild = nextkid;
+                }
+                return lastChild | m_docHandle;		
+        }
+
+        /**
+         * Retrieves an attribute node by by qualified name and namespace URI.
+         *
+         * @param nodeHandle int Handle of the node upon which to look up this attribute.
+         * @param namespaceURI The namespace URI of the attribute to
+         *   retrieve, or null.
+         * @param name The local name of the attribute to
+         *   retrieve.
+         * @return The attribute node handle with the specified name (
+         *   <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such
+         *   attribute.
+         */
+        public int getAttributeNode(int nodeHandle, String namespaceURI, String name) {
+                int nsIndex = m_nsNames.stringToIndex(namespaceURI),
+                                                                        nameIndex = m_localNames.stringToIndex(name);
+                nodeHandle &= NODEHANDLE_MASK;
+                nodes.readSlot(nodeHandle, gotslot);
+                short type = (short) (gotslot[0] & 0xFFFF);
+                // If nodeHandle points to element next slot would be first attribute
+                if (type == ELEMENT_NODE)
+                        nodeHandle++;
+                // Iterate through Attribute Nodes
+                while (type == ATTRIBUTE_NODE) {
+                        if ((nsIndex == (gotslot[0] << 16)) && (gotslot[3] == nameIndex))
+                                return nodeHandle | m_docHandle;
+                        // Goto next sibling
+                        nodeHandle = gotslot[2];
+                        nodes.readSlot(nodeHandle, gotslot);
+                }
+                return NULL;
+        }
+
+        /**
+         * Given a node handle, get the index of the node's first attribute.
+         *
+         * @param nodeHandle int Handle of the Element node.
+         * @return Handle of first attribute, or DTM.NULL to indicate none exists.
+         */
+        public int getFirstAttribute(int nodeHandle) {
+                nodeHandle &= NODEHANDLE_MASK;
+
+                // %REVIEW% jjk: Just a quick observation: If you're going to
+                // call readEntry repeatedly on the same node, it may be
+                // more efficiently to do a readSlot to get the data locally,
+                // reducing the addressing and call-and-return overhead.
+
+                // Should we check if handle is element (do we want sanity checks?)
+                if (ELEMENT_NODE != (nodes.readEntry(nodeHandle, 0) & 0xFFFF))
+                        return NULL;
+                // First Attribute (if any) should be at next position in table
+                nodeHandle++;
+                return(ATTRIBUTE_NODE == (nodes.readEntry(nodeHandle, 0) & 0xFFFF)) ? 
+                nodeHandle | m_docHandle : NULL;
+        }
+
+        /**
+         * Given a node handle, get the index of the node's first child.
+         * If not yet resolved, waits for more nodes to be added to the document and
+         * tries again
+         *
+         * @param nodeHandle handle to node, which should probably be an element
+         *                   node, but need not be.
+         *
+         * @param inScope    true if all namespaces in scope should be returned,
+         *                   false if only the namespace declarations should be
+         *                   returned.
+         * @return handle of first namespace, or DTM.NULL to indicate none exists.
+         */
+        public int getFirstNamespaceNode(int nodeHandle, boolean inScope) {
+
+                return NULL;
+        }
+
+        /**
+         * Given a node handle, advance to its next sibling.
+         *
+         * %TBD% This currently uses the DTM-internal definition of
+         * sibling; eg, the last attr's next sib is the first
+         * child. In the old DTM, the DOM proxy layer provided the
+         * additional logic for the public view.  If we're rewriting
+         * for XPath emulation, that test must be done here.
+         *
+         * %TBD% CODE INTERACTION WITH COROUTINE PARSE - If not yet
+         * resolved, should wait for more nodes to be added to the document
+         * and tries again.
+         *
+         * @param nodeHandle int Handle of the node.
+         * @return int Node-number of next sibling,
+         * or DTM.NULL to indicate none exists.
+         * */
+        public int getNextSibling(int nodeHandle) {
+                nodeHandle &= NODEHANDLE_MASK;
+                // Document root has no next sibling
+                if (nodeHandle == 0)
+                        return NULL;
+
+                short type = (short) (nodes.readEntry(nodeHandle, 0) & 0xFFFF);
+                if ((type == ELEMENT_NODE) || (type == ATTRIBUTE_NODE) ||
+                                (type == ENTITY_REFERENCE_NODE)) {
+                        int nextSib = nodes.readEntry(nodeHandle, 2);
+                        if (nextSib == NULL)
+                                return NULL;
+                        if (nextSib != 0)
+                                return (m_docHandle | nextSib);
+                        // ###shs should cycle/wait if nextSib is 0? Working on threading next
+                }
+                // Next Sibling is in the next position if it shares the same parent
+                int thisParent = nodes.readEntry(nodeHandle, 1);
+                
+                if (nodes.readEntry(++nodeHandle, 1) == thisParent)
+                        return (m_docHandle | nodeHandle);
+
+                return NULL;
+        }
+
+        /**
+         * Given a node handle, find its preceeding sibling.
+         * WARNING: DTM is asymmetric; this operation is resolved by search, and is
+         * relatively expensive.
+         *
+         * @param nodeHandle the id of the node.
+         * @return int Node-number of the previous sib,
+         * or DTM.NULL to indicate none exists.
+         */
+        public int getPreviousSibling(int nodeHandle) {
+                nodeHandle &= NODEHANDLE_MASK;
+                // Document root has no previous sibling
+                if (nodeHandle == 0)
+                        return NULL;
+
+                int parent = nodes.readEntry(nodeHandle, 1);
+                int kid = NULL;
+                for (int nextkid = getFirstChild(parent); nextkid != nodeHandle;
+                                nextkid = getNextSibling(nextkid)) {
+                        kid = nextkid;
+                }
+                return kid | m_docHandle;
+        }
+
+        /**
+         * Given a node handle, advance to the next attribute. If an
+         * element, we advance to its first attribute; if an attr, we advance to
+         * the next attr on the same node.
+         *
+         * @param nodeHandle int Handle of the node.
+         * @return int DTM node-number of the resolved attr,
+         * or DTM.NULL to indicate none exists.
+         */
+        public int getNextAttribute(int nodeHandle) {
+                nodeHandle &= NODEHANDLE_MASK;
+                nodes.readSlot(nodeHandle, gotslot);
+
+                //%REVIEW% Why are we using short here? There's no storage
+                //reduction for an automatic variable, especially one used
+                //so briefly, and it typically costs more cycles to process
+                //than an int would.
+                short type = (short) (gotslot[0] & 0xFFFF);
+
+                if (type == ELEMENT_NODE) {
+                        return getFirstAttribute(nodeHandle);
+                } else if (type == ATTRIBUTE_NODE) {
+                        if (gotslot[2] != NULL)
+                                return (m_docHandle | gotslot[2]);
+                }
+                return NULL;
+        }
+
+        /**
+         * Given a namespace handle, advance to the next namespace.
+         *
+         * %TBD% THIS METHOD DOES NOT MATCH THE CURRENT SIGNATURE IN
+         * THE DTM INTERFACE.  FIX IT, OR JUSTIFY CHANGING THE DTM
+         * API.
+         *
+         * @param namespaceHandle handle to node which must be of type NAMESPACE_NODE.
+         * @return handle of next namespace, or DTM.NULL to indicate none exists.
+         */
+        public int getNextNamespaceNode(int baseHandle,int namespaceHandle, boolean inScope) {
+                // ###shs need to work on namespace
+                return NULL;
+        }
+
+        /**
+         * Given a node handle, advance to its next descendant.
+         * If not yet resolved, waits for more nodes to be added to the document and
+         * tries again.
+         *
+         * @param subtreeRootNodeHandle
+         * @param nodeHandle int Handle of the node.
+         * @return handle of next descendant,
+         * or DTM.NULL to indicate none exists.
+         */
+        public int getNextDescendant(int subtreeRootHandle, int nodeHandle) {
+                subtreeRootHandle &= NODEHANDLE_MASK;
+                nodeHandle &= NODEHANDLE_MASK;
+                // Document root [Document Node? -- jjk] - no next-sib
+                if (nodeHandle == 0)
+                        return NULL;
+                while (!m_isError) {
+                        // Document done and node out of bounds
+                        if (done && (nodeHandle > nodes.slotsUsed()))
+                                break;
+                        if (nodeHandle > subtreeRootHandle) {
+                                nodes.readSlot(nodeHandle+1, gotslot);
+                                if (gotslot[2] != 0) {
+                                        short type = (short) (gotslot[0] & 0xFFFF);
+                                        if (type == ATTRIBUTE_NODE) {
+                                                nodeHandle +=2;
+                                        } else {
+                                                int nextParentPos = gotslot[1];
+                                                if (nextParentPos >= subtreeRootHandle)
+                                                        return (m_docHandle | (nodeHandle+1));
+                                                else
+                                                        break;
+                                        }
+                                } else if (!done) {
+                                        // Add wait logic here
+                                } else
+                                        break;
+                        } else {
+                                nodeHandle++;
+                        }
+                }
+                // Probably should throw error here like original instead of returning
+                return NULL;
+        }
+
+        /**
+         * Given a node handle, advance to the next node on the following axis.
+         *
+         * @param axisContextHandle the start of the axis that is being traversed.
+         * @param nodeHandle
+         * @return handle of next sibling,
+         * or DTM.NULL to indicate none exists.
+         */
+        public int getNextFollowing(int axisContextHandle, int nodeHandle) {
+                //###shs still working on
+                return NULL;
+        }
+
+        /**
+         * Given a node handle, advance to the next node on the preceding axis.
+         *
+         * @param axisContextHandle the start of the axis that is being traversed.
+         * @param nodeHandle the id of the node.
+         * @return int Node-number of preceding sibling,
+         * or DTM.NULL to indicate none exists.
+         */
+        public int getNextPreceding(int axisContextHandle, int nodeHandle) {
+                // ###shs copied from Xalan 1, what is this suppose to do?
+                nodeHandle &= NODEHANDLE_MASK;
+                while (nodeHandle > 1) {
+                        nodeHandle--;
+                        if (ATTRIBUTE_NODE == (nodes.readEntry(nodeHandle, 0) & 0xFFFF))
+                                continue;
+
+                        // if nodeHandle is _not_ an ancestor of
+                        // axisContextHandle, specialFind will return it.
+                        // If it _is_ an ancestor, specialFind will return -1
+
+                        // %REVIEW% unconditional return defeats the
+                        // purpose of the while loop -- does this
+                        // logic make any sense?
+
+                        return (m_docHandle | nodes.specialFind(axisContextHandle, nodeHandle));
+                }
+                return NULL;
+        }
+
+        /**
+         * Given a node handle, find its parent node.
+         *
+         * @param nodeHandle the id of the node.
+         * @return int Node-number of parent,
+         * or DTM.NULL to indicate none exists.
+         */
+        public int getParent(int nodeHandle) {
+                // Should check to see within range?
+
+                // Document Root should not have to be handled differently
+                return (m_docHandle | nodes.readEntry(nodeHandle, 1));
+        }
+
+        /**
+         * Returns the root element of the document.
+         * @return nodeHandle to the Document Root.
+         */
+        public int getDocumentRoot() {
+                return (m_docHandle | m_docElement);
+        }
+
+        /**
+                * Given a node handle, find the owning document node.
+                *
+                * @param nodeHandle the id of the node.
+                * @return int Node handle of document, which should always be valid.
+                */
+        public int getDocument() {
+                return m_docHandle;
+        }
+
+        /**
+         * Given a node handle, find the owning document node.  This has the exact
+         * same semantics as the DOM Document method of the same name, in that if
+         * the nodeHandle is a document node, it will return NULL.
+         *
+         * <p>%REVIEW% Since this is DOM-specific, it may belong at the DOM
+         * binding layer. Included here as a convenience function and to
+         * aid porting of DOM code to DTM.</p>
+         *
+         * @param nodeHandle the id of the node.
+         * @return int Node handle of owning document, or NULL if the nodeHandle is
+         *             a document.
+         */
+        public int getOwnerDocument(int nodeHandle) {
+                // Assumption that Document Node is always in 0 slot
+                if ((nodeHandle & NODEHANDLE_MASK) == 0)
+                        return NULL;
+                return (nodeHandle & DOCHANDLE_MASK);
+        }
+
+
+        /**
+         * Get the string-value of a node as a String object
+         * (see http://www.w3.org/TR/xpath#data-model
+         * for the definition of a node's string-value).
+         *
+         * @param nodeHandle The node ID.
+         *
+         * @return A string object that represents the string-value of the given node.
+         */
+        public XMLString getStringValue(int nodeHandle) {
+        // ###zaj - researching 
+        nodes.readSlot(nodeHandle, gotslot);
+        int nodetype=gotslot[0] & 0xFF;		
+        String value=null;
+
+        switch (nodetype) {			
+        case TEXT_NODE:   
+        case COMMENT_NODE:
+        case CDATA_SECTION_NODE: 
+                value= m_char.getString(gotslot[2], gotslot[3]);		
+                break;
+        case PROCESSING_INSTRUCTION_NODE:
+        case ATTRIBUTE_NODE:	
+        case ELEMENT_NODE:
+        case ENTITY_REFERENCE_NODE:
+        default:
+                break;
+        }
+        return m_xsf.newstr( value ); 
+               
+        }
+
+        /**
+         * Get number of character array chunks in
+         * the string-value of a node.
+         * (see http://www.w3.org/TR/xpath#data-model
+         * for the definition of a node's string-value).
+         * Note that a single text node may have multiple text chunks.
+         *
+         * EXPLANATION: This method is an artifact of the fact that the
+         * underlying m_chars object may not store characters in a
+         * single contiguous array -- for example,the current
+         * FastStringBuffer may split a single node's text across
+         * multiple allocation units.  This call tells us how many
+         * separate accesses will be required to retrieve the entire
+         * content. PLEASE NOTE that this may not be the same as the
+         * number of SAX characters() events that caused the text node
+         * to be built in the first place, since m_chars buffering may
+         * be on different boundaries than the parser's buffers.
+         *
+         * @param nodeHandle The node ID.
+         *
+         * @return number of character array chunks in
+         *         the string-value of a node.
+         * */
+        //###zaj - tbd
+        public int getStringValueChunkCount(int nodeHandle)
+        {
+                //###zaj    return value 
+                return 0;
+        }
+
+        /**
+         * Get a character array chunk in the string-value of a node.
+         * (see http://www.w3.org/TR/xpath#data-model
+         * for the definition of a node's string-value).
+         * Note that a single text node may have multiple text chunks.
+         *
+         * EXPLANATION: This method is an artifact of the fact that
+         * the underlying m_chars object may not store characters in a
+         * single contiguous array -- for example,the current
+         * FastStringBuffer may split a single node's text across
+         * multiple allocation units.  This call retrieves a single
+         * contiguous portion of the text -- as much as m-chars was
+         * able to store in a single allocation unit.  PLEASE NOTE
+         * that this may not be the same granularityas the SAX
+         * characters() events that caused the text node to be built
+         * in the first place, since m_chars buffering may be on
+         * different boundaries than the parser's buffers.
+         *
+         * @param nodeHandle The node ID.
+         * @param chunkIndex Which chunk to get.
+         * @param startAndLen An array of 2 where the start position and length of
+         *                    the chunk will be returned.
+         *
+         * @return The character array reference where the chunk occurs.  */
+        //###zaj - tbd 
+        public char[] getStringValueChunk(int nodeHandle, int chunkIndex,
+                                                                                                                                                int[] startAndLen) {return new char[0];}
+
+        /**
+         * Given a node handle, return an ID that represents the node's expanded name.
+         *
+         * @param nodeHandle The handle to the node in question.
+         *
+         * @return the expanded-name id of the node.
+         */
+        public int getExpandedNameID(int nodeHandle) {
+           nodes.readSlot(nodeHandle, gotslot);
+           String qName = m_localNames.indexToString(gotslot[3]); 
+           // Remove prefix from qName
+           // %TBD% jjk This is assuming the elementName is the qName.
+           int colonpos = qName.indexOf(":");
+           String localName = qName.substring(colonpos+1);
+           // Get NS
+           String namespace = m_nsNames.indexToString(gotslot[0] << 16); 
+           // Create expanded name
+           String expandedName = namespace + ":" + localName;
+           int expandedNameID = m_nsNames.stringToIndex(expandedName);
+
+        return expandedNameID;
+        }
+
+
+        /**
+         * Given an expanded name, return an ID.  If the expanded-name does not
+         * exist in the internal tables, the entry will be created, and the ID will
+         * be returned.  Any additional nodes that are created that have this
+         * expanded name will use this ID.
+         *
+         * @param nodeHandle The handle to the node in question.
+         *
+         * @return the expanded-name id of the node.
+         */
+        public int getExpandedNameID(String namespace, String localName, int type) {
+           // Create expanded name
+          // %TBD% jjk Expanded name is bitfield-encoded as
+          // typeID[6]nsuriID[10]localID[16]. Switch to that form, and to
+          // accessing the ns/local via their tables rather than confusing
+          // nsnames and expandednames.
+           String expandedName = namespace + ":" + localName;
+           int expandedNameID = m_nsNames.stringToIndex(expandedName);
+
+           return expandedNameID;
+        }
+
+
+        /**
+         * Given an expanded-name ID, return the local name part.
+         *
+         * @param ExpandedNameID an ID that represents an expanded-name.
+         * @return String Local name of this node.
+         */
+        public String getLocalNameFromExpandedNameID(int ExpandedNameID) {
+
+           // Get expanded name
+           String expandedName = m_localNames.indexToString(ExpandedNameID); 
+           // Remove prefix from expanded name
+           int colonpos = expandedName.indexOf(":");
+           String localName = expandedName.substring(colonpos+1);
+           return localName;
+        }
+
+
+        /**
+         * Given an expanded-name ID, return the namespace URI part.
+         *
+         * @param ExpandedNameID an ID that represents an expanded-name.
+         * @return String URI value of this node's namespace, or null if no
+         * namespace was resolved.
+        */
+        public String getNamespaceFromExpandedNameID(int ExpandedNameID) {
+
+           String expandedName = m_localNames.indexToString(ExpandedNameID); 
+           // Remove local name from expanded name
+           int colonpos = expandedName.indexOf(":");
+           String nsName = expandedName.substring(0, colonpos);
+
+        return nsName;
+        }
+
+
+        /**
+         * fixednames 
+        */ 
+        static final String[] fixednames=
+        {
+                null,null,							// nothing, Element
+                null,"#text",						// Attr, Text
+                "#cdata_section",null,	// CDATA, EntityReference
+                null,null,							// Entity, PI
+                "#comment","#document",	// Comment, Document
+                null,"#document-fragment", // Doctype, DocumentFragment
+                null};									// Notation
+
+        /**
+         * Given a node handle, return its DOM-style node name. This will
+         * include names such as #text or #document.
+         *
+         * @param nodeHandle the id of the node.
+         * @return String Name of this node, which may be an empty string.
+         * %REVIEW% Document when empty string is possible...
+         */
+        public String getNodeName(int nodeHandle) {
+                nodes.readSlot(nodeHandle, gotslot);
+                short type = (short) (gotslot[0] & 0xFFFF);
+                String name = fixednames[type];
+                if (null == name) {
+                  int i=gotslot[3];
+                  /**/System.out.println("got i="+i+" "+(i>>16)+"/"+(i&0xffff));
+                  
+                  name=m_localNames.indexToString(i & 0xFFFF);
+                  String prefix=m_prefixNames.indexToString(i >>16);
+                  if(prefix!=null && prefix.length()>0)
+                    name=prefix+":"+name;
+                }
+                return name;
+        }
+
+        /**
+         * Given a node handle, return the XPath node name.  This should be
+         * the name as described by the XPath data model, NOT the DOM-style
+         * name.
+         *
+         * @param nodeHandle the id of the node.
+         * @return String Name of this node.
+         */
+        public String getNodeNameX(int nodeHandle) {return null;}
+
+        /**
+         * Given a node handle, return its DOM-style localname.
+         * (As defined in Namespaces, this is the portion of the name after any
+         * colon character)
+         *
+         * %REVIEW% What's the local name of something other than Element/Attr?
+         * Should this be DOM-style (undefined unless namespaced), or other?
+         *
+         * @param nodeHandle the id of the node.
+         * @return String Local name of this node.
+         */
+        public String getLocalName(int nodeHandle) {
+                nodes.readSlot(nodeHandle, gotslot);
+                short type = (short) (gotslot[0] & 0xFFFF);
+                String name = "";
+                if ((type==ELEMENT_NODE) || (type==ATTRIBUTE_NODE)) {
+                  int i=gotslot[3];
+                  name=m_localNames.indexToString(i & 0xFFFF);
+                  if(name==null) name="";
+                }
+                return name;
+        }
+
+        /**
+         * Given a namespace handle, return the prefix that the namespace decl is
+         * mapping.
+         * Given a node handle, return the prefix used to map to the namespace.
+         *
+         * <p> %REVIEW% Are you sure you want "" for no prefix?  </p>
+         *
+         * %REVIEW%  Should this be DOM-style (undefined unless namespaced),
+         * or other?
+         *
+         * @param nodeHandle the id of the node.
+         * @return String prefix of this node's name, or "" if no explicit
+         * namespace prefix was given.
+         */
+        public String getPrefix(int nodeHandle) {
+                nodes.readSlot(nodeHandle, gotslot);
+                short type = (short) (gotslot[0] & 0xFFFF);
+                String name = "";
+                if((type==ELEMENT_NODE) || (type==ATTRIBUTE_NODE)) {
+                  int i=gotslot[3];
+                  name=m_prefixNames.indexToString(i >>16);
+                  if(name==null) name="";
+                }
+                return name;
+        }
+
+        /**
+         * Given a node handle, return its DOM-style namespace URI
+         * (As defined in Namespaces, this is the declared URI which this node's
+         * prefix -- or default in lieu thereof -- was mapped to.)
+         *
+         * @param nodeHandle the id of the node.
+         * @return String URI value of this node's namespace, or null if no
+         * namespace was resolved.
+         */
+        public String getNamespaceURI(int nodeHandle) {return null;}
+
+        /**
+         * Given a node handle, return its node value. This is mostly
+         * as defined by the DOM, but may ignore some conveniences.
+         * <p>
+         *
+         * @param nodeHandle The node id.
+         * @return String Value of this node, or null if not
+         * meaningful for this node type.
+         */
+        public String getNodeValue(int nodeHandle)
+        {
+                nodes.readSlot(nodeHandle, gotslot);
+                int nodetype=gotslot[0] & 0xFF;		// ###zaj use mask to get node type
+                String value=null;
+
+                switch (nodetype) {			// ###zaj todo - document nodetypes
+                case ATTRIBUTE_NODE:
+                        nodes.readSlot(nodeHandle+1, gotslot);
+                case TEXT_NODE:   
+                case COMMENT_NODE:
+                case CDATA_SECTION_NODE: 
+                        value=m_char.getString(gotslot[2], gotslot[3]);		//###zaj
+                        break;
+                case PROCESSING_INSTRUCTION_NODE:
+                case ELEMENT_NODE:
+                case ENTITY_REFERENCE_NODE:
+                default:
+                        break;
+                }
+                return value; 
+        }
+
+        /**
+         * Given a node handle, return its DOM-style node type.
+         * <p>
+         * %REVIEW% Generally, returning short is false economy. Return int?
+         *
+         * @param nodeHandle The node id.
+         * @return int Node type, as per the DOM's Node._NODE constants.
+         */
+        public short getNodeType(int nodeHandle) {
+                return(short) (nodes.readEntry(nodeHandle, 0) & 0xFFFF);
+        }
+
+        /**
+         * <meta name="usage" content="internal"/>
+         * Get the depth level of this node in the tree (equals 1 for
+         * a parentless node).
+         *
+         * @param nodeHandle The node id.
+         * @return the number of ancestors, plus one
+         */
+        public short getLevel(int nodeHandle) {
+                short count = 0;
+                while (nodeHandle != 0) {
+                        count++;
+                        nodeHandle = nodes.readEntry(nodeHandle, 1);
+                }
+                return count;
+        }
+
+        // ============== Document query functions ==============
+
+        /**
+         * Tests whether DTM DOM implementation implements a specific feature and
+         * that feature is supported by this node.
+         *
+         * @param feature The name of the feature to test.
+         * @param versionThis is the version number of the feature to test.
+         *   If the version is not
+         *   specified, supporting any version of the feature will cause the
+         *   method to return <code>true</code>.
+         * @return Returns <code>true</code> if the specified feature is
+         *   supported on this node, <code>false</code> otherwise.
+         */
+        public boolean isSupported(String feature, String version) {return false;}
+
+        /**
+         * Return the base URI of the document entity. If it is not known
+         * (because the document was parsed from a socket connection or from
+         * standard input, for example), the value of this property is unknown.
+         *
+         * @return the document base URI String object or null if unknown.
+         */
+        public String getDocumentBaseURI()
+        {
+      
+          return m_documentBaseURI;
+        }
+        
+        /**
+         * Set the base URI of the document entity.
+         *
+         * @param baseURI the document base URI String object or null if unknown.
+         */
+        public void setDocumentBaseURI(String baseURI)
+        {
+      
+          m_documentBaseURI = baseURI;
+        }
+        
+        /**
+         * Return the system identifier of the document entity. If
+         * it is not known, the value of this property is unknown.
+         *
+         * @param nodeHandle The node id, which can be any valid node handle.
+         * @return the system identifier String object or null if unknown.
+         */
+        public String getDocumentSystemIdentifier(int nodeHandle) {return null;}
+
+        /**
+         * Return the name of the character encoding scheme
+         *        in which the document entity is expressed.
+         *
+         * @param nodeHandle The node id, which can be any valid node handle.
+         * @return the document encoding String object.
+         */
+        public String getDocumentEncoding(int nodeHandle) {return null;}
+
+        /**
+         * Return an indication of the standalone status of the document,
+         *        either "yes" or "no". This property is derived from the optional
+         *        standalone document declaration in the XML declaration at the
+         *        beginning of the document entity, and has no value if there is no
+         *        standalone document declaration.
+         *
+         * @param nodeHandle The node id, which can be any valid node handle.
+         * @return the document standalone String object, either "yes", "no", or null.
+         */
+        public String getDocumentStandalone(int nodeHandle) {return null;}
+
+        /**
+         * Return a string representing the XML version of the document. This
+         * property is derived from the XML declaration optionally present at the
+         * beginning of the document entity, and has no value if there is no XML
+         * declaration.
+         *
+         * @param the document handle
+         *
+         * @return the document version String object
+         */
+        public String getDocumentVersion(int documentHandle) {return null;}
+
+        /**
+         * Return an indication of
+         * whether the processor has read the complete DTD. Its value is a
+         * boolean. If it is false, then certain properties (indicated in their
+         * descriptions below) may be unknown. If it is true, those properties
+         * are never unknown.
+         *
+         * @return <code>true</code> if all declarations were processed {};
+         *         <code>false</code> otherwise.
+         */
+        public boolean getDocumentAllDeclarationsProcessed() {return false;}
+
+        /**
+         *   A document type declaration information item has the following properties:
+         *
+         *     1. [system identifier] The system identifier of the external subset, if
+         *        it exists. Otherwise this property has no value.
+         *
+         * @return the system identifier String object, or null if there is none.
+         */
+        public String getDocumentTypeDeclarationSystemIdentifier() {return null;}
+
+        /**
+         * Return the public identifier of the external subset,
+         * normalized as described in 4.2.2 External Entities [XML]. If there is
+         * no external subset or if it has no public identifier, this property
+         * has no value.
+         *
+         * @param the document type declaration handle
+         *
+         * @return the public identifier String object, or null if there is none.
+         */
+        public String getDocumentTypeDeclarationPublicIdentifier() {return null;}
+
+        /**
+         * Returns the <code>Element</code> whose <code>ID</code> is given by
+         * <code>elementId</code>. If no such element exists, returns
+         * <code>DTM.NULL</code>. Behavior is not defined if more than one element
+         * has this <code>ID</code>. Attributes (including those
+         * with the name "ID") are not of type ID unless so defined by DTD/Schema
+         * information available to the DTM implementation.
+         * Implementations that do not know whether attributes are of type ID or
+         * not are expected to return <code>DTM.NULL</code>.
+         *
+         * <p>%REVIEW% Presumably IDs are still scoped to a single document,
+         * and this operation searches only within a single document, right?
+         * Wouldn't want collisions between DTMs in the same process.</p>
+         *
+         * @param elementId The unique <code>id</code> value for an element.
+         * @return The handle of the matching element.
+         */
+        public int getElementById(String elementId) {return 0;}
+
+        /**
+         * The getUnparsedEntityURI function returns the URI of the unparsed
+         * entity with the specified name in the same document as the context
+         * node (see [3.3 Unparsed Entities]). It returns the empty string if
+         * there is no such entity.
+         * <p>
+         * XML processors may choose to use the System Identifier (if one
+         * is provided) to resolve the entity, rather than the URI in the
+         * Public Identifier. The details are dependent on the processor, and
+         * we would have to support some form of plug-in resolver to handle
+         * this properly. Currently, we simply return the System Identifier if
+         * present, and hope that it a usable URI or that our caller can
+         * map it to one.
+         * TODO: Resolve Public Identifiers... or consider changing function name.
+         * <p>
+         * If we find a relative URI
+         * reference, XML expects it to be resolved in terms of the base URI
+         * of the document. The DOM doesn't do that for us, and it isn't
+         * entirely clear whether that should be done here; currently that's
+         * pushed up to a higher level of our application. (Note that DOM Level
+         * 1 didn't store the document's base URI.)
+         * TODO: Consider resolving Relative URIs.
+         * <p>
+         * (The DOM's statement that "An XML processor may choose to
+         * completely expand entities before the structure model is passed
+         * to the DOM" refers only to parsed entities, not unparsed, and hence
+         * doesn't affect this function.)
+         *
+         * @param name A string containing the Entity Name of the unparsed
+         * entity.
+         *
+         * @return String containing the URI of the Unparsed Entity, or an
+         * empty string if no such entity exists.
+         */
+        public String getUnparsedEntityURI(String name) {return null;}
+
+
+        // ============== Boolean methods ================
+
+        /**
+         * Return true if the xsl:strip-space or xsl:preserve-space was processed
+         * during construction of the DTM document.
+         *
+         * <p>%REVEIW% Presumes a 1:1 mapping from DTM to Document, since
+         * we aren't saying which Document to query...?</p>
+         */
+        public boolean supportsPreStripping() {return false;}
+
+        /**
+         * Figure out whether nodeHandle2 should be considered as being later
+         * in the document than nodeHandle1, in Document Order as defined
+         * by the XPath model. This may not agree with the ordering defined
+         * by other XML applications.
+         * <p>
+         * There are some cases where ordering isn't defined, and neither are
+         * the results of this function -- though we'll generally return true.
+         *
+         * TODO: Make sure this does the right thing with attribute nodes!!!
+         *
+         * @param node1 DOM Node to perform position comparison on.
+         * @param node2 DOM Node to perform position comparison on .
+         *
+         * @return false if node2 comes before node1, otherwise return true.
+         * You can think of this as
+         * <code>(node1.documentOrderPosition &lt;= node2.documentOrderPosition)</code>.
+         */
+        public boolean isNodeAfter(int nodeHandle1, int nodeHandle2) {return false;}
+
+        /**
+         *     2. [element content whitespace] A boolean indicating whether the
+         *        character is white space appearing within element content (see [XML],
+         *        2.10 "White Space Handling"). Note that validating XML processors are
+         *        required by XML 1.0 to provide this information. If there is no
+         *        declaration for the containing element, this property has no value for
+         *        white space characters. If no declaration has been read, but the [all
+         *        declarations processed] property of the document information item is
+         *        false (so there may be an unread declaration), then the value of this
+         *        property is unknown for white space characters. It is always false for
+         *        characters that are not white space.
+         *
+         * @param nodeHandle the node ID.
+         * @return <code>true</code> if the character data is whitespace;
+         *         <code>false</code> otherwise.
+         */
+        public boolean isCharacterElementContentWhitespace(int nodeHandle) {return false;}
+
+        /**
+         *    10. [all declarations processed] This property is not strictly speaking
+         *        part of the infoset of the document. Rather it is an indication of
+         *        whether the processor has read the complete DTD. Its value is a
+         *        boolean. If it is false, then certain properties (indicated in their
+         *        descriptions below) may be unknown. If it is true, those properties
+         *        are never unknown.
+         *
+         * @param the document handle
+         *
+         * @param documentHandle A node handle that must identify a document.
+         * @return <code>true</code> if all declarations were processed;
+         *         <code>false</code> otherwise.
+         */
+        public boolean isDocumentAllDeclarationsProcessed(int documentHandle) {return false;}
+
+        /**
+         *     5. [specified] A flag indicating whether this attribute was actually
+         *        specified in the start-tag of its element, or was defaulted from the
+         *        DTD.
+         *
+         * @param the attribute handle
+         *
+         * NEEDSDOC @param attributeHandle
+         * @return <code>true</code> if the attribute was specified;
+         *         <code>false</code> if it was defaulted.
+         */
+        public boolean isAttributeSpecified(int attributeHandle) {return false;}
+
+        // ========== Direct SAX Dispatch, for optimization purposes ========
+
+        /**
+         * Directly call the
+         * characters method on the passed ContentHandler for the
+         * string-value of the given node (see http://www.w3.org/TR/xpath#data-model
+         * for the definition of a node's string-value). Multiple calls to the
+         * ContentHandler's characters methods may well occur for a single call to
+         * this method.
+         *
+         * @param nodeHandle The node ID.
+         * @param ch A non-null reference to a ContentHandler.
+         *
+         * @throws org.xml.sax.SAXException
+         */
+        public void dispatchCharactersEvents(
+                                                                                                                                                        int nodeHandle, org.xml.sax.ContentHandler ch)
+        throws org.xml.sax.SAXException {}
+
+        /**
+         * Directly create SAX parser events from a subtree.
+         *
+         * @param nodeHandle The node ID.
+         * @param ch A non-null reference to a ContentHandler.
+         *
+         * @throws org.xml.sax.SAXException
+         */
+
+        public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch)
+        throws org.xml.sax.SAXException {}
+        
+        /**
+         * Return an DOM node for the given node.
+         *
+         * @param nodeHandle The node ID.
+         *
+         * @return A node representation of the DTM node.
+         */
+        public org.w3c.dom.Node getNode(int nodeHandle)
+        {
+          return null;
+        }
+
+        // ==== Construction methods (may not be supported by some implementations!) =====
+        // %REVIEW% jjk: These probably aren't the right API. At the very least
+        // they need to deal with current-insertion-location and end-element
+        // issues.
+
+        /**
+         * Append a child to the end of the child list of the current node. Please note that the node
+         * is always cloned if it is owned by another document.
+         *
+         * <p>%REVIEW% "End of the document" needs to be defined more clearly.
+         * Does it become the last child of the Document? Of the root element?</p>
+         *
+         * @param newChild Must be a valid new node handle.
+         * @param clone true if the child should be cloned into the document.
+         * @param cloneDepth if the clone argument is true, specifies that the
+         *                   clone should include all it's children.
+         */
+        public void appendChild(int newChild, boolean clone, boolean cloneDepth) {
+                boolean sameDoc = ((newChild & DOCHANDLE_MASK) == m_docHandle);
+                if (clone || !sameDoc) {
+
+                } else {
+
+                }
+        }
+
+        /**
+         * Append a text node child that will be constructed from a string,
+         * to the end of the document.
+         *
+         * <p>%REVIEW% "End of the document" needs to be defined more clearly.
+         * Does it become the last child of the Document? Of the root element?</p>
+         *
+         * @param str Non-null reference to a string.
+         */
+        public void appendTextChild(String str) {
+                // ###shs Think more about how this differs from createTextNode
+          //%TBD%
+        }
+
+
+  //================================================================
+  // ==== BUILDER methods ====
+  // %TBD% jjk: SHOULD PROBABLY BE INLINED, unless we want to support
+  // both SAX1 and SAX2 and share this logic between them.
+
+  /** Append a text child at the current insertion point. Assumes that the
+   * actual content of the text has previously been appended to the m_char
+   * buffer (shared with the builder).
+   *
+   * @param m_char_current_start int Starting offset of node's content in m_char.
+   * @param contentLength int Length of node's content in m_char.
+   * */
+  void appendTextChild(int m_char_current_start,int contentLength)
+  {
+    // create a Text Node
+    // %TBD% may be possible to combine with appendNode()to replace the next chunk of code
+    int w0 = TEXT_NODE;
+    // W1: Parent
+    int w1 = currentParent;
+    // W2: Start position within m_char
+    int w2 = m_char_current_start;
+    // W3: Length of the full string
+    int w3 = contentLength;
+
+    int ourslot = appendNode(w0, w1, w2, w3);
+    previousSibling = ourslot;
+  }
+  
+  /** Append a comment child at the current insertion point. Assumes that the
+   * actual content of the comment has previously been appended to the m_char
+   * buffer (shared with the builder).
+   *
+   * @param m_char_current_start int Starting offset of node's content in m_char.
+   * @param contentLength int Length of node's content in m_char.
+   * */
+  void appendComment(int m_char_current_start,int contentLength)
+  {
+    // create a Comment Node
+    // %TBD% may be possible to combine with appendNode()to replace the next chunk of code
+    int w0 = COMMENT_NODE;
+    // W1: Parent
+    int w1 = currentParent;
+    // W2: Start position within m_char
+    int w2 = m_char_current_start;
+    // W3: Length of the full string
+    int w3 = contentLength;
+
+    int ourslot = appendNode(w0, w1, w2, w3);
+    previousSibling = ourslot;
+  }
+  
+  
+  /** Append an Element child at the current insertion point. This
+   * Element then _becomes_ the insertion point; subsequent appends
+   * become its lastChild until an appendEndElement() call is made.
+   * 
+   * Assumes that the symbols (local name, namespace URI and prefix)
+   * have already been added to the pools
+   *
+   * Note that this _only_ handles the Element node itself. Attrs and
+   * namespace nodes are unbundled in the ContentHandler layer
+   * and appended separately.
+   *
+   * @param namespaceIndex: Index within the namespaceURI string pool
+   * @param localNameIndex Index within the local name string pool
+   * @param prefixIndex: Index within the prefix string pool
+   * */
+  void appendStartElement(int namespaceIndex,int localNameIndex, int prefixIndex)
+  {
+                // do document root node creation here on the first element, create nodes for
+                // this element and its attributes, store the element, namespace, and attritute
+                // name indexes to the nodes array, keep track of the current node and parent
+                // element used
+
+                // W0  High:  Namespace  Low:  Node Type
+                int w0 = (namespaceIndex << 16) | ELEMENT_NODE;
+                // W1: Parent
+                int w1 = currentParent;
+                // W2: Next  (initialized as 0)
+                int w2 = 0;
+                // W3: Tagname high: prefix Low: local name
+                int w3 = localNameIndex | prefixIndex<<16;
+                /**/System.out.println("set w3="+w3+" "+(w3>>16)+"/"+(w3&0xffff));
+
+                //int ourslot = nodes.appendSlot(w0, w1, w2, w3);
+                int ourslot = appendNode(w0, w1, w2, w3);
+                currentParent = ourslot;
+                previousSibling = 0;
+
+                // set the root element pointer when creating the first element node
+                if (m_docElement == NULL)
+                        m_docElement = ourslot;
+  }
+  
+  /** Append a Namespace Declaration child at the current insertion point.
+   * Assumes that the symbols (namespace URI and prefix) have already been
+   * added to the pools
+   *
+   * @param prefixIndex: Index within the prefix string pool
+   * @param namespaceIndex: Index within the namespaceURI string pool
+   * @param isID: If someone really insists on writing a bad DTD, it is
+   * theoretically possible for a namespace declaration to also be declared
+   * as being a node ID. I don't really want to support that stupidity,
+   * but I'm not sure we can refuse to accept it.
+   * */
+  void appendNSDeclaration(int prefixIndex, int namespaceIndex,
+                           boolean isID)
+  {
+    // %REVIEW% I'm assigning this node the "namespace for namespaces"
+    // which the DOM defined. It is expected that the Namespace spec will
+    // adopt this as official. It isn't strictly needed since it's implied
+    // by the nodetype, but for now...
+
+    // %REVIEW% Prefix need not be recorded; it's implied too. But
+    // recording it might simplify the design.
+
+    // %TBD% isID is not currently honored.
+
+    final int namespaceForNamespaces=m_nsNames.stringToIndex("http://www.w3.org/2000/xmlns/");
+
+    // W0  High:  Namespace  Low:  Node Type
+    int w0 = NAMESPACE_NODE | (m_nsNames.stringToIndex("http://www.w3.org/2000/xmlns/")<<16);
+
+    // W1:  Parent
+    int w1 = currentParent;
+    // W2:  CURRENTLY UNUSED -- It's next-sib in attrs, but we have no kids.
+    int w2 = 0;
+    // W3:  namespace name
+    int w3 = namespaceIndex;
+    // Add node
+    int ourslot = appendNode(w0, w1, w2, w3);
+    previousSibling = ourslot;	// Should attributes be previous siblings
+    previousSiblingWasParent = false;
+    return ;//(m_docHandle | ourslot);
+  }
+
+  /** Append an Attribute child at the current insertion
+   * point.  Assumes that the symbols (namespace URI, local name, and
+   * prefix) have already been added to the pools, and that the content has
+   * already been appended to m_char. Note that the attribute's content has
+   * been flattened into a single string; DTM does _NOT_ attempt to model
+   * the details of entity references within attribute values.
+   *
+   * @param namespaceIndex int Index within the namespaceURI string pool
+   * @param localNameIndex int Index within the local name string pool
+   * @param prefixIndex int Index within the prefix string pool
+   * @param isID boolean True if this attribute was declared as an ID
+   * (for use in supporting getElementByID).
+   * @param m_char_current_start int Starting offset of node's content in m_char.
+   * @param contentLength int Length of node's content in m_char.
+   * */
+  void appendAttribute(int namespaceIndex, int localNameIndex, int prefixIndex,
+                       boolean isID,
+                       int m_char_current_start, int contentLength)
+  {
+    // %TBD% isID is not currently honored.
+
+    // W0  High:  Namespace  Low:  Node Type
+    int w0 = ATTRIBUTE_NODE | namespaceIndex<<16;
+
+    // W1:  Parent
+    int w1 = currentParent;
+    // W2:  Next (not yet resolved)
+    int w2 = 0;
+    // W3:  Tagname high: prefix Low: local name
+    int w3 = localNameIndex | prefixIndex<<16;
+    /**/System.out.println("set w3="+w3+" "+(w3>>16)+"/"+(w3&0xffff));
+    // Add node
+    int ourslot = appendNode(w0, w1, w2, w3);
+    previousSibling = ourslot;	// Should attributes be previous siblings
+    
+    // Attribute's content is currently appended as a Text Node
+
+    // W0: Node Type
+    w0 = TEXT_NODE;
+    // W1: Parent
+    w1 = ourslot;
+    // W2: Start Position within buffer
+    w2 = m_char_current_start;
+    // W3: Length
+    w3 = contentLength;
+    appendNode(w0, w1, w2, w3);
+
+    // Attrs are Parents
+    previousSiblingWasParent = true;
+    return ;//(m_docHandle | ourslot);
+  }
+  
+
+
+  /** Terminate the element currently acting as an insertion point. Subsequent
+   * insertions will occur as the last child of this element's parent.
+   * */
+  void appendEndElement()
+  {
+    // pop up the stacks
+    
+    if (previousSiblingWasParent)
+      nodes.writeEntry(previousSibling, 2, NULL);
+    
+    // Pop parentage 
+    previousSibling = currentParent;
+    nodes.readSlot(currentParent, gotslot);
+    currentParent = gotslot[1] & 0xFFFF;
+    
+    // The element just being finished will be
+    // the previous sibling for the next operation
+    previousSiblingWasParent = true;
+    
+    // Pop a level of namespace table
+    // namespaceTable.removeLastElem();
+  }
+  
+  /**  Starting a new document. Perform any resets/initialization
+   * not already handled.
+   * */
+  void appendStartDocument()
+  {
+    
+    // %TBD% reset slot 0 to indicate ChunkedIntArray reuse or wait for
+    //       the next initDocument().
+    m_docElement = NULL;	 // reset nodeHandle to the root of the actual dtm doc content
+    initDocument(0);
+  }
+
+  /**  All appends to this document have finished; do whatever final
+   * cleanup is needed.
+   * */
+  void appendEndDocument()
+  {
+    done = true;
+    // %TBD% may need to notice the last slot number and slot count to avoid
+    // residual data from provious use of this DTM
+  }
+
+}
diff --git a/src/org/apache/xml/dtm/DTMException.java b/src/org/apache/xml/dtm/DTMException.java
new file mode 100644
index 0000000..3e90ffd
--- /dev/null
+++ b/src/org/apache/xml/dtm/DTMException.java
@@ -0,0 +1,347 @@
+package org.apache.xml.dtm;
+
+
+import java.lang.reflect.Method;
+import java.lang.IllegalAccessException;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.xml.transform.SourceLocator;
+
+
+/**
+ * This class specifies an exceptional condition that occured
+ * in the DTM module.
+ */
+public class DTMException extends RuntimeException {
+
+    /** Field locator specifies where the error occured.
+     *  @serial */
+    SourceLocator locator;
+
+    /**
+     * Method getLocator retrieves an instance of a SourceLocator
+     * object that specifies where an error occured.
+     *
+     * @return A SourceLocator object, or null if none was specified.
+     */
+    public SourceLocator getLocator() {
+        return locator;
+    }
+
+    /**
+     * Method setLocator sets an instance of a SourceLocator
+     * object that specifies where an error occured.
+     *
+     * @param location A SourceLocator object, or null to clear the location.
+     */
+    public void setLocator(SourceLocator location) {
+        locator = location;
+    }
+
+    /** Field containedException specifies a wrapped exception.  May be null.
+     *  @serial */
+    Throwable containedException;
+
+    /**
+     * This method retrieves an exception that this exception wraps.
+     *
+     * @return An Throwable object, or null.
+     * @see #getCause
+     */
+    public Throwable getException() {
+        return containedException;
+    }
+
+    /**
+     * Returns the cause of this throwable or <code>null</code> if the
+     * cause is nonexistent or unknown.  (The cause is the throwable that
+     * caused this throwable to get thrown.)
+     */
+    public Throwable getCause() {
+
+        return ((containedException == this)
+                ? null
+                : containedException);
+    }
+
+    /**
+     * Initializes the <i>cause</i> of this throwable to the specified value.
+     * (The cause is the throwable that caused this throwable to get thrown.)
+     *
+     * <p>This method can be called at most once.  It is generally called from
+     * within the constructor, or immediately after creating the
+     * throwable.  If this throwable was created
+     * with {@link #DTMException(Throwable)} or
+     * {@link #DTMException(String,Throwable)}, this method cannot be called
+     * even once.
+     *
+     * @param  cause the cause (which is saved for later retrieval by the
+     *         {@link #getCause()} method).  (A <tt>null</tt> value is
+     *         permitted, and indicates that the cause is nonexistent or
+     *         unknown.)
+     * @return  a reference to this <code>Throwable</code> instance.
+     * @throws IllegalArgumentException if <code>cause</code> is this
+     *         throwable.  (A throwable cannot
+     *         be its own cause.)
+     * @throws IllegalStateException if this throwable was
+     *         created with {@link #DTMException(Throwable)} or
+     *         {@link #DTMException(String,Throwable)}, or this method has already
+     *         been called on this throwable.
+     */
+    public synchronized Throwable initCause(Throwable cause) {
+
+        if ((this.containedException == null) && (cause != null)) {
+            throw new IllegalStateException("Can't overwrite cause");
+        }
+
+        if (cause == this) {
+            throw new IllegalArgumentException(
+                "Self-causation not permitted");
+        }
+
+        this.containedException = cause;
+
+        return this;
+    }
+
+    /**
+     * Create a new DTMException.
+     *
+     * @param message The error or warning message.
+     */
+    public DTMException(String message) {
+
+        super(message);
+
+        this.containedException = null;
+        this.locator            = null;
+    }
+
+    /**
+     * Create a new DTMException wrapping an existing exception.
+     *
+     * @param e The exception to be wrapped.
+     */
+    public DTMException(Throwable e) {
+
+        super(e.getMessage());
+
+        this.containedException = e;
+        this.locator            = null;
+    }
+
+    /**
+     * Wrap an existing exception in a DTMException.
+     *
+     * <p>This is used for throwing processor exceptions before
+     * the processing has started.</p>
+     *
+     * @param message The error or warning message, or null to
+     *                use the message from the embedded exception.
+     * @param e Any exception
+     */
+    public DTMException(String message, Throwable e) {
+
+        super(((message == null) || (message.length() == 0))
+              ? e.getMessage()
+              : message);
+
+        this.containedException = e;
+        this.locator            = null;
+    }
+
+    /**
+     * Create a new DTMException from a message and a Locator.
+     *
+     * <p>This constructor is especially useful when an application is
+     * creating its own exception from within a DocumentHandler
+     * callback.</p>
+     *
+     * @param message The error or warning message.
+     * @param locator The locator object for the error or warning.
+     */
+    public DTMException(String message, SourceLocator locator) {
+
+        super(message);
+
+        this.containedException = null;
+        this.locator            = locator;
+    }
+
+    /**
+     * Wrap an existing exception in a DTMException.
+     *
+     * @param message The error or warning message, or null to
+     *                use the message from the embedded exception.
+     * @param locator The locator object for the error or warning.
+     * @param e Any exception
+     */
+    public DTMException(String message, SourceLocator locator,
+                                Throwable e) {
+
+        super(message);
+
+        this.containedException = e;
+        this.locator            = locator;
+    }
+
+    /**
+     * Get the error message with location information
+     * appended.
+     */
+    public String getMessageAndLocation() {
+
+        StringBuffer sbuffer = new StringBuffer();
+        String       message = super.getMessage();
+
+        if (null != message) {
+            sbuffer.append(message);
+        }
+
+        if (null != locator) {
+            String systemID = locator.getSystemId();
+            int    line     = locator.getLineNumber();
+            int    column   = locator.getColumnNumber();
+
+            if (null != systemID) {
+                sbuffer.append("; SystemID: ");
+                sbuffer.append(systemID);
+            }
+
+            if (0 != line) {
+                sbuffer.append("; Line#: ");
+                sbuffer.append(line);
+            }
+
+            if (0 != column) {
+                sbuffer.append("; Column#: ");
+                sbuffer.append(column);
+            }
+        }
+
+        return sbuffer.toString();
+    }
+
+    /**
+     * Get the location information as a string.
+     *
+     * @return A string with location info, or null
+     * if there is no location information.
+     */
+    public String getLocationAsString() {
+
+        if (null != locator) {
+            StringBuffer sbuffer  = new StringBuffer();
+            String       systemID = locator.getSystemId();
+            int          line     = locator.getLineNumber();
+            int          column   = locator.getColumnNumber();
+
+            if (null != systemID) {
+                sbuffer.append("; SystemID: ");
+                sbuffer.append(systemID);
+            }
+
+            if (0 != line) {
+                sbuffer.append("; Line#: ");
+                sbuffer.append(line);
+            }
+
+            if (0 != column) {
+                sbuffer.append("; Column#: ");
+                sbuffer.append(column);
+            }
+
+            return sbuffer.toString();
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Print the the trace of methods from where the error
+     * originated.  This will trace all nested exception
+     * objects, as well as this object.
+     */
+    public void printStackTrace() {
+        printStackTrace(new java.io.PrintWriter(System.err, true));
+    }
+
+    /**
+     * Print the the trace of methods from where the error
+     * originated.  This will trace all nested exception
+     * objects, as well as this object.
+     * @param s The stream where the dump will be sent to.
+     */
+    public void printStackTrace(java.io.PrintStream s) {
+        printStackTrace(new java.io.PrintWriter(s));
+    }
+
+    /**
+     * Print the the trace of methods from where the error
+     * originated.  This will trace all nested exception
+     * objects, as well as this object.
+     * @param s The writer where the dump will be sent to.
+     */
+    public void printStackTrace(java.io.PrintWriter s) {
+
+        if (s == null) {
+            s = new java.io.PrintWriter(System.err, true);
+        }
+
+        try {
+            String locInfo = getLocationAsString();
+
+            if (null != locInfo) {
+                s.println(locInfo);
+            }
+
+            super.printStackTrace(s);
+        } catch (Throwable e) {}
+
+        Throwable exception = getException();
+
+        for (int i = 0; (i < 10) && (null != exception); i++) {
+            s.println("---------");
+
+            try {
+                if (exception instanceof DTMException) {
+                    String locInfo =
+                        ((DTMException) exception)
+                            .getLocationAsString();
+
+                    if (null != locInfo) {
+                        s.println(locInfo);
+                    }
+                }
+
+                exception.printStackTrace(s);
+            } catch (Throwable e) {
+                s.println("Could not print stack trace...");
+            }
+
+            try {
+                Method meth =
+                    ((Object) exception).getClass().getMethod("getException",
+                        null);
+
+                if (null != meth) {
+                    Throwable prev = exception;
+
+                    exception = (Throwable) meth.invoke(exception, null);
+
+                    if (prev == exception) {
+                        break;
+                    }
+                } else {
+                    exception = null;
+                }
+            } catch (InvocationTargetException ite) {
+                exception = null;
+            } catch (IllegalAccessException iae) {
+                exception = null;
+            } catch (NoSuchMethodException nsme) {
+                exception = null;
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/org/apache/xml/dtm/DTMFilter.java b/src/org/apache/xml/dtm/DTMFilter.java
new file mode 100644
index 0000000..5efd4b8
--- /dev/null
+++ b/src/org/apache/xml/dtm/DTMFilter.java
@@ -0,0 +1,224 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xml.dtm;
+
+/**
+ * Simple filter for doing node tests.  Note the semantics of this are
+ * somewhat different that the DOM's NodeFilter.
+ */
+public interface DTMFilter
+{
+
+  // Constants for whatToShow.  These are used to set the node type that will 
+  // be traversed. These values may be ORed together before being passed to
+  // the DTMIterator.
+
+  /**
+   * Show all <code>Nodes</code>.
+   */
+  public static final int SHOW_ALL = 0xFFFFFFFF;
+
+  /**
+   * Show <code>Element</code> nodes.
+   */
+  public static final int SHOW_ELEMENT = 0x00000001;
+
+  /**
+   * Show <code>Attr</code> nodes. This is meaningful only when creating an
+   * iterator or tree-walker with an attribute node as its
+   * <code>root</code>; in this case, it means that the attribute node
+   * will appear in the first position of the iteration or traversal.
+   * Since attributes are never children of other nodes, they do not
+   * appear when traversing over the main document tree.
+   */
+  public static final int SHOW_ATTRIBUTE = 0x00000002;
+
+  /**
+   * Show <code>Text</code> nodes.
+   */
+  public static final int SHOW_TEXT = 0x00000004;
+
+  /**
+   * Show <code>CDATASection</code> nodes.
+   */
+  public static final int SHOW_CDATA_SECTION = 0x00000008;
+
+  /**
+   * Show <code>EntityReference</code> nodes. Note that if Entity References
+   * have been fully expanded while the tree was being constructed, these
+   * nodes will not appear and this mask has no effect.
+   */
+  public static final int SHOW_ENTITY_REFERENCE = 0x00000010;
+
+  /**
+   * Show <code>Entity</code> nodes. This is meaningful only when creating
+   * an iterator or tree-walker with an<code> Entity</code> node as its
+   * <code>root</code>; in this case, it means that the <code>Entity</code>
+   *  node will appear in the first position of the traversal. Since
+   * entities are not part of the document tree, they do not appear when
+   * traversing over the main document tree.
+   */
+  public static final int SHOW_ENTITY = 0x00000020;
+
+  /**
+   * Show <code>ProcessingInstruction</code> nodes.
+   */
+  public static final int SHOW_PROCESSING_INSTRUCTION = 0x00000040;
+
+  /**
+   * Show <code>Comment</code> nodes.
+   */
+  public static final int SHOW_COMMENT = 0x00000080;
+
+  /**
+   * Show <code>Document</code> nodes. (Of course, as with Attributes
+   * and such, this is meaningful only when the iteration root is the
+   * Document itself, since Document has no parent.)
+   */
+  public static final int SHOW_DOCUMENT = 0x00000100;
+
+  /**
+   * Show <code>DocumentType</code> nodes. 
+   */
+  public static final int SHOW_DOCUMENT_TYPE = 0x00000200;
+
+  /**
+   * Show <code>DocumentFragment</code> nodes. (Of course, as with
+   * Attributes and such, this is meaningful only when the iteration
+   * root is the Document itself, since DocumentFragment has no parent.)
+   */
+  public static final int SHOW_DOCUMENT_FRAGMENT = 0x00000400;
+
+  /**
+   * Show <code>Notation</code> nodes. This is meaningful only when creating
+   * an iterator or tree-walker with a <code>Notation</code> node as its
+   * <code>root</code>; in this case, it means that the
+   * <code>Notation</code> node will appear in the first position of the
+   * traversal. Since notations are not part of the document tree, they do
+   * not appear when traversing over the main document tree.
+   */
+  public static final int SHOW_NOTATION = 0x00000800;
+  
+  /**
+
+   * This bit instructs the iterator to show namespace nodes, which
+   * are modeled by DTM but not by the DOM.  Make sure this does not
+   * conflict with {@link org.w3c.dom.traversal.NodeFilter}.
+   * <p>
+   * %REVIEW% Might be safer to start from higher bits and work down,
+   * to leave room for the DOM to expand its set of constants... Or,
+   * possibly, to create a DTM-specific field for these additional bits.
+   */
+  public static final int SHOW_NAMESPACE = 0x00001000;
+
+  /**
+   * Special bit for filters implementing match patterns starting with
+   * a function.  Make sure this does not conflict with
+   * {@link org.w3c.dom.traversal.NodeFilter}.
+   * <p>
+   * %REVIEW% Might be safer to start from higher bits and work down,
+   * to leave room for the DOM to expand its set of constants... Or,
+   * possibly, to create a DTM-specific field for these additional bits.
+   */
+  public static final int SHOW_BYFUNCTION = 0x00010000;
+
+  /**
+   * Test whether a specified node is visible in the logical view of a
+   * <code>DTMIterator</code>. Normally, this function
+   * will be called by the implementation of <code>DTMIterator</code>; 
+   * it is not normally called directly from
+   * user code.
+   * 
+   * @param nodeHandle int Handle of the node.
+   * @param whatToShow one of SHOW_XXX values.
+   * @return one of FILTER_ACCEPT, FILTER_REJECT, or FILTER_SKIP.
+   */
+  public short acceptNode(int nodeHandle, int whatToShow);
+  
+  /**
+   * Test whether a specified node is visible in the logical view of a
+   * <code>DTMIterator</code>. Normally, this function
+   * will be called by the implementation of <code>DTMIterator</code>; 
+   * it is not normally called directly from
+   * user code.
+   * <p>
+   * TODO: Should this be setNameMatch(expandedName) followed by accept()?
+   * Or will we really be testing a different name at every invocation?
+   * 
+   * <p>%REVIEW% Under what circumstances will this be used? The cases
+   * I've considered are just as easy and just about as efficient if
+   * the name test is performed in the DTMIterator... -- Joe</p>
+   * 
+   * <p>%REVIEW% Should that 0xFFFF have a mnemonic assigned to it?
+   * Also: This representation is assuming the expanded name is indeed
+   * split into high/low 16-bit halfwords. If we ever change the
+   * balance between namespace and localname bits (eg because we
+   * decide there are many more localnames than namespaces, which is
+   * fairly likely), this is going to break. It might be safer to
+   * encapsulate the details with a makeExpandedName method and make
+   * that responsible for setting up the wildcard version as well.</p>
+   * 
+   * @param nodeHandle int Handle of the node.
+   * @param whatToShow one of SHOW_XXX values.
+   * @param expandedName a value defining the exanded name as defined in 
+   *                     the DTM interface.  Wild cards will be defined 
+   *                     by 0xFFFF in the namespace and/or localname
+   *			 portion of the expandedName.
+   * @return one of FILTER_ACCEPT, FILTER_REJECT, or FILTER_SKIP.  */
+  public short acceptNode(int nodeHandle, int whatToShow, int expandedName);
+ 
+}
diff --git a/src/org/apache/xml/utils/DTMIterator.java b/src/org/apache/xml/dtm/DTMIterator.java
similarity index 62%
rename from src/org/apache/xml/utils/DTMIterator.java
rename to src/org/apache/xml/dtm/DTMIterator.java
index b9ed43d..a12a4c0 100644
--- a/src/org/apache/xml/utils/DTMIterator.java
+++ b/src/org/apache/xml/dtm/DTMIterator.java
@@ -54,11 +54,13 @@
  * information on the Apache Software Foundation, please see
  * <http://www.apache.org/>.
  */
-package org.apache.xml.utils;
+package org.apache.xml.dtm;
 
 /**
- * <code>Iterators</code> are used to step through a set of nodes.  
- * It is modeled largely after the DOM NodeIterator.
+
+ * <code>DTMIterators</code> are used to step through a (possibly
+ * filtered) set of nodes.  Their API is modeled largely after the DOM
+ * NodeIterator.
  * 
  * <p>A DTMIterator is a somewhat unusual type of iterator, in that it 
  * can serve both single node iteration and random access.</p>
@@ -71,12 +73,21 @@
  * <p>A DTMIterator is meant to be created once as a master static object, and 
  * then cloned many times for runtime use.  Or the master object itself may 
  * be used for simpler use cases.</p>
- * <p>State: In progress!!</p>
- */
+ *
+ * <p>At this time, we do not expect DTMIterator to emulate
+ * NodeIterator's "maintain relative position" semantics under
+ * document mutation.  It's likely to respond more like the
+ * TreeWalker's "current node" semantics. However, since the base DTM
+ * is immutable, this issue currently makes no practical
+ * difference.</p>
+ *
+ * <p>State: In progress!!</p> */
 public interface DTMIterator
 {
 
-  // Constants returned by acceptNode
+  // Constants returned by acceptNode, borrowed from the DOM Traversal chapter
+  // %REVIEW% Should we explicitly initialize them from, eg,
+  // org.w3c.dom.traversal.NodeFilter.FILTER_ACCEPT?
 
   /**
    * Accept the node.
@@ -84,7 +95,9 @@
   public static final short FILTER_ACCEPT = 1;
 
   /**
-   * Reject the node. (same as FILTER_SKIP).
+   * Reject the node. Same behavior as FILTER_SKIP. (In the DOM these
+   * differ when applied to a TreeWalker but have the same result when
+   * applied to a NodeIterator).
    */
   public static final short FILTER_REJECT = 2;
 
@@ -95,11 +108,13 @@
   
   /**
    * Set the environment in which this iterator operates, which should provide:
-   * a node (the context node... same value as "root" defined below) 
-   * a pair of non-zero positive integers (the context position and the context size) 
-   * a set of variable bindings 
-   * a function library 
-   * the set of namespace declarations in scope for the expression.
+   * <ul>
+   * <li>a node (the context node... same value as "root" defined below) </li>
+   * <li>a pair of non-zero positive integers (the context position and the context size) </li>
+   * <li>a set of variable bindings </li>
+   * <li>a function library </li>
+   * <li>the set of namespace declarations in scope for the expression.</li>
+   * <ul>
    * 
    * <p>At this time the exact implementation of this environment is application 
    * dependent.  Probably a proper interface will be created fairly soon.</p>
@@ -107,29 +122,51 @@
    * @param environment The environment object.
    */
   public void setEnvironment(Object environment);
+  
+  /**
+   * Get an instance of a DTM that "owns" a node handle.  Since a node 
+   * iterator may be passed without a DTMManager, this allows the 
+   * caller to easily get the DTM using just the iterator.
+   *
+   * @param nodeHandle the nodeHandle.
+   *
+   * @return a non-null DTM reference.
+   */
+  public DTM getDTM(int nodeHandle);
+  
+  /**
+   * Get an instance of the DTMManager.  Since a node 
+   * iterator may be passed without a DTMManager, this allows the 
+   * caller to easily get the DTMManager using just the iterator.
+   *
+   * @return a non-null DTMManager reference.
+   */
+  public DTMManager getDTMManager();
 
   /**
    * The root node of the <code>DTMIterator</code>, as specified when it
    * was created.  Note the root node is not the root node of the 
-   * document tree, but the context node from where the itteration 
-   * begins.
+   * document tree, but the context node from where the iteration 
+   * begins and ends.
    *
    * @return nodeHandle int Handle of the context node.
    */
   public int getRoot();
 
   /**
-   * The root node of the <code>DTMIterator</code>, as specified when it
-   * was created.  Note the root node is not the root node of the 
-   * document tree, but the context node from where the itteration 
-   * begins.
+   * Reset the root node of the <code>DTMIterator</code>, overriding
+   * the value specified when it was created.  Note the root node is
+   * not the root node of the document tree, but the context node from
+   * where the iteration begins.
    *
    * @param nodeHandle int Handle of the context node.
    */
   public void setRoot(int nodeHandle);
   
   /**
-   * Reset the iterator to the start.
+   * Reset the iterator to the start. After resetting, the next node returned
+   * will be the root node -- or, if that's filtered out, the first node
+   * within the root's subtree which is _not_ skipped by the filters.
    */
   public void reset();
 
@@ -140,34 +177,38 @@
    * <code>whatToShow</code> will be skipped, but their children may still
    * be considered.
    *
-   * @return one of the SHOW_XXX constants.
+   * @return one of the SHOW_XXX constants, or several ORed together.
    */
   public int getWhatToShow();
 
   /**
-   *  The value of this flag determines whether the children of entity
+   * <p>The value of this flag determines whether the children of entity
    * reference nodes are visible to the iterator. If false, they  and
    * their descendants will be rejected. Note that this rejection takes
-   * precedence over <code>whatToShow</code> and the filter. 
-   * <br>
-   * <br> To produce a view of the document that has entity references
+   * precedence over <code>whatToShow</code> and the filter. </p>
+   * 
+   * <p> To produce a view of the document that has entity references
    * expanded and does not expose the entity reference node itself, use
    * the <code>whatToShow</code> flags to hide the entity reference node
    * and set <code>expandEntityReferences</code> to true when creating the
    * iterator. To produce a view of the document that has entity reference
    * nodes but no entity expansion, use the <code>whatToShow</code> flags
    * to show the entity reference node and set
-   * <code>expandEntityReferences</code> to false.
+   * <code>expandEntityReferences</code> to false.</p>
    *
-   * @return true if entity references will be expanded.
-   */
+   * <p>NOTE: In Xalan's use of DTM we will generally have fully expanded
+   * entity references when the document tree was built, and thus this
+   * flag will have no effect.</p>
+   *
+   * @return true if entity references will be expanded.  */
   public boolean getExpandEntityReferences();
 
   /**
    * Returns the next node in the set and advances the position of the
    * iterator in the set. After a <code>DTMIterator</code> has setRoot called,
-   * the first call to <code>nextNode()</code> returns the first node in
-   * the set.
+   * the first call to <code>nextNode()</code> returns that root or (if it
+   * is rejected by the filters) the first node within its subtree which is
+   * not filtered out.
    * @return The next node handle in the set being iterated over, or
    *   -1 if there are no more members in that set.
    */
@@ -187,11 +228,20 @@
    * in the INVALID state. After <code>detach</code> has been invoked,
    * calls to <code>nextNode</code> or <code>previousNode</code> will
    * raise a runtime exception.
+   *
+   * %REVIEW% This method may not be required in DTMIterator.
+   * It was needed in DOMIterator because data linkages were
+   * established to support the "maintain relative position" semantic
+   * under document mutation...  but if DTM doesn't need
+   * that semantic, we probably don't need to worry about this
+   * cleanup. On the other hand, at worst it's a harmless no-op...
    */
   public void detach();
 
   /**
-   * Get the current node in the iterator.</a>.
+   * Get the current node in the iterator. Note that this differs from
+   * the DOM's NodeIterator, where the current position lies between two
+   * nodes (as part of the maintain-relative-position semantic).
    *
    * @return The current node handle, or -1.
    */
@@ -213,17 +263,27 @@
    * be cached, enabling random access, and giving the ability to do 
    * sorts and the like.  They are not cached by default.
    *
+   * %REVIEW% Shouldn't the other random-access methods throw an exception
+   * if they're called on a DTMIterator with this flag set false?
+   *
    * @param b true if the nodes should be cached.
    */
   public void setShouldCacheNodes(boolean b);
-
+  
   /**
-   * Get the current position, which is one less than
-   * the next nextNode() call will retrieve.  i.e. if
-   * you call getCurrentPos() and the return is 0, the next
-   * fetch will take place at index 1.
+   * Tells if this iterator can have nodes added to it or set via 
+   * the <code>setItem(int node, int index)</code> method.
+   * 
+   * @return True if the nodelist can be mutated.
+   */
+  public boolean isMutable();
+
+  /** Get the current position within the cached list, which is one
+   * less than the next nextNode() call will retrieve.  i.e. if you
+   * call getCurrentPos() and the return is 0, the next fetch will
+   * take place at index 1.
    *
-   * @return The position of the iteration.</a>.
+   * @return The position of the iteration.
    */
   public int getCurrentPos();
 
@@ -231,7 +291,8 @@
    * If an index is requested, NodeSet will call this method
    * to run the iterator to the index.  By default this sets
    * m_next to the index.  If the index argument is -1, this
-   * signals that the iterator should be run to the end.
+   * signals that the iterator should be run to the end and
+   * completely fill the cache.
    *
    * @param index The index to run to, or -1 if the iterator should be run
    *              to the end.
@@ -258,13 +319,29 @@
   public int item(int index);
   
   /**
+   * Sets the node at the specified index of this vector to be the
+   * specified node. The previous component at that position is discarded.
+   *
+   * <p>The index must be a value greater than or equal to 0 and less
+   * than the current size of the vector.  
+   * The iterator must be in cached mode.</p>
+   * 
+   * <p>Meant to be used for sorted iterators.</p>
+   *
+   * @param node Node to set
+   * @param index Index of where to set the node
+   */
+  public void setItem(int node, int index);
+  
+  /**
    * The number of nodes in the list. The range of valid child node indices
-   * is 0 to <code>length-1</code> inclusive.
+   * is 0 to <code>length-1</code> inclusive. Note that this requires running
+   * the iterator to completion, and presumably filling the cache.
    *
    * @return The number of nodes in the list.
    */
   public int getLength();
-  
+    
   //=========== Cloning operations. ============
   
   /**
diff --git a/src/org/apache/xml/dtm/DTMManager.java b/src/org/apache/xml/dtm/DTMManager.java
new file mode 100644
index 0000000..4fb156b
--- /dev/null
+++ b/src/org/apache/xml/dtm/DTMManager.java
@@ -0,0 +1,537 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xml.dtm;
+
+import java.io.IOException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.BufferedReader;
+
+import java.util.Properties;
+import java.util.Enumeration;
+
+import org.apache.xml.utils.PrefixResolver;
+import org.apache.xml.utils.XMLString;
+import org.apache.xml.utils.XMLStringFactory;
+
+/**
+ * A DTMManager instance can be used to create DTM and
+ * DTMIterator objects, and manage the DTM objects in the system.
+ *
+ * <p>The system property that determines which Factory implementation
+ * to create is named "org.apache.xml.utils.DTMFactory". This
+ * property names a concrete subclass of the DTMFactory abstract
+ *  class. If the property is not defined, a platform default is be used.</p>
+ *
+ * <p>An instance of this class <emph>must</emph> be safe to use across
+ * thread instances.  It is expected that a client will create a single instance
+ * of a DTMManager to use across multiple threads.  This will allow sharing
+ * of DTMs across multiple processes.</p>
+ *
+ * <p>Note: this class is incomplete right now.  It will be pretty much
+ * modeled after javax.xml.transform.TransformerFactory in terms of its
+ * factory support.</p>
+ *
+ * <p>State: In progress!!</p>
+ */
+public abstract class DTMManager
+{
+
+  /** The default property name according to the JAXP spec. */
+  private static final String defaultPropName =
+    "org.apache.xml.dtm.DTMManager";
+
+  /**
+   * The default table for exandedNameID lookups.
+   */
+  private static ExpandedNameTable m_expandedNameTable =
+    new ExpandedNameTable();
+
+  /**
+   * Factory for creating XMLString objects.
+   *  %TBD% Make this set by the caller.
+   */
+  protected XMLStringFactory m_xsf = null;
+
+  /**
+   * Default constructor is protected on purpose.
+   */
+  protected DTMManager(){}
+
+  /**
+   * Get the XMLStringFactory used for the DTMs.
+   *
+   *
+   * @return a valid XMLStringFactory object, or null if it hasn't been set yet.
+   */
+  public XMLStringFactory getXMLStringFactory()
+  {
+    return m_xsf;
+  }
+
+  /**
+   * Set the XMLStringFactory used for the DTMs.
+   *
+   *
+   * @param xsf a valid XMLStringFactory object, should not be null.
+   */
+  public void setXMLStringFactory(XMLStringFactory xsf)
+  {
+    m_xsf = xsf;
+  }
+
+  /**
+   * Obtain a new instance of a <code>DTMManager</code>.
+   * This static method creates a new factory instance
+   * This method uses the following ordered lookup procedure to determine
+   * the <code>DTMManager</code> implementation class to
+   * load:
+   * <ul>
+   * <li>
+   * Use the <code>javax.xml.parsers.DocumentBuilderFactory</code> system
+   * property.
+   * </li>
+   * <li>
+   * Use the JAVA_HOME(the parent directory where jdk is
+   * installed)/lib/jaxp.properties for a property file that contains the
+   * name of the implementation class keyed on the same value as the
+   * system property defined above.
+   * </li>
+   * <li>
+   * Use the Services API (as detailed in teh JAR specification), if
+   * available, to determine the classname. The Services API will look
+   * for a classname in the file
+   * <code>META-INF/services/javax.xml.parsers.DTMManager</code>
+   * in jars available to the runtime.
+   * </li>
+   * <li>
+   * Platform default <code>DTMManager</code> instance.
+   * </li>
+   * </ul>
+   *
+   * Once an application has obtained a reference to a <code>
+   * DTMManager</code> it can use the factory to configure
+   * and obtain parser instances.
+   *
+   * @return new DTMManager instance, never null.
+   *
+   * @throws DTMConfigurationException
+   * if the implmentation is not available or cannot be instantiated.
+   */
+  public static DTMManager newInstance(XMLStringFactory xsf) 
+           throws DTMConfigurationException
+  {
+
+    String classname = findFactory(defaultPropName,
+                                   "org.apache.xml.dtm.DTMManagerDefault");
+
+    if (classname == null)
+    {
+      throw new DTMConfigurationException("No default implementation found");
+    }
+
+    DTMManager factoryImpl;
+
+    try
+    {
+      Class clazz = Class.forName(classname);
+
+      factoryImpl = (DTMManager) clazz.newInstance();
+    }
+    catch (ClassNotFoundException cnfe)
+    {
+      throw new DTMConfigurationException(cnfe);
+    }
+    catch (IllegalAccessException iae)
+    {
+      throw new DTMConfigurationException(iae);
+    }
+    catch (InstantiationException ie)
+    {
+      throw new DTMConfigurationException(ie);
+    }
+    factoryImpl.setXMLStringFactory(xsf);
+
+    return factoryImpl;
+  }
+
+  /**
+   * Get an instance of a DTM, loaded with the content from the
+   * specified source.  If the unique flag is true, a new instance will
+   * always be returned.  Otherwise it is up to the DTMManager to return a
+   * new instance or an instance that it already created and may be being used
+   * by someone else.
+   * (I think more parameters will need to be added for error handling, and entity
+   * resolution).
+   *
+   * @param source the specification of the source object, which may be null,
+   *               in which case it is assumed that node construction will take
+   *               by some other means.
+   * @param unique true if the returned DTM must be unique, probably because it
+   * is going to be mutated.
+   * @param whiteSpaceFilter Enables filtering of whitespace nodes, and may
+   *                         be null.
+   * @param incremental true if the DTM should be built incrementally, if
+   *                    possible.
+   *
+   * @return a non-null DTM reference.
+   */
+  public abstract DTM getDTM(javax.xml.transform.Source source,
+                             boolean unique, DTMWSFilter whiteSpaceFilter,
+                             boolean incremental);
+
+  /**
+   * Get the instance of DTM that "owns" a node handle.
+   *
+   * @param nodeHandle the nodeHandle.
+   *
+   * @return a non-null DTM reference.
+   */
+  public abstract DTM getDTM(int nodeHandle);
+
+  /**
+   * Given a W3C DOM node, try and return a DTM handle.
+   * Note: calling this may be non-optimal.
+   *
+   * @param node Non-null reference to a DOM node.
+   *
+   * @return a valid DTM handle.
+   */
+  public abstract int getDTMHandleFromNode(org.w3c.dom.Node node);
+
+  /**
+   * Creates a DTM representing an empty <code>DocumentFragment</code> object.
+   * @return a non-null DTM reference.
+   */
+  public abstract DTM createDocumentFragment();
+
+  /**
+   * Release a DTM either to a lru pool, or completely remove reference.
+   * DTMs without system IDs are always hard deleted.
+   * State: experimental.
+   *
+   * @param dtm The DTM to be released.
+   * @param shouldHardDelete True if the DTM should be removed no matter what.
+   * @return true if the DTM was removed, false if it was put back in a lru pool.
+   */
+  public abstract boolean release(DTM dtm, boolean shouldHardDelete);
+
+  /**
+   * Create a new <code>DTMIterator</code> based on an XPath
+   * <a href="http://www.w3.org/TR/xpath#NT-LocationPath>LocationPath</a> or
+   * a <a href="http://www.w3.org/TR/xpath#NT-UnionExpr">UnionExpr</a>.
+   *
+   * @param xpathCompiler ??? Somehow we need to pass in a subpart of the
+   * expression.  I hate to do this with strings, since the larger expression
+   * has already been parsed.
+   *
+   * @param pos The position in the expression.
+   * @return The newly created <code>DTMIterator</code>.
+   */
+  public abstract DTMIterator createDTMIterator(Object xpathCompiler,
+          int pos);
+
+  /**
+   * Create a new <code>DTMIterator</code> based on an XPath
+   * <a href="http://www.w3.org/TR/xpath#NT-LocationPath>LocationPath</a> or
+   * a <a href="http://www.w3.org/TR/xpath#NT-UnionExpr">UnionExpr</a>.
+   *
+   * @param xpathString Must be a valid string expressing a
+   * <a href="http://www.w3.org/TR/xpath#NT-LocationPath>LocationPath</a> or
+   * a <a href="http://www.w3.org/TR/xpath#NT-UnionExpr">UnionExpr</a>.
+   *
+   * @param presolver An object that can resolve prefixes to namespace URLs.
+   *
+   * @return The newly created <code>DTMIterator</code>.
+   */
+  public abstract DTMIterator createDTMIterator(String xpathString,
+          PrefixResolver presolver);
+
+  /**
+   * Create a new <code>DTMIterator</code> based only on a whatToShow
+   * and a DTMFilter.  The traversal semantics are defined as the
+   * descendant access.
+   * <p>
+   * Note that DTMIterators may not be an exact match to DOM
+   * NodeIterators. They are initialized and used in much the same way
+   * as a NodeIterator, but their response to document mutation is not
+   * currently defined.
+   *
+   * @param whatToShow This flag specifies which node types may appear in
+   *   the logical view of the tree presented by the iterator. See the
+   *   description of <code>NodeFilter</code> for the set of possible
+   *   <code>SHOW_</code> values.These flags can be combined using
+   *   <code>OR</code>.
+   * @param filter The <code>NodeFilter</code> to be used with this
+   *   <code>DTMFilter</code>, or <code>null</code> to indicate no filter.
+   * @param entityReferenceExpansion The value of this flag determines
+   *   whether entity reference nodes are expanded.
+   *
+   * @return The newly created <code>DTMIterator</code>.
+   */
+  public abstract DTMIterator createDTMIterator(int whatToShow,
+          DTMFilter filter, boolean entityReferenceExpansion);
+
+  /**
+   * Create a new <code>DTMIterator</code> that holds exactly one node.
+   *
+   * @param node The node handle that the DTMIterator will iterate to.
+   *
+   * @return The newly created <code>DTMIterator</code>.
+   */
+  public abstract DTMIterator createDTMIterator(int node);
+
+  // -------------------- private methods --------------------
+
+  /**
+   * Avoid reading all the files when the findFactory
+   * method is called the second time (cache the result of
+   * finding the default impl).
+   */
+  private static String foundFactory = null;
+
+  /**
+   * Temp debug code - this will be removed after we test everything
+   */
+  private static boolean debug;
+
+  static
+  {
+    try
+    {
+      debug = System.getProperty("dtm.debug") != null;
+    }
+    catch (SecurityException ex){}
+  }
+
+  /**
+   * Private implementation method - will find the implementation
+   * class in the specified order.
+   *
+   * @param factoryId   Name of the factory interface.
+   * @param xmlProperties Name of the properties file based on JAVA/lib.
+   * @param defaultFactory Default implementation, if nothing else is found.
+   *
+   * @return The factory class name.
+   */
+  private static String findFactory(String factoryId, String defaultFactory)
+  {
+
+    // Use the system property first
+    try
+    {
+      String systemProp = null;
+
+      try
+      {
+        systemProp = System.getProperty(factoryId);
+      }
+      catch (SecurityException se){}
+
+      if (systemProp != null)
+      {
+        if (debug)
+        {
+          System.err.println("DTM: found system property" + systemProp);
+        }
+
+        return systemProp;
+      }
+    }
+    catch (SecurityException se){}
+
+    if (foundFactory != null)
+    {
+      return foundFactory;
+    }
+
+    // try to read from $java.home/lib/jaxp.properties
+    try
+    {
+      String javah = System.getProperty("java.home");
+      String configFile = javah + File.separator + "lib" + File.separator
+                          + "jaxp.properties";
+      File f = new File(configFile);
+
+      if (f.exists())
+      {
+        Properties props = new Properties();
+
+        props.load(new FileInputStream(f));
+
+        foundFactory = props.getProperty(factoryId);
+
+        if (debug)
+        {
+          System.err.println("DTM: found java.home property " + foundFactory);
+        }
+
+        if (foundFactory != null)
+        {
+          return foundFactory;
+        }
+      }
+    }
+    catch (Exception ex)
+    {
+      if (debug)
+      {
+        ex.printStackTrace();
+      }
+    }
+
+    String serviceId = "META-INF/services/" + factoryId;
+
+    // try to find services in CLASSPATH
+    try
+    {
+      ClassLoader cl = DTMManager.class.getClassLoader();
+      InputStream is = null;
+
+      if (cl == null)
+      {
+        is = ClassLoader.getSystemResourceAsStream(serviceId);
+      }
+      else
+      {
+        is = cl.getResourceAsStream(serviceId);
+      }
+
+      if (is != null)
+      {
+        if (debug)
+        {
+          System.err.println("DTM: found  " + serviceId);
+        }
+
+        BufferedReader rd = new BufferedReader(new InputStreamReader(is));
+
+        foundFactory = rd.readLine();
+
+        rd.close();
+
+        if (debug)
+        {
+          System.err.println("DTM: loaded from services: " + foundFactory);
+        }
+
+        if ((foundFactory != null) &&!"".equals(foundFactory))
+        {
+          return foundFactory;
+        }
+      }
+    }
+    catch (Exception ex)
+    {
+      if (debug)
+      {
+        ex.printStackTrace();
+      }
+    }
+
+    return defaultFactory;
+  }
+
+  /** %TBD% Doc */
+  static final int IDENT_DTM_DEFAULT = 0xFFF00000;
+
+  /** %TBD% Doc */
+  static final int IDENT_NODE_DEFAULT = 0x000FFFFF;
+
+  /**
+   * %TBD% Doc
+   *
+   * NEEDSDOC @param dtm
+   *
+   * NEEDSDOC ($objectName$) @return
+   */
+  public abstract int getDTMIdentity(DTM dtm);
+
+  /**
+   * %TBD% Doc
+   *
+   * NEEDSDOC ($objectName$) @return
+   */
+  public int getDTMIdentityMask()
+  {
+    return IDENT_DTM_DEFAULT;
+  }
+
+  /**
+   * %TBD% Doc
+   *
+   * NEEDSDOC ($objectName$) @return
+   */
+  public int getNodeIdentityMask()
+  {
+    return IDENT_NODE_DEFAULT;
+  }
+
+  /**
+   * return the expanded name table.
+   *
+   * NEEDSDOC @param dtm
+   *
+   * NEEDSDOC ($objectName$) @return
+   */
+  public ExpandedNameTable getExpandedNameTable(DTM dtm)
+  {
+    return m_expandedNameTable;
+  }
+}
diff --git a/src/org/apache/xml/dtm/DTMManagerDefault.java b/src/org/apache/xml/dtm/DTMManagerDefault.java
new file mode 100644
index 0000000..910ee6f
--- /dev/null
+++ b/src/org/apache/xml/dtm/DTMManagerDefault.java
@@ -0,0 +1,656 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xml.dtm;
+
+import java.util.Vector;
+
+// JAXP 1.1
+import javax.xml.parsers.*;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.Source;
+import javax.xml.transform.SourceLocator;
+
+// Apache XML Utilities
+import org.apache.xml.utils.PrefixResolver;
+import org.apache.xml.utils.SystemIDResolver;
+import org.apache.xml.dtm.dom2dtm.DOM2DTM;
+import org.apache.xml.dtm.sax2dtm.SAX2DTM;
+
+// W3C DOM
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+// SAX2
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.helpers.XMLReaderFactory;
+import org.xml.sax.ext.DeclHandler;
+import org.xml.sax.ext.LexicalHandler;
+
+import org.apache.xml.utils.XMLString;
+import org.apache.xml.utils.XMLStringFactory;
+
+/**
+ * The default implementation for the DTMManager.
+ */
+public class DTMManagerDefault extends DTMManager
+{
+
+  /** NEEDSDOC Field m_dtms */
+  protected Vector m_dtms = new Vector();
+
+  /**
+   * Constructor DTMManagerDefault
+   *
+   */
+  public DTMManagerDefault(){}
+
+  /** Set this to true if you want a dump of the DTM after creation. */
+  private static final boolean DUMPTREE = false;
+  
+  /** Set this to true if you want a basic diagnostics. */
+  private static final boolean DEBUG = false;
+
+  /**
+   * Get an instance of a DTM, loaded with the content from the
+   * specified source.  If the unique flag is true, a new instance will
+   * always be returned.  Otherwise it is up to the DTMManager to return a
+   * new instance or an instance that it already created and may be being used
+   * by someone else.
+   * (I think more parameters will need to be added for error handling, and entity
+   * resolution).
+   *
+   * @param source the specification of the source object.
+   * @param unique true if the returned DTM must be unique, probably because it
+   * is going to be mutated.
+   * @param whiteSpaceFilter Enables filtering of whitespace nodes, and may
+   *                         be null.
+   * @param incremental true if the DTM should be built incrementally, if
+   *                    possible.
+   *
+   * @return a non-null DTM reference.
+   */
+  public DTM getDTM(Source source, boolean unique,
+                    DTMWSFilter whiteSpaceFilter, boolean incremental)
+  {
+    if(DEBUG && null != source)
+      System.out.println("Starting source: "+source.getSystemId());
+    XMLStringFactory xstringFactory = m_xsf;
+    int documentID = m_dtms.size() << 20;
+
+    if ((null != source) && source instanceof DOMSource)
+    {
+      DOM2DTM dtm = new DOM2DTM(this, (DOMSource) source, documentID,
+                                whiteSpaceFilter, xstringFactory);
+
+      m_dtms.add(dtm);
+
+      if (DUMPTREE)
+      {
+        dtm.dumpDTM();
+      }
+
+      return dtm;
+    }
+    else
+    {
+      boolean isSAXSource = (null != source)
+                            ? (source instanceof SAXSource) : true;
+      boolean isStreamSource = (null != source)
+                               ? (source instanceof StreamSource) : false;
+
+      if (isSAXSource || isStreamSource)
+      {
+        XMLReader reader;
+        InputSource xmlSource;
+
+        if (null == source)
+        {
+          xmlSource = null;
+          reader = null;
+        }
+        else
+        {
+          reader = getXMLReader(source);
+          xmlSource = SAXSource.sourceToInputSource(source);
+
+          String urlOfSource = xmlSource.getSystemId();
+
+          if (null != urlOfSource)
+          {
+            try
+            {
+              urlOfSource = SystemIDResolver.getAbsoluteURI(urlOfSource);
+            }
+            catch (Exception e)
+            {
+
+              // %REVIEW% Is there a better way to send a warning?
+              System.err.println("Can not absolutize URL: " + urlOfSource);
+            }
+
+            xmlSource.setSystemId(urlOfSource);
+          }
+        }
+
+        // Create the basic SAX2DTM.
+        SAX2DTM dtm = new SAX2DTM(this, source, documentID, whiteSpaceFilter,
+                                  xstringFactory);
+
+        // Go ahead and add the DTM to the lookup table.  This needs to be 
+        // done before any parsing occurs.
+        m_dtms.add(dtm);
+
+        boolean haveXercesParser =
+          (null != reader)
+          && (reader instanceof org.apache.xerces.parsers.SAXParser);
+
+        if (haveXercesParser)
+          incremental = true;  // No matter what.  %REVIEW%
+
+        if (incremental)
+        {
+
+          // Create a CoroutineManager to manage the coordination between the 
+          // parser and the transformation.  This will "throttle" between 
+          // the parser and the calling application.
+          CoroutineManager coroutineManager = new CoroutineManager();
+
+          // Create an CoRoutine ID for the transformation.
+          int appCoroutine = coroutineManager.co_joinCoroutineSet(-1);
+          CoroutineParser coParser;
+
+          if (haveXercesParser)
+          {
+            // CoroutineSAXParser_Xerces to avoid threading.
+            // System.out.println("Using CoroutineSAXParser_Xerces to avoid threading");
+            coParser = new CoroutineSAXParser_Xerces(
+              (org.apache.xerces.parsers.SAXParser) reader, coroutineManager,
+              appCoroutine);
+          }
+          else
+          {
+            // Create a CoroutineSAXParser that will run on the secondary thread.
+            if (null == reader)
+              coParser = new CoroutineSAXParser(coroutineManager,
+                                                appCoroutine);
+            else
+              coParser = new CoroutineSAXParser(coroutineManager,
+                                                appCoroutine, reader);
+          }
+
+          // Have the DTM set itself up as the CoroutineSAXParser's listener.
+          dtm.setCoroutineParser(coParser, appCoroutine);
+
+          // Get the parser's CoRoutine ID.
+          int parserCoroutine = coParser.getParserCoroutineID();
+
+          if (null == xmlSource)
+          {
+
+            // Then the user will construct it themselves.
+            return dtm;
+          }
+
+          // System.out.println("parserCoroutine (mgr): "+parserCoroutine);
+          // %TBD%  It's probably OK to have these bypass the CoRoutine stuff??
+          // Or maybe not?
+          // ... Depends on how broken will things get if they occur at the same
+          // time that someone is trying to read the DTM model. I'd suggest that
+          // we instead extend CoroutineParser to handle these, and let it
+          // pass the registration through to the reader if that's the Right Thng
+          reader.setDTDHandler(dtm);
+          reader.setErrorHandler(dtm);
+
+          try
+          {
+
+            // %REVIEW% Consider making coParser just be a throttling filter
+            Object gotMore = coParser.doParse(xmlSource, appCoroutine);
+
+            if (gotMore instanceof Exception)
+            {
+              dtm.clearCoRoutine();
+
+              throw ((Exception) gotMore);
+            }
+            else if (gotMore != Boolean.TRUE)
+            {
+
+              // %REVIEW% Consider having coParser self-terminate at end of file.
+              dtm.clearCoRoutine();
+            }
+          }
+          catch (RuntimeException re)
+          {
+
+            // coroutineManager.co_exit(appCoroutine);
+            dtm.clearCoRoutine();
+
+            throw re;
+          }
+          catch (Exception e)
+          {
+
+            // coroutineManager.co_exit(appCoroutine);
+            dtm.clearCoRoutine();
+
+            throw new org.apache.xml.utils.WrappedRuntimeException(e);
+          }
+        }
+        else
+        {
+          if (null == reader)
+          {
+
+            // Then the user will construct it themselves.
+            return dtm;
+          }
+
+          // not incremental
+          reader.setContentHandler(dtm);
+          reader.setDTDHandler(dtm);
+          reader.setErrorHandler(dtm);
+
+          try
+          {
+            reader.setProperty(
+              "http://xml.org/sax/properties/lexical-handler", dtm);
+          }
+          catch (SAXNotRecognizedException e){}
+          catch (SAXNotSupportedException e){}
+
+          try
+          {
+            reader.parse(xmlSource);
+          }
+          catch (RuntimeException re)
+          {
+
+            // coroutineManager.co_exit(appCoroutine);
+            dtm.clearCoRoutine();
+
+            throw re;
+          }
+          catch (Exception e)
+          {
+
+            // coroutineManager.co_exit(appCoroutine);
+            dtm.clearCoRoutine();
+
+            throw new org.apache.xml.utils.WrappedRuntimeException(e);
+          }
+        }
+
+        if (DUMPTREE)
+        {
+          System.out.println("Dumping SAX2DOM");
+          dtm.dumpDTM();
+        }
+
+        return dtm;
+      }
+      else
+      {
+
+        // It should have been handled by a derived class or the caller 
+        // made a mistake.
+        throw new DTMException("Not supported: " + source);
+      }
+    }
+  }
+
+  /**
+   * Given a W3C DOM node, try and return a DTM handle.
+   * Note: calling this may be non-optimal, and there is no guarantee that
+   * the node will be found in any particular DTM.
+   *
+   * @param node Non-null reference to a DOM node.
+   *
+   * @return a valid DTM handle.
+   */
+  public int getDTMHandleFromNode(org.w3c.dom.Node node)
+  {
+
+    if (node instanceof org.apache.xml.dtm.DTMNodeProxy)
+      return ((org.apache.xml.dtm.DTMNodeProxy) node).getDTMNodeNumber();
+    else
+    {
+      // Find the DOM2DTMs wrapped around this Document (if any)
+      // and check whether they contain the Node in question.
+      //
+      // NOTE that since a DOM2DTM may represent a subtree rather
+      // than a full document, we have to be prepared to check more
+      // than one -- and there is no guarantee that we will find 
+      // one that contains ancestors or siblings of the node we're
+      // seeking.
+      //
+      // %REVIEW% We could search for the one which contains this
+      // node at the deepest level, and thus covers the widest
+      // subtree, but that's going to entail additional work
+      // checking more DTMs... and getHandleFromNode is not a
+      // cheap operation in most implementations.
+      for(int i=m_dtms.size()-1;i>=0;--i)
+	{
+	  DTM thisDTM=(DTM)m_dtms.elementAt(i);
+	  if(thisDTM instanceof DOM2DTM)
+	    {
+	      int handle=((DOM2DTM)thisDTM).getHandleOfNode(node);
+	      if(handle!=DTM.NULL) return handle;
+	    }
+	}
+      
+      // Fallback: Not found in one we know how to search.
+      // Current solution: Generate a new DOM2DTM with this node as root.
+      // %REVIEW% Maybe the best I can do??
+      DTM dtm = getDTM(new javax.xml.transform.dom.DOMSource(node), false,
+                       null, true);
+
+      return dtm.getDocument();
+    }
+  }
+
+  /**
+   * This method returns the SAX2 parser to use with the InputSource
+   * obtained from this URI.
+   * It may return null if any SAX2-conformant XML parser can be used,
+   * or if getInputSource() will also return null. The parser must
+   * be free for use (i.e.
+   * not currently in use for another parse().
+   *
+   * @param inputSource The value returned from the URIResolver.
+   * @returns a SAX2 XMLReader to use to resolve the inputSource argument.
+   *
+   * @return non-null XMLReader reference ready to parse.
+   */
+  public XMLReader getXMLReader(Source inputSource)
+  {
+
+    try
+    {
+      XMLReader reader = (inputSource instanceof SAXSource)
+                         ? ((SAXSource) inputSource).getXMLReader() : null;
+
+      if (null == reader)
+      {
+        try
+        {
+          javax.xml.parsers.SAXParserFactory factory =
+            javax.xml.parsers.SAXParserFactory.newInstance();
+
+          factory.setNamespaceAware(true);
+
+          javax.xml.parsers.SAXParser jaxpParser = factory.newSAXParser();
+
+          reader = jaxpParser.getXMLReader();
+        }
+        catch (javax.xml.parsers.ParserConfigurationException ex)
+        {
+          throw new org.xml.sax.SAXException(ex);
+        }
+        catch (javax.xml.parsers.FactoryConfigurationError ex1)
+        {
+          throw new org.xml.sax.SAXException(ex1.toString());
+        }
+        catch (NoSuchMethodError ex2){}
+        catch (AbstractMethodError ame){}
+
+        if (null == reader)
+          reader = XMLReaderFactory.createXMLReader();
+      }
+
+      try
+      {
+        reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
+                          true);
+      }
+      catch (org.xml.sax.SAXException se)
+      {
+
+        // What can we do?
+        // TODO: User diagnostics.
+      }
+
+      try
+      {
+        reader.setFeature("http://apache.org/xml/features/validation/dynamic",
+                          true);
+      }
+      catch (org.xml.sax.SAXException se)
+      {
+
+        // What can we do?
+        // TODO: User diagnostics.
+      }
+
+      return reader;
+    }
+    catch (org.xml.sax.SAXException se)
+    {
+      throw new DTMException(se.getMessage(), se);
+    }
+  }
+
+  /**
+   * NEEDSDOC Method getDTM
+   *
+   *
+   * NEEDSDOC @param nodeHandle
+   *
+   * NEEDSDOC (getDTM) @return
+   */
+  public DTM getDTM(int nodeHandle)
+  {
+
+    // Performance critical function.
+    return (DTM) m_dtms.elementAt(nodeHandle >> 20);
+  }
+
+  /**
+   * NEEDSDOC Method getDTMIdentity
+   *
+   *
+   * NEEDSDOC @param dtm
+   *
+   * NEEDSDOC (getDTMIdentity) @return
+   */
+  public int getDTMIdentity(DTM dtm)
+  {
+
+    // A backwards search should normally be the fastest.
+    int n = m_dtms.size();
+
+    for (int i = (n - 1); i >= 0; i--)
+    {
+      DTM tdtm = (DTM) m_dtms.elementAt(i);
+
+      if (tdtm == dtm)
+        return i;
+    }
+
+    return -1;
+  }
+
+  /**
+   * NEEDSDOC Method release
+   *
+   *
+   * NEEDSDOC @param dtm
+   * NEEDSDOC @param shouldHardDelete
+   *
+   * NEEDSDOC (release) @return
+   */
+  public boolean release(DTM dtm, boolean shouldHardDelete)
+  {
+
+    if (dtm instanceof SAX2DTM)
+    {
+      ((SAX2DTM) dtm).clearCoRoutine();
+    }
+
+    int i = getDTMIdentity(dtm);
+
+    // %TBD% Recover space.
+    if (i >= 0)
+    {
+      m_dtms.setElementAt(null, i);
+    }
+
+    /** @todo: implement this org.apache.xml.dtm.DTMManager abstract method */
+    return true;
+  }
+
+  /**
+   * Method createDocumentFragment
+   *
+   *
+   * NEEDSDOC (createDocumentFragment) @return
+   */
+  public DTM createDocumentFragment()
+  {
+
+    try
+    {
+      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+
+      dbf.setNamespaceAware(true);
+
+      DocumentBuilder db = dbf.newDocumentBuilder();
+      Document doc = db.newDocument();
+      Node df = doc.createDocumentFragment();
+
+      return getDTM(new DOMSource(df), true, null, false);
+    }
+    catch (Exception e)
+    {
+      throw new DTMException(e);
+    }
+  }
+
+  /**
+   * NEEDSDOC Method createDTMIterator
+   *
+   *
+   * NEEDSDOC @param whatToShow
+   * NEEDSDOC @param filter
+   * NEEDSDOC @param entityReferenceExpansion
+   *
+   * NEEDSDOC (createDTMIterator) @return
+   */
+  public DTMIterator createDTMIterator(int whatToShow, DTMFilter filter,
+                                       boolean entityReferenceExpansion)
+  {
+
+    /** @todo: implement this org.apache.xml.dtm.DTMManager abstract method */
+    return null;
+  }
+
+  /**
+   * NEEDSDOC Method createDTMIterator
+   *
+   *
+   * NEEDSDOC @param xpathString
+   * NEEDSDOC @param presolver
+   *
+   * NEEDSDOC (createDTMIterator) @return
+   */
+  public DTMIterator createDTMIterator(String xpathString,
+                                       PrefixResolver presolver)
+  {
+
+    /** @todo: implement this org.apache.xml.dtm.DTMManager abstract method */
+    return null;
+  }
+
+  /**
+   * NEEDSDOC Method createDTMIterator
+   *
+   *
+   * NEEDSDOC @param node
+   *
+   * NEEDSDOC (createDTMIterator) @return
+   */
+  public DTMIterator createDTMIterator(int node)
+  {
+
+    /** @todo: implement this org.apache.xml.dtm.DTMManager abstract method */
+    return null;
+  }
+
+  /**
+   * NEEDSDOC Method createDTMIterator
+   *
+   *
+   * NEEDSDOC @param xpathCompiler
+   * NEEDSDOC @param pos
+   *
+   * NEEDSDOC (createDTMIterator) @return
+   */
+  public DTMIterator createDTMIterator(Object xpathCompiler, int pos)
+  {
+
+    /** @todo: implement this org.apache.xml.dtm.DTMManager abstract method */
+    return null;
+  }
+}
diff --git a/src/org/apache/xml/dtm/DTMNamedNodeMap.java b/src/org/apache/xml/dtm/DTMNamedNodeMap.java
new file mode 100644
index 0000000..b7c43b6
--- /dev/null
+++ b/src/org/apache/xml/dtm/DTMNamedNodeMap.java
@@ -0,0 +1,323 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xml.dtm;
+
+import org.w3c.dom.*;
+
+import java.util.Vector;
+
+/**
+ * <meta name="usage" content="internal"/>
+ * DTMNamedNodeMap is a quickie (as opposed to quick) implementation of the DOM's
+ * NamedNodeMap interface, intended to support DTMProxy's getAttributes()
+ * call.
+ * <p>
+ * ***** Note: this does _not_ current attempt to cache any of the data;
+ * if you ask for attribute 27 and then 28, you'll have to rescan the first
+ * 27. It should probably at least keep track of the last one retrieved,
+ * and possibly buffer the whole array.
+ * <p>
+ * ***** Also note that there's no fastpath for the by-name query; we search
+ * linearly until we find it or fail to find it. Again, that could be
+ * optimized at some cost in object creation/storage.
+ */
+public class DTMNamedNodeMap implements NamedNodeMap
+{
+
+  /** The DTM for this node. */
+  DTM dtm;
+
+  /** The DTM element handle. */
+  int element;
+
+  /** The number of nodes in this map. */
+  short m_count = -1;
+
+  /**
+   * Create a getAttributes NamedNodeMap for a given DTM element node
+   *
+   * @param dtm The DTM Reference, must be non-null.
+   * @param element The DTM element handle.
+   */
+  DTMNamedNodeMap(DTM dtm, int element)
+  {
+    this.dtm = dtm;
+    this.element = element;
+  }
+
+  /**
+   * Return the number of Attributes on this Element
+   *
+   * @return The number of nodes in this map.
+   */
+  public int getLength()
+  {
+
+    if (m_count == -1)
+    {
+      short count = 0;
+
+      for (int n = dtm.getNextAttribute(element); n != -1;
+              n = dtm.getNextAttribute(n))
+      {
+        ++count;
+      }
+
+      m_count = count;
+    }
+
+    return (int) m_count;
+  }
+
+  /**
+   * Retrieves a node specified by name.
+   * @param nameThe <code>nodeName</code> of a node to retrieve.
+   *
+   * @param name Name of the item being requested.
+   * @return A <code>Node</code> (of any type) with the specified
+   *   <code>nodeName</code>, or <code>null</code> if it does not identify
+   *   any node in this map.
+   */
+  public Node getNamedItem(String name)
+  {
+
+    for (int n = dtm.getNextAttribute(element); n != -1;
+            n = dtm.getNextAttribute(n))
+    {
+      if (dtm.getNodeName(n).equals(name))
+        return dtm.getNode(n);
+    }
+
+    return null;
+  }
+
+  /**
+   * Returns the <code>index</code>th item in the map. If <code>index</code>
+   * is greater than or equal to the number of nodes in this map, this
+   * returns <code>null</code>.
+   * @param indexIndex into this map.
+   *
+   * @param i The index of the requested item.
+   * @return The node at the <code>index</code>th position in the map, or
+   *   <code>null</code> if that is not a valid index.
+   */
+  public Node item(int i)
+  {
+
+    int count = 0;
+
+    for (int n = dtm.getNextAttribute(element); n != -1;
+            n = dtm.getNextAttribute(n))
+    {
+      if (count == i)
+        return dtm.getNode(n);
+      else
+        ++count;
+    }
+
+    return null;
+  }
+
+  /**
+   * Adds a node using its <code>nodeName</code> attribute. If a node with
+   * that name is already present in this map, it is replaced by the new
+   * one.
+   * <br>As the <code>nodeName</code> attribute is used to derive the name
+   * which the node must be stored under, multiple nodes of certain types
+   * (those that have a "special" string value) cannot be stored as the
+   * names would clash. This is seen as preferable to allowing nodes to be
+   * aliased.
+   * @param newNode node to store in this map. The node will later be
+   *   accessible using the value of its <code>nodeName</code> attribute.
+   *
+   * @return If the new <code>Node</code> replaces an existing node the
+   *   replaced <code>Node</code> is returned, otherwise <code>null</code>
+   *   is returned.
+   * @exception DOMException
+   *   WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
+   *   different document than the one that created this map.
+   *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
+   *   <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
+   *   <code>Attr</code> that is already an attribute of another
+   *   <code>Element</code> object. The DOM user must explicitly clone
+   *   <code>Attr</code> nodes to re-use them in other elements.
+   */
+  public Node setNamedItem(Node newNode)
+  {
+    throw new DTMException(DTMException.NO_MODIFICATION_ALLOWED_ERR);
+  }
+
+  /**
+   * Removes a node specified by name. When this map contains the attributes
+   * attached to an element, if the removed attribute is known to have a
+   * default value, an attribute immediately appears containing the
+   * default value as well as the corresponding namespace URI, local name,
+   * and prefix when applicable.
+   * @param name The <code>nodeName</code> of the node to remove.
+   *
+   * @return The node removed from this map if a node with such a name
+   *   exists.
+   * @exception DOMException
+   *   NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in
+   *   this map.
+   *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
+   */
+  public Node removeNamedItem(String name)
+  {
+    throw new DTMException(DTMException.NO_MODIFICATION_ALLOWED_ERR);
+  }
+
+  /**
+   * Retrieves a node specified by local name and namespace URI. HTML-only
+   * DOM implementations do not need to implement this method.
+   * @param namespaceURI The namespace URI of the node to retrieve.
+   * @param localName The local name of the node to retrieve.
+   *
+   * @return A <code>Node</code> (of any type) with the specified local
+   *   name and namespace URI, or <code>null</code> if they do not
+   *   identify any node in this map.
+   * @since DOM Level 2
+   */
+  public Node getNamedItemNS(String namespaceURI, String localName)
+  {
+    throw new DTMException(DTMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   * Adds a node using its <code>namespaceURI</code> and
+   * <code>localName</code>. If a node with that namespace URI and that
+   * local name is already present in this map, it is replaced by the new
+   * one.
+   * <br>HTML-only DOM implementations do not need to implement this method.
+   * @param arg A node to store in this map. The node will later be
+   *   accessible using the value of its <code>namespaceURI</code> and
+   *   <code>localName</code> attributes.
+   *
+   * @return If the new <code>Node</code> replaces an existing node the
+   *   replaced <code>Node</code> is returned, otherwise <code>null</code>
+   *   is returned.
+   * @exception DOMException
+   *   WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
+   *   different document than the one that created this map.
+   *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
+   *   <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
+   *   <code>Attr</code> that is already an attribute of another
+   *   <code>Element</code> object. The DOM user must explicitly clone
+   *   <code>Attr</code> nodes to re-use them in other elements.
+   * @since DOM Level 2
+   */
+  public Node setNamedItemNS(Node arg) throws DOMException
+  {
+    throw new DTMException(DTMException.NO_MODIFICATION_ALLOWED_ERR);
+  }
+
+  /**
+   * Removes a node specified by local name and namespace URI. A removed
+   * attribute may be known to have a default value when this map contains
+   * the attributes attached to an element, as returned by the attributes
+   * attribute of the <code>Node</code> interface. If so, an attribute
+   * immediately appears containing the default value as well as the
+   * corresponding namespace URI, local name, and prefix when applicable.
+   * <br>HTML-only DOM implementations do not need to implement this method.
+   * 
+   * @param namespaceURI The namespace URI of the node to remove.
+   * @param localName The local name of the node to remove.
+   *
+   * @return The node removed from this map if a node with such a local
+   *   name and namespace URI exists.
+   * @exception DOMException
+   *   NOT_FOUND_ERR: Raised if there is no node with the specified
+   *   <code>namespaceURI</code> and <code>localName</code> in this map.
+   *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
+   * @since DOM Level 2
+   */
+  public Node removeNamedItemNS(String namespaceURI, String localName)
+          throws DOMException
+  {
+    throw new DTMException(DTMException.NO_MODIFICATION_ALLOWED_ERR);
+  }
+
+  /**
+   * <meta name="usage" content="internal"/>
+   * Simple implementation of DOMException.
+   */
+  public class DTMException extends org.w3c.dom.DOMException
+  {
+
+    /**
+     * Constructs a DOM/DTM exception.
+     *
+     * @param code
+     * @param message
+     */
+    public DTMException(short code, String message)
+    {
+      super(code, message);
+    }
+
+    /**
+     * Constructor DTMException
+     *
+     *
+     * @param code
+     */
+    public DTMException(short code)
+    {
+      super(code, "");
+    }
+  }
+}
diff --git a/src/org/apache/xml/dtm/DTMNodeProxy.java b/src/org/apache/xml/dtm/DTMNodeProxy.java
new file mode 100644
index 0000000..c0e6822
--- /dev/null
+++ b/src/org/apache/xml/dtm/DTMNodeProxy.java
@@ -0,0 +1,1156 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xml.dtm;
+
+import org.w3c.dom.*;
+
+/**
+ * <meta name="usage" content="internal"/>
+ * <code>DTMNodeProxy</code> presents a DOM Node API front-end to the DTM model.
+ * <p>
+ * It does _not_ attempt to address the "node identity" question; no effort
+ * is made to prevent the creation of multiple proxies referring to a single
+ * DTM node. Users can create a mechanism for managing this, or relinquish the
+ * use of "==" and use the .sameNodeAs() mechanism, which is under
+ * consideration for future versions of the DOM.
+ * <p>
+ * DTMNodeProxy may be subclassed further to present specific DOM node types.
+ *
+ * @see org.w3c.dom
+ */
+public class DTMNodeProxy
+        implements Node, Document, Text, Element, Attr,
+                   ProcessingInstruction, Comment
+{
+
+  /** The DTM for this node. */
+  public DTM dtm;
+
+  /** The DTM node handle. */
+  int node;
+
+  /**
+   * Create a DTMNodeProxy Node representing a specific Node in a DTM
+   *
+   * @param dtm The DTM Reference, must be non-null.
+   * @param node The DTM node handle.
+   */
+  DTMNodeProxy(DTM dtm, int node)
+  {
+    this.dtm = dtm;
+    this.node = node;
+  }
+
+  /**
+   * NON-DOM: Return the DTM model
+   *
+   * @return The DTM that this proxy is a representative for.
+   */
+  public final DTM getDTM()
+  {
+    return dtm;
+  }
+
+  /**
+   * NON-DOM: Return the DTM node number
+   *
+   * @return The DTM node handle.
+   */
+  public final int getDTMNodeNumber()
+  {
+    return node;
+  }
+
+  /**
+   * Test for equality based on node number.
+   *
+   * @param node A DTM node proxy reference.
+   *
+   * @return true if the given node has the same handle as this node.
+   */
+  public final boolean equals(Node node)
+  {
+
+    try
+    {
+      DTMNodeProxy dtmp = (DTMNodeProxy) node;
+
+      // return (dtmp.node == this.node);
+      // Patch attributed to Gary L Peskin <garyp@firstech.com>
+      return (dtmp.node == this.node) && (dtmp.dtm == this.dtm);
+    }
+    catch (ClassCastException cce)
+    {
+      return false;
+    }
+  }
+
+  /**
+   * Test for equality based on node number.
+   *
+   * @param node A DTM node proxy reference.
+   *
+   * @return true if the given node has the same handle as this node.
+   */
+  public final boolean equals(Object node)
+  {
+
+    try
+    {
+
+      // DTMNodeProxy dtmp = (DTMNodeProxy)node;
+      // return (dtmp.node == this.node);
+      // Patch attributed to Gary L Peskin <garyp@firstech.com>
+      return equals((Node) node);
+    }
+    catch (ClassCastException cce)
+    {
+      return false;
+    }
+  }
+
+  /**
+   * FUTURE DOM: Test node identity, in lieu of Node==Node
+   *
+   * @param other
+   *
+   * @return true if the given node has the same handle as this node.
+   */
+  public final boolean sameNodeAs(Node other)
+  {
+
+    if (!(other instanceof DTMNodeProxy))
+      return false;
+
+    DTMNodeProxy that = (DTMNodeProxy) other;
+
+    return this.dtm == that.dtm && this.node == that.node;
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Node
+   */
+  public final String getNodeName()
+  {
+    return dtm.getNodeName(node);
+  }
+
+  /**
+   * A PI's "target" states what processor channel the PI's data
+   * should be directed to. It is defined differently in HTML and XML.
+   * <p>
+   * In XML, a PI's "target" is the first (whitespace-delimited) token
+   * following the "<?" token that begins the PI.
+   * <p>
+   * In HTML, target is always null.
+   * <p>
+   * Note that getNodeName is aliased to getTarget.
+   *
+   * @return
+   */
+  public final String getTarget()
+  {
+    return dtm.getNodeName(node);
+  }  // getTarget():String
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Node as of DOM Level 2
+   */
+  public final String getLocalName()
+  {
+    return dtm.getLocalName(node);
+  }
+
+  /**
+   * @return The prefix for this node.
+   * @see org.w3c.dom.Node as of DOM Level 2
+   */
+  public final String getPrefix()
+  {
+    return dtm.getPrefix(node);
+  }
+
+  /**
+   *
+   * @param prefix
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Node as of DOM Level 2 -- DTMNodeProxy is read-only
+   */
+  public final void setPrefix(String prefix) throws DOMException
+  {
+    throw new DTMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Node as of DOM Level 2
+   */
+  public final String getNamespaceURI()
+  {
+    return dtm.getNamespaceURI(node);
+  }
+
+  /**
+   *
+   * @param feature
+   * @param version
+   *
+   * @return
+   * @see org.w3c.dom.Node as of DOM Level 2
+   */
+  public final boolean supports(String feature, String version)
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param feature
+   * @param version
+   *
+   * @return
+   * @see org.w3c.dom.Node as of DOM Level 2
+   */
+  public final boolean isSupported(String feature, String version)
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Node
+   */
+  public final String getNodeValue() throws DOMException
+  {
+
+    // ***** ASSUMPTION: ATTRIBUTES HAVE SINGLE TEXT-NODE CHILD.
+    // (SIMILAR ASSUMPTION CURRENTLY MADE IN DTM; BE SURE TO
+    // REVISIT THIS IF THAT CHANGES!)
+    if (getNodeType() == Node.ATTRIBUTE_NODE)
+      return dtm.getNodeValue(node + 1);
+
+    return dtm.getNodeValue(node);
+  }
+
+  /**
+   *
+   * @param nodeValue
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Node -- DTMNodeProxy is read-only
+   */
+  public final void setNodeValue(String nodeValue) throws DOMException
+  {
+    throw new DTMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Node
+   */
+  public final short getNodeType()
+  {
+    return (short) dtm.getNodeType(node);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Node
+   */
+  public final Node getParentNode()
+  {
+
+    if (getNodeType() == Node.ATTRIBUTE_NODE)
+      return null;
+
+    int newnode = dtm.getParent(node);
+
+    return (newnode == -1) ? null : dtm.getNode(newnode);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Node
+   */
+  public final Node getOwnerNode()
+  {
+
+    int newnode = dtm.getParent(node);
+
+    return (newnode == -1) ? null : dtm.getNode(newnode);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Node
+   */
+  public final NodeList getChildNodes()
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Node
+   */
+  public final Node getFirstChild()
+  {
+
+    int newnode = dtm.getFirstChild(node);
+
+    return (newnode == -1) ? null : dtm.getNode(newnode);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Node
+   */
+  public final Node getLastChild()
+  {
+
+    int newnode = dtm.getLastChild(node);
+
+    return (newnode == -1) ? null : dtm.getNode(newnode);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Node
+   */
+  public final Node getPreviousSibling()
+  {
+
+    int newnode = dtm.getPreviousSibling(node);
+
+    return (newnode == -1) ? null : dtm.getNode(newnode);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Node
+   */
+  public final Node getNextSibling()
+  {
+
+    // Attr's Next is defined at DTM level, but not at DOM level.
+    if (dtm.getNodeType(node) == Node.ATTRIBUTE_NODE)
+      return null;
+
+    int newnode = dtm.getNextSibling(node);
+
+    return (newnode == -1) ? null : dtm.getNode(newnode);
+  }
+
+  // DTMNamedNodeMap m_attrs;
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Node
+   */
+  public final NamedNodeMap getAttributes()
+  {
+
+    return new DTMNamedNodeMap(dtm, node);
+  }
+
+  /**
+   * Method hasAttribute
+   *
+   *
+   * @param name
+   *
+   * (hasAttribute) @return
+   */
+  public boolean hasAttribute(String name)
+  {
+
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+
+    // return false;
+  }
+
+  /**
+   * Method hasAttributeNS
+   *
+   *
+   * @param name
+   * @param x
+   *
+   * (hasAttributeNS) @return
+   */
+  public boolean hasAttributeNS(String name, String x)
+  {
+
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+
+    // return false;
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Node
+   */
+  public final Document getOwnerDocument()
+  {
+    return new DTMNodeProxy(dtm, dtm.getDocument());
+  }
+
+  /**
+   *
+   * @param newChild
+   * @param refChild
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Node -- DTMNodeProxy is read-only
+   */
+  public final Node insertBefore(Node newChild, Node refChild)
+          throws DOMException
+  {
+    throw new DTMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+  }
+
+  /**
+   *
+   * @param newChild
+   * @param oldChild
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Node -- DTMNodeProxy is read-only
+   */
+  public final Node replaceChild(Node newChild, Node oldChild)
+          throws DOMException
+  {
+    throw new DTMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+  }
+
+  /**
+   *
+   * @param oldChild
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Node -- DTMNodeProxy is read-only
+   */
+  public final Node removeChild(Node oldChild) throws DOMException
+  {
+    throw new DTMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+  }
+
+  /**
+   *
+   * @param newChild
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Node -- DTMNodeProxy is read-only
+   */
+  public final Node appendChild(Node newChild) throws DOMException
+  {
+    throw new DTMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Node
+   */
+  public final boolean hasChildNodes()
+  {
+    return (-1 != dtm.getFirstChild(node));
+  }
+
+  /**
+   *
+   * @param deep
+   *
+   * @return
+   * @see org.w3c.dom.Node -- DTMNodeProxy is read-only
+   */
+  public final Node cloneNode(boolean deep)
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Document
+   */
+  public final DocumentType getDoctype()
+  {
+    return null;
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Document
+   */
+  public final DOMImplementation getImplementation()
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Document
+   */
+  public final Element getDocumentElement()
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param tagName
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Document
+   */
+  public final Element createElement(String tagName) throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Document
+   */
+  public final DocumentFragment createDocumentFragment()
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param data
+   *
+   * @return
+   * @see org.w3c.dom.Document
+   */
+  public final Text createTextNode(String data)
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param data
+   *
+   * @return
+   * @see org.w3c.dom.Document
+   */
+  public final Comment createComment(String data)
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param data
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Document
+   */
+  public final CDATASection createCDATASection(String data)
+          throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param target
+   * @param data
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Document
+   */
+  public final ProcessingInstruction createProcessingInstruction(
+          String target, String data) throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param name
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Document
+   */
+  public final Attr createAttribute(String name) throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param name
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Document
+   */
+  public final EntityReference createEntityReference(String name)
+          throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param tagname
+   *
+   * @return
+   * @see org.w3c.dom.Document
+   */
+  public final NodeList getElementsByTagName(String tagname)
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param importedNode
+   * @param deep
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Document as of DOM Level 2 -- DTMNodeProxy is read-only
+   */
+  public final Node importNode(Node importedNode, boolean deep)
+          throws DOMException
+  {
+    throw new DTMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+  }
+
+  /**
+   *
+   * @param namespaceURI
+   * @param qualifiedName
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Document as of DOM Level 2
+   */
+  public final Element createElementNS(
+          String namespaceURI, String qualifiedName) throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param namespaceURI
+   * @param qualifiedName
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Document as of DOM Level 2
+   */
+  public final Attr createAttributeNS(
+          String namespaceURI, String qualifiedName) throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param namespaceURI
+   * @param localName
+   *
+   * @return
+   * @see org.w3c.dom.Document as of DOM Level 2
+   */
+  public final NodeList getElementsByTagNameNS(String namespaceURI,
+          String localName)
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param elementId
+   *
+   * @return
+   * @see org.w3c.dom.Document as of DOM Level 2
+   */
+  public final Element getElementById(String elementId)
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param offset
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Text
+   */
+  public final Text splitText(int offset) throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.CharacterData
+   */
+  public final String getData() throws DOMException
+  {
+    return dtm.getNodeValue(node);
+  }
+
+  /**
+   *
+   * @param data
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.CharacterData
+   */
+  public final void setData(String data) throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.CharacterData
+   */
+  public final int getLength()
+  {
+
+    // %%FIX: This should do something smarter?
+    return dtm.getNodeValue(node).length();
+  }
+
+  /**
+   *
+   * @param offset
+   * @param count
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.CharacterData
+   */
+  public final String substringData(int offset, int count) throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param arg
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.CharacterData
+   */
+  public final void appendData(String arg) throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param offset
+   * @param arg
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.CharacterData
+   */
+  public final void insertData(int offset, String arg) throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param offset
+   * @param count
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.CharacterData
+   */
+  public final void deleteData(int offset, int count) throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param offset
+   * @param count
+   * @param arg
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.CharacterData
+   */
+  public final void replaceData(int offset, int count, String arg)
+          throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Element
+   */
+  public final String getTagName()
+  {
+    return dtm.getNodeName(node);
+  }
+
+  /**
+   *
+   * @param name
+   *
+   * @return
+   * @see org.w3c.dom.Element
+   */
+  public final String getAttribute(String name)
+  {
+
+    DTMNamedNodeMap  map = new DTMNamedNodeMap(dtm, node);
+    Node node = map.getNamedItem(name);
+    return (null == node) ? null : node.getNodeValue();
+  }
+
+  /**
+   *
+   * @param name
+   * @param value
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Element
+   */
+  public final void setAttribute(String name, String value)
+          throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param name
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Element
+   */
+  public final void removeAttribute(String name) throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param name
+   *
+   * @return
+   * @see org.w3c.dom.Element
+   */
+  public final Attr getAttributeNode(String name)
+  {
+
+    DTMNamedNodeMap  map = new DTMNamedNodeMap(dtm, node);
+    return (Attr)map.getNamedItem(name);
+  }
+
+  /**
+   *
+   * @param newAttr
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Element
+   */
+  public final Attr setAttributeNode(Attr newAttr) throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param oldAttr
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Element
+   */
+  public final Attr removeAttributeNode(Attr oldAttr) throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   * Introduced in DOM Level 2.
+   *
+   * @return
+   */
+  public boolean hasAttributes()
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /** @see org.w3c.dom.Element */
+  public final void normalize()
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param namespaceURI
+   * @param localName
+   *
+   * @return
+   * @see org.w3c.dom.Element
+   */
+  public final String getAttributeNS(String namespaceURI, String localName)
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param namespaceURI
+   * @param qualifiedName
+   * @param value
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Element
+   */
+  public final void setAttributeNS(
+          String namespaceURI, String qualifiedName, String value)
+            throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param namespaceURI
+   * @param localName
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Element
+   */
+  public final void removeAttributeNS(String namespaceURI, String localName)
+          throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param namespaceURI
+   * @param localName
+   *
+   * @return
+   * @see org.w3c.dom.Element
+   */
+  public final Attr getAttributeNodeNS(String namespaceURI, String localName)
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @param newAttr
+   *
+   * @return
+   *
+   * @throws DOMException
+   * @see org.w3c.dom.Element
+   */
+  public final Attr setAttributeNodeNS(Attr newAttr) throws DOMException
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Attr
+   */
+  public final String getName()
+  {
+    return dtm.getNodeName(node);
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Attr
+   */
+  public final boolean getSpecified()
+  {
+
+    // %%FIX
+    return true;
+  }
+
+  /**
+   *
+   * @return
+   * @see org.w3c.dom.Attr
+   */
+  public final String getValue()
+  {
+    return dtm.getNodeValue(node + 1);
+  }
+
+  /**
+   *
+   * @param value
+   * @see org.w3c.dom.Attr
+   */
+  public final void setValue(String value)
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   * Get the owner element of an attribute.
+   *
+   * @return
+   * @see org.w3c.dom.Attr as of DOM Level 2
+   */
+  public final Element getOwnerElement()
+  {
+    throw new DTMException(DOMException.NOT_SUPPORTED_ERR);
+  }
+
+  /**
+   * <meta name="usage" content="internal"/>
+   * Simple implementation of DOMException.
+   */
+  public class DTMException extends org.w3c.dom.DOMException
+  {
+
+    /**
+     * Constructs a DOM/DTM exception.
+     *
+     * @param code
+     * @param message
+     */
+    public DTMException(short code, String message)
+    {
+      super(code, message);
+    }
+
+    /**
+     * Constructor DTMException
+     *
+     *
+     * @param code
+     */
+    public DTMException(short code)
+    {
+      super(code, "");
+    }
+  }
+}
diff --git a/src/org/apache/xml/dtm/DTMSafeStringPool.java b/src/org/apache/xml/dtm/DTMSafeStringPool.java
new file mode 100644
index 0000000..633747c
--- /dev/null
+++ b/src/org/apache/xml/dtm/DTMSafeStringPool.java
@@ -0,0 +1,147 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999,2000 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xerces" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.apache.org.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.xml.dtm;
+import org.apache.xml.utils.IntVector;
+import java.util.Vector;
+
+/** <p>Like DTMStringPool, but threadsafe. It's been proposed that DTMs
+ * share their string pool(s); that raises threadsafety issues which
+ * this addresses. Of course performance is inferior to that of the
+ * bare-bones version.</p>
+ *
+ * <p>Status: Passed basic test in main().</p>
+ * */
+public class DTMSafeStringPool
+extends DTMStringPool
+{
+  public synchronized void removeAllElements()
+    {
+      super.removeAllElements();
+    }
+
+  /** @return string whose value is uniquely identified by this integer index.
+   * @throws java.lang.ArrayIndexOutOfBoundsException
+   *  if index doesn't map to a string.
+   * */ 
+  public synchronized String indexToString(int i)
+    throws java.lang.ArrayIndexOutOfBoundsException
+    {
+      return super.indexToString(i);
+    }
+
+  /** @return integer index uniquely identifying the value of this string. */ 
+  public synchronized int stringToIndex(String s)
+    {
+      return super.stringToIndex(s);
+    }
+
+  /** Command-line unit test driver. This test relies on the fact that
+   * this version of the pool assigns indices consecutively, starting
+   * from zero, as new unique strings are encountered.
+   */
+  public static void main(String[] args)
+  {
+    String[] word={
+      "Zero","One","Two","Three","Four","Five",
+      "Six","Seven","Eight","Nine","Ten",
+      "Eleven","Twelve","Thirteen","Fourteen","Fifteen",
+      "Sixteen","Seventeen","Eighteen","Nineteen","Twenty",
+      "Twenty-One","Twenty-Two","Twenty-Three","Twenty-Four",
+      "Twenty-Five","Twenty-Six","Twenty-Seven","Twenty-Eight",
+      "Twenty-Nine","Thirty","Thirty-One","Thirty-Two",
+      "Thirty-Three","Thirty-Four","Thirty-Five","Thirty-Six",
+      "Thirty-Seven","Thirty-Eight","Thirty-Nine"};
+
+    DTMStringPool pool=new DTMSafeStringPool();
+
+    System.out.println("If no complaints are printed below, we passed initial test.");
+
+    for(int pass=0;pass<=1;++pass)
+      {
+	int i;
+
+	for(i=0;i<word.length;++i)
+	  {
+	    int j=pool.stringToIndex(word[i]);
+	    if(j!=i)
+	      System.out.println("\tMismatch populating pool: assigned "+
+				 j+" for create "+i);
+	  }
+
+	for(i=0;i<word.length;++i)
+	  {
+	    int j=pool.stringToIndex(word[i]);
+	    if(j!=i)
+	      System.out.println("\tMismatch in stringToIndex: returned "+
+				 j+" for lookup "+i);
+	  }
+
+	for(i=0;i<word.length;++i)
+	  {
+	    String w=pool.indexToString(i);
+	    if(!word[i].equals(w))
+	      System.out.println("\tMismatch in indexToString: returned"+
+				 w+" for lookup "+i);
+	  }
+	
+	pool.removeAllElements();
+	
+	System.out.println("\nPass "+pass+" complete\n");
+      } // end pass loop
+  }
+} // DTMSafeStringPool
diff --git a/src/org/apache/xml/dtm/DTMStringPool.java b/src/org/apache/xml/dtm/DTMStringPool.java
new file mode 100644
index 0000000..fb97d1e
--- /dev/null
+++ b/src/org/apache/xml/dtm/DTMStringPool.java
@@ -0,0 +1,215 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999,2000 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xerces" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.apache.org.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.xml.dtm;
+import org.apache.xml.utils.IntVector;
+import java.util.Vector;
+
+/** <p>DTMStringPool is an "interning" mechanism for strings. It will
+ * create a stable 1:1 mapping between a set of string values and a set of
+ * integer index values, so the integers can be used to reliably and
+ * uniquely identify (and when necessary retrieve) the strings.</p>
+ *
+ * <p>Design Priorities:
+ * <ul>
+ * <li>String-to-index lookup speed is critical.</li>
+ * <li>Index-to-String lookup speed is slightly less so.</li>
+ * <li>Threadsafety is not guaranteed at this level.
+ * Enforce that in the application if needed.</li>
+ * <li>Storage efficiency is an issue but not a huge one.
+ * It is expected that string pools won't exceed about 2000 entries.</li>
+ * </ul>
+ * </p>
+ *
+ * <p>Implementation detail: A standard Hashtable is relatively
+ * inefficient when looking up primitive int values, especially when
+ * we're already maintaining an int-to-string vector.  So I'm
+ * maintaining a simple hash chain within this class.</p>
+ *
+ * <p>NOTE: There is nothing in the code that has a real dependency upon
+ * String. It would work with any object type that implements reliable
+ * .hashCode() and .equals() operations. The API enforces Strings because
+ * it's safer that way, but this could trivially be turned into a general
+ * ObjectPool if one was needed.</p>
+ *
+ * <p>Status: Passed basic test in main().</p>
+ * */
+public class DTMStringPool
+{
+  Vector m_intToString;
+  static final int HASHPRIME=101;
+  int[] m_hashStart=new int[HASHPRIME];
+  IntVector m_hashChain;
+  public static final int NULL=-1;
+
+  public DTMStringPool()
+    {
+      m_intToString=new Vector();
+      m_hashChain=new IntVector();
+      removeAllElements();
+      
+      // -sb Add this to force empty strings to be index 0.
+      stringToIndex("");
+    }
+  
+  public void removeAllElements()
+    {
+      m_intToString.removeAllElements();
+      for(int i=0;i<HASHPRIME;++i)
+        m_hashStart[i]=NULL;
+      m_hashChain.removeAllElements();
+    }
+
+  /** @return string whose value is uniquely identified by this integer index.
+   * @throws java.lang.ArrayIndexOutOfBoundsException
+   *  if index doesn't map to a string.
+   * */ 
+  public String indexToString(int i)
+    throws java.lang.ArrayIndexOutOfBoundsException
+    {
+      if(i==NULL) return null;
+      return (String) m_intToString.elementAt(i);
+    }
+
+  /** @return integer index uniquely identifying the value of this string. */ 
+  public int stringToIndex(String s)
+    {
+      if(s==null) return NULL;
+      
+      int hashslot=s.hashCode()%HASHPRIME;
+      if(hashslot<0) hashslot=-hashslot;
+
+      // Is it one we already know?
+      int hashlast=m_hashStart[hashslot];
+      int hashcandidate=hashlast;
+      while(hashcandidate!=NULL)
+        {
+          if(m_intToString.elementAt(hashcandidate).equals(s))
+            return hashcandidate;
+
+          hashlast=hashcandidate;
+          hashcandidate=m_hashChain.elementAt(hashcandidate);
+        }
+      
+      // New value. Add to tables.
+      int newIndex=m_intToString.size();
+      m_intToString.addElement(s);
+
+      m_hashChain.addElement(NULL);	// Initialize to no-following-same-hash
+      if(hashlast==NULL)  // First for this hash
+        m_hashStart[hashslot]=newIndex;
+      else // Link from previous with same hash
+        m_hashChain.setElementAt(newIndex,hashlast);
+
+      return newIndex;
+    }
+
+  /** Command-line unit test driver. This test relies on the fact that
+   * this version of the pool assigns indices consecutively, starting
+   * from zero, as new unique strings are encountered.
+   */
+  public static void main(String[] args)
+  {
+    String[] word={
+      "Zero","One","Two","Three","Four","Five",
+      "Six","Seven","Eight","Nine","Ten",
+      "Eleven","Twelve","Thirteen","Fourteen","Fifteen",
+      "Sixteen","Seventeen","Eighteen","Nineteen","Twenty",
+      "Twenty-One","Twenty-Two","Twenty-Three","Twenty-Four",
+      "Twenty-Five","Twenty-Six","Twenty-Seven","Twenty-Eight",
+      "Twenty-Nine","Thirty","Thirty-One","Thirty-Two",
+      "Thirty-Three","Thirty-Four","Thirty-Five","Thirty-Six",
+      "Thirty-Seven","Thirty-Eight","Thirty-Nine"};
+
+    DTMStringPool pool=new DTMStringPool();
+
+    System.out.println("If no complaints are printed below, we passed initial test.");
+
+    for(int pass=0;pass<=1;++pass)
+      {
+        int i;
+
+        for(i=0;i<word.length;++i)
+          {
+            int j=pool.stringToIndex(word[i]);
+            if(j!=i)
+              System.out.println("\tMismatch populating pool: assigned "+
+                                 j+" for create "+i);
+          }
+
+        for(i=0;i<word.length;++i)
+          {
+            int j=pool.stringToIndex(word[i]);
+            if(j!=i)
+              System.out.println("\tMismatch in stringToIndex: returned "+
+                                 j+" for lookup "+i);
+          }
+
+        for(i=0;i<word.length;++i)
+          {
+            String w=pool.indexToString(i);
+            if(!word[i].equals(w))
+              System.out.println("\tMismatch in indexToString: returned"+
+                                 w+" for lookup "+i);
+          }
+        
+        pool.removeAllElements();
+        
+        System.out.println("\nPass "+pass+" complete\n");
+      } // end pass loop
+  }
+}
diff --git a/src/org/apache/xml/dtm/DTMTreeWalker.java b/src/org/apache/xml/dtm/DTMTreeWalker.java
new file mode 100644
index 0000000..05b8b68
--- /dev/null
+++ b/src/org/apache/xml/dtm/DTMTreeWalker.java
@@ -0,0 +1,433 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xml.dtm;
+
+import org.w3c.dom.*;
+
+import org.xml.sax.*;
+import org.xml.sax.ext.LexicalHandler;
+
+import org.apache.xml.utils.NodeConsumer;
+import org.apache.xml.utils.XMLString;
+
+/**
+ * <meta name="usage" content="advanced"/>
+ * This class does a pre-order walk of the DTM tree, calling a ContentHandler
+ * interface as it goes.
+ * I think normally this class should not be needed, because 
+ * of DTM#dispatchToEvents.
+ */
+public class DTMTreeWalker
+{
+
+  /** Local reference to a ContentHandler          */
+  private ContentHandler m_contentHandler = null;
+
+  /** DomHelper for this TreeWalker          */
+  protected DTM m_dtm;
+  
+  /**
+   * Set the DTM to be traversed.
+   * 
+   * @param dtm The Document Table Model to be used.
+   */
+  public void setDTM(DTM dtm)
+  {
+    m_dtm = dtm;
+  }
+
+  /**
+   * Get the ContentHandler used for the tree walk.
+   *
+   * @return the ContentHandler used for the tree walk
+   */
+  public ContentHandler getcontentHandler()
+  {
+    return m_contentHandler;
+  }
+  
+  /**
+   * Set the ContentHandler used for the tree walk.
+   *
+   * @param ch the ContentHandler to be the result of the tree walk.
+   */
+  public void setcontentHandler(ContentHandler ch)
+  {
+    m_contentHandler = ch;
+  }
+
+  
+  /**
+   * Constructor.
+   * @param   contentHandler The implemention of the
+   * contentHandler operation (toXMLString, digest, ...)
+   */
+  public DTMTreeWalker()
+  {
+  }
+  
+  /**
+   * Constructor.
+   * @param   contentHandler The implemention of the
+   * contentHandler operation (toXMLString, digest, ...)
+   */
+  public DTMTreeWalker(ContentHandler contentHandler, DTM dtm)
+  {
+    this.m_contentHandler = contentHandler;
+    m_dtm = dtm;
+  }
+  
+  /**
+   * Perform a pre-order traversal non-recursive style.
+   *
+   * @param pos Node in the tree where to start traversal
+   *
+   * @throws TransformerException
+   */
+  public void traverse(int pos) throws org.xml.sax.SAXException
+  {
+
+    int top = pos;
+
+    while (DTM.NULL != pos)
+    {
+      startNode(pos);
+
+      int nextNode = m_dtm.getFirstChild(pos);
+
+      while (DTM.NULL == nextNode)
+      {
+        endNode(pos);
+
+        if (top == pos)
+          break;
+
+        nextNode = m_dtm.getNextSibling(pos);
+
+        if (DTM.NULL == nextNode)
+        {
+          pos = m_dtm.getParent(pos);
+
+          if ((DTM.NULL == pos) || (top == pos))
+          {
+            if (DTM.NULL != pos)
+              endNode(pos);
+
+            nextNode = DTM.NULL;
+
+            break;
+          }
+        }
+      }
+
+      pos = nextNode;
+    }
+  }
+
+  /**
+   * Perform a pre-order traversal non-recursive style.
+   *
+   * @param pos Node in the tree where to start traversal
+   * @param top Node in the tree where to end traversal
+   *
+   * @throws TransformerException
+   */
+  public void traverse(int pos, int top) throws org.xml.sax.SAXException
+  {
+
+    while (DTM.NULL != pos)
+    {
+      startNode(pos);
+
+      int nextNode = m_dtm.getFirstChild(pos);
+
+      while (DTM.NULL == nextNode)
+      {
+        endNode(pos);
+
+        if ((DTM.NULL != top) && top == pos)
+          break;
+
+        nextNode = m_dtm.getNextSibling(pos);
+
+        if (DTM.NULL == nextNode)
+        {
+          pos = m_dtm.getParent(pos);
+
+          if ((DTM.NULL == pos) || ((DTM.NULL != top) && (top == pos)))
+          {
+            nextNode = DTM.NULL;
+
+            break;
+          }
+        }
+      }
+
+      pos = nextNode;
+    }
+  }
+
+  /** Flag indicating whether following text to be processed is raw text          */
+  boolean nextIsRaw = false;
+  
+  /**
+   * Optimized dispatch of characters.
+   */
+  private final void dispatachChars(int node)
+     throws org.xml.sax.SAXException
+  {
+    m_dtm.dispatchCharactersEvents(node, m_contentHandler);
+  }
+
+  /**
+   * Start processing given node
+   *
+   *
+   * @param node Node to process
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  protected void startNode(int node) throws org.xml.sax.SAXException
+  {
+
+    if (m_contentHandler instanceof NodeConsumer)
+    {
+      // %TBD%
+//      ((NodeConsumer) m_contentHandler).setOriginatingNode(node);
+    }
+
+    switch (m_dtm.getNodeType(node))
+    {
+    case DTM.COMMENT_NODE :
+    {
+      XMLString data = m_dtm.getStringValue(node);
+
+      if (m_contentHandler instanceof LexicalHandler)
+      {
+        LexicalHandler lh = ((LexicalHandler) this.m_contentHandler);
+        data.dispatchAsComment(lh);
+      }
+    }
+    break;
+    case DTM.DOCUMENT_FRAGMENT_NODE :
+
+      // ??;
+      break;
+    case DTM.DOCUMENT_NODE :
+      this.m_contentHandler.startDocument();
+      break;
+    case DTM.ELEMENT_NODE :
+      DTM dtm = m_dtm;           
+
+      for (int nsn = dtm.getFirstNamespaceNode(node, true); DTM.NULL != nsn;
+           nsn = dtm.getNextNamespaceNode(node, nsn, true))
+      {
+        // String prefix = dtm.getPrefix(nsn);
+        String prefix = dtm.getNodeNameX(nsn);
+
+        this.m_contentHandler.startPrefixMapping(prefix, dtm.getNodeValue(nsn));
+        
+      }
+
+      // System.out.println("m_dh.getNamespaceOfNode(node): "+m_dh.getNamespaceOfNode(node));
+      // System.out.println("m_dh.getLocalNameOfNode(node): "+m_dh.getLocalNameOfNode(node));
+      String ns = dtm.getNamespaceURI(node);
+      if(null == ns)
+        ns = "";
+        
+      // %OPT% !!
+      org.xml.sax.helpers.AttributesImpl attrs = 
+                            new org.xml.sax.helpers.AttributesImpl();
+              
+      for (int i = dtm.getFirstAttribute(node); 
+           i != DTM.NULL; 
+           i = dtm.getNextAttribute(i)) 
+      {
+        attrs.addAttribute(dtm.getNamespaceURI(i), 
+                           dtm.getLocalName(i), 
+                           dtm.getNodeName(i), 
+                           "CDATA", 
+                           dtm.getNodeValue(i));
+      }
+      
+        
+      this.m_contentHandler.startElement(ns,
+                                         m_dtm.getLocalName(node),
+                                         m_dtm.getNodeName(node),
+                                         attrs);
+      break;
+    case DTM.PROCESSING_INSTRUCTION_NODE :
+    {
+      String name = m_dtm.getNodeName(node);
+
+      // String data = pi.getData();
+      if (name.equals("xslt-next-is-raw"))
+      {
+        nextIsRaw = true;
+      }
+      else
+      {
+        this.m_contentHandler.processingInstruction(name,
+                                                    m_dtm.getNodeValue(node));
+      }
+    }
+    break;
+    case DTM.CDATA_SECTION_NODE :
+    {
+      boolean isLexH = (m_contentHandler instanceof LexicalHandler);
+      LexicalHandler lh = isLexH
+                          ? ((LexicalHandler) this.m_contentHandler) : null;
+
+      if (isLexH)
+      {
+        lh.startCDATA();
+      }
+      
+      dispatachChars(node);
+
+      {
+        if (isLexH)
+        {
+          lh.endCDATA();
+        }
+      }
+    }
+    break;
+    case DTM.TEXT_NODE :
+    {
+      if (nextIsRaw)
+      {
+        nextIsRaw = false;
+
+        m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
+        dispatachChars(node);
+        m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
+      }
+      else
+      {
+        dispatachChars(node);
+      }
+    }
+    break;
+    case DTM.ENTITY_REFERENCE_NODE :
+    {
+      if (m_contentHandler instanceof LexicalHandler)
+      {
+        ((LexicalHandler) this.m_contentHandler).startEntity(
+          m_dtm.getNodeName(node));
+      }
+      else
+      {
+
+        // warning("Can not output entity to a pure SAX ContentHandler");
+      }
+    }
+    break;
+    default :
+    }
+  }
+
+  /**
+   * End processing of given node 
+   *
+   *
+   * @param node Node we just finished processing
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  protected void endNode(int node) throws org.xml.sax.SAXException
+  {
+
+    switch (m_dtm.getNodeType(node))
+    {
+    case DTM.DOCUMENT_NODE :
+      this.m_contentHandler.endDocument();
+      break;
+    case DTM.ELEMENT_NODE :
+      String ns = m_dtm.getNamespaceURI(node);
+      if(null == ns)
+        ns = "";
+      this.m_contentHandler.endElement(ns,
+                                         m_dtm.getLocalName(node),
+                                         m_dtm.getNodeName(node));
+
+      for (int nsn = m_dtm.getFirstNamespaceNode(node, true); DTM.NULL != nsn;
+           nsn = m_dtm.getNextNamespaceNode(node, nsn, true))
+      {
+        // String prefix = m_dtm.getPrefix(nsn);
+        String prefix = m_dtm.getNodeNameX(nsn);
+
+        this.m_contentHandler.endPrefixMapping(prefix);
+      }
+      break;
+    case DTM.CDATA_SECTION_NODE :
+      break;
+    case DTM.ENTITY_REFERENCE_NODE :
+    {
+      if (m_contentHandler instanceof LexicalHandler)
+      {
+        LexicalHandler lh = ((LexicalHandler) this.m_contentHandler);
+
+        lh.endEntity(m_dtm.getNodeName(node));
+      }
+    }
+    break;
+    default :
+    }
+  }
+}  //TreeWalker
+
diff --git a/src/org/apache/xml/dtm/DTMWSFilter.java b/src/org/apache/xml/dtm/DTMWSFilter.java
new file mode 100644
index 0000000..c62e6f7
--- /dev/null
+++ b/src/org/apache/xml/dtm/DTMWSFilter.java
@@ -0,0 +1,36 @@
+package org.apache.xml.dtm;
+
+/**
+ * This interface is meant to be implemented by a client of the DTM, and allows
+ * stripping of whitespace nodes.
+ */
+public interface DTMWSFilter
+{
+  /**
+   * Do not strip whitespace child nodes of this element.
+   */
+  public static final short NOTSTRIP = 1;
+
+  /**
+   * Strip whitespace child nodes of this element.
+   */
+  public static final short STRIP = 2;
+
+  /**
+   * Inherit whitespace stripping behavior of the parent node.
+   */
+  public static final short INHERIT = 3;
+
+  /**
+   * Test whether whitespace-only text nodes are visible in the logical 
+   * view of <code>DTM</code>. Normally, this function
+   * will be called by the implementation of <code>DTM</code>; 
+   * it is not normally called directly from
+   * user code.
+   * 
+   * @param elementHandle int Handle of the element.
+   * @return one of NOTSTRIP, STRIP, or INHERIT.
+   */
+  public short getShouldStripSpace(int elementHandle);
+  
+}
\ No newline at end of file
diff --git a/src/org/apache/xml/dtm/ExpandedNameTable.java b/src/org/apache/xml/dtm/ExpandedNameTable.java
new file mode 100644
index 0000000..ef66cf0
--- /dev/null
+++ b/src/org/apache/xml/dtm/ExpandedNameTable.java
@@ -0,0 +1,191 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xml.dtm;
+
+/**
+ * This is a default implementation of a table that manages mappings from
+ * expanded names to expandedNameIDs.
+ *
+ * %REVIEW% Note that this is not really a separate table, or a
+ * separate pool. Instead, it's an access method build on top of the
+ * existing pools, using three pieces of information: the index
+ * numbers for a node's namespaceURI, localName, and node type, which
+ * are combined to yield a composite index number.
+ *
+ * %TBD% startup sequence -- how this gets access to the appropriate
+ * string pools in the DTMDocument/stylesheet.
+ *
+ * */
+public class ExpandedNameTable
+{
+
+  /** Probably a reference to static pool.     */
+  private DTMStringPool m_locNamesPool;
+
+  /** Probably a reference to static pool.   */
+  private DTMStringPool m_namespaceNames;
+  
+  public static int BITS_PER_LOCALNAME = 16;
+  public static int BITS_PER_NAMESPACE = 10;
+
+  public static int MASK_LOCALNAME = 0x0000FFFF;
+  public static int MASK_NAMESPACE = 0x03FF0000;
+  public static int MASK_NODETYPE = 0xFC000000;
+
+  /**
+   * Create an expanded name table that uses private string pool lookup.
+   */
+  public ExpandedNameTable()
+  {
+    m_locNamesPool = new DTMSafeStringPool();
+    m_namespaceNames = new DTMSafeStringPool();
+  }
+
+  /**
+   * Constructor ExpandedNameTable
+   *
+   * @param locNamesPool Local element names lookup.
+   * @param namespaceNames Namespace values lookup.
+   */
+  public ExpandedNameTable(DTMStringPool locNamesPool,
+                           DTMStringPool namespaceNames)
+  {
+    m_locNamesPool = locNamesPool;
+    m_namespaceNames = namespaceNames;
+  }
+
+  /**
+   * Given an expanded name, return an ID.  If the expanded-name does not
+   * exist in the internal tables, the entry will be created, and the ID will
+   * be returned.  Any additional nodes that are created that have this
+   * expanded name will use this ID.
+   *
+   * @param namespace
+   * @param localName
+   *
+   * @return the expanded-name id of the node.
+   */
+  public int getExpandedNameID(String namespace, String localName, int type)
+  {
+    int nsID = (null != namespace) ? m_namespaceNames.stringToIndex(namespace) : 0;
+    int lnID = m_locNamesPool.stringToIndex(localName);
+    
+    int expandedTypeID = (type << (BITS_PER_NAMESPACE+BITS_PER_LOCALNAME)) 
+                       | (nsID << BITS_PER_LOCALNAME) | lnID;
+
+    return expandedTypeID;
+  }
+  
+  /**
+   * Given a type, return an expanded name ID.Any additional nodes that are 
+   * created that have this expanded name will use this ID.
+   *
+   * @param namespace
+   * @param localName
+   *
+   * @return the expanded-name id of the node.
+   */
+  public int getExpandedNameID(int type)
+  {
+    int expandedTypeID = (type << (BITS_PER_NAMESPACE+BITS_PER_LOCALNAME));
+
+    return expandedTypeID;
+  }
+
+  /**
+   * Given an expanded-name ID, return the local name part.
+   *
+   * @param ExpandedNameID an ID that represents an expanded-name.
+   * @return String Local name of this node, or null if the node has no name.
+   */
+  public String getLocalName(int ExpandedNameID)
+  {
+    int localNameID = (ExpandedNameID & MASK_LOCALNAME);
+    
+    if (0 == localNameID) 
+      return null;
+    else
+      return m_locNamesPool.indexToString(localNameID);
+  }
+
+  /**
+   * Given an expanded-name ID, return the namespace URI part.
+   *
+   * @param ExpandedNameID an ID that represents an expanded-name.
+   * @return String URI value of this node's namespace, or null if no
+   * namespace was resolved.
+   */
+  public String getNamespace(int ExpandedNameID)
+  {
+
+    int id = (ExpandedNameID & MASK_NAMESPACE) >> BITS_PER_LOCALNAME;
+    return (0 == id) ? null : m_namespaceNames.indexToString(id);
+  }
+
+  /**
+   * Given an expanded-name ID, return the namespace URI part.
+   *
+   * @param ExpandedNameID an ID that represents an expanded-name.
+   * @return String URI value of this node's namespace, or null if no
+   * namespace was resolved.
+   */
+  public int getType(int ExpandedNameID)
+  {
+
+    return ((ExpandedNameID & MASK_NAMESPACE) >> (BITS_PER_LOCALNAME+BITS_PER_NAMESPACE));
+  }
+}
diff --git a/src/org/apache/xml/dtm/TestDTM.java b/src/org/apache/xml/dtm/TestDTM.java
new file mode 100644
index 0000000..cc3c9ea
--- /dev/null
+++ b/src/org/apache/xml/dtm/TestDTM.java
@@ -0,0 +1,116 @@
+package org.apache.xml.dtm;
+
+import org.apache.xml.dtm.DTMDocumentImpl;
+import org.apache.xml.dtm.TestDTMNodes;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * Tests the DTM by creating
+ *
+ * REWRITTEN to use SAX2 ContentHandler APIs -- original draft used
+ * an incomplete/incorrect version of SAX1 DocumentHandler, which is
+ * being phased out as quickly as we can possibly manage it.
+ *
+ * %TBD% I _think_ the SAX convention is that "no namespace" is expressed
+ * as "" rather than as null (which is the DOM's convention). What should 
+ * DTM expect? What should it do with the other?
+ */
+public class TestDTM {
+
+  public static void main(String argv[]) {
+    String text;
+
+    /*  <?xml version="1.0"?>
+     *  <top>
+     *   <A>
+     *    <B hat="new" car="Honda" dog="Boxer">Life is good</B>
+     *   </A>
+     *   <C>My Anaconda<D/>Words</C>
+     *  </top> */
+
+    DTMDocumentImpl doc = new DTMDocumentImpl(null, 0, null, 
+                    org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());
+
+    try
+      {
+        doc.startDocument();
+
+        doc.startElement("", "top", "top", null);
+
+        doc.startElement("", "A", "A", null);
+
+        AttributesImpl atts = new AttributesImpl();
+        atts.addAttribute("", "", "hat", "CDATA", "new");
+        atts.addAttribute("", "", "car", "CDATA", "Honda");
+        atts.addAttribute("", "", "dog", "CDATA", "Boxer");
+        doc.startElement("","B","B", atts);
+        text="Life is good";
+        doc.characters(text.toCharArray(),0,text.length());
+        doc.endElement("","B","B");
+
+        doc.endElement("","A","A");
+        doc.startElement("","C","C", null);
+
+        text="My Anaconda";
+        doc.characters(text.toCharArray(),0,text.length());
+        doc.startElement("","D","D",null);
+        doc.endElement("","D","D");
+        text="Words";
+        doc.characters(text.toCharArray(),0,text.length());
+
+        doc.endElement("", "C", "C");
+
+        boolean BUILDPURCHASEORDER=false;
+        if(BUILDPURCHASEORDER)
+          {
+            int root, h, c1, c2, c3, c4, c1_text, c2_text, c3_text, c4_text;
+
+            doc.startElement(null,"PurchaseOrderList","PurchaseOrderList", null);
+
+            for (int i = 0; i < 10; i++) {
+
+              doc.startElement("","PurchaseOrder","PurchaseOrder", null);
+
+              doc.startElement("","Item","Item", null);
+              text="Basketball" + " - " + i;
+              doc.characters(text.toCharArray(),0,text.length());
+                      
+              doc.endElement("", "Item", "Item");
+
+              doc.startElement("","Description","Description", null);
+              // c2.createAttribute();
+              text="Professional Leather Michael Jordan Signatured Basketball";
+              doc.characters(text.toCharArray(),0,text.length());
+                      
+              doc.endElement("", "Description", "Description");
+
+              doc.startElement("","UnitPrice","UnitPrice", null);
+              text="$12.99";
+              doc.characters(text.toCharArray(),0,text.length());
+                      
+              doc.endElement("", "UnitPrice", "UnitPrice");
+
+              doc.startElement("","Quantity","Quantity", null);
+              text="50";
+              doc.characters(text.toCharArray(),0,text.length());
+                      
+              doc.endElement("", "Quantity", "Quantity");
+
+              doc.endElement("", "PurchaseOrder", "PurchaseOrder");
+            }
+
+            doc.endElement("", "PurchaseOrderList", "PurchaseOrderList");
+          } // if(BUILDPURCHASEORDER)
+
+        doc.endElement("", "top", "top");
+        doc.endDocument();
+      }
+    catch(org.xml.sax.SAXException e)
+      {
+        e.printStackTrace();
+      }
+                
+
+    TestDTMNodes.printNodeTable(doc);
+  }
+}
diff --git a/src/org/apache/xml/dtm/TestDTMNodes.java b/src/org/apache/xml/dtm/TestDTMNodes.java
new file mode 100644
index 0000000..34c94c0
--- /dev/null
+++ b/src/org/apache/xml/dtm/TestDTMNodes.java
@@ -0,0 +1,32 @@
+package org.apache.xml.dtm;
+
+import org.apache.xml.dtm.ChunkedIntArray;
+
+/** Debugging dump routine for DTMDocumentImpl. Note that it directly accesses
+ * that class's internal data... which probably shouldn't be exposed.
+ */
+public class TestDTMNodes {
+
+  public static void printNodeTable(DTMDocumentImpl doc) {
+    int length = doc.nodes.slotsUsed(), slot[] = new int[4];
+    for (int i=0; i <= length; i++) {
+      doc.nodes.readSlot(i, slot);
+
+      // Word0 is shown as its two halfwords
+      short high = (short) (slot[0] >> 16);
+      short low = (short) (slot[0] & 0xFFFF);
+
+      System.out.println(i + ": (" + high + ") (" + low +
+			 ") " + slot[1] + " " + slot[2] +
+			 " " +slot[3] +
+			 "\n\tName: " +  doc.getNodeName(i) +
+			 " Value: " + doc.getNodeValue(i) +
+			 " Parent: " + doc.getParent(i) +
+			 " FirstAttr: " + doc.getFirstAttribute(i) +
+			 " FirstChild: " + doc.getFirstChild(i) +
+			 " NextSib: " + doc.getNextSibling(i)
+			 ); 
+    }
+
+  }
+}
diff --git a/src/org/apache/xml/dtm/dom2dtm/DOM2DTM.java b/src/org/apache/xml/dtm/dom2dtm/DOM2DTM.java
new file mode 100644
index 0000000..dcb1427
--- /dev/null
+++ b/src/org/apache/xml/dtm/dom2dtm/DOM2DTM.java
@@ -0,0 +1,1364 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xml.dtm.dom2dtm;
+
+import org.apache.xml.dtm.*;
+import org.apache.xml.utils.IntVector;
+import org.apache.xml.utils.IntStack;
+import org.apache.xml.utils.BoolStack;
+import org.apache.xml.utils.StringBufferPool;
+import org.apache.xml.utils.FastStringBuffer;
+import org.apache.xml.utils.TreeWalker;
+import org.apache.xml.utils.QName;
+import org.apache.xml.utils.XMLCharacterRecognizer;
+
+import org.w3c.dom.*;
+
+import java.util.Vector;
+
+import javax.xml.transform.dom.DOMSource;
+import org.xml.sax.ContentHandler;
+
+import org.apache.xml.utils.NodeVector;
+
+import org.apache.xml.utils.XMLString;
+import org.apache.xml.utils.XMLStringFactory;
+
+/**
+ * The <code>DOM2DTM</code> class serves up a DOM via a DTM API.
+ */
+public class DOM2DTM extends DTMDefaultBase
+{
+  /**
+   * This represents the number of integers per node in the
+   * <code>m_info</code> member variable.
+   */
+  protected static final int NODEINFOBLOCKSIZE = DEFAULTNODEINFOBLOCKSIZE;
+
+  /** The top of the subtree, may not be the same as m_context if "//foo" pattern. */
+  transient private Node m_root;
+
+  /** The current position in the tree. */
+  transient private Node m_pos;
+
+  /** true if all the nodes have been processed. */
+  transient private boolean m_nodesAreProcessed;
+
+  /**
+   * %TBD% Needs doc... how to explain?
+   * [0] index of parent.
+   * [1] index of previous sibling.
+   */
+  transient private IntStack m_levelInfo = new IntStack();
+
+  /**
+   * %TBD% Doc
+   */
+  transient private NamedNodeMap m_attrs;
+
+  /**
+   * %TBD% Doc
+   */
+  transient private int m_attrsPos;
+
+  /** NEEDSDOC Field LEVELINFO_PARENT */
+  static final int LEVELINFO_PARENT = 1;
+
+  /** NEEDSDOC Field LEVELINFO_PREVSIB */
+  static final int LEVELINFO_PREVSIB = 0;
+
+  /** NEEDSDOC Field LEVELINFO_NPERLEVEL */
+  static final int LEVELINFO_NPERLEVEL = 2;
+  
+  /** Samed element for attribute iteration */
+  private Node m_elementForAttrs;
+  
+  /** Samed element index for attribute iteration */
+  private int m_elementForAttrsIndex;
+
+  /**
+   * The node objects.  The instance part of the handle indexes directly
+   * into this vector.  Each DTM node may actually be composed of several
+   * DOM nodes.
+   */
+  protected Vector m_nodes = new Vector();
+
+  /**
+   * Construct a DOM2DTM object from a DOM node.
+   *
+   * @param mgr The DTMManager who owns this DTM.
+   * @param domSource the DOM source that this DTM will wrap.
+   * @param dtmIdentity The DTM identity ID for this DTM.
+   * @param whiteSpaceFilter The white space filter for this DTM, which may 
+   *                         be null.
+   */
+  public DOM2DTM(DTMManager mgr, DOMSource domSource, 
+                 int dtmIdentity, DTMWSFilter whiteSpaceFilter,
+                 XMLStringFactory xstringfactory)
+  {
+    super(mgr, domSource, dtmIdentity, whiteSpaceFilter, xstringfactory);
+
+    m_root = domSource.getNode();
+    m_pos = null;
+    m_nodesAreProcessed = false;
+    addNode(m_root, 0, DTM.NULL, DTM.NULL);
+  }
+
+  /**
+   * Construct the node map from the node.
+   *
+   * @param node The node that is to be added to the DTM.
+   * @param level The current level in the tree.
+   * @param parentIndex The current parent index.
+   * @param previousSibling The previous sibling index.
+   *
+   * @return The index identity of the node that was added.
+   */
+  protected int addNode(Node node, int level, int parentIndex,
+                        int previousSibling)
+  {
+
+    int nodeIndex = m_nodes.size();
+    
+    int type = node.getNodeType();
+    
+    m_nodes.addElement(node);
+
+    int startInfo = nodeIndex * NODEINFOBLOCKSIZE;
+
+    m_info.addElements(NODEINFOBLOCKSIZE);
+    m_info.setElementAt(level, startInfo + OFFSET_LEVEL);
+
+    if (Node.ATTRIBUTE_NODE == type)
+    {
+      String name = node.getNodeName();
+
+      if (name.startsWith("xmlns:") || name.equals("xmlns"))
+      {
+        type = DTM.NAMESPACE_NODE;
+      }
+    }
+
+    m_info.setElementAt(type, startInfo + OFFSET_TYPE);
+    m_info.setElementAt(NOTPROCESSED, startInfo + OFFSET_FIRSTCHILD);
+    m_info.setElementAt(NOTPROCESSED, startInfo + OFFSET_NEXTSIBLING);
+    m_info.setElementAt(previousSibling, startInfo + OFFSET_PREVSIBLING);
+    m_info.setElementAt(parentIndex, startInfo + OFFSET_PARENT);
+    
+    if(DTM.NULL != parentIndex && type != DTM.ATTRIBUTE_NODE && type != DTM.NAMESPACE_NODE)
+    {
+      int startParentInfo = parentIndex * NODEINFOBLOCKSIZE;
+      if(NOTPROCESSED == m_info.elementAt(startParentInfo + OFFSET_FIRSTCHILD))
+      {
+        m_info.setElementAt(nodeIndex, startParentInfo + OFFSET_FIRSTCHILD);
+      }
+    }
+    
+    String nsURI = node.getNamespaceURI();
+    String localName =  (type == Node.PROCESSING_INSTRUCTION_NODE) ? 
+                         node.getNodeName() :
+                         node.getLocalName();
+    ExpandedNameTable exnt = m_mgr.getExpandedNameTable(this);
+
+    int expandedNameID = (null != localName) 
+       ? exnt.getExpandedNameID(nsURI, localName, type) :
+         exnt.getExpandedNameID(type);
+
+    m_info.setElementAt(expandedNameID, startInfo + OFFSET_EXPANDEDNAMEID);    
+
+    if (DTM.NULL != previousSibling)
+    {
+      m_info.setElementAt(nodeIndex,
+                          (previousSibling * NODEINFOBLOCKSIZE)
+                          + OFFSET_NEXTSIBLING);
+    }
+
+    return nodeIndex;
+  }
+  
+  /**
+   * Return the number of integers in each node info block.
+   */
+  protected int getNodeInfoBlockSize()
+  {
+    return NODEINFOBLOCKSIZE;
+  }
+  
+  /**
+   * Get the number of nodes that have been added.
+   */
+  protected int getNumberOfNodes()
+  {
+    return m_nodes.size();
+  }
+
+
+  /**
+   * This method iterates to the next node that will be added to the table.
+   * Each call to this method adds a new node to the table, unless the end
+   * is reached, in which case it returns null.
+   *
+   * @return The true if a next node is found or false if 
+   *         there are no more nodes.
+   */
+  protected boolean nextNode()
+  {
+    // Non-recursive one-fetch-at-a-time depth-first traversal with 
+    // attribute/namespace nodes and white-space stripping.
+    // Yippee!  Not for the faint of heart.  I would be glad for 
+    // constructive suggestions on how to make this cleaner.
+
+    if (m_nodesAreProcessed)
+    {
+      return false;
+    }
+    
+    if(m_nodes.size() == 47)
+    {
+      int x = 5;
+      x++;
+    }
+
+    Node top = m_root;  // tells us when to stop.
+    Node pos = (null == m_pos) ? m_root : m_pos;
+
+    Node nextNode;
+    int type = pos.getNodeType();
+
+    int currentIndexHandle = m_nodes.size()-1;
+    int posInfo = currentIndexHandle * NODEINFOBLOCKSIZE;
+    
+    boolean shouldPushLevel = true;
+    if (Node.ELEMENT_NODE == type)
+    {
+      m_attrs = pos.getAttributes();
+      m_attrsPos = 0;
+
+      if (null != m_attrs)
+      {
+        if (m_attrsPos < m_attrs.getLength())
+        {
+          m_elementForAttrs = pos;
+          m_elementForAttrsIndex = currentIndexHandle;
+          nextNode = m_attrs.item(m_attrsPos);
+        }
+        else
+          nextNode = pos.getFirstChild();
+      }
+      else
+      {
+        nextNode = pos.getFirstChild();
+      }
+    }
+    else if (Node.ATTRIBUTE_NODE == type)
+    {
+      m_info.setElementAt(DTM.NULL, posInfo + OFFSET_FIRSTCHILD);
+      m_attrsPos++;
+
+      if (m_attrsPos < m_attrs.getLength())
+      {
+        nextNode = m_attrs.item(m_attrsPos);
+        shouldPushLevel = false;
+      }
+      else
+      {
+        m_info.setElementAt(DTM.NULL, posInfo + OFFSET_NEXTSIBLING); 
+        pos = m_elementForAttrs;
+        currentIndexHandle = m_elementForAttrsIndex;
+        posInfo = currentIndexHandle * NODEINFOBLOCKSIZE;
+        nextNode = pos.getFirstChild();
+        m_levelInfo.quickPop(LEVELINFO_NPERLEVEL);
+      }
+    }
+    else
+      nextNode = pos.getFirstChild();  
+     
+    // %TBD% Text node coalition.
+    if((null != m_wsfilter) && (null != nextNode) && getShouldStripWhitespace())
+    {
+      int t = nextNode.getNodeType();
+      
+      if((Node.CDATA_SECTION_NODE == t) || (Node.TEXT_NODE == t))
+      {
+        String data = nextNode.getNodeValue();
+        if(XMLCharacterRecognizer.isWhiteSpace(data))
+        {
+          nextNode = nextNode.getNextSibling();
+        }
+      }
+    }
+    if (shouldPushLevel && (null != nextNode))
+    {
+      m_levelInfo.push(currentIndexHandle); // parent
+      m_levelInfo.push(DTM.NULL); // previous sibling
+    }
+
+    while (null == nextNode)
+    {
+      if(m_info.elementAt(posInfo + OFFSET_FIRSTCHILD) == NOTPROCESSED)
+      {
+        m_info.setElementAt(DTM.NULL, posInfo + OFFSET_FIRSTCHILD);
+      }
+      
+      if (top.equals(pos))
+      {
+        m_info.setElementAt(DTM.NULL, posInfo + OFFSET_NEXTSIBLING);
+        break;
+      }
+      
+      nextNode = pos.getNextSibling();
+      if(null != nextNode && Node.DOCUMENT_TYPE_NODE == nextNode.getNodeType())
+      {
+        // Xerces
+        nextNode = nextNode.getNextSibling(); // just skip it.
+      }
+      
+      if(Node.ELEMENT_NODE == pos.getNodeType())
+      {
+        // I think this only has to be popped here, and not at getParent,
+        // oddly enough at first glance.
+        popShouldStripWhitespace();
+      }
+
+      // %TBD% Text node coalition.
+      if((null != nextNode) && (null != m_wsfilter) && getShouldStripWhitespace())
+      {
+        int t = nextNode.getNodeType();
+        
+        if((Node.CDATA_SECTION_NODE == t) || (Node.TEXT_NODE == t))
+        {
+          String data = nextNode.getNodeValue();
+          if(XMLCharacterRecognizer.isWhiteSpace(data))
+          {
+            nextNode = nextNode.getNextSibling();
+          }
+        }
+      }
+                  
+      if (null == nextNode)
+      {
+        m_info.setElementAt(DTM.NULL, posInfo + OFFSET_NEXTSIBLING);
+
+        currentIndexHandle = m_info.elementAt(posInfo + OFFSET_PARENT);
+        posInfo = currentIndexHandle * NODEINFOBLOCKSIZE;
+        m_levelInfo.quickPop(LEVELINFO_NPERLEVEL);
+        pos = pos.getParentNode();
+
+        if ((null == pos) || (top.equals(pos)))
+        {
+          m_info.setElementAt(DTM.NULL, posInfo + OFFSET_NEXTSIBLING);
+          nextNode = null;
+          // break;
+          m_nodesAreProcessed = true;
+          return false;
+        }
+      }
+        
+      
+    } // end while (null == nextNode) [for next sibling, parent]
+
+    pos = nextNode;
+
+    if (null != pos)
+    {
+      int level = m_levelInfo.size() / LEVELINFO_NPERLEVEL;
+      int newIndexHandle = 
+            addNode(pos, level, m_levelInfo.peek(LEVELINFO_PARENT),
+                m_levelInfo.peek(LEVELINFO_PREVSIB));
+
+      m_pos = pos;
+
+      int sz = m_levelInfo.size();
+
+      m_levelInfo.setElementAt(newIndexHandle,
+                               sz - (1 + LEVELINFO_PREVSIB));
+                               
+      if((null != m_wsfilter) && (Node.ELEMENT_NODE == pos.getNodeType()))
+      {
+        short wsv = m_wsfilter.getShouldStripSpace(newIndexHandle);
+        boolean shouldStrip = (DTMWSFilter.INHERIT == wsv) ? 
+                  getShouldStripWhitespace() : (DTMWSFilter.STRIP == wsv);
+        pushShouldStripWhitespace(shouldStrip);
+      }
+      return true;
+    }
+
+
+    m_nodesAreProcessed = true;
+    m_pos = null;
+    return false;
+  }
+
+  /**
+   * Return an DOM node for the given node.
+   *
+   * @param nodeHandle The node ID.
+   *
+   * @return A node representation of the DTM node.
+   */
+  public Node getNode(int nodeHandle)
+  {
+
+    int identity = nodeHandle & m_mask;
+
+    return (Node) m_nodes.elementAt(identity);
+  }
+
+  /**
+   * Get a Node from an identity index.
+   *
+   * NEEDSDOC @param nodeIdentity
+   *
+   * NEEDSDOC ($objectName$) @return
+   */
+  protected Node lookupNode(int nodeIdentity)
+  {
+    return (Node) m_nodes.elementAt(nodeIdentity);
+  }
+
+  /**
+   * Get the next node identity value in the list, and call the iterator
+   * if it hasn't been added yet.
+   *
+   * @param identity The node identity (index).
+   * @return identity+1, or DTM.NULL.
+   */
+  protected int getNextNodeIdentity(int identity)
+  {
+
+    identity += 1;
+
+    if (identity >= m_nodes.size())
+    {
+      if (!nextNode())
+        identity = DTM.NULL;
+    }
+
+    return identity;
+  }
+
+  /**
+   * Get the handle from a Node.
+   * <p>%OPT% This will be pretty slow.</p>
+   * 
+   * %REVIEW% This relies on being able to test node-identity via
+   * object-identity. DTM2DOM proxying is a great example of a case where
+   * that doesn't work. DOM Level 3 will provide the isSameNode() method
+   * to fix that, but until then this is going to be flaky.
+   *
+   * @param node A node, which may be null.
+   *
+   * @return The node handle or <code>DTM.NULL</code>.
+   */
+  private int getHandleFromNode(Node node)
+  {
+    if (null != node)
+    {
+      int len = m_nodes.size();
+      for (int i = 0; i < len; i++)
+	{
+	  if (m_nodes.elementAt(i) == node)
+	    return i | m_dtmIdent;
+	}
+    }
+
+    return DTM.NULL;
+  }
+
+  /** Get the handle from a Node. This is a more robust version of
+   * getHandleFromNode, intended to be usable by the public.
+   *
+   * <p>%OPT% This will be pretty slow.</p>
+   * 
+   * %REVIEW% This relies on being able to test node-identity via
+   * object-identity. DTM2DOM proxying is a great example of a case where
+   * that doesn't work. DOM Level 3 will provide the isSameNode() method
+   * to fix that, but until then this is going to be flaky.
+   *
+   * @param node A node, which may be null.
+   *
+   * @return The node handle or <code>DTM.NULL</code>.  */
+  public int getHandleOfNode(Node node)
+  {
+    if (null != node)
+    {
+      // Is Node actually within the same document? If not, don't search!
+      // This would be easier if m_root was always the Document node, but
+      // we decided to allow wrapping a DTM around a subtree.
+      if((m_root==node) ||
+	 (m_root.getNodeType()==DOCUMENT_NODE &&
+	  m_root==node.getOwnerDocument()) ||
+	 (m_root.getNodeType()!=DOCUMENT_NODE &&
+	  m_root.getOwnerDocument()==node.getOwnerDocument())
+	 )
+	{
+	  // If node _is_ in m_root's tree, find its handle
+	  //
+	  // %OPT% This check may be improved significantly when DOM
+	  // Level 3 nodeKey and relative-order tests become
+	  // available!
+	  for(Node cursor=node;
+	      cursor!=null;
+	      cursor=
+		(cursor.getNodeType()!=ATTRIBUTE_NODE)
+		? cursor.getParentNode()
+		: ((org.w3c.dom.Attr)cursor).getOwnerElement())
+	    {
+	      if(cursor==m_root)
+		// We know this node; find its handle.
+		return getHandleFromNode(node); 
+	    } // for ancestors of node
+	} // if node and m_root in same Document
+    } // if node!=null
+
+    return DTM.NULL;
+  }
+
+  /**
+   * Retrieves an attribute node by by qualified name and namespace URI.
+   *
+   * @param nodeHandle int Handle of the node upon which to look up this attribute..
+   * @param namespaceURI The namespace URI of the attribute to
+   *   retrieve, or null.
+   * @param name The local name of the attribute to
+   *   retrieve.
+   * @return The attribute node handle with the specified name (
+   *   <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such
+   *   attribute.
+   */
+  public int getAttributeNode(int nodeHandle, String namespaceURI,
+                              String name)
+  {
+
+    // %OPT% This is probably slower than it needs to be.
+    if (null == namespaceURI)
+      namespaceURI = "";
+
+    int type = getNodeType(nodeHandle);
+
+    if (DTM.ELEMENT_NODE == type)
+    {
+
+      // Assume that attributes immediately follow the element.
+      int identity = nodeHandle & m_mask;
+
+      while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
+      {
+        // Assume this can not be null.
+        type = getNodeType(identity);
+
+        if (type == DTM.ATTRIBUTE_NODE)
+        {
+          Node node = lookupNode(identity);
+          String nodeuri = node.getNamespaceURI();
+
+          if (null == nodeuri)
+            nodeuri = "";
+
+          String nodelocalname = node.getLocalName();
+
+          if (nodeuri.equals(namespaceURI) && name.equals(nodelocalname))
+            return identity | m_dtmIdent;
+        }
+        else if (DTM.NAMESPACE_NODE != type)
+        {
+          break;
+        }
+      }
+    }
+
+    return DTM.NULL;
+  }
+
+  /**
+   * Get the string-value of a node as a String object
+   * (see http://www.w3.org/TR/xpath#data-model
+   * for the definition of a node's string-value).
+   *
+   * @param nodeHandle The node ID.
+   *
+   * @return A string object that represents the string-value of the given node.
+   */
+  public XMLString getStringValue(int nodeHandle)
+  {
+
+    int type = getNodeType(nodeHandle);
+    Node node = getNode(nodeHandle);
+    // %TBD% If an element only has one text node, we should just use it 
+    // directly.
+    if(DTM.ELEMENT_NODE == type || DTM.DOCUMENT_NODE == type 
+    || DTM.DOCUMENT_FRAGMENT_NODE == type)
+    {
+      FastStringBuffer buf = StringBufferPool.get();
+      String s;
+  
+      try
+      {
+        getNodeData(node, buf);
+  
+        s = (buf.length() > 0) ? buf.toString() : "";
+      }
+      finally
+      {
+        StringBufferPool.free(buf);
+      }
+  
+      return m_xstrf.newstr( s );
+
+    }
+    return m_xstrf.newstr( node.getNodeValue() );
+  }
+  
+  /**
+   * Retrieve the text content of a DOM subtree, appending it into a
+   * user-supplied FastStringBuffer object. Note that attributes are
+   * not considered part of the content of an element.
+   * <p>
+   * There are open questions regarding whitespace stripping. 
+   * Currently we make no special effort in that regard, since the standard
+   * DOM doesn't yet provide DTD-based information to distinguish
+   * whitespace-in-element-context from genuine #PCDATA. Note that we
+   * should probably also consider xml:space if/when we address this.
+   * DOM Level 3 may solve the problem for us.
+   *
+   * @param node Node whose subtree is to be walked, gathering the
+   * contents of all Text or CDATASection nodes.
+   * @param buf FastStringBuffer into which the contents of the text
+   * nodes are to be concatenated.
+   */
+  protected static void getNodeData(Node node, FastStringBuffer buf)
+  {
+
+    switch (node.getNodeType())
+    {
+    case Node.DOCUMENT_FRAGMENT_NODE :
+    case Node.DOCUMENT_NODE :
+    case Node.ELEMENT_NODE :
+    {
+      for (Node child = node.getFirstChild(); null != child;
+              child = child.getNextSibling())
+      {
+        getNodeData(child, buf);
+      }
+    }
+    break;
+    case Node.TEXT_NODE :
+    case Node.CDATA_SECTION_NODE :
+      buf.append(node.getNodeValue());
+      break;
+    case Node.ATTRIBUTE_NODE :
+      buf.append(node.getNodeValue());
+      break;
+    case Node.PROCESSING_INSTRUCTION_NODE :
+      // warning(XPATHErrorResources.WG_PARSING_AND_PREPARING);        
+      break;
+    default :
+      // ignore
+      break;
+    }
+  }
+
+  /**
+   * Given a node handle, return its DOM-style node name. This will
+   * include names such as #text or #document.
+   *
+   * @param nodeHandle the id of the node.
+   * @return String Name of this node, which may be an empty string.
+   * %REVIEW% Document when empty string is possible...
+   * %REVIEW-COMMENT% It should never be empty, should it?
+   */
+  public String getNodeName(int nodeHandle)
+  {
+
+    Node node = getNode(nodeHandle);
+
+    // Assume non-null.
+    return node.getNodeName();
+  }
+
+  /**
+   * Given a node handle, return the XPath node name.  This should be
+   * the name as described by the XPath data model, NOT the DOM-style
+   * name.
+   *
+   * @param nodeHandle the id of the node.
+   * @return String Name of this node, which may be an empty string.
+   */
+  public String getNodeNameX(int nodeHandle)
+  {
+
+    String name;
+    short type = getNodeType(nodeHandle);
+
+    switch (type)
+    {
+    case DTM.NAMESPACE_NODE :
+    {
+      Node node = getNode(nodeHandle);
+
+      // assume not null.
+      name = node.getNodeName();
+      if(name.startsWith("xmlns:"))
+      {
+        name = QName.getLocalPart(name);
+      }
+      else if(name.equals("xmlns"))
+      {
+        name = "";
+      }
+    }
+    break;
+    case DTM.ATTRIBUTE_NODE :
+    case DTM.ELEMENT_NODE :
+    case DTM.ENTITY_REFERENCE_NODE :
+    case DTM.PROCESSING_INSTRUCTION_NODE :
+    {
+      Node node = getNode(nodeHandle);
+
+      // assume not null.
+      name = node.getNodeName();
+    }
+    break;
+    default :
+      name = "";
+    }
+
+    return name;
+  }
+
+  /**
+   * Given a node handle, return its XPath-style localname.
+   * (As defined in Namespaces, this is the portion of the name after any
+   * colon character).
+   *
+   * @param nodeHandle the id of the node.
+   * @return String Local name of this node.
+   */
+  public String getLocalName(int nodeHandle)
+  {
+
+    String name;
+    short type = getNodeType(nodeHandle);
+
+    switch (type)
+    {
+    case DTM.ATTRIBUTE_NODE :
+    case DTM.ELEMENT_NODE :
+    case DTM.ENTITY_REFERENCE_NODE :
+    case DTM.NAMESPACE_NODE :
+    case DTM.PROCESSING_INSTRUCTION_NODE :
+    {
+      Node node = getNode(nodeHandle);
+
+      // assume not null.
+      name = node.getLocalName();
+
+      if (null == name)
+      {
+        String qname = node.getNodeName();
+        int index = qname.indexOf(':');
+
+        name = (index < 0) ? qname : qname.substring(index + 1);
+      }
+    }
+    break;
+    default :
+      name = "";
+    }
+
+    return name;
+  }
+
+  /**
+   * Given a namespace handle, return the prefix that the namespace decl is
+   * mapping.
+   * Given a node handle, return the prefix used to map to the namespace.
+   *
+   * <p> %REVIEW% Are you sure you want "" for no prefix?  </p>
+   * <p> %REVIEW-COMMENT% I think so... not totally sure. -sb  </p>
+   *
+   * @param nodeHandle the id of the node.
+   * @return String prefix of this node's name, or "" if no explicit
+   * namespace prefix was given.
+   */
+  public String getPrefix(int nodeHandle)
+  {
+
+    String prefix;
+    short type = getNodeType(nodeHandle);
+
+    switch (type)
+    {
+    case DTM.NAMESPACE_NODE :
+    {
+      Node node = getNode(nodeHandle);
+
+      // assume not null.
+      String qname = node.getNodeName();
+      int index = qname.indexOf(':');
+
+      prefix = (index < 0) ? "" : qname.substring(index + 1);
+    }
+    break;
+    case DTM.ATTRIBUTE_NODE :
+    case DTM.ELEMENT_NODE :
+    {
+      Node node = getNode(nodeHandle);
+
+      // assume not null.
+      String qname = node.getNodeName();
+      int index = qname.indexOf(':');
+
+      prefix = (index < 0) ? "" : qname.substring(0, index);
+    }
+    break;
+    default :
+      prefix = "";
+    }
+
+    return prefix;
+  }
+
+  /**
+   * Given a node handle, return its DOM-style namespace URI
+   * (As defined in Namespaces, this is the declared URI which this node's
+   * prefix -- or default in lieu thereof -- was mapped to.)
+   *
+   * <p>%REVIEW% Null or ""? -sb</p>
+   *
+   * @param nodeHandle the id of the node.
+   * @return String URI value of this node's namespace, or null if no
+   * namespace was resolved.
+   */
+  public String getNamespaceURI(int nodeHandle)
+  {
+
+    String nsuri;
+    short type = getNodeType(nodeHandle);
+
+    switch (type)
+    {
+    case DTM.ATTRIBUTE_NODE :
+    case DTM.ELEMENT_NODE :
+    case DTM.ENTITY_REFERENCE_NODE :
+    case DTM.NAMESPACE_NODE :
+    case DTM.PROCESSING_INSTRUCTION_NODE :
+    {
+      Node node = getNode(nodeHandle);
+
+      // assume not null.
+      nsuri = node.getNamespaceURI();
+
+      // %TBD% Handle DOM1?
+    }
+    break;
+    default :
+      nsuri = null;
+    }
+
+    return nsuri;
+  }
+
+  /**
+   * Given a node handle, return its node value. This is mostly
+   * as defined by the DOM, but may ignore some conveniences.
+   * <p>
+   *
+   * @param nodeHandle The node id.
+   * @return String Value of this node, or null if not
+   * meaningful for this node type.
+   */
+  public String getNodeValue(int nodeHandle)
+  {
+
+    Node node = getNode(nodeHandle);
+
+    return node.getNodeValue();
+  }
+
+
+  /**
+   *   A document type declaration information item has the following properties:
+   *
+   *     1. [system identifier] The system identifier of the external subset, if
+   *        it exists. Otherwise this property has no value.
+   *
+   * @return the system identifier String object, or null if there is none.
+   */
+  public String getDocumentTypeDeclarationSystemIdentifier()
+  {
+
+    Document doc;
+
+    if (m_root.getNodeType() == Node.DOCUMENT_NODE)
+      doc = (Document) m_root;
+    else
+      doc = m_root.getOwnerDocument();
+
+    if (null != doc)
+    {
+      DocumentType dtd = doc.getDoctype();
+
+      if (null != dtd)
+      {
+        return dtd.getSystemId();
+      }
+    }
+
+    return null;
+  }
+
+  /**
+   * Return the public identifier of the external subset,
+   * normalized as described in 4.2.2 External Entities [XML]. If there is
+   * no external subset or if it has no public identifier, this property
+   * has no value.
+   *
+   * @param the document type declaration handle
+   *
+   * @return the public identifier String object, or null if there is none.
+   */
+  public String getDocumentTypeDeclarationPublicIdentifier()
+  {
+
+    Document doc;
+
+    if (m_root.getNodeType() == Node.DOCUMENT_NODE)
+      doc = (Document) m_root;
+    else
+      doc = m_root.getOwnerDocument();
+
+    if (null != doc)
+    {
+      DocumentType dtd = doc.getDoctype();
+
+      if (null != dtd)
+      {
+        return dtd.getPublicId();
+      }
+    }
+
+    return null;
+  }
+
+  /**
+   * Returns the <code>Element</code> whose <code>ID</code> is given by
+   * <code>elementId</code>. If no such element exists, returns
+   * <code>DTM.NULL</code>. Behavior is not defined if more than one element
+   * has this <code>ID</code>. Attributes (including those
+   * with the name "ID") are not of type ID unless so defined by DTD/Schema
+   * information available to the DTM implementation.
+   * Implementations that do not know whether attributes are of type ID or
+   * not are expected to return <code>DTM.NULL</code>.
+   *
+   * <p>%REVIEW% Presumably IDs are still scoped to a single document,
+   * and this operation searches only within a single document, right?
+   * Wouldn't want collisions between DTMs in the same process.</p>
+   *
+   * @param elementId The unique <code>id</code> value for an element.
+   * @return The handle of the matching element.
+   */
+  public int getElementById(String elementId)
+  {
+
+    Document doc = (m_root.getNodeType() == Node.DOCUMENT_NODE) 
+        ? (Document) m_root : m_root.getOwnerDocument();
+        
+    if(null != doc)
+    {
+      Node elem = doc.getElementById(elementId);
+      if(null != elem)
+      {
+        int elemHandle = getHandleFromNode(elem);
+        
+        if(DTM.NULL == elemHandle)
+        {
+          int identity = m_nodes.size()-1;
+          while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
+          {
+            Node node = getNode(identity);
+            if(node == elem)
+            {
+              elemHandle = getHandleFromNode(elem);
+              break;
+            }
+           }
+        }
+        
+        return elemHandle;
+      }
+    
+    }
+    return DTM.NULL;
+  }
+
+  /**
+   * The getUnparsedEntityURI function returns the URI of the unparsed
+   * entity with the specified name in the same document as the context
+   * node (see [3.3 Unparsed Entities]). It returns the empty string if
+   * there is no such entity.
+   * <p>
+   * XML processors may choose to use the System Identifier (if one
+   * is provided) to resolve the entity, rather than the URI in the
+   * Public Identifier. The details are dependent on the processor, and
+   * we would have to support some form of plug-in resolver to handle
+   * this properly. Currently, we simply return the System Identifier if
+   * present, and hope that it a usable URI or that our caller can
+   * map it to one.
+   * TODO: Resolve Public Identifiers... or consider changing function name.
+   * <p>
+   * If we find a relative URI
+   * reference, XML expects it to be resolved in terms of the base URI
+   * of the document. The DOM doesn't do that for us, and it isn't
+   * entirely clear whether that should be done here; currently that's
+   * pushed up to a higher level of our application. (Note that DOM Level
+   * 1 didn't store the document's base URI.)
+   * TODO: Consider resolving Relative URIs.
+   * <p>
+   * (The DOM's statement that "An XML processor may choose to
+   * completely expand entities before the structure model is passed
+   * to the DOM" refers only to parsed entities, not unparsed, and hence
+   * doesn't affect this function.)
+   *
+   * @param name A string containing the Entity Name of the unparsed
+   * entity.
+   *
+   * @return String containing the URI of the Unparsed Entity, or an
+   * empty string if no such entity exists.
+   */
+  public String getUnparsedEntityURI(String name)
+  {
+
+    String url = "";
+    Document doc = (m_root.getNodeType() == Node.DOCUMENT_NODE) 
+        ? (Document) m_root : m_root.getOwnerDocument();
+
+    if (null != doc)
+    {
+      DocumentType doctype = doc.getDoctype();
+  
+      if (null != doctype)
+      {
+        NamedNodeMap entities = doctype.getEntities();
+        if(null == entities)
+          return url;
+        Entity entity = (Entity) entities.getNamedItem(name);
+        if(null == entity)
+          return url;
+        
+        String notationName = entity.getNotationName();
+  
+        if (null != notationName)  // then it's unparsed
+        {
+          // The draft says: "The XSLT processor may use the public 
+          // identifier to generate a URI for the entity instead of the URI 
+          // specified in the system identifier. If the XSLT processor does 
+          // not use the public identifier to generate the URI, it must use 
+          // the system identifier; if the system identifier is a relative 
+          // URI, it must be resolved into an absolute URI using the URI of 
+          // the resource containing the entity declaration as the base 
+          // URI [RFC2396]."
+          // So I'm falling a bit short here.
+          url = entity.getSystemId();
+  
+          if (null == url)
+          {
+            url = entity.getPublicId();
+          }
+          else
+          {
+            // This should be resolved to an absolute URL, but that's hard 
+            // to do from here.
+          }        
+        }
+      }
+    }
+
+    return url;
+  }
+
+  /**
+   *     5. [specified] A flag indicating whether this attribute was actually
+   *        specified in the start-tag of its element, or was defaulted from the
+   *        DTD.
+   *
+   * @param the attribute handle
+   *
+   * NEEDSDOC @param attributeHandle
+   * @return <code>true</code> if the attribute was specified;
+   *         <code>false</code> if it was defaulted.
+   */
+  public boolean isAttributeSpecified(int attributeHandle)
+  {
+    int type = getNodeType(attributeHandle);
+
+    if (DTM.ATTRIBUTE_NODE == type)
+    {
+      Attr attr = (Attr)getNode(attributeHandle);
+      return attr.getSpecified();
+    }
+    return false;
+  }
+
+  /** Bind a CoroutineParser to this DTM. NOT RELEVANT for DOM2DTM, since
+   * we're wrapped around an existing DOM.
+   *
+   * @param coroutineParser The parser that we want to recieve events from
+   * on demand.
+   */
+  public void setCoroutineParser(CoroutineParser coroutineParser)
+  {
+  }
+  
+  /** getContentHandler returns "our SAX builder" -- the thing that
+   * someone else should send SAX events to in order to extend this
+   * DTM model.
+   *
+   * @return null if this model doesn't respond to SAX events,
+   * "this" if the DTM object has a built-in SAX ContentHandler,
+   * the CoroutineParser if we're bound to one and should receive
+   * the SAX stream via it for incremental build purposes...
+   * */
+  public org.xml.sax.ContentHandler getContentHandler()
+  {
+      return null;
+  }
+  
+  /**
+   * Return this DTM's lexical handler.
+   *
+   * %REVIEW% Should this return null if constrution already done/begun?
+   *
+   * @return null if this model doesn't respond to lexical SAX events,
+   * "this" if the DTM object has a built-in SAX ContentHandler,
+   * the CoroutineParser if we're bound to one and should receive
+   * the SAX stream via it for incremental build purposes...
+   */
+  public org.xml.sax.ext.LexicalHandler getLexicalHandler()
+  {
+
+    return null;
+  }
+
+  
+  /**
+   * Return this DTM's EntityResolver.
+   *
+   * @return null if this model doesn't respond to SAX entity ref events.
+   */
+  public org.xml.sax.EntityResolver getEntityResolver()
+  {
+
+    return null;
+  }
+  
+  /**
+   * Return this DTM's DTDHandler.
+   *
+   * @return null if this model doesn't respond to SAX dtd events.
+   */
+  public org.xml.sax.DTDHandler getDTDHandler()
+  {
+
+    return null;
+  }
+
+  /**
+   * Return this DTM's ErrorHandler.
+   *
+   * @return null if this model doesn't respond to SAX error events.
+   */
+  public org.xml.sax.ErrorHandler getErrorHandler()
+  {
+
+    return null;
+  }
+  
+  /**
+   * Return this DTM's DeclHandler.
+   *
+   * @return null if this model doesn't respond to SAX Decl events.
+   */
+  public org.xml.sax.ext.DeclHandler getDeclHandler()
+  {
+
+    return null;
+  }  
+
+  /** @return true iff we're building this model incrementally (eg
+   * we're partnered with a CoroutineParser) and thus require that the
+   * transformation and the parse run simultaneously. Guidance to the
+   * DTMManager.
+   * */
+  public boolean needsTwoThreads()
+  {
+    return false;
+  }
+
+  // ========== Direct SAX Dispatch, for optimization purposes ========
+
+  /**
+   * Directly call the
+   * characters method on the passed ContentHandler for the
+   * string-value of the given node (see http://www.w3.org/TR/xpath#data-model
+   * for the definition of a node's string-value). Multiple calls to the
+   * ContentHandler's characters methods may well occur for a single call to
+   * this method.
+   *
+   * @param nodeHandle The node ID.
+   * @param ch A non-null reference to a ContentHandler.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public void dispatchCharactersEvents(
+          int nodeHandle, org.xml.sax.ContentHandler ch)
+            throws org.xml.sax.SAXException
+  {
+    int type = getNodeType(nodeHandle);
+    Node node = getNode(nodeHandle);
+    dispatchNodeData(node, ch, 0);
+  }
+  
+  /**
+   * Retrieve the text content of a DOM subtree, appending it into a
+   * user-supplied FastStringBuffer object. Note that attributes are
+   * not considered part of the content of an element.
+   * <p>
+   * There are open questions regarding whitespace stripping. 
+   * Currently we make no special effort in that regard, since the standard
+   * DOM doesn't yet provide DTD-based information to distinguish
+   * whitespace-in-element-context from genuine #PCDATA. Note that we
+   * should probably also consider xml:space if/when we address this.
+   * DOM Level 3 may solve the problem for us.
+   *
+   * @param node Node whose subtree is to be walked, gathering the
+   * contents of all Text or CDATASection nodes.
+   * @param buf FastStringBuffer into which the contents of the text
+   * nodes are to be concatenated.
+   */
+  protected static void dispatchNodeData(Node node, 
+                                         org.xml.sax.ContentHandler ch, 
+                                         int depth)
+            throws org.xml.sax.SAXException
+  {
+
+    switch (node.getNodeType())
+    {
+    case Node.DOCUMENT_FRAGMENT_NODE :
+    case Node.DOCUMENT_NODE :
+    case Node.ELEMENT_NODE :
+    {
+      for (Node child = node.getFirstChild(); null != child;
+              child = child.getNextSibling())
+      {
+        dispatchNodeData(child, ch, depth+1);
+      }
+    }
+    break;
+    case Node.PROCESSING_INSTRUCTION_NODE : // %REVIEW%
+    case Node.COMMENT_NODE :
+      if(0 != depth)
+        break;
+    case Node.TEXT_NODE :
+    case Node.CDATA_SECTION_NODE :
+    case Node.ATTRIBUTE_NODE :
+      String str = node.getNodeValue();
+      ch.characters(str.toCharArray(), 0, str.length());
+      break;
+//    /* case Node.PROCESSING_INSTRUCTION_NODE :
+//      // warning(XPATHErrorResources.WG_PARSING_AND_PREPARING);        
+//      break; */
+    default :
+      // ignore
+      break;
+    }
+  }
+  
+  TreeWalker m_walker = new TreeWalker(null);
+  
+  /**
+   * Directly create SAX parser events from a subtree.
+   *
+   * @param nodeHandle The node ID.
+   * @param ch A non-null reference to a ContentHandler.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch)
+          throws org.xml.sax.SAXException
+  {
+    TreeWalker treeWalker = m_walker;
+    ContentHandler prevCH = treeWalker.getContentHandler();
+    
+    if(null != prevCH)
+    {
+      treeWalker = new TreeWalker(null);
+    }
+    treeWalker.setContentHandler(ch);
+    
+    try
+    {
+      Node node = getNode(nodeHandle);
+      treeWalker.traverse(node);
+    }
+    finally
+    {
+      treeWalker.setContentHandler(null);
+    }
+  }
+
+}
diff --git a/src/org/apache/xml/dtm/dom2dtm/UnitTest.java b/src/org/apache/xml/dtm/dom2dtm/UnitTest.java
new file mode 100644
index 0000000..0a9f602
--- /dev/null
+++ b/src/org/apache/xml/dtm/dom2dtm/UnitTest.java
@@ -0,0 +1,177 @@
+package org.apache.xml.dtm.dom2dtm;
+
+import javax.xml.parsers.*;
+import javax.xml.transform.*;
+import javax.xml.transform.dom.*;
+import javax.xml.transform.stream.*;
+import org.w3c.dom.*;
+import org.xml.sax.*;
+import java.io.StringReader;
+
+import org.apache.xml.dtm.*;
+
+/**
+ * Simple unit test for DOM2DTM.
+ */
+public class UnitTest
+{
+
+  public UnitTest()
+  {
+  }
+  
+  // No namespaces, only elements & attributes
+  static String s_doc1String1 = 
+              "<?xml version=\"1.0\"?>" +
+              "<far-north>" +
+              " <north>" +
+              "  <near-north>" +
+              "   <far-west/>" +
+              "   <west/>" +
+              "   <near-west near-west-attr1='near-west-attr1-value'/>" +
+              "   <center>" +
+              "    <near-south>" +
+              "     <south south-attr1='south-attr1-value' south-attr2='south-attr2-value'>" +
+              "      <far-south/>" +
+              "     </south>" +
+              "    </near-south>" +
+              "   </center>" +
+              "   <near-east/>" +
+              "   <east/>" +
+              "   <far-east/>" +
+              "  </near-north>" +
+              " </north>" +
+              "</far-north>";
+
+  // With namespaces
+  static String s_doc1String2 = 
+              "<?xml version=\"1.0\"?>" +
+              "<far-north>" +
+              " <north xmlns:x='http://x.com'>" +
+              "  <near-north>" +
+              "   <far-west xmlns:y='http://y.com'/>" +
+              "   <west/>" +
+              "   <near-west near-west-attr1='near-west-attr1-value'/>" +
+              "   <center xmlns:y='http://y.com'>" +
+              "    <near-south xmlns:z='http://z.com' xmlns:v='http://v.com'>" +
+              "     <south south-attr1='south-attr1-value' south-attr2='south-attr2-value'>" +
+              "      <far-south/>" +
+              "     </south>" +
+              "    </near-south>" +
+              "   </center>" +
+              "   <near-east/>" +
+              "   <east/>" +
+              "   <far-east/>" +
+              "  </near-north>" +
+              " </north>" +
+              "</far-north>";
+              
+    // Reproduces bug where things don't get processed after the last attribute.
+  static String s_doc1String2a = 
+              "<?xml version=\"1.0\"?>" +
+              "<far-north>" +
+                "<center>" +
+                  "<near-south a='a' b='b'>" +
+                    "<south c='c' d='d'/>" +
+                  "</near-south>" +
+                "</center>" +
+                "<near-east/>" +
+              "</far-north>";
+                
+  // namespaces and text
+  static String s_doc1String3x = 
+              "<?xml version=\"1.0\"?>" +
+              "<far-north>a" +
+              " <north xmlns:x='http://x.com'>b" +
+              "  <near-north>c" +
+              "   <far-west xmlns:y='http://y.com'>d</far-west>" +
+              "   <west>e</west>" +
+              "   <near-west near-west-attr1='near-west-attr1-value'>f</near-west>" +
+              "   <center xmlns:y='http://y.com'>g" +
+              "    <near-south xmlns:z='http://z.com' xmlns:v='http://v.com'>h" +
+              "     <south south-attr1='south-attr1-value' south-attr2='south-attr2-value'>i" +
+              "      <far-south>j</far-south>k" +
+              "     </south>l" +
+              "    </near-south>m" +
+              "   </center>n" +
+              "   <near-east>o</near-east>" +
+              "   <east>p</east>" +
+              "   <far-east>q</far-east>r" +
+              "  </near-north>s" +
+              " </north>t" +
+              "</far-north>";
+              
+    static String s_doc1String3 = 
+              "<?xml version=\"1.0\"?>" +
+              "<docs>" +
+              "  <doc xmlns:ext=\"http://somebody.elses.extension\">" +
+              "    <section xmlns:foo=\"http://foo.com\">" +
+              "      <inner xmlns:whiz=\"http://whiz.com/special/page\"/>" +
+              "    </section>" +
+              "  </doc>" +
+              "</docs>";
+  
+  protected int run(String[] args)
+    throws Exception
+  {
+    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+    dbf.setNamespaceAware(true);
+    DocumentBuilder db = dbf.newDocumentBuilder();
+    StringReader sr = new StringReader(s_doc1String3);
+    
+    Document doc = db.parse(new InputSource(sr));
+    
+    DTMManager dtmMgr = DTMManager.newInstance(
+                 org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());
+    DTM dtm = dtmMgr.getDTM(new DOMSource(doc), true, null, true);
+    
+    int docHandle = dtm.getDocument();
+    outputChildren(docHandle, dtm, 0);
+
+//    TransformerFactory tf = TransformerFactory.newInstance();
+//    Transformer t = tf.newTransformer();
+//    t.setOutputProperty(OutputKeys.INDENT, "yes");
+//    t.transform(new DOMSource(doc), new StreamResult(System.out));
+    
+    System.out.println("DOM2DTM Unit test done!");
+    
+    return 0;
+  }
+  
+  protected void outputChildren(int handle, DTM dtm, int indentAmount)
+  {
+    for (handle = dtm.getFirstChild(handle); handle != DTM.NULL; 
+         handle = dtm.getNextSibling(handle)) 
+    {
+      for (int i = 0; i < indentAmount; i++) 
+      {
+        System.out.print(' ');
+      }
+      
+      System.out.print("node name: "+dtm.getNodeName(handle));
+      System.out.println(", val: "+dtm.getStringValue(handle));
+      
+      for (int ns = dtm.getFirstNamespaceNode(handle, true); ns != DTM.NULL; 
+           ns = dtm.getNextNamespaceNode(handle, ns, true)) 
+      {
+        System.out.print("ns decl: "+dtm.getNodeName(ns));
+        System.out.println(", val: "+dtm.getStringValue(ns));
+      }
+      for (int attr = dtm.getFirstAttribute(handle); attr != DTM.NULL; 
+           attr = dtm.getNextAttribute(attr)) 
+      {
+        System.out.print("attr: "+dtm.getNodeName(attr));
+        System.out.println(", val: "+dtm.getStringValue(attr));
+      }
+      
+      outputChildren(handle, dtm, indentAmount+1);
+    }
+  }
+  
+  public static void main(String[] args)
+    throws Exception
+  {
+    UnitTest unitTest1 = new UnitTest();
+    unitTest1.run(args);
+  }
+}
\ No newline at end of file
diff --git a/src/org/apache/xml/dtm/sax2dtm/SAX2DTM.java b/src/org/apache/xml/dtm/sax2dtm/SAX2DTM.java
new file mode 100644
index 0000000..dd9e5db
--- /dev/null
+++ b/src/org/apache/xml/dtm/sax2dtm/SAX2DTM.java
@@ -0,0 +1,2190 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xml.dtm.sax2dtm;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+import org.xml.sax.*;
+import org.xml.sax.ext.*;
+
+import javax.xml.transform.Source;
+
+import org.apache.xml.utils.FastStringBuffer;
+import org.apache.xml.utils.IntVector;
+import org.apache.xml.utils.IntStack;
+import org.apache.xml.utils.XMLCharacterRecognizer;
+import org.apache.xml.utils.SystemIDResolver;
+import org.apache.xml.dtm.*;
+import org.apache.xml.utils.XMLString;
+import org.apache.xml.utils.XMLStringFactory;
+
+/**
+ * This class implements a DTM that tends to be optimized more for speed than
+ * for compactness, that is constructed via SAX2 ContentHandler events.
+ */
+public class SAX2DTM extends DTMDefaultBase
+        implements EntityResolver, DTDHandler, ContentHandler, ErrorHandler,
+                   DeclHandler, LexicalHandler
+{
+
+  /** simple DEBUG flag, for dumping diagnostics info. */
+  private static final boolean DEBUG = false;
+
+  /**
+   * If we're building the model incrementally on demand, we need to
+   * be able to tell the source when to send us more data.
+   *
+   * Note that if this has not been set, and you attempt to read ahead
+   * of the current build point, we'll probably throw a null-pointer
+   * exception. We could try to wait-and-retry instead, as a very poor
+   * fallback, but that has all the known problems with multithreading
+   * on multiprocessors and we Don't Want to Go There.
+   *
+   * @see setCoroutineParser
+   */
+  private CoroutineParser m_coroutineParser = null;
+
+  /**
+   * If we're building the model incrementally on demand, we need to
+   * be able to tell the source who to return the data to.
+   *
+   * Note that if this has not been set, and you attempt to read ahead
+   * of the current build point, we'll probably throw a MethodNotFound
+   * exception. We could try to wait-and-retry instead, as a very poor
+   * fallback, but that has all the known problems with multithreading
+   * on multiprocessors and we Don't Want to Go There.
+   *
+   * @see setCoroutineParser
+   */
+  private int m_appCoroutineID = -1;
+
+  /**
+   * The number of nodes, which is also used to determine the next
+   *  node index.
+   */
+  private int m_size = 0;
+
+  /**
+   * All the character content, including attribute values, are stored in
+   * this buffer.
+   * %REVIEW% Should this have an option of being shared?
+   */
+  private FastStringBuffer m_chars = new FastStringBuffer(13, 13);
+
+  /** This vector holds offset and length data. */
+  protected IntVector m_data = new IntVector();
+
+  /** The table of expanded names, which may well be owned by the DTMManager */
+  ExpandedNameTable m_ent;
+
+  /** The parent stack, needed only for construction. */
+  transient private IntStack m_parents = new IntStack();
+
+  /** The current construction level, needed only for construction time. */
+  transient private int m_level = 0;
+
+  /** The current previous node, needed only for construction time. */
+  transient private int m_previous = 0;
+
+  /** Namespace support, only relevent at construction time. */
+  transient private java.util.Vector m_prefixMappings =
+    new java.util.Vector();
+
+  /** Namespace support, only relevent at construction time. */
+  transient private IntStack m_contextIndexes = new IntStack();
+
+  /** Type of next characters() event within text block in prgress. */
+  transient private int m_textType = DTM.TEXT_NODE;
+
+  /**
+   * Type of coalesced text block. See logic in the characters()
+   * method.
+   */
+  transient private int m_coalescedTextType = DTM.TEXT_NODE;
+
+  /** The SAX Document locator */
+  transient private Locator m_locator = null;
+
+  /** Tree Walker for dispatchToEvents. */
+  protected DTMTreeWalker m_walker = new DTMTreeWalker();
+
+  /** pool of string values that come as strings. */
+  private DTMStringPool m_valuesOrPrefixes = new DTMStringPool();
+
+  /** End document has been reached. */
+  private boolean m_endDocumentOccured = false;
+
+  /**
+   * This represents the number of integers per node in the
+   * <code>m_info</code> member variable.
+   */
+  protected static final int NODEINFOBLOCKSIZE = DEFAULTNODEINFOBLOCKSIZE + 1;
+
+  /**
+   * The value at this offset in the m_info table is an index
+   * into the data table, or name prefix.  Or if the node is an
+   *  attribute node, if the value is positive, it is a pool index into
+   *  the m_valuesOrPrefixes pool, or if the value is negative, it should
+   *  be made positive and used as an index into the m_data list, with the
+   *  first value at that offset being the qname index, and the next value
+   *  at the offset being the value index.
+   */
+  protected static final int OFFSET_DATA_OR_QNAME = DEFAULTNODEINFOBLOCKSIZE;
+
+  /**
+   * This table holds the ID string to node associations, for
+   * XML IDs.
+   */
+  protected Hashtable m_idAttributes = new Hashtable();
+
+  /**
+   * fixed dom-style names.
+   */
+  static final String[] m_fixednames = { null, null,  // nothing, Element
+                                         null, "#text",  // Attr, Text
+                                         "#cdata_section", null,  // CDATA, EntityReference
+                                         null, null,  // Entity, PI
+                                         "#comment", "#document",  // Comment, Document
+                                         null, "#document-fragment",  // Doctype, DocumentFragment
+                                         null };  // Notation
+
+  /**
+   * Vector of entities.  Each record is composed of four Strings:
+   *  publicId, systemID, notationName, and name.
+   */
+  private Vector m_entities = null;
+
+  /** m_entities public ID offset. */
+  private static final int ENTITY_FIELD_PUBLICID = 0;
+
+  /** m_entities system ID offset. */
+  private static final int ENTITY_FIELD_SYSTEMID = 1;
+
+  /** m_entities notation name offset. */
+  private static final int ENTITY_FIELD_NOTATIONNAME = 2;
+
+  /** m_entities name offset. */
+  private static final int ENTITY_FIELD_NAME = 3;
+
+  /** Number of entries per record for m_entities. */
+  private static final int ENTITY_FIELDS_PER = 4;
+
+  /**
+   * The starting offset within m_chars for the text or
+   * CDATA_SECTION node currently being acumulated,
+   * or -1 if there is no text node in progress
+   */
+  private int m_textPendingStart = -1;
+
+  /**
+   * Construct a SAX2DTM object ready to be constructed from SAX2
+   * ContentHandler events.
+   *
+   * @param mgr The DTMManager who owns this DTM.
+   * @param source the JAXP 1.1 Source object for this DTM.
+   * @param dtmIdentity The DTM identity ID for this DTM.
+   * @param whiteSpaceFilter The white space filter for this DTM, which may
+   *                         be null.
+   * @param xstringfactory XMLString factory for creating character content.
+   */
+  public SAX2DTM(DTMManager mgr, Source source, int dtmIdentity,
+                 DTMWSFilter whiteSpaceFilter,
+                 XMLStringFactory xstringfactory)
+  {
+
+    super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory);
+
+    m_ent = mgr.getExpandedNameTable(this);
+
+    if (null == m_ent)
+      m_ent = new ExpandedNameTable();
+
+    int doc = addNode(DTM.DOCUMENT_NODE,
+                      m_ent.getExpandedNameID(DTM.DOCUMENT_NODE), m_level,
+                      DTM.NULL, DTM.NULL, 0, true);
+
+    m_level++;
+
+    m_parents.push(doc);
+
+    m_previous = DTM.NULL;
+  }
+
+  /**
+   * Get the CoRoutine ID for the application.
+   *
+   * @return The CoRoutine ID for the application.
+   */
+  public int getAppCoroutineID()
+  {
+    return m_appCoroutineID;
+  }
+
+  /**
+   * Ask the CoRoutine parser to doTerminate and clear the reference.
+   */
+  public void clearCoRoutine()
+  {
+    clearCoRoutine(true);
+  }
+
+  /**
+   * Ask the CoRoutine parser to doTerminate and clear the reference. If 
+   * the CoRoutine parser has already been cleared, this will have no effect.
+   *
+   * @param callDoTerminate true of doTerminate should be called on the 
+   * coRoutine parser.
+   */
+  public void clearCoRoutine(boolean callDoTerminate)
+  {
+
+    if (null != m_coroutineParser)
+    {
+      if (callDoTerminate)
+        m_coroutineParser.doTerminate(m_appCoroutineID);
+
+      m_coroutineParser = null;
+    }
+  }
+
+  /**
+   * Bind a CoroutineParser to this DTM. If we discover we need nodes
+   * that have not yet been built, we will ask this object to send us more
+   * events, and it will manage interactions with its data sources.
+   *
+   * Note that we do not actually build the CoroutineParser, since we don't
+   * know what source it's reading from, what thread that source will run in,
+   * or when it will run.
+   *
+   * @param coroutineParser The parser that we want to recieve events from
+   * on demand.
+   * @param appCoRID The CoRoutine ID for the application.
+   */
+  public void setCoroutineParser(CoroutineParser coroutineParser,
+                                 int appCoRID)
+  {
+
+    // Establish coroutine link so we can request more data
+    //
+    // Note: It's possible that some versions of CoroutineParser may
+    // not actually use a CoroutineManager, and hence may not require
+    // that we obtain an Application Coroutine ID. (This relies on the
+    // coroutine transaction details having been encapsulated in the
+    // CoroutineParser.do...() methods.)
+    m_coroutineParser = coroutineParser;
+
+    CoroutineManager cm = coroutineParser.getCoroutineManager();
+
+    m_appCoroutineID = appCoRID;
+
+    // Establish SAX-stream link so we can receive the requested data
+    coroutineParser.setContentHandler(this);
+    coroutineParser.setLexHandler(this);
+
+    // Are the following really needed? coroutineParser doesn't yet
+    // support them, and they're mostly no-ops here...
+    //coroutineParser.setErrorHandler(this);
+    //coroutineParser.setDTDHandler(this);
+    //coroutineParser.setDeclHandler(this);
+  }
+
+  /**
+   * getContentHandler returns "our SAX builder" -- the thing that
+   * someone else should send SAX events to in order to extend this
+   * DTM model.
+   *
+   * %REVIEW% Should this return null if constrution already done/begun?
+   *
+   * @return null if this model doesn't respond to SAX events,
+   * "this" if the DTM object has a built-in SAX ContentHandler,
+   * the CoroutineParser if we're bound to one and should receive
+   * the SAX stream via it for incremental build purposes...
+   */
+  public ContentHandler getContentHandler()
+  {
+
+    if (m_coroutineParser instanceof CoroutineSAXParser)
+      return (ContentHandler) m_coroutineParser;
+    else
+      return this;
+  }
+
+  /**
+   * Return this DTM's lexical handler.
+   *
+   * %REVIEW% Should this return null if constrution already done/begun?
+   *
+   * @return null if this model doesn't respond to lexical SAX events,
+   * "this" if the DTM object has a built-in SAX ContentHandler,
+   * the CoroutineParser if we're bound to one and should receive
+   * the SAX stream via it for incremental build purposes...
+   */
+  public LexicalHandler getLexicalHandler()
+  {
+
+    if (m_coroutineParser instanceof CoroutineSAXParser)
+      return (LexicalHandler) m_coroutineParser;
+    else
+      return this;
+  }
+
+  /**
+   * Return this DTM's EntityResolver.
+   *
+   * @return null if this model doesn't respond to SAX entity ref events.
+   */
+  public EntityResolver getEntityResolver()
+  {
+    return this;
+  }
+
+  /**
+   * Return this DTM's DTDHandler.
+   *
+   * @return null if this model doesn't respond to SAX dtd events.
+   */
+  public DTDHandler getDTDHandler()
+  {
+    return this;
+  }
+
+  /**
+   * Return this DTM's ErrorHandler.
+   *
+   * @return null if this model doesn't respond to SAX error events.
+   */
+  public ErrorHandler getErrorHandler()
+  {
+    return this;
+  }
+
+  /**
+   * Return this DTM's DeclHandler.
+   *
+   * @return null if this model doesn't respond to SAX Decl events.
+   */
+  public DeclHandler getDeclHandler()
+  {
+    return this;
+  }
+
+  /**
+   * @return true iff we're building this model incrementally (eg
+   * we're partnered with a CoroutineParser) and thus require that the
+   * transformation and the parse run simultaneously. Guidance to the
+   * DTMManager.
+   */
+  public boolean needsTwoThreads()
+  {
+    return null != m_coroutineParser;
+  }
+
+  /**
+   * Directly call the
+   * characters method on the passed ContentHandler for the
+   * string-value of the given node (see http://www.w3.org/TR/xpath#data-model
+   * for the definition of a node's string-value). Multiple calls to the
+   * ContentHandler's characters methods may well occur for a single call to
+   * this method.
+   *
+   * @param nodeHandle The node ID.
+   * @param ch A non-null reference to a ContentHandler.
+   *
+   * @throws SAXException
+   */
+  public void dispatchCharactersEvents(int nodeHandle, ContentHandler ch)
+          throws SAXException
+  {
+
+    int identity = nodeHandle & m_mask;
+    int type = getNodeType(identity);
+
+    if (isTextType(type))
+    {
+      int dataIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+      int offset = m_data.elementAt(dataIndex);
+      int length = m_data.elementAt(dataIndex + 1);
+
+      m_chars.sendSAXcharacters(ch, offset, length);
+    }
+    else
+    {
+      int firstChild = getNodeInfo(identity, OFFSET_FIRSTCHILD);
+
+      if (DTM.NULL != firstChild)
+      {
+        int offset = -1;
+        int length = 0;
+        int level = getNodeInfo(identity, OFFSET_LEVEL);
+
+        identity = firstChild;
+
+        while (DTM.NULL != identity
+               && (getNodeInfo(identity, OFFSET_LEVEL) > level))
+        {
+          type = getNodeType(identity);
+
+          if (isTextType(type))
+          {
+            int dataIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+
+            if (-1 == offset)
+            {
+              offset = m_data.elementAt(dataIndex);
+            }
+
+            length += m_data.elementAt(dataIndex + 1);
+          }
+
+          identity = getNextNodeIdentity(identity);
+        }
+
+        if (length > 0)
+        {
+          m_chars.sendSAXcharacters(ch, offset, length);
+        }
+      }
+      else
+      {
+        int dataIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+
+        if (dataIndex < 0)
+        {
+          dataIndex = -dataIndex;
+          dataIndex = m_data.elementAt(dataIndex + 1);
+        }
+
+        String str = m_valuesOrPrefixes.indexToString(dataIndex);
+
+        ch.characters(str.toCharArray(), 0, str.length());
+      }
+    }
+  }
+
+  /**
+   * Given a node handle, return its DOM-style node name. This will
+   * include names such as #text or #document.
+   *
+   * @param nodeHandle the id of the node.
+   * @return String Name of this node, which may be an empty string.
+   * %REVIEW% Document when empty string is possible...
+   * %REVIEW-COMMENT% It should never be empty, should it?
+   */
+  public String getNodeName(int nodeHandle)
+  {
+
+    int expandedTypeID = getExpandedNameID(nodeHandle);
+    int namespaceID = (expandedTypeID & ExpandedNameTable.MASK_NAMESPACE)
+                      >> ExpandedNameTable.BITS_PER_LOCALNAME;
+
+    if (0 == namespaceID)
+    {
+      String name = m_ent.getLocalName(expandedTypeID);
+      int type = getNodeType(nodeHandle);
+
+      if (type == DTM.NAMESPACE_NODE)
+      {
+        if (name == null)
+          return "xmlns";
+        else
+          return "xmlns:" + name;
+      }
+      else if (name == null)
+      {
+        return m_fixednames[type];
+      }
+      else
+        return name;
+    }
+    else
+    {
+      int qnameIndex = getNodeInfoNoWait(nodeHandle & m_mask,
+                                         OFFSET_DATA_OR_QNAME);
+
+      if (qnameIndex < 0)
+      {
+        qnameIndex = -qnameIndex;
+        qnameIndex = m_data.elementAt(qnameIndex);
+      }
+
+      return m_valuesOrPrefixes.indexToString(qnameIndex);
+    }
+  }
+
+  /**
+   * Given a node handle, return the XPath node name.  This should be
+   * the name as described by the XPath data model, NOT the DOM-style
+   * name.
+   *
+   * @param nodeHandle the id of the node.
+   * @return String Name of this node, which may be an empty string.
+   */
+  public String getNodeNameX(int nodeHandle)
+  {
+
+    int expandedTypeID = getExpandedNameID(nodeHandle);
+    int namespaceID = (expandedTypeID & ExpandedNameTable.MASK_NAMESPACE)
+                      >> ExpandedNameTable.BITS_PER_LOCALNAME;
+
+    if (0 == namespaceID)
+    {
+      String name = m_ent.getLocalName(expandedTypeID);
+
+      if (name == null)
+        return "";
+      else
+        return name;
+    }
+    else
+    {
+      int qnameIndex = getNodeInfoNoWait(nodeHandle & m_mask,
+                                         OFFSET_DATA_OR_QNAME);
+
+      if (qnameIndex < 0)
+      {
+        qnameIndex = -qnameIndex;
+        qnameIndex = m_data.elementAt(qnameIndex);
+      }
+
+      return m_valuesOrPrefixes.indexToString(qnameIndex);
+    }
+  }
+
+  /**
+   *     5. [specified] A flag indicating whether this attribute was actually
+   *        specified in the start-tag of its element, or was defaulted from the
+   *        DTD.
+   *
+   * @param the attribute handle
+   *
+   * @param attributeHandle Must be a valid handle to an attribute node.
+   * @return <code>true</code> if the attribute was specified;
+   *         <code>false</code> if it was defaulted.
+   */
+  public boolean isAttributeSpecified(int attributeHandle)
+  {
+
+    // I'm not sure if I want to do anything with this...
+    return true;  // ??
+  }
+
+  /**
+   *   A document type declaration information item has the following properties:
+   *
+   *     1. [system identifier] The system identifier of the external subset, if
+   *        it exists. Otherwise this property has no value.
+   *
+   * @return the system identifier String object, or null if there is none.
+   */
+  public String getDocumentTypeDeclarationSystemIdentifier()
+  {
+
+    /** @todo: implement this org.apache.xml.dtm.DTMDefaultBase abstract method */
+    error("Not yet supported!");
+
+    return null;
+  }
+
+  /**
+   * Get the next node identity value in the list, and call the iterator
+   * if it hasn't been added yet.
+   *
+   * @param identity The node identity (index).
+   * @return identity+1, or DTM.NULL.
+   */
+  protected int getNextNodeIdentity(int identity)
+  {
+
+    identity += 1;
+
+    while (identity >= m_size)
+    {
+      if (null == m_coroutineParser)
+        return DTM.NULL;
+
+      nextNode();
+    }
+
+    return identity;
+  }
+
+  /**
+   * Directly create SAX parser events from a subtree.
+   *
+   * @param nodeHandle The node ID.
+   * @param ch A non-null reference to a ContentHandler.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch)
+          throws org.xml.sax.SAXException
+  {
+
+    DTMTreeWalker treeWalker = m_walker;
+    ContentHandler prevCH = treeWalker.getcontentHandler();
+
+    if (null != prevCH)
+    {
+      treeWalker = new DTMTreeWalker();
+    }
+
+    treeWalker.setcontentHandler(ch);
+    treeWalker.setDTM(this);
+
+    try
+    {
+      treeWalker.traverse(nodeHandle);
+    }
+    finally
+    {
+      treeWalker.setcontentHandler(null);
+    }
+  }
+
+  /**
+   * Return the number of integers in each node info block.
+   *
+   * @return the number of integers in each node info block.
+   */
+  protected int getNodeInfoBlockSize()
+  {
+    return NODEINFOBLOCKSIZE;
+  }
+
+  /**
+   * Get the number of nodes that have been added.
+   *
+   * @return The number of that are currently in the tree.
+   */
+  protected int getNumberOfNodes()
+  {
+    return m_size;
+  }
+
+  /**
+   * This method should try and build one or more nodes in the table.
+   *
+   * @return The true if a next node is found or false if
+   *         there are no more nodes.
+   */
+  protected boolean nextNode()
+  {
+
+    if (null == m_coroutineParser)
+      return false;
+
+    if (m_endDocumentOccured)
+    {
+      clearCoRoutine();
+
+      return false;
+    }
+
+    Object gotMore = m_coroutineParser.doMore(true, m_appCoroutineID);
+
+    // gotMore may be a Boolean (TRUE if still parsing, FALSE if
+    // EOF) or an exception if CoroutineParser malfunctioned
+    // (code error rather than user error).
+    //
+    // %REVIEW% Currently the ErrorHandlers sketched herein are
+    // no-ops, so I'm going to initially leave this also as a
+    // no-op.
+    if (!(gotMore instanceof Boolean))
+    {
+
+      // for now...
+      clearCoRoutine();
+
+      return false;
+
+      // %TBD% 
+    }
+
+    if (gotMore != Boolean.TRUE)
+    {
+
+      // EOF reached without satisfying the request
+      clearCoRoutine();  // Drop connection, stop trying
+
+      // %TBD% deregister as its listener?
+    }
+
+    return true;
+  }
+
+  /**
+   * Bottleneck determination of text type.
+   *
+   * @param type oneof DTM.XXX_NODE.
+   *
+   * @return true if this is a text or cdata section.
+   */
+  private final boolean isTextType(int type)
+  {
+    return (DTM.TEXT_NODE == type || DTM.CDATA_SECTION_NODE == type);
+  }
+
+  /**
+   * Construct the node map from the node.
+   *
+   * @param type raw type ID, one of DTM.XXX_NODE.
+   * @param expandedTypeID The expended type ID.
+   * @param level The current level in the tree.
+   * @param parentIndex The current parent index.
+   * @param previousSibling The previous sibling index.
+   * @param dataOrPrefix index into m_data table, or string handle.
+   * @param canHaveFirstChild true if the node can have a first child, false
+   *                          if it is atomic.
+   *
+   * @return The index identity of the node that was added.
+   */
+  protected int addNode(int type, int expandedTypeID, int level,
+                        int parentIndex, int previousSibling,
+                        int dataOrPrefix, boolean canHaveFirstChild)
+  {
+
+    int nodeIndex = m_size++;
+    int startInfo = nodeIndex * NODEINFOBLOCKSIZE;
+
+    m_info.addElements(NODEINFOBLOCKSIZE);
+    m_info.setElementAt(level, startInfo + OFFSET_LEVEL);
+    m_info.setElementAt(type, startInfo + OFFSET_TYPE);
+    m_info.setElementAt((canHaveFirstChild) ? NOTPROCESSED : DTM.NULL,
+                        startInfo + OFFSET_FIRSTCHILD);
+    m_info.setElementAt(NOTPROCESSED, startInfo + OFFSET_NEXTSIBLING);
+    m_info.setElementAt(previousSibling, startInfo + OFFSET_PREVSIBLING);
+    m_info.setElementAt(parentIndex, startInfo + OFFSET_PARENT);
+    m_info.setElementAt(expandedTypeID, startInfo + OFFSET_EXPANDEDNAMEID);
+    m_info.setElementAt(dataOrPrefix, startInfo + OFFSET_DATA_OR_QNAME);
+
+    // Text nodes no longer need special handling, because we
+    // don't add them until they're complete
+    {
+      if (DTM.NULL != parentIndex && type != DTM.ATTRIBUTE_NODE
+              && type != DTM.NAMESPACE_NODE)
+      {
+        int startParentInfo = parentIndex * NODEINFOBLOCKSIZE;
+
+        if (NOTPROCESSED
+                == m_info.elementAt(startParentInfo + OFFSET_FIRSTCHILD))
+        {
+          m_info.setElementAt(nodeIndex, startParentInfo + OFFSET_FIRSTCHILD);
+        }
+      }
+
+      // Note that we don't want nextSibling to be processed until
+      // charactersFlush() is called.
+      if (DTM.NULL != previousSibling)
+      {
+        int startPrevInfo = previousSibling * NODEINFOBLOCKSIZE;
+
+        m_info.setElementAt(nodeIndex, startPrevInfo + OFFSET_NEXTSIBLING);
+      }
+    }
+
+    return nodeIndex;
+  }
+
+  /**
+   * Given a node handle, return its node value. This is mostly
+   * as defined by the DOM, but may ignore some conveniences.
+   * <p>
+   *
+   * @param nodeHandle The node id.
+   * @return String Value of this node, or null if not
+   * meaningful for this node type.
+   */
+  public String getNodeValue(int nodeHandle)
+  {
+
+    int identity = nodeHandle & m_mask;
+    int type = getNodeType(identity);
+
+    if (isTextType(type))
+    {
+      int dataIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+      int offset = m_data.elementAt(dataIndex);
+      int length = m_data.elementAt(dataIndex + 1);
+
+      // %OPT% We should cache this, I guess.
+      return m_chars.getString(offset, length);
+    }
+    else if (DTM.ELEMENT_NODE == type || DTM.DOCUMENT_FRAGMENT_NODE == type
+             || DTM.DOCUMENT_NODE == type)
+    {
+      return null;
+    }
+    else
+    {
+      int dataIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+
+      if (dataIndex < 0)
+      {
+        dataIndex = -dataIndex;
+        dataIndex = m_data.elementAt(dataIndex + 1);
+      }
+
+      return m_valuesOrPrefixes.indexToString(dataIndex);
+    }
+  }
+
+  /**
+   * Given a node handle, return its XPath-style localname.
+   * (As defined in Namespaces, this is the portion of the name after any
+   * colon character).
+   *
+   * @param nodeHandle the id of the node.
+   * @return String Local name of this node.
+   */
+  public String getLocalName(int nodeHandle)
+  {
+
+    int expandedTypeID = getExpandedNameID(nodeHandle);
+    String name = m_ent.getLocalName(expandedTypeID);
+
+    if (name == null)
+      return "";
+    else
+      return name;
+  }
+
+  /**
+   * The getUnparsedEntityURI function returns the URI of the unparsed
+   * entity with the specified name in the same document as the context
+   * node (see [3.3 Unparsed Entities]). It returns the empty string if
+   * there is no such entity.
+   * <p>
+   * XML processors may choose to use the System Identifier (if one
+   * is provided) to resolve the entity, rather than the URI in the
+   * Public Identifier. The details are dependent on the processor, and
+   * we would have to support some form of plug-in resolver to handle
+   * this properly. Currently, we simply return the System Identifier if
+   * present, and hope that it a usable URI or that our caller can
+   * map it to one.
+   * TODO: Resolve Public Identifiers... or consider changing function name.
+   * <p>
+   * If we find a relative URI
+   * reference, XML expects it to be resolved in terms of the base URI
+   * of the document. The DOM doesn't do that for us, and it isn't
+   * entirely clear whether that should be done here; currently that's
+   * pushed up to a higher level of our application. (Note that DOM Level
+   * 1 didn't store the document's base URI.)
+   * TODO: Consider resolving Relative URIs.
+   * <p>
+   * (The DOM's statement that "An XML processor may choose to
+   * completely expand entities before the structure model is passed
+   * to the DOM" refers only to parsed entities, not unparsed, and hence
+   * doesn't affect this function.)
+   *
+   * @param name A string containing the Entity Name of the unparsed
+   * entity.
+   *
+   * @return String containing the URI of the Unparsed Entity, or an
+   * empty string if no such entity exists.
+   */
+  public String getUnparsedEntityURI(String name)
+  {
+
+    String url = "";
+
+    if (null == m_entities)
+      return url;
+
+    int n = m_entities.size();
+
+    for (int i = 0; i < n; i += ENTITY_FIELDS_PER)
+    {
+      String ename = (String) m_entities.elementAt(i + ENTITY_FIELD_NAME);
+
+      if (null != ename && ename.equals(name))
+      {
+        String nname = (String) m_entities.elementAt(i
+                         + ENTITY_FIELD_NOTATIONNAME);
+
+        if (null != nname)
+        {
+
+          // The draft says: "The XSLT processor may use the public 
+          // identifier to generate a URI for the entity instead of the URI 
+          // specified in the system identifier. If the XSLT processor does 
+          // not use the public identifier to generate the URI, it must use 
+          // the system identifier; if the system identifier is a relative 
+          // URI, it must be resolved into an absolute URI using the URI of 
+          // the resource containing the entity declaration as the base 
+          // URI [RFC2396]."
+          // So I'm falling a bit short here.
+          url = (String) m_entities.elementAt(i + ENTITY_FIELD_SYSTEMID);
+
+          if (null == url)
+          {
+            url = (String) m_entities.elementAt(i + ENTITY_FIELD_PUBLICID);
+          }
+        }
+
+        break;
+      }
+    }
+
+    return url;
+  }
+
+  /**
+   * Given a namespace handle, return the prefix that the namespace decl is
+   * mapping.
+   * Given a node handle, return the prefix used to map to the namespace.
+   *
+   * <p> %REVIEW% Are you sure you want "" for no prefix?  </p>
+   * <p> %REVIEW-COMMENT% I think so... not totally sure. -sb  </p>
+   *
+   * @param nodeHandle the id of the node.
+   * @return String prefix of this node's name, or "" if no explicit
+   * namespace prefix was given.
+   */
+  public String getPrefix(int nodeHandle)
+  {
+
+    int identity = nodeHandle & m_mask;
+    int type = getNodeType(identity);
+
+    if (DTM.ELEMENT_NODE == type)
+    {
+      int prefixIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+
+      if (0 == prefixIndex)
+        return "";
+      else
+      {
+        String qname = m_valuesOrPrefixes.indexToString(prefixIndex);
+
+        return getPrefix(qname, null);
+      }
+    }
+    else if (DTM.ATTRIBUTE_NODE == type)
+    {
+      int prefixIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+
+      if (prefixIndex < 0)
+      {
+        prefixIndex = m_data.elementAt(-prefixIndex);
+
+        String qname = m_valuesOrPrefixes.indexToString(prefixIndex);
+
+        return getPrefix(qname, null);
+      }
+    }
+
+    return "";
+  }
+
+  /**
+   * Retrieves an attribute node by by qualified name and namespace URI.
+   *
+   * @param nodeHandle int Handle of the node upon which to look up this attribute..
+   * @param namespaceURI The namespace URI of the attribute to
+   *   retrieve, or null.
+   * @param name The local name of the attribute to
+   *   retrieve.
+   * @return The attribute node handle with the specified name (
+   *   <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such
+   *   attribute.
+   */
+  public int getAttributeNode(int nodeHandle, String namespaceURI,
+                              String name)
+  {
+
+    for (int attrH = getFirstAttribute(nodeHandle); DTM.NULL != attrH;
+            attrH = getNextAttribute(attrH))
+    {
+      String attrNS = getNamespaceURI(attrH);
+      String attrName = getLocalName(attrH);
+      boolean nsMatch = namespaceURI == attrNS
+                        || (namespaceURI != null
+                            && namespaceURI.equals(attrNS));
+
+      if (nsMatch && name.equals(attrName))
+        return attrH;
+    }
+
+    return DTM.NULL;
+  }
+
+  /**
+   * Return the public identifier of the external subset,
+   * normalized as described in 4.2.2 External Entities [XML]. If there is
+   * no external subset or if it has no public identifier, this property
+   * has no value.
+   *
+   * @param the document type declaration handle
+   *
+   * @return the public identifier String object, or null if there is none.
+   */
+  public String getDocumentTypeDeclarationPublicIdentifier()
+  {
+
+    /** @todo: implement this org.apache.xml.dtm.DTMDefaultBase abstract method */
+    error("Not yet supported!");
+
+    return null;
+  }
+
+  /**
+   * Given a node handle, return its DOM-style namespace URI
+   * (As defined in Namespaces, this is the declared URI which this node's
+   * prefix -- or default in lieu thereof -- was mapped to.)
+   *
+   * <p>%REVIEW% Null or ""? -sb</p>
+   *
+   * @param nodeHandle the id of the node.
+   * @return String URI value of this node's namespace, or null if no
+   * namespace was resolved.
+   */
+  public String getNamespaceURI(int nodeHandle)
+  {
+
+    int expandedTypeID = getExpandedNameID(nodeHandle);
+
+    return m_ent.getNamespace(expandedTypeID);
+  }
+
+  /**
+   * Get the string-value of a node as a String object
+   * (see http://www.w3.org/TR/xpath#data-model
+   * for the definition of a node's string-value).
+   *
+   * @param nodeHandle The node ID.
+   *
+   * @return A string object that represents the string-value of the given node.
+   */
+  public XMLString getStringValue(int nodeHandle)
+  {
+
+    int identity = nodeHandle & m_mask;
+    int type = getNodeType(identity);
+
+    if (isTextType(type))
+    {
+      int dataIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+      int offset = m_data.elementAt(dataIndex);
+      int length = m_data.elementAt(dataIndex + 1);
+
+      return m_xstrf.newstr(m_chars, offset, length);
+    }
+    else
+    {
+      int firstChild = getNodeInfo(identity, OFFSET_FIRSTCHILD);
+
+      if (DTM.NULL != firstChild)
+      {
+        int offset = -1;
+        int length = 0;
+        int level = getNodeInfo(identity, OFFSET_LEVEL);
+
+        identity = firstChild;
+
+        while (DTM.NULL != identity
+               && (getNodeInfo(identity, OFFSET_LEVEL) > level))
+        {
+          type = getNodeType(identity);
+
+          if (isTextType(type))
+          {
+            int dataIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+
+            if (-1 == offset)
+            {
+              offset = m_data.elementAt(dataIndex);
+            }
+
+            length += m_data.elementAt(dataIndex + 1);
+          }
+
+          identity = getNextNodeIdentity(identity);
+        }
+
+        if (length > 0)
+        {
+          return m_xstrf.newstr(m_chars, offset, length);
+        }
+      }
+      else
+      {
+        int dataIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+
+        if (dataIndex < 0)
+        {
+          dataIndex = -dataIndex;
+          dataIndex = m_data.elementAt(dataIndex + 1);
+        }
+
+        return m_xstrf.newstr(m_valuesOrPrefixes.indexToString(dataIndex));
+      }
+    }
+
+    return m_xstrf.emptystr();
+  }
+
+  /**
+   * Returns the <code>Element</code> whose <code>ID</code> is given by
+   * <code>elementId</code>. If no such element exists, returns
+   * <code>DTM.NULL</code>. Behavior is not defined if more than one element
+   * has this <code>ID</code>. Attributes (including those
+   * with the name "ID") are not of type ID unless so defined by DTD/Schema
+   * information available to the DTM implementation.
+   * Implementations that do not know whether attributes are of type ID or
+   * not are expected to return <code>DTM.NULL</code>.
+   *
+   * <p>%REVIEW% Presumably IDs are still scoped to a single document,
+   * and this operation searches only within a single document, right?
+   * Wouldn't want collisions between DTMs in the same process.</p>
+   *
+   * @param elementId The unique <code>id</code> value for an element.
+   * @return The handle of the matching element.
+   */
+  public int getElementById(String elementId)
+  {
+
+    Integer intObj;
+    boolean isMore = true;
+
+    do
+    {
+      intObj = (Integer) m_idAttributes.get(elementId);
+
+      if (null != intObj)
+        return intObj.intValue();
+
+      if (!isMore || m_endDocumentOccured)
+        break;
+
+      isMore = nextNode();
+    }
+    while (null == intObj);
+
+    return DTM.NULL;
+  }
+
+  /**
+   * Get a prefix either from the qname or from the uri mapping, or just make
+   * one up!
+   *
+   * @param qname The qualified name, which may be null.
+   * @param uri The namespace URI, which may be null.
+   *
+   * @return The prefix if there is one, or null.
+   */
+  private String getPrefix(String qname, String uri)
+  {
+
+    String prefix;
+
+    if (null != uri && uri.length() > 0)
+    {
+      int uriIndex = m_prefixMappings.indexOf(uri, 0);
+
+      if (uriIndex >= 0)
+      {
+        prefix = (String) m_prefixMappings.elementAt(uriIndex - 1);
+      }
+      else if (null != qname)
+      {
+        int indexOfNSSep = qname.indexOf(':');
+
+        if (qname.equals("xmlns"))
+          prefix = "";
+        else if (qname.startsWith("xmlns:"))
+          prefix = qname.substring(indexOfNSSep + 1);
+        else
+          prefix = (indexOfNSSep > 0)
+                   ? qname.substring(0, indexOfNSSep) : null;
+      }
+      else
+      {
+        prefix = null;  // ??
+      }
+    }
+    else if (null != qname)
+    {
+      int indexOfNSSep = qname.indexOf(':');
+
+      if (qname.equals("xmlns"))
+        prefix = "";
+      else if (qname.startsWith("xmlns:"))
+        prefix = qname.substring(indexOfNSSep + 1);
+      else
+        prefix = (indexOfNSSep > 0) ? qname.substring(0, indexOfNSSep) : null;
+    }
+    else
+    {
+      prefix = null;
+    }
+
+    return prefix;
+  }
+
+  /**
+   * Set an ID string to node association in the ID table.
+   *
+   * @param id The ID string.
+   * @param elem The associated element handle.
+   */
+  public void setIDAttribute(String id, int elem)
+  {
+    m_idAttributes.put(id, new Integer(elem));
+  }
+
+  /**
+   * Check whether accumulated text should be stripped; if not,
+   * append the appropriate flavor of text/cdata node.
+   */
+  protected void charactersFlush()
+  {
+
+    if (m_textPendingStart >= 0)  // -1 indicates no-text-in-progress
+    {
+      int length = m_chars.size() - m_textPendingStart;
+      boolean doStrip = false;
+
+      if (getShouldStripWhitespace())
+      {
+        doStrip = m_chars.isWhitespace(m_textPendingStart, length);
+      }
+
+      if (doStrip)
+        m_chars.setLength(m_textPendingStart);  // Discard accumulated text
+      else
+      {
+        int exName = m_ent.getExpandedNameID(DTM.TEXT_NODE);
+        int dataIndex = m_data.size();
+
+        m_previous = addNode(m_coalescedTextType, exName, m_level,
+                             m_parents.peek(), m_previous, dataIndex, false);
+
+        m_data.addElement(m_textPendingStart);
+        m_data.addElement(length);
+      }
+
+      // Reset for next text block
+      m_textPendingStart = -1;
+      m_textType = m_coalescedTextType = DTM.TEXT_NODE;
+    }
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of the EntityResolver interface.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Resolve an external entity.
+   *
+   * <p>Always return null, so that the parser will use the system
+   * identifier provided in the XML document.  This method implements
+   * the SAX default behaviour: application writers can override it
+   * in a subclass to do special translations such as catalog lookups
+   * or URI redirection.</p>
+   *
+   * @param publicId The public identifer, or null if none is
+   *                 available.
+   * @param systemId The system identifier provided in the XML
+   *                 document.
+   * @return The new input source, or null to require the
+   *         default behaviour.
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.EntityResolver#resolveEntity
+   *
+   * @throws SAXException
+   */
+  public InputSource resolveEntity(String publicId, String systemId)
+          throws SAXException
+  {
+    return null;
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of DTDHandler interface.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Receive notification of a notation declaration.
+   *
+   * <p>By default, do nothing.  Application writers may override this
+   * method in a subclass if they wish to keep track of the notations
+   * declared in a document.</p>
+   *
+   * @param name The notation name.
+   * @param publicId The notation public identifier, or null if not
+   *                 available.
+   * @param systemId The notation system identifier.
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.DTDHandler#notationDecl
+   *
+   * @throws SAXException
+   */
+  public void notationDecl(String name, String publicId, String systemId)
+          throws SAXException
+  {
+
+    // no op
+  }
+
+  /**
+   * Receive notification of an unparsed entity declaration.
+   *
+   * <p>By default, do nothing.  Application writers may override this
+   * method in a subclass to keep track of the unparsed entities
+   * declared in a document.</p>
+   *
+   * @param name The entity name.
+   * @param publicId The entity public identifier, or null if not
+   *                 available.
+   * @param systemId The entity system identifier.
+   * @param notationName The name of the associated notation.
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.DTDHandler#unparsedEntityDecl
+   *
+   * @throws SAXException
+   */
+  public void unparsedEntityDecl(
+          String name, String publicId, String systemId, String notationName)
+            throws SAXException
+  {
+
+    if (null == m_entities)
+    {
+      m_entities = new Vector();
+    }
+
+    try
+    {
+      systemId = SystemIDResolver.getAbsoluteURI(systemId,
+                                                 getDocumentBaseURI());
+    }
+    catch (Exception e)
+    {
+      throw new org.xml.sax.SAXException(e);
+    }
+
+    //  private static final int ENTITY_FIELD_PUBLICID = 0;
+    m_entities.addElement(publicId);
+
+    //  private static final int ENTITY_FIELD_SYSTEMID = 1;
+    m_entities.addElement(systemId);
+
+    //  private static final int ENTITY_FIELD_NOTATIONNAME = 2;
+    m_entities.addElement(notationName);
+
+    //  private static final int ENTITY_FIELD_NAME = 3;
+    m_entities.addElement(name);
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of ContentHandler interface.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Receive a Locator object for document events.
+   *
+   * <p>By default, do nothing.  Application writers may override this
+   * method in a subclass if they wish to store the locator for use
+   * with other document events.</p>
+   *
+   * @param locator A locator for all SAX document events.
+   * @see org.xml.sax.ContentHandler#setDocumentLocator
+   * @see org.xml.sax.Locator
+   */
+  public void setDocumentLocator(Locator locator)
+  {
+    m_locator = locator;
+  }
+
+  /**
+   * Receive notification of the beginning of the document.
+   *
+   * <p>By default, do nothing.  Application writers may override this
+   * method in a subclass to take specific actions at the beginning
+   * of a document (such as allocating the root node of a tree or
+   * creating an output file).</p>
+   *
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.ContentHandler#startDocument
+   */
+  public void startDocument() throws SAXException
+  {
+    m_contextIndexes.push(m_prefixMappings.size());  // for the next element.
+  }
+
+  /**
+   * Receive notification of the end of the document.
+   *
+   * <p>By default, do nothing.  Application writers may override this
+   * method in a subclass to take specific actions at the end
+   * of a document (such as finalising a tree or closing an output
+   * file).</p>
+   *
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.ContentHandler#endDocument
+   */
+  public void endDocument() throws SAXException
+  {
+
+    charactersFlush();
+    m_info.setElementAt(DTM.NULL, OFFSET_NEXTSIBLING);
+
+    int lastNode = m_previous;
+
+    if (DTM.NULL != m_previous)
+    {
+      int startInfo = lastNode * NODEINFOBLOCKSIZE;
+
+      m_info.setElementAt(DTM.NULL, startInfo + OFFSET_NEXTSIBLING);
+    }
+
+    m_parents = null;
+    m_prefixMappings = null;
+    m_contextIndexes = null;
+
+    m_level--;
+
+    m_endDocumentOccured = true;
+  }
+
+  /**
+   * Receive notification of the start of a Namespace mapping.
+   *
+   * <p>By default, do nothing.  Application writers may override this
+   * method in a subclass to take specific actions at the start of
+   * each Namespace prefix scope (such as storing the prefix mapping).</p>
+   *
+   * @param prefix The Namespace prefix being declared.
+   * @param uri The Namespace URI mapped to the prefix.
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.ContentHandler#startPrefixMapping
+   */
+  public void startPrefixMapping(String prefix, String uri)
+          throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("startPrefixMapping: prefix: " + prefix + ", uri: "
+                         + uri);
+
+    m_prefixMappings.addElement(prefix);  // JDK 1.1.x compat -sc
+    m_prefixMappings.addElement(uri);  // JDK 1.1.x compat -sc
+  }
+
+  /**
+   * Receive notification of the end of a Namespace mapping.
+   *
+   * <p>By default, do nothing.  Application writers may override this
+   * method in a subclass to take specific actions at the end of
+   * each prefix mapping.</p>
+   *
+   * @param prefix The Namespace prefix being declared.
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.ContentHandler#endPrefixMapping
+   */
+  public void endPrefixMapping(String prefix) throws SAXException
+  {
+
+    if (DEBUG)
+      System.out.println("endPrefixMapping: prefix: " + prefix);
+
+    int start = m_contextIndexes.peek();
+    int index = m_prefixMappings.indexOf(prefix, start);
+
+    if (index > -1)
+    {
+      m_prefixMappings.setElementAt("%@$#^@#", index);
+      m_prefixMappings.setElementAt("%@$#^@#", index + 1);
+    }
+
+    // no op
+  }
+
+  /**
+   * Check if a declaration has already been made for a given prefix.
+   *
+   * @param prefix non-null prefix string.
+   *
+   * @return true if the declaration has already been declared in the
+   *         current context.
+   */
+  protected boolean declAlreadyDeclared(String prefix)
+  {
+
+    int startDecls = m_contextIndexes.peek();
+    java.util.Vector prefixMappings = m_prefixMappings;
+    int nDecls = prefixMappings.size();
+
+    for (int i = startDecls; i < nDecls; i += 2)
+    {
+      String prefixDecl = (String) prefixMappings.elementAt(i);
+
+      if (prefixDecl == null)
+        continue;
+
+      if (prefixDecl.equals(prefix))
+        return true;
+    }
+
+    return false;
+  }
+
+  /**
+   * Receive notification of the start of an element.
+   *
+   * <p>By default, do nothing.  Application writers may override this
+   * method in a subclass to take specific actions at the start of
+   * each element (such as allocating a new tree node or writing
+   * output to a file).</p>
+   *
+   * @param name The element type name.
+   *
+   * @param uri The Namespace URI, or the empty string if the
+   *        element has no Namespace URI or if Namespace
+   *        processing is not being performed.
+   * @param localName The local name (without prefix), or the
+   *        empty string if Namespace processing is not being
+   *        performed.
+   * @param qName The qualified name (with prefix), or the
+   *        empty string if qualified names are not available.
+   * @param attributes The specified or defaulted attributes.
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.ContentHandler#startElement
+   */
+  public void startElement(
+          String uri, String localName, String qName, Attributes attributes)
+            throws SAXException
+  {
+
+    charactersFlush();
+
+    int exName = m_ent.getExpandedNameID(uri, localName, DTM.ELEMENT_NODE);
+    String prefix = getPrefix(qName, uri);
+    int prefixIndex = (null != prefix)
+                      ? m_valuesOrPrefixes.stringToIndex(qName) : 0;
+    int elemNode = addNode(DTM.ELEMENT_NODE, exName, m_level,
+                           m_parents.peek(), m_previous, prefixIndex, true);
+
+    m_level++;
+
+    m_parents.push(elemNode);
+
+    int startDecls = m_contextIndexes.peek();
+    int nDecls = m_prefixMappings.size();
+    int prev = DTM.NULL;
+
+    for (int i = startDecls; i < nDecls; i += 2)
+    {
+      prefix = (String) m_prefixMappings.elementAt(i);
+
+      if (prefix == null)
+        continue;
+
+      String declURL = (String) m_prefixMappings.elementAt(i + 1);
+
+      exName = m_ent.getExpandedNameID(null, prefix, DTM.NAMESPACE_NODE);
+
+      int val = m_valuesOrPrefixes.stringToIndex(declURL);
+
+      prev = addNode(DTM.NAMESPACE_NODE, exName, m_level, elemNode, prev,
+                     val, false);
+    }
+
+    int n = attributes.getLength();
+
+    for (int i = 0; i < n; i++)
+    {
+      String attrUri = attributes.getURI(i);
+      String attrQName = attributes.getQName(i);
+      String valString = attributes.getValue(i);
+
+      prefix = getPrefix(attrQName, attrUri);
+
+      int nodeType;
+
+      if ((null != attrQName)
+              && (attrQName.equals("xmlns")
+                  || attrQName.startsWith("xmlns:")))
+      {
+        if (declAlreadyDeclared(prefix))
+          continue;  // go to the next attribute.
+
+        nodeType = DTM.NAMESPACE_NODE;
+      }
+      else
+      {
+        nodeType = DTM.ATTRIBUTE_NODE;
+
+        if (attributes.getType(i).equalsIgnoreCase("ID"))
+          setIDAttribute(valString, elemNode);
+      }
+
+      int val = m_valuesOrPrefixes.stringToIndex(valString);
+      String attrLocalName = attributes.getLocalName(i);
+
+      if (null != prefix)
+      {
+        prefixIndex = m_valuesOrPrefixes.stringToIndex(attrQName);
+
+        int dataIndex = m_data.size();
+
+        m_data.addElement(prefixIndex);
+        m_data.addElement(val);
+
+        val = -dataIndex;
+      }
+
+      exName = m_ent.getExpandedNameID(attrUri, attrLocalName, nodeType);
+      prev = addNode(nodeType, exName, m_level, elemNode, prev, val, false);
+    }
+
+    if (DTM.NULL != prev)
+    {
+      int startInfo = prev * NODEINFOBLOCKSIZE;
+
+      m_info.setElementAt(DTM.NULL, startInfo + OFFSET_NEXTSIBLING);
+    }
+
+    if (null != m_wsfilter)
+    {
+      short wsv = m_wsfilter.getShouldStripSpace(elemNode);
+      boolean shouldStrip = (DTMWSFilter.INHERIT == wsv)
+                            ? getShouldStripWhitespace()
+                            : (DTMWSFilter.STRIP == wsv);
+
+      pushShouldStripWhitespace(shouldStrip);
+    }
+
+    m_previous = DTM.NULL;
+
+    m_contextIndexes.push(m_prefixMappings.size());  // for the children.
+  }
+
+  /**
+   * Receive notification of the end of an element.
+   *
+   * <p>By default, do nothing.  Application writers may override this
+   * method in a subclass to take specific actions at the end of
+   * each element (such as finalising a tree node or writing
+   * output to a file).</p>
+   *
+   * @param name The element type name.
+   * @param attributes The specified or defaulted attributes.
+   *
+   * @param uri The Namespace URI, or the empty string if the
+   *        element has no Namespace URI or if Namespace
+   *        processing is not being performed.
+   * @param localName The local name (without prefix), or the
+   *        empty string if Namespace processing is not being
+   *        performed.
+   * @param qName The qualified XML 1.0 name (with prefix), or the
+   *        empty string if qualified names are not available.
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.ContentHandler#endElement
+   */
+  public void endElement(String uri, String localName, String qName)
+          throws SAXException
+  {
+
+    charactersFlush();
+
+    // If no one noticed, startPrefixMapping is a drag.
+    // Pop the context for the last child (the one pushed by startElement)
+    m_prefixMappings.setSize(m_contextIndexes.pop());
+
+    // Do it again for this one (the one pushed by the last endElement).
+    m_prefixMappings.setSize(m_contextIndexes.pop());
+    m_contextIndexes.push(m_prefixMappings.size());  // for the next element.
+
+    m_level--;
+
+    int lastNode = m_previous;
+
+    m_previous = m_parents.pop();
+
+    int startInfo = m_previous * NODEINFOBLOCKSIZE;
+
+    if (m_info.elementAt(startInfo + OFFSET_FIRSTCHILD) == NOTPROCESSED)
+    {
+      m_info.setElementAt(DTM.NULL, startInfo + OFFSET_FIRSTCHILD);
+    }
+    else if (DTM.NULL != lastNode)
+    {
+      startInfo = lastNode * NODEINFOBLOCKSIZE;
+
+      m_info.setElementAt(DTM.NULL, startInfo + OFFSET_NEXTSIBLING);
+    }
+
+    popShouldStripWhitespace();
+  }
+
+  /**
+   * Receive notification of character data inside an element.
+   *
+   * <p>By default, do nothing.  Application writers may override this
+   * method to take specific actions for each chunk of character data
+   * (such as adding the data to a node or buffer, or printing it to
+   * a file).</p>
+   *
+   * @param ch The characters.
+   * @param start The start position in the character array.
+   * @param length The number of characters to use from the
+   *               character array.
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.ContentHandler#characters
+   */
+  public void characters(char ch[], int start, int length) throws SAXException
+  {
+
+    if (m_textPendingStart == -1)  // First one in this block
+    {
+      m_textPendingStart = m_chars.size();
+      m_coalescedTextType = m_textType;
+    }
+
+    m_chars.append(ch, start, length);
+
+    // Type logic: If all adjacent text is CDATASections, the
+    // concatentated text is treated as a single CDATASection (see
+    // initialization above).  If any were ordinary Text, the whole
+    // thing is treated as Text. This may be worth %REVIEW%ing.
+    if (m_textType == DTM.TEXT_NODE)
+      m_coalescedTextType = DTM.TEXT_NODE;
+  }
+
+  /**
+   * Receive notification of ignorable whitespace in element content.
+   *
+   * <p>By default, do nothing.  Application writers may override this
+   * method to take specific actions for each chunk of ignorable
+   * whitespace (such as adding data to a node or buffer, or printing
+   * it to a file).</p>
+   *
+   * @param ch The whitespace characters.
+   * @param start The start position in the character array.
+   * @param length The number of characters to use from the
+   *               character array.
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.ContentHandler#ignorableWhitespace
+   */
+  public void ignorableWhitespace(char ch[], int start, int length)
+          throws SAXException
+  {
+
+    // %OPT% We can probably take advantage of the fact that we know this 
+    // is whitespace.
+    characters(ch, start, length);
+  }
+
+  /**
+   * Receive notification of a processing instruction.
+   *
+   * <p>By default, do nothing.  Application writers may override this
+   * method in a subclass to take specific actions for each
+   * processing instruction, such as setting status variables or
+   * invoking other methods.</p>
+   *
+   * @param target The processing instruction target.
+   * @param data The processing instruction data, or null if
+   *             none is supplied.
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.ContentHandler#processingInstruction
+   */
+  public void processingInstruction(String target, String data)
+          throws SAXException
+  {
+
+    charactersFlush();
+
+    int exName = m_ent.getExpandedNameID(null, target,
+                                         DTM.PROCESSING_INSTRUCTION_NODE);
+    int dataIndex = m_valuesOrPrefixes.stringToIndex(data);
+
+    m_previous = addNode(DTM.PROCESSING_INSTRUCTION_NODE, exName, m_level,
+                         m_parents.peek(), m_previous, dataIndex, false);
+  }
+
+  /**
+   * Receive notification of a skipped entity.
+   *
+   * <p>By default, do nothing.  Application writers may override this
+   * method in a subclass to take specific actions for each
+   * processing instruction, such as setting status variables or
+   * invoking other methods.</p>
+   *
+   * @param name The name of the skipped entity.
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.ContentHandler#processingInstruction
+   */
+  public void skippedEntity(String name) throws SAXException
+  {
+
+    // %REVIEW% What should be done here?
+    // no op
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of the ErrorHandler interface.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Receive notification of a parser warning.
+   *
+   * <p>The default implementation does nothing.  Application writers
+   * may override this method in a subclass to take specific actions
+   * for each warning, such as inserting the message in a log file or
+   * printing it to the console.</p>
+   *
+   * @param e The warning information encoded as an exception.
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.ErrorHandler#warning
+   * @see org.xml.sax.SAXParseException
+   */
+  public void warning(SAXParseException e) throws SAXException
+  {
+
+    // %REVIEW% Is there anyway to get the JAXP error listener here?
+    System.err.println(e.getMessage());
+  }
+
+  /**
+   * Receive notification of a recoverable parser error.
+   *
+   * <p>The default implementation does nothing.  Application writers
+   * may override this method in a subclass to take specific actions
+   * for each error, such as inserting the message in a log file or
+   * printing it to the console.</p>
+   *
+   * @param e The warning information encoded as an exception.
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.ErrorHandler#warning
+   * @see org.xml.sax.SAXParseException
+   */
+  public void error(SAXParseException e) throws SAXException
+  {
+    throw e;
+  }
+
+  /**
+   * Report a fatal XML parsing error.
+   *
+   * <p>The default implementation throws a SAXParseException.
+   * Application writers may override this method in a subclass if
+   * they need to take specific actions for each fatal error (such as
+   * collecting all of the errors into a single report): in any case,
+   * the application must stop all regular processing when this
+   * method is invoked, since the document is no longer reliable, and
+   * the parser may no longer report parsing events.</p>
+   *
+   * @param e The error information encoded as an exception.
+   * @throws SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.ErrorHandler#fatalError
+   * @see org.xml.sax.SAXParseException
+   */
+  public void fatalError(SAXParseException e) throws SAXException
+  {
+    throw e;
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of the DeclHandler interface.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Report an element type declaration.
+   *
+   * <p>The content model will consist of the string "EMPTY", the
+   * string "ANY", or a parenthesised group, optionally followed
+   * by an occurrence indicator.  The model will be normalized so
+   * that all whitespace is removed,and will include the enclosing
+   * parentheses.</p>
+   *
+   * @param name The element type name.
+   * @param model The content model as a normalized string.
+   * @throws SAXException The application may raise an exception.
+   */
+  public void elementDecl(String name, String model) throws SAXException
+  {
+
+    // no op
+  }
+
+  /**
+   * Report an attribute type declaration.
+   *
+   * <p>Only the effective (first) declaration for an attribute will
+   * be reported.  The type will be one of the strings "CDATA",
+   * "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY",
+   * "ENTITIES", or "NOTATION", or a parenthesized token group with
+   * the separator "|" and all whitespace removed.</p>
+   *
+   * @param eName The name of the associated element.
+   * @param aName The name of the attribute.
+   * @param type A string representing the attribute type.
+   * @param valueDefault A string representing the attribute default
+   *        ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
+   *        none of these applies.
+   * @param value A string representing the attribute's default value,
+   *        or null if there is none.
+   * @throws SAXException The application may raise an exception.
+   */
+  public void attributeDecl(
+          String eName, String aName, String type, String valueDefault, String value)
+            throws SAXException
+  {
+
+    // no op
+  }
+
+  /**
+   * Report an internal entity declaration.
+   *
+   * <p>Only the effective (first) declaration for each entity
+   * will be reported.</p>
+   *
+   * @param name The name of the entity.  If it is a parameter
+   *        entity, the name will begin with '%'.
+   * @param value The replacement text of the entity.
+   * @throws SAXException The application may raise an exception.
+   * @see #externalEntityDecl
+   * @see org.xml.sax.DTDHandler#unparsedEntityDecl
+   */
+  public void internalEntityDecl(String name, String value)
+          throws SAXException
+  {
+
+    // no op
+  }
+
+  /**
+   * Report a parsed external entity declaration.
+   *
+   * <p>Only the effective (first) declaration for each entity
+   * will be reported.</p>
+   *
+   * @param name The name of the entity.  If it is a parameter
+   *        entity, the name will begin with '%'.
+   * @param publicId The declared public identifier of the entity, or
+   *        null if none was declared.
+   * @param systemId The declared system identifier of the entity.
+   * @throws SAXException The application may raise an exception.
+   * @see #internalEntityDecl
+   * @see org.xml.sax.DTDHandler#unparsedEntityDecl
+   */
+  public void externalEntityDecl(
+          String name, String publicId, String systemId) throws SAXException
+  {
+
+    // no op
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of the LexicalHandler interface.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Report the start of DTD declarations, if any.
+   *
+   * <p>Any declarations are assumed to be in the internal subset
+   * unless otherwise indicated by a {@link #startEntity startEntity}
+   * event.</p>
+   *
+   * <p>Note that the start/endDTD events will appear within
+   * the start/endDocument events from ContentHandler and
+   * before the first startElement event.</p>
+   *
+   * @param name The document type name.
+   * @param publicId The declared public identifier for the
+   *        external DTD subset, or null if none was declared.
+   * @param systemId The declared system identifier for the
+   *        external DTD subset, or null if none was declared.
+   * @throws SAXException The application may raise an
+   *            exception.
+   * @see #endDTD
+   * @see #startEntity
+   */
+  public void startDTD(String name, String publicId, String systemId)
+          throws SAXException
+  {
+
+    // no op
+  }
+
+  /**
+   * Report the end of DTD declarations.
+   *
+   * @throws SAXException The application may raise an exception.
+   * @see #startDTD
+   */
+  public void endDTD() throws SAXException
+  {
+
+    // no op
+  }
+
+  /**
+   * Report the beginning of an entity in content.
+   *
+   * <p><strong>NOTE:</entity> entity references in attribute
+   * values -- and the start and end of the document entity --
+   * are never reported.</p>
+   *
+   * <p>The start and end of the external DTD subset are reported
+   * using the pseudo-name "[dtd]".  All other events must be
+   * properly nested within start/end entity events.</p>
+   *
+   * <p>Note that skipped entities will be reported through the
+   * {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity}
+   * event, which is part of the ContentHandler interface.</p>
+   *
+   * @param name The name of the entity.  If it is a parameter
+   *        entity, the name will begin with '%'.
+   * @throws SAXException The application may raise an exception.
+   * @see #endEntity
+   * @see org.xml.sax.ext.DeclHandler#internalEntityDecl
+   * @see org.xml.sax.ext.DeclHandler#externalEntityDecl
+   */
+  public void startEntity(String name) throws SAXException
+  {
+
+    // no op
+  }
+
+  /**
+   * Report the end of an entity.
+   *
+   * @param name The name of the entity that is ending.
+   * @throws SAXException The application may raise an exception.
+   * @see #startEntity
+   */
+  public void endEntity(String name) throws SAXException
+  {
+
+    // no op
+  }
+
+  /**
+   * Report the start of a CDATA section.
+   *
+   * <p>The contents of the CDATA section will be reported through
+   * the regular {@link org.xml.sax.ContentHandler#characters
+   * characters} event.</p>
+   *
+   * @throws SAXException The application may raise an exception.
+   * @see #endCDATA
+   */
+  public void startCDATA() throws SAXException
+  {
+    m_textType = DTM.CDATA_SECTION_NODE;
+  }
+
+  /**
+   * Report the end of a CDATA section.
+   *
+   * @throws SAXException The application may raise an exception.
+   * @see #startCDATA
+   */
+  public void endCDATA() throws SAXException
+  {
+    m_textType = DTM.TEXT_NODE;
+  }
+
+  /**
+   * Report an XML comment anywhere in the document.
+   *
+   * <p>This callback will be used for comments inside or outside the
+   * document element, including comments in the external DTD
+   * subset (if read).</p>
+   *
+   * @param ch An array holding the characters in the comment.
+   * @param start The starting position in the array.
+   * @param length The number of characters to use from the array.
+   * @throws SAXException The application may raise an exception.
+   */
+  public void comment(char ch[], int start, int length) throws SAXException
+  {
+
+    charactersFlush();
+
+    int exName = m_ent.getExpandedNameID(DTM.COMMENT_NODE);
+
+    // For now, treat comments as strings...  I guess we should do a 
+    // seperate FSB buffer instead.
+    int dataIndex = m_valuesOrPrefixes.stringToIndex(new String(ch, start,
+                      length));
+
+    m_previous = addNode(DTM.COMMENT_NODE, exName, m_level, m_parents.peek(),
+                         m_previous, dataIndex, false);
+  }
+}
diff --git a/src/org/apache/xml/utils/DOMBuilder.java b/src/org/apache/xml/utils/DOMBuilder.java
index daec0d7..e0f7645 100644
--- a/src/org/apache/xml/utils/DOMBuilder.java
+++ b/src/org/apache/xml/utils/DOMBuilder.java
@@ -59,6 +59,7 @@
 import org.apache.xalan.res.XSLMessages;
 import org.apache.xpath.res.XPATHErrorResources;
 import org.apache.xml.utils.NodeVector;
+import java.util.Stack;
 
 import org.xml.sax.ext.LexicalHandler;
 import org.xml.sax.ContentHandler;
@@ -87,7 +88,7 @@
   public DocumentFragment m_docFrag = null;
 
   /** Vector of element nodes          */
-  protected NodeVector m_elemStack = new NodeVector();
+  protected Stack m_elemStack = new Stack();
 
   /**
    * DOMBuilder instance constructor... it will add the DOM nodes
@@ -375,7 +376,8 @@
   public void endElement(String ns, String localName, String name)
           throws org.xml.sax.SAXException
   {
-    m_currentNode = m_elemStack.popAndTop();
+    m_elemStack.pop();
+    m_currentNode = m_elemStack.isEmpty() ? null : (Node)m_elemStack.peek();
   }
 
   /**
diff --git a/src/org/apache/xml/utils/DTM.java b/src/org/apache/xml/utils/DTM.java
deleted file mode 100644
index 5d18c79..0000000
--- a/src/org/apache/xml/utils/DTM.java
+++ /dev/null
@@ -1,637 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xml.utils;
-
-/**
- * <meta name="usage" content="internal"/>
- * <code>DTM</code> is an XML document model expressed as a table rather than
- * an object tree. It attempts to provide an interface to a parse tree that 
- * has very little object creation.
- * 
- * <p>Nodes in the DTM are identified by integer "handles".  A handle must 
- * be unique within a document.  A processing application must be careful, 
- * because a handle is not unique within a process... you can have two 
- * handles that belong to different documents.  It is up to the calling 
- * application to keep track of the association of a document with it's 
- * handle.</p>
- * 
- * <p>Namespace URLs, local-names, and expanded-names can all be represented 
- * by integer ID values.  An expanded name is made of a combination of the URL 
- * ID in the high two bytes, and the local-name ID is held in the low two 
- * bytes.  Thus a comparison of an expanded name can be quickly made in a 
- * single operation.  Also, the symbol space for URLs and local-names must 
- * be limited to 32K each (if you are to only use positive values for index 
- * lookup), which means that these should not be part of a general string 
- * pool mechanism.  Note that the namespace URL id can be 0, which should have 
- * the meaning that the namespace is null.  Zero should also not be used for 
- * a local-name index.</p>
- * 
- * <p>The model of the tree, as well as the general navigation model, is 
- * that of XPath 1.0, for the moment.  The model will be adapted to match
- * the XPath 2.0 data model, XML Schema, and InfoSet.</p>
- * 
- * <p>DTM does _not_ directly support the W3C's Document Object Model. However,
- * it attempts to come close enough that an implementation of DTM can be created 
- * that wraps a DOM.</p>
- * <p>State: In progress!!</p>
- */
-public interface DTM
-{
-
-  // These are the same as the DOM on purpose.
-  /**
-   * The node is an <code>Element</code>.
-   */
-  public static final short ELEMENT_NODE              = 1;
-  /**
-   * The node is an <code>Attr</code>.
-   */
-  public static final short ATTRIBUTE_NODE            = 2;
-  /**
-   * The node is a <code>Text</code> node.
-   */
-  public static final short TEXT_NODE                 = 3;
-  /**
-   * The node is a <code>CDATASection</code>.
-   */
-  public static final short CDATA_SECTION_NODE        = 4;
-  /**
-   * The node is an <code>EntityReference</code>.
-   */
-  public static final short ENTITY_REFERENCE_NODE     = 5;
-  /**
-   * The node is an <code>Entity</code>.
-   */
-  public static final short ENTITY_NODE               = 6;
-  /**
-   * The node is a <code>ProcessingInstruction</code>.
-   */
-  public static final short PROCESSING_INSTRUCTION_NODE = 7;
-  /**
-   * The node is a <code>Comment</code>.
-   */
-  public static final short COMMENT_NODE              = 8;
-  /**
-   * The node is a <code>Document</code>.
-   */
-  public static final short DOCUMENT_NODE             = 9;
-  /**
-   * The node is a <code>DocumentType</code>.
-   */
-  public static final short DOCUMENT_TYPE_NODE        = 10;
-  /**
-   * The node is a <code>DocumentFragment</code>.
-   */
-  public static final short DOCUMENT_FRAGMENT_NODE    = 11;
-  /**
-   * The node is a <code>Notation</code>.
-   */
-  public static final short NOTATION_NODE             = 12;
-
-  /**
-   * The node is a <code>namespace node</code>.
-   */
-  public static final short NAMESPACE_NODE             = 113;
-  
-  // ========= DTM Implementation Control Functions. ==============
-
-  /**
-   * Set a suggested parse block size for the parser.
-   *
-   * @param blockSizeSuggestion Suggested size of the parse blocks, in bytes.
-   */
-  public void setParseBlockSize(int blockSizeSuggestion);
-
-  /**
-   * Set an implementation dependent feature.
-   *
-   * @param featureId A feature URL.
-   * @param state true if this feature should be on, false otherwise.
-   */
-  public void setFeature(String featureId, boolean state);
-  
-  // ========= Document Navigation Functions =========
-
-  /**
-   * Given a node handle, get the handle of the node's first child.
-   * If not yet resolved, waits for more nodes to be added to the document and
-   * tries again.
-   * 
-   * @param nodeHandle int Handle of the node..
-   * @return int DTM node-number of first child, or -1 to indicate none exists.
-   */
-  public int getFirstChild(int nodeHandle);
-
-  /**
-   * Given a node handle, advance to its last child.
-   * If not yet resolved, waits for more nodes to be added to the document and
-   * tries again.
-   * 
-   * @param nodeHandle int Handle of the node..
-   * @return int Node-number of last child,
-   * or -1 to indicate none exists.
-   */
-  public int getLastChild(int nodeHandle);
-
-  /**
-   * Given a node handle, get the index of the node's first attribute.
-   * 
-   * @param nodeHandle int Handle of the node..
-   * @return Handle of first attribute, or -1 to indicate none exists.
-   */
-  public int getFirstAttribute(int nodeHandle);
-  
-  /**
-   * Given a node handle, get the index of the node's first child.
-   * If not yet resolved, waits for more nodes to be added to the document and
-   * tries again
-   * 
-   * @param nodeHandle handle to node, which should probably be an element 
-   *                   node, but need not be.
-   *                   
-   * @param inScope    true if all namespaces in scope should be returned, 
-   *                   false if only the namespace declarations should be 
-   *                   returned.
-   * @return handle of first namespace, or -1 to indicate none exists.
-   */
-  public int getFirstNamespaceNode(int nodeHandle, boolean inScope);
-
-  /**
-   * Given a node handle, advance to its next sibling.
-   * If not yet resolved, waits for more nodes to be added to the document and
-   * tries again.
-   * @param nodeHandle int Handle of the node..
-   * @return int Node-number of next sibling,
-   * or -1 to indicate none exists.
-   */
-  public int getNextSibling(int nodeHandle);
-  
-  /**
-   * Given a node handle, find its preceeding sibling.
-   * WARNING: DTM is asymmetric; this operation is resolved by search, and is
-   * relatively expensive.
-   * @param postition int Handle of the node..
-   *
-   * @param nodeHandle the id of the node.
-   * @return int Node-number of the previous sib,
-   * or -1 to indicate none exists.
-   */
-  public int getPreviousSibling(int nodeHandle);
-
-  /**
-   * Given a node handle, advance to the next attribute. If an
-   * element, we advance to its first attribute; if an attr, we advance to
-   * the next attr on the same node.
-   * 
-   * @param nodeHandle int Handle of the node..
-   * @return int DTM node-number of the resolved attr,
-   * or -1 to indicate none exists.
-   */
-  public int getNextAttribute(int nodeHandle);
-
-  /**
-   * Given a namespace handle, advance to the next namespace.
-   * 
-   * @param namespaceHandle handle to node which must be of type NAMESPACE_NODE.
-   * @return handle of next namespace, or -1 to indicate none exists.
-   */
-  public int getNextNamespaceNode(int namespaceHandle, boolean inScope);
-
-  /**
-   * Given a node handle, advance to its next descendant.
-   * If not yet resolved, waits for more nodes to be added to the document and
-   * tries again.
-   *
-   * @param subtreeRootNodeHandle
-   * @param nodeHandle int Handle of the node..
-   * @return handle of next descendant,
-   * or -1 to indicate none exists.
-   */
-  public int getNextDescendant(int subtreeRootHandle, int nodeHandle);
-
-  /**
-   * Given a node handle, advance to the next node on the following axis.
-   *
-   * @param axisContextHandle the start of the axis that is being traversed.
-   * @param nodeHandle
-   * @return handle of next sibling,
-   * or -1 to indicate none exists.
-   */
-  public int getNextFollowing(int axisContextHandle, int nodeHandle);
-  
-  /**
-   * Given a node handle, advance to the next node on the preceding axis.
-   * 
-   * @param axisContextHandle the start of the axis that is being traversed.
-   * @param nodeHandle the id of the node.
-   * @return int Node-number of preceding sibling,
-   * or -1 to indicate none exists.
-   */
-  public int getNextPreceding(int axisContextHandle, int nodeHandle);
-
-  /**
-   * Given a node handle, find its parent node.
-   * @param postition int Handle of the node..
-   *
-   * @param nodeHandle the id of the node.
-   * @return int Node-number of parent,
-   * or -1 to indicate none exists.
-   */
-  public int getParent(int nodeHandle);
-
-  /**
-   * Get the string-value of a node as a String object
-   * (see http://www.w3.org/TR/xpath#data-model 
-   * for the definition of a node's string-value).
-   *
-   * @param nodeHandle The node ID.
-   *
-   * @return A string object that represents the string-value of the given node.
-   */
-  public String getStringValue(int nodeHandle);
-  
-  /**
-   * Get number of character array chunks in 
-   * the string-value of a node.
-   * (see http://www.w3.org/TR/xpath#data-model 
-   * for the definition of a node's string-value).
-   * Note that a single text node may have multiple text chunks.
-   *
-   * @param nodeHandle The node ID.
-   *
-   * @return number of character array chunks in 
-   *         the string-value of a node.
-   */
-  public int getStringValueChunkCount(int nodeHandle);
-  
-  /**
-   * Get a character array chunk in the string-value of a node.
-   * (see http://www.w3.org/TR/xpath#data-model 
-   * for the definition of a node's string-value).
-   * Note that a single text node may have multiple text chunks.
-   *
-   * @param nodeHandle The node ID.
-   * @param chunkIndex Which chunk to get.
-   * @param startAndLen An array of 2 where the start position and length of 
-   *                    the chunk will be returned.
-   *
-   * @return The character array reference where the chunk occurs.
-   */
-  public char[] getStringValueChunk(int nodeHandle, int chunkIndex, 
-                                    int[] startAndLen);
-
-  /**
-   * Given a node handle, return an ID that represents the node's expanded name.
-   * 
-   * @param nodeHandle The handle to the node in question.
-   *
-   * @return the expanded-name id of the node.
-   */
-  public int getExpandedNameID(int nodeHandle);
-  
-  /**
-   * Given an expanded name, return an ID.  If the expanded-name does not 
-   * exist in the internal tables, the entry will be created, and the ID will 
-   * be returned.  Any additional nodes that are created that have this 
-   * expanded name will use this ID.
-   * 
-   * @param nodeHandle The handle to the node in question.
-   *
-   * @return the expanded-name id of the node.
-   */
-  public int getExpandedNameID(String namespace, String localName);
-  
-  /**
-   * Given an expanded-name ID, return the local name part.
-   *
-   * @param ExpandedNameID an ID that represents an expanded-name.
-   * @return String Local name of this node.
-   */
-  public String getLocalNameFromExpandedNameID(int ExpandedNameID);
-  
-  /**
-   * Given an expanded-name ID, return the namespace URI part.
-   *
-   * @param ExpandedNameID an ID that represents an expanded-name.
-   * @return String URI value of this node's namespace, or null if no
-   * namespace was resolved.
-   */
-  public String getNamespaceFromExpandedNameID(int ExpandedNameID);
-
-  /**
-   * Given a node handle, return its DOM-style node name.
-   *
-   * @param nodeHandle the id of the node.
-   * @return String Name of this node.
-   */
-  public String getNodeName(int nodeHandle);
-
-  /**
-   * Given a node handle, return its DOM-style localname.
-   * (As defined in Namespaces, this is the portion of the name after any
-   * colon character)
-   *
-   * @param nodeHandle the id of the node.
-   * @return String Local name of this node.
-   */
-  public String getLocalName(int nodeHandle);
-
-  /**
-   * Given a node handle, return its DOM-style name prefix.
-   * (As defined in Namespaces, this is the portion of the name before any
-   * colon character)
-   * @param postition int Handle of the node..
-   *
-   * @param nodeHandle the id of the node.
-   * @return String prefix of this node's name, or null if no explicit
-   * namespace prefix was given.
-   */
-  public String getPrefix(int nodeHandle);
-
-  /**
-   * Given a node handle, return its DOM-style namespace URI
-   * (As defined in Namespaces, this is the declared URI which this node's
-   * prefix -- or default in lieu thereof -- was mapped to.)
-   * @param postition int Handle of the node..
-   *
-   * @param nodeHandle the id of the node.
-   * @return String URI value of this node's namespace, or null if no
-   * namespace was resolved.
-   */
-  public String getNamespaceURI(int nodeHandle);
-
-  /**
-   * Given a node handle, return its node value. This is mostly
-   * as defined by the DOM, but may ignore some conveniences.
-   * <p>
-   * @param postition int Handle of the node..
-   *
-   * @param nodeHandle The node id.
-   * @return String Value of this node, or null if not
-   * meaningful for this node type.
-   */
-  public String getNodeValue(int nodeHandle);
-
-  /**
-   * Given a node handle, return its DOM-style node type.
-   * @param postition int Handle of the node..
-   *
-   * @param nodeHandle The node id.
-   * @return int Node type, as per the DOM's Node._NODE constants.
-   */
-  public int getNodeType(int nodeHandle);
-  
-  /**
-   * <meta name="usage" content="internal"/>
-   * Get the depth level of this node in the tree (equals 1 for
-   * a parentless node).
-   *
-   * @param nodeHandle The node id.
-   * @return the number of ancestors, plus one
-   */
-  public short getLevel(int nodeHandle);
-  
-  // ============== Document query functions ============== 
-  
-  /**
-   * Return the base URI of the document entity. If it is not known
-   * (because the document was parsed from a socket connection or from
-   * standard input, for example), the value of this property is unknown.
-   *
-   * @param nodeHandle The node id, which can be any valid node handle.
-   * @return the document base URI String object or null if unknown.
-   */
-  public String getDocumentBaseURI(int nodeHandle);
-
-  /**
-   * Return the system identifier of the document entity. If
-   * it is not known, the value of this property is unknown.
-   *
-   * @param nodeHandle The node id, which can be any valid node handle.
-   * @return the system identifier String object or null if unknown.
-   */
-  public int getDocumentSystemIdentifier(int nodeHandle);
-
-  /**
-   * Return the name of the character encoding scheme
-   *        in which the document entity is expressed.
-   *
-   * @param nodeHandle The node id, which can be any valid node handle.
-   * @return the document encoding String object.
-   */
-  public String getDocumentEncoding(int nodeHandle);
-
-  /**
-   * Return an indication of the standalone status of the document,
-   *        either "yes" or "no". This property is derived from the optional
-   *        standalone document declaration in the XML declaration at the
-   *        beginning of the document entity, and has no value if there is no
-   *        standalone document declaration.
-   *
-   * @param nodeHandle The node id, which can be any valid node handle.
-   * @return the document standalone String object, either "yes", "no", or null.
-   */
-  public String getDocumentStandalone(int nodeHandle);
-
-  /**
-   * Return a string representing the XML version of the document. This
-   * property is derived from the XML declaration optionally present at the
-   * beginning of the document entity, and has no value if there is no XML
-   * declaration.
-   *
-   * @param the document handle
-   *
-   * @return the document version String object
-   */
-  public String getDocumentVersion(int documentHandle);
-
-  /**
-   * Return an indication of
-   * whether the processor has read the complete DTD. Its value is a
-   * boolean. If it is false, then certain properties (indicated in their
-   * descriptions below) may be unknown. If it is true, those properties
-   * are never unknown.
-   *
-   * @return <code>true</code> if all declarations were processed;
-   *         <code>false</code> otherwise.
-   */
-  public boolean getDocumentAllDeclarationsProcessed();
-
-  /**
-   *   A document type declaration information item has the following properties:
-   *
-   *     1. [system identifier] The system identifier of the external subset, if
-   *        it exists. Otherwise this property has no value.
-   *
-   * @return the system identifier String object, or null if there is none.
-   */
-  public String getDocumentTypeDeclarationSystemIdentifier();
-
-  /**
-   * Return the public identifier of the external subset,
-   * normalized as described in 4.2.2 External Entities [XML]. If there is
-   * no external subset or if it has no public identifier, this property
-   * has no value.
-   *
-   * @param the document type declaration handle
-   *
-   * @return the public identifier String object, or null if there is none.
-   */
-  public int getDocumentTypeDeclarationPublicIdentifier();
-
-  // ============== Boolean methods ================
-  
-  /**
-   * Figure out whether nodeHandle2 should be considered as being later
-   * in the document than nodeHandle1, in Document Order as defined
-   * by the XPath model. This may not agree with the ordering defined
-   * by other XML applications.
-   * <p>
-   * There are some cases where ordering isn't defined, and neither are
-   * the results of this function -- though we'll generally return true.
-   * 
-   * TODO: Make sure this does the right thing with attribute nodes!!!
-   *
-   * @param node1 DOM Node to perform position comparison on.
-   * @param node2 DOM Node to perform position comparison on .
-   * 
-   * @return false if node2 comes before node1, otherwise return true.
-   * You can think of this as 
-   * <code>(node1.documentOrderPosition &lt;= node2.documentOrderPosition)</code>.
-   */
-  public boolean isNodeAfter(int nodeHandle1, int nodeHandle2);
-
-  /**
-   *     2. [element content whitespace] A boolean indicating whether the
-   *        character is white space appearing within element content (see [XML],
-   *        2.10 "White Space Handling"). Note that validating XML processors are
-   *        required by XML 1.0 to provide this information. If there is no
-   *        declaration for the containing element, this property has no value for
-   *        white space characters. If no declaration has been read, but the [all
-   *        declarations processed] property of the document information item is
-   *        false (so there may be an unread declaration), then the value of this
-   *        property is unknown for white space characters. It is always false for
-   *        characters that are not white space.
-   *
-   * @param nodeHandle the node ID.
-   * @return <code>true</code> if the character data is whitespace;
-   *         <code>false</code> otherwise.
-   */
-  public boolean isCharacterElementContentWhitespace(int nodeHandle);
-
-  /**
-   *    10. [all declarations processed] This property is not strictly speaking
-   *        part of the infoset of the document. Rather it is an indication of
-   *        whether the processor has read the complete DTD. Its value is a
-   *        boolean. If it is false, then certain properties (indicated in their
-   *        descriptions below) may be unknown. If it is true, those properties
-   *        are never unknown.
-   *
-   * @param the document handle
-   *
-   * @param documentHandle A node handle that must identify a document.
-   * @return <code>true</code> if all declarations were processed;
-   *         <code>false</code> otherwise.
-   */
-  public boolean isDocumentAllDeclarationsProcessed(int documentHandle);
-
-  /**
-   *     5. [specified] A flag indicating whether this attribute was actually
-   *        specified in the start-tag of its element, or was defaulted from the
-   *        DTD.
-   *
-   * @param the attribute handle
-   *
-   * NEEDSDOC @param attributeHandle
-   * @return <code>true</code> if the attribute was specified;
-   *         <code>false</code> if it was defaulted.
-   */
-  public boolean isAttributeSpecified(int attributeHandle);
-  
-  
-  // ========== Direct SAX Dispatch, for optimization purposes ========
-  
-  /**
-   * Directly call the
-   * characters method on the passed ContentHandler for the 
-   * string-value of the given node (see http://www.w3.org/TR/xpath#data-model 
-   * for the definition of a node's string-value). Multiple calls to the 
-   * ContentHandler's characters methods may well occur for a single call to 
-   * this method.
-   *
-   * @param nodeHandle The node ID.
-   * @param ch A non-null reference to a ContentHandler.
-   *
-   * @throws org.xml.sax.SAXException
-   */
-  public void dispatchCharactersEvents(
-    int nodeHandle, org.xml.sax.ContentHandler ch)
-      throws org.xml.sax.SAXException;
-
-  /**
-   * Directly create SAX parser events from a subtree.
-   *
-   * @param nodeHandle The node ID.
-   * @param ch A non-null reference to a ContentHandler.
-   *
-   * @throws org.xml.sax.SAXException
-   */
-  public void dispatchToEvents(
-    int nodeHandle, org.xml.sax.ContentHandler ch)
-      throws org.xml.sax.SAXException;
-
-}
diff --git a/src/org/apache/xml/utils/DTMFilter.java b/src/org/apache/xml/utils/DTMFilter.java
deleted file mode 100644
index ecdba3b..0000000
--- a/src/org/apache/xml/utils/DTMFilter.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package org.apache.xml.utils;
-
-/**
- * Simple filter for doing node tests.  Note the semantics of this are somewhat 
- * different that the DOM's NodeFilter.
- */
-public interface DTMFilter
-{
-
-  // Constants for whatToShow.  These are used to set the node type that will 
-  // be traversed.
-
-  /**
-   * Show all <code>Nodes</code>.
-   */
-  public static final int SHOW_ALL = 0xFFFFFFFF;
-
-  /**
-   * Show <code>Element</code> nodes.
-   */
-  public static final int SHOW_ELEMENT = 0x00000001;
-
-  /**
-   * Show <code>Attr</code> nodes. This is meaningful only when creating an
-   * iterator or tree-walker with an attribute node as its
-   * <code>root</code>; in this case, it means that the attribute node
-   * will appear in the first position of the iteration or traversal.
-   * Since attributes are never children of other nodes, they do not
-   * appear when traversing over the document tree.
-   */
-  public static final int SHOW_ATTRIBUTE = 0x00000002;
-
-  /**
-   * Show <code>Text</code> nodes.
-   */
-  public static final int SHOW_TEXT = 0x00000004;
-
-  /**
-   * Show <code>CDATASection</code> nodes.
-   */
-  public static final int SHOW_CDATA_SECTION = 0x00000008;
-
-  /**
-   * Show <code>EntityReference</code> nodes.
-   */
-  public static final int SHOW_ENTITY_REFERENCE = 0x00000010;
-
-  /**
-   * Show <code>Entity</code> nodes. This is meaningful only when creating
-   * an iterator or tree-walker with an<code> Entity</code> node as its
-   * <code>root</code>; in this case, it means that the <code>Entity</code>
-   *  node will appear in the first position of the traversal. Since
-   * entities are not part of the document tree, they do not appear when
-   * traversing over the document tree.
-   */
-  public static final int SHOW_ENTITY = 0x00000020;
-
-  /**
-   * Show <code>ProcessingInstruction</code> nodes.
-   */
-  public static final int SHOW_PROCESSING_INSTRUCTION = 0x00000040;
-
-  /**
-   * Show <code>Comment</code> nodes.
-   */
-  public static final int SHOW_COMMENT = 0x00000080;
-
-  /**
-   * Show <code>Document</code> nodes.
-   */
-  public static final int SHOW_DOCUMENT = 0x00000100;
-
-  /**
-   * Show <code>DocumentType</code> nodes.
-   */
-  public static final int SHOW_DOCUMENT_TYPE = 0x00000200;
-
-  /**
-   * Show <code>DocumentFragment</code> nodes.
-   */
-  public static final int SHOW_DOCUMENT_FRAGMENT = 0x00000400;
-
-  /**
-   * Show <code>Notation</code> nodes. This is meaningful only when creating
-   * an iterator or tree-walker with a <code>Notation</code> node as its
-   * <code>root</code>; in this case, it means that the
-   * <code>Notation</code> node will appear in the first position of the
-   * traversal. Since notations are not part of the document tree, they do
-   * not appear when traversing over the document tree.
-   */
-  public static final int SHOW_NOTATION = 0x00000800;
-  
-  /** This bit specifies a namespace, and extends the SHOW_XXX stuff 
-   *  in {@link org.w3c.dom.traversal.NodeFilter}. */
-  public static final int SHOW_NAMESPACE = 0x00001000;
-
-  /**
-   * Special bitmap for match patterns starting with a function.
-   * Make sure this does not conflict with {@link org.w3c.dom.traversal.NodeFilter}.
-   */
-  public static final int SHOW_BYFUNCTION = 0x00010000;
-
-  /**
-   * Test whether a specified node is visible in the logical view of a
-   * <code>DTMIterator</code>. Normally, this function
-   * will be called by the implementation of <code>DTMIterator</code>; 
-   * it is not normally called directly from
-   * user code.
-   * 
-   * @param nodeHandle int Handle of the node.
-   * @param whatToShow one of SHOW_XXX values.
-   * @return one of FILTER_ACCEPT, FILTER_REJECT, or FILTER_SKIP.
-   */
-  public short acceptNode(int nodeHandle, int whatToShow);
-  
-  /**
-   * Test whether a specified node is visible in the logical view of a
-   * <code>DTMIterator</code>. Normally, this function
-   * will be called by the implementation of <code>DTMIterator</code>; 
-   * it is not normally called directly from
-   * user code.
-   * 
-   * @param nodeHandle int Handle of the node.
-   * @param whatToShow one of SHOW_XXX values.
-   * @param expandedName a value defining the exanded name as defined in 
-   *                     the DTM interface.  Wild cards will be defined 
-   *                     by 0xFFFF in the high word and/or in the low word.
-   * @return one of FILTER_ACCEPT, FILTER_REJECT, or FILTER_SKIP.
-   */
-  public short acceptNode(int nodeHandle, int whatToShow, int expandedName);
- 
-}
\ No newline at end of file
diff --git a/src/org/apache/xml/utils/DTMManager.java b/src/org/apache/xml/utils/DTMManager.java
deleted file mode 100644
index f456fbe..0000000
--- a/src/org/apache/xml/utils/DTMManager.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-package org.apache.xml.utils;
-
-/**
- * A DTMManager instance can be used to create DTM and
- * DTMIterator objects, and manage the DTM objects in the system.
- *
- * <p>The system property that determines which Factory implementation
- * to create is named "org.apache.xml.utils.DTMFactory". This
- * property names a concrete subclass of the DTMFactory abstract
- *  class. If the property is not defined, a platform default is be used.</p>
- *  
- * <p>An instance of this class <emph>must</emph> be safe to use across 
- * thread instances.  It is expected that a client will create a single instance 
- * of a DTMManager to use across multiple threads.  This will allow sharing 
- * of DTMs across multiple processes.</p>
- *  
- * <p>Note: this class is incomplete right now.  It will be pretty much 
- * modeled after javax.xml.transform.TransformerFactory in terms of its 
- * factory support.</p>
- * 
- * <p>State: In progress!!</p>
- */
-public abstract class DTMManager
-{
-
-  /**
-   * Default constructor is protected on purpose.
-   */
-  protected DTMManager(){}
-
-  /**
-   * Get an instance of a DTM.  If the unique flag is true, a new instance will
-   * always be returned.  Otherwise it is up to the DTMManager to return a
-   * new instance or an instance that it already created and may be being used
-   * by someone else.
-   * (I think more parameters will need to be added for error handling, and entity
-   * resolution).
-   *
-   * @param source the specification of the source object.
-   * @param unique true if the returned DTM must be unique, probably because it
-   * is going to be mutated.
-   *
-   * @return a non-null DTM reference.
-   */
-  public abstract DTM getDTM(javax.xml.transform.Source source,
-                             boolean unique);
-                             
-  /**
-   * Get an instance of a DTM that "owns" a node handle.
-   *
-   * @param nodeHandle the nodeHandle.
-   *
-   * @return a non-null DTM reference.
-   */
-  public abstract DTM getDTM(int nodeHandle);
-
-
-  /**
-   * Create a new <code>DTMIterator</code> based on an XPath
-   * <a href="http://www.w3.org/TR/xpath#NT-LocationPath>LocationPath</a> or
-   * a <a href="http://www.w3.org/TR/xpath#NT-UnionExpr">UnionExpr</a>.
-   *
-   * @param xpathCompiler ??? Somehow we need to pass in a subpart of the
-   * expression.  I hate to do this with strings, since the larger expression
-   * has already been parsed.
-   *
-   * @param pos The position in the expression.
-   * @return The newly created <code>DTMIterator</code>.
-   */
-  public abstract DTMIterator createDTMIterator(Object xpathCompiler,
-          int pos);
-
-  /**
-   * Create a new <code>DTMIterator</code> based on an XPath
-   * <a href="http://www.w3.org/TR/xpath#NT-LocationPath>LocationPath</a> or
-   * a <a href="http://www.w3.org/TR/xpath#NT-UnionExpr">UnionExpr</a>.
-   *
-   * @param xpathString Must be a valid string expressing a
-   * <a href="http://www.w3.org/TR/xpath#NT-LocationPath>LocationPath</a> or
-   * a <a href="http://www.w3.org/TR/xpath#NT-UnionExpr">UnionExpr</a>.
-   *
-   * @param presolver An object that can resolve prefixes to namespace URLs.
-   *
-   * @return The newly created <code>DTMIterator</code>.
-   */
-  public abstract DTMIterator createDTMIterator(String xpathString,
-          PrefixResolver presolver);
-
-  /**
-   * Create a new <code>DTMIterator</code> based only on a whatToShow and
-   * a DTMFilter.  The traversal semantics are defined as the descendant
-   * access.
-   *
-   * @param whatToShow This flag specifies which node types may appear in
-   *   the logical view of the tree presented by the iterator. See the
-   *   description of <code>NodeFilter</code> for the set of possible
-   *   <code>SHOW_</code> values.These flags can be combined using
-   *   <code>OR</code>.
-   * @param filter The <code>NodeFilter</code> to be used with this
-   *   <code>TreeWalker</code>, or <code>null</code> to indicate no filter.
-   * @param entityReferenceExpansion The value of this flag determines
-   *   whether entity reference nodes are expanded.
-   *
-   * @return The newly created <code>NodeIterator</code>.
-   */
-  public abstract DTMIterator createDTMIterator(int whatToShow,
-          DTMFilter filter, boolean entityReferenceExpansion);
-}
diff --git a/src/org/apache/xml/utils/FastStringBuffer.java b/src/org/apache/xml/utils/FastStringBuffer.java
index c6f9706..523b798 100644
--- a/src/org/apache/xml/utils/FastStringBuffer.java
+++ b/src/org/apache/xml/utils/FastStringBuffer.java
@@ -2,7 +2,7 @@
  * The Apache Software License, Version 1.1
  *
  *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -59,7 +59,7 @@
 /**
  * Bare-bones, unsafe, fast string buffer. No thread-safety, no
  * parameter range checking, exposed fields. Note that in typical
- * applications, thread-safety of a StringBuffer is a somewhat 
+ * applications, thread-safety of a StringBuffer is a somewhat
  * dubious concept in any case.
  * <p>
  * Note that Stree is using a single FastStringBuffer as a string pool,
@@ -79,49 +79,63 @@
  * theory, RTFs might want to be tuned differently from the main
  * document's text.
  * <p>
- * */
+ */
 public class FastStringBuffer
 {
-  /** Field m_chunkBits sets our chunking strategy, by saying how many
+  // If nonzero, forces the inial chunk size.
+  /**/static final int DEBUG_FORCE_INIT_BITS=0;
+
+  /**
+   * Field m_chunkBits sets our chunking strategy, by saying how many
    * bits of index can be used within a single chunk before flowing over
    * to the next chunk. For example, if m_chunkbits is set to 15, each
-   * chunk can contain up to 2^15 (32K) characters  */
-  int m_chunkBits=15;
-        
-  /** Field m_maxChunkBits affects our chunk-growth strategy, by saying what
-   * the largest permissible chunk size is in this particular FastStringBuffer 
-   * hierarchy. */
-  int m_maxChunkBits=15;
-  
-  /** Field m_rechunkBits affects our chunk-growth strategy, by saying how
+   * chunk can contain up to 2^15 (32K) characters  
+   */
+  int m_chunkBits = 15;
+
+  /**
+   * Field m_maxChunkBits affects our chunk-growth strategy, by saying what
+   * the largest permissible chunk size is in this particular FastStringBuffer
+   * hierarchy. 
+   */
+  int m_maxChunkBits = 15;
+
+  /**
+   * Field m_rechunkBits affects our chunk-growth strategy, by saying how
    * many chunks should be allocated at one size before we encapsulate them
    * into the first chunk of the next size up. For example, if m_rechunkBits
    * is set to 3, then after 8 chunks at a given size we will rebundle
    * them as the first element of a FastStringBuffer using a chunk size
    * 8 times larger (chunkBits shifted left three bits).
    */
-  int m_rebundleBits=2;
+  int m_rebundleBits = 2;
 
-  /** Field m_chunkSize establishes the maximum size of one chunk of the array
+  /**
+   * Field m_chunkSize establishes the maximum size of one chunk of the array
    * as 2**chunkbits characters.
-   * (Which may also be the minimum size if we aren't tuning for storage) */
-  int m_chunkSize; // =1<<(m_chunkBits-1);
-  
-  /** Field m_chunkMask is m_chunkSize-1 -- in other words, m_chunkBits
-   * worth of low-order '1' bits, useful for shift-and-mask addressing
-   * within the chunks. */
-  int m_chunkMask; // =m_chunkSize-1;
+   * (Which may also be the minimum size if we aren't tuning for storage) 
+   */
+  int m_chunkSize;  // =1<<(m_chunkBits-1);
 
-  /** Field m_array holds the string buffer's text contents, using an
-   * array-of-arrays. Note that this array, and the arrays it contains, may be 
-   * reallocated when necessary in order to allow the buffer to grow; 
+  /**
+   * Field m_chunkMask is m_chunkSize-1 -- in other words, m_chunkBits
+   * worth of low-order '1' bits, useful for shift-and-mask addressing
+   * within the chunks. 
+   */
+  int m_chunkMask;  // =m_chunkSize-1;
+
+  /**
+   * Field m_array holds the string buffer's text contents, using an
+   * array-of-arrays. Note that this array, and the arrays it contains, may be
+   * reallocated when necessary in order to allow the buffer to grow;
    * references to them should be considered to be invalidated after any
    * append. However, the only time these arrays are directly exposed
    * is in the sendSAXcharacters call.
    */
   char[][] m_array;
 
-  /** Field m_lastChunk is an index into m_array[], pointing to the last
+  /**
+   * Field m_lastChunk is an index into m_array[], pointing to the last
    * chunk of the Chunked Array currently in use. Note that additional
    * chunks may actually be allocated, eg if the FastStringBuffer had
    * previously been truncated or if someone issued an ensureSpace request.
@@ -131,20 +145,23 @@
    */
   int m_lastChunk = 0;
 
-  /** Field m_firstFree is an index into m_array[m_lastChunk][], pointing to 
+  /**
+   * Field m_firstFree is an index into m_array[m_lastChunk][], pointing to
    * the first character in the Chunked Array which is not part of the
-   * FastStringBuffer's current content. Since m_array[][] is zero-based, 
-   * the length of that content can be calculated as 
-   * (m_lastChunk<<m_chunkBits) + m_firstFree */
+   * FastStringBuffer's current content. Since m_array[][] is zero-based,
+   * the length of that content can be calculated as
+   * (m_lastChunk<<m_chunkBits) + m_firstFree 
+   */
   int m_firstFree = 0;
-  
-  /** Field m_innerFSB, when non-null, is a FastStringBuffer whose total
+
+  /**
+   * Field m_innerFSB, when non-null, is a FastStringBuffer whose total
    * length equals m_chunkSize, and which replaces m_array[0]. This allows
    * building a hierarchy of FastStringBuffers, where early appends use
    * a smaller chunkSize (for less wasted memory overhead) but later
    * ones use a larger chunkSize (for less heap activity overhead).
    */
-  FastStringBuffer m_innerFSB=null;
+  FastStringBuffer m_innerFSB = null;
 
   /**
    * Construct a FastStringBuffer, with allocation policy as per parameters.
@@ -156,41 +173,46 @@
    * <p>
    * An alternative would be to accept integer sizes and round to powers of two;
    * that really doesn't seem to buy us much, if anything.
-   * 
-   * @param initChunkBits Length in characters of the initial allocation 
-   * of a chunk, expressed in log-base-2. (That is, 10 means allocate 1024 
+   *
+   * @param initChunkBits Length in characters of the initial allocation
+   * of a chunk, expressed in log-base-2. (That is, 10 means allocate 1024
    * characters.) Later chunks will use larger allocation units, to trade off
-   * allocation speed of large document against storage efficiency of small 
+   * allocation speed of large document against storage efficiency of small
    * ones.
    * @param maxChunkBits Number of character-offset bits that should be used for
-   * addressing within a chunk. Maximum length of a chunk is 2^chunkBits 
+   * addressing within a chunk. Maximum length of a chunk is 2^chunkBits
    * characters.
    * @param rebundleBits Number of character-offset bits that addressing should
    * advance before we attempt to take a step from initChunkBits to maxChunkBits
    */
-  public FastStringBuffer(int initChunkBits,int maxChunkBits, int rebundleBits)
+  public FastStringBuffer(int initChunkBits, int maxChunkBits,
+                          int rebundleBits)
   {
+    if(DEBUG_FORCE_INIT_BITS!=0) initChunkBits=DEBUG_FORCE_INIT_BITS;
+
     m_array = new char[16][];
 
     // Don't bite off more than we're prepared to swallow!
-    if(initChunkBits>maxChunkBits)
-      initChunkBits=maxChunkBits;
-        
-    m_chunkBits=initChunkBits;
-    m_maxChunkBits=maxChunkBits;
-    m_rebundleBits=rebundleBits;
-        
-    m_chunkSize=1<<(initChunkBits);
-    m_chunkMask=m_chunkSize-1;
+    if (initChunkBits > maxChunkBits)
+      initChunkBits = maxChunkBits;
+
+    m_chunkBits = initChunkBits;
+    m_maxChunkBits = maxChunkBits;
+    m_rebundleBits = rebundleBits;
+    m_chunkSize = 1 << (initChunkBits);
+    m_chunkMask = m_chunkSize - 1;
     m_array[0] = new char[m_chunkSize];
   }
 
   /**
    * Construct a FastStringBuffer, using a default rebundleBits value.
+   *
+   * NEEDSDOC @param initChunkBits
+   * NEEDSDOC @param maxChunkBits
    */
-  public FastStringBuffer(int initChunkBits,int maxChunkBits)
+  public FastStringBuffer(int initChunkBits, int maxChunkBits)
   {
-          this(initChunkBits,maxChunkBits,2);
+    this(initChunkBits, maxChunkBits, 2);
   }
 
   /**
@@ -200,26 +222,29 @@
    * ISSUE: Should this call assert initial size, or fixed size?
    * Now configured as initial, with a default for fixed.
    *
-   * @param 
+   * @param
+   *
+   * NEEDSDOC @param initChunkBits
    */
   public FastStringBuffer(int initChunkBits)
   {
-    this(initChunkBits,15,2);
+    this(initChunkBits, 15, 2);
   }
+
   /**
    * Construct a FastStringBuffer, using a default allocation policy.
    */
   public FastStringBuffer()
   {
+
     // 10 bits is 1K. 15 bits is 32K. Remember that these are character
     // counts, so actual memory allocation unit is doubled for UTF-16 chars.
     //
     // For reference: In the original FastStringBuffer, we simply
     // overallocated by blocksize (default 1KB) on each buffer-growth.
-    this(10,15,2);
+    this(10, 15, 2);
   }
 
-
   /**
    * Get the length of the list. Synonym for length().
    *
@@ -227,7 +252,7 @@
    */
   public final int size()
   {
-        return (m_lastChunk<<m_chunkBits) + m_firstFree;
+    return (m_lastChunk << m_chunkBits) + m_firstFree;
   }
 
   /**
@@ -237,7 +262,7 @@
    */
   public final int length()
   {
-    return (m_lastChunk<<m_chunkBits) + m_firstFree;
+    return (m_lastChunk << m_chunkBits) + m_firstFree;
   }
 
   /**
@@ -247,22 +272,26 @@
    */
   public final void reset()
   {
+
     m_lastChunk = 0;
     m_firstFree = 0;
-	
-	// Recover the original chunk size
-	FastStringBuffer innermost=this;
-	while(innermost.m_innerFSB!=null)
-		innermost=innermost.m_innerFSB;
-	m_chunkBits=innermost.m_chunkBits;
-	m_chunkSize=innermost.m_chunkSize;
-	m_chunkMask=innermost.m_chunkMask;
-	 
-	// Discard the hierarchy
-	m_innerFSB  = null;
 
-	m_array=new char[16][0];
-	m_array[0]=new char[m_chunkSize];
+    // Recover the original chunk size
+    FastStringBuffer innermost = this;
+
+    while (innermost.m_innerFSB != null)
+    {
+      innermost = innermost.m_innerFSB;
+    }
+
+    m_chunkBits = innermost.m_chunkBits;
+    m_chunkSize = innermost.m_chunkSize;
+    m_chunkMask = innermost.m_chunkMask;
+
+    // Discard the hierarchy
+    m_innerFSB = null;
+    m_array = new char[16][0];
+    m_array[0] = new char[m_chunkSize];
   }
 
   /**
@@ -274,78 +303,89 @@
    * The only safe use for our setLength() is to truncate the FastStringBuffer
    * to a shorter string.
    * <p>
-   * TODO: Current setLength code is probably not the best solution.
+   * TODO: %REVEIW% Current setLength code is probably not the best solution.
    * It releases memory that in theory we shouldn retain and
    * reuse. Holding onto that would require recursive truncation of
    * the inner FSB, and extending the append operations to recurse
    * into the inner FSB when space exists within them. Could be done,
    * but nontrivial change and adds some overhead to the append
-   * operation. Consider alternatives. *****
+   * operation. Consider alternatives. 
    *
    * @param l New length. If l<0 or l>=getLength(), this operation will
    * not report an error but future operations will almost certainly fail.
    */
   public final void setLength(int l)
   {
-	m_lastChunk = l >>> m_chunkBits;
-	if(m_lastChunk==0 && m_innerFSB!=null)
-	{
-		m_innerFSB.setLength(l,this);
-	}
-	else
-	{
-		m_firstFree = l  &  m_chunkMask;
-	}
+
+    m_lastChunk = l >>> m_chunkBits;
+
+    if (m_lastChunk == 0 && m_innerFSB != null)
+    {
+      m_innerFSB.setLength(l, this);
+    }
+    else
+    {
+      m_firstFree = l & m_chunkMask;
+    }
   }
-  
-  /** Subroutine for the public setLength() method. Deals with the fact
+
+  /**
+   * Subroutine for the public setLength() method. Deals with the fact
    * that truncation may require restoring one of the innerFSBs
+   *
+   * NEEDSDOC @param l
+   * NEEDSDOC @param rootFSB
    */
-  final void setLength(int l, FastStringBuffer rootFSB)
+  private final void setLength(int l, FastStringBuffer rootFSB)
   {
-	m_lastChunk = l >>> m_chunkBits;
-	if(m_lastChunk==0 && m_innerFSB!=null)
-	{
-		m_innerFSB.setLength(l,rootFSB);
-	}
-	else
-	{
-		// Undo encapsulation -- pop the innerFSB data back up to root.
-		rootFSB.m_chunkBits   =m_chunkBits;
-        rootFSB.m_maxChunkBits=m_maxChunkBits;
-        rootFSB.m_rebundleBits=m_rebundleBits;
-        rootFSB.m_chunkSize   =m_chunkSize;
-        rootFSB.m_chunkMask   =m_chunkMask;
-        rootFSB.m_array       =m_array; 
-		rootFSB.m_innerFSB    =m_innerFSB;
-		rootFSB.m_lastChunk   =m_lastChunk; 
-		
-		// Finally, truncate this sucker.
-		rootFSB.m_firstFree = l  &  m_chunkMask;
-	}
+
+    m_lastChunk = l >>> m_chunkBits;
+
+    if (m_lastChunk == 0 && m_innerFSB != null)
+    {
+      m_innerFSB.setLength(l, rootFSB);
+    }
+    else
+    {
+
+      // Undo encapsulation -- pop the innerFSB data back up to root.
+      rootFSB.m_chunkBits = m_chunkBits;
+      rootFSB.m_maxChunkBits = m_maxChunkBits;
+      rootFSB.m_rebundleBits = m_rebundleBits;
+      rootFSB.m_chunkSize = m_chunkSize;
+      rootFSB.m_chunkMask = m_chunkMask;
+      rootFSB.m_array = m_array;
+      rootFSB.m_innerFSB = m_innerFSB;
+      rootFSB.m_lastChunk = m_lastChunk;
+
+      // Finally, truncate this sucker.
+      rootFSB.m_firstFree = l & m_chunkMask;
+    }
   }
 
   /**
    * Note that this operation has been somewhat deoptimized by the shift to a
-   * chunked array, as there is no factory method to produce a String object 
+   * chunked array, as there is no factory method to produce a String object
    * directly from an array of arrays and hence a double copy is needed.
-   * By using ensureCapacity we hope to minimize the heap overhead of building 
+   * By using ensureCapacity we hope to minimize the heap overhead of building
    * the intermediate StringBuffer.
    * <p>
    * (It really is a pity that Java didn't design String as a final subclass
    * of MutableString, rather than having StringBuffer be a separate hierarchy.
    * We'd avoid a <strong>lot</strong> of double-buffering.)
-   * 
+   *
    * @return the contents of the FastStringBuffer as a standard Java string.
    */
   public final String toString()
   {
-	int length=(m_lastChunk<<m_chunkBits)+m_firstFree;
-    return getString(new StringBuffer(length),0,0,length).toString();
+
+    int length = (m_lastChunk << m_chunkBits) + m_firstFree;
+
+    return getString(new StringBuffer(length), 0, 0, length).toString();
   }
 
   /**
-   * Append a single character onto the FastStringBuffer, growing the 
+   * Append a single character onto the FastStringBuffer, growing the
    * storage if necessary.
    * <p>
    * NOTE THAT after calling append(), previously obtained
@@ -356,51 +396,59 @@
    */
   public final void append(char value)
   {
+
     char[] chunk;
-          
+
     // We may have preallocated chunks. If so, all but last should
     // be at full size.
-    boolean lastchunk=(m_lastChunk+1==m_array.length);
-          
-    if(m_firstFree<m_chunkSize) // Simplified test single-character-fits
-      chunk=m_array[m_lastChunk];
-          
+    boolean lastchunk = (m_lastChunk + 1 == m_array.length);
+
+    if (m_firstFree < m_chunkSize)  // Simplified test single-character-fits
+      chunk = m_array[m_lastChunk];
     else
+    {
+
+      // Extend array?
+      int i = m_array.length;
+
+      if (m_lastChunk + 1 == i)
       {
-        // Extend array?
-        int i=m_array.length;
-        if(m_lastChunk+1==i)
-          {
-            char[][] newarray=new char[i+16][];
-            System.arraycopy(m_array,0,newarray,0,i);
-            m_array=newarray;
-          }
-                  
-        // Advance one chunk
-        chunk=m_array[++m_lastChunk];
-        if(chunk==null)
-          {
-                // Hierarchical encapsulation
-                if(m_lastChunk==1<<m_rebundleBits && m_chunkBits<m_maxChunkBits)
-                {
-                  // Should do all the work of both encapsulating
-                  // existing data and establishing new sizes/offsets
-                  m_innerFSB=new FastStringBuffer(this);
-                }
-                                
-            // Add a chunk.
-            chunk=m_array[m_lastChunk]=new char[m_chunkSize];
-          }
-                  
-        m_firstFree=0;
+        char[][] newarray = new char[i + 16][];
+
+        System.arraycopy(m_array, 0, newarray, 0, i);
+
+        m_array = newarray;
       }
 
+      // Advance one chunk
+      chunk = m_array[++m_lastChunk];
+
+      if (chunk == null)
+      {
+
+        // Hierarchical encapsulation
+        if (m_lastChunk == 1 << m_rebundleBits
+                && m_chunkBits < m_maxChunkBits)
+        {
+
+          // Should do all the work of both encapsulating
+          // existing data and establishing new sizes/offsets
+          m_innerFSB = new FastStringBuffer(this);
+        }
+
+        // Add a chunk.
+        chunk = m_array[m_lastChunk] = new char[m_chunkSize];
+      }
+
+      m_firstFree = 0;
+    }
+
     // Space exists in the chunk. Append the character.
-    chunk[m_firstFree++]=value;
+    chunk[m_firstFree++] = value;
   }
 
   /**
-   * Append the contents of a String onto the FastStringBuffer, 
+   * Append the contents of a String onto the FastStringBuffer,
    * growing the storage if necessary.
    * <p>
    * NOTE THAT after calling append(), previously obtained
@@ -410,57 +458,73 @@
    */
   public final void append(String value)
   {
-    int strlen=value.length();
+
+    int strlen = value.length();
+
     if (0 == strlen)
       return;
-    int copyfrom=0;
-    char[] chunk=m_array[m_lastChunk];
-    int available=m_chunkSize-m_firstFree;
-          
-    // Repeat while data remains to be copied
-    while(strlen>0)
-      {
-        // Copy what fits
-        if(available>strlen) available=strlen;
-        value.getChars(copyfrom, copyfrom+available, m_array[m_lastChunk], m_firstFree);
-        strlen-=available;
-        copyfrom+=available;
-                  
-        // If there's more left, allocate another chunk and continue
-        if(strlen>0)
-          {
-            // Extend array?
-            int i=m_array.length;
-            if(m_lastChunk+1==i)
-              {
-                char[][] newarray=new char[i+16][];
-                System.arraycopy(m_array,0,newarray,0,i);
-                m_array=newarray;
-              }
-                  
-            // Advance one chunk
-            chunk=m_array[++m_lastChunk];
-            if(chunk==null)
-              {
-                // Hierarchical encapsulation
-                if(m_lastChunk==1<<m_rebundleBits && m_chunkBits<m_maxChunkBits)
-                {
-                  // Should do all the work of both encapsulating
-                  // existing data and establishing new sizes/offsets
-                  m_innerFSB=new FastStringBuffer(this);
-                }
 
-                // Add a chunk. 
-                chunk=m_array[m_lastChunk]=new char[m_chunkSize];
-              }
-            available=m_chunkSize;
-                          
-            m_firstFree=0;
+    int copyfrom = 0;
+    char[] chunk = m_array[m_lastChunk];
+    int available = m_chunkSize - m_firstFree;
+
+    // Repeat while data remains to be copied
+    while (strlen > 0)
+    {
+
+      // Copy what fits
+      if (available > strlen)
+        available = strlen;
+
+      value.getChars(copyfrom, copyfrom + available, m_array[m_lastChunk],
+                     m_firstFree);
+
+      strlen -= available;
+      copyfrom += available;
+
+      // If there's more left, allocate another chunk and continue
+      if (strlen > 0)
+      {
+
+        // Extend array?
+        int i = m_array.length;
+
+        if (m_lastChunk + 1 == i)
+        {
+          char[][] newarray = new char[i + 16][];
+
+          System.arraycopy(m_array, 0, newarray, 0, i);
+
+          m_array = newarray;
+        }
+
+        // Advance one chunk
+        chunk = m_array[++m_lastChunk];
+
+        if (chunk == null)
+        {
+
+          // Hierarchical encapsulation
+          if (m_lastChunk == 1 << m_rebundleBits
+                  && m_chunkBits < m_maxChunkBits)
+          {
+
+            // Should do all the work of both encapsulating
+            // existing data and establishing new sizes/offsets
+            m_innerFSB = new FastStringBuffer(this);
           }
+
+          // Add a chunk. 
+          chunk = m_array[m_lastChunk] = new char[m_chunkSize];
+        }
+
+        available = m_chunkSize;
+        m_firstFree = 0;
       }
-          
+    }
+
     // Adjust the insert point in the last chunk, when we've reached it.
-    m_firstFree+=available;
+    m_firstFree += available;
   }
 
   /**
@@ -474,60 +538,77 @@
    */
   public final void append(StringBuffer value)
   {
-    int strlen=value.length();
+
+    int strlen = value.length();
+
     if (0 == strlen)
       return;
-    int copyfrom=0;
-    char[] chunk=m_array[m_lastChunk];
-    int available=m_chunkSize-m_firstFree;
-          
+
+    int copyfrom = 0;
+    char[] chunk = m_array[m_lastChunk];
+    int available = m_chunkSize - m_firstFree;
+
     // Repeat while data remains to be copied
-    while(strlen>0)
+    while (strlen > 0)
+    {
+
+      // Copy what fits
+      if (available > strlen)
+        available = strlen;
+
+      value.getChars(copyfrom, copyfrom + available, m_array[m_lastChunk],
+                     m_firstFree);
+
+      strlen -= available;
+      copyfrom += available;
+
+      // If there's more left, allocate another chunk and continue
+      if (strlen > 0)
       {
-        // Copy what fits
-        if(available>strlen) available=strlen;
-        value.getChars(copyfrom, copyfrom+available, m_array[m_lastChunk], m_firstFree);
-        strlen-=available;
-        copyfrom+=available;
-                  
-        // If there's more left, allocate another chunk and continue
-        if(strlen>0)
+
+        // Extend array?
+        int i = m_array.length;
+
+        if (m_lastChunk + 1 == i)
+        {
+          char[][] newarray = new char[i + 16][];
+
+          System.arraycopy(m_array, 0, newarray, 0, i);
+
+          m_array = newarray;
+        }
+
+        // Advance one chunk
+        chunk = m_array[++m_lastChunk];
+
+        if (chunk == null)
+        {
+
+          // Hierarchical encapsulation
+          if (m_lastChunk == 1 << m_rebundleBits
+                  && m_chunkBits < m_maxChunkBits)
           {
-            // Extend array?
-            int i=m_array.length;
-            if(m_lastChunk+1==i)
-              {
-                char[][] newarray=new char[i+16][];
-                System.arraycopy(m_array,0,newarray,0,i);
-                m_array=newarray;
-              }
-                  
-            // Advance one chunk
-            chunk=m_array[++m_lastChunk];
-            if(chunk==null)
-              {
-                // Hierarchical encapsulation
-                if(m_lastChunk==1<<m_rebundleBits &&  m_chunkBits<m_maxChunkBits)
-                {
-                  // Should do all the work of both encapsulating
-                  // existing data and establishing new sizes/offsets
-                  m_innerFSB=new FastStringBuffer(this);
-                }
-                // Add a chunk.
-                chunk=m_array[m_lastChunk]=new char[m_chunkSize];
-              }
-            available=m_chunkSize;
-                          
-            m_firstFree=0;
+
+            // Should do all the work of both encapsulating
+            // existing data and establishing new sizes/offsets
+            m_innerFSB = new FastStringBuffer(this);
           }
+
+          // Add a chunk.
+          chunk = m_array[m_lastChunk] = new char[m_chunkSize];
+        }
+
+        available = m_chunkSize;
+        m_firstFree = 0;
       }
-          
+    }
+
     // Adjust the insert point in the last chunk, when we've reached it.
-    m_firstFree+=available;
+    m_firstFree += available;
   }
 
   /**
-   * Append part of the contents of a Character Array onto the 
+   * Append part of the contents of a Character Array onto the
    * FastStringBuffer,  growing the storage if necessary.
    * <p>
    * NOTE THAT after calling append(), previously obtained
@@ -540,60 +621,77 @@
    */
   public final void append(char[] chars, int start, int length)
   {
-    int strlen=length;
+
+    int strlen = length;
+
     if (0 == strlen)
       return;
-    int copyfrom=start;
-    char[] chunk=m_array[m_lastChunk];
-    int available=m_chunkSize-m_firstFree;
-          
-    // Repeat while data remains to be copied
-    while(strlen>0)
-      {
-        // Copy what fits
-        if(available>strlen) available=strlen;
-        System.arraycopy(chars,copyfrom, m_array[m_lastChunk], m_firstFree, available);
-        strlen-=available;
-        copyfrom+=available;
-                  
-        // If there's more left, allocate another chunk and continue
-        if(strlen>0)
-          {
-            // Extend array?
-            int i=m_array.length;
-            if(m_lastChunk+1==i)
-              {
-                char[][] newarray=new char[i+16][];
-                System.arraycopy(m_array,0,newarray,0,i);
-                m_array=newarray;
-              }
-                  
-            // Advance one chunk
-            chunk=m_array[++m_lastChunk];
-            if(chunk==null)
-              {
-                // Hierarchical encapsulation
-                if(m_lastChunk==1<<m_rebundleBits &&  m_chunkBits<m_maxChunkBits)
-                {
-                  // Should do all the work of both encapsulating
-                  // existing data and establishing new sizes/offsets
-                  m_innerFSB=new FastStringBuffer(this);
-                }
-                // Add a chunk.
-                chunk=m_array[m_lastChunk]=new char[m_chunkSize];
-              }
-            available=m_chunkSize;
 
-            m_firstFree=0;
+    int copyfrom = start;
+    char[] chunk = m_array[m_lastChunk];
+    int available = m_chunkSize - m_firstFree;
+
+    // Repeat while data remains to be copied
+    while (strlen > 0)
+    {
+
+      // Copy what fits
+      if (available > strlen)
+        available = strlen;
+
+      System.arraycopy(chars, copyfrom, m_array[m_lastChunk], m_firstFree,
+                       available);
+
+      strlen -= available;
+      copyfrom += available;
+
+      // If there's more left, allocate another chunk and continue
+      if (strlen > 0)
+      {
+
+        // Extend array?
+        int i = m_array.length;
+
+        if (m_lastChunk + 1 == i)
+        {
+          char[][] newarray = new char[i + 16][];
+
+          System.arraycopy(m_array, 0, newarray, 0, i);
+
+          m_array = newarray;
+        }
+
+        // Advance one chunk
+        chunk = m_array[++m_lastChunk];
+
+        if (chunk == null)
+        {
+
+          // Hierarchical encapsulation
+          if (m_lastChunk == 1 << m_rebundleBits
+                  && m_chunkBits < m_maxChunkBits)
+          {
+
+            // Should do all the work of both encapsulating
+            // existing data and establishing new sizes/offsets
+            m_innerFSB = new FastStringBuffer(this);
           }
+
+          // Add a chunk.
+          chunk = m_array[m_lastChunk] = new char[m_chunkSize];
+        }
+
+        available = m_chunkSize;
+        m_firstFree = 0;
       }
-          
+    }
+
     // Adjust the insert point in the last chunk, when we've reached it.
-    m_firstFree+=available;
+    m_firstFree += available;
   }
 
   /**
-   * Append the contents of another FastStringBuffer onto 
+   * Append the contents of another FastStringBuffer onto
    * this FastStringBuffer, growing the storage if necessary.
    * <p>
    * NOTE THAT after calling append(), previously obtained
@@ -604,119 +702,145 @@
    */
   public final void append(FastStringBuffer value)
   {
+
     // Complicating factor here is that the two buffers may use
     // different chunk sizes, and even if they're the same we're
     // probably on a different alignment due to previously appended
     // data. We have to work through the source in bite-sized chunks.
-    int strlen=value.length();
+    int strlen = value.length();
+
     if (0 == strlen)
       return;
-    int copyfrom=0;
-    char[] chunk=m_array[m_lastChunk];
-    int available=m_chunkSize-m_firstFree;
-          
+
+    int copyfrom = 0;
+    char[] chunk = m_array[m_lastChunk];
+    int available = m_chunkSize - m_firstFree;
+
     // Repeat while data remains to be copied
-    while(strlen>0)
+    while (strlen > 0)
+    {
+
+      // Copy what fits
+      if (available > strlen)
+        available = strlen;
+
+      int sourcechunk = (copyfrom + value.m_chunkSize - 1)
+                        >>> value.m_chunkBits;
+      int sourcecolumn = copyfrom & value.m_chunkMask;
+      int runlength = value.m_chunkSize - sourcecolumn;
+
+      if (runlength > available)
+        runlength = available;
+
+      System.arraycopy(value.m_array[sourcechunk], sourcecolumn,
+                       m_array[m_lastChunk], m_firstFree, runlength);
+
+      if (runlength != available)
+        System.arraycopy(value.m_array[sourcechunk + 1], 0,
+                         m_array[m_lastChunk], m_firstFree + runlength,
+                         available - runlength);
+
+      strlen -= available;
+      copyfrom += available;
+
+      // If there's more left, allocate another chunk and continue
+      if (strlen > 0)
       {
-        // Copy what fits
-        if(available>strlen) available=strlen;
-                  
-        int sourcechunk=(copyfrom+value.m_chunkSize-1)>>>value.m_chunkBits;
-        int sourcecolumn=copyfrom & value.m_chunkMask;
-        int runlength=value.m_chunkSize-sourcecolumn;
-        if(runlength>available) runlength=available;
-        System.arraycopy(value.m_array[sourcechunk],sourcecolumn,
-                         m_array[m_lastChunk], m_firstFree, runlength);
-        if(runlength!=available)
-          System.arraycopy(value.m_array[sourcechunk+1],0,
-                           m_array[m_lastChunk], m_firstFree+runlength, available-runlength);
-                  
-        strlen-=available;
-        copyfrom+=available;
-                  
-        // If there's more left, allocate another chunk and continue
-        if(strlen>0)
+
+        // Extend array?
+        int i = m_array.length;
+
+        if (m_lastChunk + 1 == i)
+        {
+          char[][] newarray = new char[i + 16][];
+
+          System.arraycopy(m_array, 0, newarray, 0, i);
+
+          m_array = newarray;
+        }
+
+        // Advance one chunk
+        chunk = m_array[++m_lastChunk];
+
+        if (chunk == null)
+        {
+
+          // Hierarchical encapsulation
+          if (m_lastChunk == 1 << m_rebundleBits
+                  && m_chunkBits < m_maxChunkBits)
           {
-            // Extend array?
-            int i=m_array.length;
-            if(m_lastChunk+1==i)
-              {
-                char[][] newarray=new char[i+16][];
-                System.arraycopy(m_array,0,newarray,0,i);
-                m_array=newarray;
-              }
-                  
-            // Advance one chunk
-            chunk=m_array[++m_lastChunk];
-            if(chunk==null)
-              {
-                // Hierarchical encapsulation
-                if(m_lastChunk==1<<m_rebundleBits &&  m_chunkBits<m_maxChunkBits)
-                {
-                  // Should do all the work of both encapsulating
-                  // existing data and establishing new sizes/offsets
-                  m_innerFSB=new FastStringBuffer(this);
-                }
-                // Add a chunk. 
-                chunk=m_array[m_lastChunk]=new char[m_chunkSize];
-              }
-            available=m_chunkSize;
-                          
-            m_firstFree=0;
+
+            // Should do all the work of both encapsulating
+            // existing data and establishing new sizes/offsets
+            m_innerFSB = new FastStringBuffer(this);
           }
+
+          // Add a chunk. 
+          chunk = m_array[m_lastChunk] = new char[m_chunkSize];
+        }
+
+        available = m_chunkSize;
+        m_firstFree = 0;
       }
-          
+    }
+
     // Adjust the insert point in the last chunk, when we've reached it.
-    m_firstFree+=available;
+    m_firstFree += available;
   }
 
-  /** @return true if the specified range of characters are all whitespace,
+  /**
+   * @return true if the specified range of characters are all whitespace,
    * as defined by XMLCharacterRecognizer.
    * <p>
    * CURRENTLY DOES NOT CHECK FOR OUT-OF-RANGE.
-   * 
+   *
    * @param start Offset of first character in the range.
    * @param length Number of characters to send.
    */
   public boolean isWhitespace(int start, int length)
   {
-    int sourcechunk=start >>> m_chunkBits;
-    int sourcecolumn=start & m_chunkMask;
-    int available=m_chunkSize-sourcecolumn;
-	boolean chunkOK;
-          
-    while(length>0)
-      {
-        int runlength=(length<=available) ? length : available;
-		
-		if(sourcechunk==0 && m_innerFSB!=null)
-			chunkOK=m_innerFSB.isWhitespace(sourcecolumn,runlength);
-		else
-			chunkOK=org.apache.xml.utils.XMLCharacterRecognizer
-			    .isWhiteSpace(m_array[sourcechunk],sourcecolumn,runlength);
-		if(!chunkOK)
-          return false;
-        
-        length-=runlength;
-        ++sourcechunk;
-        sourcecolumn=0;
-        available=m_chunkSize;
-      }
-          
+
+    int sourcechunk = start >>> m_chunkBits;
+    int sourcecolumn = start & m_chunkMask;
+    int available = m_chunkSize - sourcecolumn;
+    boolean chunkOK;
+
+    while (length > 0)
+    {
+      int runlength = (length <= available) ? length : available;
+
+      if (sourcechunk == 0 && m_innerFSB != null)
+        chunkOK = m_innerFSB.isWhitespace(sourcecolumn, runlength);
+      else
+        chunkOK = org.apache.xml.utils.XMLCharacterRecognizer.isWhiteSpace(
+          m_array[sourcechunk], sourcecolumn, runlength);
+
+      if (!chunkOK)
+        return false;
+
+      length -= runlength;
+
+      ++sourcechunk;
+
+      sourcecolumn = 0;
+      available = m_chunkSize;
+    }
+
     return true;
   }
-  
+
   /**
    * @param start Offset of first character in the range.
    * @param length Number of characters to send.
-   * @return a new String object initialized from the specified range of 
+   * @return a new String object initialized from the specified range of
    * characters.
    */
   public String getString(int start, int length)
   {
-    return getString(new StringBuffer(length),start>>>m_chunkBits,start&m_chunkMask,length).toString();
+    return getString(new StringBuffer(length), start >>> m_chunkBits,
+                     start & m_chunkMask, length).toString();
   }
-  
+
   /**
    * @param sb StringBuffer to be appended to
    * @param start Offset of first character in the range.
@@ -725,56 +849,83 @@
    */
   StringBuffer getString(StringBuffer sb, int start, int length)
   {
-    return getString(sb,start>>>m_chunkBits,start&m_chunkMask,length);
+    return getString(sb, start >>> m_chunkBits, start & m_chunkMask, length);
   }
-  
-  /** Internal support for toString() and getString().
+
+  /**
+   * Internal support for toString() and getString().
    * PLEASE NOTE SIGNATURE CHANGE from earlier versions; it now appends into
-   * and returns a StringBuffer supplied by the caller. This simplifies 
+   * and returns a StringBuffer supplied by the caller. This simplifies
    * m_innerFSB support.
    * <p>
    * Note that this operation has been somewhat deoptimized by the shift to a
-   * chunked array, as there is no factory method to produce a String object 
+   * chunked array, as there is no factory method to produce a String object
    * directly from an array of arrays and hence a double copy is needed.
-   * By presetting length we hope to minimize the heap overhead of building 
+   * By presetting length we hope to minimize the heap overhead of building
    * the intermediate StringBuffer.
    * <p>
    * (It really is a pity that Java didn't design String as a final subclass
    * of MutableString, rather than having StringBuffer be a separate hierarchy.
    * We'd avoid a <strong>lot</strong> of double-buffering.)
+   *
+   *
+   * @param sb
+   * @param startChunk
+   * @param startColumn
+   * @param length
    * 
    * @return the contents of the FastStringBuffer as a standard Java string.
    */
-  StringBuffer getString(StringBuffer sb,int startChunk,int startColumn,int length)
+  StringBuffer getString(StringBuffer sb, int startChunk, int startColumn,
+                         int length)
   {
-    int stop=(startChunk<<m_chunkBits)+startColumn+length;
-    int stopChunk=stop>>>m_chunkBits;
-    int stopColumn=stop&m_chunkMask;
-      
-	// Factored out
+
+    int stop = (startChunk << m_chunkBits) + startColumn + length;
+    int stopChunk = stop >>> m_chunkBits;
+    int stopColumn = stop & m_chunkMask;
+
+    // Factored out
     //StringBuffer sb=new StringBuffer(length);
-          
-    for(int i=startChunk;i<stopChunk;++i)
-      {
-		if(i==0 && m_innerFSB!=null)
-			m_innerFSB.getString(sb,startColumn,m_chunkSize-startColumn);
-		else
-			sb.append(m_array[i],startColumn,m_chunkSize-startColumn);
-        startColumn=0; // after first chunk
-      }
+    for (int i = startChunk; i < stopChunk; ++i)
+    {
+      if (i == 0 && m_innerFSB != null)
+        m_innerFSB.getString(sb, startColumn, m_chunkSize - startColumn);
+      else
+        sb.append(m_array[i], startColumn, m_chunkSize - startColumn);
 
-	if(stopChunk==0 && m_innerFSB!=null)
-		m_innerFSB.getString(sb,startColumn,stopColumn-startColumn);
-	else if(stopColumn>startColumn)
-		sb.append(m_array[stopChunk],startColumn,stopColumn-startColumn);
+      startColumn = 0;  // after first chunk
+    }
 
-	return sb;
+    if (stopChunk == 0 && m_innerFSB != null)
+      m_innerFSB.getString(sb, startColumn, stopColumn - startColumn);
+    else if (stopColumn > startColumn)
+      sb.append(m_array[stopChunk], startColumn, stopColumn - startColumn);
+
+    return sb;
   }
-  
-  /** Sends the specified range of characters as one or more SAX characters()
+
+  /**
+   * Get a single character from the string buffer.
+   *
+   *
+   * @param pos character position requested.
+   * @return A character from the requested position.
+   */
+  public char charAt(int pos)
+  {
+    int startChunk = pos >>> m_chunkBits;
+
+    if (startChunk == 0 && m_innerFSB != null)
+      return m_innerFSB.charAt(pos & m_chunkMask);
+    else
+      return m_array[startChunk][pos & m_chunkMask];
+  }
+
+  /**
+   * Sends the specified range of characters as one or more SAX characters()
    * events.
-   * Note that the buffer reference passed to the ContentHandler may be 
-   * invalidated if the FastStringBuffer is edited; it's the user's 
+   * Note that the buffer reference passed to the ContentHandler may be
+   * invalidated if the FastStringBuffer is edited; it's the user's
    * responsibility to manage access to the FastStringBuffer to prevent this
    * problem from arising.
    * <p>
@@ -782,68 +933,127 @@
    * single call. As is always true in SAX, one logical string may be split
    * across multiple blocks of memory and hence delivered as several
    * successive events.
-   * 
+   *
    * @param ch SAX ContentHandler object to receive the event.
    * @param start Offset of first character in the range.
    * @param length Number of characters to send.
    * @exception org.xml.sax.SAXException may be thrown by handler's
    * characters() method.
    */
-  public void sendSAXcharacters(org.xml.sax.ContentHandler ch,int start, int length) 
-       throws org.xml.sax.SAXException
+  public void sendSAXcharacters(
+          org.xml.sax.ContentHandler ch, int start, int length)
+            throws org.xml.sax.SAXException
   {
-    int stop=start+length;
-    int startChunk=start>>>m_chunkBits;
-    int startColumn=start&m_chunkMask;
-    int stopChunk=stop>>>m_chunkBits;
-    int stopColumn=stop&m_chunkMask;
-          
-    for(int i=startChunk;i<stopChunk;++i)
-      {
-		if(i==0 && m_innerFSB!=null)
-			m_innerFSB.sendSAXcharacters(ch,startColumn,m_chunkSize-startColumn);
-		else
-			ch.characters(m_array[i],startColumn,m_chunkSize-startColumn);
-        startColumn=0; // after first chunk
-      }
+
+    int stop = start + length;
+    int startChunk = start >>> m_chunkBits;
+    int startColumn = start & m_chunkMask;
+    int stopChunk = stop >>> m_chunkBits;
+    int stopColumn = stop & m_chunkMask;
+
+    for (int i = startChunk; i < stopChunk; ++i)
+    {
+      if (i == 0 && m_innerFSB != null)
+        m_innerFSB.sendSAXcharacters(ch, startColumn,
+                                     m_chunkSize - startColumn);
+      else
+        ch.characters(m_array[i], startColumn, m_chunkSize - startColumn);
+
+      startColumn = 0;  // after first chunk
+    }
 
     // Last, or only, chunk
-	if(stopChunk==0 && m_innerFSB!=null)
-		m_innerFSB.sendSAXcharacters(ch,startColumn,stopColumn-startColumn);
-	else if(stopColumn>startColumn)
-	    ch.characters(m_array[stopChunk],startColumn,stopColumn-startColumn);
+    if (stopChunk == 0 && m_innerFSB != null)
+      m_innerFSB.sendSAXcharacters(ch, startColumn, stopColumn - startColumn);
+    else if (stopColumn > startColumn)
+      ch.characters(m_array[stopChunk], startColumn,
+                    stopColumn - startColumn);
+  }
+  
+  /**
+   * Sends the specified range of characters as sax Comment.
+   * <p>
+   * Note that, unlike sendSAXcharacters, this has to be done as a single 
+   * call to LexicalHandler#comment.
+   *
+   * @param ch SAX LexicalHandler object to receive the event.
+   * @param start Offset of first character in the range.
+   * @param length Number of characters to send.
+   * @exception org.xml.sax.SAXException may be thrown by handler's
+   * characters() method.
+   */
+  public void sendSAXComment(
+          org.xml.sax.ext.LexicalHandler ch, int start, int length)
+            throws org.xml.sax.SAXException
+  {
+
+    // %OPT% Do it this way for now...
+    String comment = getString(start, length);
+    ch.comment(comment.toCharArray(), 0, length);
   }
 
-  /** Encapsulation c'tor. After this is called, the source FastStringBuffer
+  /**
+   * Copies characters from this string into the destination character
+   * array.
+   *
+   * @param      srcBegin   index of the first character in the string
+   *                        to copy.
+   * @param      srcEnd     index after the last character in the string
+   *                        to copy.
+   * @param      dst        the destination array.
+   * @param      dstBegin   the start offset in the destination array.
+   * @exception IndexOutOfBoundsException If any of the following
+   *            is true:
+   *            <ul><li><code>srcBegin</code> is negative.
+   *            <li><code>srcBegin</code> is greater than <code>srcEnd</code>
+   *            <li><code>srcEnd</code> is greater than the length of this
+   *                string
+   *            <li><code>dstBegin</code> is negative
+   *            <li><code>dstBegin+(srcEnd-srcBegin)</code> is larger than
+   *                <code>dst.length</code></ul>
+   * @exception NullPointerException if <code>dst</code> is <code>null</code>
+   */
+  private void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin)
+  {
+    // %TBD% Joe needs to write this function.  Make public when implemented.
+  }
+
+  /**
+   * Encapsulation c'tor. After this is called, the source FastStringBuffer
    * will be reset to use the new object as its m_innerFSB, and will have
    * had its chunk size reset appropriately. IT SHOULD NEVER BE CALLED
    * EXCEPT WHEN source.length()==1<<(source.m_chunkBits+source.m_rebundleBits)
+   *
+   * NEEDSDOC @param source
    */
   private FastStringBuffer(FastStringBuffer source)
   {
-        // Copy existing information into new encapsulation
-        m_chunkBits   =source.m_chunkBits;
-        m_maxChunkBits=source.m_maxChunkBits;
-        m_rebundleBits=source.m_rebundleBits;
-        m_chunkSize   =source.m_chunkSize;
-        m_chunkMask   =source.m_chunkMask;
-        m_array       =source.m_array; 
-		m_innerFSB    =source.m_innerFSB;
-		// These have to be adjusted because we're calling just at the time
-		// when we would be about to allocate another chunk
-        m_lastChunk   =source.m_lastChunk-1; 
-        m_firstFree   =source.m_chunkSize;
-        
-        // Establish capsule as the Inner FSB, reset chunk sizes/addressing
-		source.m_array = new char[16][];
-        source.m_innerFSB=this; 
-		// Since we encapsulated just as we were about to append another
-		// chunk, return ready to create the chunk after the innerFSB
-		// -- 1, not 0.
-        source.m_lastChunk=1;
-        source.m_firstFree=0;
-        source.m_chunkBits+=m_rebundleBits;
-        source.m_chunkSize=1<<(source.m_chunkBits); 
-        source.m_chunkMask=source.m_chunkSize-1;
+
+    // Copy existing information into new encapsulation
+    m_chunkBits = source.m_chunkBits;
+    m_maxChunkBits = source.m_maxChunkBits;
+    m_rebundleBits = source.m_rebundleBits;
+    m_chunkSize = source.m_chunkSize;
+    m_chunkMask = source.m_chunkMask;
+    m_array = source.m_array;
+    m_innerFSB = source.m_innerFSB;
+
+    // These have to be adjusted because we're calling just at the time
+    // when we would be about to allocate another chunk
+    m_lastChunk = source.m_lastChunk - 1;
+    m_firstFree = source.m_chunkSize;
+
+    // Establish capsule as the Inner FSB, reset chunk sizes/addressing
+    source.m_array = new char[16][];
+    source.m_innerFSB = this;
+
+    // Since we encapsulated just as we were about to append another
+    // chunk, return ready to create the chunk after the innerFSB
+    // -- 1, not 0.
+    source.m_lastChunk = 1;
+    source.m_firstFree = 0;
+    source.m_chunkBits += m_rebundleBits;
+    source.m_chunkSize = 1 << (source.m_chunkBits);
+    source.m_chunkMask = source.m_chunkSize - 1;
   }
 }
diff --git a/src/org/apache/xml/utils/IntStack.java b/src/org/apache/xml/utils/IntStack.java
index fc4567e..2febdd7 100644
--- a/src/org/apache/xml/utils/IntStack.java
+++ b/src/org/apache/xml/utils/IntStack.java
@@ -144,6 +144,18 @@
   }
 
   /**
+   * Looks at the object at the position the stack counting down n items.
+   *
+   * @param n The number of items down, indexed from zero.
+   * @return     the object at n items down.
+   * @throws  EmptyStackException  if this stack is empty.
+   */
+  public int peek(int n)
+  {
+    return m_map[m_firstFree-(1+n)];
+  }
+
+  /**
    * Sets an object at a the top of the statck
    *
    *
diff --git a/src/org/apache/xml/utils/IntVector.java b/src/org/apache/xml/utils/IntVector.java
index 56df1fe..242e957 100644
--- a/src/org/apache/xml/utils/IntVector.java
+++ b/src/org/apache/xml/utils/IntVector.java
@@ -109,6 +109,17 @@
   {
     return m_firstFree;
   }
+  
+  /**
+   * Get the length of the list.
+   *
+   * @return length of the list
+   */
+  public final void setSize(int sz)
+  {
+    m_firstFree = sz;
+  }
+
 
   /**
    * Append a int onto the vector.
@@ -133,6 +144,55 @@
 
     m_firstFree++;
   }
+  
+  /**
+   * Append several int values onto the vector.
+   *
+   * @param value Int to add to the list 
+   */
+  public final void addElements(int value, int numberOfElements)
+  {
+
+    if ((m_firstFree + numberOfElements) >= m_mapSize)
+    {
+      m_mapSize += (m_blocksize+numberOfElements);
+
+      int newMap[] = new int[m_mapSize];
+
+      System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1);
+
+      m_map = newMap;
+    }
+
+    for (int i = 0; i < numberOfElements; i++) 
+    {
+      m_map[m_firstFree] = value;
+      m_firstFree++;
+    }
+  }
+  
+  /**
+   * Append several slots onto the vector, but do not set the values.
+   *
+   * @param value Int to add to the list 
+   */
+  public final void addElements(int numberOfElements)
+  {
+
+    if ((m_firstFree + numberOfElements) >= m_mapSize)
+    {
+      m_mapSize += (m_blocksize+numberOfElements);
+
+      int newMap[] = new int[m_mapSize];
+
+      System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1);
+
+      m_map = newMap;
+    }
+    
+    m_firstFree += numberOfElements;
+  }
+  
 
   /**
    * Inserts the specified node in this vector at the specified index.
@@ -245,9 +305,9 @@
    * @param node object to set
    * @param index Index of where to set the object
    */
-  public final void setElementAt(int node, int index)
+  public final void setElementAt(int value, int index)
   {
-    m_map[index] = node;
+    m_map[index] = value;
   }
 
   /**
diff --git a/src/org/apache/xml/utils/NodeVector.java b/src/org/apache/xml/utils/NodeVector.java
index 076f520..391752d 100644
--- a/src/org/apache/xml/utils/NodeVector.java
+++ b/src/org/apache/xml/utils/NodeVector.java
@@ -57,8 +57,7 @@
 package org.apache.xml.utils;
 
 import java.io.Serializable;
-
-import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 /**
  * <meta name="usage" content="internal"/>
@@ -73,7 +72,7 @@
 
   /** Array of nodes this points to.
    *  @serial          */
-  private Node m_map[];
+  private int m_map[];
 
   /** Number of nodes in this NodeVector.
    *  @serial          */
@@ -117,7 +116,7 @@
 
     if ((null != this.m_map) && (this.m_map == clone.m_map))
     {
-      clone.m_map = new Node[this.m_map.length];
+      clone.m_map = new int[this.m_map.length];
 
       System.arraycopy(this.m_map, 0, clone.m_map, 0, this.m_map.length);
     }
@@ -140,21 +139,21 @@
    *
    * @param value Node to add to the vector
    */
-  public void addElement(Node value)
+  public void addElement(int value)
   {
 
     if ((m_firstFree + 1) >= m_mapSize)
     {
       if (null == m_map)
       {
-        m_map = new Node[m_blocksize];
+        m_map = new int[m_blocksize];
         m_mapSize = m_blocksize;
       }
       else
       {
         m_mapSize += m_blocksize;
 
-        Node newMap[] = new Node[m_mapSize];
+        int newMap[] = new int[m_mapSize];
 
         System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1);
 
@@ -172,7 +171,7 @@
    *
    * @param value Node to add to the vector
    */
-  public final void push(Node value)
+  public final void push(int value)
   {
 
     int ff = m_firstFree;
@@ -181,14 +180,14 @@
     {
       if (null == m_map)
       {
-        m_map = new Node[m_blocksize];
+        m_map = new int[m_blocksize];
         m_mapSize = m_blocksize;
       }
       else
       {
         m_mapSize += m_blocksize;
 
-        Node newMap[] = new Node[m_mapSize];
+        int newMap[] = new int[m_mapSize];
 
         System.arraycopy(m_map, 0, newMap, 0, ff + 1);
 
@@ -208,14 +207,14 @@
    *
    * @return the node at the tail of the vector
    */
-  public final Node pop()
+  public final int pop()
   {
 
     m_firstFree--;
 
-    Node n = m_map[m_firstFree];
+    int n = m_map[m_firstFree];
 
-    m_map[m_firstFree] = null;
+    m_map[m_firstFree] = DTM.NULL;
 
     return n;
   }
@@ -226,14 +225,14 @@
    *
    * @return The top of the stack after it's been popped 
    */
-  public final Node popAndTop()
+  public final int popAndTop()
   {
 
     m_firstFree--;
 
-    m_map[m_firstFree] = null;
+    m_map[m_firstFree] = DTM.NULL;
 
-    return (m_firstFree == 0) ? null : m_map[m_firstFree - 1];
+    return (m_firstFree == 0) ? DTM.NULL : m_map[m_firstFree - 1];
   }
 
   /**
@@ -244,7 +243,7 @@
 
     m_firstFree--;
 
-    m_map[m_firstFree] = null;
+    m_map[m_firstFree] = DTM.NULL;
   }
 
   /**
@@ -254,10 +253,10 @@
    *
    * @return Node at the top of the stack or null if stack is empty.  
    */
-  public final Node peepOrNull()
+  public final int peepOrNull()
   {
     return ((null != m_map) && (m_firstFree > 0))
-           ? m_map[m_firstFree - 1] : null;
+           ? m_map[m_firstFree - 1] : DTM.NULL;
   }
 
   /**
@@ -268,12 +267,12 @@
    * @param v1 First node to add to vector
    * @param v2 Second node to add to vector
    */
-  public final void pushPair(Node v1, Node v2)
+  public final void pushPair(int v1, int v2)
   {
 
     if (null == m_map)
     {
-      m_map = new Node[m_blocksize];
+      m_map = new int[m_blocksize];
       m_mapSize = m_blocksize;
     }
     else
@@ -282,7 +281,7 @@
       {
         m_mapSize += m_blocksize;
 
-        Node newMap[] = new Node[m_mapSize];
+        int newMap[] = new int[m_mapSize];
 
         System.arraycopy(m_map, 0, newMap, 0, m_firstFree);
 
@@ -304,8 +303,8 @@
   {
 
     m_firstFree -= 2;
-    m_map[m_firstFree] = null;
-    m_map[m_firstFree + 1] = null;
+    m_map[m_firstFree] = DTM.NULL;
+    m_map[m_firstFree + 1] = DTM.NULL;
   }
 
   /**
@@ -315,7 +314,7 @@
    *
    * @param n Node to set at the tail of vector
    */
-  public final void setTail(Node n)
+  public final void setTail(int n)
   {
     m_map[m_firstFree - 1] = n;
   }
@@ -327,7 +326,7 @@
    *
    * @param n Node to set
    */
-  public final void setTailSub1(Node n)
+  public final void setTailSub1(int n)
   {
     m_map[m_firstFree - 2] = n;
   }
@@ -339,7 +338,7 @@
    *
    * @return Node at the tail of the vector
    */
-  public final Node peepTail()
+  public final int peepTail()
   {
     return m_map[m_firstFree - 1];
   }
@@ -351,10 +350,29 @@
    *
    * @return Node one away from the tail
    */
-  public final Node peepTailSub1()
+  public final int peepTailSub1()
   {
     return m_map[m_firstFree - 2];
   }
+  
+  /**
+   * Insert a node in order in the list.
+   * 
+   * @param value Node to insert
+   */
+  public void insertInOrder(int value)
+  {
+    for (int i = 0; i < m_firstFree; i++) 
+    {
+      if(value < m_map[i])
+      {
+        insertElementAt(value, i);
+        return;
+      }
+    }
+    addElement(value);
+    
+  }
 
   /**
    * Inserts the specified node in this vector at the specified index.
@@ -365,19 +383,19 @@
    * @param value Node to insert
    * @param at Position where to insert
    */
-  public void insertElementAt(Node value, int at)
+  public void insertElementAt(int value, int at)
   {
 
     if (null == m_map)
     {
-      m_map = new Node[m_blocksize];
+      m_map = new int[m_blocksize];
       m_mapSize = m_blocksize;
     }
     else if ((m_firstFree + 1) >= m_mapSize)
     {
       m_mapSize += m_blocksize;
 
-      Node newMap[] = new Node[m_mapSize];
+      int newMap[] = new int[m_mapSize];
 
       System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1);
 
@@ -407,13 +425,13 @@
     if (null == m_map)
     {
       m_mapSize = nNodes + m_blocksize;
-      m_map = new Node[m_mapSize];
+      m_map = new int[m_mapSize];
     }
     else if ((m_firstFree + nNodes) >= m_mapSize)
     {
       m_mapSize += (nNodes + m_blocksize);
 
-      Node newMap[] = new Node[m_mapSize];
+      int newMap[] = new int[m_mapSize];
 
       System.arraycopy(m_map, 0, newMap, 0, m_firstFree + nNodes);
 
@@ -439,7 +457,7 @@
 
     for (int i = 0; i < m_firstFree; i++)
     {
-      m_map[i] = null;
+      m_map[i] = DTM.NULL;
     }
 
     m_firstFree = 0;
@@ -456,7 +474,7 @@
    *
    * @return True if the node was successfully removed
    */
-  public boolean removeElement(Node s)
+  public boolean removeElement(int s)
   {
 
     if (null == m_map)
@@ -464,14 +482,14 @@
 
     for (int i = 0; i < m_firstFree; i++)
     {
-      Node node = m_map[i];
+      int node = m_map[i];
 
-      if ((null != node) && node.equals(s))
+      if ( node == s )
       {
         if (i > m_firstFree)
           System.arraycopy(m_map, i + 1, m_map, i - 1, m_firstFree - i);
         else
-          m_map[i] = null;
+          m_map[i] = DTM.NULL;
 
         m_firstFree--;
 
@@ -499,7 +517,7 @@
     if (i > m_firstFree)
       System.arraycopy(m_map, i + 1, m_map, i - 1, m_firstFree - i);
     else
-      m_map[i] = null;
+      m_map[i] = DTM.NULL;
   }
 
   /**
@@ -512,12 +530,12 @@
    * @param node Node to set
    * @param index Index of where to set the node
    */
-  public void setElementAt(Node node, int index)
+  public void setElementAt(int node, int index)
   {
 
     if (null == m_map)
     {
-      m_map = new Node[m_blocksize];
+      m_map = new int[m_blocksize];
       m_mapSize = m_blocksize;
     }
 
@@ -531,11 +549,11 @@
    *
    * @return Node at specified index
    */
-  public Node elementAt(int i)
+  public int elementAt(int i)
   {
 
     if (null == m_map)
-      return null;
+      return DTM.NULL;
 
     return m_map[i];
   }
@@ -547,7 +565,7 @@
    *
    * @return True if the given node was found.
    */
-  public boolean contains(Node s)
+  public boolean contains(int s)
   {
 
     if (null == m_map)
@@ -555,9 +573,9 @@
 
     for (int i = 0; i < m_firstFree; i++)
     {
-      Node node = m_map[i];
+      int node = m_map[i];
 
-      if ((null != node) && node.equals(s))
+      if (node == s)
         return true;
     }
 
@@ -575,7 +593,7 @@
    * argument in this vector at position index or later in the
    * vector; returns -1 if the object is not found.
    */
-  public int indexOf(Node elem, int index)
+  public int indexOf(int elem, int index)
   {
 
     if (null == m_map)
@@ -583,9 +601,9 @@
 
     for (int i = index; i < m_firstFree; i++)
     {
-      Node node = m_map[i];
+      int node = m_map[i];
 
-      if ((null != node) && node.equals(elem))
+      if ( node == elem )
         return i;
     }
 
@@ -602,7 +620,7 @@
    * argument in this vector at position index or later in the
    * vector; returns -1 if the object is not found.
    */
-  public int indexOf(Node elem)
+  public int indexOf(int elem)
   {
 
     if (null == m_map)
@@ -610,9 +628,9 @@
 
     for (int i = 0; i < m_firstFree; i++)
     {
-      Node node = m_map[i];
+      int node = m_map[i];
 
-      if ((null != node) && node.equals(elem))
+      if (node == elem)
         return i;
     }
 
diff --git a/src/org/apache/xml/utils/PrefixResolver.java b/src/org/apache/xml/utils/PrefixResolver.java
index f77b680..6f612da 100644
--- a/src/org/apache/xml/utils/PrefixResolver.java
+++ b/src/org/apache/xml/utils/PrefixResolver.java
@@ -58,15 +58,17 @@
 
 /**
  * <meta name="usage" content="advanced"/>
- * The class that implements this interface can resolve prefixes
- * to namespaces.
+ * The class that implements this interface can resolve prefixes to
+ * namespaces. Examples would include resolving the meaning of a
+ * prefix at a particular point in a document, or mapping the prefixes
+ * used in an XPath expression.
  */
 public interface PrefixResolver
 {
 
   /**
    * Given a namespace, get the corrisponding prefix.  This assumes that
-   * the PrevixResolver hold's it's own namespace context, or is a namespace
+   * the PrefixResolver holds its own namespace context, or is a namespace
    * context itself.
    *
    * @param prefix The prefix to look up, which may be an empty string ("") for the default Namespace.
@@ -77,12 +79,12 @@
   String getNamespaceForPrefix(String prefix);
 
   /**
-   * Given a namespace, get the corrisponding prefix, based on the node context.
+   * Given a namespace, get the corresponding prefix, based on the context node.
    *
    * @param prefix The prefix to look up, which may be an empty string ("") for the default Namespace.
    * @param context The node context from which to look up the URI.
    *
-   * @return The associated Namespace URI, or null if the prefix
+   * @return The associated Namespace URI as a string, or null if the prefix
    *         is undeclared in this context.
    */
   String getNamespaceForPrefix(String prefix, org.w3c.dom.Node context);
@@ -92,6 +94,13 @@
    *
    * @return The base identifier from where relative URIs should be absolutized, or null 
    * if the base ID is unknown.
+   * <p>
+   * CAVEAT: Note that the base URI in an XML document may vary with where
+   * you are in the document, if part of the doc's contents were brought in
+   * via an external entity reference or if mechanisms such as xml:base have
+   * been used. Unless this PrefixResolver is bound to a specific portion of
+   * the document, or has been kept up to date via some other mechanism, it
+   * may not accurately reflect that context information.
    */
   public String getBaseIdentifier();
 }
diff --git a/src/org/apache/xml/utils/TreeWalker.java b/src/org/apache/xml/utils/TreeWalker.java
index 788dda5..54f4b36 100644
--- a/src/org/apache/xml/utils/TreeWalker.java
+++ b/src/org/apache/xml/utils/TreeWalker.java
@@ -87,12 +87,22 @@
    *
    * @return the ContentHandler used for the tree walk
    */
-  public ContentHandler getcontentHandler()
+  public ContentHandler getContentHandler()
   {
     return m_contentHandler;
   }
 
   /**
+   * Get the ContentHandler used for the tree walk.
+   *
+   * @return the ContentHandler used for the tree walk
+   */
+  public void setContentHandler(ContentHandler ch)
+  {
+    m_contentHandler = ch;
+  }
+
+  /**
    * Constructor.
    * @param   contentHandler The implemention of the
    * contentHandler operation (toXMLString, digest, ...)
@@ -213,15 +223,8 @@
   private final void dispatachChars(Node node)
      throws org.xml.sax.SAXException
   {
-    if(node.isSupported(org.apache.xalan.stree.SaxEventDispatch.SUPPORTSINTERFACE, "1.0"))
-    {
-      ((org.apache.xalan.stree.SaxEventDispatch)node).dispatchCharactersEvent(m_contentHandler);
-    }
-    else
-    {
-      String data = ((Text) node).getData();
-      this.m_contentHandler.characters(data.toCharArray(), 0, data.length());
-    }
+    String data = ((Text) node).getData();
+    this.m_contentHandler.characters(data.toCharArray(), 0, data.length());
   }
 
   /**
diff --git a/src/org/apache/xml/utils/XMLString.java b/src/org/apache/xml/utils/XMLString.java
new file mode 100644
index 0000000..e91ba96
--- /dev/null
+++ b/src/org/apache/xml/utils/XMLString.java
@@ -0,0 +1,711 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xml.utils;
+
+import java.util.Locale;
+
+/**
+ * This class is meant to be an interface to character strings, whether they
+ * be java Strings or <code>org.apache.xml.utils.FastStringBuffer</code>s, or
+ * other character data.  By using XMLString, character copies can be reduced
+ * in the XML pipeline.
+ */
+public interface XMLString
+{
+
+  /**
+   * Directly call the
+   * characters method on the passed ContentHandler for the
+   * string-value. Multiple calls to the
+   * ContentHandler's characters methods may well occur for a single call to
+   * this method.
+   *
+   * @param ch A non-null reference to a ContentHandler.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public abstract void dispatchCharactersEvents(org.xml.sax.ContentHandler ch)
+    throws org.xml.sax.SAXException;
+
+  /**
+   * Directly call the
+   * comment method on the passed LexicalHandler for the
+   * string-value.
+   *
+   * @param lh A non-null reference to a LexicalHandler.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public abstract void dispatchAsComment(org.xml.sax.ext.LexicalHandler lh)
+    throws org.xml.sax.SAXException;
+    
+  /**
+   * Conditionally trim all leading and trailing whitespace in the specified String.
+   * All strings of white space are
+   * replaced by a single space character (#x20), except spaces after punctuation which
+   * receive double spaces if doublePunctuationSpaces is true.
+   * This function may be useful to a formatter, but to get first class
+   * results, the formatter should probably do it's own white space handling
+   * based on the semantics of the formatting object.
+   * 
+   * @param   trimHead    Trim leading whitespace?
+   * @param   trimTail    Trim trailing whitespace?
+   * @param   doublePunctuationSpaces    Use double spaces for punctuation?
+   * @return              The trimmed string.
+   */
+  public XMLString fixWhiteSpace(boolean trimHead,
+                                 boolean trimTail,
+                                 boolean doublePunctuationSpaces);
+
+  /**
+   * Returns the length of this string.
+   *
+   * @return  the length of the sequence of characters represented by this
+   *          object.
+   */
+  public abstract int length();
+
+  /**
+   * Returns the character at the specified index. An index ranges
+   * from <code>0</code> to <code>length() - 1</code>. The first character
+   * of the sequence is at index <code>0</code>, the next at index
+   * <code>1</code>, and so on, as for array indexing.
+   *
+   * @param      index   the index of the character.
+   * @return     the character at the specified index of this string.
+   *             The first character is at index <code>0</code>.
+   * @exception  IndexOutOfBoundsException  if the <code>index</code>
+   *             argument is negative or not less than the length of this
+   *             string.
+   */
+  public abstract char charAt(int index);
+
+  /**
+   * Copies characters from this string into the destination character
+   * array.
+   *
+   * @param      srcBegin   index of the first character in the string
+   *                        to copy.
+   * @param      srcEnd     index after the last character in the string
+   *                        to copy.
+   * @param      dst        the destination array.
+   * @param      dstBegin   the start offset in the destination array.
+   * @exception IndexOutOfBoundsException If any of the following
+   *            is true:
+   *            <ul><li><code>srcBegin</code> is negative.
+   *            <li><code>srcBegin</code> is greater than <code>srcEnd</code>
+   *            <li><code>srcEnd</code> is greater than the length of this
+   *                string
+   *            <li><code>dstBegin</code> is negative
+   *            <li><code>dstBegin+(srcEnd-srcBegin)</code> is larger than
+   *                <code>dst.length</code></ul>
+   * @exception NullPointerException if <code>dst</code> is <code>null</code>
+   */
+  public abstract void getChars(int srcBegin, int srcEnd, char dst[],
+                                int dstBegin);
+                                
+  /**
+   * Compares this string to the specified object.
+   * The result is <code>true</code> if and only if the argument is not
+   * <code>null</code> and is a <code>String</code> object that represents
+   * the same sequence of characters as this object.
+   *
+   * @param   anObject   the object to compare this <code>String</code>
+   *                     against.
+   * @return  <code>true</code> if the <code>String </code>are equal;
+   *          <code>false</code> otherwise.
+   * @see     java.lang.String#compareTo(java.lang.String)
+   * @see     java.lang.String#equalsIgnoreCase(java.lang.String)
+   */
+  public abstract boolean equals(XMLString anObject);
+
+
+  /**
+   * Compares this string to the specified object.
+   * The result is <code>true</code> if and only if the argument is not
+   * <code>null</code> and is a <code>String</code> object that represents
+   * the same sequence of characters as this object.
+   *
+   * @param   anObject   the object to compare this <code>String</code>
+   *                     against.
+   * @return  <code>true</code> if the <code>String </code>are equal;
+   *          <code>false</code> otherwise.
+   * @see     java.lang.String#compareTo(java.lang.String)
+   * @see     java.lang.String#equalsIgnoreCase(java.lang.String)
+   */
+  public abstract boolean equals(Object anObject);
+
+  /**
+   * Compares this <code>String</code> to another <code>String</code>,
+   * ignoring case considerations.  Two strings are considered equal
+   * ignoring case if they are of the same length, and corresponding
+   * characters in the two strings are equal ignoring case.
+   *
+   * @param   anotherString   the <code>String</code> to compare this
+   *                          <code>String</code> against.
+   * @return  <code>true</code> if the argument is not <code>null</code>
+   *          and the <code>String</code>s are equal,
+   *          ignoring case; <code>false</code> otherwise.
+   * @see     #equals(Object)
+   * @see     java.lang.Character#toLowerCase(char)
+   * @see java.lang.Character#toUpperCase(char)
+   */
+  public abstract boolean equalsIgnoreCase(String anotherString);
+
+  /**
+   * Compares two strings lexicographically.
+   *
+   * @param   anotherString   the <code>String</code> to be compared.
+   * @return  the value <code>0</code> if the argument string is equal to
+   *          this string; a value less than <code>0</code> if this string
+   *          is lexicographically less than the string argument; and a
+   *          value greater than <code>0</code> if this string is
+   *          lexicographically greater than the string argument.
+   * @exception java.lang.NullPointerException if <code>anotherString</code>
+   *          is <code>null</code>.
+   */
+  public abstract int compareTo(XMLString anotherString);
+
+  /**
+   * Compares two strings lexicographically, ignoring case considerations.
+   * This method returns an integer whose sign is that of
+   * <code>this.toUpperCase().toLowerCase().compareTo(
+   * str.toUpperCase().toLowerCase())</code>.
+   * <p>
+   * Note that this method does <em>not</em> take locale into account,
+   * and will result in an unsatisfactory ordering for certain locales.
+   * The java.text package provides <em>collators</em> to allow
+   * locale-sensitive ordering.
+   *
+   * @param   str   the <code>String</code> to be compared.
+   * @return  a negative integer, zero, or a positive integer as the
+   *          the specified String is greater than, equal to, or less
+   *          than this String, ignoring case considerations.
+   * @see     java.text.Collator#compare(String, String)
+   * @since   1.2
+   */
+  public abstract int compareToIgnoreCase(XMLString str);
+
+  /**
+   * Tests if this string starts with the specified prefix beginning
+   * a specified index.
+   *
+   * @param   prefix    the prefix.
+   * @param   toffset   where to begin looking in the string.
+   * @return  <code>true</code> if the character sequence represented by the
+   *          argument is a prefix of the substring of this object starting
+   *          at index <code>toffset</code>; <code>false</code> otherwise.
+   *          The result is <code>false</code> if <code>toffset</code> is
+   *          negative or greater than the length of this
+   *          <code>String</code> object; otherwise the result is the same
+   *          as the result of the expression
+   *          <pre>
+   *          this.subString(toffset).startsWith(prefix)
+   *          </pre>
+   * @exception java.lang.NullPointerException if <code>prefix</code> is
+   *          <code>null</code>.
+   */
+  public abstract boolean startsWith(String prefix, int toffset);
+
+  /**
+   * Tests if this string starts with the specified prefix beginning
+   * a specified index.
+   *
+   * @param   prefix    the prefix.
+   * @param   toffset   where to begin looking in the string.
+   * @return  <code>true</code> if the character sequence represented by the
+   *          argument is a prefix of the substring of this object starting
+   *          at index <code>toffset</code>; <code>false</code> otherwise.
+   *          The result is <code>false</code> if <code>toffset</code> is
+   *          negative or greater than the length of this
+   *          <code>String</code> object; otherwise the result is the same
+   *          as the result of the expression
+   *          <pre>
+   *          this.subString(toffset).startsWith(prefix)
+   *          </pre>
+   * @exception java.lang.NullPointerException if <code>prefix</code> is
+   *          <code>null</code>.
+   */
+  public abstract boolean startsWith(XMLString prefix, int toffset);
+
+  /**
+   * Tests if this string starts with the specified prefix.
+   *
+   * @param   prefix   the prefix.
+   * @return  <code>true</code> if the character sequence represented by the
+   *          argument is a prefix of the character sequence represented by
+   *          this string; <code>false</code> otherwise.
+   *          Note also that <code>true</code> will be returned if the
+   *          argument is an empty string or is equal to this
+   *          <code>String</code> object as determined by the
+   *          {@link #equals(Object)} method.
+   * @exception java.lang.NullPointerException if <code>prefix</code> is
+   *          <code>null</code>.
+   * @since   JDK1. 0
+   */
+  public abstract boolean startsWith(String prefix);
+
+  /**
+   * Tests if this string starts with the specified prefix.
+   *
+   * @param   prefix   the prefix.
+   * @return  <code>true</code> if the character sequence represented by the
+   *          argument is a prefix of the character sequence represented by
+   *          this string; <code>false</code> otherwise.
+   *          Note also that <code>true</code> will be returned if the
+   *          argument is an empty string or is equal to this
+   *          <code>String</code> object as determined by the
+   *          {@link #equals(Object)} method.
+   * @exception java.lang.NullPointerException if <code>prefix</code> is
+   *          <code>null</code>.
+   * @since   JDK1. 0
+   */
+  public abstract boolean startsWith(XMLString prefix);
+
+  /**
+   * Tests if this string ends with the specified suffix.
+   *
+   * @param   suffix   the suffix.
+   * @return  <code>true</code> if the character sequence represented by the
+   *          argument is a suffix of the character sequence represented by
+   *          this object; <code>false</code> otherwise. Note that the
+   *          result will be <code>true</code> if the argument is the
+   *          empty string or is equal to this <code>String</code> object
+   *          as determined by the {@link #equals(Object)} method.
+   * @exception java.lang.NullPointerException if <code>suffix</code> is
+   *          <code>null</code>.
+   */
+  public abstract boolean endsWith(String suffix);
+
+  /**
+   * Returns a hashcode for this string. The hashcode for a
+   * <code>String</code> object is computed as
+   * <blockquote><pre>
+   * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
+   * </pre></blockquote>
+   * using <code>int</code> arithmetic, where <code>s[i]</code> is the
+   * <i>i</i>th character of the string, <code>n</code> is the length of
+   * the string, and <code>^</code> indicates exponentiation.
+   * (The hash value of the empty string is zero.)
+   *
+   * @return  a hash code value for this object.
+   */
+  public abstract int hashCode();
+
+  /**
+   * Returns the index within this string of the first occurrence of the
+   * specified character. If a character with value <code>ch</code> occurs
+   * in the character sequence represented by this <code>String</code>
+   * object, then the index of the first such occurrence is returned --
+   * that is, the smallest value <i>k</i> such that:
+   * <blockquote><pre>
+   * this.charAt(<i>k</i>) == ch
+   * </pre></blockquote>
+   * is <code>true</code>. If no such character occurs in this string,
+   * then <code>-1</code> is returned.
+   *
+   * @param   ch   a character.
+   * @return  the index of the first occurrence of the character in the
+   *          character sequence represented by this object, or
+   *          <code>-1</code> if the character does not occur.
+   */
+  public abstract int indexOf(int ch);
+
+  /**
+   * Returns the index within this string of the first occurrence of the
+   * specified character, starting the search at the specified index.
+   * <p>
+   * If a character with value <code>ch</code> occurs in the character
+   * sequence represented by this <code>String</code> object at an index
+   * no smaller than <code>fromIndex</code>, then the index of the first
+   * such occurrence is returned--that is, the smallest value <i>k</i>
+   * such that:
+   * <blockquote><pre>
+   * (this.charAt(<i>k</i>) == ch) && (<i>k</i> >= fromIndex)
+   * </pre></blockquote>
+   * is true. If no such character occurs in this string at or after
+   * position <code>fromIndex</code>, then <code>-1</code> is returned.
+   * <p>
+   * There is no restriction on the value of <code>fromIndex</code>. If it
+   * is negative, it has the same effect as if it were zero: this entire
+   * string may be searched. If it is greater than the length of this
+   * string, it has the same effect as if it were equal to the length of
+   * this string: <code>-1</code> is returned.
+   *
+   * @param   ch          a character.
+   * @param   fromIndex   the index to start the search from.
+   * @return  the index of the first occurrence of the character in the
+   *          character sequence represented by this object that is greater
+   *          than or equal to <code>fromIndex</code>, or <code>-1</code>
+   *          if the character does not occur.
+   */
+  public abstract int indexOf(int ch, int fromIndex);
+
+  /**
+   * Returns the index within this string of the last occurrence of the
+   * specified character. That is, the index returned is the largest
+   * value <i>k</i> such that:
+   * <blockquote><pre>
+   * this.charAt(<i>k</i>) == ch
+   * </pre></blockquote>
+   * is true.
+   * The String is searched backwards starting at the last character.
+   *
+   * @param   ch   a character.
+   * @return  the index of the last occurrence of the character in the
+   *          character sequence represented by this object, or
+   *          <code>-1</code> if the character does not occur.
+   */
+  public abstract int lastIndexOf(int ch);
+
+  /**
+   * Returns the index within this string of the last occurrence of the
+   * specified character, searching backward starting at the specified
+   * index. That is, the index returned is the largest value <i>k</i>
+   * such that:
+   * <blockquote><pre>
+   * this.charAt(k) == ch) && (k <= fromIndex)
+   * </pre></blockquote>
+   * is true.
+   *
+   * @param   ch          a character.
+   * @param   fromIndex   the index to start the search from. There is no
+   *          restriction on the value of <code>fromIndex</code>. If it is
+   *          greater than or equal to the length of this string, it has
+   *          the same effect as if it were equal to one less than the
+   *          length of this string: this entire string may be searched.
+   *          If it is negative, it has the same effect as if it were -1:
+   *          -1 is returned.
+   * @return  the index of the last occurrence of the character in the
+   *          character sequence represented by this object that is less
+   *          than or equal to <code>fromIndex</code>, or <code>-1</code>
+   *          if the character does not occur before that point.
+   */
+  public abstract int lastIndexOf(int ch, int fromIndex);
+
+  /**
+   * Returns the index within this string of the first occurrence of the
+   * specified substring. The integer returned is the smallest value
+   * <i>k</i> such that:
+   * <blockquote><pre>
+   * this.startsWith(str, <i>k</i>)
+   * </pre></blockquote>
+   * is <code>true</code>.
+   *
+   * @param   str   any string.
+   * @return  if the string argument occurs as a substring within this
+   *          object, then the index of the first character of the first
+   *          such substring is returned; if it does not occur as a
+   *          substring, <code>-1</code> is returned.
+   * @exception java.lang.NullPointerException if <code>str</code> is
+   *          <code>null</code>.
+   */
+  public abstract int indexOf(String str);
+
+  /**
+   * Returns the index within this string of the first occurrence of the
+   * specified substring. The integer returned is the smallest value
+   * <i>k</i> such that:
+   * <blockquote><pre>
+   * this.startsWith(str, <i>k</i>)
+   * </pre></blockquote>
+   * is <code>true</code>.
+   *
+   * @param   str   any string.
+   * @return  if the string argument occurs as a substring within this
+   *          object, then the index of the first character of the first
+   *          such substring is returned; if it does not occur as a
+   *          substring, <code>-1</code> is returned.
+   * @exception java.lang.NullPointerException if <code>str</code> is
+   *          <code>null</code>.
+   */
+  public abstract int indexOf(XMLString str);
+
+  /**
+   * Returns the index within this string of the first occurrence of the
+   * specified substring, starting at the specified index. The integer
+   * returned is the smallest value <i>k</i> such that:
+   * <blockquote><pre>
+   * this.startsWith(str, <i>k</i>) && (<i>k</i> >= fromIndex)
+   * </pre></blockquote>
+   * is <code>true</code>.
+   * <p>
+   * There is no restriction on the value of <code>fromIndex</code>. If
+   * it is negative, it has the same effect as if it were zero: this entire
+   * string may be searched. If it is greater than the length of this
+   * string, it has the same effect as if it were equal to the length of
+   * this string: <code>-1</code> is returned.
+   *
+   * @param   str         the substring to search for.
+   * @param   fromIndex   the index to start the search from.
+   * @return  If the string argument occurs as a substring within this
+   *          object at a starting index no smaller than
+   *          <code>fromIndex</code>, then the index of the first character
+   *          of the first such substring is returned. If it does not occur
+   *          as a substring starting at <code>fromIndex</code> or beyond,
+   *          <code>-1</code> is returned.
+   * @exception java.lang.NullPointerException if <code>str</code> is
+   *          <code>null</code>
+   */
+  public abstract int indexOf(String str, int fromIndex);
+
+  /**
+   * Returns the index within this string of the rightmost occurrence
+   * of the specified substring.  The rightmost empty string "" is
+   * considered to occur at the index value <code>this.length()</code>.
+   * The returned index is the largest value <i>k</i> such that
+   * <blockquote><pre>
+   * this.startsWith(str, k)
+   * </pre></blockquote>
+   * is true.
+   *
+   * @param   str   the substring to search for.
+   * @return  if the string argument occurs one or more times as a substring
+   *          within this object, then the index of the first character of
+   *          the last such substring is returned. If it does not occur as
+   *          a substring, <code>-1</code> is returned.
+   * @exception java.lang.NullPointerException  if <code>str</code> is
+   *          <code>null</code>.
+   */
+  public abstract int lastIndexOf(String str);
+
+  /**
+   * Returns the index within this string of the last occurrence of
+   * the specified substring.
+   *
+   * @param   str         the substring to search for.
+   * @param   fromIndex   the index to start the search from. There is no
+   *          restriction on the value of fromIndex. If it is greater than
+   *          the length of this string, it has the same effect as if it
+   *          were equal to the length of this string: this entire string
+   *          may be searched. If it is negative, it has the same effect
+   *          as if it were -1: -1 is returned.
+   * @return  If the string argument occurs one or more times as a substring
+   *          within this object at a starting index no greater than
+   *          <code>fromIndex</code>, then the index of the first character of
+   *          the last such substring is returned. If it does not occur as a
+   *          substring starting at <code>fromIndex</code> or earlier,
+   *          <code>-1</code> is returned.
+   * @exception java.lang.NullPointerException if <code>str</code> is
+   *          <code>null</code>.
+   */
+  public abstract int lastIndexOf(String str, int fromIndex);
+
+  /**
+   * Returns a new string that is a substring of this string. The
+   * substring begins with the character at the specified index and
+   * extends to the end of this string. <p>
+   * Examples:
+   * <blockquote><pre>
+   * "unhappy".substring(2) returns "happy"
+   * "Harbison".substring(3) returns "bison"
+   * "emptiness".substring(9) returns "" (an empty string)
+   * </pre></blockquote>
+   *
+   * @param      beginIndex   the beginning index, inclusive.
+   * @return     the specified substring.
+   * @exception  IndexOutOfBoundsException  if
+   *             <code>beginIndex</code> is negative or larger than the
+   *             length of this <code>String</code> object.
+   */
+  public abstract XMLString substring(int beginIndex);
+
+  /**
+   * Returns a new string that is a substring of this string. The
+   * substring begins at the specified <code>beginIndex</code> and
+   * extends to the character at index <code>endIndex - 1</code>.
+   * Thus the length of the substring is <code>endIndex-beginIndex</code>.
+   *
+   * @param      beginIndex   the beginning index, inclusive.
+   * @param      endIndex     the ending index, exclusive.
+   * @return     the specified substring.
+   * @exception  IndexOutOfBoundsException  if the
+   *             <code>beginIndex</code> is negative, or
+   *             <code>endIndex</code> is larger than the length of
+   *             this <code>String</code> object, or
+   *             <code>beginIndex</code> is larger than
+   *             <code>endIndex</code>.
+   */
+  public abstract XMLString substring(int beginIndex, int endIndex);
+
+  /**
+   * Concatenates the specified string to the end of this string.
+   *
+   * @param   str   the <code>String</code> that is concatenated to the end
+   *                of this <code>String</code>.
+   * @return  a string that represents the concatenation of this object's
+   *          characters followed by the string argument's characters.
+   * @exception java.lang.NullPointerException if <code>str</code> is
+   *          <code>null</code>.
+   */
+  public abstract XMLString concat(String str);
+
+  /**
+   * Converts all of the characters in this <code>String</code> to lower
+   * case using the rules of the given <code>Locale</code>.
+   *
+   * @param locale use the case transformation rules for this locale
+   * @return the String, converted to lowercase.
+   * @see     java.lang.Character#toLowerCase(char)
+   * @see     java.lang.String#toUpperCase(Locale)
+   */
+  public abstract XMLString toLowerCase(Locale locale);
+
+  /**
+   * Converts all of the characters in this <code>String</code> to lower
+   * case using the rules of the default locale, which is returned
+   * by <code>Locale.getDefault</code>.
+   * <p>
+   *
+   * @return  the string, converted to lowercase.
+   * @see     java.lang.Character#toLowerCase(char)
+   * @see     java.lang.String#toLowerCase(Locale)
+   */
+  public abstract XMLString toLowerCase();
+
+  /**
+   * Converts all of the characters in this <code>String</code> to upper
+   * case using the rules of the given locale.
+   * @param locale use the case transformation rules for this locale
+   * @return the String, converted to uppercase.
+   * @see     java.lang.Character#toUpperCase(char)
+   * @see     java.lang.String#toLowerCase(Locale)
+   */
+  public abstract XMLString toUpperCase(Locale locale);
+
+  /**
+   * Converts all of the characters in this <code>String</code> to upper
+   * case using the rules of the default locale, which is returned
+   * by <code>Locale.getDefault</code>.
+   *
+   * <p>
+   * If no character in this string has a different uppercase version,
+   * based on calling the <code>toUpperCase</code> method defined by
+   * <code>Character</code>, then the original string is returned.
+   * <p>
+   * Otherwise, this method creates a new <code>String</code> object
+   * representing a character sequence identical in length to the
+   * character sequence represented by this <code>String</code> object and
+   * with every character equal to the result of applying the method
+   * <code>Character.toUpperCase</code> to the corresponding character of
+   * this <code>String</code> object. <p>
+   * Examples:
+   * <blockquote><pre>
+   * "Fahrvergnügen".toUpperCase() returns "FAHRVERGNÜGEN"
+   * "Visit Ljubinje!".toUpperCase() returns "VISIT LJUBINJE!"
+   * </pre></blockquote>
+   *
+   * @return  the string, converted to uppercase.
+   * @see     java.lang.Character#toUpperCase(char)
+   * @see     java.lang.String#toUpperCase(Locale)
+   */
+  public abstract XMLString toUpperCase();
+
+  /**
+   * Removes white space from both ends of this string.
+   * <p>
+   * If this <code>String</code> object represents an empty character
+   * sequence, or the first and last characters of character sequence
+   * represented by this <code>String</code> object both have codes
+   * greater than <code>'&#92;u0020'</code> (the space character), then a
+   * reference to this <code>String</code> object is returned.
+   * <p>
+   * Otherwise, if there is no character with a code greater than
+   * <code>'&#92;u0020'</code> in the string, then a new
+   * <code>String</code> object representing an empty string is created
+   * and returned.
+   * <p>
+   * Otherwise, let <i>k</i> be the index of the first character in the
+   * string whose code is greater than <code>'&#92;u0020'</code>, and let
+   * <i>m</i> be the index of the last character in the string whose code
+   * is greater than <code>'&#92;u0020'</code>. A new <code>String</code>
+   * object is created, representing the substring of this string that
+   * begins with the character at index <i>k</i> and ends with the
+   * character at index <i>m</i>-that is, the result of
+   * <code>this.substring(<i>k</i>,&nbsp;<i>m</i>+1)</code>.
+   * <p>
+   * This method may be used to trim
+   * {@link Character#isSpace(char) whitespace} from the beginning and end
+   * of a string; in fact, it trims all ASCII control characters as well.
+   *
+   * @return  this string, with white space removed from the front and end.
+   */
+  public abstract XMLString trim();
+
+  /**
+   * This object (which is already a string!) is itself returned.
+   *
+   * @return  the string itself.
+   */
+  public abstract String toString();
+  
+  /**
+   * Tell if this object contains a java String object.
+   * 
+   * @return true if this XMLString can return a string without creating one.
+   */
+  public abstract boolean hasString();
+  
+  /**
+   * Convert a string to a double -- Allowed input is in fixed
+   * notation ddd.fff.
+   *
+   * @return A double value representation of the string, or return Double.NaN 
+   * if the string can not be converted.
+   */
+  public double toDouble();
+}
diff --git a/compat_src/org/apache/xalan/xslt/XSLProcessorException.java b/src/org/apache/xml/utils/XMLStringFactory.java
similarity index 64%
rename from compat_src/org/apache/xalan/xslt/XSLProcessorException.java
rename to src/org/apache/xml/utils/XMLStringFactory.java
index 0a2b352..8675597 100644
--- a/compat_src/org/apache/xalan/xslt/XSLProcessorException.java
+++ b/src/org/apache/xml/utils/XMLStringFactory.java
@@ -54,54 +54,54 @@
  * information on the Apache Software Foundation, please see
  * <http://www.apache.org/>.
  */
-package org.apache.xalan.xslt;
-
-import org.xml.sax.SAXException;
-import org.apache.xalan.res.XSLTErrorResources;
-import org.apache.xalan.res.XSLMessages;
-
+package org.apache.xml.utils;
 
 /**
- * <meta name="usage" content="general"/>
- * The exception used for most XSLT errors.
+ * A concrete class that implements this interface creates XMLString objects.
  */
-public class XSLProcessorException extends SAXException
+public abstract class XMLStringFactory
 {
-  private Exception m_exception;
-  
+
   /**
-   * Create an XSLProcessorException object that holds 
-   * an error message.
-   * @param message The error message.
+   * Create a new XMLString from a Java string.
+   *
+   *
+   * @param string Java String reference, which must be non-null.
+   *
+   * @return An XMLString object that wraps the String reference.
    */
-  public XSLProcessorException(String message) 
-  {
-     super((null == message) ? XSLMessages.createMessage(XSLTErrorResources.ER_XSLT_ERROR, null) : message);
-     m_exception = null;
-  }
-  
+  public abstract XMLString newstr(String string);
+
   /**
-   * Create an XSLProcessorException object that holds 
-   * an error message, and another exception 
-   * that caused this exception.
-   * @param message The error message.
-   * @param e The exception that caused this exception.
+   * Create a XMLString from a FastStringBuffer.
+   *
+   *
+   * @param string FastStringBuffer reference, which must be non-null.
+   * @param start The start position in the array.
+   * @param length The number of characters to read from the array.
+   *
+   * @return An XMLString object that wraps the FastStringBuffer reference.
    */
-  public XSLProcessorException (String message, Exception e)
-  {
-    super((null == message) ? XSLMessages.createMessage(XSLTErrorResources.ER_XSLT_ERROR, null) : message);
-    this.m_exception = e;
-  }
-  
+  public abstract XMLString newstr(FastStringBuffer string, int start, 
+                                   int length);
+
   /**
-   * Create an XSLProcessorException object that holds 
-   * another exception that caused this exception.
-   * @param e The exception that caused this exception.
+   * Create a XMLString from a FastStringBuffer.
+   *
+   *
+   * @param string FastStringBuffer reference, which must be non-null.
+   * @param start The start position in the array.
+   * @param length The number of characters to read from the array.
+   *
+   * @return An XMLString object that wraps the FastStringBuffer reference.
    */
-  public XSLProcessorException (Exception e)
-  {
-    super((null == e.getMessage()) ? XSLMessages.createMessage(XSLTErrorResources.ER_XSLT_ERROR, null) : e.getMessage());
-    this.m_exception = e;
-  }
-    
+  public abstract XMLString newstr(char[] string, int start, 
+                                   int length);
+                                   
+  /**
+   * Get a cheap representation of an empty string.
+   * 
+   * @return An non-null reference to an XMLString that represents "".
+   */
+  public abstract XMLString emptystr();
 }
diff --git a/src/org/apache/xpath/Expression.java b/src/org/apache/xpath/Expression.java
index 8a6ce7c..e3e08bb 100644
--- a/src/org/apache/xpath/Expression.java
+++ b/src/org/apache/xpath/Expression.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.res.XPATHErrorResources;
diff --git a/src/org/apache/xpath/NodeSet.java b/src/org/apache/xpath/NodeSet.java
index c2fc758..7f7509a 100644
--- a/src/org/apache/xpath/NodeSet.java
+++ b/src/org/apache/xpath/NodeSet.java
@@ -56,12 +56,17 @@
  */
 package org.apache.xpath;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.DOMException;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.NodeList;
+//import org.w3c.dom.NamedNodeMap;
+//import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.traversal.NodeFilter;
+//import org.w3c.dom.DOMException;
+
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMFilter;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMManager;
 
 import org.apache.xml.utils.NodeVector;
 import org.apache.xpath.axes.ContextNodeList;
@@ -91,7 +96,8 @@
  * less-than-enlightening results when you do so.</p>
  */
 public class NodeSet extends NodeVector
-        implements NodeList, NodeIterator, Cloneable, ContextNodeList
+        implements /* NodeList, NodeIterator, */ DTMIterator, 
+        Cloneable
 {
 
   /**
@@ -106,25 +112,27 @@
    * Create an empty, using the given block size.
    *
    * @param blocksize Size of blocks to allocate 
+   * @param dummy pass zero for right now...
    */
-  public NodeSet(int blocksize)
+  public NodeSet(int blocksize, int dummy)
   {
     super(blocksize);
   }
 
-  /**
-   * Create a NodeSet, and copy the members of the
-   * given nodelist into it.
-   *
-   * @param nodelist List of Nodes to be made members of the new set.
-   */
-  public NodeSet(NodeList nodelist)
-  {
-
-    super();
-
-    addNodes(nodelist);
-  }
+  // %TBD%
+//  /**
+//   * Create a NodeSet, and copy the members of the
+//   * given nodelist into it.
+//   *
+//   * @param nodelist List of Nodes to be made members of the new set.
+//   */
+//  public NodeSet(NodeList nodelist)
+//  {
+//
+//    super();
+//
+//    addNodes(nodelist);
+//  }
 
   /**
    * Create a NodeSet, and copy the members of the
@@ -137,16 +145,16 @@
 
     super();
 
-    addNodes((NodeIterator) nodelist);
+    addNodes((DTMIterator) nodelist);
   }
 
   /**
    * Create a NodeSet, and copy the members of the
-   * given NodeIterator into it.
+   * given DTMIterator into it.
    *
    * @param ni Iterator which yields Nodes to be made members of the new set.
    */
-  public NodeSet(NodeIterator ni)
+  public NodeSet(DTMIterator ni)
   {
 
     super();
@@ -159,22 +167,56 @@
    *
    * @param node Single node to be added to the new set.
    */
-  public NodeSet(Node node)
+  public NodeSet(int node)
   {
 
     super();
 
     addNode(node);
   }
+  
+  /**
+   * Set the environment in which this iterator operates, which should provide:
+   * a node (the context node... same value as "root" defined below) 
+   * a pair of non-zero positive integers (the context position and the context size) 
+   * a set of variable bindings 
+   * a function library 
+   * the set of namespace declarations in scope for the expression.
+   * 
+   * <p>At this time the exact implementation of this environment is application 
+   * dependent.  Probably a proper interface will be created fairly soon.</p>
+   * 
+   * @param environment The environment object.
+   */
+  public void setEnvironment(Object environment)
+  {
+    // no-op
+  }
+
 
   /**
    * @return The root node of the Iterator, as specified when it was created.
    * For non-Iterator NodeSets, this will be null.
    */
-  public Node getRoot()
+  public int getRoot()
   {
-    return null;
+    // %TBD%?
+    return DTM.NULL;
   }
+  
+  /**
+   * The root node of the <code>DTMIterator</code>, as specified when it
+   * was created.  Note the root node is not the root node of the 
+   * document tree, but the context node from where the itteration 
+   * begins.
+   *
+   * @param nodeHandle int Handle of the context node.
+   */
+  public void setRoot(int nodeHandle)
+  {
+  // %TBD%
+  }
+
 
   /**
    * Clone this NodeSet.
@@ -206,7 +248,7 @@
    * @throws CloneNotSupportedException if this subclass of NodeSet
    * does not support the clone() operation.
    */
-  public NodeIterator cloneWithReset() throws CloneNotSupportedException
+  public DTMIterator cloneWithReset() throws CloneNotSupportedException
   {
 
     NodeSet clone = (NodeSet) clone();
@@ -227,26 +269,26 @@
   /**
    *  This attribute determines which node types are presented via the
    * iterator. The available set of constants is defined in the
-   * <code>NodeFilter</code> interface. For NodeSets, the mask has been
+   * <code>DTMFilter</code> interface. For NodeSets, the mask has been
    * hardcoded to show all nodes except EntityReference nodes, which have
    * no equivalent in the XPath data model.
    *
    * @return integer used as a bit-array, containing flags defined in
-   * the DOM's NodeFilter class. The value will be 
+   * the DOM's DTMFilter class. The value will be 
    * <code>SHOW_ALL & ~SHOW_ENTITY_REFERENCE</code>, meaning that
    * only entity references are suppressed.
    */
   public int getWhatToShow()
   {
-    return NodeFilter.SHOW_ALL & ~NodeFilter.SHOW_ENTITY_REFERENCE;
+    return DTMFilter.SHOW_ALL & ~DTMFilter.SHOW_ENTITY_REFERENCE;
   }
 
   /**
    * The filter object used to screen nodes. Filters are applied to
-   * further reduce (and restructure) the NodeIterator's view of the
+   * further reduce (and restructure) the DTMIterator's view of the
    * document. In our case, we will be using hardcoded filters built
    * into our iterators... but getFilter() is part of the DOM's 
-   * NodeIterator interface, so we have to support it.
+   * DTMIterator interface, so we have to support it.
    *
    * @return null, which is slightly misleading. True, there is no
    * user-written filter object, but in fact we are doing some very
@@ -254,7 +296,7 @@
    * returning a placeholder object just to indicate that this is
    * not going to return all nodes selected by whatToShow.
    */
-  public NodeFilter getFilter()
+  public DTMFilter getFilter()
   {
     return null;
   }
@@ -279,10 +321,38 @@
   {
     return true;
   }
+  
+  /**
+   * Get an instance of a DTM that "owns" a node handle.  Since a node 
+   * iterator may be passed without a DTMManager, this allows the 
+   * caller to easily get the DTM using just the iterator.
+   *
+   * @param nodeHandle the nodeHandle.
+   *
+   * @return a non-null DTM reference.
+   */
+  public DTM getDTM(int nodeHandle)
+  {
+    // %TBD%
+    return null;
+  }
+  
+  /**
+   * Get an instance of the DTMManager.  Since a node 
+   * iterator may be passed without a DTMManager, this allows the 
+   * caller to easily get the DTMManager using just the iterator.
+   *
+   * @return a non-null DTMManager reference.
+   */
+  public DTMManager getDTMManager()
+  {
+    // %TBD%
+    return null;
+  }
 
   /**
    *  Returns the next node in the set and advances the position of the
-   * iterator in the set. After a NodeIterator is created, the first call
+   * iterator in the set. After a DTMIterator is created, the first call
    * to nextNode() returns the first node in the set.
    * @return  The next <code>Node</code> in the set being iterated over, or
    *   <code>null</code> if there are no more members in that set.
@@ -290,19 +360,19 @@
    *    INVALID_STATE_ERR: Raised if this method is called after the
    *   <code>detach</code> method was invoked.
    */
-  public Node nextNode() throws DOMException
+  public int nextNode()
   {
 
     if ((m_next) < this.size())
     {
-      Node next = this.elementAt(m_next);
+      int next = this.elementAt(m_next);
 
       m_next++;
 
       return next;
     }
     else
-      return null;
+      return DTM.NULL;
   }
 
   /**
@@ -316,7 +386,7 @@
    * @throws RuntimeException thrown if this NodeSet is not of 
    * a cached type, and hence doesn't know what the previous node was.
    */
-  public Node previousNode() throws DOMException
+  public int previousNode()
   {
 
     if (!m_cacheNodes)
@@ -330,7 +400,7 @@
       return this.elementAt(m_next);
     }
     else
-      return null;
+      return DTM.NULL;
   }
 
   /**
@@ -396,12 +466,12 @@
    *   <code>NodeList</code>, or <code>null</code> if that is not a valid
    *   index.
    */
-  public Node item(int index)
+  public int item(int index)
   {
 
     runTo(index);
 
-    return (Node) this.elementAt(index);
+    return this.elementAt(index);
   }
 
   /**
@@ -428,7 +498,7 @@
    * @throws RuntimeException thrown if this NodeSet is not of 
    * a mutable type.
    */
-  public void addNode(Node n)
+  public void addNode(int n)
   {
 
     if (!m_mutable)
@@ -446,7 +516,7 @@
    * @throws RuntimeException thrown if this NodeSet is not of 
    * a mutable type.
    */
-  public void insertNode(Node n, int pos)
+  public void insertNode(int n, int pos)
   {
 
     if (!m_mutable)
@@ -462,7 +532,7 @@
    * @throws RuntimeException thrown if this NodeSet is not of 
    * a mutable type.
    */
-  public void removeNode(Node n)
+  public void removeNode(int n)
   {
 
     if (!m_mutable)
@@ -471,73 +541,75 @@
     this.removeElement(n);
   }
 
-  /**
-   * Copy NodeList members into this nodelist, adding in
-   * document order.  If a node is null, don't add it.
-   *
-   * @param nodelist List of nodes which should now be referenced by
-   * this NodeSet.
-   * @throws RuntimeException thrown if this NodeSet is not of 
-   * a mutable type.
-   */
-  public void addNodes(NodeList nodelist)
-  {
+  // %TBD%
+//  /**
+//   * Copy NodeList members into this nodelist, adding in
+//   * document order.  If a node is null, don't add it.
+//   *
+//   * @param nodelist List of nodes which should now be referenced by
+//   * this NodeSet.
+//   * @throws RuntimeException thrown if this NodeSet is not of 
+//   * a mutable type.
+//   */
+//  public void addNodes(NodeList nodelist)
+//  {
+//
+//    if (!m_mutable)
+//      throw new RuntimeException("This NodeSet is not mutable!");
+//
+//    if (null != nodelist)  // defensive to fix a bug that Sanjiva reported.
+//    {
+//      int nChildren = nodelist.getLength();
+//
+//      for (int i = 0; i < nChildren; i++)
+//      {
+//        int obj = nodelist.item(i);
+//
+//        if (null != obj)
+//        {
+//          addElement(obj);
+//        }
+//      }
+//    }
+//
+//    // checkDups();
+//  }
 
-    if (!m_mutable)
-      throw new RuntimeException("This NodeSet is not mutable!");
-
-    if (null != nodelist)  // defensive to fix a bug that Sanjiva reported.
-    {
-      int nChildren = nodelist.getLength();
-
-      for (int i = 0; i < nChildren; i++)
-      {
-        Node obj = nodelist.item(i);
-
-        if (null != obj)
-        {
-          addElement(obj);
-        }
-      }
-    }
-
-    // checkDups();
-  }
-
-  /**
-   * <p>Copy NodeList members into this nodelist, adding in
-   * document order.  Only genuine node references will be copied;
-   * nulls appearing in the source NodeSet will
-   * not be added to this one. </p>
-   * 
-   * <p> In case you're wondering why this function is needed: NodeSet
-   * implements both NodeIterator and NodeList. If this method isn't
-   * provided, Java can't decide which of those to use when addNodes()
-   * is invoked. Providing the more-explicit match avoids that
-   * ambiguity.)</p>
-   *
-   * @param ns NodeSet whose members should be merged into this NodeSet.
-   * @throws RuntimeException thrown if this NodeSet is not of 
-   * a mutable type.
-   */
-  public void addNodes(NodeSet ns)
-  {
-
-    if (!m_mutable)
-      throw new RuntimeException("This NodeSet is not mutable!");
-
-    addNodes((NodeIterator) ns);
-  }
+  // %TBD%
+//  /**
+//   * <p>Copy NodeList members into this nodelist, adding in
+//   * document order.  Only genuine node references will be copied;
+//   * nulls appearing in the source NodeSet will
+//   * not be added to this one. </p>
+//   * 
+//   * <p> In case you're wondering why this function is needed: NodeSet
+//   * implements both DTMIterator and NodeList. If this method isn't
+//   * provided, Java can't decide which of those to use when addNodes()
+//   * is invoked. Providing the more-explicit match avoids that
+//   * ambiguity.)</p>
+//   *
+//   * @param ns NodeSet whose members should be merged into this NodeSet.
+//   * @throws RuntimeException thrown if this NodeSet is not of 
+//   * a mutable type.
+//   */
+//  public void addNodes(NodeSet ns)
+//  {
+//
+//    if (!m_mutable)
+//      throw new RuntimeException("This NodeSet is not mutable!");
+//
+//    addNodes((DTMIterator) ns);
+//  }
 
   /**
    * Copy NodeList members into this nodelist, adding in
    * document order.  Null references are not added.
    *
-   * @param iterator NodeIterator which yields the nodes to be added.
+   * @param iterator DTMIterator which yields the nodes to be added.
    * @throws RuntimeException thrown if this NodeSet is not of 
    * a mutable type.
    */
-  public void addNodes(NodeIterator iterator)
+  public void addNodes(DTMIterator iterator)
   {
 
     if (!m_mutable)
@@ -545,9 +617,9 @@
 
     if (null != iterator)  // defensive to fix a bug that Sanjiva reported.
     {
-      Node obj;
+      int obj;
 
-      while (null != (obj = iterator.nextNode()))
+      while (DTM.NULL != (obj = iterator.nextNode()))
       {
         addElement(obj);
       }
@@ -556,120 +628,122 @@
     // checkDups();
   }
 
-  /**
-   * Copy NodeList members into this nodelist, adding in
-   * document order.  If a node is null, don't add it.
-   *
-   * @param nodelist List of nodes to be added
-   * @param support The XPath runtime context.
-   * @throws RuntimeException thrown if this NodeSet is not of 
-   * a mutable type.
-   */
-  public void addNodesInDocOrder(NodeList nodelist, XPathContext support)
-  {
-
-    if (!m_mutable)
-      throw new RuntimeException("This NodeSet is not mutable!");
-
-    int nChildren = nodelist.getLength();
-
-    for (int i = 0; i < nChildren; i++)
-    {
-      Node node = nodelist.item(i);
-
-      if (null != node)
-      {
-        addNodeInDocOrder(node, support);
-      }
-    }
-  }
+  // %TBD%
+//  /**
+//   * Copy NodeList members into this nodelist, adding in
+//   * document order.  If a node is null, don't add it.
+//   *
+//   * @param nodelist List of nodes to be added
+//   * @param support The XPath runtime context.
+//   * @throws RuntimeException thrown if this NodeSet is not of 
+//   * a mutable type.
+//   */
+//  public void addNodesInDocOrder(NodeList nodelist, XPathContext support)
+//  {
+//
+//    if (!m_mutable)
+//      throw new RuntimeException("This NodeSet is not mutable!");
+//
+//    int nChildren = nodelist.getLength();
+//
+//    for (int i = 0; i < nChildren; i++)
+//    {
+//      int node = nodelist.item(i);
+//
+//      if (null != node)
+//      {
+//        addNodeInDocOrder(node, support);
+//      }
+//    }
+//  }
 
   /**
    * Copy NodeList members into this nodelist, adding in
    * document order.  If a node is null, don't add it.
    *
-   * @param iterator NodeIterator which yields the nodes to be added.
+   * @param iterator DTMIterator which yields the nodes to be added.
    * @param support The XPath runtime context.
    * @throws RuntimeException thrown if this NodeSet is not of 
    * a mutable type.
    */
-  public void addNodesInDocOrder(NodeIterator iterator, XPathContext support)
+  public void addNodesInDocOrder(DTMIterator iterator, XPathContext support)
   {
 
     if (!m_mutable)
       throw new RuntimeException("This NodeSet is not mutable!");
 
-    Node node;
+    int node;
 
-    while (null != (node = iterator.nextNode()))
+    while (DTM.NULL != (node = iterator.nextNode()))
     {
       addNodeInDocOrder(node, support);
     }
   }
 
-  /**
-   * Add the node list to this node set in document order.
-   *
-   * @param start index.
-   * @param end index.
-   * @param testIndex index.
-   * @param nodelist The nodelist to add.
-   * @param support The XPath runtime context.
-   *
-   * @return false always.
-   * @throws RuntimeException thrown if this NodeSet is not of 
-   * a mutable type.
-   */
-  private boolean addNodesInDocOrder(int start, int end, int testIndex,
-                                     NodeList nodelist, XPathContext support)
-  {
-
-    if (!m_mutable)
-      throw new RuntimeException("This NodeSet is not mutable!");
-
-    boolean foundit = false;
-    int i;
-    Node node = nodelist.item(testIndex);
-
-    for (i = end; i >= start; i--)
-    {
-      Node child = (Node) elementAt(i);
-
-      if (child == node)
-      {
-        i = -2;  // Duplicate, suppress insert
-
-        break;
-      }
-
-      if (!support.getDOMHelper().isNodeAfter(node, child))
-      {
-        insertElementAt(node, i + 1);
-
-        testIndex--;
-
-        if (testIndex > 0)
-        {
-          boolean foundPrev = addNodesInDocOrder(0, i, testIndex, nodelist,
-                                                 support);
-
-          if (!foundPrev)
-          {
-            addNodesInDocOrder(i, size() - 1, testIndex, nodelist, support);
-          }
-        }
-
-        break;
-      }
-    }
-
-    if (i == -1)
-    {
-      insertElementAt(node, 0);
-    }
-
-    return foundit;
-  }
+  // %TBD%
+//  /**
+//   * Add the node list to this node set in document order.
+//   *
+//   * @param start index.
+//   * @param end index.
+//   * @param testIndex index.
+//   * @param nodelist The nodelist to add.
+//   * @param support The XPath runtime context.
+//   *
+//   * @return false always.
+//   * @throws RuntimeException thrown if this NodeSet is not of 
+//   * a mutable type.
+//   */
+//  private boolean addNodesInDocOrder(int start, int end, int testIndex,
+//                                     NodeList nodelist, XPathContext support)
+//  {
+//
+//    if (!m_mutable)
+//      throw new RuntimeException("This NodeSet is not mutable!");
+//
+//    boolean foundit = false;
+//    int i;
+//    int node = nodelist.item(testIndex);
+//
+//    for (i = end; i >= start; i--)
+//    {
+//      int child = elementAt(i);
+//
+//      if (child == node)
+//      {
+//        i = -2;  // Duplicate, suppress insert
+//
+//        break;
+//      }
+//
+//      if (!support.getDOMHelper().isNodeAfter(node, child))
+//      {
+//        insertElementAt(node, i + 1);
+//
+//        testIndex--;
+//
+//        if (testIndex > 0)
+//        {
+//          boolean foundPrev = addNodesInDocOrder(0, i, testIndex, nodelist,
+//                                                 support);
+//
+//          if (!foundPrev)
+//          {
+//            addNodesInDocOrder(i, size() - 1, testIndex, nodelist, support);
+//          }
+//        }
+//
+//        break;
+//      }
+//    }
+//
+//    if (i == -1)
+//    {
+//      insertElementAt(node, 0);
+//    }
+//
+//    return foundit;
+//  }
 
   /**
    * Add the node into a vector of nodes where it should occur in
@@ -684,7 +758,7 @@
    * @throws RuntimeException thrown if this NodeSet is not of 
    * a mutable type.
    */
-  public int addNodeInDocOrder(Node node, boolean test, XPathContext support)
+  public int addNodeInDocOrder(int node, boolean test, XPathContext support)
   {
 
     if (!m_mutable)
@@ -702,7 +776,7 @@
 
       for (i = size - 1; i >= 0; i--)
       {
-        Node child = (Node) elementAt(i);
+        int child = elementAt(i);
 
         if (child == node)
         {
@@ -711,7 +785,8 @@
           break;
         }
 
-        if (!support.getDOMHelper().isNodeAfter(node, child))
+        DTM dtm = support.getDTM(node);
+        if (!dtm.isNodeAfter(node, child))
         {
           break;
         }
@@ -732,7 +807,7 @@
 
       for (int i = 0; i < insertIndex; i++)
       {
-        if (this.item(i).equals(node))
+        if (i == node)
         {
           foundit = true;
 
@@ -761,7 +836,7 @@
    * @throws RuntimeException thrown if this NodeSet is not of 
    * a mutable type.
    */
-  public int addNodeInDocOrder(Node node, XPathContext support)
+  public int addNodeInDocOrder(int node, XPathContext support)
   {
 
     if (!m_mutable)
@@ -787,7 +862,7 @@
    * @throws RuntimeException thrown if this NodeSet is not of 
    * a mutable type.
    */
-  public void addElement(Node value)
+  public void addElement(int value)
   {
 
     if (!m_mutable)
@@ -807,7 +882,7 @@
    * @throws RuntimeException thrown if this NodeSet is not of 
    * a mutable type.
    */
-  public void insertElementAt(Node value, int at)
+  public void insertElementAt(int value, int at)
   {
 
     if (!m_mutable)
@@ -862,7 +937,7 @@
    * @throws RuntimeException thrown if this NodeSet is not of 
    * a mutable type.
    */
-  public boolean removeElement(Node s)
+  public boolean removeElement(int s)
   {
 
     if (!m_mutable)
@@ -902,7 +977,24 @@
    * @throws RuntimeException thrown if this NodeSet is not of 
    * a mutable type.
    */
-  public void setElementAt(Node node, int index)
+  public void setElementAt(int node, int index)
+  {
+
+    if (!m_mutable)
+      throw new RuntimeException("This NodeSet is not mutable!");
+
+    super.setElementAt(node, index);
+  }
+  
+  /**
+   * Same as setElementAt.
+   *
+   * @param node  The node to be set.
+   * @param index The index of the node to be replaced.
+   * @throws RuntimeException thrown if this NodeSet is not of 
+   * a mutable type.
+   */
+  public void setItem(int node, int index)
   {
 
     if (!m_mutable)
@@ -918,7 +1010,7 @@
    *
    * @return Node at specified index.
    */
-  public Node elementAt(int i)
+  public int elementAt(int i)
   {
 
     runTo(i);
@@ -933,7 +1025,7 @@
    *
    * @return True if the given node was found.
    */
-  public boolean contains(Node s)
+  public boolean contains(int s)
   {
 
     runTo(-1);
@@ -952,7 +1044,7 @@
    * argument in this vector at position index or later in the
    * vector; returns -1 if the object is not found.
    */
-  public int indexOf(Node elem, int index)
+  public int indexOf(int elem, int index)
   {
 
     runTo(-1);
@@ -970,7 +1062,7 @@
    * argument in this vector at position index or later in the
    * vector; returns -1 if the object is not found.
    */
-  public int indexOf(Node elem)
+  public int indexOf(int elem)
   {
 
     runTo(-1);
@@ -1018,7 +1110,7 @@
    * @throws RuntimeException thrown if this NodeSet is not of 
    * a cached type, and thus doesn't permit indexed access.
    */
-  public Node getCurrentNode()
+  public int getCurrentNode()
   {
 
     if (!m_cacheNodes)
@@ -1026,7 +1118,7 @@
         "This NodeSet can not do indexing or counting functions!");
 
     int saved = m_next;
-    Node n = elementAt(m_next-1);
+    int n = elementAt(m_next-1);
     m_next = saved; // HACK: I think this is a bit of a hack.  -sb
     return n;
   }
@@ -1071,6 +1163,16 @@
     m_mutable = true;
   }
   
+  /**
+   * Tells if this iterator can have nodes added to it or set via 
+   * the <code>setItem(int node, int index)</code> method.
+   * 
+   * @return True if the nodelist can be mutated.
+   */
+  public boolean isMutable()
+  {
+    return m_mutable;
+  }
   
   transient private int m_last = 0;
   
diff --git a/src/org/apache/xpath/SourceTree.java b/src/org/apache/xpath/SourceTree.java
index 37b8baf..9f04629 100644
--- a/src/org/apache/xpath/SourceTree.java
+++ b/src/org/apache/xpath/SourceTree.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 /**
  * <meta name="usage" content="internal"/>
@@ -74,7 +74,7 @@
    * {@link org.w3c.dom.Document} node.
    * @param url The URI of the source tree.
    */
-  public SourceTree(Node root, String url)
+  public SourceTree(int root, String url)
   {
     m_root = root;
     m_url = url;
@@ -85,5 +85,5 @@
 
   /** The root of the source tree, which may or may not be a 
    * {@link org.w3c.dom.Document} node.  */
-  public Node m_root;
+  public int m_root;
 }
diff --git a/src/org/apache/xpath/SourceTreeManager.java b/src/org/apache/xpath/SourceTreeManager.java
index 42f017a..e9105c1 100644
--- a/src/org/apache/xpath/SourceTreeManager.java
+++ b/src/org/apache/xpath/SourceTreeManager.java
@@ -64,8 +64,12 @@
 import java.util.StringTokenizer;
 import java.util.Vector;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.Document;
+import org.apache.xpath.objects.XString;
+
+//import org.w3c.dom.Node;
+//import org.w3c.dom.Document;
+
+import org.apache.xml.dtm.DTM;
 
 import javax.xml.transform.URIResolver;
 import javax.xml.transform.TransformerException;
@@ -78,7 +82,6 @@
 
 // import org.xml.sax.Locator;
 import org.apache.xalan.res.XSLMessages;
-import org.apache.xalan.stree.SourceTreeHandler;
 import org.apache.xml.utils.SystemIDResolver;
 import org.apache.xml.utils.SAXSourceLocator;
 import org.apache.xpath.res.XPATHErrorResources;
@@ -141,30 +144,19 @@
    *
    * @return The base URI of the owner argument.
    */
-  public String findURIFromDoc(Document owner)
+  public String findURIFromDoc(int owner)
   {
-
-    Node root = owner.getOwnerDocument();
-
-    if (null == root)
-      root = owner;
-
-    String url = null;
     int n = m_sourceTree.size();
 
     for (int i = 0; i < n; i++)
     {
       SourceTree sTree = (SourceTree) m_sourceTree.elementAt(i);
 
-      if (root == sTree.m_root)
-      {
-        url = sTree.m_url;
-
-        break;
-      }
+      if (owner == sTree.m_root)
+        return sTree.m_url;
     }
 
-    return url;
+    return null;
   }
 
   /**
@@ -209,14 +201,14 @@
    * @param n The node to cache.
    * @param source The Source object to cache.
    */
-  public void putDocumentInCache(Node n, Source source)
+  public void putDocumentInCache(int n, Source source)
   {
 
-    Node cachedNode = getNode(source);
+    int cachedNode = getNode(source);
 
-    if (null != cachedNode)
+    if (DTM.NULL != cachedNode)
     {
-      if (!cachedNode.equals(n))
+      if (!(cachedNode == n))
         throw new RuntimeException(
           "Programmer's Error!  "
           + "putDocumentInCache found reparse of doc: "
@@ -236,7 +228,7 @@
    *
    * @return The node that is associated with the Source, or null if not found.
    */
-  public Node getNode(Source source)
+  public int getNode(Source source)
   {
 
 //    if (source instanceof DOMSource)
@@ -246,11 +238,9 @@
     String url = source.getSystemId();
 
     if (null == url)
-      return null;
+      return DTM.NULL;
 
-    Node node = null;
     int n = m_sourceTree.size();
-    ;
 
     // System.out.println("getNode: "+n);
     for (int i = 0; i < n; i++)
@@ -260,15 +250,11 @@
       // System.out.println("getNode -         url: "+url);
       // System.out.println("getNode - sTree.m_url: "+sTree.m_url);
       if (url.equals(sTree.m_url))
-      {
-        node = sTree.m_root;
-
-        break;
-      }
+        return sTree.m_root;
     }
 
     // System.out.println("getNode - returning: "+node);
-    return node;
+    return DTM.NULL;
   }
 
   /**
@@ -283,8 +269,8 @@
    *
    * @throws TransformerException If the URL can not resolve to a node.
    */
-  public Node getSourceTree(
-          String base, String urlString, SourceLocator locator)
+  public int getSourceTree(
+          String base, String urlString, SourceLocator locator, XPathContext xctxt)
             throws TransformerException
   {
 
@@ -294,7 +280,7 @@
       Source source = this.resolveURI(base, urlString, locator);
 
       // System.out.println("getSourceTree - base: "+base+", urlString: "+urlString+", source: "+source.getSystemId());
-      return getSourceTree(source, locator);
+      return getSourceTree(source, locator, xctxt);
     }
     catch (IOException ioe)
     {
@@ -318,18 +304,18 @@
    * @throws TransformerException if the Source argument can't be resolved to 
    *         a node.
    */
-  public Node getSourceTree(Source source, SourceLocator locator)
+  public int getSourceTree(Source source, SourceLocator locator, XPathContext xctxt)
           throws TransformerException
   {
 
-    Node n = getNode(source);
+    int n = getNode(source);
 
-    if (null != n)
+    if (DTM.NULL != n)
       return n;
 
-    n = getDOMNode(source, locator);
+    n = parseToNode(source, locator, xctxt);
 
-    if (null != n)
+    if (DTM.NULL != n)
       putDocumentInCache(n, source);
 
     return n;
@@ -346,83 +332,31 @@
    * @throws TransformerException if the source argument can not be resolved 
    *         to a source node.
    */
-  public Node getDOMNode(Source source, SourceLocator locator)
+  public int parseToNode(Source source, SourceLocator locator, XPathContext xctxt)
           throws TransformerException
   {
 
-    if (source instanceof DOMSource)
-    {
-      return ((DOMSource) source).getNode();
-    }
-
-    Node doc = null;
-
     try
-    {
-
-      // System.out.println("reading: "+source.getSystemId());
-      XMLReader reader = getXMLReader(source, locator);
-
-      // TODO: Need to use factory of some kind to create the ContentHandler
-      // (Also, try using JAXP if need be...)
-      ContentHandler handler = new SourceTreeHandler();
-
-      if (handler instanceof org.apache.xalan.stree.SourceTreeHandler)
+    {      
+      Object xowner = xctxt.getOwnerObject();
+      DTM dtm;
+      if(null != xowner && xowner instanceof org.apache.xml.dtm.DTMWSFilter)
       {
-
-        // temp hack
-        ((org.apache.xalan.stree.SourceTreeHandler) handler).setUseMultiThreading(
-          false);
+        dtm = xctxt.getDTM(source, false, 
+                          (org.apache.xml.dtm.DTMWSFilter)xowner, false);
       }
-
-      reader.setContentHandler(handler);
-
-      if (handler instanceof org.xml.sax.DTDHandler)
-        reader.setDTDHandler((org.xml.sax.DTDHandler) handler);
-
-      try
+      else
       {
-        if (handler instanceof org.xml.sax.ext.LexicalHandler)
-          reader.setProperty("http://xml.org/sax/properties/lexical-handler",
-                             handler);
-
-        if (handler instanceof org.xml.sax.ext.DeclHandler)
-          reader.setProperty(
-            "http://xml.org/sax/properties/declaration-handler", handler);
+        dtm = xctxt.getDTM(source, false, null, false);
       }
-      catch (org.xml.sax.SAXException se){}
-
-      try
-      {
-        if (handler instanceof org.xml.sax.ext.LexicalHandler)
-          reader.setProperty("http://xml.org/sax/handlers/LexicalHandler",
-                             handler);
-
-        if (handler instanceof org.xml.sax.ext.DeclHandler)
-          reader.setProperty("http://xml.org/sax/handlers/DeclHandler",
-                             handler);
-      }
-      catch (org.xml.sax.SAXNotRecognizedException snre){}
-
-      InputSource isource = SAXSource.sourceToInputSource(source);
-
-      reader.parse(isource);
-
-      if (handler instanceof org.apache.xalan.stree.SourceTreeHandler)
-      {
-        doc = ((org.apache.xalan.stree.SourceTreeHandler) handler).getRoot();
-      }
+      return dtm.getDocument();
     }
-    catch (IOException ioe)
+    catch (Exception e)
     {
-      throw new TransformerException(ioe.getMessage(), locator, ioe);
-    }
-    catch (org.xml.sax.SAXException se)
-    {
-      throw new TransformerException(se.getMessage(), locator, se);
+      e.printStackTrace();
+      throw new TransformerException(e.getMessage(), locator, e);
     }
 
-    return doc;
   }
 
   /**
@@ -441,7 +375,7 @@
    *
    * @throws TransformerException if the reader can not be created.
    */
-  public XMLReader getXMLReader(Source inputSource, SourceLocator locator)
+  public static XMLReader getXMLReader(Source inputSource, SourceLocator locator)
           throws TransformerException
   {
 
diff --git a/src/org/apache/xpath/XPath.java b/src/org/apache/xpath/XPath.java
index e78ff07..ff3de7d 100644
--- a/src/org/apache/xpath/XPath.java
+++ b/src/org/apache/xpath/XPath.java
@@ -56,10 +56,13 @@
  */
 package org.apache.xpath;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.Document;
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.DocumentFragment;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.Document;
+//import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.DocumentFragment;
+
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import java.util.Vector;
 
@@ -227,6 +230,36 @@
   {  
     this(exprString, locator, prefixResolver, type, null);    
   }
+  
+  /**
+   * <meta name="usage" content="experimental"/>
+   * Given an expression and a context, evaluate the XPath
+   * and call the callback as nodes are found.  Only some simple
+   * types of expresions right now can call back, so if this
+   * method returns null, then the callbacks have been called, otherwise
+   * a valid XObject will be returned.
+   * 
+   * @param xctxt The execution context.
+   * @param contextNode The node that "." expresses.
+   * @param namespaceContext The context in which namespaces in the
+   * XPath are supposed to be expanded.
+
+   * @return The result of the XPath or null if callbacks are used.
+   * @throws TransformerException thrown if
+   * the error condition is severe enough to halt processing.
+   *
+   * @throws javax.xml.transform.TransformerException
+   */
+  public XObject execute(
+          XPathContext xctxt, org.w3c.dom.Node contextNode, 
+          PrefixResolver namespaceContext)
+            throws javax.xml.transform.TransformerException
+  {
+    return execute(
+          xctxt, xctxt.getDTMHandleFromNode(contextNode), 
+          namespaceContext);
+  }
+  
 
   /**
    * <meta name="usage" content="experimental"/>
@@ -235,24 +268,19 @@
    * types of expresions right now can call back, so if this
    * method returns null, then the callbacks have been called, otherwise
    * a valid XObject will be returned.
+   * 
    * @param xctxt The execution context.
    * @param contextNode The node that "." expresses.
    * @param namespaceContext The context in which namespaces in the
    * XPath are supposed to be expanded.
+   * 
    * @throws TransformerException thrown if the active ProblemListener decides
    * the error condition is severe enough to halt processing.
-   * @param callback Interface that implements the processLocatedNode method.
-   * @param callbackInfo Object that will be passed to the processLocatedNode method.
-   * @param stopAtFirst True if the search should stop once the first node in document
-   * order is found.
-   * @return The result of the XPath or null if callbacks are used.
-   * @throws TransformerException thrown if
-   * the error condition is severe enough to halt processing.
    *
    * @throws javax.xml.transform.TransformerException
    */
   public XObject execute(
-          XPathContext xctxt, Node contextNode, PrefixResolver namespaceContext)
+          XPathContext xctxt, int contextNode, PrefixResolver namespaceContext)
             throws javax.xml.transform.TransformerException
   {
 
@@ -285,7 +313,7 @@
       {
         e = ((org.apache.xml.utils.WrappedRuntimeException) e).getException();
       }
-
+      e.printStackTrace();
 
       String msg = e.getMessage();
       msg = (msg == null || msg.length()== 0)? "Unknown error in XPath" : msg;
@@ -326,7 +354,7 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  public double getMatchScore(XPathContext xctxt, Node context)
+  public double getMatchScore(XPathContext xctxt, int context)
           throws javax.xml.transform.TransformerException
   {
 
@@ -338,9 +366,12 @@
       XObject score = m_mainExp.execute(xctxt);
 
       if (DEBUG_MATCHES)
+      {
+        DTM dtm = xctxt.getDTM(context);
         System.out.println("score: " + score.num() + " for "
-                           + context.getNodeName() + " for xpath "
+                           + dtm.getNodeName(context) + " for xpath "
                            + this.getPatternString());
+      }
 
       return score.num();
     }
@@ -380,7 +411,7 @@
    *                              throw an exception.
    */
   public void warn(
-          XPathContext xctxt, Node sourceNode, int msg, Object[] args)
+          XPathContext xctxt, int sourceNode, int msg, Object[] args)
             throws javax.xml.transform.TransformerException
   {
 
@@ -433,7 +464,7 @@
    *                              throw an exception.
    */
   public void error(
-          XPathContext xctxt, Node sourceNode, int msg, Object[] args)
+          XPathContext xctxt, int sourceNode, int msg, Object[] args)
             throws javax.xml.transform.TransformerException
   {
 
diff --git a/src/org/apache/xpath/XPathAPI.java b/src/org/apache/xpath/XPathAPI.java
index ad2af27..b2f4f91 100644
--- a/src/org/apache/xpath/XPathAPI.java
+++ b/src/org/apache/xpath/XPathAPI.java
@@ -159,7 +159,9 @@
     XObject list = eval(contextNode, str, namespaceNode);
 
     // Have the XObject return its result as a NodeSet.
-    return list.nodeset();
+    // %TBD% Convert to DOM nodeset
+//    return list.nodeset();
+    return null;
   }
 
   /**
@@ -272,7 +274,9 @@
     XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null);
 
     // Execute the XPath, and have it return the result
-    return xpath.execute(xpathSupport, contextNode, prefixResolver);
+    // %TBD% Need to convert contextNode to a DTM node
+//    return xpath.execute(xpathSupport, contextNode, prefixResolver);
+    return null;
   }
 
   /**
@@ -311,6 +315,8 @@
     XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null);
 
     // Execute the XPath, and have it return the result
-    return xpath.execute(new XPathContext(), contextNode, prefixResolver);
+    // %TBD% Need to convert contextNode to a DTM node
+    // return xpath.execute(new XPathContext(), contextNode, prefixResolver);
+    return null;
   }
 }
diff --git a/src/org/apache/xpath/XPathContext.java b/src/org/apache/xpath/XPathContext.java
index 37c7fcd..8b8d564 100644
--- a/src/org/apache/xpath/XPathContext.java
+++ b/src/org/apache/xpath/XPathContext.java
@@ -76,11 +76,12 @@
 import org.apache.xpath.axes.SubContextList;
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.objects.XNodeSet;
+import org.apache.xpath.objects.XString;
 
 // DOM Imports
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.traversal.TreeWalker;
-import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.traversal.TreeWalker;
+//import org.w3c.dom.Node;
 
 import org.apache.xalan.extensions.ExpressionContext;
 
@@ -92,7 +93,6 @@
 // TRaX imports
 import javax.xml.transform.URIResolver;
 import javax.xml.transform.TransformerException;
-import org.apache.xml.utils.SAXSourceLocator;
 import javax.xml.transform.sax.SAXSource;
 import javax.xml.transform.dom.DOMSource;
 
@@ -103,12 +103,204 @@
 import javax.xml.transform.Source;
 import javax.xml.transform.ErrorListener;
 
+import org.apache.xml.dtm.DTMManager;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMFilter;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMWSFilter;
+
+// Utility imports.
+import org.apache.xml.utils.SAXSourceLocator;
+import org.apache.xml.utils.XMLString;
+import org.apache.xml.utils.XMLStringFactory;
+
+import org.apache.xpath.axes.DescendantIterator;
+
 /**
  * <meta name="usage" content="advanced"/>
  * Default class for the runtime execution context for XPath.
+ * 
+ * <p>This class extends DTMManager but does not directly implement it.</p>
  */
-public class XPathContext implements ExpressionContext
+public class XPathContext extends DTMManager // implements ExpressionContext
 {
+  /**
+   * Though XPathContext context extends 
+   * the DTMManager, it really is a proxy for this object, which 
+   * is the real DTMManager.
+   */
+  private DTMManager m_dtmManager = DTMManager.newInstance(
+                   org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());
+  
+  /**
+   * Return the DTMManager object.  Though XPathContext context extends 
+   * the DTMManager, it really is a proxy for the real DTMManager.  If a 
+   * caller needs to make a lot of calls to the DTMManager, it is faster 
+   * if it gets the real one from this function.
+   */
+   public DTMManager getDTMManager()
+   {
+     return m_dtmManager;
+   }
+  
+  /**
+   * Get an instance of a DTM, loaded with the content from the
+   * specified source.  If the unique flag is true, a new instance will
+   * always be returned.  Otherwise it is up to the DTMManager to return a
+   * new instance or an instance that it already created and may be being used
+   * by someone else.
+   * (I think more parameters will need to be added for error handling, and entity
+   * resolution).
+   *
+   * @param source the specification of the source object, which may be null, 
+   *               in which case it is assumed that node construction will take 
+   *               by some other means.
+   * @param unique true if the returned DTM must be unique, probably because it
+   * is going to be mutated.
+   * @param whiteSpaceFilter Enables filtering of whitespace nodes, and may 
+   *                         be null.
+   * @param incremental true if the construction should try and be incremental.
+   *
+   * @return a non-null DTM reference.
+   */
+  public DTM getDTM(javax.xml.transform.Source source, boolean unique, 
+                    DTMWSFilter wsfilter,
+                    boolean incremental)
+  {
+    return m_dtmManager.getDTM(source, unique, wsfilter, 
+                               incremental);
+  }
+                             
+  /**
+   * Get an instance of a DTM that "owns" a node handle.
+   *
+   * @param nodeHandle the nodeHandle.
+   *
+   * @return a non-null DTM reference.
+   */
+  public DTM getDTM(int nodeHandle)
+  {
+    return m_dtmManager.getDTM(nodeHandle);
+  }
+  
+  /**
+   * Given a W3C DOM node, try and return a DTM handle.
+   * Note: calling this may be non-optimal.
+   * 
+   * @param node Non-null reference to a DOM node.
+   * 
+   * @return a valid DTM handle.
+   */
+  public int getDTMHandleFromNode(org.w3c.dom.Node node)
+  {
+    return m_dtmManager.getDTMHandleFromNode(node);
+  }
+
+  
+  /**
+   * %TBD% Doc
+   */
+  public int getDTMIdentity(DTM dtm)
+  {
+    return m_dtmManager.getDTMIdentity(dtm);
+  }
+  
+  /**
+   * Creates an empty <code>DocumentFragment</code> object. 
+   * @return A new <code>DocumentFragment handle</code>.
+   */
+  public DTM createDocumentFragment()
+  {
+    return m_dtmManager.createDocumentFragment();
+  }
+  
+  /**
+   * Release a DTM either to a lru pool, or completely remove reference.
+   * DTMs without system IDs are always hard deleted.
+   * State: experimental.
+   * 
+   * @param dtm The DTM to be released.
+   * @param shouldHardDelete True if the DTM should be removed no matter what.
+   * @return true if the DTM was removed, false if it was put back in a lru pool.
+   */
+  public boolean release(DTM dtm, boolean shouldHardDelete)
+  {
+    return m_dtmManager.release(dtm, shouldHardDelete);
+  }
+
+  /**
+   * Create a new <code>DTMIterator</code> based on an XPath
+   * <a href="http://www.w3.org/TR/xpath#NT-LocationPath>LocationPath</a> or
+   * a <a href="http://www.w3.org/TR/xpath#NT-UnionExpr">UnionExpr</a>.
+   *
+   * @param xpathCompiler ??? Somehow we need to pass in a subpart of the
+   * expression.  I hate to do this with strings, since the larger expression
+   * has already been parsed.
+   *
+   * @param pos The position in the expression.
+   * @return The newly created <code>DTMIterator</code>.
+   */
+  public DTMIterator createDTMIterator(Object xpathCompiler, int pos)
+  {
+    return m_dtmManager.createDTMIterator(xpathCompiler, pos);
+  }
+
+  /**
+   * Create a new <code>DTMIterator</code> based on an XPath
+   * <a href="http://www.w3.org/TR/xpath#NT-LocationPath>LocationPath</a> or
+   * a <a href="http://www.w3.org/TR/xpath#NT-UnionExpr">UnionExpr</a>.
+   *
+   * @param xpathString Must be a valid string expressing a
+   * <a href="http://www.w3.org/TR/xpath#NT-LocationPath>LocationPath</a> or
+   * a <a href="http://www.w3.org/TR/xpath#NT-UnionExpr">UnionExpr</a>.
+   *
+   * @param presolver An object that can resolve prefixes to namespace URLs.
+   *
+   * @return The newly created <code>DTMIterator</code>.
+   */
+  public DTMIterator createDTMIterator(String xpathString,
+          PrefixResolver presolver)
+  {
+    return m_dtmManager.createDTMIterator(xpathString, presolver);
+  }
+
+  /**
+   * Create a new <code>DTMIterator</code> based only on a whatToShow and
+   * a DTMFilter.  The traversal semantics are defined as the descendant
+   * access.
+   *
+   * @param whatToShow This flag specifies which node types may appear in
+   *   the logical view of the tree presented by the iterator. See the
+   *   description of <code>NodeFilter</code> for the set of possible
+   *   <code>SHOW_</code> values.These flags can be combined using
+   *   <code>OR</code>.
+   * @param filter The <code>NodeFilter</code> to be used with this
+   *   <code>TreeWalker</code>, or <code>null</code> to indicate no filter.
+   * @param entityReferenceExpansion The value of this flag determines
+   *   whether entity reference nodes are expanded.
+   *
+   * @return The newly created <code>NodeIterator</code>.
+   */
+  public DTMIterator createDTMIterator(int whatToShow,
+          DTMFilter filter, boolean entityReferenceExpansion)
+  {
+    return m_dtmManager.createDTMIterator(whatToShow, filter, entityReferenceExpansion);
+  }
+  
+  /**
+   * Create a new <code>DTMIterator</code> that holds exactly one node.
+   *
+   * @param node The node handle that the DTMIterator will iterate to.
+   *
+   * @return The newly created <code>DTMIterator</code>.
+   */
+  public DTMIterator createDTMIterator(int node)
+  {
+    DescendantIterator iter = new DescendantIterator();
+    iter.initContext(this, node);
+    return iter;
+    // return m_dtmManager.createDTMIterator(node);
+  }
 
   /**
    * Create an XPathContext instance.
@@ -450,7 +642,7 @@
   //==========================================================
   // SECTION: Execution context state tracking
   //==========================================================
-
+  
   /**
    * The current context node list.
    */
@@ -465,11 +657,11 @@
    * @return  the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>,
    * also refered to here as a <term>context node list</term>.
    */
-  public final ContextNodeList getContextNodeList()
+  public final DTMIterator getContextNodeList()
   {
 
     if (m_contextNodeLists.size() > 0)
-      return (ContextNodeList) m_contextNodeLists.peek();
+      return (DTMIterator) m_contextNodeLists.peek();
     else
       return null;
   }
@@ -481,7 +673,7 @@
    * @param nl the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>,
    * also refered to here as a <term>context node list</term>.
    */
-  public final void pushContextNodeList(ContextNodeList nl)
+  public final void pushContextNodeList(DTMIterator nl)
   {
     m_contextNodeLists.push(nl);
   }
@@ -514,18 +706,18 @@
    *
    * @return the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
    */
-  public final Node getCurrentNode()
+  public final int getCurrentNode()
   {
     return m_currentNodes.peepOrNull();
   }
-
+  
   /**
    * Set the current context node and expression node.
    *
    * @param cn the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
    * @param en the sub-expression context node.
    */
-  public final void pushCurrentNodeAndExpression(Node cn, Node en)
+  public final void pushCurrentNodeAndExpression(int cn, int en)
   {
     m_currentNodes.push(cn);
     m_currentExpressionNodes.push(en);
@@ -545,7 +737,7 @@
    *
    * @param n the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
    */
-  public final void pushCurrentNode(Node n)
+  public final void pushCurrentNode(int n)
   {
     m_currentNodes.push(n);
   }
@@ -569,7 +761,7 @@
    *
    * @return The current sub-expression node.
    */
-  public final Node getCurrentExpressionNode()
+  public final int getCurrentExpressionNode()
   {
     return m_currentExpressionNodes.peepOrNull();
   }
@@ -579,7 +771,7 @@
    *
    * @param n The sub-expression node to be current.
    */
-  public final void pushCurrentExpressionNode(Node n)
+  public final void pushCurrentExpressionNode(int n)
   {
     m_currentExpressionNodes.push(n);
   }
@@ -666,7 +858,7 @@
    * Get the current context node.
    * @return The current context node.
    */
-  public final Node getContextNode()
+  public final int getContextNode()
   {
     return this.getCurrentNode();
   }
@@ -676,12 +868,12 @@
    * @return An iterator for the current context list, as
    * defined in XSLT.
    */
-  public final NodeIterator getContextNodes()
+  public final DTMIterator getContextNodes()
   {
 
     try
     {
-      ContextNodeList cnl = getContextNodeList();
+      DTMIterator cnl = getContextNodeList();
 
       if (null != cnl)
         return cnl.cloneWithReset();
@@ -693,24 +885,73 @@
       return null;  // error reporting?
     }
   }
-
+  
+  XPathExpressionContext expresionContext = new XPathExpressionContext();
+  
   /**
-   * Get the value of a node as a number.
-   * @param n Node to be converted to a number.  May be null.
-   * @return value of n as a number.
+   * The the expression context for extensions for this context.
+   * 
+   * @return An object that implements the ExpressionContext.
    */
-  public final double toNumber(Node n)
+  public ExpressionContext getExpressionContext()
   {
-    return XNodeSet.getNumberFromNode(n);
+    return expresionContext;
+  }
+  
+  class XPathExpressionContext implements ExpressionContext
+  {
+    
+    /**
+     * Get the current context node.
+     * @return The current context node.
+     */
+    public org.w3c.dom.Node getContextNode()
+    {
+      int context = m_currentNodes.peepOrNull();
+      
+      return getDTM(context).getNode(context);
+    }
+  
+    /**
+     * Get the current context node list.
+     * @return An iterator for the current context list, as
+     * defined in XSLT.
+     */
+    public org.w3c.dom.traversal.NodeIterator getContextNodes()
+    {
+      // %TBD%
+      return null;
+    }
+  
+    /**
+     * Get the value of a node as a number.
+     * @param n Node to be converted to a number.  May be null.
+     * @return value of n as a number.
+     */
+    public double toNumber(org.w3c.dom.Node n)
+    {
+      // %REVIEW% You can't get much uglier than this...
+      int nodeHandle = getDTMHandleFromNode(n);
+      DTM dtm = getDTM(nodeHandle);
+      XString xobj = (XString)dtm.getStringValue(nodeHandle);
+      return xobj.num();
+    }
+  
+    /**
+     * Get the value of a node as a string.
+     * @param n Node to be converted to a string.  May be null.
+     * @return value of n as a string, or an empty string if n is null.
+     */
+    public String toString(org.w3c.dom.Node n)
+    {
+      // %REVIEW% You can't get much uglier than this...
+      int nodeHandle = getDTMHandleFromNode(n);
+      DTM dtm = getDTM(nodeHandle);
+      XMLString strVal = dtm.getStringValue(nodeHandle);
+      return strVal.toString();
+    }
+
+    
   }
 
-  /**
-   * Get the value of a node as a string.
-   * @param n Node to be converted to a string.  May be null.
-   * @return value of n as a string, or an empty string if n is null.
-   */
-  public final String toString(Node n)
-  {
-    return XNodeSet.getStringFromNode(n);
-  }
 }
diff --git a/src/org/apache/xpath/axes/AncestorOrSelfWalker.java b/src/org/apache/xpath/axes/AncestorOrSelfWalker.java
index 2d71eff..d507d40 100644
--- a/src/org/apache/xpath/axes/AncestorOrSelfWalker.java
+++ b/src/org/apache/xpath/axes/AncestorOrSelfWalker.java
@@ -61,9 +61,10 @@
 import org.apache.xpath.axes.LocPathIterator;
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
-import org.apache.xpath.DOMHelper;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.utils.IntStack;
 
 /**
  * Walker for the 'ancestor-or-self' axes.
@@ -87,21 +88,21 @@
    *
    * @param n The context node.
    */
-  protected void pushAncestors(Node n)
+  protected void pushAncestors(int n)
   {
 
-    m_ancestors = new Stack();
+    m_ancestors = new IntStack();
 
     m_ancestors.push(n);
 
-    DOMHelper dh = m_lpi.getDOMHelper();
+    DTM dtm = getDTM(n);
 
-    while (null != (n = dh.getParentOfNode(n)))
+    while (DTM.NULL != (n = dtm.getParent(n)))
     {
       m_ancestors.push(n);
     }
 
-    m_nextLevelAmount = m_ancestors.isEmpty() ? 0 : 1;
+    m_nextLevelAmount = m_ancestors.empty() ? 0 : 1;
     m_ancestorsPos = m_ancestors.size() - 1;
   }
 
@@ -112,6 +113,6 @@
    */
   protected int getLevelMax()
   {
-    return m_lpi.getDOMHelper().getLevel(m_root);
+    return getDTM(m_root).getLevel(m_root);
   }
 }
diff --git a/src/org/apache/xpath/axes/AncestorWalker.java b/src/org/apache/xpath/axes/AncestorWalker.java
index 089da18..5f112de 100644
--- a/src/org/apache/xpath/axes/AncestorWalker.java
+++ b/src/org/apache/xpath/axes/AncestorWalker.java
@@ -61,9 +61,10 @@
 import org.apache.xpath.axes.LocPathIterator;
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
-import org.apache.xpath.DOMHelper;
+import org.apache.xml.utils.IntStack;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 /**
  * Walker for the 'ancestor' axes.
@@ -103,19 +104,19 @@
    *
    * @param n
    */
-  protected void pushAncestors(Node n)
+  protected void pushAncestors(int n)
   {
 
-    m_ancestors = new Stack();
+    m_ancestors = new IntStack();
 
-    DOMHelper dh = m_lpi.getDOMHelper();
+    DTM dtm = getDTM(n);
 
-    while (null != (n = dh.getParentOfNode(n)))
+    while (DTM.NULL != (n = dtm.getParent(n)))
     {
       m_ancestors.push(n);
     }
 
-    m_nextLevelAmount = m_ancestors.isEmpty() ? 0 : 1;
+    m_nextLevelAmount = m_ancestors.empty() ? 0 : 1;
     m_ancestorsPos = m_ancestors.size() - 1;
   }
 
@@ -124,7 +125,7 @@
    *
    * @param root The context node of this step.
    */
-  public void setRoot(Node root)
+  public void setRoot(int root)
   {
     pushAncestors(root);
     super.setRoot(root);
@@ -138,10 +139,11 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   visible children in the TreeWalker's logical view.
    */
-  public Node firstChild()
+  public int firstChild()
   {
 
-    Node next = (m_ancestorsPos < 0) ? null : (Node) m_ancestors.elementAt(m_ancestorsPos--);
+    int next = (m_ancestorsPos < 0) ? DTM.NULL 
+                              : (int) m_ancestors.elementAt(m_ancestorsPos--);
 
     m_nextLevelAmount = (m_ancestorsPos < 0) ? 0 : 1;
 
@@ -151,7 +153,7 @@
   /** Stack of ancestors.  We have to do this instead of 
    *  just using getParent on the fly, because we have to walk the ancestors 
    *  in document order. */
-  transient protected Stack m_ancestors;
+  transient protected IntStack m_ancestors;
   
   /** The position within the stack.
    *  @serial */
@@ -165,9 +167,9 @@
   protected int getLevelMax()
   {
 
-    DOMHelper dh = m_lpi.getDOMHelper();
-    Node p = dh.getParentOfNode(m_root);
+    DTM dtm = getDTM(m_root);
+    int p = dtm.getParent(m_root);
 
-    return (null == p) ? 1 : dh.getLevel(p);
+    return (DTM.NULL == p) ? 1 : dtm.getLevel(p);
   }
 }
diff --git a/src/org/apache/xpath/axes/AttributeIterator.java b/src/org/apache/xpath/axes/AttributeIterator.java
index c4374e8..f569bac 100644
--- a/src/org/apache/xpath/axes/AttributeIterator.java
+++ b/src/org/apache/xpath/axes/AttributeIterator.java
@@ -63,11 +63,14 @@
 import org.apache.xpath.patterns.NodeTest;
 import org.apache.xpath.objects.XObject;
 
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.Node;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.traversal.NodeFilter;
+//import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.NamedNodeMap;
+//import org.w3c.dom.DOMException;
+//import org.w3c.dom.traversal.NodeFilter;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMFilter;
 
 /**
  * <meta name="usage" content="advanced"/>
@@ -75,7 +78,7 @@
  * attribute axes patterns.
  * @see org.apache.xpath.axes.WalkerFactory#newLocPathIterator
  */
-public class AttributeIterator extends LocPathIterator
+public class AttributeIterator extends ChildTestIterator
 {
 
   /**
@@ -90,205 +93,18 @@
   public AttributeIterator(Compiler compiler, int opPos, int analysis)
           throws javax.xml.transform.TransformerException
   {
-
-    super(compiler, opPos, analysis, false);
-
-    int firstStepPos = compiler.getFirstChildPos(opPos);
-    int whatToShow = compiler.getWhatToShow(firstStepPos);
-
-    if ((0 == (whatToShow
-               & (NodeFilter.SHOW_ATTRIBUTE | NodeFilter.SHOW_ELEMENT
-                  | NodeFilter.SHOW_PROCESSING_INSTRUCTION))) || (whatToShow == NodeFilter.SHOW_ALL))
-      initNodeTest(whatToShow);
-    else
-    {
-      initNodeTest(whatToShow, compiler.getStepNS(firstStepPos),
-                              compiler.getStepLocalName(firstStepPos));
-    }
-    initPredicateInfo(compiler, firstStepPos);
+    super(compiler, opPos, analysis);
   }
   
   /**
-   * Get a cloned LocPathIterator that holds the same 
-   * position as this iterator.
-   *
-   * @return A clone of this iterator that holds the same node position.
-   *
-   * @throws CloneNotSupportedException
+   * Get the next node via getFirstAttribute && getNextAttribute.
    */
-  public Object clone() throws CloneNotSupportedException
+  protected int getNextNode()
   {
-    LocPathIterator clone = (LocPathIterator) super.clone();
-    return clone;
+    m_lastFetched = (DTM.NULL == m_lastFetched)
+                     ? m_cdtm.getFirstAttribute(m_context)
+                     : m_cdtm.getNextAttribute(m_lastFetched);
+    return m_lastFetched;
   }
 
-  /**
-   *  Get a cloned Iterator that is reset to the beginning
-   *  of the query.
-   * 
-   *  @return A cloned NodeIterator set of the start of the query.
-   * 
-   *  @throws CloneNotSupportedException
-   */
-  public NodeIterator cloneWithReset() throws CloneNotSupportedException
-  {
-
-    AttributeIterator clone = (AttributeIterator) super.cloneWithReset();
-
-    clone.m_attrListPos = 0;
-    
-    clone.resetProximityPositions();
-
-    return clone;
-  }
-
-  /**
-   * Initialize the attribute list.
-   */
-  private void initAttrList()
-  {
-
-    if (m_context.getNodeType() == Node.ELEMENT_NODE)
-    {
-      m_attrListPos = 0;
-      m_attributeList = m_context.getAttributes();
-
-      if (null != m_attributeList)
-      {
-        m_nAttrs = m_attributeList.getLength();
-      }
-      else
-        m_nAttrs = 0;
-
-      if (0 == m_nAttrs)
-      {
-        m_foundLast = true;
-      }
-    }
-  }
-
-  /**
-   *  Returns the next node in the set and advances the position of the
-   * iterator in the set. After a NodeIterator is created, the first call
-   * to nextNode() returns the first node in the set.
-   *
-   * @return  The next <code>Node</code> in the set being iterated over, or
-   *   <code>null</code> if there are no more members in that set.
-   *
-   * @throws DOMException
-   *    INVALID_STATE_ERR: Raised if this method is called after the
-   *   <code>detach</code> method was invoked.
-   */
-  public Node nextNode() throws DOMException
-  {
-    // If the cache is on, and the node has already been found, then 
-    // just return from the list.
-    if ((null != m_cachedNodes)
-            && (m_cachedNodes.getCurrentPos() < m_cachedNodes.size()))
-    {
-      Node next = m_cachedNodes.nextNode();
-
-      this.setCurrentPos(m_cachedNodes.getCurrentPos());
-
-      return next;
-    }
-
-    if (m_foundLast)
-      return null;
-
-    if (null == m_attributeList)
-    {
-      initAttrList();
-      resetProximityPositions();
-    }
-
-    org.apache.xpath.VariableStack vars;
-    int savedStart;
-    if (-1 != m_varStackPos)
-    {
-      vars = m_execContext.getVarStack();
-
-      // These three statements need to be combined into one operation.
-      savedStart = vars.getSearchStart();
-
-      vars.setSearchStart(m_varStackPos);
-      vars.pushContextPosition(m_varStackContext);
-    }
-    else
-    {
-      // Yuck.  Just to shut up the compiler!
-      vars = null;
-      savedStart = 0;
-    }
-    
-    try
-    {
-      Node next;
-  
-      do
-      {
-        m_lastFetched = next =
-          (null == m_attributeList || m_attrListPos >= m_nAttrs)
-          ? null : m_attributeList.item(m_attrListPos++);
-  
-        if (null != next)
-        {
-          if(NodeFilter.FILTER_ACCEPT == acceptNode(next))
-            break;
-          else
-            continue;
-        }
-        else
-          break;
-      }
-      while (next != null);
-  
-      if (null != next)
-      {
-        if (null != m_cachedNodes)
-          m_cachedNodes.addElement(m_lastFetched);
-  
-        m_next++;
-  
-        return next;
-      }
-      else
-      {
-        m_foundLast = true;
-  
-        return null;
-      }
-    }
-    finally
-    {
-      if (-1 != m_varStackPos)
-      {
-        // These two statements need to be combined into one operation.
-        vars.setSearchStart(savedStart);
-        vars.popContextPosition();
-      }
-    }
-  }
-  
-  /**
-   * Get the index of the last node that can be itterated to.
-   *
-   * @param xctxt XPath runtime context.
-   *
-   * @return the index of the last node that can be itterated to.
-   */
-  public int getLastPos(XPathContext xctxt)
-  {
-    return m_nAttrs;
-  }
-
-
-  /** The attribute list for the given context. */
-  transient private NamedNodeMap m_attributeList;
-
-  /** The position within the attribute list. */
-  transient private int m_attrListPos = 0;
-
-  /** The number of attributes within the list. */
-  transient private int m_nAttrs = 0;
 }
diff --git a/src/org/apache/xpath/axes/AttributeWalker.java b/src/org/apache/xpath/axes/AttributeWalker.java
index 54e5b0b..a7cbb4d 100644
--- a/src/org/apache/xpath/axes/AttributeWalker.java
+++ b/src/org/apache/xpath/axes/AttributeWalker.java
@@ -60,8 +60,9 @@
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.NamedNodeMap;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.NamedNodeMap;
+import org.apache.xml.dtm.DTM;
 
 /**
  * Walker for the 'attribute' axes.
@@ -85,42 +86,40 @@
    *
    * @param root The context node of this step.
    */
-  public void setRoot(Node root)
+  public void setRoot(int root)
   {
 
-    m_attrListPos = -1;
-    m_attributeList = null;
-    m_nAttrs = -2;
-    m_nextLevelAmount = 1;
+    // System.out.println("ChildWalker.setRoot");
+    m_nextLevelAmount = (getDTM(root).getFirstAttribute(root) != DTM.NULL) ? 1 : 0;
 
+    // System.out.println("Back from calling hasChildNodes");
     super.setRoot(root);
+
+    // System.out.println("Exiting ChildWalker.setRoot");
   }
 
   /**
-   * Moves the <code>TreeWalker</code> to the first visible child of the
+   *  Moves the <code>TreeWalker</code> to the first visible child of the
    * current node, and returns the new node. If the current node has no
    * visible children, returns <code>null</code> , and retains the current
    * node.
    * @return  The new node, or <code>null</code> if the current node has no
    *   visible children in the TreeWalker's logical view.
    */
-  public Node firstChild()
+  public int firstChild()
   {
 
-    if (m_currentNode.getNodeType() == Node.ELEMENT_NODE)
-    {
-      m_attrListPos = -1;
-      m_attributeList = m_currentNode.getAttributes();
-
-      if (null != m_attributeList)
-        m_nAttrs = m_attributeList.getLength();
-      else
-        m_nAttrs = -2;
-    }
-
+    // System.out.println("ChildWalker.firstChild");
     m_nextLevelAmount = 0;
 
-    return nextSibling();
+    if (m_root == m_currentNode)
+    {
+
+      // System.out.println("ChildWalker - Calling getFirstChild");
+      return setCurrentIfNotNull(getDTM(m_root).getFirstAttribute(m_currentNode));
+    }
+    else
+      return DTM.NULL;
   }
 
   /**
@@ -130,34 +129,15 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   next sibling in the TreeWalker's logical view.
    */
-  public Node nextSibling()
+  public int nextSibling()
   {
 
-    // Attributes don't really have siblings, but we'll fake it.
-    if (null != m_attributeList)
-    {
-      m_attrListPos++;
-
-      if (m_attrListPos < m_nAttrs)
-      {
-        return setCurrentIfNotNull(m_attributeList.item(m_attrListPos));
-      }
-      else
-        m_attributeList = null;
-    }
-
-    return null;
+    if (m_root != m_currentNode)
+      return setCurrentIfNotNull(getDTM(m_root).getNextAttribute(m_currentNode));
+    else
+      return DTM.NULL;
   }
 
-  /** The attribute list for the given context.    */
-  transient NamedNodeMap m_attributeList;
-
-  /** The position within the attribute list.  */
-  transient int m_attrListPos;
-
-  /** The number of attributes within the list.  */
-  transient int m_nAttrs;
-
   /**
    * Tell what's the maximum level this axes can descend to.
    *
@@ -165,6 +145,6 @@
    */
   protected int getLevelMax()
   {
-    return m_lpi.getDOMHelper().getLevel(m_root);
+    return getDTM(m_root).getLevel(m_root);
   }
 }
diff --git a/src/org/apache/xpath/axes/AttributeWalkerOneStep.java b/src/org/apache/xpath/axes/AttributeWalkerOneStep.java
index 0f8514f..0839e03 100644
--- a/src/org/apache/xpath/axes/AttributeWalkerOneStep.java
+++ b/src/org/apache/xpath/axes/AttributeWalkerOneStep.java
@@ -56,9 +56,11 @@
  */
 package org.apache.xpath.axes;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.traversal.NodeFilter;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.NamedNodeMap;
+//import org.w3c.dom.traversal.NodeFilter;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import org.apache.xpath.patterns.NodeTestFilter;
 
@@ -70,37 +72,6 @@
 public class AttributeWalkerOneStep extends AxesWalker
 {
 
-  /** The attribute list from the context node.  */
-  transient NamedNodeMap m_attributeList;
-
-  /** The current index into m_attributeList.  -1 to start. */
-  transient int m_attrListPos;
-
-  /** The number of attributes in m_attributeList, or -2 if no attributes. */
-  transient int m_nAttrs;
-
-  /**
-   *  The root node of the TreeWalker.
-   *
-   * @param root The context node of the node step.
-   */
-  public void setRoot(Node root)
-  {
-
-    super.setRoot(root);
-
-    if (root.getNodeType() == Node.ELEMENT_NODE)
-    {
-      m_attrListPos = -1;
-      m_attributeList = m_currentNode.getAttributes();
-
-      if (null != m_attributeList)
-        m_nAttrs = m_attributeList.getLength();
-      else
-        m_nAttrs = -2;
-    }
-  }
-
   /**
    * Construct an AxesWalker using a LocPathIterator.
    *
@@ -112,45 +83,52 @@
   }
 
   /**
+   * Tell what's the maximum level this axes can descend to.
+   *
+   * @return An estimation of the maximum level this axes can descend to.
+   */
+  protected int getLevelMax()
+  {
+    return getDTM(m_root).getLevel(m_root);
+  }
+
+  /**
    * Get the next node in document order on the axes.
    *
-   * @return The next node in the itteration, or null.
+   * @return The next node in the walk, or null.
    */
-  public Node nextNode()
+  public int nextNode()
   {
 
-    if (m_isFresh)
-      m_isFresh = false;
+    int next;
 
-    Node current = this.getCurrentNode();
-
-    if (current.isSupported(FEATURE_NODETESTFILTER, "1.0"))
-      ((NodeTestFilter) current).setNodeTest(this);
-
-    Node next = null;
-
-    while (null != m_attributeList)
+    if (m_root == m_currentNode)
     {
-      m_attrListPos++;
+      next = getDTM(m_currentNode).getFirstAttribute(m_currentNode);
+      m_isFresh = false;
+    }
+    else
+      next = getDTM(m_currentNode).getNextAttribute(m_currentNode);
 
-      if (m_attrListPos < m_nAttrs)
+    if (DTM.NULL != next)
+    {
+      m_currentNode = next;
+
+      while (acceptNode(next) != DTMIterator.FILTER_ACCEPT)
       {
-        next = m_attributeList.item(m_attrListPos);
+        next = getDTM(next).getNextAttribute(next);
 
-        if (null != next)
+        if (DTM.NULL != next)
           m_currentNode = next;
+        else
+        {
+          this.m_isDone = true;
 
-        if (acceptNode(next) == NodeFilter.FILTER_ACCEPT)
           break;
-      }
-      else
-      {
-        next = null;
-        m_attributeList = null;
+        }
       }
     }
-
-    if (null == next)
+    else
       this.m_isDone = true;
 
     return next;
diff --git a/src/org/apache/xpath/axes/AxesWalker.java b/src/org/apache/xpath/axes/AxesWalker.java
index 59ee119..2de7da0 100644
--- a/src/org/apache/xpath/axes/AxesWalker.java
+++ b/src/org/apache/xpath/axes/AxesWalker.java
@@ -73,19 +73,18 @@
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.XPath;
 
-// DOM2 imports
-import org.w3c.dom.Node;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.traversal.TreeWalker;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.DOMException;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMFilter;
+
+import org.apache.xml.utils.XMLString;
 
 /**
  * Serves as common interface for axes Walkers, and stores common
  * state variables.
  */
 public abstract class AxesWalker extends PredicatedNodeTest
-        implements Cloneable, TreeWalker, NodeFilter
+        implements Cloneable , DTMFilter
 {
   
   /**
@@ -271,14 +270,15 @@
    * @return true if n is a parent of the step context, or the step context 
    *              itself.
    */
-  boolean isAncestorOfRootContext(Node n)
+  boolean isAncestorOfRootContext(int n)
   {
 
-    Node parent = m_root;
-
-    while (null != (parent = parent.getParentNode()))
+    int parent = m_root;
+    
+    DTM dtm = getDTM(parent);
+    while (DTM.NULL != (parent = dtm.getParent(parent)))
     {
-      if (parent.equals(n))
+      if (parent == n)
         return true;
     }
 
@@ -288,12 +288,12 @@
   //=============== TreeWalker Implementation ===============
 
   /**
-   * The root node of the TreeWalker, as specified in setRoot(Node root).
+   * The root node of the TreeWalker, as specified in setRoot(int root).
    * Note that this may actually be below the current node.
    *
    * @return The context node of the step.
    */
-  public Node getRoot()
+  public int getRoot()
   {
     return m_root;
   }
@@ -304,16 +304,17 @@
    *
    * @param root The context node of this step.
    */
-  public void setRoot(Node root)
+  public void setRoot(int root)
   {
-
+    // %OPT% Get this directly from the lpi.
+    m_dtm = m_lpi.getXPathContext().getDTM(root);
     m_isFresh = true;
     m_isDone = false;
     m_root = root;
     m_currentNode = root;
-    m_prevReturned = null;
+    m_prevReturned = DTM.NULL;
 
-    if (null == root)
+    if (DTM.NULL == root)
     {
       throw new RuntimeException(
         "\n !!!! Error! Setting the root of a walker to null!!!");
@@ -335,11 +336,8 @@
    *
    * @return The node at which the TreeWalker is currently positioned, only null 
    * if setRoot has not yet been called.
-   * @throws DOMException
-   *    NOT_SUPPORTED_ERR: Raised if the specified <code>currentNode</code>
-   *   is<code>null</code> .
    */
-  public final Node getCurrentNode()
+  public final int getCurrentNode()
   {
     return m_currentNode;
   }
@@ -348,10 +346,8 @@
    * Set the current node.
    *
    * @param currentNode The current itteration node, should not be null.
-   *
-   * @throws DOMException
    */
-  public void setCurrentNode(Node currentNode) throws DOMException
+  public void setCurrentNode(int currentNode)
   {
     m_currentNode = currentNode;
   }
@@ -361,13 +357,11 @@
    *
    * @param currentNode The current node or null.
    * @return The node passed in.
-   *
-   * @throws DOMException
    */
-  protected Node setCurrentIfNotNull(Node currentNode) throws DOMException
+  protected int setCurrentIfNotNull(int currentNode)
   {
 
-    if (null != currentNode)
+    if (DTM.NULL != currentNode)
       m_currentNode = currentNode;
 
     return currentNode;
@@ -378,7 +372,7 @@
    *
    * @return This AxesWalker.
    */
-  public NodeFilter getFilter()
+  public DTMFilter getFilter()
   {
     return this;
   }
@@ -410,9 +404,9 @@
    * @return  The new parent node, or null if the current node has no parent
    *   in the TreeWalker's logical view.
    */
-  public Node parentNode()
+  public int parentNode()
   {
-    return null;
+    return DTM.NULL;
   }
 
   /**
@@ -423,9 +417,9 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   visible children in the TreeWalker's logical view.
    */
-  public Node firstChild()
+  public int firstChild()
   {
-    return null;
+    return DTM.NULL;
   }
 
   /**
@@ -435,9 +429,9 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   next sibling in the TreeWalker's logical view.
    */
-  public Node nextSibling()
+  public int nextSibling()
   {
-    return null;
+    return DTM.NULL;
   }
 
   /**
@@ -448,7 +442,7 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   children  in the TreeWalker's logical view.
    */
-  public Node lastChild()
+  public int lastChild()
   {
 
     // We may need to support this...
@@ -463,7 +457,7 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   previous sibling in the TreeWalker's logical view.
    */
-  public Node previousSibling()
+  public int previousSibling()
   {
     throw new RuntimeException("previousSibling not supported!");
   }
@@ -477,7 +471,7 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   previous node in the TreeWalker's logical view.
    */
-  public Node previousNode()
+  public int previousNode()
   {
     throw new RuntimeException("previousNode not supported!");
   }
@@ -549,24 +543,15 @@
     String rootName;
     String currentNodeName;
 
-    try
-    {
-      rootName = (null == m_root)
-                 ? "null"
-                 : m_root.getNodeName() + "{"
-                   + ((org.apache.xalan.stree.Child) m_root).getUid() + "}";
-      currentNodeName =
-        (null == m_root)
-        ? "null"
-        : m_currentNode.getNodeName() + "{"
-          + ((org.apache.xalan.stree.Child) m_currentNode).getUid() + "}";
-    }
-    catch (ClassCastException cce)
-    {
-      rootName = (null == m_root) ? "null" : m_root.getNodeName();
-      currentNodeName = (null == m_root)
-                        ? "null" : m_currentNode.getNodeName();
-    }
+    rootName = (DTM.NULL == m_root)
+               ? "null"
+               : getDTM(m_root).getNodeName(m_root) + "{"
+                 + (m_root+1) + "}";
+    currentNodeName =
+      (DTM.NULL == m_currentNode)
+      ? "null"
+      : getDTM(m_currentNode).getNodeName(m_currentNode) + "{"
+        + (m_currentNode+1) + "}";
 
     return clName + "[" + rootName + "][" + currentNodeName + "]";
   }
@@ -579,10 +564,10 @@
    *
    * @return The argument.
    */
-  private Node returnNextNode(Node n)
+  private int returnNextNode(int n)
   {
 
-    if (DEBUG_LOCATED && (null != n))
+    if (DEBUG_LOCATED && (DTM.NULL != n))
     {
       printDebug("RETURN --->" + nodeToString(n));
     }
@@ -606,13 +591,11 @@
     {
       System.out.print("\n");
 
-      if (null != m_currentNode)
+      if (DTM.NULL != m_currentNode)
       {
         try
         {
-          org.apache.xalan.stree.Child n =
-            ((org.apache.xalan.stree.Child) m_currentNode);
-          int depth = n.getLevel();
+          int depth = getDTM(m_currentNode).getLevel(m_currentNode);
 
           for (int i = 0; i < depth; i++)
           {
@@ -632,7 +615,7 @@
    * @param node The top of the subtree.
    * @param indent The amount to begin the indenting at.
    */
-  private void dumpAll(Node node, int indent)
+  private void dumpAll(int node, int indent)
   {
 
     for (int i = 0; i < indent; i++)
@@ -642,9 +625,9 @@
 
     System.out.print(nodeToString(node));
 
-    if (Node.TEXT_NODE == node.getNodeType())
+    if (DTM.TEXT_NODE == getDTM(node).getNodeType(node))
     {
-      String value = node.getNodeValue();
+      XMLString value = getDTM(node).getStringValue(node);
 
       if (null != value)
       {
@@ -654,40 +637,32 @@
 
     System.out.println("");
 
-    NamedNodeMap map = node.getAttributes();
-
-    if (null != map)
+    DTM dtm = getDTM(node);
+    for (int attr = dtm.getFirstAttribute(node); attr != DTM.NULL; 
+         attr = dtm.getNextAttribute(attr))
     {
-      int n = map.getLength();
-
-      for (int i = 0; i < n; i++)
+      for (int k = 0; k < indent; k++)
       {
-        for (int k = 0; k < indent; k++)
-        {
-          System.out.print(" ");
-        }
-
-        System.out.print("attr -->");
-        System.out.print(nodeToString(map.item(i)));
-
-        String value = map.item(i).getNodeValue();
-
-        if (null != value)
-        {
-          System.out.print("+= -->" + value.trim());
-        }
-
-        System.out.println("");
+        System.out.print(" ");
       }
+
+      System.out.print("attr -->");
+      System.out.print(nodeToString(attr));
+
+      XMLString value = dtm.getStringValue(attr);
+
+      if (null != value)
+      {
+        System.out.print("+= -->" + value.trim());
+      }
+
+      System.out.println("");
     }
 
-    Node child = node.getFirstChild();
-
-    while (null != child)
+    for (int child = dtm.getFirstChild(node); DTM.NULL != child; 
+         child = dtm.getNextSibling(child))
     {
       dumpAll(child, indent + 1);
-
-      child = child.getNextSibling();
     }
   }
 
@@ -715,13 +690,11 @@
     {
       System.out.print("\n============================\n");
 
-      if (null != m_currentNode)
+      if (DTM.NULL != m_currentNode)
       {
         try
         {
-          org.apache.xalan.stree.Child n =
-            ((org.apache.xalan.stree.Child) m_currentNode);
-          int depth = n.getLevel();
+          int depth = getDTM(m_currentNode).getLevel(m_currentNode);
 
           for (int i = 0; i < depth; i++)
           {
@@ -793,15 +766,14 @@
    */
   protected boolean checkOKToTraverse(AxesWalker prevStepWalker,
                                       AxesWalker testWalker,
-                                      Node currentTestNode,
+                                      int currentTestNode,
                                       int nextLevelAmount)
   {
 
-    DOMHelper dh = m_lpi.getDOMHelper();
-    int level = dh.getLevel(currentTestNode);
+    int level = getDTM(currentTestNode).getLevel(currentTestNode);
 
     // Is this always the context node of the test walker?
-    Node prevNode = prevStepWalker.m_currentNode;
+    int prevNode = prevStepWalker.m_currentNode;
 
     // Can the previous walker go past the one being tested?
     if (DEBUG_WAITING)
@@ -815,14 +787,14 @@
 
       // Is (prevStepWalker.m_currentNode > the currentTestNode)?
       // (Sorry about the reverse logic).
-      boolean isNodeAfter = !dh.isNodeAfter(prevNode, currentTestNode);
+      boolean isNodeAfter = !getDTM(prevNode).isNodeAfter(prevNode, currentTestNode);
 
       if (DEBUG_WAITING)
         printDebug("[isNodeAfter:" + isNodeAfter + "?]");
 
       if (isNodeAfter)
       {
-        int prevStepLevel = dh.getLevel(prevNode);
+        int prevStepLevel = getDTM(prevNode).getLevel(prevNode);
 
         // If the previous step walker is below us in the tree, 
         // then we have to wait until it pops back up to our level, 
@@ -865,7 +837,7 @@
   {
 
     // printDebug("checkWaiting: "+walker.toString()+", "+nodeToString(walker.m_currentNode));
-    if ((null != walker) && (null == walker.m_currentNode))
+    if ((null != walker) && (DTM.NULL == walker.m_currentNode))
       return walker;
 
     int nWaiting = m_lpi.getWaitingCount();
@@ -934,7 +906,7 @@
         first = ws;
       else
       {
-        if (!dh.isNodeAfter(ws.m_currentNode, first.m_currentNode))
+        if (!getDTM(ws.m_currentNode).isNodeAfter(ws.m_currentNode, first.m_currentNode))
           first = ws;
       }
     }
@@ -1040,35 +1012,37 @@
    *
    * @return the next node in document order on the axes, or null.
    */
-  protected Node getNextNode()
+  protected int getNextNode()
   {
 
     if (m_isFresh)
       m_isFresh = false;
 
-    Node current = this.getCurrentNode();
+    int current = this.getCurrentNode();
 
-    if (current.isSupported(FEATURE_NODETESTFILTER, "1.0"))
-      ((NodeTestFilter) current).setNodeTest(this);
+    // %NODETESTFILTER%
+//    if (current.isSupported(FEATURE_NODETESTFILTER, "1.0"))
+//      ((NodeTestFilter) current).setNodeTest(this);
 
-    Node next = this.firstChild();
+    int next = this.firstChild();
 
-    while (null == next)
+    while (DTM.NULL == next)
     {
       next = this.nextSibling();
 
-      if (null == next)
+      if (DTM.NULL == next)
       {
-        Node p = this.parentNode();
+        int p = this.parentNode();
 
-        if (null == p)
+        if (DTM.NULL == p)
           break;
       }
     }
 
-    if (null == next)
+    if (DTM.NULL == next)
       this.m_isDone = true;
 
+    // System.out.println("Returning: "+this);
     return next;
   }
 
@@ -1081,7 +1055,7 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   next node  in the TreeWalker's logical view.
    */
-  public Node nextNode()
+  public int nextNode()
   {
 
     if (DEBUG_TRAVERSAL &&!m_didDumpAll)
@@ -1092,7 +1066,7 @@
       // dumpAll(doc, 0);
     }
 
-    Node nextNode = null;
+    int nextNode = DTM.NULL;
     AxesWalker walker = m_lpi.getLastUsedWalker();
 
     // DOMHelper dh = m_lpi.getDOMHelper();
@@ -1140,7 +1114,7 @@
           walker.printDebug(walker.toString() + "--NEXT->"
                             + nodeToString(nextNode) + ")");
 
-        if (null == nextNode)
+        if (DTM.NULL == nextNode)
         {
 
           // AxesWalker prev = walker; ?? -sb
@@ -1162,7 +1136,7 @@
         }
         else
         {
-          if (walker.acceptNode(nextNode) != NodeFilter.FILTER_ACCEPT)
+          if (walker.acceptNode(nextNode) != DTMIterator.FILTER_ACCEPT)
           {
             if (DEBUG_TRAVERSAL)
               printDebugAdd("[FILTER_SKIP]");
@@ -1182,7 +1156,7 @@
             if (DEBUG_TRAVERSAL)
               printDebug("May be returning: " + nodeToString(nextNode));
 
-            if (DEBUG_TRAVERSAL && (null != m_prevReturned))
+            if (DEBUG_TRAVERSAL && (DTM.NULL != m_prevReturned))
               printDebugAdd(", m_prevReturned: "
                             + nodeToString(m_prevReturned));
 
@@ -1237,9 +1211,9 @@
     // the next node in the nodeset because it's coming from a 
     // different document. 
     while (
-      (null != nextNode) && (null != m_prevReturned)
-      && nextNode.getOwnerDocument() == m_prevReturned.getOwnerDocument()
-      && m_lpi.getDOMHelper().isNodeAfter(nextNode, m_prevReturned));
+      (DTM.NULL != nextNode) && (DTM.NULL != m_prevReturned)
+      && getDTM(nextNode).getDocument() == getDTM(m_prevReturned).getDocument()
+      && getDTM(nextNode).isNodeAfter(nextNode, m_prevReturned));
 
     m_prevReturned = nextNode;
 
@@ -1263,6 +1237,7 @@
   {
 
     int pos = getProximityPosition();
+    
     AxesWalker walker;
 
     try
@@ -1285,9 +1260,9 @@
     {
       lpi.setLastUsedWalker(walker);
 
-      Node next;
+      int next;
 
-      while (null != (next = walker.nextNode()))
+      while (DTM.NULL != (next = walker.nextNode()))
       {
         pos++;
       }
@@ -1312,6 +1287,41 @@
   {
     return false;
   }
+  
+  /**
+   * Test whether a specified node is visible in the logical view of a
+   * <code>DTMIterator</code>. Normally, this function
+   * will be called by the implementation of <code>DTMIterator</code>;
+   * it is not normally called directly from
+   * user code.
+   *
+   * @param nodeHandle int Handle of the node.
+   * @param whatToShow one of SHOW_XXX values.
+   * @return one of FILTER_ACCEPT, FILTER_REJECT, or FILTER_SKIP.
+   */
+  public short acceptNode(int nodeHandle, int whatToShow)
+  {
+    return DTMIterator.FILTER_ACCEPT;  // %TBD%
+  }
+
+  /**
+   * Test whether a specified node is visible in the logical view of a
+   * <code>DTMIterator</code>. Normally, this function
+   * will be called by the implementation of <code>DTMIterator</code>;
+   * it is not normally called directly from
+   * user code.
+   *
+   * @param nodeHandle int Handle of the node.
+   * @param whatToShow one of SHOW_XXX values.
+   * @param expandedName a value defining the exanded name as defined in
+   *                     the DTM interface.  Wild cards will be defined
+   *                     by 0xFFFF in the high word and/or in the low word.
+   * @return one of FILTER_ACCEPT, FILTER_REJECT, or FILTER_SKIP.
+   */
+  public short acceptNode(int nodeHandle, int whatToShow, int expandedName)
+  {
+    return DTMIterator.FILTER_ACCEPT;  // %TBD%
+  }
 
   //============= Static Data =============
 
@@ -1345,19 +1355,48 @@
   public static final String FEATURE_NODETESTFILTER = "NodeTestFilter";
   
   //============= State Data =============
+  
+  /**
+   * The DTM for the root.  This can not be used, or must be changed, 
+   * for the filter walker, or any walker that can have nodes 
+   * from multiple documents.
+   * Never, ever, access this value without going through getDTM(int node).
+   */
+  private DTM m_dtm;
+  
+  /**
+   * Set the DTM for this walker.
+   * 
+   * @param dtm Non-null reference to a DTM.
+   */
+  public void setDefaultDTM(DTM dtm)
+  {
+    m_dtm = dtm;
+  }
+  
+  /**
+   * Get the DTM for this walker.
+   * 
+   * @return Non-null reference to a DTM.
+   */
+  public DTM getDTM(int node)
+  {
+    //
+    return m_lpi.getXPathContext().getDTM(node);
+  }
 
   /**
    *  The root node of the TreeWalker, as specified when it was created.
    */
-  transient Node m_root;
+  transient int m_root = DTM.NULL;
 
   /**
    *  The node at which the TreeWalker is currently positioned.
    */
-  transient Node m_currentNode;
+  transient int m_currentNode = DTM.NULL;
   
   /** The node last returned from nextNode(). */
-  transient Node m_prevReturned;
+  transient int m_prevReturned = DTM.NULL;
 
   /**
    * The arg length of the XPath step. Does not change after the constructor.
diff --git a/src/org/apache/xpath/axes/ChildIterator.java b/src/org/apache/xpath/axes/ChildIterator.java
index 623ac66..fd149b8 100644
--- a/src/org/apache/xpath/axes/ChildIterator.java
+++ b/src/org/apache/xpath/axes/ChildIterator.java
@@ -63,8 +63,9 @@
 import org.apache.xpath.WhitespaceStrippingElementMatcher;
 import org.apache.xml.utils.PrefixResolver;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.DOMException;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.DOMException;
+import org.apache.xml.dtm.DTM;
 
 /**
  * <meta name="usage" content="advanced"/>
@@ -99,88 +100,37 @@
    *
    * @return  The next <code>Node</code> in the set being iterated over, or
    *   <code>null</code> if there are no more members in that set.
-   *
-   * @throws DOMException
-   *    INVALID_STATE_ERR: Raised if this method is called after the
-   *   <code>detach</code> method was invoked.
    */
-  public Node nextNode() throws DOMException
+  public int nextNode()
   {
 
     // If the cache is on, and the node has already been found, then 
     // just return from the list.
+    // If the cache is on, and the node has already been found, then 
+    // just return from the list.
     if ((null != m_cachedNodes)
-            && (m_cachedNodes.getCurrentPos() < m_cachedNodes.size()))
+            && (m_next < m_cachedNodes.size()))
     {
-      Node next = m_cachedNodes.nextNode();
-
-      this.setCurrentPos(m_cachedNodes.getCurrentPos());
+      int next = m_cachedNodes.elementAt(m_next);
+    
+      incrementNextPosition();
+      m_currentContextNode = next;
 
       return next;
     }
 
     if (m_foundLast)
-      return null;
+      return DTM.NULL;
 
-    Node next;
+    int next;
+    DTM dtm = m_cdtm;
 
-    while (true)
-    {
-      m_lastFetched = next = (null == m_lastFetched)
-                             ? m_context.getFirstChild()
-                             : m_lastFetched.getNextSibling();
-
-      // Yuck!  Blech!  -sb
-      if (null != next)
-      {
-        int nt = next.getNodeType();
-        if(Node.DOCUMENT_TYPE_NODE == nt) // bug fix, position14, d2d, xerces DOM
-          continue;
-        else if ((Node.TEXT_NODE == nt)
-                &&!next.isSupported(SUPPORTS_PRE_STRIPPING, null))
-        {
-          Node parent = next.getParentNode();
-
-          if (null != parent && Node.ELEMENT_NODE == parent.getNodeType())
-          {
-            String data = next.getNodeValue();
-
-            if (org.apache.xml.utils.XMLCharacterRecognizer.isWhiteSpace(
-                    data))
-            {
-
-              // Ugly trick for now.
-              PrefixResolver resolver =
-                getXPathContext().getNamespaceContext();
-
-              if (resolver instanceof WhitespaceStrippingElementMatcher)
-              {
-                WhitespaceStrippingElementMatcher wsem =
-                  (WhitespaceStrippingElementMatcher) resolver;
-
-                try
-                {
-                  if (wsem.shouldStripWhiteSpace(
-                          getXPathContext(), (org.w3c.dom.Element) parent))
-                  {
-                    continue;
-                  }
-                }
-                catch (javax.xml.transform.TransformerException te)
-                {
-                  throw new org.apache.xml.utils.WrappedRuntimeException(te);
-                }
-              }
-            }
-          }
-        }
-      }
-
-      break;
-    }
+    m_lastFetched = next = (DTM.NULL == m_lastFetched)
+                           ? dtm.getFirstChild(m_context)
+                           : dtm.getNextSibling(m_lastFetched);
 
     // m_lastFetched = next;
-    if (null != next)
+    if (DTM.NULL != next)
     {
       if (null != m_cachedNodes)
         m_cachedNodes.addElement(m_lastFetched);
@@ -193,7 +143,7 @@
     {
       m_foundLast = true;
 
-      return null;
+      return DTM.NULL;
     }
   }
 }
diff --git a/src/org/apache/xpath/axes/ChildTestIterator.java b/src/org/apache/xpath/axes/ChildTestIterator.java
index 6b22440..abe3506 100644
--- a/src/org/apache/xpath/axes/ChildTestIterator.java
+++ b/src/org/apache/xpath/axes/ChildTestIterator.java
@@ -62,10 +62,13 @@
 import org.apache.xpath.patterns.NodeTest;
 import org.apache.xpath.objects.XObject;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.DOMException;
+//import org.w3c.dom.traversal.NodeFilter;
+//import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMFilter;
 
 /**
  * <meta name="usage" content="advanced"/>
@@ -95,8 +98,9 @@
     int whatToShow = compiler.getWhatToShow(firstStepPos);
 
     if ((0 == (whatToShow
-               & (NodeFilter.SHOW_ATTRIBUTE | NodeFilter.SHOW_ELEMENT
-                  | NodeFilter.SHOW_PROCESSING_INSTRUCTION))) || (whatToShow == NodeFilter.SHOW_ALL))
+               & (DTMFilter.SHOW_ATTRIBUTE | DTMFilter.SHOW_ELEMENT
+                  | DTMFilter.SHOW_PROCESSING_INSTRUCTION))) 
+                  || (whatToShow == DTMFilter.SHOW_ALL))
       initNodeTest(whatToShow);
     else
     {
@@ -114,7 +118,7 @@
    * 
    *  @throws CloneNotSupportedException
    */
-  public NodeIterator cloneWithReset() throws CloneNotSupportedException
+  public DTMIterator cloneWithReset() throws CloneNotSupportedException
   {
 
     ChildTestIterator clone = (ChildTestIterator) super.cloneWithReset();
@@ -123,6 +127,18 @@
 
     return clone;
   }
+  
+  /**
+   * Get the next node via getNextXXX.  Bottlenecked for derived class override.
+   * @return The next node on the axis, or DTM.NULL.
+   */
+  protected int getNextNode()
+  {
+    m_lastFetched = (DTM.NULL == m_lastFetched)
+                     ? m_cdtm.getFirstChild(m_context)
+                     : m_cdtm.getNextSibling(m_lastFetched);
+    return m_lastFetched;
+  }
 
   /**
    *  Returns the next node in the set and advances the position of the
@@ -131,35 +147,34 @@
    *
    * @return  The next <code>Node</code> in the set being iterated over, or
    *   <code>null</code> if there are no more members in that set.
-   *
-   * @throws DOMException
-   *    INVALID_STATE_ERR: Raised if this method is called after the
-   *   <code>detach</code> method was invoked.
    */
-  public Node nextNode() throws DOMException
+  public int nextNode()
   {
 
     // If the cache is on, and the node has already been found, then 
     // just return from the list.
+    // If the cache is on, and the node has already been found, then 
+    // just return from the list.
     if ((null != m_cachedNodes)
-            && (m_cachedNodes.getCurrentPos() < m_cachedNodes.size()))
+            && (m_next < m_cachedNodes.size()))
     {
-      Node next = m_cachedNodes.nextNode();
-
-      this.setCurrentPos(m_cachedNodes.getCurrentPos());
+      int next = m_cachedNodes.elementAt(m_next);
+    
+      incrementNextPosition();
+      m_currentContextNode = next;
 
       return next;
     }
 
     if (m_foundLast)
-      return null;
+      return DTM.NULL;
       
-    if(null == m_lastFetched)
+    if(DTM.NULL == m_lastFetched)
     {
       resetProximityPositions();
     }
 
-    Node next;
+    int next;
     
     org.apache.xpath.VariableStack vars;
     int savedStart;
@@ -184,13 +199,11 @@
     {
       do
       {
-        m_lastFetched = next = (null == m_lastFetched)
-                               ? m_context.getFirstChild()
-                               : m_lastFetched.getNextSibling();
+        next = getNextNode();
   
-        if (null != next)
+        if (DTM.NULL != next)
         {
-          if(NodeFilter.FILTER_ACCEPT == acceptNode(next))
+          if(DTMIterator.FILTER_ACCEPT == acceptNode(next))
             break;
           else
             continue;
@@ -198,9 +211,9 @@
         else
           break;
       }
-      while (next != null);
+      while (next != DTM.NULL);
   
-      if (null != next)
+      if (DTM.NULL != next)
       {
         if (null != m_cachedNodes)
           m_cachedNodes.addElement(m_lastFetched);
@@ -213,7 +226,7 @@
       {
         m_foundLast = true;
   
-        return null;
+        return DTM.NULL;
       }
     }
     finally
diff --git a/src/org/apache/xpath/axes/ChildWalker.java b/src/org/apache/xpath/axes/ChildWalker.java
index 6932157..c831581 100644
--- a/src/org/apache/xpath/axes/ChildWalker.java
+++ b/src/org/apache/xpath/axes/ChildWalker.java
@@ -60,7 +60,8 @@
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 /**
  * Walker for the 'child' axes.
@@ -84,11 +85,11 @@
    *
    * @param root The context node of this step.
    */
-  public void setRoot(Node root)
+  public void setRoot(int root)
   {
 
     // System.out.println("ChildWalker.setRoot");
-    m_nextLevelAmount = root.hasChildNodes() ? 1 : 0;
+    m_nextLevelAmount = getDTM(root).hasChildNodes(root) ? 1 : 0;
 
     // System.out.println("Back from calling hasChildNodes");
     super.setRoot(root);
@@ -104,7 +105,7 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   visible children in the TreeWalker's logical view.
    */
-  public Node firstChild()
+  public int firstChild()
   {
 
     // System.out.println("ChildWalker.firstChild");
@@ -112,12 +113,11 @@
 
     if (m_root == m_currentNode)
     {
-
       // System.out.println("ChildWalker - Calling getFirstChild");
-      return setCurrentIfNotNull(this.m_root.getFirstChild());
+      return setCurrentIfNotNull(getDTM(m_root).getFirstChild(m_root));
     }
     else
-      return null;
+      return DTM.NULL;
   }
 
   /**
@@ -127,13 +127,12 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   next sibling in the TreeWalker's logical view.
    */
-  public Node nextSibling()
+  public int nextSibling()
   {
-
     if (m_root != m_currentNode)
-      return setCurrentIfNotNull(m_currentNode.getNextSibling());
+      return setCurrentIfNotNull(getDTM(m_currentNode).getNextSibling(m_currentNode));
     else
-      return null;
+      return DTM.NULL;
   }
 
   /**
@@ -143,6 +142,6 @@
    */
   protected int getLevelMax()
   {
-    return m_lpi.getDOMHelper().getLevel(m_root);
+    return getDTM(m_root).getLevel(m_root);
   }
 }
diff --git a/src/org/apache/xpath/axes/ChildWalkerMultiStep.java b/src/org/apache/xpath/axes/ChildWalkerMultiStep.java
index 7ee8a4e..af627e5 100644
--- a/src/org/apache/xpath/axes/ChildWalkerMultiStep.java
+++ b/src/org/apache/xpath/axes/ChildWalkerMultiStep.java
@@ -56,8 +56,11 @@
  */
 package org.apache.xpath.axes;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeFilter;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeFilter;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMFilter;
+import org.apache.xml.dtm.DTMIterator;
 
 import org.apache.xpath.patterns.NodeTestFilter;
 
@@ -85,39 +88,41 @@
    *
    * @return the next valid child node.
    */
-  protected Node getNextNode()
+  protected int getNextNode()
   {
     if (m_isFresh)
       m_isFresh = false;
 
-    Node current = this.getCurrentNode();
+    int current = this.getCurrentNode();
     
-    if (current.isSupported(FEATURE_NODETESTFILTER, "1.0"))
-      ((NodeTestFilter) current).setNodeTest(this);
+    // %NODETESTFILTER%
+//    if (current.isSupported(FEATURE_NODETESTFILTER, "1.0"))
+//      ((NodeTestFilter) current).setNodeTest(this);
+    DTM dtm = getDTM(m_root);
 
-    Node next = (m_root == m_currentNode)
-                ? m_currentNode.getFirstChild()
-                : m_currentNode.getNextSibling();
+    int next = (m_root == m_currentNode)
+                ? dtm.getFirstChild(m_currentNode)
+                : dtm.getNextSibling(m_currentNode);
 
-    if (null != next)
+    if (DTM.NULL != next)
     {
       m_currentNode = next;
 
-      while (acceptNode(next) != NodeFilter.FILTER_ACCEPT)
+      while (acceptNode(next) != DTMIterator.FILTER_ACCEPT)
       {
-        next = next.getNextSibling();
+        next = dtm.getNextSibling(next);
 
-        if (null == next)
+        if (DTM.NULL == next)
           break;
         else
           m_currentNode = next;
       }
       
-      if(null == next)
+      if(DTM.NULL == next)
         m_currentNode = current; // don't advance the current node.
     }          
 
-    if (null == next)
+    if (DTM.NULL == next)
       this.m_isDone = true;
 
     return next;
@@ -133,7 +138,7 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   next node  in the TreeWalker's logical view.
    */
-  public Node nextNode()
+  public int nextNode()
   {
 
     AxesWalker walker = m_lpi.getLastUsedWalker();
@@ -141,7 +146,7 @@
 
     while (null != walker)
     {
-      Node next;
+      int next;
       if(fast)
       {
         next = walker.getNextNode();
@@ -150,11 +155,11 @@
       {
         next = walker.nextNode();
         // In this case, nextNode finished the walk, so we just return.
-        if(null != next)
+        if(DTM.NULL != next)
           return next;
       }
 
-      if (null != next)
+      if (DTM.NULL != next)
       {
         if (null != walker.m_nextWalker)
         {
@@ -177,7 +182,7 @@
       }
     }
 
-    return null;
+    return DTM.NULL;
   }
   
   /**
diff --git a/src/org/apache/xpath/axes/ChildWalkerOneStep.java b/src/org/apache/xpath/axes/ChildWalkerOneStep.java
index 59c0207..9297ea4 100644
--- a/src/org/apache/xpath/axes/ChildWalkerOneStep.java
+++ b/src/org/apache/xpath/axes/ChildWalkerOneStep.java
@@ -56,8 +56,11 @@
  */
 package org.apache.xpath.axes;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeFilter;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeFilter;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMFilter;
+import org.apache.xml.dtm.DTMIterator;
 
 import org.apache.xpath.patterns.NodeTestFilter;
 
@@ -85,7 +88,7 @@
    */
   protected int getLevelMax()
   {
-    return m_lpi.getDOMHelper().getLevel(m_root);
+    return getDTM(m_root).getLevel(m_root);
   }
 
   /**
@@ -93,28 +96,28 @@
    *
    * @return The next node in the walk, or null.
    */
-  public Node nextNode()
+  public int nextNode()
   {
 
-    Node next;
+    int next;
 
     if (m_root == m_currentNode)
     {
-      next = m_currentNode.getFirstChild();
+      next = getDTM(m_currentNode).getFirstChild(m_currentNode);
       m_isFresh = false;
     }
     else
-      next = m_currentNode.getNextSibling();
+      next = getDTM(m_currentNode).getNextSibling(m_currentNode);
 
-    if (null != next)
+    if (DTM.NULL != next)
     {
       m_currentNode = next;
 
-      while (acceptNode(next) != NodeFilter.FILTER_ACCEPT)
+      while (acceptNode(next) != DTMIterator.FILTER_ACCEPT)
       {
-        next = next.getNextSibling();
+        next = getDTM(next).getNextSibling(next);
 
-        if (null != next)
+        if (DTM.NULL != next)
           m_currentNode = next;
         else
         {
diff --git a/src/org/apache/xpath/axes/DescendantIterator.java b/src/org/apache/xpath/axes/DescendantIterator.java
index 72caa82..2b1ca79 100644
--- a/src/org/apache/xpath/axes/DescendantIterator.java
+++ b/src/org/apache/xpath/axes/DescendantIterator.java
@@ -63,11 +63,14 @@
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.compiler.OpCodes;
 
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.Node;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.traversal.NodeFilter;
+//import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.NamedNodeMap;
+//import org.w3c.dom.DOMException;
+//import org.w3c.dom.traversal.NodeFilter;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMFilter;
 
 /**
  * <meta name="usage" content="advanced"/>
@@ -116,8 +119,9 @@
     int whatToShow = compiler.getWhatToShow(firstStepPos);
 
     if ((0 == (whatToShow
-               & (NodeFilter.SHOW_ATTRIBUTE | NodeFilter.SHOW_ELEMENT
-                  | NodeFilter.SHOW_PROCESSING_INSTRUCTION))) || (whatToShow == NodeFilter.SHOW_ALL))
+               & (DTMFilter.SHOW_ATTRIBUTE | DTMFilter.SHOW_ELEMENT
+                  | DTMFilter.SHOW_PROCESSING_INSTRUCTION))) || 
+                   (whatToShow == DTMFilter.SHOW_ALL))
       initNodeTest(whatToShow);
     else
     {
@@ -128,6 +132,25 @@
   }
   
   /**
+   * Create a DescendantIterator object.
+   *
+   * @param compiler A reference to the Compiler that contains the op map.
+   * @param opPos The position within the op map, which contains the
+   * location path expression for this itterator.
+   *
+   * @throws javax.xml.transform.TransformerException
+   */
+  public DescendantIterator()
+  {
+    super(null);
+    m_orSelf = true;
+    m_fromRoot = true;
+    int whatToShow = DTMFilter.SHOW_ALL;
+    initNodeTest(whatToShow);
+  }
+
+  
+  /**
    *  Get a cloned Iterator that is reset to the beginning
    *  of the query.
    * 
@@ -135,7 +158,7 @@
    * 
    *  @throws CloneNotSupportedException
    */
-  public NodeIterator cloneWithReset() throws CloneNotSupportedException
+  public DTMIterator cloneWithReset() throws CloneNotSupportedException
   {
 
     DescendantIterator clone = (DescendantIterator) super.cloneWithReset();
@@ -157,31 +180,34 @@
    *    INVALID_STATE_ERR: Raised if this method is called after the
    *   <code>detach</code> method was invoked.
    */
-  public Node nextNode() throws DOMException
+  public int nextNode()
   {
 
     // If the cache is on, and the node has already been found, then 
     // just return from the list.
+    // If the cache is on, and the node has already been found, then 
+    // just return from the list.
     if ((null != m_cachedNodes)
-            && (m_cachedNodes.getCurrentPos() < m_cachedNodes.size()))
+            && (m_next < m_cachedNodes.size()))
     {
-      Node next = m_cachedNodes.nextNode();
-
-      this.setCurrentPos(m_cachedNodes.getCurrentPos());
+      int next = m_cachedNodes.elementAt(m_next);
+    
+      incrementNextPosition();
+      m_currentContextNode = next;
 
       return next;
     }
 
     if (m_foundLast)
-      return null;
+      return DTM.NULL;
 
-    Node pos;  // our main itteration node.  
+    int pos;  // our main itteration node.  
     boolean getSelf;
 
     // Figure out what the start context should be.
     // If the m_lastFetched is null at this point we're at the start 
     // of a fresh iteration.
-    if (null == m_lastFetched)
+    if (DTM.NULL == m_lastFetched)
     {
       getSelf = m_orSelf; // true if descendants-or-self.
       
@@ -189,10 +215,10 @@
       // or the root node.
       if (getSelf && m_fromRoot)
       {
-        if(m_context.getNodeType() == Node.DOCUMENT_NODE)
+        if(m_cdtm.getNodeType(m_context) == DTM.DOCUMENT_NODE)
           pos = m_context;
         else
-          pos = m_context.getOwnerDocument();
+          pos = m_cdtm.getDocument();
       }
       else
         pos = m_context;
@@ -227,16 +253,16 @@
     
     try
     {
-      Node top = m_startContext; // tells us when to stop.
-      Node next = null;
+      int top = m_startContext; // tells us when to stop.
+      int next = DTM.NULL;
   
       // non-recursive depth-first traversal.
-      while (null != pos)
+      while (DTM.NULL != pos)
       {
         if(getSelf)
         {
           m_lastFetched = pos; // we have to do this for a clone in a predicate to work correctly.
-          if(NodeFilter.FILTER_ACCEPT == acceptNode(pos))
+          if(DTMIterator.FILTER_ACCEPT == acceptNode(pos))
           {
             next = pos;
             break;
@@ -245,22 +271,22 @@
         else
           getSelf = true;
          
-        Node nextNode = pos.getFirstChild();
+        int nextNode = m_cdtm.getFirstChild(pos);
   
-        while (null == nextNode)
+        while (DTM.NULL == nextNode)
         {
-          if (top.equals(pos))
+          if (top == pos)
             break;
   
-          nextNode = pos.getNextSibling();
+          nextNode = m_cdtm.getNextSibling(pos);
   
-          if (null == nextNode)
+          if (DTM.NULL == nextNode)
           {
-            pos = pos.getParentNode();
+            pos = m_cdtm.getParent(pos);
   
-            if ((null == pos) || (top.equals(pos)))
+            if ((DTM.NULL == pos) || (top == pos))
             {
-              nextNode = null;
+              nextNode = DTM.NULL;
   
               break;
             }
@@ -272,7 +298,7 @@
       
       m_lastFetched = next;
   
-      if (null != next)
+      if (DTM.NULL != next)
       {
         if (null != m_cachedNodes)
           m_cachedNodes.addElement(next);
@@ -284,9 +310,9 @@
       else
       {
         m_foundLast = true;
-        m_startContext = null;
+        m_startContext = DTM.NULL;
   
-        return null;
+        return DTM.NULL;
       }
     }
     finally
@@ -301,7 +327,7 @@
   }
   
   /** The top of the subtree, may not be the same as m_context if "//foo" pattern. */ 
-  transient private Node m_startContext;
+  transient private int m_startContext = DTM.NULL;
 
   /** True if this is a descendants-or-self axes.
    *  @serial */
diff --git a/src/org/apache/xpath/axes/DescendantOrSelfWalker.java b/src/org/apache/xpath/axes/DescendantOrSelfWalker.java
index 991f685..0f280d9 100644
--- a/src/org/apache/xpath/axes/DescendantOrSelfWalker.java
+++ b/src/org/apache/xpath/axes/DescendantOrSelfWalker.java
@@ -60,7 +60,8 @@
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 /**
  * Walker for the 'descendant-or-self' axes.
@@ -84,7 +85,7 @@
    *
    * @param root The context node of this step.
    */
-  public void setRoot(Node root)
+  public void setRoot(int root)
   {
 
     m_processedSelf = false;
@@ -100,7 +101,7 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   visible children in the TreeWalker's logical view.
    */
-  public Node firstChild()
+  public int firstChild()
   {
 
     // Follow my made-up rule about returning the self node as a child.
diff --git a/src/org/apache/xpath/axes/DescendantWalker.java b/src/org/apache/xpath/axes/DescendantWalker.java
index 50c2558..cb157be 100644
--- a/src/org/apache/xpath/axes/DescendantWalker.java
+++ b/src/org/apache/xpath/axes/DescendantWalker.java
@@ -60,7 +60,8 @@
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 /**
  * Walker for the 'descendant' axes.
@@ -84,10 +85,9 @@
    *
    * @param root The context node of this step.
    */
-  public void setRoot(Node root)
+  public void setRoot(int root)
   {
-
-    m_nextLevelAmount = root.hasChildNodes() ? 1 : 0;
+    m_nextLevelAmount = getDTM(root).hasChildNodes(root) ? 1 : 0;
 
     super.setRoot(root);
   }
@@ -100,20 +100,20 @@
    * @return  The new parent node, or null if the current node has no parent
    *   in the TreeWalker's logical view.
    */
-  public Node parentNode()
+  public int parentNode()
   {
 
-    Node n;
+    int n;
 
-    if (m_root.equals(m_currentNode)) // why not == ?  -sb
+    if (m_root == m_currentNode) // why not == ?  -sb
     {
-      n = null;
+      n = DTM.NULL;
     }
     else
     {
-      Node p = m_currentNode.getParentNode();
+      int p = getDTM(m_currentNode).getParent(m_currentNode);
 
-      n = m_root.equals(p) ? null : p;
+      n = (m_root == p) ? DTM.NULL : p;
     }
 
     m_nextLevelAmount = 0;
@@ -129,13 +129,13 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   visible children in the TreeWalker's logical view.
    */
-  public Node firstChild()
+  public int firstChild()
   {
-    
-    Node next = (m_currentNode.getNodeType() != Node.ATTRIBUTE_NODE) ?
-                m_currentNode.getFirstChild() : null;
+    DTM dtm = getDTM(m_currentNode);
+    int next = (dtm.getNodeType(m_currentNode) != DTM.ATTRIBUTE_NODE) ?
+                dtm.getFirstChild(m_currentNode) : DTM.NULL;
 
-    m_nextLevelAmount = (null == next) ? 0 : (next.hasChildNodes() ? 1 : 0);
+    m_nextLevelAmount = (DTM.NULL == next) ? 0 : (dtm.hasChildNodes(next) ? 1 : 0);
 
     return setCurrentIfNotNull(next);
   }
@@ -147,13 +147,13 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   next sibling in the TreeWalker's logical view.
    */
-  public Node nextSibling()
+  public int nextSibling()
   {
+    DTM dtm = getDTM(m_root);
+    int next = (m_root == m_currentNode)
+                ? DTM.NULL : dtm.getNextSibling(m_currentNode);
 
-    Node next = m_root.equals(m_currentNode)
-                ? null : m_currentNode.getNextSibling();
-
-    m_nextLevelAmount = (null == next) ? 0 : (next.hasChildNodes() ? 1 : 0);
+    m_nextLevelAmount = (DTM.NULL == next) ? 0 : (dtm.hasChildNodes(next) ? 1 : 0);
 
     return setCurrentIfNotNull(next);
   }
diff --git a/src/org/apache/xpath/axes/FilterExprWalker.java b/src/org/apache/xpath/axes/FilterExprWalker.java
index 5eb964d..cccc625 100644
--- a/src/org/apache/xpath/axes/FilterExprWalker.java
+++ b/src/org/apache/xpath/axes/FilterExprWalker.java
@@ -70,9 +70,12 @@
 
 import java.util.Vector;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.traversal.NodeFilter;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.traversal.NodeFilter;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMFilter;
 
 /**
  * Walker for the OP_VARIABLE, or OP_EXTFUNCTION, or OP_FUNCTION, or OP_GROUP,
@@ -127,7 +130,7 @@
    * @param root non-null reference to the root, or starting point of 
    *        the query.
    */
-  public void setRoot(Node root)
+  public void setRoot(int root)
   {
 
     // System.out.println("root: "+root);
@@ -167,7 +170,7 @@
       // System.out.println("Back from m_expr.execute(m_lpi.getXPathContext()): "+obj);
       m_nodeSet = (null != obj) ? obj.nodeset() : null;
       
-      m_peek = null;
+      m_peek = DTM.NULL;
     }
     catch (javax.xml.transform.TransformerException se)
     {
@@ -198,7 +201,7 @@
 
     // clone.m_expr = (Expression)((Expression)m_expr).clone();
     if (null != m_nodeSet)
-      clone.m_nodeSet = (NodeIterator) ((ContextNodeList) m_nodeSet).clone();
+      clone.m_nodeSet = (DTMIterator) m_nodeSet.clone();
 
     return clone;
   }
@@ -210,7 +213,7 @@
    * @return  a constant to determine whether the node is accepted,
    *   rejected, or skipped, as defined  above .
    */
-  public short acceptNode(Node n)
+  public short acceptNode(int n)
   {
 
     try
@@ -220,10 +223,10 @@
         countProximityPosition(0);
 
         if (!executePredicates(n, m_lpi.getXPathContext()))
-          return NodeFilter.FILTER_SKIP;
+          return DTMIterator.FILTER_SKIP;
       }
 
-      return NodeFilter.FILTER_ACCEPT;
+      return DTMIterator.FILTER_ACCEPT;
     }
     catch (javax.xml.transform.TransformerException se)
     {
@@ -240,34 +243,35 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   next node  in the TreeWalker's logical view.
    */
-  public Node getNextNode()
+  public int getNextNode()
   {
 
-    Node next;
+    int next;
 
-    if (null != m_peek)
+    if (DTM.NULL != m_peek)
     {
       next = m_peek;
-      m_peek = null;
+      m_peek = DTM.NULL;
     }
     else
     {
       if (null != m_nodeSet)
       {
-        Node current = this.getCurrentNode();
+        int current = this.getCurrentNode();
 
-        if (current instanceof NodeTestFilter)
-          ((NodeTestFilter) current).setNodeTest(this);
+        // %NODETESTFILTER%
+//        if (current instanceof NodeTestFilter)
+//          ((NodeTestFilter) current).setNodeTest(this);
 
         next = m_nodeSet.nextNode();
       }
       else
-        next = null;
+        next = DTM.NULL;
     }
 
     // Bogus, I think, but probably OK for right now since a filterExpr 
     // can only occur at the head of a location path.
-    if (null == next)
+    if (DTM.NULL == next)
     {
       m_nextLevelAmount = 0;
     }
@@ -275,7 +279,7 @@
     {
 
       // System.out.println("FilterExprWalker.getNextNode");
-      m_nextLevelAmount = (next.hasChildNodes() ? 1 : 0);
+      m_nextLevelAmount = ((getDTM(next).getFirstChild(next) != DTM.NULL) ? 1 : 0);
 
       /* ...WAIT TO SEE IF WE REALLY NEED THIS...
       m_peek = m_nodeSet.nextNode();
@@ -289,19 +293,20 @@
       */
     }
 
-    // System.out.println("FilterExprWalker.getNextNode - Returning: "+next);
-    return setCurrentIfNotNull(next);
+    int current = setCurrentIfNotNull(next);
+    // System.out.println("Returning: "+this);
+    return current;
   }
-
+  
   /** The contained expression. Should be non-null.
    *  @serial   */
   private Expression m_expr;
 
   /** The result of executing m_expr.  Needs to be deep cloned on clone op.  */
-  transient private NodeIterator m_nodeSet;
+  transient private DTMIterator m_nodeSet;
 
   /** I think this is always null right now.    */
-  transient private Node m_peek = null;
+  transient private int m_peek = DTM.NULL;
 
   /**
    * Tell what's the maximum level this axes can descend to (which is actually
diff --git a/src/org/apache/xpath/axes/FollowingSiblingWalker.java b/src/org/apache/xpath/axes/FollowingSiblingWalker.java
index a31e9c3..8b5887b 100644
--- a/src/org/apache/xpath/axes/FollowingSiblingWalker.java
+++ b/src/org/apache/xpath/axes/FollowingSiblingWalker.java
@@ -60,7 +60,8 @@
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 /**
  * Walker for the 'following-sibling' axes.
@@ -89,10 +90,10 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   next sibling in the TreeWalker's logical view.
    */
-  public Node nextSibling()
+  public int nextSibling()
   {
 
-    Node n = m_currentNode.getNextSibling();
+    int n = getDTM(m_root).getNextSibling(m_currentNode);
 
     return setCurrentIfNotNull(n);
   }
@@ -104,6 +105,6 @@
    */
   protected int getLevelMax()
   {
-    return m_lpi.getDOMHelper().getLevel(m_root);
+    return getDTM(m_root).getLevel(m_root);
   }
 }
diff --git a/src/org/apache/xpath/axes/FollowingWalker.java b/src/org/apache/xpath/axes/FollowingWalker.java
index 3381cfd..9880c79 100644
--- a/src/org/apache/xpath/axes/FollowingWalker.java
+++ b/src/org/apache/xpath/axes/FollowingWalker.java
@@ -63,7 +63,8 @@
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.DOMHelper;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 /**
  * Walker for the 'following' axes.
@@ -87,12 +88,13 @@
    *
    * @param root The context node of this step.
    */
-  public void setRoot(Node root)
+  public void setRoot(int root)
   {      
 
     super.setRoot(root);
     
-    if(root.getNodeType() == Node.ATTRIBUTE_NODE)
+    DTM dtm = getDTM(root);
+    if(dtm.getNodeType(root) == DTM.ATTRIBUTE_NODE)
     {
       // The current node could be an attribute node, so getNextSibling() will 
       // always return null.  In that case, we want to continue the search 
@@ -101,15 +103,15 @@
       // don't have to consider following attributes, since they never match 
       // the following axes.
       /*
-      Node e = m_lpi.getDOMHelper().getParentOfNode(root);
+      int e = m_lpi.getDOMHelper().getParentOfNode(root);
       root = e.getLastChild();
       if(null == root)
         root = e;
       m_currentAncestor = e.getParentNode();
       */
-      Node e = m_lpi.getDOMHelper().getParentOfNode(root);
+      int e = dtm.getParent(root);
       m_currentNode = e;
-      m_currentAncestor = e.getOwnerDocument(); // Not totally sure why
+      m_currentAncestor = dtm.getDocument(); // Not totally sure why
     } 
     else
       m_currentAncestor = root;
@@ -130,22 +132,22 @@
    * @return  The new parent node, or null if the current node has no parent
    *   in the TreeWalker's logical view.
    */
-  public Node parentNode()
+  public int parentNode()
   {
 
-    Node n;
-//    Node nextAncestor = (null != m_currentAncestor)
+    int n;
+//    int nextAncestor = (null != m_currentAncestor)
 //                        ? m_currentAncestor.getParentNode() : null;
-    Node nextParent = m_currentNode.getParentNode();
+    int nextParent = getDTM(m_root).getParent(m_currentNode);
 
 //    if (nextParent == nextAncestor)
 //    {
 //      n = null;
 //
-//      Node ancestor = m_currentAncestor;
+//      int ancestor = m_currentAncestor;
 //
 //      while ((null != ancestor)
-//             && (null != (ancestor = (Node) ancestor.getParentNode())))
+//             && (null != (ancestor = (int) ancestor.getParentNode())))
 //      {
 //        n = ancestor.getNextSibling();
 //
@@ -162,7 +164,7 @@
 
 //    if(null != n)
 //    {
-//      Node attrNode = n.getAttributes().getNamedItem("id");
+//      int attrNode = n.getAttributes().getNamedItem("id");
 //      if(null != attrNode)
 //        System.out.println("parentNode: "+attrNode.getNodeValue());
 //      else
@@ -182,13 +184,14 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   visible children in the TreeWalker's logical view.
    */
-  public Node firstChild()
+  public int firstChild()
   {
 
-    Node n;
+    int n;
+    DTM dtm = getDTM(m_root);
     if(m_currentAncestor == m_currentNode)
     {
-//      if(m_currentNode.getNodeType() == Node.ATTRIBUTE_NODE)
+//      if(m_currentNode.getNodeType() == DTM.ATTRIBUTE_NODE)
 //      {
 //        // The current node could be an attribute node, so getNextSibling() will 
 //        // always return null.  In that case, we want to continue the search 
@@ -199,18 +202,18 @@
 //        n = m_lpi.getDOMHelper().getParentOfNode(m_currentNode).getFirstChild();
 //      } 
 //      else
-        n = m_currentNode.getNextSibling();
+        n = dtm.getNextSibling(m_currentNode);
     }
     else
     {
-      n = m_currentNode.getFirstChild();
+      n = dtm.getFirstChild(m_currentNode);
     }
 
-    m_nextLevelAmount = (null == n) ? 0 : (n.hasChildNodes() ? 1 : 0);
+    m_nextLevelAmount = (DTM.NULL == n) ? 0 : (dtm.hasChildNodes(n) ? 1 : 0);
     
 //    if(null != n)
 //    {
-//      Node attrNode = n.getAttributes().getNamedItem("id");
+//      int attrNode = n.getAttributes().getNamedItem("id");
 //      if(null != attrNode)
 //        System.out.println("firstChild: "+attrNode.getNodeValue());
 //      else
@@ -229,17 +232,18 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   next sibling in the TreeWalker's logical view.
    */
-  public Node nextSibling()
+  public int nextSibling()
   {
 
-    Node n;    
-    n = m_currentNode.getNextSibling();
+    int n;    
+    DTM dtm = getDTM(m_root);
+    n = dtm.getNextSibling(m_currentNode);
 
-    m_nextLevelAmount = (null == n) ? 0 : (n.hasChildNodes() ? 1 : 0);
+    m_nextLevelAmount = (DTM.NULL == n) ? 0 : (dtm.hasChildNodes(n) ? 1 : 0);
 
 //    if(null != n)
 //    {
-//      Node attrNode = n.getAttributes().getNamedItem("id");
+//      int attrNode = n.getAttributes().getNamedItem("id");
 //      if(null != attrNode)
 //        System.out.println("nextSibling: "+attrNode.getNodeValue());
 //      else
@@ -253,7 +257,7 @@
 
   /** What this is is frankly a little unclear.  It is used in getParent 
    *  to see if we should continue to climb the tree. */
-  transient Node m_currentAncestor;
+  transient int m_currentAncestor = DTM.NULL;
 
   /**
    * Tell what's the maximum level this axes can descend to.
diff --git a/src/org/apache/xpath/axes/LocPathIterator.java b/src/org/apache/xpath/axes/LocPathIterator.java
index ea49b33..dc2d608 100644
--- a/src/org/apache/xpath/axes/LocPathIterator.java
+++ b/src/org/apache/xpath/axes/LocPathIterator.java
@@ -61,13 +61,17 @@
 import java.util.Stack;
 
 // DOM imports
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.traversal.TreeWalker;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.Node;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.NodeList;
+//import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.traversal.TreeWalker;
+//import org.w3c.dom.traversal.NodeFilter;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.NamedNodeMap;
+//import org.w3c.dom.DOMException;
+//import org.w3c.dom.NodeList;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMFilter;
+import org.apache.xml.dtm.DTMManager;
 
 // Xalan imports
 import org.apache.xpath.res.XPATHErrorResources;
@@ -101,8 +105,7 @@
  * in which case the UnionPathIterator will cache the nodes.</p>
  */
 public class LocPathIterator extends PredicatedNodeTest
-        implements Cloneable, NodeIterator, ContextNodeList, NodeList,
-                   java.io.Serializable
+        implements Cloneable, DTMIterator, java.io.Serializable
 {
 
   /**
@@ -198,6 +201,51 @@
       m_lastUsedWalker = m_firstWalker;
     }
   }
+  
+  /**
+   * Set the environment in which this iterator operates, which should provide:
+   * a node (the context node... same value as "root" defined below) 
+   * a pair of non-zero positive integers (the context position and the context size) 
+   * a set of variable bindings 
+   * a function library 
+   * the set of namespace declarations in scope for the expression.
+   * 
+   * <p>At this time the exact implementation of this environment is application 
+   * dependent.  Probably a proper interface will be created fairly soon.</p>
+   * 
+   * @param environment The environment object.
+   */
+  public void setEnvironment(Object environment)
+  {
+    // no-op for now.
+  }
+  
+  /**
+   * Get an instance of a DTM that "owns" a node handle.  Since a node 
+   * iterator may be passed without a DTMManager, this allows the 
+   * caller to easily get the DTM using just the iterator.
+   *
+   * @param nodeHandle the nodeHandle.
+   *
+   * @return a non-null DTM reference.
+   */
+  public DTM getDTM(int nodeHandle)
+  {
+    // %OPT%
+    return m_execContext.getDTM(nodeHandle);
+  }
+  
+  /**
+   * Get an instance of the DTMManager.  Since a node 
+   * iterator may be passed without a DTMManager, this allows the 
+   * caller to easily get the DTMManager using just the iterator.
+   *
+   * @return a non-null DTMManager reference.
+   */
+  public DTMManager getDTMManager()
+  {
+    return m_execContext.getDTMManager();
+  }
 
   /**
    * Execute this iterator, meaning create a clone that can
@@ -269,6 +317,7 @@
   {
 
     this.m_context = execContext.getCurrentNode();
+    m_cdtm = execContext.getDTM(m_context);
     this.m_currentContextNode = execContext.getCurrentExpressionNode();
     this.m_execContext = execContext;
     this.m_prefixResolver = execContext.getNamespaceContext();
@@ -282,6 +331,32 @@
       this.m_varStackContext = vars.getContextPos();
     }
   }
+  
+  /**
+   * Initialize the context values for this expression
+   * after it is cloned.
+   *
+   * @param execContext The XPath runtime context for this
+   * transformation.
+   */
+  public void initContext(XPathContext execContext, int context)
+  {
+
+    this.m_context = context;
+    m_cdtm = execContext.getDTM(m_context);
+    this.m_currentContextNode = context;
+    this.m_execContext = execContext;
+    this.m_prefixResolver = execContext.getNamespaceContext();
+    this.m_dhelper = execContext.getDOMHelper();
+
+    if (m_isTopLevel)
+    {
+      VariableStack vars = execContext.getVarStack();
+
+      this.m_varStackPos = vars.getSearchStartOrTop();
+      this.m_varStackContext = vars.getContextPos();
+    }
+  }
 
   /**
    * Set the next position index of this iterator.
@@ -330,6 +405,18 @@
     else
       m_cachedNodes = null;
   }
+  
+  /**
+   * Tells if this iterator can have nodes added to it or set via 
+   * the <code>setItem(int node, int index)</code> method.
+   * 
+   * @return True if the nodelist can be mutated.
+   */
+  public boolean isMutable()
+  {
+    return (m_cachedNodes != null);
+  }
+
 
   /**
    * Get cached nodes.
@@ -389,13 +476,31 @@
    *   <code>NodeList</code> , or <code>null</code> if that is not a valid
    *   index.
    */
-  public Node item(int index)
+  public int item(int index)
   {
 
-    resetToCachedList();
+    // resetToCachedList();
 
     return m_cachedNodes.item(index);
   }
+  
+  /**
+   * Sets the node at the specified index of this vector to be the
+   * specified node. The previous component at that position is discarded.
+   *
+   * <p>The index must be a value greater than or equal to 0 and less
+   * than the current size of the vector.  
+   * The iterator must be in cached mode.</p>
+   * 
+   * <p>Meant to be used for sorted iterators.</p>
+   *
+   * @param node Node to set
+   * @param index Index of where to set the node
+   */
+  public void setItem(int node, int index)
+  {
+    m_cachedNodes.setElementAt(node, index);
+  }
 
   /**
    *  The number of nodes in the list. The range of valid child node indices
@@ -406,9 +511,18 @@
   public int getLength()
   {
 
-    resetToCachedList();
-
-    return m_cachedNodes.getLength();
+    // resetToCachedList();
+    if(m_last > 0)
+      return m_last;
+    else if(null == m_cachedNodes || !m_foundLast)
+    {
+      m_last = getLastPos(m_execContext);
+    }
+    else
+    {
+      m_last = m_cachedNodes.getLength();
+    }
+    return m_last;
   }
 
   /**
@@ -417,7 +531,7 @@
    */
   private void resetToCachedList()
   {
-
+    // %REVIEW% ? This doesn't seem to work so well...
     int pos = this.getCurrentPos();
 
     if ((null == m_cachedNodes) || (pos != 0))
@@ -444,11 +558,8 @@
    * iterator backwards in the set.
    * @return  The previous <code>Node</code> in the set being iterated over,
    *   or<code>null</code> if there are no more members in that set.
-   * @throws DOMException
-   *    INVALID_STATE_ERR: Raised if this method is called after the
-   *   <code>detach</code> method was invoked.
    */
-  public Node previousNode() throws DOMException
+  public int previousNode()
   {
 
     if (null == m_cachedNodes)
@@ -475,7 +586,7 @@
   {
 
     // TODO: ??
-    return NodeFilter.SHOW_ALL & ~NodeFilter.SHOW_ENTITY_REFERENCE;
+    return DTMFilter.SHOW_ALL & ~DTMFilter.SHOW_ENTITY_REFERENCE;
   }
 
   /**
@@ -486,7 +597,7 @@
    * @return Always null.
    * @see org.w3c.dom.traversal.NodeIterator
    */
-  public NodeFilter getFilter()
+  public DTMFilter getFilter()
   {
     return null;
   }
@@ -497,7 +608,7 @@
    * @return The "root" of this iterator, which, in XPath terms,
    * is the node context for this iterator.
    */
-  public Node getRoot()
+  public int getRoot()
   {
     return m_context;
   }
@@ -532,7 +643,8 @@
   public void detach()
   {
 
-    this.m_context = null;
+    this.m_context = DTM.NULL;
+    m_cdtm = null;
     this.m_execContext = null;
     this.m_prefixResolver = null;
     this.m_dhelper = null;
@@ -550,7 +662,7 @@
    *
    * @throws CloneNotSupportedException
    */
-  public NodeIterator cloneWithReset() throws CloneNotSupportedException
+  public DTMIterator cloneWithReset() throws CloneNotSupportedException
   {
 
     LocPathIterator clone = (LocPathIterator) clone();
@@ -608,7 +720,7 @@
 
     // super.reset();
     m_foundLast = false;
-    m_lastFetched = null;
+    m_lastFetched = DTM.NULL;
     m_next = 0;
     m_last = 0;
     m_waitingBottom = 0;
@@ -629,21 +741,19 @@
    * to nextNode() returns the first node in the set.
    * @return  The next <code>Node</code> in the set being iterated over, or
    *   <code>null</code> if there are no more members in that set.
-   * @throws DOMException
-   *    INVALID_STATE_ERR: Raised if this method is called after the
-   *   <code>detach</code> method was invoked.
    */
-  public Node nextNode() throws DOMException
+  public int nextNode()
   {
 
     // If the cache is on, and the node has already been found, then 
     // just return from the list.
     if ((null != m_cachedNodes)
-            && (m_cachedNodes.getCurrentPos() < m_cachedNodes.size()))
+            && (m_next < m_cachedNodes.size()))
     {
-      Node next = m_cachedNodes.nextNode();
-
-      this.setCurrentPos(m_cachedNodes.getCurrentPos());
+      int next = m_cachedNodes.elementAt(m_next);
+    
+      incrementNextPosition();
+      m_currentContextNode = next;
 
       return next;
     }
@@ -658,7 +768,7 @@
     // from the execute method.
     if (-1 == m_varStackPos)
     {
-      if (null == m_firstWalker.getRoot())
+      if (DTM.NULL == m_firstWalker.getRoot())
       {
         this.setNextPosition(0);
         m_firstWalker.setRoot(m_context);
@@ -678,7 +788,7 @@
       vars.setSearchStart(m_varStackPos);
       vars.pushContextPosition(m_varStackContext);
 
-      if (null == m_firstWalker.getRoot())
+      if (DTM.NULL == m_firstWalker.getRoot())
       {
         this.setNextPosition(0);
         m_firstWalker.setRoot(m_context);
@@ -686,7 +796,7 @@
         m_lastUsedWalker = m_firstWalker;
       }
 
-      Node n = returnNextNode(m_firstWalker.nextNode());
+      int n = returnNextNode(m_firstWalker.nextNode());
 
       // These two statements need to be combined into one operation.
       vars.setSearchStart(savedStart);
@@ -704,10 +814,10 @@
    *
    * @return The same node that was passed as an argument.
    */
-  protected Node returnNextNode(Node nextNode)
+  protected int returnNextNode(int nextNode)
   {
 
-    if (null != nextNode)
+    if (DTM.NULL != nextNode)
     {
       if (null != m_cachedNodes)
         m_cachedNodes.addElement(nextNode);
@@ -717,7 +827,7 @@
 
     m_lastFetched = nextNode;
 
-    if (null == nextNode)
+    if (DTM.NULL == nextNode)
       m_foundLast = true;
 
     return nextNode;
@@ -728,7 +838,7 @@
    *
    * @return The last fetched node, or null if the last fetch was null.
    */
-  public Node getCurrentNode()
+  public int getCurrentNode()
   {
     return m_lastFetched;
   }
@@ -748,15 +858,15 @@
     if (m_foundLast || ((index >= 0) && (index <= getCurrentPos())))
       return;
 
-    Node n;
+    int n;
 
     if (-1 == index)
     {
-      while (null != (n = nextNode()));
+      while (DTM.NULL != (n = nextNode()));
     }
     else
     {
-      while (null != (n = nextNode()))
+      while (DTM.NULL != (n = nextNode()))
       {
         if (getCurrentPos() >= index)
           break;
@@ -869,7 +979,7 @@
    *
    * @return The node context, same as getRoot().
    */
-  public final Node getContext()
+  public final int getContext()
   {
     return m_context;
   }
@@ -880,7 +990,7 @@
    *
    * @return The top-level node context of the entire expression.
    */
-  public final Node getCurrentContextNode()
+  public final int getCurrentContextNode()
   {
     return m_currentContextNode;
   }
@@ -890,10 +1000,22 @@
    *
    * @param n Must be a non-null reference to the node context.
    */
-  public final void setCurrentContextNode(Node n)
+  public final void setCurrentContextNode(int n)
   {
     m_currentContextNode = n;
   }
+  
+  /**
+   * Set the current context node for this iterator.
+   *
+   * @param n Must be a non-null reference to the node context.
+   */
+  public final void setRoot(int n)
+  {
+    m_context = n;
+    m_cdtm = m_execContext.getDTM(n);
+  }
+
 
   /**
    * Return the saved reference to the prefix resolver that
@@ -914,7 +1036,7 @@
    */
   public int getLast()
   {
-    return m_last;
+    return getLength();
   }
 
   /**
@@ -943,18 +1065,23 @@
 
     try
     {
-      clone = (LocPathIterator) clone();
+      // %REVIEW% %OPT%
+      if(0 == pos && m_currentContextNode != DTM.NULL)
+        clone = (LocPathIterator) cloneWithReset();
+      else
+        clone = (LocPathIterator) clone();
     }
     catch (CloneNotSupportedException cnse)
     {
       return -1;
     }
+    // %REVIEW% Commented this out, as it was messing up pos68 test. count-1?
+    // System.out.println("clone.getPredicateCount(): "+clone.getPredicateCount());
+    // clone.setPredicateCount(clone.getPredicateCount() - 1);
 
-    clone.setPredicateCount(clone.getPredicateCount() - 1);
+    int next;
 
-    Node next;
-
-    while (null != (next = clone.nextNode()))
+    while (DTM.NULL != (next = clone.nextNode()))
     {
       pos++;
     }
@@ -1007,6 +1134,12 @@
   
   //============= State Data =============
   
+  /** 
+   * The dtm of the context node.  Careful about using this... it may not 
+   * be the dtm of the current node.
+   */
+  transient protected DTM m_cdtm;
+  
   /** The starting point in m_waiting where the waiting step walkers are. */
   transient int m_waitingBottom = 0;
 
@@ -1042,7 +1175,7 @@
   // ObjectPool m_pool = new ObjectPool(this.getClass());
 
   /** The last node that was fetched, usually by nextNode. */
-  transient public Node m_lastFetched;
+  transient public int m_lastFetched = DTM.NULL;
 
   /**
    * If this iterator needs to cache nodes that are fetched, they
@@ -1071,7 +1204,7 @@
    * The context node for this iterator, which doesn't change through
    * the course of the iteration.
    */
-  transient protected Node m_context;
+  transient protected int m_context = DTM.NULL;
 
   /**
    * The node context from where the expression is being
@@ -1079,7 +1212,7 @@
    * from m_context in that this is the context for the entire
    * expression, rather than the context for the subexpression.
    */
-  transient protected Node m_currentContextNode;
+  transient protected int m_currentContextNode = DTM.NULL;
 
   /**
    * Fast access to the current prefix resolver.  It isn't really
diff --git a/src/org/apache/xpath/axes/NamespaceWalker.java b/src/org/apache/xpath/axes/NamespaceWalker.java
index f223650..b60b884 100644
--- a/src/org/apache/xpath/axes/NamespaceWalker.java
+++ b/src/org/apache/xpath/axes/NamespaceWalker.java
@@ -62,8 +62,9 @@
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.NamedNodeMap;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.NamedNodeMap;
+import org.apache.xml.dtm.DTM;
 
 /**
  * Walker for the 'namespace' axes.
@@ -83,66 +84,20 @@
   }
 
   /**
-   * Get a cloned AxesWalker.
-   *
-   * @return A cloned NamespaceWalker.
-   *
-   * @throws CloneNotSupportedException
-   */
-  public Object clone() throws CloneNotSupportedException
-  {
-
-    NamespaceWalker clone = (NamespaceWalker) super.clone();
-
-    if (null != this.m_namespaces)
-    {
-      clone.m_namespaces = (Stack) this.m_namespaces.clone();
-    }
-
-    return clone;
-  }
-
-  /**
-   *  Set the root node of the TreeWalker.
+   *  The root node of the TreeWalker.
    *
    * @param root The context node of this step.
    */
-  public void setRoot(Node root)
+  public void setRoot(int root)
   {
 
-    m_nextLevelAmount = 1;
-    m_namespaces = new Stack();
+    // System.out.println("ChildWalker.setRoot");
+    m_nextLevelAmount = (getDTM(root).getFirstNamespaceNode(root, true) != DTM.NULL) ? 1 : 0;
 
-    Node nsContext = root;
-
-    while (null != nsContext)
-    {
-      NamedNodeMap attributeList = nsContext.getAttributes();
-
-      if (null != attributeList)
-      {
-        int nAttrs = attributeList.getLength();
-
-        // System.out.println("setRoot - nAttrs: "+nAttrs);
-        for (int i = (nAttrs - 1); i >= 0; i--)
-        {
-          Node attr = attributeList.item(i);
-
-          if (m_lpi.getDOMHelper().isNamespaceNode(attr))
-          {
-
-            // System.out.println("setRoot - pushing namespace: "+attr.getNodeName());
-            m_namespaces.push(attr);
-          }
-        }
-      }
-
-      nsContext = nsContext.getParentNode();
-    }
-
+    // System.out.println("Back from calling hasChildNodes");
     super.setRoot(root);
 
-    // System.out.println("============");
+    // System.out.println("Exiting ChildWalker.setRoot");
   }
 
   /**
@@ -153,12 +108,22 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   visible children in the TreeWalker's logical view.
    */
-  public Node firstChild()
+  public int firstChild()
   {
 
+    // System.out.println("ChildWalker.firstChild");
     m_nextLevelAmount = 0;
 
-    return nextSibling();
+    if (m_root == m_currentNode)
+    {
+      DTM dtm = getDTM(m_root);
+      // System.out.println("NamespaceWalker - Calling getFirstNamespaceNode: "+dtm.getNodeName(m_currentNode));
+      int nsNode = dtm.getFirstNamespaceNode(m_currentNode, true);
+      
+      return setCurrentIfNotNull(nsNode);
+    }
+    else
+      return DTM.NULL;
   }
 
   /**
@@ -168,18 +133,21 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   next sibling in the TreeWalker's logical view.
    */
-  public Node nextSibling()
+  public int nextSibling()
   {
 
-    Node next = m_namespaces.isEmpty() ? null : (Node) m_namespaces.pop();
-
-    // System.out.println("nextSibling: "+this.nodeToString(next));
-    return this.setCurrentIfNotNull(next);
+    if (m_root != m_currentNode)
+    {
+      DTM dtm = getDTM(m_root);
+      // System.out.println("NamespaceWalker - Calling getNextNamespaceNode: "+dtm.getNodeName(m_currentNode));
+      int nsNode = dtm.getNextNamespaceNode(m_root, m_currentNode, true);
+      
+      return setCurrentIfNotNull(nsNode);
+    }
+    else
+      return DTM.NULL;
   }
 
-  /** Stack of namespace decl nodes (xmlns attributes).   */
-  transient Stack m_namespaces;
-
   /**
    * Tell what's the maximum level this axes can descend to.
    *
@@ -187,6 +155,6 @@
    */
   protected int getLevelMax()
   {
-    return m_lpi.getDOMHelper().getLevel(m_root);
+    return getDTM(m_root).getLevel(m_root);
   }
 }
diff --git a/src/org/apache/xpath/axes/ParentWalker.java b/src/org/apache/xpath/axes/ParentWalker.java
index 90b40e0..c198b81 100644
--- a/src/org/apache/xpath/axes/ParentWalker.java
+++ b/src/org/apache/xpath/axes/ParentWalker.java
@@ -60,7 +60,8 @@
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 /**
  * Walker for the 'parent' axes.
@@ -84,7 +85,7 @@
    *
    * @param root The context node of this step.
    */
-  public void setRoot(Node root)
+  public void setRoot(int root)
   {
 
     m_gotParent = false;
@@ -101,7 +102,7 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   visible children in the TreeWalker's logical view.
    */
-  public Node firstChild()
+  public int firstChild()
   {
 
     // Follow rule about returning the first occuring in document order 
@@ -110,13 +111,12 @@
     {
       m_gotParent = true;
 
-      // Patch from Merlin
-      Node n = m_lpi.getDOMHelper().getParentOfNode(m_root);
+      int n = getDTM(m_root).getParent(m_root);
 
       return setCurrentIfNotNull(n);
     }
 
-    return null;
+    return DTM.NULL;
   }
 
   /** True if we already obtained the parent node.  */
@@ -129,6 +129,6 @@
    */
   protected int getLevelMax()
   {
-    return m_lpi.getDOMHelper().getLevel(m_root) - 1;
+    return getDTM(m_root).getLevel(m_root) - 1;
   }
 }
diff --git a/src/org/apache/xpath/axes/PrecedingSiblingWalker.java b/src/org/apache/xpath/axes/PrecedingSiblingWalker.java
index 66dca78..4e13f60 100644
--- a/src/org/apache/xpath/axes/PrecedingSiblingWalker.java
+++ b/src/org/apache/xpath/axes/PrecedingSiblingWalker.java
@@ -60,7 +60,8 @@
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 /**
  * Walker for the 'preceding-sibling' axes.
@@ -89,37 +90,38 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   next sibling in the TreeWalker's logical view.
    */
-  public Node nextSibling()
+  public int nextSibling()
   {
 
-    Node next;
+    int next;
 
+    DTM dtm = getDTM(m_root);
     if (m_currentNode == m_root)
     {
-      if(m_currentNode.getNodeType() == Node.ATTRIBUTE_NODE)
+      if(dtm.getNodeType(m_currentNode) == DTM.ATTRIBUTE_NODE)
       {
         // then don't bother, since attributes don't have siblings.
         // Otherwise, we would go up to the parent, and get the so-called 
         // first attribute.
-        next = null;
+        next = DTM.NULL;
       }
       else
       {
-        Node parent = m_lpi.getDOMHelper().getParentOfNode(m_currentNode);
+        int parent = dtm.getParent(m_currentNode);
   
-        if (null == parent)
-          return null;
+        if (DTM.NULL == parent)
+          return DTM.NULL;
   
-        next = parent.getFirstChild();
+        next = dtm.getFirstChild(parent);
       }
     }
     else
     {
-      next = m_currentNode.getNextSibling();
+      next = dtm.getNextSibling(m_currentNode);
     }
 
-    if (null != next && next.equals(m_root))
-      next = null;
+    if (DTM.NULL != next && next == m_root)
+      next = DTM.NULL;
 
     return setCurrentIfNotNull(next);
   }
@@ -131,6 +133,6 @@
    */
   protected int getLevelMax()
   {
-    return m_lpi.getDOMHelper().getLevel(m_root);
+    return getDTM(m_root).getLevel(m_root);
   }
 }
diff --git a/src/org/apache/xpath/axes/PrecedingWalker.java b/src/org/apache/xpath/axes/PrecedingWalker.java
index b323d3d..9e741f8 100644
--- a/src/org/apache/xpath/axes/PrecedingWalker.java
+++ b/src/org/apache/xpath/axes/PrecedingWalker.java
@@ -61,7 +61,8 @@
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.DOMHelper;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 /**
  * Walker for the 'preceding' axes.
@@ -90,19 +91,19 @@
    *
    * @param root The context node of this step.
    */
-  public void setRoot(Node root)
+  public void setRoot(int root)
   {
-
-    if (Node.ATTRIBUTE_NODE == root.getNodeType())
+    DTM dtm = getDTM(root);
+    if (DTM.ATTRIBUTE_NODE == dtm.getNodeType(root))
     {
-      root = m_lpi.getDOMHelper().getParentOfNode(root);
+      root = dtm.getParent(root);
     }
 
     super.setRoot(root);
 
-    m_doc = m_lpi.getDOMHelper().getRootNode(root);
+    m_doc = dtm.getDocument();
     m_currentNode = m_doc;
-    m_nextLevelAmount = root.hasChildNodes() ? 1 : 0;
+    m_nextLevelAmount = (dtm.getFirstChild(root) != DTM.NULL) ? 1 : 0;
 
     super.resetProximityPositions();
   }
@@ -120,26 +121,26 @@
    * @return  The new parent node, or null if the current node has no parent
    *   in the TreeWalker's logical view.
    */
-  public Node parentNode()
+  public int parentNode()
   {
 
-    Node next = m_currentNode.getParentNode();
+    int next = getDTM(m_currentNode).getParent(m_currentNode);
 
     // If we're at the root of the tree, we're done.
-    if ((null == next) || m_doc.equals(next))
-      return null;
+    if ((DTM.NULL == next) || m_doc == next)
+      return DTM.NULL;
 
     // If the parent vertice is an ancestor of the step 
     // context, then all siblings are to the left of the 
     // ancestor path, so we're done.
     if (isAncestorOfRootContext(next))
-      return null;
+      return DTM.NULL;
 
     m_nextLevelAmount = 0;
 
 //    if(null != next)
 //    {
-//      Node attrNode = next.getAttributes().getNamedItem("id");
+//      int attrNode = next.getAttributes().getNamedItem("id");
 //      if(null != attrNode)
 //        System.out.println("parentNode: "+attrNode.getNodeValue());
 //      else
@@ -159,23 +160,25 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   visible children in the TreeWalker's logical view.
    */
-  public Node firstChild()
+  public int firstChild()
   {
 
     // Walk down the left edge of the current sub-tree.
     // Get the next child on the 'preceding' axes. This will 
     // skip any children nodes that are ancestors of the step context,
     // but will return children of those nodes.
-    if (m_root.equals(m_currentNode))
-      return null;
+    if (m_root == m_currentNode)
+      return DTM.NULL;
 
-    Node nextNode = m_currentNode;
+    int nextNode = m_currentNode;
+    
+    DTM dtm = getDTM(m_root);
 
-    while (null != nextNode)
+    while (DTM.NULL != nextNode)
     {
-      Node n = nextNode.getFirstChild();
+      int n = dtm.getFirstChild(nextNode);
 
-      if (null != n)
+      if (DTM.NULL != n)
       {
         nextNode = n;
       }
@@ -185,28 +188,28 @@
         // If the next sibling is an ancestor, then continue 
         // on to get it's first child, otherwise nextSibling() 
         // will get it.
-        nextNode = nextNode.getNextSibling();
+        nextNode = dtm.getNextSibling(nextNode);
 
-        if (null != nextNode)
+        if (DTM.NULL != nextNode)
         {
-          if (m_root.equals(nextNode) ||!isAncestorOfRootContext(nextNode))
-            return null;
+          if ((m_root == nextNode) ||!isAncestorOfRootContext(nextNode))
+            return DTM.NULL;
           else
             continue;
         }
       }
 
-      if (null != nextNode)
+      if (DTM.NULL != nextNode)
       {
-        if (m_root.equals(nextNode))
-          return null;
+        if (m_root == nextNode)
+          return DTM.NULL;
         else if (!isAncestorOfRootContext(nextNode))
           break;
       }
     }
 
-    m_nextLevelAmount = (null == nextNode)
-                        ? 0 : (nextNode.hasChildNodes() ? 1 : 0);
+    m_nextLevelAmount = (DTM.NULL == nextNode)
+                        ? 0 : (dtm.hasChildNodes(nextNode) ? 1 : 0);
 
 //    if(null != nextNode)
 //    {
@@ -229,32 +232,33 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   next sibling in the TreeWalker's logical view.
    */
-  public Node nextSibling()
+  public int nextSibling()
   {
 
-    if (m_root.equals(m_currentNode))
-      return null;
-
-    Node next = m_currentNode.getNextSibling();
+    if (m_root == m_currentNode)
+      return DTM.NULL;
     
-    if ((null == next) || m_root.equals(next)
+    DTM dtm = getDTM(m_root);
+    int next = dtm.getNextSibling(m_currentNode);
+    
+    if ((DTM.NULL == next) || m_root == next
             /* || isAncestorOfRootContext(next) */)
-      return null;
+      return DTM.NULL;
       
     if(isAncestorOfRootContext(next))
     {
-      next = next.getFirstChild();
+      next = dtm.getFirstChild(next);
       
-      if ((null == next) || m_root.equals(next)
+      if ((DTM.NULL == next) || (m_root == next)
               /* || isAncestorOfRootContext(next) */)
-        return null;
+        return DTM.NULL;
     }
 
-    m_nextLevelAmount = (null == next) ? 0 : (next.hasChildNodes() ? 1 : 0);
+    m_nextLevelAmount = (DTM.NULL == next) ? 0 : (dtm.hasChildNodes(next) ? 1 : 0);
 
 //    if(null != next)
 //    {
-//      Node attrNode = next.getAttributes().getNamedItem("id");
+//      int attrNode = next.getAttributes().getNamedItem("id");
 //      if(null != attrNode)
 //        System.out.println("nextSibling: "+attrNode.getNodeValue());
 //      else
@@ -267,7 +271,7 @@
   }
 
   /** The document owner node.  */
-  transient Node m_doc;
+  transient int m_doc = DTM.NULL;
 
   /**
    * Tell what's the maximum level this axes can descend to.
diff --git a/src/org/apache/xpath/axes/PredicatedNodeTest.java b/src/org/apache/xpath/axes/PredicatedNodeTest.java
index 6471244..418af04 100644
--- a/src/org/apache/xpath/axes/PredicatedNodeTest.java
+++ b/src/org/apache/xpath/axes/PredicatedNodeTest.java
@@ -9,9 +9,11 @@
 
 import org.apache.xml.utils.PrefixResolver;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeFilter;
-
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeFilter;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMFilter;
 
 public abstract class PredicatedNodeTest extends NodeTest implements SubContextList
 {
@@ -257,7 +259,7 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  boolean executePredicates(Node context, XPathContext xctxt)
+  boolean executePredicates(int context, XPathContext xctxt)
           throws javax.xml.transform.TransformerException
   {
 
@@ -350,18 +352,16 @@
    *
    * @return Informative string about the argument.
    */
-  protected String nodeToString(Node n)
+  protected String nodeToString(int n)
   {
-
-    try
+    if(DTM.NULL != n)
     {
-      return (null != n)
-             ? n.getNodeName() + "{" + ((org.apache.xalan.stree.Child) n).getUid() + "}"
-             : "null";
+      DTM dtm = m_lpi.getXPathContext().getDTM(n);
+      return dtm.getNodeName(n) + "{" + (n+1) + "}";
     }
-    catch (ClassCastException cce)
+    else
     {
-      return (null != n) ? n.getNodeName() : "null";
+      return "null";
     }
   }
   
@@ -376,7 +376,7 @@
    * @return  a constant to determine whether the node is accepted,
    *   rejected, or skipped, as defined  above .
    */
-  public short acceptNode(Node n)
+  public short acceptNode(int n)
   {
 
     XPathContext xctxt = m_lpi.getXPathContext();
@@ -395,10 +395,10 @@
           countProximityPosition(0);
 
           if (!executePredicates(n, xctxt))
-            return NodeFilter.FILTER_SKIP;
+            return DTMIterator.FILTER_SKIP;
         }
 
-        return NodeFilter.FILTER_ACCEPT;
+        return DTMIterator.FILTER_ACCEPT;
       }
     }
     catch (javax.xml.transform.TransformerException se)
@@ -412,7 +412,7 @@
       xctxt.popCurrentNode();
     }
 
-    return NodeFilter.FILTER_SKIP;
+    return DTMIterator.FILTER_SKIP;
   }
 
   
diff --git a/src/org/apache/xpath/axes/ReverseAxesWalker.java b/src/org/apache/xpath/axes/ReverseAxesWalker.java
index dd89531..8f1b8ee 100644
--- a/src/org/apache/xpath/axes/ReverseAxesWalker.java
+++ b/src/org/apache/xpath/axes/ReverseAxesWalker.java
@@ -66,8 +66,10 @@
 
 import javax.xml.transform.TransformerException;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeFilter;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeFilter;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 /**
  * Walker for a reverse axes.
@@ -96,15 +98,15 @@
     return true;
   }
 
-  /**
-   *  Set the root node of the TreeWalker.
-   *
-   * @param root The context node of this step.
-   */
-  public void setRoot(Node root)
-  {
-    super.setRoot(root);
-  }
+//  /**
+//   *  Set the root node of the TreeWalker.
+//   *
+//   * @param root The context node of this step.
+//   */
+//  public void setRoot(int root)
+//  {
+//    super.setRoot(root);
+//  }
 
   /**
    * Get the current sub-context position.  In order to do the
@@ -143,9 +145,9 @@
 
         // Count 'em all
         int count = 1;
-        Node next;
+        int next;
 
-        while (null != (next = clone.nextNode()))
+        while (DTM.NULL != (next = clone.nextNode()))
         {
           count++;
         }
@@ -206,9 +208,9 @@
 
       // Count 'em all
       // count = 1;
-      Node next;
+      int next;
 
-      while (null != (next = clone.nextNode()))
+      while (DTM.NULL != (next = clone.nextNode()))
       {
         count++;
       }
@@ -224,6 +226,7 @@
     }
 
     // System.out.println("getLastPos - pos: "+count);
+    // System.out.println("pos (ReverseAxesWalker): "+count);
     return count;
   }
 }
diff --git a/src/org/apache/xpath/axes/RootWalker.java b/src/org/apache/xpath/axes/RootWalker.java
index 7f1df13..e43e42f 100644
--- a/src/org/apache/xpath/axes/RootWalker.java
+++ b/src/org/apache/xpath/axes/RootWalker.java
@@ -60,7 +60,8 @@
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 /**
  * Walker for the FROM_ROOT axes.
@@ -89,7 +90,7 @@
    *
    * @param root The context node of this step.
    */
-  public void setRoot(Node root)
+  public void setRoot(int root)
   {      
 
     super.setRoot(root);
@@ -104,7 +105,7 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   visible children in the TreeWalker's logical view.
    */
-  public Node firstChild()
+  public int firstChild()
   {
 
     // Follow rule about returning the first occuring in document order 
@@ -113,12 +114,12 @@
     {
       m_processedRoot = true;
 
-      Node n = m_lpi.getDOMHelper().getRootNode(m_currentNode);
+      int n = getDTM(m_currentNode).getDocument();
 
       return setCurrentIfNotNull(n);
     }
 
-    return null;
+    return DTM.NULL;
   }
 
   /** True if the root node has been processed.   */
diff --git a/src/org/apache/xpath/axes/RootWalkerMultiStep.java b/src/org/apache/xpath/axes/RootWalkerMultiStep.java
index 117a55e..436c0b7 100644
--- a/src/org/apache/xpath/axes/RootWalkerMultiStep.java
+++ b/src/org/apache/xpath/axes/RootWalkerMultiStep.java
@@ -56,8 +56,10 @@
  */
 package org.apache.xpath.axes;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeFilter;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeFilter;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import org.apache.xpath.patterns.NodeTestFilter;
 
@@ -84,7 +86,7 @@
    *
    * @param root The context node of this step.
    */
-  public void setRoot(Node root)
+  public void setRoot(int root)
   {
 
     super.setRoot(root);
@@ -97,42 +99,46 @@
    *
    * @return the next valid child node.
    */
-  protected Node getNextNode()
+  protected int getNextNode()
   {
 
     if (m_isFresh)
       m_isFresh = false;
 
-    Node current = this.getCurrentNode();
+    int current = this.getCurrentNode();
 
-    if (current.isSupported(FEATURE_NODETESTFILTER, "1.0"))
-      ((NodeTestFilter) current).setNodeTest(this);
+    // %NODETESTFILTER%
+//    if (current.isSupported(FEATURE_NODETESTFILTER, "1.0"))
+//      ((NodeTestFilter) current).setNodeTest(this);
 
-    Node next;
+    int next;
 
     if (!m_processedRoot)
     {
       m_processedRoot = true;
-      next = m_lpi.getDOMHelper().getRootNode(m_currentNode);
+      
+      next = getDTM(m_currentNode).getDocument();
     }
     else
-      next = null;
+      next = DTM.NULL;
 
-    if (null != next)
+    if (DTM.NULL != next)
     {
       m_currentNode = next;
 
       // doesn't seem like we need to do this!
-      if (acceptNode(next) != NodeFilter.FILTER_ACCEPT)
+      if (acceptNode(next) != DTMIterator.FILTER_ACCEPT)
       {
-        next = null;
+        next = DTM.NULL;
       }
 
-      if (null == next)
+      if (DTM.NULL == next)
+      {
         m_currentNode = current;  // don't advance the current node.
+        this.m_isDone = true;
+      }
     }
-
-    if (null == next)
+    else
       this.m_isDone = true;
 
     return next;
diff --git a/src/org/apache/xpath/axes/SelfWalker.java b/src/org/apache/xpath/axes/SelfWalker.java
index 3806e92..3c9dc26 100644
--- a/src/org/apache/xpath/axes/SelfWalker.java
+++ b/src/org/apache/xpath/axes/SelfWalker.java
@@ -60,7 +60,8 @@
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
+import org.apache.xml.dtm.DTM;
 
 /**
  * Walker for the 'self' axes.
@@ -88,7 +89,7 @@
    *
    * @param root The context node of this step.
    */
-  public void setRoot(Node root)
+  public void setRoot(int root)
   {
 
     m_processedSelf = false;
@@ -104,7 +105,7 @@
    * @return  The new node, or <code>null</code> if the current node has no
    *   visible children in the TreeWalker's logical view.
    */
-  public Node firstChild()
+  public int firstChild()
   {
 
     // Follow my made-up rule about returning the self node as a child.
@@ -115,7 +116,7 @@
       return setCurrentIfNotNull(m_root);
     }
 
-    return null;
+    return DTM.NULL;
   }
 
   /** True if the self node has been processed.   */
@@ -128,6 +129,6 @@
    */
   protected int getLevelMax()
   {
-    return m_lpi.getDOMHelper().getLevel(m_root);
+    return getDTM(m_root).getLevel(m_root);
   }
 }
diff --git a/src/org/apache/xpath/axes/SelfWalkerOneStep.java b/src/org/apache/xpath/axes/SelfWalkerOneStep.java
index da31247..a96ebef 100644
--- a/src/org/apache/xpath/axes/SelfWalkerOneStep.java
+++ b/src/org/apache/xpath/axes/SelfWalkerOneStep.java
@@ -56,8 +56,10 @@
  */
 package org.apache.xpath.axes;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeFilter;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeFilter;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 /**
  * <meta name="usage" content="advanced"/>
@@ -84,21 +86,21 @@
    *
    * @return The self node or null.
    */
-  public Node nextNode()
+  public int nextNode()
   {
 
     if (m_isFresh)
     {
       m_isFresh = false;
 
-      if (acceptNode(m_root) == NodeFilter.FILTER_ACCEPT)
+      if (acceptNode(m_root) == DTMIterator.FILTER_ACCEPT)
         return m_root;
       else
-        return null;
+        return DTM.NULL;
     }
     else
     {
-      return null;
+      return DTM.NULL;
     }
   }
 }
diff --git a/src/org/apache/xpath/axes/SubContextList.java b/src/org/apache/xpath/axes/SubContextList.java
index 5c02de2..959bf3a 100644
--- a/src/org/apache/xpath/axes/SubContextList.java
+++ b/src/org/apache/xpath/axes/SubContextList.java
@@ -58,8 +58,8 @@
 
 import org.apache.xpath.XPathContext;
 
-import org.w3c.dom.Node;
-
+//import org.w3c.dom.Node;
+ 
 /**
  * <meta name="usage" content="advanced"/>
  * A class that implements this interface is a sub context node list, meaning it
diff --git a/src/org/apache/xpath/axes/UnionPathIterator.java b/src/org/apache/xpath/axes/UnionPathIterator.java
index 3e35083..6799156 100644
--- a/src/org/apache/xpath/axes/UnionPathIterator.java
+++ b/src/org/apache/xpath/axes/UnionPathIterator.java
@@ -59,10 +59,14 @@
 import org.apache.xpath.compiler.OpCodes;
 
 // DOM Imports
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.Node;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.traversal.NodeFilter;
+//import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.DOMException;
+//import org.w3c.dom.traversal.NodeFilter;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMFilter;
+import org.apache.xml.dtm.DTMManager;
 
 // Xalan Imports
 import org.apache.xpath.NodeSet;
@@ -77,14 +81,14 @@
 
 /**
  * <meta name="usage" content="advanced"/>
- * This class extends NodeSet, which implements NodeIterator,
+ * This class extends NodeSet, which implements DTMIterator,
  * and fetches nodes one at a time in document order based on a XPath
  * <a href="http://www.w3.org/TR/xpath#NT-UnionExpr">UnionExpr</a>.
  * As each node is iterated via nextNode(), the node is also stored
  * in the NodeVector, so that previousNode() can easily be done.
  */
 public class UnionPathIterator extends Expression
-        implements Cloneable, NodeIterator, ContextNodeList
+        implements Cloneable, DTMIterator, java.io.Serializable
 {
 
   /**
@@ -136,9 +140,9 @@
   public void detach()
   {
 
-    this.m_context = null;
+    this.m_context = DTM.NULL;
     this.m_execContext = null;
-    this.m_context = null;
+    this.m_context = DTM.NULL;
 
     int n = m_iterators.length;
 
@@ -208,6 +212,17 @@
     else
       m_cachedNodes = null;
   }
+  
+  /**
+   * Tells if this iterator can have nodes added to it or set via 
+   * the <code>setItem(int node, int index)</code> method.
+   * 
+   * @return True if the nodelist can be mutated.
+   */
+  public boolean isMutable()
+  {
+    return (m_cachedNodes != null);
+  }
 
   /**
    * Set the current position in the node set.
@@ -256,11 +271,8 @@
    * iterator backwards in the set.
    * @return  The previous <code>Node</code> in the set being iterated over,
    *   or<code>null</code> if there are no more members in that set.
-   * @throws DOMException
-   *    INVALID_STATE_ERR: Raised if this method is called after the
-   *   <code>detach</code> method was invoked.
    */
-  public Node previousNode() throws DOMException
+  public int previousNode()
   {
 
     if (null == m_cachedNodes)
@@ -273,16 +285,16 @@
   /**
    *  This attribute determines which node types are presented via the
    * iterator. The available set of constants is defined in the
-   * <code>NodeFilter</code> interface.
+   * <code>DTMFilter</code> interface.
    *
-   * @return A bit set that tells what node types to show (NodeFilter.SHOW_ALL at 
+   * @return A bit set that tells what node types to show (DTMFilter.SHOW_ALL at 
    * the iterator level).
    */
   public int getWhatToShow()
   {
 
     // TODO: ??
-    return NodeFilter.SHOW_ALL & ~NodeFilter.SHOW_ENTITY_REFERENCE;
+    return DTMFilter.SHOW_ALL & ~DTMFilter.SHOW_ENTITY_REFERENCE;
   }
 
   /**
@@ -290,7 +302,7 @@
    *
    * @return null.
    */
-  public NodeFilter getFilter()
+  public DTMFilter getFilter()
   {
     return null;
   }
@@ -300,7 +312,7 @@
    *
    * @return The context node of this iterator.
    */
-  public Node getRoot()
+  public int getRoot()
   {
     return m_context;
   }
@@ -379,11 +391,11 @@
    * Get a cloned Iterator that is reset to the beginning 
    * of the query.
    *
-   * @return A cloned NodeIterator set of the start of the query.
+   * @return A cloned DTMIterator set of the start of the query.
    *
    * @throws CloneNotSupportedException
    */
-  public NodeIterator cloneWithReset() throws CloneNotSupportedException
+  public DTMIterator cloneWithReset() throws CloneNotSupportedException
   {
 
     UnionPathIterator clone = (UnionPathIterator) clone();
@@ -427,7 +439,7 @@
     m_foundLast = false;
     m_next = 0;
     m_last = 0;
-    m_lastFetched = null;
+    m_lastFetched = DTM.NULL;
 
     int n = m_iterators.length;
 
@@ -514,35 +526,44 @@
   }
 
   /** The last node that was fetched, usually by nextNode. */
-  transient Node m_lastFetched;
+  transient int m_lastFetched = DTM.NULL;
 
   /**
    *  Returns the next node in the set and advances the position of the
-   * iterator in the set. After a NodeIterator is created, the first call
+   * iterator in the set. After a DTMIterator is created, the first call
    * to nextNode() returns the first node in the set.
    * @return  The next <code>Node</code> in the set being iterated over, or
    *   <code>null</code> if there are no more members in that set.
-   * @throws DOMException
-   *    INVALID_STATE_ERR: Raised if this method is called after the
-   *   <code>detach</code> method was invoked.
    */
-  public Node nextNode() throws DOMException
+  public int nextNode()
   {
 
+//    // If the cache is on, and the node has already been found, then 
+//    // just return from the list.
+//    if ((null != m_cachedNodes)
+//            && (m_cachedNodes.getCurrentPos() < m_cachedNodes.size()))
+//    {
+//      return m_cachedNodes.nextNode();
+//    }
     // If the cache is on, and the node has already been found, then 
     // just return from the list.
     if ((null != m_cachedNodes)
-            && (m_cachedNodes.getCurrentPos() < m_cachedNodes.size()))
+            && (m_next < m_cachedNodes.size()))
     {
-      return m_cachedNodes.nextNode();
+      int next = m_cachedNodes.elementAt(m_next);
+    
+      m_next++;
+      m_currentContextNode = next;
+
+      return next;
     }
 
     if (m_foundLast)
-      return null;
+      return DTM.NULL;
 
     // Loop through the iterators getting the current fetched 
     // node, and get the earliest occuring in document order
-    Node earliestNode = null;
+    int earliestNode = DTM.NULL;
 
     if (null != m_iterators)
     {
@@ -551,18 +572,18 @@
 
       for (int i = 0; i < n; i++)
       {
-        Node node = m_iterators[i].getCurrentNode();
+        int node = m_iterators[i].getCurrentNode();
 
-        if (null == node)
+        if (DTM.NULL == node)
           continue;
-        else if (null == earliestNode)
+        else if (DTM.NULL == earliestNode)
         {
           iteratorUsed = i;
           earliestNode = node;
         }
         else
         {
-          if (node.equals(earliestNode))
+          if (node == earliestNode)
           {
 
             // Found a duplicate, so skip past it.
@@ -570,9 +591,9 @@
           }
           else
           {
-            DOMHelper dh = m_execContext.getDOMHelper();
+            DTM dtm = getDTM(node);
 
-            if (dh.isNodeAfter(node, earliestNode))
+            if (dtm.isNodeAfter(node, earliestNode))
             {
               iteratorUsed = i;
               earliestNode = node;
@@ -581,7 +602,7 @@
         }
       }
 
-      if (null != earliestNode)
+      if (DTM.NULL != earliestNode)
       {
         m_iterators[iteratorUsed].nextNode();
 
@@ -614,9 +635,9 @@
     if (m_foundLast || ((index >= 0) && (index <= m_next)))
       return;
 
-    Node n;
+    int n;
 
-    while (null == (n = nextNode()))
+    while (DTM.NULL == (n = nextNode()))
     {
       if (m_next >= index)
         break;
@@ -636,13 +657,102 @@
   {
     return m_next;
   }
+  
+  /**
+   *  The number of nodes in the list. The range of valid child node indices
+   * is 0 to <code>length-1</code> inclusive.
+   *
+   * @return The number of nodes in the list, always greater or equal to zero.
+   */
+  public int getLength()
+  {
 
+    // %REVIEW% ??
+//    resetToCachedList();
+
+    return m_cachedNodes.getLength();
+  }
+
+  /**
+   *  Returns the <code>index</code> th item in the collection. If
+   * <code>index</code> is greater than or equal to the number of nodes in
+   * the list, this returns <code>null</code> .
+   * @param index  Index into the collection.
+   * @return  The node at the <code>index</code> th position in the
+   *   <code>NodeList</code> , or <code>null</code> if that is not a valid
+   *   index.
+   */
+  public int item(int index)
+  {
+    // resetToCachedList(); %TBD% ??
+
+    return m_cachedNodes.item(index);
+  }
+  
+  /**
+   * Sets the node at the specified index of this vector to be the
+   * specified node. The previous component at that position is discarded.
+   *
+   * <p>The index must be a value greater than or equal to 0 and less
+   * than the current size of the vector.  
+   * The iterator must be in cached mode.</p>
+   * 
+   * <p>Meant to be used for sorted iterators.</p>
+   *
+   * @param node Node to set
+   * @param index Index of where to set the node
+   */
+  public void setItem(int node, int index)
+  {
+    m_cachedNodes.setElementAt(node, index);
+  }
+  
+  /**
+   * Set the current context node for this iterator.
+   *
+   * @param n Must be a non-null reference to the node context.
+   */
+  public final void setRoot(int n)
+  {
+    m_context = n;
+  }
+  
+  /**
+   * Set the environment in which this iterator operates, which should provide:
+   * a node (the context node... same value as "root" defined below) 
+   * a pair of non-zero positive integers (the context position and the context size) 
+   * a set of variable bindings 
+   * a function library 
+   * the set of namespace declarations in scope for the expression.
+   * 
+   * <p>At this time the exact implementation of this environment is application 
+   * dependent.  Probably a proper interface will be created fairly soon.</p>
+   * 
+   * @param environment The environment object.
+   */
+  public void setEnvironment(Object environment)
+  {
+    // no-op for now.
+  }
+  
+  /**
+   * Get an instance of the DTMManager.  Since a node 
+   * iterator may be passed without a DTMManager, this allows the 
+   * caller to easily get the DTMManager using just the iterator.
+   *
+   * @return a non-null DTMManager reference.
+   */
+  public DTMManager getDTMManager()
+  {
+    return m_execContext.getDTMManager();
+  }
+  
   /**
    * Return the last fetched node.
    *
    * @return The last fetched node, or null if the last fetch was null.
    */
-  public Node getCurrentNode()
+  public int getCurrentNode()
   {
     return m_lastFetched;
   }
@@ -660,21 +770,35 @@
   /**
    * The node context for the expression.
    */
-  transient protected Node m_context;
+  transient protected int m_context = DTM.NULL;
 
   /**
    * The node context from where the Location Path is being
    * executed from (i.e. for current() support).
    */
-  transient protected Node m_currentContextNode;
-
+  transient protected int m_currentContextNode = DTM.NULL;
+  
+  /**
+   * Get an instance of a DTM that "owns" a node handle.  Since a node 
+   * iterator may be passed without a DTMManager, this allows the 
+   * caller to easily get the DTM using just the iterator.
+   *
+   * @param nodeHandle the nodeHandle.
+   *
+   * @return a non-null DTM reference.
+   */
+  public DTM getDTM(int nodeHandle)
+  {
+    return m_execContext.getDTM(nodeHandle);
+  }
+  
   /**
    * The node context from where the expression is being
    * executed from (i.e. for current() support).
    *
    * @return The top-level node context of the entire expression.
    */
-  public Node getCurrentContextNode()
+  public int getCurrentContextNode()
   {
     return m_currentContextNode;
   }
diff --git a/src/org/apache/xpath/compiler/Compiler.java b/src/org/apache/xpath/compiler/Compiler.java
index 70d5f45..a5e7f8f 100644
--- a/src/org/apache/xpath/compiler/Compiler.java
+++ b/src/org/apache/xpath/compiler/Compiler.java
@@ -88,11 +88,12 @@
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.SourceLocator;
 import org.apache.xml.utils.SAXSourceLocator;
+import org.apache.xml.dtm.DTMFilter;
 
 import javax.xml.transform.ErrorListener;
 import javax.xml.transform.TransformerException;
 
-import org.w3c.dom.traversal.NodeFilter;
+// import org.w3c.dom.traversal.NodeFilter;
 
 /**
  * <meta name="usage" content="advanced"/>
@@ -774,58 +775,58 @@
     switch (testType)
     {
     case OpCodes.NODETYPE_COMMENT :
-      return NodeFilter.SHOW_COMMENT;
+      return DTMFilter.SHOW_COMMENT;
     case OpCodes.NODETYPE_TEXT :
-//      return NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT;
-      return NodeFilter.SHOW_TEXT | NodeFilter.SHOW_CDATA_SECTION ;
+//      return DTMFilter.SHOW_TEXT | DTMFilter.SHOW_COMMENT;
+      return DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION ;
     case OpCodes.NODETYPE_PI :
-      return NodeFilter.SHOW_PROCESSING_INSTRUCTION;
+      return DTMFilter.SHOW_PROCESSING_INSTRUCTION;
     case OpCodes.NODETYPE_NODE :
-//      return NodeFilter.SHOW_ALL;
+//      return DTMFilter.SHOW_ALL;
       switch (axesType)
       {
       case OpCodes.FROM_NAMESPACE:
-        return NodeFilter.SHOW_ATTRIBUTE | NodeTest.SHOW_NAMESPACE;
+        return DTMFilter.SHOW_ATTRIBUTE | DTMFilter.SHOW_NAMESPACE;
       case OpCodes.FROM_ATTRIBUTES :
       case OpCodes.MATCH_ATTRIBUTE :
-        return NodeFilter.SHOW_ATTRIBUTE;
+        return DTMFilter.SHOW_ATTRIBUTE;
       case OpCodes.FROM_SELF:
       case OpCodes.FROM_ANCESTORS_OR_SELF:
       case OpCodes.FROM_DESCENDANTS_OR_SELF:
-        return NodeFilter.SHOW_ALL;
+        return DTMFilter.SHOW_ALL;
       default:
         if (getOp(0) == OpCodes.OP_MATCHPATTERN)
-          return ~NodeFilter.SHOW_ATTRIBUTE
-                  & ~NodeFilter.SHOW_DOCUMENT
-                  & ~NodeFilter.SHOW_DOCUMENT_FRAGMENT;
+          return ~DTMFilter.SHOW_ATTRIBUTE
+                  & ~DTMFilter.SHOW_DOCUMENT
+                  & ~DTMFilter.SHOW_DOCUMENT_FRAGMENT;
         else
-          return ~NodeFilter.SHOW_ATTRIBUTE;
+          return ~DTMFilter.SHOW_ATTRIBUTE;
       }
     case OpCodes.NODETYPE_ROOT :
-      return NodeFilter.SHOW_DOCUMENT | NodeFilter.SHOW_DOCUMENT_FRAGMENT;
+      return DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT;
     case OpCodes.NODETYPE_FUNCTEST :
       return NodeTest.SHOW_BYFUNCTION;
     case OpCodes.NODENAME :
       switch (axesType)
       {
       case OpCodes.FROM_NAMESPACE :
-        return NodeFilter.SHOW_ATTRIBUTE | NodeTest.SHOW_NAMESPACE;
+        return DTMFilter.SHOW_ATTRIBUTE | DTMFilter.SHOW_NAMESPACE;
       case OpCodes.FROM_ATTRIBUTES :
       case OpCodes.MATCH_ATTRIBUTE :
-        return NodeFilter.SHOW_ATTRIBUTE;
+        return DTMFilter.SHOW_ATTRIBUTE;
 
       // break;
       case OpCodes.MATCH_ANY_ANCESTOR :
       case OpCodes.MATCH_IMMEDIATE_ANCESTOR :
-        return NodeFilter.SHOW_ELEMENT;
+        return DTMFilter.SHOW_ELEMENT;
 
       // break;
       default :
-        return NodeFilter.SHOW_ELEMENT;
+        return DTMFilter.SHOW_ELEMENT;
       }
     default :
       // System.err.println("We should never reach here.");
-      return NodeFilter.SHOW_ALL;
+      return DTMFilter.SHOW_ALL;
     }
   }
 
@@ -869,12 +870,12 @@
     case OpCodes.FROM_ROOT :
       argLen = getArgLengthOfStep(opPos);
       opPos = getFirstChildPosOfStep(opPos);
-      pattern = new StepPattern(NodeFilter.SHOW_DOCUMENT | NodeFilter.SHOW_DOCUMENT_FRAGMENT);
+      pattern = new StepPattern(DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT);
       break;
     case OpCodes.MATCH_ATTRIBUTE :
       argLen = getArgLengthOfStep(opPos);
       opPos = getFirstChildPosOfStep(opPos);
-      pattern = new StepPattern(NodeFilter.SHOW_ATTRIBUTE,
+      pattern = new StepPattern(DTMFilter.SHOW_ATTRIBUTE,
                                 getStepNS(startOpPos),
                                 getStepLocalName(startOpPos));
       break;
diff --git a/src/org/apache/xpath/functions/FuncBoolean.java b/src/org/apache/xpath/functions/FuncBoolean.java
index 8ade614..f2b9c5e 100644
--- a/src/org/apache/xpath/functions/FuncBoolean.java
+++ b/src/org/apache/xpath/functions/FuncBoolean.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncCeiling.java b/src/org/apache/xpath/functions/FuncCeiling.java
index fe711e7..19b2c0d 100644
--- a/src/org/apache/xpath/functions/FuncCeiling.java
+++ b/src/org/apache/xpath/functions/FuncCeiling.java
@@ -58,7 +58,7 @@
 
 import java.lang.Math;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncConcat.java b/src/org/apache/xpath/functions/FuncConcat.java
index 5983cd5..c28e561 100644
--- a/src/org/apache/xpath/functions/FuncConcat.java
+++ b/src/org/apache/xpath/functions/FuncConcat.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncContains.java b/src/org/apache/xpath/functions/FuncContains.java
index c561c4b..7043f7f 100644
--- a/src/org/apache/xpath/functions/FuncContains.java
+++ b/src/org/apache/xpath/functions/FuncContains.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncCount.java b/src/org/apache/xpath/functions/FuncCount.java
index 97c05a4..7ba6982 100644
--- a/src/org/apache/xpath/functions/FuncCount.java
+++ b/src/org/apache/xpath/functions/FuncCount.java
@@ -58,8 +58,10 @@
 
 import org.apache.xpath.res.XPATHErrorResources;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import java.util.Vector;
 
@@ -87,13 +89,13 @@
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
 
-    NodeIterator nl = m_arg0.execute(xctxt).nodeset();
+    DTMIterator nl = m_arg0.execute(xctxt).nodeset();
 
     // We should probably make a function on the iterator for this, 
     // as a given implementation could optimize.
     int i = 0;
 
-    while (null != nl.nextNode())
+    while (DTM.NULL != nl.nextNode())
     {
       i++;
     }
diff --git a/src/org/apache/xpath/functions/FuncCurrent.java b/src/org/apache/xpath/functions/FuncCurrent.java
index ff17453..9100ff4 100644
--- a/src/org/apache/xpath/functions/FuncCurrent.java
+++ b/src/org/apache/xpath/functions/FuncCurrent.java
@@ -58,8 +58,10 @@
 
 import org.apache.xpath.res.XPATHErrorResources;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import java.util.Vector;
 
@@ -79,21 +81,6 @@
 {
 
   /**
-   * Diagnostics to show string output from a node.
-   *
-   * @param n The input node, which may be null.
-   *
-   * @return A diagnostics string representing the node.
-   */
-  protected String nodeToString(Node n)
-  {
-
-    return (null != n)
-           ? n.getNodeName() + "{" + ((org.apache.xalan.stree.Child) n).getUid() + "}"
-           : "null";
-  }
-
-  /**
    * Execute the function.  The function must return
    * a valid object.
    * @param xctxt The current execution context.
@@ -106,7 +93,7 @@
 
     // If we're in a predicate, then this will return non-null.
     PredicatedNodeTest iter = (PredicatedNodeTest) xctxt.getSubContextList();
-    Node currentNode;
+    int currentNode;
 
     if (null != iter)
     {
@@ -116,16 +103,17 @@
     }
     else
     {
-      ContextNodeList cnl = xctxt.getContextNodeList();
+      DTMIterator cnl = xctxt.getContextNodeList();
 
       if (null != cnl)
       {
+        // %REVIEW% Not so certain that this is doing the right thing?
         currentNode = cnl.getCurrentNode();
       }
       else
-        currentNode = null;
+        currentNode = DTM.NULL;
     }
 
-    return new XNodeSet(currentNode);
+    return new XNodeSet(currentNode, xctxt.getDTMManager());
   }
 }
diff --git a/src/org/apache/xpath/functions/FuncDoclocation.java b/src/org/apache/xpath/functions/FuncDoclocation.java
index dd3824e..2abf007 100644
--- a/src/org/apache/xpath/functions/FuncDoclocation.java
+++ b/src/org/apache/xpath/functions/FuncDoclocation.java
@@ -56,9 +56,10 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.Document;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import java.util.Vector;
 
@@ -86,21 +87,24 @@
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
 
-    Node whereNode = getArg0AsNode(xctxt);
+    int whereNode = getArg0AsNode(xctxt);
     String fileLocation = null;
 
-    if (null != whereNode)
+    if (DTM.NULL != whereNode)
     {
-      if (Node.DOCUMENT_FRAGMENT_NODE == whereNode.getNodeType())
+      DTM dtm = xctxt.getDTM(whereNode);
+      
+      // %REVIEW%
+      if (DTM.DOCUMENT_FRAGMENT_NODE ==  dtm.getNodeType(whereNode))
       {
-        whereNode = whereNode.getFirstChild();
+        whereNode = dtm.getFirstChild(whereNode);
       }
 
-      if (null != whereNode)
-      {
-        Document owner = whereNode.getOwnerDocument();
-
-        fileLocation = xctxt.getSourceTreeManager().findURIFromDoc(owner);
+      if (DTM.NULL != whereNode)
+      {        
+        fileLocation = dtm.getDocumentBaseURI();
+//        int owner = dtm.getDocument();
+//        fileLocation = xctxt.getSourceTreeManager().findURIFromDoc(owner);
       }
     }
 
diff --git a/src/org/apache/xpath/functions/FuncExtElementAvailable.java b/src/org/apache/xpath/functions/FuncExtElementAvailable.java
index afef467..a46dd63 100644
--- a/src/org/apache/xpath/functions/FuncExtElementAvailable.java
+++ b/src/org/apache/xpath/functions/FuncExtElementAvailable.java
@@ -62,7 +62,7 @@
 import org.apache.xalan.templates.Constants;
 import org.apache.xalan.transformer.TransformerImpl;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncExtFunction.java b/src/org/apache/xpath/functions/FuncExtFunction.java
index 1557fee..a17ade7 100644
--- a/src/org/apache/xpath/functions/FuncExtFunction.java
+++ b/src/org/apache/xpath/functions/FuncExtFunction.java
@@ -63,7 +63,7 @@
 import org.apache.xpath.objects.*;
 import org.apache.xalan.extensions.ExtensionsTable;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.traversal.NodeIterator;
 
@@ -139,7 +139,7 @@
 
     ExtensionsTable etable = xctxt.getExtensionsTable();
     Object val = etable.extFunction(m_namespace, m_extensionName, argVec,
-                                    m_methodKey, xctxt);
+                                    m_methodKey, xctxt.getExpressionContext());
 
     if (null != val)
     {
@@ -168,17 +168,19 @@
       {
         result = new XNumber(((Double) val).doubleValue());
       }
-      else if (val instanceof DocumentFragment)
+      // %TBD%
+//      else if (val instanceof DocumentFragment)
+//      {
+//        result = new XRTreeFrag((DocumentFragment) val);
+//      }
+//      else if (val instanceof NodeIterator)
+//      {
+//        result = new XNodeSet((NodeIterator) val);
+//      }
+      else if (val instanceof org.w3c.dom.Node)
       {
-        result = new XRTreeFrag((DocumentFragment) val);
-      }
-      else if (val instanceof NodeIterator)
-      {
-        result = new XNodeSet((NodeIterator) val);
-      }
-      else if (val instanceof Node)
-      {
-        result = new XNodeSet((Node) val);
+        result = new XNodeSet(xctxt.getDTMHandleFromNode((org.w3c.dom.Node)val), 
+                              xctxt.getDTMManager());
       }
       else
       {
diff --git a/src/org/apache/xpath/functions/FuncExtFunctionAvailable.java b/src/org/apache/xpath/functions/FuncExtFunctionAvailable.java
index 87364a2..f819961 100644
--- a/src/org/apache/xpath/functions/FuncExtFunctionAvailable.java
+++ b/src/org/apache/xpath/functions/FuncExtFunctionAvailable.java
@@ -60,7 +60,7 @@
 import org.apache.xalan.templates.Constants;
 import org.apache.xalan.extensions.ExtensionsTable;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncFalse.java b/src/org/apache/xpath/functions/FuncFalse.java
index 4597c55..d4b0b0f 100644
--- a/src/org/apache/xpath/functions/FuncFalse.java
+++ b/src/org/apache/xpath/functions/FuncFalse.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncFloor.java b/src/org/apache/xpath/functions/FuncFloor.java
index 1dbe99e..d7dc0e1 100644
--- a/src/org/apache/xpath/functions/FuncFloor.java
+++ b/src/org/apache/xpath/functions/FuncFloor.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncGenerateId.java b/src/org/apache/xpath/functions/FuncGenerateId.java
index 0779090..dbfa412 100644
--- a/src/org/apache/xpath/functions/FuncGenerateId.java
+++ b/src/org/apache/xpath/functions/FuncGenerateId.java
@@ -56,8 +56,9 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
 
 import java.util.Vector;
 
@@ -84,10 +85,10 @@
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
 
-    Node which = getArg0AsNode(xctxt);
+    int which = getArg0AsNode(xctxt);
 
-    if (null != which)
-      return new XString(xctxt.getDOMHelper().getUniqueID(which));
+    if (DTM.NULL != which)
+      return new XString("N" + Integer.toHexString(which+1).toUpperCase());
     else
       return XString.EMPTYSTRING;
   }
diff --git a/src/org/apache/xpath/functions/FuncId.java b/src/org/apache/xpath/functions/FuncId.java
index 8752e66..9efef85 100644
--- a/src/org/apache/xpath/functions/FuncId.java
+++ b/src/org/apache/xpath/functions/FuncId.java
@@ -61,9 +61,10 @@
 
 import org.apache.xpath.res.XPATHErrorResources;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.Document;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import java.util.Vector;
 
@@ -95,7 +96,7 @@
    *
    * @return The usedrefs value.
    */
-  private StringVector getNodesByID(XPathContext xctxt, Document docContext,
+  private StringVector getNodesByID(XPathContext xctxt, int docContext,
                                     String refval, StringVector usedrefs,
                                     NodeSet nodeSet, boolean mayBeMore)
   {
@@ -103,9 +104,10 @@
     if (null != refval)
     {
       String ref = null;
-      DOMHelper dh = xctxt.getDOMHelper();
+//      DOMHelper dh = xctxt.getDOMHelper();
       StringTokenizer tokenizer = new StringTokenizer(refval);
       boolean hasMore = tokenizer.hasMoreTokens();
+      DTM dtm = xctxt.getDTM(docContext);
 
       while (hasMore)
       {
@@ -119,9 +121,9 @@
           continue;
         }
 
-        Node node = dh.getElementByID(ref, docContext);
+        int node = dtm.getElementById(ref);
 
-        if (null != node)
+        if (DTM.NULL != node)
           nodeSet.addNodeInDocOrder(node, xctxt);
 
         if ((null != ref) && (hasMore || mayBeMore))
@@ -148,31 +150,32 @@
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
 
-    Node context = xctxt.getCurrentNode();
-    Document docContext = (Node.DOCUMENT_NODE == context.getNodeType())
-                          ? (Document) context : context.getOwnerDocument();
+    int context = xctxt.getCurrentNode();
+    DTM dtm = xctxt.getDTM(context);
+    int docContext = dtm.getDocument();
 
-    if (null == docContext)
+    if (DTM.NULL == docContext)
       error(xctxt, XPATHErrorResources.ER_CONTEXT_HAS_NO_OWNERDOC, null);
 
     XObject arg = m_arg0.execute(xctxt);
     int argType = arg.getType();
-    XNodeSet nodes = new XNodeSet();
+    XNodeSet nodes = new XNodeSet(xctxt.getDTMManager());
     NodeSet nodeSet = nodes.mutableNodeset();
 
     if (XObject.CLASS_NODESET == argType)
     {
-      NodeIterator ni = arg.nodeset();
+      DTMIterator ni = arg.nodeset();
       StringVector usedrefs = null;
-      Node pos = ni.nextNode();
+      int pos = ni.nextNode();
 
-      while (null != pos)
+      while (DTM.NULL != pos)
       {
-        String refval = DOMHelper.getNodeData(pos);
+        DTM ndtm = ni.getDTM(pos);
+        String refval = ndtm.getStringValue(pos).toString();
 
         pos = ni.nextNode();
         usedrefs = getNodesByID(xctxt, docContext, refval, usedrefs, nodeSet,
-                                null != pos);
+                                DTM.NULL != pos);
       }
       // ni.detach();
     }
diff --git a/src/org/apache/xpath/functions/FuncLang.java b/src/org/apache/xpath/functions/FuncLang.java
index e730976..5e33559 100644
--- a/src/org/apache/xpath/functions/FuncLang.java
+++ b/src/org/apache/xpath/functions/FuncLang.java
@@ -56,8 +56,10 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.Element;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.Element;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import java.util.Vector;
 
@@ -85,17 +87,20 @@
   {
 
     String lang = m_arg0.execute(xctxt).str();
-    Node parent = xctxt.getCurrentNode();
+    int parent = xctxt.getCurrentNode();
     boolean isLang = false;
+    DTM dtm = xctxt.getDTM(parent);
 
-    while (null != parent)
+    while (DTM.NULL != parent)
     {
-      if (Node.ELEMENT_NODE == parent.getNodeType())
+      if (DTM.ELEMENT_NODE == dtm.getNodeType(parent))
       {
-        String langVal = ((Element) parent).getAttribute("xml:lang");
+        int langAttr = dtm.getAttributeNode(parent, "http://www.w3.org/XML/1998/namespace", "lang");
 
-        if ((null != langVal) && (langVal.length() > 0))
+        if (DTM.NULL != langAttr)
         {
+          String langVal = dtm.getNodeValue(langAttr);
+          // %OPT%
           if (langVal.toLowerCase().startsWith(lang.toLowerCase()))
           {
             int valLen = lang.length();
@@ -111,7 +116,7 @@
         }
       }
 
-      parent = xctxt.getDOMHelper().getParentOfNode(parent);
+      parent = dtm.getParent(parent);
     }
 
     return isLang ? XBoolean.S_TRUE : XBoolean.S_FALSE;
diff --git a/src/org/apache/xpath/functions/FuncLast.java b/src/org/apache/xpath/functions/FuncLast.java
index da6cf55..049574e 100644
--- a/src/org/apache/xpath/functions/FuncLast.java
+++ b/src/org/apache/xpath/functions/FuncLast.java
@@ -56,8 +56,10 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.Element;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import java.util.Vector;
 
@@ -93,46 +95,14 @@
     // assert(null != m_contextNodeList, "m_contextNodeList must be non-null");
     // If we're in a predicate, then this will return non-null.
     SubContextList iter = xctxt.getSubContextList();
-
+    // System.out.println("iter: "+iter);
     if (null != iter)
       return iter.getLastPos(xctxt);
 
-    ContextNodeList cnl = xctxt.getContextNodeList();
-
-    if (cnl.size() == 0)
-    {
-      try
-      {
-        NodeIterator ni = (NodeIterator)cnl.clone();
-        int count = cnl.getCurrentPos();
-        while(null != ni.nextNode())
-          count++;
-        cnl.setLast(count);
-        return count;
-      }
-      catch(CloneNotSupportedException cnse){}
-    }
-    return cnl.size();
-
-    /*
-    // The code below has massive problem if inside of a predicate.  -sb
-    if (cnl.size() == 0)
-    {
-      int currentPos = cnl.getCurrentPos();
-
-      // This has problems if inside a predicate.  For now, just clone.
-      if (!cnl.isFresh())
-        cnl.reset();
-
-      cnl.setShouldCacheNodes(true);
-      cnl.runTo(-1);
-      cnl.setCurrentPos(currentPos);
-      System.out.println("cnl.getCurrentPos() after: "+cnl.getCurrentPos());
-    }
-
-    // System.out.println("cnl.size(): "+cnl.size());
-    return cnl.size();
-    */
+    DTMIterator cnl = xctxt.getContextNodeList();
+    int count = cnl.getLength();
+    // System.out.println("count: "+count);    
+    return count;
   }
 
   /**
@@ -145,6 +115,8 @@
    */
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
-    return new XNumber((double) getCountOfContextNodeList(xctxt));
+    XNumber xnum = new XNumber((double) getCountOfContextNodeList(xctxt));
+    // System.out.println("last: "+xnum.num());
+    return xnum;
   }
 }
diff --git a/src/org/apache/xpath/functions/FuncLocalPart.java b/src/org/apache/xpath/functions/FuncLocalPart.java
index 646c097..53803df 100644
--- a/src/org/apache/xpath/functions/FuncLocalPart.java
+++ b/src/org/apache/xpath/functions/FuncLocalPart.java
@@ -58,8 +58,10 @@
 
 import org.apache.xpath.res.XPATHErrorResources;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import java.util.Vector;
 
@@ -86,11 +88,9 @@
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
 
-    Node context = getArg0AsNode(xctxt);
-    
-    String s = (context != null)
-                       ? xctxt.getDOMHelper().getLocalNameOfNode(context)
-                       : "";
+    int context = getArg0AsNode(xctxt);
+    DTM dtm = xctxt.getDTM(context);
+    String s = (context != DTM.NULL) ? dtm.getLocalName(context) : "";
     if(s.startsWith("#") || s.equals("xmlns"))
       s = "";
 
diff --git a/src/org/apache/xpath/functions/FuncNamespace.java b/src/org/apache/xpath/functions/FuncNamespace.java
index 1a64cc1..6a3925f 100644
--- a/src/org/apache/xpath/functions/FuncNamespace.java
+++ b/src/org/apache/xpath/functions/FuncNamespace.java
@@ -58,8 +58,10 @@
 
 import org.apache.xpath.res.XPATHErrorResources;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import java.util.Vector;
 
@@ -86,27 +88,28 @@
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
 
-    Node context = getArg0AsNode(xctxt);
+    int context = getArg0AsNode(xctxt);
     
     String s;
-    if(context != null)
+    if(context != DTM.NULL)
     {
-      int t = context.getNodeType();
-      if(t == Node.ELEMENT_NODE)
+      DTM dtm = xctxt.getDTM(context);
+      int t = dtm.getNodeType(context);
+      if(t == DTM.ELEMENT_NODE)
       {
-        s = xctxt.getDOMHelper().getNamespaceOfNode(context);
+        s = dtm.getNamespaceURI(context);
       }
-      else if(t == Node.ATTRIBUTE_NODE)
+      else if(t == DTM.ATTRIBUTE_NODE)
       {
 
         // This function always returns an empty string for namespace nodes.
         // We check for those here.  Fix inspired by Davanum Srinivas.
 
-        s = context.getNodeName();
+        s = dtm.getNodeName(context);
         if(s.startsWith("xmlns:") || s.equals("xmlns"))
           return XString.EMPTYSTRING;
 
-        s = xctxt.getDOMHelper().getNamespaceOfNode(context);
+        s = dtm.getNamespaceURI(context);
       }
       else
         return XString.EMPTYSTRING;
diff --git a/src/org/apache/xpath/functions/FuncNormalizeSpace.java b/src/org/apache/xpath/functions/FuncNormalizeSpace.java
index 162e0aa..0715035 100644
--- a/src/org/apache/xpath/functions/FuncNormalizeSpace.java
+++ b/src/org/apache/xpath/functions/FuncNormalizeSpace.java
@@ -58,7 +58,7 @@
 
 import org.apache.xpath.res.XPATHErrorResources;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
@@ -67,7 +67,11 @@
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.objects.XString;
 import org.apache.xpath.objects.XNodeSet;
+import org.apache.xpath.objects.XMLStringFactoryImpl;
 import org.apache.xml.utils.XMLCharacterRecognizer;
+import org.apache.xml.utils.XMLString;
+import org.apache.xml.utils.XMLStringFactory;
+import org.apache.xml.utils.FastStringBuffer;
 
 /**
  * <meta name="usage" content="advanced"/>
@@ -87,119 +91,9 @@
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
 
-    String s1 = getArg0AsString(xctxt);
+    XMLString s1 = getArg0AsString(xctxt);
 
-    return new XString(fixWhiteSpace(s1, true, true, false));
+    return (XString)s1.fixWhiteSpace(true, true, false);
   }
 
-  /**
-   * Returns whether the specified <var>ch</var> conforms to the XML 1.0 definition
-   * of whitespace.  Refer to <A href="http://www.w3.org/TR/1998/REC-xml-19980210#NT-S">
-   * the definition of <CODE>S</CODE></A> for details.
-   * @param   ch      Character to check as XML whitespace.
-   * @return          =true if <var>ch</var> is XML whitespace; otherwise =false.
-   */
-  private static boolean isSpace(char ch)
-  {
-    return XMLCharacterRecognizer.isWhiteSpace(ch);  // Take the easy way out for now.
-  }
-
-  /**
-   * (Code stolen and modified from XML4J)
-   * Conditionally trim all leading and trailing whitespace in the specified String.
-   * All strings of white space are
-   * replaced by a single space character (#x20), except spaces after punctuation which
-   * receive double spaces if doublePunctuationSpaces is true.
-   * This function may be useful to a formatter, but to get first class
-   * results, the formatter should probably do it's own white space handling
-   * based on the semantics of the formatting object.
-   * @param   string      String to be trimmed.
-   * @param   trimHead    Trim leading whitespace?
-   * @param   trimTail    Trim trailing whitespace?
-   * @param   doublePunctuationSpaces    Use double spaces for punctuation?
-   * @return              The trimmed string.
-   */
-  protected String fixWhiteSpace(String string, boolean trimHead,
-                                 boolean trimTail,
-                                 boolean doublePunctuationSpaces)
-  {
-
-    char[] buf = string.toCharArray();
-    int len = buf.length;
-    boolean edit = false;
-    int s;
-
-    for (s = 0; s < len; s++)
-    {
-      if (isSpace(buf[s]))
-      {
-        break;
-      }
-    }
-
-    /* replace S to ' '. and ' '+ -> single ' '. */
-    int d = s;
-    boolean pres = false;
-
-    for (; s < len; s++)
-    {
-      char c = buf[s];
-
-      if (isSpace(c))
-      {
-        if (!pres)
-        {
-          if (' ' != c)
-          {
-            edit = true;
-          }
-
-          buf[d++] = ' ';
-
-          if (doublePunctuationSpaces && (s != 0))
-          {
-            char prevChar = buf[s - 1];
-
-            if (!((prevChar == '.') || (prevChar == '!')
-                  || (prevChar == '?')))
-            {
-              pres = true;
-            }
-          }
-          else
-          {
-            pres = true;
-          }
-        }
-        else
-        {
-          edit = true;
-          pres = true;
-        }
-      }
-      else
-      {
-        buf[d++] = c;
-        pres = false;
-      }
-    }
-
-    if (trimTail && 1 <= d && ' ' == buf[d - 1])
-    {
-      edit = true;
-
-      d--;
-    }
-
-    int start = 0;
-
-    if (trimHead && 0 < d && ' ' == buf[0])
-    {
-      edit = true;
-
-      start++;
-    }
-
-    return edit ? new String(buf, start, d - start) : string;
-  }
 }
diff --git a/src/org/apache/xpath/functions/FuncNot.java b/src/org/apache/xpath/functions/FuncNot.java
index c2ba398..9d59600 100644
--- a/src/org/apache/xpath/functions/FuncNot.java
+++ b/src/org/apache/xpath/functions/FuncNot.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncNumber.java b/src/org/apache/xpath/functions/FuncNumber.java
index 12a45c3..dbe9257 100644
--- a/src/org/apache/xpath/functions/FuncNumber.java
+++ b/src/org/apache/xpath/functions/FuncNumber.java
@@ -58,7 +58,7 @@
 
 import org.apache.xpath.res.XPATHErrorResources;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncPosition.java b/src/org/apache/xpath/functions/FuncPosition.java
index 9c436e5..23603e8 100644
--- a/src/org/apache/xpath/functions/FuncPosition.java
+++ b/src/org/apache/xpath/functions/FuncPosition.java
@@ -56,8 +56,10 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import java.util.Vector;
 
@@ -99,11 +101,38 @@
       return prox;
     }
 
-    ContextNodeList cnl = (ContextNodeList) xctxt.getContextNodeList();
+    DTMIterator cnl = xctxt.getContextNodeList();
 
     if (null != cnl)
     {
-
+      int n = cnl.getCurrentNode();
+      if(n == DTM.NULL)
+      {
+        if(cnl.getCurrentPos() == 0)
+          return 0;
+          
+        // Then I think we're in a sort.  See sort21.xsl. So the iterator has 
+        // already been spent, and is not on the node we're processing. 
+        // It's highly possible that this is an issue for other context-list 
+        // functions.  Shouldn't be a problem for last(), and it shouldn't be 
+        // a problem for current().
+        try 
+        { 
+          cnl = cnl.cloneWithReset(); 
+        }
+        catch(CloneNotSupportedException cnse)
+        {
+          throw new org.apache.xml.utils.WrappedRuntimeException(cnse);
+        }
+        int currentNode = xctxt.getContextNode();
+        // System.out.println("currentNode: "+currentNode);
+        while(DTM.NULL != (n = cnl.nextNode()))
+        {
+          if(n == currentNode)
+            break;
+        }
+      }
+      // System.out.println("n: "+n);
       // System.out.println("FuncPosition- cnl.getCurrentPos(): "+cnl.getCurrentPos());
       return cnl.getCurrentPos();
     }
@@ -122,6 +151,8 @@
    */
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
-    return new XNumber((double) getPositionInContextNodeList(xctxt));
+    double pos = (double) getPositionInContextNodeList(xctxt);
+    
+    return new XNumber(pos);
   }
 }
diff --git a/src/org/apache/xpath/functions/FuncQname.java b/src/org/apache/xpath/functions/FuncQname.java
index dbf8446..24edd9c 100644
--- a/src/org/apache/xpath/functions/FuncQname.java
+++ b/src/org/apache/xpath/functions/FuncQname.java
@@ -58,9 +58,11 @@
 
 import org.apache.xpath.res.XPATHErrorResources;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.Attr;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Attr;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import java.util.Vector;
 
@@ -88,41 +90,14 @@
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
 
-    Node context = getArg0AsNode(xctxt);
+    int context = getArg0AsNode(xctxt);
     XObject val;
 
-    if (null != context)
+    if (DTM.NULL != context)
     {
-      short ntype = context.getNodeType();
-
-      if (ntype == Node.ATTRIBUTE_NODE)
-      {
-        String qname = ((Attr) context).getName();
-
-        if (xctxt.getDOMHelper().isNamespaceNode(context))
-        {
-          if (qname.equals("xmlns"))
-            val = XString.EMPTYSTRING;
-          else
-          {
-            qname = QName.getLocalPart(qname);
-            val = (null == qname) ? XString.EMPTYSTRING : new XString(qname);
-          }
-        }
-        else
-          val = new XString(qname);
-      }
-      else if ((ntype == Node.ELEMENT_NODE)
-               || (ntype == Node.PROCESSING_INSTRUCTION_NODE))
-      {
-        String qname = context.getNodeName();
-
-        val = new XString(qname);
-      }
-      else
-      {
-        val = XString.EMPTYSTRING;
-      }
+      DTM dtm = xctxt.getDTM(context);
+      String qname = dtm.getNodeNameX(context);
+      val = (null == qname) ? XString.EMPTYSTRING : new XString(qname);
     }
     else
     {
diff --git a/src/org/apache/xpath/functions/FuncRound.java b/src/org/apache/xpath/functions/FuncRound.java
index 2aa70d0..d1bb54d 100644
--- a/src/org/apache/xpath/functions/FuncRound.java
+++ b/src/org/apache/xpath/functions/FuncRound.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncStartsWith.java b/src/org/apache/xpath/functions/FuncStartsWith.java
index cc811ac..313b1d2 100644
--- a/src/org/apache/xpath/functions/FuncStartsWith.java
+++ b/src/org/apache/xpath/functions/FuncStartsWith.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
@@ -82,7 +82,7 @@
    */
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
-    return m_arg0.execute(xctxt).str().startsWith(m_arg1.execute(xctxt).str())
+    return m_arg0.execute(xctxt).xstr().startsWith(m_arg1.execute(xctxt).xstr())
            ? XBoolean.S_TRUE : XBoolean.S_FALSE;
   }
 }
diff --git a/src/org/apache/xpath/functions/FuncString.java b/src/org/apache/xpath/functions/FuncString.java
index 75e4c8c..3fc8525 100644
--- a/src/org/apache/xpath/functions/FuncString.java
+++ b/src/org/apache/xpath/functions/FuncString.java
@@ -58,7 +58,7 @@
 
 import org.apache.xpath.res.XPATHErrorResources;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
@@ -85,6 +85,6 @@
    */
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
-    return new XString(getArg0AsString(xctxt));
+    return (XString)getArg0AsString(xctxt);
   }
 }
diff --git a/src/org/apache/xpath/functions/FuncStringLength.java b/src/org/apache/xpath/functions/FuncStringLength.java
index e9b8c64..057c1f2 100644
--- a/src/org/apache/xpath/functions/FuncStringLength.java
+++ b/src/org/apache/xpath/functions/FuncStringLength.java
@@ -58,7 +58,7 @@
 
 import org.apache.xpath.res.XPATHErrorResources;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncSubstring.java b/src/org/apache/xpath/functions/FuncSubstring.java
index 330c6a0..b39da38 100644
--- a/src/org/apache/xpath/functions/FuncSubstring.java
+++ b/src/org/apache/xpath/functions/FuncSubstring.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncSubstringAfter.java b/src/org/apache/xpath/functions/FuncSubstringAfter.java
index 49c88d3..cf45316 100644
--- a/src/org/apache/xpath/functions/FuncSubstringAfter.java
+++ b/src/org/apache/xpath/functions/FuncSubstringAfter.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
@@ -65,6 +65,8 @@
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.objects.XString;
 
+import org.apache.xml.utils.XMLString;
+
 /**
  * <meta name="usage" content="advanced"/>
  * Execute the SubstringAfter() function.
@@ -83,12 +85,12 @@
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
 
-    String s1 = m_arg0.execute(xctxt).str();
-    String s2 = m_arg1.execute(xctxt).str();
+    XMLString s1 = m_arg0.execute(xctxt).xstr();
+    XMLString s2 = m_arg1.execute(xctxt).xstr();
     int index = s1.indexOf(s2);
 
     return (-1 == index)
            ? XString.EMPTYSTRING
-           : new XString(s1.substring(index + s2.length()));
+           : (XString)s1.substring(index + s2.length());
   }
 }
diff --git a/src/org/apache/xpath/functions/FuncSubstringBefore.java b/src/org/apache/xpath/functions/FuncSubstringBefore.java
index fab5c8d..94402cb 100644
--- a/src/org/apache/xpath/functions/FuncSubstringBefore.java
+++ b/src/org/apache/xpath/functions/FuncSubstringBefore.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncSum.java b/src/org/apache/xpath/functions/FuncSum.java
index c59c829..be8c87b 100644
--- a/src/org/apache/xpath/functions/FuncSum.java
+++ b/src/org/apache/xpath/functions/FuncSum.java
@@ -56,8 +56,8 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import java.util.Vector;
 
@@ -68,6 +68,8 @@
 import org.apache.xpath.objects.XNumber;
 import org.apache.xpath.objects.XString;
 
+import org.apache.xml.utils.XMLString;
+
 /**
  * <meta name="usage" content="advanced"/>
  * Execute the Sum() function.
@@ -86,16 +88,17 @@
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
 
-    NodeIterator nodes = m_arg0.execute(xctxt).nodeset();
+    DTMIterator nodes = m_arg0.execute(xctxt).nodeset();
     double sum = 0.0;
-    Node pos;
+    int pos;
 
-    while (null != (pos = nodes.nextNode()))
+    while (DTM.NULL != (pos = nodes.nextNode()))
     {
-      String s = DOMHelper.getNodeData(pos);
+      DTM dtm = nodes.getDTM(pos);
+      XMLString s = dtm.getStringValue(pos);
 
       if (null != s)
-        sum += XString.castToNum(s);
+        sum += s.toDouble();
     }
     // nodes.detach();
 
diff --git a/src/org/apache/xpath/functions/FuncSystemProperty.java b/src/org/apache/xpath/functions/FuncSystemProperty.java
index 20b7654..03419db 100644
--- a/src/org/apache/xpath/functions/FuncSystemProperty.java
+++ b/src/org/apache/xpath/functions/FuncSystemProperty.java
@@ -66,7 +66,7 @@
 import org.apache.xml.utils.PrefixResolver;
 import org.apache.xpath.res.XPATHErrorResources;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncTranslate.java b/src/org/apache/xpath/functions/FuncTranslate.java
index 4a2621e..5e8f263 100644
--- a/src/org/apache/xpath/functions/FuncTranslate.java
+++ b/src/org/apache/xpath/functions/FuncTranslate.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncTrue.java b/src/org/apache/xpath/functions/FuncTrue.java
index 7449683..d003aba 100644
--- a/src/org/apache/xpath/functions/FuncTrue.java
+++ b/src/org/apache/xpath/functions/FuncTrue.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FuncUnparsedEntityURI.java b/src/org/apache/xpath/functions/FuncUnparsedEntityURI.java
index 375756a..ff7289e 100644
--- a/src/org/apache/xpath/functions/FuncUnparsedEntityURI.java
+++ b/src/org/apache/xpath/functions/FuncUnparsedEntityURI.java
@@ -58,8 +58,10 @@
 
 import org.apache.xpath.res.XPATHErrorResources;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.Document;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.Element;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import java.util.Vector;
 
@@ -86,10 +88,11 @@
   {
 
     String name = m_arg0.execute(xctxt).str();
-    Node context = xctxt.getCurrentNode();
-    Document doc = (Node.DOCUMENT_NODE == context.getNodeType())
-                   ? ((Document) context) : context.getOwnerDocument();
-    String uri = xctxt.getDOMHelper().getUnparsedEntityURI(name, doc);
+    int context = xctxt.getCurrentNode();
+    DTM dtm = xctxt.getDTM(context);
+    int doc = dtm.getDocument();
+    
+    String uri = dtm.getUnparsedEntityURI(name);
 
     return new XString(uri);
   }
diff --git a/src/org/apache/xpath/functions/Function.java b/src/org/apache/xpath/functions/Function.java
index bac71e3..4eed9dd 100644
--- a/src/org/apache/xpath/functions/Function.java
+++ b/src/org/apache/xpath/functions/Function.java
@@ -56,7 +56,7 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import java.util.Vector;
 
diff --git a/src/org/apache/xpath/functions/FunctionDef1Arg.java b/src/org/apache/xpath/functions/FunctionDef1Arg.java
index c1a9b41..dc7a255 100644
--- a/src/org/apache/xpath/functions/FunctionDef1Arg.java
+++ b/src/org/apache/xpath/functions/FunctionDef1Arg.java
@@ -56,11 +56,16 @@
  */
 package org.apache.xpath.functions;
 
-import org.w3c.dom.Node;
+//import org.w3c.dom.Node;
 
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.objects.XNodeSet;
 import org.apache.xpath.objects.XNumber;
+import org.apache.xpath.objects.XString;
+
+import org.apache.xml.utils.XMLString;
+
+import org.apache.xml.dtm.DTM;
 
 /**
  * <meta name="usage" content="advanced"/>
@@ -82,7 +87,7 @@
    * @throws javax.xml.transform.TransformerException if an error occurs while
    *                                   executing the argument expression.
    */
-  protected Node getArg0AsNode(XPathContext xctxt)
+  protected int getArg0AsNode(XPathContext xctxt)
           throws javax.xml.transform.TransformerException
   {
 
@@ -104,13 +109,23 @@
    * @throws javax.xml.transform.TransformerException if an error occurs while
    *                                   executing the argument expression.
    */
-  protected String getArg0AsString(XPathContext xctxt)
+  protected XMLString getArg0AsString(XPathContext xctxt)
           throws javax.xml.transform.TransformerException
   {
-
-    return (null == m_arg0)
-           ? XNodeSet.getStringFromNode(xctxt.getCurrentNode())
-           : m_arg0.execute(xctxt).str();
+    if(null == m_arg0)
+    {
+      int currentNode = xctxt.getCurrentNode();
+      if(DTM.NULL == currentNode)
+        return XString.EMPTYSTRING;
+      else
+      {
+        DTM dtm = xctxt.getDTM(currentNode);
+        return dtm.getStringValue(currentNode);
+      }
+      
+    }
+    else
+      return m_arg0.execute(xctxt).xstr();   
   }
 
   /**
@@ -130,9 +145,21 @@
           throws javax.xml.transform.TransformerException
   {
 
-    return (null == m_arg0)
-           ? XNodeSet.getNumberFromNode(xctxt.getCurrentNode())
-           : m_arg0.execute(xctxt).num();
+    if(null == m_arg0)
+    {
+      int currentNode = xctxt.getCurrentNode();
+      if(DTM.NULL == currentNode)
+        return 0;
+      else
+      {
+        DTM dtm = xctxt.getDTM(currentNode);
+        XMLString str = dtm.getStringValue(currentNode);
+        return str.toDouble();
+      }
+      
+    }
+    else
+      return m_arg0.execute(xctxt).num();
   }
 
   /**
diff --git a/src/org/apache/xpath/objects/XBoolean.java b/src/org/apache/xpath/objects/XBoolean.java
index dbea0fe..3ab3ac9 100644
--- a/src/org/apache/xpath/objects/XBoolean.java
+++ b/src/org/apache/xpath/objects/XBoolean.java
@@ -166,7 +166,7 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  public boolean equals(XObject obj2) throws javax.xml.transform.TransformerException
+  public boolean equals(XObject obj2)
   {
 
     // In order to handle the 'all' semantics of 
@@ -175,7 +175,14 @@
     if (obj2.getType() == XObject.CLASS_NODESET)
       return obj2.equals(this);
 
-    return m_val == obj2.bool();
+    try
+    {
+      return m_val == obj2.bool();
+    }
+    catch(javax.xml.transform.TransformerException te)
+    {
+      throw new org.apache.xml.utils.WrappedRuntimeException(te);
+    }
   }
 
 }
diff --git a/src/org/apache/xpath/objects/XBooleanStatic.java b/src/org/apache/xpath/objects/XBooleanStatic.java
index f13d6dd..c56898a 100644
--- a/src/org/apache/xpath/objects/XBooleanStatic.java
+++ b/src/org/apache/xpath/objects/XBooleanStatic.java
@@ -95,8 +95,15 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  public boolean equals(XObject obj2) throws javax.xml.transform.TransformerException
+  public boolean equals(XObject obj2)
   {
-    return m_val == obj2.bool();
+    try
+    {
+      return m_val == obj2.bool();
+    }
+    catch(javax.xml.transform.TransformerException te)
+    {
+      throw new org.apache.xml.utils.WrappedRuntimeException(te);
+    }
   }
 }
diff --git a/src/org/apache/xpath/objects/XMLStringFactoryImpl.java b/src/org/apache/xpath/objects/XMLStringFactoryImpl.java
new file mode 100644
index 0000000..bfcd520
--- /dev/null
+++ b/src/org/apache/xpath/objects/XMLStringFactoryImpl.java
@@ -0,0 +1,137 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xpath.objects;
+
+import org.apache.xml.utils.XMLString;
+import org.apache.xml.utils.XMLStringFactory;
+import org.apache.xml.utils.FastStringBuffer;
+
+/**
+ * <meta name="usage" content="internal"/>
+ * Class XMLStringFactoryImpl creates XString versions of XMLStrings.
+ */
+public class XMLStringFactoryImpl extends XMLStringFactory
+{
+  /** The XMLStringFactory to pass to DTM construction.   */
+  private static XMLStringFactory m_xstringfactory =
+    new XMLStringFactoryImpl();
+
+  /**
+   * Get the XMLStringFactory to pass to DTM construction.
+   *
+   *
+   * @return A never-null static reference to a String factory.
+   */
+  public static XMLStringFactory getFactory()
+  {
+    return m_xstringfactory;
+  }
+
+  /**
+   * Create a new XMLString from a Java string.
+   *
+   *
+   * @param string Java String reference, which must be non-null.
+   *
+   * @return An XMLString object that wraps the String reference.
+   */
+  public XMLString newstr(String string)
+  {
+    return new XString(string);
+  }
+
+  /**
+   * Create a XMLString from a FastStringBuffer.
+   *
+   *
+   * @param string FastStringBuffer reference, which must be non-null.
+   * @param start The start position in the array.
+   * @param length The number of characters to read from the array.
+   *
+   * @return An XMLString object that wraps the FastStringBuffer reference.
+   */
+  public XMLString newstr(FastStringBuffer fsb, int start, int length)
+  {
+    return new XStringForFSB(fsb, start, length);
+  }
+  
+  /**
+   * Create a XMLString from a FastStringBuffer.
+   *
+   *
+   * @param string FastStringBuffer reference, which must be non-null.
+   * @param start The start position in the array.
+   * @param length The number of characters to read from the array.
+   *
+   * @return An XMLString object that wraps the FastStringBuffer reference.
+   */
+  public XMLString newstr(char[] string, int start, int length)
+  {
+    return new XStringForChars(string, start, length);
+  }
+  
+  /**
+   * Get a cheap representation of an empty string.
+   * 
+   * @return An non-null reference to an XMLString that represents "".
+   */
+  public XMLString emptystr()
+  {
+    return XString.EMPTYSTRING;
+  }
+
+}
diff --git a/src/org/apache/xpath/objects/XNodeSet.java b/src/org/apache/xpath/objects/XNodeSet.java
index 73598a2..a3f4408 100644
--- a/src/org/apache/xpath/objects/XNodeSet.java
+++ b/src/org/apache/xpath/objects/XNodeSet.java
@@ -56,16 +56,21 @@
  */
 package org.apache.xpath.objects;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.Text;
+//import org.w3c.dom.DocumentFragment;
+//import org.w3c.dom.traversal.NodeIterator;
+
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMManager;
 
 import org.apache.xpath.DOMHelper;
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.NodeSet;
 import org.apache.xpath.axes.ContextNodeList;
 import org.apache.xml.utils.StringVector;
+import org.apache.xml.utils.XMLString;
 
 /**
  * <meta name="usage" content="general"/>
@@ -74,23 +79,32 @@
  */
 public class XNodeSet extends XObject
 {
+  private DTMManager m_dtmMgr;
+  
+  public DTMManager getDTMMgr()
+  {
+    return m_dtmMgr;
+  }
 
   /**
    * Construct a XNodeSet object.
    *
    * @param val Value of the XNodeSet object
    */
-  public XNodeSet(NodeIterator val)
+  public XNodeSet(DTMIterator val)
   {
     super(val);
+    m_dtmMgr = val.getDTMManager();
   }
 
   /**
-   * Construct an empty XNodeSet object.
+   * Construct an empty XNodeSet object.  This is used to create a mutable 
+   * nodeset to which random nodes may be added.
    */
-  public XNodeSet()
+  public XNodeSet(DTMManager dtmMgr)
   {
     super(new NodeSet());
+    m_dtmMgr = dtmMgr;
   }
 
   /**
@@ -98,12 +112,13 @@
    *
    * @param n Node to add to the new XNodeSet object
    */
-  public XNodeSet(Node n)
+  public XNodeSet(int n, DTMManager dtmMgr)
   {
 
     super(new NodeSet());
+    m_dtmMgr = dtmMgr;
 
-    if (null != n)
+    if (DTM.NULL != n)
     {
       ((NodeSet) m_obj).addNode(n);
     }
@@ -137,9 +152,9 @@
    *
    * @return numeric value of the string conversion from a single node.
    */
-  public static double getNumberFromNode(Node n)
+  public double getNumberFromNode(int n)
   {
-    return XString.castToNum(getStringFromNode(n));
+    return m_dtmMgr.getDTM(n).getStringValue(n).toDouble();
   }
 
   /**
@@ -151,10 +166,10 @@
   public double num()
   {
 
-    NodeIterator nl = nodeset();
-    Node node = nl.nextNode();
+    DTMIterator nl = nodeset();
+    int node = nl.nextNode();
 
-    return (node != null) ? getNumberFromNode(node) : Double.NaN;
+    return (node != DTM.NULL) ? getNumberFromNode(node) : Double.NaN;
   }
 
   /**
@@ -164,9 +179,9 @@
    */
   public boolean bool()
   {
-    return (nodeset().nextNode() != null);
+    return (nodeset().nextNode() != DTM.NULL);
   }
-
+  
   /**
    * Get the string conversion from a single node.
    *
@@ -174,25 +189,44 @@
    *
    * @return the string conversion from a single node.
    */
-  public static String getStringFromNode(Node n)
+  public XMLString getStringFromNode(int n)
   {
-
-    switch (n.getNodeType())
+    // %OPT%
+    // I guess we'll have to get a static instance of the DTM manager...
+    if(DTM.NULL != n)
     {
-    case Node.ELEMENT_NODE :
-    case Node.DOCUMENT_NODE :
-      return DOMHelper.getNodeData(n);
-    case Node.CDATA_SECTION_NODE :
-    case Node.TEXT_NODE :
-      return ((Text) n).getData();
-    case Node.COMMENT_NODE :
-    case Node.PROCESSING_INSTRUCTION_NODE :
-    case Node.ATTRIBUTE_NODE :
-      return n.getNodeValue();
-    default :
-      return DOMHelper.getNodeData(n);
+      return m_dtmMgr.getDTM(n).getStringValue(n);
+    }
+    else
+    {
+      return org.apache.xpath.objects.XString.EMPTYSTRING;
     }
   }
+  
+  /**
+   * Cast result object to an XMLString.
+   *
+   * @return The document fragment node data or the empty string. 
+   */
+  public XMLString xstr()
+  {
+    DTMIterator nl = nodeset();
+    int node = nl.nextNode();
+
+    return (node != DTM.NULL) ? getStringFromNode(node) : XString.EMPTYSTRING;
+  }
+  
+  /**
+   * Cast result object to a string.
+   *
+   * @return The string this wraps or the empty string if null
+   */
+  public void appendToFsb(org.apache.xml.utils.FastStringBuffer fsb)
+  {
+    XString xstring = (XString)xstr();
+    xstring.appendToFsb(fsb);
+  }
+
 
   /**
    * Cast result object to a string.
@@ -203,72 +237,61 @@
   public String str()
   {
 
-    NodeIterator nl = nodeset();
-    Node node = nl.nextNode();
+    DTMIterator nl = nodeset();
+    int node = nl.nextNode();
 
-    return (node != null) ? getStringFromNode(node) : "";
+    return (node != DTM.NULL) ? getStringFromNode(node).toString() : "";
   }
 
-  /**
-   * Cast result object to a result tree fragment.
-   *
-   * @param support The XPath context to use for the conversion 
-   *
-   * @return the nodeset as a result tree fragment.
-   */
-  public DocumentFragment rtree(XPathContext support)
-  {
-
-    DocumentFragment frag =
-      support.getDOMHelper().getDOMFactory().createDocumentFragment();
-    NodeIterator nl = nodeset();
-    Node node;
-
-    while (null != (node = nl.nextNode()))
-    {
-      frag.appendChild(node.cloneNode(true));
-    }
-
-    return frag;
-  }
+  // %REVIEW%
+//  /**
+//   * Cast result object to a result tree fragment.
+//   *
+//   * @param support The XPath context to use for the conversion 
+//   *
+//   * @return the nodeset as a result tree fragment.
+//   */
+//  public DTMIterator rtree(XPathContext support)
+//  {
+//    DTM frag = support.createDocumentFragment();
+//
+//    DTMIterator nl = nodeset();
+//    int node;
+//
+//    while (DTM.NULL != (node = nl.nextNode()))
+//    {
+//      frag.appendChild(node, true, true);
+//    }
+//
+//    return support.createDTMIterator(frag.getDocument());
+//  }
   
   /**
    * Cast result object to a nodelist.
    *
    * @return The nodeset as a nodelist
    */
-  public NodeIterator nodeset()
+  public DTMIterator nodeset()
   {
 
     // System.out.println("In XNodeSet.nodeset()");
-    NodeIterator ns = (NodeIterator) m_obj;
+    DTMIterator ns = (DTMIterator) m_obj;
 
-    // System.out.println("Got NodeIterator");
-    if (ns instanceof ContextNodeList)
+    // System.out.println("Is a ContextNodeList: "+ns);
+    if (ns.isFresh())  // bit of a hack...
     {
-
-      // System.out.println("Is a ContextNodeList: "+ns);
-      if (((ContextNodeList) ns).isFresh())  // bit of a hack...
-      {
-        return ns;
-      }
-      else
-      {
-        try
-        {
-          return ((ContextNodeList) ns).cloneWithReset();
-        }
-        catch (CloneNotSupportedException cnse)
-        {
-          throw new RuntimeException(cnse.getMessage());
-        }
-      }
+      return ns;
     }
     else
     {
-
-      // System.out.println("Returning node iterator");
-      return ns;
+      try
+      {
+        return ns.cloneWithReset();
+      }
+      catch (CloneNotSupportedException cnse)
+      {
+        throw new RuntimeException(cnse.getMessage());
+      }
     }
   }
 
@@ -282,7 +305,7 @@
 
     NodeSet mnl;
 
-    if (m_obj instanceof NodeSet)
+    if(m_obj instanceof NodeSet)
     {
       mnl = (NodeSet) m_obj;
     }
@@ -333,6 +356,7 @@
 
     if (XObject.CLASS_NODESET == type)
     {
+      // %OPT% This should be XMLString based instead of string based...
 
       // From http://www.w3.org/TR/xpath: 
       // If both objects to be compared are node-sets, then the comparison 
@@ -345,22 +369,22 @@
       // is true if and only if some node in $x has the string-value 
       // foo; the latter is true if and only if all nodes in $x have 
       // the string-value foo.
-      NodeIterator list1 = nodeset();
-      NodeIterator list2 = ((XNodeSet) obj2).nodeset();
-      Node node1;
-      StringVector node2Strings = null;
+      DTMIterator list1 = nodeset();
+      DTMIterator list2 = ((XNodeSet) obj2).nodeset();
+      int node1;
+      java.util.Vector node2Strings = null;
 
-      while (null != (node1 = list1.nextNode()))
+      while (DTM.NULL != (node1 = list1.nextNode()))
       {
-        String s1 = getStringFromNode(node1);
+        XMLString s1 = getStringFromNode(node1);
 
         if (null == node2Strings)
         {
-          Node node2;
+          int node2;
 
-          while (null != (node2 = list2.nextNode()))
+          while (DTM.NULL != (node2 = list2.nextNode()))
           {
-            String s2 = getStringFromNode(node2);
+            XMLString s2 = getStringFromNode(node2);
 
             if (comparator.compareStrings(s1, s2))
             {
@@ -370,7 +394,7 @@
             }
 
             if (null == node2Strings)
-              node2Strings = new StringVector();
+              node2Strings = new java.util.Vector();
 
             node2Strings.addElement(s2);
           }
@@ -381,7 +405,7 @@
 
           for (int i = 0; i < n; i++)
           {
-            if (comparator.compareStrings(s1, node2Strings.elementAt(i)))
+            if (comparator.compareStrings(s1, (XMLString)node2Strings.elementAt(i)))
             {
               result = true;
 
@@ -415,11 +439,11 @@
       // comparison on the number to be compared and on the result of 
       // converting the string-value of that node to a number using 
       // the number function is true. 
-      NodeIterator list1 = nodeset();
+      DTMIterator list1 = nodeset();
       double num2 = obj2.num();
-      Node node;
+      int node;
 
-      while (null != (node = list1.nextNode()))
+      while (DTM.NULL != (node = list1.nextNode()))
       {
         double num1 = getNumberFromNode(node);
 
@@ -433,45 +457,19 @@
     }
     else if (XObject.CLASS_RTREEFRAG == type)
     {
+      XMLString s2 = obj2.xstr();
+      DTMIterator list1 = nodeset();
+      int node;
 
-      // hmmm... 
-      // Try first to treat it as a number, so that numeric 
-      // comparisons can be done with it.  I suspect this is bogus...
-      double num2 = obj2.num();
-
-      if (!Double.isNaN(num2))
+      while (DTM.NULL != (node = list1.nextNode()))
       {
-        NodeIterator list1 = nodeset();
-        Node node;
+        XMLString s1 = getStringFromNode(node);
 
-        while (null != (node = list1.nextNode()))
+        if (comparator.compareStrings(s1, s2))
         {
-          double num1 = getNumberFromNode(node);
+          result = true;
 
-          if (comparator.compareNumbers(num1, num2))
-          {
-            result = true;
-
-            break;
-          }
-        }
-      }
-      else
-      {
-        String s2 = obj2.str();
-        NodeIterator list1 = nodeset();
-        Node node;
-
-        while (null != (node = list1.nextNode()))
-        {
-          String s1 = getStringFromNode(node);
-
-          if (comparator.compareStrings(s1, s2))
-          {
-            result = true;
-
-            break;
-          }
+          break;
         }
       }
     }
@@ -484,13 +482,13 @@
       // is a node in the node-set such that the result of performing 
       // the comparison on the string-value of the node and the other 
       // string is true. 
-      String s2 = obj2.str();
-      NodeIterator list1 = nodeset();
-      Node node;
+      XMLString s2 = obj2.xstr();
+      DTMIterator list1 = nodeset();
+      int node;
 
-      while (null != (node = list1.nextNode()))
+      while (DTM.NULL != (node = list1.nextNode()))
       {
-        String s1 = getStringFromNode(node);
+        XMLString s1 = getStringFromNode(node);
 
         if (comparator.compareStrings(s1, s2))
         {
@@ -574,9 +572,16 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  public boolean equals(XObject obj2) throws javax.xml.transform.TransformerException
+  public boolean equals(XObject obj2)
   {
-    return compare(obj2, S_EQ);
+    try
+    {
+      return compare(obj2, S_EQ);
+    }
+    catch(javax.xml.transform.TransformerException te)
+    {
+      throw new org.apache.xml.utils.WrappedRuntimeException(te);
+    }
   }
 
   /**
@@ -609,7 +614,7 @@
    *
    * @return Whether the strings are equal or not
    */
-  abstract boolean compareStrings(String s1, String s2);
+  abstract boolean compareStrings(XMLString s1, XMLString s2);
 
   /**
    * Compare two numbers
@@ -638,7 +643,7 @@
    *
    * @return True if s1 is less than s2
    */
-  boolean compareStrings(String s1, String s2)
+  boolean compareStrings(XMLString s1, XMLString s2)
   {
     return s1.compareTo(s2) < 0;
   }
@@ -673,7 +678,7 @@
    *
    * @return true if s1 is less than or equal to s2
    */
-  boolean compareStrings(String s1, String s2)
+  boolean compareStrings(XMLString s1, XMLString s2)
   {
     return s1.compareTo(s2) <= 0;
   }
@@ -708,7 +713,7 @@
    *
    * @return true if s1 is greater than s2
    */
-  boolean compareStrings(String s1, String s2)
+  boolean compareStrings(XMLString s1, XMLString s2)
   {
     return s1.compareTo(s2) > 0;
   }
@@ -743,7 +748,7 @@
    *
    * @return true if s1 is greater than or equal to s2
    */
-  boolean compareStrings(String s1, String s2)
+  boolean compareStrings(XMLString s1, XMLString s2)
   {
     return s1.compareTo(s2) >= 0;
   }
@@ -778,7 +783,7 @@
    *
    * @return true if s1 is equal to s2
    */
-  boolean compareStrings(String s1, String s2)
+  boolean compareStrings(XMLString s1, XMLString s2)
   {
     return s1.equals(s2);
   }
@@ -813,7 +818,7 @@
    *
    * @return true if s1 is not equal to s2
    */
-  boolean compareStrings(String s1, String s2)
+  boolean compareStrings(XMLString s1, XMLString s2)
   {
     return !s1.equals(s2);
   }
diff --git a/src/org/apache/xpath/objects/XNull.java b/src/org/apache/xpath/objects/XNull.java
index 5ce8772..2b7d586 100644
--- a/src/org/apache/xpath/objects/XNull.java
+++ b/src/org/apache/xpath/objects/XNull.java
@@ -56,8 +56,11 @@
  */
 package org.apache.xpath.objects;
 
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.DocumentFragment;
+//import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.DocumentFragment;
+
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.NodeSet;
@@ -137,13 +140,11 @@
    *
    * @return The object as a result tree fragment.
    */
-  public DocumentFragment rtree(XPathContext support)
+  public int rtree(XPathContext support)
   {
-
-    DocumentFragment result =
-      support.getDOMHelper().getDOMFactory().createDocumentFragment();
-
-    return result;
+    // DTM frag = support.createDocumentFragment();
+    // %REVIEW%
+    return DTM.NULL;
   }
 
   /**
@@ -151,7 +152,7 @@
    *
    * @return null
    */
-  public NodeIterator nodeset()
+  public DTMIterator nodeset()
   {
     return null;
   }
diff --git a/src/org/apache/xpath/objects/XNumber.java b/src/org/apache/xpath/objects/XNumber.java
index 343fe3a..e4d7022 100644
--- a/src/org/apache/xpath/objects/XNumber.java
+++ b/src/org/apache/xpath/objects/XNumber.java
@@ -57,6 +57,7 @@
 package org.apache.xpath.objects;
 
 import org.w3c.dom.*;
+import java.math.BigDecimal;
 
 /**
  * <meta name="usage" content="general"/>
@@ -124,6 +125,156 @@
     return (Double.isNaN(m_val) || (m_val == 0.0)) ? false : true;
   }
 
+//  /**
+//   * Cast result object to a string.
+//   *
+//   * @return "NaN" if the number is NaN, Infinity or -Infinity if
+//   * the number is infinite or the string value of the number.
+//   */
+//  private static final int PRECISION = 16;
+//  public String str()
+//  {
+//
+//    if (Double.isNaN(m_val))
+//    {
+//      return "NaN";
+//    }
+//    else if (Double.isInfinite(m_val))
+//    {
+//      if (m_val > 0)
+//        return "Infinity";
+//      else
+//        return "-Infinity";
+//    }
+//
+//    long longVal = (long)m_val;
+//    if ((double)longVal == m_val)
+//      return Long.toString(longVal);
+//
+//
+//    String s = Double.toString(m_val);
+//    int len = s.length();
+//
+//    if (s.charAt(len - 2) == '.' && s.charAt(len - 1) == '0')
+//    {
+//      return s.substring(0, len - 2);
+//    }
+//
+//    int exp = 0;
+//    int e = s.indexOf('E');
+//    if (e != -1)
+//    {
+//      exp = Integer.parseInt(s.substring(e + 1));
+//      s = s.substring(0,e);
+//      len = e;
+//    }
+//
+//    // Calculate Significant Digits:
+//    // look from start of string for first digit
+//    // look from end for last digit
+//    // significant digits = end - start + (0 or 1 depending on decimal location)
+//
+//    int decimalPos = -1;
+//    int start = (s.charAt(0) == '-') ? 1 : 0;
+//    findStart: for( ; start < len; start++ )
+//    {
+//      switch (s.charAt(start))
+//      {
+//      case '0':
+//        break;
+//      case '.':
+//        decimalPos = start;
+//        break;
+//      default:
+//        break findStart;
+//      }
+//    }
+//    int end = s.length() - 1;
+//    findEnd: for( ; end > start; end-- )
+//    {
+//      switch (s.charAt(end))
+//      {
+//      case '0':
+//        break;
+//      case '.':
+//        decimalPos = end;
+//        break;
+//      default:
+//        break findEnd;
+//      }
+//    }
+//
+//    int sigDig = end - start;
+//
+//    // clarify decimal location if it has not yet been found
+//    if (decimalPos == -1)
+//      decimalPos = s.indexOf('.');
+//
+//    // if decimal is not between start and end, add one to sigDig
+//    if (decimalPos < start || decimalPos > end)
+//      ++sigDig;
+//
+//    // reduce significant digits to PRECISION if necessary
+//    if (sigDig > PRECISION)
+//    {
+//      // re-scale BigDecimal in order to get significant digits = PRECISION
+//      BigDecimal num = new BigDecimal(s);
+//      int newScale = num.scale() - (sigDig - PRECISION);
+//      if (newScale < 0)
+//        newScale = 0;
+//      s = num.setScale(newScale, BigDecimal.ROUND_HALF_UP).toString();
+//
+//      // remove trailing '0's; keep track of decimalPos
+//      int truncatePoint = s.length();
+//      while (s.charAt(--truncatePoint) == '0')
+//        ;
+//
+//      if (s.charAt(truncatePoint) == '.')
+//      {
+//        decimalPos = truncatePoint;
+//      }
+//      else
+//      {
+//        decimalPos = s.indexOf('.');
+//        truncatePoint += 1;
+//      }
+//
+//      s = s.substring(0, truncatePoint);
+//      len = s.length();
+//    }
+//
+//    // Account for exponent by adding zeros as needed 
+//    // and moving the decimal place
+//
+//    if (exp == 0)
+//       return s;
+//
+//    start = 0;
+//    String sign;
+//    if (s.charAt(0) == '-')
+//    {
+//      sign = "-";
+//      start++;
+//    }
+//    else
+//      sign = "";
+//
+//    String wholePart = s.substring(start, decimalPos);
+//    String decimalPart = s.substring(decimalPos + 1);
+//
+//    // get the number of digits right of the decimal
+//    int decimalLen = decimalPart.length();
+//
+//    if (exp >= decimalLen)
+//      return sign + wholePart + decimalPart + zeros(exp - decimalLen);
+//
+//    if (exp > 0)
+//      return sign + wholePart + decimalPart.substring(0, exp) + "."
+//             + decimalPart.substring(exp);
+//
+//    return sign + "0." + zeros(-1 - exp) + wholePart + decimalPart;
+//  }
+
   /**
    * Cast result object to a string.
    *
@@ -191,6 +342,7 @@
            + s.substring(2, e);
   }
 
+
   /**
    * Return a string of '0' of the given length
    *
@@ -201,6 +353,8 @@
    */
   static private String zeros(int n)
   {
+    if (n < 1)
+      return "";
 
     char[] buf = new char[n];
 
@@ -232,7 +386,7 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  public boolean equals(XObject obj2) throws javax.xml.transform.TransformerException
+  public boolean equals(XObject obj2)
   {
 
     // In order to handle the 'all' semantics of 
@@ -241,6 +395,13 @@
     if (obj2.getType() == XObject.CLASS_NODESET)
       return obj2.equals(this);
 
-    return m_val == obj2.num();
+    try
+    {
+      return m_val == obj2.num();
+    }
+    catch(javax.xml.transform.TransformerException te)
+    {
+      throw new org.apache.xml.utils.WrappedRuntimeException(te);
+    }
   }
 }
diff --git a/src/org/apache/xpath/objects/XObject.java b/src/org/apache/xpath/objects/XObject.java
index a3197c4..07d5280 100644
--- a/src/org/apache/xpath/objects/XObject.java
+++ b/src/org/apache/xpath/objects/XObject.java
@@ -56,10 +56,13 @@
  */
 package org.apache.xpath.objects;
 
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Text;
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.DocumentFragment;
+//import org.w3c.dom.Text;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 import java.io.Serializable;
 
@@ -69,6 +72,7 @@
 import org.apache.xpath.XPathException;
 import org.apache.xalan.res.XSLMessages;
 import org.apache.xpath.Expression;
+import org.apache.xml.utils.XMLString;
 
 /**
  * <meta name="usage" content="general"/>
@@ -143,17 +147,24 @@
     {
       result = new XNumber(((Double) val).doubleValue());
     }
-    else if (val instanceof DocumentFragment)
+    else if (val instanceof org.w3c.dom.DocumentFragment)
     {
-      result = new XRTreeFrag((DocumentFragment) val);
+      // result = new XRTreeFrag((DocumentFragment) val);
+      // %REVIEW%
+      result = new XObject(val);
     }
-    else if (val instanceof Node)
+    else if (val instanceof org.w3c.dom.traversal.NodeIterator)
     {
-      result = new XNodeSet((Node) val);
+      // result = new XNodeSet((NodeIterator) val);
+      // %REVIEW%
+      result = new XObject(val);
     }
-    else if (val instanceof NodeIterator)
+    else if (val instanceof org.w3c.dom.Node)
     {
-      result = new XNodeSet((NodeIterator) val);
+      // result = new XNodeSet(xctxt.getDTMHandleFromNode((org.w3c.dom.Node)val), 
+      //                      xctxt.getDTMManager());
+      // %REVIEW%
+      result = new XObject(val);
     }
     else
     {
@@ -239,6 +250,16 @@
 
     return false;
   }
+  
+  /**
+   * Cast result object to a string.
+   *
+   * @return The string this wraps or the empty string if null
+   */
+  public XMLString xstr()
+  {
+    return XMLStringFactoryImpl.getFactory().newstr(str());
+  }
 
   /**
    * Cast result object to a string.
@@ -268,20 +289,18 @@
    *
    * @return the objec as a result tree fragment.
    */
-  public DocumentFragment rtree(XPathContext support)
+  public int rtree(XPathContext support)
   {
 
-    DocumentFragment result = rtree();
+    int result = rtree();
 
-    if (null == result)
+    if (DTM.NULL == result)
     {
-      result =
-        support.getDOMHelper().getDOMFactory().createDocumentFragment();
-
-      Text textNode =
-        support.getDOMHelper().getDOMFactory().createTextNode(str());
-
-      result.appendChild(textNode);
+      DTM frag = support.createDocumentFragment();
+      
+      // %OPT%
+      frag.appendTextChild(str());
+      result = frag.getDocument();
     }
 
     return result;
@@ -292,9 +311,9 @@
    *
    * @return null
    */
-  public DocumentFragment rtree()
+  public int rtree()
   {
-    return null;
+    return DTM.NULL;
   }
 
   /**
@@ -315,7 +334,7 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  public NodeIterator nodeset() throws javax.xml.transform.TransformerException
+  public DTMIterator nodeset() throws javax.xml.transform.TransformerException
   {
 
     error(XPATHErrorResources.ER_CANT_CONVERT_TO_NODELIST,
@@ -373,9 +392,10 @@
     case CLASS_UNKNOWN :
       result = m_obj;
       break;
-    case CLASS_RTREEFRAG :
-      result = rtree(support);
-      break;
+      // %TBD%  What to do here?
+//    case CLASS_RTREEFRAG :
+//      result = rtree(support);
+//      break;
     default :
       error(XPATHErrorResources.ER_CANT_CONVERT_TO_TYPE,
             new Object[]{ getTypeString(),
@@ -489,7 +509,7 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  public boolean equals(XObject obj2) throws javax.xml.transform.TransformerException
+  public boolean equals(XObject obj2)
   {
 
     // In order to handle the 'all' semantics of 
@@ -558,4 +578,15 @@
       throw new XPathException(fmsg);
     }
   }
+  
+  /**
+   * Cast result object to a string.
+   *
+   * @return The string this wraps or the empty string if null
+   */
+  public void appendToFsb(org.apache.xml.utils.FastStringBuffer fsb)
+  {
+    fsb.append(str());
+  }
+
 }
diff --git a/src/org/apache/xpath/objects/XRTreeFrag.java b/src/org/apache/xpath/objects/XRTreeFrag.java
index 564fef2..fae99f0 100644
--- a/src/org/apache/xpath/objects/XRTreeFrag.java
+++ b/src/org/apache/xpath/objects/XRTreeFrag.java
@@ -56,11 +56,17 @@
  */
 package org.apache.xpath.objects;
 
-import org.w3c.dom.*;
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.traversal.NodeFilter;
+//import org.w3c.dom.*;
+//import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.traversal.NodeFilter;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMFilter;
+
+import org.apache.xml.utils.XMLString;
 
 import org.apache.xpath.DOMHelper;
+import org.apache.xpath.XPathContext;
 
 /**
  * <meta name="usage" content="general"/>
@@ -69,15 +75,36 @@
  */
 public class XRTreeFrag extends XObject
 {
+  DTM m_dtm;
+  int m_dtmRoot;
+  XPathContext m_xctxt;
 
+//  /**
+//   * Create an XRTreeFrag Object.
+//   *
+//   * @param frag Document fragment this will wrap
+//   */
+//  public XRTreeFrag(DTMIterator frag)
+//  {
+//    super(frag);
+//    
+//    // Obviously, this constructor should be avoided when possible.
+//    m_dtmRoot = frag.cloneWithReset().nextNode();
+//  }
+  
   /**
    * Create an XRTreeFrag Object.
    *
    * @param frag Document fragment this will wrap
    */
-  public XRTreeFrag(DocumentFragment frag)
+  public XRTreeFrag(int root, XPathContext xctxt)
   {
-    super(frag);
+    super(null);
+    
+    // Obviously, this constructor should be avoided when possible.
+    m_dtmRoot = root;
+    m_xctxt = xctxt;
+    m_dtm = xctxt.getDTM(root);
   }
 
   /**
@@ -109,35 +136,11 @@
   public double num()
   {
 
-//    java.text.NumberFormat m_formatter =
-//      java.text.NumberFormat.getNumberInstance();
     double result;
-    String s = DOMHelper.getNodeData((DocumentFragment) m_obj);
+    
+    XMLString s = m_dtm.getStringValue(m_dtmRoot);
 
-    if (null != s)
-    {
-//      try
-//      {
-
-        // result = Double.valueOf(s).doubleValue();
-//        Number n = m_formatter.parse(s.trim());
-//
-//        result = n.doubleValue();
-          result = XString.castToNum(s.trim());
-//      }
-//
-//      // catch(NumberFormatException nfe)
-//      catch (java.text.ParseException nfe)
-//      {
-//        result = Double.NaN;
-//      }
-    }
-    else
-    {
-      result = Double.NaN;
-    }
-
-    return result;
+    return s.toDouble();
   }
 
   /**
@@ -150,6 +153,33 @@
   {
     return true;
   }
+  
+  private XMLString m_xmlStr = null;
+  
+  /**
+   * Cast result object to an XMLString.
+   *
+   * @return The document fragment node data or the empty string. 
+   */
+  public XMLString xstr()
+  {
+    if(null == m_xmlStr)
+      m_xmlStr = m_dtm.getStringValue(m_dtmRoot);
+    
+    return m_xmlStr;
+  }
+  
+  /**
+   * Cast result object to a string.
+   *
+   * @return The string this wraps or the empty string if null
+   */
+  public void appendToFsb(org.apache.xml.utils.FastStringBuffer fsb)
+  {
+    XString xstring = (XString)xstr();
+    xstring.appendToFsb(fsb);
+  }
+
 
   /**
    * Cast result object to a string.
@@ -158,8 +188,7 @@
    */
   public String str()
   {
-
-    String str = DOMHelper.getNodeData((DocumentFragment) m_obj);
+    String str = m_dtm.getStringValue(m_dtmRoot).toString();
 
     return (null == str) ? "" : str;
   }
@@ -169,38 +198,35 @@
    *
    * @return The document fragment this wraps
    */
-  public DocumentFragment rtree()
+  public int rtree()
   {
-    return (DocumentFragment) m_obj;
+    return m_dtmRoot;
   }
 
   /**
-   * Cast result object to a NodeIterator.
+   * Cast result object to a DTMIterator.
    *
-   * @return The document fragment as a NodeIterator
+   * @return The document fragment as a DTMIterator
    */
-  public NodeIterator asNodeIterator()
+  public DTMIterator asNodeIterator()
   {
-
-    if (m_obj instanceof NodeIterator)
-      return (NodeIterator) m_obj;
-    else
-      return new NodeIteratorWrapper(rtree());
+    return m_xctxt.createDTMIterator(m_dtmRoot);
   }
 
-  /**
-   * Cast result object to a nodelist. (special function).
-   *
-   * @return The document fragment as a nodelist
-   */
-  public NodeList convertToNodeset()
-  {
-
-    if (m_obj instanceof NodeList)
-      return (NodeList) m_obj;
-    else
-      return null;
-  }
+  // %TBD%
+//  /**
+//   * Cast result object to a nodelist. (special function).
+//   *
+//   * @return The document fragment as a nodelist
+//   */
+//  public NodeList convertToNodeset()
+//  {
+//
+//    if (m_obj instanceof NodeList)
+//      return (NodeList) m_obj;
+//    else
+//      return null;
+//  }
 
   /**
    * Tell if two objects are functionally equal.
@@ -211,172 +237,50 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  public boolean equals(XObject obj2) throws javax.xml.transform.TransformerException
+  public boolean equals(XObject obj2)
   {
 
-    if (XObject.CLASS_NODESET == obj2.getType())
+    try
     {
-
-      // In order to handle the 'all' semantics of 
-      // nodeset comparisons, we always call the 
-      // nodeset function.
-      return obj2.equals(this);
+      if (XObject.CLASS_NODESET == obj2.getType())
+      {
+  
+        // In order to handle the 'all' semantics of 
+        // nodeset comparisons, we always call the 
+        // nodeset function.
+        return obj2.equals(this);
+      }
+      else if (XObject.CLASS_BOOLEAN == obj2.getType())
+      {
+        return bool() == obj2.bool();
+      }
+      else if (XObject.CLASS_NUMBER == obj2.getType())
+      {
+        return num() == obj2.num();
+      }
+      else if (XObject.CLASS_NODESET == obj2.getType())
+      {
+        return xstr().equals(obj2.xstr());
+      }
+      else if (XObject.CLASS_STRING == obj2.getType())
+      {
+        return xstr().equals(obj2.xstr());
+      }
+      else if (XObject.CLASS_RTREEFRAG == obj2.getType())
+      {
+  
+        // Probably not so good.  Think about this.
+        return xstr().equals(obj2.xstr());
+      }
+      else
+      {
+        return super.equals(obj2);
+      }
     }
-    else if (XObject.CLASS_BOOLEAN == obj2.getType())
+    catch(javax.xml.transform.TransformerException te)
     {
-      return bool() == obj2.bool();
-    }
-    else if (XObject.CLASS_NUMBER == obj2.getType())
-    {
-      return num() == obj2.num();
-    }
-    else if (XObject.CLASS_NODESET == obj2.getType())
-    {
-      return str().equals(obj2.str());
-    }
-    else if (XObject.CLASS_STRING == obj2.getType())
-    {
-      return str().equals(obj2.str());
-    }
-    else if (XObject.CLASS_RTREEFRAG == obj2.getType())
-    {
-
-      // Probably not so good.  Think about this.
-      return str().equals(obj2.str());
-    }
-    else
-    {
-      return super.equals(obj2);
+      throw new org.apache.xml.utils.WrappedRuntimeException(te);
     }
   }
 
-  /**
-   * <meta name="usage" content="internal"/>
-   * Class to wrap a  NodeIterator object
-   */
-  class NodeIteratorWrapper implements NodeIterator
-  {
-
-    /** Position of next node          */
-    private int m_pos = -1;
-
-    /** Document fragment instance this will wrap         */
-    private DocumentFragment m_docFrag;
-
-    /**
-     * Constructor NodeIteratorWrapper
-     *
-     *
-     * @param df Document fragment instance this will wrap
-     */
-    NodeIteratorWrapper(DocumentFragment df)
-    {
-      m_docFrag = df;
-    }
-
-    /**
-     *  The root node of the Iterator, as specified when it was created.
-     *
-     * @return null
-     */
-    public Node getRoot()
-    {
-      return null;
-    }
-
-    /**
-     *  This attribute determines which node types are presented via the
-     * iterator. The available set of constants is defined in the
-     * <code>NodeFilter</code> interface.
-     *
-     * @return All node types
-     */
-    public int getWhatToShow()
-    {
-      return NodeFilter.SHOW_ALL;
-    }
-
-    /**
-     *  The filter used to screen nodes.
-     *
-     * @return null
-     */
-    public NodeFilter getFilter()
-    {
-      return null;
-    }
-
-    /**
-     *  The value of this flag determines whether the children of entity
-     * reference nodes are visible to the iterator. If false, they will be
-     * skipped over.
-     * <br> To produce a view of the document that has entity references
-     * expanded and does not expose the entity reference node itself, use the
-     * whatToShow flags to hide the entity reference node and set
-     * expandEntityReferences to true when creating the iterator. To produce
-     * a view of the document that has entity reference nodes but no entity
-     * expansion, use the whatToShow flags to show the entity reference node
-     * and set expandEntityReferences to false.
-     *
-     * @return true
-     */
-    public boolean getExpandEntityReferences()
-    {
-      return true;
-    }
-
-    /**
-     *  Returns the next node in the set and advances the position of the
-     * iterator in the set. After a NodeIterator is created, the first call
-     * to nextNode() returns the first node in the set.
-     * @return  The next <code>Node</code> in the set being iterated over, or
-     *   <code>null</code> if there are no more members in that set.
-     * @throws DOMException
-     *    INVALID_STATE_ERR: Raised if this method is called after the
-     *   <code>detach</code> method was invoked.
-     */
-    public Node nextNode() throws DOMException
-    {
-
-      if (-1 == m_pos)
-      {
-        m_pos = 0;
-
-        return m_docFrag;
-      }
-      else
-        return null;
-    }
-
-    /**
-     *  Returns the previous node in the set and moves the position of the
-     * iterator backwards in the set.
-     * @return  The previous <code>Node</code> in the set being iterated over,
-     *   or<code>null</code> if there are no more members in that set.
-     * @throws DOMException
-     *    INVALID_STATE_ERR: Raised if this method is called after the
-     *   <code>detach</code> method was invoked.
-     */
-    public Node previousNode() throws DOMException
-    {
-
-      if (0 == m_pos)
-      {
-        m_pos = -1;
-
-        return m_docFrag;
-      }
-      else
-        return null;
-    }
-
-    /**
-     *  Detaches the iterator from the set which it iterated over, releasing
-     * any computational resources and placing the iterator in the INVALID
-     * state. After<code>detach</code> has been invoked, calls to
-     * <code>nextNode</code> or<code>previousNode</code> will raise the
-     * exception INVALID_STATE_ERR.
-     */
-    public void detach(){}
-  }
 }
diff --git a/src/org/apache/xpath/objects/XString.java b/src/org/apache/xpath/objects/XString.java
index 7606caa..281e134 100644
--- a/src/org/apache/xpath/objects/XString.java
+++ b/src/org/apache/xpath/objects/XString.java
@@ -56,22 +56,40 @@
  */
 package org.apache.xpath.objects;
 
-import org.w3c.dom.*;
-
+//import org.w3c.dom.*;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMFilter;
 import org.apache.xpath.XPathContext;
+import org.apache.xml.utils.XMLString;
+import org.apache.xml.utils.XMLStringFactory;
+import org.apache.xml.utils.XMLCharacterRecognizer;
+import org.apache.xml.utils.FastStringBuffer;
+
+import java.util.Locale;
 
 /**
  * <meta name="usage" content="general"/>
  * This class represents an XPath string object, and is capable of
  * converting the string to other types, such as a number.
  */
-public class XString extends XObject
+public class XString extends XObject implements XMLString
 {
 
-  /** Empty string XString object          */
+  /** Empty string XString object */
   public static XString EMPTYSTRING = new XString("");
 
   /**
+   * Construct a XString object.  This constructor exists for derived classes.
+   *
+   * @param val String object this will wrap.
+   */
+  protected XString(Object val)
+  {
+    super(val);
+  }
+
+  /**
    * Construct a XNodeSet object.
    *
    * @param val String object this will wrap.
@@ -103,62 +121,13 @@
   }
 
   /**
-   * Cast a string to a number.
+   * Tell if this object contains a java String object.
    *
-   * @param s The string to convert
-   *
-   * @return 0.0 if the string is null, numeric value of the string
-   * or NaN
+   * @return true if this XMLString can return a string without creating one.
    */
-  public static double castToNum(String s)
+  public boolean hasString()
   {
-
-    double result;
-
-    if (null == s)
-      result = 0.0;
-    else
-    {
-      try
-      {
-
-        /**
-         * TODO: Adjust this for locale. Need to take into
-         * account the lang parameter on the xsl:sort
-         */
-
-        // It seems we can not use this as it just parses the 
-        // start of the string until it finds a non-number char, 
-        // which is not what we want according to the XSLT spec.  
-        // Also, I *think* this is a local-specific
-        // parse, which is also not what we want according to the 
-        // XSLT spec (see below).
-        // NumberFormat formatter = NumberFormat.getNumberInstance();
-        // result = formatter.parse(s.trim()).doubleValue();
-        // The dumb XSLT spec says: "The number function should 
-        // not be used for conversion of numeric data occurring 
-        // in an element in an XML document unless the element 
-        // is of a type that represents numeric data in a 
-        // language-neutral format (which would typically be 
-        // transformed into a language-specific format for 
-        // presentation to a user). In addition, the number 
-        // function cannot be used unless the language-neutral 
-        // format used by the element is consistent with the 
-        // XPath syntax for a Number."
-        // So I guess we need to check, if the default local 
-        // is french, does Double.valueOf use the local specific 
-        // parse?  Or does it use the ieee parse?
-        result = Double.valueOf(s.trim()).doubleValue();
-      }
-
-      // catch (ParseException e) 
-      catch (NumberFormatException nfe)
-      {
-        result = Double.NaN;
-      }
-    }
-
-    return result;
+    return true;
   }
 
   /**
@@ -169,7 +138,107 @@
    */
   public double num()
   {
-    return castToNum((String) m_obj);
+    return toDouble();
+  }
+
+  /**
+   * Convert a string to a double -- Allowed input is in fixed
+   * notation ddd.fff.
+   *
+   * @return A double value representation of the string, or return Double.NaN
+   * if the string can not be converted.
+   */
+  public double toDouble()
+  {
+    int end = length();
+    
+    if(0 == end)
+      return Double.NaN;
+
+    double result = 0.0;
+    int start = 0;
+    int punctPos = end-1;
+
+    // Scan to first whitespace character.
+    for (int i = start; i < end; i++)
+    {
+      char c = charAt(i);
+
+      if (!Character.isSpaceChar(c))
+      {
+        break;
+      }
+      else
+        start++;
+    }
+
+    double sign = 1.0;
+
+    if (start < end && charAt(start) == '-')
+    {
+      sign = -1.0;
+
+      start++;
+    }
+
+    int digitsFound = 0;
+
+    for (int i = start; i < end; i++)  // parse the string from left to right converting the integer part
+    {
+      char c = charAt(i);
+
+      if (c != '.')
+      {
+        if (Character.isSpaceChar(c))
+          break;
+        else if (Character.isDigit(c))
+        {
+          result = result * 10.0 + (c - 0x30);
+
+          digitsFound++;
+        }
+        else
+        {
+          return Double.NaN;
+        }
+      }
+      else
+      {
+        punctPos = i;
+
+        break;
+      }
+    }
+
+    if (charAt(punctPos) == '.')  // parse the string from the end to the '.' converting the fractional part
+    {
+      double fractPart = 0.0;
+
+      for (int i = end - 1; i > punctPos; i--)
+      {
+        char c = charAt(i);
+
+        if (Character.isSpaceChar(c))
+          break;
+        else if (Character.isDigit(c))
+        {
+          fractPart = fractPart / 10.0 + (c - 0x30);
+
+          digitsFound++;
+        }
+        else
+        {
+          return Double.NaN;
+        }
+      }
+
+      result += fractPart / 10.0;
+    }
+
+    if (0 == digitsFound)
+      return Double.NaN;
+
+    return result * sign;
   }
 
   /**
@@ -188,6 +257,16 @@
    *
    * @return The string this wraps or the empty string if null
    */
+  public XMLString xstr()
+  {
+    return this;
+  }
+
+  /**
+   * Cast result object to a string.
+   *
+   * @return The string this wraps or the empty string if null
+   */
   public String str()
   {
     return (null != m_obj) ? ((String) m_obj) : "";
@@ -196,21 +275,111 @@
   /**
    * Cast result object to a result tree fragment.
    *
-   * @param support Xpath context to use for the conversion 
+   * @param support Xpath context to use for the conversion
    *
    * @return A document fragment with this string as a child node
    */
-  public DocumentFragment rtree(XPathContext support)
+  public int rtree(XPathContext support)
   {
 
-    DocumentFragment df =
-      support.getDOMHelper().getDOMFactory().createDocumentFragment();
-    Text textNode =
-      support.getDOMHelper().getDOMFactory().createTextNode(str());
+    DTM frag = support.createDocumentFragment();
 
-    df.appendChild(textNode);
+    frag.appendTextChild(str());
 
-    return df;
+    return frag.getDocument();
+  }
+
+  /**
+   * Directly call the
+   * characters method on the passed ContentHandler for the
+   * string-value. Multiple calls to the
+   * ContentHandler's characters methods may well occur for a single call to
+   * this method.
+   *
+   * @param ch A non-null reference to a ContentHandler.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public void dispatchCharactersEvents(org.xml.sax.ContentHandler ch)
+          throws org.xml.sax.SAXException
+  {
+
+    String str = str();
+
+    ch.characters(str.toCharArray(), 0, str.length());
+  }
+
+  /**
+   * Directly call the
+   * comment method on the passed LexicalHandler for the
+   * string-value.
+   *
+   * @param lh A non-null reference to a LexicalHandler.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public void dispatchAsComment(org.xml.sax.ext.LexicalHandler lh)
+          throws org.xml.sax.SAXException
+  {
+
+    String str = str();
+
+    lh.comment(str.toCharArray(), 0, str.length());
+  }
+
+  /**
+   * Returns the length of this string.
+   *
+   * @return  the length of the sequence of characters represented by this
+   *          object.
+   */
+  public int length()
+  {
+    return str().length();
+  }
+
+  /**
+   * Returns the character at the specified index. An index ranges
+   * from <code>0</code> to <code>length() - 1</code>. The first character
+   * of the sequence is at index <code>0</code>, the next at index
+   * <code>1</code>, and so on, as for array indexing.
+   *
+   * @param      index   the index of the character.
+   * @return     the character at the specified index of this string.
+   *             The first character is at index <code>0</code>.
+   * @exception  IndexOutOfBoundsException  if the <code>index</code>
+   *             argument is negative or not less than the length of this
+   *             string.
+   */
+  public char charAt(int index)
+  {
+    return str().charAt(index);
+  }
+
+  /**
+   * Copies characters from this string into the destination character
+   * array.
+   *
+   * @param      srcBegin   index of the first character in the string
+   *                        to copy.
+   * @param      srcEnd     index after the last character in the string
+   *                        to copy.
+   * @param      dst        the destination array.
+   * @param      dstBegin   the start offset in the destination array.
+   * @exception IndexOutOfBoundsException If any of the following
+   *            is true:
+   *            <ul><li><code>srcBegin</code> is negative.
+   *            <li><code>srcBegin</code> is greater than <code>srcEnd</code>
+   *            <li><code>srcEnd</code> is greater than the length of this
+   *                string
+   *            <li><code>dstBegin</code> is negative
+   *            <li><code>dstBegin+(srcEnd-srcBegin)</code> is larger than
+   *                <code>dst.length</code></ul>
+   * @exception NullPointerException if <code>dst</code> is <code>null</code>
+   */
+  public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin)
+  {
+    str().getChars(srcBegin, srcEnd, dst, dstBegin);
   }
 
   /**
@@ -222,7 +391,7 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  public boolean equals(XObject obj2) throws javax.xml.transform.TransformerException
+  public boolean equals(XObject obj2)
   {
 
     // In order to handle the 'all' semantics of 
@@ -233,4 +402,770 @@
 
     return str().equals(obj2.str());
   }
+
+  /**
+   * Compares this string to the specified object.
+   * The result is <code>true</code> if and only if the argument is not
+   * <code>null</code> and is a <code>String</code> object that represents
+   * the same sequence of characters as this object.
+   *
+   * @param   anObject   the object to compare this <code>String</code>
+   *                     against.
+   *
+   * NEEDSDOC @param obj2
+   * @return  <code>true</code> if the <code>String </code>are equal;
+   *          <code>false</code> otherwise.
+   * @see     java.lang.String#compareTo(java.lang.String)
+   * @see     java.lang.String#equalsIgnoreCase(java.lang.String)
+   */
+  public boolean equals(XMLString obj2)
+  {
+
+    if (!obj2.hasString())
+      return obj2.equals(this);
+    else
+      return str().equals(obj2.toString());
+  }
+
+  /**
+   * Compares this string to the specified object.
+   * The result is <code>true</code> if and only if the argument is not
+   * <code>null</code> and is a <code>String</code> object that represents
+   * the same sequence of characters as this object.
+   *
+   * @param   anObject   the object to compare this <code>String</code>
+   *                     against.
+   *
+   * NEEDSDOC @param obj2
+   * @return  <code>true</code> if the <code>String </code>are equal;
+   *          <code>false</code> otherwise.
+   * @see     java.lang.String#compareTo(java.lang.String)
+   * @see     java.lang.String#equalsIgnoreCase(java.lang.String)
+   */
+  public boolean equals(Object obj2)
+  {
+
+    if (null == obj2)
+      return false;
+
+      // In order to handle the 'all' semantics of 
+      // nodeset comparisons, we always call the 
+      // nodeset function.
+    else if (obj2 instanceof XNodeSet)
+      return obj2.equals(this);
+    else
+      return str().equals(obj2.toString());
+  }
+
+  /**
+   * Compares this <code>String</code> to another <code>String</code>,
+   * ignoring case considerations.  Two strings are considered equal
+   * ignoring case if they are of the same length, and corresponding
+   * characters in the two strings are equal ignoring case.
+   *
+   * @param   anotherString   the <code>String</code> to compare this
+   *                          <code>String</code> against.
+   * @return  <code>true</code> if the argument is not <code>null</code>
+   *          and the <code>String</code>s are equal,
+   *          ignoring case; <code>false</code> otherwise.
+   * @see     #equals(Object)
+   * @see     java.lang.Character#toLowerCase(char)
+   * @see java.lang.Character#toUpperCase(char)
+   */
+  public boolean equalsIgnoreCase(String anotherString)
+  {
+    return str().equalsIgnoreCase(anotherString);
+  }
+
+  /**
+   * Compares two strings lexicographically.
+   *
+   * @param   anotherString   the <code>String</code> to be compared.
+   *
+   * NEEDSDOC @param xstr
+   * @return  the value <code>0</code> if the argument string is equal to
+   *          this string; a value less than <code>0</code> if this string
+   *          is lexicographically less than the string argument; and a
+   *          value greater than <code>0</code> if this string is
+   *          lexicographically greater than the string argument.
+   * @exception java.lang.NullPointerException if <code>anotherString</code>
+   *          is <code>null</code>.
+   */
+  public int compareTo(XMLString xstr)
+  {
+
+    int len1 = this.length();
+    int len2 = xstr.length();
+    int n = Math.min(len1, len2);
+    int i = 0;
+    int j = 0;
+
+    while (n-- != 0)
+    {
+      char c1 = this.charAt(i);
+      char c2 = xstr.charAt(j);
+
+      if (c1 != c2)
+      {
+        return c1 - c2;
+      }
+
+      i++;
+      j++;
+    }
+
+    return len1 - len2;
+  }
+
+  /**
+   * Compares two strings lexicographically, ignoring case considerations.
+   * This method returns an integer whose sign is that of
+   * <code>this.toUpperCase().toLowerCase().compareTo(
+   * str.toUpperCase().toLowerCase())</code>.
+   * <p>
+   * Note that this method does <em>not</em> take locale into account,
+   * and will result in an unsatisfactory ordering for certain locales.
+   * The java.text package provides <em>collators</em> to allow
+   * locale-sensitive ordering.
+   *
+   * @param   str   the <code>String</code> to be compared.
+   * @return  a negative integer, zero, or a positive integer as the
+   *          the specified String is greater than, equal to, or less
+   *          than this String, ignoring case considerations.
+   * @see     java.text.Collator#compare(String, String)
+   * @since   1.2
+   */
+  public int compareToIgnoreCase(XMLString str)
+  {
+    return str().compareToIgnoreCase(str.toString());
+  }
+
+  /**
+   * Tests if this string starts with the specified prefix beginning
+   * a specified index.
+   *
+   * @param   prefix    the prefix.
+   * @param   toffset   where to begin looking in the string.
+   * @return  <code>true</code> if the character sequence represented by the
+   *          argument is a prefix of the substring of this object starting
+   *          at index <code>toffset</code>; <code>false</code> otherwise.
+   *          The result is <code>false</code> if <code>toffset</code> is
+   *          negative or greater than the length of this
+   *          <code>String</code> object; otherwise the result is the same
+   *          as the result of the expression
+   *          <pre>
+   *          this.subString(toffset).startsWith(prefix)
+   *          </pre>
+   * @exception java.lang.NullPointerException if <code>prefix</code> is
+   *          <code>null</code>.
+   */
+  public boolean startsWith(String prefix, int toffset)
+  {
+    return str().startsWith(prefix, toffset);
+  }
+
+  /**
+   * Tests if this string starts with the specified prefix.
+   *
+   * @param   prefix   the prefix.
+   * @return  <code>true</code> if the character sequence represented by the
+   *          argument is a prefix of the character sequence represented by
+   *          this string; <code>false</code> otherwise.
+   *          Note also that <code>true</code> will be returned if the
+   *          argument is an empty string or is equal to this
+   *          <code>String</code> object as determined by the
+   *          {@link #equals(Object)} method.
+   * @exception java.lang.NullPointerException if <code>prefix</code> is
+   *          <code>null</code>.
+   */
+  public boolean startsWith(String prefix)
+  {
+    return startsWith(prefix, 0);
+  }
+
+  /**
+   * Tests if this string starts with the specified prefix beginning
+   * a specified index.
+   *
+   * @param   prefix    the prefix.
+   * @param   toffset   where to begin looking in the string.
+   * @return  <code>true</code> if the character sequence represented by the
+   *          argument is a prefix of the substring of this object starting
+   *          at index <code>toffset</code>; <code>false</code> otherwise.
+   *          The result is <code>false</code> if <code>toffset</code> is
+   *          negative or greater than the length of this
+   *          <code>String</code> object; otherwise the result is the same
+   *          as the result of the expression
+   *          <pre>
+   *          this.subString(toffset).startsWith(prefix)
+   *          </pre>
+   * @exception java.lang.NullPointerException if <code>prefix</code> is
+   *          <code>null</code>.
+   */
+  public boolean startsWith(XMLString prefix, int toffset)
+  {
+
+    int to = toffset;
+    int tlim = this.length();
+    int po = 0;
+    int pc = prefix.length();
+
+    // Note: toffset might be near -1>>>1.
+    if ((toffset < 0) || (toffset > tlim - pc))
+    {
+      return false;
+    }
+
+    while (--pc >= 0)
+    {
+      if (this.charAt(to) != prefix.charAt(po))
+      {
+        return false;
+      }
+
+      to++;
+      po++;
+    }
+
+    return true;
+  }
+
+  /**
+   * Tests if this string starts with the specified prefix.
+   *
+   * @param   prefix   the prefix.
+   * @return  <code>true</code> if the character sequence represented by the
+   *          argument is a prefix of the character sequence represented by
+   *          this string; <code>false</code> otherwise.
+   *          Note also that <code>true</code> will be returned if the
+   *          argument is an empty string or is equal to this
+   *          <code>String</code> object as determined by the
+   *          {@link #equals(Object)} method.
+   * @exception java.lang.NullPointerException if <code>prefix</code> is
+   *          <code>null</code>.
+   */
+  public boolean startsWith(XMLString prefix)
+  {
+    return startsWith(prefix, 0);
+  }
+
+  /**
+   * Tests if this string ends with the specified suffix.
+   *
+   * @param   suffix   the suffix.
+   * @return  <code>true</code> if the character sequence represented by the
+   *          argument is a suffix of the character sequence represented by
+   *          this object; <code>false</code> otherwise. Note that the
+   *          result will be <code>true</code> if the argument is the
+   *          empty string or is equal to this <code>String</code> object
+   *          as determined by the {@link #equals(Object)} method.
+   * @exception java.lang.NullPointerException if <code>suffix</code> is
+   *          <code>null</code>.
+   */
+  public boolean endsWith(String suffix)
+  {
+    return str().endsWith(suffix);
+  }
+
+  /**
+   * Returns a hashcode for this string. The hashcode for a
+   * <code>String</code> object is computed as
+   * <blockquote><pre>
+   * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
+   * </pre></blockquote>
+   * using <code>int</code> arithmetic, where <code>s[i]</code> is the
+   * <i>i</i>th character of the string, <code>n</code> is the length of
+   * the string, and <code>^</code> indicates exponentiation.
+   * (The hash value of the empty string is zero.)
+   *
+   * @return  a hash code value for this object.
+   */
+  public int hashCode()
+  {
+    return str().hashCode();
+  }
+
+  /**
+   * Returns the index within this string of the first occurrence of the
+   * specified character. If a character with value <code>ch</code> occurs
+   * in the character sequence represented by this <code>String</code>
+   * object, then the index of the first such occurrence is returned --
+   * that is, the smallest value <i>k</i> such that:
+   * <blockquote><pre>
+   * this.charAt(<i>k</i>) == ch
+   * </pre></blockquote>
+   * is <code>true</code>. If no such character occurs in this string,
+   * then <code>-1</code> is returned.
+   *
+   * @param   ch   a character.
+   * @return  the index of the first occurrence of the character in the
+   *          character sequence represented by this object, or
+   *          <code>-1</code> if the character does not occur.
+   */
+  public int indexOf(int ch)
+  {
+    return str().indexOf(ch);
+  }
+
+  /**
+   * Returns the index within this string of the first occurrence of the
+   * specified character, starting the search at the specified index.
+   * <p>
+   * If a character with value <code>ch</code> occurs in the character
+   * sequence represented by this <code>String</code> object at an index
+   * no smaller than <code>fromIndex</code>, then the index of the first
+   * such occurrence is returned--that is, the smallest value <i>k</i>
+   * such that:
+   * <blockquote><pre>
+   * (this.charAt(<i>k</i>) == ch) && (<i>k</i> >= fromIndex)
+   * </pre></blockquote>
+   * is true. If no such character occurs in this string at or after
+   * position <code>fromIndex</code>, then <code>-1</code> is returned.
+   * <p>
+   * There is no restriction on the value of <code>fromIndex</code>. If it
+   * is negative, it has the same effect as if it were zero: this entire
+   * string may be searched. If it is greater than the length of this
+   * string, it has the same effect as if it were equal to the length of
+   * this string: <code>-1</code> is returned.
+   *
+   * @param   ch          a character.
+   * @param   fromIndex   the index to start the search from.
+   * @return  the index of the first occurrence of the character in the
+   *          character sequence represented by this object that is greater
+   *          than or equal to <code>fromIndex</code>, or <code>-1</code>
+   *          if the character does not occur.
+   */
+  public int indexOf(int ch, int fromIndex)
+  {
+    return str().indexOf(ch, fromIndex);
+  }
+
+  /**
+   * Returns the index within this string of the last occurrence of the
+   * specified character. That is, the index returned is the largest
+   * value <i>k</i> such that:
+   * <blockquote><pre>
+   * this.charAt(<i>k</i>) == ch
+   * </pre></blockquote>
+   * is true.
+   * The String is searched backwards starting at the last character.
+   *
+   * @param   ch   a character.
+   * @return  the index of the last occurrence of the character in the
+   *          character sequence represented by this object, or
+   *          <code>-1</code> if the character does not occur.
+   */
+  public int lastIndexOf(int ch)
+  {
+    return str().lastIndexOf(ch);
+  }
+
+  /**
+   * Returns the index within this string of the last occurrence of the
+   * specified character, searching backward starting at the specified
+   * index. That is, the index returned is the largest value <i>k</i>
+   * such that:
+   * <blockquote><pre>
+   * this.charAt(k) == ch) && (k <= fromIndex)
+   * </pre></blockquote>
+   * is true.
+   *
+   * @param   ch          a character.
+   * @param   fromIndex   the index to start the search from. There is no
+   *          restriction on the value of <code>fromIndex</code>. If it is
+   *          greater than or equal to the length of this string, it has
+   *          the same effect as if it were equal to one less than the
+   *          length of this string: this entire string may be searched.
+   *          If it is negative, it has the same effect as if it were -1:
+   *          -1 is returned.
+   * @return  the index of the last occurrence of the character in the
+   *          character sequence represented by this object that is less
+   *          than or equal to <code>fromIndex</code>, or <code>-1</code>
+   *          if the character does not occur before that point.
+   */
+  public int lastIndexOf(int ch, int fromIndex)
+  {
+    return str().lastIndexOf(ch, fromIndex);
+  }
+
+  /**
+   * Returns the index within this string of the first occurrence of the
+   * specified substring. The integer returned is the smallest value
+   * <i>k</i> such that:
+   * <blockquote><pre>
+   * this.startsWith(str, <i>k</i>)
+   * </pre></blockquote>
+   * is <code>true</code>.
+   *
+   * @param   str   any string.
+   * @return  if the string argument occurs as a substring within this
+   *          object, then the index of the first character of the first
+   *          such substring is returned; if it does not occur as a
+   *          substring, <code>-1</code> is returned.
+   * @exception java.lang.NullPointerException if <code>str</code> is
+   *          <code>null</code>.
+   */
+  public int indexOf(String str)
+  {
+    return str().indexOf(str);
+  }
+
+  /**
+   * Returns the index within this string of the first occurrence of the
+   * specified substring. The integer returned is the smallest value
+   * <i>k</i> such that:
+   * <blockquote><pre>
+   * this.startsWith(str, <i>k</i>)
+   * </pre></blockquote>
+   * is <code>true</code>.
+   *
+   * @param   str   any string.
+   * @return  if the string argument occurs as a substring within this
+   *          object, then the index of the first character of the first
+   *          such substring is returned; if it does not occur as a
+   *          substring, <code>-1</code> is returned.
+   * @exception java.lang.NullPointerException if <code>str</code> is
+   *          <code>null</code>.
+   */
+  public int indexOf(XMLString str)
+  {
+    return str().indexOf(str.toString());
+  }
+
+  /**
+   * Returns the index within this string of the first occurrence of the
+   * specified substring, starting at the specified index. The integer
+   * returned is the smallest value <i>k</i> such that:
+   * <blockquote><pre>
+   * this.startsWith(str, <i>k</i>) && (<i>k</i> >= fromIndex)
+   * </pre></blockquote>
+   * is <code>true</code>.
+   * <p>
+   * There is no restriction on the value of <code>fromIndex</code>. If
+   * it is negative, it has the same effect as if it were zero: this entire
+   * string may be searched. If it is greater than the length of this
+   * string, it has the same effect as if it were equal to the length of
+   * this string: <code>-1</code> is returned.
+   *
+   * @param   str         the substring to search for.
+   * @param   fromIndex   the index to start the search from.
+   * @return  If the string argument occurs as a substring within this
+   *          object at a starting index no smaller than
+   *          <code>fromIndex</code>, then the index of the first character
+   *          of the first such substring is returned. If it does not occur
+   *          as a substring starting at <code>fromIndex</code> or beyond,
+   *          <code>-1</code> is returned.
+   * @exception java.lang.NullPointerException if <code>str</code> is
+   *          <code>null</code>
+   */
+  public int indexOf(String str, int fromIndex)
+  {
+    return str().indexOf(str, fromIndex);
+  }
+
+  /**
+   * Returns the index within this string of the rightmost occurrence
+   * of the specified substring.  The rightmost empty string "" is
+   * considered to occur at the index value <code>this.length()</code>.
+   * The returned index is the largest value <i>k</i> such that
+   * <blockquote><pre>
+   * this.startsWith(str, k)
+   * </pre></blockquote>
+   * is true.
+   *
+   * @param   str   the substring to search for.
+   * @return  if the string argument occurs one or more times as a substring
+   *          within this object, then the index of the first character of
+   *          the last such substring is returned. If it does not occur as
+   *          a substring, <code>-1</code> is returned.
+   * @exception java.lang.NullPointerException  if <code>str</code> is
+   *          <code>null</code>.
+   */
+  public int lastIndexOf(String str)
+  {
+    return str().lastIndexOf(str);
+  }
+
+  /**
+   * Returns the index within this string of the last occurrence of
+   * the specified substring.
+   *
+   * @param   str         the substring to search for.
+   * @param   fromIndex   the index to start the search from. There is no
+   *          restriction on the value of fromIndex. If it is greater than
+   *          the length of this string, it has the same effect as if it
+   *          were equal to the length of this string: this entire string
+   *          may be searched. If it is negative, it has the same effect
+   *          as if it were -1: -1 is returned.
+   * @return  If the string argument occurs one or more times as a substring
+   *          within this object at a starting index no greater than
+   *          <code>fromIndex</code>, then the index of the first character of
+   *          the last such substring is returned. If it does not occur as a
+   *          substring starting at <code>fromIndex</code> or earlier,
+   *          <code>-1</code> is returned.
+   * @exception java.lang.NullPointerException if <code>str</code> is
+   *          <code>null</code>.
+   */
+  public int lastIndexOf(String str, int fromIndex)
+  {
+    return str().lastIndexOf(str, fromIndex);
+  }
+
+  /**
+   * Returns a new string that is a substring of this string. The
+   * substring begins with the character at the specified index and
+   * extends to the end of this string. <p>
+   * Examples:
+   * <blockquote><pre>
+   * "unhappy".substring(2) returns "happy"
+   * "Harbison".substring(3) returns "bison"
+   * "emptiness".substring(9) returns "" (an empty string)
+   * </pre></blockquote>
+   *
+   * @param      beginIndex   the beginning index, inclusive.
+   * @return     the specified substring.
+   * @exception  IndexOutOfBoundsException  if
+   *             <code>beginIndex</code> is negative or larger than the
+   *             length of this <code>String</code> object.
+   */
+  public XMLString substring(int beginIndex)
+  {
+    return new XString(str().substring(beginIndex));
+  }
+
+  /**
+   * Returns a new string that is a substring of this string. The
+   * substring begins at the specified <code>beginIndex</code> and
+   * extends to the character at index <code>endIndex - 1</code>.
+   * Thus the length of the substring is <code>endIndex-beginIndex</code>.
+   *
+   * @param      beginIndex   the beginning index, inclusive.
+   * @param      endIndex     the ending index, exclusive.
+   * @return     the specified substring.
+   * @exception  IndexOutOfBoundsException  if the
+   *             <code>beginIndex</code> is negative, or
+   *             <code>endIndex</code> is larger than the length of
+   *             this <code>String</code> object, or
+   *             <code>beginIndex</code> is larger than
+   *             <code>endIndex</code>.
+   */
+  public XMLString substring(int beginIndex, int endIndex)
+  {
+    return new XString(str().substring(beginIndex, endIndex));
+  }
+
+  /**
+   * Concatenates the specified string to the end of this string.
+   *
+   * @param   str   the <code>String</code> that is concatenated to the end
+   *                of this <code>String</code>.
+   * @return  a string that represents the concatenation of this object's
+   *          characters followed by the string argument's characters.
+   * @exception java.lang.NullPointerException if <code>str</code> is
+   *          <code>null</code>.
+   */
+  public XMLString concat(String str)
+  {
+
+    // %REVIEW% Make an FSB here?
+    return new XString(str().concat(str));
+  }
+
+  /**
+   * Converts all of the characters in this <code>String</code> to lower
+   * case using the rules of the given <code>Locale</code>.
+   *
+   * @param locale use the case transformation rules for this locale
+   * @return the String, converted to lowercase.
+   * @see     java.lang.Character#toLowerCase(char)
+   * @see     java.lang.String#toUpperCase(Locale)
+   */
+  public XMLString toLowerCase(Locale locale)
+  {
+    return new XString(str().toLowerCase(locale));
+  }
+
+  /**
+   * Converts all of the characters in this <code>String</code> to lower
+   * case using the rules of the default locale, which is returned
+   * by <code>Locale.getDefault</code>.
+   * <p>
+   *
+   * @return  the string, converted to lowercase.
+   * @see     java.lang.Character#toLowerCase(char)
+   * @see     java.lang.String#toLowerCase(Locale)
+   */
+  public XMLString toLowerCase()
+  {
+    return new XString(str().toLowerCase());
+  }
+
+  /**
+   * Converts all of the characters in this <code>String</code> to upper
+   * case using the rules of the given locale.
+   * @param locale use the case transformation rules for this locale
+   * @return the String, converted to uppercase.
+   * @see     java.lang.Character#toUpperCase(char)
+   * @see     java.lang.String#toLowerCase(Locale)
+   */
+  public XMLString toUpperCase(Locale locale)
+  {
+    return new XString(str().toUpperCase(locale));
+  }
+
+  /**
+   * Converts all of the characters in this <code>String</code> to upper
+   * case using the rules of the default locale, which is returned
+   * by <code>Locale.getDefault</code>.
+   *
+   * <p>
+   * If no character in this string has a different uppercase version,
+   * based on calling the <code>toUpperCase</code> method defined by
+   * <code>Character</code>, then the original string is returned.
+   * <p>
+   * Otherwise, this method creates a new <code>String</code> object
+   * representing a character sequence identical in length to the
+   * character sequence represented by this <code>String</code> object and
+   * with every character equal to the result of applying the method
+   * <code>Character.toUpperCase</code> to the corresponding character of
+   * this <code>String</code> object. <p>
+   * Examples:
+   * <blockquote><pre>
+   * "Fahrvergnügen".toUpperCase() returns "FAHRVERGNÜGEN"
+   * "Visit Ljubinje!".toUpperCase() returns "VISIT LJUBINJE!"
+   * </pre></blockquote>
+   *
+   * @return  the string, converted to uppercase.
+   * @see     java.lang.Character#toUpperCase(char)
+   * @see     java.lang.String#toUpperCase(Locale)
+   */
+  public XMLString toUpperCase()
+  {
+    return new XString(str().toUpperCase());
+  }
+
+  /**
+   * Removes white space from both ends of this string.
+   *
+   * @return  this string, with white space removed from the front and end.
+   */
+  public XMLString trim()
+  {
+    return new XString(str().trim());
+  }
+
+  /**
+   * Returns whether the specified <var>ch</var> conforms to the XML 1.0 definition
+   * of whitespace.  Refer to <A href="http://www.w3.org/TR/1998/REC-xml-19980210#NT-S">
+   * the definition of <CODE>S</CODE></A> for details.
+   * @param   ch      Character to check as XML whitespace.
+   * @return          =true if <var>ch</var> is XML whitespace; otherwise =false.
+   */
+  private static boolean isSpace(char ch)
+  {
+    return XMLCharacterRecognizer.isWhiteSpace(ch);  // Take the easy way out for now.
+  }
+
+  /**
+   * Conditionally trim all leading and trailing whitespace in the specified String.
+   * All strings of white space are
+   * replaced by a single space character (#x20), except spaces after punctuation which
+   * receive double spaces if doublePunctuationSpaces is true.
+   * This function may be useful to a formatter, but to get first class
+   * results, the formatter should probably do it's own white space handling
+   * based on the semantics of the formatting object.
+   *
+   * @param   trimHead    Trim leading whitespace?
+   * @param   trimTail    Trim trailing whitespace?
+   * @param   doublePunctuationSpaces    Use double spaces for punctuation?
+   * @return              The trimmed string.
+   */
+  public XMLString fixWhiteSpace(boolean trimHead, boolean trimTail,
+                                 boolean doublePunctuationSpaces)
+  {
+
+    // %OPT% !!!!!!!
+    int len = this.length();
+    char[] buf = new char[len];
+
+    this.getChars(0, len, buf, 0);
+
+    boolean edit = false;
+    int s;
+
+    for (s = 0; s < len; s++)
+    {
+      if (isSpace(buf[s]))
+      {
+        break;
+      }
+    }
+
+    /* replace S to ' '. and ' '+ -> single ' '. */
+    int d = s;
+    boolean pres = false;
+
+    for (; s < len; s++)
+    {
+      char c = buf[s];
+
+      if (isSpace(c))
+      {
+        if (!pres)
+        {
+          if (' ' != c)
+          {
+            edit = true;
+          }
+
+          buf[d++] = ' ';
+
+          if (doublePunctuationSpaces && (s != 0))
+          {
+            char prevChar = buf[s - 1];
+
+            if (!((prevChar == '.') || (prevChar == '!')
+                  || (prevChar == '?')))
+            {
+              pres = true;
+            }
+          }
+          else
+          {
+            pres = true;
+          }
+        }
+        else
+        {
+          edit = true;
+          pres = true;
+        }
+      }
+      else
+      {
+        buf[d++] = c;
+        pres = false;
+      }
+    }
+
+    if (trimTail && 1 <= d && ' ' == buf[d - 1])
+    {
+      edit = true;
+
+      d--;
+    }
+
+    int start = 0;
+
+    if (trimHead && 0 < d && ' ' == buf[0])
+    {
+      edit = true;
+
+      start++;
+    }
+
+    XMLStringFactory xsf = XMLStringFactoryImpl.getFactory();
+
+    return edit ? xsf.newstr(new String(buf, start, d - start)) : this;
+  }
 }
diff --git a/src/org/apache/xpath/objects/XStringForChars.java b/src/org/apache/xpath/objects/XStringForChars.java
new file mode 100644
index 0000000..bcd8e8f
--- /dev/null
+++ b/src/org/apache/xpath/objects/XStringForChars.java
@@ -0,0 +1,185 @@
+package org.apache.xpath.objects;
+
+import org.apache.xml.utils.FastStringBuffer;
+import org.apache.xml.utils.XMLString;
+import org.apache.xml.utils.XMLStringFactory;
+import org.apache.xml.utils.XMLCharacterRecognizer;
+import java.util.Locale;
+
+
+/**
+ * This class will wrap a FastStringBuffer and allow for
+ */
+public class XStringForChars extends XString
+{
+  /** The start position in the fsb. */
+  int m_start;
+  
+  /** The length of the string. */
+  int m_length;
+  
+  protected String m_strCache = null;
+  
+  /**
+   * Construct a XNodeSet object.
+   *
+   * @param val FastStringBuffer object this will wrap, must be non-null.
+   * @param start The start position in the array.
+   * @param length The number of characters to read from the array.
+   */
+  public XStringForChars(char[] val, int start, int length)
+  {
+    super(val);
+    m_start = start;
+    m_length = length;
+    if(null == val)
+      throw new IllegalArgumentException(
+                          "The FastStringBuffer argument can not be null!!");
+  }
+
+
+  /**
+   * Construct a XNodeSet object.
+   *
+   * @param val String object this will wrap.
+   */
+  private XStringForChars(String val)
+  {
+    super(val);
+    throw new IllegalArgumentException(
+                      "XStringForChars can not take a string for an argument!");
+  }
+  
+  /**
+   * Cast result object to a string.
+   *
+   * @return The string this wraps or the empty string if null
+   */
+  public FastStringBuffer fsb()
+  {
+    throw new RuntimeException("fsb() not supported for XStringForChars!");
+  }
+  
+  /**
+   * Cast result object to a string.
+   *
+   * @return The string this wraps or the empty string if null
+   */
+  public void appendToFsb(org.apache.xml.utils.FastStringBuffer fsb)
+  {
+    fsb.append((char[])m_obj, m_start, m_length);
+  }
+
+  
+  /**
+   * Tell if this object contains a java String object.
+   * 
+   * @return true if this XMLString can return a string without creating one.
+   */
+  public boolean hasString()
+  {
+    return (null != m_strCache);
+  }
+
+  
+  /**
+   * Cast result object to a string.
+   *
+   * @return The string this wraps or the empty string if null
+   */
+  public String str()
+  {
+    if(null == m_strCache)
+      m_strCache = new String((char[])m_obj, m_start, m_length);
+    
+    return m_strCache;
+  }
+
+  /**
+   * Directly call the
+   * characters method on the passed ContentHandler for the
+   * string-value. Multiple calls to the
+   * ContentHandler's characters methods may well occur for a single call to
+   * this method.
+   *
+   * @param ch A non-null reference to a ContentHandler.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public void dispatchCharactersEvents(org.xml.sax.ContentHandler ch)
+      throws org.xml.sax.SAXException
+  {
+    ch.characters((char[])m_obj, m_start, m_length);
+  }
+      
+  /**
+   * Directly call the
+   * comment method on the passed LexicalHandler for the
+   * string-value.
+   *
+   * @param lh A non-null reference to a LexicalHandler.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public void dispatchAsComment(org.xml.sax.ext.LexicalHandler lh)
+      throws org.xml.sax.SAXException
+  {
+    lh.comment((char[])m_obj, m_start, m_length);
+  }
+  
+  /**
+   * Returns the length of this string.
+   *
+   * @return  the length of the sequence of characters represented by this
+   *          object.
+   */
+  public int length()
+  {
+    return m_length;
+  }
+
+  /**
+   * Returns the character at the specified index. An index ranges
+   * from <code>0</code> to <code>length() - 1</code>. The first character
+   * of the sequence is at index <code>0</code>, the next at index
+   * <code>1</code>, and so on, as for array indexing.
+   *
+   * @param      index   the index of the character.
+   * @return     the character at the specified index of this string.
+   *             The first character is at index <code>0</code>.
+   * @exception  IndexOutOfBoundsException  if the <code>index</code>
+   *             argument is negative or not less than the length of this
+   *             string.
+   */
+  public char charAt(int index)
+  {
+    return ((char[])m_obj)[index];
+  }
+
+  /**
+   * Copies characters from this string into the destination character
+   * array.
+   *
+   * @param      srcBegin   index of the first character in the string
+   *                        to copy.
+   * @param      srcEnd     index after the last character in the string
+   *                        to copy.
+   * @param      dst        the destination array.
+   * @param      dstBegin   the start offset in the destination array.
+   * @exception IndexOutOfBoundsException If any of the following
+   *            is true:
+   *            <ul><li><code>srcBegin</code> is negative.
+   *            <li><code>srcBegin</code> is greater than <code>srcEnd</code>
+   *            <li><code>srcEnd</code> is greater than the length of this
+   *                string
+   *            <li><code>dstBegin</code> is negative
+   *            <li><code>dstBegin+(srcEnd-srcBegin)</code> is larger than
+   *                <code>dst.length</code></ul>
+   * @exception NullPointerException if <code>dst</code> is <code>null</code>
+   */
+  public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin)
+  {
+    System.arraycopy((char[])m_obj, m_start+srcBegin, dst, dstBegin, m_start+srcEnd);
+  }
+  
+}
\ No newline at end of file
diff --git a/src/org/apache/xpath/objects/XStringForFSB.java b/src/org/apache/xpath/objects/XStringForFSB.java
new file mode 100644
index 0000000..3909947
--- /dev/null
+++ b/src/org/apache/xpath/objects/XStringForFSB.java
@@ -0,0 +1,1043 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights 
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.apache.xpath.objects;
+
+import org.apache.xml.utils.FastStringBuffer;
+import org.apache.xml.utils.XMLString;
+import org.apache.xml.utils.XMLStringFactory;
+import org.apache.xml.utils.XMLCharacterRecognizer;
+
+import java.util.Locale;
+
+/**
+ * This class will wrap a FastStringBuffer and allow for
+ */
+public class XStringForFSB extends XString
+{
+
+  /** The start position in the fsb. */
+  int m_start;
+
+  /** The length of the string. */
+  int m_length;
+
+  /** If the str() function is called, the string will be cached here. */
+  protected String m_strCache = null;
+
+  /** cached hash code */
+  protected int m_hash = 0;
+
+  /**
+   * Construct a XNodeSet object.
+   *
+   * @param val FastStringBuffer object this will wrap, must be non-null.
+   * @param start The start position in the array.
+   * @param length The number of characters to read from the array.
+   */
+  public XStringForFSB(FastStringBuffer val, int start, int length)
+  {
+
+    super(val);
+
+    m_start = start;
+    m_length = length;
+
+    if (null == val)
+      throw new IllegalArgumentException(
+        "The FastStringBuffer argument can not be null!!");
+  }
+
+  /**
+   * Construct a XNodeSet object.
+   *
+   * @param val String object this will wrap.
+   */
+  private XStringForFSB(String val)
+  {
+
+    super(val);
+
+    throw new IllegalArgumentException(
+      "XStringForFSB can not take a string for an argument!");
+  }
+
+  /**
+   * Cast result object to a string.
+   *
+   * @return The string this wraps or the empty string if null
+   */
+  public FastStringBuffer fsb()
+  {
+    return ((FastStringBuffer) m_obj);
+  }
+  
+  /**
+   * Cast result object to a string.
+   *
+   * @return The string this wraps or the empty string if null
+   */
+  public void appendToFsb(org.apache.xml.utils.FastStringBuffer fsb)
+  {
+    // %OPT% !!! FSB has to be updated to take partial fsb's for append.
+    fsb.append(str());
+  }
+
+  /**
+   * Tell if this object contains a java String object.
+   *
+   * @return true if this XMLString can return a string without creating one.
+   */
+  public boolean hasString()
+  {
+    return (null != m_strCache);
+  }
+
+//  /** NEEDSDOC Field strCount */
+//  public static int strCount = 0;
+//
+//  /** NEEDSDOC Field xtable */
+//  static java.util.Hashtable xtable = new java.util.Hashtable();
+
+  /**
+   * Cast result object to a string.
+   *
+   * @return The string this wraps or the empty string if null
+   */
+  public String str()
+  {
+
+    if (null == m_strCache)
+    {
+      m_strCache = fsb().getString(m_start, m_length);
+
+//      strCount++;
+//
+//      RuntimeException e = new RuntimeException("Bad!  Bad!");
+//      java.io.CharArrayWriter writer = new java.io.CharArrayWriter();
+//      java.io.PrintWriter pw = new java.io.PrintWriter(writer);
+//
+//      e.printStackTrace(pw);
+//
+//      String str = writer.toString();
+//
+//      str = str.substring(0, 600);
+//
+//      if (null == xtable.get(str))
+//      {
+//        xtable.put(str, str);
+//        System.out.println(str);
+//      }
+//      System.out.println("strCount: " + strCount);
+
+//      throw e;
+//      e.printStackTrace();
+      // System.exit(-1);
+    }
+
+    return m_strCache;
+  }
+
+  /**
+   * Directly call the
+   * characters method on the passed ContentHandler for the
+   * string-value. Multiple calls to the
+   * ContentHandler's characters methods may well occur for a single call to
+   * this method.
+   *
+   * @param ch A non-null reference to a ContentHandler.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public void dispatchCharactersEvents(org.xml.sax.ContentHandler ch)
+          throws org.xml.sax.SAXException
+  {
+    fsb().sendSAXcharacters(ch, m_start, m_length);
+  }
+
+  /**
+   * Directly call the
+   * comment method on the passed LexicalHandler for the
+   * string-value.
+   *
+   * @param lh A non-null reference to a LexicalHandler.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public void dispatchAsComment(org.xml.sax.ext.LexicalHandler lh)
+          throws org.xml.sax.SAXException
+  {
+    fsb().sendSAXComment(lh, m_start, m_length);
+  }
+
+  /**
+   * Returns the length of this string.
+   *
+   * @return  the length of the sequence of characters represented by this
+   *          object.
+   */
+  public int length()
+  {
+    return m_length;
+  }
+
+  /**
+   * Returns the character at the specified index. An index ranges
+   * from <code>0</code> to <code>length() - 1</code>. The first character
+   * of the sequence is at index <code>0</code>, the next at index
+   * <code>1</code>, and so on, as for array indexing.
+   *
+   * @param      index   the index of the character.
+   * @return     the character at the specified index of this string.
+   *             The first character is at index <code>0</code>.
+   * @exception  IndexOutOfBoundsException  if the <code>index</code>
+   *             argument is negative or not less than the length of this
+   *             string.
+   */
+  public char charAt(int index)
+  {
+    return fsb().charAt(m_start + index);
+  }
+
+  /**
+   * Copies characters from this string into the destination character
+   * array.
+   *
+   * @param      srcBegin   index of the first character in the string
+   *                        to copy.
+   * @param      srcEnd     index after the last character in the string
+   *                        to copy.
+   * @param      dst        the destination array.
+   * @param      dstBegin   the start offset in the destination array.
+   * @exception IndexOutOfBoundsException If any of the following
+   *            is true:
+   *            <ul><li><code>srcBegin</code> is negative.
+   *            <li><code>srcBegin</code> is greater than <code>srcEnd</code>
+   *            <li><code>srcEnd</code> is greater than the length of this
+   *                string
+   *            <li><code>dstBegin</code> is negative
+   *            <li><code>dstBegin+(srcEnd-srcBegin)</code> is larger than
+   *                <code>dst.length</code></ul>
+   * @exception NullPointerException if <code>dst</code> is <code>null</code>
+   */
+  public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin)
+  {
+
+    // %OPT% Need to call this on FSB when it is implemented.
+    // %UNTESTED% (I don't think anyone calls this yet?)
+    int n = srcEnd - srcBegin;
+
+    if (n > m_length)
+      n = m_length;
+
+    if (n > (dst.length - dstBegin))
+      n = (dst.length - dstBegin);
+
+    int end = srcBegin + m_start + n;
+    int d = dstBegin;
+    FastStringBuffer fsb = fsb();
+
+    for (int i = srcBegin + m_start; i < end; i++)
+    {
+      dst[d++] = fsb.charAt(i);
+    }
+  }
+
+  /**
+   * Compares this string to the specified object.
+   * The result is <code>true</code> if and only if the argument is not
+   * <code>null</code> and is a <code>String</code> object that represents
+   * the same sequence of characters as this object.
+   *
+   * @param   anObject   the object to compare this <code>String</code>
+   *                     against.
+   *
+   * NEEDSDOC @param obj2
+   * @return  <code>true</code> if the <code>String </code>are equal;
+   *          <code>false</code> otherwise.
+   * @see     java.lang.String#compareTo(java.lang.String)
+   * @see     java.lang.String#equalsIgnoreCase(java.lang.String)
+   */
+  public boolean equals(XMLString obj2)
+  {
+
+    if (this == obj2)
+    {
+      return true;
+    }
+
+    int n = m_length;
+
+    if (n == obj2.length())
+    {
+      FastStringBuffer fsb = fsb();
+      int i = m_start;
+      int j = 0;
+
+      while (n-- != 0)
+      {
+        if (fsb.charAt(i) != obj2.charAt(j))
+        {
+          return false;
+        }
+
+        i++;
+        j++;
+      }
+
+      return true;
+    }
+
+    return false;
+  }
+
+  /**
+   * Tell if two objects are functionally equal.
+   *
+   * @param obj2 Object to compare this to
+   *
+   * @return true if the two objects are equal
+   *
+   * @throws javax.xml.transform.TransformerException
+   */
+  public boolean equals(XObject obj2)
+  {
+
+    if (this == obj2)
+    {
+      return true;
+    }
+
+    String str = obj2.str();
+    int n = m_length;
+
+    if (n == str.length())
+    {
+      FastStringBuffer fsb = fsb();
+      int i = m_start;
+      int j = 0;
+
+      while (n-- != 0)
+      {
+        if (fsb.charAt(i) != str.charAt(j))
+        {
+          return false;
+        }
+
+        i++;
+        j++;
+      }
+
+      return true;
+    }
+
+    return false;
+  }
+
+  /**
+   * Tell if two objects are functionally equal.
+   *
+   * @param obj2 Object to compare this to
+   *
+   * NEEDSDOC @param anotherString
+   *
+   * @return true if the two objects are equal
+   *
+   * @throws javax.xml.transform.TransformerException
+   */
+  public boolean equals(String anotherString)
+  {
+
+    int n = m_length;
+
+    if (n == anotherString.length())
+    {
+      FastStringBuffer fsb = fsb();
+      int i = m_start;
+      int j = 0;
+
+      while (n-- != 0)
+      {
+        if (fsb.charAt(i) != anotherString.charAt(j))
+        {
+          return false;
+        }
+
+        i++;
+        j++;
+      }
+
+      return true;
+    }
+
+    return false;
+  }
+
+  /**
+   * Compares this string to the specified object.
+   * The result is <code>true</code> if and only if the argument is not
+   * <code>null</code> and is a <code>String</code> object that represents
+   * the same sequence of characters as this object.
+   *
+   * @param   anObject   the object to compare this <code>String</code>
+   *                     against.
+   *
+   * NEEDSDOC @param obj2
+   * @return  <code>true</code> if the <code>String </code>are equal;
+   *          <code>false</code> otherwise.
+   * @see     java.lang.String#compareTo(java.lang.String)
+   * @see     java.lang.String#equalsIgnoreCase(java.lang.String)
+   */
+  public boolean equals(Object obj2)
+  {
+
+    if (null == obj2)
+      return false;
+
+      // In order to handle the 'all' semantics of 
+      // nodeset comparisons, we always call the 
+      // nodeset function.
+    else if (obj2 instanceof XNodeSet)
+      return obj2.equals(this);
+    else if (obj2 instanceof XStringForFSB)
+      return equals((XMLString) this);
+    else
+      return equals(obj2.toString());
+  }
+
+  /**
+   * Compares this <code>String</code> to another <code>String</code>,
+   * ignoring case considerations.  Two strings are considered equal
+   * ignoring case if they are of the same length, and corresponding
+   * characters in the two strings are equal ignoring case.
+   *
+   * @param   anotherString   the <code>String</code> to compare this
+   *                          <code>String</code> against.
+   * @return  <code>true</code> if the argument is not <code>null</code>
+   *          and the <code>String</code>s are equal,
+   *          ignoring case; <code>false</code> otherwise.
+   * @see     #equals(Object)
+   * @see     java.lang.Character#toLowerCase(char)
+   * @see java.lang.Character#toUpperCase(char)
+   */
+  public boolean equalsIgnoreCase(String anotherString)
+  {
+    return (m_length == anotherString.length())
+           ? str().equalsIgnoreCase(anotherString) : false;
+  }
+
+  /**
+   * Compares two strings lexicographically.
+   *
+   * @param   anotherString   the <code>String</code> to be compared.
+   *
+   * NEEDSDOC @param xstr
+   * @return  the value <code>0</code> if the argument string is equal to
+   *          this string; a value less than <code>0</code> if this string
+   *          is lexicographically less than the string argument; and a
+   *          value greater than <code>0</code> if this string is
+   *          lexicographically greater than the string argument.
+   * @exception java.lang.NullPointerException if <code>anotherString</code>
+   *          is <code>null</code>.
+   */
+  public int compareTo(XMLString xstr)
+  {
+
+    int len1 = m_length;
+    int len2 = xstr.length();
+    int n = Math.min(len1, len2);
+    FastStringBuffer fsb = fsb();
+    int i = m_start;
+    int j = 0;
+
+    while (n-- != 0)
+    {
+      char c1 = fsb.charAt(i);
+      char c2 = xstr.charAt(j);
+
+      if (c1 != c2)
+      {
+        return c1 - c2;
+      }
+
+      i++;
+      j++;
+    }
+
+    return len1 - len2;
+  }
+
+  /**
+   * Compares two strings lexicographically, ignoring case considerations.
+   * This method returns an integer whose sign is that of
+   * <code>this.toUpperCase().toLowerCase().compareTo(
+   * str.toUpperCase().toLowerCase())</code>.
+   * <p>
+   * Note that this method does <em>not</em> take locale into account,
+   * and will result in an unsatisfactory ordering for certain locales.
+   * The java.text package provides <em>collators</em> to allow
+   * locale-sensitive ordering.
+   *
+   * @param   str   the <code>String</code> to be compared.
+   *
+   * NEEDSDOC @param xstr
+   * @return  a negative integer, zero, or a positive integer as the
+   *          the specified String is greater than, equal to, or less
+   *          than this String, ignoring case considerations.
+   * @see     java.text.Collator#compare(String, String)
+   * @since   1.2
+   */
+  public int compareToIgnoreCase(XMLString xstr)
+  {
+
+    int len1 = m_length;
+    int len2 = xstr.length();
+    int n = Math.min(len1, len2);
+    FastStringBuffer fsb = fsb();
+    int i = m_start;
+    int j = 0;
+
+    while (n-- != 0)
+    {
+      char c1 = Character.toLowerCase(fsb.charAt(i));
+      char c2 = Character.toLowerCase(xstr.charAt(j));
+
+      if (c1 != c2)
+      {
+        return c1 - c2;
+      }
+
+      i++;
+      j++;
+    }
+
+    return len1 - len2;
+  }
+
+  /**
+   * Returns a hashcode for this string. The hashcode for a
+   * <code>String</code> object is computed as
+   * <blockquote><pre>
+   * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
+   * </pre></blockquote>
+   * using <code>int</code> arithmetic, where <code>s[i]</code> is the
+   * <i>i</i>th character of the string, <code>n</code> is the length of
+   * the string, and <code>^</code> indicates exponentiation.
+   * (The hash value of the empty string is zero.)
+   *
+   * @return  a hash code value for this object.
+   */
+  public int hashCode()
+  {
+
+    int h = m_hash;
+
+    if (h == 0)
+    {
+      int off = m_start;
+      int len = m_length;
+      FastStringBuffer fsb = fsb();
+
+      for (int i = 0; i < len; i++)
+      {
+        h = 31 * h + fsb.charAt(off);
+
+        off++;
+      }
+
+      m_hash = h;
+    }
+
+    return h;
+  }
+
+  /**
+   * Tests if this string starts with the specified prefix beginning
+   * a specified index.
+   *
+   * @param   prefix    the prefix.
+   * @param   toffset   where to begin looking in the string.
+   * @return  <code>true</code> if the character sequence represented by the
+   *          argument is a prefix of the substring of this object starting
+   *          at index <code>toffset</code>; <code>false</code> otherwise.
+   *          The result is <code>false</code> if <code>toffset</code> is
+   *          negative or greater than the length of this
+   *          <code>String</code> object; otherwise the result is the same
+   *          as the result of the expression
+   *          <pre>
+   *          this.subString(toffset).startsWith(prefix)
+   *          </pre>
+   * @exception java.lang.NullPointerException if <code>prefix</code> is
+   *          <code>null</code>.
+   */
+  public boolean startsWith(XMLString prefix, int toffset)
+  {
+
+    FastStringBuffer fsb = fsb();
+    int to = m_start + toffset;
+    int tlim = m_start + m_length;
+    int po = 0;
+    int pc = prefix.length();
+
+    // Note: toffset might be near -1>>>1.
+    if ((toffset < 0) || (toffset > m_length - pc))
+    {
+      return false;
+    }
+
+    while (--pc >= 0)
+    {
+      if (fsb.charAt(to) != prefix.charAt(po))
+      {
+        return false;
+      }
+
+      to++;
+      po++;
+    }
+
+    return true;
+  }
+
+  /**
+   * Tests if this string starts with the specified prefix.
+   *
+   * @param   prefix   the prefix.
+   * @return  <code>true</code> if the character sequence represented by the
+   *          argument is a prefix of the character sequence represented by
+   *          this string; <code>false</code> otherwise.
+   *          Note also that <code>true</code> will be returned if the
+   *          argument is an empty string or is equal to this
+   *          <code>String</code> object as determined by the
+   *          {@link #equals(Object)} method.
+   * @exception java.lang.NullPointerException if <code>prefix</code> is
+   *          <code>null</code>.
+   * @since   JDK1. 0
+   */
+  public boolean startsWith(XMLString prefix)
+  {
+    return startsWith(prefix, 0);
+  }
+
+  /**
+   * Returns the index within this string of the first occurrence of the
+   * specified character. If a character with value <code>ch</code> occurs
+   * in the character sequence represented by this <code>String</code>
+   * object, then the index of the first such occurrence is returned --
+   * that is, the smallest value <i>k</i> such that:
+   * <blockquote><pre>
+   * this.charAt(<i>k</i>) == ch
+   * </pre></blockquote>
+   * is <code>true</code>. If no such character occurs in this string,
+   * then <code>-1</code> is returned.
+   *
+   * @param   ch   a character.
+   * @return  the index of the first occurrence of the character in the
+   *          character sequence represented by this object, or
+   *          <code>-1</code> if the character does not occur.
+   */
+  public int indexOf(int ch)
+  {
+    return indexOf(ch, 0);
+  }
+
+  /**
+   * Returns the index within this string of the first occurrence of the
+   * specified character, starting the search at the specified index.
+   * <p>
+   * If a character with value <code>ch</code> occurs in the character
+   * sequence represented by this <code>String</code> object at an index
+   * no smaller than <code>fromIndex</code>, then the index of the first
+   * such occurrence is returned--that is, the smallest value <i>k</i>
+   * such that:
+   * <blockquote><pre>
+   * (this.charAt(<i>k</i>) == ch) && (<i>k</i> >= fromIndex)
+   * </pre></blockquote>
+   * is true. If no such character occurs in this string at or after
+   * position <code>fromIndex</code>, then <code>-1</code> is returned.
+   * <p>
+   * There is no restriction on the value of <code>fromIndex</code>. If it
+   * is negative, it has the same effect as if it were zero: this entire
+   * string may be searched. If it is greater than the length of this
+   * string, it has the same effect as if it were equal to the length of
+   * this string: <code>-1</code> is returned.
+   *
+   * @param   ch          a character.
+   * @param   fromIndex   the index to start the search from.
+   * @return  the index of the first occurrence of the character in the
+   *          character sequence represented by this object that is greater
+   *          than or equal to <code>fromIndex</code>, or <code>-1</code>
+   *          if the character does not occur.
+   */
+  public int indexOf(int ch, int fromIndex)
+  {
+
+    int max = m_start + m_length;
+    FastStringBuffer fsb = fsb();
+
+    if (fromIndex < 0)
+    {
+      fromIndex = 0;
+    }
+    else if (fromIndex >= m_length)
+    {
+
+      // Note: fromIndex might be near -1>>>1.
+      return -1;
+    }
+
+    for (int i = m_start + fromIndex; i < max; i++)
+    {
+      if (fsb.charAt(i) == ch)
+      {
+        return i - m_start;
+      }
+    }
+
+    return -1;
+  }
+
+  /**
+   * Returns a new string that is a substring of this string. The
+   * substring begins with the character at the specified index and
+   * extends to the end of this string. <p>
+   * Examples:
+   * <blockquote><pre>
+   * "unhappy".substring(2) returns "happy"
+   * "Harbison".substring(3) returns "bison"
+   * "emptiness".substring(9) returns "" (an empty string)
+   * </pre></blockquote>
+   *
+   * @param      beginIndex   the beginning index, inclusive.
+   * @return     the specified substring.
+   * @exception  IndexOutOfBoundsException  if
+   *             <code>beginIndex</code> is negative or larger than the
+   *             length of this <code>String</code> object.
+   */
+  public XMLString substring(int beginIndex)
+  {
+
+    int len = m_length - beginIndex;
+
+    if (len <= 0)
+      return XString.EMPTYSTRING;
+    else
+    {
+      int start = m_start + beginIndex;
+
+      return new XStringForFSB(fsb(), start, len);
+    }
+  }
+
+  /**
+   * Returns a new string that is a substring of this string. The
+   * substring begins at the specified <code>beginIndex</code> and
+   * extends to the character at index <code>endIndex - 1</code>.
+   * Thus the length of the substring is <code>endIndex-beginIndex</code>.
+   *
+   * @param      beginIndex   the beginning index, inclusive.
+   * @param      endIndex     the ending index, exclusive.
+   * @return     the specified substring.
+   * @exception  IndexOutOfBoundsException  if the
+   *             <code>beginIndex</code> is negative, or
+   *             <code>endIndex</code> is larger than the length of
+   *             this <code>String</code> object, or
+   *             <code>beginIndex</code> is larger than
+   *             <code>endIndex</code>.
+   */
+  public XMLString substring(int beginIndex, int endIndex)
+  {
+
+    int len = endIndex - beginIndex;
+
+    if (len > m_length)
+      len = m_length;
+
+    if (len <= 0)
+      return XString.EMPTYSTRING;
+    else
+    {
+      int start = m_start + beginIndex;
+
+      return new XStringForFSB(fsb(), start, len);
+    }
+  }
+
+  /**
+   * Concatenates the specified string to the end of this string.
+   *
+   * @param   str   the <code>String</code> that is concatenated to the end
+   *                of this <code>String</code>.
+   * @return  a string that represents the concatenation of this object's
+   *          characters followed by the string argument's characters.
+   * @exception java.lang.NullPointerException if <code>str</code> is
+   *          <code>null</code>.
+   */
+  public XMLString concat(String str)
+  {
+
+    // %OPT% Make an FSB here?
+    return new XString(str().concat(str));
+  }
+
+  /**
+   * Removes white space from both ends of this string.
+   *
+   * @return  this string, with white space removed from the front and end.
+   */
+  public XMLString trim()
+  {
+    return fixWhiteSpace(true, true, false);
+  }
+
+  /**
+   * Returns whether the specified <var>ch</var> conforms to the XML 1.0 definition
+   * of whitespace.  Refer to <A href="http://www.w3.org/TR/1998/REC-xml-19980210#NT-S">
+   * the definition of <CODE>S</CODE></A> for details.
+   * @param   ch      Character to check as XML whitespace.
+   * @return          =true if <var>ch</var> is XML whitespace; otherwise =false.
+   */
+  private static boolean isSpace(char ch)
+  {
+    return XMLCharacterRecognizer.isWhiteSpace(ch);  // Take the easy way out for now.
+  }
+
+  /**
+   * Conditionally trim all leading and trailing whitespace in the specified String.
+   * All strings of white space are
+   * replaced by a single space character (#x20), except spaces after punctuation which
+   * receive double spaces if doublePunctuationSpaces is true.
+   * This function may be useful to a formatter, but to get first class
+   * results, the formatter should probably do it's own white space handling
+   * based on the semantics of the formatting object.
+   *
+   * @param   trimHead    Trim leading whitespace?
+   * @param   trimTail    Trim trailing whitespace?
+   * @param   doublePunctuationSpaces    Use double spaces for punctuation?
+   * @return              The trimmed string.
+   */
+  public XMLString fixWhiteSpace(boolean trimHead, boolean trimTail,
+                                 boolean doublePunctuationSpaces)
+  {
+
+    int end = m_length + m_start;
+    char[] buf = new char[m_length];
+    FastStringBuffer fsb = fsb();
+    boolean edit = false;
+
+    /* replace S to ' '. and ' '+ -> single ' '. */
+    int d = 0;
+    boolean pres = false;
+
+    for (int s = m_start; s < end; s++)
+    {
+      char c = fsb.charAt(s);
+
+      if (isSpace(c))
+      {
+        if (!pres)
+        {
+          if (' ' != c)
+          {
+            edit = true;
+          }
+
+          buf[d++] = ' ';
+
+          if (doublePunctuationSpaces && (d != 0))
+          {
+            char prevChar = buf[d - 1];
+
+            if (!((prevChar == '.') || (prevChar == '!')
+                  || (prevChar == '?')))
+            {
+              pres = true;
+            }
+          }
+          else
+          {
+            pres = true;
+          }
+        }
+        else
+        {
+          edit = true;
+          pres = true;
+        }
+      }
+      else
+      {
+        buf[d++] = c;
+        pres = false;
+      }
+    }
+
+    if (trimTail && 1 <= d && ' ' == buf[d - 1])
+    {
+      edit = true;
+
+      d--;
+    }
+
+    int start = 0;
+
+    if (trimHead && 0 < d && ' ' == buf[0])
+    {
+      edit = true;
+
+      start++;
+    }
+
+    XMLStringFactory xsf = XMLStringFactoryImpl.getFactory();
+
+    return edit ? xsf.newstr(buf, start, d - start) : this;
+  }
+
+  /**
+   * Convert a string to a double -- Allowed input is in fixed
+   * notation ddd.fff.
+   *
+   * @return A double value representation of the string, or return Double.NaN 
+   * if the string can not be converted.
+   */
+  public double toDouble()
+  {
+
+    int start = m_start;
+    int end = m_length+start;
+    
+    if(0 == end)
+      return Double.NaN;
+      
+    double result = 0.0;
+    int punctPos = end-1;
+    FastStringBuffer fsb = fsb();
+    
+    // Scan to first whitespace character.
+    for (int i = start; i < end; i++) 
+    {
+      char c = fsb.charAt(i);
+      if( !Character.isSpaceChar( c ) )
+      {
+        break;
+      }
+      else
+        start++;
+    }
+
+    double sign = 1.0;
+    if (start < end && fsb.charAt(start) == '-')
+    {
+      sign = -1.0;
+
+      start++;
+    }
+    
+    int digitsFound = 0;
+    for (int i = start; i < end; i++)  // parse the string from left to right converting the integer part
+    {
+      char c = fsb.charAt(i);
+      if (c != '.')
+      {
+        if(Character.isSpaceChar(c))
+          break;
+        else if (Character.isDigit(c))
+        {
+          result = result * 10.0 + (c - 0x30);
+          digitsFound++;
+        }
+        else
+        {
+          return Double.NaN;
+        }
+      }
+      else
+      {
+        punctPos = i;
+
+        break;
+      }
+    }
+    
+    if (fsb.charAt(punctPos) == '.')  // parse the string from the end to the '.' converting the fractional part
+    {
+      double fractPart = 0.0;
+      for (int i = end - 1; i > punctPos; i--)
+      {
+        char c = fsb.charAt(i);
+        if(Character.isSpaceChar(c))
+          break;
+        else if (Character.isDigit(c))
+        {
+          fractPart = fractPart / 10.0 + (c - 0x30);
+          digitsFound++;
+        }
+        else
+        {
+          return Double.NaN;
+        }
+      }
+
+      result += fractPart / 10.0;
+    }
+    
+    if(0 == digitsFound)
+      return Double.NaN;
+
+    return result * sign;
+  }
+
+}
diff --git a/src/org/apache/xpath/operations/Variable.java b/src/org/apache/xpath/operations/Variable.java
index d1dfb3b..e5944db 100644
--- a/src/org/apache/xpath/operations/Variable.java
+++ b/src/org/apache/xpath/operations/Variable.java
@@ -125,7 +125,7 @@
 //      error(xctxt, XPATHErrorResources.ER_COULDNOT_GET_VAR_NAMED,
 //            new Object[]{ m_qname.getLocalPart() });  //"Could not get variable named "+varName);
       
-      result = new XNodeSet();
+      result = new XNodeSet(xctxt.getDTMManager());
     }
 
     return result;
diff --git a/src/org/apache/xpath/patterns/AncestorStepPattern.java b/src/org/apache/xpath/patterns/AncestorStepPattern.java
index 3841f5b..d780aee 100644
--- a/src/org/apache/xpath/patterns/AncestorStepPattern.java
+++ b/src/org/apache/xpath/patterns/AncestorStepPattern.java
@@ -62,8 +62,10 @@
 import org.apache.xml.utils.PrefixResolver;
 import org.apache.xpath.axes.LocPathIterator;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+
+import org.apache.xml.dtm.DTM;
 
 /**
  * <meta name="usage" content="advanced"/>
@@ -161,26 +163,30 @@
   {
 
     XObject score = NodeTest.SCORE_NONE;
-    Node parent = xctxt.getCurrentNode();
-
-    while (null != (parent = xctxt.getDOMHelper().getParentOfNode(parent)))
+    int parent = xctxt.getCurrentNode();
+    DTM dtm = xctxt.getDTM(parent);
+    
+    if(null != dtm)
     {
-      try
+      while (DTM.NULL != (parent = dtm.getParent(parent)))
       {
-        xctxt.pushCurrentNode(parent);
-
-        score = execute(xctxt);
-
-        if (score != NodeTest.SCORE_NONE)
+        try
         {
-          score = SCORE_OTHER;
-
-          break;
+          xctxt.pushCurrentNode(parent);
+  
+          score = execute(xctxt);
+  
+          if (score != NodeTest.SCORE_NONE)
+          {
+            score = SCORE_OTHER;
+  
+            break;
+          }
         }
-      }
-      finally
-      {
-        xctxt.popCurrentNode();
+        finally
+        {
+          xctxt.popCurrentNode();
+        }
       }
     }
 
diff --git a/src/org/apache/xpath/patterns/FunctionPattern.java b/src/org/apache/xpath/patterns/FunctionPattern.java
index 2c7349d..e3fcb32 100644
--- a/src/org/apache/xpath/patterns/FunctionPattern.java
+++ b/src/org/apache/xpath/patterns/FunctionPattern.java
@@ -63,8 +63,11 @@
 import org.apache.xpath.objects.XNumber;
 import org.apache.xpath.objects.XObject;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
+//import org.w3c.dom.Node;
+//import org.w3c.dom.traversal.NodeIterator;
+
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
 
 /**
  * <meta name="usage" content="advanced"/>
@@ -120,18 +123,20 @@
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
 
-    Node context = xctxt.getCurrentNode();
+    int context = xctxt.getCurrentNode();
     XObject obj = m_functionExpr.execute(xctxt);
-    NodeIterator nl = obj.nodeset();
+    
+    DTMIterator nl =  obj.nodeset();
+    
     XNumber score = SCORE_NONE;
 
     if (null != nl)
     {
-      Node n;
+      int n;
 
-      while (null != (n = nl.nextNode()))
+      while (DTM.NULL != (n = nl.nextNode()))
       {
-        score = (n.equals(context)) ? SCORE_OTHER : SCORE_NONE;
+        score = (n == context) ? SCORE_OTHER : SCORE_NONE;
 
         if (score == SCORE_OTHER)
         {
diff --git a/src/org/apache/xpath/patterns/NodeTest.java b/src/org/apache/xpath/patterns/NodeTest.java
index 588091c..92e7f09 100644
--- a/src/org/apache/xpath/patterns/NodeTest.java
+++ b/src/org/apache/xpath/patterns/NodeTest.java
@@ -56,11 +56,8 @@
  */
 package org.apache.xpath.patterns;
 
-import org.w3c.dom.traversal.NodeFilter;
-
 import org.apache.xpath.compiler.OpCodes;
 import org.apache.xpath.XPath;
-import org.apache.xpath.DOMHelper;
 import org.apache.xpath.Expression;
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.objects.XNumber;
@@ -68,8 +65,8 @@
 import org.apache.xpath.WhitespaceStrippingElementMatcher;
 import org.apache.xml.utils.PrefixResolver;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeFilter;
+import org.apache.xml.dtm.DTMFilter;
+import org.apache.xml.dtm.DTM;
 
 /**
  * <meta name="usage" content="advanced"/>
@@ -94,10 +91,6 @@
    */
   protected int m_whatToShow;
 
-  /** This bit specifies a namespace, and extends the SHOW_XXX stuff 
-   *  in {@link org.w3c.dom.traversal.NodeFilter}. */
-  public static final int SHOW_NAMESPACE = 0x00001000;
-
   /**
    * Special bitmap for match patterns starting with a function.
    * Make sure this does not conflict with {@link org.w3c.dom.traversal.NodeFilter}.
@@ -292,40 +285,40 @@
 
     java.util.Vector v = new java.util.Vector();
 
-    if (0 != (whatToShow & NodeFilter.SHOW_ATTRIBUTE))
+    if (0 != (whatToShow & DTMFilter.SHOW_ATTRIBUTE))
       v.addElement("SHOW_ATTRIBUTE");
 
-    if (0 != (whatToShow & NodeFilter.SHOW_CDATA_SECTION))
+    if (0 != (whatToShow & DTMFilter.SHOW_CDATA_SECTION))
       v.addElement("SHOW_CDATA_SECTION");
 
-    if (0 != (whatToShow & NodeFilter.SHOW_COMMENT))
+    if (0 != (whatToShow & DTMFilter.SHOW_COMMENT))
       v.addElement("SHOW_COMMENT");
 
-    if (0 != (whatToShow & NodeFilter.SHOW_DOCUMENT))
+    if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT))
       v.addElement("SHOW_DOCUMENT");
 
-    if (0 != (whatToShow & NodeFilter.SHOW_DOCUMENT_FRAGMENT))
+    if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_FRAGMENT))
       v.addElement("SHOW_DOCUMENT_FRAGMENT");
 
-    if (0 != (whatToShow & NodeFilter.SHOW_DOCUMENT_TYPE))
+    if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_TYPE))
       v.addElement("SHOW_DOCUMENT_TYPE");
 
-    if (0 != (whatToShow & NodeFilter.SHOW_ELEMENT))
+    if (0 != (whatToShow & DTMFilter.SHOW_ELEMENT))
       v.addElement("SHOW_ELEMENT");
 
-    if (0 != (whatToShow & NodeFilter.SHOW_ENTITY))
+    if (0 != (whatToShow & DTMFilter.SHOW_ENTITY))
       v.addElement("SHOW_ENTITY");
 
-    if (0 != (whatToShow & NodeFilter.SHOW_ENTITY_REFERENCE))
+    if (0 != (whatToShow & DTMFilter.SHOW_ENTITY_REFERENCE))
       v.addElement("SHOW_ENTITY_REFERENCE");
 
-    if (0 != (whatToShow & NodeFilter.SHOW_NOTATION))
+    if (0 != (whatToShow & DTMFilter.SHOW_NOTATION))
       v.addElement("SHOW_NOTATION");
 
-    if (0 != (whatToShow & NodeFilter.SHOW_PROCESSING_INSTRUCTION))
+    if (0 != (whatToShow & DTMFilter.SHOW_PROCESSING_INSTRUCTION))
       v.addElement("SHOW_PROCESSING_INSTRUCTION");
 
-    if (0 != (whatToShow & NodeFilter.SHOW_TEXT))
+    if (0 != (whatToShow & DTMFilter.SHOW_TEXT))
       v.addElement("SHOW_TEXT");
 
     int n = v.size();
@@ -394,53 +387,32 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  public XObject execute(XPathContext xctxt, Node context)
+  public XObject execute(XPathContext xctxt, int context)
           throws javax.xml.transform.TransformerException
   {
-    short nodeType = context.getNodeType();
-    
-    // Yuck!  Blech!  -sb
-    if((Node.TEXT_NODE == nodeType || Node.CDATA_SECTION_NODE == nodeType) && !context.isSupported(SUPPORTS_PRE_STRIPPING, null))
-    {
-      Node parent = context.getParentNode();
-      if(null != parent && Node.ELEMENT_NODE == parent.getNodeType())
-      {
-        String data = context.getNodeValue();
-        if(org.apache.xml.utils.XMLCharacterRecognizer.isWhiteSpace(data))
-        {
-          // Ugly trick for now.
-          PrefixResolver resolver = xctxt.getNamespaceContext();
-          if(resolver instanceof WhitespaceStrippingElementMatcher)
-          {
-            WhitespaceStrippingElementMatcher wsem = 
-               (WhitespaceStrippingElementMatcher)resolver;
-            if(wsem.shouldStripWhiteSpace(xctxt, (org.w3c.dom.Element)parent))
-            {
-              return SCORE_NONE;
-            }
-          }
-        }
-      }
-    }
+    DTM dtm = xctxt.getDTM(context);
+    short nodeType = dtm.getNodeType(context);
 
-    if (m_whatToShow == NodeFilter.SHOW_ALL)
+    if (m_whatToShow == DTMFilter.SHOW_ALL)
       return m_score;
 
     int nodeBit = (m_whatToShow & (0x00000001 << (nodeType - 1)));
 
     switch (nodeBit)
     {
-    case NodeFilter.SHOW_DOCUMENT_FRAGMENT :
-    case NodeFilter.SHOW_DOCUMENT :
+    case DTMFilter.SHOW_DOCUMENT_FRAGMENT :
+    case DTMFilter.SHOW_DOCUMENT :
       return SCORE_OTHER;
-    case NodeFilter.SHOW_COMMENT :
+    case DTMFilter.SHOW_COMMENT :
       return m_score;
-    case NodeFilter.SHOW_CDATA_SECTION :
-    case NodeFilter.SHOW_TEXT :
-      return (!xctxt.getDOMHelper().shouldStripSourceNode(context))
-             ? m_score : SCORE_NONE;
-    case NodeFilter.SHOW_PROCESSING_INSTRUCTION :
-      return subPartMatch(context.getNodeName(), m_name)
+    case DTMFilter.SHOW_CDATA_SECTION :
+    case DTMFilter.SHOW_TEXT :
+      // was: 
+      // return (!xctxt.getDOMHelper().shouldStripSourceNode(context))
+      //       ? m_score : SCORE_NONE;
+      return m_score;
+    case DTMFilter.SHOW_PROCESSING_INSTRUCTION :
+      return subPartMatch(dtm.getNodeName(context), m_name)
              ? m_score : SCORE_NONE;
 
     // From the draft: "Two expanded names are equal if they 
@@ -455,37 +427,17 @@
     // namespace declarations. The node test will be true for any node 
     // of the principal type whose expanded name has the URI to which 
     // the prefix expands, regardless of the local part of the name."
-    case NodeFilter.SHOW_ATTRIBUTE :
+    case DTMFilter.SHOW_NAMESPACE :
     {
-      int isNamespace = (m_whatToShow & SHOW_NAMESPACE);
+      String ns = dtm.getNodeValue(context);
 
-      if (0 == isNamespace)
-      {
-        DOMHelper dh = xctxt.getDOMHelper();
-
-        if (!dh.isNamespaceNode(context))
-          return (m_isTotallyWild || (subPartMatchNS(dh.getNamespaceOfNode(context), m_namespace) && subPartMatch(dh.getLocalNameOfNode(context), m_name)))
-                 ? m_score : SCORE_NONE;
-        else
-          return SCORE_NONE;
-      }
-      else
-      {
-        if (xctxt.getDOMHelper().isNamespaceNode(context))
-        {
-          String ns = context.getNodeValue();
-
-          return (subPartMatch(ns, m_name)) ? m_score : SCORE_NONE;
-        }
-        else
-          return SCORE_NONE;
-      }
+      return (subPartMatch(ns, m_name)) ? m_score : SCORE_NONE;
     }
-    case NodeFilter.SHOW_ELEMENT :
+    case DTMFilter.SHOW_ATTRIBUTE :
+    case DTMFilter.SHOW_ELEMENT :
     {
-      DOMHelper dh = xctxt.getDOMHelper();
-
-      return (m_isTotallyWild || (subPartMatchNS(dh.getNamespaceOfNode(context), m_namespace) && subPartMatch(dh.getLocalNameOfNode(context), m_name)))
+      return (m_isTotallyWild || (subPartMatchNS(dtm.getNamespaceURI(context), m_namespace) 
+           && subPartMatch(dtm.getLocalName(context), m_name)))
              ? m_score : SCORE_NONE;
     }
     default :
@@ -509,7 +461,6 @@
   public XObject execute(XPathContext xctxt)
           throws javax.xml.transform.TransformerException
   {
-
     return execute(xctxt, xctxt.getCurrentNode());
   }
 }
diff --git a/src/org/apache/xpath/patterns/StepPattern.java b/src/org/apache/xpath/patterns/StepPattern.java
index c0c7338..2b76e9c 100644
--- a/src/org/apache/xpath/patterns/StepPattern.java
+++ b/src/org/apache/xpath/patterns/StepPattern.java
@@ -63,9 +63,12 @@
 import org.apache.xpath.axes.SubContextList;
 import org.apache.xpath.compiler.PsuedoNames;
 
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeIterator;
+// import org.w3c.dom.traversal.NodeFilter;
+// import org.w3c.dom.Node;
+// import org.w3c.dom.traversal.NodeIterator;
+
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMFilter;
 
 /**
  * <meta name="usage" content="advanced"/>
@@ -84,7 +87,7 @@
    */
   public StepPattern(int whatToShow, String namespace, String name)
   {
-    
+
     super(whatToShow, namespace, name);
   }
 
@@ -116,22 +119,22 @@
 
     switch (whatToShow)
     {
-    case NodeFilter.SHOW_COMMENT :
+    case DTMFilter.SHOW_COMMENT :
       m_targetString = PsuedoNames.PSEUDONAME_COMMENT;
       break;
-    case NodeFilter.SHOW_TEXT :
-    case NodeFilter.SHOW_CDATA_SECTION :
-    case (NodeFilter.SHOW_TEXT | NodeFilter.SHOW_CDATA_SECTION):
+    case DTMFilter.SHOW_TEXT :
+    case DTMFilter.SHOW_CDATA_SECTION :
+    case (DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION):
       m_targetString = PsuedoNames.PSEUDONAME_TEXT;
       break;
-    case NodeFilter.SHOW_ALL :
+    case DTMFilter.SHOW_ALL :
       m_targetString = PsuedoNames.PSEUDONAME_ANY;
       break;
-    case NodeFilter.SHOW_DOCUMENT :
-    case NodeFilter.SHOW_DOCUMENT | NodeFilter.SHOW_DOCUMENT_FRAGMENT :
+    case DTMFilter.SHOW_DOCUMENT :
+    case DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT :
       m_targetString = PsuedoNames.PSEUDONAME_ROOT;
       break;
-    case NodeFilter.SHOW_ELEMENT :
+    case DTMFilter.SHOW_ELEMENT :
       if (this.WILD == m_name)
         m_targetString = PsuedoNames.PSEUDONAME_ANY;
       else
@@ -344,10 +347,12 @@
   public int getProximityPosition(XPathContext xctxt)
   {
 
-    Node context = xctxt.getCurrentNode();
+    int context = xctxt.getCurrentNode();
+    
+    DTM dtm = xctxt.getDTM(context);
 
     // System.out.println("context: "+context.getNodeName());
-    Node parentContext = xctxt.getDOMHelper().getParentOfNode(context);
+    int parentContext = dtm.getParent(context);
 
     // System.out.println("parentContext: "+parentContext.getNodeName());
     try
@@ -356,8 +361,8 @@
 
       int pos = 0;
 
-      for (Node child = parentContext.getFirstChild(); child != null;
-              child = child.getNextSibling())
+      for (int child = dtm.getFirstChild(parentContext); child != DTM.NULL;
+              child = dtm.getNextSibling(child))
       {
         try
         {
@@ -367,7 +372,7 @@
           {
             pos++;
 
-            if (child.equals(context))
+            if (child == context)
             {
               return pos;
             }
@@ -409,8 +414,9 @@
   public int getLastPos(XPathContext xctxt)
   {
 
-    Node context = xctxt.getCurrentNode();
-    Node parentContext = xctxt.getDOMHelper().getParentOfNode(context);
+    int context = xctxt.getCurrentNode();
+    DTM dtm = xctxt.getDTM(context);
+    int parentContext = dtm.getParent(context);
 
     try
     {
@@ -418,8 +424,8 @@
 
       int count = 0;
 
-      for (Node child = parentContext.getFirstChild(); child != null;
-              child = child.getNextSibling())
+      for (int child = dtm.getFirstChild(parentContext); child != DTM.NULL;
+              child = dtm.getNextSibling(child))
       {
         try
         {
@@ -469,10 +475,11 @@
   {
 
     XObject score;
-    Node parent =
-      xctxt.getDOMHelper().getParentOfNode(xctxt.getCurrentNode());
+    int currentNode = xctxt.getCurrentNode();
+    DTM dtm = xctxt.getDTM(currentNode);
+    int parent = dtm.getParent(currentNode);
 
-    if (null != parent)
+    if (DTM.NULL != parent)
     {
       try
       {
@@ -542,7 +549,7 @@
    *
    * @throws javax.xml.transform.TransformerException
    */
-  public double getMatchScore(XPathContext xctxt, Node context)
+  public double getMatchScore(XPathContext xctxt, int context)
           throws javax.xml.transform.TransformerException
   {
 
diff --git a/src/org/w3c/dom/traversal/NodeIterator.java b/src/org/w3c/dom/traversal/NodeIterator.java
index 1035faf..28ebb3b 100644
--- a/src/org/w3c/dom/traversal/NodeIterator.java
+++ b/src/org/w3c/dom/traversal/NodeIterator.java
@@ -104,5 +104,7 @@
      * raise the exception INVALID_STATE_ERR.
      */
     public void detach();
+    
+
 
 }
diff --git a/src/trax/trax.properties b/src/trax/trax.properties
deleted file mode 100644
index e593c39..0000000
--- a/src/trax/trax.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Revision$ $Date$
-#
-# Note: This properties file is provided for illustrative purposes
-#       only and is not part of the interface definition.
-#       This properties file is located in the implementation JAR
-#       and different implementations will specify different
-#       implementation classes and output methods.
-#
-
-# The TRaX Stylesheet processor
-trax.processor.xslt=org.apache.xalan.processor.StylesheetProcessor
diff --git a/todo.xml b/todo.xml
deleted file mode 100644
index 04de0f8..0000000
--- a/todo.xml
+++ /dev/null
@@ -1,402 +0,0 @@
-<?xml version="1.0"?>
-
-<todo title="Things To Do" project="Xalan" major-version="2">
-
- <devs>
-  <!-- in alphabetical order, by last name -->
-  <person name="Scott Boag" email="scott_boag@lotus.com" id="SB" expertise="code">
-    Xalan architect, lead developer on Xalan-J 2.x.
-  </person>
-  <person name="Shane Curcuru" email="Shane_Curcuru@lotus.com" id="SC" expertise="test">
-    Lead tester for API issues, automation framework.
-  </person>
-  <person name="Paul Dick" email="Paul_Dick@lotus.com" id="PD" expertise="test">
-    XSLT Conformance stylesheet issues and Xalan-C testing.
-  </person>
-  <person name="Joseph Kesselman" email="Joseph_Kesselman@lotus.com" id="JK" expertise="code">
-    Xalan-J 2.x developer, compiling/compiled stylesheets experiments.
-  </person>
-  <person name="Donald Leslie" email="donald_leslie@lotus.com" id="DL" expertise="doc">
-    Xalan-J and -C documentation, servlets and samples.
-  </person>
-  <person name="Costin Manolache" email="cmanolache@yahoo.com" id="CM">
-    Xalan-J 2.x developer.
-  </person>
-  <person name="David Marston" email="David_Marston@lotus.com" id="DM" expertise="test">
-    Lead tester for XSLT Conformance stylesheet issues.
-  </person>
-  <person name="Myriam Midy" email="myriam_midy@lotus.com" id="MM" expertise="code">
-    Xalan-J 1.x and 2.x developer.
-  </person>
-  <person name="Gary L Peskin" email="garyp@firstech.com" id="GP" expertise="code">
-    Xalan-J 1.x and 2.x developer, especially extension mechanisim.
-  </person>
-
- </devs>
-
- <actions>
-
-   <target-release-description>
-    <date>01/19/01</date>
-    <level>production</level>
-    <goal type="conformance">XSLT 1.0 and XPath 1.0 compliant, 99% conformance test passage.</goal>
-    <goal type="performance">Reasonable, competative performance. [need metrics]</goal>
-    <goal type="stability">Robust.</goal>
-    <goal type="api">API Complete.</goal>
-    <goal type="documentation">Documentation complete.</goal>
-   </target-release-description>
-
-  <!-- Move to completed section when done. -->
-            
-   <action context="code" category="release">
-      No known actions pending for 2.0.0 release.
-   </action>
-  
- </actions>
-
- <actions priority="long-term" >
-  <!-- Move to completed section when done. -->
-
-   <target-release-description>
-    <date>4/15/01</date>
-    <level>beta</level>
-    <goal type="conformance">XSLT 1.1 and XPath 1.0+addendum compliant, 100% conformance test passage.</goal>
-    <goal type="performance">Very good performance. [need metrics]</goal>
-    <goal type="stability">Stable, reasonable.</goal>
-    <goal type="api">API Complete.</goal>
-    <goal type="documentation">Documentation functionally complete.</goal>
-   </target-release-description>
-   
-   <action context="code" category="conformance" who="GP">
-      Verify that the recomposing procedure for each of the recomposable
-      elements matches the standard (including errata).
-   </action>
-
-   <action context="code" category="conformance" who="GP">
-      Fix xsl:output method= so that it only accepts valid values per the
-      standard (xml, html, text, qname-that-is-not-an-ncname).  I'm looking
-      into where this change should be made.
-   </action>
-
-   <action context="code" category="conformance" who="GP">
-      Verify that the element-available function exhibits the proper
-      behavior according to Errata E7 regarding the interaction between the
-      default namespace and the element-available function.
-   </action>
-
-   <action context="code" category="extensions" who="GP">
-      Add compatibility with XalanJ1 NodeSet extension, so that stylehsheets 
-      can work with both processors.
-   </action>
-
-   <action context="code" category="bug" who="SB">
-    Handle qName paramterer to the ContentHandler methods being an empty string.
-    See note from mikael@ingen.reklam.staldal.nu (Mikael Ståldal), 01/01/2001 09:42 AM.
-   </action>
-
-   <action context="code" category="performance" who="SB">
-    Optimize "." patterns to be ultra simple iterator.
-   </action>
-
-   <action context="code" category="performance" who="SB">
-    Optimize "/foo/baz" patterns that have no variability, to a global space, 
-    and don't re-evaluate each time.
-   </action>
-
-  <action context="code" category="feature">
-    Don published a list of proposed extensions a while ago.
-    I would really like to get these implemented.  This is a good
-    area for part-time contributers, as the extensions have limited scope.
-  </action>
-
-  <action context="code" category="performance">
-    Joe could use help with the stylesheet compiler stuff.
-    Lots of work to be done there.  In particular, I would like to
-    figure out how to inline some simple itterator operations,
-    like select="node()" and select="foo".  Also, we need to figure
-    out how to analyze a particular stylesheet's dependencies, and
-    be able to package just those classes in a jar, along with the
-    compiled classes.
-    <issue id="issue-compiler-for-january-release">I suspect it is unlikely this
-    will be ready in time for this release.</issue>
-  </action>
-
-  <action context="test" category="feature" priority="high">
-    @todo need to find an HTML to DOM parser we can use!!
-    Get a good, apache-licensed HTML-to-DOM parser checked into the 
-    xml-xalan\test\java repository, for use by org.apache.qetest.xsl.XHTComparator
-  </action>
-
-  <action context="test" category="tests" priority="medium">
-    Get more real-world stylesheets checked into xml-xalan\test\tests\contrib.
-    We need more real-life examples of how people are using stylesheets, along 
-    with expected outputs (in contrib-gold) - we can then run our test driver 
-    over the whole set of them easily to get more test points.
-    Note: please feel free to contribute tests here - the committers 
-    will review and move tests into conformance, product, etc. test 
-    areas as needed, but we can always just run ContribTest on any tests.
-  </action>
-
-  <action context="test" category="tests" priority="high">
-    Get extension tests checked into xml-xalan\test\tests\extend
-    We have some at Lotus we need to cleanup and checkin, and we 
-    hope to get more examples from Gary and other list members.
-  </action>
-   
-   <action context="code" category="performance" who="SB">
-    Delete nodes in the source tree when possible.  (?? Note sure if this 
-    is do-able by beta2.)
-    <psuedo-code>
-      1) For each expression, tell if expression can traverse outside it's 
-         subtree.
-      2) For each element, tell if any following elements may need to  
-         access that node.
-      3) In instructions that traverse nodes, once the processing of the 
-         node is completed, remove the node if no following elements may 
-         need to access that node.
-      4) Keep the parse events from getting too far ahead of the transform.
-      
-      TODO: In StepPattern, Ancestors tests with predicates are problematic, 
-      and will require special treatment.
-    </psuedo-code>
-   </action>
-
-  <action context="code" category="feature">
-    XPointer built on the XPath package.
-  </action>
-
-  <action context="code" packages="xpath.axes" category="performance">
-    Schema-savy itterators.
-    This is hard because there is no standard API for schemas yet.
-  </action>
-
-  <action context="code" id="stylesheet-analysis" packages="processor" category="performance">
-    Stylesheet analysis module.  When I call a template, where is it likely to walk in the tree?
-    Can I be sure that it will not walk up again?
-  </action>
-
-  <action context="code" packages="stree" category="performance">
-    Related to stylesheet-analysis, the ability to throw away parts of the tree that have been processed,
-    and we know we won't reuse, based on the stylesheet analysis.
-  </action>
-
-  <action context="code" packages="processor" category="performance">
-    Sub-expression elimination.  When I call a series of
-    xsl:when tests, are there common subexpressions that can be
-    executed once and then shared?
-  </action>
-
-  <action context="code">
-  </action>
-
- </actions>
-
- <completed>
-  <!-- Move action sections to here when completed, and date them. -->
-  
-   <action context="doc" category="documentation" who="SB" completed="01/12/01">
-    Update and add to architecture documentation, including package headers.
-   </action>
-
-   <action context="code" category="error-handling" who="SB" completed="01/06/01">
-    Simplify some of the exception nesting, maybe, and make sure error listeners 
-    are being called for all cases.
-    <note>Fixed bug with XPaths in this area.  Most of the nesting is being caused 
-    by TranformerHandler to SAXException nesting, which can be unnested.</note>
-   </action>
-  
-   <action context="code" category="bug" who="SB" completed="01/06/01">
-    Fix 1.8 problems: extend01 (exception), numberformat 06, numberformat16, output77 (exception).
-    JDK 1.1.8, using xml-xalan\test\ConformanceTest.bat, runharness.bat, and testthreads.bat as-is.
-    <note>The number format stuff is a bug in JDK 1.8 and can't easily be fixed 
-    or hacked.</note>
-   </action>
-
-   <!-- action context="code" category="feature" who="SB" completed="01/04/01">
-    Integrate John Gentilin &lt;johnglinux@eyecatching.com> code, 
-    for SQL Extension Enhancements.
-   </action  (CHANGES BACKED OUT OF) -->
-
-   <action context="code" category="bug" who="SB" completed="01/04/01">
-    Implement xsl:strip-space for generic DOM processing.
-   </action>
-
-   <action context="code" category="performance" who="SB" completed="01/03/01">
-    For default transformer, do direct transform without stylesheet.
-   </action>
-   
-   <action context="code" category="documentation" who="SB" completed="01/01/01">
-    Fix some javadoc headers that still have old XalanJ1 text.  For instance, 
-    TransformerImpl.
-   </action>
-  
-   <action context="code" category="bugs" who="SB" completed="12/31/00">
-    Fix bug with Shane's s2s test hang.
-   </action>
-   
-   <action context="code" category="bugs" who="SB, JK" completed="12/31/00">
-    Fix bug with rare intermittent failures, probably in the STree.
-    <note>Verification testing on JK's machine needed.</note>
-   </action>
-
-   <action context="code" category="performance" who="SB" completed="12/26/00">
-    Optimize "/foo/baz" patterns to use simple child walkers.
-   </action>
-  
-  <action context="test" who="SC" category="minitest" priority="medium" completed="12/08/00">
-    Create Minitest automated test for developers to run before checkin; 
-    verifies basic functionality of TRAX interface and Xalan processor. 
-    (Still todo, minor: get xalan-dev list to vote to use this)
-  </action>
-
-  <action context="code" category="architecture" priority="high" who="SB" completed="12/10/00">
-    Fix remaining axes tests.
-  </action>
-
-  <action context="code" category="performance" priority="high" who="MM" completed="12/8/00">
-    When using STree for the input, use STree for the document() and
-    result tree fragments.
-  </action>
-
-  <action context="code" category="architecture, conformance" priority="high" who="SB" completed="12/06/00">
-    Restructure OutputFormat class to be based on properties.  Make sure 
-    include/import conformance is correct.
-  </action>
-  
-  <action context="code" category="architecture" priority="high" who="SB" completed="12/06/00">
-    Make entities in the html serializer to be resource file driven.
-  </action>
-  
-  <action context="code" category="architecture" priority="high" who="SB" completed="12/06/00">
-    Removed linefeed normalization from serializers.  I think.
-  </action>
-
-  <action context="code" completed-date="10/31/00">
-    Make this todo list.
-  </action>
-
-  <action context="code" who="SB"  category="trax" completed-date="11/06/00">
-    implement javax.trax interfaces.
-  </action>
-
-  <action context="code" packages="serialize" who="SB"  category="feature"
-          completed-date="11/17/00">
-    Implement DOMSerializer on SerializerToXML.
-  </action>
-
-  <action context="code" who="SB" packages="xpath.axes" category="performance"
-          priority="high" completed-date="11/17/00">
-    implement fast iterator for "foo" pattern.
-  </action>
-
-  <action context="code" who="MM" category="performance" priority="high" completed-date="11/29/00">
-    optimize xsl:key and key() stuff by building hash table of iterators for
-    each key.
-  </action>
-
-  <action context="code" category="code-cleanup" priority="medium" completed="12/01/00">
-    Clean up treatment of null namespaces, re "" vs. null.
-    <completed-comment>I consider this to be pretty good in most places.  "" 
-    equals the default namespace.  No pending plans for action, other than ongoing 
-    cleanup and javadoc as it occurs.</completed-comment>
-  </action>
-  
-  <action context="code"  category="conformance" priority="high" completed="12/10/00">
-    Implement namespace aliasing.
-  </action>
-
-  <action context="code" packages="templates" category="conformance" priority="medium"
-          note="done?" completed="11/29/00">
-    Catch multiple definitions of a variable with the same name and scope.
-  </action>
-  
-  <action context="code" category="code-cleanup" priority="medium" completed="11/25/00">
-    Move org.apache.xalan.utils package to org.apache.xml.utils.
-    remove resource dependencies on xalan and/or xpath package.
-  </action>
-  
-  <action context="code" category="code-cleanup, performance" packages="templates"
-   priority="medium" who="GP" completed="11/30/00">
-    Refactored the recompose logic to operate more cleanly and quickly. Fixed TemplateList
-    to properly order templates.
-  </action>
-  
-  <action context="code" category="code-cleanup" packages="extensions"
-   priority="medium" who="GP" completed="10/29/00">
-    Improved error reporting for java extension method errors.
-  </action>
-  
-  <action context="code" category="documentation" priority="medium" who="GP" completed="11/23/00">
-    Updated documentation for Extension Handling to conform to the new extension mechanism.
-  </action>
-  
-  <action context="code" category="feature" priority="medium" who="GP" completed="12/03/00">
-    Changed extension mechanism to load extensions using the thread's ContextClassLoader,
-    if available.
-  </action>
-  
-  <action context="code" category="feature" packages="extensions" 
-   priority="medium" who="GP" completed="11/28/00">
-    Implement tokenize extension.  Implement element-available and function-available for
-    built-in elements and functions.
-  </action>
-  
-  <action context="code" category="code-cleanup" packages="extensions" 
-   priority="medium" who="GP" completed="11/07/00">
-     Fix handling of xsl:fallback elements within extension elements that process their own
-     code (like redirect).
-  </action>
-  
-  <action context="code" category="code-cleanup" packages="compiler" 
-   priority="medium" who="GP" completed="11/09/00">
-     Cleaned up compiler handling of getWhatToShow() to result in cleaner code and provide
-     a more accurate filter.
-  </action>
-  
-  <action context="code" who="SB" packages="xpath.axes" category="performance" priority="high" completed="12/13/00">
-    implement fast iterator for "@foo" pattern.
-  </action>
-
-  <action context="code" who="SB" packages="xpath.axes" category="performance" priority="high" completed="12/14/00">
-    implement fast iterator for "//foo" pattern.
-  </action>
-  
-   <action context="code" category="code-cleanup" who="DL" packages="xalanservlet" priority="medium" completed="12/15/00">
-     Rewrite the sample servlet to use the TrAX interfaces and eliminate setting system properties
-     within the servlet.
-  </action>  
-
-  <action context="code" who="SB" packages="org.apache.xalan.serialize" category="samples" priority="high" completed="12/16/00">
-    Fix the serializer so it can serialize arbitrary XPath expression results (other than Document nodes).
-    As it currently stands, the ApplyXPath sample only works when you give it an expression that returns 
-    the entire Document.
-  </action>
-  
-  <action context="code" category="documentation" priority="high" completed="12/17/00">
-    Fill in all NEEDSDOC sections.
-  </action>
-
-  <action context="code" category="code-cleanup" who="DL" packages="xalan.client" priority="medium" completed="12/17/00">
-    Rewrite the client applet to use the TrAX interfaces, and move fetching of source
-    documents and stylesheets to the trusted worker thread to get around IE security restrictions.
-  </action>
-
-  <action context="code"  category="conformance" priority="high" completed="12/19/00">
-    Check relative URL resolution with notations and unparsed entities.
-    Not sure if there is a bug here.  See note from Thomal Maesing on
-    10/24/2000, titled "Antwort: Re:".
-  </action>
-
-  <action context="test" category="feature" priority="high" completed="12/19/00">
-    Update the xml-xalan\test\viewResults.xsl stylesheet to show 
-    differences between two result files from the same test (eg.
-    show differences from a results-before.xml run before a developer 
-    makes a change, with results-after.xml, which was after the 
-    developer's change.)
-    This could be a bunch of stuff added to viewResults.xsl or could 
-    be a separate stylesheet. See <b>SC</b> for details.
-  </action>
-
- </completed>
-
-</todo>
diff --git a/todo.xsl b/todo.xsl
deleted file mode 100644
index 2406854..0000000
--- a/todo.xsl
+++ /dev/null
@@ -1,146 +0,0 @@
-<?xml version="1.0"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-
-  <xsl:template match="/">
-    <HTML>
-      <HEAD>
-         <TITLE>Xalan-Java Version 2</TITLE>
-      </HEAD>
-      <BODY>
-        <!-- H1>Xalan for Java Version 2</H1 -->
-        <H2>Xalan for Java Version 2: <xsl:value-of select="todo/@title"/></H2>
-        <p><font size="-1">See a 
-          <xsl:element name="a">
-            <xsl:attribute name="href">#developer-list</xsl:attribute>
-            <xsl:text>list of developers/initials.</xsl:text>
-          </xsl:element>
-        </font></p>
-        <font size="-1"><p>Planned releases: 
-            <BR/><xsl:for-each select="todo/actions/target-release-description">
-              <xsl:element name="a">
-                <xsl:attribute name="href">#release-date-<xsl:value-of select="date"/></xsl:attribute>
-                <xsl:value-of select="date"/>
-              </xsl:element><xsl:text> </xsl:text><xsl:text> </xsl:text>
-            </xsl:for-each>
-            <xsl:element name="a">
-                <xsl:attribute name="href">#release-date-completed</xsl:attribute>
-                <xsl:text>Completed</xsl:text>
-              </xsl:element>
-
-        </p></font>
-        <xsl:for-each select="todo">
-          <xsl:for-each select="actions">
-              <xsl:for-each select="target-release-description">
-                <p>
-                  <xsl:apply-templates/>
-                </p>
-              </xsl:for-each>
-              <xsl:for-each select="action">
-                <xsl:if test="normalize-space(.)">
-                  <p>
-                   <xsl:number/>) <xsl:apply-templates/>
-                   <xsl:if test="@*">
-                    <BR/>
-                   </xsl:if>
-                   <xsl:apply-templates select="@*"/>
-                  </p>
-                </xsl:if>
-            </xsl:for-each>
-            <HR/>
-          </xsl:for-each>
-
-          <xsl:for-each select="completed">
-              <xsl:element name="a">
-                <xsl:attribute name="name">release-date-completed</xsl:attribute>
-                <H3>Completed: </H3>
-              </xsl:element>
-            <xsl:for-each select="action">
-              <xsl:if test="normalize-space(.)">
-                <p>
-                 <xsl:number/>) <xsl:apply-templates/>
-                 <xsl:if test="@*">
-                  <BR/>
-                 </xsl:if>
-                 <xsl:apply-templates select="@*"/>
-                </p>
-              </xsl:if>
-          </xsl:for-each>
-          <HR/>
-        </xsl:for-each>
-
-        <xsl:call-template name="developer-list"/>
-       </xsl:for-each>
-
-      </BODY>
-    </HTML>
-  </xsl:template>
-
-  <xsl:template match="action/@*">
-  <!-- Add link to the who attributes to corresponding item in developer-list -->
-    <b><xsl:value-of select="name(.)"/>:</b><xsl:text> </xsl:text>
-      <xsl:choose>
-        <xsl:when test="name(.)='who'">
-          <xsl:element name="a">
-            <xsl:attribute name="href">#personref-<xsl:value-of select="."/></xsl:attribute>
-            <xsl:value-of select="."/>
-          </xsl:element>
-        </xsl:when>
-        <xsl:otherwise>
-          <xsl:value-of select="."/>
-        </xsl:otherwise>
-      </xsl:choose>
-    <xsl:if test="not (position()=last())">
-      <xsl:text>, </xsl:text>
-    </xsl:if>
-  </xsl:template>
-
-  <xsl:template match="target-release-description/date">
-      <xsl:element name="a">
-        <xsl:attribute name="name">release-date-<xsl:value-of select="."/></xsl:attribute>
-        <b><xsl:text>For release: </xsl:text><xsl:value-of select="."/></b>
-      </xsl:element>
-    
-  </xsl:template>
-
-  <xsl:template match="issue">
-    <BR/><b>Issue </b><xsl:text>[</xsl:text><xsl:value-of select="@id"/>
-    <xsl:text>]: </xsl:text>
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <xsl:template match="target-release-description/level">
-    <xsl:text>, </xsl:text><xsl:apply-templates/>
-  </xsl:template>
-
-  <xsl:template match="target-release-description/goal">
-    <BR/><b>Goal </b><xsl:text>[</xsl:text><xsl:value-of select="@type"/>
-    <xsl:text>]: </xsl:text>
-    <xsl:apply-templates/>
-  </xsl:template>
-
-
-  <xsl:template name="developer-list">
-    <H3>
-      <xsl:element name="a">
-        <xsl:attribute name="name">developer-list</xsl:attribute>
-        <xsl:text>Developers:</xsl:text>
-      </xsl:element>
-    </H3>
-    <p>A list of some of people working on Xalan currently:</p>
-    <ul>
-    <xsl:for-each select="devs/person">
-      <li>
-        <a href="mailto:{@email}">
-          <xsl:value-of select="@name"/>
-        </a>
-         <xsl:element name="a">
-           <xsl:attribute name="name"><xsl:text>personref-</xsl:text><xsl:value-of select="@id"/></xsl:attribute>
-           <xsl:text> (</xsl:text><xsl:value-of select="@id"/><xsl:text>)</xsl:text>
-         </xsl:element>
-         <BR/><xsl:value-of select="."/>
-      </li>
-    </xsl:for-each>
-    </ul>
-  </xsl:template>
-
-</xsl:stylesheet>
diff --git a/trax_bugs.xml b/trax_bugs.xml
deleted file mode 100644
index cb6f9c5..0000000
--- a/trax_bugs.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0"?>
-<?xm-well_formed path="E:\xml-xalan\java\bugs.dtd"?>
-<!-- This should contain *only* SPRs (Software Problem Reports) for the TrAX API 
-     interfaces and classes. -->
-<Sprs><Spr><Name>TRAXSPR0001</Name>
-<DateCreated>11/15/2000</DateCreated>
-<State>Open</State>
-<TestDesc>SAXTransformerFactoty#FEATURE should document support for all TransformerFactories.</TestDesc><Details><![CDATA[In SAXTransformerFactoty:
-
-    /** If {@link javax.xml.transform.TransformerFactory#getFeature}
-     * returns true when passed this value as an argument,
-     * the TransformerFactory returned from
-     * {@link javax.xml.transform.TransformerFactory#newInstance} may
-     * be safely cast to a SAXTransformerFactory.
-     */
-    public static final String FEATURE =
-
-I propose you remove the phrase "returned from
-TransforerFactory.newInstance". Isn't the intent that feature testing
-can be done on all TransformerFactories, regardless how they are
-created? It can be like this instead:
-
-    /** If {@link javax.xml.transform.TransformerFactory#getFeature}
-     * returns true when passed this value as an argument,
-     * the TransformerFactory can be safely cast to a
-     * SAXTransformerFactory.
-     */]]></Details></Spr><Spr><Name>TRAXSPR0002</Name>
-<DateCreated>11/15/2000</DateCreated>
-<State>Open</State>
-<TestDesc>OutputKeys#method should document qname instead of qname-but-not-ncname</TestDesc><Details><![CDATA[In OutputKeys:
-
-    /**
-     * method = "xml" | "html" | "text" | <var>qname-but-not-ncname</var>.
-     *
-     * <p>The method attribute identifies the overall method that
-     * should be used for outputting the result tree.  Other
-     * non-namespaced values may be used,
-
-This is contradictary, change "qname-but-not-ncname" to "qname".]]></Details></Spr>
-<Spr><Name>TRAXSPR0003</Name>
-<DateCreated>11/15/2000</DateCreated>
-<State>Open</State>
-<TestDesc></TestDesc><Details><![CDATA[]]></Details></Spr>
-<Spr><Name>TRAXSPR0004</Name>
-<DateCreated>11/15/2000</DateCreated>
-<State>Open</State>
-<TestDesc></TestDesc><Details><![CDATA[]]></Details></Spr>
-<Spr><Name>TRAXSPR0005</Name>
-<DateCreated>11/15/2000</DateCreated>
-<State>Open</State>
-<TestDesc></TestDesc><Details><![CDATA[]]></Details></Spr>
-
-</Sprs>
diff --git a/xdocs/sources/design/compilation.gif b/xdocs/sources/design/compilation.gif
deleted file mode 100644
index 675d7d4..0000000
--- a/xdocs/sources/design/compilation.gif
+++ /dev/null
Binary files differ
diff --git a/xdocs/sources/design/conceptual.gif b/xdocs/sources/design/conceptual.gif
deleted file mode 100644
index 283fee5..0000000
--- a/xdocs/sources/design/conceptual.gif
+++ /dev/null
Binary files differ
diff --git a/xdocs/sources/design/data.gif b/xdocs/sources/design/data.gif
deleted file mode 100644
index 0f28a17..0000000
--- a/xdocs/sources/design/data.gif
+++ /dev/null
Binary files differ
diff --git a/xdocs/sources/design/design2_0_0.xml b/xdocs/sources/design/design2_0_0.xml
deleted file mode 100644
index d0fc2e5..0000000
--- a/xdocs/sources/design/design2_0_0.xml
+++ /dev/null
@@ -1,272 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE s1 SYSTEM "sbk:/style/dtd/document.dtd">
-<s1 title="Xalan-J 2.0 Design">
-  <p><link>Xalan-J 2.0 Design</link><img src="xmllogo.gif" alt="xmllogo.gif"/></p>
-  <p>Author: Scott Boag<br/>State: In Progress</p>
-  <ul> 
-	   <li><link anchor="intro">Introduction</link></li>
- 	   <li><link anchor="requirements">Xalan Requirements</link></li>
-	   <li><link anchor="overarch">Overview of Architecture</link></li>
-	   <li><link anchor="process">Process Module</link></li>
-	   <li><link anchor="templates">Templates Module</link></li>
-	   <li><link anchor="transformer">Transformer Module</link></li>
-       <ul>
-         <li><link anchor="stree">Stree Module</link></li>
-         <li><link anchor="extensions">Extensions Module</link></li>
-     </ul>
-	   <li><link anchor="xpath">XPath Module</link></li>
-       <ul><li><link anchor="xpathdbconn">XPath Database Connection</link></li></ul>
-	   <li><link anchor="utils">Utils Package</link></li>         
-	   <li><link anchor="other">Other Packages</link></li>         
-	   <li><link anchor="compilation">Xalan Stylesheet Complilation to Java</link></li><li><link anchor="optimizations">Future Optimizations</link></li><li><link anchor="coding">Coding Conventions</link></li>
-	        
-   <li><jump href="../apidocs/index.html">Xalan-J 2.0 Javadoc</jump></li>
-  </ul><anchor name="intro"/>
-  <s2 title="Introduction"> 
-	 <p><link>Introduction</link></p> 
-	 <p>This document presents the basic design for Xalan-J 2.0, which is a
-		<jump href="http://www.awl.com/cseng/titles/0-201-89542-0/techniques/refactoring.htm">refactoring</jump>
-		and redesign of the Xalan-J 1.x processor.   This document will expand and grow over time, and is also incomplete in some sections, though hopefully overall accurate.  The reader should be able to get a good overall idea of the internal design of Xalan, and begin to understand the process flow, and also the technical challanges.</p> 
-	 <p>The main goals of this redesign are
-		to: </p><ol> 
-		<li>Make the design and code more understandable by Open Source
-		  people.</li> 
-		<li>Reduce code size and complexity.</li>
-		<li>By simplifying the code, make optimization easier.</li> 
-		<li>Make modules generally more localized, and less tangled with other
-		  modules.</li> 
-		<li>Conform to the <jump href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_063_jaxp11.html">javax.xml.transform  (TrAX [Transformations for XML])</jump> interfaces.</li> 
-	 <li>Increase the ability to incrementally produce the result tree.</li></ol> 
-	 <p>The techniques used toward these goals are to:</p> 
-	 <ol> 
-		<li>In general, flatten the hierarchy of packages, in order to make the
-		  structure more apparent from the top-level view.</li> 
-		<li>Break the construction and the validation of the XSLT stylesheet from
-		  the stylesheet objects themselves.</li>
-		<li>Drive the construction of the stylesheet through a table, so that it
-		  is less prone to error.</li> 
-		<li>Break the transformation process into a separate package, away from
-		  the stylesheet objects.</li> 
-		<li>Create this design document, as a starting point for people interested in
-		  approaching the code.</li> 
-	 </ol> 
-	 <p>The goals are not:</p> 
-	 <ol> 
-		<li>To add more features in the progress of this refactoring. This is
-		  design and code clean-up in order to meet the above-named goals. We expect that it will be <em>much</em> easier to add
-		  features once this work is completed.</li> 
-		<li>To optimize code for the sake of optimization. However, we
-		  expect that the code will be faster once this work is complete.</li> 
-	 </ol> 
-	 <p>How well we've achieved the goals will be measured by feedback from the
-		<jump href="http://archive.covalent.net/">Xalan-dev</jump> list, and by software metrics tools.</p> 
-	 <p>Please note that the diagrams in this design document are meant to be
-		useful abstractions, and may not always be exact.</p> 
-  </s2><anchor name="requirements"/> 
-  <s2 title="Xalan Requirements"><p><link>Xalan Requirements</link></p><p>These are the concrete general requirements of Xalan, as I understand them, and covering both the Java and C++ versions.  These requirements have been built up over time by experience with product groups and general users.</p><ol><li>Java, C++ Versions.</li><li>XSLT 1.0 conformance, and beyond. (i.e. conform to the current W3C recommendation).</li><li>Have design and Code understandable by Open Source Community.</li><li>Ability to interoperate with standard APIs.  (SAX2, DOM2, JAXP)  [this is currently Less of an issue with C++].</li><li>High Performance (Raw performance, Incremental ability, Scaleability to large documents, Reduction of Garbage Collection for the Java version.)</li><li>Tooling API (Access stylesheet data structures, Access source node from result event, Ask runtime questions, Debugging API).</li><li>Support addressing of XML in standalone fashion (i.e. XPath API).</li><li>Extensibility (Ability to call Java, Ability to call JavaScript, other languages).</li><li>Multiple data sources (JDBC, LDAP, other data sources, Direct XML repository coupling).</li></ol></s2><anchor name="overarch"/> 
-  <s2 title="Overview of Architecture"> 
-	 <p><link>Overview of Architecture</link></p><p>The following diagram shows the XSLT abstract processing model.  A transformation expressed in XSLT describes rules for transforming a <jump href="http://www.w3.org/TR/xpath#data-model">Source Tree </jump> into a result tree. The transformation is achieved by associating patterns with templates. A pattern is matched against elements in the source tree. A template is instantiated to create part of the result tree. The result tree is separate from the source tree. The structure of the result tree can be completely different from the structure of the source tree. In constructing the result tree, elements from the source tree can be filtered and reordered, and arbitrary structure can be added.
-
-</p><p>The term "tree", as used within this document, describes an
-			 abstract structure that consists of nodes or events that may be produced by
-			 XML. A Tree physically may be a DOM tree, a series of well balanced parse
-			 events (such as those coming from a SAX2 ContentHander), a series of requests
-			 (the result of which can describe a tree), or a stream of marked-up
-			 characters.</p><p><img src="xslt_abstract.gif" alt="xslt_abstract.gif"/></p><p>The primary interface for Xalan 2.0 external usage is defined in the <jump href="../apidocs/javax/xml/transform/package-summary.html#package_description">javax.xml.transform</jump> interfaces.  These interfaces define a standard and powerful interface to perform tree-based transformations.</p> 
-	 <p>The internal architecture of Xalan 2.0 is divided into four major modules, and various smaller
-		modules. The main modules are:</p> 
-	 <gloss> 
-		<label><code><jump href="../apidocs/org/apache/xalan/processor/package-summary.html">org.apache.xalan.processor</jump></code></label> 
-		<item>The module that processes the stylesheet, and provides the main
-		  entry point into Xalan.</item> 
-	 </gloss> 
-	 <gloss> 
-		<label><code><jump href="../apidocs/org/apache/xalan/templates/package-summary.html">org.apache.xalan.templates</jump></code></label> 
-		<item>The module that defines the stylesheet structures, including the
-		  Stylesheet object, template element instructions, and Attribute Value
-		  Templates. </item> 
-	 </gloss> 
-	 <gloss> 
-		<label><code><jump href="../apidocs/org/apache/xalan/transformer/package-summary.html">org.apache.xalan.transformer</jump></code></label> 
-		<item>The module that applies the source tree to the Templates, and
-		  produces a result tree.</item> 
-	 </gloss> 
-	 <gloss> 
-		<label><code><jump href="../apidocs/org/apache/xpath/package-summary.html">org.apache.xpath</jump></code></label> 
-		<item>The module that processes both XPath expressions, and XSLT Match
-		  patterns.</item> 
-	 </gloss> 
-	 <p>In addition to the above modules, Xalan implements the
-		<jump href="../apidocs/javax/xml/transform/package-summary.html#package_description">javax.xml.transform</jump> interfaces, and depends on the
-	 <jump href="http://www.megginson.com/SAX/Java/index.html">SAX2</jump> and <jump href="http://www.w3.org/TR/DOM-Level-2/">DOM</jump> packages.
-</p><p><img src="trax.gif" alt="trax.gif"/></p><p>There is also a general utilities package that contains both XML utility
-	 classes such as QName, but generally useful classes such as
-	 StringToIntTable.</p> 
-	 <p>In the diagram below, the dashed lines denote visibility. All packages
-		access the SAX2 and DOM packages.</p> 
-	 <p><img src="xalan1_1x1.gif" alt="xalan1_1x1.gif"/></p> 
-	 <p>In addition to the above packages, there are the following additional
-		packages:</p> 
-	 <gloss> 
-		<label><code><jump href="../apidocs/org/apache/xalan/client/package-summary.html">org.apache.xalan.client</jump></code></label> 
-		<item>This package has a client applet. I suspect this should be moved
-		  into the samples directory.</item> 
-	 </gloss> 
-	 <gloss> 
-		<label><code><jump href="../apidocs/org/apache/xalan/extensions/package-summary.html">org.apache.xalan.extensions</jump></code></label> 
-		<item>This holds classes belonging to the Xalan extensions mechanism,
-		  which allows Java code and script to be called from within a stylesheet.</item>
-		
-	 </gloss> 
-	 <gloss> 
-		<label><code><jump href="../apidocs/org/apache/xalan/lib/package-summary.html">org.apache.xalan.lib</jump></code></label> 
-		<item>This is the built-in Xalan extensions library, which holds
-		  extensions such as Redirect (which allows a stylesheet to produce multiple
-		  output files).</item> 
-	 </gloss> 
-	 <gloss> 
-		<label><code><jump href="../apidocs/org/apache/xalan/res/package-summary.html">org.apache.xalan.res</jump></code></label> 
-		<item>This holds resource files needed by Xalan, such as error message
-		  resources.</item> 
-	 </gloss> 
-	  
-	 <gloss> 
-		<label><code><jump href="../apidocs/org/apache/xalan/trace/package-summary.html">org.apache.xalan.trace</jump></code></label> 
-		<item>This package contains classes and interfaces that allow a caller to
-		  add trace listeners to the transformation, allowing an interface to XSLT
-		  debuggers and similar tools.</item> 
-	 </gloss> 
-	 <gloss> 
-		<label><code><jump href="../apidocs/org/apache/xalan/xslt/package-summary.html">org.apache.xalan.xslt</jump></code></label> 
-		<item>This package holds the Xalan2 command line processor.</item> 
-	 </gloss> 
-  <p>A more conceptual view of this architecture is as follows:</p><p><img src="conceptual.gif" alt="Picture of conceptual architecture."/></p></s2><anchor name="process"/> 
-  <s2 title="Process Module"> 
-	 <p><link>Processor Module</link></p> 
-	 <p>The <code><jump href="../apidocs/org/apache/xalan/processor/package-summary.html">org.apache.xalan.processor</jump></code> module implements the
-		<code><jump href="../apidocs/javax/xml/transform/TransformerFactory.html">javax.xml.transform.TransformerFactory</jump></code> interface, which provides a
-		factory method for creating a concrete Processor instance, and provides methods
-		for creating a <code><jump href="../apidocs/javax/xml/transform/Templates.html">javax.xml.transform.Templates</jump></code> instance, which, in
-		Xalan and XSLT terms, is the Stylesheet. Thus the task of the process module is
-		to read the XSLT input in the form of a file, stream, SAX events, or a DOM
-		tree, and produce a Templates/Stylesheet object.</p> 
-	 <p>The overall strategy is to define a schema in that dictates the legal
-		structure for XSLT elements and attributes, and to associate with those
-		elements construction-time processors that can fill in the appropriate fields
-		in the top-level Stylesheet object, and also associate classes in the templates
-		module that can be created in a generalized fashion. This makes the validation
-		object-to-class associations centralized and declarative.</p> 
-	 <p>The schema's root class is
-		<code><jump href="../apidocs/org/apache/xalan/processor/XSLTSchema.html">org.apache.xalan.processor.XSLTSchema</jump></code>, and it is here that the
-		XSLT schema structure is defined. XSLTSchema uses
-		<code><jump href="../apidocs/org/apache/xalan/processor/XSLTElementDef.html">org.apache.xalan.processor.XSLTElementDef</jump></code> to define elements, and
-		<code><jump href="../apidocs/org/apache/xalan/processor/XSLTAttributeDef.html">org.apache.xalan.processor.XSLTAttributeDef</jump></code> to define attributes.
-		Both classes hold the allowed namespace, local name, and type of element or
-		attribute. The XSLTElementDef also holds a reference to a
-		<code><jump href="../apidocs/org/apache/xalan/processor/XSLTElementProcessor.html">org.apache.xalan.processor.XSLTElementProcessor</jump></code>, and a sometimes a
-		<code>Class</code> object, with which it can create objects that derive from
-		<code><jump href="../apidocs/org/apache/xalan/templates/ElemTemplateElement.html">org.apache.xalan.templates.ElemTemplateElement</jump></code>. In addition, the
-		XSLTElementDef instance holds a list of XSLTElementDef instances that define
-		legal elements or character events that are allowed as children of the given
-		element.</p> 
-	 <p>The implementation of the <code><jump href="../apidocs/javax/xml/transform/TransformerFactory.html">javax.xml.transform.TransformerFactory</jump></code>
-		interface is in <code><jump href="../apidocs/org/apache/xalan/processor/TransformerFactoryImpl.html">org.apache.xalan.processor.TransformerFactoryImpl</jump></code>,
-		which creates a <code><jump href="../apidocs/org/apache/xalan/processor/StylesheetHandler.html">org.apache.xalan.processor.StylesheetHandler</jump></code>
-		instance. This instance acts as the ContentHandler for the parse events, and is
-		handed to the <code><jump href="../apidocs/org/xml/sax/XMLReader.html">org.xml.sax.XMLReader</jump></code>, which the StylesheetProcessor
-		uses to parse the XSLT document. The <code>StylesheetHandler</code> then receives the parse
-		events, which maintains the state of the construction, and passes the events on
-		to the appropriate <code>XSLTElementProcessor</code> for the given event, as dictated by the
-		<code>XSLTElementDef</code> that is associated with the given event.</p> 
-	 </s2><anchor name="templates"/> 
-  <s2 title="Templates Module"> 
-	 <p><link>Templates Module</link></p> 
-	 <p>The <code><jump href="../apidocs/org/apache/xalan/templates/package-summary.html">org.apache.xalan.templates</jump></code> module implements the
-		<code><jump href="../apidocs/javax/xml/transform/Templates.html">javax.xml.transform.Templates</jump></code> interface, and defines a set of
-		classes that represent a Stylesheet. The primary purpose of this module is to
-		hold stylesheet data, not to perform procedural tasks associated with the
-		construction of the data, nor tasks associated with the transformation itself.
-		</p> 
-	 <p>The base class of all templates objects that are associated with an XSLT element is the <code><jump href="../apidocs/org/apache/xalan/templates/ElemTemplateElement.html">ElemTemplateElement</jump></code> object, which in turn implements <code><jump href="../apidocs/org/apache/xml/utils/UnImplNode.html">UnImplNode</jump></code>.   A <code>ElemTemplateElement</code> object must be immutable once it's constructed, so that it may be shared among multiple threads concurrently.  Ideally, a <code>ElemTemplateElement</code> should be a data object only, and be used via a visitor pattern.  However, in practice this is impractical, because it would cause too much data exposure and would have a significant impact on performance.  Therefore, each <code>ElemTemplateElement</code> class has an <code><jump href="../apidocs/org/apache/xalan/templates/ElemTemplateElement.html#execute(org.apache.xalan.transformer.TransformerImpl, org.w3c.dom.Node, org.apache.xml.utils.QName)">execute</jump></code> method where it performs it's transformation duties.  A <code>ElemTemplateElement</code> also knows it's position in the source stylesheet, and can answer questions about current namespace nodes.</p><p>A <code><jump href="../apidocs/org/apache/xalan/templates/StylesheetRoot.html">StylesheetRoot</jump></code>, which implements the
-		<code>Templates</code> interface, is a type of <code><jump href="../apidocs/org/apache/xalan/templates/StylesheetComposed.html">StylesheetComposed</jump></code>,
-		which is a <code><jump href="../apidocs/org/apache/xalan/templates/Stylesheet.html">Stylesheet</jump></code> composed of itself and all included
-		<code>Stylesheet</code> objects. A <code>StylesheetRoot</code> has a global
-		imports list, which is a list of all imported <code>StylesheetComposed</code>
-		instances. From each <code>StylesheetComposed</code> object, one can iterate
-		through the list of directly or indirectly included <code>Stylesheet</code>
-		objects, and one call also iterate through the list of all
-		<code>StylesheetComposed</code> objects of lesser import precedence.
-		<code>StylesheetRoot</code> is a <code>StylesheetComposed</code>, which is a
-		<code>Stylesheet</code>.</p> 
-	 <p>Each stylesheet has a set of properties, which can be set by various
-		means, usually either via an attribute on xsl:stylesheet, or via a top-level
-		xsl instruction (for instance, xsl:attribute-set). The get methods for these
-		properties only access the declaration within the given <code>Stylesheet</code>
-		object, and never takes into account included or imported stylesheets. The
-		<code>StylesheetComposed</code> derivative object, if it is a root
-		<code>Stylesheet</code> or imported <code>Stylesheet</code>, has "composed"
-		getter methods that do take into account imported and included stylesheets, for
-		some of these properties.</p> 
-	  
-  </s2><anchor name="transformer"/> 
-  <s2 title="Transformer Module"> 
-	 <p><link>Transformer Module</link></p> 
-	 <p>The <jump href="../apidocs/org/apache/xalan/transformer/package-summary.html">Transformer</jump> module is in charge of run-time transformations.  The <jump href="../apidocs/org/apache/xalan/transformer/TransformerImpl.html">TransformerImpl</jump> object, which implements the TrAX <jump href="../apidocs/javax/xml/transform/Transformer.html">Transformer</jump> interface, and has an association with a <jump href="../apidocs/org/apache/xalan/templates/StylesheetRoot.html">StylesheetRoot</jump> object, begins the processing of the source tree (or provides a <jump href="http://www.megginson.com/SAX/Java/javadoc/org/xml/sax/ContentHandler.html">ContentHandler</jump> reference via the<code><jump href="../apidocs/org/apache/xalan/stree/SourceTreeHandler.html">SourceTreeHandler</jump></code>), and performs the transformation.  The Transformer package does as much of the transformation as it can, but element level operations are generally performed in the <jump href="../apidocs/org/apache/xalan/templates/ElemTemplateElement.html#execute(org.apache.xalan.transformer.TransformerImpl, org.w3c.dom.Node, org.apache.xalan.utils.QName)">ElemTemplateElement.execute(...)</jump> methods.</p><p>Result Tree events are fed into a <jump href="../apidocs/org/apache/xalan/transformer/ResultTreeHandler.html">ResultTreeHandler</jump> object, which acts as a layer between the direct calls to the result 
-tree content handler (often a <jump href="../apidocs/org/apache/xalan/serialize/package-summary.html">Serializer</jump>), and the <code>Transformer</code>.  For one thing, 
- we have to delay the call to
- startElement(name, atts) because of the
- xsl:attribute and xsl:copy calls.  In other words,
- the attributes have to be fully collected before you
- can call startElement.</p><p>Other important classes in this package are:</p><gloss><label>CountersTable and Counter</label><item>The <code><jump href="../apidocs/org/apache/xalan/transformer/Counter.html">Counter</jump></code> class does incremental counting for support of xsl:number.
- This class stores a cache of counted nodes (m_countNodes). 
-  It tries to cache the counted nodes in document order... 
- the node count is based on its position in the cache list.  The <code><jump href="../apidocs/org/apache/xalan/transformer/CountersTable.html">CountersTable</jump></code> class is a table of counters, keyed by <code><jump href="../apidocs/org/apache/xalan/templates/ElemNumber.html">ElemNumber</jump></code> objects, each 
- of which has a list of <code>Counter</code> objects.</item></gloss><gloss><label>KeyIterator, KeyManager, and KeyTable</label><item>These classes handle mapping of keys declared with the xsl:key element.  They attempt to work incrementally, locating nodes on request but indexing all as they traverse the tree, and stopping when the requested node is found.  If a requested node is not found, then the entire tree will be traversed.  Such is the nature of xsl:key.</item></gloss><gloss><label>TransformState</label><item>This interface is meant to be used by a consumer of SAX2 events produced by Xalan, and enables the consumer 
- to get information about the state of the transform.  It 
- is primarily intended as a tooling interface.</item></gloss><p>Even though the following modules are defined in the <code>org.apache.xalan</code> package, instead of the transformer package, they are defined in this section as they are mostly related to runtime transformation.</p><anchor name="stree"/>
-  <s3 title="Stree Module"><p><link>Stree Module [And discussions about streaming]</link></p><p>The Stree module implements the default <jump href="http://www.w3.org/TR/xpath#data-model">Source Tree </jump> for Xalan, that is to be transformed.  It implements read-only <jump href="http://www.w3.org/TR/DOM-Level-2/">DOM2</jump> interfaces, and provides some information needed for fast transforms, such as document order indexes.  It also attempts to allow an incremental transform by launching the transform on a secondary thread as soon as the SAX2 <jump href="http://www.megginson.com/SAX/Java/javadoc/org/xml/sax/ContentHandler.html#startDocument()">StartDocument</jump> event has occurred.  When the transform requests a node, and the node is not present, the getFirstChild and GetNextSibling methods will wait until the child node has arrived, or an <jump href="http://www.megginson.com/SAX/Java/javadoc/org/xml/sax/ContentHandler.html#endElement(java.lang.String,%20java.lang.String,%20java.lang.String)">endElement</jump> event has occurred.</p><p>Note that the secondary thread is an issue.  It would be better to do the same thing as described above on a single thread, but using the parser in 'pull' mode, or simply with a parseNext method so the parse would occur in blocks.  However, this model would only be possible</p><p>This kind of incrementality is not perfect because it still requires an entire source tree to be concretely built.  There have been a lot of good discussions on the xalan-dev list about how to do static analysis of a stylesheet, and be able to allocate only the nodes needed by the transform, while they are needed (or not allocate source objects at all).</p></s3><s3 title="Serializer Module"><p><link>Serializer Module</link></p><p>XML serialization is a term used for turning a tree or set of events into a stream, and should not be confused with Java object serialization.  The Xalan serializers implement the <jump href="http://www.megginson.com/SAX/Java/javadoc/org/xml/sax/ContentHandler.html">ContentHandler</jump> to turn parser events coming from the transform, into a stream of XML, HTML, or plain text.  The serializers also implement the <code><jump href="../apidocs/org/apache/xalan/serializer/Serializer.html">Serializer</jump></code> which allows the transform process to set XSLT output properties and the output stream or Writer.</p></s3><s3 title="Extensions Module"><p><link>Extensions Module</link></p><p>This package contains an implementation of Xalan Extension Mechanism, which uses the <jump href="http://oss.software.ibm.com/developerworks/opensource/bsf/">Bean Scripting Framework</jump>.
-
-The Bean Scripting Framework (BSF) is an architecture for incorporating scripting into Java applications and applets.  Scripting languages such as Netscape Rhino (Javascript), VBScript, Perl, Tcl, Python, NetRexx and Rexx can be used to augment XSLT's functionality.  In addition, the Xalan extension mechanism allows use of Java classes.  See the <jump href="http://xml.apache.org/xalan/extensions.html">Xalan-J 2 extension documentation</jump> for a description of using extensions in a stylesheet. Please note that the W3C XSL Working Group is working on a specification for standard extension bindings, and this module will change to follow that specification.  </p><p>[More needed... -sb]</p></s3></s2><anchor name="xpath"/> 
-  <s2 title="XPath Module"> 
-	 <p><link>XPath Module</link></p> 
-	 <p>This module is pulled out of the Xalan package, and put in the org.apache package, to emphasize that the intention is that this package can be used independently of the XSLT engine, even though it has dependencies on the Xalan utils module.</p><p><img src="org_apache.gif" alt="xalan ---> xpath"/></p> 
-  <p>The XPath module first compiles the XPath strings into expression trees, and then executes these expressions via a call to the XPath execute(...) function.  </p>  <p>Major classes are:</p><gloss><label>XPath</label><item>Represents a compiled XPath.  Major function is <code>XObject execute(XPathContext xctxt, Node contextNode, 
-                         PrefixResolver namespaceContext).</code></item></gloss><gloss><label>XPathAPI</label><item>The methods in this class are convenience methods into the
- low-level XPath API.</item></gloss><gloss><label>XPathContext</label><item>Used as the runtime execution context for XPath.</item></gloss><gloss><label>DOMHelper</label><item>Used as a helper for handling DOM issues.  May be subclassed to take advantage 
-   of specific DOM implementations.</item></gloss><gloss><label>SourceTreeManager</label><item>bottlenecks all management of source trees.  The methods
- in this class should allow easy garbage collection of source 
- trees, and should centralize parsing for those source trees.</item></gloss><gloss><label>Expression</label><item>The base-class of all expression objects, allowing polymorphic behaviors.</item></gloss><p>The general architecture of the XPath module is divided into the compiler, and categories of expression objects.</p><p><img src="xpath.gif" alt="xpath modules"/></p><p>The most important module is the axes module.  This module implements the DOM2 <jump href="http://www.w3.org/TR/DOM-Level-2/traversal.html#Iterator-overview">NodeIterator</jump> interface, and is meant to allow XPath clients to either override the default behavior or to replace this behavior.</p><p>The <code><jump href="../apidocs/org/apache/xpath/axes/LocPathIterator.html">LocPathIterator</jump></code> and <code><jump href="../apidocs/org/apache/xpath/axes/UnionPathIterator.html">UnionPathIterator</jump></code> classes implement the <jump href="http://www.w3.org/TR/DOM-Level-2/java-binding.html#org.w3c.dom.traversal.NodeIterator">NodeIterator</jump> interface, and polymorphically use <code><jump href="../apidocs/org/apache/xpath/axes/AxesWalker.html">AxesWalker</jump></code> derived objects to execute each step in the path.  The whole trick is to execute the <code>LocationPath</code> in depth-first document order so that nodes can be found without necessarily looking ahead or performing a breadth-first search.  Because a document order depth-first search requires state to be saved for many expressions, the default operations create "Waiter" clones that have to wait while the main <code>AxesWalkers</code> traverses child nodes (think carefully about what happens when a "//foo/baz" expression is executed).   Optimization is done by implementing specialized iterators and <code>AxesWalkers</code> for certain types of operations.  The decision as to what type of iterator or walker will be created is done in the <code><jump href="../apidocs/org/apache/xpath/axes/WalkerFactory.html">WalkerFactory</jump></code> class.</p><p>[Frankly, the implementation of the default AxesWalker, with it's waiters, is the one totally incomprehensible part of Xalan.  It gets especially difficult because you can not look to the node ahead.  I would be very interested if any rocket scientists out there can come up with a better algorithm.]</p><anchor name="xpathdbconn"/><s3 title="XPath Database Connection"><p><link>XPath Direct Database Connections</link></p><p>An important part of the XPath design in both Xalan 1 and Xalan 2, is to enable database connections to be used as drivers directly to the XPath <jump href="http://www.w3.org/TR/xpath#location-paths">LocationPath</jump> handling.  This allows databases to be directly connected to the transform, and be able to take advantage of internal indexing and the like.  While in Xalan 1 this was done via the <jump href="http://xml.apache.org/xalan/apidocs/org/apache/xalan/xpath/XLocator.html">XLocator</jump> interface, in Xalan 2 this interface is no longer used, and has been replaced by the DOM2 <jump href="http://www.w3.org/TR/DOM-Level-2/traversal.html#Iterator-overview">NodeIterator</jump> interface.  An application or extension should be able to install their own NodeIterator for a given document.</p><p><img src="data.gif" alt="data.gif"/></p><p>[More to do]</p></s3></s2><anchor name="utils"/> 
-  <s2 title="Utils Package"> 
-	 <p><link>Utils Package</link></p> 
-  <p>This package contains general utilities for use by both the xalan and xpath packages.</p></s2><anchor name="other"/>
-  <s2 title="Other Packages"> 
-	 <p><link>Other Packages</link></p> 
-	 <gloss><label>client</label><item>Implementation of Xalan Applet [should we keep this?].
-
-</item></gloss> 
-		 
-		 
-		<gloss><label>lib</label><item>Implementation of Xalan-specific extensions.</item></gloss><gloss><label>res</label><item>Contains strings that require internationalization.</item></gloss></s2><anchor name="compilation"/><s2 title="Xalan Stylesheet Complilation to Java"><p><link>Xalan Stylesheet Complilation to Java</link></p><p>We are doing some work on compiling stylesheet objects to Java.  This is a work in progress, and is not meant for general use yet.  For the moment, we are writing out Java text files, and then compiling them to bytecodes via javac, rather than directly producing bytecodes.  The CompilingStylesheetProcessor derives from TransformerFactoryImpl to produce these classes, which are then bundled into a jar file.  For the moment the full Xalan jar is required, but we're looking at ways to only use a subset of Xalan, so that only a minimal jar would be required.</p><p><img src="compilation.gif" alt="compilation.gif"/></p></s2><anchor name="optimizations"/><s2 title="Future Optimizations"><p><link>Future Optimizations</link></p><p>This section enumerates some optimizations that we're planning to do in future versions of Xalan.</p><p>Likely near term optimizations (next six months?):</p><ol><li>By pre-analysis of the stylesheet, prune nodes from the tree that have been processed and can be predicted that they won't be visited again.</li><li>Eliminate redundent expressions (xsl:when, variable sets, rooted patterns, etc.).</li><li>Optimize variable patterns such as &lt;xsl:variable name="foo"&gt;&lt;xsl:variable select="yada"/&gt;&lt;/xsl:variable&gt; into &lt;xsl:variable name="foo" select="string(yada)"/&gt;, in order to reduce result tree fragment creation.</li><li>Reduce size of Stree nodes.</li><li>Implement our own NamespaceSupport class (the SAX2 one is too expensive).</li><li>More specialization of itterators and walkers.</li><li>Full Java compilation support.</li><li>Schema Awareness (if "//foo", the Schema can tell us where to look, but we need standard interface to Schemas).</li></ol><p>Likely longer term optimizations (12-18 months?):</p><ol><li>On-the-fly indexing.</li><li>Predict if nodes won't be processed at all, and so don't build them, achieve full streaming support for a certain class of stylesheets.</li></ol></s2><anchor name="coding"/> 
-  <s2 title="Coding Conventions"> 
-	 <p><link>Coding Conventions</link></p> 
-	 <p>This section documents the coding conventions used in the Xalan
-		source.</p> 
-	 <ol> 
-		<li>Class files are arranged with constructors and possibly an init()
-		  function first, public API methods second, package specific, protected, and
-		  private methods following (arranged based on related functionality), member
-		  variables with their getter/setter access methods last.</li> 
-		<li>Non-static member variables are prefixed with "m_".</li> 
-		<li>static final member variables should always be upper case, without
-		  the "m_" prefix. They need not have accessors.</li> 
-		<li>Private member variables that are not accessed outside the class need
-		  not have getter/setter methods declared.</li> 
-		<li>Private member variables that are accessed outside the class should
-		  have either package specific or public getter/setter methods declared. All
-		  accessors should follow the bean design patterns.</li> 
-		<li>Package-scoped member variables, public member variables, and
-		  protected member variables should not be declared.</li> 
-	 </ol> 
-  </s2><anchor name="open"/> 
-  
-</s1>
diff --git a/xdocs/sources/design/org_apache.gif b/xdocs/sources/design/org_apache.gif
deleted file mode 100644
index 105f264..0000000
--- a/xdocs/sources/design/org_apache.gif
+++ /dev/null
Binary files differ
diff --git a/xdocs/sources/design/process.gif b/xdocs/sources/design/process.gif
deleted file mode 100644
index c7a871e..0000000
--- a/xdocs/sources/design/process.gif
+++ /dev/null
Binary files differ
diff --git a/xdocs/sources/design/trax.gif b/xdocs/sources/design/trax.gif
deleted file mode 100644
index 8eb9614..0000000
--- a/xdocs/sources/design/trax.gif
+++ /dev/null
Binary files differ
diff --git a/xdocs/sources/design/xalan.gif b/xdocs/sources/design/xalan.gif
deleted file mode 100644
index ca4a57c..0000000
--- a/xdocs/sources/design/xalan.gif
+++ /dev/null
Binary files differ
diff --git a/xdocs/sources/design/xalan1_1x1.gif b/xdocs/sources/design/xalan1_1x1.gif
deleted file mode 100644
index c9e1536..0000000
--- a/xdocs/sources/design/xalan1_1x1.gif
+++ /dev/null
Binary files differ
diff --git a/xdocs/sources/design/xmllogo.gif b/xdocs/sources/design/xmllogo.gif
deleted file mode 100644
index b63188d..0000000
--- a/xdocs/sources/design/xmllogo.gif
+++ /dev/null
Binary files differ
diff --git a/xdocs/sources/design/xpath.gif b/xdocs/sources/design/xpath.gif
deleted file mode 100644
index cf28f9c..0000000
--- a/xdocs/sources/design/xpath.gif
+++ /dev/null
Binary files differ
diff --git a/xdocs/sources/design/xslt_abstract.gif b/xdocs/sources/design/xslt_abstract.gif
deleted file mode 100644
index fa041a6..0000000
--- a/xdocs/sources/design/xslt_abstract.gif
+++ /dev/null
Binary files differ
diff --git a/xdocs/sources/entities.ent b/xdocs/sources/entities.ent
deleted file mode 100644
index f7de044..0000000
--- a/xdocs/sources/entities.ent
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml encoding="US-ASCII"?>
-
-<!ENTITY xslt4j "Xalan-Java">
-<!ENTITY xslt4j2 "Xalan-Java 2">
-<!ENTITY xslt4j-dist "xalan-j_2_0_1">
-<!ENTITY xslt4j-current "&xslt4j; version 2.0.1">
-<!ENTITY xml4j "Xerces-Java">
-<!ENTITY xml4j-used "&xml4j; version 1.3.0">
-<!ENTITY xslt4c "Xalan-C++">
-<!ENTITY xml4c "Xerces-C++">
-<!ENTITY download "The &xslt4j-current; download from xml.apache.org includes xerces.jar from &xml4j-used;.">
-<!ENTITY traxsamplenote "To run the trax sample, you must be using an XML parser (such as Xerces 1.3.0 or Crimson 1.1) 
-                         that fully implements the JAXP 1.1 javax.xml.parsers interface.">
-
diff --git a/xdocs/sources/trax/trax.xml b/xdocs/sources/trax/trax.xml
deleted file mode 100644
index b6ecb01..0000000
--- a/xdocs/sources/trax/trax.xml
+++ /dev/null
@@ -1,533 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE spec SYSTEM "../../style/dtd/spec.dtd">
-<spec> 
-  <title>Transformation API For XML (TrAX)</title>
-  <frontmatter> 
-  <pubdate>November 12, 2000</pubdate> 
-  <copyright>Copyright 2000 Java Community Process (Sun Microsystems,
-	 Inc.)</copyright> 
-  <author><firstname>Scott</firstname> 
-	 <surname>Boag</surname> 
-	 <orgname>IBM Research</orgname> 
-	 <address> 
-		<email>sboag@lotus.com</email> 
-	 </address> 
-  </author></frontmatter> 
-  <introduction> 
-  <title>Introduction</title> 
-  <para>This overview describes the set of APIs contained in
-	 <ulink url="package-summary.html">javax.xml.transform</ulink>, <ulink url="package-summary.html">javax.xml.transform.stream</ulink>, <ulink url="package-summary.html">javax.xml.transform.dom</ulink>, and <ulink url="package-summary.html">javax.xml.transform.sax</ulink>. For the sake of brevity, these interfaces are referred to
-	 as TrAX (Transformation API for XML). </para> 
-  <para>There is a broad need for Java applications to be able to transform XML
-	 and related tree-shaped data structures. In fact, XML is not normally very
-	 useful to an application without going through some sort of transformation,
-	 unless the semantic structure is used directly as data. Almost all XML-related
-	 applications need to perform transformations. Transformations may be described
-	 by Java code, Perl code, <ulink url="http://www.w3.org/TR/xslt">XSLT</ulink>
-	 Stylesheets, other types of script, or by proprietary formats. The inputs, one
-	 or multiple, to a transformation, may be a URL, XML stream, a DOM tree, SAX
-	 Events, or a proprietary format or data structure. The output types are the
-	 pretty much the same types as the inputs, but different inputs may need to be
-	 combined with different outputs.</para> 
-  <para>The great challenge of a transformation API is how to deal with all the
-	 possible combinations of inputs and outputs, without becoming specialized for
-	 any of the given types.</para> 
-  <para>The Java community will greatly benefit from a common API that will
-	 allow them to understand and apply a single model, write to consistent
-	 interfaces, and apply the transformations polymorphically. TrAX attempts to
-	 define a model that is clean and generic, yet fills general application
-	 requirements across a wide variety of uses. </para> 
-  <sect2> 
-	 <title>General Terminology</title> 
-	 <para>This section will explain some general terminology used in this
-		document. Technical terminology will be explained in the Model section. In many
-		cases, the general terminology overlaps with the technical terminology.</para> 
-	 <variablelist> 
-		<varlistentry> 
-		  <term>Tree</term> 
-		  <listitem>This term, as used within this document, describes an
-			 abstract structure that consists of nodes or events that may be produced by
-			 XML. A Tree physically may be a DOM tree, a series of well balanced parse
-			 events (such as those coming from a SAX2 ContentHander), a series of requests
-			 (the result of which can describe a tree), or a stream of marked-up
-			 characters.</listitem> 
-		</varlistentry> 
-		<varlistentry> 
-		  <term>Source Tree(s)</term> 
-		  <listitem>One or more trees that are the inputs to the
-			 transformation.</listitem> 
-		</varlistentry> 
-		<varlistentry> 
-		  <term>Result Tree(s)</term> 
-		  <listitem>One or more trees that are the output of the
-			 transformation.</listitem> 
-		</varlistentry> 
-		<varlistentry> 
-		  <term>Transformation</term> 
-		  <listitem>The processor of consuming a stream or tree to produce
-			 another stream or tree.</listitem> 
-		</varlistentry> 
-		<varlistentry> 
-		  <term>Identity (or Copy) Transformation</term> 
-		  <listitem>The process of transformation from a source to a result,
-			 making as few structural changes as possible and no informational changes. The
-			 term is somewhat loosely used, as the process is really a copy. from one
-			 "format" (such as a DOM tree, stream, or set of SAX events) to
-			 another.</listitem> 
-		</varlistentry> 
-		<varlistentry> 
-		  <term>Serialization</term> 
-		  <listitem>The process of taking a tree and turning it into a stream. In
-			 some sense, a serialization is a specialized transformation.</listitem> 
-		</varlistentry> 
-		<varlistentry> 
-		  <term>Parsing</term> 
-		  <listitem>The process of taking a stream and turning it into a tree. In
-			 some sense, parsing is a specialized transformation.</listitem> 
-		</varlistentry> 
-		<varlistentry> 
-		  <term>Transformer</term> 
-		  <listitem>A Transformer is the object that executes the transformation.
-			 </listitem> 
-		</varlistentry> 
-		<varlistentry> 
-		  <term>Transformation instructions</term> 
-		  <listitem>Describes the transformation. A form of code, script, or
-			 simply a declaration or series of declarations.</listitem> 
-		</varlistentry> 
-		<varlistentry> 
-		  <term>Stylesheet</term> 
-		  <listitem>The same as "transformation instructions," except it is
-			 likely to be used in conjunction with <ulink
-			 url="http://www.w3.org/TR/xslt">XSLT</ulink>.</listitem> 
-		</varlistentry> 
-		<varlistentry> 
-		  <term>Templates</term> 
-		  <listitem>Another form of "transformation instructions." In the TrAX
-			 interface, this term is used to describe processed or compiled transformation
-			 instructions. The Source flows through a Templates object to be formed into the
-			 Result.</listitem> 
-		</varlistentry> 
-		<varlistentry> 
-		  <term>Processor</term> 
-		  <listitem>A general term for the thing that may both process the
-			 transformation instructions, and perform the transformation.</listitem> 
-		</varlistentry> 
-		<varlistentry> 
-		  <term>DOM</term> 
-		  <listitem>Document Object Model, specifically referring to the
-			 <termref link-url="http://www.w3.org/TR/DOM-Level-2 ">Document Object Model
-			 (DOM) Level 2 Specification</termref>.</listitem> 
-		</varlistentry> 
-		<varlistentry> 
-		  <term>SAX</term> 
-		  <listitem>Simple API for XML, specifically referring to the
-			 <termref link-url="http://www.megginson.com/SAX/SAX2">SAX 2.0
-			 release</termref>.</listitem> 
-		</varlistentry> 
-	 </variablelist> 
-  </sect2></introduction>
-  <requirements> 
-  <title>Requirements</title> 
-  <para>The following requirements have been determined from broad experience
-	 with XML projects from the various members participating on the JCP.</para> 
-  <orderedlist> 
-	 <listitem id="requirement-simple">TrAX must provide a clean, simple
-		interface for simple uses.</listitem> 
-	 <listitem id="requirement-general">TrAX must be powerful enough to be
-		applied to a wide range of uses, such as, e-commerce, content management,
-		server content delivery, and client applications.</listitem> 
-	 <listitem id="requirement-optimizeable">A processor that implements a TrAX
-		interface must be optimizeable. Performance is a critical issue for most
-		transformation use cases.</listitem> 
-	 <listitem id="requirement-compiled-model">As a specialization of the above
-		requirement, a TrAX processor must be able to support a compiled model, so that
-		a single set of transformation instructions can be compiled, optimized, and
-		applied to a large set of input sources.</listitem> 
-	 <listitem id="requirement-independence">TrAX must not be dependent an any
-		given type of transformation instructions. For instance, it must remain
-		independent of <ulink url="http://www.w3.org/TR/xslt">XSLT</ulink>.</listitem> 
-	 <listitem id="requirement-from-dom">TrAX must be able to allow processors
-		to transform DOM trees.</listitem> 
-	 <listitem id="requirement-to-dom">TrAX must be able to allow processors to
-		produce DOM trees.</listitem> 
-	 <listitem id="requirement-from-sax">TrAX must allow processors to transform
-		SAX events.</listitem> 
-	 <listitem id="requirement-to-sax">TrAX must allow processors to produce SAX
-		events.</listitem> 
-	 <listitem id="requirement-from-stream">TrAX must allow processors to
-		transform streams of XML.</listitem> 
-	 <listitem id="requirement-to-stream">TrAX must allow processors to produce
-		XML, HTML, and other types of streams.</listitem> 
-	 <listitem id="requirement-combo-input-output">TrAX must allow processors to
-		implement the various combinations of inputs and outputs within a single
-		processor.</listitem> 
-	 <listitem id="requirement-limited-input-output">TrAX must allow processors
-		to implement only a limited set of inputs. For instance, it should be possible
-		to write a processor that implements the TrAX interfaces and that only
-		processes DOM trees, not streams or SAX events.</listitem> 
-	 <listitem id="requirement-proprietary-data-structures">TrAX should allow a
-		processor to implement transformations of proprietary data structures. For
-		instance, it should be possible to implement a processor that provides TrAX
-		interfaces that performs transformation of JDOM trees.</listitem> 
-	 <listitem id="requirement-serialization-props">TrAX must allow the setting
-		of serialization properties, without constraint as to what the details of those
-		properties are.</listitem> 
-	 <listitem id="requirement-setting-parameters">TrAX must allow the setting
-		of parameters to the transformation instructions.</listitem> 
-	 <listitem id="requirement-namespaced-properties">TrAX must support the
-		setting of parameters and properties as XML Namespaced items (i.e., qualified
-		names).</listitem> 
-	 <listitem id="requirement-relative-url-resolution">TrAX must support URL
-		resolution from within the transformation, and have it return the needed data
-		structure.</listitem> 
-	 <listitem id="requirement-error-reporting">TrAX must have a mechanism for
-		reporting errors and warnings to the calling application.</listitem> 
-  </orderedlist> </requirements> 
-  <model> 
-  <title>Model</title> 
-  <para>The section defines the abstract model for TrAX, apart from the details
-	 of the interfaces.</para> 
-  <para>A TRaX <termref
-	 link-url="pattern-TransformerFactory">TransformerFactory</termref> is an object
-	 that processes transformation instructions, and produces
-	 <termref link-url="pattern-Templates">Templates</termref> (in the technical
-	 terminology). A <termref link-url="pattern-Templates">Templates</termref>
-	 object provides a <termref
-	 link-url="pattern-Transformer">Transformer</termref>, which transforms one or
-	 more <termref link-url="pattern-Source">Source</termref>s into one or more
-	 <termref link-url="pattern-Result">Result</termref>s.</para> 
-  <para>To use the TRaX interface, you create a
-	 <termref link-url="pattern-TransformerFactory">TransformerFactory</termref>,
-	 which may directly provide a <termref
-	 link-url="pattern-Transformers">Transformers</termref>, or which can provide
-	 <termref link-url="pattern-Templates">Templates</termref> from a variety of
-	 <termref link-url="pattern-Source">Source</termref>s. The
-	 <termref link-url="pattern-Templates">Templates</termref> object is a processed
-	 or compiled representation of the transformation instructions, and provides a
-	 <termref link-url="pattern-Transformer">Transformer</termref>. The
-	 <termref link-url="pattern-Transformer">Transformer</termref> processes a
-	 <termref link-url="pattern-Transformer">Source</termref> according to the
-	 instructions found in the <termref
-	 link-url="pattern-Templates">Templates</termref>, and produces a
-	 <termref link-url="pattern-Result">Result</termref>.</para> 
-  <para>The process of transformation from a tree, either in the form of an
-	 object model, or in the form of parse events, into a stream, is known as
-	 <termref>serialization</termref>. We believe this is the most suitable term for
-	 this process, despite the overlap with Java object serialization.</para> 
-  <patterns module="TRaX"> <pattern><pattern-name
-  id="pattern-Processor">Processor</pattern-name><intent>Generic concept for the
-  set of objects that implement the TrAX interfaces.</intent>
-  <responsibilities>Create compiled transformation instructions, transform
-  sources, and manage transformation parameters and
-  properties.</responsibilities><thread-safety>Only the Templates object can be
-  used concurrently in multiple threads. The rest of the processor does not do
-  synchronized blocking, and so may not be used to perform multiple concurrent
-  operations.</thread-safety></pattern><pattern> 
-  <pattern-name id="pattern-TransformerFactory">TransformerFactory</pattern-name>
-  <intent>Serve as a vendor-neutral Processor interface for
-  <ulink url="http://www.w3.org/TR/xslt">XSLT</ulink> and similar
-  processors.</intent> <responsibilities>Serve as a factory for a concrete
-  implementation of an TransformerFactory, serve as a direct factory for
-  Transformer objects, serve as a factory for Templates objects, and manage
-  processor specific features.</responsibilities> <thread-safety>A
-  TransformerFactory may not perform mulitple concurrent
-  operations.</thread-safety> </pattern> <pattern> 
-  <pattern-name id="pattern-Templates">Templates</pattern-name> <intent>The
-  runtime representation of the transformation instructions.</intent> 
-  <responsibilities>A data bag for transformation instructions; act as a factory
-  for Transformers.</responsibilities> <thread-safety>Threadsafe for concurrent
-  usage over multiple threads once construction is complete.</thread-safety>
-  </pattern> <pattern> <pattern-name
-  id="pattern-Transformer">Transformer</pattern-name> <intent>Act as a per-thread
-  execution context for transformations, act as an interface for performing the
-  transformation.</intent><responsibilities>Perform the
-  transformation.</responsibilities> <thread-safety>Only one instance per thread
-  is safe.</thread-safety> <notes>The Transformer is bound to the Templates
-  object that created it.</notes> </pattern> <pattern> 
-  <pattern-name id="pattern-Source">Source</pattern-name> <intent>Serve as a
-  single vendor-neutral object for multiple types of input.</intent> 
-  <responsibilities>Act as simple data holder for System IDs, DOM nodes, streams,
-  etc.</responsibilities> <thread-safety>Threadsafe concurrently over multiple
-  threads for read-only operations; must be synchronized for edit
-  operations.</thread-safety> </pattern><pattern> 
-  <pattern-name id="pattern-Result">Result</pattern-name> 
-  <potential-alternate-name>ResultTarget</potential-alternate-name> <intent>Serve
-  as a single object for multiple types of output, so there can be simple process
-  method signatures.</intent> <responsibilities>Act as simple data holder for
-  output stream, DOM node, ContentHandler, etc.</responsibilities> 
-  <thread-safety>Threadsafe concurrently over multiple threads for read-only,
-  must be synchronized for edit.</thread-safety> </pattern> </patterns></model> 
-  <sect1 id="package"> 
-	 <title>javax.xml.transform</title> 
-	 <para>This package defines the generic APIs for processing transformation instructions,
-		and performing a transformation from source to result. These 
-		interfaces have no dependencies on SAX or the DOM standard, and try to make as
-		few assumptions as possible about the details of the source and result of a
-		transformation. The API achieves this by defining 
-		<plink>javax.xml.transform.Source</plink> and 
-		<plink>javax.xml.transform.Result</plink> interfaces.</para> 
-	 <para>To define concrete classes for the user, the API defines specializations
-		of the interfaces found at the root level. These interfaces are found in 
-		<plink>javax.xml.transform.sax</plink>, <plink>javax.xml.transform.dom</plink>,
-		and <plink>javax.xml.transform.stream</plink>.</para> 
-	 <sect2> 
-		<title>Creating Objects</title> 
-		<para>The API allows a concrete 
-		  <plink>javax.xml.transform.TransformerFactory</plink> object to be created from
-		  the static function 
-		  <plink>javax.xml.transform.TransformerFactory#newInstance</plink>. The
-		  "javax.xml.transform.TransformerFactory" system property determines which
-		  factory implementation to instantiate. This property names a concrete subclass
-		  of the TransformerFactory abstract class. If this system property is not
-		  defined, a platform default is used.</para> 
-	 </sect2> 
-	 <sect2> 
-		<title>Specification of Inputs and Outputs</title> 
-		<para>This API defines two interface objects called 
-		  <plink>javax.xml.transform.Source</plink> and 
-		  <plink>javax.xml.transform.Result</plink>. In order to pass Source and Result
-		  objects to the interfaces, concrete classes must be used. The transformation API defines
-		  three concrete representations for each of these objects: 
-		  <plink>javax.xml.transform.stream.StreamSource</plink> and 
-		  <plink>javax.xml.transform.stream.StreamResult</plink>,
-		  <plink>javax.xml.transform.sax.SAXSource</plink> and 
-		  <plink>javax.xml.transform.sax.SAXResult</plink>, and 
-		  <plink>javax.xml.transform.dom.DOMSource</plink> and 
-		  <plink>javax.xml.transform.dom.DOMResult</plink>. Each of these objects defines
-		  a FEATURE string (which is i the form of a URL), which can be passed into 
-		  <plink>javax.xml.transform.TransformerFactory#getFeature</plink> to see if the
-		  given type of Source or Result object is supported. For instance, to test if a
-		  DOMSource and a StreamResult is supported, you can apply the following
-		  test.</para> 
-		<programlisting>    TransformerFactory tfactory = TransformerFactory.newInstance();
-
-    if (tfactory.getFeature(DOMSource.FEATURE) &amp;&amp; tfactory.getFeature(StreamResult.FEATURE))
-    {
-       ...
-    }</programlisting>
-  </sect2> 
-  <sect2> 
-	 <title id="qname-delimiter">Qualified Name representation</title> 
-	 <para><ulink url="http://www.w3.org/TR/REC-xml-names">Namespaces</ulink>
-		present something of a problem area when dealing with XML objects. Qualified
-		Names appear in XML markup as prefixed names. But the prefixes themselves do
-		not hold identity. Rather, it is the URIs that they contextually map to that
-		hold the identity. Therefore, when passing a Qualified Name like "xyz:foo"
-		among Java programs, one must provide a means to map "xyz" to a namespace.
-		</para> 
-	 <para>One solution has been to create a "QName" object that holds the
-		namespace URI, as well as the prefix and local name, but this is not always an
-		optimal solution, as when, for example, you want to use unique strings as keys
-		in a dictionary object. Not having a string representation also makes it
-		difficult to specify a namespaced identity outside the context of an XML
-		document.</para> 
-	 <para>In order to pass namespaced values to transformations, for instance
-		as a set of properties to the Serializer, this specification defines that a
-		String "qname" object parameter be passed as two-part string, the namespace URI
-		enclosed in curly braces ({}), followed by the local name. If the qname has a
-		null URI, then the String object only contains the local name. An application
-		can safely check for a non-null URI by testing to see if the first character of
-		the name is a '{' character.</para> 
-	 <para>For example, if a URI and local name were obtained from an element
-		defined with &lt;xyz:foo xmlns:xyz="http://xyz.foo.com/yada/baz.html"/&gt;,
-		then the transformation API Qualified Name would be "{http://xyz.foo.com/yada/baz.html}foo".
-		Note that the prefix is lost.</para> 
-  </sect2> 
-  <sect2> 
-	 <title>Result Tree Serialization</title> 
-	 <para>Serialization of the result tree to a stream can be controlled with
-		the <plink>javax.xml.transform.Transformer#setOutputProperties</plink> and the 
-		<plink>javax.xml.transform.Transformer#setOutputProperty</plink> methods.
-		Strings that match the <ulink url="http://www.w3.org/TR/xslt#output">XSLT
-		specification for xsl:output attributes</ulink> can be referenced from the 
-		<plink>javax.xml.transform.OutputKeys</plink> class. Other strings can be
-		specified as well. If the transformer does not recognize an output key, a 
-		<plink>java.lang.IllegalArgumentException</plink> is thrown, unless the 
-		<emphasis>unless</emphasis> the key name is <link
-		linkend="qname-delimiter">namespace qualified</link>. Output key names that are
-		qualified by a namespace are ignored or passed on to the serializer
-		mechanism.</para> 
-	 <para>If all that is desired is the simple identity transformation of a
-		source to a result, then <plink>javax.xml.transform.TransformerFactory</plink>
-		provides a
-		<plink>javax.xml.transform.TransformerFactory#newTransformer()</plink> method
-		with no arguments. This method creates a Transformer that effectively copies
-		the source to the result. This method may be used to create a DOM from SAX
-		events or to create an XML or HTML stream from a DOM or SAX events.</para>
-</sect2> 
-<sect2> 
-  <title>Exceptions and Error Reporting</title> 
-  <para>The transformation API throws three types of specialized exceptions. A
-	 <plink>javax.xml.transform.TransformerFactoryConfigurationError</plink> is parallel to
-	 the <plink>javax.xml.parsers.FactoryConfigurationError</plink>, and is thrown
-	 when a configuration problem with the TransformerFactory exists. This error
-	 will typically be thrown when the transformation factory class specified with
-	 the "javax.xml.transform.TransformerFactory" system property cannot be found or
-	 instantiated.</para> 
-  <para>A <plink>javax.xml.transform.TransformerConfigurationException</plink>
-	 may be thrown if for any reason a Transformer can not be created. A
-	 TransformerConfigurationException may be thrown if there is a syntax error in
-	 the transformation instructions, for example when
-	 <plink>javax.xml.transform.TransformerFactory#newTransformer</plink> is
-	 called.</para> 
-  <para><plink>javax.xml.transform.TransformerException</plink> is a general
-	 exception that occurs during the course of a transformation. A transformer
-	 exception may wrap another exception, and if any of the
-	 <plink>javax.xml.transform.TransformerException#printStackTrace()</plink>
-	 methods are called on it, it will produce a list of stack dumps, starting from
-	 the most recent. The transformer exception also provides a
-	 <plink>javax.xml.transform.SourceLocator</plink> object which indicates where
-	 in the source tree or transformation instructions the error occurred.
-	 <plink>javax.xml.transform.TransformerException#getMessageAndLocation()</plink>
-	 may be called to get an error message with location info, and
-	 <plink>javax.xml.transform.TransformerException#getLocationAsString()</plink>
-	 may be called to get just the location string.</para> 
-  <para>Transformation warnings and errors are normally first sent to a
-	 <plink>javax.xml.transform.ErrorListener</plink>, at which point the
-	 implementor may decide to report the error or warning, and may decide to throw
-	 an exception for a non-fatal error. The error listener may be set via
-	 <plink>javax.xml.transform.TransformerFactory#setErrorListener</plink> for
-	 reporting errors that have to do with syntax errors in the transformation
-	 instructions, or via
-	 <plink>javax.xml.transform.Transformer#setErrorListener</plink> to report
-	 errors that occur during the transformation. The error listener on both objects
-	 should always be valid and non-null, whether set by the user or a default
-	 implementation provided by the processor.</para> 
-</sect2> 
-<sect2> 
-  <title>Resolution of URIs within a transformation</title> 
-  <para>The API provides a way for URIs referenced from within the stylesheet
-	 instructions or within the transformation to be resolved by the calling
-	 application. This can be done by creating a class that implements the
-	 URIResolver interface, with its one method,
-	 <plink>javax.xml.transform.URIResolver#resolve</plink>, and use this class to
-	 set the URI resolution for the transformation instructions or transformation
-	 with <plink>javax.xml.transform.TransformerFactory#setURIResolver</plink> or
-	 <plink>javax.xml.transform.Transformer#setURIResolver</plink>. The
-	 URIResolver.resolve method takes two String arguments, the URI found in the
-	 stylesheet instructions or built as part of the transformation process, and the
-	 base URI in effect when the URI passed as the first argument was encountered.
-	 The returned <plink>javax.xml.transform.Source</plink> object must be usable by
-	 the transformer, as specified in its implemented features.</para> 
-</sect2> 
-<sect2 id="specialized-packages"> 
-<title>Specialized Packages</title> 
-<sect3> 
-  <title>javax.xml.transform.stream</title> 
-  <para>This package implements stream- and URI- specific transformation APIs.
-	 </para> 
-  <para>The <plink>javax.xml.transform.stream.StreamSource</plink> class
-	 provides methods for specifying <plink>java.io.InputStream</plink> input,
-	 <plink>java.io.Reader</plink> input, and URL input in the form of strings. Even
-	 if an input stream or reader is specified as the source,
-	 <plink>javax.xml.transform.stream.StreamSource#setSystemId</plink> should still
-	 be called, so that the transformer can know from where it should resolve
-	 relative URIs. The public identifier is always optional: if the application
-	 writer includes one, it will be provided as part of the
-	 <plink>javax.xml.transform.SourceLocator</plink> information.</para> 
-  <para>The <plink>javax.xml.transform.stream.StreamResult</plink> class
-	 provides methods for specifying <plink>java.io.OutputStream</plink>,
-	 <plink>java.io.Writer</plink>, or an output system ID, as the output of the
-	 transformation result.</para> 
-  <para>Normally streams should be used rather than readers or writers, for
-	 both the Source and Result, since readers and writers already have the encoding
-	 established to and from the internal Unicode format. However, there are times
-	 when it is useful to write to a character stream, such as when using a
-	 StringWriter in order to write to a String, or in the case of reading source
-	 XML from a StringReader.</para> 
-</sect3> 
-<sect3> 
-<title>javax.xml.transform.sax</title> 
-<para>This package implements SAX2-specific transformation APIs. It provides
-  classes which allow input from <plink>org.xml.sax.ContentHandler</plink>
-  events, and also classes that produce org.xml.sax.ContentHandler events. It
-  also provides methods to set the input source as an
-  <plink>org.xml.sax.XMLReader</plink>, or to use a
-  <plink>org.xml.sax.InputSource</plink> as the source. It also allows the
-  creation of a <plink>org.xml.sax.XMLFilter</plink>, which enables
-  transformations to "pull" from other transformations, and lets the transformer
-  to be used polymorphically as an <plink>org.xml.sax.XMLReader</plink>.</para> 
-<para>The <plink>javax.xml.transform.sax.SAXSource</plink> class allows the
-  setting of an <plink>org.xml.sax.XMLReader</plink> to be used for "pulling"
-  parse events, and an <plink>org.xml.sax.InputSource</plink> that may be used to
-  specify the SAX source.</para> 
-<para>The <plink>javax.xml.transform.sax.SAXResult</plink> class allows the
-  setting of a <plink>org.xml.sax.ContentHandler</plink> to be the receiver of
-  SAX2 events from the transformation.</para>
-<para>The <plink>javax.xml.transform.sax.SAXTransformerFactory</plink> extends
-  <plink>javax.xml.transform.TransformerFactory</plink> to provide factory
-  methods for creating <plink>javax.xml.transform.sax.TemplatesHandler</plink>,
-  <plink>javax.xml.transform.sax.TransformerHandler</plink>, and
-  <plink>org.xml.sax.XMLReader</plink> instances.</para> 
-<para>To obtain a <plink>javax.xml.transform.sax.SAXTransformerFactory</plink>,
-  the caller must cast the <plink>javax.xml.transform.TransformerFactory</plink>
-  instance returned from
-  <plink>javax.xml.transform.TransformerFactory#newInstance</plink>.</para>
-<para>The <plink>javax.xml.transform.sax.TransformerHandler</plink> interface
-  allows a transformation to be created from SAX2 parse events, which is a "push"
-  model rather than the "pull" model that normally occurs for a transformation.
-  Normal parse events are received through the
-  <plink>org.xml.sax.ContentHandler</plink> interface, lexical events such as
-  startCDATA and endCDATA are received through the
-  <plink>org.xml.sax.ext.LexicalHandler</plink> interface, and events that signal
-  the start or end of disabling output escaping are received via
-  <plink>org.xml.sax.ContentHandler#processingInstruction</plink>, with the
-  target parameter being
-  <plink>javax.xml.transform.Result#PI_DISABLE_OUTPUT_ESCAPING</plink> and
-  <plink>javax.xml.transform.Result#PI_ENABLE_OUTPUT_ESCAPING</plink>. If
-  parameters, output properties, or other features need to be set on the
-  Transformer handler, a <plink>javax.xml.transform.Transformer</plink> reference
-  will need to be obtained from
-  <plink>javax.xml.transform.sax.TransformerHandler#getTransformer</plink>, and
-  the methods invoked from that reference.</para>
-<para>The <plink>javax.xml.transform.sax.TemplatesHandler</plink> interface
-  allows the creation of <plink>javax.xml.transform.Templates</plink> objects
-  from SAX2 parse events. Once the <plink>org.xml.sax.ContentHandler</plink>
-  events are complete, the Templates object may be obtained from
-  <plink>javax.xml.transform.sax.TemplatesHandler#getTemplates</plink>. Note that 
-  <plink>javax.xml.transform.sax.TemplatesHandler#setSystemId</plink> should
-  normally be called in order to establish a base system ID from which relative
-  URLs may be resolved.</para>
-<para>The
-  <plink>javax.xml.transform.sax.SAXTransformerFactory#newXMLFilter</plink>
-  method allows the creation of a <plink>org.xml.sax.XMLFilter</plink>, which
-  encapsulates the SAX2 notion of a "pull" transformation. The following
-  illustrates several transformations chained together. Each filter points to a
-  parent <plink>org.xml.sax.XMLReader</plink>, and the final transformation is
-  caused by invoking <plink>org.xml.sax.XMLReader#parse</plink> on the final
-  reader in the chain.</para>
-</sect3> 
-<sect3> 
-<title>javax.xml.transform.dom</title> 
-<para>This package implements DOM-specific transformation APIs.</para> 
-<para>The <plink>javax.xml.transform.dom.DOMSource</plink> class allows the
-client of the implementation of this API to specify a DOM
-<plink>org.w3c.dom.Node</plink> as the source of the input tree. The model of
-how the Transformer deals with the DOM tree in terms of mismatches with the
-<ulink url="http://www.w3.org/TR/xslt#data-model">XSLT data model</ulink> or
-other data models is beyond the scope of this document. Any of the nodes
-derived from <plink>org.w3c.dom.Node</plink> are legal input.</para>
-<para>The <plink>javax.xml.transform.dom.DOMResult</plink> class allows a
-<plink>org.w3c.dom.Node</plink> to be specified to which result DOM nodes will
-be appended. If an output node is not specified, the transformer will use 
-<plink>javax.xml.parsers.DocumentBuilder#newDocument</plink> to create an
-output <plink>org.w3c.dom.Document</plink> node. If a node is specified, it
-should be one of the following: <plink>org.w3c.dom.Document</plink>, 
-<plink>org.w3c.dom.Element</plink>, or 
-<plink>org.w3c.dom.DocumentFragment</plink>. Specification of any other node
-type is implementation dependent and undefined by this API. If the result is a 
-<plink>org.w3c.dom.Document</plink>, the output of the transformation must have
-a single element root to set as the document element.</para>
-<para>The <plink>javax.xml.transform.dom.DOMLocator</plink> node may be passed
-to <plink>javax.xml.transform.TransformerException</plink> objects, and
-retrieved by trying to cast the result of
-the <plink>javax.xml.transform.TransformerException#getLocator()</plink> method.
-The implementation has no responsibility to use a DOMLocator instead of
-a <plink>javax.xml.transform.SourceLocator</plink> (though line numbers and the
-like do not make much sense for a DOM), so the result of getLocator must always
-be tested with an instanceof. </para>
-</sect3> 
-</sect2>
-</sect1>
-</spec>
\ No newline at end of file
diff --git a/xdocs/sources/xalan-collate.xsl b/xdocs/sources/xalan-collate.xsl
deleted file mode 100644
index d555d2a..0000000
--- a/xdocs/sources/xalan-collate.xsl
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0"?>
-
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-
-<xsl:template match ="/">
-  <documentation>
-    <chapter id="index"><xsl:copy-of select="document('xalan/index.xml')"/></chapter>  
-    <chapter id="whatsnew"><xsl:copy-of select="document('xalan/whatsnew.xml')"/></chapter>
-    <chapter id="overview"><xsl:copy-of select="document('xalan/overview.xml')"/></chapter>
-    <chapter id="getstarted"><xsl:copy-of select="document('xalan/getstarted.xml')"/></chapter>
-    <chapter id="faq"><xsl:copy-of select="document('xalan/faq.xml')"/></chapter>
-    <chapter id="samples"><xsl:copy-of select="document('xalan/samples.xml')"/></chapter>
-    <chapter id="commandline"><xsl:copy-of select="document('xalan/commandline.xml')"/></chapter>
-    <chapter id="usagepatterns"><xsl:copy-of select="document('xalan/usagepatterns.xml')"/></chapter>
-    <chapter id="extensions"><xsl:copy-of select="document('xalan/extensions.xml')"/></chapter>
-    <chapter id="extensionslib"><xsl:copy-of select="document('xalan/extensionslib.xml')"/></chapter>
-    <chapter id="readme"><xsl:copy-of select="document('xalan/readme.xml')"/></chapter>
-    <chapter id="api">
-      <s1 title="Java API">
-        <p>Javadoc for the entire Xalan-Java API:</p>
-        <ul>
-          <li><jump href="apidocs/index.html">Xalan-Java 2 API</jump></li>
-          <li><jump href="compat_apidocs/index.html">Xalan-Java 1 compatibility API</jump></li>
-        </ul>         
-      </s1>
-    </chapter>
-  </documentation>
-</xsl:template>
-</xsl:stylesheet>
-
-
diff --git a/xdocs/sources/xalan-jlocal.xml b/xdocs/sources/xalan-jlocal.xml
deleted file mode 100644
index d538272..0000000
--- a/xdocs/sources/xalan-jlocal.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE book SYSTEM "sbk:/style/dtd/book.dtd">
-
-<!--
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 2000 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- -->
-
-<book title="Xalan XSL Transformer User's Guide" copyright="2000 The Apache Software Foundation">
-  <resources source="sbk:/sources/xalan/resources.xml"/>
-  <document id="whatsnew" label="What's New" source="xalan/whatsnew.xml"/>
-  <separator/>
-  <document id="overview" label="Overview" source="xalan/overview.xml"/>
-  <document id="getstarted" label="Getting Started" source="xalan/getstarted.xml"/>
-  <separator/>
-  <faqs id="faq" label="FAQs" source="xalan/faq.xml"/>
-  <separator/>
-  <document id="samples" label="Sample Apps" source="xalan/samples.xml"/>
-  <document id="commandline" label="Command Line" source="xalan/commandline.xml"/>
-  <separator/>
-  <document id="usagepatterns" label="Usage Patterns" source="xalan/usagepatterns.xml"/>
-  <separator/>
-  <external href="apidocs/index.html" label="API (Javadoc)"/>
-  <separator/>
-  <document id="extensions" label="Extensions" source="xalan/extensions.xml"/>
-  <document id="extensionslib" label="Extensions Library" source="xalan/extensionslib.xml"/>
-  <separator/>
-  <document id="readme" label="Release Notes" source="xalan/readme.xml"/>
-  <separator/>
-  <external href="design/design2_0_0.html" label="Xalan 2 Design"/>
-  <separator/>
-  <external href="readme.html#bugs" label="Bugs"/>
-  <external href="http://xml.apache.org/xalan-j/test/overview.html" label="Testing"/>
-  <separator/>
-  <external href="todo.html#developer-list" label="Credits"/>  
-</book>
diff --git a/xdocs/sources/xalan-jsite.xml b/xdocs/sources/xalan-jsite.xml
deleted file mode 100644
index cb3eba1..0000000
--- a/xdocs/sources/xalan-jsite.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE book SYSTEM "sbk:/style/dtd/book.dtd">
-
-<!--
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 2000 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- -->
-
-<book title="Xalan XSL Transformer User's Guide" copyright="2000 The Apache Software Foundation">
-  <resources source="sbk:/sources/xalan/resources.xml"/>
-  <external href="../index.html" label="Home"/>
-  <separator/>
-  <document id="index" label="Xalan-J 2.0.1" source="xalan/index.xml"/>
-  <document id="whatsnew" label="What's New" source="xalan/whatsnew.xml"/>
-  <separator/>
-  <document id="overview" label="Overview" source="xalan/overview.xml"/>
-  <document id="getstarted" label="Getting Started" source="xalan/getstarted.xml"/>
-  <separator/>
-  <faqs id="faq" label="FAQs" source="xalan/faq.xml"/>
-  <separator/>
-  <document id="samples" label="Sample Apps" source="xalan/samples.xml"/>
-  <document id="commandline" label="Command Line" source="xalan/commandline.xml"/>
-  <separator/>
-  <document id="usagepatterns" label="Usage Patterns" source="xalan/usagepatterns.xml"/>
-  <separator/>
-  <external href="apidocs/index.html" label="API (Javadoc)"/>
-  <separator/>
-  <document id="extensions" label="Extensions" source="xalan/extensions.xml"/>
-  <document id="extensionslib" label="Extensions Library" source="xalan/extensionslib.xml"/>
-  <separator/>
-  <document id="readme" label="Release Notes" source="xalan/readme.xml"/>
-  <separator/>
-  <external href="design/design2_0_0.html" label="Xalan 2 Design"/>
-  <separator/>
-  <external href="readme.html#bugs" label="Bugs"/>  
-  <external href="http://xml.apache.org/xalan-j/test/overview.html" label="Testing"/>
-  <separator/>
-  <external href="todo.html#developer-list" label="Credits"/>  
-</book>
diff --git a/xdocs/sources/xalan/STATUS b/xdocs/sources/xalan/STATUS
deleted file mode 100644
index 0e0a3fc..0000000
--- a/xdocs/sources/xalan/STATUS
+++ /dev/null
@@ -1,6 +0,0 @@
-  <s3 title="Version of Xerces to use"> 
-<p>The &xslt4j-current; has been tested with &xml4j-used;. &download; For information about including xerces.jar on the system class path, see <link idref="getstarted" anchor="classpath">Setting up the system class path</link>.</p>
-<p><em>Important</em> You may experience unpredictable anomalies if your Xalan and Xerces builds are not in synch. If you download an update to Xalan, check the release notes to determine which version of Xerces you should use.</p>
-<note>You can use Xalan with other XML parsers that implement the <resource-ref idref="jaxp"/>. See 
-<link idref="usagepatterns" anchor="plug">Plugging in the Transformer and XML parser</link>.</note>
-</s3>
\ No newline at end of file
diff --git a/xdocs/sources/xalan/commandline.xml b/xdocs/sources/xalan/commandline.xml
deleted file mode 100644
index f09619a..0000000
--- a/xdocs/sources/xalan/commandline.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-<?xml version="1.0" standalone="no"?>
-<!DOCTYPE s1 SYSTEM "../../style/dtd/document.dtd">
-
-<!--
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- -->
- 
-
-<s1 title="Command-Line Utility">
-   
-   <s2 title="Using the Command-Line Utility">
-      <p>To perform a transformation, you can call &xslt4j; from the command line (or script), 
-      an applet, an application, or a servlet (see <link idref="usagepatterns">Usage Patterns</link>).</p>
-     <p>The org.apache.xalan.xslt.Process main() method provides a command-line interface
-    for performing XSL transformation. To perform a transformation from the command line or a script,
-    do the following:</p>
- 		<ol>
-    <li>Download &xslt4j;.<br/><br/></li> 
-    <li><link idref="getstarted" anchor="classpath">Set the Java classpath</link> to include xalan.jar and
-    xerces.jar (or another conformant XML Parser -- see <link idref="usagepatterns" anchor="plug">Plugging in 
-    the Transformer and XML parser</link>).<br/><br/></li>
-    <li>Call java and the Process class with the appropriate flags and
-    arguments (described below). The following command line, for example, includes the -IN, -XSL,
-    and -OUT flags with their accompanying arguments -- the XML source document, the XSL
-    stylesheet, and the output file:<br/><br/>
-    <code>java org.apache.xalan.xslt.Process -IN foo.xml -XSL foo.xsl -OUT foo.out</code>
-    </li></ol>
-    <p>The command line utility can take the following flags and arguments (the flags are case insensitive):</p> 
-      <source>-IN inputXMLURL
--XSL XSLTransformationURL
--OUT outputFileName
--V (Version info)
--QC (Quiet Pattern Conflicts Warnings)
--Q  (Quiet Mode)
--LF (Use linefeeds only on output -- default is CR/LF)
--CR (Use carriage returns only on output -- default is CR/LF)
--INDENT (Number of spaces to indent each level in output tree --default is 0)
--TT (Trace the templates as they are being called)
--TG (Trace each result tree generation event)
--TS (Trace each selection event)
--TTC (Trace the template children as they are being processed)
--EDUMP [optional]FileName (Do stackdump on error)
--XML (Use XML formatter and add XML header)
--TEXT (Use simple Text formatter)
--HTML (Use HTML formatter)
--PARAM name value (Set a stylesheet parameter)
--DIAG put out timing diagnostics
--URIRESOLVER fullClassName (Use a custom URIResolver)
--ENTITYRESOLVER fullClassName (Use a custom EntityResolver)
--CONTENTHANDLER fullClassName (Use a custom ContentHandler)
-</source>
-      <p>Use <code>-IN</code> to specify the XML source document.</p> 
-      <p>Use <code>-XSL</code> to specify the XSL stylesheet file.</p>
-      <p>Use <code>-TEXT</code> if you want the output to include only element values (not element tags with element names and
-      attributes).</p>
-      <p>Use <code>-HTML</code> to write 4.0 transitional HTML (some elements, such as &lt;br&gt;, are
-      not well formed XML).</p>
-      <p>To set stylesheet parameters from the command line, use <br/>
-      <code>java org.apache.xalan.xslt.Process -PARAM <ref>name value</ref></code></p>
-      <p>Use <code>-URIRESOLVER</code> with a fully qualified class name to utilize a custom implementation of the
-      <jump href="apidocs/javax/xml/transform/URIResolver.html">URIResolver</jump> TrAX interface to resolve URIs for
-       xsl:include, xsl:import, and the document() function.</p>
-       <p>Use <code>-ENTITYRESOLVER</code> with a fully qualified class name to utilize a custom implementation of the
-       <jump href="apidocs/org/xml/sax/EntityResolver.html">EntityResolver</jump> SAX interface to handle external entity references.</p>
-       <p>Use <code>-CONTENTHANDLER</code> with a fully qualified class name to utilize a custom implementation of the 
-       <jump href="apidocs/org/xml/sax/ContentHandler.html">ContentHandler</jump> SAX interface to serialize output.</p>
-   </s2>
-</s1>
diff --git a/xdocs/sources/xalan/extensions.xml b/xdocs/sources/xalan/extensions.xml
deleted file mode 100644
index d18614b..0000000
--- a/xdocs/sources/xalan/extensions.xml
+++ /dev/null
@@ -1,720 +0,0 @@
-<?xml version="1.0" standalone="no"?>
-<!DOCTYPE s1 SYSTEM "../../style/dtd/document.dtd">
-
-<!--
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- -->
-
-<s1 title="&xslt4j; Extensions">
-<ul>
-<li><link anchor="intro">Introduction</link></li>
-<li><link anchor="supported-lang">Supported languages</link></li>
-<li><link anchor="basic-pattern">The basic pattern</link></li>
-<li><link anchor="setup-runtime">Setting up the runtime environment</link></li>
-<li><link anchor="basic-syntax">Syntax</link></li>
-<li><link anchor="ext-elements">Using an extension element</link></li>
-<li><link anchor="ext-functions">Using extension functions</link></li>
-<li><link anchor="java-namespace">Alternative: using the abbreviated syntax for extensions implemented in Java</link></li>
-<li>Examples: <link anchor="ex-basic">basic JavaScript example</link>, <link anchor="ex-java-namespace">using the java namespace</link>, <link anchor="ex-java">using a Java Hashtable</link>, <link anchor="ex-javascript">using a JavaScript array</link></li>
-</ul><anchor name="intro"/>
-  <s2 title="Introduction">
-  <p>For those situations where you would like to augment the functionality of XSLT with calls to a procedural language, &xslt4j; supports the creation and use of extension elements and extension functions. &xslt4j; also provides a growing <link idref="extensionslib">extensions library</link> available for your use. An extension (a collection of elements and functions) inhabits a namespace, either a namespace you declare and designate as an extensions namespace, or one of the predefined namespaces that &xslt4j; provides. For information about XML namespaces, see <jump href="http://www.w3.org/TR/REC-xml-names/">Namespaces in XML</jump>.</p>
-
-<p><em>Extension elements</em>  Unlike a literal result element, which the stylesheet simply transfers to the result tree, an extension element performs an action. For example, you can use the Redirect extension elements shipped with &xslt4j; to redirect portions of your transformation output to one or more files. Extension elements may contain attributes, text nodes, other elements, basically any valid XML. Extension elements may perform quite sophisticated actions, given that the extension routine (the implementation) has direct access to the XSLT processor context object and to the element. In many cases the implementation returns void or null; if it does return a value, that value is placed in the transformation result tree.</p>
-
-<p><em>Extension functions</em>  You can think of extension functions as extending the core library of functions that XPath provides. An extension function passes arguments to the extension implementation and returns a value. You can use extension functions to return values that XSLT can interact with directly (node-set, result tree fragment, string, boolean, and number) as well as values (of any type) that you pass in turn to other extension functions. Extension functions written in Java can also access certain items in the XSLT execution environment through an <jump href="apidocs/org/apache/xalan/extensions/ExpressionContext.html">ExpressionContext</jump> interface.</p>
-
-<p>XSLT extensions are specified in the <jump href="http://www.w3.org/TR/xslt#extension">XSLT Recommendation</jump>.  This document focuses on the &xslt4j; implementation of those requirements, not on XSLT extensions in general. For additional information on extensions, consult the Recommendation or the other resources listed in <link idref="overview" anchor="uptospeed">Getting up to speed with XSLT</link>.</p>
-</s2><anchor name="supported-lang"/>
-<s2 title="Supported languages">
-<p>Extensions written in Java are directly supported by &xslt4j;.  For extensions written in languages other than Java, &xslt4j; uses the <resource-ref idref="bsf"/>, an architecture for incorporating scripting into Java applications and applets. BSF allows an application to take advantage of scripting while being independent of any specific scripting language. To date, we have tested extensions implemented in JavaScript. Other languages with BSF support appear in the table below.</p>
-<p>BSF requires bsf.jar on the classpath. This JAR file is shipped with &xslt4j; and is required only if you have extensions written in languages other than Java. The additional JAR files or DLLs required to support extensions written in other languages are listed in the table below. These files are available from the sources indicated and are not shipped with &xslt4j;.</p>
-<table>
-  <tr>
-    <td><em>Language</em></td>
-    <td><em>Version</em></td>
-    <td><em>Requirements</em></td>
-  </tr>
-  <tr>
-    <td>Mozilla Rhino (JavaScript)<br/><br/></td>
-    <td>1.5<br/><br/></td>
-    <td>js.jar available from 
-				    http://www.mozilla.org/rhino<br/><br/></td>
-  </tr>
-  <tr>
-    <td>NetRexx<br/><br/></td>
-    <td>1.148 up <br/><br/></td>
-    <td>NetRexxC.zip available from http://www2.hursley.ibm.com/netrexx<br/><br/></td>
-  </tr>
-    <tr>
-    <td>BML<br/><br/></td>
-    <td>2.4<br/><br/></td>
-    <td>bmlall.jar available from http://oss.software.ibm.com/developerworks/projects/bsf<br/><br/></td>
-  </tr>
-    <tr>
-    <td>JPython<br/><br/></td>
-    <td>1.1-beta3<br/><br/></td>
-    <td>python.jar available from http://www.jpython.org/<br/><br/></td>
-  </tr>
-    <tr>
-    <td>Jacl<br/><br/></td>
-    <td>1.1.1<br/><br/></td>
-    <td> jacl.jar and tcljava.jar from http://www.scriptics.com/java<br/><br/></td>
-  </tr>
-    <tr>
-    <td>Win32 ActiveScript langs
-	JScript, VBScript<br/><br/></td>
-    <td><br/><br/></td>
-    <td>MSVCP60.DLL from Microsoft, appropriate language DLLs from Microsoft 
-    http://msdn.microsoft.com/scripting<br/><br/></td>
-  </tr>
-    <tr>
-    <td>PerlScript<br/><br/></td>
-    <td><br/><br/></td>
-    <td>ActivePerl from http://www.activestate.com/<br/><br/></td>
-  </tr>  
-</table>
-</s2><anchor name="basic-pattern"/>
-<s2 title="The basic pattern">
-<p>Let's examine a simple example. The stylesheet below uses an extension element and an extension function to transform an element in the XML source into a statement in the output indicating the date by which a customer can expect a response to a given enquiry.</p>
-
-<p>The source element contains a numdays attribute. The extension element contains a multiplier attribute, which is used to set a variable in the extension. The extension function computes the deadline, that is the current date plus numdays * multiplier. So for &lt;deadline numdays="3"/&gt; (in the XML source) and &lt;my-ext:timelapse multiplier="2"/&gt; (in the stylesheet), the extension computes a deadline 6 days from now, and the stylesheet template transforms the deadline element into a string along the lines of <code>&lt;p&gt;We have logged your enquiry and will respond by April 29, 2000 12:07:16 PM EST.&lt;/p&gt;</code></p>
-<note>The extension function could include both numdays and multiplier as arguments, thus bypassing the need for the extension element, but the purpose here is to illustrate the usage pattern for extension elements.</note>
-<p>As you review this stylesheet, please note the following:</p>
-<ol>
-	  <li>The declaration of the Xalan lxslt namespace, which provides support for the component and
-     component/script elements:<br/><br/>
-    <code>xmlns:lxslt="http://xml.apache.org/xslt"</code><br/><br/></li>
-    <li>The declaration of a namespace for this extension:<br/><br/>
-    <code>xmlns:my-ext="ext1"</code><br/><br/></li>
-  	<li>The designation of this namespace prefix as an extension prefix. This causes any element in the namespace associated with this prefix to be treated as an extension element rather than a literal result element.<br/><br/>
-     <code>extension-element-prefixes="my-ext"</code><br/><br/></li>
-	  <li>The lxslt:component with attributes designating the namespace prefix and the elements and
-     functions this extension provides.<br/><br/></li>
-  	<li>The lxslt:script subelement with a JavaScript implementation of the extension. For Java
-     extensions, the lxslt:script element has a src attribute that you set to identify the Java class.</li>
-</ol><anchor name="ex-basic"/>   
-<source>&lt;?xml version="1.0"?&gt;
-&lt;!--Namespaces are global if you set them in the stylesheet element--&gt;
-&lt;xsl:stylesheet 
-    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
-    version="1.0"   
-    xmlns:lxslt="http://xml.apache.org/xslt"
-    xmlns:my-ext="ext1"
-    extension-element-prefixes="my-ext"&gt;
-    
-  &lt;!--The component and its script are in the lxslt namespace and define the 
-    implementation of the extension.--&gt;
-  &lt;lxslt:component prefix="my-ext" elements="timelapse" functions="getdate"&gt;
-    &lt;lxslt:script lang="javascript"&gt;
-      var multiplier=1;
-      // The methods or functions that implement extension elements always take 2
-      // arguments. The first argument is the XSL Processor context; the second 
-      // argument is the element node.
-      function timelapse(xslProcessorContext, elem)
-      {
-        multiplier=parseInt(elem.getAttribute("multiplier"));
-        // The element return value is placed in the result tree.
-        // If you do not want a return value, return null.
-        return null;
-      }
-      function getdate(numdays)
-      {
-        var d = new Date();
-        var totalDays = parseInt(numdays) * multiplier;
-        d.setDate(d.getDate() + totalDays);
-        return d.toLocaleString();
-      }
-    &lt;/lxslt:script&gt;
-  &lt;/lxslt:component&gt;
-      
-  &lt;xsl:template match="deadline"&gt;
-    &lt;p&gt;&lt;my-ext:timelapse multiplier="2"/&gt;We have logged your enquiry and will 
-      respond by &lt;xsl:value-of select="my-ext:getdate(string(@numdays))"/&gt;.&lt;/p&gt;
-  &lt;/xsl:template>
-
-&lt;/xsl:stylesheet&gt;
-</source>
-</s2><anchor name="setup-runtime"/>
-<s2 title="Setting up the runtime environment">
-<p>To run the preceding example, bsf.jar and js.jar must be on the classpath. Remember that bsf.jar must be on the classpath to run any extension written in a language other than Java. For extensions implemented in a scripting language, see the additional requirements in <link anchor="supported-lang">Supported languages</link>.</p>
-</s2><anchor name="basic-syntax"/>
-<s2 title="Syntax">
-<p>You can always use the pattern illustrated above to set up and use extension elements and extension functions. For extension elements and functions implemented in Java, you can also use an abbreviated syntax, described in <link anchor="java-namespace">Alternative: using the abbreviated syntax for extensions implemented in Java</link>. Unless you are using the abbreviated syntax, do the following:</p>
-<s3 title="1. Declare the lxslt namespace">
-<p><br/><code>xmlns:lxslt="http://xml.apache.org/xslt"</code></p>
-<p>The lxslt namespace provides support for the lxslt:component element and lxslt:script subelement.</p>
-</s3>
-<s3 title="2. Declare a unique namespace for each extension prefix">
-<p><br/><code>xmlns:<ref>prefix</ref>=<ref>URI</ref></code></p>
-<p>The <ref>prefix</ref> identifies the namespace, and <ref>URI</ref> is an arbitrary (but unique) string that matches the value of the prefix attribute of an lxslt:component element in the stylesheet.<br/>
-Example: <code>xmlns:ext1="xyz"</code><br/><br/></p>
-</s3>
-<s3 title="3. If you are using extension elements, designate the extension element prefixes">
-<p><br/>This step is required only if you are using extension elements.  If you are using extension functions only, you can skip this step.</p>
-<p>In the stylesheet element, write:</p> 
-<p><code>extension-element-prefixes="<ref>prefix-1 prefix-2 ...</ref>"</code></p>
-<p>In a literal result element or extension element include the xsl prefix:</p>
-<p><code>xsl:extension-element-prefixes="<ref>prefix1 prefix2 ...</ref>"</code></p>
-<p>Keep in mind that where you declare namespaces and designate extension prefixes determines the scope of those namespaces.To make your extensions available throughout the stylesheet, include these settings and attribute in the stylesheet element.</p>
-</s3>
-<s3 title="4. (Optional) Exclude the extension namespace declaration from the result tree">
-<p><br/>By default, namespace declarations are included in the transformation output. To exclude namespaces from the output, use</p>
-<p><code>exclude-result-prefixes="<ref>prefix-1 prefix-2 ...</ref>"</code></p>
-<p>in the stylesheet element or</p>
-<p><code>xsl:exclude-result-prefixes="<ref>prefix-1 prefix-2 ...</ref>"</code></p> 
-<p>in a literal result element or extension element.</p>
-</s3>
-<s3 title="5. Set up an lxslt:component">
-<p><br/>In the scope of the lxslt namespace declaration:</p>
-<p><code>&lt;lxslt:component prefix="<ref>prefix</ref>" </code><br/>
-   <code>&nbsp;&nbsp;&nbsp;&nbsp;functions="<ref>func-1 func-2 ...func-n</ref>"</code><br/> 
-   <code>&nbsp;&nbsp;&nbsp;&nbsp;elements="<ref>elem-1 elem-2 ...elem-n</ref>"&gt;</code><br/>
-   <code>&nbsp;&nbsp;&lt;!--See lxslt:script below--&gt;</code><br/>
-   <code>&lt;/lxslt:component&gt;</code></p>
-<p>where <ref>func-1 func-2 ... func-n</ref> and <ref>elem-1 elem-2 ... elem-n</ref> designate the functions and elements the extension provides and the stylesheet uses. You can use the function-available and element-available functions to determine at run time whether a function or element designated in the lxslt:component is actually available.</p>
-<note>If the component is implemented in Java, the values of the <code>functions</code> and <code>elements</code> attributes are ignored. The function-available and element-available functions use reflection to examine the actual Java methods.</note>
-</s3>
-<anchor name="setup-script"/>
-<s3 title="6. Set up the lxslt:script element">
-<p><br/>In each lxslt:component, you must include exactly one lxslt:script element. If the extension is implemented in JavaScript:</p>
-<p><code>&lt;lxslt:script lang="javascript" &gt;</code><br/>
-<code>&nbsp;&nbsp;&lt;!--The implementation script--&gt;</code><br/>
-<code>&lt;/lxslt:script&gt;</code></p>
-<p>For other scripting languages supported by BSF, use the same approach as for JavaScript. &xslt4j; plans to add support for using the src attribute to identify another document that contains the implementation script; this feature is not yet supported.</p>
-<p>If the extension is implemented in Java, you have three choices for the format of the src attribute in the lxslt:script element.</p>
-<p><code>&lt;lxslt:script lang="javaclass" src="xalan://<ref>FQCN</ref>"/&gt;</code>
-<br/>where <ref>FQCN</ref> is the fully qualified class name.
-<br/>Example: <code>&lt;lxslt:script lang="javaclass" src="xalan://java.util.Hashtable"/&gt;</code></p>
-<p><code>&lt;lxslt:script lang="javaclass" src="xalan://<ref>PJPN</ref>"/&gt;</code>
-<br/>where <ref>PJPN</ref> is the beginning of or the complete name of a java package.
-<br/>Example: <code>&lt;lxslt:script lang="javaclass" src="java.util"/&gt;</code></p>
-<p><code>&lt;lxslt:script lang="javaclass" src="http://xml.apache.org/xslt/java"/&gt;</code></p>
-<p>The different formats for the value of the src attribute when using Java extensions are more fully explained in <link anchor="java-namespace-declare">Declare the namespace</link>.</p>
-</s3>
-<s3 title="Implicit DTD for lxslt:component">
-<source>&lt;!ELEMENT lxslt:component (lxslt:script)&gt;
-&lt;!ATTLIST lxslt:component
-  prefix CDATA #REQUIRED
-  elements NMTOKENS #IMPLIED
-  functions NMTOKENS #IMPLIED&gt;
-
-&lt;!ELEMENT lxslt:script (#PCDATA | EMPTY)?&gt;
-&lt;!ATTLIST lxslt:script
-  lang CDATA #REQUIRED
-  src CDATA #IMPLIED&gt;</source>
-</s3>
-</s2><anchor name="ext-elements"/>
-<s2 title="Using an extension element">
-<p>Extension elements pass the extension two objects:</p>
-<ul>
-<li><jump href="apidocs/org/apache/xalan/extensions/XSLProcessorContext.html">org.apache.xalan.extensions.XSLProcessorContext</jump>, which provides access to the XSL processor, the XML source tree, the stylesheet tree, the current context node, and the current mode (if any).<br/><br/></li>
-<li><jump href="apidocs/org/apache/xalan/templates/ElemExtensionCall.html">org.apache.xalan.templates.ElemExtensionCall</jump>, which provides the API for interacting with the extension element.</li>
-</ul>
-<p>You can use the ElemExtensionCall getAttribute(String name) method, for example, to read element attributes in their raw form.  Use the getAttribute(String name, Node sourceNode, XSLTEngineImpl processor) method to evaluate the attribute as an attribute value template.  Note that the method names are the same but the method signatures are different.  For full details, see the <jump href="apidocs/org/apache/xalan/templates/ElemExtensionCall.html">Javadoc</jump> for the ElemExtensionCall class.</p>
-<s3 title="Implementing an extension element">
-<p>For each extension element in a namespace, the implementation must be a Java method with the following signature, or the scripting language equivalent:</p>
-<p><code><ref>Type element</ref>(org.apache.xalan.extensions.XSLProcessorContext, </code><br/>
-<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.apache.xalan.templates.ElemExtensionCall extensionElement)</code></p>
-<p>where <ref>Type</ref> designates the return type and <ref>element</ref> is the local part of the extension element name (the element name without the namespace prefix). In the method signature, you may also use superclasses of the indicated types.</p>
-<p>If the extension element is implemented in a loosely typed scripting language, such as JavaScript, the arguments and return value are untyped.</p>
-<p><em>Caution:</em> The value returned by an extension element is placed in the transformation result. If you are not interested in a return value, use a public void Java method or return null from a scripting language function.</p>
-<p>Java example: <code>public void myElement</code><br/>
-<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(org.apache.xalan.xslt.XSLProcessorContext, </code><br/>
-<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.apache.xalan.templates.ElemExtensionCall extensionElement)</code></p>
-<p>JavaScript example: <code>function myElement(xslProcContext, element)</code></p>
-<p>The <link idref="extensionslib" anchor="redirect">Redirect extension</link> in the extensions library contains three extension elements.</p>
-</s3>
-
-</s2><anchor name="ext-functions"/>
-<s2 title="Using extension functions">
-<p>Extension functions may include arguments of any type and return a value of any type.</p>
-<p>XSLT recognizes five data types: node-set, result-tree-fragment, string, boolean, and number. You can use XPath expressions to set variables with values of these types. You can also pass literals for string, boolean, and number arguments. If you want to pass an argument of a type that XSLT does not recognize, use another extension function to return an object of that type. The stylesheet that appears in <link anchor="format-date-stylesheet">Formatting a date</link>, for example uses extension functions to return a Date object and a SimpleDateFormat object, and then uses these objects to call another extension function.</p>
-<s3 title="Data type mapping and method selection">
-<p>When calling an extension function written in a language other than Java, objects of the following Java classes will always be passed to the extension function:</p>
-  <table>
-    <tr>
-      <th>XSLT Type</th>
-      <th>Java Type</th>
-    </tr>
-    <tr>
-       <td>Node-Set</td>
-       <td>org.w3c.dom.traversal.NodeIterator</td>
-    </tr>
-    <tr>
-       <td>String</td>
-       <td>java.lang.String</td>
-    </tr>
-    <tr>
-       <td>Boolean</td>
-       <td>java.lang.Boolean</td>
-    </tr>
-    <tr>
-       <td>Number</td>
-       <td>java.lang.Double</td>
-    </tr>
-    <tr>
-       <td>Result Tree Fragment</td>
-       <td>org.w3c.dom.DocumentFragment</td>
-    </tr>
-  </table>
-<p>Any non-XSLT type is passed without conversion.</p>
-<p>When calling an extension function written in Java, the extension function signature can specify any of the indicated Java types, as explained below:</p>
-  <table>
-    <tr>
-      <th>XSLT Type</th>
-      <th>Java Types</th>
-    </tr>
-    <tr>
-       <td>Node-Set</td>
-       <td>org.w3c.dom.traversal.NodeIterator, org.w3c.dom.NodeList, org.w3c.dom.Node or its subclasses, java.lang.String, java.lang.Object, char, [double, float, long, int, short, byte,] boolean</td>
-    </tr>
-    <tr>
-       <td>String</td>
-       <td>java.lang.String, java.lang.Object, char, [double, float, long, int, short, byte,] boolean</td>
-    </tr>
-    <tr>
-       <td>Boolean</td>
-       <td>boolean, java.lang.Boolean, java.lang.Object, java.lang.String</td>
-    </tr>
-    <tr>
-       <td>Number</td>
-       <td>double, java.lang.Double, float, long, int, short,char, byte, boolean, java.lang.String, java.lang.Object</td>
-    </tr>
-    <tr>
-       <td>Result Tree Fragment</td>
-       <td>org.w3c.dom.traversal.NodeIterator, org.w3c.dom.NodeList, org.w3c.dom.Node or its subclasses, java.lang.String, java.lang.Object, char, [double, float, long, int, short, byte,] boolean</td>
-    </tr>
-    <tr>
-       <td>Non-XSLT Type</td>
-       <td>the native type or any of its superclasses, double, float, long, int, short, char, byte, java.lang.String</td>
-    </tr>
-  </table>
-<p>When calling extension functions written in Java, &xslt4j; selects the method to call as follows:</p>
-<ol>
-  <li>&xslt4j; selects all methods whose name matches the extension function name as specified in <link anchor="ext-func-calls">Extension function Java calls</link>.</li>
-  <li>From this list of methods, &xslt4j; determines which methods are <ref>qualified</ref>.</li>
-  <li>Each qualified method is assigned a score based on the table shown above. To assign the score to a given method, &xslt4j; examines each of the XSLT argument types in the function invocation in the stylesheet. For each argument, the appropriate row in the table above is selected. Then, the corresponding Java parameter type in the method signature in the Java program is scored. Types which appear earlier in the list are given a higher score.  That is, the list appears in order of scoring preference from highest to lowest. Types shown in square brackets have equal priority.</li>
-  <li>The method with the highest score is invoked after the arguments are converted to the appropriate type. If more than one method has the highest score, an exception is thrown.</li>
-</ol>
-<p>Any extension function written in Java can have a first parameter of type <code>org.apache.xalan.extensions.ExpressionContext</code>. Any method with an ExpressionContext as the first parameter will score higher than any method which does not have an ExpressionContext as a first parameter.</p>
-</s3>
-<anchor name="ext-func-calls"/>
-<s3 title="Extension function Java calls">
-<p>The technique for instantiating Java objects and calling Java methods depends on the format of the extension namespace that was declared.  See <link anchor="java-namespace-declare">Declare the namespace</link> for the three different formats of namespace declarations for Java extensions. For each namespace format, the section below describes how to instantiate an object, how to invoke an instance method, and how to invoke a static method. The sections below explain, for each syntax, which methods are <ref>qualified</ref> for method selection as described in the preceeding section.</p>
-<s4 title="Class format namespace">
-<p><br/><em>To create an instance of an object</em>:
-<br/><code><ref>prefix</ref>:new (<ref>args</ref>)</code></p>
-<p>where <ref>prefix</ref> is the extension namespace prefix. A new instance is to be created with the <ref>args</ref> constructor arguments (if any). All constructor methods are qualified for method selection.
-<br/>Example: <code>&lt;xsl:variable name="myType"</code>
-<br/><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select="my-class:new()"&gt;</code></p>
-
-<p><em>To invoke an instance method on a specified object</em>:
-<br/><code><ref>prefix</ref>:<ref>methodName</ref> (<ref>object</ref>, <ref>args</ref>)</code></p>
-<p>where <ref>prefix</ref> is the extension namespace prefix and <ref>methodName</ref> is the name of the method to invoke on <ref>object</ref> with the <ref>args</ref> arguments. <ref>object</ref> must be an object of the class indicated by the namespace declaration.  Otherwise, the case shown immediately below will apply. Only instance methods with  the name <ref>methodName</ref> are qualified methods. If a matching method is found, <ref>object</ref> will be used to identify the object instance and <ref>args</ref> will be passed to the invoked method.
-<br/>
-Example: <code>&lt;xsl:variable name="new-pop"</code><br/>
-<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select="my-class:valueOf($myType, string(@population))"&gt;</code></p>
-
-<p><em>To invoke an instance method on a default object</em>:
-<br/><code><ref>prefix</ref>:<ref>methodName</ref> (<ref>args</ref>)</code></p>
-<p>where <ref>prefix</ref> is the extension namespace prefix and <ref>methodName</ref> is the name of the method to invoke with the <ref>args</ref> arguments. The first <ref>arg</ref>, if any, must not be an object of the class indicated by the namespace declaration.  Otherwise, the case shown immediately above will apply. Only instance methods with the name <ref>methodName</ref> are qualified methods. If a matching method is found, a default instance of the class will be created if it does not already exist.
-<br/>
-Example: <code>&lt;xsl:variable name="new-pop"</code><br/>
-<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select="my-class:valueOf(string(@population))"&gt;</code></p>
-
-<p><em>To invoke a static method</em>:
-<br/><code><ref>prefix</ref>:<ref>methodName</ref> (<ref>args</ref>)</code></p>
-<p>where <ref>prefix</ref> is the extension namespace prefix and <ref>methodName</ref> is the name of the method to invoke with the <ref>args</ref> arguments. Only static methods with the name <ref>methodName</ref> are qualified methods. If a matching method is found, <ref>args</ref> will be passed to the invoked static method.
-<br/>
-Example: <code>&lt;xsl:variable name="new-pop"</code><br/>
-<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select="my-class:printit(string(@population))"&gt;</code></p>
-</s4>
-<s4 title="Package format namespace">
-<p><br/><em>To create an instance of an object</em>:
-<br/><code><ref>prefix</ref>:<ref>subpackage</ref>.<ref>class</ref>.new (<ref>args</ref>)</code></p>
-<p>where <ref>prefix</ref> is the extension namespace prefix, <ref>subpackage</ref> is the rest of the package name (the beginning of the package name was in the namespace declaration), and <ref>class</ref> is the name of the class. A new instance is to be created with the <ref>args</ref> constructor arguments (if any). All constructor methods are qualified for method selection.
-<br/>Example: <code>&lt;xsl:variable name="myType"</code>
-<br/><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select="my-package:extclass.new()"&gt;</code></p>
-
-<p><em>To invoke an instance method on a specified instance</em>:
-<br/><code><ref>prefix</ref>:<ref>methodName</ref> (<ref>object</ref>, <ref>args</ref>)</code></p>
-<p>where <ref>prefix</ref> is the extension namespace prefix and <ref>methodName</ref> is the name of the method to invoke on <ref>object</ref> with the <ref>args</ref> arguments. Only instance methods of the <ref>object</ref> with the name <ref>methodName</ref> are qualified methods. If a matching method is found, <ref>object</ref> will be used to identify the object instance and <ref>args</ref> will be passed to the invoked method.
-<br/>
-Example: <code>&lt;xsl:variable name="new-pop"</code><br/>
-<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select="my-package:valueOf($myType, string(@population))"&gt;</code></p>
-
-<p><em>To invoke a static method</em>:
-<br/><code><ref>prefix</ref>:<ref>subpackage</ref>.<ref>class</ref>.<ref>methodName</ref> (<ref>args</ref>)</code></p>
-<p>where <ref>prefix</ref> is the extension namespace prefix, <ref>subpackage</ref> is the rest of the package name (the beginning of the package name was in the namespace declaration), <ref>class</ref> is the name of the class, and <ref>methodName</ref> is the name of the method to invoke with the <ref>args</ref> arguments. Only static methods with the name <ref>methodName</ref> are qualified methods. If a matching method is found, <ref>args</ref> will be passed to the invoked static method.
-<br/>
-Example: <code>&lt;xsl:variable name="new-pop"</code><br/>
-<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select="my-package:extclass.printit(string(@population))"&gt;</code></p>
-<note>Unlike the class format namespace, there is no concept of a default object since the namespace declaration does not identify a unique class.</note>
-</s4>
-<s4 title="Java format namespace">
-<p><br/><em>To create an instance of an object</em>:
-<br/><code><ref>prefix</ref>:<ref>FQCN</ref>.new (<ref>args</ref>)</code></p>
-<p>where <ref>prefix</ref> is the extension namespace prefix for the Java namespace and <ref>FQCN</ref> is the fully qualified class name of the class whose constructor is to be called. A new instance is to be created with the <ref>args</ref> constructor arguments (if any). All constructor methods are qualified for method selection.
-<br/>Example: <code>&lt;xsl:variable name="myHash"</code>
-<br/><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select="java:java.util.Hashtable.new()"&gt;</code></p>
-
-<p><em>To invoke an instance method on a specified instance</em>:
-<br/><code><ref>prefix</ref>:<ref>methodName</ref> (<ref>object</ref>, <ref>args</ref>)</code></p>
-<p>where <ref>prefix</ref> is the extension namespace prefix and <ref>methodName</ref> is the name of the method to invoke on <ref>object</ref> with the <ref>args</ref> arguments. Only instance methods of the <ref>object</ref> with the name <ref>methodName</ref> are qualified methods. If a matching method is found, <ref>object</ref> will be used to identify the object instance and <ref>args</ref> will be passed to the invoked method.
-<br/>
-Example: <code>&lt;xsl:variable name="new-pop"</code><br/>
-<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select="java:put($myHash, string(@region), $newpop)"&gt;</code></p>
-
-<p><em>To invoke a static method</em>:
-<br/><code><ref>prefix</ref>:<ref>FQCN</ref>.<ref>methodName</ref> (<ref>args</ref>)</code></p>
-<p>where <ref>prefix</ref> is the extension namespace prefix, <ref>FQCN</ref> is the fully qualified class name of the class whose static method is to be called, and <ref>methodName</ref> is the name of the method to invoke with the <ref>args</ref> arguments. Only static methods with the name <ref>methodName</ref> are qualified methods. If a matching method is found, <ref>args</ref> will be passed to the invoked static method.
-<br/>
-Example: <code>&lt;xsl:variable name="new-pop"</code><br/>
-<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select="java:java.lang.Integer.valueOf(string(@population))"&gt;</code></p>
-<note>Unlike the class format namespace, there is no concept of a default object since the namespace declaration does not identify a unique class.</note>
-</s4>
-</s3>
-
-<s3 title="Passing Nodes to java">
-<p>Please keep in mind that <em>all</em> LocationPath expressions return a node-set, even if the expression only returns a single attribute or a text node (node-sets with one member). You can use the XSLT string() function (as in the syntax examples above) to convert a node-set value to string, and the number() function to convert a node-set value to number (a double).</p>
-<p>If you want to pass a node-set to an extension function, set up a Java method to accept an 
-org.w3c.dom.NodeList (or an org.apache.xpath.NodeSet, which implements NodeList, if you want to modify the nodes).</p>
-<p>Suppose, for example, you have a myExtensions.ProcessNodes class with the following doSomething method:</p>
-<p><code>public static boolean doSomething(org.w3c.dom.NodeList nList)</code></p>
-<p>Assuming you set up this extension in the node-ext namespace, any of the following extension calls from a stylesheet are syntactically possible:</p>
-<p><code>&lt;!--Process the current node--&gt;</code><br/>
-<code>&lt;xsl:variable name="success" select="node-ext:MyExtensions.ProcessNodes.doSomething(.)"/&gt;</code></p>
-<p><code>&lt;!--Process all nodes in current context--></code><br/>
-<code>&lt;xsl:variable name="success" select="node-ext:MyExtensions.ProcessNodes.doSomething(*)"/&gt;</code></p>
-<p><code>&lt;!-- Process all nodes --></code><br/>
-<code>&lt;xsl:variable name="success" select="node-ext:MyExtensions.ProcessNodes.doSomething(/*)"/&gt;</code></p>
-<p><code>&lt;!--Process the foo/baz nodes in current context --></code><br/>
-<code>&lt;xsl:variable name="success" select="node-ext:MyExtensions.ProcessNodes.doSomething(foo/baz)"/&gt;</code></p>
-<p><code>&lt;!--Process the/foo/baz and /bar/saz nodes --></code><br/>
-<code>&lt;xsl:variable name="success" select="node-ext:MyExtensions.ProcessNodes.doSomething(/foo/baz | /bar/saz)"/&gt;</code></p>
-<p>The NodeList is in fact a list of references into the XML document, so keep in mind that getNextSibling(), for example, gets you the next sibling in the document, which may not be the next Node in the NodeList.</p>
-</s3>
-<s3 title="Implementing extension functions">
-<p>For each extension function in a namespace which is implemented in a language other than Java, the implementation must include a method with the following signature, or the scripting language equivalent:</p>
-<p><code>public <ref> object function</ref>(<ref>args</ref>)</code></p>
-<p>where <ref>object</ref> is the return type, <ref>function</ref> is the local part of the extension function name (the function name without the namespace prefix), and <ref>args</ref> correspond to the arguments in the function call.</p>
-<p>In addition, for extension functions implemented in Java, the implementation may include either a Java method with the signature shown above or one with the following signature:</p>
-<p><code>public <ref> object function</ref>(org.apache.xalan.extensions.ExpressionContext, <ref>args</ref>)</code></p>
-</s3>
-</s2><anchor name="java-namespace"/>
-<s2 title="Alternative: using the abbreviated syntax for extensions implemented in Java">
-<p>For extension functions and extension elements implemented in Java, Xalan permits an abbreviated syntax. When you use the abbreviated syntax, you do not use an lxslt:component to designate the functions.</p>
-<p>The abbreviated syntax supports the use of extension functions and extension elements implemented in Java. You cannot use this syntax with extensions implemented in JavaScript or another scripting language.</p>
-<anchor name="java-namespace-declare"/>
-<s3 title="Declare the namespace">
-<p>Declare the namespace for your extensions using one of the following three formats. The technique for invoking an extension for each format is explained in <link anchor="ext-func-calls">Extension function Java calls</link>.</p>
-<p><em>class format:</em> <code>xmlns:my-class="xalan://<ref>FQCN</ref>"</code></p>
-<p>where <ref>FQCN</ref> is the fully qualified class name.
-<br/>Examples: <code>xmlns:my-class="xalan://java.util.Hashtable"</code>
-<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>xmlns:my-class="xalan://mypackage.myclass"</code></p>
-<p><em>package format:</em> <code>xmlns:my-class="xalan://<ref>PJPN</ref>"</code></p>
-<p>where <ref>PJPN</ref> is a partial java package name.  That is, it is the beginning of or the complete name of a java package.
-<br/>Examples: <code>xmlns:my-package="xalan://java.util"</code>
-<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>xmlns:my-package="xalan://mypackage"</code></p>
-<p><em>Java format:</em> <code>xmlns:java="http://xml.apache.org/xslt/java"</code></p>
-<note>Although the namespace declarations for the class and package formats are shown with the xalan:// prefix, the current implementation for those formats will simply use the string to the right of the rightmost forward slash as the Java class name. This format is shown in order to comply with W3C recommendations for namespace declarations.</note>
-<note>The class: prefix which was sometimes required in earlier versions of &xslt4j; is no longer required.</note>
-<note>These formats are also available when coding the src attribute of the lxslt:script element as explained in <link anchor="setup-script">Set up the lxslt:script element</link>.</note>
-</s3>
-<s3 title="Use the namespace when you make extension calls">
-<p>Use the declared prefix with the syntax described in <link anchor="ext-func-calls">Extension function Java calls</link>.</p>
-<p>That is all. You do not include an lxslt:component element. Using the abbreviated syntax clearly involves less setup than using the lxslt:component/lxslt:script approach.</p>
-<note>We recommend that, for extensions coded in Java, the abbreviated syntax should always be used since the lxslt:component/lxslt:script constructs add no functionality.</note>
-</s3><anchor name="ex-java-namespace"/> 
-<s3 title="Example: Formatting a date">
-<p>This example uses extension functions to call the SimpleDateFormat class and the IntDate class. IntDate uses String arguments to set up a Date object:</p>
-<source>import java.util.Date;
-import java.util.Calendar;
-
-public class IntDate
-{
-  public static Date getDate(String year, String month, String day)
-    {
-      // Date(int, int, int) has been deprecated, so use Calendar to
-      // set the year, month, and day.
-      Calendar c = Calendar.getInstance();
-      // Convert each argument to int.
-      c.set ( Integer.parseInt(year),
-              Integer.parseInt(month),
-              Integer.parseInt(day) );
-      return c.getTime();
-    }
-}</source>
-<p>The template transforms date elements with four attributes. For example, it transforms <code>&lt;date format="EEEE, MMM dd, yyyy" year="2000" month="4" day="27"/&gt;</code> into &lt;p&gt;Date: Thursday, April 27, 2000.&lt;/p&gt;.</p>
-<p>As you review this stylesheet, please keep the following in mind:</p>
- <ul>
-  <li>The exclude-result-prefixes stylesheet attribute prevents the java namespace declaration from
-   appearing in the output.</li>
-  <li>The XSLT type returned by any LocationPath expression is node-set, so the XSLT string
-    function is used to convert the format, year, month, and day attribute values from node-sets to
-    strings.</li>
-  <li>The format attribute provides a String argument for constructing a java.text.SimpleDateFormat
-    object.</li>
-    <li>The IntDate class uses String values provided by the year, month, and day attributes, to set the
-    date. XSLT can pass number values, but these are converted into doubles.</li>
-  <li>The formatter variable holds a SimpleDateFormat object, and the date variable holds a Date object.
-    XSLT does not understand either of these types, but they are used to call the SimpleDateFormat format
-     method. In that call, $formatter is the object, and $date is the argument. The syntax for calling
-     Java constructors and methods is described above in <link anchor="ext-func-calls">Extension function Java calls</link>.</li>    
- </ul><anchor name="format-date-stylesheet"/>   
-<source>&lt;?xml version="1.0"?&gt;
-&lt;xsl:stylesheet 
-    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
-    version="1.0"   
-    xmlns:java="http://xml.apache.org/xslt/java"
-    exclude-result-prefixes="java"&gt;
-    
-  &lt;!--Other templates for transforming the rest of
-                                            the XML source documents--&gt;
-  
-  &lt;xsl:template match="date"&gt; 
-    &lt;xsl:variable name="year" select="string(./@year)"/&gt;
-    &lt;xsl:variable name="month" select="string(./@month)"/&gt; 
-    &lt;xsl:variable name="day" select="string(./@day)"/&gt;          
-    &lt;xsl:variable name="format" select="string(./@format)"/&gt;
-
-    &lt;xsl:variable name="formatter"       
-        select="java:java.text.SimpleDateFormat.new($format)"/&gt;
-
-    &lt;xsl:variable name="date" 
-        select="java:IntDate.getDate($year, $month, $day)"/&gt;
-
-    &lt;p&gt;Date: &lt;xsl:value-of select="java:format($formatter, $date)"/&gt;&lt;/p&gt;
-  &lt;/xsl:template&gt;
-&lt;/xsl:stylesheet&gt;  
-</source>
-</s3>
-</s2>
-<s2 title="Examples: using Java and JavaScript to implement the same extension">
-<p>This section contains two examples. The first example uses a Java extension to transform a set of name elements  into an alphabetical and numbered list. The second example uses a JavaScript script to do the same. Both examples include equivalent extension elements and an extension function.</p>
-<anchor name="ex-java"/> 
-<s3 title="Java implementation">
-<p>MyCounter.java</p>
-<source>Import java.util.*;
-
-public class MyCounter {
-  Hashtable counters = new Hashtable ();
-
-  public MyCounter () 
-  {}
-
-  public void init
-             ( org.apache.xalan.extensions.XSLProcessorContext context,
-               org.apache.xalan.templates.ElemExtensionCall extElem ) 
-  {
-    String name = extElem.getAttribute("name");
-    String value = extElem.getAttribute("value");
-    int val;
-    try 
-    {
-      val = Integer.parseInt (value);
-    } 
-    catch (NumberFormatException e) 
-    {
-      e.printStackTrace ();
-      val = 0;
-    }
-    counters.put (name, new Integer (val));
-  }
-
-  public int read(String name) 
-  {
-    Integer cval = (Integer) counters.get (name);
-    return (cval == null) ? 0 : cval.intValue ();
-  }
-
-  public void incr
-             ( org.apache.xalan.extensions.XSLProcessorContext context,
-               org.apache.xalan.templates.ElemExtensionCall extElem) 
-  {
-    String name = extElem.getAttribute("name");
-    Integer cval = (Integer) counters.get(name);
-    int nval = (cval == null) ? 0 : (cval.intValue () + 1);
-    counters.put (name, new Integer (nval));
-  }
-}
-</source>
-<p>An XML source document:</p>
-<source>&lt;?xml version="1.0"?&gt;
-&lt;doc&gt;
-  &lt;name first="David" last="Marston"/&gt;
-  &lt;name first="David" last="Bertoni"/&gt;
-  &lt;name first="Donald" last="Leslie"/&gt;
-  &lt;name first="Emily" last="Farmer"/&gt;
-  &lt;name first="Jack" last="Donohue"/&gt;
-  &lt;name first="Myriam" last="Midy"/&gt;
-  &lt;name first="Paul" last="Dick"/&gt;
-  &lt;name first="Robert" last="Weir"/&gt;
-  &lt;name first="Scott" last="Boag"/&gt;
-  &lt;name first="Shane" last="Curcuru"/&gt;
-&lt;/doc&gt;</source>
-<p>The stylesheet:</p>
-<source>&lt;?xml version="1.0"?&gt; 
-&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                xmlns:lxslt="http://xml.apache.org/xslt"
-                xmlns:counter="MyCounter"
-                extension-element-prefixes="counter"
-                version="1.0"&gt;
-
-  &lt;lxslt:component prefix="counter"
-                   elements="init incr" functions="read"&gt;
-    &lt;lxslt:script lang="javaclass" src="xalan://MyCounter"/&gt;
-  &lt;/lxslt:component&gt;
-
-  &lt;xsl:template match="/"&gt;
-    &lt;HTML&gt;
-      &lt;H1&gt;Names in alphabetical order&lt;/H1&gt;
-      &lt;counter:init name="index" value="1"/&gt;
-      &lt;xsl:for-each select="doc/name"&gt;
-        &lt;xsl:sort select="@last"/&gt;
-        &lt;xsl:sort select="@first"/&gt;
-        &lt;p&gt;
-        &lt;xsl:text&gt;[&lt;/xsl:text&gt;
-        &lt;xsl:value-of select="counter:read('index')"/&gt;
-        &lt;xsl:text&gt;]. &lt;/xsl:text&gt;
-        &lt;xsl:value-of select="@last"/&gt;
-        &lt;xsl:text&gt;, &lt;/xsl:text&gt;
-        &lt;xsl:value-of select="@first"/&gt;
-        &lt;/p&gt;
-        &lt;counter:incr name="index"/&gt;
-      &lt;/xsl:for-each&gt;
-    &lt;/HTML&gt;
-  &lt;/xsl:template&gt;
- 
-&lt;/xsl:stylesheet&gt;
-</source>
-<p>Transformation output:</p>
-<source>&lt;HTML&gt;
-&lt;H1&gt;Names in alphabetical order&lt;/H1&gt;
-&lt;p&gt;[1]. Bertoni, David&lt;/p&gt;
-&lt;p&gt;[2]. Boag, Scott&lt;/p&gt;
-&lt;p&gt;[3]. Curcuru, Shane&lt;/p&gt;
-&lt;p&gt;[4]. Dick, Paul&lt;/p&gt;
-&lt;p&gt;[5]. Donohue, Jack&lt;/p&gt;
-&lt;p&gt;[6]. Farmer, Emily&lt;/p&gt;
-&lt;p&gt;[7]. Leslie, Donald&lt;/p&gt;
-&lt;p&gt;[8]. Marston, David&lt;/p&gt;
-&lt;p&gt;[9]. Midy, Myriam&lt;/p&gt;
-&lt;p&gt;[10]. Weir, Robert&lt;/p&gt;
-&lt;/HTML&gt;</source>
-</s3><anchor name="ex-javascript"/> 
-<s3 title="JavaScript implementation">
-<p></p>
-<source>&lt;?xml version="1.0"?&gt; 
-&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                xmlns:lxslt="http://xml.apache.org/xslt"
-                xmlns:counter="MyCounter"
-                extension-element-prefixes="counter"
-                version="1.0"&gt;
-
-  &lt;lxslt:component prefix="counter"
-                   elements="init incr" functions="read"&gt;
-    &lt;lxslt:script lang="javascript"&gt;
-      var counters = new Array();
-
-      function init (xslproc, elem) {
-        name = elem.getAttribute ("name");
-        value = parseInt(elem.getAttribute ("value"));
-        counters[name] = value;
-        return null;
-      }
-
-      function read (name) {
-        // Return a string.
-        return "" + (counters[name]);
-      }
-
-      function incr (xslproc, elem)
-      {
-        name = elem.getAttribute ("name");
-        counters[name]++;
-        return null;
-      }
-    &lt;/lxslt:script&gt;
-  &lt;/lxslt:component&gt;
-
-  &lt;xsl:template match="/"&gt;
-    &lt;HTML&gt;
-      &lt;H1&gt;Names in alphatebical order&lt;/H1&gt;
-      &lt;counter:init name="index" value="1"/&gt;
-      &lt;xsl:for-each select="doc/name"&gt;
-        &lt;xsl:sort select="@last"/&gt;
-        &lt;xsl:sort select="@first"/&gt;
-        &lt;p&gt;
-        &lt;xsl:text&gt;[&lt;/xsl:text&gt;
-        &lt;xsl:value-of select="counter:read('index')"/&gt;
-        &lt;xsl:text&gt;]. &lt;/xsl:text&gt;
-        &lt;xsl:value-of select="@last"/&gt;
-        &lt;xsl:text&gt;, &lt;/xsl:text&gt;
-        &lt;xsl:value-of select="@first"/&gt;
-        &lt;/p&gt;
-        &lt;counter:incr name="index"/&gt;
-      &lt;/xsl:for-each&gt;
-    &lt;/HTML&gt;
-  &lt;/xsl:template&gt;
- 
-&lt;/xsl:stylesheet&gt;
-</source>
-<p>This stylesheet produces the same output as the preceding example with the Java extension.</p>
-</s3>
-</s2>
-</s1>
diff --git a/xdocs/sources/xalan/extensionslib.xml b/xdocs/sources/xalan/extensionslib.xml
deleted file mode 100644
index 2915c80..0000000
--- a/xdocs/sources/xalan/extensionslib.xml
+++ /dev/null
@@ -1,325 +0,0 @@
-<?xml version="1.0" standalone="no"?> 
-<!DOCTYPE s1 SYSTEM "../../style/dtd/document.dtd">
-<!-- 
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- -->
-<s1 title="Extensions library">
-<ul>
-<li><link anchor="intro">Introduction</link></li>
-<li><link anchor="xalanns">Xalan namespace</link></li>
-<li><link anchor="redirect">Redirect</link></li>
-<li><link anchor="nodeset">nodeset</link></li>
-<li><link anchor="intersection">intersection</link></li>
-<li><link anchor="difference">difference</link></li>
-<li><link anchor="distinct">distinct</link></li>
-<li><link anchor="hassamenodes">hasSameNodes</link></li>
-<li><link anchor="sql">SQL extensions</link></li>
-<li><link anchor="evaluate">evaluate</link></li>
-<li><link anchor="tokenize">tokenize</link></li>
-<li><link anchor="groupitem">group and item</link> <ref>(to be done)</ref></li>
-<li><link anchor="type">type</link> <ref>(to be done)</ref></li>
-<li><link anchor="todate">toDate</link> <ref>(to be done)</ref></li>
-<li><link anchor="formatdate">formatDate</link> <ref>(to be done)</ref></li>
-<li><link anchor="grep">grep</link> <ref>(to be done)</ref></li>
-<li><link anchor="foreachtoken">forEachToken</link> <ref>(to be done)</ref></li>
-<li>Examples: <link anchor="ex-redirect">Redirect</link>, <link anchor="ex-nodeset">nodeset</link>, <link anchor="ex-sql">SQL library</link></li>
-</ul><anchor name="intro"/>
-<s2 title= "Introduction">
-<p>Extension elements and functions provide a powerful mechanism
-for extending and simplifying what you can do with an XLST processor like
-Xalan. With input and contributions from the XML open-source developer community, we are working on placing the most useful
-extensions in an extensions library distributed with &xslt4j;. If you have ideas and/or contributions you would like to make, please email us at the <human-resource-ref idref="xalandev"/>.</p>
-</s2><anchor name="xalanns"/>
-<s2 title="Xalan namespace">
-<p>Where it makes sense, we are placing the new Xalan extensions in the org.apache.xalan.lib.Extensions class and we have defined a namespace for this class:</p>
-<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>http://xml.apache.org/xalan</code></p>
-<p>If you are calling &xslt4j;-supplied extensions, we recommend that you define this namespace in your stylesheet element, and call the extension using the namespace prefix that you have associated with that namespace. That way, if we later reorganize how the &xslt4j;-supplied extensions are stored, you won't have to modify your stylesheet.</p>
-<p>For an example that uses this namespace, see <link anchor="ex-nodeset">Example with the nodeset extension function</link>.</p>
-</s2><anchor name="redirect"/>
-<s2 title= "Redirect">
-<p>A standard XSL transformation involves an XSL stylesheet, an XML source tree, and the transformation result tree. The transformation sends the entire result to a single <jump href="apidocs/org/apache/trax/Result.html">org.apache.trax.Result</jump> object.</p> 
-<p>The Redirect extension 
-(<jump href="apidocs/org/apache/xalan/xslt/extensions/Redirect.html">org.apache.xalan.xslt.extensions.Redirect</jump>) supplies three extension elements that you can use to redirect portions of your transformation output to multiple files: &lt;open&gt;, &lt;write&gt;, and &lt;close&gt;. If you use the &lt;write&gt; element alone, the extension opens a file, writes to it, and closes the file immediately. If you want explicit control over the opening and closing of files, use &lt;write&gt; in conjunction with the &lt;open&gt; and &lt;close&gt; elements.</p>
-<p>Each of these elements includes a file attribute and/or a select attribute to designate the output file. The file attribute takes a string, so you can use it to directly specify the output file name. The select attribute takes an XPath expression, so you can use it to dynamically generate the output file name. If you include both attributes, the Redirect extension first evaluates the select attribute, and falls back to the file attribute if the select attribute expression does not return a valid file name.</p>
-<anchor name="ex-redirect"/> 
-<s3 title="Example with the Redirect extension">
-<p>Suppose you are outputting the bulk of your result tree to one file, but you want to output the transformation of all &lt;foo&gt; elements and their children to another file. The following example illustrates the basic structure of the XML source:</p>
-<source>&lt;?xml version="1.0"?&gt; 
-&lt;doc&gt;
-  &lt;foo file="foo.out"&gt;
-    Testing Redirect extension:
-      &lt;bar&gt;A foo subelement text node&lt;/bar&gt;
-  &lt;/foo&gt;
-  &lt;main&gt;
-    Everything else
-  &lt;/main&gt;  
-&lt;/doc&gt;</source>
-<p>This stylesheet redirects part of the output to a secondary file:</p>
-<source>
-&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-    version="1.0"
-    xmlns:lxslt="http://xml.apache.org/xslt"
-    xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
-    extension-element-prefixes="redirect"&gt;
-
-  &lt;xsl:template match="/"&gt;
-    &lt;standard-out&gt;
-      Standard output:
-      &lt;xsl:apply-templates/&gt;
-    &lt;/standard-out&gt;
-  &lt;/xsl:template&gt;
-  
-  &lt;xsl:template match="main"&gt;
-    &lt;main&gt;
-      &lt;xsl:apply-templates/&gt;
-    &lt;/main&gt;
-  &lt;/xsl:template&gt;
-  
-  &lt;xsl:template match="/doc/foo"&gt;
-    &lt;redirect:write select="@file"&gt;
-      &lt;foo-out&gt;
-        &lt;xsl:apply-templates/&gt;
-      &lt;/foo-out&gt;
-    &lt;/redirect:write&gt;
-  &lt;/xsl:template&gt;
-  
-  &lt;xsl:template match="bar"&gt;
-    &lt;foobar-out&gt;
-      &lt;xsl:apply-templates/&gt;
-    &lt;/foobar-out&gt;
-  &lt;/xsl:template&gt;
-  
-&lt;/xsl:stylesheet&gt;</source>
-<p>The standard output is:</p>
-<source>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
-&lt;standard-out&gt;
-  Standard output:
-  &lt;main&gt;
-    Everything else.
-  &lt;/main&gt;
-&lt;standard-out&gt;</source>
-<p>The output redirected to foo.out is:</p>
-<source>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
-&lt;foo-out&gt;
-    Testing Redirect extension:
-    &lt;foobar-out&gt;foo subelement text node&lt;/foobar-out&gt;
-  &lt;/foo-out&gt;</source>
-<p>For more information on using the Redirect extension to send output to multiple files, examine the <link idref="samples" anchor="ext1">SimpleRedirect</link> sample and see the <jump href="apidocs/org/apache/xalan/lib/Redirect.html">Redirect</jump> class Javadoc.</p>  
-</s3></s2><anchor name="nodeset"/>
-<s2 title= "nodeset">
-<p>Implemented in <jump href="apidocs/org/apache/xalan/lib/Extensions.html">org.apache.xalan.lib.Extensions</jump>,<br/>
-<code>nodeset (result-tree-fragment)</code>  casts a result tree fragment into a node-set.</p>
-<note>When you bind a variable to a template, rather than to the value generated by a select expression, the data type of the variable is result tree fragment. For more information, see <jump href="http://www.w3.org/TR/xslt#section-Result-Tree-Fragments">Result Tree Fragments</jump>.</note>
-<anchor name="ex-nodeset"/>
-<s3 title="Example with the nodeset extension function">
-<p>The following stylesheet uses the nodeset extension function to cast a result tree fragment into a node-set that can then be navigated in standard XPath manner. It uses the http://xml.apache.org/xalan namespace to provide access to the nodeset() method in xml.apache.xalan.lib.Extensions.</p>
-<source>&lt;?xml version="1.0"?&gt;
-&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
-                xmlns:xalan="http://xml.apache.org/xalan"
-                exclude-result-prefixes="xalan"&gt;
-&lt;xsl:template match="/"&gt;
-  &lt;out&gt;
-	  &lt;xsl:variable name="rtf"&gt;
-      &lt;docelem&gt;
-        &lt;elem1&gt;
-          &lt;elem1a&gt;ELEMENT1A&lt;/elem1a&gt;
-          &lt;elem1b&gt;,ELEMENT1B&lt;/elem1b&gt;
-        &lt;/elem1&gt;
-        &lt;elem2&gt;
-          &lt;elem2a&gt;ELEMENT2A&lt;/elem2a&gt;
-        &lt;/elem2&gt;
-      &lt;/docelem&gt;
-    &lt;/xsl:variable&gt;     
-      &lt;xsl:for-each select="xalan:nodeset($rtf)/docelem//*"&gt;
-        &lt;xsl:value-of select="name(.)"/&gt;&lt;xsl:text&gt;,&lt;/xsl:text&gt;
-      &lt;/xsl:for-each>
-  &lt;/out>
-&lt;/xsl:template> 
-&lt;/xsl:stylesheet&gt;</source>
-<p>The output of running this stylesheet (with any XML input source) is a comma-delimited list of the element names in the node-set<br/>
-&nbsp;&nbsp;<code>&lt;out&gt;elem1,elem1a,elem1b,elem2,elem2a&lt;/out&gt;</code></p>
-<note>For illustration purposes, the preceding stylesheet pays no attention to the structure and content of the XML input document. Instead, it processes the template (in the stylesheet) bound to the variable named rtf.</note>
-
-</s3>
-</s2><anchor name="intersection"/>
-<s2 title="intersection">
-<p>Implemented in <jump href="apidocs/org/apache/xalan/lib/Extensions.html">org.apache.xalan.lib.Extensions</jump>,<br/>
-<code>intersection (node-set1, node-set2)</code>  function returns a node-set with all nodes that are in ns1 and in ns2 .</p>
-</s2><anchor name="difference"/>
-<s2 title= "difference">
-<p>Implemented in <jump href="apidocs/org/apache/xalan/lib/Extensions.html">org.apache.xalan.lib.Extensions</jump>,<br/>
-<code>difference(node-set1, node-set2)</code> returns a node-set with the nodes in node-set1 and not in node-set2.</p>
-</s2><anchor name="distinct"/>
-<s2 title= "distinct">
- <p>Implemented in <jump href="apidocs/org/apache/xalan/lib/Extensions.html">org.apache.xalan.lib.Extensions</jump>,<br/>
- distinct (node-set) returns a node-set containing nodes with distinct string values. If more than one node in the node-set 
- contains the same text node value, distinct only returns the first of these nodes that it finds.</p>
-</s2><anchor name="hassamenodes"/>
-<s2 title= "hasSameNodes">
-<p>Implemented in <jump href="apidocs/org/apache/xalan/lib/Extensions.html">org.apache.xalan.lib.Extensions</jump>,<br/>
-<code>hasSameNodes(node-set1, node-set2)</code> returns true if both node-set1 and node-set2 contain exactly the same set of nodes.</p>
-</s2><anchor name="sql"/>
-<s2 title= "SQL library">
-<p><em>**Experimental**</em> Provides extension functions for connecting to a JDBC data source, executing a query,
-and working incrementally through "streamable" result set.</p>
-<p><em>The SQL extension use of a single row-set node to incrementally return a query result set is experimental. Keep in mind that you
-can only access row elements one at a time moving forward through the result set. The use of XPath expressions in your stylesheet, for
-example, that attempt to return nodes from the result set in any other manner may produce unpredictable results.</em></p>
-<p><jump href="apidocs/org/apache/xalan/lib/sql/XConnection.html">org.apache.xalan.lib.sql.XConnection</jump> provides three extension functions that you can use in your stylesheet.</p>
-    <ol>
-      <li>new() -- Use one of the XConnection constructors to connect to a data source, and return an XConnection
-       object.<br/><br/></li>
-      <li>query() -- Use the XConnection object query() method to return a "streamable" result set in the form of a row-set
-       node. Work your way through the row-set one row at a time. The same row element is used over and over again, so you can
-       begin "transforming" the row-set before the entire result set has been returned.<br/><br/></li>
-      <li>close() -- Use the XConnection object close() method to terminate the connection.</li>      
-    </ol>
-    <p>The query() extension function returns a Document node that contains (as needed) an array of column-header elements, 
-    a single row element that is used repeatedly, and an array of col elements. Each column-header element (one per column in
-    the row-set) contains an attribute (ColumnAttribute) for each of the column descriptors in the ResultSetMetaData object. 
-    Each col element contains a text node with a textual representation of the value for that column in the current row.</p>
-    <anchor name="ex-sql"/> 
-    <s3 title="Example with SQL library">
-    <p>This example displays the result set from a table in a sample InstantDB database. It is also
-    available as a sample application; see 
-    <link idref="samples" anchor="ext6">6-sqllib-instantdb</link>.</p>
-<source>&lt;?xml version="1.0"?&gt;
-&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                version="1.0"
-                xmlns:sql="org.apache.xalan.lib.sql.XConnection"
-                extension-element-prefixes="sql"&gt;
-  &lt;xsl:output method="html" indent="yes"/&gt;
-  &lt;xsl:param name="query" select="'SELECT * FROM import1'"/&gt;
- 
-  &lt;xsl:template match="/"&gt;
-    &lt;!-- 1. Make the connection --&gt;
-    &lt;xsl:variable name="products"
-                  select="sql:new('org.enhydra.instantdb.jdbc.idbDriver',
-                                'jdbc:idb:.\instantdb\sample.prp')"/&gt;
-    &lt;HTML&gt;
-      &lt;HEAD&gt;
-      &lt;/HEAD&gt;
-      &lt;BODY&gt;
-        &lt;TABLE border="1"&gt;
-        &lt;!--2. Execute the query --&gt;
-        &lt;xsl:variable name="table" select='sql:query($products, $query)'/&gt;
-          &lt;TR&gt;
-          &lt;!-- Get column-label attribute from each column-header--&gt;
-          &lt;xsl:for-each select="$table/row-set/column-header"&gt;
-            &lt;TH&gt;&lt;xsl:value-of select="@column-label"/&gt;&lt;/TH&gt;
-          &lt;/xsl:for-each&gt;
-          &lt;/TR&gt;
-          &lt;xsl:apply-templates select="$table/row-set/row"/&gt;
-          &lt;xsl:text&gt;&amp;#10;&lt;/xsl:text&gt;
-        &lt;/TABLE&gt;
-      &lt;/BODY&gt;
-    &lt;/HTML&gt; 
-    &lt;!-- 3. Close the connection --&gt;
-    &lt;xsl:value-of select="sql:close($products)"/&gt;
-  &lt;/xsl:template&gt;
-
-  &lt;xsl:template match="row"&gt;
-        &lt;TR&gt;
-          &lt;xsl:apply-templates select="col"/&gt;
-        &lt;/TR&gt;
-  &lt;/xsl:template&gt;
-
-  &lt;xsl:template match="col"&gt;
-    &lt;TD&gt;
-      &lt;!-- Here is the column data -->
-      &lt;xsl:value-of select="text()"/>
-    &lt;/TD>
-  &lt;/xsl:template>
-
-&lt;/xsl:stylesheet&gt;
-</source>
-</s3>
-</s2><anchor name="evaluate"/>
-<s2 title= "evaluate">
-<p>Implemented in <jump href="apidocs/org/apache/xalan/lib/Extensions.html">org.apache.xalan.lib.Extensions</jump>,<br/>
-<code>evaluate (xpath-expression)</code> function returns the result of evaluating the xpath-expression in the current 
-XPath expression context (automatically passed in by the extension mechanism).</p>
-<p>Use the evaluation extension function when the value of the expression is not known until run time.</p>
-</s2><anchor name="tokenize"/>
-<s2 title="tokenize">
-<p>Implemented in <jump href="apidocs/org/apache/xalan/lib/Extensions.html">org.apache.xalan.lib.Extensions</jump>,<br/>
-<code>tokenize (tokenize-string, delimiters)</code><br/>
-or<br/>
-<code>tokenize (tokenize-string)</code> function returns a node-set containing one text node for each token in the tokenize-string.</p>
-<p>The delimiters determine which characters are used to divide the tokenize-string into individual tokens. If you do not include
-the delimiters argument, the function uses tab (&amp;#x09), linefeed (&amp;#x0A), return (&amp;#x0D), and space (&amp;#x20) as delimiters.
-If tokenize-string is an empty string or contains only delimiters, the result is an empty node-set.</p>
-</s2><anchor name="groupitem"/>
-<s2 title= "group and item">
-<p><em>To be done.</em> Provides efficient grouping of items with a common value.</p>
-</s2><anchor name="type"/>
-<s2 title= "type">
-<p><em>To be done.</em> Returns a string that represents the Schema or DTD type.</p>
-</s2><anchor name="todate"/>
-<s2 title="to-date">
-<p><em>To be done.</em> Takes a string as input, and returns a long value representing the date.</p>
-</s2><anchor name="formatdate"/>
-<s2 title="format-date">
-<p><em>To be done.</em> Takes a date string, and formats it according to a specification.</p>
-</s2><anchor name="grep"/>
-<s2 title="grep">
-<p><em>To be done.</em> Performs a grep function and returns the substring.</p>
-</s2><anchor name="foreachtoken"/>
-<s2 title="for-each-token">
-<p><em>To be done.</em> Tokenizes a string, treats each token as a DOM Text node, and executes the
-sub-template.</p>
-</s2>
-</s1>
diff --git a/xdocs/sources/xalan/faq.xml b/xdocs/sources/xalan/faq.xml
deleted file mode 100644
index 89448e3..0000000
--- a/xdocs/sources/xalan/faq.xml
+++ /dev/null
@@ -1,141 +0,0 @@
-<?xml version="1.0" standalone="no"?> 
-<!DOCTYPE faqs SYSTEM "../../style/dtd/faqs.dtd">
-
-<faqs title="Frequently asked questions">
-
-  <faq title="Where do I go to learn about XSLT">  
-    <q>Where do I go to learn about XSLT?</q>    
-    <a><p>The definitive sources are the W3C XSLT and XPath recommendations: <resource-ref idref="xslt"/> and 
-    <resource-ref idref="xpath"/>.</p>
-    <p>For a brief listing of tutorials, discussion forums, and other materials, see <link idref="overview"
-     anchor="uptospeed">Getting up to speed with XSLT</link>.</p></a>
-  </faq>
-
-  <faq title="Which version of Xerces should I be using?">  
-    <q>Which version of Xerces should I be using?</q>    
-    <a><p>&xslt4j-current; has been tested with &xml4j-used;. See <link idref="readme" anchor="status">Status</link>.</p></a>
-  </faq>
-  
-  <faq title="Compatibility with &xslt4j; version 1">
-   <q>How do I run applications that use the &xslt4j; version 1 API with &xslt4j2;</q>
-   <a><p>Use the Xalan-Java 1 compatibility JAR to recompile and run your &xslt4j; 1 applications with &xslt4j2;. For more information, see 
-   <link idref="usagepatterns" anchor="compat">Using the &xslt4j; version 1 API</link>.</p></a>
-  </faq>
-    
-  <faq title="TrAX and JAXP">
-    <q>What are TrAX and JAXP, and are they related?</q>
-    <a><p>TrAX is the Transformation API for XML. In November 2000, TrAX was revised and incorporated into JAXP, the JAVA API for XML
-    Processing. JAXP (including TrAX) provides users a standard, vendor-neutral API for working with (and transforming) XML documents. 
-    You can use this API to build applications that are not bound to the particular implementation details of a given XML parser or XSL
-    transformer.</p>
-    <p>&xslt4j; includes the JAXP packages, implements the TrAX portion of that API (javax.xml.transform....), and includes xerces.jar from
-    &xml4j;, which implements the parser portion of the API (javax.xml.parser....).</p>
-<p>For more information, see <resource-ref idref="trax"/> and <resource-ref idref="jaxp11"/>.</p></a>
-  </faq>
-  <faq title="Chaining transformations">  
-    <q>How do you chain together a series of transformations?"</q>
-    
-    <a><p>&xslt4j; supports two strategies for chaining together a series of transformations such that the output of each 
-    transformation provides input for the next transformation.</p>
-    <ul>
-      <li>For each transformation in the series, you can set one SAX ContentHandler to process the input, and another ContenHandler to process
-       the output.<br/><br/></li>
-      <li>You can also set up a series of parent-child relationships between an XMLReader and one or more XMLFilters.</li> 
-    </ul>
-    <p>For the details and links to examples, see <link idref="usagepatterns" anchor="outasin">Using transformation output as input for 
-    another transformation</link>.</p></a>
-  </faq>
-  
-  <faq title="Issues running Xalan on JDK 1.3">
-  <q>I'm having a problem building or running &xslt4j; on the JDK 1.3.</q>
-  <a><p>The JDK 1.3 automatically places everything in the lib/ext directory in front of everything you place on the classpath. If this directory contains a version of DOM, JAXP, or Xerces that predates the &xslt4j; distribution you are using, you may have problems!</p> 
-<p>The IBM JDK 1.3 includes an earlier version of xerces.jar in the lib/ext directory, a version that does not implement the JAXP 1.1 interfaces and therefore does not work with the current Xalan release. Accordingly, you must either purge the xerces.jar that is in that directory or overwrite it with the xerces.jar that is included with the Xalan distribution.</p>
-<p>The SUN JDK 1.3 includes a pre-1.1 version of the JAXP in crimson.jar. Either purge the crimson.jar in that directory or overwrite it with a newer crimson.jar that includes and implements the JAXP 1.1 interfaces.</p></a>  
-  </faq>
-  <faq title="a &quot;DOM006 Hierarchy request error&quot;">
-  <q>Why do I get a "DOM006 Hierarchy request error" when I try to transform into a DOM Document node?</q>
-  <a>
-  <p>This error occurs when Xalan tries to add a Node to a Document node where it isn't allowed. For example, attempting to add non-whitespace
-  text to the DOM Document node produces this error.</p>
-   <p>The error can also occur when a Document node is created with the DOMImplementation createDocument() method, which takes a qualified name
-    as an argument and creates an element node.  If you then pass the returned Document node to Xalan, you get a "DOM006 Hierarchy request
-    error" when Xalan tries to add a second element to the Document node. The solution is to either use the DocumentBuilder newDocument() method
-    to create a Document that does not contain an element node, or use a DocumentFragment. It should be noted that the 
-    DocumentBuilder newDocument() method is "Non-preferred" according to the JAXP 1.1 documentation.</p>
-  </a>
-  </faq>
-  
-  <faq title="Speeding up transformations">
-  
-    <q>What can I do to speed up transformations?</q>
-    
-    <a><p>In the ongoing development of &xslt4j;, enhancing performance is the primary goal of the &xslt4j; team.
-    Here are some preliminary suggestions for you to keep in mind as you set up your applications:</p><ul>
-    <li>Use a Templates object (with a different Transformers for each transformation) to perform multiple transformations with the same 
-    set of stylesheet instructions (see <link idref="usagepatterns" anchor="multithreading">Multithreading</link>).<br/><br/></li>         
-    <li>Set up your stylesheets to function efficiently.<br/><br/></li>
-       <ul>
-         <li>Don't use "//" (descendant axes) patterns near the root of a large document.<br/><br/></li>
-         <li>Use xsl:key elements and the key() function as an efficient way to retrieve node sets.<br/><br/></li>
-         <li>Where possible, use pattern matching rather than xsl:if or xsl:when statements.<br/><br/></li>
-         <li>xsl:for-each is fast because it does not require pattern matching.<br/><br/></li>
-         <li>Keep in mind that xsl:sort prevents incremental processing.<br/><br/></li>
-         <li>When you create variables, &lt;xsl:variable name="fooElem" select="foo"/&gt; is usually faster than
-         &gt;xsl:variable name="fooElem"&gt;&lt;xsl:value-of-select="foo"/&gt;&lt;/xsl:variable&gt;.<br/><br/></li>
-         <li>Be careful using the last() function.<br/><br/></li>
-         <li>The use of index predicates within match patterns can be expensive.<br/><br/></li>
-         <li>Decoding and encoding is expensive.<br/><br/></li>
-       </ul>
-     <li>For the ultimate in server-side scalability, perform transform operations on the client. For examples, see 
-     <link idref="samples" anchor="appletxmltohtml">appletXMLtoHTML</link> and <link idref="samples"
-     anchor="get-todo-list">get-todo-list</link>.</li>
-    </ul></a>
-  </faq>
-
-  <faq title="NoClassDefFound errors">
-  
-    <q>I'm getting a NoClassDefFound error. What has to be on the classpath?</q>
-    
-    <a><ol>
-    <li>xalan.jar and xerces.jar (or the XML parser you are using) must always be on the classpath.<br/><br/></li>
-    <li>To run the samples in the samples subdirectories, xalansamples.jar must be on the classpath. To run the servlet (in
-    samples/servlet), xalanservlet.jar must be on the classpath along with the javax.servlet and javax.servlet.http packages. Sun distributes
-    the javax.servlet packages in the JSWDK servlet.jar file.<br/><br/></li>
-    <li>To run extensions (including the samples in samples/extensions), bsf.jar, and bsfengines.jar must be on the 
-    classpath. To run extensions implemented in JavaScript, js.jar must also be on the classpath. For information on what 
-    you need to run extensions implemented in other scripting languages, see <link idref="extensions"
-    anchor="supported-lang">Supported languages</link>.<br/><br/></li>
-    <li>To run applications that use the &xslt4j; version 1 API, you must put xalanj1compat.jar on the classpath, recompile the application,
-    and be sure xalanj1compat.jar is on the classpath at run time (see <link idref="usagepatterns" anchor="compat">Using the &xslt4j; version 1
-    API)</link>.</li>
-    </ol>
-    <p>For more information, see <link idref="getstarted" anchor="classpath">Setting up the system classpath</link>.</p></a>
-   </faq>
- 
-	<faq title="Stylesheet validation">
-		<q>How do I validate an XSL stylesheet?</q>
-		<a>
-      <p>An XSL stylesheet is an XML document, so it can have a DOCTYPE and be subject to validation, right? </p>
-      <p>The XSLT Recommendation includes a <jump href="http://www.w3.org/TR/xslt#dtd">DTD Fragment 
-      for XSL Stylesheets</jump> with some indications of what you need to do to create a complete DTD for a given
-      stylesheet. Keep in mind that stylesheets can include literal result elements and produce output that is not valid
-      XML.</p>
-      <p>You can use the xsl:stylesheet doctype defined in xsl-html40s.dtd for stylesheets that generate HTML.</p>
-		</a>
-	</faq>
-    
-    <faq title="Retrieving nodes in the default namespace">
-     <q>XPath isn't retrieving nodes that are in the default namespace I defined. How do I get them?</q>
-     <a><p>If you are looking for nodes in a namespace, the XPath expression must include a namespace prefix that you have mapped to the
-       namespace with an xmlns declaration. If you have declared a default namespace, it does not have a prefix (see 
-       <jump href="http://www.w3.org/TR/xpath.html#node-tests">XPath Node Tests</jump>). In order to construct XPath expressions 
-       to retrieve nodes from this namespace, you must add a namespace declaration that provides a prefix you can include in the XPath
-        expressions.</p>
-       <p>Suppose, for example, you you want to locate nodes in a default namespace declared as follows:<br/>
-       <code>xmlns="http://my-namespace"</code></p>
-       <p>Add a nampespace declaration with a prefix:<br/>
-       <code>xmlns:foo="http://my-namespace"</code></p>       
-       <p>Then you can use foo: in your XPath expression.</p>
-       <p>Hint: Don't use default namespaces, and the problem doesn't arise.</p></a>
-    </faq>   
-</faqs>
diff --git a/xdocs/sources/xalan/getstarted.xml b/xdocs/sources/xalan/getstarted.xml
deleted file mode 100644
index b81a2ad..0000000
--- a/xdocs/sources/xalan/getstarted.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" standalone="no"?>  
-<!DOCTYPE s1 SYSTEM "../../style/dtd/document.dtd">
-
-<s1 title="Getting Started">
-<ul>
-<li><link anchor="download">Downloading what you need</link></li>
-<li><link anchor="classpath">Setting up the system classpath</link></li>
-<li><link anchor="samples">Trying out the samples</link></li>
-<li><link anchor="commandline">Performing your own transformations from the command line</link></li>
-<li><link anchor="java-apps">Setting up your own XSLT applications</link></li>
-</ul>
-<anchor name="download"/>
-<s2 title="Downloading what you need">
-<p>To use Xalan, you need the following:</p>
-<ul>
-<li>The JDK or JRE 1.1.8, 1.2.2, or 1.3</li>
-<li>xalan.jar</li>
-<li>xerces.jar (or another <link idref="usagepatterns" anchor="plug">XML Parser</link>)</li>
-</ul>
-<p>You can get the JDK or JRE from <jump href="http://www.ibm.com/java/jdk">ibm.com/java/jdk/</jump> or <jump href="http://www.java.sun.com">java.sun.com</jump>.</p> 
-<p>Download <resource-ref idref="xslt4j-dist-zip"/> or <resource-ref idref="xslt4j-dist-targz"/>. Both of these files contain <resource-ref idref="xslt4j-current"/> (with xalan.jar) and xerces.jar from <resource-ref idref="xml4j-used"/>. You can use a zip or tar utility to expand these files into a full build.</p>
-
-<p>If you plan to run <link idref="extensions">XSLT extensions</link>, you need bsf.jar, which is included in the &xslt4j; distribution. If you plan to run XSLT extensions implemented in Javascript or another scripting language, you will need one or more additional files as indicated in <link idref="extensions" anchor="supported-lang">extensions language requirements</link>.</p>
-</s2><anchor name="classpath"/>
-<s2 title="Setting up the system classpath">
-<p>At the very minimum, you must include xalan.jar and xerces.jar (or another conformant XML parser -- see <link idref="usagepatterns" anchor="plug">Plugging in a Transformer and XML parser</link>) on the system classpath. To run the sample applications, include xalansamples.jar (all samples other than the servlet) and xalanservlet.jar. To run extensions, include bsf.jar. All these JAR files are distributed with &xslt4j;. For extensions implemented in JavaScript or another scripting language, see <link idref="extensions" anchor="supported-lang">extensions language requirements</link> to identify any additional JAR files you must place on the classpath and where you can get them.</p>
-<p>If you are using JDK or JRE 1.1.8, also include classes.zip on the classpath.</p>
-<note>If you are using xerces.jar from a Xerces release that is more recent than &xml4j-used;, you may need to put xerces.jar before xalan.jar on the classpath. Both JAR files include the org.w3c.dom packages. The Xerces team is tracking updates to DOM level 2, and the Xerces parser may require access to updates in these packages.</note>
-</s2><anchor name="samples"/>
-<s2 title="Trying out the samples">
-<p>The &xslt4j; distribution includes a number of basic sample applications. These samples are easy to run, and you can review the source files -- all of which are brief -- to see just how they work.</p>
-<p>To run the samples, do the following:</p>
-<ol>
-<li>Set up your classpath (see above), including xalansamples.jar and (for the servlet) xalanservlet.jar.</li>
-<li>Be sure the java executable is on your path.</li>
-<li>Go to the samples subdirectory containing the sample (use the DOS shell if you are running Windows).</li>
-<li>Use the java executable to run the sample from the command line.</li>
-<li>Examine the application source and result files.</li>
-</ol>
-<p>For example, go to the SimpleTransform subdirectory and issue the following command:</p>
-<p><code>java SimpleTransform</code></p>
-<p>The sample writes the transformation result  to a file (birds.out). To see how the example works, examine the source files: birds.xml, birds.xsl, and SimpleTransform.java.</p>
-<p>The extensions examples require additional JAR files on the classpath, and the procedure for running the sample applet and sample servlet is different. For more information about all the samples, see <link idref="samples">&xslt4j; Samples</link>.</p>
-</s2><anchor name="commandline"/>
-<s2 title="Performing your own transformations from the command line">
-<p>java.org.apache.xalan.xslt.Process provides a basic utility for performing transformations from the command line. You use this utility, for example, to run several of the extensions samples. The command line for most standard transformations is as follows:</p>
-<p><code>java org.apache.xalan.xslt.Process -in <ref>xmlSource</ref></code><br/>
-<code>&nbsp;&nbsp;&nbsp;&nbsp;-xsl <ref>stylesheet</ref> -out <ref>outputfile</ref></code></p>
-<p>where <ref>xmlSource</ref> is the XML source file name, <ref>stylesheet</ref> is the XSL stylesheet file name, and <ref>outputfile</ref> is the output file name.</p>
-<p>If you want the output to be displayed on the screen, simply omit the -out flag and argument.</p>
-<p>You can use this utility to try out XSL stylesheets you have written, to make sure they do what you expect with the XML source files they are designed to transform. The utility provides useful messages if the source file or stylesheet is not well formed. If you include a DOCTYPE statement in your XML source files and include the -validate flag on the command line, the utility will also let you know whether the XML document is valid (conforms to that DOCTYPE). For more information, see <link idref="commandline">Command-Line Utility</link>.</p>
-</s2><anchor name="java-apps"/>
-<s2 title="Setting up your own Java applications">
-<p>You can start by using your own XML source files and XSL stylesheets with the sample applications, which illustrate a number of the <link idref="usagepatterns">basic usage patterns</link>.</p>
-<p>Here is the basic TRaX procedure to keep in mind when you set up a transformation:</p>
-<ol>
-<li>Use the <jump href="apidocs/javax/xml/transform/TransformerFactory.html">TransformerFactory</jump> static newInstance() method to instantiate a TransformerFactory.<br/><br/></li>
-<li>Use the TransformerFactory newTransformer(Source stylesheet) method to process the transformation instructions in an XSLT stylesheet Source (producing under the covers a <jump href="apidocs/javax/xml/transform/Templates.html">Templates</jump> object) and generate a <jump href="apidocs/javax/xml/transform/Transformer.html">Transformer</jump>.<br/><br/></li>
-<li>Use the Transformer transform(Source xmlSource, Result transformResult) method to apply the transformation instructions (the Templates object) to the XML Source and produce the transformation Result.<br/><br/></li>
-</ol>
-<p>For more information about this procedure and its variations, see <link idref="usagepatterns">Basic Usage Patterns</link>.</p>
-</s2>
-</s1>
\ No newline at end of file
diff --git a/xdocs/sources/xalan/history.xml b/xdocs/sources/xalan/history.xml
deleted file mode 100644
index 46db54c..0000000
--- a/xdocs/sources/xalan/history.xml
+++ /dev/null
@@ -1,424 +0,0 @@
-<s3 title="Changes for &xslt4j; 2.0.1">
-<p>This release includes a number of bug fixes to the &xslt4j; and TrAX core and Xalan-Java 1 compability API. We have also</p>
-<ul>
-  <li>Entered all known &xslt4j; 2 <link anchor="bugs">bugs</link> in the Apache Bugzilla database<br/><br/></li>
-  <li>Added support for using custom URIResolver, EntityResolver, and ContentHandler implementations with the <link
-      idref="commandline">command-line utility</link><br/><br/></li> 
-  <li>Upgraded from Ant 1.2 to Ant 1.3 for our <link anchor="build">builds</link> (the new ant.jar is in the bin directory).</li>
-</ul>
-<p>Core source code updates:</p>
-<ul>
-<li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>02/06/2001<br/><ref>Modified: </ref>java/src/org/apache/xpath/axes ChildWalkerMultiStep.java<br/><ref>Committer's log entry: </ref>Fix for bug reported by "Chris P. McCabe" &lt;chris_mccabe@choicehotels.com&gt;
- 02/06/2001 06:55 PM.
- Defensive fix for if the last used walker is null, then don't check to
- see if it is a fast walker! Without this, a null pointer exception is
- very possible.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>02/06/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/transformer TransformerImpl.java<br/><ref>Committer's log entry: </ref>Fixes for exceptions being thrown that weren't being passed through
- the error listener.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>02/07/2001<br/><ref>Modified: </ref>java/src/org/apache/xpath/axes FollowingWalker.java<br/><ref>Committer's log entry: </ref>Fix for bug reported by Dave Haffner &lt;dave.haffner@xmls.com&gt;
- 02/06/2001 04:03 AM
- In parentNode(), don't screen out nextAncestor, since the parent
- is never actually returned. This sets things up correctly for firstChild
- and nextSibling.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>02/07/2001<br/><ref>Modified: </ref>java/src/org/apache/xpath/axes PrecedingWalker.java<br/><ref>Committer's log entry: </ref>Fix for bug reported by Dave Haffner &lt;dave.haffner@xmls.com&gt;
- 02/06/2001 04:03 AM
- In nextSibling(), don't return null if isAncestorOfRootContext, instead
- do next.getFirstChild().<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>02/07/2001<br/><ref>Modified: </ref>java/src/org/apache/xpath SourceTreeManager.java<br/><ref>Committer's log entry: </ref>Fix for bug reported by anders.domeij@uc.se
- 02/07/2001 09:35 AM
- removed extra bogus TransformerException decl in resolveURI<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>02/08/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/stree SourceTreeHandler.java<br/><ref>Committer's log entry: </ref>Fix bug reported by Jason Harrop &lt;jharrop@bigpond.net.au&gt;
- 02/07/2001 08:12 PM
- Don't process comment or whitespace events if inside a startDTD/endDTD
- event.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>02/10/2001<br/><ref>Modified: </ref>java/src/org/apache/xpath/axes WalkerFactory.java<br/><ref>Committer's log entry: </ref>In indirect response to bug posted by "Thee Boon Hoo" &lt;theebh@newstakes.com&gt;
- 02/07/2001 09:37 PM
-
- "//table[1]" patterns would give one node
- when they should have given 2, when applied to Boon Hoo's
- source.
- "//table[1]" is equivelent to
- "/descendant-or-self::node()/table[1]",
- and so must return the first table child
- of each table-inst element.
-
- An optimization was optimizing this to
- "/descendant-or-self::table, which is
- fine as long as indexing isn't used. Since
- we can not tell until runtime if indexing
- is being used, we have to turn of this
- optimization for all predicated "//foo[xx]"
- patterns.<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>02/12/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/processor StylesheetPIHandler.java
- TransformerFactoryImpl.java<br/><ref>Committer's log entry: </ref>Patch for Dmitri IIyin to use the specified URIResolver.<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>02/12/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/templates ElemNumber.java<br/><ref>Committer's log entry: </ref>Number Expression should be evaluated then rounded up.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>02/13/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/xslt Process.java<br/><ref>Committer's log entry: </ref>Create a document fragment for the output node, for -flavor d2d.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>02/13/2001<br/><ref>Modified: </ref>java/src/org/apache/xpath/compiler Compiler.java<br/><ref>Committer's log entry: </ref>Better error message when quo is used.<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>02/13/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/templates ElemCallTemplate.java
- ElemChoose.java ElemCopy.java ElemFallback.java
- ElemIf.java ElemLiteralResult.java
- ElemTemplate.java
- java/src/org/apache/xalan/transformer TransformerImpl.java<br/><ref>Committer's log entry: </ref>Remove extra method/call to TransformerImpl.executeChildTemplates()<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>02/13/2001<br/><ref>Modified: </ref>java/src/org/apache/xpath/patterns NodeTest.java<br/><ref>Committer's log entry: </ref>Return an empty string instead of null from getLocalName() when the
- nodetest does not have a name. Encountered with the SQL extension,
- in response to bug reported by "Michael Kay" &lt;mhkay@iclway.co.uk&gt;,
- 02/08/2001 08:57 AM.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>02/13/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/lib/sql ColumnData.java<br/><ref>Committer's log entry: </ref>In getData() return an empty string instead of null if there is
- no data to be obtained.
- In response to bug reported by "Michael Kay" &lt;mhkay@iclway.co.uk&gt;,
- 02/08/2001 08:57 AM.<br/><br/></li><li><ref>Committed by </ref>garyp@apache.org<ref> on </ref>02/19/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/extensions MethodResolver.java<br/><ref>Committer's log entry: </ref>Correct ConversionInfo array for Node-Set and RTF. Remove DocumentFragment 
-from RTF and replace with NodeList. Remove duplicate Boolean from both. Fix 
-Boolean conversion to make java.lang.Boolean higher than string.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>02/19/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/lib/sql ColumnHeader.java
- RowSet.java XStatement.java<br/><ref>Committer's log entry: </ref>Use null nodetest to mean the same as "node()". This fixes a bug reported
- by "Voytenko, Dimitry" &lt;DVoytenko@SECTORBASE.COM&gt;
- where &lt;xsl:copy-of select="sql:query(...)"/&gt;
- crashes with NullPointerException, i.e.
- there are cases where we really don't want
- to set the NodeTest.<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>02/20/2001<br/><ref>Modified: </ref>java/src/org/apache/xpath/compiler XPathParser.java<br/><ref>Committer's log entry: </ref>Check for null token before checking if it is a letter<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>02/20/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/transformer
- TransformerIdentityImpl.java<br/><ref>Committer's log entry: </ref>Fix made for bug reported by "Glencross, Christian" 
-&lt;Christian.Glencross@gs.com&gt;
- on 02/16/2001 10:18 AM.
- Xerces 1.2.3 SAX parser calls
- handler.setDocumentLocator() before handler.startDocument().
- TransformerIdentityImpl.m_resultContentHandler isn't initialised until
- TransformerIdentityImpl.startDocument() is called.
- Added lazy construction of result handler
- in setDocumentLocator, in addition to
- startDocument.<br/><br/></li><li><ref>Committed by </ref>garyp@apache.org<ref> on </ref>02/21/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/lib Extensions.java<br/><ref>Committer's log entry: </ref>Correct implementation of string value of a node.<br/><br/></li><li><ref>Committed by </ref>dleslie@apache.org<ref> on </ref>02/21/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/lib/sql Column.java
- ColumnAttribute.java ColumnData.java
- ColumnHeader.java Row.java RowSet.java
- StreamableNode.java XConnection.java
- XStatement.java package.html<br/><ref>Committer's log entry: </ref>Added experimental usage metatag to all classes in this package,
- and an explanatory note to package.html.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>02/22/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/stree ElementImpl.java<br/><ref>Committer's log entry: </ref>Bug fix attributed to Norman Walsh &lt;ndw@nwalsh.com&gt;, on
- 02/20/2001 09:50 AM. if the attribute 'name' doesn't occur in the AttList, 
-the
- result of getIndex(name) is -1, but
- getChildAttribute() would incorrectly
- return the first attribute. Fix returns
- null if index &lt; 0.<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>02/22/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/serialize SerializerToXML.java
- java/src/org/apache/xalan/transformer
- TransformerIdentityImpl.java<br/><ref>Committer's log entry: </ref>Implement DeclHandler for identity transforms<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>02/22/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/transformer TransformerImpl.java<br/><ref>Committer's log entry: </ref>Fix for bug originally reported by Daryl Beattie &lt;DarylB@screamingmedia.com&gt;
- on 02/14/2001 04:16 PM. A hang was occuring inside the use
- of a Result Tree Fragment. When the result tree fragement was
- being created, the Redirect extension was being called, which
- called createResultContentHandler which set the ContentHandler
- in the Transformer, but not in the ResultTreeHandler. Then, Redirect
- called Transformer#executeChildTemplates(
- ElemTemplateElement elem, Node sourceNode, QName mode, 
-ContentHandler handler)
- which saves the reference to the original content handler in
- the transformer, and then sets the new one by calling setContentHandler,
- which sets the ContentHandler in the ResultTreeHandler as well
- as the Transformer. When it tried to restore the old ContentHandler,
- it restored the value in the ResultTreeHandler to a Serializer, instead
- of the correct ContentHandler. When transformToRTF then called
- endDocument on it's resultTreeFragment, the event was sent
- to the Serializer instead of the SourceTreeHandler, and thus the
- isComplete flag was not set, and thus the hang. (whew!)
- The fix is in executeChildTemplates save the value of the
- resultTreeHandler's contentHandler as well as Transformer's
- content handler, and restore them both. A more architectual fix
- could be made, but not without high risk, so I think this is the best
- and safest way to fix it.<br/><br/></li><li><ref>Committed by </ref>dleslie@apache.org<ref> on </ref>02/23/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/res XSLTInfo.properties<br/><ref>Committer's log entry: </ref>Changed version to 2.0.1<br/><br/></li><li><ref>Committed by </ref>dleslie@apache.org<ref> on </ref>02/23/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/processor XSLProcessorVersion.java<br/><ref>Committer's log entry: </ref>Changed version to 2.0.1<br/><br/></li><li><ref>Committed by </ref>curcuru@apache.org<ref> on </ref>02/28/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/res XSLTErrorResources.java<br/><ref>Committer's log entry: </ref>Update text of error messages
- Submitted by: Andreas Zehnpfund<br/><br/></li><li><ref>Committed by </ref>curcuru@apache.org<ref> on </ref>02/28/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/xslt Process.java<br/><ref>Committer's log entry: </ref>Update printArgOptions() with better text and to better reflect actual
- options that are currently supported; catch missing -IN argument<br/><br/></li><li><ref>Committed by </ref>jkesselm@apache.org<ref> on </ref>03/05/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/client XSLTProcessorApplet.java
- java/src/org/apache/xalan/processor StylesheetHandler.java
- TransformerFactoryImpl.java
- java/src/org/apache/xalan/stree DocImpl.java
- StreeDOMBuilder.java TextImpl.java
- java/src/org/apache/xalan/templates OutputProperties.java
- java/src/org/apache/xalan/xslt Process.java
- java/src/org/apache/xml/utils FastStringBuffer.java
- java/src/trax trax.properties<br/><ref>Committer's log entry: </ref>New approach to FastStringBuffer, and changes needed to support it.
- We still need to do some serious work on both the initial values of the
- tuning parameters and the heuristics driving the "chunk growth" algorithms.
- Currently set for fixed-sized chunks of 8Kch in main tree, .5Kch in RTF.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/06/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/templates ElemElement.java
- ElemForEach.java ElemLiteralResult.java
- java/src/org/apache/xalan/transformer
- ClonerToResultTree.java QueuedSAXEvent.java
- QueuedStartDocument.java QueuedStartElement.java
- ResultTreeHandler.java TransformerImpl.java
- TreeWalker2Result.java<br/><ref>Committer's log entry: </ref>Fix for http://nagoya.apache.org/bugzilla/show_bug.cgi?id=741.
-
- 1) ResultTreeHandler now implements the TransformState interface.
- 2) Queued state such as the current node and the current template is stored 
-as part of QueuedStartElement. Storage will only occur if the ContentHandler 
-implements TransformClient.
- 3) When state is requested (for instance TransformState#getCurrentElement()), 
-if the queued element is null or not pending (for instance, in a characters 
-event), it will get the state from the transformer, otherwise it will get the 
-state from the queued element.
-
- Other fixes were attempted for this problem, including trying to
- get rid of queueing altogether, and flushing a bit earlier before
- the state was pushed on the various stacks, but both of
- these had show-stopping issues (see discussions
- on xalan-dev).
-
- Note that for the moment the ContextNodeList is node
- cloned as it needs to be in order for
- TransformState#getContextNodeList.<br/><br/></li><li><ref>Committed by </ref>garyp@apache.org<ref> on </ref>03/06/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/templates ElemParam.java
- java/src/org/apache/xpath Arg.java VariableStack.java<br/><ref>Committer's log entry: </ref>The field Arg.isParamVar was attempting to serve two functions: to indicate 
-variable Frame entries which are not currently activated and to indicate Frames 
-containing parameters passed with xsl:with-param. When processing was finished 
-for a node in a node-set, the isParamVar flag was turned on to indicate the 
-Frame slot was available. Unfortunately, this also indicated that the item was 
-passed as a parameter which it wasn't. This fix changes isParamVar into to 
-fields, isAvailable which indicates that the slot is available and 
-isFromWithParam indicating the Frame slot came from an xsl:with-param or a 
-top-level parameter passed in via the tranformerImpl.setParameter() API.
- I have tested this change against the conformance suite and had no 
-regression. I've also submitted a test case which fails on the existing 
-codebase but works okay after this fix.
- It is possible that I've missed something with regard to the API setParameter 
-calls but we can fix those if problems are reported.<br/><br/></li><li><ref>Committed by </ref>garyp@apache.org<ref> on </ref>03/07/2001<br/><ref>Modified: </ref>java/src/org/apache/xml/utils FastStringBuffer.java<br/><ref>Committer's log entry: </ref>Correct operation when length of content to be appended is zero.<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>03/07/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/serialize SerializerToXML.java<br/><ref>Committer's log entry: </ref>Fix closing out doctype declaration<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>03/08/2001<br/><ref>Modified: </ref>java/src/org/apache/xml/utils SystemIDResolver.java<br/><ref>Committer's log entry: </ref>Change SystemIdResolver to default to user.dir if the base URI is null<br/><br/></li><li><ref>Committed by </ref>garyp@apache.org<ref> on </ref>03/09/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/transformer TransformerImpl.java
- java/src/org/apache/xpath VariableStack.java<br/><ref>Committer's log entry: </ref>Parameters set with setParameter were available to stylesheet as variable 
-references ($myParam) even though there was no xsl:param element to receive it.<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>03/09/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/transformer
- TransformerIdentityImpl.java<br/><ref>Committer's log entry: </ref>Check if there is a DeclHandler before calling it.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/11/2001<br/><ref>Modified: </ref>java/src/org/apache/xml/utils WrappedRuntimeException.java<br/><ref>Committer's log entry: </ref>Patch attributed to Patrick Moore &lt;patrickm@rioport.com&gt; on 03/09/2001.
- Adds another constructor to pass in the error message.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/11/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/templates ElemAttribute.java
- ElemElement.java<br/><ref>Committer's log entry: </ref>Checkin addresses http://nagoya.apache.org/bugzilla/show_bug.cgi?id=923.
- elemAttribute now derives from elemElement so the basic name resolution
- code can be shared. Breaks attribset24 test, but I think the newer
- behavior is better. New virtual methods overloaded by elemAttribute are
- constructNode, resolvePrefix, and validateNodeName. Also, in the
- elemAttribute#execute method, checks are made to make sure an
- element is pending.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/11/2001<br/><ref>Modified: </ref>java/src/org/apache/xml/utils SystemIDResolver.java<br/><ref>Committer's log entry: </ref>Added getAbsoluteURI(String url), and merge
- with Myriam's changes.
- Part of fix for problem found when
- investigating http://nagoya.apache.org/bugzilla/show_bug.cgi?id=906.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/11/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/processor
- TransformerFactoryImpl.java<br/><ref>Committer's log entry: </ref>Call getAbsoluteURI(String url) for the source URL.
- Fix for problem found when
- investigating http://nagoya.apache.org/bugzilla/show_bug.cgi?id=906.
- This tries to force us always having an absolute URL in the processing
- stack as the base URL, which should be OK, I hope.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/11/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/transformer TransformerImpl.java<br/><ref>Committer's log entry: </ref>Call getAbsoluteURI(String url) for the source URL.
- Fix for problem found when
- investigating http://nagoya.apache.org/bugzilla/show_bug.cgi?id=906.
- This tries to force us always having an absolute URL in the processing
- stack as the base URL, which should be OK, I hope.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/11/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/transformer QueuedEvents.java
- QueuedStartElement.java ResultTreeHandler.java<br/><ref>Committer's log entry: </ref>The user for http://nagoya.apache.org/bugzilla/show_bug.cgi?id=741 reported
- problems on testing, so these changes are a re-fix. He tested and
- everything seems OK now. There actually may be a slight performance
- improvement involved here.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/11/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/serialize SerializerToHTML.java<br/><ref>Committer's log entry: </ref>Applied patches from dmitri.ilyin@memiq.com (Dmitri Ilyin)
- from http://nagoya.apache.org/bugzilla/show_bug.cgi?id=705.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/11/2001<br/><ref>Modified: </ref>java/src/org/apache/xpath XPathAPI.java<br/><ref>Committer's log entry: </ref>Applied patch submitted by nboyd@atg.com (Norris Boyd)
- at http://nagoya.apache.org/bugzilla/show_bug.cgi?id=702.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/11/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/serialize Encodings.java<br/><ref>Committer's log entry: </ref>Applied patch submitted by havardw@underdusken.no (H嶡rd Wigtil).
- Also added "XXX-X" variants for all "XXX_X" java encoding names.
- I'm not totally confident that this is the right thing to do, but I can't
- see that it will hurt, except to make the table a bit larger. I
- would prefer to be safe and make sure we handle the encoding.
- See my comments in http://nagoya.apache.org/bugzilla/show_bug.cgi?id=718.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/11/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/templates ElemTemplateElement.java
- StylesheetRoot.java<br/><ref>Committer's log entry: </ref>Minor changes to better bottleneck throwing of Runtime exceptions
- during processing.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/11/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/processor
- TransformerFactoryImpl.java<br/><ref>Committer's log entry: </ref>Catch all exceptions thrown when processing stylesheet, and send
- them to the error listener. There's probably some danger of having
- the same error sent to the error listener multiple times, but better too
- many reports, than none, I guess.
- This addresses http://nagoya.apache.org/bugzilla/show_bug.cgi?id=906.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/11/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/lib/sql XConnection.java
- XStatement.java<br/><ref>Added: </ref>java/src/org/apache/xalan/lib/sql ConnectionPool.java
- DefaultConnectionPool.java ExtensionError.java
- PooledConnection.java QueryParameter.java
- SQLExtensionError.java XConnectionPoolManager.java<br/><ref>Committer's log entry: </ref>These are John Gentilin &lt;johnglinux@eyecatching.com&gt;
- patches for connection pooling and parameterized
- queries. These should be considered to be unstable
- right now, as we are still working on some things.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/11/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/processor ProcessorInclude.java
- TransformerFactoryImpl.java
- java/src/org/apache/xalan/serialize SerializerToXML.java
- java/src/org/apache/xalan/stree StreeDOMHelper.java
- java/src/org/apache/xalan/transformer ResultTreeHandler.java
- TransformerIdentityImpl.java TreeWalker2Result.java
- java/src/org/apache/xml/utils AttList.java TreeWalker.java
- java/src/org/apache/xpath DOM2Helper.java XPathContext.java<br/><ref>Committer's log entry: </ref>The DOM2Helper#isNodeAfter(Node node1, Node node2) method
- has been fixed so that it no longer does the try/catch thing if one
- of the nodes doesn't implement DOMOrder, but instead does an
- instanceof test. In StreeDOMHelper, it overloads this method and
- *does* do the try/catch business, since almost always both nodes
- will implement DOMOrder in this case, and this will be faster than
- an instanceof test. Also, in various classes, I did some stuff to try
- and make sure that a DOM2Helper wasn't being created and used
- when a StreeDOMHelper is needed.
-
- This addresses http://nagoya.apache.org/bugzilla/show_bug.cgi?id=800
- and should give a good performance fix for foreign DOM processing.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/12/2001<br/><ref>Modified: </ref>java/src/org/apache/xpath/patterns NodeTest.java<br/><ref>Committer's log entry: </ref>Xerces at some point decided to use "" instead
- of null for null namespaces. There has been a
- discussion between Gary Peskin in
- Joe Kessleman on xalan-dev about this,
- but I hadn't been fully keeping up the the
- thread that well, and missed it's relation to
- this problem. I include some of the discussion
- at the end of this note. I made Xalan be able to
- compare a "" namespace to null for now, until
- we get this resolved.
-
- The gist of the discussion on xalan-dev regarding this is:
-
- &gt;&gt;1. Declare the Xerces-J support of schemas to have a bug and ask that
- &gt;&gt;Xerces be corrected to always use a null namespace URI to indicate that
- &gt;&gt;there is no default namespace. Even if the Xerces people change this
- &gt;&gt;behavior, is this correct?
- &gt;
- &gt; Yes. If your description of the problem is accurate (you should probably
- &gt; submit a more detailed case so it can be reproduced in the lab), this is a
- &gt; parser/DOM-builder bug.<br/><br/></li><li><ref>Committed by </ref>costin@apache.org<ref> on </ref>03/12/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/lib/sql ExtensionError.java<br/><ref>Committer's log entry: </ref>Removed ( commented out ) dump() method and the imports in ExtensionError.
-
- So far the method doesn't seem to be used ( no warning in the compile ).
-
- The problem is that this method is breaking the build with crimson ( since
- it uses xerces-specific classes ). It is possible to implement it on top
- of the serialization classes that are part of xalan - if someone needs the
- method I'll try to port it.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/13/2001<br/><ref>Modified: </ref>java/src/org/apache/xml/utils TreeWalker.java<br/><ref>Committer's log entry: </ref>Added back in the TreeWalker(ContentHandler contentHandler)
- constructor, because I'm worried I'll break more dependent code.<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>03/13/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/res XSLTErrorResources.java
- java/src/org/apache/xalan/xslt Process.java<br/><ref>Committer's log entry: </ref>Implement new arguments for the command line interface: URIResolver, 
-EntityResolver and ContentHandler<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>03/13/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/templates FuncFormatNumb.java<br/><ref>Committer's log entry: </ref>Fix error message to say that 2 or 3 arguments are required.<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>03/13/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/processor ProcessorLRE.java
- java/src/org/apache/xalan/res XSLTErrorResources.java<br/><ref>Committer's log entry: </ref>Better error message for missing or incorrect XSLT namespace declaration in a 
-stylesheet<br/><br/></li><li><ref>Committed by </ref>garyp@apache.org<ref> on </ref>03/13/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/lib Redirect.java
- java/src/org/apache/xalan/transformer TransformerImpl.java
- java/src/org/apache/xalan/xslt Process.java<br/><ref>Committer's log entry: </ref>Remember the Result that was used to trigger the transform. Access that 
-result from the Redirect extension to make file references in Redirect relative 
-to the original result URI.
- If this is not available, references are relative to the source URI.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/14/2001<br/><ref>Modified: </ref>java/src/org/apache/xpath VariableStack.java<br/><ref>Committer's log entry: </ref>Added protection for null pointer exception that I discovered when
- running some Cocoon tests. Since I've never seen this before,
- I assume this is related to the changes that Gary made, but am
- unsure as it's 4:00 in the morning and I'm too tired to look into it deeply.<br/><br/></li><li><ref>Committed by </ref>curcuru@apache.org<ref> on </ref>03/14/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/xslt Process.java<br/><ref>Committer's log entry: </ref>Remove check for missing -IN arg; there are a number of use
- cases for calling Process.main without an XML document<br/><br/></li><li><ref>Committed by </ref>costin@apache.org<ref> on </ref>03/14/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/xslt Process.java<br/><ref>Committer's log entry: </ref>A (last ? ) place where XMLReaderFactory was used without
- trying jaxp first. I used the same code that is used in all other
- places in xalan.
-
- With this change, the parser defined in XSLTInfo.properties will be used
- only if jaxp is not available.<br/><br/></li><li><ref>Committed by </ref>dleslie@apache.org<ref> on </ref>03/14/2001<br/><ref>Modified: </ref>java/src/org/apache/xml/utils StringVector.java<br/><ref>Committer's log entry: </ref>Added missing @serial Javadoc tags.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/15/2001<br/><ref>Modified: </ref>java/src/org/apache/xalan/lib/sql ConnectionPool.java
-                        DefaultConnectionPool.java ExtensionError.java
-                        SQLExtensionError.java XConnection.java
-                        XConnectionPoolManager.java XStatement.java<br/><ref>Committer's log entry: </ref>Update from John Gentilin &lt;johnglinux@eyecatching.com&gt; to
-  fix connection cleanup.<br/><br/></li></ul><p>Compatibility source code updates:</p><ul><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>02/02/2001<br/><ref>Modified: </ref>java/compat_src/org/apache/xalan/xslt XSLTInputSource.java
- XSLTResultTarget.java<br/><ref>Committer's log entry: </ref>Implement some more methods for compatibility<br/><br/></li><li><ref>Committed by </ref>dleslie@apache.org<ref> on </ref>02/02/2001<br/><ref>Modified: </ref>java/compat_src/org/apache/xalan/xslt XSLTInputSource.java<br/><ref>Committer's log entry: </ref>Fixed javadoc for api that was just added back.<br/><br/></li><li><ref>Committed by </ref>dleslie@apache.org<ref> on </ref>02/02/2001<br/><ref>Modified: </ref>java/compat_src/org/apache/xalan/xslt XSLTResultTarget.java<br/><ref>Committer's log entry: </ref>Fixed javadoc for api that was just added back.<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>02/02/2001<br/><ref>Modified: </ref>java/compat_src/org/apache/xalan/xslt XSLTEngineImpl.java<br/><ref>Committer's log entry: </ref>Fix problem with calling the processor with a liaison<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>02/02/2001<br/><ref>Modified: </ref>java/compat_src/org/apache/xalan/xslt XSLTEngineImpl.java<br/><ref>Committer's log entry: </ref>Fix problem where source file was being parsed more than once and if using an 
-input stream, we would get a read error<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>02/12/2001<br/><ref>Modified: </ref>java/compat_src/org/apache/xalan/xslt XSLTEngineImpl.java<br/><ref>Committer's log entry: </ref>Set system id in stylesheet handler<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>02/14/2001<br/><ref>Modified: </ref>java/compat_src/org/apache/xalan/xslt XSLTInputSource.java<br/><ref>Committer's log entry: </ref>Call local setSystemId.<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>02/15/2001<br/><ref>Modified: </ref>java/compat_src/org/apache/xalan/xslt XSLTEngineImpl.java<br/><ref>Committer's log entry: </ref>Fix problem with processing an input source created from a reader with no 
-systemId
- Fix problem with reading an input source file twice if it has a PI<br/><br/></li><li><ref>Committed by </ref>mmidy@apache.org<ref> on </ref>02/22/2001<br/><ref>Modified: </ref>java/compat_src/org/apache/xalan/xslt StylesheetRoot.java<br/><ref>Committer's log entry: </ref>Add getOutputMethod API.<br/><br/></li><li><ref>Committed by </ref>dleslie@apache.org<ref> on </ref>03/07/2001<br/><ref>Modified: </ref>java/compat_src/org/apache/xalan/xpath/xml
- XMLParserLiaisonDefault.java<br/><ref>Committer's log entry: </ref>Put in Apache copyright.<br/><br/></li><li><ref>Committed by </ref>sboag@apache.org<ref> on </ref>03/13/2001<br/><ref>Modified: </ref>java/compat_src/org/apache/xalan/xpath/xml TreeWalker.java
- java/compat_src/org/apache/xalan/xslt XSLTEngineImpl.java<br/><ref>Committer's log entry: </ref>Made changes for change to API for XalanJ2 TreeWalker, which
- now requires that the DOM helper be created by the caller.</li>
- </ul>
-</s3>
-
-<s3 title="Changes for &xslt4j; version 2.0.0">
-<p>Release 2.0 includes several bug fixes to the &xslt4j; and TrAX core and to the Xalan-Java 1 compatibility API. We also updated bsf.jar to the <resource-ref idref="bsf"/> release candidate 2.2, which fixes a bug running JPython extensions.</p>
-<p><em>Core bug fixes:</em></p>
-<ul>
-  <li>A threading problem showed up when using multiple processors. We fixed it by using a separate XPathContext object to do whitespace node
-   matches (xsl:strip-space).<br/><br/></li>
-  <li>Fixed a bug running Norm Walsh's DocBook stylesheets by not setting the variable stack position if the FilterExprWalker is not owned by a
-  top-level NodeIterator.<br/><br/></li>
-  <li>Fixed a problem with null namespace being passed from xsl:element. This bug also surfaced while processing DocBook
-   stylesheets.<br/><br/></li>
-  <li>In the interest of stability, we now treat "unknown error in XPath" as a fatal error.<br/><br/></li>
-  <li>Added support in stylesheet processing instructions for "text/xml" and "application/xml+xslt" mime types.<br/><br/></li>
-  <li>Fixed tokenizing of stylesheet processing instructions to allow parameters to be passed to server in href attributes.<br/><br/></li>
-  <li>Fixed a bug passing Transformer creation error messages to ErrorListener when an ErrorListener has been set on
-   TransformerFactory.<br/><br/></li>
-  <li>When using an Exception to instantiate a FactoryConfigurationError (extends Error), we now propagate the Exception message to 
-  super().<br/><br/></li>
-  <li>Added defensive code to ElemTemplateElement for handling a null URI.<br/><br/></li>
-  <li>When using an Exception to instantiate a TransformerException (extends Exception), we now propagate the Exception message to super() 
-  rather than a generic message.<br/><br/></li>
-  <li>Fixed a bug (the generation of an unwanted entity reference) performing the identity transformation 
-  (see <link idref="usagepatterns" anchor="serialize">Serializing output</link>) with an XML document containing a DOCTYPE
-   declaration.<br/><br/></li>
-   <li>Message manager modified so that the SourceLocator must always be passed in,
-  which will make a major difference in getting line number information.<br/><br/></li> 
-  <li>xsl:element's handling of namespace attribute and prefix in
-  name attribute changed so that it no longer manufactures prefixes...
-  it always tries its best to match the prefix entered.<br/><br/></li>  
-  <li>Bug fixed with namespace contexts in the stylesheet processor.
-  The bug could cause &lt;a xmlns:a="x"&gt;&lt;b&gt; to produce &lt;a xmlns:a="x"&gt;&lt;b xmlns:a="x"&gt;.<br/><br/></li>  
-  <li>Modified processing of xsl:message to enhance it as a debugging aid. Line numbers are now output with each
-  message. If the terminate attribute is true (the default is false) the message is sent to the console, and an exception is thrown with the
-  message "Stylesheet directed termination".<br/><br/></li>
-  <li>In TransformerException, check that the cause != null when checking for a contained exception.<br/><br/></li>
-  <li>Fixed a problem validating non-namespaced attributes and a problem allowing non-namespaced attributes to be children of the
-   stylesheet element.<br/><br/></li>
-   <li>Fixed checking of number of arguments in document() function.<br/><br/></li>
-   <li>Fixed problem with mutation of templates at run time. Templates resolution now takes place during the compose() method.<br/><br/></li>
-   <li>Fixed some minor threading issues in org.apache.xalan.stree (Child, Parent, ElementImpl, SourceTreeHandler).<br/><br/></li>
-   <li>Synchronized TrAX API functions subject to mutation to prevent mutation during a transformation.<br/><br/></li>
-   <li>Fixed bug reported by Jano Elovirta: substring() was returning an error if the start index is larger than the string.<br/><br/></li>   
-   <li>Set StringKey.toString() to return the underlying String (m_str), thus avoiding a potential symmetry problem with the equals() method
-   reported by Ito Kazumitsu.<br/><br/></li>
-   <li>In response to note from Ito Kazumitsu, changed Java encoding name "EUCJIS" in FormatterToXML to "EUC_JP".<br/><br/></li>
-   <li>When Xalan creates a FileOutputStream, it now closes the stream before exiting.<br/><br/></li>
-   <li>Fixed handling of an exception that can be thrown while building a DOM.<br/><br/></li>
-   <li>Fixed a problem reported by Dimitry Voytenko serializing compiled stylesheets.<br/><br/></li>
-   <li>For support of applets, modified TransformerFactory System.getProperty() calls to catch SecurityExceptions.<br/><br/></li>
-   <li>Fixed a bug reported by Krishna Mohan Meduri setting output properties.<br/><br/></li>
-   <li>Fixed error recovery when xsl:element encounters a bad name or unresolvable prefix.<br/><br/></li>
-   <li>Added AbstractMethodError handling to existing NoSuchMethodError handling as a fallback to the XMLReaderFactory for XML parsers that do
-       not implement the JAXP parsers interface for creating an XMLReader<br/><br/></li>
-   <li>Fixed bug with cloned iterators reported by Tim Sean.<br/><br/></li>
-   <li>Fixed null pointer exception that could occur with getValue("xxx").<br/><br/></li>
-   <li>Fixed bug reported by Tim Sean handling the xml:space attribute.</li>
-</ul>
-<p><em>Bug fixes in the <link idref="usagepatterns" anchor="compat">Xalan-Java 1 compatibility API</link>:</em></p>
-<ul>
-  <li>Fixed ProblemListener (for processing error messages) to derive from &xslt4j; 2 ErrorHandler.<br/><br/></li>
-  <li>Fixed evaluation of stylesheet string parameters to conform to &xslt4j; 1 behavior (expressions for &xslt4j; 1 vs. String objects 
-  for &xslt4j; 2).<br/><br/></li>    
-  <li>Added XPathSupport and XPathSupportDefault, and fixed the derivation of XObject sub-types (XString, etc.).<br/><br/></li>
-  <li>Fixed bug with XSLTProcessor process(xmlIn, null, out) method so that it uses the StylesheetRoot (if one exists) that has been created
-   with the processStylesheet() method.</li>
-</ul>
-<p>For a list of tasks in the &xslt4j2; To-Do list that have been completed, see <jump href="todo.html#release-date-completed">Tasks completed</jump>.</p>
-</s3>
-
-<s3 title="Changes for &xslt4j; version 2.0.D07">
-<p>&xslt4j; 2.0.D07 incorporates a <link idref="usagepatterns" anchor="compat">Xalan-Java 1 compatibility jar</link>, some performance enhancements, and a number of bug fixes for bugs found in version 2.0.D06.</p>
-<ul>
-<li>Fixed handling of disable-output-escaping="no".  Previously, once it was turned on, it could not be turned off.<br/><br/></li>
-<li>Fixed a bug with whitespace handling where Xalan was incorrectly checking for whitespace 
-    stripping before collation of multiple whitespace events into a single text node.<br/><br/></li>
-<li>Whitespace stripping wasn't working with input DOMs before.  This is now fixed.<br/><br/></li>
-<li>Fixed many exception handling problems and problems with error reporting.<br/><br/></li>
-<li>Fixed a bug resetting parameters in Transformer clearParameters().<br/><br/></li>
-<li>Fixed a bug where CDATA sections were not matching the text() node test.<br/><br/></li>
-<li>Made better memory allocation problem with result tree fragments.<br/><br/></li>
-<li>Made result tree fragment parsing of numbers consistent with strings.<br/><br/></li>
-<li>Exceptions thrown from extensions should now be properly reported via the error listener.<br/><br/></li>
-<li>Fixed hard-coded stack dump set off by m_reportInPostExceptionFromThread variable.<br/><br/></li>
-<li>Fixed intermittent threading problem with text nodes being dropped.<br/><br/></li>
-<li>Fixed problem with variable evaluation inside of union expressions.</li>
-</ul>
-</s3>
-<s3 title="Changes for &xslt4j; version 2.0.D06">
-<p>We have fixed the bugs reported in &xslt4j; 2.0.D05. Along with several other enhancements, 
-we have also fixed a number of bugs found by testing and our users:</p>
-<ul>
-<li>Fixed some threading problems and improved support for handling Exceptions thrown in a secondary thread.<br/><br/>
-Note: To support incremental output, &xslt4j; performs the transformation in a second thread while building the source tree in the main thread.<br/><br/></li>
-<li>Fixed problems encountered in piping (utilizing transformation output as input for another transformation).<br/><br/></li>
-<li>Fixed problems handling attributes and adding attributes to result tree.<br/><br/></li>
-<li>Added defensive checking for null entities, null namespaces, and empty strings passed in for URIs and local names.<br/><br/></li>
-<li>We now conform to the SAX convention of representing null namespaces with empty strings.<br/><br/></li>
-<li>Fixed a bug encountered evaluating a variable in a predicate expression applied to child nodes.<br/><br/></li>
-<li>Changed names of serializers from FormatterTo<ref>Xxx</ref> to SerializerTo<ref>Xxx</ref>. See 
-<jump href="apidocs/org/apache/xalan/serialize/package-summary.html">Package org.apache.xalan.serialize</jump>.<br/><br/></li>
-<li>Improved debugging support in a number of areas.</li>
-</ul>
-</s3>
-<s3 title="Changes for &xslt4j; version 2.0.D05">
-<p>All of the bugs reported in &xslt4j; 2.0.D01 have been fixed. The remainder of this section discusses two changes that we believe are of particular importance:</p>
-<p><em>TrAX</em></p>
-<p>The Transformation API for XML (TrAX) that &xslt4j2; implements has undergone substantial revisions since the release of &xslt4j; 2.0.D01. TrAX has joined the Java API for XML Parsing (JAXP) as part of the Sun&reg; <resource-ref idref="jsr063"/>. Accordingly, the TrAX package names have changed. The conceptual organization has also changed somewhat: The primary transformation interfaces are defined in javax.xml.transform, with concrete classes for managing stream input/output, SAX parsers and ContentHandler, and DOM parsers and DOM trees in javax.xml.transform.stream, javax.xml.transform.sax, and javax.xml.transform.dom. For more information, see <resource-ref idref="trax"/>, and review <link idref="usagepatterns">Usage Patterns</link>.</p>
-<anchor name="outputprops"/><p><em>Output properties</em></p>
-<p>The handling of xsl:output properties has changed: org.apache.xalan.serialize.OutputFormat and apache.xalan.templates.OutputFormatExtended were removed and replaced with org.apache.xalan.templates.OutputProperties. The SerializerFactory getSerializer() method now takes Properties rather than a String indicating the output method. You can replace <code>getSerializer("xml")</code>, for example, with <code>getSerializer(OutputProperties.getDefaultMethodProperties("xml"))</code>.</p>
-<p>HTML, XML, and text xsl:output properties are specified in property files in org.apache.xalan.templates: output_html.properties, output_xml.properties, and output_text.properties.</p>
-<p>You can start using the output properties defined in these files in your stylesheets. For example, you can turn URL escaping off in HTML output with<br/><code>{http\u003a//xml.apache.org/xslt}use-url-escaping=no</code><br/>
-and you can control indenting with<br/>
-<code>{http\u003a//xml.apache.org/xslt}indent-amount=<ref>n</ref></code></p>
-<note>The colon after the "http" protocol must be escaped.</note>
-<p>Character-to-entity mapping is specified in org.apache.xalan.serialize: HTMLEntities.res and XMLEntities.res. You can override entity ref 
-mapping from a stylesheet. For example:</p>
-<source>&lt;?xml version="1.0"?&gt;
-&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-         xmlns:xalan="http://xml.apache.org/xslt" version="1.0"&gt;
-
-  &lt;xsl:output xalan:entities="myentities.ent"/&gt;
-
-  &lt;xsl:template match="/"&gt;
-    &lt;out&gt;&amp;#125;&lt;/out&gt;
-  &lt;/xsl:template&gt;
-
-&lt;/xsl:stylesheet&gt;</source>
-<p>=== myentities.ent ===</p>
-<source>quot 34
-amp 38
-lt 60
-gt 62
-lala 125</source>
-<p>The output is:</p>
-<source>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
-&lt;out&gt;&amp;lala;&lt;/out&gt;</source>
-<p>See also <link idref="usagepatterns" anchor="outputprops">Setting output properties in your stylesheets</link>.</p>
-</s3>
\ No newline at end of file
diff --git a/xdocs/sources/xalan/index.xml b/xdocs/sources/xalan/index.xml
deleted file mode 100644
index 7687d8e..0000000
--- a/xdocs/sources/xalan/index.xml
+++ /dev/null
@@ -1,99 +0,0 @@
-<?xml version="1.0" standalone="no"?>
-<!DOCTYPE s1 SYSTEM "../../style/dtd/document.dtd">
-<!-- 
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- -->
-<s1 title="&xslt4j-current;">
-  <s2 title="What is it?">
-    <p>Xalan is an XSLT processor for transforming XML documents into HTML, text, or other XML document types. It implements the
-     W3C Recommendations for XSL Transformations (XSLT) and the XML Path Language (XPath). It can be used from the command line,
-     in an applet or a servlet, or as a module in other program.</p>
-  </s2>
-  <s2 title="I've heard of &xslt4j;, but what is version 2?">
-    <p>&xslt4j; version 2 recasts Xalan as an implementation of the <resource-ref idref="trax"/> interfaces, part of the <resource-ref idref="jaxp11"/>. TRaX provides a
-    modular framework and a standard API for performing XML transformations, and it utilizes system properties to determine which Transformer and which XML parser to use.</p>
-     <p>&xslt4j; version 2 also builds on <resource-ref idref="sax2"/>, <resource-ref idref="dom2"/>, and the XML parser API in
-     <resource-ref idref="jaxp"/>.</p>
-     <p>For more information, see <link idref="whatsnew">What's new in &xslt4j2;</link>.</p>
-  </s2>
-  <s2 title="How about this release?">
-  <p>&xslt4j-current; is a production release It incorporates a number of enhancements and bug fixes. For the details, see 
-  <link idref="readme">Release Notes</link>. Please send your feedback to the <human-resource-ref idref="xalandev"/>.</p>
-  </s2> 
-  <s2 title="How do I get it?">
-    <p>Download and unzip either of the following:</p>
-    <ul>
-      <li><resource-ref idref="xslt4j-dist-zip"/></li>
-      <li><resource-ref idref="xslt4j-dist-targz"/></li>
-    </ul>     
-  </s2>
-  
-  <s2 title="Where do I get Xerces?">
-    <p>The Xalan download includes xerces.jar from &xml4j-used;. This is all you need to run Xalan with the Xerces XML parser. 
-    You can, however, download the complete Xerces distribution from the <resource-ref idref="xml4j-distdir"/>.</p>
-    <note>If you plan to use a different XML parser, see <link idref="usagepatterns" anchor="plug">Plugging in a Transformer
-     and XML parser</link>.</note> 
-  </s2>
-  <s2 title="What else do I need?">
-    <p>You need the Java Development Kit or Java Runtime 1.1.8, 1.2.2, or 1.3, which you can obtain from <jump
-    href="http://www.ibm.com/java/jdk">ibm.com/java/jdk/</jump> or <jump href="http://www.java.sun.com">java.sun.com</jump>.</p> 
-  </s2>  
-    <s2 title="For more information...">
-    <p>For more information, go to <link idref="overview">Xalan Overview</link> and <link idref="getstarted">Getting
-    Started</link>. All of the Xalan documentation on this website is included in the Xalan download, as are a number of
-    <link idref="samples">Samples</link> to help you start using &xslt4j2; to transform XML documents.</p>
-  </s2>  
-</s1> 
\ No newline at end of file
diff --git a/xdocs/sources/xalan/overview.xml b/xdocs/sources/xalan/overview.xml
deleted file mode 100644
index 408e798..0000000
--- a/xdocs/sources/xalan/overview.xml
+++ /dev/null
@@ -1,195 +0,0 @@
-<?xml version="1.0" standalone="no"?>
-<!DOCTYPE s1 SYSTEM "../../style/dtd/document.dtd">
-
-<!--
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- -->
- 
-<s1 title="&xslt4j; Overview">
-<ul>
-<li><link anchor="intro">Introduction</link></li>
-<li><link anchor="features">&xslt4j; Features</link></li>
-<li><link anchor="towork">Getting to work with &xslt4j;</link></li>
-<li><link anchor="uptospeed">Getting up to speed with XSLT</link></li>
-<li><link anchor="glossary">Glossary</link></li>
-</ul><anchor name="intro"/>
-  <s2 title="Introduction">
-    <p>&xslt4j; (named after a rare musical instrument) fully implements the <resource-ref idref="xslt"/> and the 
-    <resource-ref idref="xpath"/>. XSLT is the first part of the XSL stylesheet language for XML. It includes the XSL
-     Transformation vocabulary and XPath, a language for addressing parts of XML documents. For links to background materials, 
-    discussion groups, frequently asked questions, and tutorials on XSLT, see <link anchor="uptospeed">Getting up
-    to speed with XSLT</link>.</p> 
-    <note>XSL also includes a vocabulary for formatting documents, which is not part of &xslt4j;. 
-    For more information, see <resource-ref idref="xsl"/> and the <jump
-    href="http://xml.apache.org/fop">Apache XML FOP (Formatting Objects Project)</jump>.</note>
-    <p>You use the XSLT language to compose XSL stylesheets. An XSL stylesheet contains instructions for
-     transforming XML documents from one document type into another document type (XML, HTML, or other). In structural
-     terms, an XSL stylesheet specifies the transformation of one tree of nodes (the XML input) into another tree of nodes 
-     (the output or transformation result).</p>
-    <note>The XSL stylesheet may generate and refer to cascading style sheets (<jump
-    href="http://www.w3.org/Style/CSS/">CSS</jump>) as part of its output.</note> 
-    <p>In the following example, the foo.xsl stylesheet is used to transform foo.xml into foo.out:</p>
-    <p>foo.xml:</p>
-        <source>&lt;?xml version="1.0"?>
-&lt;doc>Hello&lt;/doc></source>
-        <p>foo.xsl:</p>
-        <source>&lt;?xml version="1.0"?> 
-&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-&lt;xsl:template match="doc">
-&lt;out>&lt;xsl:value-of select="."/>&lt;/out>
-&lt;/xsl:template>
-&lt;/xsl:stylesheet></source>
-<p>foo.out:</p>
-<source>&lt;out>Hello&lt;/out></source>
-<p>By default, &xslt4j; uses &xml4j;, and it may be configured with system properties to work with other XML parsers (see <link idref="usagepatterns" anchor="plug">Plugging in a Transformer and XML parser</link>). The input may be submitted in the form of a stream of XML markup (from a URI, a character or byte stream, or another transformation), a SAX InputStream, or a DOM Node.</p>
-<p>&xslt4j; performs the transformations specified in the XSL stylesheet and packages a sequence of SAX events that may be serialized to an output stream or writer, used to build a DOM tree, or forwarded as input to another transformation.</p>
-      </s2><anchor name="features"/>
-   	  <s2 title="&xslt4j; Features">
-	    <ul> 
-		    <li>Implements the relevant W3C specifications: <resource-ref idref="xslt"/> and <resource-ref idref="xpath"/>.<br/><br/></li>
-        <li>Implements <resource-ref idref="trax"/>, now part of <resource-ref idref="jaxp"/>, and builds on
-         <resource-ref idref="sax2"/> and <resource-ref idref="dom2"/>.<br/><br/></li>
-    	  <li>May be configured to work with any XML parser, such
-        <jump href="http://xml.apache.org/xerces-j/index.html">&xml4j;</jump>, that implements <resource-ref
-        idref="jaxp"/> (see <link idref="usagepatterns" anchor="plug">Plugging in an XML
-         parser</link>).<br/><br/></li>
-    	  <li>Can process Stream, SAX or DOM input, and output to a Stream, SAX or DOM.<br/><br/></li>
-        <li>Transformations may be chained (the output of one transformation may be the input for
-         another).<br/><br/></li>
-        <li>May be run from the <link idref="commandline">command line</link> for convenient file-to-file
-            transformations.<br/><br/></li>
-    	  <li>Includes an <link idref="usagepatterns" anchor="applet">applet wrapper</link>.<br/><br/></li>
-        <li>May be used in a <link idref="samples" anchor="servlet">servlet</link> to transform XML documents into
-        HTML and serve the results to clients.<br/><br/></li>
-        <li>Supports the creation of <link idref="extensions">Java and scripting language extensions</link>. and
-         provides a growing library of extension elements and functions.</li>
-	    </ul> 
-	  </s2><anchor name="towork"/>
-    <s2 title="Getting to work with &xslt4j;">
-     <p>For instructions and some suggestions about how to get started using &xslt4j;, see 
-     <link idref="getstarted">Getting Started</link>.</p>
-    </s2><anchor name="uptospeed"/>
-    
-    <s2 title="Getting up to speed with XSLT">
-    <p>If you are still working through the details of the XSLT spec (the W3C 1.0 Recommendation), you may want 
-    to consult one or more of the following:</p>
-    <ul>
-      <li>Michael Kay's <jump href="http://www.wrox.com/Consumer/Store/Details.asp?ISBN=1861003129">XSLT Programmer's
-       Reference</jump>, Wrox Press, 2000<br/><br/></li>
-       <li>Neil Bradley's XSL Companion, Addison-Wesley, 2000<br/><br/></li>                 
-        <li>Elliotte Rusty Harold's <jump href="http://metalab.unc.edu/xml/books/bible/updates/14.html">Chapter 14 of 
-        the XML Bible: XSL Transformations</jump><br/><br/></li>
-        <li>Crane Softwright's <jump href="http://www.CraneSoftwrights.com/training/">Free preview of Practical
-         Transformation Using XSLT and XPath</jump><br/><br/></li>
-        <li>The Mulberry <jump href="http://www.mulberrytech.com/xsl/xsl-list/">XSL-List -- Open Forum on XSL</jump> 
-        (of interest to XSL users at all levels)<br/><br/></li>
-        <li>Dave Pawson's <resource-ref idref="dpawsonxslfaq"/><br/><br/></li>
-        <li>Objects by Design's <jump href="http://www.objectsbydesign.com/projects/xmi_to_html.html">Transforming XMI to
-         HTML</jump> (oriented towards XMI, "an XML-based, stream representation of a UML model," but also covers "generic"
-         XML transformations)<br/><br/></li>
-         <li>Objects by Design;'s <jump href="http://objectsbydesign.com/projects/xslt/xslt_by_example.html">XSLT by
-         Example</jump><br/><br/></li>                  
-         <li>Miloslav Nic's <jump href="http://zvon.vscht.cz/HTMLonly/XSLTutorial/Books/Book1/index.html">XSL Tutorial</jump>
-         <br/><br/></li>
-         <li>OASIS (the Organization for the Advancement of Structured Information Standards): 
-         <jump href="http://www.oasis-open.org/cover/xsl.html">Extensible Stylesheet Language (XSL)</jump> by Robin
-         Cover<br/><br/></li>
-         <li>Donald Ball's <jump href="http://www.webslingerZ.com/balld/xsl/designer_manual.xml">A Guide to XML and XSL for
-         Designers</jump><br/><br/></li>
-        <li>XSLT - XSL Transformations in 
-        <jump href="http://www.brics.dk/~amoeller/XML/">The XML Revolution: Technologies for the future Web</jump> by
-        Anders M&oslash;ller and Michael I. Schwartzbach</li>
-    </ul>
-    <p>When you come across other useful introductory or background materials, please email <human-resource-ref
-     idref="xalandev"/>, so we can add them to this list.</p>
-     
-    </s2><anchor name="glossary"/>
-    <s2 title="Glossary">
-      <gloss>
-        <label>XSLT Namespace</label>
-        <item>The <jump href="http://www.w3.org/TR/REC-xml-names/">XML namespace</jump> for XSLT. An XML namespace is a 
-        collection of element and attribute names, identified by a Unique Resource Identifier (URI), which often takes the form of
-        a URL, but is really just a unique string, not a pointer to a web page. The XSLT namespace URI is
-        http://www.w3.org/1999/XSL/Transform. In each XSLT stylesheet, you must declare this namespace in the stylesheet element
-        tag and bind it to a local prefix. Like the XSLT specification, we always use xsl as the XSLT namespace prefix in our
-        descriptions and examples, although you are free to bind any prefix to this namespace.<br/><br/></item>
-        
-        <label>XSL Instruction</label>
-        <item>Any tag associated with the XSLT namespace.<br/><br/></item>
-        
-        <label>Template</label>
-        <item>An element, usually with child elements, that specifies a "rule" or set of 
-        instructions to perform when a particular kind of node is encountered in the source tree.<br/><br/></item>
-                
-        <label>XSL Template Instruction</label>
-        <item>Any tag that occurs inside an xsl:template element and is associated with the XSLT namespace.<br/><br/></item>
-                   
-        <label>Source Tree</label>
-        <item>The XML tree input to the XSL process.<br/><br/></item>
-        
-        <label>Result Tree</label>
-        <item>The tree that is output by the XSL process.<br/><br/></item>
-                
-        <label>Match Pattern</label>
-        <item>The part of a template that defines the kind(s) of nodes to which the template applies.<br/><br/></item>
-
-      </gloss>
-      <p>For more definitions of XSLT terminology, see Dave Pawson's 
-      <jump href="http://www.dpawson.co.uk/xsl/vocab.html">XSLT Terminology
-      Clarification</jump> and the Glossary in Michael Kay's 
-      <jump href="http://www.wrox.com/Consumer/Store/Details.asp?ISBN=1861003129">XSLT Programmer's Reference</jump>.</p>
-    </s2>
-</s1> 
diff --git a/xdocs/sources/xalan/readme.xml b/xdocs/sources/xalan/readme.xml
deleted file mode 100644
index 77e143b..0000000
--- a/xdocs/sources/xalan/readme.xml
+++ /dev/null
@@ -1,288 +0,0 @@
-<?xml version="1.0" standalone="no"?> 
-<!DOCTYPE s1 SYSTEM "../../style/dtd/document.dtd"[
-<!ENTITY done-j SYSTEM "DONE">
-<!ENTITY status-j SYSTEM "STATUS">
-<!ENTITY history-j SYSTEM "history.xml">]>
-
-<!--
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- -->
-<s1 title="Release Notes">
-<p>&xslt4j-current;</p>
- <ul>
-  <li><link anchor="status0">Status</link></li>
-  <li><link anchor="build">Build Notes</link></li>
-  <li><link anchor="contact">Getting in touch</link></li>
-  <li><link anchor="history">History of software changes</link></li>
- </ul><anchor name="status0"/>
-  <s2 title="Status">
-   <ul>
-    <li><link anchor="done">Changes since version 2.0.1</link></li>
-    <li><link anchor="other">Other points of interest</link></li>
-    <li><link anchor="bugs">Bugs</link></li>
-    <li><link anchor="status">Version of Xerces to use</link></li>
-    <li><link anchor="to-do">To-do tasks for future &xslt4j; releases</link></li>
-   </ul>
-     <anchor name="done"/>
-     <s3 title="Changes since &xslt4j; 2.0.1">
-     <p>This release includes a number of bug fixes to the &xslt4j; and TrAX core and Xalan-Java 1 compability API. We have also</p>
-     <ul>
-     <li></li>
-     <li><br/><br/></li> 
-     <li></li>
-     </ul>
-     &done-j;
-     </s3>
-     <anchor name="other"/>
-     <s3 title="Other points of interest">
-     <ul>
-     <li>Handling xsl:namespace-alias declarations: In release 2.0.D01, we reported the need to do some research concerning exactly how Xalan
-     should handle xsl:namespace-alias declarations. As a result of discussions among members of the W3C Working Group on XSL, we have reached a
-     more precise consensus on how namespaces should be represented when an xsl:namespace-alias declaration is in effect.<br/><br/>
-     If a literal result element has a namespace prefix, the prefix will be preserved and the namespace URI of the element will be as
-     specified in the xsl:namespace-alias element, but the result-prefix is not required to appear in the result. This also applies to the
-     two other cases of "Literal namespace URI" mentioned in the XSLT Recommendation on 
-     <jump href="http://www.w3.org/TR/xslt#literal-result-element">Literal Result Elements</jump>. More simply, if the stylesheet calls for
-     &lt;axsl:foo&gt; to be output as a literal result element, then it will be output as &lt;axsl:foo&gt; in the result, but the namespace
-     associated with this "axsl" prefix will be as designated in the xsl:namespace-alias declaration.<br/><br/></li>
-     <li>For HTML output, &xslt4j2; outputs character entity references (&amp;copy; etc.) for the special characters designated in  
-     <jump href="http://www.w3.org/TR/xhtml1/#dtds">Appendix A. DTDs of the XHTML 1.0: The Extensible HyperText Markup
-     Language</jump>. &xslt4j; 1.x, on the other hand, outputs literal characters for some of these special characters.<br/><br/></li>
-     <li>In conformance with the <jump href="http://www.w3.org/TR/xslt#section-HTML-Output-Method">XSLT Recommendation on the HTML 
-     Output Method</jump> and <jump href="http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.1">Section B.2.1 of the HTML 4.0
-     Recommendation</jump>, &xslt4j2; uses %hh encoding for each byte of the UTF-8 representation of non-ASCII characters in HTML URI
-     attributes.<br/><br/></li>
-     <li>When your stylesheet asks for an explicit carriage-return character (&amp;#13;) to be inserted into the output, it is output during
-     the serialization process in escaped form unless escaping has been disabled.  When your stylesheet asks for an explicit line-feed character
-     (&amp;#10;) to be output, the system-default line-break character(s) is/are output during the serialization process.  Also keep in mind that
-     the XML parser normalizes line-breaks to line-feeds when it sends character events to the processor.<br/><br/></li>
-     <li>If your XML input is a DOM, use the javax.xml.parsers.DocumentBuilderFactory setCoalescing() method to set coalescing to true (it is
-     false by default), if you want to append CDATA sections to adjacent text sections to form a single text node (as the XPath standard calls
-      for), and if the XML parser supports this feature (&xml4j-used; does not).</li>
-     </ul>
-     </s3><anchor name="bugs"/>
-     <s3 title="Bugs">
-     <p>All known &xslt4j; bugs are listed in <resource-ref idref="bugzilla"/>. For a list of open bugs with links to each bug
-      report, see <resource-ref idref="buglist"/>. If you find a new bug, please enter a XalanJ2 bug report in this
-      database.</p>
-     <note>Before you can enter your first bug report, you must submit your email address to Bugzilla and receive a password.</note> 
-     <p>We strongly encourage you write patches for problems you find and submit them to
-      xalan-dev@xml.apache.org. We review the patches we receive to make sure they do not break something else, and (assuming they 
-     do not) include them in our next release. In the interest of fixing bugs, adding enhancements, and addressing outstanding design
-     issues, we sincerely want (and need!) your active participation in the ongoing development of Xalan.</p>
-     <p>Xerces bug in &xml4j-used;:</p>
-     <ul>
-       <li>&xml4j; 1.2.3 does not process namespaces in SAX events when parsing UTF-16 documents, which causes &xslt4j; to fail with UTF-16
-        documents. Xerces will post a fix shortly.<br/><br/></li>
-     </ul>
-     </s3>     
-     <anchor name="status"/>
-     &status-j;
-     <anchor name="to-do"/>
-     <s3 title="To-do tasks">
-       <p>For a list of goals, tasks, and target dates for completion, see <jump href="todo.html">Xalan-Java Version 2: Things To Do</jump>. 
-       As tasks are completed, they are moved from the to-do list to 
-       <jump href="todo.html#release-date-completed">Completed</jump>.</p>
-       <p>The source document for the to-do list is an active document in the Apache CVS repository: 
-       <jump href="http://xml.apache.org/websrc/cvsweb.cgi/xml-xalan/java/todo.xml">xml-xalan/java/todo.xml</jump>.</p>
-      </s3> 
-  </s2>
-  <anchor name="build"/>
-  
-  <s2 title="Build Notes">
-<ul>
-<li><link anchor="ant">Using Ant</link></li>
-<li><link anchor="jar">Rebuilding xalan.jar</link></li>
-<li><link anchor="samples">Rebuilding sample applications</link></li>
-<li><link anchor="doc">Rebuilding the &xslt4j; documentation</link></li>
-</ul>
-<anchor name="ant"/>
-   <s3 title="Using Ant">
-     <p>Apache <resource-ref idref="ant"/> is a flexible, powerful, and easy-to-use Java build tool that we include with the
-     &xslt4j; distribution. The Ant JAR file is in the bin directory, and the cross-platform XML build file (build.xml) is in 
-     the root directory along with a Windows32 batch file (build.bat) and a UNIX shell file (build.sh). The build file defines 
-     the "targets" that you can use Ant to build. The batch and shell files set up the classpath and launch Ant with the target 
-     (and any other arguments) you provide.</p>
-     <p><em>Instructions for using Ant</em></p>
-     <ol>
-       <li>Set the JAVA_HOME environment variable to the JDK root directory.<br/><br/>
-       If you are using JDK 1.1.8, you must also put classes.zip in the JDK bin directory on the classpath. You can use Ant 
-       with JDK 1.1.8 to compile and jar the &xslt4j; source files, but you must have JDK 1.2.2 or higher to build the
-       documentation.<br/><br/></li>
-       <li>Depending on your environment, run the batch file (build.bat) or shell file (build.sh) from the &xslt4j; root
-       directory, optionally with arguments (see the table of targets below).<br/><br/>
-       The batch/shell file adds several JAR files to the classpath and launches Ant with any arguments you provide. If you
-       provide no target, Ant compiles the source files and rebuilds xalan.jar (the "jar" target).</li>
-     </ol>
-     <p>You can also set up your classpath manually (see build.bat or build.sh for the details), and then run Ant as
-     follows:<br/><br/>
-     <code>java org.apache.tools.ant.Main <ref>target</ref></code><br/><br/>
-     where <ref>target</ref> is nothing (for the default target) or one of the following.</p>
-     <table>
-       <tr><td><em>Target</em></td><td><em>What Ant does</em></td></tr>
-       <tr><td>compile</td><td>compiles Xalan-Java in build/classes.</td></tr>
-       <tr><td>jar (the default)</td><td>creates xalan.jar in the build directory</td></tr>
-       <tr><td>samples</td><td>compiles and jars the sample apps in build/xalansamples.jar</td></tr>
-       <tr><td>servlet</td><td>compiles and jars the sample servlet in build/xalanservlet.jar</td></tr>       
-       <tr><td>docs</td><td>creates the HTML User's Guide in build/docs</td></tr>
-       <tr><td>javadocs</td><td>generates the API documentation in ./build/docs/apidocs</td></tr>
-       <tr><td>dist</td><td>generates a complete distribution tree with zip and tar.gz distribution files in build</td></tr>
-       <tr><td>clean</td><td>purges the build and distribution</td></tr> 
-  </table>
-  <p>If you build a target that depends on other targets, Ant creates those other targets in the correct order.</p>
-   </s3><anchor name="jar"/> 
-   <s3 title="Rebuilding &xslt4j;">
-     <p>The &xslt4j; build is in xalan.jar. The &xslt4j; source code tree is in the src directory.</p>
-     <p>If you are using Ant, the target is jar (the default). For more information, see <link anchor="ant">Using
-     Ant</link>.</p>
-     <p>If you want to do the build without Ant, keep the following in mind:</p>
-     <ul>
-     <li>Set the classpath to include the src directory, xerces.jar, bsf.jar, and bsfengines.jar.</li>
-     <li>Use a Java compiler (such as the IBM Just-In-Time compiler or the Sun javac) to compile all the .java files in the src
-     tree. </li>
-     <li>Use the Sun jar utility to store the resulting .class files in xalan.jar</li>
-     </ul>
-   </s3><anchor name="samples"/>
-   <s3 title="Rebuilding a sample application">
-   <p>If you modify a sample and want to recompile it, you can run the Java compiler in the directory containing the
-   example. Be sure xalan.jar and xerces.jar are on the classpath. To recompile (and run!) the class files in the
-   Servlet subdirectory, the javax.servlet and javax.servlet.http packages must also be on the classpath. Sun
-   distributes these packages in the JSWDK 1.0.1 servlet.jar file.</p> 
-   <p>After recompiling a sample, you can use the Sun jar utility to place your new .class files in
-    xalansamples.jar.</p>
-    <p>You can use Ant with the samples target to recompile the samples and place the unpackaged class files in xalansamples.jar.
-     For more information, see <link anchor="ant">Using Ant</link>.</p>
-    <note>To rebuild (and to run) the sample servlet, the javax.servlet and javax.servlet.http packages must be on your
-    classpath.</note>
-   </s3><anchor name="doc"/>
-   <s3 title="Rebuilding the &xslt4j; documentation">
-     <p>&xslt4j; includes a number of XML source files, XSL stylesheets, document type definition (DTD)
-      files, entity relationship (ENT) files, graphics, and a JavaScript file that provide the input for the Xalan
-      HTML User's Guide, and the overview and package-level documents used during the generation of Javadoc.</p>
-      <p>To rebuild the documentation, you must use the StyleBook tool and the JDK 1.2.2 java and javadoc
-      tools. StyleBook (which uses Xalan and Xerces) is in stylebook-1.0-b2.jar. Some of the document definition files,
-      stylesheets, and resources are stored in xml-site-style.tar.gz, and are unzipped when you run Ant as described
-       below.</p>
-      <p>You can use Ant with the docs target to regenerate the User's Guide and with the javadocs target to regenerate the
-      Javadoc API documentation. For more information, see <link anchor="ant">Using Ant</link>.</p>
-      <p>If you want to rebuild the documentation without using Ant, keep the following in mind:</p>
-       <ul>
-       <li>Unzip xml-site-style.tar.gz into the xdocs directory (the operation places files in a number of subdirectories).
-       <br/><br/></li>
-       <li>Be sure stylebook-1.0-b2.jar, xalanjdoc.jar, xalan.jar, bsf.jar, bsfengines.jar, and xerces.jar are on the class
-       path.<br/><br/></li>
-       <li>To build doc in a build/docs subdirectory, run StyleBook from the xdocs directory as follows:<br/><br/>
-       <code>java org.apache.stylebook.StyleBook "targetDirectory=../build/docs/" sources/xalanLocal.xml style</code>
-       <br/><br/></li>
-       <li>To build the HTML source files that javadoc needs for the TrAX top-level and package-level documentation, add
-       a build/docs/apdidocs/javax/xml/transform directory and run the Xalan command-line utility from the xdocs directory 
-       as follows (all one line):<br/><br/>
-<code>
-java org.apache.xalan.xslt.Process 
-  -in sources/trax/trax.xml
-  -param package-root '../../../src/'
-  -xsl style/stylesheets/spec.xsl 
-  -out build/docs/apidocs/javax/xml/transform/trax.html</code><br/><br/></li>
-        <li>Before you run javadoc, make sure the following directory structure exists under the Xalan root
-         directory: build/docs/apidocs.<br/><br/></li>
-       <li>To build the API documentation, run the JDK 1.2.2 javadoc tool from the xdocs directory (all one line):<br/><br/>
-<code>
-javadoc -doclet xalanjdoc.Standard 
- -docletpath ../bin/xalanjdoc.jar 
- -private
- -overview ../src/javadocOverview.html -sourcepath ../src 
- -group TrAX "javax.xml.transform*" 
- -group Xalan_Core "org.apache.xalan.processor:
-        org.apache.xalan.templates:
- org.apache.xalan.transformer"
- -group XPath "org.apache.xpath*"
- -group Utilities "org.apache.xml.utils*"
- -group Xalan_Other "org.apache.xalan.client:
-        org.apache.xalan.dtm:
- org.apache.xalan.extensions:org.apache.xalan.res:
- org.apache.xalan.stree:org.apache.xalan.trace:
- org.apache.xalan.xslt" 
- -group Xalan_Extensions "org.apache.xalan.lib*" 
- -group Serializers "org.apache.xalan.serialize" 
- org.apache.xalan.client org.apache.xalan.dtm 
- org.apache.xalan.extensions org.apache.xalan.lib 
- org.apache.xalan.lib.sql org.apache.xalan.processor 
- org.apache.xalan.res org.apache.xalan.stree 
- org.apache.xalan.templates org.apache.xalan.trace 
- org.apache.xalan.transformer org.apache.xalan.xslt 
- org.apache.xpath org.apache.xpath.axes 
- org.apache.xpath.compiler org.apache.xpath.functions 
- org.apache.xpath.objects org.apache.xpath.operations 
- org.apache.xpath.patterns org.apache.xpath.res
- org.apache.xalan.serialize javax.xml.transform  
- javax.xml.transform.dom javax.xml.transform.sax 
- javax.xml.transform.stream javax.xml.parsers
- -d ../build/docs/apidocs -windowtitle "Xalan-Java 2" 
- -doctitle "Xalan-Java 2" -bottom "Copyright &#169; 
-  2000 Apache XML Project. All Rights Reserved."
-</code></li>
-</ul>
-  </s3>    
- </s2><anchor name="contact"/>
- <s2 title="Getting in Touch">
-  <p>Your feedback is more than welcome. Offers of help are even more so! Perhaps you would like to take on an active role in the ongoing development, testing, and documentation of &xslt4j;?</p> 
-<p>Please email your comments, questions, suggestions, and offers to join the Xalan team to <human-resource-ref idref="xalandev"/>.</p>
- </s2><anchor name="history"/>
- <s2 title="Cumulative history of software changes">
-   <p>The following sections list the changes in each release since &xslt4j; version 2.0.D01.</p>
-   &history-j;
- </s2>
-</s1>
\ No newline at end of file
diff --git a/xdocs/sources/xalan/resources.xml b/xdocs/sources/xalan/resources.xml
deleted file mode 100644
index 3cfa5f2..0000000
--- a/xdocs/sources/xalan/resources.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-<?xml version="1.0" encoding="US-ASCII"?>
-<!DOCTYPE resources [
-  <!ENTITY % externalEntity SYSTEM "../entities.ent">
-  %externalEntity;
-  <!ELEMENT resources (resource|human-resource)+>
-  <!ELEMENT resource EMPTY>
-  <!ATTLIST resource 		
-        id CDATA #IMPLIED
-				title CDATA #IMPLIED
-				location CDATA #IMPLIED>
-  <!ELEMENT human-resource EMPTY>
-  <!ATTLIST human-resource 	
-        id CDATA #IMPLIED
-				name CDATA #IMPLIED
-				mailto CDATA #IMPLIED>
-   ]>  
-<resources> 	
-  <resource id="xslt4j-current" 
-            title="&xslt4j-current;" 
-            location="http://xml.apache.org/xalan"/>
-  <resource id="xslt4j-dist-zip" 
-            title="&xslt4j-dist;.zip" 
-            location="http://xml.apache.org/dist/xalan-j/&xslt4j-dist;.zip"/>
-  <resource id="xslt4j-dist-targz" 
-            title="&xslt4j-dist;.tar.gz" 
-            location="http://xml.apache.org/dist/xalan-j/&xslt4j-dist;.tar.gz"/>
-  <resource id="xslt4j-distdir" 
-            title="xalan-j distribution directory" 
-            location="http://xml.apache.org/dist/xalan-j/"/>
-  <resource id="xml4j-used" 
-            title="&xml4j-used;" 
-            location="http://xml.apache.org/xerces-j/index.html"/>
-  <resource id="xml4j-distdir" 
-            title="xerces-j distribution directory" 
-            location="http://xml.apache.org/dist/xerces-j/"/>
-  <resource id="ant" title="Ant" 
-            location="http://jakarta.apache.org/ant/index.html"/>
-  <resource id="ApacheLicense" 
-            title="The Apache Software License, Version 1.1" 
-            location="http://xml.apache.org/dist/LICENSE.txt"/>
-  <resource id="bugzilla"
-            title="Bugzilla (the Apache bug database)"
-            location="http://nagoya.betaversion.org/bugzilla/"/>
-  <resource id="buglist"
-            title="XalanJ2 open bugs"         location="http://nagoya.apache.org/bugzilla/buglist.cgi?bug_status=NEW&amp;bug_status=ASSIGNED&amp;bug_status=REOPENED&amp;email1=&amp;emailtype1=substring&amp;emailassigned_to1=1&amp;email2=&amp;emailtype2=substring&amp;emailreporter2=1&amp;bugidtype=include&amp;bug_id=&amp;changedin=&amp;votes=&amp;chfieldfrom=&amp;chfieldto=Now&amp;chfieldvalue=&amp;product=XalanJ2&amp;short_desc=&amp;short_desc_type=substring&amp;long_desc=&amp;long_desc_type=substring&amp;bug_file_loc=&amp;bug_file_loc_type=substring&amp;keywords=&amp;keywords_type=anywords&amp;field0-0-0=noop&amp;type0-0-0=noop&amp;value0-0-0=&amp;cmdtype=doit&amp;order=%27Importance%27"/>                   
-  <resource id="bsf"
-            title="Bean Scripting Framework (BSF)"
-            location="http://oss.software.ibm.com/developerworks/projects/bsf"/>     
-	
-  <resource id="Readme" 
-            title="Xalan Repository Release Notes" 
-            location="http://www.apache.org/websrc/cvsweb.cgi/xml-xalan/README"/>
-            
-  <resource id="xsl" title="Extensible Stylesheet Language (XSL) Version 1.0 W3C Candidate Recommendation"
-   location="http://www.w3.org/TR/xsl"/>
-
-  <resource id="dpawsonxslfaq" title="XSL Frequently Asked Questions" location="http://www.dpawson.co.uk/xsl/xslfaq.html"/>
-  
-  <resource id="xslt" 
-            title="W3C Recommendation XSL Transformations (XSLT) Version 1.0"
-            location="http://www.w3.org/TR/xslt"/>
-  
-  <resource id="xpath" 
-            title="XML Path Language (XPath) Version 1.0" 
-            location="http://www.w3.org/TR/xpath"/>            
-            
-  <resource id="dom" 
-            title="DOM" 
-            location="http://www.w3.org/DOM"/>
-  <resource id="dom2" 
-            title="DOM level 2" 
-            location="http://www.w3.org/TR/DOM-Level-2/"/>
-
-  <resource id="sax" 
-            title="SAX" 
-            location="http://www.megginson.com/SAX/sax.html"/>
-  <resource id="sax2" 
-            title="SAX 2" 
-            location="http://www.megginson.com/SAX/Java/index.html"/>
-  <resource id="jaxp" 
-            title="Java API for XML Parsing 1.0" 
-            location="http://java.sun.com/xml/docs/api/index.html"/>
-  <resource id="jaxp11" 
-            title="Java API for XML Processing 1.1 Public Review 2" 
-            location="http://java.sun.com/aboutJava/communityprocess/review/jsr063/jaxp-pd2.pdf"/>
-  <resource id="jsr063"
-            title="Java Specification Request 63"
-            location="http://java.sun.com/aboutJava/communityprocess/review/jsr063"/>
-  <resource id="trax" 
-            title="TRaX (Transformation API for XML)" 
-            location="apidocs/javax/xml/transform/trax.html"/>
-            
-  <resource id="compatapi"
-            title="Xalan-Java 1 compatibility Javadoc"
-            location="compat_apidocs/index.html"/>
-            
-  <human-resource id="xalandev" 
-                  name="Xalan Development Mailing List" 
-                  mailto="xalan-dev@xml.apache.org"/>
-</resources>
\ No newline at end of file
diff --git a/xdocs/sources/xalan/samples.xml b/xdocs/sources/xalan/samples.xml
deleted file mode 100644
index fa8a12b..0000000
--- a/xdocs/sources/xalan/samples.xml
+++ /dev/null
@@ -1,375 +0,0 @@
-<?xml version="1.0" standalone="no"?>
-<!DOCTYPE s1 SYSTEM "../../style/dtd/document.dtd">
-<!--
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- -->
-<s1 title="&xslt4j2; Samples">
-<ul>
-<li><link anchor="simpletransform">SimpleTransform</link></li>
-<li><link anchor="usestylesheetpi">UseStylesheetPI</link></li>
-<li><link anchor="usestylesheetparam">UseStylesheetParam</link></li>
-<li><link anchor="sax2sax">SAX2SAX</link></li>
-<li><link anchor="dom2dom">DOM2DOM</link></li>
-<li><link anchor="pipe">Pipe</link></li>
-<li><link anchor="usexmlfilters">UseXMLFilters</link></li>
-<li><link anchor="applyxpath">ApplyXPath</link></li>
-<li><link anchor="appletxmltohtml">AppletXMLtoHTML</link></li>
-<li><link anchor="get-todo-list">get-todo-list</link></li>
-<li><link anchor="servlet">servlet</link></li>
-<li><link anchor="extensions">Extensions</link></li>
-<li><link anchor="trace">Trace</link></li>
-<li><link anchor="trax">trax</link></li>
-</ul>  
-	  <s2 title="Samples to help you get started">
-    <p>Each of the subdirectories in the &xslt4j; java/samples directory contains the source files for one or more
-     sample applications. The class files for the samples are in xalansamples.jar (everything except the servlet) and xalanservlet.jar, so to run the samples, you should place these JAR files on the system classpath.</p>
-     <p>With most of the samples, you can use the following procedure:</p>
-     <ol>
-     <li>Be sure xalan.jar, xalansamples.jar, and xerces.jar are on the system class
-      path. For the extension examples, bsf.jar and (for the JavaScript extensions) js.jar must also be on the class
-      path.</li>
-     <li>Be sure the java executable is on your path.</li>
-     <li>Go to the samples subdirectory containing the sample (use the DOS shell if you are running Windows).</li>
-     <li>Run the sample from the command line (as indicated below).</li>
-    <li>Examine the application source files. You may also want to modify the source files. Remember that if you
-     modify a java file, you must recompile the class and place it on the classpath before you can run the
-     modified application.</li>
-     </ol>      
-    <p>The basic command line for running most of the samples is </p> 
-    <p><code>java <ref>classname args</ref></code></p>
-    <p>where <ref>classname</ref> is the sample class and <ref>args</ref> are the arguments, if any. As described in
-     the following sections, some samples take no arguments. The UseStylesheetParam sample takes an
-     additional argument. Several samples in extensions use the &xslt4j; 
-     <link idref="commandline">command-line utility</link>, so they take arguments for the XML source
-     file and the XSL stylesheet.</p>
-  	</s2><anchor name="simpletransform"/>
-    <s2 title="SimpleTransform">
-    <p>What it does: The SimpleTransform class uses the birds.xsl stylesheet to transform birds.xml, and prints the
-     output to birds.out.</p>
-    <p>You can run it from the SimpleTransform subdirectory with</p>
-    <p><code>java SimpleTransform</code></p>
-    </s2><anchor name="usestylesheetpi"/>
-    <s2 title="UseStylesheetPI">
-    <p>What it does: The UseStylesheetPI class uses the stylesheet processing instruction in the XML source document to determine
-     which stylesheet to use to perform the transformation.</p>
-     <p>You can run it from the UseStylesheetPI subdirectory with</p>
-     <p><code>java UseStylesheetPI</code></p>
-     <p>For more information, see <link idref="usagepatterns" anchor="embed">Working with embedded stylesheets</link>.</p>
-    </s2><anchor name="usestylesheetparam"/>
-    <s2 title="UseStylesheetParam">
-      <p>What it does: The UseStyleSheetParam class uses foo.xsl and a stylesheet parameter to transform foo.xml,
-       and prints the output to System.out. The stylesheet parameter appears as a text node in the output.</p>
-    <p>Run this sample from the UseStylesheetParam subdirectory with</p> 
-    <p><code>java UseStylesheetParam <ref>param</ref></code></p>
-    <p>where <ref>param</ref> is the stylesheet parameter value (a string of your choice).</p>  
-    </s2><anchor name="sax2sax"/>
-  <s2 title="SAX2SAX">
-  <p>What it does: Explicitly set the SAX XMLReader and SAX ContentHandler for processing the stylesheet (birds.xsl), processing the XML input (birds.xml), and producing the output (birds.out).</p>
-  <p>Run this sample from the SAX2SAX subdirectory with</p>
-   <p><code>java SAX2SAX</code></p>
-    </s2><anchor name="dom2dom"/>
-    <s2 title="DOM2DOM">
-    <p>What it does: the DOM2DOM class uses the birds.xsl stylesheet to transform a DOM Document generated from birds.xml,
-     produces an output DOM, and traverses the DOM, printing the traversal to System.out. In contrast to SimpleTransform,
-      DOM2DOM illustrates the procedure for processing an input DOM and creating an output DOM that is available for
-      further processing.</p>
-   <p>You can run it from the DOM2DOM subdirectory with</p>
-    <p><code>java DOM2DOM</code></p>
-    </s2><anchor name="pipe"/>
-    <s2 title="Pipe">
-    <p>What it does: Pipes the output from one transformation to a second transformation, then from the second
-    transformation to the third transformation. Transformer1 is the ContentHandler for the XMLReader (which parses the
-    input document). Transformer2 provides the ContentHandler for Transformer1, and Transformer3 for Transformer2.</p>
-    <note>Pipe and UseXMLFilters illustrate two strategies for using the output of one transformation as the input for
-    another transformation. The Pipe sample incorporates a "push" model -- Transformer1 "pushes" its output to
-    Transformer2, and so on -- whereas in the UseXMLFilters sample, Transformer3 "pulls" its input from Transformer2,
-    and so on.</note>
-    <p>Run this sample from the Pipe subdirectory with</p> 
-    <p><code>java Pipe</code></p>
-    </s2><anchor name="usexmlfilters"/>
-    <s2 title="UseXMLFilters">
-    <p>What it does: Chains together the same transformations as the preceding Pipe sample. Using each Transformer
-     object as an extension of the SAX XMLFilter interface, sets the XMLReader as the parent of Transformer1,
-     Transformer1 as the parent of Transformer2, and Transformer2 as the parent of of Transformer3.</p>
-      <p>Run this sample from the UseXMLFilters subdirectory with</p>
-   <p><code>java UseXMLFilters</code></p>
-    </s2><anchor name="applyxpath"/>
-    <s2 title="ApplyXPath">
-    <p>What it does: ApplyXPath uses the <jump href="apidocs/org/apache/xpath/XPathAPI.html">XPathAPI</jump> convenience methods to
-    execute an XPath expression against an XML document and return the nodes (if any) it finds.</p>
-     <note>You can use this sample as an aid when you want to find out what a given XPath expression returns from a
-     given XML file. Keep in mind that the context node (base point of evaluation) for the XPath expression is the document
-     root.</note>
-    <p>Run this sample from the ApplyXPath subdirectory with</p> 
-    <p><code>java ApplyXPath <ref>XMLFile XPathExpression</ref></code></p>
-    <p>where <ref>XMLFile</ref> is an XML source file and <ref>XPathExpression</ref> is an XPath expression to
-     apply to that file. The ApplyXPath subdirectory contains an XML file named foo.xml --<br/>
-     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;doc&gt;&lt;name first="David" last="Marston"/&gt;...&lt;/doc></code><br/> -- so you can try command
-     lines like</p>
-    <p><code>java ApplyXPath foo.xml /</code></p>
-    <p>and</p>
-    <p><code>java ApplyXPath foo.xml /doc/name/@first</code></p>
-    <p>For more information, see <link idref="usagepatterns" anchor="xpath">Working with XPath expressions</link>.</p>
-    </s2><anchor name="appletxmltohtml"/>
-    <s2 title="AppletXMLtoHTML">
-    <p>The applet uses a stylesheet to transform an XML document into HTML. It displays the XML document, the
-     stylesheet, and the HTML output.</p>
-    <p>How to run it: Open appletXMLtoHTML.hmtl in the Internet Explorer 5 browser.</p>
-    <note>This and the following sample applet do not work in the Netscape Communicator 4.7. We have some work to do to get
-    our basic strategy of using system properties to identify the Transformer and XML Parser to work in the Netscape applet
-    sandbox.<br/><br/>
-    Both applets look for xalan.jar and xerces.jar in the bin subdirectory. If you have placed these JAR files
-    elsewhere, adjust the applet archive setting in client.html and get-todo-list.html accordingly.</note>
-    </s2><anchor name="get-todo-list"/>
-    <s2 title="get-todo-list">
-    <p>This applet uses todo.xsl to transform todo.xml and display the result. The XML source (todo.xml) is a snapshot of an
-     ongoing list of tasks and task completions for the &xslt4j2; project that is maintained in the xml-xalan/java
-     subdirectory of the Apache CVS repository.</p>
-     <p>How to run it: Open get-todo-list.html in the Internet Explorer 5 browser.</p>
-    </s2><anchor name="servlet"/>
-    <s2 title="servlet">
-   <p>For a general introduction, see <link idref="usagepatterns" anchor="servlet">Using &xslt4j; in a servlet</link>.</p>
-    <p>The servlet subdirectory contains four sample servlets that use &xslt4j; to perform transformations. These servlets 
-    are in a package named servlet and are compiled in xalanservlet.jar. To run these samples, you must place 
-    xalanservlet.jar, and any XML and XSL files you want to use on a web server with a servlet engine, place 
-    xalanservlet.jar, xalan.jar, and xerces.jar on the servlet engine class path, and configure the servlet engine to
-    locate the XML and XSL files, and the properties file used by ApplyXSL.</p>
-    <p><link anchor="simplexsltservlet">servlet.SimpleXSLTServlet</link> applies a particular stylesheet to a particular 
-    XML document.</p> 
-    <p><link anchor="usestylesheetparamservlet">servlet.UseStylesheetParamServlet</link> sets a stylesheet parameter 
-    (the parameter name is hardwired into the servlet), and requires the user to supply parameters for the 
-    XML document and XSL stylesheet.</p>
-    <p><link anchor="xsltservletwithparams">servlet.XSLTServletWithParams</link> accepts parameters for the XML document, 
-    the XSL stylesheet, and any number of stylesheet parameters.</p>
-    <p><link anchor="applyxslt">servlet.ApplyXSLT</link> (and associated classes) is closer to a production level servlet. It accepts parameters, provides a 
-    listener for capturing and reporting debugger messages, and supports  use of a property file to determine which 
-    stylesheet to apply based on the identity of the client browser/device.</p>
-    <anchor name="simplexsltservlet"/>
-    <s3 title="servlet.SimpleXSLTServlet">
-    <p>What it does: servlet.SimpleXSLTServlet applies the todo.xsl stylesheet to todo.xml and returns the transformation result to the
-    HTTP client.</p>
-    <p>To run this servlet: place todo.xsl and todo.xml (from the distribution root directory) in the directory where your servlet engine
-    looks for HTTP documents, place xalanservlet.jar on the servlet engine classpath, and set up an HTML page to call the servlet as
-    follows:</p>
-<gloss><label>http://localhost/servlethome/servlet.SimpleXSLTServlet</label></gloss>
-     </s3><anchor name="usestylesheetparamservlet"/>
-     <s3 title="servlet.UseStylesheetParamServlet">
-     <note>Paul Campbell &lt;seapwc@halcyon.com&gt; wrote this servlet and the following explanatory text.
-     Thank you, Paul!</note>
-     <p>What it does: The client (perhaps an HTML form ) specifies an XML document, a stylesheet, and a value to be passed
-      to the stylesheet for a stylesheet parameter named "param1". The servlet performs the transformation and returns
-      the output to the client. The client must specify which stylesheet (containing a "param1" stylesheet parameter") 
-      and XML file are to be used.</p>
-     <p>How to run it: Configure your application server (Tomcat, Websphere or JServ, for example)
-     so it can find servlet.UseStylesheetParamServlet (in xalanservlet.jar) as well as the XML document 
-     and XSL stylesheet. For example, you can copy fooparam.xml and fooparam.xsl from samples/servlet to the application 
-     server root directory for documents.</p>
-     <p>Then you can set up an HTML client to call the servlet with arguments along the lines of</p>
-    <gloss><label>http://localhost/servlethome/servlet.UseStylesheetParamServlet?
-    XML=fooparam.xml&amp;XSL=fooparam.xsl&amp;PVAL=GoodBye</label></gloss>
-     <p>In the doGet() method, the servlet obtains the PVAL value "GoodBye") from the servlet request and passes it to the 
-     stylesheet as the paramValue argument in a Transformer setParameter() call:</p>
-      <p><code>String paramValue = httpServletRequest.getParameter("PVAL");</code><br/>
-      <code>...</code><br/>
-     <code>transformer.setParameter("param1", paramValue);</code></p>
- <p>The result is returned to the client:</p>
-<p><code>&lt;html&gt;&lt;body&gt;&lt;p&gt;GoodBye&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</code></p>
-     </s3><anchor name="xsltservletwithparams"/>
-     <s3 title="servlet.XSLTServletWithParams">
-     <p>What it does: servlet.XSLTServletWithParams takes parameters in the request -- a URL parameter for
-     the XML input document URL and an xslURL parameter for the stylesheet URL.</p>
-     <p>To use XSLTServletWithParams to perform the same transformation as SimplestServlet: 
-     place todo.xsl and todo.xml in the directory where your servlet engine looks for HTTP documents, place
-     xalanservlet.jar on the servlet engine classpath, and set up an HTML page to call the servlet as follows:</p>
-<gloss><label>http://localhost/servlethome/servlet.XSLTServletWithParams?URL=file:todo.xml&amp;
-xslURL=file:todo.xsl</label></gloss>
-     <p>If the XML document contains an associated stylesheet (a stylesheet Processing Instruction) that you want to use, simply omit the
-     xslURL parameter.</p>
-     <p>If the stylesheet takes stylesheet parameters, you can include them in the URL. For example to set set the param1
-     stylesheet parameter to foo, include param1=foo in the URL.</p>
-     </s3><anchor name="applyxslt"/>
-     <s3 title="servlet.ApplyXSLT">
-    <p>What it does: The client (which you must set up) specifies an XML document and a stylesheet. The servlet
-     performs the transformation and returns the output to the client. You can use media.properties to specify 
-    which stylesheet is to be used depending on the client browser/device.</p>
-    <note>The source files for this servlet include ApplyXSLT.java, ApplyXSLTProperties.java, DefaultApplyXSLTProperties.java,
-    ApplyXSLTListener.java, and ApplyXSLTException.java.</note>
-    <p>To run the servlet: put xalanservlet.jar on the servlet engine classpath, configure your servlet engine so it can find the 
-     stylesheets and properties file in the servlet subdirectory (and in xalanservlet.jar), and set up an HTML page to call
-     servlet.ApplyXSLT with arguments as illustrated below.</p>
-     <p>Examples:</p>
-<gloss>
-<label>http://localhost/servlethome/servlet.ApplyXSLT?URL=/data.xml&amp;xslURL=
-/style.xsl</label>
-<item>...applies the style.xsl stylesheet to the data.xml data. Both files are<br/>
-served from the Web server's HTTP document root.<br/><br/></item>
-<label>http://localhost/servlethome/servlet.ApplyXSLT?URL=/data.xml&amp;xslURL=
-/style.xsl&amp;debug=true</label>
-<item>...ensures that XML and XSL processor messages are returned in the event of problems
-applying style.xsl to data.xml<br/><br/></item>
-<label>http://localhost/servlethome/servlet.ApplyXSLT/data.xml?xslURL=/style.xsl</label>
-<item>...applies the style.xsl stylesheet to the data.xml data, just like the first example.
-This is an alternative way of specifying the XML XSLTInputSource by utilizing the HTTP request's path
-information.<br/><br/></item>
-<label>http://localhost/servlethome/servlet.ApplyXSLT/data.xml</label>
-<item>...examines data.xml for an associated XSL stylesheet (a stylesheet Processing Instruction). If multiple XSLs are associated with the data, the stylesheet whose media attribute maps to your browser type will be chosen.  If no mapping is successful, the primary associated stylesheet is used.<br/><br/></item>
-<label>http://localhost/servlet/data.xml</label>
-<item>...provides the same function as the previous example, but this example assumes
-that /servlet/data.xml has been mapped to be executed by this servlet.  The servlet engine may be configured
-to map all or some *.xml files to this servlet through the use of servlet aliases or filters.<br/><br/></item>
-<label>http://localhost/servlet/data.xml?catalog=http://www.xml.org/dtds/oag.xml</label>
-<item>...supplements any servlet-configured XCatalog
-with a catalog of supply chain DTDs residing at the XML.ORG DTD repository.</item>
-</gloss>     
-   </s3>
-     </s2><anchor name="extensions"/>
-    <s2 title="Extensions">
-    <p>For an introduction to the creation and use of extension elements and extension functions, and
-    for information about the extensions library distributed with &xslt4j;, see
-    <link idref="extensions">Extensions</link>.</p>
-    <ul>
-      <li><link anchor="ext1">1-redir</link></li>
-      <li><link anchor="ext2">2-basicJscript</link></li>
-      <li><link anchor="ext3">3-java-namespace</link></li>
-      <li><link anchor="ext4">4-numlistJava</link></li>
-      <li><link anchor="ext5">5-numlistJScript</link></li>
-      <li><link anchor="ext6">6-sqllib-instantdb</link></li>
-    </ul>
-    <p>The extensions subdirectory contains six samples with &xslt4j; extensions. Two of the samples use
-     extensions implemented in JavaScript, and four of the samples use extensions implemented in Java.</p>
-     <p>To run these examples, you must place bsf.jar (distributed with &xslt4j;), and js.jar
-      (version 1.5, available from 
-      <jump href="http://www.mozilla.org/rhino">http://www.mozilla.org/rhino</jump>) on the classpath. 
-     You do not need js.jar on the classpath for the samples that use Java extensions. </p>
-     <p>Use java.org.apache.xalan.xslt.Process, the &xslt4j; command-line utility, to run most of these samples from
-      the <link idref="commandline">command line</link>. The command line must include an -in flag with the 
-      XML source and an -xsl flag with the XSL stylesheet. If you want the output to be written to a file, rather
-      than to the screen, add an -out flag with the output file name.</p>
-      <p>Run these samples from the extensions directory as follows (each of the following is a single command
-       line):</p> 
-
-      <anchor name="ext1"/>
-      <s3 title="1-redir">
-      <p>What it does: Uses the Redirect extension elements shipped with &xslt4j; to direct output to two output
-        files.</p>
-      <p>Run this sample from the extensions subdirectory with</p> 
-       <p><code>java org.apache.xalan.xslt.Process -in 1-redir.xml</code><br/>
-       &nbsp;&nbsp;<code>-xsl 1-redir.xsl</code></p>
-      <p>The standard (non-redirected) output is written to the screen. The redirected output is written to 1-redir-out, or
-      whatever filename you assign to the doc/foo @file attribute in 1-redir.xml. The stylesheet gets the file name for
-      redirected output from the XML input file.</p>
-      </s3><anchor name="ext2"/>
-      <s3 title="2-basicJscript">
-      <p>What it does: Uses an extension element and extension function implemented in JavaScript to compute a
-      deadline for responding to a customer inquiry.</p>
-      <note>js.jar must be on the classpath.</note>
-      <p>Run this sample from the extensions subdirectory with</p>
-      <p><code>java org.apache.xalan.xslt.Process -in 2-basicJscript.xml</code>
-         <br/>&nbsp;&nbsp;<code>-xsl 2-jbasicJscript.xsl</code></p>     
-      </s3><anchor name="ext3"/>
-      <s3 title="3-java-namespace">
-      <p>What it does: Uses extension functions to format dates. This sample illustrates use of the predefined java
-        extension namespace to provide ready access to extensions implemented in Java.</p>
-      <p>Run this sample from the extensions subdirectory with</p> 
-      <p><code>java org.apache.xalan.xslt.Process -in 3-java-namespace.xml</code>
-         <br/>&nbsp;&nbsp;<code>-xsl 3-java-namespace.xsl</code></p>    
-      </s3><anchor name="ext4"/>
-      <s3 title="4-numlistJava">
-      <p>What it does: Uses a Java extension to transform a set of name elements into a numbered and alphabetized
-       list.</p>
-      <p>Run this sample from the extensions subdirectory with</p> 
-      <p><code>java org.apache.xalan.xslt.Process -in numlist.xml</code> 
-        <br/>&nbsp;&nbsp;<code>-xsl 4-numlistJava.xsl</code></p>    
-      </s3><anchor name="ext5"/>
-      <s3 title="5-numlistJscript">
-      <p>What it does: Uses a JavaScript  extension to transform a set of name elements into a numbered and
-      alphabetized list. This sample performs the same operations as the preceding Java extension.</p>
-      <note>js.jar must be on the classpath.</note>
-    <p>Run this sample from the extensions subdirectory with</p>
-      <p><code> java org.apache.xalan.xslt.Process -in numlist.xml</code>
-        <br/>&nbsp;&nbsp;<code>-xsl 5-numlistJscript.xsl</code></p>
-      </s3><anchor name="ext6"/>
-      <s3 title="6-sqllib-instantdb">
-      <p>What it does: Uses <link idref="extensionslib" anchor="sql">SQL library XConnection
-      extension</link> to connect to an InstantDB sample database, perform a query, and display the
-      query result in an HTML table.</p>
-      <note>You must include idb.jar on the classpath. We have placed a copy of idb.jar from
-      InstantDB version 3.25 in samples/extensions/instantdb. For information about InstantDB, see
-      <jump href="http://instantdb.enhydra.org/software/documentation/index.html">InstantDB</jump>
-      and the <jump href="http://instantdb.enhydra.org/software/license/index.html">Enydra Public
-      License</jump>.</note>
-      <p>Run this sample from the extensions subdirectory with (adjust the Windows classpath setting 
-      below for your operating environment):</p>
-      <p><code>java -cp instantdb/idb.jar;%classpath%</code> 
-      <br/>&nbsp;&nbsp;org.apache.xalan.xslt.Process<code></code>
-      <br/>&nbsp;&nbsp;<code>-xsl 6-sqllib-instantdb.xsl -out import1.html</code></p>
-      </s3>
-    </s2><anchor name="trace"/>
-    <s2 title="Trace">
-      <p>What it does: Trace uses the TraceListener and TraceManager classes to log transformation events.</p>
-      <p>Run this sample from the Trace subdirectory with</p>
-      <p><code>java Trace</code></p>
-      <p>and examine the result in events.log. For more information, see <link idref="usagepatterns" anchor="debugging">Debugger
-      Interface</link></p>
-     </s2><anchor name="trax"/>
-     <s2 title="trax">
-     <note>&traxsamplenote;</note>
-     <p>What it does: run a number of samples illustrating uses of the <resource-ref idref="trax"/> interfaces.</p>
-     <p>Run this sample from the trax subdirectory with</p>
-     <p><code>java Examples</code></p>
-     <p>and examine the source in Examples.java and ExampleContentHandler.java.</p>
-     </s2>
-</s1>
\ No newline at end of file
diff --git a/xdocs/sources/xalan/usagepatterns.xml b/xdocs/sources/xalan/usagepatterns.xml
deleted file mode 100644
index 0fc9312..0000000
--- a/xdocs/sources/xalan/usagepatterns.xml
+++ /dev/null
@@ -1,501 +0,0 @@
-<?xml version="1.0" standalone="no"?> 
-<!DOCTYPE s1 SYSTEM "../../style/dtd/document.dtd">
-<!--
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- -->
-<s1 title="Basic usage patterns">
-<ul>
-<li><link anchor="basic">Basic steps</link></li>
-<li><link anchor="plug">Plugging in the Transformer and XML parser</link></li>
-<li><link anchor="outputprops">Setting output properties in your stylesheets</link></li>
-<li><link anchor="embed">Working with embedded stylesheets</link></li>
-<li><link anchor="params">Setting stylesheet parameters</link></li>
-<li><link anchor="serialize">Serializing output</link></li>
-<li><link anchor="sax">Explicitly working with SAX</link></li>
-<li><link anchor="outasin">Using transformation output as input for another transformation</link></li>
-<li><link anchor="dom">Processing and producing DOM trees</link></li>
-<li><link anchor="xpath">Working with XPath expressions</link></li>
-<li><link anchor="applet">Using the &xslt4j; applet wrapper</link></li>
-<li><link anchor="servlet">Using &xslt4j; in a servlet</link></li>
-<li><link anchor="extensions">Creating and using extensions</link></li>
-<li><link anchor="multithreading">Multithreading</link></li>
-<li><link anchor="debugging">Debugger interface</link></li>
-<li><link anchor="compat">Using the &xslt4j; version 1 API</link></li>
-</ul>
-<anchor name="basic"/>
-  <s2 title="Basic steps">
-    <ol>
-    <li><link anchor="transformerfactory">Instantiate a TransformerFactory</link></li>
-    <li><link anchor="transformer">Process the stylesheet and generate a Transformer</link></li>
-    <li><link anchor="transformation">Perform the transformation</link></li>
-  </ol>
-    <p>The following example illustrates the three basic steps involved in performing a transformation.</p>
-    <source>// 1. Instantiate a TransformerFactory.
-javax.xml.transform.TransformerFactory tFactory = 
-                  javax.xml.transformerTransformerFactory.newInstance();
-
-// 2. Use the TransformerFactory to process the stylesheet Source and
-//    generate a Transformer.
-javax.xml.transform.Transformer transformer = tFactory.newTransformer
-                (new javax.xml.transform.stream.StreamSource("foo.xsl");
-
-// 3. Use the Transformer to transform an XML Source and send the
-//    output to a Result object.
-transformer.transform
-    (new javax.xml.transform.stream.StreamSource("foo.xml"), 
-     new javax.xml.transform.stream.StreamResult( new
-                                  java.io.FileOutputStream("foo.out")));</source>
-  <note>For a working example of this model at its simplest, see SimpleTransform.java in the java/samples/SimpleTransform subdirectory.</note>
-  </s2><anchor name="transformerfactory"/>
-  <s2 title="1. Instantiate a TransformerFactory">
-  <p><jump href="apidocs/javax/xml/transform/TransformerFactory#html">TransformerFactory</jump> is an abstract class with a static newInstance() method that instantiates the concrete subclass designated by the javax.xml.transform.TransformerFactory system property.</p>
-  <p>The default setting for this system property is <jump href="apidocs/org/apache/xalan/processor/TransformerFactoryImpl.html">org.apache.xalan.processor.TransformerFactoryImpl</jump>.</p>
-</s2><anchor name="transformer"/>
-  <s2 title="2. Use the TransformerFactory to process the stylesheet Source and produce a Transformer">
-<p>The TransformerFactory <jump href="apidocs/javax/xml/transform/TransformerFactory.html#newTransformer(javax.xml.transform.Source)">newTransformer(Source xslSource)</jump> method processes the stylesheet Source into a Templates object and returns a Transformer that you can use to perform a transformation (apply the Templates object to an XML Source).</p>
-<p>You may provide the stylesheet Source in the form of a stream of XML markup (<jump href="apidocs/javax/xml/transform/stream/StreamSource.html">StreamSource</jump>), a DOM Node (<jump href="apidocs/javax/xml/transform/dom/DOMSource.html">DOMSource</jump>), or a SAX InputSource (<jump href="apidocs/javax/xml/transform/sax/SAXSource.html">SAXSource</jump>). To specify a StreamSource, you may use a system ID or file name (using URI syntax), a java.io.InputStream, or a java.io.Reader. The use of DOMSource and SAXSource are illustrated in subsequent sections.</p>
-<note>If you plan to use the stylesheet Source to transform multiple XML Sources, you should use the TransformerFactory <jump href="apidocs/javax/xml/import/TransformerFactory.html#newTemplates(javax.xml.transform.Source)">newTemplates(Source xslSource)</jump> method to explicitly generate a Templates object. For each transformation, use the Templates object to generate a new Transformer. For the details, see <link anchor="multithreading">Multithreading</link>.</note>
-</s2><anchor name="transformation"/>
-<s2 title="3. Use the Transformer to perform a transformation">
-<p>Use the Transformer <jump href="apidocs/javax/xml/import/Transformer.html#transform(javax.xml.transform.Source, javax.xml.transform.Result">transform(Source xmlSource, Result transformResult)</jump> method to transform  the XML Source and place the transformation output in a Result object.</p>
-<p>Just as with the stylesheet, you can supply the XML Source in the form of a <jump href="apidocs/javax/xml/transform/stream/StreamSource.html">StreamSource</jump>, <jump href="apidocs/javax/xml/transform/dom/DOMSource.html">DOMSource</jump>, or <jump href="apidocs/javax/xml/transform/sax/SAXSource.html">SAXSource</jump>. Likewise, the Result may be a <jump href="apidocs/javax/xml/transform/stream/StreamResult.html">StreamResult</jump>, <jump href="apidocs/javax/xml/transform/dom/DOMResult.html">DOMResult</jump>, or <jump href="apidocs/javax/xml/transform/sax/SAXResult.html">SAXResult</jump>.</p>
-<p>For each node in the XML source, the Transformer uses the transformation instructions in the Templates object to determine which template to apply: one of the templates in the Templates object, a default template rule as specified in the XSLT spec, or none.</p>
-</s2><anchor name="plug"/>
-<s2 title="Plugging in a Transformer and XML parser">
-<p>The Java API for XML Processing interfaces enable you to isolate your application from the internal implementation details of a given Transformer, SAX parser, or DOM parser. For each of these objects, there is an abstract Factory class with a static newInstance() method that instantiates a concrete Factory which wraps the underlying implementation. These newInstance() methods use system property settings to determine which implementation to instantiate.</p>
-<p>&xslt4j; is distributed with system property settings for the Xalan XSLT Transformer and the Xerces DOM and SAX parsers. These settings are in xalan.jar in META-INF/services (see src/META-INF/services).</p>
-<gloss>
-  <label>System property</label>
-    <item>Setting</item>
-  <label><code>javax.xml.transform.TransformerFactory</code></label>
-   <item><code>org.apache.xalan.processor.TransformerFactoryImpl</code></item>    
-  <label><code>javax.xml.parsers.DocumentBuilderFactory</code></label>
-   <item><code>org.apache.xerces.jaxp.DocumentBuilderFactoryImpl</code></item>    
-  <label><code>javax.xml.parsers.SAXParserFactory</code></label>
-   <item><code>org.apache.xerces.jaxp.SAXParserFactoryImpl</code></item>
- </gloss>
-<p>You can change any of these settings as follows (in order of precedence):</p>
-<ol>
-  <li>Set the system property from the command line when you launch Java or from within your application.<br/><br/></li>
-  <li>Set the system property in jaxp.properties in the JAVA_HOME/lib directory, where JAVA_HOME is the root of the JDK.<br/><br/></li>
-  <li>Revise the entry in src/META-INF/services and rebuild xalan.jar.<br/><br/></li>
-</ol>
-<p>For more information about the mechanism used to determine system property values and how you can plug other implementations into your applications, see "Section 3: Plugability Layer" in the <ref>Java API for XML Processing</ref> at 
-<jump href="http://java.sun.com/aboutJava/communityprocess/review/jsr063/index.html">JSR-000063 1.1</jump>.</p> 
-</s2><anchor name="outputprops"/>
-<s2 title="Setting output properties in your stylesheets">
-<p>Output properties for XML, HTML, and Text transformation output are defined in property files in the org.apache.xalan.templates package.</p>
-<p>You can change these settings as follows:</p>
-<ol>
-  <li>Declare the xalan namespace in your stylesheet element (xmlns:xalan="http://xml.apache.org/xslt").<br/><br/></li>
-  <li>Use the namespace prefix you assign (we use "xalan" here in the text) to redefine properties of interest in the stylesheet xsl:output
-      element (for example, xalan:indent-amount="5").</li>
-</ol>
-  <p>If you want to change the property settings globally, edit the values in the property files in src/org/apache/xalan/templates, 
-  and use Ant to <link idref="readme" anchor="jar">rebuild xalan.jar</link>.</p>
-<p>The properties files define the following properties:</p>
-<p><ref>output_xml.properties</ref>:</p>
-<table>
-  <tr>
-    <th>Property</th>
-    <th>Default value</th>
-  </tr>  
-  <tr>
-    <td>xalan:indent-amount</td>
-    <td>0</td>
-  </tr>
-  <tr>
-    <td>xalan:content-handler</td>
-    <td>org.apache.xalan.serialize.SerializerToXML</td>
-  </tr>
-</table>
-<p><ref>output_html.properties</ref>:</p>
-<table>
-  <tr>
-    <th>Property</th>
-    <th>Default value</th>
-  </tr>  
-  <tr>
-    <td>xalan:indent-amount</td>
-    <td>0</td>
-  </tr>
-  <tr>
-    <td>xalan:content-handler</td>
-    <td>org.apache.xalan.serialize.SerializerToHTML</td>
-  </tr>
-  <tr>
-    <td>entities</td>
-    <td>HTMLEntities.res</td>
-  </tr>
-  <tr>
-    <td>xalan:use-url-escaping</td>
-    <td>yes</td>
-  </tr>
-</table>
-<note>You can also create your own HTML entity file (mapping characters to entities) 
-or edit src/org/apache/xalan/serialize/HTMLEntities.res and rebuild xalan.jar.</note>
-<p><ref>output_text.properties</ref>:</p>
-<table>  
-  <tr>
-    <th>Property</th>
-    <th>Default value</th>
-  </tr>
-  <tr>
-    <td>xalan:content-handler</td>
-    <td>org.apache.xalan.serialize.SerializerToText</td>
-  </tr>
-</table>
-<p>See also <link idref="readme" anchor="outputprops">Release Notes: Output Properties</link>.</p>
-</s2><anchor name="embed"/>
-<s2 title="Working with embedded stylesheets">
-<p>An XML Source may include an <jump href="http://www.w3.org/TR/xml-stylesheet/">xml-stylesheet processing instruction</jump> which identifies the stylesheet to be used to process the document. As indicated by the processing instruction <ref>href</ref> attribute, the stylesheet itself may be embedded in the XML document or located elsewhere.</p>
-<p>Suppose you have an XML document (foo.xml) with the following xml-stylesheet processing instruction:</p>
-<p><code>&lt;?xml-stylesheet type="text/xml" href="foo.xsl"?&gt;</code></p>
-<p>The following fragment, uses this instruction to locate the stylesheet (foo.xsl in the same directory as foo.xml) and create a Templates object. Note the use of the TransformerFactory getAssociatedStylesheet() in step 2a.</p>
-<note>An XML document may include more than one xml-stylesheet processing instruction, hence the support for working with multiple stylesheets. If more than one stylesheet is returned, the other stylesheets are imported into the first stylesheet.</note>
-<source>// 1. Instantiate the TransformerFactory.
-javax.xml.transform.TransformerFactory tFactory = 
-                    javax.xml.transform.TransformerFactory.newInstance();
-// 2a. Get the stylesheet from the XML source.
-String media = null , title = null, charset = null;
-javax.xml.transform.Source stylesheet = tFactory.getAssociatedStylesheet
-                   (new StreamSource("foo.xml"),media, title, charset);
-
-// 2b. Process the stylesheet and generate a Transformer.
-Transformer transformer = tFactory.newTransformer(stylesheet);
-
-// 3. Use the Transformer to perform the transformation and send the
-//    the output to a Result object.
-transformer.transform
-             (new javax.xml.transform.stream.StreamSource("foo.xml"),
-              new StreamResult (new java.io.FileOutputStream("foo.out")));</source>
-<p>For a sample that uses this technique, see <link idref="samples" anchor="usestylesheetpi">UseStylesheetPI</link>.</p>
-<p>You can also instruct the <link idref="commandline">command-line utility</link> to use stylesheet processing
-instructions:</p>
-<ol>
-  <li>Include the <code>-in</code> flag with an XML source that contains a stylesheet processing instruction.<br/><br/></li>
-  <li>Do not include the <code>-xsl</code> flag.</li>
-</ol>
-</s2><anchor name="serialize"/>
-<s2 title="Serializing output">
-<p>In some cases, you may want to "transform" a DOM tree into a stream, which the XML community calls serialization. <resource-ref idref="trax"/> and the &xslt4j; Transformer implementation provide direct support for this operation. Simply use the TransformerFactory newTransformer() method (no arguments) to create a Transformer that you can use to "copy" a DOMSource to a StreamResult. For examples, see Examples.exampleDOM2DOM(), Examples.exampleSerializeNode(), and Examples.exampleAsSerializer() in the <link idref="samples" anchor="trax">trax sample</link>.</p>
-</s2><anchor name="params"/>
-<s2 title="Setting stylesheet parameters">
-<p>An XSLT stylesheet may include parameters that are set at run time each time a transformation is performed. To set a stylesheet parameter, use the Transformer 
-<jump href="apidocs/javax/xml/transform/Transformer.html#setParameter(java.lang.String,java.lang.Object)">setParameter(String name, Object value)</jump> method. For a working example, see UseStylesheetParam.java in the samples/UseStylesheetParam subdirectory.</p>
-<p>You can also set a parameter with the command-line utility by including the <code>-param</code> flag. For example:</p>
-<p><code>java org.apache.xalan.xslt.Process -in foo.xml -xsl foo.xsl -param param1 foobar</code></p>
-<p>where <code>param</code> is the parameter name and <code>foobar</code> is the parameter value. The parameter namespace is null.</p>
-<note>&xslt4j2; processes string parameters. You are no longer required (as you were with &xslt4j; version 1) to enclose strings in single 
-quotes (') as string expressions.</note>
-</s2><anchor name="sax"/>
-<s2 title="Explicitly working with SAX">
-  <p>&xslt4j; uses the SAX event model to process stylesheets, to parse XML input documents, and to produce output. For each of these operations, an XMLReader reads input, firing parse events, and a ContentHandler listens to the XMLReader and executes parse event methods.</p>
-<p>When you use the basic procedure described above for performing transformations, &xslt4j; takes care of many of the SAX details under the covers. You are free to make these details explicit, which simply means that you can intervene in the procedure to accommodate the precise environment in which your application operates.</p>
-<p>Suppose, for example, you are using a custom XMLReader, perhaps doing more than just parsing static XML documents) to generate &xslt4j; SAX parse events. You might even have a custom reader for producing/processing stylesheets. You can cast the TransformerFactory to a SAXTransformerFactory, which provides access to a TransformerHandler, which you can set as the ContentHandler for this reader.</p>
-  <p>The following example explicitly sets up the XMLReader and ContentHandlers, and replicates the <link anchor="basic">basic steps</link> described above.</p>
-  <source>// Instantiate a TransformerFactory.
-javax.xml.transform.TransformerFactory tFactory = 
-                    javax.xml.transform.TransformerFactory.newInstance();
-// Verify that the TransformerFactory implementation you are using
-// supports SAX input and output (&xslt4j; does!).
-if (tFactory.getFeature(javax.xml.transform.sax.SAXSource.FEATURE) &amp;&amp; 
-    tFactory.getFeature(javax.xml.transform.sax.SAXResult.FEATURE))
-  { 
-    // Cast the TransformerFactory to SAXTransformerFactory.
-    javax.xml.transform.sax.SAXTransformerFactory saxTFactory = 
-                   ((javax.xml.transform.SAXTransformerFactory) tFactory);
-    // Create a Templates ContentHandler to handle parsing of the 
-    // stylesheet.
-    javax.xml.transform.sax.TemplatesHandler templatesHandler = 
-                                        saxTFactory.newTemplatesHandler();
-
-    // Create an XMLReader and set its ContentHandler.
-    org.xml.sax.XMLReader reader = 
-                   org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
-    reader.setContentHandler(templatesHandler);
-    
-    // Parse the stylesheet.                       
-    reader.parse("foo.xsl");
-
-    // Get the Templates object (generated during the parsing of the stylesheet)
-    // from the TemplatesHandler.
-    javax.xml.transform.Templates templates = 
-                                          templatesHandler.getTemplates();
-    // Create a Transformer ContentHandler to handle parsing of 
-    // the XML Source.  
-    javax.xml.transform.sax.TransformerHandler transformerHandler 
-                           = saxTFactory.newTransformerHandler(templates);
-    // Reset the XMLReader's ContentHandler to the TransformerHandler.
-    reader.setContentHandler(transformerHandler);
-
-    // Set the ContentHandler to also function as a LexicalHandler, which
-    // can process "lexical" events (such as comments and CDATA). 
-    reader.setProperty("http://xml.org/sax/properties/lexical-handler", 
-                        transformerHandler);
-
-    // Set up a Serializer to serialize the Result to a file.
-    org.apache.xalan.serialize.Serializer serializer = 
-    org.apache.xalan.serialize.SerializerFactory.getSerializer
-    (org.apache.xalan.templates.OutputProperties.getDefaultMethodProperties
-                                                                   ("xml"));
-    serializer.setOutputStream(new java.io.FileOutputStream("foo.out"));
-    // The Serializer functions as a SAX ContentHandler.
-    javax.xml.transform.Result result =
-      new javax.xml.transform.sax.SAXResult(serializer.asContentHandler());
-    transformerHandler.setResult(result);
-      
-    // Parse the XML input document.
-    reader.parse("foo.xml");</source>
-</s2><anchor name="outasin"/>
-<s2 title="Using transformation output as input for another transformation">
-
-<p>You can chain together a series of transformations such that the output of each transformation provides input for the next transformation. &xslt4j; supports two basic strategies for chaining a series of transformations:</p>
-<ul>
-  <li>Use the SAXTransformerFactory to process the stylesheet and create a TransformerHandler for each transformation. Then you can set
-the first TransformerHandler as the ContentHandler for the XMLReader that parses the input, make the second TransformerHandler the ContentHandler for the output of the first TransformerHandler, and so on. For more detail and an example, see the <link idref="samples" anchor="pipe">Pipe</link> sample.<br/><br/></li>
-  <li>Use the SAXTransformerFactory to process the stylesheet and create a SAX XMLFilter for each transformation. Set an XMLReader as the parent of the first XMLFilter, the first XMLFilter as the parent of the second XMLFilter, and so on. You launch the series of transformations by instructing the last XMLFilter to parse the XML Source for the first transformation. For more detail and an example, see the <link idref="samples" anchor="usexmlfilters">UseXMLFilters</link> sample.</li>
-</ul>
-</s2><anchor name="dom"/>
-<s2 title="Processing and producing DOM trees">
-  <p>In some cases, the input and/or desired output for a transformation may be a DOM tree object. The javax.xml.transform.DOM package provides <jump href="apidocs/javax/xml/transform/dom/DOMSource.html">DOMSource</jump> and a <jump href="apidocs/javax/xml/transform/dom/DOMResult.html">DOMResult</jump>, either or both of which you can use when you perform a transformation.</p>
-<p>In some cases, your application provides input in the form of a DOM tree, which accelerates the transformation process, since the input has in effect already been processed. To produce DOM input from a stream, you can use a <jump href="apidocs/javax/xml/parsers/DocumentBuilderFactory.html">DocumentBuilderFactory</jump> to produce a <jump href="apidocs/javax/xml/parsers/DocumentBuilder.html">DocumentBuilder</jump> with which you can parse the XML input into a DOM Document, as illustrated below.</p>
-<source>// Instantiate a DocumentBuilderFactory.
-javax.xml.parsers.DocumentBuilderFactory dfactory =
-                    javax.xml.parsers.DocumentBuilderFactory.newInstance();
-// Use the DocumentBuilderFactory to provide access to a DocumentBuilder.
-javax.xml.parsers.DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
-// Use the DocumentBuilder to parse the XML input.
-org.w3c.dom.Document inDoc = dBuilder.Parse("foo.xml");</source>
-<p>To produce DOM output, simply use a Transformer to transform to a DOMResult object.</p>
-<source>// Generate a Transformer.
-javax.xml.transform.Transformer transformer = tFactory.newTransformer
-                  (new javax.xml.transform.Stream.StreamSource("foo.xsl"));
-// Create an empy DOMResult object for the output.
-javax.xml.transform.dom.DOMResult domResult =
-                                   new javax.xml.transform.dom.DOMResult();
-// Perform the transformation.
-transformer.transform(new javax.xml.transform.dom.DOMSource(inDoc)
-                      domResult;
-// Now you can get the output Node from the DOMResult.
-org.w3c.dom.Node node = domResult.getNode();</source>
-<note>Create a new DOMResult object or use DOMResult.setNode() to assign a new container each time you want to perform a transformation 
-and place the output in a DOMResult object.</note>
-<p>The <link idref="samples" anchor="dom2dom">DOM2DOM</link> illustrates both procedures, and serializes the DOMResult to System.out.</p>
-</s2><anchor name="xpath"/>
-<s2 title="Working with XPath expressions">
-<p>XSLT stylesheets use XPath expressions to select nodes, specify conditions, and generate text for the result tree. XPath provides an API that you can call directly. For example, you may want to select nodes programmatically and do your own processing without a stylesheet.</p>
-<p>XPath is an independent entity, with clients other than XSLT processors (such as XPointer). Accordingly, &xslt4j2; has packaged XPath as a separate module (org.apache.xpath and its subpackages), although concurrently this module does use some utility classes packaged in org.apache.xalan.utils. The org.apache.xpath.XPathAPI class contains convenience methods that you can use to return single DOM Nodes, NodeIterators, and XObjects. Apart from their own functionality, these methods also provide a path into the lower-level XPath API that you may find useful.</p>
-<p>For an example that uses the XPathAPI convenience methods to execute XPath expressions against XML source files, see <link idref="samples" anchor="applyxpath">ApplyXPath</link>.</p>
-</s2><anchor name="applet"/>
-<s2 title="Using the &xslt4j; applet wrapper">
-<ol> 
-<li>Include <jump href="apidocs/org/apache/xalan/client/XSLTProcessorApplet.html">XSLTProcessorApplet</jump> in an HTML client.<br/><br/></li>
-<li>Specify the XML source document and XSL stylesheet.<br/><br/>
-You can use the DocumentURL and StyleURL PARAM tags or the <jump href="apidocs/org/apache/xalan/client/XSLTProcessorApplet.html#setDocumentURL(java.lang.String)">setdocumentURL()</jump> and <jump href="apidocs/org/apache/xalan/client/XSLTProcessorApplet.html#setStyleURL(java.lang.String)">setStyleURL()</jump> methods. If the XML document contains a stylesheet Processing Instruction (PI), you do not need to specify an XSL stylesheet.<br/><br/></li>
-<li>Call the <jump href="apidocs/org/apache/xalan/client/XSLTProcessorApplet.html#transformToHtml(java.lang.String,java.lang.String)">transformToHtml()</jump> or <jump href="apidocs/org/apache/xalan/client/XSLTProcessorApplet.html#getHtmlText()">getHtmlText()</jump> method, which performs the transformation and returns the new document as a String.</li></ol>
-<note>The transformToHTML() method takes arguments for the XML source document and XSL stylesheet. The getHtmlText() method takes no arguments: it uses property or parameter settings, as in the example below.</note>
-<p>For an example, see the <link idref="samples" anchor="appletxmltohtml">AppletXMLtoHTML</link> sample applet. The &lt;applet&gt; tag is in samples/AppletXMLtoHTML/client.html:</p>
-<source>&lt;applet  
-    name="xslControl"
-    code="org.apache.xalan.client.XSLTProcessorApplet.class"
-    archive="../../bin/xalan.jar,../../bin/xerces.jar"
-    height="0"
-    width"0">
-    &lt;param name="documentURL" value="xalanApplets.xml"/&gt;
-    &lt;param name="styleURL" value="s1ToHTML.xsl"/&gt;
-&lt;/applet&gt;</source>
-<p>When the user clicks the Transform button, the HTML client calls the getHtmlText() method, and puts the returned HTML text in a frame for the user to view.</p>
-
-</s2><anchor name="servlet"/>
-<s2 title="Using &xslt4j; in a servlet">
-<p>You can set up a servlet to use &xslt4j; to respond to requests for XML documents by transforming those documents into HTML and serving them to web browsers. To respond to HTTP GET requests, all you need to do is overwrite the HttpServlet doGet() method with a procedure that instantiates a Transformer and uses it to perform a transformation. As the following example shows, you can generate a ResultStream that a PrintWriter writes to the HttpResponse OutputStream, returning the transformation output to the web browser.</p>
-<source>
-public class SampleXSLTServlet extends javax.servlet.http.HttpServlet {
-  
-  // Respond to HTTP GET requests from browsers.
-  public void doGet (javax.servlet.http.HttpServletRequest request,
-                     javax.servlet.http.HttpServletResponse response)
-    throws javax.servlet.ServletException, java.io.IOException
-  {
-    // Output goes in the response stream.
-    java.io.PrintWriter out = 
-                         new java.io.PrintWriter(response.getOutputStream());
-    // Set content type for HTML.
-    response.setContentType("text/html");    
-    try
-    {	
-      javax.xml.transform.TransformerFactory tFactory = 
-                javax.xml.transform.TransformerFactory.newInstance();
-      // Get the XML input document and the stylesheet, both in the servlet
-      // engine document directory.
-      javax.xml.transform.Source xmlSource = 
-                new javax.xml.transform.stream.StreamSource
-                             (new java.net.URL("file:foo.xml").openStream());
-      javax.xml.transform.Source xslSource = 
-                new javax.xml.transform.stream.StreamSource
-                             (new java.net.URL("file:foo.xsl").openStream());
-      // Generate the transformer.
-      javax.xml.transform.Transformer transformer = 
-                             tFactory.newTransformer(xslSource);
-      // Perform the transformation, sending the output to the response.
-      transformer.transform(xmlSource, 
-                           new javax.xml.transform.stream.StreamResult(out));
-    }
-    // If an Exception occurs, return the error to the client.
-    catch (Exception e)
-    {
-      out.write(e.getMessage());
-      e.printStackTrace(out);    
-    }
-    // Close the PrintWriter.
-    out.close();
-  }  
-}</source>
-<p>For a working sample, see <link idref="samples" anchor="simplexsltservlet">SimpleXSLTServlet</link>.</p>
-<p>In the preceding example, the URLs for the XML document and XSL stylesheet are hardcoded in the servlet. You can also create a servlet that parses the request URL for input parameters specifying the XML document, XSL stylesheet, and any relevant stylesheet parameters. For samples, see <link idref="samples"
-anchor="usestylesheetparamservlet">UseStylesheetParamServlet</link> and <link idref="samples" anchor="xsltservletwithparams">XSLTServletWithParams</link>. For a more robust and complex sample that also employs a properties file to determine which stylesheet to use depending on the client browser/device, see <link idref="samples" anchor="applyxslt">ApplyXSLT</link>.</p>
-</s2><anchor name="extensions"/>
-<s2 title="Creating and using extensions">
-<p>For those cases where you want to be able to call procedural code from within a stylesheet, the &xslt4j; Extensions facility supports the creation of extension elements and extension functions. See <link idref="extensions">Extensions</link> and <link idref="samples" anchor="extensions">Extensions samples</link>.</p>
-</s2><anchor name="multithreading"/>
-<s2 title="Multithreading">
-<p>A given Templates object may be used repeatedly and even in multiple threads running concurrently for the transformation of XML input, but you should use the Templates object to instantiate a separate Transformer for each transformation you perform. The Templates object is an immutable runtime representation of the structure and content of a stylesheet (which may include and import multiple stylesheet sources). A Transformer, on the other hand, is a lightweight object that tracks state information during the transformation, and should only be used to perform a single transformation.</p>
-
-<p>If you want to perform multiple transformations (sequentially or concurrently) with the same stylesheet instructions, do the following:</p>
-<ol>
-  <li>Use the TransformerFactory <jump href="apidocs/javax/xml/transform/TransformerFactory.html#newTemplates(javax.xml.transform.Source)">newTemplates(Source xslSource)</jump> method to create a Templates object.<br/><br/></li>
-<li>For each transformation, use the Templates object <jump href="apidocs/javax/xml/transform/Templates.html#newTransformer()">newTransformer()</jump> method to create a Transformer, and use that Transformer's <jump href="apidocs/javax/xml/transform/Transformer.html#transform(javax.xml.transform.Source, javax.xml.transform.Result)">transform(Source xmlSource, Result transformResult)</jump> method to perform the transformation.</li>
-</ol>
-<p>For an example, see Examples.exampleUseTemplatesObj() in the <link idref="samples" anchor="trax">trax sample</link>.</p>
-</s2><anchor name="debugging"/>
-<s2 title="Debugger Interface">
-		<p>&xslt4j; contains a debugger interface in the org.apache.xalan.xslt.trace package:</p> 
-		<ul>
-		  <li><jump href="apidocs/org/apache/xalan/trace/TraceListener.html">TraceListener</jump> is an interface that debuggers 
-		  can implement. Or, like the <link idref="commandline">command-line utility</link>, you can use the <jump
-      href="apidocs/org/apache/xalan/trace/PrintTraceListener.html">PrintTraceListener</jump> implementation of that interface.
-      <br/><br/></li>
-      <li>You can register a TraceListener with the 
-      <jump href="apidocs/org/apache/xalan/trace/TraceManager.html">TraceManager</jump> associated
-      with the Transformer that will perform a given transformation.<br/><br/></li>
-		  <li><jump href="apidocs/org/apache/xalan/trace/TracerEvent.html">TracerEvent</jump> is an event that is 
-		  passed to the TraceListener.trace function. It is called before a node is 'executed' in the stylesheet.<br/><br/></li>
-		  <li><jump href="apidocs/org/apache/xalan/trace/GenerateEvent.html">GenerateEvent</jump> is an event that is 
-		  passed to the TraceListener.generated() function. It is called after an event occurs to create something in the result
-      tree.<br/><br/></li>
-      <li><jump href="apidocs/org/apache/xalan/trace/SdelectionEvent.html">SelectionEvent</jump> is an event triggered by the
-       selection of a stylesheet node.</li>
-		</ul>
-    <p>The <link idref="commandline">command-line utility</link> uses the debugger interface when you include one or more of the
-     following switches: <code>-TT</code>, <code>-TG</code>, <code>-TS</code>, <code>-TTC</code>.</p>
-    <p>Example:</p>
-<source>import org.apache.xalan.transformer.TransformerImpl;
-import org.apache.xalan.trace.TraceManager;
-import org.apache.xalan.trace.PrintTraceListener;
-...
-// Set up a PrintTraceListener object to print to a file.
-java.io.FileWriter fw = new java.io.FileWriter("events.log");
-java.io.PrintWriter pw = new java.io.PrintWriter(fw);
-PrintTraceListener ptl = new PrintTraceListener(pw);
-
-// Print information as each node is 'executed' in the stylesheet.
-ptl.m_traceElements = true;
-// Print information after each result-tree generation event.
-ptl.m_traceGeneration = true;
-// Print information after each selection event.
-ptl.m_traceSelection = true;
-// Print information whenever a template is invoked.
-ptl.m_traceTemplates = true;
-
-// Set up the transformation    
-javax.xml.transform.TransformerFactory tFactory = 
-                     javax.xml.trnasform.TransformerFactory.newInstance();
-javax.xml.transform.Transformer transformer = 
-  tFactory.newTransformer(new javax.xml.transform.stream.StreamSource
-                                                             ("foo.xsl"));
-
-// Cast the Transformer object to TransformerImpl.
-if (transformer instanceof TransformerImpl) {
-  TransformerImpl transformerImpl = (TransformerImpl)transformer;
-  
-  // Register the TraceListener with the TraceManager associated 
-  // with the TransformerImpl.
-  TraceManager trMgr = transformerImpl.getTraceManager();
-  trMgr.addTraceListener(ptl);
-  
-  // Perform the transformation --printing information to
-  // the events log during the process.
-  transformer.transform
-      ( new javax.xml.transform.stream.StreamSource("foo.xml"), 
-        new javax.xml.transform.stream.StreamResult
-                                    (new java.io.FileWriter("foo.out")) );
-}
-// Close the PrintWriter and FileWriter.
-pw.close();
-fw.close();</source>
-<p>For a sample application that uses this technique, see <link idref="samples" anchor="trace">Trace</link>.</p>
-</s2><anchor name="compat"/>
-<s2 title="Using the &xslt4j; version 1 API">
-<p>The bin directory includes a compatibility jar, xalanj1compat.jar, that lets you rebuild your Xalan-Java 1.x applications to run with Xalan-Java 2. As a point of reference, this JAR includes the API required to recompile the Xalan-Java 1.x core sample applications (excluding the sample extensions) and run them with Xalan-Java 2. To use this compatibility layer with an existing Xalan-Java 1.x application, do the following:</p>
-<ol>
-<li>Place xalanj1compat.jar on the system classpath in front of the Xalan-Java 2 xalan.jar (both are in the bin directory).<br/><br/></li>
-<li>Recompile your application. It it does not compile, you may be using Xalan-Java 1.x API that the compatibility layer does not support. <br/><br/></li>
-<li>Run the recompiled application with xalanj1compat.jar on the system classpath in front of the Xalan-Java 2 xalan.jar.</li>
-</ol>
-<p>We urge our Xalan-Java 1.x users to start using Xalan-Java 2. That is where we are concentrating our efforts to improve performance and fix any outstanding bugs. To see what portion of the Xalan-Java 1.x API we have included in xalanj1compat.jar, see <resource-ref idref="compatapi"/>. For example, the compatibility layer does not support the use of Xalan-Java 1.x extensions. If you feel that we should extend our compatibility JAR to support additional Xalan-Java 1.x API calls, please let us know exactly what you would like to see.</p>
-</s2>
-</s1>
\ No newline at end of file
diff --git a/xdocs/sources/xalan/whatsnew.xml b/xdocs/sources/xalan/whatsnew.xml
deleted file mode 100644
index 9a4eb46..0000000
--- a/xdocs/sources/xalan/whatsnew.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" standalone="no"?>
-<!DOCTYPE s1 SYSTEM "../../style/dtd/document.dtd">
-<!--
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- -->
-<s1 title="What's new in &xslt4j2;">
-
-  <s2 title="New Design">
-  <p>&xslt4j2; represents a fundamental redesign of Xalan. The primary objective of this redesign is an easier-to-use, more understandable, and more modular API that encourages wider participation in its ongoing development by the open-source XML developer community, and that lends itself to "streaming," the production of transformation output while the input is still being parsed.</p>
-<p>&xslt4j2; builds on <resource-ref idref="sax2"/>, <resource-ref idref="dom2"/>, and the <resource-ref idref="jaxp"/>. For example, &xslt4j2; incorporates the SAX parsing event model in its support for the incremental production of transformation output. &xslt4j2; also implements the  standard TrAX API (see below) that enables you to code your XML applications without reference to the internal details of a particular Transformer or XML parser.</p>
-<p>Given the scope of the redesign, the changes with respect to <jump href="http://xml.apache.org/xalan/index.html">&xslt4j; 1.x</jump> are global in nature. For an introduction to the &xslt4j2; usage patterns, see <link idref="usagepatterns">Basic Usage Patterns</link>.</p>
-<p>&xslt4j2; implements the <resource-ref idref="trax"/> interfaces. The product of extensive open-source collaboration by members of the XML developer community, TrAX provides a conceptual framework and a standard API for performing XML transformations. During its evolution, the TrAX API has undergone several revisions. We believe this API has now reached or is very close to final form. In November 2000, TrAX was incorporated into <resource-ref idref="jsr063"/>, the Java API for XML Processing 1.1 , which has been published for public review (see <resource-ref idref="jaxp11"/>). We strongly encourage you to utilize the TrAX framework when you use &xslt4j2; to perform XML transformations.</p>
-<p>The basic organization of TrAX is quite simple: use a TransformerFactory to process transformation instructions and generate a Transformer, with which you can apply the processed transformation instructions to your XML Source, producing a transformation Result. For more detail, see <link idref="usagepatterns" anchor="basic">Basic steps</link>.</p>
-<p>As part of the Java API for XML Processing, TraX provides a stable framework for plugging Transformers (like &xslt4j;) and XML parsers (like &xml4j;) into your applications without tying yourself to the internal details of those implementations. See <link idref="usagepatterns" anchor="plug">Plugging in a Transformer and XML parser</link>.</p>
-</s2>
-</s1>
\ No newline at end of file
diff --git a/xdocs/sources/xalandesign.xml b/xdocs/sources/xalandesign.xml
deleted file mode 100644
index 702da28..0000000
--- a/xdocs/sources/xalandesign.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE book SYSTEM "sbk:/style/dtd/book.dtd">
-
-<!--
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 2000 The Apache Software Foundation.  All rights 
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xalan" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 2000, Lotus
- * Development Corporation., http://www.lotus.com.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- -->
-
-<book title="Xalan 2.0.0 Design" copyright="2000 The Apache Software Foundation">
- 
-  <document id="design2_0_0"
-            label="Xalan-J 2.0.0 Design"
-            source="design/design2_0_0.xml"/>    
-</book>
-  
\ No newline at end of file
diff --git a/xdocs/style/dtd/spec.dtd b/xdocs/style/dtd/spec.dtd
deleted file mode 100644
index 8720289..0000000
--- a/xdocs/style/dtd/spec.dtd
+++ /dev/null
@@ -1,578 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- ============================================================= -->
-<!--  MODULE:    spec DTD                                          -->
-<!--  VERSION:   1.0                                               -->
-<!--  DATE:      October 18, 2000                                  -->
-
-
-<!-- ============================================================= -->
-<!--                   ISO STANDARD SPECIAL CHARACTER SETS         -->
-<!-- ============================================================= -->
-<!--
-<!ENTITY % isolat1      PUBLIC
-"ISO 8879-1986//ENTITIES Added Latin 1//EN"
-"entities/ISOlat1.pen"
-                                                                    >
-
-<!ENTITY % isonum       PUBLIC
-"ISO 8879-1986//ENTITIES Numeric and Special Graphic//EN"
-"entities/ISOnum.pen"
-                                                                    >
-
-<!ENTITY % isopub       PUBLIC
-"ISO 8879-1986//ENTITIES Publishing//EN"
-"entities/ISOpub.pen"
-                                                                    >
-
-<!ENTITY % isotech      PUBLIC
-"ISO 8879-1986//ENTITIES General Technical//EN"
-"entities/ISOtech.pen"
-                                                                    >
-
-%isolat1; %isonum; %isopub; %isotech;
--->
-
-<!-- ============================================================= -->
-<!--                    parameter entities for content models      -->
-<!-- ============================================================= -->
-
-
-<!--                    list elements                              -->
-<!ENTITY % lists       "itemizedlist | orderedlist | variablelist"   >
-
-
-<!--                    linespecific elements                      -->
-<!--                    elements where line endings and whitespace
-                        are significant                            -->
-<!ENTITY % linespecific
-                       "literallayout | programlisting"              >
-
-
-<!--                    phrase-level elements                      -->
-<!--                    elements allowed at the same level as text -->
-<!ENTITY % phraselevel "citation | emphasis | inlinegraphic | link | plink |
-                        subscript | superscript | ulink | termref"   >
-
-
-<!--                    paragraph-level elements                   -->
-<!--                    elements (including paragraphs) allowed at
-                        the level of paragraphs                    -->
-<!ENTITY % paralevel   "%linespecific; | %lists; | note | para | issue |
-                        table | figure | graphic"                    >
-
-
-<!-- ============================================================= -->
-<!--                    parameter entities for attributes          -->
-<!-- ============================================================= -->
-
-
-<!--                    common attributes                          -->
-<!ENTITY % common.atts
-             "id         ID                                 #IMPLIED
-              link-url   CDATA                              #IMPLIED" >
-
-<!--                    graphic-related attributes                 -->
-<!ENTITY % graphic.atts
-            "fileref    CDATA                              #IMPLIED
-             alt        CDATA                              #IMPLIED
-             srccredit  CDATA                              #IMPLIED
-             width      NMTOKEN                            #IMPLIED
-             depth      NMTOKEN                            #IMPLIED
-             scale      NMTOKEN                            #IMPLIED
-             scalefit   NMTOKEN                            #IMPLIED" >
-
-<!-- ============================================================= -->
-<!--                    external modules                           -->
-<!-- ============================================================= -->
-
-<!--
-<!ENTITY % table.ent SYSTEM "table.ent"                              >
-%table.ent;
--->
-
-<!-- ============================================================= -->
-<!--                    element definitions                        -->
-<!-- ============================================================= -->
-
-
-<!--                    specification                              -->
-<!ELEMENT  spec         (title, frontmatter, introduction, requirements, model, sect1+,
-                         appendix*, bibliography?)                   >
-
-<!ATTLIST  spec
-            %common.atts;                                            >
-
-<!ELEMENT  frontmatter   (pubdate, copyright, author*, abstract?)    >
-
-<!--                    title                                      -->
-<!ELEMENT  title        (#PCDATA | %phraselevel;)*                   >
-<!ATTLIST  title
-            %common.atts;                                            >
-
-
-<!--                    issue                                      -->
-<!ELEMENT  issue        (#PCDATA | %phraselevel;)*                   >
-<!ATTLIST  issue
-            %common.atts;                                            >
-
-
-<!--                    publication date                           -->
-<!--                    publication date and, possibly, time       -->
-<!ELEMENT  pubdate      (#PCDATA)                                    >
-<!ATTLIST  pubdate
-            %common.atts;                                            >
-
-
-<!--                    copyright statement                        -->
-<!ELEMENT  copyright    (#PCDATA)                                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  copyright
-            %common.atts;                                            >
-
-
-<!--                    author                                     -->
-<!ELEMENT  author       (firstname, surname, jobtitle?, orgname?,
-                         address?)                                   >
-<!--         id         unique identifier                          -->
-<!ATTLIST  author
-            %common.atts;                                            >
-
-
-<!--                    abstract                                   -->
-<!ELEMENT  abstract     (para+)                                      >
-<!--         id         unique identifier                          -->
-<!ATTLIST  abstract
-            %common.atts;                                            >
-
-<!ELEMENT  introduction        (title, (((%paralevel;)+, sect2*) | sect2+)) >
-<!--         id         unique identifier                          -->
-<!ATTLIST  introduction
-            %common.atts;                                            >
-
-<!ELEMENT  requirements        (title, (((%paralevel;)+, sect2*) | sect2+)) >
-<!--         id         unique identifier                          -->
-<!ATTLIST  requirements
-            %common.atts; >    
-
-<!ELEMENT  model        (title, (((%paralevel;)+, patterns) | sect2+)) >
-<!--         id         unique identifier                          -->
-<!ATTLIST  model
-            %common.atts;                                            >
-
-<!ELEMENT  patterns        (pattern+) >
-<!--         id         unique identifier                          -->
-<!ATTLIST  patterns
-            %common.atts; 
-			module  CDATA                              #IMPLIED
-            > 
-                        
-<!ELEMENT  pattern        (pattern-name, potential-alternate-name?, intent, responsibilities, thread-safety, notes?) >
-<!--         id         unique identifier                          -->
-<!ATTLIST  pattern
-            %common.atts;  
-                                                      >
-<!ELEMENT  pattern-name        (#PCDATA | %phraselevel;)* >
-<!--         id         unique identifier                          -->
-<!ATTLIST  pattern-name
-            %common.atts; >
-            
-<!ELEMENT  potential-alternate-name        (#PCDATA | %phraselevel;)* >
-<!--         id         unique identifier                          -->
-<!ATTLIST  potential-alternate-name
-            %common.atts; >  
-
-<!ELEMENT  intent        (#PCDATA | %phraselevel;)* >
-<!--         id         unique identifier                          -->
-<!ATTLIST  intent
-            %common.atts; >  
-
-<!ELEMENT  responsibilities        (#PCDATA | %phraselevel;)* >
-<!--         id         unique identifier                          -->
-<!ATTLIST  responsibilities
-            %common.atts; >  
-
-<!ELEMENT  thread-safety        (#PCDATA | %phraselevel;)* >
-<!--         id         unique identifier                          -->
-<!ATTLIST  thread-safety
-            %common.atts; >
-
-<!ELEMENT  notes         (#PCDATA | %phraselevel;)*                   >
-<!--         id         unique identifier                          -->
-<!ATTLIST  notes
-            %common.atts;                                            >
-
-<!--         id         unique identifier                          -->
-<!ATTLIST  sect1
-            %common.atts;                                            >
-
-<!--                    section 1                                  -->
-<!ELEMENT  sect1        (title, (((%paralevel;)+, sect2*) | sect2+)) >						   
-<!--                    section 2                                  -->
-<!ELEMENT  sect2        (title, (((%paralevel;)+, sect3*) | sect3+)) >
-<!--         id         unique identifier                          -->
-<!ATTLIST  sect2
-            %common.atts;                                            >
-
-
-<!--                    section 3                                  -->
-<!ELEMENT  sect3        (title, (((%paralevel;)+, sect4*) | sect4+)) >
-<!--         id         unique identifier                          -->
-<!ATTLIST  sect3
-            %common.atts;                                            >
-
-
-<!--                    section 4                                  -->
-<!ELEMENT  sect4        (title, (%paralevel;)+)                      >
-<!--         id         unique identifier                          -->
-<!ATTLIST  sect4
-            %common.atts;                                            >
-
-
-<!--                    appendix                                   -->
-<!ELEMENT  appendix     (title, (((%paralevel;)+, sect1*) | sect1+)) >
-<!--         id         unique identifier                          -->
-<!ATTLIST  appendix
-            %common.atts;                                            >
-
-
-<!--                    bibliography                               -->
-<!ELEMENT  bibliography (title, biblioitem+)                         >
-<!--         id         unique identifier                          -->
-<!ATTLIST  bibliography
-            %common.atts;                                            >
-
-
-<!--                    bibliography item                          -->
-<!ELEMENT  biblioitem   (designator, biblioentry)                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  biblioitem
-            %common.atts;                                            >
-
-
-<!--                    bibliography item designator               -->
-<!--                    designator contains whatever designator the
-                        author uses to identify publications listed in
-                        the bibliography (e.g., [lab 87]).  the
-                        stylesheet generates the square "[]" brackets
-                        fore & aft.                                -->
-<!ELEMENT  designator   (#PCDATA)                                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  designator
-            %common.atts;                                            >
-
-
-<!--                    bibliography entry                         -->
-<!ELEMENT  biblioentry  (#PCDATA | %phraselevel;)*                   >
-<!--         id         unique identifier                          -->
-<!ATTLIST  biblioentry
-            %common.atts;                                            >
-
-
-<!-- ============================================================= -->
-<!--                    author-related elements                    -->
-<!-- ============================================================= -->
-
-
-<!--                    first name                                 -->
-<!ELEMENT  firstname    (#PCDATA)                                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  firstname
-            %common.atts;                                            >
-
-
-<!--                    surname                                    -->
-<!ELEMENT  surname      (#PCDATA)                                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  surname
-            %common.atts;                                            >
-
-
-<!--                    job title                                  -->
-<!ELEMENT  jobtitle     (#PCDATA)                                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  jobtitle
-            %common.atts;                                            >
-
-
-<!--                    organization name                          -->
-<!ELEMENT  orgname      (#PCDATA)                                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  orgname
-            %common.atts;                                            >
-
-
-<!--                    address                                    -->
-<!ELEMENT  address      (street?, pob?, city?, state?, postcode?, 
-                         country?, phone?, fax?, email?)             >
-<!--         id         unique identifier                          -->
-<!ATTLIST  address
-            %common.atts;                                            >
-
-
-<!-- ============================================================= -->
-<!--                    address elements                           -->
-<!-- ============================================================= -->
-
-
-<!--                    street address                             -->
-<!ELEMENT  street       (#PCDATA)                                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  street
-            %common.atts;                                            >
-
-
-<!--                    post office box                            -->
-<!ELEMENT  pob          (#PCDATA)                                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  pob
-            %common.atts;                                            >
-
-
-<!--                    postcode                                   -->
-<!ELEMENT  postcode     (#PCDATA)                                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  postcode
-            %common.atts;                                            >
-
-
-<!--                    city                                       -->
-<!ELEMENT  city         (#PCDATA)                                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  city
-            %common.atts;                                            >
-
-
-<!--                    state                                      -->
-<!ELEMENT  state        (#PCDATA)                                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  state
-            %common.atts;                                            >
-
-
-<!--                    country                                    -->
-<!ELEMENT  country      (#PCDATA)                                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  country
-            %common.atts;                                            >
-
-
-<!--                    phone number                               -->
-<!ELEMENT  phone        (#PCDATA)                                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  phone
-            %common.atts;                                            >
-
-
-<!--                    fax number                                 -->
-<!ELEMENT  fax          (#PCDATA)                                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  fax
-            %common.atts;                                            >
-
-
-<!--                    email address                              -->
-<!ELEMENT  email        (#PCDATA)                                    >
-<!--         id         unique identifier                          -->
-<!ATTLIST  email
-            %common.atts;                                            >
-
-
-<!-- ============================================================= -->
-<!--                    paragraph-level elements                   -->
-<!-- ============================================================= -->
-
-
-<!--                    paragraph                                  -->
-<!ELEMENT  para         (#PCDATA | %phraselevel;)*                   >
-<!--         id         unique identifier                          -->
-<!ATTLIST  para
-            %common.atts;                                            >
-
-
-<!--                    note                                       -->
-<!ELEMENT  note         (%paralevel;)+                               >
-<!--         id         unique identifier                          -->
-<!ATTLIST  note
-            %common.atts;                                            >
-
-
-<!--                    itemized list                              -->
-<!ELEMENT  itemizedlist (listitem+)                                  >
-<!--         id         unique identifier                          -->
-<!ATTLIST  itemizedlist
-            %common.atts;                                            >
-
-
-<!--                    ordered list                               -->
-<!ELEMENT  orderedlist  (listitem+)                                  >
-<!--         id         unique identifier                          -->
-<!ATTLIST  orderedlist
-            %common.atts;                                            >
-
-
-<!--                    variable list                              -->
-<!ELEMENT  variablelist (varlistentry+)                              >
-<!--         id         unique identifier                          -->
-<!ATTLIST  variablelist
-            %common.atts;                                            >
-
-
-<!--                    list item                                  -->
-<!ELEMENT  listitem     (#PCDATA | %phraselevel; | %paralevel;)*     >
-<!--         id         unique identifier                          -->
-<!ATTLIST  listitem
-            %common.atts;                                            >
-
-
-<!--                    variable list entry                        -->
-<!ELEMENT  varlistentry (term+, listitem)                            >
-<!--         id         unique identifier                          -->
-<!ATTLIST  varlistentry
-            %common.atts;                                            >
-
-
-<!--                    term                                       -->
-<!ELEMENT  term         (#PCDATA | %phraselevel;)*                   >
-<!--         id         unique identifier                          -->
-<!ATTLIST  term
-            %common.atts;                                            >
-
-<!--                    termref                                       -->
-<!ELEMENT  termref         (#PCDATA | %phraselevel;)*                   >
-<!--         id         unique identifier                          -->
-<!ATTLIST  termref
-            %common.atts;	   >
-
-<!--                    literal layout                             -->
-<!ELEMENT  literallayout
-                        (#PCDATA | %phraselevel;)*                   >
-<!--         xml:space  whitespace handling
-             id         unique identifier                          -->
-<!ATTLIST  literallayout
-            %common.atts;                                            >
-
-
-<!--                    program listing                            -->
-<!ELEMENT  programlisting
-                        (#PCDATA | %phraselevel;)*                   >
-<!--         xml:space  whitespace handling
-             id         unique identifier                          -->
-<!ATTLIST  programlisting
-            %common.atts;                                            >
-
-
-<!--                    figure                                     -->
-<!ELEMENT  figure       (title, graphic)                             >
-<!--         id         unique identifier                          -->
-<!ATTLIST  figure
-            %common.atts;                                            >
-
-
-<!--                    graphic                                    -->
-<!ELEMENT  graphic      EMPTY                                        >
-<!--         align      alignment of graphic image.  values are:
-                          left          left aligned
-                          right         right aligned
-                          center        centered
-             fileref    path to external file
-             alt        alternate text
-             srccredit  source of graphic
-             width      width of area in which to fit graphic
-             depth      depth of area in which to fit graphic
-             scale      percentage scaling factor
-             scalefit   scale to fit width and/or depth
-             id         unique identifier                          -->
-<!ATTLIST  graphic
-             align      (left |right |center)              #IMPLIED
-            %graphic.atts;
-            %common.atts;                                            >
-
-<!--                    inline graphic                             -->
-<!ELEMENT  inlinegraphic
-                        EMPTY                                        >
-<!--         fileref    path to external file
-             alt        alternate text
-             srccredit  source of graphic
-             width      width of area in which to fit graphic
-             depth      depth of area in which to fit graphic
-             scale      percentage scaling factor
-             scalefit   scale to fit width and/or depth
-             id         unique identifier                          -->
-<!ATTLIST  inlinegraphic
-            %graphic.atts;
-            %common.atts;                                            >
-
-<!-- ============================================================= -->
-<!--                    text-level elements                        -->
-<!-- ============================================================= -->
-
-
-<!--                    bibliographic citation                     -->
-<!--                    a <citation> appears in the body of the
-                        article, and it refers through its
-                        "linkend" attribute to the id of the
-                        relevant bibliography item.
-                          the <citation> receives the same
-                        formatting as the <designator> element
-                        within the <biblioitem> being referenced.
-                        for example, when for the bibitem
-                        <biblioitem id="bib1"><designator>lab
-                        87</designator>...</biblioitem> is
-                        formatted as "[lab 87]", the bibliographic
-                        citation <citation linkend="bib1">lab
-                        87</citation> also formats as "[lab 87]".  -->
-<!ELEMENT  citation     (#PCDATA | emphasis | inlinegraphic |
-                         subscript | superscript)*                   >
-<!--         linkend    id of referenced bibliography entry
-             id         unique identifier                          -->
-<!ATTLIST  citation
-             linkend    IDREF                              #REQUIRED
-            %common.atts;                                            >
-
-
-<!--                    emphasis                                   -->
-<!ELEMENT  emphasis     (#PCDATA | %phraselevel;)*                   >
-<!--         id         unique identifier                          -->
-<!ATTLIST  emphasis
-            %common.atts;                                            >
-
-
-<!--                    subscript                                  -->
-<!ELEMENT  subscript    (#PCDATA | emphasis | subscript |
-                         superscript)*                               >
-<!--         id         unique identifier                          -->
-<!ATTLIST  subscript
-            %common.atts;                                            >
-
-
-<!--                    superscript                                -->
-<!ELEMENT  superscript  (#PCDATA | emphasis | subscript |
-                         superscript)*                               >
-<!--         id         unique identifier                          -->
-<!ATTLIST  superscript
-            %common.atts;                                            >
-
-
-<!--                    link                                       -->
-<!ELEMENT  link         (#PCDATA)                                    >
-<!--         linkend    id of referenced element
-             id         unique identifier                          -->
-<!ATTLIST  link
-             linkend    IDREF                              #REQUIRED
-            %common.atts;                                            >
-
-<!--  package link (for {@link org.xml.trax.Processor} type links, for javadocs.                              -->
-<!ELEMENT  plink         (#PCDATA)                                   >
-<!ATTLIST  plink
-            %common.atts;                                            >
-
-<!--                    ulink (external link)                      -->
-<!ELEMENT  ulink        (#PCDATA)                                    >
-<!--         url        uniform resource locator; the target of the
-                        ulink
-             id         unique identifier                          -->
-<!ATTLIST  ulink
-             url        CDATA                              #REQUIRED
-            %common.atts;                                            >
-
-
diff --git a/xdocs/style/dtd/xsl-html40s.dtd b/xdocs/style/dtd/xsl-html40s.dtd
deleted file mode 100644
index a8848bd..0000000
--- a/xdocs/style/dtd/xsl-html40s.dtd
+++ /dev/null
@@ -1,1505 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- 
-     XSLT (WD-19990813) DTD and HTML 4.0 Strict (REC-HTML40-19980424) DTD
-     This DTD defines a XSLT stylesheet with a result-ns of html
-
-     Credits:
-       Original XSLT DTD from W3C XSLT WD-19990813
-       Original XML  DTD for HTML 4.0 Strict by
-         TAMURA, Kent <kent@trl.ibm.co.jp>, for IBM's XML4J package
-       Minor fixes to XSLT & HTML DTDs by 
-         Scott Boag <scott_boag@lotus.com>
-         Henrique M. Holschuh <henriqmh@dca.fee.unicamp.br>
-       HTML/XSLT composite DTD by
-         Henrique M. Holschuh <henriqmh@dca.fee.unicamp.br>
-
-     Caveats: It is possible to generate invalid XSLT and HTML documents 
-       using this DTD, as the result-ns elements (HTML) must allow all 
-       possible xsl elements as content, and all result-ns elements had 
-       to be relaxed on their element content rules.
-
-     TODO:
-       - A XSLT/XHTML1.0 Strict DTD to use instead of this one. Lowercase
-         element names allow for better compression ratios, at least in
-         English documents.
-       - Update to HTML 4.01
-
-     $Id$
--->
-
-<!-- Predefined XML (REC-XML-19980210) entities -->
-<!ENTITY lt     "&#38;#60;">
-<!ENTITY gt     "&#62;">
-<!ENTITY amp    "&#38;#38;">
-<!ENTITY apos   "&#39;">
-<!ENTITY quot   "&#34;">
-
-<!-- 
-  Result elements allowed (inside xsl elements). These are actually
-  all of the HTML40 Strict elements. 
--->
-
-<!ENTITY % result-elements "
-  | TT
-  | I
-  | B
-  | BIG
-  | SMALL
-  | EM
-  | STRONG
-  | DFN
-  | CODE
-  | SAMP
-  | KBD
-  | VAR
-  | CITE
-  | ABBR
-  | ACRONYM
-  | SUP
-  | SUB
-  | SPAN
-  | BDO
-  | BR
-  | BODY
-  | ADDRESS
-  | DIV
-  | A
-  | MAP
-  | AREA
-  | LINK
-  | IMG
-  | OBJECT
-  | PARAM
-  | HR
-  | P
-  | H1
-  | H2
-  | H3
-  | H4
-  | H5
-  | H6
-  | PRE
-  | Q
-  | BLOCKQUOTE
-  | INS
-  | DEL
-  | DL
-  | DT
-  | DD
-  | OL
-  | UL
-  | LI
-  | FORM
-  | LABEL
-  | INPUT
-  | SELECT
-  | OPTGROUP
-  | OPTION
-  | TEXTAREA
-  | FIELDSET
-  | LEGEND
-  | BUTTON
-  | TABLE
-  | CAPTION
-  | THEAD
-  | TFOOT
-  | TBODY
-  | COLGROUP
-  | COL
-  | TR
-  | TH
-  | TD
-  | HEAD
-  | TITLE
-  | BASE
-  | META
-  | STYLE
-  | SCRIPT
-  | NOSCRIPT
-  | HTML
-">
-
-<!-- begin XSLT DTD, patched -->
-
-<!ENTITY % char-instructions "
- | 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
-">
-
-<!ENTITY % instructions "
- %char-instructions;
- | xsl:processing-instruction
- | xsl:comment
- | xsl:element
- | xsl:attribute
-">
-
-<!ENTITY % char-template "
-(#PCDATA
- %char-instructions;)*
-">
-
-<!ENTITY % template "
-(#PCDATA
- %instructions;
- %result-elements;)*
-">
-
-<!-- Used for the type of an attribute value that is a URI reference.-->
-<!ENTITY % URI "CDATA">
-
-<!-- Used for the type of an attribute value that is a pattern.-->
-<!ENTITY % pattern "CDATA">
-
-<!-- Used for the type of an attribute value that is an
-    attribute value template.-->
-<!ENTITY % avt "CDATA">
-
-<!-- Used for the type of an attribute value that is a QName; the prefix
-    gets expanded by the XSLT processor. -->
-<!ENTITY % qname "NMTOKEN">
-
-<!-- Like qname but a whitespace-separated list of QNames. -->
-<!ENTITY % qnames "NMTOKENS">
-
-<!-- Used for the type of an attribute value that is an expression.-->
-<!ENTITY % expr "CDATA">
-
-<!-- Used for the type of an attribute value that consists
-    of a single character.-->
-<!ENTITY % char "CDATA">
-
-<!-- Used for the type of an attribute value that is a priority. -->
-<!ENTITY % priority "NMTOKEN">
-
-<!ENTITY % space-att "xml:space (default|preserve) #IMPLIED">
-
-<!-- This may be overridden to customize the set of elements allowed
-at the top-level. -->
-
-<!ENTITY % non-xsl-top-level "">
-
-<!ENTITY % top-level "
-(xsl:import*,
- (xsl:include
- | xsl:strip-space
- | xsl:preserve-space
- | xsl:output
- | xsl:key
- | xsl:locale
- | xsl:attribute-set
- | xsl:variable
- | xsl:param
- | xsl:template
- %non-xsl-top-level;)*)
-">
-
-<!-- added xmlns attribute suitable for this DTD -->
-<!ENTITY % top-level-atts '
- extension-element-prefixes CDATA #IMPLIED
- id ID #IMPLIED
- xmlns:xsl CDATA #FIXED "http://www.w3.org/XSL/1999/Transform"
- xmlns CDATA #FIXED "http://www.w3.org/TR/REC-html40"
- %space-att;
-'>
-
-<!-- This entity is defined for use in the ATTLIST declaration
-for result elements. -->
-
-<!ENTITY % result-element-atts '
- xsl:extension-element-prefixes CDATA #IMPLIED
- xsl:use-attribute-sets %qnames; #IMPLIED
-'>
-
-<!ELEMENT xsl:stylesheet %top-level;>
-<!ATTLIST xsl:stylesheet %top-level-atts;>
-
-<!ELEMENT xsl:transform %top-level;>
-<!ATTLIST xsl:transform %top-level-atts;>
-
-<!ELEMENT xsl:import EMPTY>
-<!ATTLIST xsl:import href %URI; #REQUIRED>
-
-<!ELEMENT xsl:include EMPTY>
-<!ATTLIST xsl:include href %URI; #REQUIRED>
-
-<!ELEMENT xsl:strip-space EMPTY>
-<!ATTLIST xsl:strip-space elements CDATA #REQUIRED>
-
-<!ELEMENT xsl:preserve-space EMPTY>
-<!ATTLIST xsl:preserve-space elements CDATA #REQUIRED>
-
-<!ELEMENT xsl:output EMPTY>
-<!ATTLIST xsl:output
- method %qname; #IMPLIED
- version NMTOKEN #IMPLIED
- encoding NMTOKEN #IMPLIED
- xml-declaration (yes|no) #IMPLIED
- standalone (yes|no) #IMPLIED
- doctype-public CDATA #IMPLIED
- doctype-system CDATA #IMPLIED
- cdata-section-elements %qnames; #IMPLIED
- indent (yes|no) #IMPLIED
- media-type CDATA #IMPLIED
->
-
-<!ELEMENT xsl:key EMPTY>
-<!ATTLIST xsl:key
- name %qname; #REQUIRED
- match %pattern; #REQUIRED
- use %expr; #REQUIRED
->
-
-<!ELEMENT xsl:locale EMPTY>
-<!ATTLIST xsl:locale
- name %qname; #IMPLIED
- decimal-separator %char; "."
- grouping-separator %char; ","
- infinity CDATA "&#x221E;"
- minus-sign %char; "-"
- NaN CDATA "&#xFFFD;"
- percent %char; "%"
- per-mille %char; "&#x2030;"
- zero-digit %char; "0"
- digit %char; "#"
- pattern-separator %char; ";"
->
-
-<!ELEMENT xsl:template
-(#PCDATA
- %instructions;
- %result-elements;
- | xsl:param)*
->
-
-<!ATTLIST xsl:template
- match %pattern; #IMPLIED
- name %qname; #IMPLIED
- priority %priority; #IMPLIED
- mode %qname; #IMPLIED
- %space-att;
->
-
-<!ELEMENT xsl:value-of EMPTY>
-<!ATTLIST xsl:value-of
- select %expr; #REQUIRED
- disable-output-escaping (yes|no) "no"
->
-
-<!ELEMENT xsl:copy-of EMPTY>
-<!ATTLIST xsl:copy-of select %expr; #REQUIRED>
-
-<!ELEMENT xsl:number EMPTY>
-<!ATTLIST xsl:number
-  level (single|multiple|any) "single"
-  count %pattern; #IMPLIED
-  from %pattern; #IMPLIED
-  value %expr; #IMPLIED
-  format %avt; '1'
-  lang %avt; #IMPLIED
-  letter-value %avt; #IMPLIED
-  grouping-separator%avt; #IMPLIED
-  grouping-size %avt; #IMPLIED
->
-
-<!ELEMENT xsl:apply-templates (xsl:sort|xsl:with-param)*>
-<!ATTLIST xsl:apply-templates
- select %expr; "node()"
- mode %qname; #IMPLIED
->
-
-<!ELEMENT xsl:apply-imports EMPTY>
-
-<!-- xsl:sort cannot occur after any other elements or
-any non-whitespace character -->
-
-<!ELEMENT xsl:for-each
-(#PCDATA
- %instructions;
- %result-elements;
- | xsl:sort)*
->
-
-<!ATTLIST xsl:for-each
- select %expr; #REQUIRED
- %space-att;
->
-
-<!ELEMENT xsl:sort EMPTY>
-<!ATTLIST xsl:sort
- select %expr; "."
- lang %avt; #IMPLIED
- data-type %avt; "text"
- order %avt; "ascending"
- case-order %avt; #IMPLIED
->
-
-<!ELEMENT xsl:if %template;>
-<!ATTLIST xsl:if
- test %expr; #REQUIRED
- %space-att;
->
-
-<!ELEMENT xsl:choose (xsl:when+, xsl:otherwise?)>
-<!ATTLIST xsl:choose %space-att;>
-
-<!ELEMENT xsl:when %template;>
-<!ATTLIST xsl:when
- test %expr; #REQUIRED
- %space-att;
->
-
-<!ELEMENT xsl:otherwise %template;>
-<!ATTLIST xsl:otherwise %space-att;>
-
-<!ELEMENT xsl:attribute-set (xsl:attribute)*>
-<!ATTLIST xsl:attribute-set
- name %qname; #REQUIRED
- use-attribute-sets %qnames; #IMPLIED
->
-
-<!ELEMENT xsl:call-template (xsl:with-param)*>
-<!ATTLIST xsl:call-template
- name %qname; #REQUIRED
->
-
-<!ELEMENT xsl:with-param %template;>
-<!ATTLIST xsl:with-param
- name %qname; #REQUIRED
- select %expr; #IMPLIED
->
-
-<!ELEMENT xsl:variable %template;>
-<!ATTLIST xsl:variable 
- name %qname; #REQUIRED
- select %expr; #IMPLIED
->
-
-<!ELEMENT xsl:param %template;>
-<!ATTLIST xsl:param 
- name %qname; #REQUIRED
- select %expr; #IMPLIED
->
-
-<!ELEMENT xsl:text (#PCDATA)>
-<!ATTLIST xsl:text
- disable-output-escaping (yes|no) "no"
->
-
-<!ELEMENT xsl:processing-instruction %char-template;>
-<!ATTLIST xsl:processing-instruction 
- name %avt; #REQUIRED
- %space-att;
->
-
-<!ELEMENT xsl:element %template;>
-<!ATTLIST xsl:element 
- name %avt; #REQUIRED
- namespace %avt; #IMPLIED
- use-attribute-sets %qnames; #IMPLIED
- %space-att;
->
-
-<!ELEMENT xsl:attribute %char-template;>
-<!ATTLIST xsl:attribute 
- name %avt; #REQUIRED
- namespace %avt; #IMPLIED
- %space-att;
->
-
-<!ELEMENT xsl:comment %char-template;>
-<!ATTLIST xsl:comment %space-att;>
-
-<!ELEMENT xsl:copy %template;>
-<!ATTLIST xsl:copy
- %space-att;
- use-attribute-sets %qnames; #IMPLIED
->
-
-<!ELEMENT xsl:message %template;>
-<!ATTLIST xsl:message %space-att;>
-
-<!ELEMENT xsl:fallback %template;>
-<!ATTLIST xsl:fallback %space-att;>
-
-
-
-<!-- ######################################################################## -->
-<!--   HTML 4.0 Strict DTD   (revised to allow for xsl content)               -->
-<!--   Original DTD from XML4J package                                        -->
-<!--   Original SGML to XML conversion by TAMURA, Kent for IBM's XML4J        -->
-
-<!-- 
-     Container for all xsl elements allowed inside result-elements elements,
-     i.e.: all xsl elements which are valid where a result-element is valid,
-     and therefore must be valid inside ALL non-empty HTML elements.
-
-     You'll notice this does allow the user to create invalid XSL documents.
-
-  xsl:sort, xsl:param, xsl:param-variable were not inluded because
-  IMHO it is bad practice (and an error?) not to include them before 
-  other siblings, especially result-ns ones.
--->
-
-<!-- While the content should be simply %instructions; we cannot do that
-     due to the first '|' in %instructions -->
-<!ENTITY % xsl-valid-in-resultns "
-  xsl:processing-instruction
-  | xsl:comment
-  | xsl:element
-  | xsl:attribute
-  %char-instructions;
-">
-
-<!-- Also, %result-element-atts; was added to the ATTLIST of all html
-     elments -->
-
-<!-- Revision: 23 1.3 docs/data/HTML40strict.xml.dtd, xml4jdocs, xml4j-jtcsv, xml4j_1_1_9  -->
-
-<!--
-    This is HTML 4.0 Strict DTD, which excludes the presentation 
-    attributes and elements that W3C expects to phase out as 
-    support for style sheets matures. Authors should use the Strict
-    DTD when possible, but may use the Transitional DTD when support
-    for presentation attribute and elements is required.
-    
-    HTML 4.0 includes mechanisms for style sheets, scripting,
-    embedding objects, improved support for right to left and mixed
-    direction text, and enhancements to forms for improved
-    accessibility for people with disabilities.
-
-          Draft: Date: 1998/07/06 17:50:32
-
-          Authors:
-              Dave Raggett <dsr@w3.org>
-              Arnaud Le Hors <lehors@w3.org>
-              Ian Jacobs <ij@w3.org>
-
-    Further information about HTML 4.0 is available at:
-
-        http://www.w3.org/TR/REC-html40
--->
-
-<!--
-    ================================================================
-    Modified for XML 1.0 by:
-	"TAMURA, Kent" <kent@trl.ibm.co.jp>
-
-    o HTMLspecial, HTMLsymbol, HTMLlat1 aren't included in this DTD.
-    o The `lang' attribute was renamed to `xml:lang'.
-
-
-    Typical usage:
-
-    <?xml version="1.0" encoding="..."?>
-    <!DOCTYPE HTML SYSTEM ".../HTML40strict.xml.dtd">
-    <HTML>
-      <HEAD>
-        ...
-        <TITLE>...</TITLE>
-        ...
-      </HEAD>
-      <BODY>
-        ...
-      </BODY>
-    </HTML>
-
-    Note: XML is case-sensitive.  So element names must be written
-    in uppercase and attribute names must be written in lowercase.
-    ================================================================
--->
-
-<!--
-    Typical usage:
-
-    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
-            "http://www.w3.org/TR/REC-html40/strict.dtd">
-    <html>
-    <head>
-    ...
-    </head>
-    <body>
-    ...
-    </body>
-    </html>
-
-    The URI used as a system identifier with the public identifier allows
-    the user agent to download the DTD and entity sets as needed.
-
-    The FPI for the Transitional HTML 4.0 DTD is:
-
-        "-//W3C//DTD HTML 4.0 Transitional//EN"
-
-    and its URI is:
-
-        http://www.w3.org/TR/REC-html40/loose.dtd
-
-    If you are writing a document that includes frames, use 
-    the following FPI:
-
-        "-//W3C//DTD HTML 4.0 Frameset//EN"
-
-    with the URI:
-
-        http://www.w3.org/TR/REC-html40/frameset.dtd
-
-    The following URIs are supported in relation to HTML 4.0
-
-    "http://www.w3.org/TR/REC-html40/strict.dtd" (Strict DTD)
-    "http://www.w3.org/TR/REC-html40/loose.dtd" (Loose DTD)
-    "http://www.w3.org/TR/REC-html40/frameset.dtd" (Frameset DTD)
-    "http://www.w3.org/TR/REC-html40/HTMLlat1.ent" (Latin-1 entities)
-    "http://www.w3.org/TR/REC-html40/HTMLsymbol.ent" (Symbol entities)
-    "http://www.w3.org/TR/REC-html40/HTMLspecial.ent" (Special entities)
-
-    These URIs point to the latest version of each file. To reference
-    this specific revision use the following URIs:
-
-    "http://www.w3.org/TR/REC-html40-971218/strict.dtd"
-    "http://www.w3.org/TR/REC-html40-971218/loose.dtd"
-    "http://www.w3.org/TR/REC-html40-971218/frameset.dtd"
-    "http://www.w3.org/TR/REC-html40-971218/HTMLlat1.ent"
-    "http://www.w3.org/TR/REC-html40-971218/HTMLsymbol.ent"
-    "http://www.w3.org/TR/REC-html40-971218/HTMLspecial.ent"
-
--->
-
-<!--=== for XML ===-->
-<!ENTITY % Number "CDATA">
-<!ENTITY % Name "NMTOKEN">
-
-
-<!--================== Imported Names ====================================-->
-
-<!ENTITY % ContentType "CDATA"
-> <!-- media type, as per [RFC2045]
-    -->
-
-<!ENTITY % ContentTypes "CDATA"
-> <!-- comma-separated list of media types, as per [RFC2045]
-    -->
-
-<!ENTITY % Charset "CDATA"
-> <!-- a character encoding, as per [RFC2045]
-    -->
-
-<!ENTITY % Charsets "CDATA"
-> <!-- a space separated list of character encodings, as per [RFC2045]
-    -->
-
-<!ENTITY % LanguageCode "NMTOKEN"
-> <!-- a language code, as per [RFC1766]
-    -->
-
-<!ENTITY % Character "CDATA"
-> <!-- a single character from [ISO10646] 
-    -->
-
-<!ENTITY % LinkTypes "CDATA"
-> <!-- space-separated list of link types
-    -->
-
-<!ENTITY % MediaDesc "CDATA"
-> <!-- single or comma-separated list of media descriptors
-    -->
-
-<!-- Defined elsewhere in this DTD
-<!ENTITY % URI "CDATA"
-> <! a Uniform Resource Identifier,
-       see [URI]
-    -->
-
-<!ENTITY % Datetime "CDATA"><!-- date and time information. ISO date format -->
-
-
-<!ENTITY % Script "CDATA"><!-- script expression -->
-
-<!ENTITY % StyleSheet "CDATA"><!-- style sheet data -->
-
-
-
-<!ENTITY % Text "CDATA">
-
-
-<!-- Parameter Entities -->
-
-<!ENTITY % head.misc "SCRIPT|STYLE|META|LINK|OBJECT"><!-- repeatable head elements -->
-<!ENTITY % heading "H1|H2|H3|H4|H5|H6">
-<!ENTITY % list "UL | OL">
-<!ENTITY % preformatted "PRE">
-
-
-<!--================ Character mnemonic entities =========================-->
-
-<!--ENTITY % HTMLlat1 PUBLIC
-   "-//W3C//ENTITIES Latin1//EN//HTML"
-   "HTMLlat1.ent"-->
-<!--   "http://www.w3.org/TR/REC-html40-971218/HTMLlat1.ent"-->
-<!--%HTMLlat1;-->
-
-<!--ENTITY % HTMLsymbol PUBLIC
-   "-//W3C//ENTITIES Symbols//EN//HTML"
-   "HTMLsymbol.ent"-->
-<!--   "http://www.w3.org/TR/REC-html40-971218/HTMLsymbol.ent"-->
-<!--%HTMLsymbol;-->
-
-<!--ENTITY % HTMLspecial PUBLIC
-   "-//W3C//ENTITIES Special//EN//HTML"
-   "HTMLspecial.ent"-->
-<!--   "http://www.w3.org/TR/REC-html40-971218/HTMLspecial.ent"-->
-<!--%HTMLspecial;-->
-
-<!-- We define these elsewhere in this mixed DTD
-<!ENTITY quot "&#34;">
-<!ENTITY amp  "&#38;">
-<!ENTITY lt   "&#60;">
-<!ENTITY gt   "&#62;">
--->
-
-<!--=================== Generic Attributes ===============================-->
-
-<!ENTITY % coreattrs
- "id          ID             #IMPLIED
-  class       CDATA          #IMPLIED
-  style       %StyleSheet;   #IMPLIED
-  title       %Text;         #IMPLIED
-  %result-element-atts;"
->
-
-<!ENTITY % i18n
- "xml:lang    %LanguageCode; #IMPLIED
-  dir         (ltr|rtl)      #IMPLIED"
-  >
-
-<!ENTITY % events
- "onclick     %Script;       #IMPLIED
-  ondblclick  %Script;       #IMPLIED
-  onmousedown %Script;       #IMPLIED
-  onmouseup   %Script;       #IMPLIED
-  onmouseover %Script;       #IMPLIED
-  onmousemove %Script;       #IMPLIED
-  onmouseout  %Script;       #IMPLIED
-  onkeypress  %Script;       #IMPLIED
-  onkeydown   %Script;       #IMPLIED
-  onkeyup     %Script;       #IMPLIED"
-  >
-
-<!-- Reserved Feature Switch -->
-<!ENTITY % HTML.Reserved "IGNORE">
-
-<!-- The following attributes are reserved for possible future use -->
-<![ %HTML.Reserved; [
-<!ENTITY % reserved
- "datasrc     %URI;          #IMPLIED
-  datafld     CDATA          #IMPLIED
-  dataformatas (plaintext|html) plaintext"
-  >
-]]>
-
-<!ENTITY % reserved "">
-
-<!ENTITY % attrs "%coreattrs; %i18n; %events;">
-
-
-<!--=================== Text Markup ======================================-->
-
-<!ENTITY % fontstyle
- "TT | I | B | BIG | SMALL">
-
-<!ENTITY % phrase "EM | STRONG | DFN | CODE |
-                   SAMP | KBD | VAR | CITE | ABBR | ACRONYM" >
-
-<!ENTITY % special
-   "A | IMG | OBJECT | BR | SCRIPT | MAP | Q | SUB | SUP | SPAN | BDO">
-<!ENTITY % special-A
-   "IMG | OBJECT | BR | SCRIPT | MAP | Q | SUB | SUP | SPAN | BDO">
-
-<!ENTITY % formctrl "INPUT | SELECT | TEXTAREA | LABEL | BUTTON">
-
-<!-- %inline; covers inline or "text-level" elements -->
-<!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; | %formctrl;">
-<!ENTITY % inline-A "#PCDATA | %fontstyle; | %phrase; | %special-A; | %formctrl;">
-<!ENTITY % inline-LABEL "#PCDATA | %fontstyle; | %phrase; | %special; | INPUT | SELECT | TEXTAREA | BUTTON">
-
-<!--
-<!ELEMENT (%fontstyle;|%phrase;)     (%inline;)*>
-<!ATTLIST (%fontstyle;|%phrase;)
-  %attrs;
-  >-->
-<!ELEMENT TT (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST TT %attrs;>
-<!ELEMENT I (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST I %attrs;>
-<!ELEMENT B (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST B %attrs;>
-<!ELEMENT BIG (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST BIG %attrs;>
-<!ELEMENT SMALL (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST SMALL %attrs;>
-<!ELEMENT EM (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST EM %attrs;>
-<!ELEMENT STRONG (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST STRONG %attrs;>
-<!ELEMENT DFN (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST DFN %attrs;>
-<!ELEMENT CODE (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST CODE %attrs;>
-<!ELEMENT SAMP (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST SAMP %attrs;>
-<!ELEMENT KBD (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST KBD %attrs;>
-<!ELEMENT VAR (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST VAR %attrs;>
-<!ELEMENT CITE (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST CITE %attrs;>
-<!ELEMENT ABBR (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST ABBR %attrs;>
-<!ELEMENT ACRONYM (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST ACRONYM %attrs;>
-
-
-<!ELEMENT SUP (%inline; | %xsl-valid-in-resultns;)*><!-- subscript, superscript -->
-<!ATTLIST SUP
-  %attrs;
-  >
-<!ELEMENT SUB (%inline; | %xsl-valid-in-resultns;)*><!-- subscript, superscript -->
-<!ATTLIST SUB
-  %attrs;
-  >
-
-<!ELEMENT SPAN (%inline; | %xsl-valid-in-resultns;)*><!-- generic language/style container -->
-<!ATTLIST SPAN
-  %attrs;
-  %reserved;			
-  >
-
-<!ELEMENT BDO (%inline; | %xsl-valid-in-resultns;)*><!-- I18N BiDi over-ride -->
-<!ATTLIST BDO
-  %coreattrs;
-  lang        %LanguageCode; #IMPLIED
-  dir         (ltr|rtl)      #REQUIRED
-  >
-
-
-<!ELEMENT BR     EMPTY><!-- forced line break -->
-<!ATTLIST BR
-  %coreattrs;
-  >
-
-<!--================== HTML content models ===============================-->
-
-<!--
-    HTML has two basic content models:
-
-        %inline;     character level elements and text strings
-        %block;      block-like elements e.g. paragraphs and lists
--->
-
-<!ENTITY % block
-     "P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
-      BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">
-<!ENTITY % block-FORM
-     "P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
-      BLOCKQUOTE | HR | TABLE | FIELDSET | ADDRESS">
-<!ENTITY % block-FORM-FIELDSET
-     "P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
-      BLOCKQUOTE | HR | TABLE | ADDRESS">
-
-<!--<!ENTITY % flow "%block; | %inline;">-->
-<!ENTITY % flow "%inline; | %block;">
-
-<!--=================== Document Body ====================================-->
-
-<!--ELEMENT BODY     (%block;|SCRIPT)+ +(INS|DEL)  document body -->
-<!ELEMENT BODY ((INS|DEL)*, (%xsl-valid-in-resultns;|%block;|SCRIPT), (INS|DEL)*)+ ><!-- document body -->
-<!ATTLIST BODY
-  %attrs;
-  onload          %Script;   #IMPLIED
-  onunload        %Script;   #IMPLIED
-  >
-
-<!ELEMENT ADDRESS (%inline; | %xsl-valid-in-resultns;)*><!-- information on author -->
-<!ATTLIST ADDRESS
-  %attrs;
-  >
-
-<!ELEMENT DIV (%flow; | %xsl-valid-in-resultns;)*><!-- generic language/style container -->
-<!ATTLIST DIV
-  %attrs;
-  %reserved;
-  >
-
-
-<!--================== The Anchor Element ================================-->
-
-<!ENTITY % Shape "(rect|circle|poly|default)">
-<!ENTITY % Coords "CDATA"><!-- comma separated list of lengths -->
-
-<!ELEMENT A (%inline-A; | %xsl-valid-in-resultns;)*><!-- anchor -->
-<!ATTLIST A
-  %attrs;
-  charset     %Charset;      #IMPLIED
-  type        %ContentType;  #IMPLIED
-  name        CDATA          #IMPLIED
-  href        %URI;          #IMPLIED
-  hreflang    %LanguageCode; #IMPLIED
-  rel         %LinkTypes;    #IMPLIED
-  rev         %LinkTypes;    #IMPLIED
-  accesskey   %Character;    #IMPLIED
-  shape       %Shape;        "rect"
-  coords      %Coords;       #IMPLIED
-  tabindex    %Number;       #IMPLIED
-  onfocus     %Script;       #IMPLIED
-  onblur      %Script;       #IMPLIED
-  >
-
-<!--================== Client-side image maps ============================-->
-
-<!-- These can be placed in the same document or grouped in a
-     separate document although this isn't yet widely supported -->
-
-<!ELEMENT MAP  ((%xsl-valid-in-resultns;|%block;)+ | (%xsl-valid-in-resultns;|AREA+))><!-- client-side image map -->
-<!ATTLIST MAP
-  %attrs;
-  name        CDATA          #REQUIRED
-  >
-
-<!ELEMENT AREA     EMPTY><!-- client-side image map area -->
-<!ATTLIST AREA
-  %attrs;
-  shape       %Shape;        "rect"
-  coords      %Coords;       #IMPLIED
-  href        %URI;          #IMPLIED
-  nohref      (nohref)       #IMPLIED
-  alt         %Text;         #REQUIRED
-  tabindex    %Number;       #IMPLIED
-  accesskey   %Character;    #IMPLIED
-  onfocus     %Script;       #IMPLIED
-  onblur      %Script;       #IMPLIED
-  >
-
-<!--================== The LINK Element ==================================-->
-
-<!--
-  Relationship values can be used in principle:
-
-   a) for document specific toolbars/menus when used
-      with the LINK element in document head e.g.
-        start, contents, previous, next, index, end, help
-   b) to link to a separate style sheet (rel=stylesheet)
-   c) to make a link to a script (rel=script)
-   d) by stylesheets to control how collections of
-      html nodes are rendered into printed documents
-   e) to make a link to a printable version of this document
-      e.g. a postscript or pdf version (rel=alternate media=print)
--->
-
-<!ELEMENT LINK     EMPTY><!-- a media-independent link -->
-<!ATTLIST LINK
-  %attrs;
-  charset     %Charset;      #IMPLIED
-  href        %URI;          #IMPLIED
-  hreflang    %LanguageCode; #IMPLIED
-  type        %ContentType;  #IMPLIED
-  rel         %LinkTypes;    #IMPLIED
-  rev         %LinkTypes;    #IMPLIED
-  media       %MediaDesc;    #IMPLIED
-  >
-
-<!--=================== Images ===========================================-->
-
-<!-- Length defined in strict DTD for cellpadding/cellspacing -->
-<!ENTITY % Length "CDATA"><!-- nn for pixels or nn% for percentage length -->
-<!ENTITY % MultiLength "CDATA"><!-- pixel, percentage, or relative -->
-
-<!ENTITY % MultiLengths "CDATA"><!-- comma-separated list of MultiLength -->
-
-<!ENTITY % Pixels "CDATA"><!-- integer representing length in pixels -->
-
-
-<!-- To avoid problems with text-only UAs as well as 
-   to make image content understandable and navigable 
-   to users of non-visual UAs, you need to provide
-   a description with ALT, and avoid server-side image maps -->
-<!ELEMENT IMG     EMPTY><!-- Embedded image -->
-<!ATTLIST IMG
-  %attrs;
-  src         %URI;          #REQUIRED
-  alt         %Text;         #REQUIRED
-  longdesc    %URI;          #IMPLIED
-  height      %Length;       #IMPLIED
-  width       %Length;       #IMPLIED
-  usemap      %URI;          #IMPLIED
-  ismap       (ismap)        #IMPLIED
-  >
-
-<!-- USEMAP points to a MAP element which may be in this document
-  or an external document, although the latter is not widely supported -->
-
-<!--==================== OBJECT ======================================-->
-<!--
-  OBJECT is used to embed objects as part of HTML pages 
-  PARAM elements should precede other content. SGML mixed content
-  model technicality precludes specifying this formally ...
--->
-
-<!ELEMENT OBJECT (%flow; | %xsl-valid-in-resultns; | PARAM)*
-><!-- generic embedded object -->
-<!ATTLIST OBJECT
-  %attrs;
-  declare     (declare)      #IMPLIED
-  classid     %URI;          #IMPLIED
-  codebase    %URI;          #IMPLIED
-  data        %URI;          #IMPLIED
-  type        %ContentType;  #IMPLIED
-  codetype    %ContentType;  #IMPLIED
-  archive     %URI;          #IMPLIED
-  standby     %Text;         #IMPLIED
-  height      %Length;       #IMPLIED
-  width       %Length;       #IMPLIED
-  usemap      %URI;          #IMPLIED
-  name        CDATA          #IMPLIED
-  tabindex    %Number;       #IMPLIED
-  %reserved;
-  >
-
-<!ELEMENT PARAM     EMPTY><!-- named property value -->
-<!ATTLIST PARAM
-  id          ID             #IMPLIED
-  name        CDATA          #REQUIRED
-  value       CDATA          #IMPLIED
-  valuetype   (DATA|REF|OBJECT) "DATA"
-  type        %ContentType;  #IMPLIED
-  >
-
-
-<!--=================== Horizontal Rule ==================================-->
-
-<!ELEMENT HR     EMPTY><!-- horizontal rule -->
-<!ATTLIST HR
-  %coreattrs;
-  %events;
-  >
-
-<!--=================== Paragraphs =======================================-->
-
-<!ELEMENT P (%inline; | %xsl-valid-in-resultns;)*><!-- paragraph -->
-<!ATTLIST P
-  %attrs;
-  >
-
-<!--=================== Headings =========================================-->
-
-<!--
-  There are six levels of headings from H1 (the most important)
-  to H6 (the least important).
--->
-
-<!--
-<!ELEMENT (%heading;)      (%inline;)*>
-<!ATTLIST (%heading;)
-  %attrs;
-  >-->
-<!ELEMENT H1 (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST H1 %attrs;>
-<!ELEMENT H2 (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST H2 %attrs;>
-<!ELEMENT H3 (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST H3 %attrs;>
-<!ELEMENT H4 (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST H4 %attrs;>
-<!ELEMENT H5 (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST H5 %attrs;>
-<!ELEMENT H6 (%inline; | %xsl-valid-in-resultns;)*>
-<!ATTLIST H6 %attrs;>
-
-
-<!--=================== Preformatted Text ================================-->
-
-<!-- excludes markup for images and changes in font size -->
-<!--
-<!ENTITY % pre.exclusion "IMG|OBJECT|BIG|SMALL|SUB|SUP">
-
-<!ELEMENT PRE  (%inline;)* -(%pre.exclusion;)><! preformatted text -->
-
-<!ELEMENT PRE (#PCDATA |%xsl-valid-in-resultns;| TT|I|B|%phrase;|A|BR|SCRIPT|MAP|Q|SPAN|BDO|%formctrl;)*>
-			<!-- preformatted text -->
-<!ATTLIST PRE
-  %attrs;>
-<!-- Should the attribute below be incuded in PRE?
-  xml:space (default|preserve) #FIXED "preserve"
--->
-
-<!--===================== Inline Quotes ==================================-->
-
-<!ELEMENT Q  (%inline; | %xsl-valid-in-resultns;)*><!-- short inline quotation -->
-<!ATTLIST Q
-  %attrs;
-  cite        %URI;          #IMPLIED
-  >
-
-<!--=================== Block-like Quotes ================================-->
-
-<!ELEMENT BLOCKQUOTE  (%block;|%xsl-valid-in-resultns;|SCRIPT)+><!-- long quotation -->
-<!ATTLIST BLOCKQUOTE
-  %attrs;
-  cite        %URI;          #IMPLIED
-  >
-
-<!--=================== Inserted/Deleted Text ============================-->
-
-
-<!-- INS/DEL are handled by inclusion on BODY -->
-<!ELEMENT INS (%flow;|%xsl-valid-in-resultns;)*><!-- inserted text, deleted text -->
-<!ATTLIST INS
-  %attrs;
-  cite        %URI;          #IMPLIED
-  datetime    %Datetime;     #IMPLIED
-  >
-<!ELEMENT DEL (%flow;|%xsl-valid-in-resultns;)*><!-- inserted text, deleted text -->
-<!ATTLIST DEL
-  %attrs;
-  cite        %URI;          #IMPLIED
-  datetime    %Datetime;     #IMPLIED
-  >
-
-<!--=================== Lists ============================================-->
-
-<!-- definition lists - DT for term, DD for its definition -->
-
-<!ELEMENT DL  (%xsl-valid-in-resultns;| DT|DD)+><!-- definition list -->
-<!ATTLIST DL
-  %attrs;
-  >
-
-<!ELEMENT DT (%inline; | %xsl-valid-in-resultns;)*><!-- definition term -->
-<!ELEMENT DD (%flow; | %xsl-valid-in-resultns;)*><!-- definition description -->
-<!ATTLIST DT
-  %attrs;
-  >
-<!ATTLIST DD
-  %attrs;
-  >
-
-
-<!ELEMENT OL (%xsl-valid-in-resultns; | LI)+><!-- ordered list -->
-<!ATTLIST OL
-  %attrs;
-  >
-
-<!-- Unordered Lists (UL) bullet styles -->
-<!ELEMENT UL (%xsl-valid-in-resultns; | LI)+><!-- unordered list -->
-<!ATTLIST UL
-  %attrs;
-  >
-
-
-
-<!ELEMENT LI (%flow; | %xsl-valid-in-resultns;)*><!-- list item -->
-<!ATTLIST LI
-  %attrs;
-  >
-
-<!--================ Forms ===============================================-->
-<!ELEMENT FORM (%xsl-valid-in-resultns;|%block-FORM;|SCRIPT)+>
-
-<!-- interactive form -->
-<!ATTLIST FORM
-  %attrs;
-  action      %URI;          #REQUIRED
-  method      (GET|POST)     "GET"
-  enctype     %ContentType;  "application/x-www-form-urlencoded"
-  onsubmit    %Script;       #IMPLIED
-  onreset     %Script;       #IMPLIED
-  accept-charset %Charsets;  #IMPLIED
-  >
-
-<!-- Each label must not contain more than ONE field -->
-<!ELEMENT LABEL  (%inline-LABEL; | %xsl-valid-in-resultns;)*><!-- form field label text -->
-<!ATTLIST LABEL
-  %attrs;
-  for         IDREF          #IMPLIED
-  accesskey   %Character;    #IMPLIED
-  onfocus     %Script;       #IMPLIED
-  onblur      %Script;       #IMPLIED
-  >
-
-<!ENTITY % InputType
-  "(TEXT | PASSWORD | CHECKBOX |
-    RADIO | SUBMIT | RESET |
-    FILE | HIDDEN | IMAGE | BUTTON)"
-   >
-
-<!-- attribute name required for all but submit & reset -->
-<!ELEMENT INPUT     EMPTY><!-- form control -->
-<!ATTLIST INPUT
-  %attrs;
-  type        %InputType;    "TEXT"
-  name        CDATA          #IMPLIED
-  value       CDATA          #IMPLIED
-  checked     (checked)      #IMPLIED
-  disabled    (disabled)     #IMPLIED
-  readonly    (readonly)     #IMPLIED
-  size        CDATA          #IMPLIED
-  maxlength   %Number;       #IMPLIED
-  src         %URI;          #IMPLIED
-  alt         CDATA          #IMPLIED
-  usemap      %URI;          #IMPLIED
-  tabindex    %Number;       #IMPLIED
-  accesskey   %Character;    #IMPLIED
-  onfocus     %Script;       #IMPLIED
-  onblur      %Script;       #IMPLIED
-  onselect    %Script;       #IMPLIED
-  onchange    %Script;       #IMPLIED
-  accept      %ContentTypes; #IMPLIED
-  %reserved;
-  >
-
-<!ELEMENT SELECT ((%xsl-valid-in-resultns;|OPTGROUP)|(%xsl-valid-in-resultns;|OPTION))+ ><!-- option selector -->
-<!ATTLIST SELECT
-  %attrs;
-  name        CDATA          #IMPLIED
-  size        %Number;       #IMPLIED
-  multiple    (multiple)     #IMPLIED
-  disabled    (disabled)     #IMPLIED
-  tabindex    %Number;       #IMPLIED
-  onfocus     %Script;       #IMPLIED
-  onblur      %Script;       #IMPLIED
-  onchange    %Script;       #IMPLIED
-  %reserved;
-  >
-
-<!ELEMENT OPTGROUP (%xsl-valid-in-resultns;|OPTION)+>  <!-- option group -->
-<!ATTLIST OPTGROUP
-  %attrs;
-  disabled    (disabled)     #IMPLIED
-  label       %Text;         #REQUIRED
-  >
-
-<!ELEMENT OPTION  (#PCDATA | %xsl-valid-in-resultns;)*><!-- selectable choice -->
-<!ATTLIST OPTION
-  %attrs;
-  selected    (selected)     #IMPLIED
-  disabled    (disabled)     #IMPLIED
-  label       %Text;         #IMPLIED
-  value       CDATA          #IMPLIED
-  >
-
-<!ELEMENT TEXTAREA (#PCDATA | %xsl-valid-in-resultns;)*><!-- multi-line text field -->
-<!ATTLIST TEXTAREA
-  %attrs;
-  name        CDATA          #IMPLIED
-  rows        %Number;       #REQUIRED
-  cols        %Number;       #REQUIRED
-  disabled    (disabled)     #IMPLIED
-  readonly    (readonly)     #IMPLIED
-  tabindex    %Number;       #IMPLIED
-  accesskey   %Character;    #IMPLIED
-  onfocus     %Script;       #IMPLIED
-  onblur      %Script;       #IMPLIED
-  onselect    %Script;       #IMPLIED
-  onchange    %Script;       #IMPLIED
-  %reserved;
-  >
-
-<!--
-  #PCDATA is to solve the mixed content problem,
-  per specification only whitespace is allowed there!
-
-  We do allow XSL inside as well
- -->
-<!--ELEMENT FIELDSET     (#PCDATA,LEGEND,(%flow;)*)    form control group -->
-<!ELEMENT FIELDSET  (%flow;|%xsl-valid-in-resultns;|LEGEND)*><!-- form control group -->
-<!ATTLIST FIELDSET
-  %attrs;
-  >
-
-<!ELEMENT LEGEND (%inline;|%xsl-valid-in-resultns;)*><!-- fieldset legend -->
-<!ENTITY % LAlign "(top|bottom|left|right)">
-
-<!ATTLIST LEGEND
-  %attrs;
-  accesskey   %Character;    #IMPLIED
-  >
-
-<!ELEMENT BUTTON
-     (#PCDATA | %xsl-valid-in-resultns; | %fontstyle; | %phrase; | %special-A; | %block;)*
-><!-- push button -->
-<!ATTLIST BUTTON
-  %attrs;
-  name        CDATA          #IMPLIED
-  value       CDATA          #IMPLIED
-  type        (button|submit|reset) "submit"
-  disabled    (disabled)     #IMPLIED
-  tabindex    %Number;       #IMPLIED
-  accesskey   %Character;    #IMPLIED
-  onfocus     %Script;       #IMPLIED
-  onblur      %Script;       #IMPLIED
-  %reserved;
-  >
-
-<!--======================= Tables =======================================-->
-
-<!-- IETF HTML table standard, see [RFC1942] -->
-
-<!--
- The BORDER attribute sets the thickness of the frame around the
- table. The default units are screen pixels.
-
- The FRAME attribute specifies which parts of the frame around
- the table should be rendered. The values are not the same as
- CALS to avoid a name clash with the VALIGN attribute.
-
- The value "border" is included for backwards compatibility with
- <TABLE BORDER> which yields frame=border and border=implied
- For <TABLE BORDER=1> you get border=1 and frame=implied. In this
- case, it is appropriate to treat this as frame=border for backwards
- compatibility with deployed browsers.
--->
-<!ENTITY % TFrame "(void|above|below|hsides|lhs|rhs|vsides|box|border)">
-
-<!--
- The RULES attribute defines which rules to draw between cells:
-
- If RULES is absent then assume:
-     "none" if BORDER is absent or BORDER=0 otherwise "all"
--->
-
-<!ENTITY % TRules "(none | groups | rows | cols | all)">
-  
-<!-- horizontal placement of table relative to document -->
-<!ENTITY % TAlign "(left|center|right)">
-
-<!-- horizontal alignment attributes for cell contents -->
-<!ENTITY % cellhalign
-  "align      (left|center|right|justify|char) #IMPLIED
-   char       %Character;    #IMPLIED
-   charoff    %Length;       #IMPLIED"
-  >
-
-<!-- vertical alignment attributes for cell contents -->
-<!ENTITY % cellvalign
-  "valign     (top|middle|bottom|baseline) #IMPLIED"
-  >
-
-<!ELEMENT TABLE 
-  ((%xsl-valid-in-resultns;)*, CAPTION?, (%xsl-valid-in-resultns;)*,
-   ((COL | %xsl-valid-in-resultns;)*|(COLGROUP | %xsl-valid-in-resultns;)*),
-   ((THEAD?,(%xsl-valid-in-resultns;)*,TFOOT?,(%xsl-valid-in-resultns;|TBODY)+)
-    | (%xsl-valid-in-resultns;|TR)+) )>
-
-<!ELEMENT CAPTION   (%inline; | %xsl-valid-in-resultns;)*><!-- table caption -->
-<!ELEMENT THEAD     (TR|%xsl-valid-in-resultns;)+><!-- table header -->
-<!ELEMENT TFOOT     (TR|%xsl-valid-in-resultns;)+><!-- table footer -->
-<!ELEMENT TBODY     (TR|%xsl-valid-in-resultns;)+><!-- table body -->
-<!ELEMENT COLGROUP  (%xsl-valid-in-resultns; | COL)*><!-- table column group -->
-<!ELEMENT COL       EMPTY><!-- table column -->
-<!ELEMENT TR        (TH|TD| %xsl-valid-in-resultns;)+><!-- table row -->
-<!ELEMENT TH        (%flow; | %xsl-valid-in-resultns;)*><!-- table header cell, table data cell-->
-<!ELEMENT TD        (%flow; | %xsl-valid-in-resultns;)*><!-- table header cell, table data cell-->
-
-<!ATTLIST TABLE
-  %attrs;
-  summary     %Text;         #IMPLIED
-  width       %Length;       #IMPLIED
-  border      %Pixels;       #IMPLIED
-  frame       %TFrame;       #IMPLIED
-  rules       %TRules;       #IMPLIED
-  cellspacing %Length;       #IMPLIED
-  cellpadding %Length;       #IMPLIED
-  %reserved;
-  datapagesize CDATA         #IMPLIED
-  >
-
-<!ENTITY % CAlign "(top|bottom|left|right)">
-
-<!ATTLIST CAPTION
-  %attrs;
-  >
-
-<!--
-COLGROUP groups a set of COL elements. It allows you to group
-several semantically related columns together.
--->
-<!ATTLIST COLGROUP
-  %attrs;
-  span        %Number;       "1"
-  width       %MultiLength;  #IMPLIED
-  %cellhalign;
-  %cellvalign;
-  >
-
-<!--
- COL elements define the alignment properties for cells in
- one or more columns.
-
- The WIDTH attribute specifies the width of the columns, e.g.
-
-     width=64        width in screen pixels
-     width=0.5*      relative width of 0.5
-
- The SPAN attribute causes the attributes of one
- COL element to apply to more than one column.
--->
-<!ATTLIST COL
-  %attrs;
-  span        %Number;       "1"
-  width       %MultiLength;  #IMPLIED
-  %cellhalign;
-  %cellvalign;
-  >
-
-<!--
-    Use THEAD to duplicate headers when breaking table
-    across page boundaries, or for static headers when
-    TBODY sections are rendered in scrolling panel.
-
-    Use TFOOT to duplicate footers when breaking table
-    across page boundaries, or for static footers when
-    TBODY sections are rendered in scrolling panel.
-
-    Use multiple TBODY sections when rules are needed
-    between groups of table rows.
--->
-<!ATTLIST THEAD
-  %attrs;
-  %cellhalign;
-  %cellvalign;
-  >
-<!ATTLIST TBODY
-  %attrs;
-  %cellhalign;
-  %cellvalign;
-  >
-<!ATTLIST TFOOT
-  %attrs;
-  %cellhalign;
-  %cellvalign;
-  >
-
-<!ATTLIST TR
-  %attrs;
-  %cellhalign;
-  %cellvalign;
-  >
-
-
-<!-- Scope is simpler than axes attribute for common tables -->
-<!ENTITY % Scope "(ROW|COL|ROWGROUP|COLGROUP)">
-
-<!-- TH is for headers, TD for data, but for cells acting as both use TD -->
-<!ATTLIST TH
-  %attrs;
-  abbr        %Text;         #IMPLIED
-  axis        CDATA          #IMPLIED
-  headers     IDREFS         #IMPLIED
-  scope       %Scope;        #IMPLIED
-  rowspan     %Number;       "1"
-  colspan     %Number;       "1"
-  %cellhalign;
-  %cellvalign;
-  >
-<!ATTLIST TD
-  %attrs;
-  abbr        %Text;         #IMPLIED
-  axis        CDATA          #IMPLIED
-  headers     IDREFS         #IMPLIED
-  scope       %Scope;        #IMPLIED
-  rowspan     %Number;       "1"
-  colspan     %Number;       "1"
-  %cellhalign;
-  %cellvalign;
-  >
-
-
-<!--================ Document Head =======================================-->
-<!-- %head.misc; defined earlier on as "SCRIPT|STYLE|META|LINK|OBJECT",
-     extended now to allow xsl -->
-<!ENTITY % head.misc-HEAD "%head.misc;|%xsl-valid-in-resultns;">
-
-<!ENTITY % head.content "TITLE &amp; BASE?">
-
-<!--ELEMENT HEAD     (%head.content;) +(%head.misc;)   document head -->
-<!ELEMENT HEAD
-   ((%head.misc-HEAD;)*, ((BASE?,(%head.misc-HEAD;)*,TITLE?) | (TITLE?,(%head.misc-HEAD;)*,BASE?)|(%head.misc-HEAD;)*)+, (%head.misc-HEAD;)*)>
-<!ATTLIST HEAD
-  %i18n;
-  profile     %URI;          #IMPLIED
-  %result-element-atts;
-  >
-
-<!-- The TITLE element is not considered part of the flow of text.
-       It should be displayed, for example as the page header or
-       window title. Exactly one title is required per document.
-    -->
-<!--ELEMENT TITLE     (#PCDATA) -(%head.misc;)  document title -->
-<!ELEMENT TITLE  (#PCDATA |  %xsl-valid-in-resultns;)*><!-- document title -->
-<!ATTLIST TITLE %i18n; %result-element-atts;>
-
-
-<!ELEMENT BASE     EMPTY><!-- document base URI -->
-<!ATTLIST BASE
-  href        %URI;          #REQUIRED
-  >
-
-<!ELEMENT META     EMPTY><!-- generic metainformation -->
-<!ATTLIST META
-  %i18n;
-  http-equiv  %Name;         #IMPLIED
-  name        %Name;         #IMPLIED
-  content     CDATA          #REQUIRED
-  scheme      CDATA          #IMPLIED
-  %result-element-atts;
-  >
-
-<!--ELEMENT STYLE     %StyleSheet;  style info -->
-<!ELEMENT STYLE (#PCDATA | %xsl-valid-in-resultns;)*><!-- style info -->
-<!ATTLIST STYLE
-  %i18n;
-  type        %ContentType;  #REQUIRED
-  media       %MediaDesc;    #IMPLIED
-  title       %Text;         #IMPLIED
-  %result-element-atts;
-  >
-
-<!--ELEMENT SCRIPT     %Script; script statements -->
-<!ELEMENT SCRIPT (#PCDATA | %xsl-valid-in-resultns;)*><!-- script statements -->
-<!ATTLIST SCRIPT
-  charset     %Charset;      #IMPLIED
-  type        %ContentType;  #REQUIRED
-  language    CDATA          #IMPLIED
-  src         %URI;          #IMPLIED
-  defer       (defer)        #IMPLIED
-  event       CDATA          #IMPLIED
-  for         %URI;          #IMPLIED
-  %result-element-atts;
-  >
-
-<!ELEMENT NOSCRIPT (%xsl-valid-in-resultns;|%block;)+
-><!-- alternate content container for non script-based rendering -->
-<!ATTLIST NOSCRIPT
-  %attrs;
-  >
-
-<!--================ Document Structure ==================================-->
-<!ENTITY % html.content "HEAD, BODY">
-
-<!--<!ELEMENT HTML     (%html.content;)> --><!-- document root element -->
-<!ELEMENT HTML (((%xsl-valid-in-resultns;)*,HEAD?,(%xsl-valid-in-resultns;)*,BODY?,
-                (%xsl-valid-in-resultns;)*) | (%xsl-valid-in-resultns;)*)>
-<!-- document root element -->
-<!ATTLIST HTML
-  %i18n;
-  %result-element-atts;
-  >
diff --git a/xdocs/style/loaderdesign.xml b/xdocs/style/loaderdesign.xml
deleted file mode 100644
index 975055b..0000000
--- a/xdocs/style/loaderdesign.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0"?>
-
-<loader>
-  <processor name="xslt">
-    <parameter name="stylesheet" value="sbk:/style/stylesheets/design2project.xsl"/>
-  </processor>
-</loader>
diff --git a/xdocs/style/stylesheets/design2project.xsl b/xdocs/style/stylesheets/design2project.xsl
deleted file mode 100644
index 8d23940..0000000
--- a/xdocs/style/stylesheets/design2project.xsl
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0"?>
-
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-
-  <xsl:template match="/">
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <!-- match the root book element -->
-  <xsl:template match="book">
-    <project>
-      <parameter name="copyright" value="{@copyright}"/>
-      <xsl:apply-templates/>
-    </project>
-  </xsl:template>
-
- <xsl:template match="document">
-
-    <process source="{@source}" producer="parser">
-      <processor name="xslt">
-        <parameter name="stylesheet" value="sbk:/style/stylesheets/any2project.xsl"/>
-      </processor>
-    </process>
-
-    <create source="{@source}" target="{@id}.html" producer="parser" printer="html">
-      <processor name="xslt">
-        <parameter name="id" value="{@id}"/>
-        <parameter name="stylesheet" value="sbk:/style/stylesheets/designdoc2html.xsl"/>
-      </processor>
-    </create>
-  </xsl:template>
-  
-</xsl:stylesheet>
\ No newline at end of file
diff --git a/xdocs/style/stylesheets/designdoc2html.xsl b/xdocs/style/stylesheets/designdoc2html.xsl
deleted file mode 100644
index 4663e41..0000000
--- a/xdocs/style/stylesheets/designdoc2html.xsl
+++ /dev/null
@@ -1,217 +0,0 @@
-<?xml version="1.0"?>
-
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-
-  <xsl:param name="stylebook.project"/>
-  <xsl:param name="copyright"/>
-  <xsl:param name="id"/>
-
-  <xsl:template match="/">
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <xsl:template match="s1">
-    <html>
-      <head>
-        <title><xsl:value-of select="@title"/></title>
-      </head>
-      <body text="#000000" link="#0000ff" vlink="#0000aa" alink="#ff0000"
-            topmargin="4" leftmargin="4" marginwidth="4" marginheight="4"
-            bgcolor="#ffffff">
-         <xsl:variable name="topimage" select="string(./p/img/@src)"/>
-         <h1><a href="http://xml.apache.org"><img src="images/{$topimage}"/></a>&#160;&#160;
-         <xsl:value-of select="@title"/></h1><hr/>
-             <xsl:apply-templates/>
-         <hr/>
-            <font size="-1" color="#0086b2"><i>
-              Copyright &#169; <xsl:value-of select="$copyright"/>
-            </i></font>
-      </body>
-    </html>
-  </xsl:template>
-
-  <xsl:template match="s2">
-      
-      <h2><xsl:value-of select="@title"/></h2>
-      <xsl:apply-templates/>
-  </xsl:template>
-
-  <xsl:template match="s3">
-      <h3><xsl:value-of select="@title"/></h3>
-      <xsl:apply-templates/>
-  </xsl:template>
-
-  <xsl:template match="s4">
-      <h4><xsl:value-of select="@title"/></h4>
-      <xsl:apply-templates/>
-  </xsl:template>
-
-<!-- ###################################################################### -->
-<!-- blocks -->
-
-  <xsl:template match="p">
-    <p><xsl:apply-templates/></p>
-  </xsl:template>
-
-  <xsl:template match="note">
-    <table width="100%" cellspacing="3" cellpadding="0" border="0">
-      <tr>
-        <td width="20" valign="top">
-          <img src="resources/note.gif" width="20" height="24" vspace="0" hspace="0" border="0" alt="Note"/>
-        </td>
-        <td valign="top">
-          <font size="-1" face="arial,helvetica,sanserif" color="#000000">
-            <i>
-              <xsl:apply-templates/>
-            </i>
-          </font>
-        </td>
-      </tr>  
-    </table>
-  </xsl:template>
-
-  <xsl:template match="ul">
-    <ul><xsl:apply-templates/></ul>
-  </xsl:template>
-
-  <xsl:template match="ol">
-    <ol><xsl:apply-templates/></ol>
-  </xsl:template>
-
-  <xsl:template match="li">
-    <li><xsl:apply-templates/></li>
-  </xsl:template>
-  
-    <!--Definition lists: gloss, term, label, item -->
-  <xsl:template match="gloss">
-    <dl><xsl:apply-templates/></dl>
-  </xsl:template>
-   <!-- <term> contains a single-word, multi-word or symbolic 
-       designation which is regarded as a technical term. --> 
-  <xsl:template match="term">
-    <dfn><xsl:apply-templates/></dfn>
-  </xsl:template>
-  <xsl:template match="label" priority="1">
-    <dt><xsl:apply-templates/></dt>
-  </xsl:template>
-  <xsl:template match="item" priority="2">
-    <dd>
-      <xsl:apply-templates/>
-    </dd>
-  </xsl:template>
-
-  <xsl:template match="source">
-    <p><font size="-1"><pre><xsl:apply-templates/></pre></font></p>
-  </xsl:template>
-
-  <xsl:template match="table">
-    <table width="100%" border="0" cellspacing="2" cellpadding="2">
-      <xsl:apply-templates/>
-    </table>
-  </xsl:template>
-
-  <xsl:template match="tr">
-    <tr><xsl:apply-templates/></tr>
-  </xsl:template>
-
-  <xsl:template match="th">
-    <td bgcolor="#039acc" colspan="{@colspan}" rowspan="{@rowspan}" valign="center" align="center">
-      <font color="#ffffff" size="-1" face="arial,helvetica,sanserif">
-        <b><xsl:apply-templates/></b>&#160;
-      </font>
-    </td>
-  </xsl:template>
-
-  <xsl:template match="td">
-    <td bgcolor="#a0ddf0" colspan="{@colspan}" rowspan="{@rowspan}" valign="top" align="left">
-      <font color="#000000" size="-1" face="arial,helvetica,sanserif">
-        <xsl:apply-templates/>&#160;
-      </font>
-    </td>
-  </xsl:template>
-
-  <xsl:template match="tn">
-    <td bgcolor="#ffffff" colspan="{@colspan}" rowspan="{@rowspan}">
-      &#160;
-    </td>
-  </xsl:template>
-
-<!-- ###################################################################### -->
-<!-- markup -->
-
-  <xsl:template match="em">
-    <b><xsl:apply-templates/></b>
-  </xsl:template>
-
-  <xsl:template match="ref">
-    <i><xsl:apply-templates/></i>
-  </xsl:template>
-  
-  <xsl:template match="code">
-    <code><font face="courier, monospaced"><xsl:apply-templates/></font></code>
-  </xsl:template>
-  
-  <xsl:template match="br">
-    <br/>
-  </xsl:template>
-  
-<!-- ###################################################################### -->
-<!-- links -->
-
-  <xsl:template match="link">
-    <xsl:if test="string-length(@anchor)=0">
-      <xsl:if test="string-length(@idref)=0">
-        <!--xsl:apply-templates/-->
-      </xsl:if>
-      <xsl:if test="string-length(@idref)>0">
-        <a href="{@idref}.html"><xsl:apply-templates/></a>
-      </xsl:if>
-    </xsl:if>
-
-    <xsl:if test="string-length(@anchor)>0">
-      <xsl:if test="string-length(@idref)=0">
-        <a href="#{@anchor}"><xsl:apply-templates/></a>
-      </xsl:if>
-      <xsl:if test="string-length(@idref)>0">
-        <a href="{@idref}.html#{@anchor}"><xsl:apply-templates/></a>
-      </xsl:if>
-    </xsl:if>
-  </xsl:template>
-
-  <xsl:template match="anchor">
-    <a name="{@name}"><xsl:comment>anchor</xsl:comment></a>
-  </xsl:template>
-
-  <xsl:template match="jump">
-    <a href="{@href}"><xsl:apply-templates/></a>
-  </xsl:template>
-
-  <xsl:template match="/s1/s2//img">
-    <img src="images/{@src}"/>
-  </xsl:template>
-
-  <xsl:template match="resource-ref">
-    <xsl:variable name="resourceFile" 
-          select="document($stylebook.project)/book/resources/@source"/>
-    <xsl:variable name="xref" select="@idref"/>
-    <xsl:variable name="href"
-          select="document($resourceFile)/resources/resource[@id=$xref]/@location"/>
-    <xsl:variable name="label"
-          select="document($resourceFile)/resources/resource[@id=$xref]/@title"/>
-    <A href="{$href}" target="_top"><xsl:value-of select="$label"/></A>
-  </xsl:template>
-
-  <xsl:template match="human-resource-ref">
-    <xsl:variable name="resourceFile" 
-          select="document($stylebook.project)/book/resources/@source"/>  
-    <xsl:variable name="ref"  select="@idref"/>
-    <xsl:variable name="mailto"
-          select="document($resourceFile)/resources/human-resource[@id=$ref]/@mailto"/>
-   <xsl:variable name="name"
-          select="document($resourceFile)/resources/human-resource[@id=$ref]/@name"/>                          
-    <A href="mailto:{$mailto}"><xsl:value-of select="$name"/></A>
-  </xsl:template>
-
-<!-- ###################################################################### -->
-
-</xsl:stylesheet>
\ No newline at end of file
diff --git a/xdocs/style/stylesheets/done.xsl b/xdocs/style/stylesheets/done.xsl
deleted file mode 100644
index 8288ed8..0000000
--- a/xdocs/style/stylesheets/done.xsl
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-
-<!DOCTYPE xsl:stylesheet>
-
-<!-- XSL Style sheet, DTD omitted -->
-
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-  <xsl:output method="xml"/>
-  
-  <xsl:template match="Commits">
-  <xsl:comment>This XML fragment contains a list of source code updates to place in an &lt;s3&gt; section of readme.xml</xsl:comment>
-    <xsl:if test="count(Commit[@category='core'])>0">
-      <p>Core source code updates:</p>
-      <ul>
-      <xsl:for-each select="Commit[@category='core']">
-        <li><xsl:apply-templates select="Who|DateCommitted|Modified|Added|Removed|Log"/></li>
-      </xsl:for-each>
-      </ul>
-    </xsl:if>
-    <xsl:if test="count(Commit[@category='core'])=0">
-      <note>This release includes no updates of the core source code.</note>
-    </xsl:if>
-    <xsl:if test="count(Commit[@category='compat'])>0">
-      <p>Compatibility source code updates:</p>
-      <ul>
-      <xsl:for-each select="Commit[@category='compat']">
-        <li><xsl:apply-templates select="Who|DateCommitted|Modified|Added|Removed|Log"/></li>
-      </xsl:for-each>
-      </ul>
-    </xsl:if>
-    <xsl:if test="count(Commit[@category='compat'])=0">
-      <note>This release includes no updates of the compatibility source code.</note>
-    </xsl:if>
-  </xsl:template>
-  
-  <xsl:template match="Who">
-    <ref>Committed by </ref><xsl:value-of select="."/>
-  </xsl:template>
-  <xsl:template match="DateCommitted">
-    <ref> on </ref><xsl:value-of select="."/><br/>
-  </xsl:template>    
-  <xsl:template match="Modified">    
-    <ref>Modified: </ref><xsl:value-of select="."/><br/>
-  </xsl:template>    
-  <xsl:template match="Added">    
-    <ref>Added: </ref><xsl:value-of select="."/><br/>
-  </xsl:template>    
-  <xsl:template match="Removed">    
-    <ref>Removed: </ref><xsl:value-of select="."/><br/>
-  </xsl:template>    
-    <xsl:template match="Log">    
-    <ref>Committer's log entry: </ref><xsl:value-of select="."/><br/><br/>
-  </xsl:template>
-  
-</xsl:stylesheet>
\ No newline at end of file
diff --git a/xdocs/style/stylesheets/spec.xsl b/xdocs/style/stylesheets/spec.xsl
deleted file mode 100644
index 26d73bd..0000000
--- a/xdocs/style/stylesheets/spec.xsl
+++ /dev/null
@@ -1,220 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-
-<!DOCTYPE xsl:stylesheet [
-<!ENTITY copy   "&#169;">
-<!ENTITY nbsp   "&#160;">
-]>
-
-<!-- XSL Style sheet, DTD omitted -->
-
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                xmlns:redirect="org.apache.xalan.lib.Redirect"
-                extension-element-prefixes="redirect">
-  <xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>
-  
-  <xsl:param name="package-root" select="'../../../src/'"/>  <!-- root of destination for package.html files -->
-
-  <xsl:template match="spec">
-    <html>
-      <head>
-        <title>
-          <xsl:value-of select="header/title"/>
-        </title>
-      </head>
-      <body>
-        <xsl:apply-templates/>
-      </body>
-    </html>
-  </xsl:template>
-  
-  <xsl:template match="spec/title[1]">
-    <h1><xsl:apply-templates/></h1>
-  </xsl:template>
-
-  <xsl:template match="frontmatter/pubdate">
-    <p><b>Edit Date: </b><xsl:apply-templates/></p>
-  </xsl:template>
-
-  <xsl:template match="frontmatter/copyright">
-    <!-- p>&copy;<xsl:apply-templates/></p -->
-  </xsl:template>
-
-  <xsl:template match="frontmatter/author">
-  </xsl:template>
-  
-  <xsl:template match="spec/title">
-    <h2>
-      <xsl:choose>
-        <xsl:when test="@id">
-          <a name="@id">
-            <xsl:apply-templates/>
-          </a>
-        </xsl:when>
-        <xsl:otherwise>
-          <xsl:apply-templates/>
-        </xsl:otherwise>
-      </xsl:choose>
-    </h2>
-  </xsl:template>
-  
-  <xsl:template name="apply-id-templates">
-    <xsl:choose>
-      <xsl:when test="@id">
-        <a name="{@id}">
-          <xsl:apply-templates/>
-        </a>
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:apply-templates/>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-  
-  <xsl:template match="sect2/title | spec/*/title">
-    <h3>
-      <xsl:call-template name="apply-id-templates"/>
-    </h3>
-  </xsl:template>
-  
-  <xsl:template match="sect3/title">
-    <h4>
-      <xsl:call-template name="apply-id-templates"/>
-    </h4>
-  </xsl:template>
-
-  <xsl:template match="sect4/title">
-    <h5>
-      <xsl:call-template name="apply-id-templates"/>
-    </h5>
-  </xsl:template>
-  
-  <xsl:template match="para">
-    <p><xsl:apply-templates/></p>
-  </xsl:template>
-
-  <xsl:template match="variablelist">
-    <ul>
-    <xsl:for-each select="varlistentry">
-      <li>
-        <p><b><xsl:apply-templates select="term"/></b><br/>
-        <xsl:apply-templates select="listitem"/></p>
-      </li>
-    </xsl:for-each>
-    </ul>
-  </xsl:template>
-
-  <xsl:template match="orderedlist">
-    <ol>
-    <xsl:for-each select="listitem">
-      <li><xsl:apply-templates/></li>
-    </xsl:for-each>
-    </ol>
-  </xsl:template>
-
-  <xsl:template match="patterns">
-    <H3><xsl:value-of select="@module"/><xsl:text> </xsl:text>Patterns</H3>
-    <ul>
-      <xsl:for-each select="pattern">
-        <p>
-          <b>
-            <xsl:for-each select="pattern-name">
-              <xsl:call-template name="apply-id-templates"/>
-            </xsl:for-each>
-          </b>
-          <br/>
-        <xsl:apply-templates select="*[name() != 'pattern-name']"/></p>
-      </xsl:for-each>
-    </ul>
-  </xsl:template>
-  
-  <xsl:template match="pattern/intent">
-    <br/><i>Intent: </i><xsl:apply-templates/>
-  </xsl:template>
-  
-  <xsl:template match="pattern/responsibilities">
-    <br/><i>Responsibilities: </i><xsl:apply-templates/>
-  </xsl:template>
-
-  <xsl:template match="pattern/potential-alternate-name">
-    <br/><i>Potential alternate name: </i><xsl:apply-templates/>
-  </xsl:template>
-  
-  <xsl:template match="pattern/thread-safety">
-    <br/><i>Thread safety: </i><xsl:apply-templates/>
-  </xsl:template>
-
-  <xsl:template match="pattern/notes">
-    <br/><i>Notes: </i><xsl:apply-templates/>
-  </xsl:template>
-
-  <xsl:template match="programlisting">
-    <code>
-    <pre>
-      <xsl:apply-templates/>
-    </pre>
-    </code>
-  </xsl:template>
-  
-  <xsl:template match="link">
-    <A href="#{@linkend}">
-      <xsl:apply-templates/>
-    </A>
-  </xsl:template>
-  <xsl:template match="ulink">
-    <A href="{@url}">
-      <xsl:apply-templates/>
-    </A>
-  </xsl:template>
-
-  <xsl:template match="termref">
-    <xsl:choose>
-      <xsl:when test="@link-url">
-        <A href="#{@link-url}">
-          <xsl:value-of select="."/>
-        </A>
-      </xsl:when>
-      <xsl:otherwise>
-        <U><xsl:value-of select="."/></U>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-  
-  <xsl:template match="plink">
-    <xsl:text>{@link </xsl:text>
-      <xsl:value-of select="."/>
-    <xsl:text>}</xsl:text>
-  </xsl:template>
-  
-  <xsl:template match="sect1[@id='package']">
-    <xsl:variable name="filename" select="concat($package-root,translate(title,'.', '/'),'/package.html')"/>
-    <redirect:write file="{$filename}">
-      <xsl:call-template name="sub-package"/>
-    </redirect:write>
-  </xsl:template>
-  
-  <xsl:template match="sect2[@id='specialized-packages']">
-    <xsl:message>Found specialized-packages</xsl:message>
-    <xsl:for-each select="sect3">
-	  <xsl:variable name="filename" select="concat($package-root,translate(title,'.', '/'),'/package.html')"/>
-      <redirect:write file="{$filename}">
-        <xsl:call-template name="sub-package"/>
-      </redirect:write>
-    </xsl:for-each>
-  </xsl:template>
-  
-  <xsl:template name="sub-package">
-    <html>
-       <head>
-         <title>
-           <xsl:value-of select="title"/>
-         </title>
-       </head>
-       <body>
-         <xsl:apply-templates select="*[not (name()='title')]"/>
-       </body>
-     </html>
-  </xsl:template>
-
-
-</xsl:stylesheet>
-
diff --git a/xdocs/style/stylesheets/xml2fo.xsl b/xdocs/style/stylesheets/xml2fo.xsl
deleted file mode 100644
index c05930d..0000000
--- a/xdocs/style/stylesheets/xml2fo.xsl
+++ /dev/null
@@ -1,489 +0,0 @@
-<?xml version="1.0"?>
-
-<!--    XSLT stylesheet to convert the Xalan documentation collected in one xml file into a fo file
-        for use in FOP 
-
-TBD: - The faq doesn't show in the content
-     - check why margin-bottom on the page with properties is too large
-     - check why keep-next not only doesn't work, but leads to repeating already printed lines
-     - make lines containing only code look nicer (smaller line height)
-     - replace bullets in ordered lists with numbers
-     - correct the hack replacing nbsp with '-'
-     - handle the links correctly which have been external in the html doc and are now internal
-
--->
-
-<xsl:stylesheet
-     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
-     xmlns:fo="http://www.w3.org/1999/XSL/Format">
-     
-     <!-- to use with document() to get resources.xml -->
-    <xsl:param name="resourceFile" select="'../../sources/xalan/resources.xml'"/>
-    <xsl:param name="project" select="Xalan"/>
-              
-<xsl:template match ="/">
-	<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
-
-	  <!-- defines page layout -->
-	  <fo:layout-master-set>
-		<fo:simple-page-master master-name="simple"
-							   page-height="29.7cm" 
-							   page-width="21cm"
-							   margin-top="1.5cm" 
-							   margin-bottom="2cm" 
-							   margin-left="2.5cm" 
-							   margin-right="2.5cm">
-		  <fo:region-body margin-top="3cm"/>
-		  <fo:region-before extent="1.5cm"/>
-		  <fo:region-after extent="1.5cm"/>
-		</fo:simple-page-master>
-	  </fo:layout-master-set>
-
-	  <fo:page-sequence master-name="simple">
-		<fo:static-content flow-name="xsl-region-before">
-			<fo:block text-align="end" 
-			    	  font-size="10pt" 
-					  font-family="serif" 
-					  line-height="14pt" >
-				<xsl:value-of select="$project"/> documentation - p. <fo:page-number/>
-			</fo:block>
-		</fo:static-content> 
-
-		<fo:flow flow-name="xsl-region-body">
-
-          <fo:block font-size="18pt" 
-                    font-family="sans-serif" 
-                    line-height="24pt"
-                    space-after.optimum="15pt"
-                    background-color="blue"
-                    color="white"
-                    text-align="center">
-            <xsl:value-of select="$project"/> - an XSL Transformer
-          </fo:block>
-
-
-        <!-- generates table of contents and puts it into a table -->
-
-         <fo:block font-size="14pt" 
-                  font-family="sans-serif" 
-                  line-height="18pt"
-                  space-after.optimum="10pt"
-                  font-weight="bold"
-                  start-indent="15pt">
-            Content
-         </fo:block>
-
-         <fo:table>
-            <fo:table-column column-width="1cm"/>
-            <fo:table-column column-width="10cm"/>
-            <fo:table-column column-width="5cm"/>
-            <fo:table-body font-size="12pt" 
-                           line-height="16pt"
-                           font-family="sans-serif">
-              <fo:table-row>
-                  <fo:table-cell>
-                     <fo:block text-align="end" >
-                     </fo:block>
-                  </fo:table-cell>
-                  <fo:table-cell>
-                     <fo:block text-align="end" >
-                     </fo:block>
-                  </fo:table-cell>
-                  <fo:table-cell>
-                     <fo:block text-align="end" >
-                     page
-                     </fo:block>
-                  </fo:table-cell>
-              </fo:table-row>                                 
-              <xsl:for-each select="documentation/chapter"> 
-                <fo:table-row>
-                  <fo:table-cell>
-                     <fo:block text-align="end" >
-                        <xsl:number value="position()" format="I"/>.  
-                     </fo:block>
-                  </fo:table-cell>
-                  <fo:table-cell>
-                     <fo:block  text-align="start" >
-                        <fo:basic-link color="blue">
-                           <xsl:attribute name="internal-destination">
-                           <xsl:value-of select="@id"/>
-                           </xsl:attribute>
-                          <xsl:value-of select="s1/@title|faqs/@title"/>
-                        </fo:basic-link>
-                     </fo:block>
-                  </fo:table-cell>
-                  <fo:table-cell>
-                     <fo:block text-align="end">                                
-                       <fo:page-number-citation ref-id="{@id}"/>
-                     </fo:block>
-                  </fo:table-cell>
-               </fo:table-row>
-            </xsl:for-each>
-            </fo:table-body>
-         </fo:table>
-		 <xsl:apply-templates/> 
-	   </fo:flow>
-	   </fo:page-sequence>
-	</fo:root>
-</xsl:template>
-
-<!--chapter-->
-<xsl:template match="chapter">
-  <fo:block id="{@id}" break-before="page"/>
-	<xsl:apply-templates/>   
-</xsl:template>  
-
-<!-- s1 -->
-<xsl:template match ="s1">
-   <fo:block font-size="18pt" 
-            font-family="sans-serif" 
-            line-height="24pt"
-            space-before.optimum="15pt"
-            space-after.optimum="15pt"
-            background-color="blue"
-            color="white"
-            keep-with-next.within-page="always"
-            text-align="center">
-     <xsl:attribute name="id">
-     <xsl:value-of select="translate(@title,' ),-.(','____')"/>
-     </xsl:attribute>
-     <xsl:value-of select="@title"/>
-   </fo:block>
-    <xsl:apply-templates/> 
-</xsl:template>
-
-<!-- s2 -->
-<xsl:template match ="s2">
-   <fo:block font-size="16pt" 
-            font-family="sans-serif" 
-            line-height="20pt"
-            keep-with-next.within-page="always"            
-            space-before.optimum="15pt"
-            space-after.optimum="12pt"
-            text-align="start"
-            padding-top="3pt"
-            >
-     <xsl:value-of select="@title"/>
-   </fo:block>
-    <xsl:apply-templates/> 
-</xsl:template>
-
-<!-- s3 -->
-<xsl:template match ="s3">
-   <fo:block font-size="14pt" 
-            font-family="sans-serif" 
-            line-height="18pt"
-            keep-with-next.within-page="always"
-            space-before.optimum="10pt"
-            space-after.optimum="9pt"
-            text-align="start"
-            padding-top="3pt">
-     <xsl:value-of select="@title"/>
-   </fo:block>
-    <xsl:apply-templates/> 
-</xsl:template>
-
-<!-- p  [not(code)] -->
-<xsl:template match ="p"> 
-   <fo:block font-size="11pt" 
-            font-family="sans-serif" 
-            line-height="13pt"
-            space-after.optimum="3pt"
-            space-before.optimum="3pt"
-            text-align="start">
-     <xsl:apply-templates/> 
-   </fo:block>
-</xsl:template>
-
-<xsl:template match ="note"> 
-   <fo:block font-size="11pt" 
-            font-family="sans-serif" 
-            font-weight="italic"
-            line-height="13pt"
-            space-after.optimum="3pt"
-            space-before.optimum="3pt"
-            text-align="start">
-        Note:     
-     <xsl:apply-templates/> 
-   </fo:block>
-</xsl:template>
-
-<xsl:template match="anchor">
-  <fo:block> <!--id="concat(local-name(ancestor::node()="chapter"/@id.,'_',{./@name}"/-->
-    <xsl:attribute name="id">
-      <xsl:value-of select="concat(ancestor::chapter/@id,'_',./@name)"/>
-    </xsl:attribute>
-  </fo:block>    
-</xsl:template>
-
-<xsl:template match="table">
-  <xsl:variable name="colwidth" select="14.5 div count(tr[1]/td)"/>
-  <fo:table>
-  <xsl:for-each select="tr[1]/td">
-    <fo:table-column column-width="{$colwidth}cm"/>
-  </xsl:for-each>
-  <fo:table-body font-size="10pt" font-family="sans-serif">
-  <xsl:apply-templates/>
-  </fo:table-body>
-  </fo:table>  
-</xsl:template>  
-<xsl:template match="tr">
-  <fo:table-row>
-    <xsl:apply-templates/>
-  </fo:table-row>
-</xsl:template>
-<xsl:template match="td">
-  <fo:table-cell>
-    <fo:block>
-      <xsl:apply-templates/>
-    </fo:block>
-   </fo:table-cell>
-</xsl:template>
-
-<!-- p + code 
-<xsl:template match ="p[code]">
-   <fo:block font-size="11pt" 
-            font-family="sans-serif" 
-            line-height="11pt"
-            space-after.optimum="0pt"
-            space-before.optimum="0pt"
-            text-align="start">
-     <xsl:apply-templates/> 
-   </fo:block>
-</xsl:template>
--->
-
-<xsl:template match="img">
-  <fo:block>
-    <fo:external-graphic src="file:build/docs/images/{@src}"/>
-  </fo:block>
-</xsl:template>
-
-<!-- faqs -->
-<xsl:template match ="faqs">
-   <fo:block font-size="18pt" 
-            font-family="sans-serif" 
-            line-height="24pt"
-            space-before.optimum="15pt"
-            space-after.optimum="15pt"
-            background-color="blue"
-            color="white"
-            text-align="center"
-            >
-     <xsl:attribute name="id">
-     <xsl:value-of select="translate(.,' ),-.(','____')"/>
-     </xsl:attribute>
-     <xsl:value-of select="@title"/>
-   </fo:block>
-    <xsl:apply-templates/> 
-</xsl:template>
-
-<!-- faq -->
-<xsl:template match ="faq">
-    <xsl:apply-templates/> 
-</xsl:template>
-
-<!-- q in faq -->
-<xsl:template match="q">
-   <fo:block font-size="14pt" 
-            font-family="sans-serif" 
-            line-height="18pt"
-            keep-with-next.within-page="always"
-            space-before.optimum="10pt"
-            space-after.optimum="9pt"
-            text-align="start"
-            padding-top="3pt">     
-      <xsl:apply-templates/> 
-    </fo:block>
-</xsl:template>
-
-<!-- a in faq -->
-<xsl:template match ="a">
-      <xsl:apply-templates/> 
-</xsl:template>
-
-
-<!-- jump (links) -->
-<xsl:template match ="jump">
-  <fo:basic-link color="blue">
-     <xsl:attribute name="external-destination">
-       <xsl:if test="starts-with(@href,'apidocs')">
-         <xsl:value-of select="concat('http://xml.apache.org/xalan-j/',@href)"/>
-       </xsl:if>
-       <xsl:if test="not(starts-with(@href,'apidocs'))">
-         <xsl:value-of select="@href"/>
-       </xsl:if>    
-     </xsl:attribute>  
-   <xsl:value-of select="./text()"/>
-     <!--xsl:apply-templates/--> 
-   </fo:basic-link>
-</xsl:template>
-
-  <xsl:template match="link">
-    <xsl:if test="string-length(@anchor)=0">
-      <xsl:if test="string-length(@idref)=0">
-        <xsl:apply-templates/>
-      </xsl:if>
-      <xsl:if test="string-length(@idref)>0">
-        <fo:basic-link color="blue" internal-destination="{@idref}">
-        <xsl:value-of select="./text()"/></fo:basic-link>
-      </xsl:if>
-    </xsl:if>
-
-    <xsl:if test="string-length(@anchor)>0">
-      <xsl:if test="string-length(@idref)=0">
-        <fo:basic-link color="blue"
-                      internal-destination="{concat(ancestor::chapter/@id,'_',@anchor)}">
-        <xsl:value-of select="./text()"/></fo:basic-link>
-      </xsl:if>
-      <xsl:if test="string-length(@idref)>0">
-        <fo:basic-link color="blue" internal-destination="{@idref}_{@anchor}">
-        <xsl:value-of select="./text()"/></fo:basic-link>
-      </xsl:if>
-    </xsl:if>
-  </xsl:template>
-
-
-<xsl:template match="resource-ref">
-  <xsl:variable name="xref" select="@idref"/>
-  <xsl:variable name="href"
-          select="document($resourceFile)/resources/resource[@id=$xref]/@location"/>
-  <xsl:variable name="label"
-          select="document($resourceFile)/resources/resource[@id=$xref]/@title"/>
-  <fo:basic-link color="blue">
-     <xsl:attribute name="external-destination">
-       <xsl:if test="starts-with($href,'apidocs')">
-         <xsl:value-of select="concat('http://xml.apache.org/xalan-j/',$href)"/>
-       </xsl:if>
-       <xsl:if test="not(starts-with($href,'apidocs'))">
-         <xsl:value-of select="$href"/>
-       </xsl:if>    
-     </xsl:attribute>  
-     <xsl:value-of select="$label"/>
-     <!--xsl:apply-templates/--> 
-   </fo:basic-link>        
-  </xsl:template>
-
-  <xsl:template match="human-resource-ref">
-    <xsl:variable name="resourceFile" 
-          select="./xalan/resources.xml"/>  
-    <xsl:variable name="ref"  select="@idref"/>
-    <xsl:variable name="mailto"
-          select="document($resourceFile)/resources/human-resource[@id=$ref]/@mailto"/>
-    <xsl:variable name="name"
-          select="document($resourceFile)/resources/human-resource[@id=$ref]/@name"/>
-  <fo:basic-link color="blue" external-destination="mailto:{$mailto}">
-     <xsl:value-of select="$name"/>
-     <!--xsl:apply-templates/--> 
-   </fo:basic-link>          
-  </xsl:template>
-
-<xsl:template match ="source"> 
-   <fo:block font-size="10pt" 
-            font-family="Courier" 
-            text-align="start"
-            white-space-collapse="false">
-     <xsl:apply-templates/> 
-   </fo:block>
-
-</xsl:template>
-  <xsl:template match ="br">
-  <fo:block></fo:block>
-</xsl:template>
-
-<!-- code -->
-<xsl:template match ="*/code">
-   <fo:inline font-size="10pt" 
-            font-family="Courier">
-     <xsl:apply-templates/> 
-   </fo:inline>
-</xsl:template>
-
-<!-- ul (unordered list) -->
-<xsl:template match ="ul">
-  <fo:list-block start-indent="1cm" 
-                 provisional-distance-between-starts="12pt" 
-                 font-family="sans-serif" 
-                 font-size="11pt" 
-                 line-height="11pt">
-     <xsl:apply-templates/> 
-   </fo:list-block>
-</xsl:template>         
-          
-<!-- ol (ordered list) -->
-<xsl:template match ="ol">
-  <fo:list-block start-indent="1cm" 
-                 provisional-distance-between-starts="12pt" 
-                 font-family="sans-serif" 
-                 font-size="11pt" 
-                 line-height="11pt">
-     <xsl:apply-templates/> 
-   </fo:list-block>
-</xsl:template>
-
-
-<!-- li (list item) in unordered list -->
-<xsl:template match ="ul/li">
-    <fo:list-item>
-      <fo:list-item-label>
-        <fo:block><fo:inline font-family="Symbol">&#183;</fo:inline></fo:block>
-      </fo:list-item-label>
-      <fo:list-item-body>
-        <fo:block space-after.optimum="4pt"
-              text-align="start"
-              padding-top="3pt">
-          <xsl:apply-templates/> 
-       </fo:block>
-      </fo:list-item-body>
-    </fo:list-item>
-</xsl:template>
-
-<!-- li (list item) in ordered list -->
-<xsl:template match ="ol/li">
-    <fo:list-item>
-      <fo:list-item-label>
-        <fo:block>
-          <xsl:number level="multiple" count="li" format="1"/>)
-        </fo:block>
-      </fo:list-item-label>
-      <fo:list-item-body>
-        <fo:block space-after.optimum="4pt"
-              text-align="start"
-              padding-top="3pt">
-          <xsl:apply-templates/> 
-       </fo:block>
-      </fo:list-item-body>
-    </fo:list-item>
-</xsl:template>
-
-<!-- temporary kludge for definition list gloss with label-item pairs ) -->
-
-<xsl:template match="gloss">
-  <xsl:apply-templates/>
-</xsl:template>
-<xsl:template match="label">
-   <fo:block font-size="11pt" 
-            font-family="sans-serif" 
-            line-height="13pt"
-            space-after.optimum="3pt"
-            space-before.optimum="6pt"
-            text-align="start">
-     <xsl:apply-templates/> 
-   </fo:block>
-</xsl:template> 
-<xsl:template match="item">
-   <fo:block font-size="11pt" 
-            font-family="sans-serif" 
-            line-height="13pt"
-            space-after.optimum="6pt"
-            space-before.optimum="0pt"
-            margin-left="24pt"
-            text-align="start">
-     <xsl:apply-templates/>
-     <fo:block></fo:block> 
-   </fo:block>
-</xsl:template> 
-
-<!-- end body -->
-
-</xsl:stylesheet>
diff --git a/xdocs/xml-site-style.tar.gz b/xdocs/xml-site-style.tar.gz
deleted file mode 100644
index e2c4de3..0000000
--- a/xdocs/xml-site-style.tar.gz
+++ /dev/null
Binary files differ