Reconcile with honeycomb-release

Change-Id: I2716b91f5b133ffd4b908227315129a5041fb3c6
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..8449e9d
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,42 @@
+#
+# Copyright (C) 2011 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+LOCAL_PATH := $(call my-dir)
+
+apache-xml_src_files := $(call all-java-files-under,src/main/java)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := apache-xml
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := $(apache-xml_src_files)
+LOCAL_JAVACFLAGS := -encoding UTF-8
+LOCAL_JAVA_LIBRARIES := core
+LOCAL_NO_STANDARD_LIBRARIES := true
+LOCAL_JAVA_RESOURCE_DIRS := src/main/java
+include $(BUILD_JAVA_LIBRARY)
+
+ifeq ($(WITH_HOST_DALVIK),true)
+    include $(CLEAR_VARS)
+    LOCAL_MODULE := apache-xml-hostdex
+    LOCAL_MODULE_TAGS := optional
+    LOCAL_SRC_FILES := $(apache-xml_src_files)
+    LOCAL_JAVACFLAGS := -encoding UTF-8
+    LOCAL_JAVA_LIBRARIES := core-hostdex
+    LOCAL_NO_STANDARD_LIBRARIES := true
+    LOCAL_BUILD_HOST_DEX := true
+    LOCAL_MODULE_TAGS := optional
+    LOCAL_JAVA_RESOURCE_DIRS := src/main/java
+    include $(BUILD_HOST_JAVA_LIBRARY)
+endif
diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MODULE_LICENSE_APACHE2
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..097bafb
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,80 @@
+   =========================================================================
+   ==  NOTICE file corresponding to section 4(d) of the Apache License,   ==
+   ==  Version 2.0, in this case for the Apache Xalan Java distribution.  ==
+   =========================================================================
+
+   Apache Xalan (Xalan XSLT processor)
+   Copyright 1999-2006 The Apache Software Foundation
+
+   Apache Xalan (Xalan serializer)
+   Copyright 1999-2006 The Apache Software Foundation
+
+   This product includes software developed at
+   The Apache Software Foundation (http://www.apache.org/).
+
+   =========================================================================
+   Portions of this software was originally based on the following:
+     - software copyright (c) 1999-2002, Lotus Development Corporation.,
+       http://www.lotus.com.
+     - software copyright (c) 2001-2002, Sun Microsystems.,
+       http://www.sun.com.
+     - software copyright (c) 2003, IBM Corporation., 
+       http://www.ibm.com.
+       
+   =========================================================================
+   The binary distribution package (ie. jars, samples and documentation) of
+   this product includes software developed by the following:
+       
+     - The Apache Software Foundation 
+         - Xerces Java - see LICENSE.txt 
+         - JAXP 1.3 APIs - see LICENSE.txt
+         - Bytecode Engineering Library - see LICENSE.txt
+         - Regular Expression - see LICENSE.txt
+       
+     - Scott Hudson, Frank Flannery, C. Scott Ananian 
+         - CUP Parser Generator runtime (javacup\runtime) - see LICENSE.txt 
+ 
+   ========================================================================= 
+   The source distribution package (ie. all source and tools required to build
+   Xalan Java) of this product includes software developed by the following:
+       
+     - The Apache Software Foundation
+         - Xerces Java - see LICENSE.txt 
+         - JAXP 1.3 APIs - see LICENSE.txt
+         - Bytecode Engineering Library - see LICENSE.txt
+         - Regular Expression - see LICENSE.txt
+         - Ant - see LICENSE.txt
+         - Stylebook doc tool - see LICENSE.txt    
+       
+     - Elliot Joel Berk and C. Scott Ananian 
+         - Lexical Analyzer Generator (JLex) - see LICENSE.txt
+
+   =========================================================================       
+   Apache Xerces Java
+   Copyright 1999-2006 The Apache Software Foundation
+
+   This product includes software developed at
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Portions of Apache Xerces Java in xercesImpl.jar and xml-apis.jar
+   were originally based on the following:
+     - software copyright (c) 1999, IBM Corporation., http://www.ibm.com.
+     - software copyright (c) 1999, Sun Microsystems., http://www.sun.com.
+     - voluntary contributions made by Paul Eng on behalf of the 
+       Apache Software Foundation that were originally developed at iClick, Inc.,
+       software copyright (c) 1999.    
+
+   =========================================================================   
+   Apache xml-commons xml-apis (redistribution of xml-apis.jar)
+
+   Apache XML Commons
+   Copyright 2001-2003,2006 The Apache Software Foundation.
+
+   This product includes software developed at
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Portions of this software were originally based on the following:
+     - software copyright (c) 1999, IBM Corporation., http://www.ibm.com.
+     - software copyright (c) 1999, Sun Microsystems., http://www.sun.com.
+     - software copyright (c) 2000 World Wide Web Consortium, http://www.w3.org
+
diff --git a/ThirdPartyProject.prop b/ThirdPartyProject.prop
new file mode 100644
index 0000000..0657faa
--- /dev/null
+++ b/ThirdPartyProject.prop
@@ -0,0 +1,12 @@
+currentVersion=889881,901014
+version=889881,901014
+isNative=false
+name=apache-xml
+keywords=apache xml commons xalan xslt xpath validation
+onDevice=true
+homepage=http://xml.apache.org/xalan-j/
+xalanSvn=http://svn.apache.org/repos/asf/xalan/java/trunk
+xalanSvnRev=889881
+xmlCommonsSvn=http://svn.apache.org/repos/asf/xml/commons/trunk
+xmlCommonsSvnRef=901014
+
diff --git a/src/main/java/org/apache/xalan/Version.java b/src/main/java/org/apache/xalan/Version.java
new file mode 100644
index 0000000..23e8fbe
--- /dev/null
+++ b/src/main/java/org/apache/xalan/Version.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: Version.java 577939 2007-09-20 21:45:37Z minchau $
+ */
+package org.apache.xalan;
+
+/**
+ * Administrative class to keep track of the version number of
+ * the Xalan release.
+ * <P>This class implements the upcoming standard of having
+ * org.apache.project-name.Version.getVersion() be a standard way 
+ * to get version information.  This class will replace the older 
+ * org.apache.xalan.processor.Version class.</P>
+ * <P>See also: org/apache/xalan/res/XSLTInfo.properties for 
+ * information about the version of the XSLT spec we support.</P>
+ * @xsl.usage general
+ */
+public class Version
+{
+
+  /**
+   * Get the basic version string for the current Xalan release.
+   * Version String formatted like 
+   * <CODE>"<B>Xalan</B> <B>Java</B> v.r[.dd| <B>D</B>nn]"</CODE>.
+   *
+   * Futurework: have this read version info from jar manifest.
+   *
+   * @return String denoting our current version
+   */
+  public static String getVersion()
+  {
+     return getProduct()+" "+getImplementationLanguage()+" "
+           +getMajorVersionNum()+"."+getReleaseVersionNum()+"."
+           +( (getDevelopmentVersionNum() > 0) ? 
+               ("D"+getDevelopmentVersionNum()) : (""+getMaintenanceVersionNum()));  
+  }
+
+  /**
+   * Print the processor version to the command line.
+   *
+   * @param argv command line arguments, unused.
+   */
+  public static void main(String argv[])
+  {
+    System.out.println(getVersion());
+  }
+  
+  /**
+   * Name of product: Xalan.
+   */
+  public static String getProduct()
+  {
+    return "Xalan";
+  }
+
+  /**
+   * Implementation Language: Java.
+   */
+  public static String getImplementationLanguage()
+  {
+    return "Java";
+  }
+  
+  
+  /**
+   * Major version number.
+   * Version number. This changes only when there is a
+   *          significant, externally apparent enhancement from
+   *          the previous release. 'n' represents the n'th
+   *          version.
+   *
+   *          Clients should carefully consider the implications
+   *          of new versions as external interfaces and behaviour
+   *          may have changed.
+   */
+  public static int getMajorVersionNum()
+  {
+    return 2;
+    
+  }  
+
+  /**
+   * Release Number.
+   * Release number. This changes when:
+   *            -  a new set of functionality is to be added, eg,
+   *               implementation of a new W3C specification.
+   *            -  API or behaviour change.
+   *            -  its designated as a reference release.
+   */
+  public static int getReleaseVersionNum()
+  {
+    return 7;
+  }
+  
+  /**
+   * Maintenance Drop Number.
+   * Optional identifier used to designate maintenance
+   *          drop applied to a specific release and contains
+   *          fixes for defects reported. It maintains compatibility
+   *          with the release and contains no API changes.
+   *          When missing, it designates the final and complete
+   *          development drop for a release.
+   */
+  public static int getMaintenanceVersionNum()
+  {
+    return 1;
+  }
+
+  /**
+   * Development Drop Number.
+   * Optional identifier designates development drop of
+   *          a specific release. D01 is the first development drop
+   *          of a new release.
+   *
+   *          Development drops are works in progress towards a
+   *          compeleted, final release. A specific development drop
+   *          may not completely implement all aspects of a new
+   *          feature, which may take several development drops to
+   *          complete. At the point of the final drop for the
+   *          release, the D suffix will be omitted.
+   *
+   *          Each 'D' drops can contain functional enhancements as
+   *          well as defect fixes. 'D' drops may not be as stable as
+   *          the final releases.
+   */
+  public static int getDevelopmentVersionNum()
+  { 
+    try {   
+        if ((new String("")).length() == 0)
+          return 0;
+        else  
+          return Integer.parseInt("");
+    } catch (NumberFormatException nfe) {
+           return 0;
+    }    
+  }      
+}
diff --git a/src/main/java/org/apache/xalan/Version.src b/src/main/java/org/apache/xalan/Version.src
new file mode 100644
index 0000000..f1fb77e
--- /dev/null
+++ b/src/main/java/org/apache/xalan/Version.src
@@ -0,0 +1,153 @@
+/*

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements. See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership. The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the  "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *     http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

+/*

+ * $Id$

+ */

+package org.apache.xalan;

+

+/**

+ * Administrative class to keep track of the version number of

+ * the Xalan release.

+ * <P>This class implements the upcoming standard of having

+ * org.apache.project-name.Version.getVersion() be a standard way 

+ * to get version information.  This class will replace the older 

+ * org.apache.xalan.processor.Version class.</P>

+ * <P>See also: org/apache/xalan/res/XSLTInfo.properties for 

+ * information about the version of the XSLT spec we support.</P>

+ * @xsl.usage general

+ */

+public class Version

+{

+

+  /**

+   * Get the basic version string for the current Xalan release.

+   * Version String formatted like 

+   * <CODE>"<B>Xalan</B> <B>Java</B> v.r[.dd| <B>D</B>nn]"</CODE>.

+   *

+   * Futurework: have this read version info from jar manifest.

+   *

+   * @return String denoting our current version

+   */

+  public static String getVersion()

+  {

+     return getProduct()+" "+getImplementationLanguage()+" "

+           +getMajorVersionNum()+"."+getReleaseVersionNum()+"."

+           +( (getDevelopmentVersionNum() > 0) ? 

+               ("D"+getDevelopmentVersionNum()) : (""+getMaintenanceVersionNum()));  

+  }

+

+  /**

+   * Print the processor version to the command line.

+   *

+   * @param argv command line arguments, unused.

+   */

+  public static void main(String argv[])

+  {

+    System.out.println(getVersion());

+  }

+  

+  /**

+   * Name of product: Xalan.

+   */

+  public static String getProduct()

+  {

+    return "Xalan";

+  }

+

+  /**

+   * Implementation Language: Java.

+   */

+  public static String getImplementationLanguage()

+  {

+    return "Java";

+  }

+  

+  

+  /**

+   * Major version number.

+   * Version number. This changes only when there is a

+   *          significant, externally apparent enhancement from

+   *          the previous release. 'n' represents the n'th

+   *          version.

+   *

+   *          Clients should carefully consider the implications

+   *          of new versions as external interfaces and behaviour

+   *          may have changed.

+   */

+  public static int getMajorVersionNum()

+  {

+    return @version.VERSION@;

+    

+  }  

+

+  /**

+   * Release Number.

+   * Release number. This changes when:

+   *            -  a new set of functionality is to be added, eg,

+   *               implementation of a new W3C specification.

+   *            -  API or behaviour change.

+   *            -  its designated as a reference release.

+   */

+  public static int getReleaseVersionNum()

+  {

+    return @version.RELEASE@;

+  }

+  

+  /**

+   * Maintenance Drop Number.

+   * Optional identifier used to designate maintenance

+   *          drop applied to a specific release and contains

+   *          fixes for defects reported. It maintains compatibility

+   *          with the release and contains no API changes.

+   *          When missing, it designates the final and complete

+   *          development drop for a release.

+   */

+  public static int getMaintenanceVersionNum()

+  {

+    return @version.MINOR@;

+  }

+

+  /**

+   * Development Drop Number.

+   * Optional identifier designates development drop of

+   *          a specific release. D01 is the first development drop

+   *          of a new release.

+   *

+   *          Development drops are works in progress towards a

+   *          compeleted, final release. A specific development drop

+   *          may not completely implement all aspects of a new

+   *          feature, which may take several development drops to

+   *          complete. At the point of the final drop for the

+   *          release, the D suffix will be omitted.

+   *

+   *          Each 'D' drops can contain functional enhancements as

+   *          well as defect fixes. 'D' drops may not be as stable as

+   *          the final releases.

+   */

+  public static int getDevelopmentVersionNum()

+  { 

+    try {   

+        if ((new String("@version.DEVELOPER@")).length() == 0)

+          return 0;

+        else  

+          return Integer.parseInt("@version.DEVELOPER@");

+    } catch (NumberFormatException nfe) {

+           return 0;

+    }    

+  }      

+}

diff --git a/src/main/java/org/apache/xalan/extensions/ExpressionContext.java b/src/main/java/org/apache/xalan/extensions/ExpressionContext.java
new file mode 100644
index 0000000..b40bb9a
--- /dev/null
+++ b/src/main/java/org/apache/xalan/extensions/ExpressionContext.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ExpressionContext.java 468637 2006-10-28 06:51:02Z minchau $
+ */
+package org.apache.xalan.extensions;
+
+import javax.xml.transform.ErrorListener;
+
+import org.apache.xpath.objects.XObject;
+import org.w3c.dom.Node;
+import org.w3c.dom.traversal.NodeIterator;
+
+/**
+ * An object that implements this interface can supply
+ * information about the current XPath expression context.
+ */
+public interface ExpressionContext
+{
+
+  /**
+   * Get the current context node.
+   * @return The current context node.
+   */
+  public Node getContextNode();
+
+  /**
+   * Get the current context node list.
+   * @return An iterator for the current context list, as
+   * defined in XSLT.
+   */
+  public NodeIterator getContextNodes();
+  
+  /**
+   * Get the error listener.
+   * @return The registered error listener.
+   */
+  public ErrorListener getErrorListener();
+
+  /**
+   * 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(Node n);
+
+  /**
+   * 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(Node n);
+
+  /**
+   * Get a variable based on it's qualified name.
+   *
+   * @param qname The qualified name of the variable.
+   *
+   * @return The evaluated value of the variable.
+   *
+   * @throws javax.xml.transform.TransformerException
+   */
+  public XObject getVariableOrParam(org.apache.xml.utils.QName qname)
+            throws javax.xml.transform.TransformerException;
+  
+  /**
+   * Get the XPathContext that owns this ExpressionContext.
+   * 
+   * Note: exslt:function requires the XPathContext to access
+   * the variable stack and TransformerImpl.
+   * 
+   * @return The current XPathContext.
+   * @throws javax.xml.transform.TransformerException
+   */
+  public org.apache.xpath.XPathContext getXPathContext()
+            throws javax.xml.transform.TransformerException;
+
+}
diff --git a/src/main/java/org/apache/xalan/extensions/ExpressionVisitor.java b/src/main/java/org/apache/xalan/extensions/ExpressionVisitor.java
new file mode 100644
index 0000000..cd895df
--- /dev/null
+++ b/src/main/java/org/apache/xalan/extensions/ExpressionVisitor.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ExpressionVisitor.java 468637 2006-10-28 06:51:02Z minchau $
+ */
+package org.apache.xalan.extensions;
+
+import org.apache.xalan.templates.StylesheetRoot;
+import org.apache.xpath.ExpressionOwner;
+import org.apache.xpath.XPathVisitor;
+import org.apache.xpath.functions.FuncExtFunction;
+import org.apache.xpath.functions.FuncExtFunctionAvailable;
+import org.apache.xpath.functions.Function;
+
+/**
+ * When {@link org.apache.xalan.processor.StylesheetHandler} creates 
+ * an {@link org.apache.xpath.XPath}, the ExpressionVisitor
+ * visits the XPath expression. For any extension functions it 
+ * encounters, it instructs StylesheetRoot to register the
+ * extension namespace. 
+ * 
+ * This mechanism is required to locate extension functions
+ * that may be embedded within an expression.
+ */
+public class ExpressionVisitor extends XPathVisitor
+{
+  private StylesheetRoot m_sroot;
+  
+  /**
+   * The constructor sets the StylesheetRoot variable which
+   * is used to register extension namespaces.
+   * @param sroot the StylesheetRoot that is being constructed.
+   */
+  public ExpressionVisitor (StylesheetRoot sroot)
+  {
+    m_sroot = sroot;
+  }
+  
+  /**
+   * If the function is an extension function, register the namespace.
+   * 
+   * @param owner The current XPath object that owns the expression.
+   * @param func The function currently being visited.
+   * 
+   * @return true to continue the visit in the subtree, if any.
+   */
+  public boolean visitFunction(ExpressionOwner owner, Function func)
+  {
+    if (func instanceof FuncExtFunction)
+    {
+      String namespace = ((FuncExtFunction)func).getNamespace();
+      m_sroot.getExtensionNamespacesManager().registerExtension(namespace);      
+    }
+    else if (func instanceof FuncExtFunctionAvailable)
+    {
+      String arg = ((FuncExtFunctionAvailable)func).getArg0().toString();
+      if (arg.indexOf(":") > 0)
+      {
+      	String prefix = arg.substring(0,arg.indexOf(":"));
+      	String namespace = this.m_sroot.getNamespaceForPrefix(prefix);
+      	m_sroot.getExtensionNamespacesManager().registerExtension(namespace);
+      }
+    }
+    return true;
+  }
+
+}
diff --git a/src/main/java/org/apache/xalan/extensions/ExtensionHandler.java b/src/main/java/org/apache/xalan/extensions/ExtensionHandler.java
new file mode 100644
index 0000000..9c46e8a
--- /dev/null
+++ b/src/main/java/org/apache/xalan/extensions/ExtensionHandler.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ExtensionHandler.java 468637 2006-10-28 06:51:02Z minchau $
+ */
+package org.apache.xalan.extensions;
+
+import java.io.IOException;
+import java.util.Vector;
+
+import javax.xml.transform.TransformerException;
+
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xalan.templates.Stylesheet;
+import org.apache.xalan.transformer.TransformerImpl;
+import org.apache.xpath.functions.FuncExtFunction;
+
+/**
+ * Abstract base class for handling an extension namespace for XPath.
+ * Provides functions to test a function's existence and call a function.
+ * Also provides functions for calling an element and testing for
+ * an element's existence.
+ *
+ * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
+ * @xsl.usage internal
+ */
+public abstract class ExtensionHandler
+{
+
+  /** uri of the extension namespace */
+  protected String m_namespaceUri; 
+
+  /** scripting language of implementation */
+  protected String m_scriptLang;
+
+  /**
+   * This method loads a class using the context class loader if we're
+   * running under Java2 or higher.
+   * 
+   * @param className Name of the class to load
+   */
+  static Class getClassForName(String className)
+      throws ClassNotFoundException
+  {
+    // Hack for backwards compatibility with XalanJ1 stylesheets
+    if(className.equals("org.apache.xalan.xslt.extensions.Redirect")) {
+      className = "org.apache.xalan.lib.Redirect";
+    }
+
+    return ObjectFactory.findProviderClass(
+        className, ObjectFactory.findClassLoader(), true);
+  }
+
+  /**
+   * Construct a new extension namespace handler given all the information
+   * needed.
+   *
+   * @param namespaceUri the extension namespace URI that I'm implementing
+   * @param scriptLang   language of code implementing the extension
+   */
+  protected ExtensionHandler(String namespaceUri, String scriptLang)
+  {
+    m_namespaceUri = namespaceUri;
+    m_scriptLang = scriptLang;
+  }
+
+  /**
+   * Tests whether a certain function name is known within this namespace.
+   * @param function name of the function being tested
+   * @return true if its known, false if not.
+   */
+  public abstract boolean isFunctionAvailable(String function);
+
+  /**
+   * Tests whether a certain element name is known within this namespace.
+   * @param element Name of element to check
+   * @return true if its known, false if not.
+   */
+  public abstract boolean isElementAvailable(String element);
+
+  /**
+   * Process a call to a function.
+   *
+   * @param funcName Function name.
+   * @param args     The arguments of the function call.
+   * @param methodKey A key that uniquely identifies this class and method call.
+   * @param exprContext The context in which this expression is being executed.
+   *
+   * @return the return value of the function evaluation.
+   *
+   * @throws TransformerException          if parsing trouble
+   */
+  public abstract Object callFunction(
+    String funcName, Vector args, Object methodKey,
+      ExpressionContext exprContext) throws TransformerException;
+
+  /**
+   * Process a call to a function.
+   *
+   * @param extFunction The XPath extension function.
+   * @param args     The arguments of the function call.
+   * @param exprContext The context in which this expression is being executed.
+   *
+   * @return the return value of the function evaluation.
+   *
+   * @throws TransformerException          if parsing trouble
+   */
+  public abstract Object callFunction(
+    FuncExtFunction extFunction, Vector args,
+      ExpressionContext exprContext) throws TransformerException;
+
+  /**
+   * Process a call to this extension namespace via an element. As a side
+   * effect, the results are sent to the TransformerImpl's result tree.
+   *
+   * @param localPart      Element name's local part.
+   * @param element        The extension element being processed.
+   * @param transformer    Handle to TransformerImpl.
+   * @param stylesheetTree The compiled stylesheet tree.
+   * @param methodKey      A key that uniquely identifies this class and method call.
+   *
+   * @throws XSLProcessorException thrown if something goes wrong
+   *            while running the extension handler.
+   * @throws MalformedURLException if loading trouble
+   * @throws FileNotFoundException if loading trouble
+   * @throws IOException           if loading trouble
+   * @throws TransformerException  if parsing trouble
+   */
+  public abstract void processElement(
+    String localPart, ElemTemplateElement element, TransformerImpl transformer,
+      Stylesheet stylesheetTree, Object methodKey) throws TransformerException, IOException;
+}
diff --git a/src/main/java/org/apache/xalan/extensions/ExtensionNamespaceSupport.java b/src/main/java/org/apache/xalan/extensions/ExtensionNamespaceSupport.java
new file mode 100644
index 0000000..8ad232f
--- /dev/null
+++ b/src/main/java/org/apache/xalan/extensions/ExtensionNamespaceSupport.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ExtensionNamespaceSupport.java 468637 2006-10-28 06:51:02Z minchau $
+ */
+package org.apache.xalan.extensions;
+
+import java.lang.reflect.Constructor;
+
+import javax.xml.transform.TransformerException;
+
+/**
+ * During styleseet composition, an ExtensionNamespaceSupport object is created for each extension 
+ * namespace the stylesheet uses. At the beginning of a transformation, TransformerImpl generates
+ * an ExtensionHandler for each of these objects and adds an entry to the ExtensionsTable hashtable.
+ */
+public class ExtensionNamespaceSupport
+{
+  // Namespace, ExtensionHandler class name, constructor signature 
+  // and arguments.
+  String m_namespace = null;
+  String m_handlerClass = null;
+  Class [] m_sig = null;  
+  Object [] m_args = null;
+ 
+  public ExtensionNamespaceSupport(String namespace, 
+                                   String handlerClass, 
+                                   Object[] constructorArgs)
+  {
+    m_namespace = namespace;
+    m_handlerClass = handlerClass;
+    m_args = constructorArgs;
+    // Create the constructor signature.
+    m_sig = new Class[m_args.length];
+    for (int i = 0; i < m_args.length; i++)
+    {
+      if (m_args[i] != null)
+        m_sig[i] = m_args[i].getClass();//System.out.println("arg class " + i + " " +m_sig[i]);
+      else // If an arguments is null, pick the constructor later.
+      {
+        m_sig = null;
+        break;
+      }
+    }
+  }
+  
+  public String getNamespace()
+  {
+    return m_namespace;
+  }
+  
+  /**
+   * Launch the ExtensionHandler that this ExtensionNamespaceSupport object defines.
+   */
+  public ExtensionHandler launch()
+    throws TransformerException
+  {
+    ExtensionHandler handler = null;
+    try
+    {
+      Class cl = ExtensionHandler.getClassForName(m_handlerClass);
+      Constructor con = null;
+      //System.out.println("class " + cl + " " + m_args + " " + m_args.length + " " + m_sig);
+      if (m_sig != null)
+        con = cl.getConstructor(m_sig);
+      else // Pick the constructor based on number of args.
+      {
+        Constructor[] cons = cl.getConstructors();
+        for (int i = 0; i < cons.length; i ++)
+        {
+          if (cons[i].getParameterTypes().length == m_args.length)
+          {
+            con = cons[i];
+            break;
+          }
+        }
+      }
+      // System.out.println("constructor " + con);
+      if (con != null)
+        handler = (ExtensionHandler)con.newInstance(m_args);
+      else
+        throw new TransformerException("ExtensionHandler constructor not found");
+    }
+    catch (Exception e)
+    {
+      throw new TransformerException(e);
+    }
+    return handler;
+  }
+
+}
diff --git a/src/main/java/org/apache/xalan/extensions/ExtensionNamespacesManager.java b/src/main/java/org/apache/xalan/extensions/ExtensionNamespacesManager.java
new file mode 100644
index 0000000..867b14c
--- /dev/null
+++ b/src/main/java/org/apache/xalan/extensions/ExtensionNamespacesManager.java
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ExtensionNamespacesManager.java 469672 2006-10-31 21:56:19Z minchau $
+ */
+package org.apache.xalan.extensions;
+
+import java.util.Vector;
+
+import org.apache.xalan.templates.Constants;
+
+/**
+ * Used during assembly of a stylesheet to collect the information for each 
+ * extension namespace that is required during the transformation process 
+ * to generate an {@link ExtensionHandler}.
+ * 
+ */
+public class ExtensionNamespacesManager
+{
+  /**
+   * Vector of ExtensionNamespaceSupport objects to be used to generate ExtensionHandlers.
+   */
+  private Vector m_extensions = new Vector();
+  /**
+   * Vector of ExtensionNamespaceSupport objects for predefined ExtensionNamespaces. Elements
+   * from this vector are added to the m_extensions vector when encountered in the stylesheet.
+   */
+  private Vector m_predefExtensions = new Vector(7);
+  /**
+   * Vector of extension namespaces for which sufficient information is not yet available to
+   * complete the registration process.
+   */
+  private Vector m_unregisteredExtensions = new Vector();
+  
+  /**
+   * An ExtensionNamespacesManager is instantiated the first time an extension function or
+   * element is found in the stylesheet. During initialization, a vector of ExtensionNamespaceSupport
+   * objects is created, one for each predefined extension namespace.
+   */
+  public ExtensionNamespacesManager()
+  {
+    setPredefinedNamespaces();
+  }
+  
+  /**
+   * If necessary, register the extension namespace found compiling a function or 
+   * creating an extension element. 
+   * 
+   * If it is a predefined namespace, create a
+   * support object to simplify the instantiate of an appropriate ExtensionHandler
+   * during transformation runtime. Otherwise, add the namespace, if necessary,
+   * to a vector of undefined extension namespaces, to be defined later.
+   * 
+   */
+  public void registerExtension(String namespace)
+  {
+    if (namespaceIndex(namespace, m_extensions) == -1)
+    {
+      int predef = namespaceIndex(namespace, m_predefExtensions);
+      if (predef !=-1)
+        m_extensions.add(m_predefExtensions.get(predef));
+      else if (!(m_unregisteredExtensions.contains(namespace)))
+        m_unregisteredExtensions.add(namespace);       
+    }
+  }
+  
+  /**
+   * Register the extension namespace for an ElemExtensionDecl or ElemFunction,
+   * and prepare a support object to launch the appropriate ExtensionHandler at 
+   * transformation runtime.
+   */  
+  public void registerExtension(ExtensionNamespaceSupport extNsSpt)
+  {
+    String namespace = extNsSpt.getNamespace();
+    if (namespaceIndex(namespace, m_extensions) == -1)
+    {
+      m_extensions.add(extNsSpt);
+      if (m_unregisteredExtensions.contains(namespace))
+        m_unregisteredExtensions.remove(namespace);
+    }
+    
+  }
+  
+  /**
+   * Get the index for a namespace entry in the extension namespace Vector, -1 if
+   * no such entry yet exists.
+   */
+  public int namespaceIndex(String namespace, Vector extensions)
+  {
+    for (int i = 0; i < extensions.size(); i++)
+    {
+      if (((ExtensionNamespaceSupport)extensions.get(i)).getNamespace().equals(namespace))
+        return i;
+    }
+    return -1;
+  }
+  
+    
+  /**
+   * Get the vector of extension namespaces. Used to provide
+   * the extensions table access to a list of extension
+   * namespaces encountered during composition of a stylesheet.
+   */
+  public Vector getExtensions()
+  {
+    return m_extensions;
+  }
+  
+  /**
+   * Attempt to register any unregistered extension namespaces.
+   */
+  public void registerUnregisteredNamespaces()
+  {
+    for (int i = 0; i < m_unregisteredExtensions.size(); i++)
+    {
+      String ns = (String)m_unregisteredExtensions.get(i);
+      ExtensionNamespaceSupport extNsSpt = defineJavaNamespace(ns);
+      if (extNsSpt != null)
+        m_extensions.add(extNsSpt);
+    }    
+  }
+  
+    /**
+   * For any extension namespace that is not either predefined or defined 
+   * by a "component" declaration or exslt function declaration, attempt 
+   * to create an ExtensionNamespaceSuport object for the appropriate 
+   * Java class or Java package Extension Handler.
+   * 
+   * Called by StylesheetRoot.recompose(), after all ElemTemplate compose()
+   * operations have taken place, in order to set up handlers for
+   * the remaining extension namespaces.
+   * 
+   * @param ns The extension namespace URI.
+   * @return   An ExtensionNamespaceSupport object for this namespace
+   * (which defines the ExtensionHandler to be used), or null if such 
+   * an object cannot be created. 
+   *
+   * @throws javax.xml.transform.TransformerException
+   */
+  public ExtensionNamespaceSupport defineJavaNamespace(String ns)
+  {
+    return defineJavaNamespace(ns, ns);
+  }
+  public ExtensionNamespaceSupport defineJavaNamespace(String ns, String classOrPackage)
+  {
+    if(null == ns || ns.trim().length() == 0) // defensive. I don't think it's needed.  -sb
+      return null;
+
+    // Prepare the name of the actual class or package, stripping
+    // out any leading "class:".  Next, see if there is a /.  If so,
+    // only look at the text to the right of the rightmost /.
+    String className = classOrPackage;
+    if (className.startsWith("class:"))
+      className = className.substring(6);
+
+    int lastSlash = className.lastIndexOf("/");
+    if (-1 != lastSlash)
+      className = className.substring(lastSlash + 1);
+      
+    // The className can be null here, and can cause an error in getClassForName
+    // in JDK 1.8.
+    if(null == className || className.trim().length() == 0) 
+      return null;
+    
+    try
+    {
+      ExtensionHandler.getClassForName(className);
+      return new ExtensionNamespaceSupport(
+                           ns, 
+                           "org.apache.xalan.extensions.ExtensionHandlerJavaClass",                                         
+                           new Object[]{ns, "javaclass", className});
+    }
+    catch (ClassNotFoundException e)
+    {
+      return new ExtensionNamespaceSupport(
+                            ns, 
+                            "org.apache.xalan.extensions.ExtensionHandlerJavaPackage",
+                            new Object[]{ns, "javapackage", className + "."});
+    }
+  }
+  
+/*
+  public ExtensionNamespaceSupport getSupport(int index, Vector extensions)
+  {
+    return (ExtensionNamespaceSupport)extensions.elementAt(index);
+  }
+*/
+  
+  
+  /**
+   * Set up a Vector for predefined extension namespaces.
+   */
+  private void setPredefinedNamespaces()
+  {    
+    String uri = Constants.S_EXTENSIONS_JAVA_URL;
+    String handlerClassName = "org.apache.xalan.extensions.ExtensionHandlerJavaPackage";
+    String lang = "javapackage";
+    String lib = "";
+    m_predefExtensions.add(new ExtensionNamespaceSupport(uri, handlerClassName,
+                                             new Object[]{uri, lang, lib}));
+   
+    uri = Constants.S_EXTENSIONS_OLD_JAVA_URL;
+    m_predefExtensions.add(new ExtensionNamespaceSupport(uri, handlerClassName,
+                                             new Object[]{uri, lang, lib}));
+    
+    uri = Constants.S_EXTENSIONS_LOTUSXSL_JAVA_URL;
+    m_predefExtensions.add(new ExtensionNamespaceSupport(uri, handlerClassName,
+                                             new Object[]{uri, lang, lib}));
+    
+    uri = Constants.S_BUILTIN_EXTENSIONS_URL;
+    handlerClassName = "org.apache.xalan.extensions.ExtensionHandlerJavaClass";
+    lang = "javaclass"; // for remaining predefined extension namespaces.    
+    lib = "org.apache.xalan.lib.Extensions";
+    m_predefExtensions.add(new ExtensionNamespaceSupport(uri, handlerClassName,
+                                             new Object[]{uri, lang, lib}));
+    
+    uri = Constants.S_BUILTIN_OLD_EXTENSIONS_URL;
+    m_predefExtensions.add(new ExtensionNamespaceSupport(uri, handlerClassName,
+                                             new Object[]{uri, lang, lib}));
+    
+    // Xalan extension namespaces (redirect, pipe and SQL).
+    uri = Constants.S_EXTENSIONS_REDIRECT_URL;
+    lib = "org.apache.xalan.lib.Redirect";
+    m_predefExtensions.add(new ExtensionNamespaceSupport(uri, handlerClassName,
+                                             new Object[]{uri, lang, lib}));
+ 
+    uri = Constants.S_EXTENSIONS_PIPE_URL;
+    lib = "org.apache.xalan.lib.PipeDocument";
+    m_predefExtensions.add(new ExtensionNamespaceSupport(uri, handlerClassName,
+                                             new Object[]{uri, lang, lib}));
+ 
+    uri = Constants.S_EXTENSIONS_SQL_URL;
+    lib = "org.apache.xalan.lib.sql.XConnection";
+    m_predefExtensions.add(new ExtensionNamespaceSupport(uri, handlerClassName,
+                                             new Object[]{uri, lang, lib}));
+ 
+    
+    //EXSLT namespaces (not including EXSLT function namespaces which are
+    // registered by the associated ElemFunction.
+    uri = Constants.S_EXSLT_COMMON_URL;
+    lib = "org.apache.xalan.lib.ExsltCommon";
+    m_predefExtensions.add(new ExtensionNamespaceSupport(uri, handlerClassName,
+                                             new Object[]{uri, lang, lib}));
+
+    uri = Constants.S_EXSLT_MATH_URL;
+    lib = "org.apache.xalan.lib.ExsltMath";
+    m_predefExtensions.add(new ExtensionNamespaceSupport(uri, handlerClassName,
+                                             new Object[]{uri, lang, lib}));
+    
+    uri = Constants.S_EXSLT_SETS_URL;
+    lib = "org.apache.xalan.lib.ExsltSets";
+    m_predefExtensions.add(new ExtensionNamespaceSupport(uri, handlerClassName,
+                                             new Object[]{uri, lang, lib}));
+    
+    uri = Constants.S_EXSLT_DATETIME_URL;
+    lib = "org.apache.xalan.lib.ExsltDatetime";
+    m_predefExtensions.add(new ExtensionNamespaceSupport(uri, handlerClassName,
+                                             new Object[]{uri, lang, lib}));
+                                             
+    uri = Constants.S_EXSLT_DYNAMIC_URL;
+    lib = "org.apache.xalan.lib.ExsltDynamic";
+    m_predefExtensions.add(new ExtensionNamespaceSupport(uri, handlerClassName,
+                                             new Object[]{uri, lang, lib}));
+
+    uri = Constants.S_EXSLT_STRINGS_URL;
+    lib = "org.apache.xalan.lib.ExsltStrings";
+    m_predefExtensions.add(new ExtensionNamespaceSupport(uri, handlerClassName,
+                                             new Object[]{uri, lang, lib}));                                             
+  }    
+  
+}
diff --git a/src/main/java/org/apache/xalan/extensions/ExtensionsTable.java b/src/main/java/org/apache/xalan/extensions/ExtensionsTable.java
new file mode 100644
index 0000000..cb5cc48
--- /dev/null
+++ b/src/main/java/org/apache/xalan/extensions/ExtensionsTable.java
@@ -0,0 +1,241 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ExtensionsTable.java 469672 2006-10-31 21:56:19Z minchau $
+ */
+package org.apache.xalan.extensions;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+import org.apache.xalan.res.XSLMessages;
+import org.apache.xalan.res.XSLTErrorResources;
+import org.apache.xalan.templates.StylesheetRoot;
+import org.apache.xpath.XPathProcessorException;
+import org.apache.xpath.functions.FuncExtFunction;
+
+/**
+ * Class holding a table registered extension namespace handlers
+ * @xsl.usage internal
+ */
+public class ExtensionsTable
+{  
+  /**
+   * Table of extensions that may be called from the expression language
+   * via the call(name, ...) function.  Objects are keyed on the call
+   * name.
+   * @xsl.usage internal
+   */
+  public Hashtable m_extensionFunctionNamespaces = new Hashtable();
+  
+  /**
+   * The StylesheetRoot associated with this extensions table.
+   */
+  private StylesheetRoot m_sroot;
+  
+  /**
+   * The constructor (called from TransformerImpl) registers the
+   * StylesheetRoot for the transformation and instantiates an
+   * ExtensionHandler for each extension namespace.
+   * @xsl.usage advanced
+   */
+  public ExtensionsTable(StylesheetRoot sroot)
+    throws javax.xml.transform.TransformerException
+  {
+    m_sroot = sroot;
+    Vector extensions = m_sroot.getExtensions();
+    for (int i = 0; i < extensions.size(); i++)
+    {
+      ExtensionNamespaceSupport extNamespaceSpt = 
+                 (ExtensionNamespaceSupport)extensions.get(i);
+      ExtensionHandler extHandler = extNamespaceSpt.launch();
+        if (extHandler != null)
+          addExtensionNamespace(extNamespaceSpt.getNamespace(), extHandler);
+      }
+    }
+       
+  /**
+   * Get an ExtensionHandler object that represents the
+   * given namespace.
+   * @param extns A valid extension namespace.
+   *
+   * @return ExtensionHandler object that represents the
+   * given namespace.
+   */
+  public ExtensionHandler get(String extns)
+  {
+    return (ExtensionHandler) m_extensionFunctionNamespaces.get(extns);
+  }
+
+  /**
+   * Register an extension namespace handler. This handler provides
+   * functions for testing whether a function is known within the
+   * namespace and also for invoking the functions.
+   *
+   * @param uri the URI for the extension.
+   * @param extNS the extension handler.
+   * @xsl.usage advanced
+   */
+  public void addExtensionNamespace(String uri, ExtensionHandler extNS)
+  {
+    m_extensionFunctionNamespaces.put(uri, extNS);
+  }
+
+  /**
+   * Execute the function-available() function.
+   * @param ns       the URI of namespace in which the function is needed
+   * @param funcName the function name being tested
+   *
+   * @return whether the given function is available or not.
+   *
+   * @throws javax.xml.transform.TransformerException
+   */
+  public boolean functionAvailable(String ns, String funcName)
+          throws javax.xml.transform.TransformerException
+  {
+    boolean isAvailable = false;
+    
+    if (null != ns)
+    {
+      ExtensionHandler extNS = 
+           (ExtensionHandler) m_extensionFunctionNamespaces.get(ns);
+      if (extNS != null)
+        isAvailable = extNS.isFunctionAvailable(funcName);
+    }
+    return isAvailable;
+  }
+  
+  /**
+   * Execute the element-available() function.
+   * @param ns       the URI of namespace in which the function is needed
+   * @param elemName name of element being tested
+   *
+   * @return whether the given element is available or not.
+   *
+   * @throws javax.xml.transform.TransformerException
+   */
+  public boolean elementAvailable(String ns, String elemName)
+          throws javax.xml.transform.TransformerException
+  {
+    boolean isAvailable = false;
+    if (null != ns)
+    {
+      ExtensionHandler extNS = 
+               (ExtensionHandler) m_extensionFunctionNamespaces.get(ns);
+      if (extNS != null) // defensive
+        isAvailable = extNS.isElementAvailable(elemName);
+    } 
+    return isAvailable;        
+  }  
+  
+  /**
+   * Handle an extension function.
+   * @param ns        the URI of namespace in which the function is needed
+   * @param funcName  the function name being called
+   * @param argVec    arguments to the function in a vector
+   * @param methodKey a unique key identifying this function instance in the
+   *                  stylesheet
+   * @param exprContext a context which may be passed to an extension function
+   *                  and provides callback functions to access various
+   *                  areas in the environment
+   *
+   * @return result of executing the function
+   *
+   * @throws javax.xml.transform.TransformerException
+   */
+  public Object extFunction(String ns, String funcName, 
+                            Vector argVec, Object methodKey, 
+                            ExpressionContext exprContext)
+            throws javax.xml.transform.TransformerException
+  {
+    Object result = null;
+    if (null != ns)
+    {
+      ExtensionHandler extNS =
+        (ExtensionHandler) m_extensionFunctionNamespaces.get(ns);
+      if (null != extNS)
+      {
+        try
+        {
+          result = extNS.callFunction(funcName, argVec, methodKey,
+                                      exprContext);
+        }
+        catch (javax.xml.transform.TransformerException e)
+        {
+          throw e;
+        }
+        catch (Exception e)
+        {
+          throw new javax.xml.transform.TransformerException(e);
+        }
+      }
+      else
+      {
+        throw new XPathProcessorException(XSLMessages.createMessage(XSLTErrorResources.ER_EXTENSION_FUNC_UNKNOWN, new Object[]{ns, funcName })); 
+        //"Extension function '" + ns + ":" + funcName + "' is unknown");
+      }
+    }
+    return result;    
+  }
+  
+  /**
+   * Handle an extension function.
+   * @param extFunction  the extension function
+   * @param argVec    arguments to the function in a vector
+   * @param exprContext a context which may be passed to an extension function
+   *                  and provides callback functions to access various
+   *                  areas in the environment
+   *
+   * @return result of executing the function
+   *
+   * @throws javax.xml.transform.TransformerException
+   */
+  public Object extFunction(FuncExtFunction extFunction, Vector argVec, 
+                            ExpressionContext exprContext)
+         throws javax.xml.transform.TransformerException
+  {
+    Object result = null;
+    String ns = extFunction.getNamespace();
+    if (null != ns)
+    {
+      ExtensionHandler extNS =
+        (ExtensionHandler) m_extensionFunctionNamespaces.get(ns);
+      if (null != extNS)
+      {
+        try
+        {
+          result = extNS.callFunction(extFunction, argVec, exprContext);
+        }
+        catch (javax.xml.transform.TransformerException e)
+        {
+          throw e;
+        }
+        catch (Exception e)
+        {
+          throw new javax.xml.transform.TransformerException(e);
+        }
+      }
+      else
+      {
+        throw new XPathProcessorException(XSLMessages.createMessage(XSLTErrorResources.ER_EXTENSION_FUNC_UNKNOWN, 
+                                          new Object[]{ns, extFunction.getFunctionName()})); 
+      }
+    }
+    return result;        
+  }
+}
diff --git a/src/main/java/org/apache/xalan/extensions/ObjectFactory.java b/src/main/java/org/apache/xalan/extensions/ObjectFactory.java
new file mode 100755
index 0000000..3772cb7
--- /dev/null
+++ b/src/main/java/org/apache/xalan/extensions/ObjectFactory.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ObjectFactory.java 468637 2006-10-28 06:51:02Z minchau $
+ */
+
+package org.apache.xalan.extensions;
+
+/**
+ * This class is duplicated for each JAXP subpackage so keep it in sync.
+ * It is package private and therefore is not exposed as part of the JAXP
+ * API.
+ * <p>
+ * This code is designed to implement the JAXP 1.1 spec pluggability
+ * feature and is designed to run on JDK version 1.1 and
+ * later, and to compile on JDK 1.2 and onward.  
+ * The code also runs both as part of an unbundled jar file and
+ * when bundled as part of the JDK.
+ * <p>
+ * This class was moved from the <code>javax.xml.parsers.ObjectFactory</code>
+ * class and modified to be used as a general utility for creating objects 
+ * dynamically.
+ *
+ * @version $Id: ObjectFactory.java 468637 2006-10-28 06:51:02Z minchau $
+ */
+class ObjectFactory {
+
+    /**
+     * Figure out which ClassLoader to use.  For JDK 1.2 and later use
+     * the context ClassLoader.
+     */
+    static ClassLoader findClassLoader()
+        throws ConfigurationError
+    {
+        // BEGIN android-changed
+        //     the context class loader is always sufficient
+        return Thread.currentThread().getContextClassLoader();
+        // END android-changed
+    } // findClassLoader():ClassLoader
+
+    /**
+     * Find a Class using the specified ClassLoader
+     */ 
+    static Class findProviderClass(String className, ClassLoader cl,
+                                           boolean doFallback)
+        throws ClassNotFoundException, ConfigurationError
+    {   
+        //throw security exception if the calling thread is not allowed to access the
+        //class. Restrict the access to the package classes as specified in java.security policy.
+        SecurityManager security = System.getSecurityManager();
+        try{
+                if (security != null){
+                    final int lastDot = className.lastIndexOf(".");
+                    String packageName = className;
+                    if (lastDot != -1) packageName = className.substring(0, lastDot);
+                    security.checkPackageAccess(packageName);
+                 }   
+        }catch(SecurityException e){
+            throw e;
+        }
+        
+        Class providerClass;
+        if (cl == null) {
+            // XXX Use the bootstrap ClassLoader.  There is no way to
+            // load a class using the bootstrap ClassLoader that works
+            // in both JDK 1.1 and Java 2.  However, this should still
+            // work b/c the following should be true:
+            //
+            // (cl == null) iff current ClassLoader == null
+            //
+            // Thus Class.forName(String) will use the current
+            // ClassLoader which will be the bootstrap ClassLoader.
+            providerClass = Class.forName(className);
+        } else {
+            try {
+                providerClass = cl.loadClass(className);
+            } catch (ClassNotFoundException x) {
+                if (doFallback) {
+                    // Fall back to current classloader
+                    ClassLoader current = ObjectFactory.class.getClassLoader();
+                    if (current == null) {
+                        providerClass = Class.forName(className);
+                    } else if (cl != current) {
+                        cl = current;
+                        providerClass = cl.loadClass(className);
+                    } else {
+                        throw x;
+                    }
+                } else {
+                    throw x;
+                }
+            }
+        }
+
+        return providerClass;
+    }
+
+    //
+    // Classes
+    //
+
+    /**
+     * A configuration error.
+     */
+    static class ConfigurationError 
+        extends Error {
+                static final long serialVersionUID = 8564305128443551853L;
+        //
+        // Data
+        //
+
+        /** Exception. */
+        private Exception exception;
+
+        //
+        // Constructors
+        //
+
+        /**
+         * Construct a new instance with the specified detail string and
+         * exception.
+         */
+        ConfigurationError(String msg, Exception x) {
+            super(msg);
+            this.exception = x;
+        } // <init>(String,Exception)
+
+        //
+        // Public methods
+        //
+
+        /** Returns the exception associated to this error. */
+        Exception getException() {
+            return exception;
+        } // getException():Exception
+
+    } // class ConfigurationError
+
+} // class ObjectFactory
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorAttributeSet.java b/src/main/java/org/apache/xalan/processor/ProcessorAttributeSet.java
new file mode 100644
index 0000000..97f1660
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorAttributeSet.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorAttributeSet.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import javax.xml.transform.TransformerException;
+
+import org.apache.xalan.templates.ElemAttributeSet;
+import org.apache.xalan.templates.ElemTemplateElement;
+
+import org.xml.sax.Attributes;
+
+/**
+ * This class processes parse events for an xsl:attribute-set.
+ * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
+ * @see <a href="http://www.w3.org/TR/xslt#attribute-sets">attribute-sets in XSLT Specification</a>
+ */
+class ProcessorAttributeSet extends XSLTElementProcessor
+{
+    static final long serialVersionUID = -6473739251316787552L;
+
+  /**
+   * Receive notification of the start of an xsl:attribute-set element.
+   *
+   * @param handler The calling StylesheetHandler/TemplatesBuilder.
+   * @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 rawName The raw XML 1.0 name (with prefix), or the
+   *        empty string if raw names are not available.
+   * @param attributes The attributes attached to the element.  If
+   *        there are no attributes, it shall be an empty
+   *        Attributes object.
+   * 
+   * @see org.apache.xalan.processor.StylesheetHandler#startElement
+   * @see org.xml.sax.ContentHandler#startElement
+   * @see org.xml.sax.ContentHandler#endElement
+   * @see org.xml.sax.Attributes
+   */
+  public void startElement(
+          StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
+            throws org.xml.sax.SAXException
+  {
+
+    ElemAttributeSet eat = new ElemAttributeSet();
+
+    eat.setLocaterInfo(handler.getLocator());
+    try
+    {
+      eat.setPrefixes(handler.getNamespaceSupport());
+    }
+    catch(TransformerException te)
+    {
+      throw new org.xml.sax.SAXException(te);
+    }
+
+    eat.setDOMBackPointer(handler.getOriginatingNode());
+    setPropertiesFromAttributes(handler, rawName, attributes, eat);
+    handler.getStylesheet().setAttributeSet(eat);
+
+    // handler.pushElemTemplateElement(eat);
+    ElemTemplateElement parent = handler.getElemTemplateElement();
+
+    parent.appendChild(eat);
+    handler.pushElemTemplateElement(eat);
+  }
+
+  /**
+   * Receive notification of the end of an element.
+   *
+   * @param name The element type name.
+   * @param attributes The specified or defaulted attributes.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   */
+  public void endElement(
+          StylesheetHandler handler, String uri, String localName, String rawName)
+            throws org.xml.sax.SAXException
+  {
+    handler.popElemTemplateElement();
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorCharacters.java b/src/main/java/org/apache/xalan/processor/ProcessorCharacters.java
new file mode 100644
index 0000000..b318f39
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorCharacters.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorCharacters.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import javax.xml.transform.TransformerException;
+
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xalan.templates.ElemText;
+import org.apache.xalan.templates.ElemTextLiteral;
+import org.apache.xml.utils.XMLCharacterRecognizer;
+
+import org.w3c.dom.Node;
+
+/**
+ * This class processes character events for a XSLT template element.
+ * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
+ * @see <a href="http://www.w3.org/TR/xslt#section-Creating-the-Result-Tree">section-Creating-the-Result-Tree in XSLT Specification</a>
+ */
+public class ProcessorCharacters extends XSLTElementProcessor
+{
+    static final long serialVersionUID = 8632900007814162650L;
+
+  /**
+   * Receive notification of the start of the non-text event.  This
+   * is sent to the current processor when any non-text event occurs.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   */
+  public void startNonText(StylesheetHandler handler) throws org.xml.sax.SAXException
+  {
+    if (this == handler.getCurrentProcessor())
+    {
+      handler.popProcessor();
+    }
+
+    int nChars = m_accumulator.length();
+
+    if ((nChars > 0)
+            && ((null != m_xslTextElement)
+                ||!XMLCharacterRecognizer.isWhiteSpace(m_accumulator)) 
+                || handler.isSpacePreserve())
+    {
+      ElemTextLiteral elem = new ElemTextLiteral();
+
+      elem.setDOMBackPointer(m_firstBackPointer);
+      elem.setLocaterInfo(handler.getLocator());
+      try
+      {
+        elem.setPrefixes(handler.getNamespaceSupport());
+      }
+      catch(TransformerException te)
+      {
+        throw new org.xml.sax.SAXException(te);
+      }
+
+      boolean doe = (null != m_xslTextElement)
+                    ? m_xslTextElement.getDisableOutputEscaping() : false;
+
+      elem.setDisableOutputEscaping(doe);
+      elem.setPreserveSpace(true);
+
+      char[] chars = new char[nChars];
+
+      m_accumulator.getChars(0, nChars, chars, 0);
+      elem.setChars(chars);
+
+      ElemTemplateElement parent = handler.getElemTemplateElement();
+
+      parent.appendChild(elem);
+    }
+
+    m_accumulator.setLength(0);
+    m_firstBackPointer = null;
+  }
+  
+  protected Node m_firstBackPointer = null;
+
+  /**
+   * Receive notification of character data inside an element.
+   *
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @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 org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   * @see org.xml.sax.ContentHandler#characters
+   */
+  public void characters(
+          StylesheetHandler handler, char ch[], int start, int length)
+            throws org.xml.sax.SAXException
+  {
+
+    m_accumulator.append(ch, start, length);
+    
+    if(null == m_firstBackPointer)
+      m_firstBackPointer = handler.getOriginatingNode();
+
+    // Catch all events until a non-character event.
+    if (this != handler.getCurrentProcessor())
+      handler.pushProcessor(this);
+  }
+
+  /**
+   * Receive notification of the end of an element.
+   *
+   * @param handler The calling StylesheetHandler/TemplatesBuilder.
+   * @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 rawName The raw XML 1.0 name (with prefix), or the
+   *        empty string if raw names are not available.
+   * @see org.apache.xalan.processor.StylesheetHandler#startElement
+   * @see org.apache.xalan.processor.StylesheetHandler#endElement
+   * @see org.xml.sax.ContentHandler#startElement
+   * @see org.xml.sax.ContentHandler#endElement
+   * @see org.xml.sax.Attributes
+   */
+  public void endElement(
+          StylesheetHandler handler, String uri, String localName, String rawName)
+            throws org.xml.sax.SAXException
+  {
+
+    // Since this has been installed as the current processor, we 
+    // may get and end element event, in which case, we pop and clear 
+    // and then call the real element processor.
+    startNonText(handler);
+    handler.getCurrentProcessor().endElement(handler, uri, localName,
+                                             rawName);
+    handler.popProcessor();
+  }
+
+  /**
+   * Accumulate characters, until a non-whitespace event has
+   * occured.
+   */
+  private StringBuffer m_accumulator = new StringBuffer();
+
+  /**
+   * The xsl:text processor will call this to set a
+   * preserve space state.
+   */
+  private ElemText m_xslTextElement;
+
+  /**
+   * Set the current setXslTextElement. The xsl:text 
+   * processor will call this to set a preserve space state.
+   *
+   * @param xslTextElement The current xslTextElement that 
+   *                       is preserving state, or null.
+   */
+  void setXslTextElement(ElemText xslTextElement)
+  {
+    m_xslTextElement = xslTextElement;
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorDecimalFormat.java b/src/main/java/org/apache/xalan/processor/ProcessorDecimalFormat.java
new file mode 100644
index 0000000..43250a6
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorDecimalFormat.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorDecimalFormat.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import org.apache.xalan.templates.DecimalFormatProperties;
+import org.xml.sax.Attributes;
+
+/**
+ * Process xsl:decimal-format by creating a DecimalFormatProperties 
+ * object and passing it to the stylesheet.
+ * 
+ * @see org.apache.xalan.templates.Stylesheet#setDecimalFormat
+ * @see org.apache.xalan.templates.DecimalFormatProperties
+ * @see <a href="http://www.w3.org/TR/xslt#format-number">format-number in XSLT Specification</a>
+ * @xsl.usage internal
+ */
+class ProcessorDecimalFormat extends XSLTElementProcessor
+{
+    static final long serialVersionUID = -5052904382662921627L;
+
+  /**
+   * Receive notification of the start of an element.
+   *
+   * @param handler The calling StylesheetHandler/TemplatesBuilder.
+   * @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 rawName The raw XML 1.0 name (with prefix), or the
+   *        empty string if raw names are not available.
+   * @param attributes The attributes attached to the element.  If
+   *        there are no attributes, it shall be an empty
+   *        Attributes object.
+   * @see org.apache.xalan.processor.StylesheetHandler#startElement
+   * @see org.apache.xalan.processor.StylesheetHandler#endElement
+   * @see org.xml.sax.ContentHandler#startElement
+   * @see org.xml.sax.ContentHandler#endElement
+   * @see org.xml.sax.Attributes
+   */
+  public void startElement(
+          StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
+            throws org.xml.sax.SAXException
+  {
+
+    DecimalFormatProperties dfp = new DecimalFormatProperties(handler.nextUid());
+    
+    dfp.setDOMBackPointer(handler.getOriginatingNode());
+    dfp.setLocaterInfo(handler.getLocator());
+    
+    setPropertiesFromAttributes(handler, rawName, attributes, dfp);
+    handler.getStylesheet().setDecimalFormat(dfp);
+    
+    handler.getStylesheet().appendChild(dfp);
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorExsltFuncResult.java b/src/main/java/org/apache/xalan/processor/ProcessorExsltFuncResult.java
new file mode 100644
index 0000000..3a909fa
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorExsltFuncResult.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorExsltFuncResult.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import org.apache.xalan.templates.ElemExsltFuncResult;
+import org.apache.xalan.templates.ElemExsltFunction;
+import org.apache.xalan.templates.ElemParam;
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xalan.templates.ElemVariable;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * This class processes parse events for an exslt func:result element.
+ * @xsl.usage internal
+ */
+public class ProcessorExsltFuncResult extends ProcessorTemplateElem
+{
+    static final long serialVersionUID = 6451230911473482423L;
+  
+  /**
+   * Verify that the func:result element does not appear within a variable,
+   * parameter, or another func:result, and that it belongs to a func:function 
+   * element.
+   */
+  public void startElement(
+          StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
+            throws SAXException
+  {
+    String msg = "";
+
+    super.startElement(handler, uri, localName, rawName, attributes);
+    ElemTemplateElement ancestor = handler.getElemTemplateElement().getParentElem();
+    while (ancestor != null && !(ancestor instanceof ElemExsltFunction))
+    {
+      if (ancestor instanceof ElemVariable 
+          || ancestor instanceof ElemParam
+          || ancestor instanceof ElemExsltFuncResult)
+      {
+        msg = "func:result cannot appear within a variable, parameter, or another func:result.";
+        handler.error(msg, new SAXException(msg));
+      }
+      ancestor = ancestor.getParentElem();
+    }
+    if (ancestor == null)
+    {
+      msg = "func:result must appear in a func:function element";
+      handler.error(msg, new SAXException(msg));
+    }
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorExsltFunction.java b/src/main/java/org/apache/xalan/processor/ProcessorExsltFunction.java
new file mode 100644
index 0000000..8eb4e41
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorExsltFunction.java
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorExsltFunction.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import org.apache.xalan.templates.ElemApplyImport;
+import org.apache.xalan.templates.ElemApplyTemplates;
+import org.apache.xalan.templates.ElemAttribute;
+import org.apache.xalan.templates.ElemCallTemplate;
+import org.apache.xalan.templates.ElemComment;
+import org.apache.xalan.templates.ElemCopy;
+import org.apache.xalan.templates.ElemCopyOf;
+import org.apache.xalan.templates.ElemElement;
+import org.apache.xalan.templates.ElemExsltFuncResult;
+import org.apache.xalan.templates.ElemExsltFunction;
+import org.apache.xalan.templates.ElemFallback;
+import org.apache.xalan.templates.ElemLiteralResult;
+import org.apache.xalan.templates.ElemMessage;
+import org.apache.xalan.templates.ElemNumber;
+import org.apache.xalan.templates.ElemPI;
+import org.apache.xalan.templates.ElemParam;
+import org.apache.xalan.templates.ElemTemplate;
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xalan.templates.ElemText;
+import org.apache.xalan.templates.ElemTextLiteral;
+import org.apache.xalan.templates.ElemValueOf;
+import org.apache.xalan.templates.ElemVariable;
+import org.apache.xalan.templates.Stylesheet;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+
+/**
+ * This class processes parse events for an exslt func:function element.
+ * @xsl.usage internal
+ */
+public class ProcessorExsltFunction extends ProcessorTemplateElem
+{
+    static final long serialVersionUID = 2411427965578315332L;
+  /**
+   * Start an ElemExsltFunction. Verify that it is top level and that it has a name attribute with a
+   * namespace.
+   */
+  public void startElement(
+          StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
+            throws SAXException
+  {
+    //System.out.println("ProcessorFunction.startElement()");
+    String msg = "";
+    if (!(handler.getElemTemplateElement() instanceof Stylesheet))
+    {
+      msg = "func:function element must be top level.";
+      handler.error(msg, new SAXException(msg));
+    }
+    super.startElement(handler, uri, localName, rawName, attributes);
+       
+    String val = attributes.getValue("name");
+    int indexOfColon = val.indexOf(":");
+    if (indexOfColon > 0)
+    {
+      //String prefix = val.substring(0, indexOfColon);
+      //String localVal = val.substring(indexOfColon + 1);
+      //String ns = handler.getNamespaceSupport().getURI(prefix);
+      //if (ns.length() > 0)
+      //  System.out.println("fullfuncname " + ns + localVal);
+    }
+    else
+    {
+      msg = "func:function name must have namespace";
+      handler.error(msg, new SAXException(msg));
+    }
+  }
+  
+  /**
+   * Must include; super doesn't suffice!
+   */
+  protected void appendAndPush(
+          StylesheetHandler handler, ElemTemplateElement elem)
+            throws SAXException
+  {
+    //System.out.println("ProcessorFunction appendAndPush()" + elem);
+    super.appendAndPush(handler, elem);
+    //System.out.println("originating node " + handler.getOriginatingNode());
+    elem.setDOMBackPointer(handler.getOriginatingNode());
+    handler.getStylesheet().setTemplate((ElemTemplate) elem);
+  }
+    
+  /**
+   * End an ElemExsltFunction, and verify its validity.
+   */
+  public void endElement(
+          StylesheetHandler handler, String uri, String localName, String rawName)
+            throws SAXException
+  {
+   ElemTemplateElement function = handler.getElemTemplateElement();
+   validate(function, handler); // may throw exception
+   super.endElement(handler, uri, localName, rawName);   
+  }
+  
+  /**
+   * Non-recursive traversal of FunctionElement tree based on TreeWalker to verify that
+   * there are no literal result elements except within a func:result element and that
+   * the func:result element does not contain any following siblings except xsl:fallback.
+   */
+  public void validate(ElemTemplateElement elem, StylesheetHandler handler)
+    throws SAXException
+  {
+    String msg = "";
+    while (elem != null)
+    { 
+      //System.out.println("elem " + elem);
+      if (elem instanceof ElemExsltFuncResult 
+          && elem.getNextSiblingElem() != null 
+          && !(elem.getNextSiblingElem() instanceof ElemFallback))
+      {
+        msg = "func:result has an illegal following sibling (only xsl:fallback allowed)";
+        handler.error(msg, new SAXException(msg));
+      }
+      
+      if((elem instanceof ElemApplyImport
+	 || elem instanceof ElemApplyTemplates
+	 || elem instanceof ElemAttribute
+	 || elem instanceof ElemCallTemplate
+	 || elem instanceof ElemComment
+	 || elem instanceof ElemCopy
+	 || elem instanceof ElemCopyOf
+	 || elem instanceof ElemElement
+	 || elem instanceof ElemLiteralResult
+	 || elem instanceof ElemNumber
+	 || elem instanceof ElemPI
+	 || elem instanceof ElemText
+	 || elem instanceof ElemTextLiteral
+	 || elem instanceof ElemValueOf)
+	&& !(ancestorIsOk(elem)))
+      {
+        msg ="misplaced literal result in a func:function container.";
+        handler.error(msg, new SAXException(msg));
+      }
+      ElemTemplateElement nextElem = elem.getFirstChildElem();
+      while (nextElem == null)
+      {
+        nextElem = elem.getNextSiblingElem();
+        if (nextElem == null)
+          elem = elem.getParentElem();
+        if (elem == null || elem instanceof ElemExsltFunction)
+          return; // ok
+      }  
+      elem = nextElem;
+    }
+  }
+  
+  /**
+   * Verify that a literal result belongs to a result element, a variable, 
+   * or a parameter.
+   */
+  
+  boolean ancestorIsOk(ElemTemplateElement child)
+  {
+    while (child.getParentElem() != null && !(child.getParentElem() instanceof ElemExsltFunction))
+    {
+      ElemTemplateElement parent = child.getParentElem();
+      if (parent instanceof ElemExsltFuncResult 
+          || parent instanceof ElemVariable
+          || parent instanceof ElemParam
+          || parent instanceof ElemMessage)
+        return true;
+      child = parent;      
+    }
+    return false;
+  }
+  
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorGlobalParamDecl.java b/src/main/java/org/apache/xalan/processor/ProcessorGlobalParamDecl.java
new file mode 100644
index 0000000..3fa4cc3
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorGlobalParamDecl.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorGlobalParamDecl.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import org.apache.xalan.templates.ElemParam;
+import org.apache.xalan.templates.ElemTemplateElement;
+
+/**
+ * This class processes parse events for an xsl:param element.
+ * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
+ * @see <a href="http://www.w3.org/TR/xslt#top-level-variables">top-level-variables in XSLT Specification</a>
+ */
+class ProcessorGlobalParamDecl extends ProcessorTemplateElem
+{
+    static final long serialVersionUID = 1900450872353587350L;
+
+  /**
+   * Append the current template element to the current
+   * template element, and then push it onto the current template
+   * element stack.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param elem The non-null reference to the ElemParam element.
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  protected void appendAndPush(
+          StylesheetHandler handler, ElemTemplateElement elem)
+            throws org.xml.sax.SAXException
+  {
+
+    // Just push, but don't append.
+    handler.pushElemTemplateElement(elem);
+  }
+
+  /**
+   * Receive notification of the end of an element.
+   *
+   * @param name The element type name.
+   * @param attributes The specified or defaulted attributes.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   */
+  public void endElement(
+          StylesheetHandler handler, String uri, String localName, String rawName)
+            throws org.xml.sax.SAXException
+  {
+
+    ElemParam v = (ElemParam) handler.getElemTemplateElement();
+
+    handler.getStylesheet().appendChild(v);
+    handler.getStylesheet().setParam(v);
+    super.endElement(handler, uri, localName, rawName);
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorGlobalVariableDecl.java b/src/main/java/org/apache/xalan/processor/ProcessorGlobalVariableDecl.java
new file mode 100644
index 0000000..8caacbd
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorGlobalVariableDecl.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorGlobalVariableDecl.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xalan.templates.ElemVariable;
+
+/**
+ * This class processes parse events for an xsl:variable element.
+ * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
+ * @see <a href="http://www.w3.org/TR/xslt#top-level-variables">top-level-variables in XSLT Specification</a>
+ */
+class ProcessorGlobalVariableDecl extends ProcessorTemplateElem
+{
+    static final long serialVersionUID = -5954332402269819582L;
+
+  /**
+   * Append the current template element to the current
+   * template element, and then push it onto the current template
+   * element stack.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param elem The non-null reference to the ElemVariable element.
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  protected void appendAndPush(
+          StylesheetHandler handler, ElemTemplateElement elem)
+            throws org.xml.sax.SAXException
+  {
+
+    // Just push, but don't append.
+    handler.pushElemTemplateElement(elem);
+  }
+
+  /**
+   * Receive notification of the end of an element.
+   *
+   * @param name The element type name.
+   * @param attributes The specified or defaulted attributes.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   */
+  public void endElement(
+          StylesheetHandler handler, String uri, String localName, String rawName)
+            throws org.xml.sax.SAXException
+  {
+
+    ElemVariable v = (ElemVariable) handler.getElemTemplateElement();
+
+    handler.getStylesheet().appendChild(v);
+    handler.getStylesheet().setVariable(v);
+    super.endElement(handler, uri, localName, rawName);
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorImport.java b/src/main/java/org/apache/xalan/processor/ProcessorImport.java
new file mode 100644
index 0000000..c044bcf
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorImport.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorImport.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import org.apache.xalan.res.XSLTErrorResources;
+
+/**
+ * This class processes parse events for an xsl:import element.
+ * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
+ * @see <a href="http://www.w3.org/TR/xslt#import">import in XSLT Specification</a>
+ * 
+ * @xsl.usage internal
+ */
+public class ProcessorImport extends ProcessorInclude
+{
+    static final long serialVersionUID = -8247537698214245237L;
+
+  /**
+   * Get the stylesheet type associated with an imported stylesheet
+   *
+   * @return the type of the stylesheet
+   */
+  protected int getStylesheetType()
+  {
+    return StylesheetHandler.STYPE_IMPORT;
+  }
+
+  /**
+   * Get the error number associated with this type of stylesheet importing itself
+   *
+   * @return the appropriate error number
+   */
+  protected String getStylesheetInclErr()
+  {
+    return XSLTErrorResources.ER_IMPORTING_ITSELF;
+  }
+
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorInclude.java b/src/main/java/org/apache/xalan/processor/ProcessorInclude.java
new file mode 100644
index 0000000..814a0f3
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorInclude.java
@@ -0,0 +1,396 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorInclude.java 469349 2006-10-31 03:06:50Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import java.io.IOException;
+
+import javax.xml.XMLConstants;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.xalan.res.XSLMessages;
+import org.apache.xalan.res.XSLTErrorResources;
+import org.apache.xml.utils.SystemIDResolver;
+import org.apache.xml.utils.TreeWalker;
+
+import org.w3c.dom.Node;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * TransformerFactory class for xsl:include markup.
+ * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
+ * @see <a href="http://www.w3.org/TR/xslt#include">include in XSLT Specification</a>
+ * 
+ * @xsl.usage internal
+ */
+public class ProcessorInclude extends XSLTElementProcessor
+{
+    static final long serialVersionUID = -4570078731972673481L;
+
+  /**
+   * The base URL of the XSL document.
+   * @serial
+   */
+  private String m_href = null;
+
+  /**
+   * Get the base identifier with which this stylesheet is associated.
+   *
+   * @return non-null reference to the href attribute string, or 
+   *         null if setHref has not been called.
+   */
+  public String getHref()
+  {
+    return m_href;
+  }
+
+  /**
+   * Get the base identifier with which this stylesheet is associated.
+   *
+   * @param baseIdent Should be a non-null reference to a valid URL string.
+   */
+  public void setHref(String baseIdent)
+  {
+    // Validate?
+    m_href = baseIdent;
+  }
+
+  /**
+   * Get the stylesheet type associated with an included stylesheet
+   *
+   * @return the type of the stylesheet
+   */
+  protected int getStylesheetType()
+  {
+    return StylesheetHandler.STYPE_INCLUDE;
+  }
+
+  /**
+   * Get the error number associated with this type of stylesheet including itself
+   *
+   * @return the appropriate error number
+   */
+  protected String getStylesheetInclErr()
+  {
+    return XSLTErrorResources.ER_STYLESHEET_INCLUDES_ITSELF;
+  }
+
+  /**
+   * Receive notification of the start of an xsl:include element.
+   *
+   * @param handler The calling StylesheetHandler/TemplatesBuilder.
+   * @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 rawName The raw XML 1.0 name (with prefix), or the
+   *        empty string if raw names are not available.
+   * @param attributes The attributes attached to the element.  If
+   *        there are no attributes, it shall be an empty
+   *        Attributes object.
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  public void startElement(
+          StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
+            throws org.xml.sax.SAXException
+  {
+
+
+    setPropertiesFromAttributes(handler, rawName, attributes, this);
+
+    try
+    {
+
+      // Get the Source from the user's URIResolver (if any).
+      Source sourceFromURIResolver = getSourceFromUriResolver(handler);
+      // Get the system ID of the included/imported stylesheet module
+      String hrefUrl = getBaseURIOfIncludedStylesheet(handler, sourceFromURIResolver);
+
+      if (handler.importStackContains(hrefUrl))
+      {
+        throw new org.xml.sax.SAXException(
+          XSLMessages.createMessage(
+          getStylesheetInclErr(), new Object[]{ hrefUrl }));  //"(StylesheetHandler) "+hrefUrl+" is directly or indirectly importing itself!");
+      }
+
+      // Push the system ID and corresponding Source
+      // on some stacks for later retrieval during parse() time.
+      handler.pushImportURL(hrefUrl);
+      handler.pushImportSource(sourceFromURIResolver);
+
+      int savedStylesheetType = handler.getStylesheetType();
+
+      handler.setStylesheetType(this.getStylesheetType());
+      handler.pushNewNamespaceSupport();
+
+      try
+      {
+        parse(handler, uri, localName, rawName, attributes);
+      }
+      finally
+      {
+        handler.setStylesheetType(savedStylesheetType);
+        handler.popImportURL();
+        handler.popImportSource();
+        handler.popNamespaceSupport();
+      }
+    }
+    catch(TransformerException te)
+    {
+      handler.error(te.getMessage(), te);
+    }
+  }
+
+  /**
+   * Set off a new parse for an included or imported stylesheet.  This will 
+   * set the {@link StylesheetHandler} to a new state, and recurse in with 
+   * a new set of parse events.  Once this function returns, the state of 
+   * the StylesheetHandler should be restored.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, which should be the XSLT namespace.
+   * @param localName The local name (without prefix), which should be "include" or "import".
+   * @param rawName The qualified name (with prefix).
+   * @param attributes The list of attributes on the xsl:include or xsl:import element.
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  protected void parse(
+          StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
+            throws org.xml.sax.SAXException
+  {
+    TransformerFactoryImpl processor = handler.getStylesheetProcessor();
+    URIResolver uriresolver = processor.getURIResolver();
+
+    try
+    {
+      Source source = null;
+      
+      // The base identifier, an aboslute URI
+      // that is associated with the included/imported
+      // stylesheet module is known in this method,
+      // so this method does the pushing of the
+      // base ID onto the stack.
+     
+      if (null != uriresolver)
+      {
+        // There is a user provided URI resolver.
+        // At the startElement() call we would
+        // have tried to obtain a Source from it
+        // which we now retrieve
+        source = handler.peekSourceFromURIResolver();
+
+        if (null != source && source instanceof DOMSource)
+        {
+          Node node = ((DOMSource)source).getNode();
+          
+          // There is a user provided URI resolver.
+          // At the startElement() call we would
+          // have already pushed the system ID, obtained
+          // from either the source.getSystemId(), if non-null
+          // or from SystemIDResolver.getAbsoluteURI() as a backup
+          // which we now retrieve.
+          String systemId = handler.peekImportURL();
+          
+          // Push the absolute URI of the included/imported
+          // stylesheet module onto the stack.
+          if (systemId != null)
+              handler.pushBaseIndentifier(systemId);
+        
+          TreeWalker walker = new TreeWalker(handler, new org.apache.xml.utils.DOM2Helper(), systemId);
+
+          try
+          {
+            walker.traverse(node);
+          }
+          catch(org.xml.sax.SAXException se)
+          {
+            throw new TransformerException(se);
+          }
+          if (systemId != null)
+            handler.popBaseIndentifier();
+          return;
+        }
+      }
+      
+      if(null == source)
+      {
+        String absURL = SystemIDResolver.getAbsoluteURI(getHref(),
+                          handler.getBaseIdentifier());
+
+        source = new StreamSource(absURL);
+      }
+      
+      // possible callback to a class that over-rides this method.
+      source = processSource(handler, source);
+      
+      XMLReader reader = null;
+      
+      if(source instanceof SAXSource)
+      {
+        SAXSource saxSource = (SAXSource)source;
+        reader = saxSource.getXMLReader(); // may be null
+      }
+      
+      InputSource inputSource = SAXSource.sourceToInputSource(source);
+
+      if (null == reader)
+      {  
+        // Use JAXP1.1 ( if possible )
+        try {
+          javax.xml.parsers.SAXParserFactory factory=
+                                                     javax.xml.parsers.SAXParserFactory.newInstance();
+          factory.setNamespaceAware( true );
+          
+          if (handler.getStylesheetProcessor().isSecureProcessing())
+          {
+            try
+            {
+              factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+            }
+            catch (org.xml.sax.SAXException se) {}
+          }
+          
+          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 (null != reader)
+      {
+        reader.setContentHandler(handler);
+        
+        // Push the absolute URI of the included/imported
+        // stylesheet module onto the stack.
+        handler.pushBaseIndentifier(inputSource.getSystemId());
+
+        try
+        {
+          reader.parse(inputSource);
+        }
+        finally
+        {
+          handler.popBaseIndentifier();
+        }
+      }
+    }
+    catch (IOException ioe)
+    {
+      handler.error(XSLTErrorResources.ER_IOEXCEPTION,
+                    new Object[]{ getHref() }, ioe);
+    }
+    catch(TransformerException te)
+    {
+      handler.error(te.getMessage(), te);
+    }
+  }
+
+  /**
+   * This method does nothing, but a class that extends this class could
+   * over-ride it and do some processing of the source.
+   * @param handler The calling StylesheetHandler/TemplatesBuilder.
+   * @param source The source of the included stylesheet.
+   * @return the same or an equivalent source to what was passed in.
+   */
+  protected Source processSource(StylesheetHandler handler, Source source)
+  {
+      return source;
+  }
+  
+  /**
+   * Get the Source object for the included or imported stylesheet module
+   * obtained from the user's URIResolver, if there is no user provided 
+   * URIResolver null is returned.
+   */
+  private Source getSourceFromUriResolver(StylesheetHandler handler)
+            throws TransformerException {
+        Source s = null;
+            TransformerFactoryImpl processor = handler.getStylesheetProcessor();
+            URIResolver uriresolver = processor.getURIResolver();
+            if (uriresolver != null) {
+                String href = getHref();
+                String base = handler.getBaseIdentifier();
+                s = uriresolver.resolve(href,base);
+            }
+
+        return s;
+    }
+
+    /**
+     * Get the base URI of the included or imported stylesheet,
+     * if the user provided a URIResolver, then get the Source
+     * object for the stylsheet from it, and get the systemId 
+     * from that Source object, otherwise try to recover by
+     * using the SysteIDResolver to figure out the base URI.
+     * @param handler The handler that processes the stylesheet as SAX events,
+     * and maintains state
+     * @param s The Source object from a URIResolver, for the included stylesheet module,
+     * so this will be null if there is no URIResolver set.
+     */
+    private String getBaseURIOfIncludedStylesheet(StylesheetHandler handler, Source s)
+            throws TransformerException {
+        
+
+        
+        String baseURI;
+        String idFromUriResolverSource;
+        if (s != null && (idFromUriResolverSource = s.getSystemId()) != null) {
+            // We have a Source obtained from a users's URIResolver,
+            // and the system ID is set on it, so return that as the base URI
+            baseURI = idFromUriResolverSource;
+        } else {
+            // The user did not provide a URIResolver, or it did not 
+            // return a Source for the included stylesheet module, or
+            // the Source has no system ID set, so we fall back to using
+            // the system ID Resolver to take the href and base
+            // to generate the baseURI of the included stylesheet.
+            baseURI = SystemIDResolver.getAbsoluteURI(getHref(), handler
+                    .getBaseIdentifier());
+        }
+
+        return baseURI;
+    }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorKey.java b/src/main/java/org/apache/xalan/processor/ProcessorKey.java
new file mode 100644
index 0000000..2e4cd2a
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorKey.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorKey.java 469688 2006-10-31 22:39:43Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.xalan.res.XSLMessages;
+import org.apache.xalan.res.XSLTErrorResources;
+import org.apache.xalan.templates.KeyDeclaration;
+import org.xml.sax.Attributes;
+
+/**
+ * TransformerFactory for xsl:key markup.
+ * <pre>
+ * <!ELEMENT xsl:key EMPTY>
+ * <!ATTLIST xsl:key
+ *   name %qname; #REQUIRED
+ *   match %pattern; #REQUIRED
+ *   use %expr; #REQUIRED
+ * >
+ * </pre>
+ * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
+ * @see <a href="http://www.w3.org/TR/xslt#key">key in XSLT Specification</a>
+ */
+class ProcessorKey extends XSLTElementProcessor
+{
+    static final long serialVersionUID = 4285205417566822979L;
+
+  /**
+   * Receive notification of the start of an xsl:key element.
+   *
+   * @param handler The calling StylesheetHandler/TemplatesBuilder.
+   * @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 rawName The raw XML 1.0 name (with prefix), or the
+   *        empty string if raw names are not available.
+   * @param attributes The attributes attached to the element.  If
+   *        there are no attributes, it shall be an empty
+   *        Attributes object.
+   */
+  public void startElement(
+          StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
+            throws org.xml.sax.SAXException
+  {
+
+    KeyDeclaration kd = new KeyDeclaration(handler.getStylesheet(), handler.nextUid());
+
+    kd.setDOMBackPointer(handler.getOriginatingNode());
+    kd.setLocaterInfo(handler.getLocator());
+    setPropertiesFromAttributes(handler, rawName, attributes, kd);
+    handler.getStylesheet().setKey(kd);
+  }
+
+  /**
+   * Set the properties of an object from the given attribute list.
+   * @param handler The stylesheet's Content handler, needed for
+   *                error reporting.
+   * @param rawName The raw name of the owner element, needed for
+   *                error reporting.
+   * @param attributes The list of attributes.
+   * @param target The target element where the properties will be set.
+   */
+  void setPropertiesFromAttributes(
+          StylesheetHandler handler, String rawName, Attributes attributes, 
+          org.apache.xalan.templates.ElemTemplateElement target)
+            throws org.xml.sax.SAXException
+  {
+
+    XSLTElementDef def = getElemDef();
+
+    // Keep track of which XSLTAttributeDefs have been processed, so 
+    // I can see which default values need to be set.
+    List processedDefs = new ArrayList();
+    int nAttrs = attributes.getLength();
+
+    for (int i = 0; i < nAttrs; i++)
+    {
+      String attrUri = attributes.getURI(i);
+      String attrLocalName = attributes.getLocalName(i);
+      XSLTAttributeDef attrDef = def.getAttributeDef(attrUri, attrLocalName);
+
+      if (null == attrDef)
+      {
+
+        // Then barf, because this element does not allow this attribute.
+        handler.error(attributes.getQName(i)
+                      + "attribute is not allowed on the " + rawName
+                      + " element!", null);
+      }
+      else
+      {
+        String valueString = attributes.getValue(i);
+
+        if (valueString.indexOf(org.apache.xpath.compiler.Keywords.FUNC_KEY_STRING
+                                + "(") >= 0)
+          handler.error(
+            XSLMessages.createMessage(
+            XSLTErrorResources.ER_INVALID_KEY_CALL, null), null);
+
+        processedDefs.add(attrDef);
+        attrDef.setAttrValue(handler, attrUri, attrLocalName,
+                             attributes.getQName(i), attributes.getValue(i),
+                             target);
+      }
+    }
+
+    XSLTAttributeDef[] attrDefs = def.getAttributes();
+    int nAttrDefs = attrDefs.length;
+
+    for (int i = 0; i < nAttrDefs; i++)
+    {
+      XSLTAttributeDef attrDef = attrDefs[i];
+      String defVal = attrDef.getDefault();
+
+      if (null != defVal)
+      {
+        if (!processedDefs.contains(attrDef))
+        {
+          attrDef.setDefAttrValue(handler, target);
+        }
+      }
+
+      if (attrDef.getRequired())
+      {
+        if (!processedDefs.contains(attrDef))
+          handler.error(
+            XSLMessages.createMessage(
+              XSLTErrorResources.ER_REQUIRES_ATTRIB, new Object[]{ rawName,
+                                                                   attrDef.getName() }), null);
+      }
+    }
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorLRE.java b/src/main/java/org/apache/xalan/processor/ProcessorLRE.java
new file mode 100644
index 0000000..baf9f34
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorLRE.java
@@ -0,0 +1,369 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorLRE.java 475981 2006-11-16 23:35:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import java.util.List;
+
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.apache.xalan.res.XSLMessages;
+import org.apache.xalan.res.XSLTErrorResources;
+import org.apache.xalan.templates.Constants;
+import org.apache.xalan.templates.ElemExtensionCall;
+import org.apache.xalan.templates.ElemLiteralResult;
+import org.apache.xalan.templates.ElemTemplate;
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xalan.templates.Stylesheet;
+import org.apache.xalan.templates.StylesheetRoot;
+import org.apache.xalan.templates.XMLNSDecl;
+import org.apache.xml.utils.SAXSourceLocator;
+import org.apache.xpath.XPath;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * Processes an XSLT literal-result-element, or something that looks 
+ * like one.  The actual {@link org.apache.xalan.templates.ElemTemplateElement}
+ * produced may be a {@link org.apache.xalan.templates.ElemLiteralResult}, 
+ * a {@link org.apache.xalan.templates.StylesheetRoot}, or a 
+ * {@link org.apache.xalan.templates.ElemExtensionCall}.
+ * 
+ * @see <a href="http://www.w3.org/TR/xslt#literal-result-element">literal-result-element in XSLT Specification</a>
+ * @see org.apache.xalan.templates.ElemLiteralResult
+ * @xsl.usage internal
+ */
+public class ProcessorLRE extends ProcessorTemplateElem
+{
+    static final long serialVersionUID = -1490218021772101404L;
+  /**
+   * Receive notification of the start of an element.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param attributes The specified or defaulted attributes.
+   */
+  public void startElement(
+          StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
+            throws org.xml.sax.SAXException
+  {
+
+    try
+    {
+      ElemTemplateElement p = handler.getElemTemplateElement();
+      boolean excludeXSLDecl = false;
+      boolean isLREAsStyleSheet = false;
+
+      if (null == p)
+      {
+
+        // Literal Result Template as stylesheet.
+        XSLTElementProcessor lreProcessor = handler.popProcessor();
+        XSLTElementProcessor stylesheetProcessor =
+                                                  handler.getProcessorFor(Constants.S_XSLNAMESPACEURL, "stylesheet",
+                                                                          "xsl:stylesheet");
+
+        handler.pushProcessor(lreProcessor);
+
+        Stylesheet stylesheet;
+        try
+        {
+          stylesheet = getStylesheetRoot(handler);
+        }
+        catch(TransformerConfigurationException tfe)
+        {
+          throw new TransformerException(tfe);
+        }
+
+        // stylesheet.setDOMBackPointer(handler.getOriginatingNode());
+        // ***** Note that we're assigning an empty locator. Is this necessary?
+        SAXSourceLocator slocator = new SAXSourceLocator();
+        Locator locator = handler.getLocator();
+        if(null != locator)
+        {
+          slocator.setLineNumber(locator.getLineNumber());
+          slocator.setColumnNumber(locator.getColumnNumber());
+          slocator.setPublicId(locator.getPublicId());
+          slocator.setSystemId(locator.getSystemId());
+        }
+        stylesheet.setLocaterInfo(slocator);
+        stylesheet.setPrefixes(handler.getNamespaceSupport());
+        handler.pushStylesheet(stylesheet);
+
+        isLREAsStyleSheet = true;
+
+        AttributesImpl stylesheetAttrs = new AttributesImpl();
+        AttributesImpl lreAttrs = new AttributesImpl();
+        int n = attributes.getLength();
+
+        for (int i = 0; i < n; i++)
+        {
+          String attrLocalName = attributes.getLocalName(i);
+          String attrUri = attributes.getURI(i);
+          String value = attributes.getValue(i);
+
+          if ((null != attrUri) && attrUri.equals(Constants.S_XSLNAMESPACEURL))
+          {
+            stylesheetAttrs.addAttribute(null, attrLocalName, attrLocalName,
+                                         attributes.getType(i),
+                                         attributes.getValue(i));
+          }
+          else if ((attrLocalName.startsWith("xmlns:") || attrLocalName.equals(
+                                                                               "xmlns")) && value.equals(Constants.S_XSLNAMESPACEURL))
+          {
+
+            // ignore
+          }
+          else
+          {
+            lreAttrs.addAttribute(attrUri, attrLocalName,
+                                  attributes.getQName(i),
+                                  attributes.getType(i),
+                                  attributes.getValue(i));
+          }
+        }
+
+        attributes = lreAttrs;
+
+        // Set properties from the attributes, but don't throw 
+        // an error if there is an attribute defined that is not 
+        // allowed on a stylesheet.
+				try{
+        stylesheetProcessor.setPropertiesFromAttributes(handler, "stylesheet",
+                                                        stylesheetAttrs, stylesheet);
+				}
+				catch (Exception e)
+				{
+					// This is pretty ugly, but it will have to do for now. 
+					// This is just trying to append some text specifying that
+					// this error came from a missing or invalid XSLT namespace
+					// declaration.
+					// If someone comes up with a better solution, please feel 
+					// free to contribute it. -mm
+         
+					if (stylesheet.getDeclaredPrefixes() == null || 
+						!declaredXSLNS(stylesheet))
+					{
+						throw new org.xml.sax.SAXException(XSLMessages.createWarning(XSLTErrorResources.WG_OLD_XSLT_NS, null));
+					}
+					else
+                    {
+						throw new org.xml.sax.SAXException(e);
+                    }
+				}
+        handler.pushElemTemplateElement(stylesheet);
+
+        ElemTemplate template = new ElemTemplate();
+        if (slocator != null)
+            template.setLocaterInfo(slocator);
+
+        appendAndPush(handler, template);
+
+        XPath rootMatch = new XPath("/", stylesheet, stylesheet, XPath.MATCH, 
+             handler.getStylesheetProcessor().getErrorListener());
+
+        template.setMatch(rootMatch);
+
+        // template.setDOMBackPointer(handler.getOriginatingNode());
+        stylesheet.setTemplate(template);
+
+        p = handler.getElemTemplateElement();
+        excludeXSLDecl = true;
+      }
+
+      XSLTElementDef def = getElemDef();
+      Class classObject = def.getClassObject();
+      boolean isExtension = false;
+      boolean isComponentDecl = false;
+      boolean isUnknownTopLevel = false;
+
+      while (null != p)
+      {
+
+        // System.out.println("Checking: "+p);
+        if (p instanceof ElemLiteralResult)
+        {
+          ElemLiteralResult parentElem = (ElemLiteralResult) p;
+
+          isExtension = parentElem.containsExtensionElementURI(uri);
+        }
+        else if (p instanceof Stylesheet)
+        {
+          Stylesheet parentElem = (Stylesheet) p;
+
+          isExtension = parentElem.containsExtensionElementURI(uri);
+
+          if ((false == isExtension) && (null != uri)
+              && (uri.equals(Constants.S_BUILTIN_EXTENSIONS_URL)
+                  || uri.equals(Constants.S_BUILTIN_OLD_EXTENSIONS_URL)))
+          {
+            isComponentDecl = true;
+          }
+          else
+          {
+            isUnknownTopLevel = true;
+          }
+        }
+
+        if (isExtension)
+          break;
+
+        p = p.getParentElem();
+      }
+
+      ElemTemplateElement elem = null;
+
+      try
+      {
+        if (isExtension)
+        {
+
+          // System.out.println("Creating extension(1): "+uri);
+          elem = new ElemExtensionCall();
+        }
+        else if (isComponentDecl)
+        {
+          elem = (ElemTemplateElement) classObject.newInstance();
+        }
+        else if (isUnknownTopLevel)
+        {
+
+          // TBD: Investigate, not sure about this.  -sb
+          elem = (ElemTemplateElement) classObject.newInstance();
+        }
+        else
+        {
+          elem = (ElemTemplateElement) classObject.newInstance();
+        }
+
+        elem.setDOMBackPointer(handler.getOriginatingNode());
+        elem.setLocaterInfo(handler.getLocator());
+        elem.setPrefixes(handler.getNamespaceSupport(), excludeXSLDecl);
+
+        if (elem instanceof ElemLiteralResult)
+        {
+          ((ElemLiteralResult) elem).setNamespace(uri);
+          ((ElemLiteralResult) elem).setLocalName(localName);
+          ((ElemLiteralResult) elem).setRawName(rawName);
+          ((ElemLiteralResult) elem).setIsLiteralResultAsStylesheet(
+                                                                    isLREAsStyleSheet);
+        }
+      }
+      catch (InstantiationException ie)
+      {
+        handler.error(XSLTErrorResources.ER_FAILED_CREATING_ELEMLITRSLT, null, ie);//"Failed creating ElemLiteralResult instance!", ie);
+      }
+      catch (IllegalAccessException iae)
+      {
+        handler.error(XSLTErrorResources.ER_FAILED_CREATING_ELEMLITRSLT, null, iae);//"Failed creating ElemLiteralResult instance!", iae);
+      }
+
+      setPropertiesFromAttributes(handler, rawName, attributes, elem);
+
+      // bit of a hack here...
+      if (!isExtension && (elem instanceof ElemLiteralResult))
+      {
+        isExtension =
+                     ((ElemLiteralResult) elem).containsExtensionElementURI(uri);
+
+        if (isExtension)
+        {
+
+          // System.out.println("Creating extension(2): "+uri);
+          elem = new ElemExtensionCall();
+
+          elem.setLocaterInfo(handler.getLocator());
+          elem.setPrefixes(handler.getNamespaceSupport());
+          ((ElemLiteralResult) elem).setNamespace(uri);
+          ((ElemLiteralResult) elem).setLocalName(localName);
+          ((ElemLiteralResult) elem).setRawName(rawName);
+          setPropertiesFromAttributes(handler, rawName, attributes, elem);
+        }
+      }
+
+      appendAndPush(handler, elem);
+    }
+    catch(TransformerException te)
+    {
+      throw new org.xml.sax.SAXException(te);
+    }
+  }
+
+  /**
+   * This method could be over-ridden by a class that extends this class.
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @return an object that represents the stylesheet element.
+   */
+  protected Stylesheet getStylesheetRoot(StylesheetHandler handler) throws TransformerConfigurationException
+  {
+    StylesheetRoot stylesheet;
+    stylesheet = new StylesheetRoot(handler.getSchema(), handler.getStylesheetProcessor().getErrorListener());
+    if (handler.getStylesheetProcessor().isSecureProcessing())
+      stylesheet.setSecureProcessing(true);
+    
+    return stylesheet;
+  }
+  
+
+/**
+   * Receive notification of the end of an element.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   */
+  public void endElement(
+          StylesheetHandler handler, String uri, String localName, String rawName)
+            throws org.xml.sax.SAXException
+  {
+
+    ElemTemplateElement elem = handler.getElemTemplateElement();
+
+    if (elem instanceof ElemLiteralResult)
+    {
+      if (((ElemLiteralResult) elem).getIsLiteralResultAsStylesheet())
+      {
+        handler.popStylesheet();
+      }
+    }
+
+    super.endElement(handler, uri, localName, rawName);
+  }
+	
+	private boolean declaredXSLNS(Stylesheet stylesheet)
+	{
+		List declaredPrefixes = stylesheet.getDeclaredPrefixes();
+		int n = declaredPrefixes.size();
+
+		for (int i = 0; i < n; i++)
+		{
+			XMLNSDecl decl = (XMLNSDecl) declaredPrefixes.get(i);
+			if(decl.getURI().equals(Constants.S_XSLNAMESPACEURL))
+				return true;
+		}
+		return false;
+	}
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorNamespaceAlias.java b/src/main/java/org/apache/xalan/processor/ProcessorNamespaceAlias.java
new file mode 100644
index 0000000..5ba7d19
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorNamespaceAlias.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorNamespaceAlias.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import org.apache.xalan.res.XSLTErrorResources;
+import org.apache.xalan.templates.NamespaceAlias;
+import org.xml.sax.Attributes;
+
+/**
+ * TransformerFactory for xsl:namespace-alias markup.
+ * A stylesheet can use the xsl:namespace-alias element to
+ * declare that one namespace URI is an alias for another namespace URI.
+ * <pre>
+ * <!ELEMENT xsl:namespace-alias EMPTY>
+ * <!ATTLIST xsl:namespace-alias
+ *   stylesheet-prefix CDATA #REQUIRED
+ *   result-prefix CDATA #REQUIRED
+ * >
+ * </pre>
+ * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
+ * @see <a href="http://www.w3.org/TR/xslt#literal-result-element">literal-result-element in XSLT Specification</a>
+ */
+class ProcessorNamespaceAlias extends XSLTElementProcessor
+{
+    static final long serialVersionUID = -6309867839007018964L;
+
+  /**
+   * Receive notification of the start of an xsl:namespace-alias element.
+   *
+   * @param handler The calling StylesheetHandler/TemplatesBuilder.
+   * @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 rawName The raw XML 1.0 name (with prefix), or the
+   *        empty string if raw names are not available.
+   * @param attributes The attributes attached to the element.  If
+   *        there are no attributes, it shall be an empty
+   *        Attributes object.
+   */
+  public void startElement(
+          StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
+            throws org.xml.sax.SAXException
+  {
+    final String resultNS;
+    NamespaceAlias na = new NamespaceAlias(handler.nextUid());
+
+    setPropertiesFromAttributes(handler, rawName, attributes, na);
+    String prefix = na.getStylesheetPrefix();
+    if(prefix.equals("#default"))
+    {
+      prefix = "";
+      na.setStylesheetPrefix(prefix);
+    }
+    String stylesheetNS = handler.getNamespaceForPrefix(prefix);
+    na.setStylesheetNamespace(stylesheetNS);
+    prefix = na.getResultPrefix();
+    if(prefix.equals("#default"))
+    {
+      prefix = "";
+      na.setResultPrefix(prefix);
+      resultNS = handler.getNamespaceForPrefix(prefix);
+      if(null == resultNS)
+        handler.error(XSLTErrorResources.ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, null, null);
+    }
+    else
+    {
+        resultNS = handler.getNamespaceForPrefix(prefix);
+        if(null == resultNS)
+         handler.error(XSLTErrorResources.ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, new Object[] {prefix}, null);
+    }
+   
+    na.setResultNamespace(resultNS);
+    handler.getStylesheet().setNamespaceAlias(na);
+    handler.getStylesheet().appendChild(na);
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorOutputElem.java b/src/main/java/org/apache/xalan/processor/ProcessorOutputElem.java
new file mode 100644
index 0000000..cb07b43
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorOutputElem.java
@@ -0,0 +1,223 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorOutputElem.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.TransformerException;
+
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xalan.templates.OutputProperties;
+import org.apache.xml.serializer.OutputPropertiesFactory;
+import org.apache.xml.utils.QName;
+import org.apache.xml.utils.SystemIDResolver;
+import org.xml.sax.Attributes;
+
+/**
+ * TransformerFactory for xsl:output markup.
+ * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
+ * @see <a href="http://www.w3.org/TR/xslt#output">output in XSLT Specification</a>
+ */
+class ProcessorOutputElem extends XSLTElementProcessor
+{
+    static final long serialVersionUID = 3513742319582547590L;
+
+  /** The output properties, set temporarily while the properties are 
+   *  being set from the attributes, and then nulled after that operation 
+   *  is completed.  */
+  private OutputProperties m_outputProperties;
+
+  /**
+   * Set the cdata-section-elements property from the attribute value.
+   * @see javax.xml.transform.OutputKeys#CDATA_SECTION_ELEMENTS
+   * @param newValue non-null reference to processed attribute value.
+   */
+  public void setCdataSectionElements(java.util.Vector newValue)
+  {
+    m_outputProperties.setQNameProperties(OutputKeys.CDATA_SECTION_ELEMENTS, newValue);
+  }
+
+  /**
+   * Set the doctype-public property from the attribute value.
+   * @see javax.xml.transform.OutputKeys#DOCTYPE_PUBLIC
+   * @param newValue non-null reference to processed attribute value.
+   */
+  public void setDoctypePublic(String newValue)
+  {
+    m_outputProperties.setProperty(OutputKeys.DOCTYPE_PUBLIC, newValue);
+  }
+
+  /**
+   * Set the doctype-system property from the attribute value.
+   * @see javax.xml.transform.OutputKeys#DOCTYPE_SYSTEM
+   * @param newValue non-null reference to processed attribute value.
+   */
+  public void setDoctypeSystem(String newValue)
+  {
+    m_outputProperties.setProperty(OutputKeys.DOCTYPE_SYSTEM, newValue);
+  }
+
+  /**
+   * Set the encoding property from the attribute value.
+   * @see javax.xml.transform.OutputKeys#ENCODING
+   * @param newValue non-null reference to processed attribute value.
+   */
+  public void setEncoding(String newValue)
+  {
+    m_outputProperties.setProperty(OutputKeys.ENCODING, newValue);
+  }
+
+  /**
+   * Set the indent property from the attribute value.
+   * @see javax.xml.transform.OutputKeys#INDENT
+   * @param newValue non-null reference to processed attribute value.
+   */
+  public void setIndent(boolean newValue)
+  {
+    m_outputProperties.setBooleanProperty(OutputKeys.INDENT, newValue);
+  }
+
+  /**
+   * Set the media type property from the attribute value.
+   * @see javax.xml.transform.OutputKeys#MEDIA_TYPE
+   * @param newValue non-null reference to processed attribute value.
+   */
+  public void setMediaType(String newValue)
+  {
+    m_outputProperties.setProperty(OutputKeys.MEDIA_TYPE, newValue);
+  }
+
+  /**
+   * Set the method property from the attribute value.
+   * @see javax.xml.transform.OutputKeys#METHOD
+   * @param newValue non-null reference to processed attribute value.
+   */
+  public void setMethod(org.apache.xml.utils.QName newValue)
+  {
+    m_outputProperties.setQNameProperty(OutputKeys.METHOD, newValue);
+  }
+
+  /**
+   * Set the omit-xml-declaration property from the attribute value.
+   * @see javax.xml.transform.OutputKeys#OMIT_XML_DECLARATION
+   * @param newValue processed attribute value.
+   */
+  public void setOmitXmlDeclaration(boolean newValue)
+  {
+    m_outputProperties.setBooleanProperty(OutputKeys.OMIT_XML_DECLARATION, newValue);
+  }
+
+  /**
+   * Set the standalone property from the attribute value.
+   * @see javax.xml.transform.OutputKeys#STANDALONE
+   * @param newValue processed attribute value.
+   */
+  public void setStandalone(boolean newValue)
+  {
+    m_outputProperties.setBooleanProperty(OutputKeys.STANDALONE, newValue);
+  }
+
+  /**
+   * Set the version property from the attribute value.
+   * @see javax.xml.transform.OutputKeys#VERSION
+   * @param newValue non-null reference to processed attribute value.
+   */
+  public void setVersion(String newValue)
+  {
+    m_outputProperties.setProperty(OutputKeys.VERSION, newValue);
+  }
+  
+  /**
+   * Set a foreign property from the attribute value.
+   * @param newValue non-null reference to attribute value.
+   */
+  public void setForeignAttr(String attrUri, String attrLocalName, String attrRawName, String attrValue)
+  {
+    QName key = new QName(attrUri, attrLocalName);
+    m_outputProperties.setProperty(key, attrValue);
+  }
+  
+  /**
+   * Set a foreign property from the attribute value.
+   * @param newValue non-null reference to attribute value.
+   */
+  public void addLiteralResultAttribute(String attrUri, String attrLocalName, String attrRawName, String attrValue)
+  {
+    QName key = new QName(attrUri, attrLocalName);
+    m_outputProperties.setProperty(key, attrValue);
+  }
+
+  /**
+   * Receive notification of the start of an xsl:output element.
+   *
+   * @param handler The calling StylesheetHandler/TemplatesBuilder.
+   * @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 rawName The raw XML 1.0 name (with prefix), or the
+   *        empty string if raw names are not available.
+   * @param attributes The attributes attached to the element.  If
+   *        there are no attributes, it shall be an empty
+   *        Attributes object.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public void startElement(
+          StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
+            throws org.xml.sax.SAXException
+  {
+    // Hmmm... for the moment I don't think I'll have default properties set for this. -sb
+    m_outputProperties = new OutputProperties();
+
+    m_outputProperties.setDOMBackPointer(handler.getOriginatingNode());
+    m_outputProperties.setLocaterInfo(handler.getLocator());
+    m_outputProperties.setUid(handler.nextUid());
+    setPropertiesFromAttributes(handler, rawName, attributes, this);
+    
+    // Access this only from the Hashtable level... we don't want to 
+    // get default properties.
+    String entitiesFileName =
+      (String) m_outputProperties.getProperties().get(OutputPropertiesFactory.S_KEY_ENTITIES);
+
+    if (null != entitiesFileName)
+    {
+      try
+      {
+        String absURL = SystemIDResolver.getAbsoluteURI(entitiesFileName,
+                    handler.getBaseIdentifier());
+        m_outputProperties.getProperties().put(OutputPropertiesFactory.S_KEY_ENTITIES, absURL);
+      }
+      catch(TransformerException te)
+      {
+        handler.error(te.getMessage(), te);
+      }
+    }
+    
+    handler.getStylesheet().setOutput(m_outputProperties);
+    
+    ElemTemplateElement parent = handler.getElemTemplateElement();
+    parent.appendChild(m_outputProperties);
+    
+    m_outputProperties = null;
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorPreserveSpace.java b/src/main/java/org/apache/xalan/processor/ProcessorPreserveSpace.java
new file mode 100644
index 0000000..ba2e443
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorPreserveSpace.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorPreserveSpace.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import java.util.Vector;
+
+import org.apache.xalan.templates.Stylesheet;
+import org.apache.xalan.templates.WhiteSpaceInfo;
+import org.apache.xpath.XPath;
+
+import org.xml.sax.Attributes;
+
+/**
+ * TransformerFactory for xsl:preserve-space markup.
+ * <pre>
+ * <!ELEMENT xsl:preserve-space EMPTY>
+ * <!ATTLIST xsl:preserve-space elements CDATA #REQUIRED>
+ * </pre>
+ */
+class ProcessorPreserveSpace extends XSLTElementProcessor
+{
+    static final long serialVersionUID = -5552836470051177302L;
+
+  /**
+   * Receive notification of the start of an preserve-space element.
+   *
+   * @param handler The calling StylesheetHandler/TemplatesBuilder.
+   * @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 rawName The raw XML 1.0 name (with prefix), or the
+   *        empty string if raw names are not available.
+   * @param attributes The attributes attached to the element.  If
+   *        there are no attributes, it shall be an empty
+   *        Attributes object.
+   */
+  public void startElement(
+          StylesheetHandler handler, String uri, String localName, String rawName, 
+          Attributes attributes)
+            throws org.xml.sax.SAXException
+  {
+    Stylesheet thisSheet = handler.getStylesheet();
+	WhitespaceInfoPaths paths = new WhitespaceInfoPaths(thisSheet);
+    setPropertiesFromAttributes(handler, rawName, attributes, paths);
+
+    Vector xpaths = paths.getElements();
+
+    for (int i = 0; i < xpaths.size(); i++)
+    {
+      WhiteSpaceInfo wsi = new WhiteSpaceInfo((XPath) xpaths.elementAt(i), false, thisSheet);
+      wsi.setUid(handler.nextUid());
+
+      thisSheet.setPreserveSpaces(wsi);
+    }
+    paths.clearElements();
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorStripSpace.java b/src/main/java/org/apache/xalan/processor/ProcessorStripSpace.java
new file mode 100644
index 0000000..1a6d5d7
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorStripSpace.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorStripSpace.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import java.util.Vector;
+
+import org.apache.xalan.templates.Stylesheet;
+import org.apache.xalan.templates.WhiteSpaceInfo;
+import org.apache.xpath.XPath;
+
+import org.xml.sax.Attributes;
+
+/**
+ * TransformerFactory for xsl:strip-space markup.
+ * <pre>
+ * <!ELEMENT xsl:strip-space EMPTY>
+ * <!ATTLIST xsl:strip-space elements CDATA #REQUIRED>
+ * </pre>
+ */
+class ProcessorStripSpace extends ProcessorPreserveSpace
+{
+    static final long serialVersionUID = -5594493198637899591L;
+
+  /**
+   * Receive notification of the start of an strip-space element.
+   *
+   * @param handler The calling StylesheetHandler/TemplatesBuilder.
+   * @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 rawName The raw XML 1.0 name (with prefix), or the
+   *        empty string if raw names are not available.
+   * @param attributes The attributes attached to the element.  If
+   *        there are no attributes, it shall be an empty
+   *        Attributes object.
+   */
+  public void startElement(
+          StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
+            throws org.xml.sax.SAXException
+  {
+    Stylesheet thisSheet = handler.getStylesheet();
+	WhitespaceInfoPaths paths = new WhitespaceInfoPaths(thisSheet);
+    setPropertiesFromAttributes(handler, rawName, attributes, paths);
+
+    Vector xpaths = paths.getElements();
+
+    for (int i = 0; i < xpaths.size(); i++)
+    {
+      WhiteSpaceInfo wsi = new WhiteSpaceInfo((XPath) xpaths.elementAt(i), true, thisSheet);
+      wsi.setUid(handler.nextUid());
+
+      thisSheet.setStripSpaces(wsi);
+    }
+    paths.clearElements();
+
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorStylesheetDoc.java b/src/main/java/org/apache/xalan/processor/ProcessorStylesheetDoc.java
new file mode 100644
index 0000000..169b1d3
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorStylesheetDoc.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorStylesheetDoc.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+/**
+ * This class processes the xsl:stylesheet element.  At the 
+ * moment, it defers all methods to it's superclass.
+ * @xsl.usage internal
+ */
+public class ProcessorStylesheetDoc extends XSLTElementProcessor
+{
+    static final long serialVersionUID = -1661497592836231844L;
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorStylesheetElement.java b/src/main/java/org/apache/xalan/processor/ProcessorStylesheetElement.java
new file mode 100644
index 0000000..9314ebd
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorStylesheetElement.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorStylesheetElement.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.apache.xalan.templates.Stylesheet;
+import org.apache.xalan.templates.StylesheetComposed;
+import org.apache.xalan.templates.StylesheetRoot;
+
+import org.xml.sax.Attributes;
+
+/**
+ * TransformerFactory for xsl:stylesheet or xsl:transform markup.
+ * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
+ * @see <a href="http://www.w3.org/TR/xslt#stylesheet-element">stylesheet-element in XSLT Specification</a>
+ * 
+ * @xsl.usage internal
+ */
+public class ProcessorStylesheetElement extends XSLTElementProcessor
+{
+    static final long serialVersionUID = -877798927447840792L;
+
+  /**
+   * Receive notification of the start of an strip-space element.
+   *
+   * @param handler The calling StylesheetHandler/TemplatesBuilder.
+   * @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 rawName The raw XML 1.0 name (with prefix), or the
+   *        empty string if raw names are not available.
+   * @param attributes The attributes attached to the element.  If
+   *        there are no attributes, it shall be an empty
+   *        Attributes object.
+   */
+  public void startElement(
+          StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
+            throws org.xml.sax.SAXException
+  {
+
+		super.startElement(handler, uri, localName, rawName, attributes);
+    try
+    {
+      int stylesheetType = handler.getStylesheetType();
+      Stylesheet stylesheet;
+
+      if (stylesheetType == StylesheetHandler.STYPE_ROOT)
+      {
+        try
+        {
+          stylesheet = getStylesheetRoot(handler);
+        }
+        catch(TransformerConfigurationException tfe)
+        {
+          throw new TransformerException(tfe);
+        }
+      }
+      else
+      {
+        Stylesheet parent = handler.getStylesheet();
+
+        if (stylesheetType == StylesheetHandler.STYPE_IMPORT)
+        {
+          StylesheetComposed sc = new StylesheetComposed(parent);
+
+          parent.setImport(sc);
+
+          stylesheet = sc;
+        }
+        else
+        {
+          stylesheet = new Stylesheet(parent);
+
+          parent.setInclude(stylesheet);
+        }
+      }
+
+      stylesheet.setDOMBackPointer(handler.getOriginatingNode());
+      stylesheet.setLocaterInfo(handler.getLocator());
+
+      stylesheet.setPrefixes(handler.getNamespaceSupport());
+      handler.pushStylesheet(stylesheet);
+      setPropertiesFromAttributes(handler, rawName, attributes,
+                                  handler.getStylesheet());
+      handler.pushElemTemplateElement(handler.getStylesheet());
+    }
+    catch(TransformerException te)
+    {
+      throw new org.xml.sax.SAXException(te);
+    }
+  }
+
+  /**
+   * This method can be over-ridden by a class that extends this one.
+   * @param handler The calling StylesheetHandler/TemplatesBuilder.
+   */
+  protected Stylesheet getStylesheetRoot(StylesheetHandler handler) throws TransformerConfigurationException
+  {
+    StylesheetRoot stylesheet;
+    stylesheet = new StylesheetRoot(handler.getSchema(), handler.getStylesheetProcessor().getErrorListener());
+    
+    if (handler.getStylesheetProcessor().isSecureProcessing())
+      stylesheet.setSecureProcessing(true);
+    
+    return stylesheet;
+  }
+
+/**
+   * Receive notification of the end of an element.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   */
+  public void endElement(
+          StylesheetHandler handler, String uri, String localName, String rawName)
+            throws org.xml.sax.SAXException
+  {
+		super.endElement(handler, uri, localName, rawName);
+    handler.popElemTemplateElement();
+    handler.popStylesheet();
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorTemplate.java b/src/main/java/org/apache/xalan/processor/ProcessorTemplate.java
new file mode 100644
index 0000000..cd11ecd
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorTemplate.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorTemplate.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import org.apache.xalan.templates.ElemTemplate;
+import org.apache.xalan.templates.ElemTemplateElement;
+
+/**
+ * TransformerFactory for xsl:template markup.
+ */
+class ProcessorTemplate extends ProcessorTemplateElem
+{
+    static final long serialVersionUID = -8457812845473603860L;
+  
+  /**
+   * Append the current template element to the current
+   * template element, and then push it onto the current template
+   * element stack.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param elem Must be a non-null reference to a {@link org.apache.xalan.templates.ElemTemplate} object.
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  protected void appendAndPush(
+          StylesheetHandler handler, ElemTemplateElement elem)
+            throws org.xml.sax.SAXException
+  {
+
+    super.appendAndPush(handler, elem);
+    elem.setDOMBackPointer(handler.getOriginatingNode());
+    handler.getStylesheet().setTemplate((ElemTemplate) elem);
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorTemplateElem.java b/src/main/java/org/apache/xalan/processor/ProcessorTemplateElem.java
new file mode 100644
index 0000000..d3331bd
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorTemplateElem.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorTemplateElem.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import javax.xml.transform.TransformerException;
+
+import org.apache.xalan.res.XSLTErrorResources;
+import org.apache.xalan.templates.ElemTemplateElement;
+
+import org.xml.sax.Attributes;
+
+/**
+ * This class processes parse events for an XSLT template element.
+ * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
+ * @see <a href="http://www.w3.org/TR/xslt#section-Creating-the-Result-Tree">section-Creating-the-Result-Tree in XSLT Specification</a>
+ */
+public class ProcessorTemplateElem extends XSLTElementProcessor
+{
+    static final long serialVersionUID = 8344994001943407235L;
+
+  /**
+   * Receive notification of the start of an element.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param attributes The specified or defaulted attributes.
+   */
+  public void startElement(
+          StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
+            throws org.xml.sax.SAXException
+  {
+
+    super.startElement(handler, uri, localName, rawName, attributes);
+    try
+    {
+      // ElemTemplateElement parent = handler.getElemTemplateElement();
+      XSLTElementDef def = getElemDef();
+      Class classObject = def.getClassObject();
+      ElemTemplateElement elem = null;
+
+      try
+      {
+        elem = (ElemTemplateElement) classObject.newInstance();
+
+        elem.setDOMBackPointer(handler.getOriginatingNode());
+        elem.setLocaterInfo(handler.getLocator());
+        elem.setPrefixes(handler.getNamespaceSupport());
+      }
+      catch (InstantiationException ie)
+      {
+        handler.error(XSLTErrorResources.ER_FAILED_CREATING_ELEMTMPL, null, ie);//"Failed creating ElemTemplateElement instance!", ie);
+      }
+      catch (IllegalAccessException iae)
+      {
+        handler.error(XSLTErrorResources.ER_FAILED_CREATING_ELEMTMPL, null, iae);//"Failed creating ElemTemplateElement instance!", iae);
+      }
+
+      setPropertiesFromAttributes(handler, rawName, attributes, elem);
+      appendAndPush(handler, elem);
+    }
+    catch(TransformerException te)
+    {
+      throw new org.xml.sax.SAXException(te);
+    }
+  }
+
+  /**
+   * Append the current template element to the current
+   * template element, and then push it onto the current template
+   * element stack.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param elem non-null reference to a the current template element.
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  protected void appendAndPush(
+          StylesheetHandler handler, ElemTemplateElement elem)
+            throws org.xml.sax.SAXException
+  {
+
+    ElemTemplateElement parent = handler.getElemTemplateElement();
+    if(null != parent)  // defensive, for better multiple error reporting. -sb
+    {
+      parent.appendChild(elem);
+      handler.pushElemTemplateElement(elem);
+    }
+  }
+
+  /**
+   * Receive notification of the end of an element.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   */
+  public void endElement(
+          StylesheetHandler handler, String uri, String localName, String rawName)
+            throws org.xml.sax.SAXException
+  {
+    super.endElement(handler, uri, localName, rawName);
+    handler.popElemTemplateElement().setEndLocaterInfo(handler.getLocator());
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorText.java b/src/main/java/org/apache/xalan/processor/ProcessorText.java
new file mode 100644
index 0000000..5111a41
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorText.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorText.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xalan.templates.ElemText;
+
+/**
+ * Process xsl:text.
+ * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
+ * @see <a href="http://www.w3.org/TR/xslt#element-text">element-text in XSLT Specification</a>
+ */
+public class ProcessorText extends ProcessorTemplateElem
+{
+    static final long serialVersionUID = 5170229307201307523L;
+
+  /**
+   * Append the current template element to the current
+   * template element, and then push it onto the current template
+   * element stack.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param elem non-null reference to a {@link org.apache.xalan.templates.ElemText}.
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  protected void appendAndPush(
+          StylesheetHandler handler, ElemTemplateElement elem)
+            throws org.xml.sax.SAXException
+  {
+
+    // Don't push this element onto the element stack.
+    ProcessorCharacters charProcessor =
+      (ProcessorCharacters) handler.getProcessorFor(null, "text()", "text");
+
+    charProcessor.setXslTextElement((ElemText) elem);
+
+    ElemTemplateElement parent = handler.getElemTemplateElement();
+
+    parent.appendChild(elem);
+    elem.setDOMBackPointer(handler.getOriginatingNode());
+  }
+
+  /**
+   * Receive notification of the end of an element.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   */
+  public void endElement(
+          StylesheetHandler handler, String uri, String localName, String rawName)
+            throws org.xml.sax.SAXException
+  {
+
+    ProcessorCharacters charProcessor 
+      = (ProcessorCharacters) handler.getProcessorFor(null, "text()", "text");
+
+    charProcessor.setXslTextElement(null);
+
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/ProcessorUnknown.java b/src/main/java/org/apache/xalan/processor/ProcessorUnknown.java
new file mode 100644
index 0000000..8aed015
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/ProcessorUnknown.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: ProcessorUnknown.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import org.xml.sax.Attributes;
+
+/**
+ * This class processes an unknown template element.  It is used both 
+ * for unknown top-level elements, and for elements in the 
+ * xslt namespace when the version is higher than the version 
+ * of XSLT that we are set up to process.
+ * @xsl.usage internal
+ */
+public class ProcessorUnknown extends ProcessorLRE
+{
+    static final long serialVersionUID = 600521151487682248L;
+
+}
diff --git a/src/main/java/org/apache/xalan/processor/StylesheetHandler.java b/src/main/java/org/apache/xalan/processor/StylesheetHandler.java
new file mode 100644
index 0000000..dba47ac
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/StylesheetHandler.java
@@ -0,0 +1,1727 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: StylesheetHandler.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import java.util.Stack;
+
+import javax.xml.transform.ErrorListener;
+import javax.xml.transform.Source;
+import javax.xml.transform.SourceLocator;
+import javax.xml.transform.Templates;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.sax.TemplatesHandler;
+
+import org.apache.xalan.extensions.ExpressionVisitor;
+import org.apache.xalan.res.XSLMessages;
+import org.apache.xalan.res.XSLTErrorResources;
+import org.apache.xalan.templates.Constants;
+import org.apache.xalan.templates.ElemForEach;
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xalan.templates.Stylesheet;
+import org.apache.xalan.templates.StylesheetRoot;
+import org.apache.xml.utils.BoolStack;
+import org.apache.xml.utils.NamespaceSupport2;
+import org.apache.xml.utils.NodeConsumer;
+import org.apache.xml.utils.PrefixResolver;
+import org.apache.xml.utils.SAXSourceLocator;
+import org.apache.xml.utils.XMLCharacterRecognizer;
+import org.apache.xpath.XPath;
+import org.apache.xpath.compiler.FunctionTable;
+import org.apache.xpath.functions.Function;
+
+import org.w3c.dom.Node;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.helpers.DefaultHandler;
+import org.xml.sax.helpers.NamespaceSupport;
+
+/**
+ * Initializes and processes a stylesheet via SAX events.
+ * This class acts as essentially a state machine, maintaining
+ * a ContentHandler stack, and pushing appropriate content
+ * handlers as parse events occur.
+ * @xsl.usage advanced
+ */
+public class StylesheetHandler extends DefaultHandler
+        implements TemplatesHandler, PrefixResolver, NodeConsumer
+{
+
+
+  /**
+   * The function table of XPath and XSLT;
+   */
+  private FunctionTable m_funcTable = new FunctionTable();
+  
+  /**
+   * The flag for the setting of the optimize feature;
+   */
+  private boolean m_optimize = true;
+  
+  /**
+   * The flag for the setting of the incremental feature;
+   */
+  private boolean m_incremental = false;
+  
+  /**
+   * The flag for the setting of the source_location feature;
+   */
+  private boolean m_source_location = false;
+  
+  /**
+   * Create a StylesheetHandler object, creating a root stylesheet
+   * as the target.
+   *
+   * @param processor non-null reference to the transformer factory that owns this handler.
+   *
+   * @throws TransformerConfigurationException if a StylesheetRoot
+   * can not be constructed for some reason.
+   */
+  public StylesheetHandler(TransformerFactoryImpl processor)
+          throws TransformerConfigurationException
+  {
+    Class func = org.apache.xalan.templates.FuncDocument.class;
+    m_funcTable.installFunction("document", func);
+
+    // func = new org.apache.xalan.templates.FuncKey();
+    // FunctionTable.installFunction("key", func);
+    func = org.apache.xalan.templates.FuncFormatNumb.class;
+
+    m_funcTable.installFunction("format-number", func);
+
+    m_optimize =((Boolean) processor.getAttribute(
+            TransformerFactoryImpl.FEATURE_OPTIMIZE)).booleanValue();
+    m_incremental = ((Boolean) processor.getAttribute(
+            TransformerFactoryImpl.FEATURE_INCREMENTAL)).booleanValue();
+    m_source_location = ((Boolean) processor.getAttribute(
+            TransformerFactoryImpl.FEATURE_SOURCE_LOCATION)).booleanValue();
+    // m_schema = new XSLTSchema();
+    init(processor);
+    
+  }
+
+  /**
+   * Do common initialization.
+   *
+   * @param processor non-null reference to the transformer factory that owns this handler.
+   */
+  void init(TransformerFactoryImpl processor)
+  {
+    m_stylesheetProcessor = processor;
+
+    // Set the initial content handler.
+    m_processors.push(m_schema.getElementProcessor());
+    this.pushNewNamespaceSupport();
+
+    // m_includeStack.push(SystemIDResolver.getAbsoluteURI(this.getBaseIdentifier(), null));
+    // initXPath(processor, null);
+  }
+
+  /**
+   * Process an expression string into an XPath.
+   * Must be public for access by the AVT class.
+   *
+   * @param str A non-null reference to a valid or invalid XPath expression string.
+   *
+   * @return A non-null reference to an XPath object that represents the string argument.
+   *
+   * @throws javax.xml.transform.TransformerException if the expression can not be processed.
+   * @see <a href="http://www.w3.org/TR/xslt#section-Expressions">Section 4 Expressions in XSLT Specification</a>
+   */
+  public XPath createXPath(String str, ElemTemplateElement owningTemplate)
+          throws javax.xml.transform.TransformerException
+  {
+    ErrorListener handler = m_stylesheetProcessor.getErrorListener();
+    XPath xpath = new XPath(str, owningTemplate, this, XPath.SELECT, handler, 
+            m_funcTable);
+    // Visit the expression, registering namespaces for any extension functions it includes.
+    xpath.callVisitors(xpath, new ExpressionVisitor(getStylesheetRoot()));
+    return xpath;
+  }
+
+  /**
+   * Process an expression string into an XPath.
+   *
+   * @param str A non-null reference to a valid or invalid match pattern string.
+   *
+   * @return A non-null reference to an XPath object that represents the string argument.
+   *
+   * @throws javax.xml.transform.TransformerException if the pattern can not be processed.
+   * @see <a href="http://www.w3.org/TR/xslt#patterns">Section 5.2 Patterns in XSLT Specification</a>
+   */
+  XPath createMatchPatternXPath(String str, ElemTemplateElement owningTemplate)
+          throws javax.xml.transform.TransformerException
+  {
+    ErrorListener handler = m_stylesheetProcessor.getErrorListener();
+    XPath xpath = new XPath(str, owningTemplate, this, XPath.MATCH, handler, 
+        m_funcTable);
+    // Visit the expression, registering namespaces for any extension functions it includes.
+    xpath.callVisitors(xpath, new ExpressionVisitor(getStylesheetRoot()));
+    return xpath;    
+  }
+
+  /**
+   * Given a namespace, get the corrisponding prefix from the current
+   * namespace support context.
+   *
+   * @param prefix The prefix to look up, which may be an empty string ("") for the default Namespace.
+   *
+   * @return The associated Namespace URI, or null if the prefix
+   *         is undeclared in this context.
+   */
+  public String getNamespaceForPrefix(String prefix)
+  {
+    return this.getNamespaceSupport().getURI(prefix);
+  }
+
+  /**
+   * Given a namespace, get the corrisponding prefix.  This is here only
+   * to support the {@link org.apache.xml.utils.PrefixResolver} interface,
+   * and will throw an error if invoked on this object.
+   *
+   * @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
+   *         is undeclared in this context.
+   */
+  public String getNamespaceForPrefix(String prefix, org.w3c.dom.Node context)
+  {
+
+    // Don't need to support this here.  Return the current URI for the prefix,
+    // ignoring the context.
+    assertion(true, "can't process a context node in StylesheetHandler!");
+
+    return null;
+  }
+
+  /**
+   * Utility function to see if the stack contains the given URL.
+   *
+   * @param stack non-null reference to a Stack.
+   * @param url URL string on which an equality test will be performed.
+   *
+   * @return true if the stack contains the url argument.
+   */
+  private boolean stackContains(Stack stack, String url)
+  {
+
+    int n = stack.size();
+    boolean contains = false;
+
+    for (int i = 0; i < n; i++)
+    {
+      String url2 = (String) stack.elementAt(i);
+
+      if (url2.equals(url))
+      {
+        contains = true;
+
+        break;
+      }
+    }
+
+    return contains;
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of the TRAX TemplatesBuilder interface.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * When this object is used as a ContentHandler or ContentHandler, it will
+   * create a Templates object, which the caller can get once
+   * the SAX events have been completed.
+   * @return The stylesheet object that was created during
+   * the SAX event process, or null if no stylesheet has
+   * been created.
+   * 
+   * Author <a href="mailto:scott_boag@lotus.com">Scott Boag</a>
+   *
+   *
+   */
+  public Templates getTemplates()
+  {
+    return getStylesheetRoot();
+  }
+
+  /**
+   * Set the base ID (URL or system ID) for the stylesheet
+   * created by this builder.  This must be set in order to
+   * resolve relative URLs in the stylesheet.
+   *
+   * @param baseID Base URL for this stylesheet.
+   */
+  public void setSystemId(String baseID)
+  {
+    pushBaseIndentifier(baseID);
+  }
+
+  /**
+   * 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 this.getBaseIdentifier();
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of the EntityResolver interface.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Resolve an external entity.
+   *
+   * @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 org.xml.sax.SAXException if the entity can not be resolved.
+   */
+  public InputSource resolveEntity(String publicId, String systemId)
+          throws org.xml.sax.SAXException
+  {
+    return getCurrentProcessor().resolveEntity(this, publicId, systemId);
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // 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.
+   * @see org.xml.sax.DTDHandler#notationDecl
+   */
+  public void notationDecl(String name, String publicId, String systemId)
+  {
+    getCurrentProcessor().notationDecl(this, name, publicId, systemId);
+  }
+
+  /**
+   * Receive notification of an unparsed entity declaration.
+   *
+   * @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.
+   * @see org.xml.sax.DTDHandler#unparsedEntityDecl
+   */
+  public void unparsedEntityDecl(String name, String publicId,
+                                 String systemId, String notationName)
+  {
+    getCurrentProcessor().unparsedEntityDecl(this, name, publicId, systemId,
+                                             notationName);
+  }
+
+  /**
+   * Given a namespace URI, and a local name or a node type, get the processor
+   * for the element, or return null if not allowed.
+   *
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   *
+   * @return A non-null reference to a element processor.
+   *
+   * @throws org.xml.sax.SAXException if the element is not allowed in the
+   * found position in the stylesheet.
+   */
+  XSLTElementProcessor getProcessorFor(
+          String uri, String localName, String rawName)
+            throws org.xml.sax.SAXException
+  {
+
+    XSLTElementProcessor currentProcessor = getCurrentProcessor();
+    XSLTElementDef def = currentProcessor.getElemDef();
+    XSLTElementProcessor elemProcessor = def.getProcessorFor(uri, localName);
+
+    if (null == elemProcessor
+            && !(currentProcessor instanceof ProcessorStylesheetDoc)
+            && ((null == getStylesheet()
+                || Double.valueOf(getStylesheet().getVersion()).doubleValue()
+                   > Constants.XSLTVERSUPPORTED) 
+                ||(!uri.equals(Constants.S_XSLNAMESPACEURL) &&
+                            currentProcessor instanceof ProcessorStylesheetElement)
+                || getElemVersion() > Constants.XSLTVERSUPPORTED
+        ))
+    {
+      elemProcessor = def.getProcessorForUnknown(uri, localName);
+    }
+
+    if (null == elemProcessor)
+      error(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_ALLOWED_IN_POSITION, new Object[]{rawName}),null);//rawName + " is not allowed in this position in the stylesheet!",
+            
+                
+    return elemProcessor;
+  }
+
+  ////////////////////////////////////////////////////////////////////
+  // Implementation of ContentHandler interface.
+  ////////////////////////////////////////////////////////////////////
+
+  /**
+   * Receive a Locator object for document events.
+   * This is called by the parser to push a locator for the
+   * stylesheet being parsed. The stack needs to be popped
+   * after the stylesheet has been parsed. We pop in
+   * popStylesheet.
+   *
+   * @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)
+  {
+
+    // System.out.println("pushing locator for: "+locator.getSystemId());
+    m_stylesheetLocatorStack.push(new SAXSourceLocator(locator));
+  }
+
+  /**
+   * The level of the stylesheet we are at.
+   */
+  private int m_stylesheetLevel = -1;
+
+  /**
+   * Receive notification of the beginning of the document.
+   *
+   * @see org.xml.sax.ContentHandler#startDocument
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  public void startDocument() throws org.xml.sax.SAXException
+  {
+    m_stylesheetLevel++;
+    pushSpaceHandling(false);
+  }
+
+  /** m_parsingComplete becomes true when the top-level stylesheet and all
+   * its included/imported stylesheets have been been fully parsed, as an
+   * indication that composition/optimization/compilation can begin.
+   * @see isStylesheetParsingComplete  */
+  private boolean m_parsingComplete = false;
+
+  /**
+   * Test whether the _last_ endDocument() has been processed.
+   * This is needed as guidance for stylesheet optimization
+   * and compilation engines, which generally don't want to start
+   * until all included and imported stylesheets have been fully
+   * parsed.
+   *
+   * @return true iff the complete stylesheet tree has been built.
+   */
+  public boolean isStylesheetParsingComplete()
+  {
+    return m_parsingComplete;
+  }
+
+  /**
+   * Receive notification of the end of the document.
+   *
+   * @see org.xml.sax.ContentHandler#endDocument
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  public void endDocument() throws org.xml.sax.SAXException
+  {
+
+    try
+    {
+      if (null != getStylesheetRoot())
+      {
+        if (0 == m_stylesheetLevel)
+          getStylesheetRoot().recompose();        
+      }
+      else
+        throw new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_NO_STYLESHEETROOT, null)); //"Did not find the stylesheet root!");
+
+      XSLTElementProcessor elemProcessor = getCurrentProcessor();
+
+      if (null != elemProcessor)
+        elemProcessor.startNonText(this);
+
+      m_stylesheetLevel--;			
+      
+      popSpaceHandling();
+
+      // WARNING: This test works only as long as stylesheets are parsed
+      // more or less recursively. If we switch to an iterative "work-list"
+      // model, this will become true prematurely. In that case,
+      // isStylesheetParsingComplete() will have to be adjusted to be aware
+      // of the worklist.
+      m_parsingComplete = (m_stylesheetLevel < 0);
+    }
+    catch (TransformerException te)
+    {
+      throw new org.xml.sax.SAXException(te);
+    }
+  }
+  
+  private java.util.Vector m_prefixMappings = new java.util.Vector();
+
+  /**
+   * 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 element (such as allocating a new tree node or writing
+   * output to a file).</p>
+   *
+   * @param prefix The Namespace prefix being declared.
+   * @param uri The Namespace URI mapped to the prefix.
+   * @see org.xml.sax.ContentHandler#startPrefixMapping
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  public void startPrefixMapping(String prefix, String uri)
+          throws org.xml.sax.SAXException
+  {
+
+    // m_nsSupport.pushContext();
+    // this.getNamespaceSupport().declarePrefix(prefix, uri);
+    //m_prefixMappings.add(prefix); // JDK 1.2+ only -sc
+    //m_prefixMappings.add(uri); // JDK 1.2+ only -sc
+    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 start of
+   * each element (such as allocating a new tree node or writing
+   * output to a file).</p>
+   *
+   * @param prefix The Namespace prefix being declared.
+   * @see org.xml.sax.ContentHandler#endPrefixMapping
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  public void endPrefixMapping(String prefix) throws org.xml.sax.SAXException
+  {
+
+    // m_nsSupport.popContext();
+  }
+
+  /**
+   * Flush the characters buffer.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  private void flushCharacters() throws org.xml.sax.SAXException
+  {
+
+    XSLTElementProcessor elemProcessor = getCurrentProcessor();
+
+    if (null != elemProcessor)
+      elemProcessor.startNonText(this);
+  }
+
+  /**
+   * Receive notification of the start of an element.
+   *
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param attributes The specified or defaulted attributes.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  public void startElement(
+          String uri, String localName, String rawName, Attributes attributes)
+            throws org.xml.sax.SAXException
+  {
+    NamespaceSupport nssupport = this.getNamespaceSupport();
+    nssupport.pushContext();
+    
+    int n = m_prefixMappings.size();
+
+    for (int i = 0; i < n; i++) 
+    {
+      String prefix = (String)m_prefixMappings.elementAt(i++);
+      String nsURI = (String)m_prefixMappings.elementAt(i);
+      nssupport.declarePrefix(prefix, nsURI);
+    }
+    //m_prefixMappings.clear(); // JDK 1.2+ only -sc
+    m_prefixMappings.removeAllElements(); // JDK 1.1.x compat -sc
+
+    m_elementID++;
+
+    // This check is currently done for all elements.  We should possibly consider
+    // limiting this check to xsl:stylesheet elements only since that is all it really
+    // applies to.  Also, it could be bypassed if m_shouldProcess is already true.
+    // In other words, the next two statements could instead look something like this:
+    // if (!m_shouldProcess)
+    // {
+    //   if (localName.equals(Constants.ELEMNAME_STYLESHEET_STRING) &&
+    //       url.equals(Constants.S_XSLNAMESPACEURL))
+    //   {
+    //     checkForFragmentID(attributes);
+    //     if (!m_shouldProcess)
+    //       return;
+    //   }
+    //   else
+    //     return;
+    // } 
+    // I didn't include this code statement at this time because in practice 
+    // it is a small performance hit and I was waiting to see if its absence
+    // caused a problem. - GLP
+
+    checkForFragmentID(attributes);
+
+    if (!m_shouldProcess)
+      return;
+
+    flushCharacters();
+    
+    pushSpaceHandling(attributes);
+
+    XSLTElementProcessor elemProcessor = getProcessorFor(uri, localName,
+                                           rawName);
+
+    if(null != elemProcessor)  // defensive, for better multiple error reporting. -sb
+    {
+      this.pushProcessor(elemProcessor);
+      elemProcessor.startElement(this, uri, localName, rawName, attributes);
+    }
+    else
+    {
+      m_shouldProcess = false;
+      popSpaceHandling();
+    }
+                
+  }
+
+  /**
+   * Receive notification of the end of an element.
+   *
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @see org.xml.sax.ContentHandler#endElement
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  public void endElement(String uri, String localName, String rawName)
+          throws org.xml.sax.SAXException
+  {
+
+    m_elementID--;
+
+    if (!m_shouldProcess)
+      return;
+
+    if ((m_elementID + 1) == m_fragmentID)
+      m_shouldProcess = false;
+
+    flushCharacters();
+    
+    popSpaceHandling();
+
+    XSLTElementProcessor p = getCurrentProcessor();
+
+    p.endElement(this, uri, localName, rawName);
+    this.popProcessor();
+    this.getNamespaceSupport().popContext();
+  }
+
+  /**
+   * Receive notification of character data inside an element.
+   *
+   * @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.
+   * @see org.xml.sax.ContentHandler#characters
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  public void characters(char ch[], int start, int length)
+          throws org.xml.sax.SAXException
+  {
+
+    if (!m_shouldProcess)
+      return;
+
+    XSLTElementProcessor elemProcessor = getCurrentProcessor();
+    XSLTElementDef def = elemProcessor.getElemDef();
+
+    if (def.getType() != XSLTElementDef.T_PCDATA)
+      elemProcessor = def.getProcessorFor(null, "text()");
+
+    if (null == elemProcessor)
+    {
+
+      // If it's whitespace, just ignore it, otherwise flag an error.
+      if (!XMLCharacterRecognizer.isWhiteSpace(ch, start, length))
+        error(
+          XSLMessages.createMessage(XSLTErrorResources.ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, null),null);//"Non-whitespace text is not allowed in this position in the stylesheet!",
+          
+    }
+    else
+      elemProcessor.characters(this, ch, start, length);
+  }
+
+  /**
+   * Receive notification of ignorable whitespace in element content.
+   *
+   * @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.
+   * @see org.xml.sax.ContentHandler#ignorableWhitespace
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  public void ignorableWhitespace(char ch[], int start, int length)
+          throws org.xml.sax.SAXException
+  {
+
+    if (!m_shouldProcess)
+      return;
+
+    getCurrentProcessor().ignorableWhitespace(this, 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>
+   *
+   * <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.
+   * @see org.xml.sax.ContentHandler#processingInstruction
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  public void processingInstruction(String target, String data)
+          throws org.xml.sax.SAXException
+  {
+    if (!m_shouldProcess)
+      return;
+
+    // Recreating Scott's kluge:
+    // A xsl:for-each or xsl:apply-templates may have a special 
+    // PI that tells us not to cache the document.  This PI 
+    // should really be namespaced.
+    //    String localName = getLocalName(target);
+    //    String ns = m_stylesheet.getNamespaceFromStack(target);
+    //
+    // %REVIEW%: We need a better PI architecture
+    
+    String prefix="",ns="", localName=target;
+    int colon=target.indexOf(':');
+    if(colon>=0)
+    {
+      ns=getNamespaceForPrefix(prefix=target.substring(0,colon));
+      localName=target.substring(colon+1);
+    }
+
+    try
+    {
+      // A xsl:for-each or xsl:apply-templates may have a special 
+      // PI that tells us not to cache the document.  This PI 
+      // should really be namespaced... but since the XML Namespaces
+      // spec never defined namespaces as applying to PI's, and since
+      // the testcase we're trying to support is inconsistant in whether
+      // it binds the prefix, I'm going to make this sloppy for
+      // testing purposes.
+      if(
+        "xalan-doc-cache-off".equals(target) ||
+        "xalan:doc-cache-off".equals(target) ||
+	   ("doc-cache-off".equals(localName) &&
+	    ns.equals("org.apache.xalan.xslt.extensions.Redirect") )
+	 )
+      {
+	if(!(m_elems.peek() instanceof ElemForEach))
+          throw new TransformerException
+	    ("xalan:doc-cache-off not allowed here!", 
+	     getLocator());
+        ElemForEach elem = (ElemForEach)m_elems.peek();
+
+        elem.m_doc_cache_off = true;
+
+	//System.out.println("JJK***** Recognized <? {"+ns+"}"+prefix+":"+localName+" "+data+"?>");
+      }
+    }
+    catch(Exception e)
+    {
+      // JJK: Officially, unknown PIs can just be ignored.
+      // Do we want to issue a warning?
+    }
+
+
+    flushCharacters();
+    getCurrentProcessor().processingInstruction(this, target, data);
+  }
+
+  /**
+   * 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.
+   * @see org.xml.sax.ContentHandler#processingInstruction
+   *
+   * @throws org.xml.sax.SAXException Any SAX exception, possibly
+   *            wrapping another exception.
+   */
+  public void skippedEntity(String name) throws org.xml.sax.SAXException
+  {
+
+    if (!m_shouldProcess)
+      return;
+
+    getCurrentProcessor().skippedEntity(this, name);
+  }
+
+  /**
+   * Warn the user of an problem.
+   *
+   * @param msg An key into the {@link org.apache.xalan.res.XSLTErrorResources}
+   * table, that is one of the WG_ prefixed definitions.
+   * @param args An array of arguments for the given warning.
+   *
+   * @throws org.xml.sax.SAXException that wraps a
+   * {@link javax.xml.transform.TransformerException} if the current
+   * {@link javax.xml.transform.ErrorListener#warning}
+   * method chooses to flag this condition as an error.
+   * @xsl.usage internal
+   */
+  public void warn(String msg, Object args[]) throws org.xml.sax.SAXException
+  {
+
+    String formattedMsg = XSLMessages.createWarning(msg, args);
+    SAXSourceLocator locator = getLocator();
+    ErrorListener handler = m_stylesheetProcessor.getErrorListener();
+
+    try
+    {
+      if (null != handler)
+        handler.warning(new TransformerException(formattedMsg, locator));
+    }
+    catch (TransformerException te)
+    {
+      throw new org.xml.sax.SAXException(te);
+    }
+  }
+
+  /**
+   * Assert that a condition is true.  If it is not true, throw an error.
+   *
+   * @param condition false if an error should not be thrown, otherwise true.
+   * @param msg Error message to be passed to the RuntimeException as an
+   * argument.
+   * @throws RuntimeException if the condition is not true.
+   * @xsl.usage internal
+   */
+  private void assertion(boolean condition, String msg) throws RuntimeException
+  {
+    if (!condition)
+      throw new RuntimeException(msg);
+  }
+
+  /**
+   * Tell the user of an error, and probably throw an
+   * exception.
+   *
+   * @param msg An error message.
+   * @param e An error which the SAXException should wrap.
+   *
+   * @throws org.xml.sax.SAXException that wraps a
+   * {@link javax.xml.transform.TransformerException} if the current
+   * {@link javax.xml.transform.ErrorListener#error}
+   * method chooses to flag this condition as an error.
+   * @xsl.usage internal
+   */
+  protected void error(String msg, Exception e)
+          throws org.xml.sax.SAXException
+  {
+
+    SAXSourceLocator locator = getLocator();
+    ErrorListener handler = m_stylesheetProcessor.getErrorListener();
+    TransformerException pe;
+
+    if (!(e instanceof TransformerException))
+    {
+      pe = (null == e)
+           ? new TransformerException(msg, locator)
+           : new TransformerException(msg, locator, e);
+    }
+    else
+      pe = (TransformerException) e;
+
+    if (null != handler)
+    {
+      try
+      {
+        handler.error(pe);
+      }
+      catch (TransformerException te)
+      {
+        throw new org.xml.sax.SAXException(te);
+      }
+    }
+    else
+      throw new org.xml.sax.SAXException(pe);
+  }
+
+  /**
+   * Tell the user of an error, and probably throw an
+   * exception.
+   *
+   * @param msg A key into the {@link org.apache.xalan.res.XSLTErrorResources}
+   * table, that is one of the WG_ prefixed definitions.
+   * @param args An array of arguments for the given warning.
+   * @param e An error which the SAXException should wrap.
+   *
+   * @throws org.xml.sax.SAXException that wraps a
+   * {@link javax.xml.transform.TransformerException} if the current
+   * {@link javax.xml.transform.ErrorListener#error}
+   * method chooses to flag this condition as an error.
+   * @xsl.usage internal
+   */
+  protected void error(String msg, Object args[], Exception e)
+          throws org.xml.sax.SAXException
+  {
+
+    String formattedMsg = XSLMessages.createMessage(msg, args);
+
+    error(formattedMsg, e);
+  }
+
+  /**
+   * Receive notification of a XSLT processing warning.
+   *
+   * @param e The warning information encoded as an exception.
+   *
+   * @throws org.xml.sax.SAXException that wraps a
+   * {@link javax.xml.transform.TransformerException} if the current
+   * {@link javax.xml.transform.ErrorListener#warning}
+   * method chooses to flag this condition as an error.
+   */
+  public void warning(org.xml.sax.SAXParseException e)
+          throws org.xml.sax.SAXException
+  {
+
+    String formattedMsg = e.getMessage();
+    SAXSourceLocator locator = getLocator();
+    ErrorListener handler = m_stylesheetProcessor.getErrorListener();
+
+    try
+    {
+      handler.warning(new TransformerException(formattedMsg, locator));
+    }
+    catch (TransformerException te)
+    {
+      throw new org.xml.sax.SAXException(te);
+    }
+  }
+
+  /**
+   * Receive notification of a recoverable XSLT processing error.
+   *
+   * @param e The error information encoded as an exception.
+   *
+   * @throws org.xml.sax.SAXException that wraps a
+   * {@link javax.xml.transform.TransformerException} if the current
+   * {@link javax.xml.transform.ErrorListener#error}
+   * method chooses to flag this condition as an error.
+   */
+  public void error(org.xml.sax.SAXParseException e)
+          throws org.xml.sax.SAXException
+  {
+
+    String formattedMsg = e.getMessage();
+    SAXSourceLocator locator = getLocator();
+    ErrorListener handler = m_stylesheetProcessor.getErrorListener();
+
+    try
+    {
+      handler.error(new TransformerException(formattedMsg, locator));
+    }
+    catch (TransformerException te)
+    {
+      throw new org.xml.sax.SAXException(te);
+    }
+  }
+
+  /**
+   * Report a fatal XSLT processing error.
+   *
+   * @param e The error information encoded as an exception.
+   *
+   * @throws org.xml.sax.SAXException that wraps a
+   * {@link javax.xml.transform.TransformerException} if the current
+   * {@link javax.xml.transform.ErrorListener#fatalError}
+   * method chooses to flag this condition as an error.
+   */
+  public void fatalError(org.xml.sax.SAXParseException e)
+          throws org.xml.sax.SAXException
+  {
+
+    String formattedMsg = e.getMessage();
+    SAXSourceLocator locator = getLocator();
+    ErrorListener handler = m_stylesheetProcessor.getErrorListener();
+
+    try
+    {
+      handler.fatalError(new TransformerException(formattedMsg, locator));
+    }
+    catch (TransformerException te)
+    {
+      throw new org.xml.sax.SAXException(te);
+    }
+  }
+
+  /**
+   * If we have a URL to a XML fragment, this is set
+   * to false until the ID is found.
+   * (warning: I worry that this should be in a stack).
+   */
+  private boolean m_shouldProcess = true;
+
+  /**
+   * If we have a URL to a XML fragment, the value is stored
+   * in this string, and the m_shouldProcess flag is set to
+   * false until we match an ID with this string.
+   * (warning: I worry that this should be in a stack).
+   */
+  private String m_fragmentIDString;
+
+  /**
+   * Keep track of the elementID, so we can tell when
+   * is has completed.  This isn't a real ID, but rather
+   * a nesting level.  However, it's good enough for
+   * our purposes.
+   * (warning: I worry that this should be in a stack).
+   */
+  private int m_elementID = 0;
+
+  /**
+   * The ID of the fragment that has been found
+   * (warning: I worry that this should be in a stack).
+   */
+  private int m_fragmentID = 0;
+
+  /**
+   * Check to see if an ID attribute matched the #id, called
+   * from startElement.
+   *
+   * @param attributes The specified or defaulted attributes.
+   */
+  private void checkForFragmentID(Attributes attributes)
+  {
+
+    if (!m_shouldProcess)
+    {
+      if ((null != attributes) && (null != m_fragmentIDString))
+      {
+        int n = attributes.getLength();
+
+        for (int i = 0; i < n; i++)
+        {
+          String name = attributes.getQName(i);
+
+          if (name.equals(Constants.ATTRNAME_ID))
+          {
+            String val = attributes.getValue(i);
+
+            if (val.equalsIgnoreCase(m_fragmentIDString))
+            {
+              m_shouldProcess = true;
+              m_fragmentID = m_elementID;
+            }
+          }
+        }
+      }
+    }
+  }
+
+  /**
+   *  The XSLT TransformerFactory for needed services.
+   */
+  private TransformerFactoryImpl m_stylesheetProcessor;
+
+  /**
+   * Get the XSLT TransformerFactoryImpl for needed services.
+   * TODO: This method should be renamed.
+   *
+   * @return The TransformerFactoryImpl that owns this handler.
+   */
+  public TransformerFactoryImpl getStylesheetProcessor()
+  {
+    return m_stylesheetProcessor;
+  }
+
+  /**
+   * If getStylesheetType returns this value, the current stylesheet
+   *  is a root stylesheet.
+   * @xsl.usage internal
+   */
+  public static final int STYPE_ROOT = 1;
+
+  /**
+   * If getStylesheetType returns this value, the current stylesheet
+   *  is an included stylesheet.
+   * @xsl.usage internal
+   */
+  public static final int STYPE_INCLUDE = 2;
+
+  /**
+   * If getStylesheetType returns this value, the current stylesheet
+   *  is an imported stylesheet.
+   * @xsl.usage internal
+   */
+  public static final int STYPE_IMPORT = 3;
+
+  /** The current stylesheet type. */
+  private int m_stylesheetType = STYPE_ROOT;
+
+  /**
+   * Get the type of stylesheet that should be built
+   * or is being processed.
+   *
+   * @return one of STYPE_ROOT, STYPE_INCLUDE, or STYPE_IMPORT.
+   */
+  int getStylesheetType()
+  {
+    return m_stylesheetType;
+  }
+
+  /**
+   * Set the type of stylesheet that should be built
+   * or is being processed.
+   *
+   * @param type Must be one of STYPE_ROOT, STYPE_INCLUDE, or STYPE_IMPORT.
+   */
+  void setStylesheetType(int type)
+  {
+    m_stylesheetType = type;
+  }
+
+  /**
+   * The stack of stylesheets being processed.
+   */
+  private Stack m_stylesheets = new Stack();
+
+  /**
+   * Return the stylesheet that this handler is constructing.
+   *
+   * @return The current stylesheet that is on top of the stylesheets stack,
+   *  or null if no stylesheet is on the stylesheets stack.
+   */
+  Stylesheet getStylesheet()
+  {
+    return (m_stylesheets.size() == 0)
+           ? null : (Stylesheet) m_stylesheets.peek();
+  }
+
+  /**
+   * Return the last stylesheet that was popped off the stylesheets stack.
+   *
+   * @return The last popped stylesheet, or null.
+   */
+  Stylesheet getLastPoppedStylesheet()
+  {
+    return m_lastPoppedStylesheet;
+  }
+
+  /**
+   * Return the stylesheet root that this handler is constructing.
+   *
+   * @return The root stylesheet of the stylesheets tree.
+   */
+  public StylesheetRoot getStylesheetRoot()
+  {
+    if (m_stylesheetRoot != null){
+        m_stylesheetRoot.setOptimizer(m_optimize);
+        m_stylesheetRoot.setIncremental(m_incremental);
+        m_stylesheetRoot.setSource_location(m_source_location);  		
+    }
+    return m_stylesheetRoot;
+  }
+
+  /** The root stylesheet of the stylesheets tree. */
+  StylesheetRoot m_stylesheetRoot;
+        
+        /** The last stylesheet that was popped off the stylesheets stack. */
+  Stylesheet m_lastPoppedStylesheet;
+
+  /**
+   * Push the current stylesheet being constructed. If no other stylesheets
+   * have been pushed onto the stack, assume the argument is a stylesheet
+   * root, and also set the stylesheet root member.
+   *
+   * @param s non-null reference to a stylesheet.
+   */
+  public void pushStylesheet(Stylesheet s)
+  {
+
+    if (m_stylesheets.size() == 0)
+      m_stylesheetRoot = (StylesheetRoot) s;
+
+    m_stylesheets.push(s);
+  }
+
+  /**
+   * Pop the last stylesheet pushed, and return the stylesheet that this
+   * handler is constructing, and set the last popped stylesheet member.
+   * Also pop the stylesheet locator stack.
+   *
+   * @return The stylesheet popped off the stack, or the last popped stylesheet.
+   */
+  Stylesheet popStylesheet()
+  {
+
+    // The stylesheetLocatorStack needs to be popped because
+    // a locator was pushed in for this stylesheet by the SAXparser by calling
+    // setDocumentLocator().
+    if (!m_stylesheetLocatorStack.isEmpty())
+      m_stylesheetLocatorStack.pop();
+
+    if (!m_stylesheets.isEmpty())
+      m_lastPoppedStylesheet = (Stylesheet) m_stylesheets.pop();
+
+    // Shouldn't this be null if stylesheets is empty?  -sb
+    return m_lastPoppedStylesheet;
+  }
+
+  /**
+   * The stack of current processors.
+   */
+  private Stack m_processors = new Stack();
+
+  /**
+   * Get the current XSLTElementProcessor at the top of the stack.
+   *
+   * @return Valid XSLTElementProcessor, which should never be null.
+   */
+  XSLTElementProcessor getCurrentProcessor()
+  {
+    return (XSLTElementProcessor) m_processors.peek();
+  }
+
+  /**
+   * Push the current XSLTElementProcessor onto the top of the stack.
+   *
+   * @param processor non-null reference to the current element processor.
+   */
+  void pushProcessor(XSLTElementProcessor processor)
+  {
+    m_processors.push(processor);
+  }
+
+  /**
+   * Pop the current XSLTElementProcessor from the top of the stack.
+   * @return the XSLTElementProcessor which was popped.
+   */
+  XSLTElementProcessor popProcessor()
+  {
+    return (XSLTElementProcessor) m_processors.pop();
+  }
+
+  /**
+   * The root of the XSLT Schema, which tells us how to
+   * transition content handlers, create elements, etc.
+   * For the moment at least, this can't be static, since
+   * the processors store state.
+   */
+  private XSLTSchema m_schema = new XSLTSchema();
+
+  /**
+   * Get the root of the XSLT Schema, which tells us how to
+   * transition content handlers, create elements, etc.
+   *
+   * @return The root XSLT Schema, which should never be null.
+   * @xsl.usage internal
+   */
+  public XSLTSchema getSchema()
+  {
+    return m_schema;
+  }
+
+  /**
+   * The stack of elements, pushed and popped as events occur.
+   */
+  private Stack m_elems = new Stack();
+
+  /**
+   * Get the current ElemTemplateElement at the top of the stack.
+   * @return Valid ElemTemplateElement, which may be null.
+   */
+  ElemTemplateElement getElemTemplateElement()
+  {
+
+    try
+    {
+      return (ElemTemplateElement) m_elems.peek();
+    }
+    catch (java.util.EmptyStackException ese)
+    {
+      return null;
+    }
+  }  
+
+  /** An increasing number that is used to indicate the order in which this element
+   *  was encountered during the parse of the XSLT tree.
+   */
+  private int m_docOrderCount = 0;
+
+  /**
+   * Returns the next m_docOrderCount number and increments the number for future use.
+   */
+  int nextUid()
+  {
+    return m_docOrderCount++;
+  }
+
+  /**
+   * Push the current XSLTElementProcessor to the top of the stack.  As a
+   * side-effect, set the document order index (simply because this is a
+   * convenient place to set it).
+   *
+   * @param elem Should be a non-null reference to the intended current
+   * template element.
+   */
+  void pushElemTemplateElement(ElemTemplateElement elem)
+  {
+
+    if (elem.getUid() == -1)
+      elem.setUid(nextUid());
+
+    m_elems.push(elem);
+  }
+
+  /**
+   * Get the current XSLTElementProcessor from the top of the stack.
+   * @return the ElemTemplateElement which was popped.
+   */
+  ElemTemplateElement popElemTemplateElement()
+  {
+    return (ElemTemplateElement) m_elems.pop();
+  }
+
+  /**
+   * This will act as a stack to keep track of the
+   * current include base.
+   */
+  Stack m_baseIdentifiers = new Stack();
+
+  /**
+   * Push a base identifier onto the base URI stack.
+   *
+   * @param baseID The current base identifier for this position in the
+   * stylesheet, which may be a fragment identifier, or which may be null.
+   * @see <a href="http://www.w3.org/TR/xslt#base-uri">
+   * Section 3.2 Base URI of XSLT specification.</a>
+   */
+  void pushBaseIndentifier(String baseID)
+  {
+
+    if (null != baseID)
+    {
+      int posOfHash = baseID.indexOf('#');
+
+      if (posOfHash > -1)
+      {
+        m_fragmentIDString = baseID.substring(posOfHash + 1);
+        m_shouldProcess = false;
+      }
+      else
+        m_shouldProcess = true;
+    }
+    else
+      m_shouldProcess = true;
+
+    m_baseIdentifiers.push(baseID);
+  }
+
+  /**
+   * Pop a base URI from the stack.
+   * @return baseIdentifier.
+   */
+  String popBaseIndentifier()
+  {
+    return (String) m_baseIdentifiers.pop();
+  }
+
+  /**
+   * Return the base identifier.
+   *
+   * @return The base identifier of the current stylesheet.
+   */
+  public String getBaseIdentifier()
+  {
+
+    // Try to get the baseIdentifier from the baseIdentifier's stack,
+    // which may not be the same thing as the value found in the
+    // SourceLocators stack.
+    String base = (String) (m_baseIdentifiers.isEmpty()
+                            ? null : m_baseIdentifiers.peek());
+
+    // Otherwise try the stylesheet.
+    if (null == base)
+    {
+      SourceLocator locator = getLocator();
+
+      base = (null == locator) ? "" : locator.getSystemId();
+    }
+
+    return base;
+  }
+
+  /**
+   * The top of this stack should contain the currently processed
+   * stylesheet SAX locator object.
+   */
+  private Stack m_stylesheetLocatorStack = new Stack();
+
+  /**
+   * Get the current stylesheet Locator object.
+   *
+   * @return non-null reference to the current locator object.
+   */
+  public SAXSourceLocator getLocator()
+  {
+
+    if (m_stylesheetLocatorStack.isEmpty())
+    {
+      SAXSourceLocator locator = new SAXSourceLocator();
+
+      locator.setSystemId(this.getStylesheetProcessor().getDOMsystemID());
+
+      return locator;
+
+      // m_stylesheetLocatorStack.push(locator);
+    }
+
+    return ((SAXSourceLocator) m_stylesheetLocatorStack.peek());
+  }
+
+  /**
+   * A stack of URL hrefs for imported stylesheets.  This is
+   * used to diagnose circular imports.
+   */
+  private Stack m_importStack = new Stack();
+  
+  /**
+   * A stack of Source objects obtained from a URIResolver,
+   * for each element in this stack there is a 1-1 correspondence
+   * with an element in the m_importStack.
+   */
+  private Stack m_importSourceStack = new Stack();
+
+  /**
+   * Push an import href onto the stylesheet stack.
+   *
+   * @param hrefUrl non-null reference to the URL for the current imported
+   * stylesheet.
+   */
+  void pushImportURL(String hrefUrl)
+  {
+    m_importStack.push(hrefUrl);
+  }
+  
+  /**
+   * Push the Source of an import href onto the stylesheet stack,
+   * obtained from a URIResolver, null if there is no URIResolver,
+   * or if that resolver returned null.
+   */
+  void pushImportSource(Source sourceFromURIResolver)
+  {
+    m_importSourceStack.push(sourceFromURIResolver);
+  }
+
+  /**
+   * See if the imported stylesheet stack already contains
+   * the given URL.  Used to test for recursive imports.
+   *
+   * @param hrefUrl non-null reference to a URL string.
+   *
+   * @return true if the URL is on the import stack.
+   */
+  boolean importStackContains(String hrefUrl)
+  {
+    return stackContains(m_importStack, hrefUrl);
+  }
+
+  /**
+   * Pop an import href from the stylesheet stack.
+   *
+   * @return non-null reference to the import URL that was popped.
+   */
+  String popImportURL()
+  {
+    return (String) m_importStack.pop();
+  }
+  
+  String peekImportURL()
+  {
+    return (String) m_importStack.peek();
+  }
+  
+  Source peekSourceFromURIResolver()
+  {
+    return (Source) m_importSourceStack.peek();
+  }
+  
+  /**
+   * Pop a Source from a user provided URIResolver, corresponding
+   * to the URL popped from the m_importStack.
+   */
+  Source popImportSource()
+  {
+    return (Source) m_importSourceStack.pop();
+  }
+
+  /**
+   * If this is set to true, we've already warned about using the
+   * older XSLT namespace URL.
+   */
+  private boolean warnedAboutOldXSLTNamespace = false;
+
+  /** Stack of NamespaceSupport objects. */
+  Stack m_nsSupportStack = new Stack();
+
+  /**
+   * Push a new NamespaceSupport instance.
+   */
+  void pushNewNamespaceSupport()
+  {
+    m_nsSupportStack.push(new NamespaceSupport2());
+  }
+
+  /**
+   * Pop the current NamespaceSupport object.
+   *
+   */
+  void popNamespaceSupport()
+  {
+    m_nsSupportStack.pop();
+  }
+
+  /**
+   * Get the current NamespaceSupport object.
+   *
+   * @return a non-null reference to the current NamespaceSupport object,
+   * which is the top of the namespace support stack.
+   */
+  NamespaceSupport getNamespaceSupport()
+  {
+    return (NamespaceSupport) m_nsSupportStack.peek();
+  }
+
+  /**
+   * The originating node if the current stylesheet is being created
+   *  from a DOM.
+   *  @see org.apache.xml.utils.NodeConsumer
+   */
+  private Node m_originatingNode;
+
+  /**
+   * Set the node that is originating the SAX event.
+   *
+   * @param n Reference to node that originated the current event.
+   * @see org.apache.xml.utils.NodeConsumer
+   */
+  public void setOriginatingNode(Node n)
+  {
+    m_originatingNode = n;
+  }
+
+  /**
+   * Set the node that is originating the SAX event.
+   *
+   * @return Reference to node that originated the current event.
+   * @see org.apache.xml.utils.NodeConsumer
+   */
+  public Node getOriginatingNode()
+  {
+    return m_originatingNode;
+  }
+  
+  /**
+   * Stack of booleans that are pushed and popped in start/endElement depending 
+   * on the value of xml:space=default/preserve.
+   */
+  private BoolStack m_spacePreserveStack = new BoolStack();
+  
+  /**
+   * Return boolean value from the spacePreserve stack depending on the value 
+   * of xml:space=default/preserve.
+   * 
+   * @return true if space should be preserved, false otherwise.
+   */
+  boolean isSpacePreserve()
+  {
+    return m_spacePreserveStack.peek();
+  }
+  
+  /**
+   * Pop boolean value from the spacePreserve stack.
+   */
+  void popSpaceHandling()
+  {
+    m_spacePreserveStack.pop();
+  }
+  
+  /**
+   * Push boolean value on to the spacePreserve stack.
+   * 
+   * @param b true if space should be preserved, false otherwise.
+   */
+  void pushSpaceHandling(boolean b)
+    throws org.xml.sax.SAXParseException
+  {
+    m_spacePreserveStack.push(b);
+  }
+  
+  /**
+   * Push boolean value on to the spacePreserve stack depending on the value 
+   * of xml:space=default/preserve.
+   * 
+   * @param attrs list of attributes that were passed to startElement.
+   */
+  void pushSpaceHandling(Attributes attrs)
+    throws org.xml.sax.SAXParseException
+  {    
+    String value = attrs.getValue("xml:space");
+    if(null == value)
+    {
+      m_spacePreserveStack.push(m_spacePreserveStack.peekOrFalse());
+    }
+    else if(value.equals("preserve"))
+    {
+      m_spacePreserveStack.push(true);
+    }
+    else if(value.equals("default"))
+    {
+      m_spacePreserveStack.push(false);
+    }
+    else
+    {
+      SAXSourceLocator locator = getLocator();
+      ErrorListener handler = m_stylesheetProcessor.getErrorListener();
+  
+      try
+      {
+        handler.error(new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_ILLEGAL_XMLSPACE_VALUE, null), locator)); //"Illegal value for xml:space", locator));
+      }
+      catch (TransformerException te)
+      {
+        throw new org.xml.sax.SAXParseException(te.getMessage(), locator, te);
+      }
+      m_spacePreserveStack.push(m_spacePreserveStack.peek());
+    }
+  }
+  
+  private double getElemVersion()
+  {
+    ElemTemplateElement elem = getElemTemplateElement();
+    double version = -1; 
+    while ((version == -1 || version == Constants.XSLTVERSUPPORTED) && elem != null)
+    {
+      try{
+      version = Double.valueOf(elem.getXmlVersion()).doubleValue();
+      }
+      catch (Exception ex)
+      {
+        version = -1;
+      }
+      elem = elem.getParentElem();
+      }
+    return (version == -1)? Constants.XSLTVERSUPPORTED : version;
+  }
+    /**
+     * @see PrefixResolver#handlesNullPrefixes()
+     */
+    public boolean handlesNullPrefixes() {
+        return false;
+    }
+
+    /**
+     * @return Optimization flag
+     */
+    public boolean getOptimize() {
+        return m_optimize;
+    }
+
+    /**
+     * @return Incremental flag
+     */
+    public boolean getIncremental() {
+        return m_incremental;
+    }
+
+    /**
+     * @return Source Location flag
+     */
+    public boolean getSource_location() {
+        return m_source_location;
+    }
+
+}
+
+
+
diff --git a/src/main/java/org/apache/xalan/processor/TransformerFactoryImpl.java b/src/main/java/org/apache/xalan/processor/TransformerFactoryImpl.java
new file mode 100644
index 0000000..618b412
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/TransformerFactoryImpl.java
@@ -0,0 +1,1043 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: TransformerFactoryImpl.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import javax.xml.XMLConstants;
+import javax.xml.transform.ErrorListener;
+import javax.xml.transform.Source;
+import javax.xml.transform.Templates;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+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 javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.xalan.res.XSLMessages;
+import org.apache.xalan.res.XSLTErrorResources;
+import org.apache.xalan.transformer.TrAXFilter;
+import org.apache.xalan.transformer.TransformerIdentityImpl;
+import org.apache.xalan.transformer.TransformerImpl;
+import org.apache.xalan.transformer.XalanProperties;
+
+import org.apache.xml.dtm.ref.sax2dtm.SAX2DTM;
+import org.apache.xml.utils.DefaultErrorHandler;
+import org.apache.xml.utils.SystemIDResolver;
+import org.apache.xml.utils.TreeWalker;
+import org.apache.xml.utils.StylesheetPIHandler;
+import org.apache.xml.utils.StopParseException;
+
+import org.w3c.dom.Node;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLFilter;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * The TransformerFactoryImpl, which implements the TRaX TransformerFactory
+ * interface, processes XSLT stylesheets into a Templates object
+ * (a StylesheetRoot).
+ */
+public class TransformerFactoryImpl extends SAXTransformerFactory
+{
+  /** 
+   * The path/filename of the property file: XSLTInfo.properties  
+   * Maintenance note: see also
+   * <code>org.apache.xpath.functions.FuncSystemProperty.XSLT_PROPERTIES</code>
+   */
+  public static final String XSLT_PROPERTIES =
+    "org/apache/xalan/res/XSLTInfo.properties";
+
+  /**
+   * <p>State of secure processing feature.</p>
+   */
+  private boolean m_isSecureProcessing = false;
+
+  /**
+   * Constructor TransformerFactoryImpl
+   *
+   */
+  public TransformerFactoryImpl()
+  {
+  }
+
+  /** Static string to be used for incremental feature */
+  public static final String FEATURE_INCREMENTAL =
+                             "http://xml.apache.org/xalan/features/incremental";
+
+  /** Static string to be used for optimize feature */
+  public static final String FEATURE_OPTIMIZE =
+                             "http://xml.apache.org/xalan/features/optimize";
+
+  /** Static string to be used for source_location feature */
+  public static final String FEATURE_SOURCE_LOCATION =
+                             XalanProperties.SOURCE_LOCATION;
+
+  public javax.xml.transform.Templates processFromNode(Node node)
+          throws TransformerConfigurationException
+  {
+
+    try
+    {
+      TemplatesHandler builder = newTemplatesHandler();
+      TreeWalker walker = new TreeWalker(builder,
+                                         new org.apache.xml.utils.DOM2Helper(),
+                                         builder.getSystemId());
+
+      walker.traverse(node);
+
+      return builder.getTemplates();
+    }
+    catch (org.xml.sax.SAXException se)
+    {
+      if (m_errorListener != null)
+      {
+        try
+        {
+          m_errorListener.fatalError(new TransformerException(se));
+        }
+        catch (TransformerConfigurationException ex)
+        {
+          throw ex;
+        }
+        catch (TransformerException ex)
+        {
+          throw new TransformerConfigurationException(ex);
+        }
+
+        return null;
+      }
+      else
+      {
+
+        // Should remove this later... but right now diagnostics from 
+        // TransformerConfigurationException are not good.
+        // se.printStackTrace();
+        throw new TransformerConfigurationException(XSLMessages.createMessage(XSLTErrorResources.ER_PROCESSFROMNODE_FAILED, null), se); 
+        //"processFromNode failed", se);
+      }
+    }
+    catch (TransformerConfigurationException tce)
+    {
+      // Assume it's already been reported to the error listener.
+      throw tce;
+    }
+   /* catch (TransformerException tce)
+    {
+      // Assume it's already been reported to the error listener.
+      throw new TransformerConfigurationException(tce.getMessage(), tce);
+    }*/
+    catch (Exception e)
+    {
+      if (m_errorListener != null)
+      {
+        try
+        {
+          m_errorListener.fatalError(new TransformerException(e));
+        }
+        catch (TransformerConfigurationException ex)
+        {
+          throw ex;
+        }
+        catch (TransformerException ex)
+        {
+          throw new TransformerConfigurationException(ex);
+        }
+
+        return null;
+      }
+      else
+      {
+        // Should remove this later... but right now diagnostics from 
+        // TransformerConfigurationException are not good.
+        // se.printStackTrace();
+        throw new TransformerConfigurationException(XSLMessages.createMessage(XSLTErrorResources.ER_PROCESSFROMNODE_FAILED, null), e); //"processFromNode failed",
+                                                    //e);
+      }
+    }
+  }
+
+  /**
+   * The systemID that was specified in
+   * processFromNode(Node node, String systemID).
+   */
+  private String m_DOMsystemID = null;
+
+  /**
+   * The systemID that was specified in
+   * processFromNode(Node node, String systemID).
+   *
+   * @return The systemID, or null.
+   */
+  String getDOMsystemID()
+  {
+    return m_DOMsystemID;
+  }
+
+  /**
+   * Process the stylesheet from a DOM tree, if the
+   * processor supports the "http://xml.org/trax/features/dom/input"
+   * feature.
+   *
+   * @param node A DOM tree which must contain
+   * valid transform instructions that this processor understands.
+   * @param systemID The systemID from where xsl:includes and xsl:imports
+   * should be resolved from.
+   *
+   * @return A Templates object capable of being used for transformation purposes.
+   *
+   * @throws TransformerConfigurationException
+   */
+  javax.xml.transform.Templates processFromNode(Node node, String systemID)
+          throws TransformerConfigurationException
+  {
+
+    m_DOMsystemID = systemID;
+
+    return processFromNode(node);
+  }
+
+  /**
+   * Get InputSource specification(s) that are associated with the
+   * given document specified in the source param,
+   * via the xml-stylesheet processing instruction
+   * (see http://www.w3.org/TR/xml-stylesheet/), and that matches
+   * the given criteria.  Note that it is possible to return several stylesheets
+   * that match the criteria, in which case they are applied as if they were
+   * a list of imports or cascades.
+   *
+   * <p>Note that DOM2 has it's own mechanism for discovering stylesheets.
+   * Therefore, there isn't a DOM version of this method.</p>
+   *
+   *
+   * @param source The XML source that is to be searched.
+   * @param media The media attribute to be matched.  May be null, in which
+   *              case the prefered templates 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.
+   *
+   * @return A Source object capable of being used to create a Templates object.
+   *
+   * @throws TransformerConfigurationException
+   */
+  public Source getAssociatedStylesheet(
+          Source source, String media, String title, String charset)
+            throws TransformerConfigurationException
+  {
+
+    String baseID;
+    InputSource isource = null;
+    Node node = null;
+    XMLReader reader = null;
+
+    if (source instanceof DOMSource)
+    {
+      DOMSource dsource = (DOMSource) source;
+
+      node = dsource.getNode();
+      baseID = dsource.getSystemId();
+    }
+    else
+    {
+      isource = SAXSource.sourceToInputSource(source);
+      baseID = isource.getSystemId();
+    }
+
+    // What I try to do here is parse until the first startElement
+    // is found, then throw a special exception in order to terminate 
+    // the parse.
+    StylesheetPIHandler handler = new StylesheetPIHandler(baseID, media,
+                                    title, charset);
+    
+    // Use URIResolver. Patch from Dmitri Ilyin 
+    if (m_uriResolver != null) 
+    {
+      handler.setURIResolver(m_uriResolver); 
+    }
+
+    try
+    {
+      if (null != node)
+      {
+        TreeWalker walker = new TreeWalker(handler, new org.apache.xml.utils.DOM2Helper(), baseID);
+
+        walker.traverse(node);
+      }
+      else
+      {
+
+        // Use JAXP1.1 ( if possible )
+        try
+        {
+          javax.xml.parsers.SAXParserFactory factory =
+            javax.xml.parsers.SAXParserFactory.newInstance();
+
+          factory.setNamespaceAware(true);
+
+          if (m_isSecureProcessing)
+          {
+            try
+            {
+              factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+            }
+            catch (org.xml.sax.SAXException e) {}
+          }
+
+          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();
+        }
+
+        // Need to set options!
+        reader.setContentHandler(handler);
+        reader.parse(isource);
+      }
+    }
+    catch (StopParseException spe)
+    {
+
+      // OK, good.
+    }
+    catch (org.xml.sax.SAXException se)
+    {
+      throw new TransformerConfigurationException(
+        "getAssociatedStylesheets failed", se);
+    }
+    catch (IOException ioe)
+    {
+      throw new TransformerConfigurationException(
+        "getAssociatedStylesheets failed", ioe);
+    }
+
+    return handler.getAssociatedStylesheet();
+  }
+
+  /**
+   * Create a new Transformer object that performs a copy
+   * of the source to the result.
+   *
+   * @return A Transformer object that may be used to perform a transformation
+   * in a single thread, never null.
+   *
+   * @throws TransformerConfigurationException May throw this during
+   *            the parse when it is constructing the
+   *            Templates object and fails.
+   */
+  public TemplatesHandler newTemplatesHandler()
+          throws TransformerConfigurationException
+  {
+    return new StylesheetHandler(this);
+  }
+
+  /**
+   * <p>Set a feature for this <code>TransformerFactory</code> and <code>Transformer</code>s
+   * or <code>Template</code>s created by this factory.</p>
+   * 
+   * <p>
+   * Feature names are fully qualified {@link java.net.URI}s.
+   * Implementations may define their own features.
+   * An {@link TransformerConfigurationException} is thrown if this <code>TransformerFactory</code> or the
+   * <code>Transformer</code>s or <code>Template</code>s it creates cannot support the feature.
+   * It is possible for an <code>TransformerFactory</code> to expose a feature value but be unable to change its state.
+   * </p>
+   * 
+   * <p>See {@link javax.xml.transform.TransformerFactory} for full documentation of specific features.</p>
+   * 
+   * @param name Feature name.
+   * @param value Is feature state <code>true</code> or <code>false</code>.
+   *  
+   * @throws TransformerConfigurationException if this <code>TransformerFactory</code>
+   *   or the <code>Transformer</code>s or <code>Template</code>s it creates cannot support this feature.
+   * @throws NullPointerException If the <code>name</code> parameter is null.
+   */
+  public void setFeature(String name, boolean value)
+	  throws TransformerConfigurationException {
+  
+  	// feature name cannot be null
+  	if (name == null) {
+  	    throw new NullPointerException(
+                  XSLMessages.createMessage(
+                      XSLTErrorResources.ER_SET_FEATURE_NULL_NAME, null));    
+  	}
+  		
+  	// secure processing?
+  	if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
+  	    m_isSecureProcessing = value;			
+  	}
+  	// This implementation does not support the setting of a feature other than
+  	// the secure processing feature.
+  	else
+    {
+      throw new TransformerConfigurationException(
+          XSLMessages.createMessage(
+            XSLTErrorResources.ER_UNSUPPORTED_FEATURE, 
+            new Object[] {name}));
+    }
+  }
+
+  /**
+   * Look up the value of a feature.
+   * <p>The feature name is any fully-qualified URI.  It is
+   * possible for an TransformerFactory to recognize a feature name but
+   * to be unable to return its value; this is especially true
+   * in the case of an adapter for a SAX1 Parser, which has
+   * no way of knowing whether the underlying parser is
+   * validating, for example.</p>
+   *
+   * @param name The feature name, which is a fully-qualified URI.
+   * @return The current state of the feature (true or false).
+   */
+  public boolean getFeature(String name) {
+  	
+    // feature name cannot be null
+    if (name == null) 
+    {
+    	throw new NullPointerException(
+            XSLMessages.createMessage(
+            XSLTErrorResources.ER_GET_FEATURE_NULL_NAME, null));    
+    }
+	  	
+    // Try first with identity comparison, which 
+    // will be faster.
+    if ((DOMResult.FEATURE == name) || (DOMSource.FEATURE == name)
+            || (SAXResult.FEATURE == name) || (SAXSource.FEATURE == name)
+            || (StreamResult.FEATURE == name)
+            || (StreamSource.FEATURE == name)
+            || (SAXTransformerFactory.FEATURE == name)
+            || (SAXTransformerFactory.FEATURE_XMLFILTER == name))
+      return true;
+    else if ((DOMResult.FEATURE.equals(name))
+             || (DOMSource.FEATURE.equals(name))
+             || (SAXResult.FEATURE.equals(name))
+             || (SAXSource.FEATURE.equals(name))
+             || (StreamResult.FEATURE.equals(name))
+             || (StreamSource.FEATURE.equals(name))
+             || (SAXTransformerFactory.FEATURE.equals(name))
+             || (SAXTransformerFactory.FEATURE_XMLFILTER.equals(name)))
+      return true;	      
+    // secure processing?
+    else if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING))
+      return m_isSecureProcessing;
+    else      
+      // unknown feature
+      return false;
+  }
+  
+  /**
+   * Flag set by FEATURE_OPTIMIZE.
+   * This feature specifies whether to Optimize stylesheet processing. By
+   * default it is set to true.
+   */
+  private boolean m_optimize = true;
+  
+  /** Flag set by FEATURE_SOURCE_LOCATION.
+   * This feature specifies whether the transformation phase should
+   * keep track of line and column numbers for the input source
+   * document. Note that this works only when that
+   * information is available from the source -- in other words, if you
+   * pass in a DOM, there's little we can do for you.
+   * 
+   * The default is false. Setting it true may significantly
+   * increase storage cost per node. 
+   */
+  private boolean m_source_location = false;
+  
+  /**
+   * Flag set by FEATURE_INCREMENTAL.
+   * This feature specifies whether to produce output incrementally, rather than
+   * waiting to finish parsing the input before generating any output. By 
+   * default this attribute is set to false. 
+   */
+  private boolean m_incremental = false;
+  
+  /**
+   * Allows the user to set specific attributes on the underlying
+   * implementation.
+   *
+   * @param name The name of the attribute.
+   * @param value The value of the attribute; Boolean or String="true"|"false"
+   *
+   * @throws IllegalArgumentException thrown if the underlying
+   * implementation doesn't recognize the attribute.
+   */
+  public void setAttribute(String name, Object value)
+          throws IllegalArgumentException
+  {
+    if (name.equals(FEATURE_INCREMENTAL))
+    {
+      if(value instanceof Boolean)
+      {
+        // Accept a Boolean object..
+        m_incremental = ((Boolean)value).booleanValue();
+      }
+      else if(value instanceof String)
+      {
+        // .. or a String object
+        m_incremental = (new Boolean((String)value)).booleanValue();
+      }
+      else
+      {
+        // Give a more meaningful error message
+        throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_BAD_VALUE, new Object[]{name, value})); //name + " bad value " + value);
+      }
+	}
+    else if (name.equals(FEATURE_OPTIMIZE))
+    {
+      if(value instanceof Boolean)
+      {
+        // Accept a Boolean object..
+        m_optimize = ((Boolean)value).booleanValue();
+      }
+      else if(value instanceof String)
+      {
+        // .. or a String object
+        m_optimize = (new Boolean((String)value)).booleanValue();
+      }
+      else
+      {
+        // Give a more meaningful error message
+        throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_BAD_VALUE, new Object[]{name, value})); //name + " bad value " + value);
+      }
+    }
+    
+    // Custom Xalan feature: annotate DTM with SAX source locator fields.
+    // This gets used during SAX2DTM instantiation. 
+    //
+    // %REVIEW% Should the name of this field really be in XalanProperties?
+    // %REVIEW% I hate that it's a global static, but didn't want to change APIs yet.
+    else if(name.equals(FEATURE_SOURCE_LOCATION))
+    {
+      if(value instanceof Boolean)
+      {
+        // Accept a Boolean object..
+        m_source_location = ((Boolean)value).booleanValue();
+      }
+      else if(value instanceof String)
+      {
+        // .. or a String object
+        m_source_location = (new Boolean((String)value)).booleanValue();
+      }
+      else
+      {
+        // Give a more meaningful error message
+        throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_BAD_VALUE, new Object[]{name, value})); //name + " bad value " + value);
+      }
+    }
+    
+    else
+    {
+      throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_SUPPORTED, new Object[]{name})); //name + "not supported");
+    }
+  }
+
+  /**
+   * Allows the user to retrieve specific attributes on the underlying
+   * implementation.
+   *
+   * @param name The name of the attribute.
+   * @return value The value of the attribute.
+   *
+   * @throws IllegalArgumentException thrown if the underlying
+   * implementation doesn't recognize the attribute.
+   */
+  public Object getAttribute(String name) throws IllegalArgumentException
+  {
+    if (name.equals(FEATURE_INCREMENTAL))
+    {
+      return new Boolean(m_incremental);            
+    }
+    else if (name.equals(FEATURE_OPTIMIZE))
+    {
+      return new Boolean(m_optimize);
+    }
+    else if (name.equals(FEATURE_SOURCE_LOCATION))
+    {
+      return new Boolean(m_source_location);
+    }
+    else
+      throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_ATTRIB_VALUE_NOT_RECOGNIZED, new Object[]{name})); //name + " attribute not recognized");
+  }
+
+  /**
+   * Create an XMLFilter that uses the given source as the
+   * transformation instructions.
+   *
+   * @param src The source of the transformation instructions.
+   *
+   * @return An XMLFilter object, or null if this feature is not supported.
+   *
+   * @throws TransformerConfigurationException
+   */
+  public XMLFilter newXMLFilter(Source src)
+          throws TransformerConfigurationException
+  {
+
+    Templates templates = newTemplates(src);
+    if( templates==null ) return null;
+    
+    return newXMLFilter(templates);
+  }
+
+  /**
+   * Create an XMLFilter that uses the given source as the
+   * transformation instructions.
+   *
+   * @param templates non-null reference to Templates object.
+   *
+   * @return An XMLFilter object, or null if this feature is not supported.
+   *
+   * @throws TransformerConfigurationException
+   */
+  public XMLFilter newXMLFilter(Templates templates)
+          throws TransformerConfigurationException
+  {
+    try 
+    {
+      return new TrAXFilter(templates);
+    } 
+    catch( TransformerConfigurationException ex ) 
+    {
+      if( m_errorListener != null) 
+      {
+        try 
+        {
+          m_errorListener.fatalError( ex );
+          return null;
+        } 
+        catch( TransformerConfigurationException ex1 ) 
+        {
+          throw ex1;
+        }
+        catch( TransformerException ex1 ) 
+        {
+          throw new TransformerConfigurationException(ex1);
+        }
+      }
+      throw ex;
+    }
+  }
+
+  /**
+   * Get a TransformerHandler object that can process SAX
+   * ContentHandler events into a Result, based on the transformation
+   * instructions specified by the argument.
+   *
+   * @param src The source of the transformation instructions.
+   *
+   * @return TransformerHandler ready to transform SAX events.
+   *
+   * @throws TransformerConfigurationException
+   */
+  public TransformerHandler newTransformerHandler(Source src)
+          throws TransformerConfigurationException
+  {
+
+    Templates templates = newTemplates(src);
+    if( templates==null ) return null;
+    
+    return newTransformerHandler(templates);
+  }
+
+  /**
+   * Get a TransformerHandler object that can process SAX
+   * ContentHandler events into a Result, based on the Templates argument.
+   *
+   * @param templates The source of the transformation instructions.
+   *
+   * @return TransformerHandler ready to transform SAX events.
+   * @throws TransformerConfigurationException
+   */
+  public TransformerHandler newTransformerHandler(Templates templates)
+          throws TransformerConfigurationException
+  {
+    try {
+      TransformerImpl transformer =
+        (TransformerImpl) templates.newTransformer();
+      transformer.setURIResolver(m_uriResolver);
+      TransformerHandler th =
+        (TransformerHandler) transformer.getInputContentHandler(true);
+
+      return th;
+    } 
+    catch( TransformerConfigurationException ex ) 
+    {
+      if( m_errorListener != null ) 
+      {
+        try 
+        {
+          m_errorListener.fatalError( ex );
+          return null;
+        } 
+        catch (TransformerConfigurationException ex1 ) 
+        {
+          throw ex1;
+        }
+        catch (TransformerException ex1 ) 
+        {
+          throw new TransformerConfigurationException(ex1);
+        }
+      }
+      
+      throw ex;
+    }
+    
+  }
+
+//  /** The identity transform string, for support of newTransformerHandler()
+//   *  and newTransformer().  */
+//  private static final String identityTransform =
+//    "<xsl:stylesheet " + "xmlns:xsl='http://www.w3.org/1999/XSL/Transform' "
+//    + "version='1.0'>" + "<xsl:template match='/|node()'>"
+//    + "<xsl:copy-of select='.'/>" + "</xsl:template>" + "</xsl:stylesheet>";
+//
+//  /** The identity transform Templates, built from identityTransform, 
+//   *  for support of newTransformerHandler() and newTransformer().  */
+//  private static Templates m_identityTemplate = null;
+
+  /**
+   * Get a TransformerHandler object that can process SAX
+   * ContentHandler events into a Result.
+   *
+   * @return TransformerHandler ready to transform SAX events.
+   *
+   * @throws TransformerConfigurationException
+   */
+  public TransformerHandler newTransformerHandler()
+          throws TransformerConfigurationException
+  {
+    return new TransformerIdentityImpl(m_isSecureProcessing);
+  }
+
+  /**
+   * Process the source into a Transformer object.  Care must
+   * be given to know that this object can not be used concurrently
+   * in multiple threads.
+   *
+   * @param source An object that holds a URL, input stream, etc.
+   *
+   * @return A Transformer object capable of
+   * being used for transformation purposes in a single thread.
+   *
+   * @throws TransformerConfigurationException May throw this during the parse when it
+   *            is constructing the Templates object and fails.
+   */
+  public Transformer newTransformer(Source source)
+          throws TransformerConfigurationException
+  {
+    try 
+    {
+      Templates tmpl=newTemplates( source );
+      /* this can happen if an ErrorListener is present and it doesn't
+         throw any exception in fatalError. 
+         The spec says: "a Transformer must use this interface
+         instead of throwing an exception" - the newTemplates() does
+         that, and returns null.
+      */
+      if( tmpl==null ) return null;
+      Transformer transformer = tmpl.newTransformer();
+      transformer.setURIResolver(m_uriResolver);
+      return transformer;
+    } 
+    catch( TransformerConfigurationException ex ) 
+    {
+      if( m_errorListener != null ) 
+      {
+        try 
+        {
+          m_errorListener.fatalError( ex );
+          return null; // TODO: but the API promises to never return null...
+        } 
+        catch( TransformerConfigurationException ex1 ) 
+        {
+          throw ex1;
+        }
+        catch( TransformerException ex1 ) 
+        {
+          throw new TransformerConfigurationException( ex1 );
+        }
+      }
+      throw ex;
+    }
+  }
+
+  /**
+   * Create a new Transformer object that performs a copy
+   * of the source to the result.
+   *
+   * @return A Transformer object capable of
+   * being used for transformation purposes in a single thread.
+   *
+   * @throws TransformerConfigurationException May throw this during
+   *            the parse when it is constructing the
+   *            Templates object and it fails.
+   */
+  public Transformer newTransformer() throws TransformerConfigurationException
+  {
+      return new TransformerIdentityImpl(m_isSecureProcessing);
+  }
+
+  /**
+   * Process the source into a Templates object, which is likely
+   * a compiled representation of the source. This Templates object
+   * may then be used concurrently across multiple threads.  Creating
+   * a Templates object allows the TransformerFactory to do detailed
+   * performance optimization of transformation instructions, without
+   * penalizing runtime transformation.
+   *
+   * @param source An object that holds a URL, input stream, etc.
+   * @return A Templates object capable of being used for transformation purposes.
+   *
+   * @throws TransformerConfigurationException May throw this during the parse when it
+   *            is constructing the Templates object and fails.
+   */
+  public Templates newTemplates(Source source)
+          throws TransformerConfigurationException
+  {
+
+    String baseID = source.getSystemId();
+
+    if (null != baseID) {
+       baseID = SystemIDResolver.getAbsoluteURI(baseID);
+    }
+
+
+    if (source instanceof DOMSource)
+    {
+      DOMSource dsource = (DOMSource) source;
+      Node node = dsource.getNode();
+
+      if (null != node)
+        return processFromNode(node, baseID);
+      else
+      {
+        String messageStr = XSLMessages.createMessage(
+          XSLTErrorResources.ER_ILLEGAL_DOMSOURCE_INPUT, null);
+
+        throw new IllegalArgumentException(messageStr);
+      }
+    }
+
+    TemplatesHandler builder = newTemplatesHandler();
+    builder.setSystemId(baseID);
+    
+    try
+    {
+      InputSource isource = SAXSource.sourceToInputSource(source);
+      isource.setSystemId(baseID);
+      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);
+
+          if (m_isSecureProcessing)
+          {
+            try
+            {
+              factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+            }
+            catch (org.xml.sax.SAXException se) {}
+          }
+
+          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 you set the namespaces to true, we'll end up getting double 
+      // xmlns attributes.  Needs to be fixed.  -sb
+      // reader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
+      reader.setContentHandler(builder);
+      reader.parse(isource);
+    }
+    catch (org.xml.sax.SAXException se)
+    {
+      if (m_errorListener != null)
+      {
+        try
+        {
+          m_errorListener.fatalError(new TransformerException(se));
+        }
+        catch (TransformerConfigurationException ex1)
+        {
+          throw ex1;
+        }
+        catch (TransformerException ex1)
+        {
+          throw new TransformerConfigurationException(ex1);
+        }
+      }
+      else
+      {
+        throw new TransformerConfigurationException(se.getMessage(), se);
+      }
+    }
+    catch (Exception e)
+    {
+      if (m_errorListener != null)
+      {
+        try
+        {
+          m_errorListener.fatalError(new TransformerException(e));
+          return null;
+        }
+        catch (TransformerConfigurationException ex1)
+        {
+          throw ex1;
+        }
+        catch (TransformerException ex1)
+        {
+          throw new TransformerConfigurationException(ex1);
+        }
+      }
+      else
+      {
+        throw new TransformerConfigurationException(e.getMessage(), e);
+      }
+    }
+
+    return builder.getTemplates();
+  }
+
+  /**
+   * The object that implements the URIResolver interface,
+   * or null.
+   */
+  URIResolver m_uriResolver;
+
+  /**
+   * Set an object that will be used to resolve URIs used in
+   * xsl:import, etc.  This will be used as the default for the
+   * transformation.
+   * @param resolver An object that implements the URIResolver interface,
+   * or null.
+   */
+  public void setURIResolver(URIResolver resolver)
+  {
+    m_uriResolver = resolver;
+  }
+
+  /**
+   * Get the object that will be used to resolve URIs used in
+   * xsl:import, etc.  This will be used as the default for the
+   * transformation.
+   *
+   * @return The URIResolver that was set with setURIResolver.
+   */
+  public URIResolver getURIResolver()
+  {
+    return m_uriResolver;
+  }
+
+  /** The error listener.   */
+  private ErrorListener m_errorListener = new org.apache.xml.utils.DefaultErrorHandler(false);
+
+  /**
+   * Get the error listener in effect for the TransformerFactory.
+   *
+   * @return A non-null reference to an error listener.
+   */
+  public ErrorListener getErrorListener()
+  {
+    return m_errorListener;
+  }
+
+  /**
+   * Set an error listener for the TransformerFactory.
+   *
+   * @param listener Must be a non-null reference to an ErrorListener.
+   *
+   * @throws IllegalArgumentException if the listener argument is null.
+   */
+  public void setErrorListener(ErrorListener listener)
+          throws IllegalArgumentException
+  {
+
+    if (null == listener)
+      throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_ERRORLISTENER, null));
+      // "ErrorListener");
+
+    m_errorListener = listener;
+  }
+  
+  /**
+   * Return the state of the secure processing feature.
+   * 
+   * @return state of the secure processing feature.
+   */
+  public boolean isSecureProcessing()
+  {
+    return m_isSecureProcessing;
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/WhitespaceInfoPaths.java b/src/main/java/org/apache/xalan/processor/WhitespaceInfoPaths.java
new file mode 100644
index 0000000..086345c
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/WhitespaceInfoPaths.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: WhitespaceInfoPaths.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import java.util.Vector;
+
+import org.apache.xalan.templates.Stylesheet;
+import org.apache.xalan.templates.WhiteSpaceInfo;
+
+public class WhitespaceInfoPaths extends WhiteSpaceInfo
+{
+    static final long serialVersionUID = 5954766719577516723L;
+	
+  /**
+   * Bean property to allow setPropertiesFromAttributes to
+   * get the elements attribute.
+   */
+  private Vector m_elements;
+
+  /**
+   * Set from the elements attribute.  This is a list of 
+   * whitespace delimited element qualified names that specify
+   * preservation of whitespace.
+   *
+   * @param elems Should be a non-null reference to a list 
+   *              of {@link org.apache.xpath.XPath} objects.
+   */
+  public void setElements(Vector elems)
+  {
+    m_elements = elems;
+  }
+
+  /**
+   * Get the property set by setElements().  This is a list of 
+   * whitespace delimited element qualified names that specify
+   * preservation of whitespace.
+   *
+   * @return A reference to a list of {@link org.apache.xpath.XPath} objects, 
+   *         or null.
+   */
+  Vector getElements()
+  {
+    return m_elements;
+  }
+  
+  public void clearElements()
+  {
+  	m_elements = null;
+  }
+
+ /**
+   * Constructor WhitespaceInfoPaths
+   *
+   * @param thisSheet The current stylesheet
+   */
+  public WhitespaceInfoPaths(Stylesheet thisSheet)
+  {
+  	super(thisSheet);
+  	setStylesheet(thisSheet);
+  }
+
+
+}
+
diff --git a/src/main/java/org/apache/xalan/processor/XSLProcessorVersion.src b/src/main/java/org/apache/xalan/processor/XSLProcessorVersion.src
new file mode 100644
index 0000000..caae25d
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/XSLProcessorVersion.src
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: XSLProcessorVersion.src 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+/**
+ * Administrative class to keep track of the version number of
+ * the Xalan release.
+ * <P>See also: org/apache/xalan/res/XSLTInfo.properties</P>
+ * @deprecated To be replaced by org.apache.xalan.Version.getVersion()
+ * @xsl.usage general
+ */
+public class XSLProcessorVersion
+{
+
+  /**
+   * Print the processor version to the command line.
+   *
+   * @param argv command line arguments, unused.
+   */
+  public static void main(String argv[])
+  {
+    System.out.println(S_VERSION);
+  }
+
+  /**
+   * Constant name of product.
+   */
+  public static final String PRODUCT = "Xalan";
+
+  /**
+   * Implementation Language.
+   */
+  public static final String LANGUAGE = "Java";
+
+  /**
+   * Major version number.
+   * Version number. This changes only when there is a
+   *          significant, externally apparent enhancement from
+   *          the previous release. 'n' represents the n'th
+   *          version.
+   *
+   *          Clients should carefully consider the implications
+   *          of new versions as external interfaces and behaviour
+   *          may have changed.
+   */
+  public static final int VERSION = @version.VERSION@;
+
+  /**
+   * Release Number.
+   * Release number. This changes when:
+   *            -  a new set of functionality is to be added, eg,
+   *               implementation of a new W3C specification.
+   *            -  API or behaviour change.
+   *            -  its designated as a reference release.
+   */
+  public static final int RELEASE = @version.RELEASE@;
+
+  /**
+   * Maintenance Drop Number.
+   * Optional identifier used to designate maintenance
+   *          drop applied to a specific release and contains
+   *          fixes for defects reported. It maintains compatibility
+   *          with the release and contains no API changes.
+   *          When missing, it designates the final and complete
+   *          development drop for a release.
+   */
+  public static final int MAINTENANCE = @version.MINOR@;
+
+  /**
+   * Development Drop Number.
+   * Optional identifier designates development drop of
+   *          a specific release. D01 is the first development drop
+   *          of a new release.
+   *
+   *          Development drops are works in progress towards a
+   *          compeleted, final release. A specific development drop
+   *          may not completely implement all aspects of a new
+   *          feature, which may take several development drops to
+   *          complete. At the point of the final drop for the
+   *          release, the D suffix will be omitted.
+   *
+   *          Each 'D' drops can contain functional enhancements as
+   *          well as defect fixes. 'D' drops may not be as stable as
+   *          the final releases.
+   */
+  public static final int DEVELOPMENT = 0;
+  
+  /**
+   * Version String like <CODE>"<B>Xalan</B> <B>Language</B>
+   * v.r[.dd| <B>D</B>nn]"</CODE>.
+   * <P>Semantics of the version string are identical to the Xerces project.</P>
+   */
+  public static final String S_VERSION = PRODUCT+" "+LANGUAGE+" "
+                                   +VERSION+"."+RELEASE+"."
+                                   +(DEVELOPMENT > 0 ? ("D"+DEVELOPMENT)
+                                     : (""+MAINTENANCE));
+
+}
diff --git a/src/main/java/org/apache/xalan/processor/XSLTAttributeDef.java b/src/main/java/org/apache/xalan/processor/XSLTAttributeDef.java
new file mode 100644
index 0000000..6e00c88
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/XSLTAttributeDef.java
@@ -0,0 +1,1665 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: XSLTAttributeDef.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import javax.xml.transform.TransformerException;
+
+import org.apache.xalan.res.XSLMessages;
+import org.apache.xalan.res.XSLTErrorResources;
+import org.apache.xalan.templates.AVT;
+import org.apache.xalan.templates.Constants;
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xml.utils.QName;
+import org.apache.xml.utils.StringToIntTable;
+import org.apache.xml.utils.StringVector;
+import org.apache.xml.utils.XML11Char;
+import org.apache.xpath.XPath;
+
+ 
+/**
+ * This class defines an attribute for an element in a XSLT stylesheet,
+ * is meant to reflect the structure defined in http://www.w3.org/TR/xslt#dtd, and the
+ * mapping between Xalan classes and the markup attributes in the element.
+ */
+public class XSLTAttributeDef
+{
+   // How to handle invalid values for this attribute 
+   static final int FATAL = 0;
+   static final int ERROR = 1;
+   static final int WARNING = 2;
+   
+   
+  /**
+   * Construct an instance of XSLTAttributeDef.
+   *
+   * @param namespace The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param type One of T_CDATA, T_URL, T_AVT, T_PATTERN, T_EXPR, T_CHAR,
+   * T_NUMBER, T_YESNO, T_QNAME, T_QNAMES, T_ENUM, T_SIMPLEPATTERNLIST,
+   * T_NMTOKEN, T_STRINGLIST, T_PREFIX_URLLIST, T_ENUM_OR_PQNAME, T_NCNAME.
+   * @param required true if this is attribute is required by the XSLT specification.
+   * @param supportsAVT true if this attribute supports AVT's.
+   * @param errorType the type of error to issue if validation fails.  One of FATAL, ERROR, WARNING. 
+   */
+  XSLTAttributeDef(String namespace, String name, int type, boolean required, boolean supportsAVT, int errorType)
+  {
+    this.m_namespace = namespace;
+    this.m_name = name;
+    this.m_type = type;
+    this.m_required = required;
+    this.m_supportsAVT = supportsAVT;
+    this.m_errorType = errorType;
+  }
+
+  /**
+   * Construct an instance of XSLTAttributeDef.
+   *
+   * @param namespace The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param type One of T_CDATA, T_URL, T_AVT, T_PATTERN, T_EXPR,
+   * T_CHAR, T_NUMBER, T_YESNO, T_QNAME, T_QNAMES, T_ENUM,
+   * T_SIMPLEPATTERNLIST, T_NMTOKEN, T_STRINGLIST, T_PREFIX_URLLIST, 
+   * T_ENUM_OR_PQNAME, T_NCNAME.
+   * @param supportsAVT true if this attribute supports AVT's. 
+   * @param errorType the type of error to issue if validation fails.  One of FATAL, ERROR, WARNING. 
+   * @param defaultVal The default value for this attribute.
+   */
+  XSLTAttributeDef(String namespace, String name, int type, boolean supportsAVT, int errorType, String defaultVal)
+  {
+
+    this.m_namespace = namespace;
+    this.m_name = name;
+    this.m_type = type;
+    this.m_required = false;
+    this.m_supportsAVT = supportsAVT;  
+    this.m_errorType = errorType;      
+    this.m_default = defaultVal;
+   }
+
+  /**
+   * Construct an instance of XSLTAttributeDef that uses two
+   * enumerated values.
+   *
+   * @param namespace The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param required true if this attribute is required by the XSLT specification.
+   * @param supportsAVT true if this attribute supports AVT's.  
+   * @param prefixedQNameValAllowed If true, the type is T_ENUM_OR_PQNAME       
+   * @param errorType the type of error to issue if validation fails.  One of FATAL, ERROR, WARNING. 
+   * @param k1 The XSLT name of the enumerated value.
+   * @param v1 An integer representation of k1.
+   * @param k2 The XSLT name of the enumerated value.
+   * @param v2 An integer representation of k2.
+    */
+  XSLTAttributeDef(String namespace, String name, boolean required, boolean supportsAVT, 
+                    boolean prefixedQNameValAllowed, int errorType, String k1, int v1, String k2, int v2)
+  {
+
+    this.m_namespace = namespace;
+    this.m_name = name;
+	this.m_type = prefixedQNameValAllowed ? this.T_ENUM_OR_PQNAME : this.T_ENUM;    
+    this.m_required = required;
+    this.m_supportsAVT = supportsAVT;    
+    this.m_errorType = errorType;    
+    m_enums = new StringToIntTable(2);
+
+    m_enums.put(k1, v1);
+    m_enums.put(k2, v2);
+  }
+
+  /**
+   * Construct an instance of XSLTAttributeDef that uses three
+   * enumerated values.
+   *
+   * @param namespace The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param required true if this attribute is required by the XSLT specification.
+   * @param supportsAVT true if this attribute supports AVT's.
+   * @param prefixedQNameValAllowed If true, the type is T_ENUM_OR_PQNAME
+   * @param errorType the type of error to issue if validation fails.  One of FATAL, ERROR, WARNING.    * 
+   * @param k1 The XSLT name of the enumerated value.
+   * @param v1 An integer representation of k1.
+   * @param k2 The XSLT name of the enumerated value.
+   * @param v2 An integer representation of k2.
+   * @param k3 The XSLT name of the enumerated value.
+   * @param v3 An integer representation of k3.
+   */
+  XSLTAttributeDef(String namespace, String name, boolean required, boolean supportsAVT,
+                    boolean prefixedQNameValAllowed, int errorType, String k1, int v1, String k2, int v2, String k3, int v3)
+  {
+
+    this.m_namespace = namespace;
+    this.m_name = name;
+	this.m_type = prefixedQNameValAllowed ? this.T_ENUM_OR_PQNAME : this.T_ENUM;    
+    this.m_required = required;
+    this.m_supportsAVT = supportsAVT; 
+    this.m_errorType = errorType;      
+    m_enums = new StringToIntTable(3);
+
+    m_enums.put(k1, v1);
+    m_enums.put(k2, v2);
+    m_enums.put(k3, v3);
+  }
+
+  /**
+   * Construct an instance of XSLTAttributeDef that uses three
+   * enumerated values.
+   *
+   * @param namespace The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param required true if this attribute is required by the XSLT specification.
+   * @param supportsAVT true if this attribute supports AVT's.
+   * @param prefixedQNameValAllowed If true, the type is T_ENUM_OR_PQNAME
+   * @param errorType the type of error to issue if validation fails.  One of FATAL, ERROR, WARNING.    * @param k1 The XSLT name of the enumerated value.
+   * @param v1 An integer representation of k1.
+   * @param k2 The XSLT name of the enumerated value.
+   * @param v2 An integer representation of k2.
+   * @param k3 The XSLT name of the enumerated value.
+   * @param v3 An integer representation of k3.
+   * @param k4 The XSLT name of the enumerated value.
+   * @param v4 An integer representation of k4.
+   */
+  XSLTAttributeDef(String namespace, String name, boolean required, boolean supportsAVT,
+                   boolean prefixedQNameValAllowed, int errorType, String k1, int v1, String k2, int v2, 
+                   String k3, int v3, String k4, int v4)
+  {
+
+    this.m_namespace = namespace;
+    this.m_name = name;
+	this.m_type = prefixedQNameValAllowed ? this.T_ENUM_OR_PQNAME : this.T_ENUM;    
+    this.m_required = required;
+    this.m_supportsAVT = supportsAVT;      
+    this.m_errorType = errorType; 
+    m_enums = new StringToIntTable(4);
+
+    m_enums.put(k1, v1);
+    m_enums.put(k2, v2);
+    m_enums.put(k3, v3);
+    m_enums.put(k4, v4);
+  }
+
+  /** Type values that represent XSLT attribute types. */
+  static final int T_CDATA = 1,
+
+  // <!-- Used for the type of an attribute value that is a URI reference.-->
+  T_URL = 2,
+
+  // <!-- Used for the type of an attribute value that is an
+  // attribute value template.-->
+  T_AVT = 3,  // Attribute Value Template
+
+  // <!-- Used for the type of an attribute value that is a pattern.-->
+  T_PATTERN = 4,
+
+  // <!-- Used for the type of an attribute value that is an expression.-->
+  T_EXPR = 5,
+
+  // <!-- Used for the type of an attribute value that consists
+  // of a single character.-->
+  T_CHAR = 6,
+
+  // <!-- Used for the type of an attribute value that is a number. -->
+  T_NUMBER = 7,
+
+  // Used for boolean values
+  T_YESNO = 8,
+
+  // <!-- Used for the type of an attribute value that is a QName; the prefix
+  // gets expanded by the XSLT processor. -->
+  T_QNAME = 9,
+
+  // <!--Used for a whitespace-separated list of QNames where the non-prefixed
+  // entries are not to be placed in the default namespace. -->
+  T_QNAMES = 10,
+
+  // <!-- Used for enumerated values -->
+  T_ENUM = 11,
+
+  // Used for simple match patterns, i.e. xsl:strip-space spec.
+  T_SIMPLEPATTERNLIST = 12,
+
+  // Used for a known token.
+  T_NMTOKEN = 13,
+
+  // Used for a list of white-space delimited strings.
+  T_STRINGLIST = 14,
+
+  // Used for a list of white-space delimited strings.
+  // Prefixes are checked to make sure they refer to 
+  // valid namespaces, and are resolved when processed
+  T_PREFIX_URLLIST = 15,
+  
+  // Used for enumerated values, one of which could be a qname-but-not-ncname
+  T_ENUM_OR_PQNAME = 16,
+
+  // Used for the type of an attribute value that is a NCName
+  T_NCNAME = 17,
+  
+  // Used for QName attributes that are always AVT.  Prefix isn't resolved.
+  T_AVT_QNAME = 18,
+  
+  // Used for a list of QNames where non-prefixed items are to be resolved
+  // using the default namespace (This is only true for cdata-section-elements)
+  T_QNAMES_RESOLVE_NULL = 19,
+  
+  // Used for a list of white-space delimited strings.
+  // strings are checked to make sure they are valid 
+  // prefixes, and are not expanded when processed. 
+  T_PREFIXLIST = 20;
+
+  /** Representation for an attribute in a foreign namespace. */
+  static final XSLTAttributeDef m_foreignAttr = new XSLTAttributeDef("*", "*",
+                                            XSLTAttributeDef.T_CDATA,false, false, WARNING);
+
+  /** Method name that objects may implement if they wish to have forein attributes set. */
+  static final String S_FOREIGNATTR_SETTER = "setForeignAttr";
+
+  /**
+   * The allowed namespace for this element.
+   */
+  private String m_namespace;
+
+  /**
+   * Get the allowed namespace for this attribute.
+   *
+   * @return The allowed namespace for this attribute, which may be null, or may be "*".
+   */
+  String getNamespace()
+  {
+    return m_namespace;
+  }
+
+  /**
+   * The name of this element.
+   */
+  private String m_name;
+
+  /**
+   * Get the name of this attribute.
+   *
+   * @return non-null reference to the name of this attribute, which may be "*".
+   */
+  String getName()
+  {
+    return m_name;
+  }
+
+  /**
+   * The type of this attribute value.
+   */
+  private int m_type;
+
+  /**
+   * Get the type of this attribute value.
+   *
+   * @return One of T_CDATA, T_URL, T_AVT, T_PATTERN, T_EXPR, T_CHAR,
+   * T_NUMBER, T_YESNO, T_QNAME, T_QNAMES, T_ENUM, T_SIMPLEPATTERNLIST,
+   * T_NMTOKEN, T_STRINGLIST, T_PREFIX_URLLIST, T_ENUM_OR_PQNAME.
+   */
+  int getType()
+  {
+    return m_type;
+  }
+
+  /**
+   * If this element is of type T_ENUM, this will contain
+   * a map from the attribute string to the Xalan integer
+   * value.
+   */
+  private StringToIntTable m_enums;
+
+  /**
+   * If this element is of type T_ENUM, this will return
+   * a map from the attribute string to the Xalan integer
+   * value.
+   * @param key The XSLT attribute value.
+   *
+   * @return The integer representation of the enumerated value for this attribute.
+   * @throws Throws NullPointerException if m_enums is null.
+   */
+  private int getEnum(String key)
+  {
+    return m_enums.get(key);
+  }
+
+ /**
+   * If this element is of type T_ENUM, this will return
+   * an array of strings - the values in the enumeration
+   *
+   * @return An array of the enumerated values permitted for this attribute.
+   *
+   * @throws Throws NullPointerException if m_enums is null.
+   */
+  private String[] getEnumNames()
+  {
+    return m_enums.keys();
+  }
+
+  /**
+   * The default value for this attribute.
+   */
+  private String m_default;
+
+  /**
+   * Get the default value for this attribute.
+   *
+   * @return The default value for this attribute, or null.
+   */
+  String getDefault()
+  {
+    return m_default;
+  }
+
+  /**
+   * Set the default value for this attribute.
+   *
+   * @param def String representation of the default value for this attribute.
+   */
+  void setDefault(String def)
+  {
+    m_default = def;
+  }
+
+  /**
+   * If true, this is a required attribute.
+   */
+  private boolean m_required;
+
+  /**
+   * Get whether or not this is a required attribute.
+   *
+   * @return true if this is a required attribute.
+   */
+  boolean getRequired()
+  {
+    return m_required;
+  }
+
+  /**
+   * If true, this is attribute supports AVT's.
+   */
+  private boolean m_supportsAVT;
+
+  /**
+   * Get whether or not this attribute supports AVT's.
+   *
+   * @return true if this attribute supports AVT's.
+   */
+  boolean getSupportsAVT()
+  {
+    return m_supportsAVT;
+  }
+  
+  int m_errorType = this.WARNING;
+  
+  /**
+   * Get the type of error message to use if the attribute value is invalid.
+   *
+   * @return one of XSLAttributeDef.FATAL, XSLAttributeDef.ERROR, XSLAttributeDef.WARNING
+   */
+  int getErrorType()
+  {
+    return m_errorType;
+  }
+  /**
+   * String that should represent the setter method which which
+   * may be used on objects to set a value that represents this attribute  
+   */
+  String m_setterString = null;
+
+  /**
+   * Return a string that should represent the setter method.
+   * The setter method name will be created algorithmically the
+   * first time this method is accessed, and then cached for return
+   * by subsequent invocations of this method.
+   *
+   * @return String that should represent the setter method which which
+   * may be used on objects to set a value that represents this attribute,
+   * of null if no setter method should be called.
+   */
+  public String getSetterMethodName()
+  {
+
+    if (null == m_setterString)
+    {
+      if (m_foreignAttr == this)
+      {
+        return S_FOREIGNATTR_SETTER;
+      }
+      else if (m_name.equals("*"))
+      {
+        m_setterString = "addLiteralResultAttribute";
+
+        return m_setterString;
+      }
+
+      StringBuffer outBuf = new StringBuffer();
+
+      outBuf.append("set");
+
+      if ((m_namespace != null)
+              && m_namespace.equals(Constants.S_XMLNAMESPACEURI))
+      {
+        outBuf.append("Xml");
+      }
+
+      int n = m_name.length();
+
+      for (int i = 0; i < n; i++)
+      {
+        char c = m_name.charAt(i);
+
+        if ('-' == c)
+        {
+          i++;
+
+          c = m_name.charAt(i);
+          c = Character.toUpperCase(c);
+        }
+        else if (0 == i)
+        {
+          c = Character.toUpperCase(c);
+        }
+
+        outBuf.append(c);
+      }
+
+      m_setterString = outBuf.toString();
+    }
+
+    return m_setterString;
+  }
+
+  /**
+   * Process an attribute string of type T_AVT into
+   * a AVT value.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value Should be an Attribute Value Template string.
+   *
+   * @return An AVT object that may be used to evaluate the Attribute Value Template.
+   *
+   * @throws org.xml.sax.SAXException which will wrap a
+   * {@link javax.xml.transform.TransformerException}, if there is a syntax error
+   * in the attribute value template string.
+   */
+  AVT processAVT(
+          StylesheetHandler handler, String uri, String name, String rawName, String value,
+          ElemTemplateElement owner)
+            throws org.xml.sax.SAXException
+  {
+
+    try
+    {
+      AVT avt = new AVT(handler, uri, name, rawName, value, owner);
+
+      return avt;
+    }
+    catch (TransformerException te)
+    {
+      throw new org.xml.sax.SAXException(te);
+    }
+  }
+
+  /**
+   * Process an attribute string of type T_CDATA into
+   * a String value.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value non-null string reference.
+   *
+   * @return The value argument.
+   * 
+   * @throws org.xml.sax.SAXException.
+   */
+  Object processCDATA(StylesheetHandler handler, String uri, String name,
+                      String rawName, String value, ElemTemplateElement owner)
+                      throws org.xml.sax.SAXException
+  {
+  	if (getSupportsAVT()) {
+	    try
+	    {
+	      AVT avt = new AVT(handler, uri, name, rawName, value, owner);
+	      return avt;
+	    }
+	    catch (TransformerException te)
+	    {
+	      throw new org.xml.sax.SAXException(te);
+	    }  		
+  	} else {  	  	
+	    return value;
+  	}
+  }
+
+  /**
+   * Process an attribute string of type T_CHAR into
+   * a Character value.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value Should be a string with a length of 1.
+   *
+   * @return Character object.
+   *
+   * @throws org.xml.sax.SAXException if the string is not a length of 1.
+   */
+  Object processCHAR(
+          StylesheetHandler handler, String uri, String name, String rawName, String value, ElemTemplateElement owner)
+            throws org.xml.sax.SAXException
+  {
+	if (getSupportsAVT()) {
+	    try
+	    {
+	      AVT avt = new AVT(handler, uri, name, rawName, value, owner);
+	
+		  // If an AVT wasn't used, validate the value
+		  if ((avt.isSimple()) && (value.length() != 1)) {
+		  	handleError(handler, XSLTErrorResources.INVALID_TCHAR, new Object[] {name, value},null);
+            return null;
+		  }	
+	      return avt;
+	    }
+	    catch (TransformerException te)
+	    {
+	      throw new org.xml.sax.SAXException(te);
+	    }
+	} else {    
+	    if (value.length() != 1)
+	    {
+            handleError(handler, XSLTErrorResources.INVALID_TCHAR, new Object[] {name, value},null);
+            return null;
+	    }
+
+	    return new Character(value.charAt(0));
+	}
+  }
+
+  /**
+   * Process an attribute string of type T_ENUM into a int value.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value non-null string that represents an enumerated value that is
+   * valid for this element.
+   * @param owner
+   *
+   * @return An Integer representation of the enumerated value if this attribute does not support
+   *         AVT.  Otherwise, and AVT is returned.
+   */
+  Object processENUM(StylesheetHandler handler, String uri, String name,
+                     String rawName, String value, ElemTemplateElement owner)
+                     throws org.xml.sax.SAXException
+  {
+
+	AVT avt = null;
+	if (getSupportsAVT()) {
+	    try
+	    {
+	      avt = new AVT(handler, uri, name, rawName, value, owner);
+	      
+	      // If this attribute used an avt, then we can't validate at this time.
+	      if (!avt.isSimple()) return avt;
+	    }
+	    catch (TransformerException te)
+	    {
+	      throw new org.xml.sax.SAXException(te);
+	    }
+	}    
+	
+    int retVal = this.getEnum(value);
+    
+	if (retVal == StringToIntTable.INVALID_KEY) 
+    {
+       StringBuffer enumNamesList = getListOfEnums();
+       handleError(handler, XSLTErrorResources.INVALID_ENUM,new Object[]{name, value, enumNamesList.toString() },null);
+       return null;
+    }
+
+	if (getSupportsAVT()) return avt;
+	else return new Integer(retVal);	
+
+  }
+
+  /**
+   * Process an attribute string of that is either an enumerated value or a qname-but-not-ncname.
+   * Returns an AVT, if this attribute support AVT; otherwise returns int or qname.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value non-null string that represents an enumerated value that is
+   * valid for this element.
+   * @param owner
+   *
+   * @return AVT if attribute supports AVT. An Integer representation of the enumerated value if
+   *         attribute does not support AVT and an enumerated value was used.  Otherwise a qname
+   *         is returned.
+   */
+  Object processENUM_OR_PQNAME(StylesheetHandler handler, String uri, String name,
+                     String rawName, String value, ElemTemplateElement owner)
+                     throws org.xml.sax.SAXException
+  {
+
+	Object objToReturn = null;
+	
+	if (getSupportsAVT()) {
+	    try
+	    {
+	      AVT avt = new AVT(handler, uri, name, rawName, value, owner);
+	      if (!avt.isSimple()) return avt;
+	      else objToReturn = avt;
+	    }  
+	    catch (TransformerException te)
+	    {
+	      throw new org.xml.sax.SAXException(te);
+	    }
+	}    
+	
+    // An avt wasn't used.
+  	int key = this.getEnum(value);
+    
+    if (key != StringToIntTable.INVALID_KEY) 
+    {
+        if (objToReturn == null) objToReturn = new Integer(key);
+    }
+
+    // enum not used.  Validate qname-but-not-ncname.
+    else
+    {
+        try 
+        {
+			QName qname = new QName(value, handler, true);
+            if (objToReturn == null) objToReturn = qname;	
+	        
+			if (qname.getPrefix() == null) {
+	           StringBuffer enumNamesList = getListOfEnums();
+
+ 	           enumNamesList.append(" <qname-but-not-ncname>");
+               handleError(handler,XSLTErrorResources.INVALID_ENUM,new Object[]{name, value, enumNamesList.toString() },null); 
+               return null;
+        
+	        }            
+        }
+        catch (IllegalArgumentException ie) 
+        {
+           StringBuffer enumNamesList = getListOfEnums();
+           enumNamesList.append(" <qname-but-not-ncname>");
+           
+           handleError(handler,XSLTErrorResources.INVALID_ENUM,new Object[]{name, value, enumNamesList.toString() },ie); 
+           return null;
+
+        }
+        catch (RuntimeException re)
+        {
+           StringBuffer enumNamesList = getListOfEnums();
+           enumNamesList.append(" <qname-but-not-ncname>");
+
+           handleError(handler,XSLTErrorResources.INVALID_ENUM,new Object[]{name, value, enumNamesList.toString() },re); 
+           return null;
+        }    
+  	}
+  	
+  	return objToReturn;
+  }
+
+  /**
+   * Process an attribute string of type T_EXPR into
+   * an XPath value.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value An XSLT expression string.
+   *
+   * @return an XPath object that may be used for evaluation.
+   *
+   * @throws org.xml.sax.SAXException that wraps a
+   * {@link javax.xml.transform.TransformerException} if the expression
+   * string contains a syntax error.
+   */
+  Object processEXPR(
+          StylesheetHandler handler, String uri, String name, String rawName, String value,
+          ElemTemplateElement owner)
+            throws org.xml.sax.SAXException
+  {
+
+    try
+    {
+      XPath expr = handler.createXPath(value, owner);
+
+      return expr;
+    }
+    catch (TransformerException te)
+    {
+      throw new org.xml.sax.SAXException(te);
+    }
+  }
+
+  /**
+   * Process an attribute string of type T_NMTOKEN into
+   * a String value.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value A NMTOKEN string.
+   *
+   * @return the value argument or an AVT if this attribute supports AVTs.
+   * 
+   * @throws org.xml.sax.SAXException if the value is not a valid nmtoken
+   */
+  Object processNMTOKEN(StylesheetHandler handler, String uri, String name,
+                        String rawName, String value, ElemTemplateElement owner)
+             throws org.xml.sax.SAXException
+  {
+  	
+  	if (getSupportsAVT()) {
+	    try
+	    {
+	      AVT avt = new AVT(handler, uri, name, rawName, value, owner);
+	
+		  // If an AVT wasn't used, validate the value
+		  if ((avt.isSimple()) && (!XML11Char.isXML11ValidNmtoken(value))) {
+            handleError(handler,XSLTErrorResources.INVALID_NMTOKEN, new Object[] {name,value},null);
+            return null;
+		  }	
+	      return avt;
+	    }
+	    catch (TransformerException te)
+	    {
+	      throw new org.xml.sax.SAXException(te);
+	    }  		
+  	} else {
+  		if (!XML11Char.isXML11ValidNmtoken(value)) {
+            handleError(handler,XSLTErrorResources.INVALID_NMTOKEN, new Object[] {name,value},null);
+            return null;
+  		}
+  	}	  			
+    return value;
+  }
+
+  /**
+   * Process an attribute string of type T_PATTERN into
+   * an XPath match pattern value.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value A match pattern string.
+   *
+   * @return An XPath pattern that may be used to evaluate the XPath.
+   *
+   * @throws org.xml.sax.SAXException that wraps a
+   * {@link javax.xml.transform.TransformerException} if the match pattern
+   * string contains a syntax error.
+   */
+  Object processPATTERN(
+          StylesheetHandler handler, String uri, String name, String rawName, String value,
+          ElemTemplateElement owner)
+            throws org.xml.sax.SAXException
+  {
+
+    try
+    {
+      XPath pattern = handler.createMatchPatternXPath(value, owner);
+
+      return pattern;
+    }
+    catch (TransformerException te)
+    {
+      throw new org.xml.sax.SAXException(te);
+    }
+  }
+
+  /**
+   * Process an attribute string of type T_NUMBER into
+   * a double value.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value A string that can be parsed into a double value.
+   * @param number
+   *
+   * @return A Double object.
+   *
+   * @throws org.xml.sax.SAXException that wraps a
+   * {@link javax.xml.transform.TransformerException}
+   * if the string does not contain a parsable number.
+   */
+  Object processNUMBER(
+          StylesheetHandler handler, String uri, String name, String rawName, String value, ElemTemplateElement owner)
+            throws org.xml.sax.SAXException
+  {
+
+
+	if (getSupportsAVT()) 
+	{
+		Double val;
+		AVT avt = null;
+	    try
+	    {
+	      avt = new AVT(handler, uri, name, rawName, value, owner);
+	      
+	      // If this attribute used an avt, then we can't validate at this time.
+	      if (avt.isSimple()) 
+	      {
+	      	val = Double.valueOf(value);
+	      }
+	    }
+	    catch (TransformerException te)
+	    {
+	      throw new org.xml.sax.SAXException(te);
+	    } 
+	    catch (NumberFormatException nfe)
+	    {
+	     	handleError(handler,XSLTErrorResources.INVALID_NUMBER, new Object[] {name, value}, nfe);
+            return null;
+	    }
+	    return avt;
+	
+	} 
+	else
+    {
+	    try
+	    {
+	      return Double.valueOf(value);
+	    }
+	    catch (NumberFormatException nfe)
+	    {
+            handleError(handler,XSLTErrorResources.INVALID_NUMBER, new Object[] {name, value}, nfe);
+            return null;
+	    }
+    }    
+  }
+
+  /**
+   * Process an attribute string of type T_QNAME into a QName value.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value A string that represents a potentially prefix qualified name.
+   * @param owner
+   *
+   * @return A QName object if this attribute does not support AVT's.  Otherwise, an AVT
+   *         is returned.
+   *
+   * @throws org.xml.sax.SAXException if the string contains a prefix that can not be
+   * resolved, or the string contains syntax that is invalid for a qualified name.
+   */
+  Object processQNAME(
+          StylesheetHandler handler, String uri, String name, String rawName, String value, ElemTemplateElement owner)
+            throws org.xml.sax.SAXException
+  {
+
+     try 
+        {	
+   	      QName qname = new QName(value, handler, true);
+          return qname;
+        }
+        catch (IllegalArgumentException ie)
+        {
+            // thrown by QName constructor
+            handleError(handler,XSLTErrorResources.INVALID_QNAME, new Object[] {name, value},ie);
+            return null;
+        }
+        catch (RuntimeException re) {
+            // thrown by QName constructor
+            handleError(handler,XSLTErrorResources.INVALID_QNAME, new Object[] {name, value},re);
+            return null;
+        }
+  	}
+ 
+
+  /**
+   * Process an attribute string of type T_QNAME into a QName value.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value A string that represents a potentially prefix qualified name.
+   * @param owner
+   *
+   * @return An AVT is returned.
+   *
+   * @throws org.xml.sax.SAXException if the string contains a prefix that can not be
+   * resolved, or the string contains syntax that is invalid for a qualified name.
+   */
+  Object processAVT_QNAME(
+          StylesheetHandler handler, String uri, String name, String rawName, String value, ElemTemplateElement owner)
+            throws org.xml.sax.SAXException
+  {
+
+       AVT avt = null;
+       try
+       {
+          avt = new AVT(handler, uri, name, rawName, value, owner);
+    
+          // If an AVT wasn't used, validate the value
+          if (avt.isSimple())
+          {
+             int indexOfNSSep = value.indexOf(':');
+
+             if (indexOfNSSep >= 0) 
+             {   
+                  String prefix = value.substring(0, indexOfNSSep);
+                  if (!XML11Char.isXML11ValidNCName(prefix))
+                  {
+                     handleError(handler,XSLTErrorResources.INVALID_QNAME,new Object[]{name,value },null);
+                     return null;
+                  }
+             }
+                 
+             String localName =  (indexOfNSSep < 0)
+                 ? value : value.substring(indexOfNSSep + 1); 
+             
+             if ((localName == null) || (localName.length() == 0) ||
+                 (!XML11Char.isXML11ValidNCName(localName)))
+             {    
+                     handleError(handler,XSLTErrorResources.INVALID_QNAME,new Object[]{name,value },null );
+                     return null;
+             }
+          }  
+        }
+        catch (TransformerException te)
+        {
+           // thrown by AVT constructor
+          throw new org.xml.sax.SAXException(te);
+        } 
+    
+    return avt;
+ }
+
+  /**
+   * Process an attribute string of type NCName into a String
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value A string that represents a potentially prefix qualified name.
+   * @param owner
+   *
+   * @return A String object if this attribute does not support AVT's.  Otherwise, an AVT
+   *         is returned.
+   *
+   * @throws org.xml.sax.SAXException if the string contains a prefix that can not be
+   * resolved, or the string contains syntax that is invalid for a NCName.
+   */
+  Object processNCNAME(
+          StylesheetHandler handler, String uri, String name, String rawName, String value, ElemTemplateElement owner)
+            throws org.xml.sax.SAXException
+  {
+    
+    if (getSupportsAVT()) 
+    {
+        AVT avt = null;
+        try
+        {
+          avt = new AVT(handler, uri, name, rawName, value, owner);
+    
+          // If an AVT wasn't used, validate the value
+          if ((avt.isSimple()) &&  (!XML11Char.isXML11ValidNCName(value))) 
+          {
+             handleError(handler,XSLTErrorResources.INVALID_NCNAME,new Object[] {name,value},null);
+             return null;
+          }      
+          return avt;
+        }
+        catch (TransformerException te)
+        {
+           // thrown by AVT constructor
+          throw new org.xml.sax.SAXException(te);
+        } 
+        
+    } else {
+        if (!XML11Char.isXML11ValidNCName(value)) 
+        {
+            handleError(handler,XSLTErrorResources.INVALID_NCNAME,new Object[] {name,value},null);
+            return null;
+        }
+        return value;
+    }
+ }
+
+  /**
+   * Process an attribute string of type T_QNAMES into a vector of QNames where
+   * the specification requires that non-prefixed elements not be placed in a
+   * namespace.  (See section 2.4 of XSLT 1.0.)
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value A whitespace delimited list of qualified names.
+   *
+   * @return a Vector of QName objects.
+   *
+   * @throws org.xml.sax.SAXException if the one of the qualified name strings
+   * contains a prefix that can not be
+   * resolved, or a qualified name contains syntax that is invalid for a qualified name.
+   */
+  Vector processQNAMES(
+          StylesheetHandler handler, String uri, String name, String rawName, String value)
+            throws org.xml.sax.SAXException
+  {
+
+    StringTokenizer tokenizer = new StringTokenizer(value, " \t\n\r\f");
+    int nQNames = tokenizer.countTokens();
+    Vector qnames = new Vector(nQNames);
+
+    for (int i = 0; i < nQNames; i++)
+    {
+      // Fix from Alexander Rudnev
+      qnames.addElement(new QName(tokenizer.nextToken(), handler));
+    }
+
+    return qnames;
+  }
+
+ /**
+   * Process an attribute string of type T_QNAMES_RESOLVE_NULL into a vector
+   * of QNames where the specification requires non-prefixed elements to be
+   * placed in the default namespace.  (See section 16 of XSLT 1.0; the
+   * <em>only</em> time that this will get called is for the
+   * <code>cdata-section-elements</code> attribute on <code>xsl:output</code>.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value A whitespace delimited list of qualified names.
+   *
+   * @return a Vector of QName objects.
+   *
+   * @throws org.xml.sax.SAXException if the one of the qualified name strings
+   * contains a prefix that can not be resolved, or a qualified name contains
+   * syntax that is invalid for a qualified name.
+   */
+  final Vector processQNAMESRNU(StylesheetHandler handler, String uri,
+    String name, String rawName, String value)
+    throws org.xml.sax.SAXException
+  {
+
+    StringTokenizer tokenizer = new StringTokenizer(value, " \t\n\r\f");
+    int nQNames = tokenizer.countTokens();
+    Vector qnames = new Vector(nQNames);
+
+    String defaultURI = handler.getNamespaceForPrefix("");
+    for (int i = 0; i < nQNames; i++)
+    {
+      String tok = tokenizer.nextToken();
+      if (tok.indexOf(':') == -1) {
+        qnames.addElement(new QName(defaultURI,tok));
+      } else {
+        qnames.addElement(new QName(tok, handler));
+      }
+    }
+    return qnames;
+  }
+
+  /**
+   * Process an attribute string of type T_SIMPLEPATTERNLIST into
+   * a vector of XPath match patterns.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value A whitespace delimited list of simple match patterns.
+   *
+   * @return A Vector of XPath objects.
+   *
+   * @throws org.xml.sax.SAXException that wraps a
+   * {@link javax.xml.transform.TransformerException} if one of the match pattern
+   * strings contains a syntax error.
+   */
+  Vector processSIMPLEPATTERNLIST(
+          StylesheetHandler handler, String uri, String name, String rawName, String value,
+          ElemTemplateElement owner)
+            throws org.xml.sax.SAXException
+  {
+
+    try
+    {
+      StringTokenizer tokenizer = new StringTokenizer(value, " \t\n\r\f");
+      int nPatterns = tokenizer.countTokens();
+      Vector patterns = new Vector(nPatterns);
+
+      for (int i = 0; i < nPatterns; i++)
+      {
+        XPath pattern =
+          handler.createMatchPatternXPath(tokenizer.nextToken(), owner);
+
+        patterns.addElement(pattern);
+      }
+
+      return patterns;
+    }
+    catch (TransformerException te)
+    {
+      throw new org.xml.sax.SAXException(te);
+    }
+  }
+
+  /**
+   * Process an attribute string of type T_STRINGLIST into
+   * a vector of XPath match patterns.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value a whitespace delimited list of string values.
+   *
+   * @return A StringVector of the tokenized strings.
+   */
+  StringVector processSTRINGLIST(StylesheetHandler handler, String uri,
+                                 String name, String rawName, String value)
+  {
+
+    StringTokenizer tokenizer = new StringTokenizer(value, " \t\n\r\f");
+    int nStrings = tokenizer.countTokens();
+    StringVector strings = new StringVector(nStrings);
+
+    for (int i = 0; i < nStrings; i++)
+    {
+      strings.addElement(tokenizer.nextToken());
+    }
+
+    return strings;
+  }
+
+  /**
+   * Process an attribute string of type T_URLLIST into
+   * a vector of prefixes that may be resolved to URLs.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value A list of whitespace delimited prefixes.
+   *
+   * @return A vector of strings that may be resolved to URLs.
+   *
+   * @throws org.xml.sax.SAXException if one of the prefixes can not be resolved.
+   */
+  StringVector processPREFIX_URLLIST(
+          StylesheetHandler handler, String uri, String name, String rawName, String value)
+            throws org.xml.sax.SAXException
+  {
+
+    StringTokenizer tokenizer = new StringTokenizer(value, " \t\n\r\f");
+    int nStrings = tokenizer.countTokens();
+    StringVector strings = new StringVector(nStrings);
+
+    for (int i = 0; i < nStrings; i++)
+    {
+      String prefix = tokenizer.nextToken();
+      String url = handler.getNamespaceForPrefix(prefix);
+
+      if (url != null)
+        strings.addElement(url);
+      else
+        throw new org.xml.sax.SAXException(XSLMessages.createMessage(XSLTErrorResources.ER_CANT_RESOLVE_NSPREFIX, new Object[] {prefix}));
+    
+    }
+
+    return strings;
+  }
+
+  /**
+    * Process an attribute string of type T_PREFIXLIST into
+    * a vector of prefixes that may be resolved to URLs.
+    *
+    * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+    * @param uri The Namespace URI, or an empty string.
+    * @param name The local name (without prefix), or empty string if not namespace processing.
+    * @param rawName The qualified name (with prefix).
+    * @param value A list of whitespace delimited prefixes.
+    *
+    * @return A vector of strings that may be resolved to URLs.
+    *
+    * @throws org.xml.sax.SAXException if one of the prefixes can not be resolved.
+    */
+   StringVector processPREFIX_LIST(
+           StylesheetHandler handler, String uri, String name, 
+           String rawName, String value) throws org.xml.sax.SAXException
+   {
+    
+     StringTokenizer tokenizer = new StringTokenizer(value, " \t\n\r\f");
+     int nStrings = tokenizer.countTokens();
+     StringVector strings = new StringVector(nStrings);
+
+     for (int i = 0; i < nStrings; i++)
+     {
+       String prefix = tokenizer.nextToken();
+       String url = handler.getNamespaceForPrefix(prefix);
+       if (prefix.equals(Constants.ATTRVAL_DEFAULT_PREFIX) || url != null)
+         strings.addElement(prefix);
+       else
+         throw new org.xml.sax.SAXException(
+              XSLMessages.createMessage(
+                   XSLTErrorResources.ER_CANT_RESOLVE_NSPREFIX, 
+                   new Object[] {prefix}));
+    
+     }
+
+     return strings;
+   }
+
+
+  /**
+   * Process an attribute string of type T_URL into
+   * a URL value.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value non-null string that conforms to the URL syntax.
+   *
+   * @return The non-absolutized URL argument, in other words, the value argument.  If this 
+   *         attribute supports AVT, an AVT is returned.
+   *
+   * @throws org.xml.sax.SAXException if the URL does not conform to the URL syntax.
+   */
+  Object processURL(
+          StylesheetHandler handler, String uri, String name, String rawName, String value, ElemTemplateElement owner)
+            throws org.xml.sax.SAXException
+  {
+
+    if (getSupportsAVT()) {
+	    try
+	    {
+	      AVT avt = new AVT(handler, uri, name, rawName, value, owner);
+	
+		  // If an AVT wasn't used, validate the value
+		 // if (avt.getSimpleString() != null) {
+			   // TODO: syntax check URL value.
+			    // return SystemIDResolver.getAbsoluteURI(value, 
+			    //                                         handler.getBaseIdentifier());
+		  //}	
+	      return avt;
+	    }
+	    catch (TransformerException te)
+	    {
+	      throw new org.xml.sax.SAXException(te);
+	    }  		
+     } else {
+    // TODO: syntax check URL value.
+    // return SystemIDResolver.getAbsoluteURI(value, 
+    //                                         handler.getBaseIdentifier());
+     	
+	    return value;
+    }
+  }
+
+  /**
+   * Process an attribute string of type T_YESNO into
+   * a Boolean value.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value A string that should be "yes" or "no".
+   *
+   * @return Boolean object representation of the value.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  private Boolean processYESNO(
+          StylesheetHandler handler, String uri, String name, String rawName, String value)
+            throws org.xml.sax.SAXException
+  {
+
+    // Is this already checked somewhere else?  -sb
+    if (!(value.equals("yes") || value.equals("no")))
+    {
+      handleError(handler, XSLTErrorResources.INVALID_BOOLEAN, new Object[] {name,value}, null);
+      return null;
+   }
+ 
+     return new Boolean(value.equals("yes") ? true : false);
+  }
+
+  /**
+   * Process an attribute value.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param name The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param value The unprocessed string value of the attribute.
+   *
+   * @return The processed Object representation of the attribute.
+   *
+   * @throws org.xml.sax.SAXException if the attribute value can not be processed.
+   */
+  Object processValue(
+          StylesheetHandler handler, String uri, String name, String rawName, String value,
+          ElemTemplateElement owner)
+            throws org.xml.sax.SAXException
+  {
+
+    int type = getType();
+    Object processedValue = null;
+
+    switch (type)
+    {
+    case T_AVT :
+      processedValue = processAVT(handler, uri, name, rawName, value, owner);
+      break;
+    case T_CDATA :
+      processedValue = processCDATA(handler, uri, name, rawName, value, owner);
+      break;
+    case T_CHAR :
+      processedValue = processCHAR(handler, uri, name, rawName, value, owner);
+      break;
+    case T_ENUM :
+      processedValue = processENUM(handler, uri, name, rawName, value, owner);
+      break;
+    case T_EXPR :
+      processedValue = processEXPR(handler, uri, name, rawName, value, owner);
+      break;
+    case T_NMTOKEN :
+      processedValue = processNMTOKEN(handler, uri, name, rawName, value, owner);
+      break;
+    case T_PATTERN :
+      processedValue = processPATTERN(handler, uri, name, rawName, value, owner);
+      break;
+    case T_NUMBER :
+      processedValue = processNUMBER(handler, uri, name, rawName, value, owner);
+      break;
+    case T_QNAME :
+      processedValue = processQNAME(handler, uri, name, rawName, value, owner);
+      break;
+    case T_QNAMES :
+      processedValue = processQNAMES(handler, uri, name, rawName, value);
+      break;
+	case T_QNAMES_RESOLVE_NULL:
+      processedValue = processQNAMESRNU(handler, uri, name, rawName, value);
+      break;
+    case T_SIMPLEPATTERNLIST :
+      processedValue = processSIMPLEPATTERNLIST(handler, uri, name, rawName,
+                                                value, owner);
+      break;
+    case T_URL :
+      processedValue = processURL(handler, uri, name, rawName, value, owner);
+      break;
+    case T_YESNO :
+      processedValue = processYESNO(handler, uri, name, rawName, value);
+      break;
+    case T_STRINGLIST :
+      processedValue = processSTRINGLIST(handler, uri, name, rawName, value);
+      break;
+    case T_PREFIX_URLLIST :
+      processedValue = processPREFIX_URLLIST(handler, uri, name, rawName,
+                                             value);
+      break;
+    case T_ENUM_OR_PQNAME :
+    	processedValue = processENUM_OR_PQNAME(handler, uri, name, rawName, value, owner);
+    	break;
+    case T_NCNAME :
+        processedValue = processNCNAME(handler, uri, name, rawName, value, owner);
+        break;
+    case T_AVT_QNAME :
+        processedValue = processAVT_QNAME(handler, uri, name, rawName, value, owner);
+        break;
+    case T_PREFIXLIST :
+      processedValue = processPREFIX_LIST(handler, uri, name, rawName,
+                                             value);
+      break;
+
+    default :
+    }
+
+    return processedValue;
+  }
+
+  /**
+   * Set the default value of an attribute.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param elem The object on which the property will be set.
+   *
+   * @throws org.xml.sax.SAXException wraps an invocation exception if the
+   * setter method can not be invoked on the object.
+   */
+  void setDefAttrValue(StylesheetHandler handler, ElemTemplateElement elem)
+          throws org.xml.sax.SAXException
+  {
+    setAttrValue(handler, this.getNamespace(), this.getName(),
+                 this.getName(), this.getDefault(), elem);
+  }
+
+  /**
+   * Get the primative type for the class, if there
+   * is one.  If the class is a Double, for instance,
+   * this will return double.class.  If the class is not one
+   * of the 9 primative types, it will return the same
+   * class that was passed in.
+   *
+   * @param obj The object which will be resolved to a primative class object if possible.
+   *
+   * @return The most primative class representation possible for the object, never null.
+   */
+  private Class getPrimativeClass(Object obj)
+  {
+
+    if (obj instanceof XPath)
+      return XPath.class;
+
+    Class cl = obj.getClass();
+
+    if (cl == Double.class)
+    {
+      cl = double.class;
+    }
+
+    if (cl == Float.class)
+    {
+      cl = float.class;
+    }
+    else if (cl == Boolean.class)
+    {
+      cl = boolean.class;
+    }
+    else if (cl == Byte.class)
+    {
+      cl = byte.class;
+    }
+    else if (cl == Character.class)
+    {
+      cl = char.class;
+    }
+    else if (cl == Short.class)
+    {
+      cl = short.class;
+    }
+    else if (cl == Integer.class)
+    {
+      cl = int.class;
+    }
+    else if (cl == Long.class)
+    {
+      cl = long.class;
+    }
+
+    return cl;
+  }
+  
+  /**
+   * StringBuffer containing comma delimited list of valid values for ENUM type.
+   * Used to build error message.
+   */
+  private StringBuffer getListOfEnums() 
+  {
+     StringBuffer enumNamesList = new StringBuffer();            
+     String [] enumValues = this.getEnumNames();
+
+     for (int i = 0; i < enumValues.length; i++)
+     {
+        if (i > 0)
+        {
+           enumNamesList.append(' ');
+        }
+        enumNamesList.append(enumValues[i]);
+    }        
+    return enumNamesList;
+  }
+
+  /**
+   * Set a value on an attribute.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param attrUri The Namespace URI of the attribute, or an empty string.
+   * @param attrLocalName The local name (without prefix), or empty string if not namespace processing.
+   * @param attrRawName The raw name of the attribute, including possible prefix.
+   * @param attrValue The attribute's value.
+   * @param elem The object that should contain a property that represents the attribute.
+   *
+   * @throws org.xml.sax.SAXException
+   */
+  boolean setAttrValue(
+          StylesheetHandler handler, String attrUri, String attrLocalName, 
+          String attrRawName, String attrValue, ElemTemplateElement elem)
+            throws org.xml.sax.SAXException
+  {
+    if(attrRawName.equals("xmlns") || attrRawName.startsWith("xmlns:"))
+      return true;
+      
+    String setterString = getSetterMethodName();
+
+    // If this is null, then it is a foreign namespace and we 
+    // do not process it.
+    if (null != setterString)
+    {
+      try
+      {
+        Method meth;
+        Object[] args;
+
+        if(setterString.equals(S_FOREIGNATTR_SETTER))
+        {
+          // workaround for possible crimson bug
+          if( attrUri==null) attrUri="";
+          // First try to match with the primative value.
+          Class sclass = attrUri.getClass();
+          Class[] argTypes = new Class[]{ sclass, sclass,
+                                      sclass, sclass };
+  
+          meth = elem.getClass().getMethod(setterString, argTypes);
+  
+          args = new Object[]{ attrUri, attrLocalName,
+                                      attrRawName, attrValue };
+        }
+        else
+        {
+          Object value = processValue(handler, attrUri, attrLocalName,
+                                      attrRawName, attrValue, elem);
+          // If a warning was issued because the value for this attribute was
+          // invalid, then the value will be null.  Just return
+          if (null == value) return false;
+                                      
+          // First try to match with the primative value.
+          Class[] argTypes = new Class[]{ getPrimativeClass(value) };
+  
+          try
+          {
+            meth = elem.getClass().getMethod(setterString, argTypes);
+          }
+          catch (NoSuchMethodException nsme)
+          {
+            Class cl = ((Object) value).getClass();
+  
+            // If this doesn't work, try it with the non-primative value;
+            argTypes[0] = cl;
+            meth = elem.getClass().getMethod(setterString, argTypes);
+          }
+  
+          args = new Object[]{ value };
+        }
+
+        meth.invoke(elem, args);
+      }
+      catch (NoSuchMethodException nsme)
+      {
+        if (!setterString.equals(S_FOREIGNATTR_SETTER)) 
+        {
+          handler.error(XSLTErrorResources.ER_FAILED_CALLING_METHOD, new Object[]{setterString}, nsme);//"Failed calling " + setterString + " method!", nsme);
+          return false;
+        }
+      }
+      catch (IllegalAccessException iae)
+      {
+        handler.error(XSLTErrorResources.ER_FAILED_CALLING_METHOD, new Object[]{setterString}, iae);//"Failed calling " + setterString + " method!", iae);
+        return false;
+      }
+      catch (InvocationTargetException nsme)
+      {
+        handleError(handler, XSLTErrorResources.WG_ILLEGAL_ATTRIBUTE_VALUE,
+            new Object[]{ Constants.ATTRNAME_NAME, getName()}, nsme);
+        return false;
+      }
+    }
+    
+    return true;
+  }
+  
+  private void handleError(StylesheetHandler handler, String msg, Object [] args, Exception exc) throws org.xml.sax.SAXException
+  {
+    switch (getErrorType()) 
+    {
+        case (FATAL):
+        case (ERROR):
+                handler.error(msg, args, exc);          
+                break;
+        case (WARNING):
+                handler.warn(msg, args);       
+        default: break;
+    }
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/XSLTElementDef.java b/src/main/java/org/apache/xalan/processor/XSLTElementDef.java
new file mode 100644
index 0000000..1129639
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/XSLTElementDef.java
@@ -0,0 +1,833 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: XSLTElementDef.java 468640 2006-10-28 06:53:53Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.apache.xalan.templates.Constants;
+import org.apache.xml.utils.QName;
+
+/**
+ * This class defines the allowed structure for an element in a XSLT stylesheet,
+ * is meant to reflect the structure defined in http://www.w3.org/TR/xslt#dtd, and the
+ * mapping between Xalan classes and the markup elements in the XSLT instance.
+ * This actually represents both text nodes and elements.
+ */
+public class XSLTElementDef
+{
+
+  /**
+   * Construct an instance of XSLTElementDef.  This must be followed by a
+   * call to build().
+   */
+  XSLTElementDef(){}
+
+  /**
+   * Construct an instance of XSLTElementDef.
+   *
+   * @param namespace  The Namespace URI, "*", or null.
+   * @param name The local name (without prefix), "*", or null.
+   * @param nameAlias A potential alias for the name, or null.
+   * @param elements An array of allowed child element defs, or null.
+   * @param attributes An array of allowed attribute defs, or null.
+   * @param contentHandler The element processor for this element.
+   * @param classObject The class of the object that this element def should produce.
+   */
+  XSLTElementDef(XSLTSchema schema, String namespace, String name, String nameAlias,
+                 XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
+                 XSLTElementProcessor contentHandler, Class classObject)
+  {
+    build(namespace, name, nameAlias, elements, attributes, contentHandler,
+          classObject);
+    if ( (null != namespace)
+    &&  (namespace.equals(Constants.S_XSLNAMESPACEURL)
+        || namespace.equals(Constants.S_BUILTIN_EXTENSIONS_URL)
+        || namespace.equals(Constants.S_BUILTIN_OLD_EXTENSIONS_URL)))
+    {
+      schema.addAvailableElement(new QName(namespace, name));
+      if(null != nameAlias)
+        schema.addAvailableElement(new QName(namespace, nameAlias));
+    } 
+  }
+	
+	/**
+   * Construct an instance of XSLTElementDef.
+   *
+   * @param namespace  The Namespace URI, "*", or null.
+   * @param name The local name (without prefix), "*", or null.
+   * @param nameAlias A potential alias for the name, or null.
+   * @param elements An array of allowed child element defs, or null.
+   * @param attributes An array of allowed attribute defs, or null.
+   * @param contentHandler The element processor for this element.
+   * @param classObject The class of the object that this element def should produce.
+   * @param has_required true if this element has required elements by the XSLT specification.
+   */
+  XSLTElementDef(XSLTSchema schema, String namespace, String name, String nameAlias,
+                 XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
+                 XSLTElementProcessor contentHandler, Class classObject, boolean has_required)
+  {
+		this.m_has_required = has_required;
+    build(namespace, name, nameAlias, elements, attributes, contentHandler,
+          classObject);
+    if ( (null != namespace)
+    &&  (namespace.equals(Constants.S_XSLNAMESPACEURL)
+        || namespace.equals(Constants.S_BUILTIN_EXTENSIONS_URL)
+        || namespace.equals(Constants.S_BUILTIN_OLD_EXTENSIONS_URL)))
+    {
+      schema.addAvailableElement(new QName(namespace, name));
+      if(null != nameAlias)
+        schema.addAvailableElement(new QName(namespace, nameAlias));
+    } 
+		
+  }
+	
+	/**
+   * Construct an instance of XSLTElementDef.
+   *
+   * @param namespace  The Namespace URI, "*", or null.
+   * @param name The local name (without prefix), "*", or null.
+   * @param nameAlias A potential alias for the name, or null.
+   * @param elements An array of allowed child element defs, or null.
+   * @param attributes An array of allowed attribute defs, or null.
+   * @param contentHandler The element processor for this element.
+   * @param classObject The class of the object that this element def should produce.
+   * @param has_required true if this element has required elements by the XSLT specification.
+   * @param required true if this element is required by the XSLT specification.
+   */
+  XSLTElementDef(XSLTSchema schema, String namespace, String name, String nameAlias,
+                 XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
+                 XSLTElementProcessor contentHandler, Class classObject, 
+								 boolean has_required, boolean required)
+  {
+    this(schema, namespace, name,  nameAlias,
+                 elements, attributes,
+                 contentHandler, classObject, has_required);
+		this.m_required = required;
+  }
+	
+	/**
+   * Construct an instance of XSLTElementDef.
+   *
+   * @param namespace  The Namespace URI, "*", or null.
+   * @param name The local name (without prefix), "*", or null.
+   * @param nameAlias A potential alias for the name, or null.
+   * @param elements An array of allowed child element defs, or null.
+   * @param attributes An array of allowed attribute defs, or null.
+   * @param contentHandler The element processor for this element.
+   * @param classObject The class of the object that this element def should produce.
+   * @param has_required true if this element has required elements by the XSLT specification.
+   * @param required true if this element is required by the XSLT specification.
+   * @param order the order this element should appear according to the XSLT specification.   
+   * @param multiAllowed whether this element is allowed more than once
+   */
+  XSLTElementDef(XSLTSchema schema, String namespace, String name, String nameAlias,
+                 XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
+                 XSLTElementProcessor contentHandler, Class classObject, 
+								 boolean has_required, boolean required, int order, 
+								 boolean multiAllowed)
+  {
+		this(schema, namespace, name,  nameAlias,
+                 elements, attributes,
+                 contentHandler, classObject, has_required, required);    
+		this.m_order = order;
+		this.m_multiAllowed = multiAllowed;
+  }
+	
+	/**
+   * Construct an instance of XSLTElementDef.
+   *
+   * @param namespace  The Namespace URI, "*", or null.
+   * @param name The local name (without prefix), "*", or null.
+   * @param nameAlias A potential alias for the name, or null.
+   * @param elements An array of allowed child element defs, or null.
+   * @param attributes An array of allowed attribute defs, or null.
+   * @param contentHandler The element processor for this element.
+   * @param classObject The class of the object that this element def should produce.
+   * @param has_required true if this element has required elements by the XSLT specification.
+   * @param required true if this element is required by the XSLT specification.
+   * @param has_order whether this element has ordered child elements
+   * @param order the order this element should appear according to the XSLT specification.   
+   * @param multiAllowed whether this element is allowed more than once
+   */
+  XSLTElementDef(XSLTSchema schema, String namespace, String name, String nameAlias,
+                 XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
+                 XSLTElementProcessor contentHandler, Class classObject, 
+								 boolean has_required, boolean required, boolean has_order, int order, 
+								 boolean multiAllowed)
+  {
+		this(schema, namespace, name,  nameAlias,
+                 elements, attributes,
+                 contentHandler, classObject, has_required, required);    
+		this.m_order = order;
+		this.m_multiAllowed = multiAllowed;
+    this.m_isOrdered = has_order;		
+  }
+	
+	/**
+   * Construct an instance of XSLTElementDef.
+   *
+   * @param namespace  The Namespace URI, "*", or null.
+   * @param name The local name (without prefix), "*", or null.
+   * @param nameAlias A potential alias for the name, or null.
+   * @param elements An array of allowed child element defs, or null.
+   * @param attributes An array of allowed attribute defs, or null.
+   * @param contentHandler The element processor for this element.
+   * @param classObject The class of the object that this element def should produce.
+   * @param has_order whether this element has ordered child elements
+   * @param order the order this element should appear according to the XSLT specification.   
+   * @param multiAllowed whether this element is allowed more than once
+   */
+  XSLTElementDef(XSLTSchema schema, String namespace, String name, String nameAlias,
+                 XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
+                 XSLTElementProcessor contentHandler, Class classObject, 
+								 boolean has_order, int order, boolean multiAllowed)
+  {
+    this(schema, namespace, name,  nameAlias,
+                 elements, attributes,
+                 contentHandler, classObject, 
+								 order, multiAllowed);
+		this.m_isOrdered = has_order;		
+  }
+	
+	/**
+   * Construct an instance of XSLTElementDef.
+   *
+   * @param namespace  The Namespace URI, "*", or null.
+   * @param name The local name (without prefix), "*", or null.
+   * @param nameAlias A potential alias for the name, or null.
+   * @param elements An array of allowed child element defs, or null.
+   * @param attributes An array of allowed attribute defs, or null.
+   * @param contentHandler The element processor for this element.
+   * @param classObject The class of the object that this element def should produce.
+   * @param order the order this element should appear according to the XSLT specification.   
+   * @param multiAllowed whether this element is allowed more than once
+   */
+  XSLTElementDef(XSLTSchema schema, String namespace, String name, String nameAlias,
+                 XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
+                 XSLTElementProcessor contentHandler, Class classObject, 
+								 int order, boolean multiAllowed)
+  {
+    this(schema, namespace, name, nameAlias, elements, attributes, contentHandler,
+          classObject);
+    this.m_order = order;
+		this.m_multiAllowed = multiAllowed;
+  }
+
+  /**
+   * Construct an instance of XSLTElementDef that represents text.
+   *
+   * @param classObject The class of the object that this element def should produce.
+   * @param contentHandler The element processor for this element.
+   * @param type Content type, one of T_ELEMENT, T_PCDATA, or T_ANY.
+   */
+  XSLTElementDef(Class classObject, XSLTElementProcessor contentHandler,
+                 int type)
+  {
+
+    this.m_classObject = classObject;
+    this.m_type = type;
+
+    setElementProcessor(contentHandler);
+  }
+
+  /**
+   * Construct an instance of XSLTElementDef.
+   *
+   * @param namespace  The Namespace URI, "*", or null.
+   * @param name The local name (without prefix), "*", or null.
+   * @param nameAlias A potential alias for the name, or null.
+   * @param elements An array of allowed child element defs, or null.
+   * @param attributes An array of allowed attribute defs, or null.
+   * @param contentHandler The element processor for this element.
+   * @param classObject The class of the object that this element def should produce.
+   */
+  void build(String namespace, String name, String nameAlias,
+             XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
+             XSLTElementProcessor contentHandler, Class classObject)
+  {
+
+    this.m_namespace = namespace;
+    this.m_name = name;
+    this.m_nameAlias = nameAlias;
+    this.m_elements = elements;
+    this.m_attributes = attributes;
+
+    setElementProcessor(contentHandler);
+
+    this.m_classObject = classObject;
+		
+		if (hasRequired() && m_elements != null)
+		{
+			int n = m_elements.length;
+			for (int i = 0; i < n; i++)
+			{
+				XSLTElementDef def = m_elements[i];
+				
+				if (def != null && def.getRequired())
+				{
+					if (m_requiredFound == null)			
+						m_requiredFound = new Hashtable();
+					m_requiredFound.put(def.getName(), "xsl:" +def.getName()); 
+				}
+			}
+		}
+  }
+
+  /**
+   * Tell if two objects are equal, when either one may be null.
+   * If both are null, they are considered equal.
+   *
+   * @param obj1 A reference to the first object, or null.
+   * @param obj2 A reference to the second object, or null.
+   *
+   * @return true if the to objects are equal by both being null or 
+   * because obj2.equals(obj1) returns true.
+   */
+  private static boolean equalsMayBeNull(Object obj1, Object obj2)
+  {
+    return (obj2 == obj1)
+           || ((null != obj1) && (null != obj2) && obj2.equals(obj1));
+  }
+
+  /**
+   * Tell if the two string refs are equal,
+   * equality being defined as:
+   * 1) Both strings are null.
+   * 2) One string is null and the other is empty.
+   * 3) Both strings are non-null, and equal.
+   *
+   * @param s1 A reference to the first string, or null.
+   * @param s2 A reference to the second string, or null.
+   *
+   * @return true if Both strings are null, or if 
+   * one string is null and the other is empty, or if 
+   * both strings are non-null, and equal because 
+   * s1.equals(s2) returns true.
+   */
+  private static boolean equalsMayBeNullOrZeroLen(String s1, String s2)
+  {
+
+    int len1 = (s1 == null) ? 0 : s1.length();
+    int len2 = (s2 == null) ? 0 : s2.length();
+
+    return (len1 != len2) ? false 
+						 : (len1 == 0) ? true 
+								 : s1.equals(s2);
+  }
+
+  /** Content type enumerations    */
+  static final int T_ELEMENT = 1, T_PCDATA = 2, T_ANY = 3;
+
+  /**
+   * The type of this element.
+   */
+  private int m_type = T_ELEMENT;
+
+  /**
+   * Get the type of this element.
+   *
+   * @return Content type, one of T_ELEMENT, T_PCDATA, or T_ANY.
+   */
+  int getType()
+  {
+    return m_type;
+  }
+
+  /**
+   * Set the type of this element.
+   *
+   * @param t Content type, one of T_ELEMENT, T_PCDATA, or T_ANY.
+   */
+  void setType(int t)
+  {
+    m_type = t;
+  }
+
+  /**
+   * The allowed namespace for this element.
+   */
+  private String m_namespace;
+
+  /**
+   * Get the allowed namespace for this element.
+   *
+   * @return The Namespace URI, "*", or null.
+   */
+  String getNamespace()
+  {
+    return m_namespace;
+  }
+
+  /**
+   * The name of this element.
+   */
+  private String m_name;
+
+  /**
+   * Get the local name of this element.
+   *
+   * @return The local name of this element, "*", or null.
+   */
+  String getName()
+  {
+    return m_name;
+  }
+
+  /**
+   * The name of this element.
+   */
+  private String m_nameAlias;
+
+  /**
+   * Get the name of this element.
+   *
+   * @return A potential alias for the name, or null.
+   */
+  String getNameAlias()
+  {
+    return m_nameAlias;
+  }
+
+  /**
+   * The allowed elements for this type.
+   */
+  private XSLTElementDef[] m_elements;
+
+  /**
+   * Get the allowed elements for this type.
+   *
+   * @return An array of allowed child element defs, or null.
+   * @xsl.usage internal
+   */
+  public XSLTElementDef[] getElements()
+  {
+    return m_elements;
+  }
+
+  /**
+   * Set the allowed elements for this type.
+   *
+   * @param defs An array of allowed child element defs, or null.
+   */
+  void setElements(XSLTElementDef[] defs)
+  {
+    m_elements = defs;
+  }
+
+  /**
+   * Tell if the namespace URI and local name match this
+   * element.
+   * @param uri The namespace uri, which may be null.
+   * @param localName The local name of an element, which may be null.
+   *
+   * @return true if the uri and local name arguments are considered 
+   * to match the uri and local name of this element def.
+   */
+  private boolean QNameEquals(String uri, String localName)
+  {
+
+    return (equalsMayBeNullOrZeroLen(m_namespace, uri)
+            && (equalsMayBeNullOrZeroLen(m_name, localName)
+                || equalsMayBeNullOrZeroLen(m_nameAlias, localName)));
+  }
+
+  /**
+   * Given a namespace URI, and a local name, get the processor
+   * for the element, or return null if not allowed.
+   *
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   *
+   * @return The element processor that matches the arguments, or null.
+   */
+  XSLTElementProcessor getProcessorFor(String uri, String localName) 
+	{
+
+    XSLTElementProcessor elemDef = null;  // return value
+
+    if (null == m_elements)
+      return null;
+
+    int n = m_elements.length;
+    int order = -1;
+		boolean multiAllowed = true;
+    for (int i = 0; i < n; i++)
+    {
+      XSLTElementDef def = m_elements[i];
+
+      // A "*" signals that the element allows literal result
+      // elements, so just assign the def, and continue to  
+      // see if anything else matches.
+      if (def.m_name.equals("*"))
+      {
+				
+        // Don't allow xsl elements
+        if (!equalsMayBeNullOrZeroLen(uri, Constants.S_XSLNAMESPACEURL))
+				{
+          elemDef = def.m_elementProcessor;
+				  order = def.getOrder();
+					multiAllowed = def.getMultiAllowed();
+				}
+      }
+			else if (def.QNameEquals(uri, localName))
+			{	
+				if (def.getRequired())
+					this.setRequiredFound(def.getName(), true);
+				order = def.getOrder();
+				multiAllowed = def.getMultiAllowed();
+				elemDef = def.m_elementProcessor;
+				break;
+			}
+		}		
+		
+		if (elemDef != null && this.isOrdered())
+		{			
+			int lastOrder = getLastOrder();
+			if (order > lastOrder)
+				setLastOrder(order);
+			else if (order == lastOrder && !multiAllowed)
+			{
+				return null;
+			}
+			else if (order < lastOrder && order > 0)
+			{
+				return null;
+			}
+		}
+
+    return elemDef;
+  }
+
+  /**
+   * Given an unknown element, get the processor
+   * for the element.
+   *
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   *
+   * @return normally a {@link ProcessorUnknown} reference.
+   * @see ProcessorUnknown
+   */
+  XSLTElementProcessor getProcessorForUnknown(String uri, String localName)
+  {
+
+    // XSLTElementProcessor lreDef = null; // return value
+    if (null == m_elements)
+      return null;
+
+    int n = m_elements.length;
+
+    for (int i = 0; i < n; i++)
+    {
+      XSLTElementDef def = m_elements[i];
+
+      if (def.m_name.equals("unknown") && uri.length() > 0)
+      {
+        return def.m_elementProcessor;
+      }
+    }
+
+    return null;
+  }
+
+  /**
+   * The allowed attributes for this type.
+   */
+  private XSLTAttributeDef[] m_attributes;
+
+  /**
+   * Get the allowed attributes for this type.
+   *
+   * @return An array of allowed attribute defs, or null.
+   */
+  XSLTAttributeDef[] getAttributes()
+  {
+    return m_attributes;
+  }
+
+  /**
+   * Given a namespace URI, and a local name, return the element's
+   * attribute definition, if it has one.
+   *
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   *
+   * @return The attribute def that matches the arguments, or null.
+   */
+  XSLTAttributeDef getAttributeDef(String uri, String localName)
+  {
+
+    XSLTAttributeDef defaultDef = null;
+    XSLTAttributeDef[] attrDefs = getAttributes();
+    int nAttrDefs = attrDefs.length;
+
+    for (int k = 0; k < nAttrDefs; k++)
+    {
+      XSLTAttributeDef attrDef = attrDefs[k];
+      String uriDef = attrDef.getNamespace();
+      String nameDef = attrDef.getName();
+      
+      if (nameDef.equals("*") && (equalsMayBeNullOrZeroLen(uri, uriDef) || 
+          (uriDef != null && uriDef.equals("*") && uri!=null && uri.length() > 0 )))
+      {
+        return attrDef;
+      }
+      else if (nameDef.equals("*") && (uriDef == null))
+      {
+
+        // In this case, all attributes are legal, so return 
+        // this as the last resort.
+        defaultDef = attrDef;
+      }
+      else if (equalsMayBeNullOrZeroLen(uri, uriDef)
+               && localName.equals(nameDef))
+      {
+        return attrDef;
+      }
+    }
+
+    if (null == defaultDef)
+    {
+      if (uri.length() > 0 && !equalsMayBeNullOrZeroLen(uri, Constants.S_XSLNAMESPACEURL))
+      {
+        return XSLTAttributeDef.m_foreignAttr;
+      }
+    }
+
+    return defaultDef;
+  }
+
+  /**
+   * If non-null, the ContentHandler/TransformerFactory for this element.
+   */
+  private XSLTElementProcessor m_elementProcessor;
+
+  /**
+   * Return the XSLTElementProcessor for this element.
+   *
+   * @return The element processor for this element.
+   * @xsl.usage internal
+   */
+  public XSLTElementProcessor getElementProcessor()
+  {
+    return m_elementProcessor;
+  }
+
+  /**
+   * Set the XSLTElementProcessor for this element.
+   *
+   * @param handler The element processor for this element.
+   * @xsl.usage internal
+   */
+  public void setElementProcessor(XSLTElementProcessor handler)
+  {
+
+    if (handler != null)
+    {
+      m_elementProcessor = handler;
+
+      m_elementProcessor.setElemDef(this);
+    }
+  }
+
+  /**
+   * If non-null, the class object that should in instantiated for
+   * a Xalan instance of this element.
+   */
+  private Class m_classObject;
+
+  /**
+   * Return the class object that should in instantiated for
+   * a Xalan instance of this element.
+   *
+   * @return The class of the object that this element def should produce, or null.
+   */
+  Class getClassObject()
+  {
+    return m_classObject;
+  }
+	
+	/**
+   * If true, this has a required element.
+   */
+  private boolean m_has_required = false;
+
+  /**
+   * Get whether or not this has a required element.
+   *
+   * @return true if this this has a required element.
+   */
+  boolean hasRequired()
+  {
+    return m_has_required;
+  }
+	
+	/**
+   * If true, this is a required element.
+   */
+  private boolean m_required = false;
+
+  /**
+   * Get whether or not this is a required element.
+   *
+   * @return true if this is a required element.
+   */
+  boolean getRequired()
+  {
+    return m_required;
+  }
+	
+	Hashtable m_requiredFound;
+	
+	/**
+   * Set this required element found.
+   *
+   */
+  void setRequiredFound(String elem, boolean found)
+  {
+   if (m_requiredFound.get(elem) != null) 
+		 m_requiredFound.remove(elem);
+  }
+	
+	/**
+   * Get whether all required elements were found.
+   *
+   * @return true if all required elements were found.
+   */
+  boolean getRequiredFound()
+  {
+		if (m_requiredFound == null)
+			return true;
+    return m_requiredFound.isEmpty();
+  }
+	
+	/**
+   * Get required elements that were not found.
+   *
+   * @return required elements that were not found.
+   */
+  String getRequiredElem()
+  {
+		if (m_requiredFound == null)
+			return null;
+		Enumeration elems = m_requiredFound.elements();
+		String s = "";
+		boolean first = true;
+		while (elems.hasMoreElements())
+		{
+			if (first)
+				first = false;
+			else
+			 s = s + ", ";
+			s = s + (String)elems.nextElement();
+		}
+    return s;
+  }
+	
+	boolean m_isOrdered = false;	
+	
+	/**
+   * Get whether this element requires ordered children.
+   *
+   * @return true if this element requires ordered children.
+   */
+  boolean isOrdered()
+  {
+		/*if (!m_CheckedOrdered)
+		{
+			m_CheckedOrdered = true;
+			m_isOrdered = false;
+			if (null == m_elements)
+				return false;
+
+			int n = m_elements.length;
+
+			for (int i = 0; i < n; i++)
+			{
+				if (m_elements[i].getOrder() > 0)
+				{
+					m_isOrdered = true;
+					return true;
+				}
+			}
+			return false;
+		}
+		else*/
+			return m_isOrdered;
+  }
+	
+	/**
+   * the order that this element should appear, or -1 if not ordered
+   */
+  private int m_order = -1;
+	
+	/**
+   * Get the order that this element should appear .
+   *
+   * @return the order that this element should appear.
+   */
+  int getOrder()
+  {
+    return m_order;
+  }
+	
+	/**
+   * the highest order of child elements have appeared so far, 
+   * or -1 if not ordered
+   */
+  private int m_lastOrder = -1;
+	
+	/**
+   * Get the highest order of child elements have appeared so far .
+   *
+   * @return the highest order of child elements have appeared so far.
+   */
+  int getLastOrder()
+  {
+    return m_lastOrder;
+  }
+	
+	/**
+   * Set the highest order of child elements have appeared so far .
+   *
+   * @param order the highest order of child elements have appeared so far.
+   */
+  void setLastOrder(int order)
+  {
+    m_lastOrder = order ;
+  }
+	
+	/**
+   * True if this element can appear multiple times
+   */
+  private boolean m_multiAllowed = true;
+	
+	/**
+   * Get whether this element can appear multiple times
+   *
+   * @return true if this element can appear multiple times
+   */
+  boolean getMultiAllowed()
+  {
+    return m_multiAllowed;
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/XSLTElementProcessor.java b/src/main/java/org/apache/xalan/processor/XSLTElementProcessor.java
new file mode 100644
index 0000000..7858b42
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/XSLTElementProcessor.java
@@ -0,0 +1,383 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: XSLTElementProcessor.java 469688 2006-10-31 22:39:43Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Vector;
+
+import javax.xml.transform.TransformerException;
+
+import org.apache.xalan.res.XSLMessages;
+import org.apache.xalan.res.XSLTErrorResources;
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xml.utils.IntStack;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * This class acts as the superclass for all stylesheet element
+ * processors, and deals with things that are common to all elements.
+ * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
+ */
+public class XSLTElementProcessor extends ElemTemplateElement
+{
+    static final long serialVersionUID = 5597421564955304421L;
+
+  /**
+   * Construct a processor for top-level elements.
+   * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
+   */
+  XSLTElementProcessor(){}
+	
+	private IntStack m_savedLastOrder;
+
+  /**
+   * The element definition that this processor conforms to.
+   */
+  private XSLTElementDef m_elemDef;
+
+  /**
+   * Get the element definition that belongs to this element.
+   *
+   * @return The element definition object that produced and constrains this element.
+   */
+  XSLTElementDef getElemDef()
+  {
+    return m_elemDef;
+  }
+
+  /**
+   * Set the element definition that belongs to this element.
+   *
+   * @param def The element definition object that produced and constrains this element.
+   */
+  void setElemDef(XSLTElementDef def)
+  {
+    m_elemDef = def;
+  }
+
+  /**
+   * Resolve an external entity.
+   *
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @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.
+   */
+  public InputSource resolveEntity(
+          StylesheetHandler handler, String publicId, String systemId)
+            throws org.xml.sax.SAXException
+  {
+    return null;
+  }
+
+  /**
+   * Receive notification of a notation declaration.
+   *
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param name The notation name.
+   * @param publicId The notation public identifier, or null if not
+   *                 available.
+   * @param systemId The notation system identifier.
+   * @see org.xml.sax.DTDHandler#notationDecl
+   */
+  public void notationDecl(StylesheetHandler handler, String name,
+                           String publicId, String systemId)
+  {
+
+    // no op
+  }
+
+  /**
+   * Receive notification of an unparsed entity declaration.
+   *
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @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.
+   * @see org.xml.sax.DTDHandler#unparsedEntityDecl
+   */
+  public void unparsedEntityDecl(StylesheetHandler handler, String name,
+                                 String publicId, String systemId,
+                                 String notationName)
+  {
+
+    // no op
+  }
+
+  /**
+   * Receive notification of the start of the non-text event.  This
+   * is sent to the current processor when any non-text event occurs.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   */
+  public void startNonText(StylesheetHandler handler) throws org.xml.sax.SAXException
+  {
+
+    // no op
+  }
+
+  /**
+   * Receive notification of the start of an element.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   * @param attributes The specified or defaulted attributes.
+   */
+  public void startElement(
+          StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
+            throws org.xml.sax.SAXException
+  {
+
+    if (m_savedLastOrder == null)
+				m_savedLastOrder = new IntStack();
+			m_savedLastOrder.push(getElemDef().getLastOrder());
+			getElemDef().setLastOrder(-1);
+  }
+
+  /**
+   * Receive notification of the end of an element.
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param uri The Namespace URI, or an empty string.
+   * @param localName The local name (without prefix), or empty string if not namespace processing.
+   * @param rawName The qualified name (with prefix).
+   */
+  public void endElement(
+          StylesheetHandler handler, String uri, String localName, String rawName)
+            throws org.xml.sax.SAXException
+  {
+		if (m_savedLastOrder != null && !m_savedLastOrder.empty())
+			getElemDef().setLastOrder(m_savedLastOrder.pop());
+		
+		if (!getElemDef().getRequiredFound())
+			handler.error(XSLTErrorResources.ER_REQUIRED_ELEM_NOT_FOUND, new Object[]{getElemDef().getRequiredElem()}, null);
+  }
+
+  /**
+   * Receive notification of character data inside an element.
+   *
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @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.
+   */
+  public void characters(
+          StylesheetHandler handler, char ch[], int start, int length)
+            throws org.xml.sax.SAXException
+  {
+    handler.error(XSLTErrorResources.ER_CHARS_NOT_ALLOWED, null, null);//"Characters are not allowed at this point in the document!",
+                  //null);
+  }
+
+  /**
+   * Receive notification of ignorable whitespace in element content.
+   *
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @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.
+   */
+  public void ignorableWhitespace(
+          StylesheetHandler handler, char ch[], int start, int length)
+            throws org.xml.sax.SAXException
+  {
+
+    // no op
+  }
+
+  /**
+   * Receive notification of a processing instruction.
+   *
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param target The processing instruction target.
+   * @param data The processing instruction data, or null if
+   *             none is supplied.
+   */
+  public void processingInstruction(
+          StylesheetHandler handler, String target, String data)
+            throws org.xml.sax.SAXException
+  {
+
+    // no op
+  }
+
+  /**
+   * Receive notification of a skipped entity.
+   *
+   *
+   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
+   * @param name The name of the skipped entity.
+   */
+  public void skippedEntity(StylesheetHandler handler, String name)
+          throws org.xml.sax.SAXException
+  {
+
+    // no op
+  }
+
+  /**
+   * Set the properties of an object from the given attribute list.
+   * @param handler The stylesheet's Content handler, needed for
+   *                error reporting.
+   * @param rawName The raw name of the owner element, needed for
+   *                error reporting.
+   * @param attributes The list of attributes.
+   * @param target The target element where the properties will be set.
+   */
+  void setPropertiesFromAttributes(
+          StylesheetHandler handler, String rawName, Attributes attributes, 
+          ElemTemplateElement target)
+            throws org.xml.sax.SAXException
+  {
+    setPropertiesFromAttributes(handler, rawName, attributes, target, true);
+  }
+
+  /**
+   * Set the properties of an object from the given attribute list.
+   * @param handler The stylesheet's Content handler, needed for
+   *                error reporting.
+   * @param rawName The raw name of the owner element, needed for
+   *                error reporting.
+   * @param attributes The list of attributes.
+   * @param target The target element where the properties will be set.
+   * @param throwError True if it should throw an error if an
+   * attribute is not defined.
+   * @return the attributes not allowed on this element.
+   *
+   * @throws TransformerException
+   */
+  Attributes setPropertiesFromAttributes(
+          StylesheetHandler handler, String rawName, Attributes attributes, 
+          ElemTemplateElement target, boolean throwError)
+            throws org.xml.sax.SAXException
+  {
+
+    XSLTElementDef def = getElemDef();
+    AttributesImpl undefines = null;
+    boolean isCompatibleMode = ((null != handler.getStylesheet() 
+                                 && handler.getStylesheet().getCompatibleMode())
+                                || !throwError);
+    if (isCompatibleMode)
+      undefines = new AttributesImpl();
+
+
+    // Keep track of which XSLTAttributeDefs have been processed, so 
+    // I can see which default values need to be set.
+    List processedDefs = new ArrayList();
+
+    // Keep track of XSLTAttributeDefs that were invalid
+    List errorDefs = new ArrayList();    
+    int nAttrs = attributes.getLength();
+
+    for (int i = 0; i < nAttrs; i++)
+    {
+      String attrUri = attributes.getURI(i);
+      // Hack for Crimson.  -sb
+      if((null != attrUri) && (attrUri.length() == 0)
+                           && (attributes.getQName(i).startsWith("xmlns:") || 
+                               attributes.getQName(i).equals("xmlns")))
+      {
+        attrUri = org.apache.xalan.templates.Constants.S_XMLNAMESPACEURI;
+      }
+      String attrLocalName = attributes.getLocalName(i);
+      XSLTAttributeDef attrDef = def.getAttributeDef(attrUri, attrLocalName);
+
+      if (null == attrDef)
+      {
+        if (!isCompatibleMode)
+        {
+
+          // Then barf, because this element does not allow this attribute.
+          handler.error(XSLTErrorResources.ER_ATTR_NOT_ALLOWED, new Object[]{attributes.getQName(i), rawName}, null);//"\""+attributes.getQName(i)+"\""
+                        //+ " attribute is not allowed on the " + rawName
+                       // + " element!", null);
+        }
+        else
+        {
+          undefines.addAttribute(attrUri, attrLocalName,
+                                 attributes.getQName(i),
+                                 attributes.getType(i),
+                                 attributes.getValue(i));
+        }
+      }
+      else
+      {
+        // Can we switch the order here:
+
+        boolean success = attrDef.setAttrValue(handler, attrUri, attrLocalName,
+                             attributes.getQName(i), attributes.getValue(i),
+                             target);
+                             
+        // Now we only add the element if it passed a validation check
+        if (success)
+            processedDefs.add(attrDef);
+        else
+            errorDefs.add(attrDef);
+      }
+    }
+
+    XSLTAttributeDef[] attrDefs = def.getAttributes();
+    int nAttrDefs = attrDefs.length;
+
+    for (int i = 0; i < nAttrDefs; i++)
+    {
+      XSLTAttributeDef attrDef = attrDefs[i];
+      String defVal = attrDef.getDefault();
+
+      if (null != defVal)
+      {
+        if (!processedDefs.contains(attrDef))
+        {
+          attrDef.setDefAttrValue(handler, target);
+        }
+      }
+
+      if (attrDef.getRequired())
+      {
+        if ((!processedDefs.contains(attrDef)) && (!errorDefs.contains(attrDef)))
+          handler.error(
+            XSLMessages.createMessage(
+              XSLTErrorResources.ER_REQUIRES_ATTRIB, new Object[]{ rawName,
+                                                                   attrDef.getName() }), null);
+      }
+    }
+
+    return undefines;
+  }
+}
diff --git a/src/main/java/org/apache/xalan/processor/XSLTSchema.java b/src/main/java/org/apache/xalan/processor/XSLTSchema.java
new file mode 100644
index 0000000..8f6eb2e
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/XSLTSchema.java
@@ -0,0 +1,922 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: XSLTSchema.java 476466 2006-11-18 08:22:31Z minchau $
+ */
+package org.apache.xalan.processor;
+
+import java.util.HashMap;
+
+import org.apache.xalan.templates.Constants;
+import org.apache.xalan.templates.ElemApplyImport;
+import org.apache.xalan.templates.ElemApplyTemplates;
+import org.apache.xalan.templates.ElemAttribute;
+import org.apache.xalan.templates.ElemCallTemplate;
+import org.apache.xalan.templates.ElemChoose;
+import org.apache.xalan.templates.ElemComment;
+import org.apache.xalan.templates.ElemCopy;
+import org.apache.xalan.templates.ElemCopyOf;
+import org.apache.xalan.templates.ElemElement;
+import org.apache.xalan.templates.ElemExsltFuncResult;
+import org.apache.xalan.templates.ElemExsltFunction;
+import org.apache.xalan.templates.ElemExtensionDecl;
+import org.apache.xalan.templates.ElemExtensionScript;
+import org.apache.xalan.templates.ElemFallback;
+import org.apache.xalan.templates.ElemForEach;
+import org.apache.xalan.templates.ElemIf;
+import org.apache.xalan.templates.ElemLiteralResult;
+import org.apache.xalan.templates.ElemMessage;
+import org.apache.xalan.templates.ElemNumber;
+import org.apache.xalan.templates.ElemOtherwise;
+import org.apache.xalan.templates.ElemPI;
+import org.apache.xalan.templates.ElemParam;
+import org.apache.xalan.templates.ElemSort;
+import org.apache.xalan.templates.ElemTemplate;
+import org.apache.xalan.templates.ElemText;
+import org.apache.xalan.templates.ElemTextLiteral;
+import org.apache.xalan.templates.ElemUnknown;
+import org.apache.xalan.templates.ElemValueOf;
+import org.apache.xalan.templates.ElemVariable;
+import org.apache.xalan.templates.ElemWhen;
+import org.apache.xalan.templates.ElemWithParam;
+import org.apache.xml.utils.QName;
+
+/**
+ * This class defines the allowed structure for a stylesheet, and the
+ * mapping between Xalan classes and the markup elements in the stylesheet.
+ * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
+ */
+public class XSLTSchema extends XSLTElementDef
+{
+
+  /**
+   * Construct a XSLTSchema which represents the XSLT "schema".
+   */
+  XSLTSchema()
+  {
+    build();
+  }
+
+  /**
+   * This method builds an XSLT "schema" according to http://www.w3.org/TR/xslt#dtd.  This
+   * schema provides instructions for building the Xalan Stylesheet (Templates) structure.
+   */
+  void build()
+  {
+	// xsl:import, xsl:include
+    XSLTAttributeDef hrefAttr = new XSLTAttributeDef(null, "href",
+                                  XSLTAttributeDef.T_URL, true, false,XSLTAttributeDef.ERROR);
+                                  
+	// xsl:preserve-space, xsl:strip-space
+    XSLTAttributeDef elementsAttr = new XSLTAttributeDef(null, "elements",
+                                      XSLTAttributeDef.T_SIMPLEPATTERNLIST,
+                                      true, false, XSLTAttributeDef.ERROR);
+                                      
+    // XSLTAttributeDef anyNamespacedAttr = new XSLTAttributeDef("*", "*",
+    //                                XSLTAttributeDef.T_CDATA, false);
+    
+    // xsl:output
+    XSLTAttributeDef methodAttr = new XSLTAttributeDef(null, "method",
+                                    XSLTAttributeDef.T_QNAME, false, false,XSLTAttributeDef.ERROR);
+    XSLTAttributeDef versionAttr = new XSLTAttributeDef(null, "version",
+                                     XSLTAttributeDef.T_NMTOKEN, false, false,XSLTAttributeDef.ERROR);
+    XSLTAttributeDef encodingAttr = new XSLTAttributeDef(null, "encoding",
+                                      XSLTAttributeDef.T_CDATA, false, false,XSLTAttributeDef.ERROR);
+    XSLTAttributeDef omitXmlDeclarationAttr = new XSLTAttributeDef(null,
+                                                "omit-xml-declaration",
+                                                XSLTAttributeDef.T_YESNO,
+                                                false, false,XSLTAttributeDef.ERROR);
+    XSLTAttributeDef standaloneAttr = new XSLTAttributeDef(null,
+                                        "standalone",
+                                        XSLTAttributeDef.T_YESNO, false, false,XSLTAttributeDef.ERROR);
+    XSLTAttributeDef doctypePublicAttr = new XSLTAttributeDef(null,
+                                           "doctype-public",
+                                           XSLTAttributeDef.T_CDATA, false, false,XSLTAttributeDef.ERROR);
+    XSLTAttributeDef doctypeSystemAttr = new XSLTAttributeDef(null,
+                                           "doctype-system",
+                                           XSLTAttributeDef.T_CDATA, false, false,XSLTAttributeDef.ERROR);
+    XSLTAttributeDef cdataSectionElementsAttr = new XSLTAttributeDef(null,
+                                                  "cdata-section-elements",
+                                                  XSLTAttributeDef.T_QNAMES_RESOLVE_NULL,
+                                                  false, false,XSLTAttributeDef.ERROR);
+    XSLTAttributeDef indentAttr = new XSLTAttributeDef(null, "indent",
+                                    XSLTAttributeDef.T_YESNO, false, false,XSLTAttributeDef.ERROR);
+    XSLTAttributeDef mediaTypeAttr = new XSLTAttributeDef(null, "media-type",
+                                       XSLTAttributeDef.T_CDATA, false, false,XSLTAttributeDef.ERROR);
+                                       
+                  
+    // Required.
+    // It is an error if the name attribute is invalid on any of these elements
+    // xsl:key, xsl:attribute-set, xsl:call-template, xsl:with-param, xsl:variable, xsl:param
+    XSLTAttributeDef nameAttrRequired = new XSLTAttributeDef(null, "name",
+                                          XSLTAttributeDef.T_QNAME, true, false,XSLTAttributeDef.ERROR);
+	// Required.
+    // Support AVT
+    // xsl:element, xsl:attribute                                    
+    XSLTAttributeDef nameAVTRequired = new XSLTAttributeDef(null, "name",
+                                         XSLTAttributeDef.T_AVT_QNAME, true, true,XSLTAttributeDef.WARNING);
+            
+
+    // Required.
+    // Support AVT
+    // xsl:processing-instruction                                     
+    XSLTAttributeDef nameAVT_NCNAMERequired = new XSLTAttributeDef(null, "name",
+                                         XSLTAttributeDef.T_NCNAME, true, true,XSLTAttributeDef.WARNING);
+                                        
+    // Optional.
+    // Static error if invalid
+    // xsl:template, xsl:decimal-format                                      
+    XSLTAttributeDef nameAttrOpt_ERROR = new XSLTAttributeDef(null, "name",
+                                     XSLTAttributeDef.T_QNAME, false, false,XSLTAttributeDef.ERROR);
+
+    // xsl:key                                 
+    XSLTAttributeDef useAttr = new XSLTAttributeDef(null, "use",
+                                 XSLTAttributeDef.T_EXPR, true, false,XSLTAttributeDef.ERROR);
+           
+    // xsl:element, xsl:attribute                              
+    XSLTAttributeDef namespaceAVTOpt = new XSLTAttributeDef(null,
+                                         "namespace",XSLTAttributeDef.T_URL,
+                                         false, true,XSLTAttributeDef.WARNING);
+    // xsl:decimal-format                                     
+    XSLTAttributeDef decimalSeparatorAttr = new XSLTAttributeDef(null,
+                                              "decimal-separator",
+                                              XSLTAttributeDef.T_CHAR, false,XSLTAttributeDef.ERROR, ".");
+    XSLTAttributeDef infinityAttr = new XSLTAttributeDef(null, "infinity",
+                                      XSLTAttributeDef.T_CDATA, false,XSLTAttributeDef.ERROR,"Infinity");
+    XSLTAttributeDef minusSignAttr = new XSLTAttributeDef(null, "minus-sign",
+                                       XSLTAttributeDef.T_CHAR, false,XSLTAttributeDef.ERROR,"-");
+    XSLTAttributeDef NaNAttr = new XSLTAttributeDef(null, "NaN",
+                                 XSLTAttributeDef.T_CDATA, false,XSLTAttributeDef.ERROR, "NaN");
+    XSLTAttributeDef percentAttr = new XSLTAttributeDef(null, "percent",
+                                     XSLTAttributeDef.T_CHAR, false,XSLTAttributeDef.ERROR, "%");
+    XSLTAttributeDef perMilleAttr = new XSLTAttributeDef(null, "per-mille",
+                                      XSLTAttributeDef.T_CHAR,
+                                      false, false,XSLTAttributeDef.ERROR /* ,"&#x2030;" */);
+    XSLTAttributeDef zeroDigitAttr = new XSLTAttributeDef(null, "zero-digit",
+                                       XSLTAttributeDef.T_CHAR, false,XSLTAttributeDef.ERROR, "0");
+    XSLTAttributeDef digitAttr = new XSLTAttributeDef(null, "digit",
+                                   XSLTAttributeDef.T_CHAR, false,XSLTAttributeDef.ERROR, "#");
+    XSLTAttributeDef patternSeparatorAttr = new XSLTAttributeDef(null,
+                                              "pattern-separator",
+                                              XSLTAttributeDef.T_CHAR, false,XSLTAttributeDef.ERROR, ";");
+    // xsl:decimal-format                                         
+    XSLTAttributeDef groupingSeparatorAttr = new XSLTAttributeDef(null,
+                                               "grouping-separator",
+                                               XSLTAttributeDef.T_CHAR, false,XSLTAttributeDef.ERROR,",");
+
+                                              
+    // xsl:element, xsl:attribute-set, xsl:copy                                           
+    XSLTAttributeDef useAttributeSetsAttr = new XSLTAttributeDef(null,
+                                              "use-attribute-sets",
+                                              XSLTAttributeDef.T_QNAMES,
+                                              false, false, XSLTAttributeDef.ERROR);
+
+    // xsl:if, xsl:when         
+    XSLTAttributeDef testAttrRequired = new XSLTAttributeDef(null, "test",   
+                                          XSLTAttributeDef.T_EXPR, true, false,XSLTAttributeDef.ERROR);
+      
+      
+    // Required.                                       
+    // xsl:value-of, xsl:for-each, xsl:copy-of                             
+    XSLTAttributeDef selectAttrRequired = new XSLTAttributeDef(null,
+                                            "select",
+                                            XSLTAttributeDef.T_EXPR, true, false,XSLTAttributeDef.ERROR);
+
+    // Optional.                                          
+    // xsl:variable, xsl:param, xsl:with-param                                       
+    XSLTAttributeDef selectAttrOpt = new XSLTAttributeDef(null, "select",
+                                       XSLTAttributeDef.T_EXPR, false, false,XSLTAttributeDef.ERROR);
+
+    // Optional.
+    // Default: "node()"
+    // xsl:apply-templates                                           
+    XSLTAttributeDef selectAttrDefNode = new XSLTAttributeDef(null, "select",
+                                           XSLTAttributeDef.T_EXPR, false,XSLTAttributeDef.ERROR, "node()");
+    // Optional.
+    // Default: "."
+    // xsl:sort                                        
+    XSLTAttributeDef selectAttrDefDot = new XSLTAttributeDef(null, "select",
+                                          XSLTAttributeDef.T_EXPR, false,XSLTAttributeDef.ERROR, ".");
+    // xsl:key                                      
+    XSLTAttributeDef matchAttrRequired = new XSLTAttributeDef(null, "match",
+                                           XSLTAttributeDef.T_PATTERN, true, false,XSLTAttributeDef.ERROR);
+    // xsl:template                                       
+    XSLTAttributeDef matchAttrOpt = new XSLTAttributeDef(null, "match",
+                                      XSLTAttributeDef.T_PATTERN, false, false,XSLTAttributeDef.ERROR);
+    // xsl:template                                  
+    XSLTAttributeDef priorityAttr = new XSLTAttributeDef(null, "priority",
+                                     XSLTAttributeDef.T_NUMBER, false, false,XSLTAttributeDef.ERROR);
+                                     
+    // xsl:template, xsl:apply-templates                                 
+    XSLTAttributeDef modeAttr = new XSLTAttributeDef(null, "mode",
+                                     XSLTAttributeDef.T_QNAME, false, false,XSLTAttributeDef.ERROR);
+   
+    XSLTAttributeDef spaceAttr =
+      new XSLTAttributeDef(Constants.S_XMLNAMESPACEURI, "space", false, false, false, XSLTAttributeDef.WARNING,
+                           "default", Constants.ATTRVAL_STRIP, "preserve",
+                           Constants.ATTRVAL_PRESERVE);
+                           
+                         
+    XSLTAttributeDef spaceAttrLiteral =
+      new XSLTAttributeDef(Constants.S_XMLNAMESPACEURI, "space", 
+                                          XSLTAttributeDef.T_URL, false, true,XSLTAttributeDef.ERROR);
+    // xsl:namespace-alias                                      
+    XSLTAttributeDef stylesheetPrefixAttr = new XSLTAttributeDef(null,
+                                              "stylesheet-prefix",
+                                              XSLTAttributeDef.T_CDATA, true, false,XSLTAttributeDef.ERROR);
+    XSLTAttributeDef resultPrefixAttr = new XSLTAttributeDef(null,
+                                          "result-prefix",
+                                          XSLTAttributeDef.T_CDATA, true, false,XSLTAttributeDef.ERROR);
+                                          
+    // xsl:text, xsl:value-of                                      
+    XSLTAttributeDef disableOutputEscapingAttr = new XSLTAttributeDef(null,
+                                                   "disable-output-escaping",
+                                                   XSLTAttributeDef.T_YESNO,
+                                                   false, false,XSLTAttributeDef.ERROR);
+                                                   
+	// xsl:number                                                   
+    XSLTAttributeDef levelAttr = new XSLTAttributeDef(null, "level", false, false, false, XSLTAttributeDef.ERROR,
+                                   "single", Constants.NUMBERLEVEL_SINGLE,
+                                   "multiple", Constants.NUMBERLEVEL_MULTI,
+                                   "any", Constants.NUMBERLEVEL_ANY);
+    levelAttr.setDefault("single");
+    XSLTAttributeDef countAttr = new XSLTAttributeDef(null, "count",
+                                   XSLTAttributeDef.T_PATTERN, false, false,XSLTAttributeDef.ERROR);
+    XSLTAttributeDef fromAttr = new XSLTAttributeDef(null, "from",
+                                  XSLTAttributeDef.T_PATTERN, false, false,XSLTAttributeDef.ERROR);
+    XSLTAttributeDef valueAttr = new XSLTAttributeDef(null, "value",
+                                   XSLTAttributeDef.T_EXPR, false, false,XSLTAttributeDef.ERROR);
+    XSLTAttributeDef formatAttr = new XSLTAttributeDef(null, "format",
+                                    XSLTAttributeDef.T_CDATA, false, true,XSLTAttributeDef.ERROR);
+    formatAttr.setDefault("1");
+    
+    // xsl:number, xsl:sort
+    XSLTAttributeDef langAttr = new XSLTAttributeDef(null, "lang",
+                                  XSLTAttributeDef.T_NMTOKEN, false, true,XSLTAttributeDef.ERROR);
+   
+    // xsl:number
+    XSLTAttributeDef letterValueAttr = new XSLTAttributeDef(null,
+                                         "letter-value",
+                                         false, true, false, XSLTAttributeDef.ERROR,
+                                         "alphabetic", Constants.NUMBERLETTER_ALPHABETIC,
+                                         "traditional", Constants.NUMBERLETTER_TRADITIONAL);
+    // xsl:number
+    XSLTAttributeDef groupingSeparatorAVT = new XSLTAttributeDef(null,
+                                              "grouping-separator",
+                                              XSLTAttributeDef.T_CHAR, false, true,XSLTAttributeDef.ERROR);
+    // xsl:number
+    XSLTAttributeDef groupingSizeAttr = new XSLTAttributeDef(null,
+                                          "grouping-size",
+                                          XSLTAttributeDef.T_NUMBER, false, true,XSLTAttributeDef.ERROR);
+   
+   // xsl:sort
+    XSLTAttributeDef dataTypeAttr = new XSLTAttributeDef(null, "data-type", false, true, true, XSLTAttributeDef.ERROR,
+                                    "text", Constants.SORTDATATYPE_TEXT ,"number", Constants.SORTDATATYPE_TEXT);
+	dataTypeAttr.setDefault("text");
+	
+	// xsl:sort
+    XSLTAttributeDef orderAttr = new XSLTAttributeDef(null, "order", false, true, false,XSLTAttributeDef.ERROR,
+                                    "ascending", Constants.SORTORDER_ASCENDING, 
+                                    "descending", Constants.SORTORDER_DESCENDING);
+    orderAttr.setDefault("ascending");
+
+    // xsl:sort                             
+    XSLTAttributeDef caseOrderAttr = new XSLTAttributeDef(null, "case-order", false, true, false,XSLTAttributeDef.ERROR,
+                                       "upper-first", Constants.SORTCASEORDER_UPPERFIRST ,
+                                       "lower-first", Constants.SORTCASEORDER_LOWERFIRST);
+	    
+    // xsl:message                                   
+    XSLTAttributeDef terminateAttr = new XSLTAttributeDef(null, "terminate",
+                                       XSLTAttributeDef.T_YESNO, false, false,XSLTAttributeDef.ERROR);
+    terminateAttr.setDefault("no");
+
+	// top level attributes
+    XSLTAttributeDef xslExcludeResultPrefixesAttr =
+      new XSLTAttributeDef(Constants.S_XSLNAMESPACEURL,
+                           "exclude-result-prefixes",
+                           XSLTAttributeDef.T_PREFIXLIST, false, false,XSLTAttributeDef.ERROR);
+    XSLTAttributeDef xslExtensionElementPrefixesAttr =
+      new XSLTAttributeDef(Constants.S_XSLNAMESPACEURL,
+                           "extension-element-prefixes",
+                           XSLTAttributeDef.T_PREFIX_URLLIST, false, false,XSLTAttributeDef.ERROR);
+    // result-element-atts                       
+    XSLTAttributeDef xslUseAttributeSetsAttr =
+      new XSLTAttributeDef(Constants.S_XSLNAMESPACEURL, "use-attribute-sets",
+                           XSLTAttributeDef.T_QNAMES, false, false,XSLTAttributeDef.ERROR);
+    XSLTAttributeDef xslVersionAttr =
+      new XSLTAttributeDef(Constants.S_XSLNAMESPACEURL, "version",
+                           XSLTAttributeDef.T_NMTOKEN, false, false,XSLTAttributeDef.ERROR);
+                           
+    XSLTElementDef charData = new XSLTElementDef(this, null, "text()",
+                                null /*alias */, null /* elements */, null,  /* attributes */
+                                new ProcessorCharacters(),
+                                ElemTextLiteral.class /* class object */);
+
+    charData.setType(XSLTElementDef.T_PCDATA);
+
+    XSLTElementDef whiteSpaceOnly = new XSLTElementDef(this, null, "text()",
+                                      null /*alias */, null /* elements */,
+                                      null,  /* attributes */
+                                      null,
+                                      ElemTextLiteral.class /* should be null? -sb */);
+
+    charData.setType(XSLTElementDef.T_PCDATA);
+
+    XSLTAttributeDef resultAttr = new XSLTAttributeDef(null, "*",
+                                    XSLTAttributeDef.T_AVT, false, true,XSLTAttributeDef.WARNING);
+    XSLTAttributeDef xslResultAttr =
+      new XSLTAttributeDef(Constants.S_XSLNAMESPACEURL, "*",
+                           XSLTAttributeDef.T_CDATA, false, false,XSLTAttributeDef.WARNING);
+                           
+    XSLTElementDef[] templateElements = new XSLTElementDef[23];
+    XSLTElementDef[] templateElementsAndParams = new XSLTElementDef[24];
+    XSLTElementDef[] templateElementsAndSort = new XSLTElementDef[24];
+    //exslt
+    XSLTElementDef[] exsltFunctionElements = new XSLTElementDef[24];
+    
+    XSLTElementDef[] charTemplateElements = new XSLTElementDef[15];
+    XSLTElementDef resultElement = new XSLTElementDef(this, null, "*",
+                                     null /*alias */,
+                                     templateElements /* elements */,
+                                     new XSLTAttributeDef[]{
+                                       spaceAttrLiteral, // special
+                                       xslExcludeResultPrefixesAttr,
+                                       xslExtensionElementPrefixesAttr,
+                                       xslUseAttributeSetsAttr,
+                                       xslVersionAttr,
+                                       xslResultAttr,
+                                       resultAttr }, 
+                                        new ProcessorLRE(),
+                                     ElemLiteralResult.class /* class object */, 20, true);
+    XSLTElementDef unknownElement =
+      new XSLTElementDef(this, "*", "unknown", null /*alias */,
+                         templateElementsAndParams /* elements */,
+                         new XSLTAttributeDef[]{ xslExcludeResultPrefixesAttr,
+                                                 xslExtensionElementPrefixesAttr,
+                                                 xslUseAttributeSetsAttr,
+                                                 xslVersionAttr,
+                                                 xslResultAttr,
+                                                 resultAttr }, 
+                                                                                                 new ProcessorUnknown(),
+                         ElemUnknown.class /* class object */, 20, true);
+    XSLTElementDef xslValueOf = new XSLTElementDef(this,
+                                  Constants.S_XSLNAMESPACEURL, "value-of",
+                                  null /*alias */, null /* elements */,
+                                  new XSLTAttributeDef[]{ selectAttrRequired,
+                                                          disableOutputEscapingAttr }, 
+                                               new ProcessorTemplateElem(),
+                                  ElemValueOf.class /* class object */, 20, true);
+    XSLTElementDef xslCopyOf = new XSLTElementDef(this,
+                                 Constants.S_XSLNAMESPACEURL, "copy-of",
+                                 null /*alias */, null /* elements */,
+                                 new XSLTAttributeDef[]{ selectAttrRequired },
+                                 new ProcessorTemplateElem(),
+                                 ElemCopyOf.class /* class object */, 20, true);
+    XSLTElementDef xslNumber = new XSLTElementDef(this,
+                                 Constants.S_XSLNAMESPACEURL, "number",
+                                 null /*alias */, null /* elements */,
+                                 new XSLTAttributeDef[]{ levelAttr,
+                                                         countAttr,
+                                                         fromAttr,
+                                                         valueAttr,
+                                                         formatAttr,
+                                                         langAttr,
+                                                         letterValueAttr,
+                                                         groupingSeparatorAVT,
+                                                         groupingSizeAttr }, 
+                                        new ProcessorTemplateElem(),
+                                 ElemNumber.class /* class object */, 20, true);
+
+    // <!-- xsl:sort cannot occur after any other elements or
+    // any non-whitespace character -->
+    XSLTElementDef xslSort = new XSLTElementDef(this,
+                                                Constants.S_XSLNAMESPACEURL,
+                                                "sort", null /*alias */,
+                                                null /* elements */,
+                                                new XSLTAttributeDef[]{
+                                                  selectAttrDefDot,
+                                                  langAttr,
+                                                  dataTypeAttr,
+                                                  orderAttr,
+                                                  caseOrderAttr }, 
+                                       new ProcessorTemplateElem(),
+                                                ElemSort.class/* class object */, 19, true );
+    XSLTElementDef xslWithParam = new XSLTElementDef(this,
+                                    Constants.S_XSLNAMESPACEURL,
+                                    "with-param", null /*alias */,
+                                    templateElements /* elements */,  // %template;>
+                                    new XSLTAttributeDef[]{ nameAttrRequired,
+                                                            selectAttrOpt }, new ProcessorTemplateElem(),
+                                                                             ElemWithParam.class /* class object */, 19, true);
+    XSLTElementDef xslApplyTemplates = new XSLTElementDef(this,
+                                         Constants.S_XSLNAMESPACEURL,
+                                         "apply-templates", null /*alias */,
+                                         new XSLTElementDef[]{ xslSort,
+                                                               xslWithParam } /* elements */, new XSLTAttributeDef[]{
+                                                                 selectAttrDefNode,
+                                                                 modeAttr }, 
+                                                                        new ProcessorTemplateElem(),
+                                         ElemApplyTemplates.class /* class object */, 20, true);
+    XSLTElementDef xslApplyImports =
+      new XSLTElementDef(this, Constants.S_XSLNAMESPACEURL, "apply-imports",
+                         null /*alias */, null /* elements */,
+                         new XSLTAttributeDef[]{},
+                         new ProcessorTemplateElem(),
+                         ElemApplyImport.class /* class object */);
+    XSLTElementDef xslForEach = new XSLTElementDef(this,
+                                  Constants.S_XSLNAMESPACEURL, "for-each",
+                                  null /*alias */, templateElementsAndSort,  // (#PCDATA %instructions; %result-elements; | xsl:sort)*
+                                  new XSLTAttributeDef[]{ selectAttrRequired,
+                                                          spaceAttr }, 
+                                               new ProcessorTemplateElem(),
+                                  ElemForEach.class /* class object */, true, false, true, 20, true);
+    XSLTElementDef xslIf = new XSLTElementDef(this,
+                                              Constants.S_XSLNAMESPACEURL,
+                                              "if", null /*alias */,
+                                              templateElements /* elements */,  // %template;
+                                              new XSLTAttributeDef[]{
+                                                testAttrRequired,
+                                                spaceAttr }, new ProcessorTemplateElem(),
+                                                             ElemIf.class /* class object */, 20, true);
+    XSLTElementDef xslWhen =
+      new XSLTElementDef(this, Constants.S_XSLNAMESPACEURL, "when",
+                         null /*alias */, templateElements /* elements */,  // %template;>
+                                                new XSLTAttributeDef[]{
+                                                  testAttrRequired,
+                                                  spaceAttr }, new ProcessorTemplateElem(),
+                                                               ElemWhen.class /* class object */,
+                                                                                                false, true, 1, true);
+    XSLTElementDef xslOtherwise = new XSLTElementDef(this,
+                                    Constants.S_XSLNAMESPACEURL, "otherwise",
+                                    null /*alias */,
+                                    templateElements /* elements */,  // %template;>
+                                    new XSLTAttributeDef[]{ spaceAttr },
+                                    new ProcessorTemplateElem(),
+                                    ElemOtherwise.class /* class object */,
+                                                       false, false, 2, false);
+    XSLTElementDef xslChoose = new XSLTElementDef(this,
+                                 Constants.S_XSLNAMESPACEURL, "choose",
+                                 null /*alias */,
+                                 new XSLTElementDef[]{ xslWhen,
+                                                       xslOtherwise } /* elements */, 
+                                        new XSLTAttributeDef[]{ spaceAttr },
+                                 new ProcessorTemplateElem(),
+                                 ElemChoose.class /* class object */, true, false, true, 20, true);                                
+    XSLTElementDef xslAttribute = new XSLTElementDef(this,
+                                    Constants.S_XSLNAMESPACEURL, "attribute",
+                                    null /*alias */,
+                                    charTemplateElements /* elements */,  // %char-template;>
+                                    new XSLTAttributeDef[]{ nameAVTRequired,
+                                                            namespaceAVTOpt,
+                                                            spaceAttr }, 
+                                    new ProcessorTemplateElem(),
+                                    ElemAttribute.class /* class object */, 20, true);
+    XSLTElementDef xslCallTemplate =
+      new XSLTElementDef(this, Constants.S_XSLNAMESPACEURL, "call-template",
+                         null /*alias */,
+                         new XSLTElementDef[]{ xslWithParam } /* elements */,
+                         new XSLTAttributeDef[]{ nameAttrRequired },
+                         new ProcessorTemplateElem(),
+                         ElemCallTemplate.class /* class object */, 20, true);
+    XSLTElementDef xslVariable = new XSLTElementDef(this,
+                                   Constants.S_XSLNAMESPACEURL, "variable",
+                                   null /*alias */,
+                                   templateElements /* elements */,  // %template;>
+                                   new XSLTAttributeDef[]{ nameAttrRequired,
+                                                           selectAttrOpt }, 
+                                  new ProcessorTemplateElem(),
+                                   ElemVariable.class /* class object */, 20, true);
+    XSLTElementDef xslParam = new XSLTElementDef(this,
+                                Constants.S_XSLNAMESPACEURL, "param",
+                                null /*alias */,
+                                templateElements /* elements */,  // %template;>
+                                new XSLTAttributeDef[]{ nameAttrRequired,
+                                                        selectAttrOpt }, 
+                                       new ProcessorTemplateElem(),
+                                ElemParam.class /* class object */, 19, true);
+    XSLTElementDef xslText =
+      new XSLTElementDef(this, Constants.S_XSLNAMESPACEURL, "text",
+                         null /*alias */,
+                         new XSLTElementDef[]{ charData } /* elements */,
+                         new XSLTAttributeDef[]{ disableOutputEscapingAttr },
+                         new ProcessorText(),
+                         ElemText.class /* class object */, 20, true);
+    XSLTElementDef xslProcessingInstruction =
+      new XSLTElementDef(this, Constants.S_XSLNAMESPACEURL,
+                         "processing-instruction", null /*alias */,
+                         charTemplateElements /* elements */,  // %char-template;>
+                         new XSLTAttributeDef[]{
+                                                  nameAVT_NCNAMERequired,
+                                                  spaceAttr }, 
+                                        new ProcessorTemplateElem(),
+                          ElemPI.class /* class object */, 20, true);
+    XSLTElementDef xslElement = new XSLTElementDef(this,
+                                  Constants.S_XSLNAMESPACEURL, "element",
+                                  null /*alias */,
+                                  templateElements /* elements */,  // %template;
+                                  new XSLTAttributeDef[]{ nameAVTRequired,
+                                                          namespaceAVTOpt,
+                                                          useAttributeSetsAttr,
+                                                          spaceAttr }, 
+                                               new ProcessorTemplateElem(),
+                                  ElemElement.class /* class object */, 20, true);
+    XSLTElementDef xslComment = new XSLTElementDef(this,
+                                  Constants.S_XSLNAMESPACEURL, "comment",
+                                  null /*alias */,
+                                  charTemplateElements /* elements */,  // %char-template;>
+                                  new XSLTAttributeDef[]{ spaceAttr },
+                                  new ProcessorTemplateElem(),
+                                  ElemComment.class /* class object */, 20, true);
+    XSLTElementDef xslCopy =
+      new XSLTElementDef(this, Constants.S_XSLNAMESPACEURL, "copy",
+                         null /*alias */, templateElements /* elements */,  // %template;>
+                          new XSLTAttributeDef[]{
+                                                  spaceAttr,
+                                                  useAttributeSetsAttr }, 
+                                        new ProcessorTemplateElem(),
+                          ElemCopy.class /* class object */, 20, true);
+    XSLTElementDef xslMessage = new XSLTElementDef(this,
+                                  Constants.S_XSLNAMESPACEURL, "message",
+                                  null /*alias */,
+                                  templateElements /* elements */,  // %template;>
+                                  new XSLTAttributeDef[]{ terminateAttr },
+                                  new ProcessorTemplateElem(),
+                                  ElemMessage.class /* class object */, 20, true);
+    XSLTElementDef xslFallback = new XSLTElementDef(this,
+                                   Constants.S_XSLNAMESPACEURL, "fallback",
+                                   null /*alias */,
+                                   templateElements /* elements */,  // %template;>
+                                   new XSLTAttributeDef[]{ spaceAttr },
+                                   new ProcessorTemplateElem(),
+                                   ElemFallback.class /* class object */, 20, true);
+    //exslt
+    XSLTElementDef exsltFunction =
+                                  new XSLTElementDef(this, 
+                                  Constants.S_EXSLT_FUNCTIONS_URL, 
+                                  "function",
+                                  null /*alias */,
+                                  exsltFunctionElements /* elements */,
+                                  new XSLTAttributeDef[]{ nameAttrRequired },
+                                  new ProcessorExsltFunction(),
+                                  ElemExsltFunction.class /* class object */);
+    XSLTElementDef exsltResult =
+                                  new XSLTElementDef(this, 
+                                  Constants.S_EXSLT_FUNCTIONS_URL, 
+                                  "result",
+                                  null /*alias */,
+                                  templateElements /* elements */,
+                                  new XSLTAttributeDef[]{ selectAttrOpt },
+                                  new ProcessorExsltFuncResult(),
+                                  ElemExsltFuncResult.class  /* class object */);            
+    
+
+    int i = 0;
+
+    templateElements[i++] = charData;  // #PCDATA
+
+    // char-instructions
+    templateElements[i++] = xslApplyTemplates;
+    templateElements[i++] = xslCallTemplate;
+    templateElements[i++] = xslApplyImports;
+    templateElements[i++] = xslForEach;
+    templateElements[i++] = xslValueOf;
+    templateElements[i++] = xslCopyOf;
+    templateElements[i++] = xslNumber;
+    templateElements[i++] = xslChoose;
+    templateElements[i++] = xslIf;
+    templateElements[i++] = xslText;
+    templateElements[i++] = xslCopy;
+    templateElements[i++] = xslVariable;
+    templateElements[i++] = xslMessage;
+    templateElements[i++] = xslFallback;
+
+    // instructions
+    templateElements[i++] = xslProcessingInstruction;
+    templateElements[i++] = xslComment;
+    templateElements[i++] = xslElement;
+    templateElements[i++] = xslAttribute;
+    templateElements[i++] = resultElement;
+    templateElements[i++] = unknownElement;
+    templateElements[i++] = exsltFunction;
+    templateElements[i++] = exsltResult;
+
+    System.arraycopy(templateElements, 0, templateElementsAndParams, 0, i);
+    System.arraycopy(templateElements, 0, templateElementsAndSort, 0, i);
+    System.arraycopy(templateElements, 0, exsltFunctionElements, 0, i);
+    
+    templateElementsAndParams[i] = xslParam;
+    templateElementsAndSort[i] = xslSort;
+    exsltFunctionElements[i]   = xslParam;
+
+    i = 0;
+    charTemplateElements[i++] = charData;  // #PCDATA
+
+    // char-instructions
+    charTemplateElements[i++] = xslApplyTemplates;
+    charTemplateElements[i++] = xslCallTemplate;
+    charTemplateElements[i++] = xslApplyImports;
+    charTemplateElements[i++] = xslForEach;
+    charTemplateElements[i++] = xslValueOf;
+    charTemplateElements[i++] = xslCopyOf;
+    charTemplateElements[i++] = xslNumber;
+    charTemplateElements[i++] = xslChoose;
+    charTemplateElements[i++] = xslIf;
+    charTemplateElements[i++] = xslText;
+    charTemplateElements[i++] = xslCopy;
+    charTemplateElements[i++] = xslVariable;
+    charTemplateElements[i++] = xslMessage;
+    charTemplateElements[i++] = xslFallback;
+
+    XSLTElementDef importDef = new XSLTElementDef(this,
+                                 Constants.S_XSLNAMESPACEURL, "import",
+                                 null /*alias */, null /* elements */,
+                                 new XSLTAttributeDef[]{ hrefAttr },  // EMPTY
+                                 new ProcessorImport(),
+                                 null /* class object */,
+                                        1, true);
+    XSLTElementDef includeDef = new XSLTElementDef(this,
+                                  Constants.S_XSLNAMESPACEURL, "include",
+                                  null /*alias */, null /* elements */,  // EMPTY
+                                  new XSLTAttributeDef[]{ hrefAttr },
+                                  new ProcessorInclude(),
+                                  null /* class object */,
+                                               20, true);
+    
+    XSLTAttributeDef[] scriptAttrs = new XSLTAttributeDef[]{
+    					    new XSLTAttributeDef(null, "lang", XSLTAttributeDef.T_NMTOKEN,
+                                                                 true, false,XSLTAttributeDef.WARNING),
+                                            new XSLTAttributeDef(null, "src", XSLTAttributeDef.T_URL, 
+                                            			 false, false,XSLTAttributeDef.WARNING)};
+
+    XSLTAttributeDef[] componentAttrs = new XSLTAttributeDef[]{ 
+                                            new XSLTAttributeDef(null, "prefix", XSLTAttributeDef.T_NMTOKEN, 
+                                            			 true, false,XSLTAttributeDef.WARNING),
+                                            new XSLTAttributeDef(null, "elements", XSLTAttributeDef.T_STRINGLIST, 
+                                            			 false, false,XSLTAttributeDef.WARNING),
+                                            new XSLTAttributeDef(null, "functions", XSLTAttributeDef.T_STRINGLIST, 
+                                            			 false, false,XSLTAttributeDef.WARNING) };
+
+    XSLTElementDef[] topLevelElements = new XSLTElementDef[]
+                                 {includeDef,
+                                  importDef,
+                                  // resultElement,
+                                  whiteSpaceOnly,
+                                  unknownElement,
+                                  new XSLTElementDef(
+                                         this,
+                                         Constants.S_XSLNAMESPACEURL,
+                                         "strip-space",
+                                         null /*alias */,
+                                         null /* elements */,
+                                         new XSLTAttributeDef[]{
+                                                elementsAttr },
+                                                new ProcessorStripSpace(),
+                                         null /* class object */, 20, true),
+                                  new XSLTElementDef(
+                                         this,
+                                         Constants.S_XSLNAMESPACEURL,
+                                         "preserve-space",
+                                         null /*alias */,
+                                         null /* elements */,
+                                         new XSLTAttributeDef[]{
+                                                 elementsAttr },
+                                                 new ProcessorPreserveSpace(),
+                                         null /* class object */, 20, true),
+                                  new XSLTElementDef(
+                                         this,
+                                         Constants.S_XSLNAMESPACEURL,
+                                         "output",
+                                         null /*alias */,
+                                         null /* elements */,
+                                         new XSLTAttributeDef[]{
+                                                  methodAttr,
+                                                  versionAttr,
+                                                  encodingAttr,
+                                                  omitXmlDeclarationAttr,
+                                                  standaloneAttr,
+                                                  doctypePublicAttr,
+                                                  doctypeSystemAttr,
+                                                  cdataSectionElementsAttr,
+                                                  indentAttr,
+                                                  mediaTypeAttr,
+                                                  XSLTAttributeDef.m_foreignAttr }, 
+                                          new ProcessorOutputElem(), null /* class object */, 20, true), 
+                                  new XSLTElementDef(
+                                          this,
+                                          Constants.S_XSLNAMESPACEURL,
+                                          "key",
+                                          null /*alias */,
+                                          null /* elements */,  // EMPTY
+                                          new XSLTAttributeDef[]{ nameAttrRequired,
+                                                  matchAttrRequired,
+                                                  useAttr }, 
+                                          new ProcessorKey(), null /* class object */, 20, true),
+                                  new XSLTElementDef(
+                                          this,
+                                          Constants.S_XSLNAMESPACEURL,
+                                          "decimal-format",
+                                          null /*alias */,
+                                          null /* elements */,  // EMPTY
+                                          new XSLTAttributeDef[]{
+                                                  nameAttrOpt_ERROR,
+                                                  decimalSeparatorAttr,
+                                                  groupingSeparatorAttr,
+                                                  infinityAttr,
+                                                  minusSignAttr,
+                                                  NaNAttr,
+                                                  percentAttr,
+                                                  perMilleAttr,
+                                                  zeroDigitAttr,
+                                                  digitAttr,
+                                                  patternSeparatorAttr }, 
+                                           new ProcessorDecimalFormat(),
+                                           null /* class object */, 20, true),
+                                  new XSLTElementDef(
+                                           this,
+                                           Constants.S_XSLNAMESPACEURL,
+                                           "attribute-set",
+                                           null /*alias */,
+                                           new XSLTElementDef[]{
+                                                   xslAttribute } /* elements */,
+                                           new XSLTAttributeDef[]{
+                                                   nameAttrRequired,
+                                                   useAttributeSetsAttr }, 
+                                           new ProcessorAttributeSet(),
+                                           null /* class object */, 20, true),
+                                  new XSLTElementDef(
+                                           this,
+                                           Constants.S_XSLNAMESPACEURL,
+                                           "variable",
+                                           null /*alias */,
+                                           templateElements /* elements */,
+                                           new XSLTAttributeDef[]{
+                                                   nameAttrRequired,
+                                                   selectAttrOpt }, 
+                                           new ProcessorGlobalVariableDecl(),
+                                           ElemVariable.class /* class object */, 20, true),
+                                  new XSLTElementDef(
+                                           this,
+                                           Constants.S_XSLNAMESPACEURL,
+                                           "param",
+                                           null /*alias */,
+                                           templateElements /* elements */,
+                                           new XSLTAttributeDef[]{
+                                                   nameAttrRequired,
+                                                   selectAttrOpt }, 
+                                           new ProcessorGlobalParamDecl(),
+                                           ElemParam.class /* class object */, 20, true),
+                                  new XSLTElementDef(
+                                           this,
+                                           Constants.S_XSLNAMESPACEURL,
+                                           "template",
+                                           null /*alias */,
+                                           templateElementsAndParams /* elements */,
+                                           new XSLTAttributeDef[]{
+                                                   matchAttrOpt,
+                                                   nameAttrOpt_ERROR,
+                                                   priorityAttr,
+                                                   modeAttr,
+                                                   spaceAttr }, 
+                                           new ProcessorTemplate(), ElemTemplate.class /* class object */, true, 20, true), 
+                                  new XSLTElementDef(
+                                           this,
+                                           Constants.S_XSLNAMESPACEURL,
+                                           "namespace-alias",
+                                           null /*alias */,
+                                          null /* elements */,  // EMPTY
+                                           new XSLTAttributeDef[]{ 
+                                                   stylesheetPrefixAttr,
+                                                   resultPrefixAttr }, 
+                                           new ProcessorNamespaceAlias(), null /* class object */, 20, true),
+                                  new XSLTElementDef(
+                                           this,
+                                           Constants.S_BUILTIN_EXTENSIONS_URL,
+                                           "component",
+                                           null /*alias */,
+                                           new XSLTElementDef[]{
+                                                    new XSLTElementDef(
+                                                        this,
+                                                        Constants.S_BUILTIN_EXTENSIONS_URL,
+                                                        "script",
+                                                        null /*alias */,
+                                                    	new XSLTElementDef[]{ 
+                                                        charData } /* elements */,
+                                                        scriptAttrs, 
+                                                        new ProcessorLRE(),
+                                                        ElemExtensionScript.class /* class object */, 20, true) },  // EMPTY
+                                           componentAttrs, 
+                                           new ProcessorLRE(), ElemExtensionDecl.class /* class object */),
+                                  new XSLTElementDef(
+                                           this,
+                                           Constants.S_BUILTIN_OLD_EXTENSIONS_URL,
+                                           "component",
+                                           null /*alias */,
+                                           new XSLTElementDef[]{
+                                                    new XSLTElementDef(
+                                                        this,
+                                                        Constants.S_BUILTIN_OLD_EXTENSIONS_URL,
+                                                        "script",
+                                                        null /*alias */,
+                                                    	new XSLTElementDef[]{ 
+                                                        charData } /* elements */,
+                                                        scriptAttrs, 
+                                                        new ProcessorLRE(),
+                                                        ElemExtensionScript.class /* class object */, 20, true) },  // EMPTY
+                                           componentAttrs, 
+                                           new ProcessorLRE(), ElemExtensionDecl.class /* class object */),
+                                  exsltFunction}/* exslt */;  //end of topevelElements
+    
+    XSLTAttributeDef excludeResultPrefixesAttr =
+      new XSLTAttributeDef(null, "exclude-result-prefixes",
+                           XSLTAttributeDef.T_PREFIXLIST, false,false,XSLTAttributeDef.WARNING);
+    XSLTAttributeDef extensionElementPrefixesAttr =
+      new XSLTAttributeDef(null, "extension-element-prefixes",
+                           XSLTAttributeDef.T_PREFIX_URLLIST, false,false,XSLTAttributeDef.WARNING);
+    XSLTAttributeDef idAttr = new XSLTAttributeDef(null, "id",
+                                XSLTAttributeDef.T_CDATA, false,false,XSLTAttributeDef.WARNING);
+    XSLTAttributeDef versionAttrRequired = new XSLTAttributeDef(null,
+                                             "version",
+                                             XSLTAttributeDef.T_NMTOKEN,
+                                             true,false,XSLTAttributeDef.WARNING);
+    XSLTElementDef stylesheetElemDef = new XSLTElementDef(this,
+                                         Constants.S_XSLNAMESPACEURL,
+                                         "stylesheet", "transform",
+                                         topLevelElements,
+                                         new XSLTAttributeDef[]{
+                                           extensionElementPrefixesAttr,
+                                           excludeResultPrefixesAttr,
+                                           idAttr,
+                                           versionAttrRequired,
+                                           spaceAttr }, new ProcessorStylesheetElement(),  /* ContentHandler */
+                                         null  /* class object */,
+                                         true, -1, false);
+
+    importDef.setElements(new XSLTElementDef[]{ stylesheetElemDef,
+                                                resultElement,
+                                                unknownElement });
+    includeDef.setElements(new XSLTElementDef[]{ stylesheetElemDef,
+                                                 resultElement,
+                                                 unknownElement });
+    build(null, null, null, new XSLTElementDef[]{ stylesheetElemDef,
+                                                  whiteSpaceOnly,
+                                                  resultElement,
+                                                  unknownElement }, null,
+                                                                    new ProcessorStylesheetDoc(),  /* ContentHandler */
+                                                                    null  /* class object */
+                                                                      );
+  }
+
+  /**
+   * A hashtable of all available built-in elements for use by the element-available
+   * function.
+   * TODO:  When we convert to Java2, this should be a Set.
+   */
+  private HashMap m_availElems = new HashMap();
+  
+  /**
+   * Get the table of available elements.
+   * 
+   * @return table of available elements, keyed by qualified names, and with 
+   * values of the same qualified names.
+   */
+  public HashMap getElemsAvailable() 
+  {
+    return m_availElems;
+  }
+
+  /**
+   * Adds a new element name to the Hashtable of available elements.
+   * @param elemName The name of the element to add to the Hashtable of available elements.
+   */
+  void addAvailableElement(QName elemName)
+  {
+    m_availElems.put(elemName, elemName);
+  }
+
+  /**
+   * Determines whether the passed element name is present in the list of available elements.
+   * @param elemName The name of the element to look up.
+   *
+   * @return true if an element corresponding to elemName is available.
+   */
+  public boolean elementAvailable(QName elemName)
+  {
+    return m_availElems.containsKey(elemName);
+  }
+}
+
diff --git a/src/main/java/org/apache/xalan/processor/package.html b/src/main/java/org/apache/xalan/processor/package.html
new file mode 100644
index 0000000..6d1dd4e
--- /dev/null
+++ b/src/main/java/org/apache/xalan/processor/package.html
@@ -0,0 +1,41 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<!-- $Id: package.html 468640 2006-10-28 06:53:53Z minchau $ -->
+<html>
+  <title>Xalan Processor Package.</title>
+  <body>
+    <p>Parses an XSLT stylesheet document (which may include and import other stylesheet documents) and produces a StylesheetRoot
+    (a TRaX Templates object).</p>
+    
+    <p>StylesheetProcessor implements the TRaX {@link javax.xml.transform.TransformerFactory} interface,
+    as well as the {@link javax.xml.transform.sax.SAXTransformerFactory} interface. 
+    It registers the {@link org.apache.xalan.processor.StylesheetHandler} object 
+    (a TrAX {@link javax.xml.transform.sax.TemplatesHandler} implementation) 
+    as the SAX ContentHandler for an XMLReader, and uses the XMLReader to parse 
+    the stylesheet document.</p>
+    <p>Before parsing the XSLT input, StylesheetHandler assembles an {@link org.apache.xalan.processor.XSLTSchema}, 
+    which uses {@link org.apache.xalan.processor.XSLTElementDef}
+    and {@link org.apache.xalan.processor.XSLTAttributeDef} objects to 
+    recursively define the elements and attributes that an XSLT stylesheet may 
+    contain. The StylesheetHandler then passes on each parse event to the 
+    {@link org.apache.xalan.processor.XSLTElementProcessor} which the 
+    XSLTElementDef assigned to the element associated with that event.</p>
+ </body>
+</html>
+
+
diff --git a/src/main/java/org/apache/xalan/res/XSLMessages.java b/src/main/java/org/apache/xalan/res/XSLMessages.java
new file mode 100644
index 0000000..cbbfd88
--- /dev/null
+++ b/src/main/java/org/apache/xalan/res/XSLMessages.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: XSLMessages.java 468641 2006-10-28 06:54:42Z minchau $
+ */
+package org.apache.xalan.res;
+
+import java.util.ListResourceBundle;
+
+import org.apache.xpath.res.XPATHMessages;
+
+/**
+ * Sets things up for issuing error messages.  This class is misnamed, and
+ * should be called XalanMessages, or some such.
+ * @xsl.usage internal
+ */
+public class XSLMessages extends XPATHMessages
+{
+
+  /** The language specific resource object for Xalan messages.  */
+  private static ListResourceBundle XSLTBundle = new XSLTErrorResources(); // android-changed
+
+  /**
+   * Creates a message from the specified key and replacement
+   * arguments, localized to the given locale.
+   *
+   * @param msgKey    The key for the message text.
+   * @param args      The arguments to be used as replacement text
+   *                  in the message created.
+   *
+   * @return The formatted message string.
+   */
+  public static final String createMessage(String msgKey, Object args[])  //throws Exception
+  {
+      // BEGIN android-changed
+      //     don't localize resources
+      return createMsg(XSLTBundle, msgKey, args);
+      // END android-changed
+  }
+  
+  /**
+   * Creates a message from the specified key and replacement
+   * arguments, localized to the given locale.
+   *
+   * @param msgKey    The key for the message text.
+   * @param args      The arguments to be used as replacement text
+   *                  in the message created.
+   *
+   * @return The formatted warning string.
+   */
+  public static final String createWarning(String msgKey, Object args[])  //throws Exception
+  {
+      // BEGIN android-changed
+      //     don't localize exception messages
+      return createMsg(XSLTBundle, msgKey, args);
+      // END android-changed
+  }
+}
diff --git a/src/main/java/org/apache/xalan/res/XSLTErrorResources.java b/src/main/java/org/apache/xalan/res/XSLTErrorResources.java
new file mode 100644
index 0000000..8310540
--- /dev/null
+++ b/src/main/java/org/apache/xalan/res/XSLTErrorResources.java
@@ -0,0 +1,1511 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: XSLTErrorResources.java 468641 2006-10-28 06:54:42Z minchau $
+ */
+package org.apache.xalan.res;
+
+import java.util.ListResourceBundle;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Set up error messages.
+ * We build a two dimensional array of message keys and
+ * message strings. In order to add a new message here,
+ * you need to first add a String constant. And 
+ *  you need to enter key , value pair as part of contents
+ * Array. You also need to update MAX_CODE for error strings
+ * and MAX_WARNING for warnings ( Needed for only information
+ * purpose )
+ */
+public class XSLTErrorResources extends ListResourceBundle
+{
+
+/*
+ * This file contains error and warning messages related to Xalan Error
+ * Handling.
+ *
+ *  General notes to translators:
+ *
+ *  1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
+ *     components.
+ *     XSLT is an acronym for "XML Stylesheet Language: Transformations".
+ *     XSLTC is an acronym for XSLT Compiler.
+ *
+ *  2) A stylesheet is a description of how to transform an input XML document
+ *     into a resultant XML document (or HTML document or text).  The
+ *     stylesheet itself is described in the form of an XML document.
+ *
+ *  3) A template is a component of a stylesheet that is used to match a
+ *     particular portion of an input document and specifies the form of the
+ *     corresponding portion of the output document.
+ *
+ *  4) An element is a mark-up tag in an XML document; an attribute is a
+ *     modifier on the tag.  For example, in <elem attr='val' attr2='val2'>
+ *     "elem" is an element name, "attr" and "attr2" are attribute names with
+ *     the values "val" and "val2", respectively.
+ *
+ *  5) A namespace declaration is a special attribute that is used to associate
+ *     a prefix with a URI (the namespace).  The meanings of element names and
+ *     attribute names that use that prefix are defined with respect to that
+ *     namespace.
+ *
+ *  6) "Translet" is an invented term that describes the class file that
+ *     results from compiling an XML stylesheet into a Java class.
+ *
+ *  7) XPath is a specification that describes a notation for identifying
+ *     nodes in a tree-structured representation of an XML document.  An
+ *     instance of that notation is referred to as an XPath expression.
+ *
+ */
+
+  /* 
+   * Static variables
+   */
+  public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = 
+	"ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; 
+	
+  public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT =
+	"ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT";
+   
+  public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE";
+  public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
+  public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE";
+  public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS";
+  public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; 
+  public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES="ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES";
+  public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB";
+  public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND";
+  public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT";
+  public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB";
+  public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB";
+  public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB =
+	 "ER_BAD_VAL_ON_LEVEL_ATTRIB";
+  public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML =
+	 "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML";
+  public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = 
+	 "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME";
+  public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB";
+  public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = 
+	 "ER_NEED_NAME_OR_MATCH_ATTRIB";
+  public static final String ER_CANT_RESOLVE_NSPREFIX =
+	 "ER_CANT_RESOLVE_NSPREFIX";
+  public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE";
+  public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC";
+  public static final String ER_ELEMTEMPLATEELEM_ERR ="ER_ELEMTEMPLATEELEM_ERR";
+  public static final String ER_NULL_CHILD = "ER_NULL_CHILD";
+  public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB";
+  public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB";
+  public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB";
+  public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC";
+  public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = 
+	 "ER_COULD_NOT_CREATE_XML_PROC_LIAISON";
+  public static final String ER_PROCESS_NOT_SUCCESSFUL = 
+	 "ER_PROCESS_NOT_SUCCESSFUL";
+  public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL";
+  public static final String ER_ENCODING_NOT_SUPPORTED = 
+	 "ER_ENCODING_NOT_SUPPORTED";
+  public static final String ER_COULD_NOT_CREATE_TRACELISTENER = 
+	 "ER_COULD_NOT_CREATE_TRACELISTENER";
+  public static final String ER_KEY_REQUIRES_NAME_ATTRIB = 
+	 "ER_KEY_REQUIRES_NAME_ATTRIB";
+  public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = 
+	 "ER_KEY_REQUIRES_MATCH_ATTRIB";
+  public static final String ER_KEY_REQUIRES_USE_ATTRIB = 
+	 "ER_KEY_REQUIRES_USE_ATTRIB";
+  public static final String ER_REQUIRES_ELEMENTS_ATTRIB = 
+	 "ER_REQUIRES_ELEMENTS_ATTRIB";
+  public static final String ER_MISSING_PREFIX_ATTRIB = 
+	 "ER_MISSING_PREFIX_ATTRIB";
+  public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL";
+  public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND";
+  public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION";
+  public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB";
+  public static final String ER_STYLESHEET_INCLUDES_ITSELF = 
+	 "ER_STYLESHEET_INCLUDES_ITSELF";
+  public static final String ER_PROCESSINCLUDE_ERROR ="ER_PROCESSINCLUDE_ERROR";
+  public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB";
+  public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = 
+	 "ER_MISSING_CONTAINER_ELEMENT_COMPONENT";
+  public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = 
+	 "ER_CAN_ONLY_OUTPUT_TO_ELEMENT";
+  public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR";
+  public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR";
+  public static final String ER_NO_SELECT_EXPRESSION ="ER_NO_SELECT_EXPRESSION";
+  public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = 
+	 "ER_CANNOT_SERIALIZE_XSLPROCESSOR";
+  public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET";
+  public static final String ER_FAILED_PROCESS_STYLESHEET = 
+	 "ER_FAILED_PROCESS_STYLESHEET";
+  public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC";
+  public static final String ER_COULDNT_FIND_FRAGMENT = 
+	 "ER_COULDNT_FIND_FRAGMENT";
+  public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT";
+  public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = 
+	 "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB";
+  public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = 
+	 "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB";
+  public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = 
+	 "ER_NO_CLONE_OF_DOCUMENT_FRAG";
+  public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM";
+  public static final String ER_XMLSPACE_ILLEGAL_VALUE = 
+	 "ER_XMLSPACE_ILLEGAL_VALUE";
+  public static final String ER_NO_XSLKEY_DECLARATION = 
+	 "ER_NO_XSLKEY_DECLARATION";
+  public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL";
+  public static final String ER_XSLFUNCTIONS_UNSUPPORTED = 
+	 "ER_XSLFUNCTIONS_UNSUPPORTED";
+  public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR";
+  public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = 
+	 "ER_NOT_ALLOWED_INSIDE_STYLESHEET";
+  public static final String ER_RESULTNS_NOT_SUPPORTED = 
+	 "ER_RESULTNS_NOT_SUPPORTED";
+  public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = 
+	 "ER_DEFAULTSPACE_NOT_SUPPORTED";
+  public static final String ER_INDENTRESULT_NOT_SUPPORTED = 
+	 "ER_INDENTRESULT_NOT_SUPPORTED";
+  public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB";
+  public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM";
+  public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE";
+  public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN";
+  public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = 
+	 "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE";
+  public static final String ER_MISPLACED_XSLOTHERWISE = 
+	 "ER_MISPLACED_XSLOTHERWISE";
+  public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = 
+	 "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE";
+  public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = 
+	 "ER_NOT_ALLOWED_INSIDE_TEMPLATE";
+  public static final String ER_UNKNOWN_EXT_NS_PREFIX = 
+	 "ER_UNKNOWN_EXT_NS_PREFIX";
+  public static final String ER_IMPORTS_AS_FIRST_ELEM = 
+	 "ER_IMPORTS_AS_FIRST_ELEM";
+  public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF";
+  public static final String ER_XMLSPACE_ILLEGAL_VAL ="ER_XMLSPACE_ILLEGAL_VAL";
+  public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = 
+	 "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL";
+  public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION";
+  public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR";
+  public static final String ER_CURRENCY_SIGN_ILLEGAL=
+	 "ER_CURRENCY_SIGN_ILLEGAL";
+  public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = 
+	 "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM";
+  public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = 
+	 "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER";
+  public static final String ER_REDIRECT_COULDNT_GET_FILENAME = 
+	 "ER_REDIRECT_COULDNT_GET_FILENAME";
+  public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = 
+	 "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT";
+  public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = 
+	 "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX";
+  public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI";
+  public static final String ER_MISSING_ARG_FOR_OPTION = 
+	 "ER_MISSING_ARG_FOR_OPTION";
+  public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION";
+  public static final String ER_MALFORMED_FORMAT_STRING = 
+	 "ER_MALFORMED_FORMAT_STRING";
+  public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = 
+	 "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB";
+  public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = 
+	 "ER_ILLEGAL_ATTRIBUTE_VALUE";
+  public static final String ER_CHOOSE_REQUIRES_WHEN ="ER_CHOOSE_REQUIRES_WHEN";
+  public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = 
+	 "ER_NO_APPLY_IMPORT_IN_FOR_EACH";
+  public static final String ER_CANT_USE_DTM_FOR_OUTPUT = 
+	 "ER_CANT_USE_DTM_FOR_OUTPUT";
+  public static final String ER_CANT_USE_DTM_FOR_INPUT = 
+	 "ER_CANT_USE_DTM_FOR_INPUT";
+  public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED";
+  public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
+  public static final String ER_INVALID_UTF16_SURROGATE = 
+	 "ER_INVALID_UTF16_SURROGATE";
+  public static final String ER_XSLATTRSET_USED_ITSELF = 
+	 "ER_XSLATTRSET_USED_ITSELF";
+  public static final String ER_CANNOT_MIX_XERCESDOM ="ER_CANNOT_MIX_XERCESDOM";
+  public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS";
+  public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = 
+	 "ER_IN_ELEMTEMPLATEELEM_READOBJECT";
+  public static final String ER_DUPLICATE_NAMED_TEMPLATE = 
+	 "ER_DUPLICATE_NAMED_TEMPLATE";
+  public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL";
+  public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF";
+  public static final String ER_ILLEGAL_DOMSOURCE_INPUT = 
+	 "ER_ILLEGAL_DOMSOURCE_INPUT";
+  public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = 
+	 "ER_CLASS_NOT_FOUND_FOR_OPTION";
+  public static final String ER_REQUIRED_ELEM_NOT_FOUND = 
+	 "ER_REQUIRED_ELEM_NOT_FOUND";
+  public static final String ER_INPUT_CANNOT_BE_NULL ="ER_INPUT_CANNOT_BE_NULL";
+  public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL";
+  public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL";
+  public static final String ER_SOURCE_CANNOT_BE_NULL = 
+	 "ER_SOURCE_CANNOT_BE_NULL";
+  public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR";
+  public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN";
+  public static final String ER_CANNOT_CREATE_EXTENSN = 
+	 "ER_CANNOT_CREATE_EXTENSN";
+  public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = 
+	 "ER_INSTANCE_MTHD_CALL_REQUIRES";
+  public static final String ER_INVALID_ELEMENT_NAME ="ER_INVALID_ELEMENT_NAME";
+  public static final String ER_ELEMENT_NAME_METHOD_STATIC = 
+	 "ER_ELEMENT_NAME_METHOD_STATIC";
+  public static final String ER_EXTENSION_FUNC_UNKNOWN = 
+	 "ER_EXTENSION_FUNC_UNKNOWN";
+  public static final String ER_MORE_MATCH_CONSTRUCTOR = 
+	 "ER_MORE_MATCH_CONSTRUCTOR";
+  public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD";
+  public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT";
+  public static final String ER_INVALID_CONTEXT_PASSED = 
+	 "ER_INVALID_CONTEXT_PASSED";
+  public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS";
+  public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME";
+  public static final String ER_NO_URL = "ER_NO_URL";
+  public static final String ER_POOL_SIZE_LESSTHAN_ONE = 
+	 "ER_POOL_SIZE_LESSTHAN_ONE";
+  public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER";
+  public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT";
+  public static final String ER_ILLEGAL_XMLSPACE_VALUE = 
+	 "ER_ILLEGAL_XMLSPACE_VALUE";
+  public static final String ER_PROCESSFROMNODE_FAILED = 
+	 "ER_PROCESSFROMNODE_FAILED";
+  public static final String ER_RESOURCE_COULD_NOT_LOAD = 
+	 "ER_RESOURCE_COULD_NOT_LOAD";
+  public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = 
+	 "ER_BUFFER_SIZE_LESSTHAN_ZERO";
+  public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = 
+	 "ER_UNKNOWN_ERROR_CALLING_EXTENSION";
+  public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL";
+  public static final String ER_ELEM_CONTENT_NOT_ALLOWED = 
+	 "ER_ELEM_CONTENT_NOT_ALLOWED";
+  public static final String ER_STYLESHEET_DIRECTED_TERMINATION = 
+	 "ER_STYLESHEET_DIRECTED_TERMINATION";
+  public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO";
+  public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE";
+  public static final String ER_COULD_NOT_LOAD_RESOURCE = 
+	 "ER_COULD_NOT_LOAD_RESOURCE";
+  public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = 
+	 "ER_CANNOT_INIT_DEFAULT_TEMPLATES";
+  public static final String ER_RESULT_NULL = "ER_RESULT_NULL";
+  public static final String ER_RESULT_COULD_NOT_BE_SET = 
+	 "ER_RESULT_COULD_NOT_BE_SET";
+  public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED";
+  public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = 
+	 "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE";
+  public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = 
+	 "ER_CANNOT_TRANSFORM_SOURCE_TYPE";
+  public static final String ER_NULL_CONTENT_HANDLER ="ER_NULL_CONTENT_HANDLER";
+  public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER";
+  public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE";
+  public static final String ER_NO_PARENT_FOR_FILTER ="ER_NO_PARENT_FOR_FILTER";
+  public static final String ER_NO_STYLESHEET_IN_MEDIA = 
+	 "ER_NO_STYLESHEET_IN_MEDIA";
+  public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI";
+  public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
+  public static final String ER_PROPERTY_VALUE_BOOLEAN = 
+	 "ER_PROPERTY_VALUE_BOOLEAN";
+  public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = 
+	 "ER_COULD_NOT_FIND_EXTERN_SCRIPT";
+  public static final String ER_RESOURCE_COULD_NOT_FIND = 
+	 "ER_RESOURCE_COULD_NOT_FIND";
+  public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = 
+	 "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED";
+  public static final String ER_FAILED_CREATING_ELEMLITRSLT = 
+	 "ER_FAILED_CREATING_ELEMLITRSLT";
+  public static final String ER_VALUE_SHOULD_BE_NUMBER = 
+	 "ER_VALUE_SHOULD_BE_NUMBER";
+  public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL";
+  public static final String ER_FAILED_CALLING_METHOD = 
+	 "ER_FAILED_CALLING_METHOD";
+  public static final String ER_FAILED_CREATING_ELEMTMPL = 
+	 "ER_FAILED_CREATING_ELEMTMPL";
+  public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED";
+  public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED";
+  public static final String ER_BAD_VALUE = "ER_BAD_VALUE";
+  public static final String ER_ATTRIB_VALUE_NOT_FOUND = 
+	 "ER_ATTRIB_VALUE_NOT_FOUND";
+  public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = 
+	 "ER_ATTRIB_VALUE_NOT_RECOGNIZED";
+  public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE";
+  public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG";
+  public static final String  ER_CANNOT_FIND_SAX1_DRIVER = 
+	 "ER_CANNOT_FIND_SAX1_DRIVER";
+  public static final String  ER_SAX1_DRIVER_NOT_LOADED = 
+	 "ER_SAX1_DRIVER_NOT_LOADED";
+  public static final String  ER_SAX1_DRIVER_NOT_INSTANTIATED = 
+	 "ER_SAX1_DRIVER_NOT_INSTANTIATED" ;
+  public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = 
+	 "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER";
+  public static final String  ER_PARSER_PROPERTY_NOT_SPECIFIED = 
+	 "ER_PARSER_PROPERTY_NOT_SPECIFIED";
+  public static final String  ER_PARSER_ARG_CANNOT_BE_NULL = 
+	 "ER_PARSER_ARG_CANNOT_BE_NULL" ;
+  public static final String  ER_FEATURE = "ER_FEATURE";
+  public static final String ER_PROPERTY = "ER_PROPERTY" ;
+  public static final String ER_NULL_ENTITY_RESOLVER ="ER_NULL_ENTITY_RESOLVER";
+  public static final String  ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER" ;
+  public static final String ER_NO_DRIVER_NAME_SPECIFIED = 
+	 "ER_NO_DRIVER_NAME_SPECIFIED";
+  public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED";
+  public static final String ER_POOLSIZE_LESS_THAN_ONE = 
+	 "ER_POOLSIZE_LESS_THAN_ONE";
+  public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME";
+  public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER";
+  public static final String ER_ASSERT_NO_TEMPLATE_PARENT = 
+	 "ER_ASSERT_NO_TEMPLATE_PARENT";
+  public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = 
+	 "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR";
+  public static final String ER_NOT_ALLOWED_IN_POSITION = 
+	 "ER_NOT_ALLOWED_IN_POSITION";
+  public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = 
+	 "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION";
+  public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE =
+  	 "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE";
+  public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX =
+ 	 "ER_NAMESPACE_CONTEXT_NULL_PREFIX";
+  public static final String ER_XPATH_RESOLVER_NULL_QNAME =
+	 "ER_XPATH_RESOLVER_NULL_QNAME";
+  public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY =
+	 "ER_XPATH_RESOLVER_NEGATIVE_ARITY";
+  public static final String INVALID_TCHAR = "INVALID_TCHAR";
+  public static final String INVALID_QNAME = "INVALID_QNAME";
+  public static final String INVALID_ENUM = "INVALID_ENUM";
+  public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN";
+  public static final String INVALID_NCNAME = "INVALID_NCNAME";
+  public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN";
+  public static final String INVALID_NUMBER = "INVALID_NUMBER";
+  public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL";
+  public static final String ER_DUPLICATE_GLOBAL_VAR ="ER_DUPLICATE_GLOBAL_VAR";
+  public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR";
+  public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH";
+  public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX";
+  public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET";
+  public static final String ER_FUNCTION_NOT_FOUND = 
+	 "ER_FUNCTION_NOT_FOUND"; 
+  public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = 
+     "ER_CANT_HAVE_CONTENT_AND_SELECT";
+  public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE";    
+  public static final String ER_SET_FEATURE_NULL_NAME =
+  	"ER_SET_FEATURE_NULL_NAME";
+  public static final String ER_GET_FEATURE_NULL_NAME =
+  	"ER_GET_FEATURE_NULL_NAME";
+  public static final String ER_UNSUPPORTED_FEATURE =
+  	"ER_UNSUPPORTED_FEATURE";
+  public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING =
+  	"ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING";
+     
+  public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE";
+  public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = 
+	 "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR";
+  public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = 
+	 "WG_EXPR_ATTRIB_CHANGED_TO_SELECT";
+  public static final String WG_NO_LOCALE_IN_FORMATNUMBER = 
+	 "WG_NO_LOCALE_IN_FORMATNUMBER";
+  public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND";
+  public static final String WG_CANNOT_MAKE_URL_FROM ="WG_CANNOT_MAKE_URL_FROM";
+  public static final String WG_CANNOT_LOAD_REQUESTED_DOC = 
+	 "WG_CANNOT_LOAD_REQUESTED_DOC";
+  public static final String WG_CANNOT_FIND_COLLATOR ="WG_CANNOT_FIND_COLLATOR";
+  public static final String WG_FUNCTIONS_SHOULD_USE_URL = 
+	 "WG_FUNCTIONS_SHOULD_USE_URL";
+  public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = 
+	 "WG_ENCODING_NOT_SUPPORTED_USING_UTF8";
+  public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = 
+	 "WG_ENCODING_NOT_SUPPORTED_USING_JAVA";
+  public static final String WG_SPECIFICITY_CONFLICTS = 
+	 "WG_SPECIFICITY_CONFLICTS";
+  public static final String WG_PARSING_AND_PREPARING = 
+	 "WG_PARSING_AND_PREPARING";
+  public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE";
+  public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP";
+  public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED";
+  public static final String WG_NO_DECIMALFORMAT_DECLARATION = 
+	 "WG_NO_DECIMALFORMAT_DECLARATION";
+  public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS";
+  public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = 
+	 "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED";
+  public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = 
+	 "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE";
+  public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE";
+  public static final String WG_COULD_NOT_RESOLVE_PREFIX = 
+	 "WG_COULD_NOT_RESOLVE_PREFIX";
+  public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = 
+	 "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB";
+  public static final String WG_ILLEGAL_ATTRIBUTE_NAME = 
+	 "WG_ILLEGAL_ATTRIBUTE_NAME";
+  public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = 
+	 "WG_ILLEGAL_ATTRIBUTE_VALUE";
+  public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG";
+  public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = 
+	 "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML";
+  public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = 
+	 "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME";
+  public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = 
+	 "WG_ILLEGAL_ATTRIBUTE_POSITION";
+  public static final String NO_MODIFICATION_ALLOWED_ERR = 
+         "NO_MODIFICATION_ALLOWED_ERR";
+
+  /*
+   * Now fill in the message text.
+   * Then fill in the message text for that message code in the
+   * array. Use the new error code as the index into the array.
+   */
+
+  // Error messages...
+
+  /** Get the lookup table for error messages.   
+   *
+   * @return The int to message lookup table.
+   */
+  public Object[][] getContents()
+  {
+    return new Object[][] {
+
+  /** Error message ID that has a null message, but takes in a single object.    */
+  {"ER0000" , "{0}" },
+
+    { ER_NO_CURLYBRACE,                            
+      "Error: Can not have '{' within expression"},
+
+    { ER_ILLEGAL_ATTRIBUTE , 
+     "{0} has an illegal attribute: {1}"},
+
+  {ER_NULL_SOURCENODE_APPLYIMPORTS ,
+      "sourceNode is null in xsl:apply-imports!"},
+
+  {ER_CANNOT_ADD,
+      "Can not add {0} to {1}"},
+
+    { ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, 
+      "sourceNode is null in handleApplyTemplatesInstruction!"},
+
+    { ER_NO_NAME_ATTRIB, 
+     "{0} must have a name attribute."},
+
+    {ER_TEMPLATE_NOT_FOUND,
+     "Could not find template named: {0}"},
+
+    {ER_CANT_RESOLVE_NAME_AVT,
+      "Could not resolve name AVT in xsl:call-template."},
+
+    {ER_REQUIRES_ATTRIB,
+     "{0} requires attribute: {1}"},
+
+    { ER_MUST_HAVE_TEST_ATTRIB, 
+      "{0} must have a ''test'' attribute."},
+
+    {ER_BAD_VAL_ON_LEVEL_ATTRIB,
+      "Bad value on level attribute: {0}"},
+
+    {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, 
+      "processing-instruction name can not be 'xml'"},
+
+    { ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME,
+      "processing-instruction name must be a valid NCName: {0}"},
+
+    { ER_NEED_MATCH_ATTRIB,
+      "{0} must have a match attribute if it has a mode."},
+
+    { ER_NEED_NAME_OR_MATCH_ATTRIB,
+      "{0} requires either a name or a match attribute."},
+
+    {ER_CANT_RESOLVE_NSPREFIX,
+      "Can not resolve namespace prefix: {0}"},
+
+    { ER_ILLEGAL_VALUE,
+     "xml:space has an illegal value: {0}"},
+
+    { ER_NO_OWNERDOC,
+      "Child node does not have an owner document!"},
+
+    { ER_ELEMTEMPLATEELEM_ERR,
+     "ElemTemplateElement error: {0}"},
+
+    { ER_NULL_CHILD,
+     "Trying to add a null child!"},
+
+    { ER_NEED_SELECT_ATTRIB,
+     "{0} requires a select attribute."},
+
+    { ER_NEED_TEST_ATTRIB ,
+      "xsl:when must have a 'test' attribute."},
+
+    { ER_NEED_NAME_ATTRIB,
+      "xsl:with-param must have a 'name' attribute."},
+
+    { ER_NO_CONTEXT_OWNERDOC,
+      "context does not have an owner document!"},
+
+    {ER_COULD_NOT_CREATE_XML_PROC_LIAISON,
+      "Could not create XML TransformerFactory Liaison: {0}"},
+
+    {ER_PROCESS_NOT_SUCCESSFUL,
+      "Xalan: Process was not successful."},
+
+    { ER_NOT_SUCCESSFUL,
+     "Xalan: was not successful."},
+
+    { ER_ENCODING_NOT_SUPPORTED,
+     "Encoding not supported: {0}"},
+
+    {ER_COULD_NOT_CREATE_TRACELISTENER,
+      "Could not create TraceListener: {0}"},
+
+    {ER_KEY_REQUIRES_NAME_ATTRIB,
+      "xsl:key requires a 'name' attribute!"},
+
+    { ER_KEY_REQUIRES_MATCH_ATTRIB,
+      "xsl:key requires a 'match' attribute!"},
+
+    { ER_KEY_REQUIRES_USE_ATTRIB,
+      "xsl:key requires a 'use' attribute!"},
+
+    { ER_REQUIRES_ELEMENTS_ATTRIB,
+      "(StylesheetHandler) {0} requires an ''elements'' attribute!"},
+
+    { ER_MISSING_PREFIX_ATTRIB,
+      "(StylesheetHandler) {0} attribute ''prefix'' is missing"},
+
+    { ER_BAD_STYLESHEET_URL,
+     "Stylesheet URL is bad: {0}"},
+
+    { ER_FILE_NOT_FOUND,
+     "Stylesheet file was not found: {0}"},
+
+    { ER_IOEXCEPTION,
+      "Had IO Exception with stylesheet file: {0}"},
+
+    { ER_NO_HREF_ATTRIB, 
+      "(StylesheetHandler) Could not find href attribute for {0}"},
+
+    { ER_STYLESHEET_INCLUDES_ITSELF, 
+      "(StylesheetHandler) {0} is directly or indirectly including itself!"},
+
+    { ER_PROCESSINCLUDE_ERROR,
+      "StylesheetHandler.processInclude error, {0}"},
+
+    { ER_MISSING_LANG_ATTRIB,
+      "(StylesheetHandler) {0} attribute ''lang'' is missing"},
+
+    { ER_MISSING_CONTAINER_ELEMENT_COMPONENT,
+      "(StylesheetHandler) misplaced {0} element?? Missing container element ''component''"},
+
+    { ER_CAN_ONLY_OUTPUT_TO_ELEMENT,
+      "Can only output to an Element, DocumentFragment, Document, or PrintWriter."},
+
+    { ER_PROCESS_ERROR,
+     "StylesheetRoot.process error"},
+
+    { ER_UNIMPLNODE_ERROR,
+     "UnImplNode error: {0}"},
+
+    { ER_NO_SELECT_EXPRESSION,
+      "Error! Did not find xpath select expression (-select)."},
+
+    { ER_CANNOT_SERIALIZE_XSLPROCESSOR, 
+      "Can not serialize an XSLProcessor!"},
+
+    { ER_NO_INPUT_STYLESHEET,
+      "Stylesheet input was not specified!"},
+
+    { ER_FAILED_PROCESS_STYLESHEET,
+      "Failed to process stylesheet!"},
+
+    { ER_COULDNT_PARSE_DOC,       
+     "Could not parse {0} document!"},
+
+    { ER_COULDNT_FIND_FRAGMENT,
+     "Could not find fragment: {0}"},
+
+    { ER_NODE_NOT_ELEMENT,
+      "Node pointed to by fragment identifier was not an element: {0}"},
+
+    { ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB,
+      "for-each must have either a match or name attribute"},
+
+    { ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, 
+      "templates must have either a match or name attribute"},
+
+    { ER_NO_CLONE_OF_DOCUMENT_FRAG,
+      "No clone of a document fragment!"},
+
+    { ER_CANT_CREATE_ITEM,
+      "Can not create item in result tree: {0}"},
+
+    { ER_XMLSPACE_ILLEGAL_VALUE,
+      "xml:space in the source XML has an illegal value: {0}"},
+
+    { ER_NO_XSLKEY_DECLARATION,
+      "There is no xsl:key declaration for {0}!"},
+
+    { ER_CANT_CREATE_URL, 
+     "Error! Cannot create url for: {0}"},
+
+    { ER_XSLFUNCTIONS_UNSUPPORTED,
+     "xsl:functions is unsupported"},
+
+    { ER_PROCESSOR_ERROR, 
+     "XSLT TransformerFactory Error"},
+
+    { ER_NOT_ALLOWED_INSIDE_STYLESHEET,
+      "(StylesheetHandler) {0} not allowed inside a stylesheet!"},
+
+    { ER_RESULTNS_NOT_SUPPORTED, 
+      "result-ns no longer supported!  Use xsl:output instead."},
+
+    { ER_DEFAULTSPACE_NOT_SUPPORTED, 
+      "default-space no longer supported!  Use xsl:strip-space or xsl:preserve-space instead."},
+
+    { ER_INDENTRESULT_NOT_SUPPORTED,
+      "indent-result no longer supported!  Use xsl:output instead."},
+
+    { ER_ILLEGAL_ATTRIB,
+      "(StylesheetHandler) {0} has an illegal attribute: {1}"},
+
+    { ER_UNKNOWN_XSL_ELEM,
+     "Unknown XSL element: {0}"},
+
+    { ER_BAD_XSLSORT_USE,
+      "(StylesheetHandler) xsl:sort can only be used with xsl:apply-templates or xsl:for-each."},
+
+    { ER_MISPLACED_XSLWHEN,
+      "(StylesheetHandler) misplaced xsl:when!"},
+
+    { ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE,
+      "(StylesheetHandler) xsl:when not parented by xsl:choose!"},
+
+    { ER_MISPLACED_XSLOTHERWISE,
+      "(StylesheetHandler) misplaced xsl:otherwise!"},
+
+    { ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE,
+      "(StylesheetHandler) xsl:otherwise not parented by xsl:choose!"},
+
+    { ER_NOT_ALLOWED_INSIDE_TEMPLATE,
+      "(StylesheetHandler) {0} is not allowed inside a template!"},
+
+    { ER_UNKNOWN_EXT_NS_PREFIX, 
+      "(StylesheetHandler) {0} extension namespace prefix {1} unknown"},
+
+    { ER_IMPORTS_AS_FIRST_ELEM, 
+      "(StylesheetHandler) Imports can only occur as the first elements in the stylesheet!"},
+
+    { ER_IMPORTING_ITSELF,
+      "(StylesheetHandler) {0} is directly or indirectly importing itself!"},
+
+    { ER_XMLSPACE_ILLEGAL_VAL,
+      "(StylesheetHandler) " + "xml:space has an illegal value: {0}"},
+
+    { ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL,
+      "processStylesheet not succesfull!"},
+
+    { ER_SAX_EXCEPTION, 
+     "SAX Exception"},
+
+//  add this message to fix bug 21478
+    { ER_FUNCTION_NOT_SUPPORTED, 
+     "Function not supported!"},
+
+    { ER_XSLT_ERROR,
+     "XSLT Error"},
+
+    { ER_CURRENCY_SIGN_ILLEGAL,
+      "currency sign is not allowed in format pattern string"},
+
+    { ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM,
+      "Document function not supported in Stylesheet DOM!"},
+
+    { ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER,
+      "Can't resolve prefix of non-Prefix resolver!"},
+
+    { ER_REDIRECT_COULDNT_GET_FILENAME,
+      "Redirect extension: Could not get filename - file or select attribute must return vald string."},
+
+    { ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT,
+      "Can not build FormatterListener in Redirect extension!"},
+
+    { ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX,
+      "Prefix in exclude-result-prefixes is not valid: {0}"},
+
+    { ER_MISSING_NS_URI, 
+      "Missing namespace URI for specified prefix"},
+
+    { ER_MISSING_ARG_FOR_OPTION,
+      "Missing argument for option: {0}"},
+
+    { ER_INVALID_OPTION,
+     "Invalid option: {0}"},
+
+    { ER_MALFORMED_FORMAT_STRING,
+     "Malformed format string: {0}"},
+
+    { ER_STYLESHEET_REQUIRES_VERSION_ATTRIB,
+      "xsl:stylesheet requires a 'version' attribute!"},
+
+    { ER_ILLEGAL_ATTRIBUTE_VALUE,
+      "Attribute: {0} has an illegal value: {1}"},
+
+    { ER_CHOOSE_REQUIRES_WHEN,
+     "xsl:choose requires an xsl:when"},
+
+    { ER_NO_APPLY_IMPORT_IN_FOR_EACH,
+      "xsl:apply-imports not allowed in a xsl:for-each"},
+
+    { ER_CANT_USE_DTM_FOR_OUTPUT,
+      "Cannot use a DTMLiaison for an output DOM node... pass a org.apache.xpath.DOM2Helper instead!"},
+
+    { ER_CANT_USE_DTM_FOR_INPUT,
+      "Cannot use a DTMLiaison for a input DOM node... pass a org.apache.xpath.DOM2Helper instead!"},
+
+    { ER_CALL_TO_EXT_FAILED,
+      "Call to extension element failed: {0}"},
+
+    { ER_PREFIX_MUST_RESOLVE,
+      "Prefix must resolve to a namespace: {0}"},
+
+    { ER_INVALID_UTF16_SURROGATE,
+      "Invalid UTF-16 surrogate detected: {0} ?"},
+
+    { ER_XSLATTRSET_USED_ITSELF,
+      "xsl:attribute-set {0} used itself, which will cause an infinite loop."},
+
+    { ER_CANNOT_MIX_XERCESDOM,
+      "Can not mix non Xerces-DOM input with Xerces-DOM output!"},
+
+    { ER_TOO_MANY_LISTENERS,
+      "addTraceListenersToStylesheet - TooManyListenersException"},
+
+    { ER_IN_ELEMTEMPLATEELEM_READOBJECT,
+      "In ElemTemplateElement.readObject: {0}"},
+
+    { ER_DUPLICATE_NAMED_TEMPLATE,
+      "Found more than one template named: {0}"},
+
+    { ER_INVALID_KEY_CALL,
+      "Invalid function call: recursive key() calls are not allowed"},
+
+    { ER_REFERENCING_ITSELF,
+      "Variable {0} is directly or indirectly referencing itself!"},
+
+    { ER_ILLEGAL_DOMSOURCE_INPUT,
+      "The input node can not be null for a DOMSource for newTemplates!"},
+
+    { ER_CLASS_NOT_FOUND_FOR_OPTION,
+	"Class file not found for option {0}"},
+
+    { ER_REQUIRED_ELEM_NOT_FOUND,
+	"Required Element not found: {0}"},
+
+    { ER_INPUT_CANNOT_BE_NULL,
+	"InputStream cannot be null"},
+
+    { ER_URI_CANNOT_BE_NULL,
+	"URI cannot be null"},
+
+    { ER_FILE_CANNOT_BE_NULL,
+	"File cannot be null"},
+
+    { ER_SOURCE_CANNOT_BE_NULL,
+		"InputSource cannot be null"},
+
+    { ER_CANNOT_INIT_BSFMGR,
+		"Could not initialize BSF Manager"},
+
+    { ER_CANNOT_CMPL_EXTENSN,
+		"Could not compile extension"},
+
+    { ER_CANNOT_CREATE_EXTENSN,
+      "Could not create extension: {0} because of: {1}"},
+
+    { ER_INSTANCE_MTHD_CALL_REQUIRES,
+      "Instance method call to method {0} requires an Object instance as first argument"},
+
+    { ER_INVALID_ELEMENT_NAME,
+      "Invalid element name specified {0}"},
+
+    { ER_ELEMENT_NAME_METHOD_STATIC,
+      "Element name method must be static {0}"},
+
+    { ER_EXTENSION_FUNC_UNKNOWN,
+             "Extension function {0} : {1} is unknown"},
+
+    { ER_MORE_MATCH_CONSTRUCTOR,
+             "More than one best match for constructor for {0}"},
+
+    { ER_MORE_MATCH_METHOD,
+             "More than one best match for method {0}"},
+
+    { ER_MORE_MATCH_ELEMENT,
+             "More than one best match for element method {0}"},
+
+    { ER_INVALID_CONTEXT_PASSED,
+             "Invalid context passed to evaluate {0}"},
+
+    { ER_POOL_EXISTS,
+             "Pool already exists"},
+
+    { ER_NO_DRIVER_NAME,
+             "No driver Name specified"},
+
+    { ER_NO_URL,
+             "No URL specified"},
+
+    { ER_POOL_SIZE_LESSTHAN_ONE,
+             "Pool size is less than one!"},
+
+    { ER_INVALID_DRIVER,
+             "Invalid driver name specified!"},
+
+    { ER_NO_STYLESHEETROOT,
+             "Did not find the stylesheet root!"},
+
+    { ER_ILLEGAL_XMLSPACE_VALUE,
+         "Illegal value for xml:space"},
+
+    { ER_PROCESSFROMNODE_FAILED,
+         "processFromNode failed"},
+
+    { ER_RESOURCE_COULD_NOT_LOAD,
+        "The resource [ {0} ] could not load: {1} \n {2} \t {3}"},
+
+    { ER_BUFFER_SIZE_LESSTHAN_ZERO,
+        "Buffer size <=0"},
+
+    { ER_UNKNOWN_ERROR_CALLING_EXTENSION,
+        "Unknown error when calling extension"},
+
+    { ER_NO_NAMESPACE_DECL,
+        "Prefix {0} does not have a corresponding namespace declaration"},
+
+    { ER_ELEM_CONTENT_NOT_ALLOWED,
+        "Element content not allowed for lang=javaclass {0}"},
+
+    { ER_STYLESHEET_DIRECTED_TERMINATION,
+        "Stylesheet directed termination"},
+
+    { ER_ONE_OR_TWO,
+        "1 or 2"},
+
+    { ER_TWO_OR_THREE,
+        "2 or 3"},
+
+    { ER_COULD_NOT_LOAD_RESOURCE,
+        "Could not load {0} (check CLASSPATH), now using just the defaults"},
+
+    { ER_CANNOT_INIT_DEFAULT_TEMPLATES,
+        "Cannot initialize default templates"},
+
+    { ER_RESULT_NULL,
+        "Result should not be null"},
+
+    { ER_RESULT_COULD_NOT_BE_SET,
+        "Result could not be set"},
+
+    { ER_NO_OUTPUT_SPECIFIED,
+        "No output specified"},
+
+    { ER_CANNOT_TRANSFORM_TO_RESULT_TYPE,
+        "Can''t transform to a Result of type {0}"},
+
+    { ER_CANNOT_TRANSFORM_SOURCE_TYPE,
+        "Can''t transform a Source of type {0}"},
+
+    { ER_NULL_CONTENT_HANDLER,
+        "Null content handler"},
+
+    { ER_NULL_ERROR_HANDLER,
+        "Null error handler"},
+
+    { ER_CANNOT_CALL_PARSE,
+        "parse can not be called if the ContentHandler has not been set"},
+
+    { ER_NO_PARENT_FOR_FILTER,
+        "No parent for filter"},
+
+    { ER_NO_STYLESHEET_IN_MEDIA,
+         "No stylesheet found in: {0}, media= {1}"},
+
+    { ER_NO_STYLESHEET_PI,
+         "No xml-stylesheet PI found in: {0}"},
+
+    { ER_NOT_SUPPORTED,
+       "Not supported: {0}"},
+
+    { ER_PROPERTY_VALUE_BOOLEAN,
+       "Value for property {0} should be a Boolean instance"},
+
+    { ER_COULD_NOT_FIND_EXTERN_SCRIPT,
+         "Could not get to external script at {0}"},
+
+    { ER_RESOURCE_COULD_NOT_FIND,
+        "The resource [ {0} ] could not be found.\n {1}"},
+
+    { ER_OUTPUT_PROPERTY_NOT_RECOGNIZED,
+        "Output property not recognized: {0}"},
+
+    { ER_FAILED_CREATING_ELEMLITRSLT,
+        "Failed creating ElemLiteralResult instance"},
+
+  //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE
+  // In latest Xalan code base key name is  ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care
+  //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc.
+  //NOTE: Not only the key name but message has also been changed. 
+    { ER_VALUE_SHOULD_BE_NUMBER,
+        "Value for {0} should contain a parsable number"},
+
+    { ER_VALUE_SHOULD_EQUAL,
+        "Value for {0} should equal yes or no"},
+
+    { ER_FAILED_CALLING_METHOD,
+        "Failed calling {0} method"},
+
+    { ER_FAILED_CREATING_ELEMTMPL,
+        "Failed creating ElemTemplateElement instance"},
+
+    { ER_CHARS_NOT_ALLOWED,
+        "Characters are not allowed at this point in the document"},
+
+    { ER_ATTR_NOT_ALLOWED,
+        "\"{0}\" attribute is not allowed on the {1} element!"},
+
+    { ER_BAD_VALUE,
+     "{0} bad value {1} "},
+
+    { ER_ATTRIB_VALUE_NOT_FOUND,
+     "{0} attribute value not found "},
+
+    { ER_ATTRIB_VALUE_NOT_RECOGNIZED,
+     "{0} attribute value not recognized "},
+
+    { ER_NULL_URI_NAMESPACE,
+     "Attempting to generate a namespace prefix with a null URI"},
+
+    { ER_NUMBER_TOO_BIG,
+     "Attempting to format a number bigger than the largest Long integer"},
+
+    { ER_CANNOT_FIND_SAX1_DRIVER,
+     "Cannot find SAX1 driver class {0}"},
+
+    { ER_SAX1_DRIVER_NOT_LOADED,
+     "SAX1 driver class {0} found but cannot be loaded"},
+
+    { ER_SAX1_DRIVER_NOT_INSTANTIATED,
+     "SAX1 driver class {0} loaded but cannot be instantiated"},
+
+    { ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER,
+     "SAX1 driver class {0} does not implement org.xml.sax.Parser"},
+
+    { ER_PARSER_PROPERTY_NOT_SPECIFIED,
+     "System property org.xml.sax.parser not specified"},
+
+    { ER_PARSER_ARG_CANNOT_BE_NULL,
+     "Parser argument must not be null"},
+
+    { ER_FEATURE,
+     "Feature: {0}"},
+
+    { ER_PROPERTY,
+     "Property: {0}"},
+
+    { ER_NULL_ENTITY_RESOLVER,
+     "Null entity resolver"},
+
+    { ER_NULL_DTD_HANDLER,
+     "Null DTD handler"},
+
+    { ER_NO_DRIVER_NAME_SPECIFIED,
+     "No Driver Name Specified!"},
+
+    { ER_NO_URL_SPECIFIED,
+     "No URL Specified!"},
+
+    { ER_POOLSIZE_LESS_THAN_ONE,
+     "Pool size is less than 1!"},
+
+    { ER_INVALID_DRIVER_NAME,
+     "Invalid Driver Name Specified!"},
+
+    { ER_ERRORLISTENER,
+     "ErrorListener"},
+
+
+// Note to translators:  The following message should not normally be displayed
+//   to users.  It describes a situation in which the processor has detected
+//   an internal consistency problem in itself, and it provides this message
+//   for the developer to help diagnose the problem.  The name
+//   'ElemTemplateElement' is the name of a class, and should not be
+//   translated.
+    { ER_ASSERT_NO_TEMPLATE_PARENT,
+     "Programmer's error! The expression has no ElemTemplateElement parent!"},
+
+
+// Note to translators:  The following message should not normally be displayed
+//   to users.  It describes a situation in which the processor has detected
+//   an internal consistency problem in itself, and it provides this message
+//   for the developer to help diagnose the problem.  The substitution text
+//   provides further information in order to diagnose the problem.  The name
+//   'RedundentExprEliminator' is the name of a class, and should not be
+//   translated.
+    { ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR,
+     "Programmer''s assertion in RedundentExprEliminator: {0}"},
+
+    { ER_NOT_ALLOWED_IN_POSITION,
+     "{0} is not allowed in this position in the stylesheet!"},
+
+    { ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION,
+     "Non-whitespace text is not allowed in this position in the stylesheet!"},
+
+  // This code is shared with warning codes.
+  // SystemId Unknown
+    { INVALID_TCHAR,
+     "Illegal value: {1} used for CHAR attribute: {0}.  An attribute of type CHAR must be only 1 character!"},
+
+    // Note to translators:  The following message is used if the value of
+    // an attribute in a stylesheet is invalid.  "QNAME" is the XML data-type of
+    // the attribute, and should not be translated.  The substitution text {1} is
+    // the attribute value and {0} is the attribute name.
+  //The following codes are shared with the warning codes...
+    { INVALID_QNAME,
+     "Illegal value: {1} used for QNAME attribute: {0}"},
+
+    // Note to translators:  The following message is used if the value of
+    // an attribute in a stylesheet is invalid.  "ENUM" is the XML data-type of
+    // the attribute, and should not be translated.  The substitution text {1} is
+    // the attribute value, {0} is the attribute name, and {2} is a list of valid
+    // values.
+    { INVALID_ENUM,
+     "Illegal value: {1} used for ENUM attribute: {0}.  Valid values are: {2}."},
+
+// Note to translators:  The following message is used if the value of
+// an attribute in a stylesheet is invalid.  "NMTOKEN" is the XML data-type
+// of the attribute, and should not be translated.  The substitution text {1} is
+// the attribute value and {0} is the attribute name.
+    { INVALID_NMTOKEN,
+     "Illegal value: {1} used for NMTOKEN attribute: {0} "},
+
+// Note to translators:  The following message is used if the value of
+// an attribute in a stylesheet is invalid.  "NCNAME" is the XML data-type
+// of the attribute, and should not be translated.  The substitution text {1} is
+// the attribute value and {0} is the attribute name.
+    { INVALID_NCNAME,
+     "Illegal value: {1} used for NCNAME attribute: {0} "},
+
+// Note to translators:  The following message is used if the value of
+// an attribute in a stylesheet is invalid.  "boolean" is the XSLT data-type
+// of the attribute, and should not be translated.  The substitution text {1} is
+// the attribute value and {0} is the attribute name.
+    { INVALID_BOOLEAN,
+     "Illegal value: {1} used for boolean attribute: {0} "},
+
+// Note to translators:  The following message is used if the value of
+// an attribute in a stylesheet is invalid.  "number" is the XSLT data-type
+// of the attribute, and should not be translated.  The substitution text {1} is
+// the attribute value and {0} is the attribute name.
+     { INVALID_NUMBER,
+     "Illegal value: {1} used for number attribute: {0} "},
+
+
+  // End of shared codes...
+
+// Note to translators:  A "match pattern" is a special form of XPath expression
+// that is used for matching patterns.  The substitution text is the name of
+// a function.  The message indicates that when this function is referenced in
+// a match pattern, its argument must be a string literal (or constant.)
+// ER_ARG_LITERAL - new error message for bugzilla //5202
+    { ER_ARG_LITERAL,
+     "Argument to {0} in match pattern must be a literal."},
+
+// Note to translators:  The following message indicates that two definitions of
+// a variable.  A "global variable" is a variable that is accessible everywher
+// in the stylesheet.
+// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790
+    { ER_DUPLICATE_GLOBAL_VAR,
+     "Duplicate global variable declaration."},
+
+
+// Note to translators:  The following message indicates that two definitions of
+// a variable were encountered.
+// ER_DUPLICATE_VAR - new error message for bugzilla #790
+    { ER_DUPLICATE_VAR,
+     "Duplicate variable declaration."},
+
+    // Note to translators:  "xsl:template, "name" and "match" are XSLT keywords
+    // which must not be translated.
+    // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789
+    { ER_TEMPLATE_NAME_MATCH,
+     "xsl:template must have a name or match attribute (or both)"},
+
+    // Note to translators:  "exclude-result-prefixes" is an XSLT keyword which
+    // should not be translated.  The message indicates that a namespace prefix
+    // encountered as part of the value of the exclude-result-prefixes attribute
+    // was in error.
+    // ER_INVALID_PREFIX - new error message for bugzilla #788
+    { ER_INVALID_PREFIX,
+     "Prefix in exclude-result-prefixes is not valid: {0}"},
+
+    // Note to translators:  An "attribute set" is a set of attributes that can
+    // be added to an element in the output document as a group.  The message
+    // indicates that there was a reference to an attribute set named {0} that
+    // was never defined.
+    // ER_NO_ATTRIB_SET - new error message for bugzilla #782
+    { ER_NO_ATTRIB_SET,
+     "attribute-set named {0} does not exist"},
+     
+    // Note to translators:  This message indicates that there was a reference
+    // to a function named {0} for which no function definition could be found.
+    { ER_FUNCTION_NOT_FOUND,
+     "The function named {0} does not exist"},
+
+    // Note to translators:  This message indicates that the XSLT instruction
+    // that is named by the substitution text {0} must not contain other XSLT
+    // instructions (content) or a "select" attribute.  The word "select" is
+    // an XSLT keyword in this case and must not be translated.
+    { ER_CANT_HAVE_CONTENT_AND_SELECT,
+     "The {0} element must not have both content and a select attribute."},
+
+    // Note to translators:  This message indicates that the value argument
+    // of setParameter must be a valid Java Object.
+    { ER_INVALID_SET_PARAM_VALUE,
+     "The value of param {0} must be a valid Java Object"},
+
+    { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT,
+      "The result-prefix attribute of an xsl:namespace-alias element has the value '#default', but there is no declaration of the default namespace in scope for the element"},
+
+    { ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX,
+      "The result-prefix attribute of an xsl:namespace-alias element has the value ''{0}'', but there is no namespace declaration for the prefix ''{0}'' in scope for the element."},
+
+    { ER_SET_FEATURE_NULL_NAME,
+      "The feature name cannot be null in TransformerFactory.setFeature(String name, boolean value)."},
+    
+    { ER_GET_FEATURE_NULL_NAME,
+      "The feature name cannot be null in TransformerFactory.getFeature(String name)."},
+    
+    { ER_UNSUPPORTED_FEATURE,
+      "Cannot set the feature ''{0}'' on this TransformerFactory."},
+    
+    { ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING,
+  	  "Use of the extension element ''{0}'' is not allowed when the secure processing feature is set to true."},
+    
+    { ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, 		
+      "Cannot get the prefix for a null namespace uri."},
+
+    { ER_NAMESPACE_CONTEXT_NULL_PREFIX, 		
+      "Cannot get the namespace uri for null prefix."},
+
+    { ER_XPATH_RESOLVER_NULL_QNAME, 		
+      "The function name cannot be null."},
+
+    { ER_XPATH_RESOLVER_NEGATIVE_ARITY, 		
+      "The arity cannot be negative."},
+  // Warnings...
+
+    { WG_FOUND_CURLYBRACE,
+      "Found '}' but no attribute template open!"},
+
+    { WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR,
+      "Warning: count attribute does not match an ancestor in xsl:number! Target = {0}"},
+
+    { WG_EXPR_ATTRIB_CHANGED_TO_SELECT,
+      "Old syntax: The name of the 'expr' attribute has been changed to 'select'."},
+
+    { WG_NO_LOCALE_IN_FORMATNUMBER,
+      "Xalan doesn't yet handle the locale name in the format-number function."},
+
+    { WG_LOCALE_NOT_FOUND,
+      "Warning: Could not find locale for xml:lang={0}"},
+
+    { WG_CANNOT_MAKE_URL_FROM,
+      "Can not make URL from: {0}"},
+
+    { WG_CANNOT_LOAD_REQUESTED_DOC,
+      "Can not load requested doc: {0}"},
+
+    { WG_CANNOT_FIND_COLLATOR,
+      "Could not find Collator for <sort xml:lang={0}"},
+
+    { WG_FUNCTIONS_SHOULD_USE_URL,
+      "Old syntax: the functions instruction should use a url of {0}"},
+
+    { WG_ENCODING_NOT_SUPPORTED_USING_UTF8,
+      "encoding not supported: {0}, using UTF-8"},
+
+    { WG_ENCODING_NOT_SUPPORTED_USING_JAVA,
+      "encoding not supported: {0}, using Java {1}"},
+
+    { WG_SPECIFICITY_CONFLICTS,
+      "Specificity conflicts found: {0} Last found in stylesheet will be used."},
+
+    { WG_PARSING_AND_PREPARING,
+      "========= Parsing and preparing {0} =========="},
+
+    { WG_ATTR_TEMPLATE,
+     "Attr Template, {0}"},
+
+    { WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE,
+      "Match conflict between xsl:strip-space and xsl:preserve-space"},
+
+    { WG_ATTRIB_NOT_HANDLED,
+      "Xalan does not yet handle the {0} attribute!"},
+
+    { WG_NO_DECIMALFORMAT_DECLARATION,
+      "No declaration found for decimal format: {0}"},
+
+    { WG_OLD_XSLT_NS,
+     "Missing or incorrect XSLT Namespace. "},
+
+    { WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED,
+      "Only one default xsl:decimal-format declaration is allowed."},
+
+    { WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE,
+      "xsl:decimal-format names must be unique. Name \"{0}\" has been duplicated."},
+
+    { WG_ILLEGAL_ATTRIBUTE,
+      "{0} has an illegal attribute: {1}"},
+
+    { WG_COULD_NOT_RESOLVE_PREFIX,
+      "Could not resolve namespace prefix: {0}. The node will be ignored."},
+
+    { WG_STYLESHEET_REQUIRES_VERSION_ATTRIB,
+      "xsl:stylesheet requires a 'version' attribute!"},
+
+    { WG_ILLEGAL_ATTRIBUTE_NAME,
+      "Illegal attribute name: {0}"},
+
+    { WG_ILLEGAL_ATTRIBUTE_VALUE,
+      "Illegal value used for attribute {0}: {1}"},
+
+    { WG_EMPTY_SECOND_ARG,
+      "Resulting nodeset from second argument of document function is empty. Return an empty node-set."},
+
+  //Following are the new WARNING keys added in XALAN code base after Jdk 1.4 (Xalan 2.2-D11)
+
+    // Note to translators:  "name" and "xsl:processing-instruction" are keywords
+    // and must not be translated.
+    { WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML,
+      "The value of the 'name' attribute of xsl:processing-instruction name must not be 'xml'"},
+
+    // Note to translators:  "name" and "xsl:processing-instruction" are keywords
+    // and must not be translated.  "NCName" is an XML data-type and must not be
+    // translated.
+    { WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME,
+      "The value of the ''name'' attribute of xsl:processing-instruction must be a valid NCName: {0}"},
+
+    // Note to translators:  This message is reported if the stylesheet that is
+    // being processed attempted to construct an XML document with an attribute in a
+    // place other than on an element.  The substitution text specifies the name of
+    // the attribute.
+    { WG_ILLEGAL_ATTRIBUTE_POSITION,
+      "Cannot add attribute {0} after child nodes or before an element is produced.  Attribute will be ignored."},
+
+    { NO_MODIFICATION_ALLOWED_ERR,
+      "An attempt is made to modify an object where modifications are not allowed."
+    },
+
+    //Check: WHY THERE IS A GAP B/W NUMBERS in the XSLTErrorResources properties file?
+
+  // Other miscellaneous text used inside the code...
+  { "ui_language", "en"},
+  {  "help_language",  "en" },
+  {  "language",  "en" },
+  { "BAD_CODE", "Parameter to createMessage was out of bounds"},
+  {  "FORMAT_FAILED", "Exception thrown during messageFormat call"},
+  {  "version", ">>>>>>> Xalan Version "},
+  {  "version2",  "<<<<<<<"},
+  {  "yes", "yes"},
+  { "line", "Line #"},
+  { "column","Column #"},
+  { "xsldone", "XSLProcessor: done"},
+
+
+  // Note to translators:  The following messages provide usage information
+  // for the Xalan Process command line.  "Process" is the name of a Java class,
+  // and should not be translated.
+  { "xslProc_option", "Xalan-J command line Process class options:"},
+  { "xslProc_option", "Xalan-J command line Process class options\u003a"},
+  { "xslProc_invalid_xsltc_option", "The option {0} is not supported in XSLTC mode."},
+  { "xslProc_invalid_xalan_option", "The option {0} can only be used with -XSLTC."},
+  { "xslProc_no_input", "Error: No stylesheet or input xml is specified. Run this command without any option for usage instructions."},
+  { "xslProc_common_options", "-Common Options-"},
+  { "xslProc_xalan_options", "-Options for Xalan-"},
+  { "xslProc_xsltc_options", "-Options for XSLTC-"},
+  { "xslProc_return_to_continue", "(press <return> to continue)"},
+
+   // Note to translators: The option name and the parameter name do not need to
+   // be translated. Only translate the messages in parentheses.  Note also that
+   // leading whitespace in the messages is used to indent the usage information
+   // for each option in the English messages.
+   // Do not translate the keywords: XSLTC, SAX, DOM and DTM.
+  { "optionXSLTC", "   [-XSLTC (use XSLTC for transformation)]"},
+  { "optionIN", "   [-IN inputXMLURL]"},
+  { "optionXSL", "   [-XSL XSLTransformationURL]"},
+  { "optionOUT",  "   [-OUT outputFileName]"},
+  { "optionLXCIN", "   [-LXCIN compiledStylesheetFileNameIn]"},
+  { "optionLXCOUT", "   [-LXCOUT compiledStylesheetFileNameOutOut]"},
+  { "optionPARSER", "   [-PARSER fully qualified class name of parser liaison]"},
+  {  "optionE", "   [-E (Do not expand entity refs)]"},
+  {  "optionV",  "   [-E (Do not expand entity refs)]"},
+  {  "optionQC", "   [-QC (Quiet Pattern Conflicts Warnings)]"},
+  {  "optionQ", "   [-Q  (Quiet Mode)]"},
+  {  "optionLF", "   [-LF (Use linefeeds only on output {default is CR/LF})]"},
+  {  "optionCR", "   [-CR (Use carriage returns only on output {default is CR/LF})]"},
+  { "optionESCAPE", "   [-ESCAPE (Which characters to escape {default is <>&\"\'\\r\\n}]"},
+  { "optionINDENT", "   [-INDENT (Control how many spaces to indent {default is 0})]"},
+  { "optionTT", "   [-TT (Trace the templates as they are being called.)]"},
+  { "optionTG", "   [-TG (Trace each generation event.)]"},
+  { "optionTS", "   [-TS (Trace each selection event.)]"},
+  {  "optionTTC", "   [-TTC (Trace the template children as they are being processed.)]"},
+  { "optionTCLASS", "   [-TCLASS (TraceListener class for trace extensions.)]"},
+  { "optionVALIDATE", "   [-VALIDATE (Set whether validation occurs.  Validation is off by default.)]"},
+  { "optionEDUMP", "   [-EDUMP {optional filename} (Do stackdump on error.)]"},
+  {  "optionXML", "   [-XML (Use XML formatter and add XML header.)]"},
+  {  "optionTEXT", "   [-TEXT (Use simple Text formatter.)]"},
+  {  "optionHTML", "   [-HTML (Use HTML formatter.)]"},
+  {  "optionPARAM", "   [-PARAM name expression (Set a stylesheet parameter)]"},
+  {  "noParsermsg1", "XSL Process was not successful."},
+  {  "noParsermsg2", "** Could not find parser **"},
+  { "noParsermsg3",  "Please check your classpath."},
+  { "noParsermsg4", "If you don't have IBM's XML Parser for Java, you can download it from"},
+  { "noParsermsg5", "IBM's AlphaWorks: http://www.alphaworks.ibm.com/formula/xml"},
+  { "optionURIRESOLVER", "   [-URIRESOLVER full class name (URIResolver to be used to resolve URIs)]"},
+  { "optionENTITYRESOLVER",  "   [-ENTITYRESOLVER full class name (EntityResolver to be used to resolve entities)]"},
+  { "optionCONTENTHANDLER",  "   [-CONTENTHANDLER full class name (ContentHandler to be used to serialize output)]"},
+  {  "optionLINENUMBERS",  "   [-L use line numbers for source document]"},
+  { "optionSECUREPROCESSING", "   [-SECURE (set the secure processing feature to true.)]"},
+
+    // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11)
+
+
+  {  "optionMEDIA",  "   [-MEDIA mediaType (use media attribute to find stylesheet associated with a document.)]"},
+  {  "optionFLAVOR",  "   [-FLAVOR flavorName (Explicitly use s2s=SAX or d2d=DOM to do transform.)] "}, // Added by sboag/scurcuru; experimental
+  { "optionDIAG", "   [-DIAG (Print overall milliseconds transform took.)]"},
+  { "optionINCREMENTAL",  "   [-INCREMENTAL (request incremental DTM construction by setting http://xml.apache.org/xalan/features/incremental true.)]"},
+  {  "optionNOOPTIMIMIZE",  "   [-NOOPTIMIMIZE (request no stylesheet optimization processing by setting http://xml.apache.org/xalan/features/optimize false.)]"},
+  { "optionRL",  "   [-RL recursionlimit (assert numeric limit on stylesheet recursion depth.)]"},
+  {   "optionXO",  "   [-XO [transletName] (assign the name to the generated translet)]"},
+  {  "optionXD", "   [-XD destinationDirectory (specify a destination directory for translet)]"},
+  {  "optionXJ",  "   [-XJ jarfile (packages translet classes into a jar file of name <jarfile>)]"},
+  {   "optionXP",  "   [-XP package (specifies a package name prefix for all generated translet classes)]"},
+
+  //AddITIONAL  STRINGS that need L10n
+  // Note to translators:  The following message describes usage of a particular
+  // command-line option that is used to enable the "template inlining"
+  // optimization.  The optimization involves making a copy of the code
+  // generated for a template in another template that refers to it.
+  { "optionXN",  "   [-XN (enables template inlining)]" },
+  { "optionXX",  "   [-XX (turns on additional debugging message output)]"},
+  { "optionXT" , "   [-XT (use translet to transform if possible)]"},
+  { "diagTiming"," --------- Transform of {0} via {1} took {2} ms" },
+  { "recursionTooDeep","Template nesting too deep. nesting = {0}, template {1} {2}" },
+  { "nameIs", "name is" },
+  { "matchPatternIs", "match pattern is" }
+
+  };
+  }
+  // ================= INFRASTRUCTURE ======================
+
+  /** String for use when a bad error code was encountered.    */
+  public static final String BAD_CODE = "BAD_CODE";
+
+  /** String for use when formatting of the error string failed.   */
+  public static final String FORMAT_FAILED = "FORMAT_FAILED";
+
+  /** General error string.   */
+  public static final String ERROR_STRING = "#error";
+
+  /** String to prepend to error messages.  */
+  public static final String ERROR_HEADER = "Error: ";
+
+  /** String to prepend to warning messages.    */
+  public static final String WARNING_HEADER = "Warning: ";
+
+  /** String to specify the XSLT module.  */
+  public static final String XSL_HEADER = "XSLT ";
+
+  /** String to specify the XML parser module.  */
+  public static final String XML_HEADER = "XML ";
+
+  /** I don't think this is used any more.
+   * @deprecated  */
+  public static final String QUERY_HEADER = "PATTERN ";
+
+
+  /**
+   *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
+   *   of ResourceBundle.getBundle().
+   *
+   *   @param className the name of the class that implements the resource bundle.
+   *   @return the ResourceBundle
+   *   @throws MissingResourceException
+   */
+  public static final XSLTErrorResources loadResourceBundle(String className)
+          throws MissingResourceException
+  {
+
+    Locale locale = Locale.getDefault();
+    String suffix = getResourceSuffix(locale);
+
+    try
+    {
+
+      // first try with the given locale
+      return (XSLTErrorResources) ResourceBundle.getBundle(className
+              + suffix, locale);
+    }
+    catch (MissingResourceException e)
+    {
+      try  // try to fall back to en_US if we can't load
+      {
+
+        // Since we can't find the localized property file,
+        // fall back to en_US.
+        return (XSLTErrorResources) ResourceBundle.getBundle(className,
+                new Locale("en", "US"));
+      }
+      catch (MissingResourceException e2)
+      {
+
+        // Now we are really in trouble.
+        // very bad, definitely very bad...not going to get very far
+        throw new MissingResourceException(
+          "Could not load any resource bundles.", className, "");
+      }
+    }
+  }
+
+  /**
+   * Return the resource file suffic for the indicated locale
+   * For most locales, this will be based the language code.  However
+   * for Chinese, we do distinguish between Taiwan and PRC
+   *
+   * @param locale the locale
+   * @return an String suffix which canbe appended to a resource name
+   */
+  private static final String getResourceSuffix(Locale locale)
+  {
+
+    String suffix = "_" + locale.getLanguage();
+    String country = locale.getCountry();
+
+    if (country.equals("TW"))
+      suffix += "_" + country;
+
+    return suffix;
+  }
+
+
+}
diff --git a/src/main/java/org/apache/xalan/res/XSLTInfo.properties b/src/main/java/org/apache/xalan/res/XSLTInfo.properties
new file mode 100644
index 0000000..309ac32
--- /dev/null
+++ b/src/main/java/org/apache/xalan/res/XSLTInfo.properties
@@ -0,0 +1,30 @@
+##
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the  "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+#
+# $Id: XSLTInfo.properties 468641 2006-10-28 06:54:42Z minchau $
+#
+#  XSLT Resource File
+#
+
+vendor=Apache Software Foundation
+vendor-url=http://xml.apache.org/xalan-j
+
+# Product Version: Xalan-Java @impl.version@
+
+# W3C XSL Transformations (XSLT) Version 1.0
+version=1.0
diff --git a/src/main/java/org/apache/xalan/res/package.html b/src/main/java/org/apache/xalan/res/package.html
new file mode 100644
index 0000000..b4acbad
--- /dev/null
+++ b/src/main/java/org/apache/xalan/res/package.html
@@ -0,0 +1,26 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<!-- $Id: package.html 468641 2006-10-28 06:54:42Z minchau $ -->
+<html>
+  <title>Xalan resource Package.</title>
+  <body>
+    <p>Contains strings that require internationalization.<p>
+ </body>
+</html>
+
+
diff --git a/src/main/java/org/apache/xalan/serialize/SerializerUtils.java b/src/main/java/org/apache/xalan/serialize/SerializerUtils.java
new file mode 100644
index 0000000..5127989
--- /dev/null
+++ b/src/main/java/org/apache/xalan/serialize/SerializerUtils.java
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: SerializerUtils.java 468642 2006-10-28 06:55:10Z minchau $
+ */
+package org.apache.xalan.serialize;
+
+import javax.xml.transform.TransformerException;
+
+import org.apache.xalan.transformer.TransformerImpl;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.serializer.NamespaceMappings;
+import org.apache.xml.serializer.SerializationHandler;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.objects.XObject;
+import org.xml.sax.SAXException;
+
+/**
+ * Class that contains only static methods that are used to "serialize",
+ * these methods are used by Xalan and are not in org.apache.xml.serializer
+ * because they have dependancies on the packages org.apache.xpath or org.
+ * apache.xml.dtm or org.apache.xalan.transformer. The package org.apache.xml.
+ * serializer should not depend on Xalan or XSLTC.
+ * @xsl.usage internal
+ */
+public class SerializerUtils
+{
+
+    /**
+     * Copy an DOM attribute to the created output element, executing
+     * attribute templates as need be, and processing the xsl:use
+     * attribute.
+     *
+     * @param handler SerializationHandler to which the attributes are added.
+     * @param attr Attribute node to add to SerializationHandler.
+     *
+     * @throws TransformerException
+     */
+    public static void addAttribute(SerializationHandler handler, int attr)
+        throws TransformerException
+    {
+
+        TransformerImpl transformer =
+            (TransformerImpl) handler.getTransformer();
+        DTM dtm = transformer.getXPathContext().getDTM(attr);
+
+        if (SerializerUtils.isDefinedNSDecl(handler, attr, dtm))
+            return;
+
+        String ns = dtm.getNamespaceURI(attr);
+
+        if (ns == null)
+            ns = "";
+
+        // %OPT% ...can I just store the node handle?
+        try
+        {
+            handler.addAttribute(
+                ns,
+                dtm.getLocalName(attr),
+                dtm.getNodeName(attr),
+                "CDATA",
+                dtm.getNodeValue(attr), false);
+        }
+        catch (SAXException e)
+        {
+            // do something?
+        }
+    } // end copyAttributeToTarget method
+
+    /**
+     * Copy DOM attributes to the result element.
+     *
+     * @param src Source node with the attributes
+     *
+     * @throws TransformerException
+     */
+    public static void addAttributes(SerializationHandler handler, int src)
+        throws TransformerException
+    {
+
+        TransformerImpl transformer =
+            (TransformerImpl) handler.getTransformer();
+        DTM dtm = transformer.getXPathContext().getDTM(src);
+
+        for (int node = dtm.getFirstAttribute(src);
+            DTM.NULL != node;
+            node = dtm.getNextAttribute(node))
+        {
+            addAttribute(handler, node);
+        }
+    }
+
+    /**
+     * Given a result tree fragment, walk the tree and
+     * output it to the SerializationHandler.
+     *
+     * @param obj Result tree fragment object
+     * @param support XPath context for the result tree fragment
+     *
+     * @throws org.xml.sax.SAXException
+     */
+    public static void outputResultTreeFragment(
+        SerializationHandler handler,
+        XObject obj,
+        XPathContext support)
+        throws org.xml.sax.SAXException
+    {
+
+        int doc = obj.rtf();
+        DTM dtm = support.getDTM(doc);
+
+        if (null != dtm)
+        {
+            for (int n = dtm.getFirstChild(doc);
+                DTM.NULL != n;
+                n = dtm.getNextSibling(n))
+            {
+                handler.flushPending();
+
+                // I think. . . . This used to have a (true) arg
+                // to flush prefixes, will that cause problems ???
+                if (dtm.getNodeType(n) == DTM.ELEMENT_NODE
+                        && dtm.getNamespaceURI(n) == null)
+                    handler.startPrefixMapping("", "");
+                dtm.dispatchToEvents(n, handler);
+            }
+        }
+    }
+
+    /**
+     * Copy <KBD>xmlns:</KBD> attributes in if not already in scope.
+     *
+     * As a quick hack to support ClonerToResultTree, this can also be used
+     * to copy an individual namespace node.
+     *
+     * @param src Source Node
+     * NEEDSDOC @param type
+     * NEEDSDOC @param dtm
+     *
+     * @throws TransformerException
+     */
+    public static void processNSDecls(
+        SerializationHandler handler,
+        int src,
+        int type,
+        DTM dtm)
+        throws TransformerException
+    {
+
+        try
+        {
+            if (type == DTM.ELEMENT_NODE)
+            {
+                for (int namespace = dtm.getFirstNamespaceNode(src, true);
+                    DTM.NULL != namespace;
+                    namespace = dtm.getNextNamespaceNode(src, namespace, true))
+                {
+
+                    // String prefix = dtm.getPrefix(namespace);
+                    String prefix = dtm.getNodeNameX(namespace);
+                    String desturi = handler.getNamespaceURIFromPrefix(prefix);
+                    //            String desturi = getURI(prefix);
+                    String srcURI = dtm.getNodeValue(namespace);
+
+                    if (!srcURI.equalsIgnoreCase(desturi))
+                    {
+                        handler.startPrefixMapping(prefix, srcURI, false);
+                    }
+                }
+            }
+            else if (type == DTM.NAMESPACE_NODE)
+            {
+                String prefix = dtm.getNodeNameX(src);
+                // Brian M. - some changes here to get desturi
+                String desturi = handler.getNamespaceURIFromPrefix(prefix);
+                String srcURI = dtm.getNodeValue(src);
+
+                if (!srcURI.equalsIgnoreCase(desturi))
+                {
+                    handler.startPrefixMapping(prefix, srcURI, false);
+                }
+            }
+        }
+        catch (org.xml.sax.SAXException se)
+        {
+            throw new TransformerException(se);
+        }
+    }
+
+    /**
+     * 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 static boolean isDefinedNSDecl(
+        SerializationHandler serializer,
+        int attr,
+        DTM dtm)
+    {
+
+        if (DTM.NAMESPACE_NODE == dtm.getNodeType(attr))
+        {
+
+            // String prefix = dtm.getPrefix(attr);
+            String prefix = dtm.getNodeNameX(attr);
+            String uri = serializer.getNamespaceURIFromPrefix(prefix);
+            //      String uri = getURI(prefix);
+
+            if ((null != uri) && uri.equals(dtm.getStringValue(attr)))
+                return true;
+        }
+
+        return 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
+     *
+     * NEEDSDOC @param dtm
+     * NEEDSDOC @param namespace
+     *
+     * @throws org.xml.sax.SAXException
+     */
+    public static void ensureNamespaceDeclDeclared(
+        SerializationHandler handler,
+        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;
+            NamespaceMappings ns = handler.getNamespaceMappings();
+            if (ns != null)
+            {
+
+                foundURI = ns.lookupNamespace(prefix);
+                if ((null == foundURI) || !foundURI.equals(uri))
+                {
+                    handler.startPrefixMapping(prefix, uri, false);
+                }
+            }
+        }
+    }
+}
diff --git a/src/main/java/org/apache/xalan/templates/AVT.java b/src/main/java/org/apache/xalan/templates/AVT.java
new file mode 100644
index 0000000..a8247e1
--- /dev/null
+++ b/src/main/java/org/apache/xalan/templates/AVT.java
@@ -0,0 +1,614 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: AVT.java 469221 2006-10-30 18:26:44Z minchau $
+ */
+package org.apache.xalan.templates;
+
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import javax.xml.transform.TransformerException;
+
+import org.apache.xalan.processor.StylesheetHandler;
+import org.apache.xalan.res.XSLMessages;
+import org.apache.xalan.res.XSLTErrorResources;
+import org.apache.xml.utils.FastStringBuffer;
+import org.apache.xml.utils.StringBufferPool;
+import org.apache.xpath.XPath;
+import org.apache.xpath.XPathContext;
+
+/**
+ * Class to hold an Attribute Value Template.
+ * @xsl.usage advanced
+ */
+public class AVT implements java.io.Serializable, XSLTVisitable
+{
+    static final long serialVersionUID = 5167607155517042691L;
+  
+  /**
+    *We are not going to use the object pool if USE_OBJECT_POOL == false.
+  */
+  private final static boolean USE_OBJECT_POOL = false; 
+  
+  /**
+    * INIT_BUFFER_CHUNK_BITS is used to set initial size of
+    * of the char m_array in FastStringBuffer if USE_OBJECT_POOL == false. 
+    * size = 2^ INIT_BUFFER_CHUNK_BITS, INIT_BUFFER_CHUNK_BITS = 7 
+    * corresponds size = 256. 
+  */
+  private final static int INIT_BUFFER_CHUNK_BITS = 8; 
+  
+  /**
+   * If the AVT is not complex, just hold the simple string.
+   * @serial
+   */
+  private String m_simpleString = null;
+
+  /**
+   * If the AVT is complex, hold a Vector of AVTParts.
+   * @serial
+   */
+  private Vector m_parts = null;
+  
+   
+
+  /**
+   * The name of the attribute.
+   * @serial
+   */
+  private String m_rawName;
+
+  /**
+   * Get the raw name of the attribute, with the prefix unprocessed.
+   *
+   * @return non-null reference to prefixed name.
+   */
+  public String getRawName()
+  {
+    return m_rawName;
+  }
+
+  /**
+   * Get the raw name of the attribute, with the prefix unprocessed.
+   *
+   * @param rawName non-null reference to prefixed name.
+   */
+  public void setRawName(String rawName)
+  {
+    m_rawName = rawName;
+  }
+
+  /**
+   * The name of the attribute.
+   * @serial
+   */
+  private String m_name;
+
+  /**
+   * Get the local name of the attribute.
+   *
+   * @return non-null reference to name string.
+   */
+  public String getName()
+  {
+    return m_name;
+  }
+
+  /**
+   * Set the local name of the attribute.
+   *
+   * @param name non-null reference to name string.
+   */
+  public void setName(String name)
+  {
+    m_name = name;
+  }
+
+  /**
+   * The namespace URI of the owning attribute.
+   * @serial
+   */
+  private String m_uri;
+
+  /**
+   * Get the namespace URI of the attribute.
+   *
+   * @return non-null reference to URI, "" if null namespace.
+   */
+  public String getURI()
+  {
+    return m_uri;
+  }
+
+  /**
+   * Get the namespace URI of the attribute.
+   *
+   * @param uri non-null reference to URI, "" if null namespace.
+   */
+  public void setURI(String uri)
+  {
+    m_uri = uri;
+  }
+
+  /**
+   * Construct an AVT by parsing the string, and either
+   * constructing a vector of AVTParts, or simply hold
+   * on to the string if the AVT is simple.
+   *
+   * @param handler non-null reference to StylesheetHandler that is constructing.
+   * @param uri non-null reference to URI, "" if null namespace.
+   * @param name  non-null reference to name string.
+   * @param rawName prefixed name.
+   * @param stringedValue non-null raw string value.
+   *
+   * @throws javax.xml.transform.TransformerException
+   */
+  public AVT(StylesheetHandler handler, String uri, String name, 
+             String rawName, String stringedValue,
+             ElemTemplateElement owner)
+          throws javax.xml.transform.TransformerException
+  {
+
+    m_uri = uri;
+    m_name = name;
+    m_rawName = rawName;
+
+    StringTokenizer tokenizer = new StringTokenizer(stringedValue, "{}\"\'",
+                                  true);
+    int nTokens = tokenizer.countTokens();
+
+    if (nTokens < 2)
+    {
+      m_simpleString = stringedValue;  // then do the simple thing
+    }
+    else
+    {
+      FastStringBuffer buffer = null;
+      FastStringBuffer exprBuffer = null;
+      if(USE_OBJECT_POOL){
+        buffer = StringBufferPool.get(); 
+        exprBuffer = StringBufferPool.get();
+      }else{
+        buffer = new FastStringBuffer(6);
+        exprBuffer = new FastStringBuffer(6);
+      }
+      try
+      {
+        m_parts = new Vector(nTokens + 1);
+
+        String t = null;  // base token
+        String lookahead = null;  // next token
+        String error = null;  // if non-null, break from loop
+
+        while (tokenizer.hasMoreTokens())
+        {
+          if (lookahead != null)
+          {
+            t = lookahead;
+            lookahead = null;
+          }
+          else
+            t = tokenizer.nextToken();
+
+          if (t.length() == 1)
+          {
+            switch (t.charAt(0))
+            {
+            case ('\"') :
+            case ('\'') :
+            {
+
+              // just keep on going, since we're not in an attribute template
+              buffer.append(t);
+
+              break;
+            }
+            case ('{') :
+            {
+
+              try
+              {
+                // Attribute Value Template start
+                lookahead = tokenizer.nextToken();
+
+                if (lookahead.equals("{"))
+                {
+
+                  // Double curlys mean escape to show curly
+                  buffer.append(lookahead);
+
+                  lookahead = null;
+
+                  break;  // from switch
+                }
+
+                /*
+                else if(lookahead.equals("\"") || lookahead.equals("\'"))
+                {
+                // Error. Expressions can not begin with quotes.
+                error = "Expressions can not begin with quotes.";
+                break; // from switch
+                }
+                */
+                else
+                {
+                  if (buffer.length() > 0)
+                  {
+                    m_parts.addElement(new AVTPartSimple(buffer.toString()));
+                    buffer.setLength(0);
+                  }
+
+                  exprBuffer.setLength(0);
+
+                  while (null != lookahead)
+                  {
+                    if (lookahead.length() == 1)
+                    {
+                      switch (lookahead.charAt(0))
+                      {
+                      case '\'' :
+                      case '\"' :
+                        {
+
+                          // String start
+                          exprBuffer.append(lookahead);
+
+                          String quote = lookahead;
+
+                          // Consume stuff 'till next quote
+                          lookahead = tokenizer.nextToken();
+
+                          while (!lookahead.equals(quote))
+                          {
+                            exprBuffer.append(lookahead);
+
+                            lookahead = tokenizer.nextToken();
+                          }
+
+                          exprBuffer.append(lookahead);
+
+                          lookahead = tokenizer.nextToken();
+
+                          break;
+                        }
+                      case '{' :
+                        {
+
+                          // What's another curly doing here?
+                          error = XSLMessages.createMessage(
+                                                            XSLTErrorResources.ER_NO_CURLYBRACE, null);  //"Error: Can not have \"{\" within expression.";
+                          
+                          lookahead = null;  // breaks out of inner while loop
+
+                          break;
+                        }
+                      case '}' :
+                        {
+
+                          // Proper close of attribute template.
+                          // Evaluate the expression.
+                          buffer.setLength(0);
+
+                          XPath xpath =
+                                       handler.createXPath(exprBuffer.toString(), owner);
+
+                          m_parts.addElement(new AVTPartXPath(xpath));
+
+                          lookahead = null;  // breaks out of inner while loop
+
+                          break;
+                        }
+                      default :
+                        {
+
+                          // part of the template stuff, just add it.
+                          exprBuffer.append(lookahead);
+
+                          lookahead = tokenizer.nextToken();
+                        }
+                      }  // end inner switch
+                    }  // end if lookahead length == 1
+                    else
+                    {
+
+                      // part of the template stuff, just add it.
+                      exprBuffer.append(lookahead);
+
+                      lookahead = tokenizer.nextToken();
+                    }
+                  }  // end while(!lookahead.equals("}"))
+
+                  if (error != null)
+                  {
+                    break;  // from inner while loop
+                  }
+                }
+
+                break;
+              }
+              catch (java.util.NoSuchElementException ex)
+              {
+                error = XSLMessages.createMessage(XSLTErrorResources.ER_ILLEGAL_ATTRIBUTE_VALUE, new Object[]{ name, stringedValue }); 
+                break;
+              }
+            }
+            case ('}') :
+            {
+              lookahead = tokenizer.nextToken();
+
+              if (lookahead.equals("}"))
+              {
+
+                // Double curlys mean escape to show curly
+                buffer.append(lookahead);
+
+                lookahead = null;  // swallow
+              }
+              else
+              {
+
+                // Illegal, I think...
+                try
+                {
+                  handler.warn(XSLTErrorResources.WG_FOUND_CURLYBRACE, null);  //"Found \"}\" but no attribute template open!");
+                }
+                catch (org.xml.sax.SAXException se)
+                {
+                  throw new TransformerException(se);
+                }
+
+                buffer.append("}");
+
+                // leave the lookahead to be processed by the next round.
+              }
+
+              break;
+            }
+            default :
+            {
+
+              // Anything else just add to string.
+              buffer.append(t);
+            }
+            }  // end switch t
+          }  // end if length == 1
+          else
+          {
+
+            // Anything else just add to string.
+            buffer.append(t);
+          }
+
+          if (null != error)
+          {
+            try
+            {
+              handler.warn(XSLTErrorResources.WG_ATTR_TEMPLATE,
+                           new Object[]{ error });  //"Attr Template, "+error);
+            }
+            catch (org.xml.sax.SAXException se)
+            {
+              throw new TransformerException(se);
+            }
+
+            break;
+          }
+        }  // end while(tokenizer.hasMoreTokens())
+
+        if (buffer.length() > 0)
+        {
+          m_parts.addElement(new AVTPartSimple(buffer.toString()));
+          buffer.setLength(0);
+        }
+      }
+      finally
+      {
+        if(USE_OBJECT_POOL){
+             StringBufferPool.free(buffer);
+             StringBufferPool.free(exprBuffer);
+         }else{
+            buffer = null;
+            exprBuffer = null;
+         };
+      }
+    }  // end else nTokens > 1
+
+    if (null == m_parts && (null == m_simpleString))
+    {
+
+      // Error?
+      m_simpleString = "";
+    }
+  }
+
+  /**
+   * Get the AVT as the original string.
+   *
+   * @return The AVT as the original string
+   */
+  public String getSimpleString()
+  {
+
+    if (null != m_simpleString){
+      return m_simpleString;
+    }
+    else if (null != m_parts){
+     final FastStringBuffer buf = getBuffer();
+     String out = null;
+
+    int n = m_parts.size();
+    try{
+      for (int i = 0; i < n; i++){
+        AVTPart part = (AVTPart) m_parts.elementAt(i);
+        buf.append(part.getSimpleString());
+      }
+      out = buf.toString();
+    }finally{
+      if(USE_OBJECT_POOL){
+         StringBufferPool.free(buf);
+     }else{
+        buf.setLength(0); 
+     };
+    }
+    return out;
+  }else{
+      return "";
+  }
+}
+
+  /**
+   * Evaluate the AVT and return a String.
+   *
+   * @param xctxt Te XPathContext to use to evaluate this.
+   * @param context The current source tree context.
+   * @param nsNode The current namespace context (stylesheet tree context).
+   *
+   * @return The AVT evaluated as a string
+   *
+   * @throws javax.xml.transform.TransformerException
+   */
+  public String evaluate(
+          XPathContext xctxt, int context, org.apache.xml.utils.PrefixResolver nsNode)
+            throws javax.xml.transform.TransformerException
+  {
+    if (null != m_simpleString){
+        return m_simpleString;
+    }else if (null != m_parts){
+      final FastStringBuffer buf =getBuffer();
+      String out = null;
+      int n = m_parts.size();
+      try{
+        for (int i = 0; i < n; i++){
+          AVTPart part = (AVTPart) m_parts.elementAt(i);  
+          part.evaluate(xctxt, buf, context, nsNode);
+        }
+       out = buf.toString();
+      }finally{
+          if(USE_OBJECT_POOL){
+             StringBufferPool.free(buf);
+         }else{
+           buf.setLength(0); 
+         }
+      }
+     return out;
+    }else{
+      return "";
+    }
+  }
+
+  /**
+   * Test whether the AVT is insensitive to the context in which
+   *  it is being evaluated. This is intended to facilitate
+   *  compilation of templates, by allowing simple AVTs to be
+   *  converted back into strings.
+   *
+   *  Currently the only case we recognize is simple strings.
+   * ADDED 9/5/2000 to support compilation experiment
+   *
+   * @return True if the m_simpleString member of this AVT is not null
+   */
+  public boolean isContextInsensitive()
+  {
+    return null != m_simpleString;
+  }
+
+  /**
+   * Tell if this expression or it's subexpressions can traverse outside
+   * the current subtree.
+   *
+   * @return true if traversal outside the context node's subtree can occur.
+   */
+  public boolean canTraverseOutsideSubtree()
+  {
+
+    if (null != m_parts)
+    {
+      int n = m_parts.size();
+
+      for (int i = 0; i < n; i++)
+      {
+        AVTPart part = (AVTPart) m_parts.elementAt(i);
+
+        if (part.canTraverseOutsideSubtree())
+          return true;
+      }
+    }
+
+    return false;
+  }
+  
+  /**
+   * This function is used to fixup variables from QNames to stack frame 
+   * indexes at stylesheet build time.
+   * @param vars List of QNames that correspond to variables.  This list 
+   * should be searched backwards for the first qualified name that 
+   * corresponds to the variable reference qname.  The position of the 
+   * QName in the vector from the start of the vector will be its position 
+   * in the stack frame (but variables above the globalsTop value will need 
+   * to be offset to the current stack frame).
+   */
+  public void fixupVariables(java.util.Vector vars, int globalsSize)
+  {
+    if (null != m_parts)
+    {
+      int n = m_parts.size();
+
+      for (int i = 0; i < n; i++)
+      {
+        AVTPart part = (AVTPart) m_parts.elementAt(i);
+
+        part.fixupVariables(vars, globalsSize);
+      }
+    }
+  }
+  
+  /**
+   * @see XSLTVisitable#callVisitors(XSLTVisitor)
+   */
+  public void callVisitors(XSLTVisitor visitor)
+  {
+  	if(visitor.visitAVT(this) && (null != m_parts))
+  	{
+      int n = m_parts.size();
+
+      for (int i = 0; i < n; i++)
+      {
+        AVTPart part = (AVTPart) m_parts.elementAt(i);
+
+        part.callVisitors(visitor);
+      }  		
+  	}
+  }
+
+
+  /**
+   * Returns true if this AVT is simple
+   */
+  public boolean isSimple() {
+  	return m_simpleString != null;
+  }
+  
+  private final FastStringBuffer getBuffer(){
+    if(USE_OBJECT_POOL){
+      return StringBufferPool.get();
+    }else{
+      return new FastStringBuffer(INIT_BUFFER_CHUNK_BITS);
+    }
+  }
+}
diff --git a/src/main/java/org/apache/xalan/templates/AVTPart.java b/src/main/java/org/apache/xalan/templates/AVTPart.java
new file mode 100644
index 0000000..4d9a02d
--- /dev/null
+++ b/src/main/java/org/apache/xalan/templates/AVTPart.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: AVTPart.java 468643 2006-10-28 06:56:03Z minchau $
+ */
+package org.apache.xalan.templates;
+
+import org.apache.xml.utils.FastStringBuffer;
+import org.apache.xpath.XPathContext;
+
+/**
+ * Class to hold a part, either a string or XPath,
+ * of an Attribute Value Template.
+ * @xsl.usage internal
+ */
+public abstract class AVTPart implements java.io.Serializable, XSLTVisitable
+{
+    static final long serialVersionUID = -1747749903613916025L;
+
+  /**
+   * Construct a part.
+   */
+  public AVTPart(){}
+
+  /**
+   * Get the AVT part as the original string.
+   *
+   * @return the AVT part as the original string.
+   */
+  public abstract String getSimpleString();
+
+  /**
+   * Write the evaluated value into the given
+   * string buffer.
+   *
+   * @param xctxt The XPath context to use to evaluate this AVT.
+   * @param buf Buffer to write into.
+   * @param context The current source tree context.
+   * @param nsNode The current namespace context (stylesheet tree context).
+   *
+   * @throws javax.xml.transform.TransformerException
+   */
+  public abstract void evaluate(
+    XPathContext xctxt, FastStringBuffer buf, int context,
+      org.apache.xml.utils.PrefixResolver nsNode)
+        throws javax.xml.transform.TransformerException;
+
+  /**
+   * Set the XPath support.
+   *
+   * @param support XPathContext to set. 
+   */
+  public void setXPathSupport(XPathContext support){}
+  
+  /**
+   * Tell if this expression or it's subexpressions can traverse outside 
+   * the current subtree.
+   * 
+   * @return true if traversal outside the context node's subtree can occur.
+   */
+   public boolean canTraverseOutsideSubtree()
+   {
+    return false;
+   }
+   
+  /**
+   * This function is used to fixup variables from QNames to stack frame 
+   * indexes at stylesheet build time.
+   * @param vars List of QNames that correspond to variables.  This list 
+   * should be searched backwards for the first qualified name that 
+   * corresponds to the variable reference qname.  The position of the 
+   * QName in the vector from the start of the vector will be its position 
+   * in the stack frame (but variables above the globalsTop value will need 
+   * to be offset to the current stack frame).
+   */
+  public abstract void fixupVariables(java.util.Vector vars, int globalsSize);
+
+
+}
diff --git a/src/main/java/org/apache/xalan/templates/AVTPartSimple.java b/src/main/java/org/apache/xalan/templates/AVTPartSimple.java
new file mode 100644
index 0000000..0e489d3
--- /dev/null
+++ b/src/main/java/org/apache/xalan/templates/AVTPartSimple.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: AVTPartSimple.java 468643 2006-10-28 06:56:03Z minchau $
+ */
+package org.apache.xalan.templates;
+
+import org.apache.xml.utils.FastStringBuffer;
+import org.apache.xpath.XPathContext;
+
+/**
+ * Simple string part of a complex AVT.
+ * @xsl.usage internal
+ */
+public class AVTPartSimple extends AVTPart
+{
+    static final long serialVersionUID = -3744957690598727913L;
+
+  /**
+   * Simple string value;
+   * @serial
+   */
+  private String m_val;
+
+  /**
+   * Construct a simple AVT part.
+   * @param val A pure string section of an AVT.
+   */
+  public AVTPartSimple(String val)
+  {
+    m_val = val;
+  }
+
+  /**
+   * Get the AVT part as the original string.
+   *
+   * @return the AVT part as the original string.
+   */
+  public String getSimpleString()
+  {
+    return m_val;
+  }
+  
+  /**
+   * This function is used to fixup variables from QNames to stack frame 
+   * indexes at stylesheet build time.
+   * @param vars List of QNames that correspond to variables.  This list 
+   * should be searched backwards for the first qualified name that 
+   * corresponds to the variable reference qname.  The position of the 
+   * QName in the vector from the start of the vector will be its position 
+   * in the stack frame (but variables above the globalsTop value will need 
+   * to be offset to the current stack frame).
+   */
+  public void fixupVariables(java.util.Vector vars, int globalsSize)
+  {
+    // no-op
+  }
+
+
+  /**
+   * Write the value into the buffer.
+   *
+   * @param xctxt An XPathContext object, providing infomation specific
+   * to this invocation and this thread. Maintains SAX state, variables, 
+   * error handler and  so on, so the transformation/XPath object itself
+   * can be simultaneously invoked from multiple threads.
+   * @param buf Buffer to write into.
+   * @param context The current source tree context.
+   * @param nsNode The current namespace context (stylesheet tree context).
+   */
+  public void evaluate(XPathContext xctxt, FastStringBuffer buf,
+                       int context,
+                       org.apache.xml.utils.PrefixResolver nsNode)
+  {
+    buf.append(m_val);
+  }
+  /**
+   * @see XSLTVisitable#callVisitors(XSLTVisitor)
+   */
+  public void callVisitors(XSLTVisitor visitor)
+  {
+  	// Don't do anything for the subpart for right now.
+  }
+
+}
diff --git a/src/main/java/org/apache/xalan/templates/AVTPartXPath.java b/src/main/java/org/apache/xalan/templates/AVTPartXPath.java
new file mode 100644
index 0000000..dde5f31
--- /dev/null
+++ b/src/main/java/org/apache/xalan/templates/AVTPartXPath.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: AVTPartXPath.java 468643 2006-10-28 06:56:03Z minchau $
+ */
+package org.apache.xalan.templates;
+
+import org.apache.xml.utils.FastStringBuffer;
+import org.apache.xpath.XPath;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.XPathFactory;
+import org.apache.xpath.compiler.XPathParser;
+import org.apache.xpath.objects.XObject;
+
+/**
+ * Simple string part of a complex AVT.
+ * @xsl.usage internal
+ */
+public class AVTPartXPath extends AVTPart
+{
+    static final long serialVersionUID = -4460373807550527675L;
+
+  /**
+   * The XPath object contained in this part.
+   * @serial
+   */
+  private XPath m_xpath;
+  
+  /**
+   * This function is used to fixup variables from QNames to stack frame 
+   * indexes at stylesheet build time.
+   * @param vars List of QNames that correspond to variables.  This list 
+   * should be searched backwards for the first qualified name that 
+   * corresponds to the variable reference qname.  The position of the 
+   * QName in the vector from the start of the vector will be its position 
+   * in the stack frame (but variables above the globalsTop value will need 
+   * to be offset to the current stack frame).
+   */
+  public void fixupVariables(java.util.Vector vars, int globalsSize)
+  {
+    m_xpath.fixupVariables(vars, globalsSize);
+  }
+  
+  /**
+   * Tell if this expression or it's subexpressions can traverse outside 
+   * the current subtree.
+   * 
+   * @return true if traversal outside the context node's subtree can occur.
+   */
+   public boolean canTraverseOutsideSubtree()
+   {
+    return m_xpath.getExpression().canTraverseOutsideSubtree();
+   }
+
+  /**
+   * Construct a simple AVT part.
+   *
+   * @param xpath Xpath section of AVT 
+   */
+  public AVTPartXPath(XPath xpath)
+  {
+    m_xpath = xpath;
+  }
+
+  /**
+   * Construct a simple AVT part.
+   * 
+   * @param val A pure string section of an AVT.
+   * @param nsNode An object which can be used to determine the
+   * Namespace Name (URI) for any Namespace prefix used in the XPath. 
+   * Usually this is based on the context where the XPath was specified,
+   * such as a node within a Stylesheet.
+   * @param xpathProcessor XPath parser
+   * @param factory XPath factory
+   * @param liaison An XPathContext object, providing infomation specific
+   * to this invocation and this thread. Maintains SAX output state, 
+   * variables, error handler and so on, so the transformation/XPath 
+   * object itself can be simultaneously invoked from multiple threads.
+   *
+   * @throws javax.xml.transform.TransformerException
+   * TODO: Fix or remove this unused c'tor.
+   */
+  public AVTPartXPath(
+          String val, org.apache.xml.utils.PrefixResolver nsNode, 
+          XPathParser xpathProcessor, XPathFactory factory, 
+          XPathContext liaison)
+            throws javax.xml.transform.TransformerException
+  {
+    m_xpath = new XPath(val, null, nsNode, XPath.SELECT, liaison.getErrorListener());
+  }
+
+  /**
+   * Get the AVT part as the original string.
+   *
+   * @return the AVT part as the original string.
+   */
+  public String getSimpleString()
+  {
+    return "{" + m_xpath.getPatternString() + "}";
+  }
+
+  /**
+   * Write the value into the buffer.
+   *
+   * @param xctxt An XPathContext object, providing infomation specific
+   * to this invocation and this thread. Maintains SAX state, variables, 
+   * error handler and  so on, so the transformation/XPath object itself
+   * can be simultaneously invoked from multiple threads.
+   * @param buf Buffer to write into.
+   * @param context The current source tree context.
+   * @param nsNode The current namespace context (stylesheet tree context).
+   *
+   * @throws javax.xml.transform.TransformerException
+   */
+  public void evaluate(
+          XPathContext xctxt, FastStringBuffer buf, int context, org.apache.xml.utils.PrefixResolver nsNode)
+            throws javax.xml.transform.TransformerException
+  {
+
+    XObject xobj = m_xpath.execute(xctxt, context, nsNode);
+
+    if (null != xobj)
+    {
+      xobj.appendToFsb(buf);
+    }
+  }
+  
+  /**
+   * @see XSLTVisitable#callVisitors(XSLTVisitor)
+   */
+  public void callVisitors(XSLTVisitor visitor)
+  {
+  	m_xpath.getExpression().callVisitors(m_xpath, visitor);
+  }
+}
diff --git a/src/main/java/org/apache/xalan/templates/AbsPathChecker.java b/src/main/java/org/apache/xalan/templates/AbsPathChecker.java
new file mode 100644
index 0000000..9303d30
--- /dev/null
+++ b/src/main/java/org/apache/xalan/templates/AbsPathChecker.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: AbsPathChecker.java 468643 2006-10-28 06:56:03Z minchau $
+ */
+package org.apache.xalan.templates;
+
+import org.apache.xpath.ExpressionOwner;
+import org.apache.xpath.XPathVisitor;
+import org.apache.xpath.axes.LocPathIterator;
+import org.apache.xpath.functions.FuncCurrent;
+import org.apache.xpath.functions.FuncExtFunction;
+import org.apache.xpath.functions.Function;
+import org.apache.xpath.operations.Variable;
+
+/**
+ * This class runs over a path expression that is assumed to be absolute, and 
+ * checks for variables and the like that may make it context dependent.
+ */
+public class AbsPathChecker extends XPathVisitor
+{
+	private boolean m_isAbs = true;
+	
+	/**
+	 * Process the LocPathIterator to see if it contains variables 
+	 * or functions that may make it context dependent.
+	 * @param path LocPathIterator that is assumed to be absolute, but needs checking.
+	 * @return true if the path is confirmed to be absolute, false if it 
+	 * may contain context dependencies.
+	 */
+	public boolean checkAbsolute(LocPathIterator path)
+	{
+		m_isAbs = true;
+		path.callVisitors(null, this);
+		return m_isAbs;
+	}
+	
+	/**
+	 * Visit a function.
+	 * @param owner The owner of the expression, to which the expression can 
+	 *              be reset if rewriting takes place.
+	 * @param func The function reference object.
+	 * @return true if the sub expressions should be traversed.
+	 */
+	public boolean visitFunction(ExpressionOwner owner, Function func)
+	{
+		if((func instanceof FuncCurrent) ||
+		   (func instanceof FuncExtFunction))
+			m_isAbs = false;
+		return true;
+	}
+	
+	/**
+	 * Visit a variable reference.
+	 * @param owner The owner of the expression, to which the expression can 
+	 *              be reset if rewriting takes place.
+	 * @param var The variable reference object.
+	 * @return true if the sub expressions should be traversed.
+	 */
+	public boolean visitVariableRef(ExpressionOwner owner, Variable var)
+	{
+		m_isAbs = false;
+		return true;
+	}
+}
+
diff --git a/src/main/java/org/apache/xalan/templates/Constants.java b/src/main/java/org/apache/xalan/templates/Constants.java
new file mode 100644
index 0000000..717fa35
--- /dev/null
+++ b/src/main/java/org/apache/xalan/templates/Constants.java
@@ -0,0 +1,399 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: Constants.java 468643 2006-10-28 06:56:03Z minchau $
+ */
+package org.apache.xalan.templates;
+
+
+/**
+ * Primary constants used in the TransformerImpl classes.
+ * @xsl.usage advanced
+ */
+public class Constants extends org.apache.xml.utils.Constants
+{
+
+  /**
+   * IDs for XSL element types. These are associated
+   * with the string literals in the TransformerImpl class.
+   * Don't change the numbers. NOTE THAT THESE ARE NOT IN
+   * ALPHABETICAL ORDER!
+   * (It's a pity Java doesn't have a real Enumerated Mnemonic
+   * datatype... or a C-like preprocessor in lieu thereof which
+   * could be used to generate and maintain synch between these lists.)
+   */
+  public static final int ELEMNAME_UNDEFINED = -1, ELEMNAME_WITHPARAM = 2,
+                          ELEMNAME_ADDATTRIBUTE = 4, ELEMNAME_ANCHOR = 22,
+
+  //  ELEMNAME_ANCHOR_PATTERN = 23,
+  ELEMNAME_APPLY_TEMPLATES = 50, ELEMNAME_USE = 34, ELEMNAME_CHILDREN = 6,
+                                 ELEMNAME_CHOOSE = 37, ELEMNAME_COMMENT = 59,  // my own
+                                 ELEMNAME_CONSTRUCT = 7,  // my own
+                                 ELEMNAME_CONTENTS = 8, ELEMNAME_COPY = 9,
+                                 ELEMNAME_COPY_OF = 74,
+                                 ELEMNAME_DECIMALFORMAT = 83,
+                                 ELEMNAME_DEFINEATTRIBUTESET = 40,
+
+  //  ELEMNAME_DEFINECONSTANT = 29,
+  //  ELEMNAME_DEFINEMACRO = 10,
+  ELEMNAME_DEFINESCRIPT = 11, ELEMNAME_DISPLAYIF = 12,  // my own
+                              ELEMNAME_EMPTY = 14, ELEMNAME_EVAL = 15,
+                              ELEMNAME_EXPECTEDCHILDREN = 16,
+                              ELEMNAME_EXTENSION = 54,
+                              ELEMNAME_EXTENSIONHANDLER = 63,
+                              ELEMNAME_FOREACH = 28, ELEMNAME_KEY = 31,
+                              ELEMNAME_IF = 36, ELEMNAME_IMPORT = 26,
+                              ELEMNAME_INCLUDE = 27,
+                              ELEMNAME_CALLTEMPLATE = 17,
+                              ELEMNAME_PARAMVARIABLE = 41,
+                              ELEMNAME_NUMBER = 35, ELEMNAME_NSALIAS = 84,
+                              ELEMNAME_OTHERWISE = 39, ELEMNAME_PI = 58,
+                              ELEMNAME_PRESERVESPACE = 33,
+                              ELEMNAME_REMOVEATTRIBUTE = 5,
+                              ELEMNAME_TEMPLATE = 19, ELEMNAME_SORT = 64,
+                              ELEMNAME_STRIPSPACE = 32,
+                              ELEMNAME_STYLESHEET = 25, ELEMNAME_TEXT = 42,
+                              ELEMNAME_VALUEOF = 30, ELEMNAME_WHEN = 38,
+
+  // Pattern by example support  
+  ELEMNAME_ROOT = 44, ELEMNAME_ANY = 45, ELEMNAME_ELEMENT = 46,
+                      ELEMNAME_TARGETELEMENT = 47, ELEMNAME_ATTRIBUTE = 48,
+                      ELEMNAME_TARGETATTRIBUTE = 49, ELEMNAME_URL = 52,  // my own
+                      ELEMNAME_CALL = 55,  // my own
+
+  //  ELEMNAME_WITHPARAM = 56,
+  ELEMNAME_FALLBACK = 57,  // my own
+  ELEMNAME_TARGETPI = 60,  // my own
+  ELEMNAME_TARGETCOMMENT = 61,  // my own
+  ELEMNAME_TARGETTEXT = 62,  // my own
+  ELEMNAME_CSSSTYLECONVERSION = 65,  // my own
+  ELEMNAME_COUNTER = 66, ELEMNAME_COUNTERS = 67,
+  ELEMNAME_COUNTERINCREMENT = 68, ELEMNAME_COUNTERRESET = 69,
+  ELEMNAME_COUNTERSCOPE = 71, ELEMNAME_APPLY_IMPORTS = 72,
+  ELEMNAME_VARIABLE = 73, ELEMNAME_MESSAGE = 75, ELEMNAME_LOCALE = 76,
+  ELEMNAME_LITERALRESULT = 77, ELEMNAME_TEXTLITERALRESULT = 78,
+  ELEMNAME_EXTENSIONCALL = 79, ELEMNAME_EXTENSIONDECL = 85,
+  ELEMNAME_EXTENSIONSCRIPT = 86, ELEMNAME_OUTPUT = 80,
+  ELEMNAME_COMPONENT = 81, ELEMNAME_SCRIPT = 82;
+
+  // Next free number: 90 (88 and 89 used for EXSLT elements);
+
+  /**
+   * Literals for XSL element names.  Note that there are more
+   * names than IDs, because some names map to the same ID.
+   */
+  public static final String       
+	  ELEMNAME_ANCHOR_STRING = "anchor",
+      ELEMNAME_ANY_STRING = "any",  // pattern-by-example support
+      ELEMNAME_APPLY_IMPORTS_STRING = "apply-imports",
+      ELEMNAME_APPLY_TEMPLATES_STRING = "apply-templates",
+      ELEMNAME_ARG_STRING = "arg",
+      ELEMNAME_ATTRIBUTESET_STRING = "attribute-set",
+      ELEMNAME_ATTRIBUTE_STRING = "attribute",  // pattern-by-example support
+      ELEMNAME_CALLTEMPLATEARG_STRING = "invoke-arg",
+      ELEMNAME_CALLTEMPLATE_STRING = "call-template",
+      ELEMNAME_CALL_STRING = "call",
+      ELEMNAME_CHILDREN_STRING = "children",
+      ELEMNAME_CHOOSE_STRING = "choose",
+      ELEMNAME_COMMENT_STRING = "comment",
+      ELEMNAME_COMPONENT_STRING = "component",
+      ELEMNAME_CONSTRUCT_STRING = "construct",  // my own
+      ELEMNAME_CONTENTS_STRING = "contents", 
+      ELEMNAME_COPY_OF_STRING ="copy-of",
+      ELEMNAME_COPY_STRING = "copy",
+      ELEMNAME_COUNTERINCREMENT_STRING = "counter-increment",
+      ELEMNAME_COUNTERRESET_STRING = "counter-reset",
+      ELEMNAME_COUNTERSCOPE_STRING = "counter-scope",
+      ELEMNAME_COUNTERS_STRING = "counters",
+      ELEMNAME_COUNTER_STRING = "counter",
+      ELEMNAME_CSSSTYLECONVERSION_STRING = "css-style-conversion",
+      ELEMNAME_DECIMALFORMAT_STRING = "decimal-format",
+      ELEMNAME_DISPLAYIF_STRING = "display-if",  // my own
+      ELEMNAME_ELEMENT_STRING = "element",  // pattern-by-example support
+      ELEMNAME_EMPTY_STRING = "empty",
+      ELEMNAME_EVAL_STRING = "eval",
+      ELEMNAME_EXPECTEDCHILDREN_STRING = "expectedchildren",
+      ELEMNAME_EXTENSIONHANDLER_STRING = "code-dispatcher",
+      ELEMNAME_EXTENSION_STRING = "functions",
+      ELEMNAME_FALLBACK_STRING = "fallback",
+      ELEMNAME_FOREACH_STRING = "for-each",
+      ELEMNAME_IF_STRING = "if",
+      ELEMNAME_IMPORT_STRING = "import",
+      ELEMNAME_INCLUDE_STRING = "include",
+      ELEMNAME_KEY_STRING = "key",
+      ELEMNAME_LOCALE_STRING = "locale",
+      ELEMNAME_MESSAGE_STRING = "message",
+      ELEMNAME_NSALIAS_STRING = "namespace-alias",
+      ELEMNAME_NUMBER_STRING = "number",
+      ELEMNAME_OTHERWISE_STRING = "otherwise",
+      ELEMNAME_OUTPUT_STRING = "output",
+      ELEMNAME_PARAMVARIABLE_STRING = "param",
+      ELEMNAME_PI_OLD_STRING = "pi",
+      ELEMNAME_PI_STRING = "processing-instruction",
+      ELEMNAME_PRESERVESPACE_STRING = "preserve-space",
+      ELEMNAME_ROOT_STRING = "root",  // pattern-by-example support
+      ELEMNAME_SCRIPT_STRING = "script",
+      ELEMNAME_SORT_STRING = "sort",
+      ELEMNAME_STRIPSPACE_STRING = "strip-space",
+      ELEMNAME_STYLESHEET_STRING = "stylesheet",
+      ELEMNAME_TARGETATTRIBUTE_STRING = "target-attribute",  // pattern-by-example support
+      ELEMNAME_TARGETCOMMENT_STRING = "target-comment",
+      ELEMNAME_TARGETELEMENT_STRING = "target-element",  // pattern-by-example support
+      ELEMNAME_TARGETPI_STRING = "target-pi",
+      ELEMNAME_TARGETTEXT_STRING = "target-text",
+      ELEMNAME_TEMPLATE_STRING = "template",
+      ELEMNAME_TEXT_STRING = "text",
+      ELEMNAME_TRANSFORM_STRING = "transform",
+      ELEMNAME_URL_STRING = "uri",  // pattern-by-example support
+      ELEMNAME_USE_STRING = "use",
+      ELEMNAME_VALUEOF_STRING = "value-of",
+      ELEMNAME_VARIABLE_STRING = "variable",
+      ELEMNAME_WHEN_STRING = "when",
+      ELEMNAME_WITHPARAM_STRING = "with-param";
+  
+  /**
+   * Literals for EXSLT function elements.
+   */
+  public static final String
+    EXSLT_ELEMNAME_FUNCTION_STRING = "function",
+    EXSLT_ELEMNAME_FUNCRESULT_STRING = "result";
+  public static final int
+    EXSLT_ELEMNAME_FUNCTION = 88,
+    EXSLT_ELEMNAME_FUNCRESULT = 89;
+  
+  
+  /**
+   * Literals for XSL attribute names.  Note that there may be more
+   * names than IDs, because some names may map to the same ID.
+   */
+  public static final String
+	  ATTRNAME_AMOUNT = "amount",
+      ATTRNAME_ANCESTOR = "ancestor",
+      ATTRNAME_ARCHIVE = "archive",
+      ATTRNAME_ATTRIBUTE = "attribute",
+      ATTRNAME_ATTRIBUTE_SET = "attribute-set",
+      ATTRNAME_CASEORDER = "case-order",
+      ATTRNAME_CLASS = "class",
+      ATTRNAME_CLASSID = "classid",
+      ATTRNAME_CODEBASE = "codebase",
+      ATTRNAME_CODETYPE = "type",
+      ATTRNAME_CONDITION = "condition",
+      ATTRNAME_COPYTYPE = "copy-type",
+      ATTRNAME_COUNT = "count",
+      ATTRNAME_DATATYPE = "data-type",
+      ATTRNAME_DECIMALSEPARATOR = "decimal-separator",
+      ATTRNAME_DEFAULT = "default",
+      ATTRNAME_DEFAULTSPACE = "default-space",
+      ATTRNAME_DEPTH = "with-children",
+      ATTRNAME_DIGIT = "digit",
+      ATTRNAME_DIGITGROUPSEP = "digit-group-sep",
+      ATTRNAME_DISABLE_OUTPUT_ESCAPING = "disable-output-escaping",
+      ATTRNAME_ELEMENT = "element",
+      ATTRNAME_ELEMENTS = "elements",
+      ATTRNAME_EXCLUDE_RESULT_PREFIXES ="exclude-result-prefixes",
+      ATTRNAME_EXPR = "expr",
+      ATTRNAME_EXTENSIONELEMENTPREFIXES = "extension-element-prefixes",
+      ATTRNAME_FORMAT = "format",
+      ATTRNAME_FROM = "from",
+      ATTRNAME_GROUPINGSEPARATOR = "grouping-separator",
+      ATTRNAME_GROUPINGSIZE = "grouping-size",
+      ATTRNAME_HREF = "href",
+      ATTRNAME_ID = "id",
+      ATTRNAME_IMPORTANCE = "importance",
+      ATTRNAME_INDENTRESULT = "indent-result",
+      ATTRNAME_INFINITY = "infinity",
+      ATTRNAME_LANG = "lang",
+      ATTRNAME_LETTERVALUE = "letter-value",
+      ATTRNAME_LEVEL = "level",
+      ATTRNAME_MATCH = "match",
+      ATTRNAME_METHOD = "calls",
+      ATTRNAME_MINUSSIGN = "minus-sign",
+      ATTRNAME_MODE = "mode",
+      ATTRNAME_NAME = "name",
+      ATTRNAME_NAMESPACE = "namespace",
+      ATTRNAME_NAN = "NaN",
+      ATTRNAME_NDIGITSPERGROUP = "n-digits-per-group",
+      ATTRNAME_NS = "ns",
+      ATTRNAME_ONLY = "only",
+      ATTRNAME_ORDER = "order",
+      ATTRNAME_OUTPUT_CDATA_SECTION_ELEMENTS = "cdata-section-elements",
+      ATTRNAME_OUTPUT_DOCTYPE_PUBLIC = "doctype-public",
+      ATTRNAME_OUTPUT_DOCTYPE_SYSTEM = "doctype-system",
+      ATTRNAME_OUTPUT_ENCODING = "encoding",
+      ATTRNAME_OUTPUT_INDENT = "indent",
+      ATTRNAME_OUTPUT_MEDIATYPE = "media-type",
+      ATTRNAME_OUTPUT_METHOD = "method",  // qname, 
+      ATTRNAME_OUTPUT_OMITXMLDECL = "omit-xml-declaration",
+      ATTRNAME_OUTPUT_STANDALONE = "standalone",
+      ATTRNAME_OUTPUT_VERSION = "version",
+      ATTRNAME_PATTERNSEPARATOR = "pattern-separator",
+      ATTRNAME_PERCENT = "percent",
+      ATTRNAME_PERMILLE = "per-mille",
+      ATTRNAME_PRIORITY = "priority",
+      ATTRNAME_REFID = "refID",
+      ATTRNAME_RESULTNS = "result-ns",
+      ATTRNAME_RESULT_PREFIX = "result-prefix",
+      ATTRNAME_SELECT = "select",
+      ATTRNAME_SEQUENCESRC = "sequence-src",
+      ATTRNAME_STYLE = "style",
+      ATTRNAME_STYLESHEET_PREFIX = "stylesheet-prefix",
+      ATTRNAME_TERMINATE = "terminate",
+      ATTRNAME_TEST = "test",
+      ATTRNAME_TOSTRING = "to-string",
+      ATTRNAME_TYPE = "type",
+      ATTRNAME_USE = "use",
+      ATTRNAME_USEATTRIBUTESETS = "use-attribute-sets",
+      ATTRNAME_VALUE = "value",
+      ATTRNAME_VERSION = "version",
+      ATTRNAME_XMLNS = "xmlns:", // namespace declaration prefix -- NOT an attribute by itself
+      ATTRNAME_XMLNSDEF = "xmlns", // default namespace
+      ATTRNAME_XMLSPACE = "xml:space", 
+      ATTRNAME_ZERODIGIT = "zero-digit";
+
+  /** IDs for XSL attribute types. These are associated
+   * with the string literals in the TransformerImpl c