Hi Lukasz,

before trying to answer your questions (inline, that is), can I ask you
something ? What's the reason to generate Java classes from your XML
schema without descriptor classes (instead of a mapping file) ? I just
would like to understand this requirement.

Cheers
Werner

Lukasz Kustusz wrote:
> Hello,
> 
> Actually I have several newbie questions, as I'm not sure I know what
> I'm doing with Castor, but the final message in the log (attached) is
> where I finally hit the wall.
> 
> I'm trying to: 1. Generate necessary objects from a xsd schema
> (attached). To this effect I'm using the below command
> 
> 
> java -classpath
> .;C:\Progra~1\Java\jdk1.6.0_11\jre\lib\ext\castor-1.2\castor-1.2-codegen.jar;C:\Progra~1\Java\jdk1.6.0_11\jre\lib\ext\castor-1.2\castor-1.2.jar;C:\Progra~1\Java\jdk1.6.0_11\jre\lib\ext\castor-1.2\castor-1.2-xml.jar;C:\Progra~1\Java\jdk1.6.0_11\jre\lib\ext\commons-logging-1.1.1.jar;C:\Progra~1\Java\jdk1.6.0_11\jre\lib\ext\castor-1.2\castor-1.2-xml-schema.jar;C:\Progra~1\Java\jdk1.6.0_11\jre\lib\ext\castor-1.2\castor-1.2-ddlgen.jar;C:\Progra~1\Java\jdk1.6.0_11\jre\lib\ext\velocity-1.6.2.jar
> org.exolab.castor.builder.SourceGeneratorMain -i
> Resources\promo3_4.xsd -package nikonpromosystem -gen-mapping
> promomap -verbose
> 
> Here there's two issues: First the mapping (sic!) doesn't get generated, even
> though the command executes without errors. 
In addition to the -gen-mapping option you will have to use the -nodesc
option.

> Second of all I get my
> objects in 4 different packages:
> 
> nikonpromosystem 
> nikonpromosystem.descriptors
> nikonpromosystem.types
> nikonpromosystem.types.descriptors
Yes, this is default. When you start using the -nodesc option, the
descriptors packages will disappear.

> In classes.txt there's the listing of all the classes generated.
> Definitelly more than I expected from the xsd. Nevertheless I tried
> to use those classes in my code, using the code examples without the
> mapping (castor-reference-guide-1.3 sections 1.8.2.2 & 1.8.2.3.2) .
> Here's the code:
Hi, if you did not use this with the mapping file(that did not get
generated), there is no use trying this, as the XML
generated/unmarshalled from will not meet the XML schema. You will have
to use either the mapping generated and or the XML class descriptors.
> 
> 
> private Unmarshaller unmarshaller; private Marshaller marshaller; 
> private XMLContext context; private static Logger log; private
> XMLClassDescriptorResolver classDescriptorResolver; private
> nikonpromosystem.PromoCall promocall ;
> 
> promocall = new nikonpromosystem.PromoCall(); String[] s = new
> String[]{"nikonpromosystem","nikonpromosystem.descriptors","nikonpromosystem.types","nikonpromosystem.types.descriptiors"};
>  context = new XMLContext(); try { context.addPackages(s);
> //that's where the error happens; } catch (ResolverException ex) {
> log.error(ex);}
> 
> unmarshaller = context.createUnmarshaller(); marshaller =
> context.createMarshaller();
> 
> reader = new FileReader("sample.xml"); promocall =
> (nikonpromosystem.PromoCall) unmarshaller.unmarshal(reader);
> 
> 
> I also tried to replace the XMLContext with classDescriptorResolver
> bat that also failed:
> 
> promocall = new nikonpromosystem.PromoCall(); classDescriptorResolver
> =
> (org.exolab.castor.xml.XMLClassDescriptorResolver)ClassDescriptorResolverFactory.createClassDescriptorResolver(BindingType.XML);
>  
> classDescriptorResolver.setClassLoader(promocall.getClass().getClassLoader());
> //NullPointerException
> 
> I also tried generating the mapping from within the code using the
> MappingTool, but...:
> 
> MappingTool tool = new MappingTool(); promocall = new
> nikonpromosystem.PromoCall(); tool.addClass(promocall.getClass());
> //NullPointerException
> 
> At this point I don't know what else I can try... Help?
> 
> 
> Lukasz.
> 
> 
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ---------------------------------------------------------------------
>  To unsubscribe from this list, please visit:
> 
> http://xircles.codehaus.org/manage_email

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to