tmiller 02/03/15 08:10:21 Modified: java/src/org/apache/xalan/xsltc/compiler LiteralElement.java Log: bug 6819, variables translated before attrs to fix problems with dependency, fix by Santiago Pericas-Geertsen Revision Changes Path 1.15 +16 -4 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.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- LiteralElement.java 1 Feb 2002 20:07:08 -0000 1.14 +++ LiteralElement.java 15 Mar 2002 16:10:21 -0000 1.15 @@ -1,5 +1,5 @@ /* - * @(#)$Id: LiteralElement.java,v 1.14 2002/02/01 20:07:08 tmiller Exp $ + * @(#)$Id: LiteralElement.java,v 1.15 2002/03/15 16:10:21 tmiller Exp $ * * The Apache Software License, Version 1.1 * @@ -77,10 +77,11 @@ import org.apache.xalan.xsltc.compiler.util.*; final class LiteralElement extends Instruction { + private String _name; - private Hashtable _accessedPrefixes = null; private LiteralElement _parent; private Vector _attributeElements = null; + private Hashtable _accessedPrefixes = null; private final static String XMLNS_STRING = "xmlns"; @@ -344,7 +345,9 @@ /** * Compiles code that emits the literal element to the output handler, * first the start tag, then namespace declaration, then attributes, - * then the element contents, and then the element end tag. + * then the element contents, and then the element end tag. Since the + * value of an attribute may depend on a variable, variables must be + * compiled first. */ public void translate(ClassGenerator classGen, MethodGenerator methodGen) { @@ -354,8 +357,17 @@ // Compile code to emit element start tag il.append(methodGen.loadHandler()); il.append(new PUSH(cpg, _name)); - il.append(DUP2); // duplicate these 2 args for endElement + il.append(DUP2); // duplicate these 2 args for endElement il.append(methodGen.startElement()); + + // The value of an attribute may depend on a (sibling) variable + for (int i = 0; i < elementCount(); i++) { + final SyntaxTreeNode item = (SyntaxTreeNode) elementAt(i); + if (item instanceof Variable) { + item.translate(classGen, methodGen); + removeElement(item); // avoid translating it twice + } + } // Compile code to emit namespace attributes if (_accessedPrefixes != null) {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]