Btw forgot the mention the top level tag for the schemas

<!-- The xsds in the previous email come here -->
</xs:schema>




________________________________
From: Soumya <soumya_...@yahoo.co.in>
To: user@xmlbeans.apache.org
Sent: Thu, 29 April, 2010 5:04:42 PM
Subject: Re: XmlBean object confusion


Dear Peter,
thanks for your prompt reply.
My apologies for not furnishing all details in the first instance
So here is the error trail -
org.apache.xmlbeans.XmlException: XML object is not of type D=xml_element
 at org.apache.xmlbeans.impl.store.Root.autoTypedDocument(Root.java:445)
 at org.apache.xmlbeans.impl.store.Root.loadXml(Root.java:1049)
 at org.apache.xmlbeans.impl.store.Root.loadXml(Root.java:1039)
 at org.apache.xmlbeans.impl.store.Root.loadXml(Root.java:1059)
 at 
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:214)
 at com.company.type.one.XmlElementDocument$Factory.parse(Unknown Source)



So as you see it was using the correct package but still says it cannot 
recognise it.
As for target namespace we didnt use any. i.e. used default.
type1.xsd - 
package used is com.company.type.one

<xs:element name="xml_element">
                  <xs:complexType>
                     <xs:sequence maxOccurs="1">
                      <xs:choice>
                        <xs:element name="request">
                            <xs:complexType>
                             <xs:sequence maxOccurs="1">
                                  <xs:choice>
                                <xs:element name="customer" type="customerT"/>
                                <xs:element nam ............
                                    ................................... />
                                  </xs:choice>
                             </xs:sequence>                                     
                            </xs:complexType>
                        </xs:element>
....................
....................
</xs:element>

type2.xsd

type2.xsd - 
package used is com.company.type.two

<xs:element name="xml_element">
                  <xs:complexType>
                     <xs:sequence maxOccurs="1">
                      <xs:choice>
                        <xs:element name="request">
                            <xs:complexType>
                             <xs:sequence maxOccurs="1">
                                  <xs:choice>
                                <xs:element name="transaction" 
type="transactionT"/>
                                <xs:element nam ............
                                    ................................... 
/>
                                  </xs:choice>
                             </xs:sequence>                                     
                            </xs:complexType>
                        </xs:element>
....................
....................
</xs:element>


Sample XML that failed -
<xml_element>
  <request success="y">
    <customer>
      <range_num>0</range_num>
        ..............
        ..............
    </customer>
  </request>
</xml_element>

So as u see 2 different xsds that have same top level tags and corresponding 
Document classes, but different package names. so 2 different jars.
Still it errored out.

I have fixed the issue by combining the 2 xsds into one and having a common 
package name.
But still was trying to dig into the actual reason for the issue I faced!

Thanks in advance.
Soumya






________________________________
From: Peter Keller <pkel...@globalphasing.com>
To: user@xmlbeans.apache.org
Sent: Thu, 29 April, 2010 2:02:57 PM
Subject: Re: XmlBean object confusion

Dear Soumya,

Your assumption that this has something to do with the Java typesystem may be 
wrong, but since you haven't given us the actual text of the error message we 
have no way of knowing.

You have also given us very little information about how you have written your 
schemae, but one thing occurs to me: do they both have the same target 
namespace? If they do, there may be a conflict between the definitions of the 
root elements, and the problem is with the XML type system rather than the Java 
one (see the XMLBeans javadoc for org.apache.xmlbeans.SchemaType). If this is 
the problem, and you need to keep a single target namespace, you could design 
your way out of this problem by merging the two schemae into a single one: use 
either <xsd:choice> or derivation from a common supertype to allow the new 
single schema to describe both types of document.

Regards,
Peter.

On Thu, 29 Apr 2010, Soumya wrote:

> Date: Thu, 29 Apr 2010 16:39:42 +0530 (IST)
> From: Soumya <soumya_...@yahoo.co.in>
> Reply-To: user@xmlbeans.apache.org
> To: user@xmlbeans.apache.org
> Subject: XmlBean object confusion
> 
> Hi guys,
> 
> I came across a strange issue today for which I am having serious doubts 
> about my Java skills!!..
> if this is something very obvious and I am posing a blind eye to it please do 
> open my eyes!
> 
> I have an xsd say type1.xsd which has an element <xml_element> at the top 
> level.
> xml from it would look like
> <xml_element>
>     <request>
>         <customer>
> .....
> </xml_element>
> 
> Now I have another xsd which has the same top level elements xml_element and 
> request but different
> inside. xml complying to it would look like
> <xml_element>
>     <request>
>         <transaction>
> .....
> </xml_element>
> 
> So you can see above that the 2 top level elements <xml_element> and 
> <request> are the same.
> Now I use Xmlbeans to generate 2 different jars out of it -
> type1.xsd has the following document object - 
> com.company.type.one.XmlElementDocument
> 
> type2.xsd has the following document object - 
> com.company.type.two.XmlElementDocument
> 
> Kindly note the packages are different and so are fully qualified classnames. 
> Also they are in 2
> different jars type1.jar and type2.jar
> 
> Now when I load my Application and try to use
> com.company.type.one.XmlElementDocument.Factory.parse("somexml") - where 
> "somexml" is actually of
> type type1.xsd it errors out telling xml not of type <xml_element> - 
> shocking!! it works fine
> standalone. But when I put both jars together it errors out!!
> 
> if i remove type2.jar from the application it works fine happily again.
> 
> Ideally since the package names are different shouldnt the 2 
> XmlElementDocument s be identifiable
> separately.. after all that's why java is so good with fully qualified 
> classnames.
> Please suggest if you have faced similar issue.
> thanks in advance.
> Soumya
> 
> 
> 

-- Peter Keller                                     Tel.: +44 (0)1223 353033
Global Phasing Ltd.,                             Fax.: +44 (0)1223 366889
Sheraton House,
Castle Park,
Cambridge CB3 0AX
United Kingdom

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org
For additional commands, e-mail: user-h...@xmlbeans.apache.org


Reply via email to