I would like to generate the java classes for a xml file where a 
particular element has one subelement and an attribute with the 
same name. This results in the generated class being non-compilable
 since the resultant class has two conflicting methods. I would 
like to know what are the reasonable options/solutions I have.

The schema itself is not under my control so I am unable to change
 it (in this particular situation the schema is jakarta struts 
configuration schema). The specific situation is as follows 
(including the xsd snippet for a struts configuration file). The 
name which causes the problem is "forward". The compiler error is 
on the method "getForward". I am using all the default settings of 
sourceGenerator. I attempted to find a solution in the 
sourceGenerator user document but was unable to identify one. I am
not sure if the xml mapping file is relevant to source generation.

Thanks for all assistance.
Dhananjay


--------------------------------------------------
Details
--------------------------------------------------

----------------------------
XSD Snippet
----------------------------
<xsd:element name='action'>
 <xsd:complexType>
  <xsd:sequence>
.......
      <xsd:element ref='forward' minOccurs='0' maxOccurs='unbounded'/>
  </xsd:sequence>
  <xsd:attribute name='id' type='xsd:ID' use='optional'/>
  <xsd:attribute name='attribute' type='xsd:string' use='optional'/>
  <xsd:attribute name='className' type='xsd:string' use='optional'/>
  <xsd:attribute name='forward' type='xsd:string' use='optional'/>
......
 </xsd:complexType>
</xsd:element>

 <xsd:element name='forward'>
  <xsd:complexType>
.......
  </xsd:complexType>
 </xsd:element>

----------------------------
Generated Code Snippet
----------------------------
.......
    public java.lang.String getForward()
    {
        return this._forward;
    } //-- java.lang.String getForward()

    /**
     *
     * @param index
    **/
    public Forward getForward(int index)
        throws java.lang.IndexOutOfBoundsException
    {
        //-- check bounds for index
        if ((index < 0) || (index > _forwardList.size())) {
            throw new IndexOutOfBoundsException();
        }

        return (Forward) _forwardList.elementAt(index);
    } //-- Forward getForward(int)

    /**
    **/
    public Forward[] getForward()
    {
        int size = _forwardList.size();
        Forward[] mArray = new Forward[size];
        for (int index = 0; index < size; index++) {
            mArray[index] = (Forward) _forwardList.elementAt(index);
        }
        return mArray;
    } //-- Forward[] getForward()

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

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

Reply via email to