santiagopg    2002/07/09 08:33:56

  Modified:    java/src/org/apache/xalan/xsltc/compiler AttributeSet.java
  Log:
  Fix for Bugzilla 4603 (thanks to Henri Zongaro)
  
  Revision  Changes    Path
  1.12      +21 -30    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AttributeSet.java
  
  Index: AttributeSet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AttributeSet.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- AttributeSet.java 10 May 2002 15:40:02 -0000      1.11
  +++ AttributeSet.java 9 Jul 2002 15:33:56 -0000       1.12
  @@ -84,6 +84,7 @@
       // Element contents
       private QName            _name;
       private UseAttributeSets _useSets;
  +    private AttributeSet     _mergeSet;
       private String           _method;
       private boolean          _ignore = false;
       
  @@ -161,15 +162,10 @@
   
        if (_ignore) return (Type.Void);
   
  -     final AttributeSet other = stable.addAttributeSet(this);
  -     if (other != null) {
  -         _method = other.getMethodName();
  -         merge(other);
  -         other.ignore();
  -     }
  -     else {
  -         _method = AttributeSetPrefix + getXSLTC().nextAttributeSetSerial();
  -     }
  +        // _mergeSet Point to any previous definition of this attribute set
  +     _mergeSet = stable.addAttributeSet(this);
  +
  +     _method = AttributeSetPrefix + getXSLTC().nextAttributeSetSerial();
   
        if (_useSets != null) _useSets.typeCheck(stable);
        typeCheckContents(stable);
  @@ -177,26 +173,6 @@
       }
   
       /**
  -     * Merge this attribute set with some other one
  -     */
  -    private void merge(AttributeSet other) {
  -     // Both attribute sets may inherit from other sets...
  -     if (_useSets == null)
  -         _useSets = other._useSets;
  -     else
  -         _useSets.addAttributeSets(other.getAttribute("use-attribute-sets"));
  -
  -     // Merge the contents of the two attribute sets...
  -     final Enumeration attributes = other.elements();
  -     while (attributes.hasMoreElements()) {
  -         SyntaxTreeNode element = (SyntaxTreeNode)attributes.nextElement();
  -         if (element instanceof XslAttribute) {
  -             setFirstElement((XslAttribute)element);
  -         }
  -     }
  -    }
  -
  -    /**
        * Compile a method that outputs the attributes in this set
        */
       public void translate(ClassGenerator classGen, MethodGenerator 
methodGen) {
  @@ -205,6 +181,21 @@
   
        // Create a new method generator for an attribute set method
        methodGen = new AttributeSetMethodGenerator(_method, classGen);
  +
  +        // Generate a reference to previous attribute-set definitions with 
the
  +        // same name first.  Those later in the stylesheet take precedence.
  +        if (_mergeSet != null) {
  +            final ConstantPoolGen cpg = classGen.getConstantPool();
  +            final InstructionList il = methodGen.getInstructionList();
  +            final String methodName = _mergeSet.getMethodName();
  +
  +            il.append(classGen.loadTranslet());
  +            il.append(methodGen.loadHandler());
  +            il.append(methodGen.loadIterator());
  +            final int method = cpg.addMethodref(classGen.getClassName(),
  +                                                methodName, ATTR_SET_SIG);
  +            il.append(new INVOKESPECIAL(method));
  +        }
   
        // Translate other used attribute sets first, as local attributes
        // take precedence (last attributes overrides first)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to