[ 
http://issues.apache.org/jira/browse/XERCESJ-1068?page=comments#action_63340 ]
     
Anil Saldhana commented on XERCESJ-1068:
----------------------------------------

Hi Mike,
   here is my code that bombs and the workaround:

public XSTypeDefinition getXSTypeDefinition(SchemaGrammar sg, String classname, 
String typeNS)
   {
      XSTypeDefinition xstype = null;
      if (sg == null)
         throw new IllegalArgumentException("Schema Grammar is null");

      XSModel xsmodel = sg.toXSModel();

      if (xsmodel != null)
      {
         short typedef = XSTypeDefinition.COMPLEX_TYPE;
         XSNamedMap xsnamedmap = xsmodel.getComponentsByNamespace(typedef, 
typeNS);
         if (xsnamedmap != null)
         {
            int len = xsnamedmap.getLength();
            for (int i = 0; i < len; i++)
            {
               XSTypeDefinition xst = (XSTypeDefinition)xsnamedmap.item(0);
               if (classname.equals(xst.getName()) && 
typeNS.equals(xst.getNamespace()))
                  return xst;
            }

         }
         //There is a bug in Xerces code
         /*int len = xsnamedmap.getLength();
         for (int i = 0; i < len; i++)
         {
            xstype = (XSTypeDefinition)xsnamedmap.itemByName(typeNS, classname);
         }*/
      }
      return xstype;
   }


Notice that I have to loop thru the items in the namedmap  to get the item.


The context,  I am satisfied with Xerces Schema infrastructure to give me an 
object graph given schema file(s).  But my requirement also includes creating 
schema files from Java interfaces.  Hence I have to use your Xerces schema 
implementation to create a XSModel and then write it into a file.

> XSNamedMap4Types.java: Doing Object comparison when Strings are compared
> ------------------------------------------------------------------------
>
>          Key: XERCESJ-1068
>          URL: http://issues.apache.org/jira/browse/XERCESJ-1068
>      Project: Xerces2-J
>         Type: Bug
>   Components: XML Schema datatypes
>     Versions: 2.6.2
>     Reporter: Anil Saldhana

>
> public XSObject itemByName(String namespace, String localName) {
>         if (namespace != null)
>             namespace = namespace.intern();
>         for (int i = 0; i < fNSNum; i++) {
>             if (namespace == fNamespaces[i]) {
>                 XSTypeDefinition type = 
> (XSTypeDefinition)fMaps[i].get(localName);
>                 // only return it if it mataches the required type
>                 if (type.getTypeCategory() == fType)
>                     return type;
>                 return null;
>             }
>         }
>         return null;
>     }
> You are doing object comparison, when you should be doing the following:
> if(namespace.equals(fNamespaces[i]))

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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

Reply via email to