Hi Robert, The Mapping API needs a bit of an update when it comes to namespaces to make things a bit easy to use. Currently you also need to specify the namespace for the fields as such:
<?xml version="1.0" encoding="UTF-8"?> <mapping xmlns:foo="http://BankOnline/CreditServices/AccountInfo"> <class name="HttpResponse"> <description>Default mapping for class HttpResponse</description> <map-to xml="Acct" ns-uri="http://BankOnline/CreditServices/AccountInfo"/> <field name="CCID" type="java.lang.String" required="false"> <bind-xml name="foo:ccid" node="element" location="Response"/> </field> <field name="acctNum" type="java.lang.String" required="false"> <bind-xml name="foo:acctnum" node="element" location="Response"/> </field> <field name="expDate" type="java.lang.String" required="false"> <bind-xml name="foo:expdate" node="element" location="Response"/> </field> <field name="status" type="int" required="false"> <bind-xml name="foo:status" node="element" location="Response"/> </field> <field name="cardType" type="java.lang.String" required="false"> <bind-xml name="foo:cardtype" node="element" location="Response"/> </field> </class> </mapping> Note the "foo" prefix for each of the fields in the bind-xml/@name. It doesn't matter what prefix you use, as long as it's declared to the proper namespace. --Keith Robert Newton wrote: > > I'm having difficulty unmarshalling an XML document that contains a > namespace. Could someone please tell me what I am doing wrong? I'm using > Castor-xml 0.9.5. > > This mapping works fine when the namespace is not specified in XML. But > when the namespace is included in the xml and I try to use ns-uri, I receive > a SAXException org.xml.sax.SAXException: > unable to find FieldDescriptor for 'ccid' in ClassDescriptor of > Response{file: [not available]; line: 5; > column: 15}. > > It's obviously a scoping issue. I can't seem to find any documentation or > examples on how to correctly use ns-uri for an XML namespace. > > Sample XML: > > <?xml version="1.0" encoding="utf-8"?> > <Acct xmlns="http://BankOnline/CreditServices/AccountInfo" > <Response> > <ccid>123456789</ccid> > <acctnum>987654321</acctnum> > <expdate>0803</expdate> > <status>4</status> > <cardtype>V</cardtype> > </Response> > </Acct> > > The mapping file that I am attempting to use: > > <?xml version="1.0" encoding="UTF-8"?> > <mapping> > <class name="HttpResponse"> > > <description>Default mapping for class HttpResponse</description> > <map-to xml="Acct" > ns-uri="http://BankOnline/CreditServices/AccountInfo"/> > > <field name="CCID" type="java.lang.String" required="false"> > <bind-xml name="ccid" node="element" location="Response"/> > </field> > <field name="acctNum" type="java.lang.String" required="false"> > <bind-xml name="acctnum" node="element" location="Response"/> > </field> > <field name="expDate" type="java.lang.String" required="false"> > <bind-xml name="expdate" node="element" location="Response"/> > </field> > <field name="status" type="int" required="false"> > <bind-xml name="status" node="element" location="Response"/> > </field> > <field name="cardType" type="java.lang.String" required="false"> > <bind-xml name="cardtype" node="element" location="Response"/> > </field> > </class> > </mapping> > > _________________________________________________________________ > Instant message with integrated webcam using MSN Messenger 6.0. Try it now > FREE! http://msnmessenger-download.com > > ----------------------------------------------------------- > 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
