[prev in list] [next in list] [prev in thread] [next in thread]
List: xalan-cvs
Subject: cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/compiler LiteralElement.java
From: santiagopg () apache ! org
Date: 2004-06-10 22:26:03
Message-ID: 20040610222603.72771.qmail () minotaur ! apache ! org
[Download RAW message or body]
santiagopg 2004/06/10 15:26:03
Modified: java/src/org/apache/xalan/xsltc/compiler LiteralElement.java
Log:
Patch for Bugzilla 29411. New algorithm shoudl optimize the way NS decls are \
reported for nested literal elements. Note that the algorithm will not work accross \
non-literal elements. E.g., if there is an xsl:element between two literal elements, \
the inner literal element may report unnecessary NS delcs. This is just a simple way \
to ensure that any NS decls defined by the xsl:element instruction are re-defined in \
the inner literal (see namespace39 in the conf tests).
Revision Changes Path
1.27 +17 -19 \
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LiteralElement.java
Index: LiteralElement.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LiteralElement.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- LiteralElement.java 21 May 2004 20:29:28 -0000 1.26
+++ LiteralElement.java 10 Jun 2004 22:26:03 -0000 1.27
@@ -44,7 +44,7 @@
final class LiteralElement extends Instruction {
private String _name;
- private LiteralElement _literalElemParent;
+ private LiteralElement _literalElemParent = null;
private Vector _attributeElements = null;
private Hashtable _accessedPrefixes = null;
@@ -75,10 +75,14 @@
* Returns the namespace URI for which a prefix is pointing to
*/
private String accessedNamespace(String prefix) {
- if (_accessedPrefixes == null)
- return(null);
- else
- return((String)_accessedPrefixes.get(prefix));
+ if (_literalElemParent != null) {
+ String result = _literalElemParent.accessedNamespace(prefix);
+ if (result != null) {
+ return result;
+ }
+ }
+ return _accessedPrefixes != null ?
+ (String) _accessedPrefixes.get(prefix) : null;
}
/**
@@ -92,11 +96,9 @@
// Check if the parent has a declaration for this namespace
if (_literalElemParent != null) {
final String parentUri = _literalElemParent.accessedNamespace(prefix);
- if (parentUri == null) {
- _literalElemParent.registerNamespace(prefix, uri, stable, declared);
- return;
- }
- if (parentUri.equals(uri)) return;
+ if (parentUri != null && parentUri.equals(uri)) {
+ return;
+ }
}
// Check if we have any declared namesaces
@@ -228,14 +230,10 @@
final SymbolTable stable = parser.getSymbolTable();
stable.setCurrentNode(this);
- // Find the closest literal element ancestor (if there is one)
- SyntaxTreeNode _literalElemParent = getParent();
- while (_literalElemParent != null && !(_literalElemParent instanceof \
LiteralElement)) {
- _literalElemParent = _literalElemParent.getParent();
- }
-
- if (!(_literalElemParent instanceof LiteralElement)) {
- _literalElemParent = null;
+ // Check if in a literal element context
+ SyntaxTreeNode parent = getParent();
+ if (parent != null && parent instanceof LiteralElement) {
+ _literalElemParent = (LiteralElement) parent;
}
_name = translateQName(_qname, stable);
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic