Radu,

Based on your response to the earlier messages to this list I thought
that it would be possible to build into XmlBeans a schema aware
comparison capability.

My comparison algorithm is of course fairly specific to my own
implementation. However, I think that following capabilities are fairly
generic to a schema aware comparison:
- ignore comments
- ignore attribute ordering
- understand default attribute values - if attribute 'attr1' has a
default value of 1 then the following elements should be considered to
be the same.
   <elm attr1="1"/>
   <elm />
- ordering of child elements is not important. The following elements
should be considered the same:
   <elm>
      <a>1</a>
      <b>2</b>
   </elm>

   <elm>
      <b>2</b>
      <a>1</a>
   </elm>

For my own implementation I need to be able to ignore certain
attributes. In some cases if 2 elements are exactly the same except for
one specific attribute I might not care. Basically to the compare, but
ignore certain differences.

I can implement the comparison capability I need using XmlBeans in my
own code. Since I suspect a lot of what I need to do would be useful to
others it would be nice to understand if it is possible to build this
sort of schema aware comparison into XmlBeans.

Regards,

Jon

============================================
Jonathan O. Baker
http://oval.mitre.org
The MITRE Corporation
Email: [EMAIL PROTECTED]
 

>-----Original Message-----
>From: Radu Preotiuc-Pietro [mailto:[EMAIL PROTECTED] 
>Sent: Wednesday, June 13, 2007 4:54 PM
>To: [email protected]
>Subject: RE: XmlBeans for schema aware comparisons
>
>No progress has been made since then.
>
>But with XMLBeans, say you have objects obj1 and obj2, you have access
>to the Schema type for each XmlObject, (SchemaType obj.schemaType()).
>SchemaType contains all the information about that type from 
>the Schema.
>XmlCursor on the other hand (XmlCuror obj.newCursor()) contains all
the
>information from the instance document, so with these you 
>should be able
>to implement any comparison algorithm.
>
>Just out of curiosity, could you give a brief overview of what 
>algorithm
>you have in mind (like, are comments relevant, is the order of
>attributes relevant etc)?
>
>Radu
>
>> -----Original Message-----
>> From: Baker, Jon [mailto:[EMAIL PROTECTED] 
>> Sent: Wednesday, June 13, 2007 9:46 AM
>> To: [email protected]
>> Subject: XmlBeans for schema aware comparisons
>> 
>> In august of 2006 a question was asked about using XmlBeans 
>> for a schema aware comparison of two XmlObjects. Has any 
>> progress been made on this capability since then? How hard is 
>> it to implement in XmlBeans?
>> In your response to the question you mentioned that XmlBeans 
>> has the foundation for this code already implemented. Where 
>> can I find out more information so that I can decide if I 
>> want to try to add this capability to XmlBeans?
>> 
>> Thanks,
>> 
>> Jon
>> 
>> ============================================
>> Jonathan O. Baker
>> The MITRE Corporation
>> Email: [EMAIL PROTECTED]
>> 
>> 
>>  
>> 
>> >-----Original Message-----
>> >From: Radu Preotiuc-Pietro [mailto:[EMAIL PROTECTED]
>> >Sent: Wednesday, August 30, 2006 1:10 PM
>> >To: [email protected]
>> >Subject: RE: How to use XmlObject.valueEquals
>> >
>> >The JavaDoc for .valueEquals() is fairly detailed but forgets to 
>> >mention one thing: that .valueEquals() is only implemented 
>> for simple 
>> >type values.
>> >
>> >Actually, Schema-aware comparison is something that a lot of people

>> >find valuable and XmlBeans has all the foundation work done 
>> to support 
>> >something like that, unfortunately we weren't able to find an 
>> >interested person that could contribute the code to do it.
>> >
>> >This is my way of saying basically that this would be a 
>> great project 
>> >for someone who is looking to get involved in XmlBeans and 
>in Apache 
>> >and open-source in general.
>> >
>> >Radu
>> >
>> >-----Original Message-----
>> >From: Bailey, Brian P [mailto:[EMAIL PROTECTED]
>> >Sent: Thursday, August 17, 2006 3:35 PM
>> >To: [email protected]
>> >Subject: How to use XmlObject.valueEquals
>> >
>> >Hi, I'm using xmlbeans 2.1.0 and have a question about comparing 
>> >XmlObjects for equivalency. I have the following schema:
>> >
>> ><schema xmlns="http://www.w3.org/2001/XMLSchema";
>> >xmlns:tns="http://myself.com/data";
>> >targetNamespace="http://myself.com/data";>
>> >  <complexType name="location2DType">
>> >    <sequence>
>> >      <element name="latitude" type="double"/>
>> >      <element name="longitude" type="double"/>
>> >    </sequence>
>> >  </complexType>
>> >  <element name="Location2D" type="tns:location2DType"/> </schema>
>> >
>> >
>> >I would like to compare two documents based on this schema 
>> and see if 
>> >they are equivalent (ignoring element prefixes, attribute ordering,

>> >etc.). I thought I might use XmlObject.valueEquals(), but 
>> that doesn't 
>> >seem to work. For example, when running the following code, I see
>> >"valueEquals: true" even though the latitude value is different:
>> >
>> >      Location2DDocument doc1 =
>> >Location2DDocument.Factory.newInstance();
>> >      doc1.addNewLocation2D();
>> >      doc1.getLocation2D().setLatitude(34.2);
>> >      doc1.getLocation2D().setLongitude(84.8);
>> >      
>> >      Location2DDocument doc2 =
>> >Location2DDocument.Factory.newInstance();
>> >      doc2.addNewLocation2D();
>> >      doc2.getLocation2D().setLatitude(95.2);
>> >      doc2.getLocation2D().setLongitude(84.8);
>> >      
>> >      System.out.println("valueEquals: " + doc1.valueEquals(doc2));
>> >
>> >What should I use to compare two xml beans for equivalency?
>> >
>> 
>>---------------------------------------------------------------------
>> >To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >For additional commands, e-mail: [EMAIL PROTECTED]
>> >
>> >_____________________________________________________________
>> _________
>> _
>> >Notice:  This email message, together with any attachments, may
>> contain
>> >information  of  BEA Systems,  Inc.,  its subsidiaries  and
>> affiliated
>> >entities,  that may be confidential,  proprietary,  copyrighted
>> and/or
>> >legally privileged, and is intended solely for the use of the 
>> >individual or entity named in this message. If you are not 
>> the intended
>> recipient,
>> >and have received this message in error, please immediately return
>> this
>> >by email and then delete it.
>> >
>> 
>>---------------------------------------------------------------------
>> >To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >For additional commands, e-mail: [EMAIL PROTECTED]
>> >
>> >
>> 
>>
---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> 
>> 
>
>Notice:  This email message, together with any attachments, 
>may contain information  of  BEA Systems,  Inc.,  its 
>subsidiaries  and  affiliated entities,  that may be 
>confidential,  proprietary,  copyrighted  and/or legally 
>privileged, and is intended solely for the use of the 
>individual or entity named in this message. If you are not the 
>intended recipient, and have received this message in error, 
>please immediately return this by email and then delete it.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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

Reply via email to