Done. WS-COMMONS-120.

On 11/2/06, Davanum Srinivas <[EMAIL PROTECTED]> wrote:

John,

JIRA please, the text gets mangled, so can't apply it.

thanks,
dims

On 11/2/06, John Kaputin (gmail) <[EMAIL PROTECTED]> wrote:
> Can one of the regular XmlSchema developers please review this issue and
the
> patch below and confirm if it's appropriate for me to open a JIRA for
this
> and apply the patch.
>
> The XmlSchema class inherits the equals(Object) method from
XmlSchemaObject.
> This method uses line number, line position and sourceURI for equality
> checking, however line number and position are always zero (they are not
> used yet?). This can cause a false positive when checking equality of
two
> different schemas that share the same source URI.
>
> For example, the WSDL 2.0 testcase at [1] has two inlined schemas.  For
> XmlSchema1.equals(XmlSchema2), both XmlSchema objects will have line
number
> zero, line position zero and the WSDL URI as their sourceURI and
> XmlSchemaObject.equals will return true, even though in this case the
two
> inlined schemas have different target namespaces and xs:include
different
> schema documents.
>
> [1]
>
http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Chameleon-4G/getBalance.wsdl
>
> I think a solution is to create an equals method on XmlSchema which
inherits
> super.equals (i.e. from XmlSchemaObject) and adds further equality
checking
> specific to XmlSchema. I have tried the patch below and this fixes my
> testcase, although it may require more equality checking to be more
> generally useful.
>
> Index:
>
C:/workspace/woden/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
> ===================================================================
> ---
>
C:/workspace/woden/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
> (revision 469501)
> +++
>
C:/workspace/woden/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
> (working copy)
> @@ -244,4 +244,56 @@
>      public void setNamespaceContext(NamespacePrefixList
namespaceContext) {
>          this.namespaceContext = namespaceContext;
>      }
> +
> +    /**
> +     * Override the equals(Object) method with equivalence checking
> +     * that is specific to this class.
> +     */
> +    public boolean equals(Object what) {
> +
> +        //Note: this method may no longer be required when line
> number/position are used correctly in XmlSchemaObject.
> +        //Currently they are simply initialized to zero, but they are
used
> in XmlSchemaObject.equals
> +        //which can result in a false positive (e.g. if a WSDL contains
2
> inlined schemas).
> +
> +        if (what == this) {
> +            return true;
> +        }
> +
> +        //If the inherited behaviour determines that the objects are
NOT
> equal, return false.
> +        //Otherwise, do some further equivalence checking.
> +
> +        if(!super.equals(what)) {
> +            return false;
> +        }
> +
> +        if (!(what instanceof XmlSchema)) {
> +            return false;
> +        }
> +
> +        XmlSchema xs = (XmlSchema) what;
> +
> +        if (this.id != null) {
> +            if (!this.id.equals(xs.id)) {
> +                return false;
> +            }
> +        } else {
> +            if (xs.id != null) {
> +                return false;
> +            }
> +        }
> +
> +        if (this.syntacticalTargetNamespace != null) {
> +            if (!this.syntacticalTargetNamespace.equals(
> xs.syntacticalTargetNamespace)) {
> +                return false;
> +            }
> +        } else {
> +            if (xs.syntacticalTargetNamespace != null) {
> +                return false;
> +            }
> +        }
> +
> +        //TODO decide if further schema content should be checked for
> equivalence.
> +
> +        return true;
> +    }
>  }
>
>
> regards,
> John Kaputin (Woden)
>
>


--
Davanum Srinivas : http://www.wso2.net (Oxygen for Web Service Developers)

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


Reply via email to