<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Message</TITLE>
<META content="MSHTML 6.00.2800.1126" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=421193014-14082003><FONT face=Arial color=#0000ff size=2>I was
thinking more along the lines of an extendable approach, an abstract class
Equivalance which could be extended to provide various implementations,
such as literal equivalance, normalized text equivalance, etc.
It seems like equivalance definitions would often differ in only a few
details on specific leaf types in the tree (such as ignoring
namespaces, normalizing text, etc.). If that's true, then this could
provide a framework in which people only have to implement a minimal amount,
inheriting the rest.</FONT></SPAN></DIV>
<DIV><SPAN class=421193014-14082003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=421193014-14082003><FONT face=Arial color=#0000ff size=2>The
top level class just has to provide one big instanceof conditional and define
the methods for each type, and the rest can be implemented in the
concrete classes. Or, for the introspection-sensitive, a method could be
implemented in each type (Element, Document, EntityRef, etc.), specifying the
Equivalance to use:</FONT></SPAN></DIV>
<DIV><SPAN class=421193014-14082003><FONT face=Arial color=#0000ff size=2>
boolean equivalentTo(Object obj, Equivalance equiv);</FONT></SPAN></DIV>
<DIV><SPAN class=421193014-14082003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=421193014-14082003><FONT face=Arial color=#0000ff
size=2>Optionally, throw in a Filter, for maximum
flexibility:</FONT></SPAN></DIV>
<DIV><SPAN class=421193014-14082003><FONT face=Arial color=#0000ff size=2>
<DIV><SPAN class=421193014-14082003><FONT face=Arial color=#0000ff size=2>
boolean equivalentTo(Object obj, Equivalance equiv, Filter
filter);</FONT></SPAN></DIV>
<DIV><SPAN class=421193014-14082003></SPAN> </DIV>
<DIV><SPAN class=421193014-14082003>Then you could define filters for any
circumstance: check only the elements...</SPAN></DIV> </FONT></SPAN></DIV>
<DIV><SPAN class=421193014-14082003><FONT face=Arial color=#0000ff size=2>Is
this a work-saver, or just make-work? Would anybody use this? Or
just me? </FONT></SPAN></DIV>
<DIV><SPAN class=421193014-14082003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=421193014-14082003><FONT face=Arial color=#0000ff
size=2>(Actually, I can probably keep doing a string compare of the
outputter text, myself. But if everybody's doing that, shouldn't there be
a method in Element or Document to do it so we're not duplicating that code all
over the world? I'm smiling because it's pretty funny if we think its not
respectable enough to go into the API, but we all do it in our
products.)</FONT></SPAN></DIV>
<DIV><SPAN class=421193014-14082003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=421193014-14082003><FONT face=Arial color=#0000ff
size=2>Neil</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> Rolf Lear
[mailto:rlear@algorithmics.com] <BR><B>Sent:</B> Thursday, August 14, 2003
10:03 AM<BR><B>To:</B> 'Neil'; jdom-interest@jdom.org<BR><B>Subject:</B> RE:
[jdom-interest] XML equivalence<BR><BR></FONT></DIV>
<P><FONT size=2>More than anything, I think you will discover that every
person will have a different opinion as to when two elements are
"equals"...</FONT></P>
<P><FONT size=2>Are they equals with the same namespace/name, with "equals"
elements in the content, etc...</FONT> </P>
<P><FONT size=2>Basically, there are too many ways in which elements can be
considered equals (depends on how you want it to behave for your application).
Putting any one application's specific "equals" code in to the JDom source
would probably be counter-productive.</FONT></P>
<P><FONT size=2>Rolf</FONT> </P>
<P><FONT size=2>-----Original Message-----</FONT> <BR><FONT size=2>From: Neil
[<A href="mailto:neil@ipdevco.com">mailto:neil@ipdevco.com</A>]</FONT>
<BR><FONT size=2>Sent: Thursday, August 14, 2003 9:56 AM</FONT> <BR><FONT
size=2>To: jdom-interest@jdom.org</FONT> <BR><FONT size=2>Subject:
[jdom-interest] XML equivalence</FONT> </P><BR>
<P><FONT size=2>When I first read the following in the FAQ, I was a little
surprised,</FONT> <BR><FONT size=2>although it makes perfect sense.</FONT>
</P>
<P><FONT size=2>>Why does equals() only do a == check?</FONT> <BR><FONT
size=2>></FONT> <BR><FONT size=2>>In JDOM two objects are only equal if
they're the exact same object. This</FONT> <BR><FONT size=2>lets a call
like</FONT> <BR><FONT size=2>>list.remove(elem) remove only the exact
Element passed in, not any element</FONT> <BR><FONT size=2>that's equivalent.
</FONT><BR><FONT size=2>>This's a very important distinction. Doing a full
equals() on an Element</FONT> <BR><FONT size=2>would require recursing
</FONT><BR><FONT size=2>>down the tree, and in general we believe it
unlikely you'll want to know if</FONT> <BR><FONT size=2>this element and all
</FONT><BR><FONT size=2>>its children are equivalent to another one. If you
really do want to know</FONT> <BR><FONT size=2>you can write some
</FONT><BR><FONT size=2>>comparison code yourself that checks only as much
as you want to check</FONT> <BR><FONT size=2>(maybe the </FONT><BR><FONT
size=2>>name/namespaces only) instead of doing a full recurse.</FONT>
<BR><FONT size=2> </FONT><BR><FONT size=2>However, since I've been using
JDOM, I've now twice wanted to be able to do</FONT> <BR><FONT size=2>true
equivalence checking. I must not be the only one.</FONT> </P>
<P><FONT size=2>Have any contributors worked on this or are working on
this? Maybe it's</FONT> <BR><FONT size=2>time for me to do some
contributing, but I'm not sure my XML sophistication</FONT> <BR><FONT
size=2>is great enough. I'm pretty much just a surface level user of
XML, though</FONT> <BR><FONT size=2>I'm experienced with java frameworks and
design.</FONT> </P>
<P><FONT size=2>Any comments?</FONT> </P><BR>
<P><FONT size=2>Neil Brandt</FONT> </P><BR><BR><BR><BR><BR><BR>
<P><FONT size=2>_______________________________________________</FONT>
<BR><FONT size=2>To control your jdom-interest membership:</FONT> <BR><FONT
size=2><A
href="http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com"
target=_blank>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com</A></FONT>
</P></BLOCKQUOTE></BODY></HTML>