You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by Edward Frederick <ep...@gmail.com> on 2006/01/22 02:10:39 UTC

Bug in Extensions Validation

Hello,

As you may recall from my previous messages, I'm using the new
extensions to add a method to a hierarchy of types.

I think I've discovered a bug in the validation for method
collisions--I'm able to get my desired functionality, but only after
commenting out a chunk of validation code in
org.apache.xmlbeans.impl.config.BindingConfigImpl:

/*
                if (methodSignatures.containsKey(methods[j]))
                {

                    InterfaceExtensionImpl.MethodSignatureImpl ms2 =
(InterfaceExtensionImpl.MethodSignatureImpl)
methodSignatures.get(methods[j]);
                    BindingConfigImpl.error("Colliding methods '" +
ms.getSignature() + "' in interfaces " +
                        ms.getInterfaceName() + " and " +
ms2.getInterfaceName() + ".", null);

                    return;
                }
*/


An error is falsely detected when one type extends another and they
both implement the same extension interface but with a different
static handler.

Example:

XSD:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:element name="base-instance" type="base-type"/>
<xsd:element name="child-instance" type="child-type"/>

<xsd:complexType name="base-type">
  <xsd:sequence>
    <xsd:element name="baseString" type="xsd:string"/>
  </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="child-type">
 <xsd:complexContent>
  <xsd:extension base="base-type">
    <xsd:sequence>
      <xsd:element name="childString" type="xsd:string"/>
    </xsd:sequence>
  </xsd:extension>
 </xsd:complexContent>
</xsd:complexType>

</xsd:schema>


XSDCONFIG:

<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config">

    <xb:extension for="noNamespace.BaseType">
        <xb:interface name="ExtIf">
            <xb:staticHandler>Handler</xb:staticHandler>
        </xb:interface>
    </xb:extension>
    <xb:extension for="noNamespace.ChildType">
        <xb:interface name="ExtIf">
            <xb:staticHandler>Handler2</xb:staticHandler>
        </xb:interface>
    </xb:extension>
</xb:config>

ExtIf.java:

public interface ExtIf {

        public void delegate();
}


Handler.java:

import org.apache.xmlbeans.XmlObject;

public class Handler {
     public static void delegate(XmlObject xo){}
}


Handler2.java:

import org.apache.xmlbeans.XmlObject;

public class Handler2 {
     public static void delegate(XmlObject xo){}
}



When I compile the above scheme with the trunk, I get a collision
error. If I comment out the validation, I get the expected (and
desired) result:

noNamespace/impl/BaseTypeImpl.java:

...
    public void delegate()
    {
        Handler.delegate(this);
    }
..


noNamespace/impl/ChildTypeImpl.java:

...
    public void delegate()
    {
        Handler2.delegate(this);
    }
..


I think this behavior is important so that you can get nice
polymorphism at the XmlObject level even when using static handlers.

I'd like to submit a patch to fix the validation, but I don't think I
am sophisticated enough (with respect to XMLBeans) to pull it off
right now.

Any ideas?

Thanks,

Ed

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org