Hi Paul,

You can do this with a mapping file. You just have to be real careful to
make sure the field name in the mapping file, matches exactly with
what's in the generated descriptor.

So for example in you have a class com.acme.Foo, with a field _bar you
can override the the field descriptor for bar as such:

<mapping>

<class name="com.acme.Foo" auto-complete="true">

   <field name="_bar" type="...">
      <bind-xml name="bar"/>
   </field>

</class>

</mapping>

When you marshal, you'll have to load the mapping file and set it in the
Marshaller, you can't use the generated marshal() methods.

So you'll need to do something like the following:

Mapping mapping = new Mapping();
mapping.loadMapping("mapping.xml");

Marshaller m = new Marshaller(writer);
m.setMapping(mapping):
m.marshal(foo);

--Keith

> Paul Grillo wrote:
> 
> I've been using the SourceGenerator for many large XSD schemas and it
> has been extremely helpful given that i'm almost non-conversant in XML
> Schema definition.  The java objects however, have been just great.
> 
> My quesiton, however is this.  I can't change the element name in the
> schema, but need to override the field descriptor (out put tag name)
> for that element.
> Below:
>           <xsd:element name="OutGroupIncdMsgIdsRow" minOccurs ="0"
> maxOccurs="5">
> I would like to insure that the tag that is generated when marshalling
> is "row".
> Currently i am actually editing the generated field descriptor class
> for OutGroupIncdMsgIdsDescriptor to insure that "row" is used.
> However, that means i have to re-edit every time i generate the
> classes, which does happen because these schemas are redistributed to
> me with minor changes.  I would like to maintain changes to the
> schema, but not have to change the generated java.
> 
> So, is there anything i can place in the schema below to insure that
> "row" is used as a descriptor for element named:OutGroupIncdMsgIdsRow
> ?
> 
>        <xsd:element name="OutGroupIncdMsgIds">
>         <xsd:complexType>
>          <xsd:sequence>
>           <xsd:element name="OutGroupIncdMsgIdsRow" minOccurs ="0"
> maxOccurs="5">
>            <xsd:complexType>
>             <xsd:sequence>
>              <xsd:element name="OutGrpIncdMsgIdsCommonDesign">
>               <xsd:complexType>
>                <xsd:sequence>
> 
>                 <xsd:element name="MessageId">
>                  <xsd:simpleType>
>                   <xsd:restriction base="xsd:string">
>                    <xsd:maxLength value="8"/>
>                   </xsd:restriction>
>                  </xsd:simpleType>
>                 </xsd:element>
> 
>                </xsd:sequence>
>               </xsd:complexType>
>              </xsd:element>
>             </xsd:sequence>
>            </xsd:complexType>
>           </xsd:element>
>          </xsd:sequence>
>         </xsd:complexType>
>        </xsd:element>

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to