[jdom-interest] XML equivalence
Jason Hunter
jhunter at servlets.com
Thu Aug 14 12:49:29 PDT 2003
Well, XQuery has a deep-equal() function that compares nodes. For
elements it compares their name, namespace, attributes, text, and
child elements recursively. Comments and processing instructions are
ignored.
-jh-
Rolf Lear wrote:
> More than anything, I think you will discover that every person will
> have a different opinion as to when two elements are "equals"...
>
> Are they equals with the same namespace/name, with "equals" elements in
> the content, etc...
>
> 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.
>
> Rolf
>
> -----Original Message-----
> From: Neil [mailto:neil at ipdevco.com]
> Sent: Thursday, August 14, 2003 9:56 AM
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] XML equivalence
>
>
> When I first read the following in the FAQ, I was a little surprised,
> although it makes perfect sense.
>
> >Why does equals() only do a == check?
> >
> >In JDOM two objects are only equal if they're the exact same object. This
> lets a call like
> >list.remove(elem) remove only the exact Element passed in, not any
> element
> that's equivalent.
> >This's a very important distinction. Doing a full equals() on an Element
> would require recursing
> >down the tree, and in general we believe it unlikely you'll want to
> know if
> this element and all
> >its children are equivalent to another one. If you really do want to know
> you can write some
> >comparison code yourself that checks only as much as you want to check
> (maybe the
> >name/namespaces only) instead of doing a full recurse.
>
> However, since I've been using JDOM, I've now twice wanted to be able to do
> true equivalence checking. I must not be the only one.
>
> Have any contributors worked on this or are working on this? Maybe it's
> time for me to do some contributing, but I'm not sure my XML sophistication
> is great enough. I'm pretty much just a surface level user of XML, though
> I'm experienced with java frameworks and design.
>
> Any comments?
>
>
> Neil Brandt
>
>
>
>
>
>
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
>
>
More information about the jdom-interest
mailing list