Hi all,
I am running into an issue with the mapping of a XML message
to a Java object.

In a nutshell, I am trying to take an XML string and create a 
Java object out of it (or vice versa).

The Java object is com.bac.srp.process.ProcessResponse

// psuedo code
ProcessResponse {
        // has a array of SrpView Objects. 
        private com.bac.cso.srp.SrpView[] optionalServiceRequests;
}


SrpView is another class that has following String attributes as mentioned
in the mapped file




The following is the mapping file that I created

<?xml version="1.0"?>
<!DOCTYPE mapping SYSTEM "E:\mapping.dtd">
<mapping>
        <class name="com.bac.srp.process.ProcessResponse">
                <map-to xml="process-response"/>
                <field name="Version" type="string">
                        <bind-xml name="VersionId"/>
                </field>
                <field name="Action" type="string">
                        <bind-xml name="Action"/>
                </field>
                <field name="InfrastructureToken"
type="com.bac.inf.InfrastructureToken">
                        <bind-xml name="infrastructure-token"/>
                </field>
                <field name="RequiredDocumentation" type="strings"
collection="array">
                        <bind-xml name="required-documentation"/>
                </field>
                <field name="MandatoryServiceRequests"
type="com.bac.cso.srp.SrpView" collection="array">
                        <bind-xml name="MandatoryServiceRequests"/>
                </field>
        </class>
        <class name="com.bac.cso.srp.SrpView">
                <field name="Version" type="string">
                        <bind-xml name="VersionId"/>
                </field>
                <field name="AssignedToCai" type="string">
                        <bind-xml name="AssignedToCai"/>
                </field>
                <field name="PreferredContactAddressLine1" type="string">
                        <bind-xml name="preferred-contact-address-line1"
node="element"/>
                </field>
                <field name="CaseNumber" type="string">
                        <bind-xml name="CaseNumber" node="element"/>
                </field>
        </class>
</mapping>


The xml message that I have is as follows
<?xml version="1.0"?>
<process-response>
        <VersionId>VersionId</VersionId>
        <Action>Action</Action>
        <MandatoryServiceRequests>               
                <ServiceRequest>  <!-- If I remove this it works-->
                        <VersionId>VersionId1</VersionId>
                        <AssignedToCai>AssignedToCai1</AssignedToCai>
                        <CaseNumber>CaseNumber1</CaseNumber>
                </ServiceRequest>
                <ServiceRequest> <!-- if I remove this it works ->
                        <VersionId>VersionId2</VersionId>
                        <AssignedToCai>AssignedToCai2</AssignedToCai>
                        <CaseNumber>CaseNumber2</CaseNumber>
                </ServiceRequest>
        </MandatoryServiceRequests>
</process-response>


Within the MandatoryServiceRequest tag, if I remove the ServiceRequest tag
then it works perfectly.
However,when the above XML  message  above "as is", I  get an exception.

org.xml.sax.SAXException: unable to find FieldDescriptor for
'ServiceRequest' in ClassDescriptor of com.bac.cso.srp.Srp-view
        at
org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:76
7)
        at
org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1340)


I would appreciate it if somebody can point me the right direction as to how
I should map the file correctly ?
The format of the XML message is coming from another source so I would like
to keep the framework quite flexible without enforcing rules on the
structure 
of the XML document I receive.



Thanks much for the help in advance.

Regads,
Sunil .K

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

Reply via email to