[ 
https://issues.apache.org/jira/browse/XMLBEANS-346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12540314
 ] 

jeffb0 edited comment on XMLBEANS-346 at 11/5/07 4:35 PM:
-----------------------------------------------------------------

I believe I am encountering the same or a similar issue with XMLBeans 2.3. 

I am using several different schemas in my project (all without namespaces, and 
there is nothing I can do about that).  They are each compiled into a separate 
jar, each using a separate package, using the xmlbeans ant task.  I can only 
seem to successfully parse xml (using the <My Schema's Root Element 
Document>.Factory.parse(String xml) method) for the schema jar that is first in 
the classpath, otherwise I get a ClassCastException as described in this bug.

I've done some debugging, and I'm coming to the conclusion that the structure 
of the schemaorg_apache_xmlbeans.namespace package is probably responsible.  
Since my schemas do not have namespaces, each of jars I've built share some 
files that are identically named in identical packages.  Specifically, I've 
seen that each jar has a schemaorg_apache_xmlbeans.namespace._nons.xmlns.xsb 
file that seems to point to the actual schema for that jar.  If the factory 
uses this file to determine some of the classes it will use to parse the xml it 
has, this may explain the ClassCastException, as it's only looking at the first 
file on the classpath and not the correct one for the XML it has.

I think I would be beneficial to have a schema compiler feature to specify the 
location where these files are generated, like the Java package options, since 
sometimes the developer can't control if namespaces are used in his schemas or 
not.

      was (Author: jeffb0):
    I believe I am encountering the same or a similar issue with XMLBeans 2.3. 

I am using several different schemas in my project (all without namespaces, and 
there is nothing I can do about that).  They are each compiled into a separate 
jar, each using a separate package, using the xmlbeans ant task.  I can only 
seem to successfully parse xml (using the Factory.parse(String xml) method) for 
the schema jar that is first in the classpath, otherwise I get a 
ClassCastException as described in this bug.

I've done some debugging, and I'm coming to the conclusion that the structure 
of the schemaorg_apache_xmlbeans.namespace package is probably responsible.  
Since my schemas do not have namespaces, each of jars I've built share some 
files that are identically named in identical packages.  Specifically, I've 
seen that each jar has a schemaorg_apache_xmlbeans.namespace._nons.xmlns.xsb 
file that seems to point to the actual schema for that jar.  If the factory 
uses this file to determine some of the classes it will use to parse the xml it 
has, this may explain the ClassCastException, as it's only looking at the first 
file on the classpath and not the correct one for the XML.

I think I would be beneficial to have a schema compiler feature to specify the 
location where these files are generated, like the Java package options, since 
sometimes the developer can't control if namespaces are used in his schemas or 
not.
  
> Getting ClassCastException if the same root element exist in different XSD
> --------------------------------------------------------------------------
>
>                 Key: XMLBEANS-346
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-346
>             Project: XMLBeans
>          Issue Type: Bug
>          Components: XmlObject
>    Affects Versions: Version 2.2
>         Environment: Windows xp operating system , jdk 1.4, WebLogic Server. 
>            Reporter: rajasekhar juluri
>
> HI All!
>    
>    I created the below XSD with two different packages.
>    1)   Package structure as follows      
>             -> test.xmlbeans.one 
>             -> test.xmlbeans.two
>      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
> elementFormDefault="qualified">
>       <xs:element name="cXML">
>               <xs:complexType>
>                       <xs:sequence>
>                               <xs:element ref="HEADER"/>
>                       
>                       </xs:sequence>
>                       
>               </xs:complexType>
>       </xs:element>
>       
>       <xs:element name="HEADER">
>              <xs:complexType>
>                       <xs:sequence>   
>                               <xs:element ref="From"/>
>                               <xs:element ref="To"/>
>                               <xs:element ref="Sender"/>
>                       </xs:sequence>
>               </xs:complexType>
>       </xs:element>
>      </xs:schema> 
>   
>    2)   jar file generated successfully. While executing the below program i 
> found ClassCastException.  
>        
>     java.lang.ClassCastException: test.xmlbeans.one.CXMLDocumentImpl
>                at 
> test.xmlbeans.two.CXMLDocument$Factory.parse(CXMLDocument.java)              
>  
>        
>        This is the sample program 
>             
>            class TextXMlBeans{
>                 public static void main(String arg[]) trhows Exception{
>                 test.xmlbeans.two.CXMLDocument cxml = 
> test.xmlbeans.two.CXMLDocument.Factory.parse(new File(fileName), opt);
>              
>                }
>              }
>  
> Thanks,
> Rajasekhar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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

Reply via email to