< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java

Print this page
rev 1019 : 8168664: [JAXP] XALAN: xsl:element generates namespace prefixes if namespace is given as URI only

@@ -191,14 +191,13 @@
     }
 
     /**
      * At runtime the compilation of xsl:element results in code that: (i)
      * evaluates the avt for the name, (ii) checks for a prefix in the name
-     * (iii) generates a new prefix and create a new qname when necessary
-     * (iv) calls startElement() on the handler (v) looks up a uri in the XML
-     * when the prefix is not known at compile time (vi) calls namespace()
-     * on the handler (vii) evaluates the contents (viii) calls endElement().
+     * (iii) calls startElement() on the handler (iv) looks up a uri in the XML
+     * when the prefix is not known at compile time (v) calls namespace()
+     * on the handler (vi) evaluates the contents (vii) calls endElement().
      */
     public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
         final ConstantPoolGen cpg = classGen.getConstantPool();
         final InstructionList il = methodGen.getInstructionList();
 

@@ -207,56 +206,47 @@
             translateLiteral(classGen, methodGen);
             return;
         }
 
         if (!_ignore) {
+            // store the name into a variable so _name.translate only needs
+            // to be called once
+            LocalVariableGen nameValue = methodGen.addLocalVariable2
+                ("nameValue", Util.getJCRefType(STRING_SIG), null);
 
-            // if the qname is an AVT, then the qname has to be checked at runtime if it is a valid qname
-            LocalVariableGen nameValue =
-                    methodGen.addLocalVariable2("nameValue",
-                                                Util.getJCRefType(STRING_SIG),
-                                                null);
-
-            // store the name into a variable first so _name.translate only needs to be called once
             _name.translate(classGen, methodGen);
+
             nameValue.setStart(il.append(new ASTORE(nameValue.getIndex())));
             il.append(new ALOAD(nameValue.getIndex()));
 
-            // call checkQName if the name is an AVT
-            final int check = cpg.addMethodref(BASIS_LIBRARY_CLASS, "checkQName",
-                            "("
-                            +STRING_SIG
-                            +")V");
-            il.append(new INVOKESTATIC(check));
+            // if the qname is an AVT, then the qname has to be checked at
+            // runtime if it is a valid qname
+            il.append(new INVOKESTATIC(cpg.addMethodref
+                (BASIS_LIBRARY_CLASS, "checkQName", "(" + STRING_SIG + ")V")));
 
-            // Push handler for call to endElement()
+            // push handler for call to endElement()
             il.append(methodGen.loadHandler());
 
             // load name value again
             nameValue.setEnd(il.append(new ALOAD(nameValue.getIndex())));
 
             if (_namespace != null) {
                 _namespace.translate(classGen, methodGen);
-            }
-            else {
+            } else {
                 il.append(ACONST_NULL);
             }
 
-            // Push additional arguments
+            // push additional arguments
             il.append(methodGen.loadHandler());
             il.append(methodGen.loadDOM());
             il.append(methodGen.loadCurrentNode());
 
-            // Invoke BasisLibrary.startXslElemCheckQName()
-            il.append(new INVOKESTATIC(
-            cpg.addMethodref(BASIS_LIBRARY_CLASS, "startXslElement",
-                    "(" + STRING_SIG
-                    + STRING_SIG
-                    + TRANSLET_OUTPUT_SIG
-                    + DOM_INTF_SIG + "I)" + STRING_SIG)));
-
-
+            // invoke BasisLibrary.startXslElement()
+            il.append(new INVOKESTATIC(cpg.addMethodref
+                (BASIS_LIBRARY_CLASS, "startXslElement", "(" + STRING_SIG +
+                 STRING_SIG + TRANSLET_OUTPUT_SIG + DOM_INTF_SIG + "I)" +
+                 STRING_SIG)));
         }
 
         translateContents(classGen, methodGen);
 
         if (!_ignore) {
< prev index next >