I could be way way off here, and I haven't looked at this in a long time, but.... have you both set up type inheritance for the schema types and a substitution group for the elements? I have a faint recollection that for the xml you want to be acceptable all the elements "instantiating" the subtypes have to be in a substitution group for the element "instantiating" the base type. I don't know if this will be sufficient to get the output you want but I suspect it is necessary.

maybe this is relevant and might help :-)
david jencks

On Oct 25, 2007, at 8:00 AM, Jeff Garrett wrote:

Hi all.
I took a quick scan though the archive and some google searches but did not find what I was looking for. If I missed a good link, please provide it. I am using Xml Beans 2.2 in my project and all is well, very well in fact. I am not an expert and am fairly new, but so far its been very intuitive for me. But one small thing is bugging me and I can't find a way to fix it (if its possible).

In my xsd, I define a base type and multiple types that extend the base type. It is esentially an abstract object, with more detalied and specific objects extending the abstract object. This is reflected in the generated source and interfaces, as the specific types really do extend the base object. I am 99% sure my schema is defined properly, so I don't think its it, but I could be wrong. The base type has a few attributes and the specific types each specific attributes that belong to it only (whereas base ones are available to all specific types)

Now, the problem, is that when something occurs involving the specific types, the base class is referenced in a way that I don't want. I know its not wrong, and the xml I have validates, but it doesn't look the way I want it to. Best described with an example. In this example, the info tag will add a new base type by default, but really I add a specific type since each contains more info specific to that type. And this is obviously allowed since the specific type is also a base type (through inheritance). Fyi, the namespace prefix indicates cei=base type, odis=specific type.

How can I get it such that it looks like the way I want it, not the way I currently get it? I want the specific type to be in the tag, not the base type and a reference to it using xsi:type. I know the base type will need to be referenced because they are not in the same namespace, but I don't see why it is the type in the tag, when really it is the specific type being used. Is there a setting in XmlOptions that says always use specific type, never base type? Or is there something I have to set in the xsd? I have tried lots of different settings, btu have been unsuccessful thus far.

Thanks.
Jeff G.

This is what I currently get:
    <m:op>
      <m:info>
        <cei:baseType xsi:type=SpecificType>
          <cei:attr1>String</cei:attr1>
          <cei:attr2>2001-12-17T09:30:47.0Z</cei:attr2>
          <odis:attrX>String</odis:attrX>
          <odis:attrY>2001-12-17T09:30: 47.0Z</odis:attrY>
        </cei:baseType>
      </m:info>
    </m:op>

This is what I want:
    <m:op>
      <m:info>
        <odis:specificType>
          <cei:attr1>String</cei:attr1>
          <cei:attr2>2001-12-17T09:30:47.0Z</cei:attr2>
          <odis:attrX>String</odis:attrX>
          <odis:attrY>2001-12-17T09:30:47.0Z</odis:attrY>
        </odis:specificType>
      </m:info>
    </m:op>


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

Reply via email to