You need to modify your mapping.xml file as such:
<field name="productGroup" type="string"/> should be: <field name="productGroup" type="string"> <bind-xml name="product_group"/> </field> --Keith jose luis campos wrote: > > org.xml.sax.SAXException: unable to find FieldDescriptor for > 'product_group' in ClassDescriptor of org.sibum.amazon.Catalog{file: > [not available]; line: 6; column: 16} > > > What im doing wrong? Please check the xml file at > http://rcm.amazon.com/e/cm?t=universitstea-20&l=st1&search=XML&mode=books&p=102&o=1&f=xml > > Complete code follows. > > Product.java > /* > * Author: Administrator > * Created: Saturday, March 13, 2004 11:21:59 AM > * Modified: Saturday, March 13, 2004 11:21:59 AM > */ > package org.sibum.amazon; > public class Product > { > private String ranking; > private String title; > private String asin; > private String author; > private String image; > private String smallImage; > private String ourPrice; > private String listPrice; > private String releaseDate; > private String binding; > private String availability; > private String taggedURL; > > > public Product(String r,String t,String as,String au,String > img,String sImg,String oP,String lP,String rD,String b,String > av,String tURL) > {ranking=r; > title=t; > asin=as; > author=au; > image=img; > smallImage=sImg; > ourPrice=oP; > listPrice=lP; > releaseDate=rD; > binding=b; > availability=av; > taggedURL=tURL; > > } > > > ! ! public Product() > {} > public String getRanking() > { > return ranking; > } > > public void setRanking(String str) > { > ranking=str; > } > > public String getTitle() > { > return title; > } > > public void setTitle(String str) > { > title=str; > } > > public String getAsin() > { > return asin; > } > > public void setAsin(String str) > { > asin=str; > } > > public String getAuthor() > { > return author; > } > > public void setAuthor(String str) > { > author=str; > } > > public String getImage() > { > return image; > } > > public void setImage(String str) > { > image=str; > } > > public String getSmallImag! e(! ) > { > return smallImage; > } > > public void setSmallImage(String str) > { > smallImage=str; > } > > public String getOurPrice() > { > return ourPrice; > } > > public void setOurPrice(String str) > { > ourPrice=str; > } > > public String getListPrice() > { > return listPrice; > } > > public void setListPrice(String str) > { > listPrice=str; > } > > public String getReleaseDate() > { > return releaseDate; > } > > public void setReleaseDate(String str) > { > releaseDate=str; > } > > public String getBinding() > { > return binding; > } > > public void setBinding(String str) > { > binding=str; > } > > public String getA! vail! ability() > { > return availability; > } > > public void setAvailability(String str) > { > availability=str; > } > > public String getTaggedURL() > { > return taggedURL; > } > > public void setTaggedURL(String str) > { > taggedURL=str; > } > } > > > /******************************************************************/ > Catalog.java > > package org.sibum.amazon; > import java.util.List; > import java.util.ArrayList; > public class Catalog{ > private String keyword; > private String productGroup; > > private List productos= new ArrayList(); > public Catalog() { } > > public void addProducto(org.sibum.amazon.Product p) { > productos.add(p); > } > public List getProductos() { > return productos; > } > > public String getKeyword() { > return keyword; > } > public void setKeyword(String k) { > this.keyword =k; > } > > public String getProductGroup() { > return productGroup; > } > public void setProductGroup(String p) { > this.productGroup =p; > } > } > > > /********************************************************/ > > VerProductos.java > > > package org.sibum.amazon; > import org.exolab.castor.xml.*; > import org.exolab.castor.mapping.*; > import java.io.InputStreamReader; > import java.io.FileReader; > import java.io.InputStream; > import java.net.URL; > import java.util.List; > import java.util.Iterator; > > public class VerProductos{ > > public static void main(String args[]) { > try { > Mapping mapping = new Mapping(); > mapping.loadMapping("mapping.xml"); > Unmarshaller un = new > Unmarshaller(org.sibum.amazon.Catalog.class); > un.setMapping( mapping ); > URL url=new > URL("http://rcm.amazon.com/e/cm?t=universitstea-20&l=st1&search=XML&mode=books&p=102&o=1&f=xml"); > //FileReader in = new FileReader("producto.xml"); > > InputStream in=url.openStream(); > > > Catalog cat = (Catalog) un.unmarshal(new InputStreamReader(in)); > > in.close(); > System.out.println( cat.getKeyword() ); > > List productos= cat.getProductos(); > Iterator iter = productos.iterator(); > while ( iter.hasNext() ) { > Product product= (Product) iter.next(); > System.out.println("\n" + product.getTitle() ); > System.out.println("-----------------------------"); > } > > > } catch (Exception e) { > System.out.println( e ); > } > } > } > > > > mapping.xml > > > <?xml version="1.0"?> > <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version > 1.0//EN" "http://castor.exolab.org/mapping.dtd"> > <mapping> > <description>Archivo mapping para la lista de productos.</description> > > <class name="org.sibum.amazon.Product"> > <field name="ranking" type="string"/> > <field name="title" type="string" /> > <field name="asin" type="string" /> > <field name="author" type="string" /> > <field name="image" type="string" /> > <field name="smallImage" type="string" /> > <field name="ourPrice" type="string"/> > <field name="listPrice" type="string" /> > <field name="releaseDate" type="string" /> > <field name="binding" type="string" /> > <field name="availability" type="string" /> > <field name="taggedURL" type="string" /> > </class> > > <class name="org.sibum.amazon.Catalog"> > <field name="keyword" type="string"/> > <field name="productGroup" type="string"/> > <field name="productos" type="org.sibum.amazon.Product" > collection="collection" /> > </class> > > </mapping> > > ---------------------------------------------------------------------- > Charla con tus amigos en línea mediante MSN Messenger: Haz clic aquí > ----------------------------------------------------------- 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