You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sh...@apache.org on 2014/05/16 18:11:35 UTC

svn commit: r1595253 [13/18] - in /xalan/java/branches/WebSite: ./ xalan-j/ xalan-j/design/ xalan-j/design/resources/ xalan-j/resources/ xalan-j/xsltc/ xalan-j/xsltc/resources/

Added: xalan/java/branches/WebSite/xalan-j/xsltc/xsl_if_design.html
URL: http://svn.apache.org/viewvc/xalan/java/branches/WebSite/xalan-j/xsltc/xsl_if_design.html?rev=1595253&view=auto
==============================================================================
--- xalan/java/branches/WebSite/xalan-j/xsltc/xsl_if_design.html (added)
+++ xalan/java/branches/WebSite/xalan-j/xsltc/xsl_if_design.html Fri May 16 16:11:33 2014
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+<title>ASF: &lt;xsl:if&gt;</title>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+<meta http-equiv="Content-Style-Type" content="text/css" />
+<link rel="stylesheet" type="text/css" href="resources/apache-xalan.css" />
+</head>
+<!--
+ * 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.
+ -->
+<body>
+<div id="title">
+<table class="HdrTitle">
+<tbody>
+<tr>
+<th rowspan="2">
+<a href="../index.html">
+<img alt="Trademark Logo" src="resources/XalanJ-Logo-tm.png" width="190" height="90" />
+</a>
+</th>
+<th text-align="center" width="75%">
+<a href="index.html">XSLTC Design</a>
+</th>
+</tr>
+<tr>
+<td valign="middle">&lt;xsl:if&gt;</td>
+</tr>
+</tbody>
+</table>
+<table class="HdrButtons" align="center" border="1">
+<tbody>
+<tr>
+<td>
+<a href="http://www.apache.org">Apache Foundation</a>
+</td>
+<td>
+<a href="http://xalan.apache.org">Xalan Project</a>
+</td>
+<td>
+<a href="http://xerces.apache.org">Xerces Project</a>
+</td>
+<td>
+<a href="http://www.w3.org/TR">Web Consortium</a>
+</td>
+<td>
+<a href="http://www.oasis-open.org/standards">Oasis Open</a>
+</td>
+</tr>
+</tbody>
+</table>
+</div>
+<div id="navLeft">
+<ul>
+<li>
+<a href="index.html">Overview</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_compiler.html">Compiler design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_whitespace_design.html">Whitespace</a>
+</li>
+<li>
+<a href="xsl_sort_design.html">xsl:sort</a>
+</li>
+<li>
+<a href="xsl_key_design.html">Keys</a>
+</li>
+<li>
+<a href="xsl_comment_design.html">Comment design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_lang_design.html">lang()</a>
+</li>
+<li>
+<a href="xsl_unparsed_design.html">Unparsed entities</a>
+</li></ul><hr /><ul>
+<li>If design<br />
+</li>
+<li>
+<a href="xsl_choose_design.html">Choose|When|Otherwise design</a>
+</li>
+<li>
+<a href="xsl_include_design.html">Include|Import design</a>
+</li>
+<li>
+<a href="xsl_variable_design.html">Variable|Param design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_runtime.html">Runtime</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_dom.html">Internal DOM</a>
+</li>
+<li>
+<a href="xsltc_namespace.html">Namespaces</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_trax.html">Translet &amp; TrAX</a>
+</li>
+<li>
+<a href="xsltc_predicates.html">XPath Predicates</a>
+</li>
+<li>
+<a href="xsltc_iterators.html">Xsltc Iterators</a>
+</li>
+<li>
+<a href="xsltc_native_api.html">Xsltc Native API</a>
+</li>
+<li>
+<a href="xsltc_trax_api.html">Xsltc TrAX API</a>
+</li>
+<li>
+<a href="xsltc_performance.html">Performance Hints</a>
+</li>
+</ul>
+</div>
+<div id="content">
+<h2>&lt;xsl:if&gt;</h2>
+
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Contents</h3>
+  <ul>
+    <li>
+<a href="#functionality">Functionality</a>
+</li>
+    <li>
+<a href="#implementation">Implementation</a>
+</li>    
+  </ul>
+  
+
+  <a name="functionality">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Functionality</h3>
+
+  <p>This element is cruical to XSL processing, but still very simple both in
+  its use and implementation. The element is used like this:</p>
+<blockquote class="source">
+<pre>
+  &lt;xsl:if test="contains($the-world,'Elvis')"&gt;
+    &lt;xsl:message&gt;Elvis is still alive!&lt;/xsl:message&gt;
+  &lt;/xsl:if&gt;</pre>
+</blockquote>
+
+  <p>The element's contents will only be executed if the test succeeds. There
+  is no <code>&lt;xsl:else&gt;</code> element. One has to use either several
+  <code>&lt;xsl:if&gt;</code>-elements or use a choose-element.</p>
+
+  
+
+  <a name="implementation">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Implementation</h3>
+
+  <p>The basic implementation is very simple:</p>
+  <ul>
+    <li>execute the expression from the 'test'-attribute</li>
+    <li>evaluate the resulting boolean value</li>
+    <li>ignore the element contents if the value is 'false'</li>
+    <li>otherwise execute the element contents</li>
+  </ul>
+
+  <p>There is onle type of function call that makes this a bit more complicated.
+  The <code>function-available()</code> and <code>element-available()</code>
+  function calls can be used to test for extension elements and functions. A
+  very common use for these is to encapsulate all references to extension
+  elements inside an <code>&lt;xsl:if&gt;</code> element and test for the
+  existance of this element before attempting to use it. XSLTC has to support
+  this. Otherwise we may risk either outputting erronuous error or warning
+  messages about acessing non-existing elements, or even worse, compiling in
+  calls to non-existing methods in the translet, causing the JVM's verifier to
+  prevent the translet from being loaded.</p>
+
+  <p>The <code>function-available()</code> and <code>element-available()</code>
+  functions have been updated to perform an evaluation at compile-time, so that
+  the <code>If</code> class can know wether to compile in calls to extensions or
+  not. This is possible because both functions take only literal expressions as
+  parameters. See the <code>getResult()</code> methods of the
+  <code>FunctionAvailableCall</code> and <code>ElementAvailableCall</code>
+  classes for details.</p>
+
+  
+
+<p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+</div>
+<div id="footer">Copyright © 1999-2014 The Apache Software Foundation<br />Apache, Xalan, and the Feather logo are trademarks of The Apache Software Foundation<div class="small">Web Page created on - Thu 2014-05-15</div>
+</div>
+</body>
+</html>

Propchange: xalan/java/branches/WebSite/xalan-j/xsltc/xsl_if_design.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xalan/java/branches/WebSite/xalan-j/xsltc/xsl_include_design.html
URL: http://svn.apache.org/viewvc/xalan/java/branches/WebSite/xalan-j/xsltc/xsl_include_design.html?rev=1595253&view=auto
==============================================================================
--- xalan/java/branches/WebSite/xalan-j/xsltc/xsl_include_design.html (added)
+++ xalan/java/branches/WebSite/xalan-j/xsltc/xsl_include_design.html Fri May 16 16:11:33 2014
@@ -0,0 +1,283 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+<title>ASF: &lt;xsl:include&gt; / &lt;xsl:import&gt;</title>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+<meta http-equiv="Content-Style-Type" content="text/css" />
+<link rel="stylesheet" type="text/css" href="resources/apache-xalan.css" />
+</head>
+<!--
+ * 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.
+ -->
+<body>
+<div id="title">
+<table class="HdrTitle">
+<tbody>
+<tr>
+<th rowspan="2">
+<a href="../index.html">
+<img alt="Trademark Logo" src="resources/XalanJ-Logo-tm.png" width="190" height="90" />
+</a>
+</th>
+<th text-align="center" width="75%">
+<a href="index.html">XSLTC Design</a>
+</th>
+</tr>
+<tr>
+<td valign="middle">&lt;xsl:include&gt; / &lt;xsl:import&gt;</td>
+</tr>
+</tbody>
+</table>
+<table class="HdrButtons" align="center" border="1">
+<tbody>
+<tr>
+<td>
+<a href="http://www.apache.org">Apache Foundation</a>
+</td>
+<td>
+<a href="http://xalan.apache.org">Xalan Project</a>
+</td>
+<td>
+<a href="http://xerces.apache.org">Xerces Project</a>
+</td>
+<td>
+<a href="http://www.w3.org/TR">Web Consortium</a>
+</td>
+<td>
+<a href="http://www.oasis-open.org/standards">Oasis Open</a>
+</td>
+</tr>
+</tbody>
+</table>
+</div>
+<div id="navLeft">
+<ul>
+<li>
+<a href="index.html">Overview</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_compiler.html">Compiler design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_whitespace_design.html">Whitespace</a>
+</li>
+<li>
+<a href="xsl_sort_design.html">xsl:sort</a>
+</li>
+<li>
+<a href="xsl_key_design.html">Keys</a>
+</li>
+<li>
+<a href="xsl_comment_design.html">Comment design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_lang_design.html">lang()</a>
+</li>
+<li>
+<a href="xsl_unparsed_design.html">Unparsed entities</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_if_design.html">If design</a>
+</li>
+<li>
+<a href="xsl_choose_design.html">Choose|When|Otherwise design</a>
+</li>
+<li>Include|Import design<br />
+</li>
+<li>
+<a href="xsl_variable_design.html">Variable|Param design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_runtime.html">Runtime</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_dom.html">Internal DOM</a>
+</li>
+<li>
+<a href="xsltc_namespace.html">Namespaces</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_trax.html">Translet &amp; TrAX</a>
+</li>
+<li>
+<a href="xsltc_predicates.html">XPath Predicates</a>
+</li>
+<li>
+<a href="xsltc_iterators.html">Xsltc Iterators</a>
+</li>
+<li>
+<a href="xsltc_native_api.html">Xsltc Native API</a>
+</li>
+<li>
+<a href="xsltc_trax_api.html">Xsltc TrAX API</a>
+</li>
+<li>
+<a href="xsltc_performance.html">Performance Hints</a>
+</li>
+</ul>
+</div>
+<div id="content">
+<h2>&lt;xsl:include&gt; / &lt;xsl:import&gt;</h2>
+
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Contents</h3>
+  <ul>
+    <li>
+<a href="#functionality">Functionality</a>
+</li>
+    <li>
+<a href="#implementation">Implementation</a>
+</li>    
+  </ul>
+  
+
+  <a name="functionality">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Functionality</h3>
+
+    <p>
+<code>&lt;xsl:include&gt;</code> allows you to include one stylesheet
+    into another. The includ<b>ed</b> stylesheet's templates will have the same
+    default priorities and import precedence as the includ<b>ing</b> stylesheet.
+    <code>&lt;xsl:import&gt;</code> offers the same, but the import precedence
+    of elements in an import<b>ed</b> stylesheet is always less than that of
+    the import<b>ing</b> stylesheet.</p>
+   
+  
+
+  <a name="implementation">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Implementation</h3>
+ 
+    <a name="include">‌</a>
+    <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h4>&lt;xsl:include&gt;</h4>
+
+    <p>This is the simplest case, so we will look at that first. The algorithm
+    for including another stylesheet is roughly:</p>
+
+    <ul>
+      <li>get the including stylesheet from the XSLT parser</li>
+      <li>get the value of the "href" attribute from the
+        <code>&lt;xsl:include&gt;</code> element and check for circular
+        includes/imports</li>
+      <li>check if there is a defined <code>SourceLoader</code> set either
+        through the native or the TrAX API</li>
+      <li>get an <code>InputSource</code> for the document to include, either
+        from the <code>SourceLoader</code> or from the document's URI</li>
+      <li>parse the input document using the compiler's XSLT parser</li>
+      <li>set the import precedence of the included stylesheet to the same as
+        the import precedence of the including stylesheet</li>
+      <li>get the top-level stylesheet from the XSLT parser</li>
+      <li>move all variables, parameters, and top-level elements (include
+        templates) from the included stylesheet to the top-level stylesheet
+        (all elements will keep their import precedence even after being moved
+        to the top-level stylesheet)</li>
+    </ul>
+ 
+        
+
+    <a name="import">‌</a>
+    <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h4>&lt;xsl:import&gt;</h4>
+
+    <p>This is very similar to <code>&lt;xsl:include&gt;</code>, but import
+    precedence has to be handled differently. Looking at the code you'll find
+    this fragment:</p>
+<blockquote class="source">
+<pre>
+    // Handle precedence for the including stylesheet
+    final int currPrecedence = parser.getCurrentImportPrecedence();
+    final int nextPrecedence = parser.getNextImportPrecedence();
+    _imported.setImportPrecedence(currPrecedence);
+    context.setImportPrecedence(nextPrecedence);</pre>
+</blockquote>
+
+    <p>The important thing here is that the imported stylesheet has import
+    precedence <b>less</b> than the importing stylesheet. So the imported
+    stylesheet gets the current import precedence, while the current stylesheet
+    gets the next available (unused) import precedence. The
+    <code>Stylesheet</code> class has a method
+    <code>setImportPrecedence()</code> that ensures that the import precedence
+    is set not only for the stylesheet itself, but that it is also propagated
+    down to any included/imported stylesheets:</p>
+<blockquote class="source">
+<pre>
+    public void setImportPrecedence(final int precedence) {
+	// Set import precedence for this stylesheet
+	_importPrecedence = precedence;
+
+	// Set import precedence for all included stylesheets
+	final Enumeration elements = elements();
+	while (elements.hasMoreElements()) {
+	    SyntaxTreeNode child = (SyntaxTreeNode)elements.nextElement();
+	    if (child instanceof Include) {
+		Stylesheet included = ((Include)child).getIncludedStylesheet();
+		if (included != null) included.setImportPrecedence(precedence);
+	    }
+	}
+
+	// Set import precedence for the stylesheet that imported this one
+	if (_importedFrom != null) {
+	    if (_importedFrom.getImportPrecedence() &lt; precedence) {
+		final Parser parser = getParser();
+		final int nextPrecedence = parser.getNextImportPrecedence();
+		_importedFrom.setImportPrecedence(nextPrecedence);
+	    }
+	}
+	// Set import precedence for the stylesheet that included this one
+	else if (_includedFrom != null) {
+	    if (_includedFrom.getImportPrecedence() != precedence)
+		_includedFrom.setImportPrecedence(precedence);
+	}
+    }</pre>
+</blockquote>
+
+    <p>This method has been carefully cluttered together, and it works, and it
+    should not be touched.</p>
+
+    
+
+    <a name="apply-imports">‌</a>
+    <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h4>&lt;xsl:apply-imports&gt;</h4>
+
+    
+
+  
+
+<p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+</div>
+<div id="footer">Copyright © 1999-2014 The Apache Software Foundation<br />Apache, Xalan, and the Feather logo are trademarks of The Apache Software Foundation<div class="small">Web Page created on - Thu 2014-05-15</div>
+</div>
+</body>
+</html>

Propchange: xalan/java/branches/WebSite/xalan-j/xsltc/xsl_include_design.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xalan/java/branches/WebSite/xalan-j/xsltc/xsl_key_design.html
URL: http://svn.apache.org/viewvc/xalan/java/branches/WebSite/xalan-j/xsltc/xsl_key_design.html?rev=1595253&view=auto
==============================================================================
--- xalan/java/branches/WebSite/xalan-j/xsltc/xsl_key_design.html (added)
+++ xalan/java/branches/WebSite/xalan-j/xsltc/xsl_key_design.html Fri May 16 16:11:33 2014
@@ -0,0 +1,425 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+<title>ASF: &lt;xsl:key&gt; / key() / IdKeyPattern</title>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+<meta http-equiv="Content-Style-Type" content="text/css" />
+<link rel="stylesheet" type="text/css" href="resources/apache-xalan.css" />
+</head>
+<!--
+ * 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.
+ -->
+<body>
+<div id="title">
+<table class="HdrTitle">
+<tbody>
+<tr>
+<th rowspan="2">
+<a href="../index.html">
+<img alt="Trademark Logo" src="resources/XalanJ-Logo-tm.png" width="190" height="90" />
+</a>
+</th>
+<th text-align="center" width="75%">
+<a href="index.html">XSLTC Design</a>
+</th>
+</tr>
+<tr>
+<td valign="middle">&lt;xsl:key&gt; / key() / IdKeyPattern</td>
+</tr>
+</tbody>
+</table>
+<table class="HdrButtons" align="center" border="1">
+<tbody>
+<tr>
+<td>
+<a href="http://www.apache.org">Apache Foundation</a>
+</td>
+<td>
+<a href="http://xalan.apache.org">Xalan Project</a>
+</td>
+<td>
+<a href="http://xerces.apache.org">Xerces Project</a>
+</td>
+<td>
+<a href="http://www.w3.org/TR">Web Consortium</a>
+</td>
+<td>
+<a href="http://www.oasis-open.org/standards">Oasis Open</a>
+</td>
+</tr>
+</tbody>
+</table>
+</div>
+<div id="navLeft">
+<ul>
+<li>
+<a href="index.html">Overview</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_compiler.html">Compiler design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_whitespace_design.html">Whitespace</a>
+</li>
+<li>
+<a href="xsl_sort_design.html">xsl:sort</a>
+</li>
+<li>Keys<br />
+</li>
+<li>
+<a href="xsl_comment_design.html">Comment design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_lang_design.html">lang()</a>
+</li>
+<li>
+<a href="xsl_unparsed_design.html">Unparsed entities</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_if_design.html">If design</a>
+</li>
+<li>
+<a href="xsl_choose_design.html">Choose|When|Otherwise design</a>
+</li>
+<li>
+<a href="xsl_include_design.html">Include|Import design</a>
+</li>
+<li>
+<a href="xsl_variable_design.html">Variable|Param design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_runtime.html">Runtime</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_dom.html">Internal DOM</a>
+</li>
+<li>
+<a href="xsltc_namespace.html">Namespaces</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_trax.html">Translet &amp; TrAX</a>
+</li>
+<li>
+<a href="xsltc_predicates.html">XPath Predicates</a>
+</li>
+<li>
+<a href="xsltc_iterators.html">Xsltc Iterators</a>
+</li>
+<li>
+<a href="xsltc_native_api.html">Xsltc Native API</a>
+</li>
+<li>
+<a href="xsltc_trax_api.html">Xsltc TrAX API</a>
+</li>
+<li>
+<a href="xsltc_performance.html">Performance Hints</a>
+</li>
+</ul>
+</div>
+<div id="content">
+<h2>&lt;xsl:key&gt; / key() / IdKeyPattern</h2>
+
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Contents</h3>
+  <ul>
+    <li>
+<a href="#functionality">Functionality</a>
+</li>
+    <li>
+<a href="#implementation">Implementation</a>
+</li>    
+  </ul>
+  
+
+  <a name="functionality">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Functionality</h3>
+
+  <p>The <code>&lt;xsl:key&gt;</code> element is a top-level element that can be
+  used to define a named index of nodes from the source XML tree(s). The
+  element has three attributes:</p>
+
+  <ul>
+    <li>
+      <code>name</code> - the name of the index
+    </li>
+    <li>
+      <code>match</code> - a pattern that defines the nodeset we want
+      indexed
+    </li>
+    <li>
+      <code>use</code> - an expression that defines the value to be used
+      as the index key value.
+    </li>
+  </ul>
+
+  <p>A named index can be accessed using either the <code>key()</code> function
+  or a KeyPattern. Both these methods address the index using its defined name
+  (the "name" attribute above) and a parameter defining one or more lookup
+  values for the index. The function or pattern returns a node set containing
+  all nodes in the index whose key value match the parameter's value(s):</p>
+
+  <blockquote class="source">
+<pre>
+    &lt;xsl:key name="book-author" match="book" use="author"/&gt;
+        :
+        :
+    &lt;xsl:for-each select="key('book-author', 'Mikhail Bulgakov')"&gt;
+      &lt;xsl:value-of select="author"/&gt;
+      &lt;xsl:text&gt;: &lt;/xsl:text&gt;
+      &lt;xsl:value-of select="author"/&gt;
+      &lt;xsl:text&gt;&amp;#xa;&lt;/xsl:text&gt;
+    &lt;/xsl:for-each&gt;</pre>
+</blockquote>
+
+  <p>The KeyPattern can be used within an index definition to create unions
+  and intersections of node sets:</p>
+<blockquote class="source">
+<pre>
+    &lt;xsl:key name="cultcies" match="farmer | fisherman" use="name"/&gt;</pre>
+</blockquote>
+
+  <p>This could have been done using regular <code>&lt;xsl:for-each&gt;</code>
+  and <code>&lt;xsl:select&gt;</code> elements. However, if your stylesheet
+  accesses the same selection of nodes over and over again, the transformation
+  will be much more efficient using pre-indexed keys as shown above.</p>
+
+  
+
+  <a name="implementation">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Implementation</h3>
+
+    <a name="indexing">‌</a>
+    <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h4>Indexing</h4>
+
+    <p>The <code>AbstractTranslet</code> class has a global hashtable that holds
+    an index for each named key in the stylesheet (hashing on the "name"
+    attribute of <code>&lt;xsl:key&gt;</code>). <code>AbstractTranslet</code>
+    has a couple of public methods for inserting and retrieving data from this
+    hashtable:</p>
+<blockquote class="source">
+<pre>
+    public void buildKeyIndex(String keyName, int nodeID, String value);
+    public KeyIndex KeyIndex getKeyIndex(String keyName);</pre>
+</blockquote>
+
+    <p>The <code>Key</code> class compiles code that traverses the input DOM and
+    extracts nodes that match some given parameters (the <code>"match"</code>
+    attribute of the <code>&lt;xsl:key&gt;</code> element). A new element is
+    inserted into the named key's index. The nodes' DOM index and the value
+    translated from the <code>"use"</code> attribute of the
+    <code>&lt;xsl:key&gt;</code> element are stored in the new entry in the
+    index.</p>
+
+    <p>Something similar is done for indexing IDs. This index is generated from
+    the <code>ID</code> and <code>IDREF</code> fields in the input document's
+    DTD. This means that the code for generating this index cannot be generated
+    at compile-time, which again means that the code has to be generic enough
+    to handle all DTDs. The class that handles this is the
+    <code>org.apache.xalan.xsltc.dom.DTDMonitor</code> class. This class
+    implements the <code>org.xml.sax.XMLReader</code> and
+    <code>org.xml.sax.DTDHandler</code> interfaces. A client application using
+    the native API must instanciate a <code>DTDMonitor</code> and pass it to the
+    translet code - if, and only if, it wants IDs indexed (one can improve
+    performance by omitting this step). This is descrived in the
+    <a href="xsltc_native_api.html">XSLTC Native API reference</a>. The
+    <code>DTDMonitor</code> class will use the same indexing as the code
+    generated by the <code>Key</code> class. The index for ID's is called
+    "##id". We assume that no stylesheets will contain a key with this name.</p>
+
+    <p>The index itself is implemented in the
+    <code>org.apache.xalan.xsltc.dom.KeyIndex</code> class. The index has an
+    hashtable with all the values from the matching nodes (the part of the node
+    used to generate this value is the one specified in the <code>"use"</code>
+    attribute). For every matching value there is a bit-array (implemented in
+    the <code>org.apache.xalan.xsltc.BitArray</code> class), holding a list of
+    all node indexes for which this value gives a match:</p>
+    <p>
+<img src="key_relations.gif" alt="key_relations.gif" />
+</p>
+    <p>
+<b>
+<i>Figure 1: Indexing tables</i>
+</b>
+</p>
+
+    <p>The <code>KeyIndex</code> class implements the <code>NodeIterator</code>
+    interface, so that it can be returned directly by the implementation of the
+    <code>key()</code> function. This is how the index generated by
+    <code>&lt;xsl:key&gt;</code> and the node-set returned by the
+    <code>key()</code> and KeyPattern are tied together. You can see how this is
+    done in the <code>translate()</code> method of the <code>KeyCall</code>
+    class.</p>
+
+    <p>The <code>key()</code> function can be called in two ways:</p>
+<blockquote class="source">
+<pre>
+    key('key-name','value')
+    key('key-name','node-set')</pre>
+</blockquote>
+
+    <p>The first parameter is always the name of the key. We use this value to
+    lookup our index from the _keyIndexes hashtable in AbstractTranslet:</p>
+    <blockquote class="source">
+<pre>
+    il.append(classGen.aloadThis());
+    _name.translate(classGen, methodGen);
+    il.append(new INVOKEVIRTUAL(getKeyIndex));</pre>
+</blockquote>
+
+    <p>This compiles into a call to
+    <code>AbstractTranslet.getKeyIndex(String name)</code>, and it leaves a
+    <code>KeyIndex</code> object on the stack. What we then need to do it to
+    initialise the <code>KeyIndex</code> to give us nodes with the requested
+    value. This is done by leaving the <code>KeyIndex</code> object on the stack
+    and pushing the <code>"value"</code> parameter to <code>key()</code>, before
+    calling <code>lookup()</code> on the index:</p>
+<blockquote class="source">
+<pre>
+    il.append(DUP);  // duplicate the KeyIndex obejct before return
+    _value.translate(classGen, methodGen);
+    il.append(new INVOKEVIRTUAL(lookup));</pre>
+</blockquote>
+
+    <p>This compiles into a call to <code>KeyIndex.lookup(String value)</code>.
+    This will initialise the <code>KeyIndex</code> object to return nodes that
+    match the given value, so the <code>KeyIndex</code> object can be left on
+    the stack when we return. This because the <code>KeyIndex</code> object
+    implements the <code>NodeIterator</code> interface.</p>
+
+    <p>This matter is a bit more complex when the second parameter of
+    <code>key()</code> is a node-set. In this case we need to traverse the nodes
+    in the set and do a lookup for each node in the set. What I do is this:</p>
+
+    <ul>
+      <li>
+        construct a <code>KeyIndex</code> object that will hold the
+        return node-set
+      </li>
+      <li>
+        find the named <code>KeyIndex</code> object from the hashtable in
+        AbstractTranslet
+      </li>
+      <li>
+        get an iterator for the node-set and do the folowing loop:</li>
+        <ul>
+          <li>get string value for current node</li>
+          <li>do lookup in KeyIndex object for the named index</li>
+          <li>merge the resulting node-set into the return node-set</li>
+        </ul>
+      <li>
+        leave the return node-set on stack when done
+      </li>
+    </ul>
+
+    
+
+    <a name="improvements">‌</a>
+    <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h4>Possible indexing improvements</h4>
+
+    <p>The indexing implementation can be very, very memeory exhaustive as there
+    is one <code>BitArray</code> allocated for each value for every index. This
+    is particulary bad for the index used for IDs ('##id'), where a single value
+    should only map to one, single node. This means that a whole
+    <code>BitArray</code> is used just to contain one node. The
+    <code>KeyIndex</code> class should be updated to hold the first node for a
+    value in an <code>Integer</code> object, and then replace that with a
+    <code>BitArray</code> or a <code>Vector</code> only is a second node is
+    added to the value. Here is an outline for <code>KeyIndex</code>:</p>
+    <blockquote class="source">
+<pre>
+
+    public void add(Object value, int node) {
+        Object container;
+	if ((container = (BitArray)_index.get(value)) == null) {
+            _index.put(value, new Integer(node));
+	}
+	else {
+            // Check if there is _one_ node for this value
+            if (container instanceof Integer) {
+                int first = ((Integer)container
+                _nodes = new BitArray(_arraySize);
+                _nodes.setMask(node &amp; 0xff000000);
+                _nodes.setBit(first &amp; 0x00ffffff);
+                _nodes.setBit(node &amp; 0x00ffffff);
+                _index.put(value, _nodes);
+            }
+            // Otherwise add node to axisting bit array
+            else {
+                _nodex = (BitArray)container;
+                _nodes.setBit(node &amp; 0x00ffffff);
+            }
+        }
+    }</pre>
+</blockquote>
+
+    <p>Other methods inside the <code>KeyIndex</code> should be updated to
+    reflect this.</p>
+
+    
+
+    <a name="patterns">‌</a>
+    <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h4>Id and Key patterns</h4>
+
+    <p>As already mentioned, the challenge with the <code>id()</code> and
+    <code>key()</code> patterns is that they have no specific node type. 
+    Patterns are normally grouped based on their pattern's "kernel" node type.
+    This is done in the <code>org.apache.xalan.xsltc.compiler.Mode</code> class.
+    The <code>Mode</code> class has a method, <code>flatternAlaternative</code>,
+    that does this grouping, and all templates with a common kernel node type
+    will be inserted into a "test sequence". A test sequence is a set templates
+    with the same kernel node type. The <code>TestSeq</code> class generates
+    code that will figure out which pattern, amongst several patterns with the
+    same kernel node type, that matches a certain node. This is used by the
+    <code>Mode</code> class when generating the <code>applyTemplates</code>
+    method in the translet. A test sequence is also generated for all templates
+    whose pattern does not have a kernel node type. This is the case for all
+    Id and KeyPatterns. This test sequence, if necessary, is put before the
+    big <code>switch()</code> in the <code>applyTemplates()</code> mehtod. This
+    test has to be done for every single node that is traversed, causing the
+    transformation to slow down siginificantly. This is why we do <b>not</b>
+    recommend using this type of patterns with XSLTC.</p>
+
+    
+
+  
+
+<p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+</div>
+<div id="footer">Copyright © 1999-2014 The Apache Software Foundation<br />Apache, Xalan, and the Feather logo are trademarks of The Apache Software Foundation<div class="small">Web Page created on - Thu 2014-05-15</div>
+</div>
+</body>
+</html>

Propchange: xalan/java/branches/WebSite/xalan-j/xsltc/xsl_key_design.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xalan/java/branches/WebSite/xalan-j/xsltc/xsl_lang_design.html
URL: http://svn.apache.org/viewvc/xalan/java/branches/WebSite/xalan-j/xsltc/xsl_lang_design.html?rev=1595253&view=auto
==============================================================================
--- xalan/java/branches/WebSite/xalan-j/xsltc/xsl_lang_design.html (added)
+++ xalan/java/branches/WebSite/xalan-j/xsltc/xsl_lang_design.html Fri May 16 16:11:33 2014
@@ -0,0 +1,217 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+<title>ASF: lang() function</title>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+<meta http-equiv="Content-Style-Type" content="text/css" />
+<link rel="stylesheet" type="text/css" href="resources/apache-xalan.css" />
+</head>
+<!--
+ * 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.
+ -->
+<body>
+<div id="title">
+<table class="HdrTitle">
+<tbody>
+<tr>
+<th rowspan="2">
+<a href="../index.html">
+<img alt="Trademark Logo" src="resources/XalanJ-Logo-tm.png" width="190" height="90" />
+</a>
+</th>
+<th text-align="center" width="75%">
+<a href="index.html">XSLTC Design</a>
+</th>
+</tr>
+<tr>
+<td valign="middle">lang() function</td>
+</tr>
+</tbody>
+</table>
+<table class="HdrButtons" align="center" border="1">
+<tbody>
+<tr>
+<td>
+<a href="http://www.apache.org">Apache Foundation</a>
+</td>
+<td>
+<a href="http://xalan.apache.org">Xalan Project</a>
+</td>
+<td>
+<a href="http://xerces.apache.org">Xerces Project</a>
+</td>
+<td>
+<a href="http://www.w3.org/TR">Web Consortium</a>
+</td>
+<td>
+<a href="http://www.oasis-open.org/standards">Oasis Open</a>
+</td>
+</tr>
+</tbody>
+</table>
+</div>
+<div id="navLeft">
+<ul>
+<li>
+<a href="index.html">Overview</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_compiler.html">Compiler design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_whitespace_design.html">Whitespace</a>
+</li>
+<li>
+<a href="xsl_sort_design.html">xsl:sort</a>
+</li>
+<li>
+<a href="xsl_key_design.html">Keys</a>
+</li>
+<li>
+<a href="xsl_comment_design.html">Comment design</a>
+</li></ul><hr /><ul>
+<li>lang()<br />
+</li>
+<li>
+<a href="xsl_unparsed_design.html">Unparsed entities</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_if_design.html">If design</a>
+</li>
+<li>
+<a href="xsl_choose_design.html">Choose|When|Otherwise design</a>
+</li>
+<li>
+<a href="xsl_include_design.html">Include|Import design</a>
+</li>
+<li>
+<a href="xsl_variable_design.html">Variable|Param design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_runtime.html">Runtime</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_dom.html">Internal DOM</a>
+</li>
+<li>
+<a href="xsltc_namespace.html">Namespaces</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_trax.html">Translet &amp; TrAX</a>
+</li>
+<li>
+<a href="xsltc_predicates.html">XPath Predicates</a>
+</li>
+<li>
+<a href="xsltc_iterators.html">Xsltc Iterators</a>
+</li>
+<li>
+<a href="xsltc_native_api.html">Xsltc Native API</a>
+</li>
+<li>
+<a href="xsltc_trax_api.html">Xsltc TrAX API</a>
+</li>
+<li>
+<a href="xsltc_performance.html">Performance Hints</a>
+</li>
+</ul>
+</div>
+<div id="content">
+<h2>lang() function</h2>
+
+  <ul>
+    <li>
+<a href="#functionality">Functionality</a>
+</li>
+    <li>
+<a href="#implementation">Implementation</a>
+</li>    
+  </ul>
+  <a name="functionality">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Functionality</h3>
+
+  <p>The <code>xml:lang</code> can be used to determine the language for a node or
+  a node-set. The attribute can be used to store language-specific data in an
+  XML document:</p>
+
+  <blockquote class="source">
+<pre>
+    &lt;phrases&gt;
+      &lt;greeting xml:lang="en"&gt;Hello!&lt;/greeting&gt;
+      &lt;greeting xml:lang="no"&gt;Hei!&lt;/greeting&gt;
+      &lt;greeting xml:lang="fr"&gt;Salut!&lt;/greeting&gt;
+      &lt;greeting xml:lang="es"&gt;Hola!&lt;/greeting&gt;
+      &lt;greeting xml:lang="de"&gt;Sweinhund!&lt;/greeting&gt;
+    &lt;/phrases&gt;
+  </pre>
+</blockquote>
+
+  <p>The XSL stylesheet can use the <code>lang()</code> function to select the
+  element with the desired language:</p>
+
+  <blockquote class="source">
+<pre>
+    &lt;xsl:template match="greeting"&gt;
+      &lt;xsl:if test="lang("de")&gt;
+        &lt;xsl:value-of select="."/&gt;
+        &lt;xsl:text&gt; Grossglucklicher wunche!&lt;/xsl:text&gt;
+      &lt;/xsl:if&gt;
+    &lt;/xsl:template&gt;
+  </pre>
+</blockquote>
+ <a name="implementation">‌</a>
+<p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Implementation</h3>
+
+  <p>The DOM interface has been given a method that returns the language for
+  a given node. The language is returned as a string (on whatever format is
+  used in the XML document - should be iso), and may be null if no language is
+  defined.</p>
+
+  <blockquote class="source">
+<pre>
+    public String DOM.getLanguage(int node);
+  </pre>
+</blockquote>
+
+  <p>The BasisLibrary class has a static method that will compare the language
+  of the context node with some other language and return the result as a
+  boolean.</p>
+
+  <blockquote class="source">
+<pre>
+    public static boolean BasisLibrary.testLanguage(String language, DOM dom, int node);
+  </pre>
+</blockquote>
+
+  <p>The compiled code for the <code>lang()</code> method calls this method in the
+  BasisLibrary and leaves the result on the stack for the calling element.</p>
+  
+<p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+</div>
+<div id="footer">Copyright © 1999-2014 The Apache Software Foundation<br />Apache, Xalan, and the Feather logo are trademarks of The Apache Software Foundation<div class="small">Web Page created on - Thu 2014-05-15</div>
+</div>
+</body>
+</html>

Propchange: xalan/java/branches/WebSite/xalan-j/xsltc/xsl_lang_design.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xalan/java/branches/WebSite/xalan-j/xsltc/xsl_sort_design.html
URL: http://svn.apache.org/viewvc/xalan/java/branches/WebSite/xalan-j/xsltc/xsl_sort_design.html?rev=1595253&view=auto
==============================================================================
--- xalan/java/branches/WebSite/xalan-j/xsltc/xsl_sort_design.html (added)
+++ xalan/java/branches/WebSite/xalan-j/xsltc/xsl_sort_design.html Fri May 16 16:11:33 2014
@@ -0,0 +1,349 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+<title>ASF: &lt;xsl:sort&gt;</title>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+<meta http-equiv="Content-Style-Type" content="text/css" />
+<link rel="stylesheet" type="text/css" href="resources/apache-xalan.css" />
+</head>
+<!--
+ * 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.
+ -->
+<body>
+<div id="title">
+<table class="HdrTitle">
+<tbody>
+<tr>
+<th rowspan="2">
+<a href="../index.html">
+<img alt="Trademark Logo" src="resources/XalanJ-Logo-tm.png" width="190" height="90" />
+</a>
+</th>
+<th text-align="center" width="75%">
+<a href="index.html">XSLTC Design</a>
+</th>
+</tr>
+<tr>
+<td valign="middle">&lt;xsl:sort&gt;</td>
+</tr>
+</tbody>
+</table>
+<table class="HdrButtons" align="center" border="1">
+<tbody>
+<tr>
+<td>
+<a href="http://www.apache.org">Apache Foundation</a>
+</td>
+<td>
+<a href="http://xalan.apache.org">Xalan Project</a>
+</td>
+<td>
+<a href="http://xerces.apache.org">Xerces Project</a>
+</td>
+<td>
+<a href="http://www.w3.org/TR">Web Consortium</a>
+</td>
+<td>
+<a href="http://www.oasis-open.org/standards">Oasis Open</a>
+</td>
+</tr>
+</tbody>
+</table>
+</div>
+<div id="navLeft">
+<ul>
+<li>
+<a href="index.html">Overview</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_compiler.html">Compiler design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_whitespace_design.html">Whitespace</a>
+</li>
+<li>xsl:sort<br />
+</li>
+<li>
+<a href="xsl_key_design.html">Keys</a>
+</li>
+<li>
+<a href="xsl_comment_design.html">Comment design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_lang_design.html">lang()</a>
+</li>
+<li>
+<a href="xsl_unparsed_design.html">Unparsed entities</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_if_design.html">If design</a>
+</li>
+<li>
+<a href="xsl_choose_design.html">Choose|When|Otherwise design</a>
+</li>
+<li>
+<a href="xsl_include_design.html">Include|Import design</a>
+</li>
+<li>
+<a href="xsl_variable_design.html">Variable|Param design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_runtime.html">Runtime</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_dom.html">Internal DOM</a>
+</li>
+<li>
+<a href="xsltc_namespace.html">Namespaces</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_trax.html">Translet &amp; TrAX</a>
+</li>
+<li>
+<a href="xsltc_predicates.html">XPath Predicates</a>
+</li>
+<li>
+<a href="xsltc_iterators.html">Xsltc Iterators</a>
+</li>
+<li>
+<a href="xsltc_native_api.html">Xsltc Native API</a>
+</li>
+<li>
+<a href="xsltc_trax_api.html">Xsltc TrAX API</a>
+</li>
+<li>
+<a href="xsltc_performance.html">Performance Hints</a>
+</li>
+</ul>
+</div>
+<div id="content">
+<h2>&lt;xsl:sort&gt;</h2>
+
+  <ul>
+    <li>
+<a href="#functionality">Functionality</a>
+</li>
+    <li>
+<a href="#sort-class">The Sort class</a>
+</li>
+    <li>
+<a href="#iterator">The SortingIterator class</a>
+</li>
+    <li>
+<a href="#sortrecord">The NodeSortRecord class</a>
+</li>    
+    <li>
+<a href="#recordfactory">The NodeSortRecordFactory class</a>
+</li>
+  </ul>
+  
+  <a name="functionality">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Functionality</h3>
+
+  <p>The <code>&lt;xsl:sort&gt;</code> element is used to define a sort key
+  which specifies the order in which nodes selected by either
+  <code>&lt;xsl:apply-templates&gt;</code> or <code>&lt;xsl:for-each&gt;</code>
+  are processed. The nodes can be sorted either in numerical or alphabetic
+  order, and the alphabetic order may vary depeinding on the language in use.
+  The nodes can be sorted either in ascending or descending order.</p>
+
+  <a name="sort-class">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>The Sort class</h3>
+
+  <p>Static methods of the Sort class is responsible for generating the
+  necessary code for invoking SortingIterators under
+  <code>&lt;xsl:apply-templates&gt;</code> and <code>&lt;xsl:for-each&gt;</code>
+  elements. Both these elements can have several <code>&lt;xsl:sort&gt;</code>
+  child nodes defining primary, secondary, teriary, etc. keys. The code for
+  <code>&lt;xsl:apply-templates&gt;</code> and <code>&lt;xsl:for-each&gt;</code>
+  create  vectors containg a Sort object for each sort key. The object methods
+  of the Sort object encapsulate a container for key-specific data (such as the
+  sort key itself, sort order, sort type, and such) while the static methods
+  take a vector of Sort objects and generate the actual code.</p>
+
+  <p>The <code>translate()</code> method of the Sort object is never called. The
+  vectors containing the Sort objects for a <code>&lt;xsl:apply-templates&gt;</code>
+  or <code>&lt;xsl:for-each&gt;</code> element are instead passed to the static
+  <code>translateSortIterator()</code> method. This method compiles code that
+  instanciates a SortingIterator object that will pass on a node-set in a
+  specific order to the code handling the <code>&lt;xsl:apply-templates&gt;</code>
+  or <code>&lt;xsl:for-each&gt;</code> element.</p>
+
+  <a name="iterator">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>The SortingIterator class</h3>
+
+  <p>The SortingIterator class is responsible for sorting nodes encapsulated in
+  sort obects. These sort objects must be of a class inheriting from
+  NodeSortRecord, a the SortingIterator object needs a factory object providing
+  it with the correct type of objects:</p>
+
+  <p>
+<img src="sort_objects.gif" alt="sort_objects.gif" />
+</p>
+  <p>
+<b>
+<i>Figure 1: SortingIterator</i>
+</b>
+</p>
+
+  <p>The SortingIterator class is fairly dumb and leaves much of the work to the
+  NodeSortRecord class. The iterator gets the NodeSortRecords from the factory
+  object and sorts them using quicksort and calling <code>compareTo()</code> on
+  pairs of NodeSortRecord objects.</p>
+
+  <a name="sortrecord">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>The NodeSortRecord class</h3>
+
+  <p>The static methods in the Sort class generates a class inheriting from
+  NodeSortRecord, with the following overloaded methods:</p>
+
+  <ul>
+    <li>
+<b>Class Constructor</b>
+</li>
+      <ul>
+<li>The class constructor is overloaded to create sort-key global
+      tables, such as an array containing the sort order for all the sort keys
+      and another array containg all the sort types. Different sort order/types
+      can be specified for the different levels of sort keys, but we assume that
+      the same language is used for all levels.</li>
+</ul>
+      
+    <li>
+<code>extractValueFromDOM(int level)</code>
+</li>
+      <ul>
+<li>This method is called by the SortingIterator object to extract the
+      value for a specific sort key for a node. The SortingIterator will only
+      use this method once and will cache the returned value for later use. The
+      method will only be called if absultely necessary.</li>
+</ul>
+
+    <li>
+<code>compareType(int level)</code>
+</li>
+      <ul>
+<li>This method returns the sort type for one sort key level. Returns
+      either <code>COMPARE_STRING</code> or <code>COMPARE_NUMERIC</code>.</li>
+</ul>
+    
+    <li>
+<code>sortOrder(int level)</code>
+</li>
+      <ul>
+<li>This method returns the sort order for one sort key level. Returns
+      either <code>COMPARE_ASCENDING</code> or <code>COMPARE_DESCENDING</code>
+</li>
+</ul>
+    
+    <li>
+<code>getCollator(int level)</code>
+</li>
+      <ul>
+<li>This method returns a Collator object for language-specific
+      string comparisons. The same Collator is used for all levels of the key.
+      </li>
+</ul> 
+  </ul>
+
+  <p>The <code>compareTo()</code> method of the NodeSortRecord base class deserves
+  a bit of attention. It takes its own node (from the this pointer) and another
+  node and compares, if necessary, the values for all sort keys:</p>
+
+  <blockquote class="source">
+<pre>
+    /**
+     * Compare this sort element to another. The first level is checked first,
+     * and we proceed to the next level only if the first level keys are
+     * identical (and so the key values may not even be extracted from the DOM)
+     */
+    public int compareTo(NodeSortRecord other) {
+	int cmp;
+    
+	for (int level=0; level&lt;_levels; level++) {
+	    
+	    // Compare the two nodes either as numeric or text values
+	    if (compareType(level) == COMPARE_NUMERIC) {
+		final Double our = numericValue(level);
+		final Double their = other.numericValue(level);
+		if (our == null) return(-1);
+		if (their == null) return(1);
+		cmp = our.compareTo(their);
+	    }
+	    else {
+		String our = stringValue(level);
+		String their = other.stringValue(level);
+		if (our == null) return(-1);
+		if (their == null) return(1);
+		cmp = getCollator().compare(our,their);
+	    }
+	    
+	    // Return inverse compare value if inverse sort order
+	    if (cmp != 0) {
+		if (sortOrder(level) == COMPARE_DESCENDING)
+		    return(0 - cmp);
+		else
+		    return(cmp);
+	    }
+	    
+	}
+	return(0);
+    }
+  </pre>
+</blockquote>
+
+  <p>The two methods <code>stringValue(int level)</code> and 
+  <code>numericValue(int level)</code> return values for one level of the sort key
+  of a node. These methods cache these values after they are first read so that
+  the <code>DOM.getNodeValue()</code> is only called once. Also, the algorithm
+  used for these two methods assure that <code>DOM.getNodeValue()</code> is only
+  called when needed. The value for a node's secondary sort key is never
+  retrieved if the node can be uniquely identified by its primary key.</p>
+
+  <a name="recordfactory">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>The NodeSortRecordFactory class</h3>
+
+  <p>After the static methods of the Sort class has generated the new class for
+  sort objects it generates code that instanciates a new NodeSortRecordFactory
+  object. This object is passed as a parameter to SortingIterators constructor
+  and is used by the iterator to generate the necessary sort objects.</p>
+
+  
+<p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+</div>
+<div id="footer">Copyright © 1999-2014 The Apache Software Foundation<br />Apache, Xalan, and the Feather logo are trademarks of The Apache Software Foundation<div class="small">Web Page created on - Thu 2014-05-15</div>
+</div>
+</body>
+</html>

Propchange: xalan/java/branches/WebSite/xalan-j/xsltc/xsl_sort_design.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xalan/java/branches/WebSite/xalan-j/xsltc/xsl_unparsed_design.html
URL: http://svn.apache.org/viewvc/xalan/java/branches/WebSite/xalan-j/xsltc/xsl_unparsed_design.html?rev=1595253&view=auto
==============================================================================
--- xalan/java/branches/WebSite/xalan-j/xsltc/xsl_unparsed_design.html (added)
+++ xalan/java/branches/WebSite/xalan-j/xsltc/xsl_unparsed_design.html Fri May 16 16:11:33 2014
@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+<title>ASF: unparsed-entity-uri()</title>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+<meta http-equiv="Content-Style-Type" content="text/css" />
+<link rel="stylesheet" type="text/css" href="resources/apache-xalan.css" />
+</head>
+<!--
+ * 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.
+ -->
+<body>
+<div id="title">
+<table class="HdrTitle">
+<tbody>
+<tr>
+<th rowspan="2">
+<a href="../index.html">
+<img alt="Trademark Logo" src="resources/XalanJ-Logo-tm.png" width="190" height="90" />
+</a>
+</th>
+<th text-align="center" width="75%">
+<a href="index.html">XSLTC Design</a>
+</th>
+</tr>
+<tr>
+<td valign="middle">unparsed-entity-uri()</td>
+</tr>
+</tbody>
+</table>
+<table class="HdrButtons" align="center" border="1">
+<tbody>
+<tr>
+<td>
+<a href="http://www.apache.org">Apache Foundation</a>
+</td>
+<td>
+<a href="http://xalan.apache.org">Xalan Project</a>
+</td>
+<td>
+<a href="http://xerces.apache.org">Xerces Project</a>
+</td>
+<td>
+<a href="http://www.w3.org/TR">Web Consortium</a>
+</td>
+<td>
+<a href="http://www.oasis-open.org/standards">Oasis Open</a>
+</td>
+</tr>
+</tbody>
+</table>
+</div>
+<div id="navLeft">
+<ul>
+<li>
+<a href="index.html">Overview</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_compiler.html">Compiler design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_whitespace_design.html">Whitespace</a>
+</li>
+<li>
+<a href="xsl_sort_design.html">xsl:sort</a>
+</li>
+<li>
+<a href="xsl_key_design.html">Keys</a>
+</li>
+<li>
+<a href="xsl_comment_design.html">Comment design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_lang_design.html">lang()</a>
+</li>
+<li>Unparsed entities<br />
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_if_design.html">If design</a>
+</li>
+<li>
+<a href="xsl_choose_design.html">Choose|When|Otherwise design</a>
+</li>
+<li>
+<a href="xsl_include_design.html">Include|Import design</a>
+</li>
+<li>
+<a href="xsl_variable_design.html">Variable|Param design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_runtime.html">Runtime</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_dom.html">Internal DOM</a>
+</li>
+<li>
+<a href="xsltc_namespace.html">Namespaces</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_trax.html">Translet &amp; TrAX</a>
+</li>
+<li>
+<a href="xsltc_predicates.html">XPath Predicates</a>
+</li>
+<li>
+<a href="xsltc_iterators.html">Xsltc Iterators</a>
+</li>
+<li>
+<a href="xsltc_native_api.html">Xsltc Native API</a>
+</li>
+<li>
+<a href="xsltc_trax_api.html">Xsltc TrAX API</a>
+</li>
+<li>
+<a href="xsltc_performance.html">Performance Hints</a>
+</li>
+</ul>
+</div>
+<div id="content">
+<h2>unparsed-entity-uri()</h2>
+
+  <ul>
+    <li>
+<a href="#functionality">Functionality</a>
+</li>
+    <li>
+<a href="#implementation">Implementation</a>
+</li>
+  </ul>
+  
+  <a name="functionality">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Functionality</h3>
+
+
+  <p>The <code>unparsed-entity-uri()</code> function gives access to declarations
+  of unparsed entities in the DTD of the source document. If the DTD contains
+  the declaration:</p>
+
+  <blockquote class="source">
+<pre>
+    &lt;!ENTITY mom-picture SYSTEM "http://www.home.com/mom.jpg" NDATA JPEG&gt;
+  </pre>
+</blockquote>
+
+  <p>the expression <code>unparsed-entity-uri('mom-picture')</code> returns an
+  URI for the file <code>mom.jpg</code>.</p>
+
+  <a name="implementation">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Implementation</h3>
+
+  <p>Unparsed entities must be gathered from the XML input document at the time
+  when the DOM is built. To achieve this our parser must parse the document DTD
+  (if any) and store all data of type NDATA (not XML data) in a
+  hashtable in the AbstractTranslet object. All the compiled code for this
+  function needs to do is call a method in the translet for retrieving the
+  value for the requested element:</p>
+
+  <blockquote class="source">
+<pre>
+    public String AbstractTranslet.getUnparsedEntity(String entityName);
+  </pre>
+</blockquote>
+
+  <p>The translet will use the supplied <code>entityName</code> to look up the
+  value in the hashtable and then leave the string value on the stack for the
+  element that called <code>lang()</code>.</p>
+  
+<p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+</div>
+<div id="footer">Copyright © 1999-2014 The Apache Software Foundation<br />Apache, Xalan, and the Feather logo are trademarks of The Apache Software Foundation<div class="small">Web Page created on - Thu 2014-05-15</div>
+</div>
+</body>
+</html>

Propchange: xalan/java/branches/WebSite/xalan-j/xsltc/xsl_unparsed_design.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xalan/java/branches/WebSite/xalan-j/xsltc/xsl_variable_design.html
URL: http://svn.apache.org/viewvc/xalan/java/branches/WebSite/xalan-j/xsltc/xsl_variable_design.html?rev=1595253&view=auto
==============================================================================
--- xalan/java/branches/WebSite/xalan-j/xsltc/xsl_variable_design.html (added)
+++ xalan/java/branches/WebSite/xalan-j/xsltc/xsl_variable_design.html Fri May 16 16:11:33 2014
@@ -0,0 +1,364 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+<title>ASF: &lt;xsl:variable&gt; / &lt;xsl:param&gt;</title>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+<meta http-equiv="Content-Style-Type" content="text/css" />
+<link rel="stylesheet" type="text/css" href="resources/apache-xalan.css" />
+</head>
+<!--
+ * 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.
+ -->
+<body>
+<div id="title">
+<table class="HdrTitle">
+<tbody>
+<tr>
+<th rowspan="2">
+<a href="../index.html">
+<img alt="Trademark Logo" src="resources/XalanJ-Logo-tm.png" width="190" height="90" />
+</a>
+</th>
+<th text-align="center" width="75%">
+<a href="index.html">XSLTC Design</a>
+</th>
+</tr>
+<tr>
+<td valign="middle">&lt;xsl:variable&gt; / &lt;xsl:param&gt;</td>
+</tr>
+</tbody>
+</table>
+<table class="HdrButtons" align="center" border="1">
+<tbody>
+<tr>
+<td>
+<a href="http://www.apache.org">Apache Foundation</a>
+</td>
+<td>
+<a href="http://xalan.apache.org">Xalan Project</a>
+</td>
+<td>
+<a href="http://xerces.apache.org">Xerces Project</a>
+</td>
+<td>
+<a href="http://www.w3.org/TR">Web Consortium</a>
+</td>
+<td>
+<a href="http://www.oasis-open.org/standards">Oasis Open</a>
+</td>
+</tr>
+</tbody>
+</table>
+</div>
+<div id="navLeft">
+<ul>
+<li>
+<a href="index.html">Overview</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_compiler.html">Compiler design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_whitespace_design.html">Whitespace</a>
+</li>
+<li>
+<a href="xsl_sort_design.html">xsl:sort</a>
+</li>
+<li>
+<a href="xsl_key_design.html">Keys</a>
+</li>
+<li>
+<a href="xsl_comment_design.html">Comment design</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_lang_design.html">lang()</a>
+</li>
+<li>
+<a href="xsl_unparsed_design.html">Unparsed entities</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsl_if_design.html">If design</a>
+</li>
+<li>
+<a href="xsl_choose_design.html">Choose|When|Otherwise design</a>
+</li>
+<li>
+<a href="xsl_include_design.html">Include|Import design</a>
+</li>
+<li>Variable|Param design<br />
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_runtime.html">Runtime</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_dom.html">Internal DOM</a>
+</li>
+<li>
+<a href="xsltc_namespace.html">Namespaces</a>
+</li></ul><hr /><ul>
+<li>
+<a href="xsltc_trax.html">Translet &amp; TrAX</a>
+</li>
+<li>
+<a href="xsltc_predicates.html">XPath Predicates</a>
+</li>
+<li>
+<a href="xsltc_iterators.html">Xsltc Iterators</a>
+</li>
+<li>
+<a href="xsltc_native_api.html">Xsltc Native API</a>
+</li>
+<li>
+<a href="xsltc_trax_api.html">Xsltc TrAX API</a>
+</li>
+<li>
+<a href="xsltc_performance.html">Performance Hints</a>
+</li>
+</ul>
+</div>
+<div id="content">
+<h2>&lt;xsl:variable&gt; / &lt;xsl:param&gt;</h2>
+
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Contents</h3>
+  <ul>
+    <li>
+<a href="#functionality">Functionality</a>
+</li>
+    <li>
+<a href="#implementation">Implementation</a>
+</li>    
+  </ul>
+  
+
+  <a name="functionality">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Functionality</h3>
+
+  <p>Variables in XSLT are not really variables, as their values cannot be
+  changed. They resemble constants from conventional programming languages. The
+  only way in which a variable can be changed is by declaring it inside a
+  for-each loop, in which case its value will be updated for every iteration.
+  Top-level variables (variables that are direct child nodes of the
+  <code>&lt;xsl:stylesheet&gt;</code> element) can never be changed.</p>
+
+  <blockquote class="source">
+<pre>
+    &lt;xsl:for-each select="/foo/bar"&gt;
+      &lt;xsl:variable name="some-bar" select="."/&gt;
+      &lt;xsl:value-of select="$some-bar"/&gt;
+    &lt;/xsl:for-each&gt;</pre>
+</blockquote>
+
+  <p>Parameters are assigned a value either from the process that invoked
+  the stylesheet (top-level parameter), or from a
+  <code>&lt;xsl:with-param&gt;</code> or from a default value (in which case it
+  behaves as if it was a variable).</p>
+
+  <blockquote class="source">
+<pre>
+    &lt;xsl:template match="/"&gt;
+      &lt;xsl:call-template name="blob"&gt;
+        &lt;xsl:with-param name="par" select="'some-value'"/&gt;
+      &lt;/xsl:call-template&gt;
+    &lt;/xsl:template&gt;
+
+    &lt;xsl:template name="blob"&gt;
+      &lt;xsl:param name="par" select="'default-value'"/&gt;
+      &lt;xsl:value-of select="$param"/&gt;
+    &lt;/xsl:template&gt;</pre>
+</blockquote>
+
+  
+
+  <a name="implementation">‌</a>
+  <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h3>Implementation</h3>
+
+    <p>Variables and parameters share a common base class
+    <code>VariableBase</code> that contains a lot of common methods. This class
+    handles both global and local variables/parameters.</p>
+
+    <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h4>Top-level parameters and variables</h4>
+
+    <p>All top-level (ie. global) parameters and variables are stored inside
+    fields in the translet class. Variables are stored as objects or basic
+    data types (such as boolean, char, int, etc.) while parameters have to be
+    "boxed" inside an object. This is because parameters are also stored as
+    objects inside the translet. The <code>addParameter()</code> method of the
+    <code>AbstractTranslet</code> class stores the parameter in a Hashtable
+    (the Hashtable maps the parameter name to the parameter value). The
+    "boxing" of the parameter's value is done by the class that handles the
+    parameters type. This class is a subclass of
+    <code>org.apache.xalan.xsltc.compiler.util.Type</code>.</p>
+
+    <p>Note that all top-level parameters and variables from all imported and
+    included stylesheets will be placed as direct children of the top-level
+    stylesheet in the AST. This done to make global variables truly global and
+    not just global in the stylesheet where it was declared.</p>
+
+    
+
+    <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h4>Local parameters and variables</h4>
+
+    <p>Local variables that are accessible from a given syntax tree node will
+    first be put on the JVM's stack and stored in a local variable slot. This
+    makes the variable or parameter accessible from all code within that
+    method. But, in some special cases, the code that is compiled to handle an
+    element/expression within the variable scope is not put inside the same
+    method as the actual variable. This is the case for some predicates.
+    All syntax-tree nodes implement the <code>isClosureBoundary()</code> method
+    to indicate if its child an ancestor nodes will end up in a different method
+    then itself. This method is used by the <code>Variable</code> and
+    <code>Param</code> classes to determine if the variable or parameter will
+    "escape" the variable frame.</p>
+
+    <blockquote class="source">
+<pre>
+    &lt;xsl:for-each select="/foo/bar/baz"&gt;
+        &lt;xsl:variable name="pos" select="3"/&gt;
+        &lt;xsl:apply-templates select="/foo/bar[$pos]"/&gt;
+    &lt;/xsl:for-each&gt;</pre>
+</blockquote>
+
+    <p>The predicate in this stylesheet fragment is compiled into a separate
+    auxiliary class that implements the <code>Filter</code> interface. It will
+    therefore not have access to the variable "pos" in the current stack frame.
+    A common technique for cases like this is to use a <b>"closure"</b>. A
+    closure is a record that contains references to all variables that are in
+    scope for a certain part of the compiled scope. This is done in a very
+    simple manner in XSLTC. All variables or parameters that can "escape" the
+    stack are passed to the translet via its <code>addVariable()</code> method.
+    They can then later be retrieved by the <code>getVariable()</code> method.
+    </p>
+
+    <p>
+<b>Important note 1:</b> A predicate does not always result in a
+    auxiliary class. In some cases we optimize the code by using tailored
+    iterators and goodies like that instead. We may want to update the
+    predicate code to check if an auxiliary class will be generated before
+    returning true or false from the <code>isClosureBoundary()</code>
+    method.</p>
+
+    <p>
+<b>Important note 2:</b> There could be other closure boundaries
+    that we have not yet discovered or considered. This could be, for instance,
+    sort records and other auxiliary classes:</p>
+
+    <blockquote class="source">
+<pre>
+    &lt;xsl:variable name="sort-order" select="'decending'"/&gt;
+    &lt;xsl:for-each select="/foo/bar/baz"&gt;
+        &lt;xsl:sort select="@name" order="$sort-order"/&gt;
+        &lt;xsl:value-of select="."/&gt;
+    &lt;/xsl:for-each&gt;</pre>
+</blockquote>
+
+    <p>I would not be surprised if this fails. A fix could be to implement the
+    <code>isClosureBoundary()</code> in the <code>Sort</code> class and have the
+    method return 'true' in all cases.</p>
+
+    
+
+    <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h4>Parameter and variable references</h4>
+
+    <p>A parameter or variable reference does the oposite of a parameter or
+    variable. The value is read from either a global field, a local variable
+    slot or from a call to <code>getVariable()</code> /
+    <code>getParameter()</code>. The chosen method depends is we're dealing with
+    a parameter or a variable, a global or a local, an escaping variable or not.
+    </p>
+
+    <p>The XPath parser identifies all variable references and instanciates
+    either a <code>VariableRef</code> or a <code>ParameterRef</code>. The XPath
+    parser calls the parser's <code>lookupVariable</code> method in an initial
+    attempt to find the variable/parameter instance. If that fails, it goes on
+    to call the symbol table's <code>lookupName()</code> method. If that also
+    fails this means that either:</p>
+
+    <ul>
+      <li>a variable or parameter with the given name does not exist</li>
+      <li>the variable will be declared at a later stage
+      (but within the same scope)</li>
+    </ul>
+
+    <p>The XPath parser creates an instance of the <code>UnresolvedRef</code>
+    class. This class attempts to locate the variable after the whole AST has
+    been built, when the <code>typeCheck()</code> method is called. If this
+    fails an error is reported and the compilation stops. Otherwise the class
+    creates a <code>VariableRef</code> or a <code>ParameterRef</code> instance
+    and lets that handle the reference.</p>
+
+    
+
+    <p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+<h4>Forward references</h4>
+
+    <p>XSLTC allows for forward references to global variables and parameters.
+    You can even reference variables in not-yet included/imported stylesheets.
+    In most cases, this is handled by changing the order of top-level elements.
+    (Variables are placed first so that they are handled before any includes
+    or imports).  But when a variable contains references to other variables,
+    then this requires some extra code in the <code>Stylesheet</code> and
+    <code>VariableBase</code> classes. The <code>VariableBase</code> has a
+    method that returns a vector containing all variables that are referenced
+    in the variable definition.</p>
+
+    <blockquote class="source">
+<pre>
+    &lt;xsl:variable name="C" select="$A &lt; $B"/&gt;
+    &lt;xsl:variable name="A" select="1"/&gt;
+    &lt;xsl:variable name="B" select="2"/&gt;</pre>
+</blockquote>
+
+    <p>In this case, the <code>getDependencies()</code> method for variable
+    C will return the variables A and B. The stylesheet has a method called
+    <code>resolveReferences</code> that will order the variables accordingly
+    so that the variable values are computed in the desired order. This method
+    will issue an error message and terminate the compilation if there are
+    circular variable/parameter dependencies.</p>
+
+    
+
+  
+
+<p align="right" size="2">
+<a href="#content">(top)</a>
+</p>
+</div>
+<div id="footer">Copyright © 1999-2014 The Apache Software Foundation<br />Apache, Xalan, and the Feather logo are trademarks of The Apache Software Foundation<div class="small">Web Page created on - Thu 2014-05-15</div>
+</div>
+</body>
+</html>

Propchange: xalan/java/branches/WebSite/xalan-j/xsltc/xsl_variable_design.html
------------------------------------------------------------------------------
    svn:eol-style = native



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