Hi, hmmm ... getData() just returns the same as getText().
My problem is, that I only have a Document with elements containing a 'type'-attribute, which contains names of (simple) Schema datatypes (int,long,date,....) .. e.g. Element <field type="xsd:int">12345</field> should map to an java.lang.Integer(not String!) with the value 12345 - or throw an Exception if the mapping couldn't be performed. (think of a method like "Object mapElementToObject (Element element)") I thought dom4j would perhaps provide necessary mappers/wrappers to do the mapping in a simple manner. thanks for your help Florian -----Ursprungliche Nachricht----- Von: David D. Lucas [mailto:[EMAIL PROTECTED]] Gesendet: Mittwoch, 20. November 2002 15:22 An: Florian Georg Cc: [EMAIL PROTECTED] Betreff: Re: [dom4j-user] Mapping Schema - DataTypes to Objects Try the following... // snip Object obj = ((Element)root.selectSingleNode("/record/field")).getData(); if (obj instanceof java.lang.String) { .... } // snip Florian Georg wrote: > Hi, > > I wonder how to use the dom4j Schema capabilities to > get Java Objects mapped from XML elements like this : > > <field name="foo" type="xsd:string">bar</field> > >>From the cookbook-example I got the impression that receiving > a java.lang.String object is quite that simple : > > // snip > Object obj = > ((DatatypeElement)root.selectSingleNode("/record/field")).getValue(); > if (obj instanceof java.lang.String) > { .... } > // snip > > but it's not that simple, is it ? :) > (I just got an ClassCastException from DefaultElement to DatatypeElement) > > help would be greatly appreciated ! > -- Florian -- +------------------------------------------------------------+ | David Lucas mailto:[EMAIL PROTECTED] | | Lucas Software Engineering, Inc. (740) 964-6248 Voice | | Unix,Java,C++,CORBA,XML,EJB (614) 668-4020 Mobile | | Middleware,Frameworks (888) 866-4728 Fax/Msg | +------------------------------------------------------------+ | GPS Location: 40.0150 deg Lat, -82.6378 deg Long | | IMHC: "Jesus Christ is the way, the truth, and the life." | | IMHC: "I know where I am; I know where I'm going." <>< | +------------------------------------------------------------+ Notes: PGP Key Block=http://www.lse.com/~ddlucas/pgpblock.txt IMHO="in my humble opinion" IMHC="in my humble conviction" All trademarks above are those of their respective owners.
smime.p7s
Description: application/pkcs7-signature