[ 
https://issues.apache.org/jira/browse/XMLBEANS-658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18010661#comment-18010661
 ] 

PJ Fanning edited comment on XMLBEANS-658 at 7/29/25 12:49 PM:
---------------------------------------------------------------

The issue is that equal_to is not implemented in XmlComplexContentImpl. 
valueEquals eventually delegates to this method.

https://github.com/apache/xmlbeans/blob/f9364f526a6b6832f40cf821f7136e2526100ade/src/main/java/org/apache/xmlbeans/impl/values/XmlComplexContentImpl.java#L71-L77

equal_to basically checks that the types are equal but ignores the values.

The XMLBeans code is over 20 years old and was basically abandoned. The Apache 
POI project made the very unfortunate decision to use the lib even when it was 
well past its prime in terms of community engagement. POI is stuck with it but 
it is hard to fix anything in XMLBeans because it invariably breaks something 
else.


was (Author: fanningpj):
The issue is that equal_to is not implemented in XmlComplexContentImpl. 
valueEquals eventually delegates to this method.

https://github.com/apache/xmlbeans/blob/f9364f526a6b6832f40cf821f7136e2526100ade/src/main/java/org/apache/xmlbeans/impl/values/XmlComplexContentImpl.java#L71-L77

The XMLBeans code is over 20 years old and was basically abandoned. The Apache 
POI project made the very unfortunate decision to use the lib even when it was 
well past its prime in terms of community engagement. POI is stuck with it but 
it is hard to fix anything in XMLBeans because it invariably breaks something 
else.

> valueEquals always returns true
> -------------------------------
>
>                 Key: XMLBEANS-658
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-658
>             Project: XMLBeans
>          Issue Type: Bug
>    Affects Versions: Version 5.0.0, Version 5.3.0
>            Reporter: Mingun
>            Priority: Major
>
> I found, that {{valueEquals}} will return {{true}} for two obviously 
> different XML values.
> Take the following schema:
> {code:XML}
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
> xmlns:this="ValueEqualsIssue" elementFormDefault="qualified" 
> attributeFormDefault="unqualified" targetNamespace="ValueEqualsIssue">
>   <xs:complexType name="Type">
>     <xs:sequence>
>       <xs:element name="Element" type="xs:string" minOccurs="0"/>
>     </xs:sequence>
>   </xs:complexType>
>   <xs:element name="Type" type="this:Type"/>
> </xs:schema>
> {code}
> The following code...
> {code:Java}
> final TypeDocument doc1 = TypeDocument.Factory.newInstance();
> doc1.addNewType().setElement("child");
> final TypeDocument doc2 = TypeDocument.Factory.newInstance();
> doc2.addNewType();
> final TypeDocument doc3 = TypeDocument.Factory.newInstance();
> doc3.addNewType().setElement("another");
> System.out.println(doc1);
> System.out.println(doc2);
> System.out.println(doc3);
> System.out.println();
> System.out.println("doc1 valueEquals doc2 = "+doc1.valueEquals(doc2)); // true
> System.out.println("doc2 valueEquals doc1 = "+doc2.valueEquals(doc1)); // true
> System.out.println();
> System.out.println("doc1 valueEquals doc3 = "+doc1.valueEquals(doc3)); // true
> System.out.println("doc3 valueEquals doc1 = "+doc3.valueEquals(doc1)); // true
> {code}
> ...output
> {noformat}
> <Type xmlns="ValueEqualsIssue">
>   <Element>child</Element>
> </Type>
> <Type xmlns="ValueEqualsIssue"/>
> <Type xmlns="ValueEqualsIssue">
>   <Element>another</Element>
> </Type>
> doc1 valueEquals doc2 = true
> doc2 valueEquals doc1 = true
> doc1 valueEquals doc3 = true
> doc3 valueEquals doc1 = true
> {noformat}
> Obviously, those two XMLs are not equal.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to