You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Gerd Mueller <Ge...@smb-tec.com> on 2003/11/25 16:19:52 UTC

Bug or Feature ?

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                                    gerd@smb-tec.com     
SMB GmbH                                  http://www.smb-tec.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: Bug or Feature ?

Posted by Kohsuke Kawaguchi <Ko...@Sun.COM>.
> 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 ? 

Like Geoff wrote, this is done intentionally. Check the SymbolTable
class and see how it's used.

regards,
--
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi@sun.com


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: Bug or Feature ?

Posted by Kohsuke Kawaguchi <Ko...@Sun.COM>.
> 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.

Since you asked for it,

> strOne.internalize();

it should be: "strOne=strOne.intern();"


regards,
--
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi@sun.com


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: Bug or Feature ?

Posted by Geoff Granum <gr...@purdue.edu>.
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
granum@purdue.edu
Aeronautical & Astronautical Engineering,
Purdue University
West Lafayette, Indiana

On Tue, 25 Nov 2003 16:19:52 +0100, Gerd Mueller 
<Ge...@smb-tec.com> 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                                    gerd@smb-tec.com
> SMB GmbH                                  http://www.smb-tec.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org