You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by zo...@apache.org on 2006/09/15 04:35:19 UTC

svn commit: r446474 - /xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java

Author: zongaro
Date: Thu Sep 14 19:35:18 2006
New Revision: 446474

URL: http://svn.apache.org/viewvc?view=rev&rev=446474
Log:
Part of patch for XALANJ-1774

Added getNodeIDForStylesheetNSLookup method which is used to get the unique
stylesheet node ID for this node or the nearest enclosing element node in the
syntax tree that has namespace declarations.  If there is no such node, the
value -1 is returned.

Reviewed by Christine Li (jycli () ca ! ibm ! com)

Modified:
    xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java

Modified: xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java
URL: http://svn.apache.org/viewvc/xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java?view=diff&rev=446474&r1=446473&r2=446474
==============================================================================
--- xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java (original)
+++ xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java Thu Sep 14 19:35:18 2006
@@ -75,6 +75,12 @@
     protected AttributeList _attributes = null;   // Attributes of this element
     private   Hashtable _prefixMapping = null; // Namespace declarations
 
+    public static final int UNKNOWN_STYLESHEET_NODE_ID = -1;
+
+    // Records whether this node or any descendant needs to know the
+    // in-scope namespaces at transform-time
+    private int _nodeIDForStylesheetNSLookup = UNKNOWN_STYLESHEET_NODE_ID;
+
     // Sentinel - used to denote unrecognised syntaxt tree nodes.
     static final SyntaxTreeNode Dummy = new AbsolutePathPattern(null);
 
@@ -740,6 +746,35 @@
 	il.append(methodGen.storeHandler());
     }
 
+    /**
+     * Retrieve an ID to identify the namespaces in scope at this point in the
+     * stylesheet
+     * @return An <code>int</code> representing the node ID or <code>-1</code>
+     *         if no namespace declarations are in scope
+     */
+    protected final int getNodeIDForStylesheetNSLookup() {
+        if (_nodeIDForStylesheetNSLookup == UNKNOWN_STYLESHEET_NODE_ID) {
+            Hashtable prefixMapping = getPrefixMapping();
+            int parentNodeID =
+                    (_parent != null) ? _parent.getNodeIDForStylesheetNSLookup()
+                                      : UNKNOWN_STYLESHEET_NODE_ID; 
+
+            // If this node in the stylesheet has no namespace declarations of
+            // its own, use the ID of the nearest ancestor element that does 
+            // have namespace declarations.
+            if (prefixMapping == null) {
+                _nodeIDForStylesheetNSLookup = parentNodeID;
+            } else {
+                // Inform the XSLTC object that we'll need to know about this
+                // node's namespace declarations.
+                _nodeIDForStylesheetNSLookup =
+                    getXSLTC().registerStylesheetPrefixMappingForRuntime(
+                                       prefixMapping, parentNodeID);
+            }
+        }
+
+        return _nodeIDForStylesheetNSLookup;
+    }
     /**
      * Returns true if this expression/instruction depends on the context. By 
      * default, every expression/instruction depends on the context unless it 



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