Ok.  Without getting into building a reusable test case, assume my schema 
excerpt looks like this:

 <xs:element name="questionsInfo">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="questionSections"/>

The "questionsInfo" element maps to a "QuestionsInfo" class.  In my Java code, 
I create a QuestionsInfo object, populate it, and then marshal it.  I end up 
with the following excerpt:

  <questionsInfo
   xmlns="http://schemas.wamu.com/2006/07/LoanRiskRating";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
     xsi:type="questionsInfo"> 

>From what I now understand about the "xsi:type" attribute, it's supposed to 
>specify the name of the type that the element uses.  When this result document 
>is validated against the schema, it fails to validate, because it can't find a 
>type named "questionsInfo", because it doesn't exist.

I can work around this by changing my marshalling code to not generate the 
xsi:type attribute, but Castor really shouldn't have created the xsi:type 
element in the first place, as the element references an anonymous type, not a 
named type.

> -----Original Message-----
> From: Werner Guttmann [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, May 10, 2007 11:10 PM
> To: [email protected]
> Subject: AW: [castor-user] Problems with xsi:type
> 
> David,
> 
> Can you show us s small sample that highlights your problem, 
> and the 'incorrect' connection between the anonymous complex 
> type definition and the xsi:type usage ? 
> 
> Regards
> Werner
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Karr, David [mailto:[EMAIL PROTECTED]
> > Gesendet: Donnerstag, 10. Mai 2007 20:30
> > An: [email protected]
> > Betreff: [castor-user] Problems with xsi:type
> > 
> > I've never paid much attention to the "xsi:type" attribute before.  
> > I'm now looking at a situation where I'm trying to validate 
> a response 
> > generated by Castor against the schema used by Castor.  
> What I seem to 
> > be seeing is that Castor generates the xsi:type attribute, 
> by default.
> > The problem is, the resulting XML doesn't validate against 
> the schema.
> > This is because the element uses an anonymous type, not a 
> named type.
> > 
> > I know that it's possible to suppress the generation of the 
> xsi:type 
> > atribute when marshalling.  However, is it possible for 
> Castor to only 
> > generate the xsi:type attribute when the element uses a named type, 
> > and leave it off when it uses an anonymous type?
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> > 
> >     http://xircles.codehaus.org/manage_email
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
> 

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to