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

PJ Fanning commented on XMLBEANS-658:
-------------------------------------

https://github.com/apache/xmlbeans/commit/f9364f526a6b6832f40cf821f7136e2526100ade
 reproduces the issue.

The XMLBeans project is not very active and it could take a while to fix this 
and then do a release.

You could workaround this by using the `save` method to write the XML to a 
StringWriter and then to compare the underlying String to the value for another 
instance. Not ideal but should work.

> 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