I did EXACTLY the same thing when I started using Xerces (and feel bad for it, but I digress).

It is much faster to do an == comparison, so Xerces does. In order to make this work you must call 'internalize()' on a string:

========
String strOne = "Hello World";
ArrayList list = someObject.getArrayList();
// Pretend that this list was created in
//another function or class and contains "Hello World" as the first value


if(strOne == (String)list.get(0)){ // this code will NOT be hit. (cannot be assured that it will anyway). } // Internalize the strings strOne.internalize(); ((String)list.get(0)).internalize(); if(strOne == (String)list.get(0)){ // this code WILL ALWAYS be hit. }


=======
So, short answer, it is a feature. If someone else could point out any errors in my code I'd appreciate it. The general idea is correct, I do not know the finer points, and I think there is a function in the Xerces libraries which is used instead of just internalizing everything. Don't remember, its been a while.


cheers,
--
Geoff Granum
[EMAIL PROTECTED]
Aeronautical & Astronautical Engineering,
Purdue University
West Lafayette, Indiana

On Tue, 25 Nov 2003 16:19:52 +0100, Gerd Mueller <[EMAIL PROTECTED]> wrote:


Hi,


Line 88 ff, version 1.14 (Xerces 2.6.0) of the source code of
org.apache.xerces.impl.xs.SubstitutionGroupHandler states
the following:

        if (element.localpart == exemplar.fName &&
            element.uri == exemplar.fTargetNamespace) {
            return exemplar;
        }

i.e. strings are not compared with 'equals'. Was this done by
a certain intention, e.g. for performance reasons, or is it
a bug ?

I'm using org.apache.xerces.impl.xs.models package in my application
and the code above causes me trouble.

Best Regards,
gerd

________________________________________________________________
Gerd Mueller                                    [EMAIL PROTECTED]
SMB GmbH                                  http://www.smb-tec.com

---------------------------------------------------------------------
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