You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mu...@apache.org on 2026/08/02 10:43:06 UTC

(xalan-java) branch xalan-j_xslt3.0_mvn updated: committing xalan-j xslt3.0 implementation improvements

This is an automated email from the ASF dual-hosted git repository.

mukulgandhi pushed a commit to branch xalan-j_xslt3.0_mvn
in repository https://gitbox.apache.org/repos/asf/xalan-java.git


The following commit(s) were added to refs/heads/xalan-j_xslt3.0_mvn by this push:
     new ba21c1bb9 committing xalan-j xslt3.0 implementation improvements
ba21c1bb9 is described below

commit ba21c1bb99d49120cc72fbc6b01ae73a3e58373a
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Sun Aug 2 16:12:29 2026 +0530

    committing xalan-j xslt3.0 implementation improvements
---
 .../apache/xalan/processor/StylesheetHandler.java  |   7 +-
 .../org/apache/xalan/processor/XSLTSchema.java     |  21 +-
 .../org/apache/xalan/res/XSLTErrorResources.java   |   8 +-
 .../java/org/apache/xalan/templates/Constants.java |   7 +
 .../org/apache/xalan/templates/ElemAccept.java     |   4 +-
 .../apache/xalan/templates/ElemAnalyzeString.java  |   2 +-
 .../apache/xalan/templates/ElemApplyImport.java    |  10 +-
 .../apache/xalan/templates/ElemApplyTemplates.java |   4 +-
 .../org/apache/xalan/templates/ElemAssert.java     |   2 +-
 .../org/apache/xalan/templates/ElemAttribute.java  |   4 +-
 .../apache/xalan/templates/ElemAttributeSet.java   |  14 +-
 .../apache/xalan/templates/ElemCallTemplate.java   |   2 +-
 .../java/org/apache/xalan/templates/ElemCatch.java |   2 +-
 .../apache/xalan/templates/ElemCharacterMap.java   |   2 +-
 .../org/apache/xalan/templates/ElemChoose.java     |   2 +-
 .../org/apache/xalan/templates/ElemComment.java    |   2 +-
 .../apache/xalan/templates/ElemContextItem.java    |   2 +-
 .../java/org/apache/xalan/templates/ElemCopy.java  |   2 +-
 .../org/apache/xalan/templates/ElemCopyOf.java     |   2 +-
 .../org/apache/xalan/templates/ElemDocument.java   |   2 +-
 .../org/apache/xalan/templates/ElemElement.java    |   4 +-
 .../java/org/apache/xalan/templates/ElemEmpty.java |  11 +-
 .../org/apache/xalan/templates/ElemEvaluate.java   |   4 +-
 .../org/apache/xalan/templates/ElemExpose.java     |   5 +-
 .../org/apache/xalan/templates/ElemFallback.java   |   4 +-
 .../org/apache/xalan/templates/ElemForEach.java    |   2 +-
 .../apache/xalan/templates/ElemForEachGroup.java   |   2 +-
 .../java/org/apache/xalan/templates/ElemFork.java  | 316 +++++++++++----------
 .../org/apache/xalan/templates/ElemFunction.java   |   2 +-
 .../xalan/templates/ElemGlobalContextItem.java     |   2 +-
 .../java/org/apache/xalan/templates/ElemIf.java    |  13 +-
 .../apache/xalan/templates/ElemImportSchema.java   |   2 +-
 .../org/apache/xalan/templates/ElemIterate.java    |   2 +-
 .../apache/xalan/templates/ElemIterateBreak.java   |   2 +-
 .../xalan/templates/ElemIterateNextIteration.java  |   2 +-
 .../xalan/templates/ElemIterateOnCompletion.java   |   2 +-
 .../apache/xalan/templates/ElemLiteralResult.java  |   2 +-
 .../java/org/apache/xalan/templates/ElemMap.java   |   3 +-
 .../xalan/templates/ElemMatchingSubstring.java     |   2 +-
 .../java/org/apache/xalan/templates/ElemMerge.java |   2 +-
 .../apache/xalan/templates/ElemMergeAction.java    |   2 +-
 .../org/apache/xalan/templates/ElemMergeKey.java   |   5 +-
 .../apache/xalan/templates/ElemMergeSource.java    |   5 +-
 .../org/apache/xalan/templates/ElemMessage.java    |   2 +-
 .../java/org/apache/xalan/templates/ElemMode.java  |   3 +-
 .../org/apache/xalan/templates/ElemNamespace.java  |   2 +-
 .../org/apache/xalan/templates/ElemNextMatch.java  |   4 +-
 .../xalan/templates/ElemNonMatchingSubstring.java  |   2 +-
 .../org/apache/xalan/templates/ElemNumber.java     |   2 +-
 .../org/apache/xalan/templates/ElemOtherwise.java  |  11 +-
 .../xalan/templates/ElemOutputCharacter.java       |   5 +-
 .../java/org/apache/xalan/templates/ElemPI.java    |  11 +-
 .../java/org/apache/xalan/templates/ElemParam.java |   2 +-
 .../apache/xalan/templates/ElemPerformSort.java    |   2 +-
 .../apache/xalan/templates/ElemResultDocument.java |   2 +-
 .../org/apache/xalan/templates/ElemSequence.java   |   2 +-
 .../java/org/apache/xalan/templates/ElemSort.java  |   5 +-
 .../apache/xalan/templates/ElemSourceDocument.java |   2 +-
 .../org/apache/xalan/templates/ElemTemplate.java   |   2 +-
 .../java/org/apache/xalan/templates/ElemText.java  |   2 +-
 .../apache/xalan/templates/ElemTextLiteral.java    |   4 +-
 .../java/org/apache/xalan/templates/ElemTry.java   |   2 +-
 .../org/apache/xalan/templates/ElemUnknown.java    |   3 -
 .../java/org/apache/xalan/templates/ElemUse.java   |   3 -
 .../org/apache/xalan/templates/ElemUsePackage.java |   4 +-
 .../org/apache/xalan/templates/ElemValueOf.java    |   2 +-
 .../org/apache/xalan/templates/ElemVariable.java   |   2 +-
 .../java/org/apache/xalan/templates/ElemWhen.java  |  14 +-
 .../org/apache/xalan/templates/ElemWithParam.java  |   2 +-
 .../org/apache/xalan/templates/FuncCopyOf.java     |   2 +-
 .../xalan/templates/FuncCurrentMergeGroup.java     |   3 +-
 .../xalan/templates/FuncCurrentMergeKey.java       |   3 +-
 .../org/apache/xalan/templates/FuncDocument.java   |   6 +-
 .../java/org/apache/xalan/templates/FuncKey.java   |   2 +-
 .../org/apache/xalan/templates/FuncRegexGroup.java |   2 +-
 .../xalan/templates/GroupingKeyAndGroupPair.java   |   9 +-
 .../java/org/apache/xalan/templates/ModeList.java  |   5 +-
 .../xalan/templates/XslFunctionDefinitionKey.java  |   2 +-
 .../org/apache/xpath/compiler/FunctionTable.java   |   2 +-
 .../functions}/FuncFormatNumber.java               |   7 +-
 .../org/apache/xpath/functions/FuncSerialize.java  |   1 -
 81 files changed, 294 insertions(+), 344 deletions(-)

diff --git a/src/main/java/org/apache/xalan/processor/StylesheetHandler.java b/src/main/java/org/apache/xalan/processor/StylesheetHandler.java
index 020099fb5..967731c71 100644
--- a/src/main/java/org/apache/xalan/processor/StylesheetHandler.java
+++ b/src/main/java/org/apache/xalan/processor/StylesheetHandler.java
@@ -15,9 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xalan.processor;
 
 import java.util.Hashtable;
@@ -435,8 +432,8 @@ public class StylesheetHandler extends DefaultHandler
 
     if (elemProcessor == null) {
        if (processorImportSchema == null) {
-    	   // added for XSLT 3.0
-    	   error(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_ALLOWED_IN_POSITION, new Object[] {rawName}), null);
+    	   // Added for XSLT 3.0
+    	   error(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_ALLOWED_IN_POSITION, new Object[] { rawName }), null);
        }
     }            
                 
diff --git a/src/main/java/org/apache/xalan/processor/XSLTSchema.java b/src/main/java/org/apache/xalan/processor/XSLTSchema.java
index 629b95539..fe78f3aab 100644
--- a/src/main/java/org/apache/xalan/processor/XSLTSchema.java
+++ b/src/main/java/org/apache/xalan/processor/XSLTSchema.java
@@ -859,10 +859,19 @@ public class XSLTSchema extends XSLTElementDef
 						                 useWhenAttrOpt, spaceAttr }, 
 				new ProcessorTemplateElem(),
 				ElemResultDocument.class /* class object */, true, false, true, 20, true);
+		
+		XSLTElementDef xslSequence = new XSLTElementDef(this,
+				Constants.S_XSLNAMESPACEURL, "sequence",
+				null /*alias */,
+				templateElements /* elements */,  // %template;>
+				new XSLTAttributeDef[] { selectAttrOpt, xpathDefaultNamespaceAttrOpt,
+						expandTextAttrOpt, useWhenAttrOpt }, 
+				new ProcessorTemplateElem(),
+				ElemSequence.class /* class object */, 20, true);
 
 		XSLTElementDef xslFork = new XSLTElementDef(this,
 				Constants.S_XSLNAMESPACEURL, "fork",
-				null /*alias */, templateElements,
+				null /*alias */, new XSLTElementDef[] { xslSequence, xslForEachGroup },
 				new XSLTAttributeDef[] { useWhenAttrOpt, spaceAttr }, 
 				new ProcessorTemplateElem(),
 				ElemFork.class /* class object */, true, false, true, 20, true);
@@ -1033,15 +1042,7 @@ public class XSLTSchema extends XSLTElementDef
 						selectAttrOpt, asAttrOpt, xpathDefaultNamespaceAttrOpt, 
 						expandTextAttrOpt, useWhenAttrOpt, xslStaticOpt }, 
 				new ProcessorTemplateElem(),
-				ElemVariable.class /* class object */, 20, true);
-		XSLTElementDef xslSequence = new XSLTElementDef(this,
-				Constants.S_XSLNAMESPACEURL, "sequence",
-				null /*alias */,
-				templateElements /* elements */,  // %template;>
-				new XSLTAttributeDef[] { selectAttrOpt, xpathDefaultNamespaceAttrOpt,
-						expandTextAttrOpt, useWhenAttrOpt }, 
-				new ProcessorTemplateElem(),
-				ElemSequence.class /* class object */, 20, true);
+				ElemVariable.class /* class object */, 20, true);		
 		XSLTElementDef xslParam = new XSLTElementDef(this,
 				Constants.S_XSLNAMESPACEURL, "param",
 				null /*alias */,
diff --git a/src/main/java/org/apache/xalan/res/XSLTErrorResources.java b/src/main/java/org/apache/xalan/res/XSLTErrorResources.java
index bc7936d33..4c28ba47e 100644
--- a/src/main/java/org/apache/xalan/res/XSLTErrorResources.java
+++ b/src/main/java/org/apache/xalan/res/XSLTErrorResources.java
@@ -376,6 +376,7 @@ public class XSLTErrorResources extends ListResourceBundle
 	 "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR";
   public static final String ER_NOT_ALLOWED_IN_POSITION = 
 	 "ER_NOT_ALLOWED_IN_POSITION";
+  public static final String ER_XSL_FORK = "ER_XSL_FORK";
   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 =
@@ -1085,10 +1086,13 @@ public class XSLTErrorResources extends ListResourceBundle
      "Programmer''s assertion in RedundentExprEliminator: {0}"},
 
     { ER_NOT_ALLOWED_IN_POSITION,
-     "XTSE0010 : {0} is not allowed in this position in the stylesheet"},
+     "XTSE0010 : An XML element {0} is not allowed in this position in the stylesheet."},
+    
+    { ER_XSL_FORK,
+      "XTSE0010 : [{1}, {2}] An XML element {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!"},
+     "XTSE0010 : Non-whitespace text is not allowed in this position in the stylesheet."},
 
   // This code is shared with warning codes.
   // SystemId Unknown
diff --git a/src/main/java/org/apache/xalan/templates/Constants.java b/src/main/java/org/apache/xalan/templates/Constants.java
index c0a4686c5..80912ec5b 100644
--- a/src/main/java/org/apache/xalan/templates/Constants.java
+++ b/src/main/java/org/apache/xalan/templates/Constants.java
@@ -541,6 +541,13 @@ public class Constants extends org.apache.xml.utils.Constants
   
   public static final String ATTRVAL_ABSENT = "absent";
   
+  /**
+   * An xsl:fork instruction's xsl:sequence run-time
+   * timeout, in seconds. Specification of this time-out
+   * value is Xalan-J specific.
+   */
+  public static final int XSL_FORK_SEQ_RUN_TIMEOUT = 30;
+  
   public static final String XSL_SER_NAMESACE = "http://www.w3.org/2010/xslt-xquery-serialization";
   
   public static final String XSL_SER_PARAMS = "serialization-parameters";
diff --git a/src/main/java/org/apache/xalan/templates/ElemAccept.java b/src/main/java/org/apache/xalan/templates/ElemAccept.java
index b8708ab43..e7da35751 100644
--- a/src/main/java/org/apache/xalan/templates/ElemAccept.java
+++ b/src/main/java/org/apache/xalan/templates/ElemAccept.java
@@ -24,11 +24,11 @@ import javax.xml.transform.TransformerException;
 import org.apache.xalan.transformer.TransformerImpl;
 
 /**
- * Implementation of XSLT 3.0 xsl:accept element.
+ * Implementation of an XSLT 3.0 instruction xsl:accept.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
- * @xsl.usage internal
+ * @xsl.usage advanced
  */
 public class ElemAccept extends ElemTemplateElement
 {
diff --git a/src/main/java/org/apache/xalan/templates/ElemAnalyzeString.java b/src/main/java/org/apache/xalan/templates/ElemAnalyzeString.java
index bc4d8add1..4c35f5d67 100644
--- a/src/main/java/org/apache/xalan/templates/ElemAnalyzeString.java
+++ b/src/main/java/org/apache/xalan/templates/ElemAnalyzeString.java
@@ -39,7 +39,7 @@ import org.apache.xpath.regex.Matcher;
 import xml.xpath31.processor.types.XSNumericType;
 
 /**
- * Implementation of XSLT 3.0 instruction xsl:analyze-string.
+ * Implementation of an XSLT 3.0 instruction xsl:analyze-string.
  *   
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemApplyImport.java b/src/main/java/org/apache/xalan/templates/ElemApplyImport.java
index c0790864a..abba3aee2 100644
--- a/src/main/java/org/apache/xalan/templates/ElemApplyImport.java
+++ b/src/main/java/org/apache/xalan/templates/ElemApplyImport.java
@@ -15,9 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xalan.templates;
 
 import javax.xml.transform.TransformerException;
@@ -28,11 +25,8 @@ import org.apache.xml.dtm.DTM;
 import org.apache.xpath.XPath;
 
 /**
- * Implement xsl:apply-imports.
- * <pre>
- * <!ELEMENT xsl:apply-imports EMPTY>
- * </pre>
- * @see <a href="http://www.w3.org/TR/xslt#apply-imports">apply-imports in XSLT Specification</a>
+ * Implementation of an XSLT instruction xsl:apply-imports.
+ *  
  * @xsl.usage advanced
  */
 public class ElemApplyImport extends ElemTemplateElement
diff --git a/src/main/java/org/apache/xalan/templates/ElemApplyTemplates.java b/src/main/java/org/apache/xalan/templates/ElemApplyTemplates.java
index cb82e9dd8..d4778f1a8 100644
--- a/src/main/java/org/apache/xalan/templates/ElemApplyTemplates.java
+++ b/src/main/java/org/apache/xalan/templates/ElemApplyTemplates.java
@@ -67,8 +67,8 @@ import org.xml.sax.SAXException;
 import xml.xpath31.processor.types.XSAnyAtomicType;
 import xml.xpath31.processor.types.XSBoolean;
 
-/**
- * Implementation of XSLT 3.0 xsl:apply-templates element.
+/** 
+ * Implementation of an XSLT 3.0 instruction xsl:apply-templates.
  * 
  * @xsl.usage advanced
  */
diff --git a/src/main/java/org/apache/xalan/templates/ElemAssert.java b/src/main/java/org/apache/xalan/templates/ElemAssert.java
index ddb3cff84..536f5db42 100644
--- a/src/main/java/org/apache/xalan/templates/ElemAssert.java
+++ b/src/main/java/org/apache/xalan/templates/ElemAssert.java
@@ -43,7 +43,7 @@ import org.xml.sax.InputSource;
 import xml.xpath31.processor.types.XSString;
 
 /**
- * Implementation of XSLT 3.0 xsl:assert instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:assert.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemAttribute.java b/src/main/java/org/apache/xalan/templates/ElemAttribute.java
index ee7957d16..55a28b548 100644
--- a/src/main/java/org/apache/xalan/templates/ElemAttribute.java
+++ b/src/main/java/org/apache/xalan/templates/ElemAttribute.java
@@ -50,9 +50,7 @@ import org.xml.sax.SAXException;
 import org.apache.xml.dtm.DTM;
 
 /**
- * Implementation of XSL stylesheet instruction xsl:attribute.
- * 
- * @see <a href="https://www.w3.org/TR/xslt-30/#creating-attributes">xsl:attribute in XSLT 3.0 Specification</a>
+ * Implementation of an XSLT 3.0 instruction xsl:attribute.
  * 
  * @xsl.usage advanced
  */
diff --git a/src/main/java/org/apache/xalan/templates/ElemAttributeSet.java b/src/main/java/org/apache/xalan/templates/ElemAttributeSet.java
index ee7ae1f4d..b4e2b7fb6 100644
--- a/src/main/java/org/apache/xalan/templates/ElemAttributeSet.java
+++ b/src/main/java/org/apache/xalan/templates/ElemAttributeSet.java
@@ -15,9 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xalan.templates;
 
 import javax.xml.transform.TransformerException;
@@ -29,15 +26,8 @@ import org.apache.xml.utils.QName;
 import org.w3c.dom.DOMException;
 
 /**
- * Implement xsl:attribute-set.
- * <pre>
- * &amp;!ELEMENT xsl:attribute-set (xsl:attribute)*>
- * &amp;!ATTLIST xsl:attribute-set
- *   name %qname; #REQUIRED
- *   use-attribute-sets %qnames; #IMPLIED
- * &amp;
- * </pre>
- * @see <a href="http://www.w3.org/TR/xslt#attribute-sets">attribute-sets in XSLT Specification</a>
+ * Implementation of an XSLT instruction xsl:attribute-set.
+ * 
  * @xsl.usage advanced
  */
 public class ElemAttributeSet extends ElemUse
diff --git a/src/main/java/org/apache/xalan/templates/ElemCallTemplate.java b/src/main/java/org/apache/xalan/templates/ElemCallTemplate.java
index cdd9ea6c9..4cd311a26 100644
--- a/src/main/java/org/apache/xalan/templates/ElemCallTemplate.java
+++ b/src/main/java/org/apache/xalan/templates/ElemCallTemplate.java
@@ -46,7 +46,7 @@ import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
 
 /**
- * Implementation of XSLT 3.0 instruction xsl:call-template.
+ * Implementation of an XSLT 3.0 instruction xsl:call-template.
  * 
  * @xsl.usage advanced
  */
diff --git a/src/main/java/org/apache/xalan/templates/ElemCatch.java b/src/main/java/org/apache/xalan/templates/ElemCatch.java
index a6675ce77..d670c0bf9 100644
--- a/src/main/java/org/apache/xalan/templates/ElemCatch.java
+++ b/src/main/java/org/apache/xalan/templates/ElemCatch.java
@@ -34,7 +34,7 @@ import org.apache.xpath.objects.XObject;
 import org.xml.sax.SAXException;
 
 /**
- * An implementation of, XSLT 3.0 xsl:catch instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:catch.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  *  
diff --git a/src/main/java/org/apache/xalan/templates/ElemCharacterMap.java b/src/main/java/org/apache/xalan/templates/ElemCharacterMap.java
index bcf9a69a3..6bc08752b 100644
--- a/src/main/java/org/apache/xalan/templates/ElemCharacterMap.java
+++ b/src/main/java/org/apache/xalan/templates/ElemCharacterMap.java
@@ -27,7 +27,7 @@ import org.apache.xpath.Expression;
 import org.apache.xpath.ExpressionOwner;
 
 /**
- * Implementation of XSLT 3.0 xsl:character-map element.
+ * Implementation of an XSLT 3.0 instruction xsl:character-map.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemChoose.java b/src/main/java/org/apache/xalan/templates/ElemChoose.java
index a79a7549d..72d3a098c 100644
--- a/src/main/java/org/apache/xalan/templates/ElemChoose.java
+++ b/src/main/java/org/apache/xalan/templates/ElemChoose.java
@@ -35,7 +35,7 @@ import org.w3c.dom.DOMException;
 import xml.xpath31.processor.types.XSAnyType;
 
 /**
- *  Implementation of the XSLT 3.0 xsl:choose instruction.
+ *  Implementation of an XSLT 3.0 instruction xsl:choose.
  *  
  *  @xsl.usage advanced
  */
diff --git a/src/main/java/org/apache/xalan/templates/ElemComment.java b/src/main/java/org/apache/xalan/templates/ElemComment.java
index acb994db0..b34f4db44 100644
--- a/src/main/java/org/apache/xalan/templates/ElemComment.java
+++ b/src/main/java/org/apache/xalan/templates/ElemComment.java
@@ -31,7 +31,7 @@ import org.apache.xpath.objects.XObject;
 import org.w3c.dom.DOMException;
 
 /**
- * Implementation of XSLT 3.0 xsl:comment element.
+ * Implementation of an XSLT 3.0 instruction xsl:comment.
  * 
  * @xsl.usage advanced
  */
diff --git a/src/main/java/org/apache/xalan/templates/ElemContextItem.java b/src/main/java/org/apache/xalan/templates/ElemContextItem.java
index e1e4d39c7..bdaeedf9d 100644
--- a/src/main/java/org/apache/xalan/templates/ElemContextItem.java
+++ b/src/main/java/org/apache/xalan/templates/ElemContextItem.java
@@ -29,7 +29,7 @@ import org.apache.xpath.objects.XObject;
 import org.w3c.dom.Node;
 
 /**
- * Implementation of an XSLT 3.0 xsl:context-item instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:context-item.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemCopy.java b/src/main/java/org/apache/xalan/templates/ElemCopy.java
index 0d8e98aa9..52a004e44 100644
--- a/src/main/java/org/apache/xalan/templates/ElemCopy.java
+++ b/src/main/java/org/apache/xalan/templates/ElemCopy.java
@@ -49,7 +49,7 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
 /**
- * Implementation of XSLT xsl:copy instruction.
+ * Implementation of an XSLT instruction xsl:copy.
  * 
  * @xsl.usage advanced
  */
diff --git a/src/main/java/org/apache/xalan/templates/ElemCopyOf.java b/src/main/java/org/apache/xalan/templates/ElemCopyOf.java
index 3da9af0f2..7ba9cb735 100644
--- a/src/main/java/org/apache/xalan/templates/ElemCopyOf.java
+++ b/src/main/java/org/apache/xalan/templates/ElemCopyOf.java
@@ -74,7 +74,7 @@ import xml.xpath31.processor.types.XSUntyped;
 import xml.xpath31.processor.types.XSUntypedAtomic;
 
 /**
- * Implementation of XSLT xsl:copy-of instruction.
+ * Implementation of an XSLT instruction xsl:copy-of.
  * 
  * @author Scott Boag <sc...@us.ibm.com>
  * @author Morris Kwan <mk...@apache.org>
diff --git a/src/main/java/org/apache/xalan/templates/ElemDocument.java b/src/main/java/org/apache/xalan/templates/ElemDocument.java
index 66110ab3b..0e4ca9ca9 100644
--- a/src/main/java/org/apache/xalan/templates/ElemDocument.java
+++ b/src/main/java/org/apache/xalan/templates/ElemDocument.java
@@ -34,7 +34,7 @@ import org.apache.xpath.objects.XMLNodeCursorImpl;
 import org.apache.xpath.objects.XObject;
 
 /**
- * Implementation of XSLT 3.0 xsl:document instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:document.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemElement.java b/src/main/java/org/apache/xalan/templates/ElemElement.java
index cda0dd478..78ec681ea 100644
--- a/src/main/java/org/apache/xalan/templates/ElemElement.java
+++ b/src/main/java/org/apache/xalan/templates/ElemElement.java
@@ -38,9 +38,7 @@ import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 
 /**
- * Implementation of XSL stylesheet instruction xsl:element.
- * 
- * @see <a href="https://www.w3.org/TR/xslt-30/#xsl-element">xsl:element in XSLT 3.0 Specification</a>
+ * Implementation of an XSLT 3.0 instruction xsl:element.
  * 
  * @xsl.usage advanced
  */
diff --git a/src/main/java/org/apache/xalan/templates/ElemEmpty.java b/src/main/java/org/apache/xalan/templates/ElemEmpty.java
index 8ae1f8e5c..fbc698de4 100644
--- a/src/main/java/org/apache/xalan/templates/ElemEmpty.java
+++ b/src/main/java/org/apache/xalan/templates/ElemEmpty.java
@@ -15,24 +15,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xalan.templates;
 
-
 /**
  * Simple empty elem to push on the stack when nothing
  * else got pushed, so that pop() works correctly.
+ * 
  * @xsl.usage internal
  */
 public class ElemEmpty extends ElemTemplateElement
 {
-    static final long serialVersionUID = 7544753713671472252L;
+  static final long serialVersionUID = 7544753713671472252L;
 
   /**
-   * Constructor ElemEmpty
-   *
+   * Class constructor.
    */
   public ElemEmpty(){}
+  
 }
diff --git a/src/main/java/org/apache/xalan/templates/ElemEvaluate.java b/src/main/java/org/apache/xalan/templates/ElemEvaluate.java
index 83a849546..f95ecef6b 100644
--- a/src/main/java/org/apache/xalan/templates/ElemEvaluate.java
+++ b/src/main/java/org/apache/xalan/templates/ElemEvaluate.java
@@ -56,9 +56,11 @@ import org.xml.sax.SAXException;
 import xml.xpath31.processor.types.XSAnyAtomicType;
 
 /**
- * An implementation of XSLT 3.0 instruction xsl:evaluate.
+ * Implementation of an XSLT 3.0 instruction xsl:evaluate.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
  */
 public class ElemEvaluate extends ElemTemplateElement {
 
diff --git a/src/main/java/org/apache/xalan/templates/ElemExpose.java b/src/main/java/org/apache/xalan/templates/ElemExpose.java
index e9547ea2b..a7aabbd2b 100644
--- a/src/main/java/org/apache/xalan/templates/ElemExpose.java
+++ b/src/main/java/org/apache/xalan/templates/ElemExpose.java
@@ -23,15 +23,14 @@ import javax.xml.transform.SourceLocator;
 import javax.xml.transform.TransformerException;
 
 import org.apache.xalan.transformer.TransformerImpl;
-import org.apache.xml.utils.QName;
 import org.apache.xpath.XPathContext;
 
 /**
- * Implementation of XSLT 3.0 xsl:expose element.
+ * Implementation of an XSLT 3.0 instruction xsl:expose.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
- * @xsl.usage internal
+ * @xsl.usage advanced
  */
 public class ElemExpose extends ElemTemplateElement
 {
diff --git a/src/main/java/org/apache/xalan/templates/ElemFallback.java b/src/main/java/org/apache/xalan/templates/ElemFallback.java
index c15665f34..d4120f961 100644
--- a/src/main/java/org/apache/xalan/templates/ElemFallback.java
+++ b/src/main/java/org/apache/xalan/templates/ElemFallback.java
@@ -23,8 +23,8 @@ import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xpath.XPath;
 
 /**
- * Implementation of XSLT 3.0 xsl:fallback instruction.
-
+ * Implementation of an XSLT 3.0 instruction xsl:fallback.
+ *
  * @xsl.usage advanced
  */
 public class ElemFallback extends ElemTemplateElement
diff --git a/src/main/java/org/apache/xalan/templates/ElemForEach.java b/src/main/java/org/apache/xalan/templates/ElemForEach.java
index de594f50c..e4ef7ffcd 100644
--- a/src/main/java/org/apache/xalan/templates/ElemForEach.java
+++ b/src/main/java/org/apache/xalan/templates/ElemForEach.java
@@ -73,7 +73,7 @@ import xml.xpath31.processor.types.XSDateTime;
 import xml.xpath31.processor.types.XSString;
 
 /**
- * Implementation of the XSLT 3.0 xsl:for-each instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:for-each.
  * 
  * @author Scott Boag <sc...@us.ibm.com>
  * @author Joseph Kesselman <ke...@alum.mit.edu>, Myriam Midy <mm...@apache.org>,
diff --git a/src/main/java/org/apache/xalan/templates/ElemForEachGroup.java b/src/main/java/org/apache/xalan/templates/ElemForEachGroup.java
index 857930a63..8a47da39e 100644
--- a/src/main/java/org/apache/xalan/templates/ElemForEachGroup.java
+++ b/src/main/java/org/apache/xalan/templates/ElemForEachGroup.java
@@ -72,7 +72,7 @@ import xml.xpath31.processor.types.XSString;
 import xml.xpath31.processor.types.XSTime;
 
 /**
- * Implementation of the XSLT 3.0 xsl:for-each-group instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:for-each-group.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  *  
diff --git a/src/main/java/org/apache/xalan/templates/ElemFork.java b/src/main/java/org/apache/xalan/templates/ElemFork.java
index cecc75548..0ad106650 100644
--- a/src/main/java/org/apache/xalan/templates/ElemFork.java
+++ b/src/main/java/org/apache/xalan/templates/ElemFork.java
@@ -24,10 +24,13 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 import javax.xml.transform.SourceLocator;
 import javax.xml.transform.TransformerException;
 
+import org.apache.xalan.res.XSLTErrorResources;
 import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xpath.Expression;
 import org.apache.xpath.ExpressionOwner;
@@ -37,15 +40,15 @@ import org.apache.xpath.objects.XObject;
 import org.xml.sax.SAXException;
 
 /**
- * Implementation of the XSLT 3.0 xsl:fork instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:fork.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  *  
  * @xsl.usage advanced
  */
-public class ElemFork extends ElemTemplateElement 
-                                                implements ExpressionOwner
+public class ElemFork extends ElemTemplateElement implements ExpressionOwner
 {
+  
   private static final long serialVersionUID = 6132007133719632871L;
   
   /**
@@ -54,9 +57,11 @@ public class ElemFork extends ElemTemplateElement
   private XPath m_useWhen = null;
   
   /**
-   * The class constructor.
+   * Class constructor.
    */
-  public ElemFork() {}
+  public ElemFork() {
+	  // No op
+  }
   
   /**
    * Method definition, to set the value of XSL attribute 
@@ -146,114 +151,108 @@ public class ElemFork extends ElemTemplateElement
 	    	}
 	    	
 	    	/**
-	    	 * An xsl:fork instruction has zero or more xsl:sequence sibling child
-	    	 * elements, or has xsl:for-each-group as child element.
-	    	 * i.e, xsl:fork instruction XSL child content has following grammar,
-	    	 * (xsl:sequence* | xsl:for-each-group).
-	    	 * We validate this xsl:fork's grammar definition below.
+	    	 * An xsl:fork instruction may have zero or more xsl:sequence child
+	    	 * instructions, or one xsl:for-each-group instruction.
+	    	 * 
+	    	 * i.e, An xsl:fork instruction, content model is following:
+	    	 * 
+	    	 * xsl:sequence* | xsl:for-each-group
 	    	 */
 	    	
-	    	ElemTemplateElement xslForkLastChildElem = null;
-	    	
-	    	for (ElemTemplateElement t = this.m_firstChild; t != null;
-																	t = t.m_nextSibling) {
-	    		if (t.m_nextSibling != null) {
-	    		   if (!(t instanceof ElemSequence)) {
-	    			  throw new TransformerException("XPTY0004 : All XSL fork child elements other than last one, "
-	    			  																				 + "should be XSL 'sequence' elements.", srcLocator); 
-	    		   }
-	    		}
-	    		else if (!((t instanceof ElemSequence) || (t instanceof ElemForEachGroup))) {
-	    		   throw new TransformerException("XPTY0004 : An XSL fork's last child element can either be "
-	    		   		                                                                                + "XSL 'sequence' or 'for-each-group'.", srcLocator);
-	    		}
-	    		else {
-	    		   xslForkLastChildElem = t;	
-	    		}
-	    	}
+	    	ElemTemplateElement xslForkChildElem = getFirstChildElem();	    		    	
 	    		    	
-	    	if (!(xslForkLastChildElem instanceof ElemForEachGroup)) {
+	    	if (!(xslForkChildElem instanceof ElemForEachGroup)) {
 	    		/**
-	    		 * Evaluate xsl:fork's xsl:sequence child elements in parallel threads,
-	    		 * and emit xsl:fork's evaluation result to an XSL transformation serializer
-	    		 * in sequential order as per xsl:sequence element siblings (i.e, first
-	    		 * xsl:sequence's evaluation result will be emitted first, then for the
-	    		 * next xsl:sequence sibling element and so on).
+	    		 * Evaluate xsl:fork's xsl:sequence child instructions in parallel 
+	    		 * threads, and emit results of xsl:sequence instructions in order 
+	    		 * as specified within an XSL stylesheet.
 	    		 */
 	    		
 	    		List<XslSequenceAndResultPair> xslSequenceEvalResultList = new ArrayList<XslSequenceAndResultPair>();
 	    		
-	    		List<XslForkWithSequenceCallable> xslForkTaskCallableList = new ArrayList<XslForkWithSequenceCallable>();
+	    		List<XslForkSequenceCallable> xslForkTaskCallableList = new ArrayList<XslForkSequenceCallable>();
 
-	    		// Determine the number of xsl:fork's xsl:sequence child elements, by 
-	    		// analyzing an XSL stylesheet's compiled object statically.
-	    		int noOfXslSeqElems = 0;	    		
+	    		int xslSeqElemCount = 0;	    		
 	    		for (ElemTemplateElement t = this.m_firstChild; t != null;
 																		t = t.m_nextSibling) {
-	    			noOfXslSeqElems++;
+	    			xslSeqElemCount++;
 	    		}
 	    		
 	    		/**
-	    		 * Instantiate java.util.concurrent.ExecutorService, with thread pool size
-	    		 * equal to the number of xsl:sequence sibling instructions within
-	    		 * xsl:fork element.
+	    		 * Instantiate java.util.concurrent.ExecutorService, to run 
+	    		 * evaluation of each xsl:sequence instruction (XSL stylesheet 
+	    		 * sibling instructions, that are child of xsl:fork instruction) 
+	    		 * within a separate thread. 
 	    		 */
-	    		ExecutorService executorServiceObj = Executors.newFixedThreadPool(noOfXslSeqElems);	    		
+	    		
+	    		ExecutorService threadpool = Executors.newFixedThreadPool((Runtime.getRuntime()).availableProcessors());	    		
 	    		
 	    		for (ElemTemplateElement t = this.m_firstChild; t != null;
-	    																t = t.m_nextSibling) {
+	    																  t = t.m_nextSibling) {
 	    			ElemSequence elemSequence = (ElemSequence)t;
 	    			elemSequence.setIsCalledFromXslFork(true);   
-	    			XslForkWithSequenceCallable xslForkWithSequenceCallable = new 
-	    																XslForkWithSequenceCallable(xctxt, transformer, elemSequence);
+	    			
+	    			XslForkSequenceCallable xslForkWithSequenceCallable = new XslForkSequenceCallable(elemSequence, transformer, xctxt);
 	    			xslForkTaskCallableList.add(xslForkWithSequenceCallable);
-	    		}	    			    		
+	    		}
 	    		
-	    		while (xslSequenceEvalResultList.size() != noOfXslSeqElems) {
-	    			for (int idx = 0; idx < xslForkTaskCallableList.size(); idx++) {
-	    				XslForkWithSequenceCallable xslForkWithSequenceCallable = xslForkTaskCallableList.get(idx);
-	    				Future<XslSequenceAndResultPair> futureObj = executorServiceObj.submit(xslForkWithSequenceCallable);
+	    		while (xslSequenceEvalResultList.size() != xslSeqElemCount) {
+	    			int size1 = xslForkTaskCallableList.size();
+	    			
+	    			for (int idx = 0; idx < size1; idx++) {
+	    				XslForkSequenceCallable xslForkSequenceCallable = xslForkTaskCallableList.get(idx);
+	    				Future<XslSequenceAndResultPair> futureObj = threadpool.submit(xslForkSequenceCallable);
+	    				
 	    				try { 
-	    				   XslSequenceAndResultPair resultObj1 = futureObj.get();
+	    				   XslSequenceAndResultPair resultObj1 = futureObj.get(Constants.XSL_FORK_SEQ_RUN_TIMEOUT, TimeUnit.SECONDS);
 	    				   xslSequenceEvalResultList.add(resultObj1);
 	    				} 
 	    				catch (InterruptedException ex) {
 	    					throw new javax.xml.transform.TransformerException("XPTY0004 : An error occured while evaluating "
-	    							                                        + "xsl:sequence instruction within xsl:fork instruction, "
-	    							                                        + "with following error trace : " + ex.getMessage() + ".", srcLocator);
+									    							                                        + "an XSL 'sequence' instruction within, XSL 'fork' instruction, "
+									    							                                        + "with following error trace : " + ex.getMessage() + ".", srcLocator);
 	    				} 
 	    				catch (ExecutionException ex) {
 	    					throw new javax.xml.transform.TransformerException("XPTY0004 : An error occured while evaluating "
-	    							                                        + "xsl:sequence instruction within xsl:fork instruction, "
-	    							                                        + "with following error trace : " + ex.getMessage() + ".", srcLocator);
-	    				}
+																		                                    + "an XSL 'sequence' instruction within, XSL 'fork' instruction, "
+																		                                    + "with following error trace : " + ex.getMessage() + ".", srcLocator);
+	    				} 
+	    				catch (TimeoutException ex) {
+	    					throw new javax.xml.transform.TransformerException("XTDE1665 : An XSL stylesheet dynamic error has occured. An xsl:fork's xsl:sequence instruction "
+	    							                                                                        + "took too long to run.", srcLocator);
+						}
 	    			}
 	    		}
 	    		
 	    		for (int idx = 0; idx < xslSequenceEvalResultList.size(); idx++) {
 	    			XslSequenceAndResultPair xslSequenceAndResultPair = xslSequenceEvalResultList.get(idx);	    			
+	    			
 	    			try {
 	    				ElemSequence elemSequence = xslSequenceAndResultPair.getElemSequence();
 						elemSequence.emitXdmItemToXSLResultTree(xctxt, transformer, 
 								                                         xslSequenceAndResultPair.getEvalResult());
 								                                         
-					} catch (TransformerException ex) {
-						throw new javax.xml.transform.TransformerException("XPTY0004 : An error occured while evaluating "
-                                													+ "xsl:sequence instruction within xsl:fork instruction, "
-                                													+ "with following error trace : " + ex.getMessage() + ".", srcLocator);
-					} catch (SAXException ex) {
-						throw new javax.xml.transform.TransformerException("XPTY0004 : An error occured while evaluating "
-																					+ "xsl:sequence instruction within xsl:fork instruction, "
-																					+ "with following error trace : " + ex.getMessage() + ".", srcLocator);
+					} 
+	    			catch (TransformerException ex) {
+	    				throw new javax.xml.transform.TransformerException("XPTY0004 : An error occured while evaluating "
+																		                                + "an XSL 'sequence' instruction within, XSL 'fork' instruction, "
+																		                                + "with following error trace : " + ex.getMessage() + ".", srcLocator);
+					} 
+	    			catch (SAXException ex) {
+	    				throw new javax.xml.transform.TransformerException("XPTY0004 : An error occured while evaluating "
+																		                                + "an XSL 'sequence' instruction within, XSL 'fork' instruction, "
+																		                                + "with following error trace : " + ex.getMessage() + ".", srcLocator);
 					}
 	    		}
 	    		
-	    		executorServiceObj.shutdown();
+	    		threadpool.shutdown();
 	    	}
-	    	else {	     	    		    	
-	    		xctxt.setSAXLocator(xslForkLastChildElem);
-    			transformer.setCurrentElement(xslForkLastChildElem);                   
-    			xslForkLastChildElem.execute(transformer);	
+	    	else {
+	    		// Evaluate an xsl:for-each-group instruction
+	    		
+	    		xctxt.setSAXLocator(xslForkChildElem);
+    			transformer.setCurrentElement(xslForkChildElem);                   
+    			xslForkChildElem.execute(transformer);	
 	    	}	    	
         }
         finally {
@@ -264,146 +263,167 @@ public class ElemFork extends ElemTemplateElement
             transformer.popCurrentTemplateRuleIsNull();
         }
   }
-
-  /**
-   * Add an XSL stylesheet child information.
-   *
-   * @param newChild Child to add to child list
-   *
-   * @return Child just added to child list
-   */
-  public ElemTemplateElement appendChild(ElemTemplateElement newChild)
-  {
-      return super.appendChild(newChild);
-  }
   
   /**
-   * Call the children visitors.
-   * 
-   * @param visitor The visitor whose appropriate method will be called.
+   * Class definition, to represent an xsl:sequence 
+   * evaluation task.
    */
-  public void callChildVisitors(XSLTVisitor visitor, boolean callAttributes)
-  {    
-      super.callChildVisitors(visitor, callAttributes);
-  }
-
-  @Override
-  public Expression getExpression() {
-	  return null;
-  }
-
-  @Override
-  public void setExpression(Expression exp) {
-	  // no op
-  }
-  
-  /**
-   * An object of this class, represents an xsl:sequence evaluation task.
-   * Multiple such task objects shall be provided to 
-   * java.util.concurrent.ExecutorService to run in parallel.
-   */
-  class XslForkWithSequenceCallable implements Callable<XslSequenceAndResultPair> {
-	  
-	  private XPathContext xctxt;
+  class XslForkSequenceCallable implements Callable<XslSequenceAndResultPair> {	  	 
+	  	  	  
+	  private ElemSequence m_elemSequence;
 	  
-	  private TransformerImpl transformer;
+	  private TransformerImpl m_transformer;
 	  
-	  private ElemSequence elemSequence;
+	  private XPathContext m_xctxt;
 	  
-	  private XslSequenceAndResultPair xslSequenceAndResultPair;
+	  private XslSequenceAndResultPair m_xslSeqAndResultPair;
 	  
 	  /**
 	   * Class constructor.
 	   */
-	  public XslForkWithSequenceCallable(XPathContext xctxt, TransformerImpl transformer, 
-			                                                              ElemSequence elemSequence) {
-		 this.xctxt = xctxt;
-		 this.transformer = transformer;
-		 this.elemSequence = elemSequence;  
+	  public XslForkSequenceCallable(ElemSequence elemSequence, TransformerImpl transformer, 
+			                                                        XPathContext xctxt) {		 
+		 this.m_elemSequence = elemSequence;
+		 this.m_transformer = transformer;
+		 this.m_xctxt = xctxt;		 
 	  }
 	  
 	  /**
-	   * This method definition represents the workload of a 
+	   * Method definition, to represent the workload of a 
 	   * task to be run by java.util.concurrent.ExecutorService.
 	   */
 	  public XslSequenceAndResultPair call() {		  
+		  
 		  try {				  
-			  xctxt.setSAXLocator(elemSequence);
-			  transformer.setCurrentElement(elemSequence);                   
-			  elemSequence.execute(transformer);
-			  XObject xslSequenceEvalResult = elemSequence.getXslSequenceEvalResult();
-			  xslSequenceAndResultPair = new XslSequenceAndResultPair(elemSequence, xslSequenceEvalResult);
+			  m_xctxt.setSAXLocator(m_elemSequence);
+			  m_transformer.setCurrentElement(m_elemSequence);                   
+			  m_elemSequence.execute(m_transformer);
+			  XObject xslSequenceEvalResult = m_elemSequence.getXslSequenceEvalResult();
+			  m_xslSeqAndResultPair = new XslSequenceAndResultPair(m_elemSequence, xslSequenceEvalResult);
 			  
-			  return xslSequenceAndResultPair;
+			  return m_xslSeqAndResultPair;
 		  }
 		  catch (TransformerException ex) {
-			  // no op
+			  // No op
 		  }
 		  
 		  return null;
 	  }
-
-	  public XPathContext getXPathContext() {
-		 return xctxt;
+	  
+	  public ElemSequence getElemSequence() {
+		  return m_elemSequence;
 	  }
 
-	  public void setXPathContext(XPathContext xctxt) {
-		 this.xctxt = xctxt;
+	  public void setElemSequence(ElemSequence elemSequence) {
+		  this.m_elemSequence = elemSequence;
 	  }
 
 	  public TransformerImpl getTransformer() {
-		 return transformer;
+		  return m_transformer;
 	  }
 
 	  public void setTransformer(TransformerImpl transformer) {
-		 this.transformer = transformer;
+		  this.m_transformer = transformer;
 	  }
-	  
-	  public ElemSequence getElemSequence() {
-		 return elemSequence;
+
+	  public XPathContext getXPathContext() {
+		  return m_xctxt;
 	  }
 
-	  public void setElemSequence(ElemSequence elemSequence) {
-		 this.elemSequence = elemSequence;
+	  public void setXPathContext(XPathContext xctxt) {
+		  this.m_xctxt = xctxt;
 	  }
 	  
 	  public XslSequenceAndResultPair getXslSequenceEvalResult() {
-		 return xslSequenceAndResultPair; 
+		 return m_xslSeqAndResultPair; 
 	  }	  
   }
   
   /**
-   * An object is of this class represents a pair of values, 
+   * Class definition, to represent a pair of values, 
    * comprising of an xsl:sequence instruction instance and 
-   * an XObject object instance representing result of it's 
-   * evaluation.
+   * an XObject object, instance which is the result of 
+   * xsl:sequence instruction evaluation.
    */
   class XslSequenceAndResultPair {
 	  
-	  private ElemSequence elemSequence;
+	  private ElemSequence m_elemSequence;
 	  
-	  private XObject evalResult;
+	  private XObject m_evalResult;
 	  
+	  /**
+	   * Class constructor.
+	   */
 	  public XslSequenceAndResultPair(ElemSequence elemSequence, XObject xObj) {
-		  this.elemSequence = elemSequence;
-		  this.evalResult = xObj;
+		  this.m_elemSequence = elemSequence;
+		  this.m_evalResult = xObj;
 	  }
 
 	  public ElemSequence getElemSequence() {
-		  return elemSequence;
+		  return m_elemSequence;
 	  }
 
 	  public void setElemSequence(ElemSequence elemSequence) {
-		  this.elemSequence = elemSequence;
+		  this.m_elemSequence = elemSequence;
 	  }
 
 	  public XObject getEvalResult() {
-		  return evalResult;
+		  return m_evalResult;
 	  }
 
 	  public void setEvalResult(XObject xObject) {
-		  this.evalResult = xObject;
+		  this.m_evalResult = xObject;
+	  }	  
+   }
+  
+  /**
+   * Add an XSL stylesheet child information.
+   *
+   * @param newChild Child to add to child list
+   *
+   * @return Child just added to child list
+   */
+  public ElemTemplateElement appendChild(ElemTemplateElement newChild)
+  {
+
+	  ElemTemplateElement result = null;
+
+	  ElemTemplateElement elemTemplateElement = getFirstChildElem();
+
+	  if (elemTemplateElement == null) {
+		  result = super.appendChild(newChild);  
+	  }
+	  else if ((elemTemplateElement instanceof ElemSequence) && (newChild instanceof ElemSequence)) {
+		  result = super.appendChild(newChild);  
+	  }
+	  else {		 
+		  int lineNo = newChild.getLineNumber();
+		  int colNo = newChild.getColumnNumber();
+
+		  error(XSLTErrorResources.ER_XSL_FORK, new Object[] { "'" + newChild.getNodeName() + "'", lineNo, colNo }); 
 	  }
+
+	  return result;
+  }
+
+  /**
+   * Call the children visitors.
+   * 
+   * @param visitor The visitor whose appropriate method will be called.
+   */
+  public void callChildVisitors(XSLTVisitor visitor, boolean callAttributes)
+  {    
+	  super.callChildVisitors(visitor, callAttributes);
+  }
+
+  @Override
+  public Expression getExpression() {
+	  return null;
+  }
+
+  @Override
+  public void setExpression(Expression exp) {
+	  // No op
   }
 
 }
diff --git a/src/main/java/org/apache/xalan/templates/ElemFunction.java b/src/main/java/org/apache/xalan/templates/ElemFunction.java
index 35aa4e8c7..ebd283522 100644
--- a/src/main/java/org/apache/xalan/templates/ElemFunction.java
+++ b/src/main/java/org/apache/xalan/templates/ElemFunction.java
@@ -100,7 +100,7 @@ import xml.xpath31.processor.types.XSTime;
 import xml.xpath31.processor.types.XSYearMonthDuration;
 
 /**
- * Implementation of an XSLT 3.0 xsl:function instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:function.
  *
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemGlobalContextItem.java b/src/main/java/org/apache/xalan/templates/ElemGlobalContextItem.java
index ca0a2eb3a..e2ad017f0 100644
--- a/src/main/java/org/apache/xalan/templates/ElemGlobalContextItem.java
+++ b/src/main/java/org/apache/xalan/templates/ElemGlobalContextItem.java
@@ -28,7 +28,7 @@ import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xpath.XPathContext;
 
 /**
- * Implementation of XSLT 3.0 xsl:global-context-item instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:global-context-item.
  *
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemIf.java b/src/main/java/org/apache/xalan/templates/ElemIf.java
index 16e959577..6eb1cb55f 100644
--- a/src/main/java/org/apache/xalan/templates/ElemIf.java
+++ b/src/main/java/org/apache/xalan/templates/ElemIf.java
@@ -15,9 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xalan.templates;
 
 import javax.xml.transform.SourceLocator;
@@ -33,14 +30,8 @@ import org.apache.xpath.objects.XObject;
 import xml.xpath31.processor.types.XSAnyType;
 
 /**
- * The XSLT xsl:if element, is used to perform conditional processing,
- * within an XSLT stylesheet.
- * 
- * <xsl:if
-        test = expression>
-       <!-- Content: sequence-constructor -->
-   </xsl:if>
-
+ * Implementation of an XSLT instruction xsl:if.
+ *
  * @xsl.usage advanced
  */
 public class ElemIf extends ElemTemplateElement
diff --git a/src/main/java/org/apache/xalan/templates/ElemImportSchema.java b/src/main/java/org/apache/xalan/templates/ElemImportSchema.java
index 6bb9f0e6a..23fe98ed6 100644
--- a/src/main/java/org/apache/xalan/templates/ElemImportSchema.java
+++ b/src/main/java/org/apache/xalan/templates/ElemImportSchema.java
@@ -23,7 +23,7 @@ import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xpath.XPath;
 
 /**
- *  Implementation of the XSLT 3.0 xsl:import-schema instruction.
+ *  Implementation of an XSLT 3.0 instruction xsl:import-schema.
  *  
  *  @author Mukul Gandhi <mu...@apache.org>
  *  
diff --git a/src/main/java/org/apache/xalan/templates/ElemIterate.java b/src/main/java/org/apache/xalan/templates/ElemIterate.java
index 400e0fb79..b1c6d3522 100644
--- a/src/main/java/org/apache/xalan/templates/ElemIterate.java
+++ b/src/main/java/org/apache/xalan/templates/ElemIterate.java
@@ -50,7 +50,7 @@ import org.xml.sax.SAXException;
 import xml.xpath31.processor.types.XSAnyAtomicType;
 
 /**
- * Implementation of the XSLT 3.0 xsl:iterate instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:iterate.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemIterateBreak.java b/src/main/java/org/apache/xalan/templates/ElemIterateBreak.java
index e9f41847f..0ec1ab529 100644
--- a/src/main/java/org/apache/xalan/templates/ElemIterateBreak.java
+++ b/src/main/java/org/apache/xalan/templates/ElemIterateBreak.java
@@ -28,7 +28,7 @@ import org.apache.xpath.XPathContext;
 import org.xml.sax.SAXException;
 
 /**
- * Implementation of the XSLT 3.0 xsl:break instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:break.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemIterateNextIteration.java b/src/main/java/org/apache/xalan/templates/ElemIterateNextIteration.java
index 3bf5e09b3..f299a9938 100644
--- a/src/main/java/org/apache/xalan/templates/ElemIterateNextIteration.java
+++ b/src/main/java/org/apache/xalan/templates/ElemIterateNextIteration.java
@@ -41,7 +41,7 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
 /**
- * Implementation of the XSLT 3.0 xsl:next-iteration instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:next-iteration.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemIterateOnCompletion.java b/src/main/java/org/apache/xalan/templates/ElemIterateOnCompletion.java
index 795fba0f8..60b3f8808 100644
--- a/src/main/java/org/apache/xalan/templates/ElemIterateOnCompletion.java
+++ b/src/main/java/org/apache/xalan/templates/ElemIterateOnCompletion.java
@@ -35,7 +35,7 @@ import org.apache.xpath.operations.XPath3UnaryOperation;
 import org.xml.sax.SAXException;
 
 /**
- * Implementation of the XSLT 3.0 xsl:on-completion instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:on-completion.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemLiteralResult.java b/src/main/java/org/apache/xalan/templates/ElemLiteralResult.java
index 15f01aa5a..2e58212a8 100644
--- a/src/main/java/org/apache/xalan/templates/ElemLiteralResult.java
+++ b/src/main/java/org/apache/xalan/templates/ElemLiteralResult.java
@@ -55,7 +55,7 @@ import org.xml.sax.SAXException;
 import xml.xpath31.processor.types.XSAnyType;
 
 /**
- * Implementation of XSL stylesheet literal result element.
+ * Implementation of an XSL stylesheet literal result element.
  * 
  * @xsl.usage advanced
  */
diff --git a/src/main/java/org/apache/xalan/templates/ElemMap.java b/src/main/java/org/apache/xalan/templates/ElemMap.java
index 1666ac6cf..009f75bd6 100644
--- a/src/main/java/org/apache/xalan/templates/ElemMap.java
+++ b/src/main/java/org/apache/xalan/templates/ElemMap.java
@@ -29,8 +29,7 @@ import org.apache.xpath.objects.XObject;
 import org.apache.xpath.objects.XPathMap;
 
 /**
- * Class definition, to implement XSLT 3.0 instruction xsl:map 
- * implementation.
+ * Implementation of an XSLT 3.0 instruction xsl:map.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemMatchingSubstring.java b/src/main/java/org/apache/xalan/templates/ElemMatchingSubstring.java
index c09e0804f..10d008033 100644
--- a/src/main/java/org/apache/xalan/templates/ElemMatchingSubstring.java
+++ b/src/main/java/org/apache/xalan/templates/ElemMatchingSubstring.java
@@ -33,7 +33,7 @@ import org.apache.xpath.XPathContext;
 import org.apache.xpath.objects.XObject;
 
 /**
-  * Implementation of XSLT 3.0 instruction xsl:matching-substring.
+  * Implementation of an XSLT 3.0 instruction xsl:matching-substring.
   *    
   * @author Mukul Gandhi <mu...@apache.org>
   *   
diff --git a/src/main/java/org/apache/xalan/templates/ElemMerge.java b/src/main/java/org/apache/xalan/templates/ElemMerge.java
index deaad2342..e09beb58e 100644
--- a/src/main/java/org/apache/xalan/templates/ElemMerge.java
+++ b/src/main/java/org/apache/xalan/templates/ElemMerge.java
@@ -53,7 +53,7 @@ import xml.xpath31.processor.types.XSString;
 import xml.xpath31.processor.types.XSTime;
 
 /**
- * Implementation of the XSLT 3.0 xsl:merge instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:merge.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  *  
diff --git a/src/main/java/org/apache/xalan/templates/ElemMergeAction.java b/src/main/java/org/apache/xalan/templates/ElemMergeAction.java
index 4713064a0..9d3da366e 100644
--- a/src/main/java/org/apache/xalan/templates/ElemMergeAction.java
+++ b/src/main/java/org/apache/xalan/templates/ElemMergeAction.java
@@ -26,7 +26,7 @@ import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 
 /**
- * Implementation of the XSLT 3.0 xsl:merge-action instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:merge-action.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  *  
diff --git a/src/main/java/org/apache/xalan/templates/ElemMergeKey.java b/src/main/java/org/apache/xalan/templates/ElemMergeKey.java
index b04c47d3c..c5e9dad22 100644
--- a/src/main/java/org/apache/xalan/templates/ElemMergeKey.java
+++ b/src/main/java/org/apache/xalan/templates/ElemMergeKey.java
@@ -25,10 +25,7 @@ import org.apache.xpath.ExpressionOwner;
 import org.apache.xpath.XPath;
 
 /**
- * Implementation of the XSLT 3.0 xsl:merge-key instruction.
- * 
- * One or more xsl:merge-key elements appear as child elements
- * of xsl:merge-source elements.
+ * Implementation of an XSLT 3.0 instruction xsl:merge-key.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  *  
diff --git a/src/main/java/org/apache/xalan/templates/ElemMergeSource.java b/src/main/java/org/apache/xalan/templates/ElemMergeSource.java
index b01ba4dc7..97217e273 100644
--- a/src/main/java/org/apache/xalan/templates/ElemMergeSource.java
+++ b/src/main/java/org/apache/xalan/templates/ElemMergeSource.java
@@ -27,10 +27,7 @@ import org.apache.xpath.ExpressionOwner;
 import org.apache.xpath.XPath;
 
 /**
- * Implementation of the XSLT 3.0 xsl:merge-source instruction.
- * 
- * One or more xsl:merge-source elements appear as child elements
- * of xsl:merge elements. 
+ * Implementation of an XSLT 3.0 instruction xsl:merge-source. 
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  *  
diff --git a/src/main/java/org/apache/xalan/templates/ElemMessage.java b/src/main/java/org/apache/xalan/templates/ElemMessage.java
index 292030551..de7b30552 100644
--- a/src/main/java/org/apache/xalan/templates/ElemMessage.java
+++ b/src/main/java/org/apache/xalan/templates/ElemMessage.java
@@ -44,7 +44,7 @@ import org.xml.sax.InputSource;
 import xml.xpath31.processor.types.XSString;
 
 /**
- * Implementation of XSLT 3.0 xsl:message instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:message.
  * 
  * @xsl.usage advanced
  */
diff --git a/src/main/java/org/apache/xalan/templates/ElemMode.java b/src/main/java/org/apache/xalan/templates/ElemMode.java
index 6e00d1fd6..cb2fb03b8 100644
--- a/src/main/java/org/apache/xalan/templates/ElemMode.java
+++ b/src/main/java/org/apache/xalan/templates/ElemMode.java
@@ -23,8 +23,7 @@ import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xml.utils.QName;
 
 /**
- * A class definition, supporting an implementation of 
- * XSLT 3.0 xsl:mode instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:mode.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemNamespace.java b/src/main/java/org/apache/xalan/templates/ElemNamespace.java
index 9b39f49c9..3c7e15c4c 100644
--- a/src/main/java/org/apache/xalan/templates/ElemNamespace.java
+++ b/src/main/java/org/apache/xalan/templates/ElemNamespace.java
@@ -36,7 +36,7 @@ import org.apache.xpath.objects.XdmNamespaceItem;
 import org.w3c.dom.DOMException;
 
 /**
- * Implementation of XSLT 3.0 xsl:namespace instruction.
+ * Implementation of XSLT 3.0 instruction xsl:namespace.
  *
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemNextMatch.java b/src/main/java/org/apache/xalan/templates/ElemNextMatch.java
index 56bfb4110..e681a499d 100644
--- a/src/main/java/org/apache/xalan/templates/ElemNextMatch.java
+++ b/src/main/java/org/apache/xalan/templates/ElemNextMatch.java
@@ -24,9 +24,7 @@ import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xpath.XPath;
 
 /**
- * Implementation of XSLT 3.0 xsl:next-match instruction.
- * 
- * @see <a href="https://www.w3.org/TR/xslt-30/#element-next-match">xsl:next-match XSLT 3.0 specification</a>
+ * Implementation of an XSLT 3.0 instruction xsl:next-match.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemNonMatchingSubstring.java b/src/main/java/org/apache/xalan/templates/ElemNonMatchingSubstring.java
index 7aa3e2d5e..98d20cdfd 100644
--- a/src/main/java/org/apache/xalan/templates/ElemNonMatchingSubstring.java
+++ b/src/main/java/org/apache/xalan/templates/ElemNonMatchingSubstring.java
@@ -30,7 +30,7 @@ import org.apache.xpath.XPathContext;
 import org.apache.xpath.objects.XObject;
 
 /**
- * Implementation of the XSLT 3.0 instruction xsl:non-matching-substring.
+ * Implementation of an XSLT 3.0 instruction xsl:non-matching-substring.
  *    
  * @author Mukul Gandhi <mu...@apache.org>
  *   
diff --git a/src/main/java/org/apache/xalan/templates/ElemNumber.java b/src/main/java/org/apache/xalan/templates/ElemNumber.java
index 7dda36416..3aa1a200b 100644
--- a/src/main/java/org/apache/xalan/templates/ElemNumber.java
+++ b/src/main/java/org/apache/xalan/templates/ElemNumber.java
@@ -54,7 +54,7 @@ import org.xml.sax.SAXException;
 import xml.xpath31.processor.types.XSNumericType;
 
 /**
- * Implementation of XSLT 3.0 xsl:number instruction. 
+ * Implementation of an XSLT instruction xsl:number. 
  * 
  * <xsl:number
  *    value? = expression
diff --git a/src/main/java/org/apache/xalan/templates/ElemOtherwise.java b/src/main/java/org/apache/xalan/templates/ElemOtherwise.java
index b84ad5a42..4612059c0 100644
--- a/src/main/java/org/apache/xalan/templates/ElemOtherwise.java
+++ b/src/main/java/org/apache/xalan/templates/ElemOtherwise.java
@@ -15,20 +15,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xalan.templates;
 
 import org.apache.xpath.XPath;
 
 /**
- * Implement xsl:otherwise.
- * <pre>
- * <!ELEMENT xsl:otherwise %template;>
- * <!ATTLIST xsl:otherwise %space-att;>
- * </pre>
- * @see <a href="http://www.w3.org/TR/xslt#section-Conditional-Processing-with-xsl:choose">XXX in XSLT Specification</a>
+ * Implementation of an XSLT instruction xsl:otherwise.
+ * 
  * @xsl.usage advanced
  */
 public class ElemOtherwise extends ElemTemplateElement
diff --git a/src/main/java/org/apache/xalan/templates/ElemOutputCharacter.java b/src/main/java/org/apache/xalan/templates/ElemOutputCharacter.java
index 725f845bb..98edc5a99 100644
--- a/src/main/java/org/apache/xalan/templates/ElemOutputCharacter.java
+++ b/src/main/java/org/apache/xalan/templates/ElemOutputCharacter.java
@@ -24,9 +24,8 @@ import org.apache.xpath.Expression;
 import org.apache.xpath.ExpressionOwner;
 import org.apache.xpath.XPath;
 
-/**
- * Implementation of XSLT 3.0 xsl:output-character element within
- * xsl:character-map element.
+/** 
+ * Implementation of an XSLT 3.0 instruction xsl:output-character.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemPI.java b/src/main/java/org/apache/xalan/templates/ElemPI.java
index 4ea6d4edb..0eb4fac47 100644
--- a/src/main/java/org/apache/xalan/templates/ElemPI.java
+++ b/src/main/java/org/apache/xalan/templates/ElemPI.java
@@ -32,15 +32,8 @@ import org.apache.xpath.objects.XObject;
 import org.w3c.dom.DOMException;
 
 /**
- * Implement xsl:processing-instruction.
- * <pre>
- * <!ELEMENT xsl:processing-instruction %char-template;>
- * <!ATTLIST xsl:processing-instruction
- *   name %avt; #REQUIRED
- *   %space-att;
- * >
- * </pre>
- * @see <a href="http://www.w3.org/TR/xslt#section-Creating-Processing-Instructions">section-Creating-Processing-Instructions in XSLT Specification</a>
+ * Implementation of an XSLT instruction xsl:processing-instruction.
+ * 
  * @xsl.usage advanced
  */
 public class ElemPI extends ElemTemplateElement
diff --git a/src/main/java/org/apache/xalan/templates/ElemParam.java b/src/main/java/org/apache/xalan/templates/ElemParam.java
index 535e8e9ff..cfcfa7d45 100644
--- a/src/main/java/org/apache/xalan/templates/ElemParam.java
+++ b/src/main/java/org/apache/xalan/templates/ElemParam.java
@@ -34,7 +34,7 @@ import org.apache.xpath.objects.ResultSequence;
 import org.apache.xpath.objects.XObject;
 
 /**
- * Implementation of XSLT 3.0 xsl:param element.
+ * Implementation of an XSLT instruction xsl:param.
  * 
  * @xsl.usage advanced
  */
diff --git a/src/main/java/org/apache/xalan/templates/ElemPerformSort.java b/src/main/java/org/apache/xalan/templates/ElemPerformSort.java
index c65a273c5..127d9cfd6 100644
--- a/src/main/java/org/apache/xalan/templates/ElemPerformSort.java
+++ b/src/main/java/org/apache/xalan/templates/ElemPerformSort.java
@@ -43,7 +43,7 @@ import org.xml.sax.SAXException;
 import xml.xpath31.processor.types.XSString;
 
 /**
- * Implementation of the XSLT 3.0 xsl:perform-sort instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:perform-sort.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemResultDocument.java b/src/main/java/org/apache/xalan/templates/ElemResultDocument.java
index 5c4d917d5..6aad8dbc9 100644
--- a/src/main/java/org/apache/xalan/templates/ElemResultDocument.java
+++ b/src/main/java/org/apache/xalan/templates/ElemResultDocument.java
@@ -64,7 +64,7 @@ import org.xml.sax.InputSource;
 import xml.xpath31.processor.types.XSString;
 
 /**
- * Implementation of the XSLT 3.0 xsl:result-document instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:result-document.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  *  
diff --git a/src/main/java/org/apache/xalan/templates/ElemSequence.java b/src/main/java/org/apache/xalan/templates/ElemSequence.java
index e0d60c2b4..1c664b7bc 100644
--- a/src/main/java/org/apache/xalan/templates/ElemSequence.java
+++ b/src/main/java/org/apache/xalan/templates/ElemSequence.java
@@ -72,7 +72,7 @@ import xml.xpath31.processor.types.XSNumericType;
 import xml.xpath31.processor.types.XSString;
 
 /**
- * Implementation of an XSLT 3.0 xsl:sequence instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:sequence.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  *
diff --git a/src/main/java/org/apache/xalan/templates/ElemSort.java b/src/main/java/org/apache/xalan/templates/ElemSort.java
index 0d137760f..4d1ae779f 100644
--- a/src/main/java/org/apache/xalan/templates/ElemSort.java
+++ b/src/main/java/org/apache/xalan/templates/ElemSort.java
@@ -28,8 +28,9 @@ import org.w3c.dom.DOMException;
 import org.w3c.dom.Node;
 
 /**
- * A class definition, to implement XSLT 3.0's xsl:sort 
- * instruction. 
+ * Implementation of an XSLT 3.0 instruction xsl:sort.
+ *
+ * @xsl.usage advanced
  */
 public class ElemSort extends ElemTemplateElement
 {
diff --git a/src/main/java/org/apache/xalan/templates/ElemSourceDocument.java b/src/main/java/org/apache/xalan/templates/ElemSourceDocument.java
index b388a8535..e7129adf6 100644
--- a/src/main/java/org/apache/xalan/templates/ElemSourceDocument.java
+++ b/src/main/java/org/apache/xalan/templates/ElemSourceDocument.java
@@ -38,7 +38,7 @@ import org.apache.xpath.objects.XMLNodeCursorImpl;
 import org.apache.xpath.objects.XObject;
 
 /**
- * Implementation of the XSLT 3.0 xsl:source-document instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:source-document.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  *  
diff --git a/src/main/java/org/apache/xalan/templates/ElemTemplate.java b/src/main/java/org/apache/xalan/templates/ElemTemplate.java
index 26c8aa482..68fc98011 100644
--- a/src/main/java/org/apache/xalan/templates/ElemTemplate.java
+++ b/src/main/java/org/apache/xalan/templates/ElemTemplate.java
@@ -48,7 +48,7 @@ import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 
 /**
- * Implementation of XSLT 3.0 xsl:template element.
+ * Implementation of an XSLT instruction xsl:template.
  * 
  * @xsl.usage advanced
  */
diff --git a/src/main/java/org/apache/xalan/templates/ElemText.java b/src/main/java/org/apache/xalan/templates/ElemText.java
index 15077eca0..e547476dd 100644
--- a/src/main/java/org/apache/xalan/templates/ElemText.java
+++ b/src/main/java/org/apache/xalan/templates/ElemText.java
@@ -26,7 +26,7 @@ import org.apache.xpath.XPath;
 import org.w3c.dom.DOMException;
 
 /**
- * Implementation of XSLT 3.0 xsl:text instruction.
+ * Implementation of XSLT instruction xsl:text.
  * 
  * @xsl.usage advanced
  */
diff --git a/src/main/java/org/apache/xalan/templates/ElemTextLiteral.java b/src/main/java/org/apache/xalan/templates/ElemTextLiteral.java
index 6fb7175e5..7d1c2eefc 100644
--- a/src/main/java/org/apache/xalan/templates/ElemTextLiteral.java
+++ b/src/main/java/org/apache/xalan/templates/ElemTextLiteral.java
@@ -29,8 +29,8 @@ import org.apache.xml.serializer.SerializerBase;
 import org.xml.sax.SAXException;
 
 /**
- * Implement a text literal.
- * @see <a href="http://www.w3.org/TR/xslt#section-Creating-Text">section-Creating-Text in XSLT Specification</a>
+ * Implementation of an XSLT text literal.
+ *
  * @xsl.usage advanced
  */
 public class ElemTextLiteral extends ElemTemplateElement
diff --git a/src/main/java/org/apache/xalan/templates/ElemTry.java b/src/main/java/org/apache/xalan/templates/ElemTry.java
index ff5f5cfa2..817f2f591 100644
--- a/src/main/java/org/apache/xalan/templates/ElemTry.java
+++ b/src/main/java/org/apache/xalan/templates/ElemTry.java
@@ -42,7 +42,7 @@ import xml.xpath31.processor.types.XSQName;
 import xml.xpath31.processor.types.XSString;
 
 /**
- * An implementation of, XSLT 3.0 xsl:try instruction.
+ * Implementation of an XSLT 3.0 instruction xsl:try.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ElemUnknown.java b/src/main/java/org/apache/xalan/templates/ElemUnknown.java
index 63b26f3f8..de4444bfe 100644
--- a/src/main/java/org/apache/xalan/templates/ElemUnknown.java
+++ b/src/main/java/org/apache/xalan/templates/ElemUnknown.java
@@ -15,9 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xalan.templates;
 
 import javax.xml.transform.TransformerException;
diff --git a/src/main/java/org/apache/xalan/templates/ElemUse.java b/src/main/java/org/apache/xalan/templates/ElemUse.java
index 8a00c6fb4..0b2480bf3 100644
--- a/src/main/java/org/apache/xalan/templates/ElemUse.java
+++ b/src/main/java/org/apache/xalan/templates/ElemUse.java
@@ -15,9 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xalan.templates;
 
 import java.util.Vector;
diff --git a/src/main/java/org/apache/xalan/templates/ElemUsePackage.java b/src/main/java/org/apache/xalan/templates/ElemUsePackage.java
index cce5ba1d4..43635694c 100644
--- a/src/main/java/org/apache/xalan/templates/ElemUsePackage.java
+++ b/src/main/java/org/apache/xalan/templates/ElemUsePackage.java
@@ -25,11 +25,11 @@ import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 
 /**
- * Implementation of XSLT 3.0 instruction xsl:use-package.
+ * Implementation of an XSLT 3.0 instruction xsl:use-package.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
- * @xsl.usage internal
+ * @xsl.usage advanced
  */
 public class ElemUsePackage extends ElemTemplateElement
 {
diff --git a/src/main/java/org/apache/xalan/templates/ElemValueOf.java b/src/main/java/org/apache/xalan/templates/ElemValueOf.java
index 9ae2bb604..0631093f1 100644
--- a/src/main/java/org/apache/xalan/templates/ElemValueOf.java
+++ b/src/main/java/org/apache/xalan/templates/ElemValueOf.java
@@ -72,7 +72,7 @@ import xml.xpath31.processor.types.XSQName;
 import xml.xpath31.processor.types.XSString;
 
 /**
- * Implementation of an XSLT 3.0 xsl:value-of instruction.
+ * Implementation of an XSLT instruction xsl:value-of.
  * 
  * @author Scott Boag <sc...@us.ibm.com>
  * @author Ilene Seelemann
diff --git a/src/main/java/org/apache/xalan/templates/ElemVariable.java b/src/main/java/org/apache/xalan/templates/ElemVariable.java
index 63b1ad55a..1d90be072 100644
--- a/src/main/java/org/apache/xalan/templates/ElemVariable.java
+++ b/src/main/java/org/apache/xalan/templates/ElemVariable.java
@@ -106,7 +106,7 @@ import xml.xpath31.processor.types.XSString;
 import xml.xpath31.processor.types.XSUntypedAtomic;
 
 /**
- * Implementation of an XSLT xsl:variable instruction.
+ * Implementation of an XSLT instruction xsl:variable.
  * 
  * @author Scott Boag <sc...@us.ibm.com>
  * @author Gary L Peskin <ga...@apache.org>
diff --git a/src/main/java/org/apache/xalan/templates/ElemWhen.java b/src/main/java/org/apache/xalan/templates/ElemWhen.java
index ae3280ed3..84f7540e1 100644
--- a/src/main/java/org/apache/xalan/templates/ElemWhen.java
+++ b/src/main/java/org/apache/xalan/templates/ElemWhen.java
@@ -15,23 +15,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xalan.templates;
 
 import org.apache.xpath.XPath;
 
 /**
- * Implement xsl:when.
- * <pre>
- * <!ELEMENT xsl:when %template;>
- * <!ATTLIST xsl:when
- *   test %expr; #REQUIRED
- *   %space-att;
- * >
- * </pre>
- * @see <a href="http://www.w3.org/TR/xslt#section-Conditional-Processing-with-xsl:choose">XXX in XSLT Specification</a>
+ * Implementation of an XSLT instruction xsl:when.
+ *
  * @xsl.usage advanced
  */
 public class ElemWhen extends ElemTemplateElement
diff --git a/src/main/java/org/apache/xalan/templates/ElemWithParam.java b/src/main/java/org/apache/xalan/templates/ElemWithParam.java
index da32293f1..4eebfa23c 100644
--- a/src/main/java/org/apache/xalan/templates/ElemWithParam.java
+++ b/src/main/java/org/apache/xalan/templates/ElemWithParam.java
@@ -40,7 +40,7 @@ import org.apache.xpath.objects.XString;
 import org.w3c.dom.NodeList;
 
 /**
- * Implementation of XSLT xsl:with-param element.
+ * Implementation of an XSLT instruction xsl:with-param.
  * 
  * @xsl.usage advanced
  */
diff --git a/src/main/java/org/apache/xalan/templates/FuncCopyOf.java b/src/main/java/org/apache/xalan/templates/FuncCopyOf.java
index 8e22ef01b..587fc8bc0 100644
--- a/src/main/java/org/apache/xalan/templates/FuncCopyOf.java
+++ b/src/main/java/org/apache/xalan/templates/FuncCopyOf.java
@@ -28,7 +28,7 @@ import org.apache.xpath.objects.XMLNodeCursorImpl;
 import org.apache.xpath.objects.XObject;
 
 /**
- * Implementation of an XSLT 3.0 function copy-of.
+ * Implementation of an XSLT 3.0 function fn:copy-of.
  * 
  * @author : Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/FuncCurrentMergeGroup.java b/src/main/java/org/apache/xalan/templates/FuncCurrentMergeGroup.java
index c3be6cb98..b28c0665e 100644
--- a/src/main/java/org/apache/xalan/templates/FuncCurrentMergeGroup.java
+++ b/src/main/java/org/apache/xalan/templates/FuncCurrentMergeGroup.java
@@ -29,8 +29,7 @@ import org.apache.xpath.objects.ResultSequence;
 import org.apache.xpath.objects.XObject;
 
 /**
- * Implementation of xsl:merge instruction's current-merge-group() 
- * function.
+ * Implementation of an XSLT 3.0 function fn:current-merge-group.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/FuncCurrentMergeKey.java b/src/main/java/org/apache/xalan/templates/FuncCurrentMergeKey.java
index 2a42af83c..fe883bb1b 100644
--- a/src/main/java/org/apache/xalan/templates/FuncCurrentMergeKey.java
+++ b/src/main/java/org/apache/xalan/templates/FuncCurrentMergeKey.java
@@ -28,8 +28,7 @@ import org.apache.xpath.functions.Function;
 import org.apache.xpath.objects.XObject;
 
 /**
- * Implementation of xsl:merge instruction's current-merge-key()
- * function.
+ * Implementation of an XSLT 3.0 function fn:current-merge-key.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/FuncDocument.java b/src/main/java/org/apache/xalan/templates/FuncDocument.java
index a46f9a5a4..6e673384e 100644
--- a/src/main/java/org/apache/xalan/templates/FuncDocument.java
+++ b/src/main/java/org/apache/xalan/templates/FuncDocument.java
@@ -15,9 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xalan.templates;
 
 import java.io.IOException;
@@ -44,7 +41,7 @@ import org.apache.xpath.objects.XMLNodeCursorImpl;
 import org.apache.xpath.objects.XObject;
 
 /**
- * Implementation of an XSLT 3.0 function fn:document.
+ * Implementation of an XSLT function fn:document.
  *
  * When the document function has exactly one argument and the argument
  * is a node-set, then the result is the union, for each node in the
@@ -56,6 +53,7 @@ import org.apache.xpath.objects.XObject;
  * of the result of calling the document function with the first argument
  * being the string-value of the node, and with the second argument being
  * the second argument passed to the document function.
+ * 
  * @xsl.usage advanced
  */
 public class FuncDocument extends Function2Args
diff --git a/src/main/java/org/apache/xalan/templates/FuncKey.java b/src/main/java/org/apache/xalan/templates/FuncKey.java
index dcb644bcb..11ddc04da 100644
--- a/src/main/java/org/apache/xalan/templates/FuncKey.java
+++ b/src/main/java/org/apache/xalan/templates/FuncKey.java
@@ -56,7 +56,7 @@ import xml.xpath31.processor.types.XSNumericType;
 import xml.xpath31.processor.types.XSTime;
 
 /**
- * Implementation of an XSLT 3.0 function fn:key.
+ * Implementation of an XSLT function fn:key.
  * 
  * @xsl.usage advanced
  */
diff --git a/src/main/java/org/apache/xalan/templates/FuncRegexGroup.java b/src/main/java/org/apache/xalan/templates/FuncRegexGroup.java
index 322e3c2f4..7fdfc41e3 100644
--- a/src/main/java/org/apache/xalan/templates/FuncRegexGroup.java
+++ b/src/main/java/org/apache/xalan/templates/FuncRegexGroup.java
@@ -30,7 +30,7 @@ import org.apache.xpath.objects.XString;
 import org.apache.xpath.regex.Matcher;
 
 /**
- * Implementation of XSLT 3.0 function fn:regex-group.
+ * Implementation of an XSLT 3.0 function fn:regex-group.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/GroupingKeyAndGroupPair.java b/src/main/java/org/apache/xalan/templates/GroupingKeyAndGroupPair.java
index 00050ce07..e618991a1 100644
--- a/src/main/java/org/apache/xalan/templates/GroupingKeyAndGroupPair.java
+++ b/src/main/java/org/apache/xalan/templates/GroupingKeyAndGroupPair.java
@@ -19,12 +19,9 @@ package org.apache.xalan.templates;
 import java.util.List;
 
 /**
- * This class is used for an implementation, when xsl:for-each-group 
- * instruction has an attribute 'group-by' or 'group-adjacent'. 
- * 
- * An object of this class, has complete information about one group 
- * (which is grouping key of the group, and all members of the group) 
- * among all the possible groups formed by xsl:for-each-group instruction.
+ * Class definition, used by XSLT 3.0 instruction xsl:for-each-group 
+ * implementation, when xsl:for-each-group has an attribute 
+ * 'group-by', or 'group-adjacent'. 
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/ModeList.java b/src/main/java/org/apache/xalan/templates/ModeList.java
index 34ed00bb6..4e71a87e4 100644
--- a/src/main/java/org/apache/xalan/templates/ModeList.java
+++ b/src/main/java/org/apache/xalan/templates/ModeList.java
@@ -23,9 +23,8 @@ import java.util.Map;
 import org.apache.xml.utils.QName;
 
 /**
- * A class definition, to encapsulate an XSL mode list indentified 
- * by xsl:mode instruction(s), and helps locate individual mode 
- * declarations.
+ * Class definition, to encapsulate an XSLT 3.0 mode list 
+ * identified by one or more xsl:mode instruction.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xalan/templates/XslFunctionDefinitionKey.java b/src/main/java/org/apache/xalan/templates/XslFunctionDefinitionKey.java
index 37582a997..e5f323af0 100644
--- a/src/main/java/org/apache/xalan/templates/XslFunctionDefinitionKey.java
+++ b/src/main/java/org/apache/xalan/templates/XslFunctionDefinitionKey.java
@@ -21,7 +21,7 @@ import org.apache.xml.utils.QName;
 
 /**
  * A class definition, whose object instance uniquely identifies 
- * an xsl:function definition.
+ * an xsl:function declaration within an XSL stylesheet.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
diff --git a/src/main/java/org/apache/xpath/compiler/FunctionTable.java b/src/main/java/org/apache/xpath/compiler/FunctionTable.java
index 2081b9246..aff99d3fa 100644
--- a/src/main/java/org/apache/xpath/compiler/FunctionTable.java
+++ b/src/main/java/org/apache/xpath/compiler/FunctionTable.java
@@ -915,7 +915,7 @@ public class FunctionTable
 	   m_functions[FUNC_PATH] = org.apache.xpath.functions.FuncPath.class;
 	   
 	   m_functions[FUNC_DOCUMENT] = org.apache.xalan.templates.FuncDocument.class;
-	   m_functions[FUNC_FORMAT_NUMBER] = org.apache.xalan.templates.FuncFormatNumber.class;
+	   m_functions[FUNC_FORMAT_NUMBER] = org.apache.xpath.functions.FuncFormatNumber.class;
   }
 
   static {
diff --git a/src/main/java/org/apache/xalan/templates/FuncFormatNumber.java b/src/main/java/org/apache/xpath/functions/FuncFormatNumber.java
similarity index 97%
rename from src/main/java/org/apache/xalan/templates/FuncFormatNumber.java
rename to src/main/java/org/apache/xpath/functions/FuncFormatNumber.java
index e14de21ab..b0952bd01 100644
--- a/src/main/java/org/apache/xalan/templates/FuncFormatNumber.java
+++ b/src/main/java/org/apache/xpath/functions/FuncFormatNumber.java
@@ -15,7 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.xalan.templates;
+package org.apache.xpath.functions;
 
 import javax.xml.transform.ErrorListener;
 import javax.xml.transform.SourceLocator;
@@ -23,12 +23,13 @@ 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.ElemTemplateElement;
+import org.apache.xalan.templates.StylesheetRoot;
 import org.apache.xalan.xslt.util.XslTransformEvaluationHelper;
 import org.apache.xml.utils.QName;
 import org.apache.xml.utils.SAXSourceLocator;
 import org.apache.xpath.XPathContext;
-import org.apache.xpath.functions.Function3Args;
-import org.apache.xpath.functions.WrongNumberArgsException;
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.objects.XPathInlineFunction;
 import org.apache.xpath.objects.XString;
diff --git a/src/main/java/org/apache/xpath/functions/FuncSerialize.java b/src/main/java/org/apache/xpath/functions/FuncSerialize.java
index f590ad1fd..004c36a1a 100644
--- a/src/main/java/org/apache/xpath/functions/FuncSerialize.java
+++ b/src/main/java/org/apache/xpath/functions/FuncSerialize.java
@@ -34,7 +34,6 @@ import org.apache.xalan.templates.Constants;
 import org.apache.xalan.templates.ElemCopyOf;
 import org.apache.xalan.templates.ElemFunction;
 import org.apache.xalan.templates.ElemTemplateElement;
-import org.apache.xalan.templates.FuncFormatNumber;
 import org.apache.xalan.templates.OutputProperties;
 import org.apache.xalan.templates.StylesheetRoot;
 import org.apache.xalan.templates.XMLNSDecl;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xalan.apache.org
For additional commands, e-mail: commits-help@xalan.apache.org