Here is a trick you can use to ignore DataEntityAction:

Add the following to your CostCenter class mapping:

     <field name="DataEntityAction" type="string" get-method="toString"
transient="true">
         <bind-xml node="element"/>
     </field>

Keep in mind this trick will work for only one DataEntityAction element,
so it's not useful for elements with a maxOccurs > 1.

You can use the trick more than once however, so if you have some other
elements that you want to skip, copy the field mapping and change the
name.

Eventually, we will be adding a way to skip elements, directly, but
currently that is the best approach. For more complex cases, you can use
an XSLT transformation to remove unwanted elements.

--Keith

Will Kriski wrote:
> 
> I only want to map a few values from an XML file into a java object.  I want
> the values under the CostCenter element to go into a CostEntityPod.  I have
> a structure like:
> 
> <CostCenterBatch>
>   <CostCenter>
>     <CostCenterNumber>1</CostCenterNumber>
>     <DataEntityAction>
>       <DataEntityActionType>Activate</DataEntityActionType>
>     </DataEntityAction>
>   </CostCenter>
> </CostCenterBatch>
> 
> and part of my mapping looks like:
> 
>         <class name="com.openInvoice.eDocument.pod.CostEntityPod">
>                 <map-to xml="CostCenter"/>
>                 <field name="CostEntityNumber" *(field name differs from XML
> name)
>                        type="java.lang.String">
>                         <bind-xml name="CostCenterNumber"/>
>                 </field>
>         </class>
> 
> I don't have the DataEntityAction field in my pod and would like to ignore
> this XML element
> -is this possible?  The error is below. Thanks
> 
>      [java] Exception in thread "main" org.xml.sax.SAXException: unable to
> find FieldDescriptor for 'DataEntityAction' in ClassDescriptor of CostCenter
>      [java]     at
> org.exolab.castor.xml.UnmarshalHandler.startElement(Unknown Source)
>      [java]     at
> org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1335)
>      [java]     at
> org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidat
> or.java:823)
>      [java]     at
> org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
> LDocumentScanner.java:1222)
>      [java]     at
> org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
> java:380)
>      [java]     at
> org.apache.xerces.framework.XMLParser.parse(XMLParser.java:900)
>      [java]     at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown
> Source)
>      [java]     at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown
> Source)
>      [java]     at CastorTest.main(CastorTest.java:47)
>      [java] Java Result: 1
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev

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

Reply via email to