An xml namespace is not just a means to put your generated objects into 
a java package, it's a necessary thing to differentiate your order 
element from somebody else's order element. Therefore I suggest you to 
keep the namespaces in your binding and xsd and add the namespace 
declaration into the xml document instance as I suggested before..

Anyway if you don't want to use namespaces and just want your generated 
objects be in a specific package, then I think the -n option should have 
worked, since in the documentation it says that it applies to elements 
with no namespace. So if you remove the targetnamespace from your xsd 
and run codegen again with the -n option, then it should do what you want..



Robert La Ferla wrote:
> Thanks Serkan.  If I remove the targetNamespace and xmlns from the  
> xsd, it does work BUT the generated classes are not in the  
> com.mycompany.order.xml package anymore.
>
> When I generated the classes, I used this:
>
> java -cp ../../lib/jibx-tools.jar org.jibx.schema.codegen.CodeGen -t  
> src oms-order-jibx.xsd
>
> I also tried this but it didn't put the classes in the package either:
>
> java -cp ../../lib/jibx-tools.jar org.jibx.schema.codegen.CodeGen -n  
> com.mycompany.orders.xml -t src oms-order-jibx.xsd
>
> What to do?
>
> Robert
>
>
> On Jul 14, 2009, at 1:38 PM, Serkan Camurcuoglu wrote:
>
>   
>> it seems like you should write the order element as <order
>> xmlns="http://www.mycompany.com/orders/xml";> since it's defined in  
>> this
>> namespace in your schema file..
>>
>>
>>
>> Robert La Ferla wrote:
>>     
>>> I am getting a "No unmarshaller for element" exception and am trying
>>> to debug it.   I suspect that I have some sort of namespace issue.
>>> I'm just not sure where to look.
>>>
>>> 1. The top of my XSD looks like this:
>>>
>>> <xs:schema targetNamespace="http://www.mycompany.com/orders/xml";
>>> xmlns="http://www.mycompany.com/orders/xml"; 
>>> xmlns:xs="http://www.w3.org/2001/XMLSchema
>>> " elementFormDefault="qualified" attributeFormDefault="unqualified">
>>>         <xs:element name="order">
>>> ...
>>>
>>>
>>> 2. The xml looks like:
>>>
>>> <order>
>>> ....
>>> </order>
>>>
>>> 3. The top of the binding file looks like:
>>>
>>> <binding xmlns:tns="http://www. mycompany.com/orders/xml"
>>> name="binding" package="com.mycompany.orders.xml">
>>>   <namespace uri="http://www. mycompany.com/orders/xml"
>>> default="elements"/>
>>>   <format type="com. mycompany.orders.xml.OrderType" enum-value-
>>> method="toString"/>
>>>   <format type="com. mycompany.orders.xml.OrderState" enum-value-
>>> method="toString"/>
>>>   <mapping class="com. mycompany.orders.xml.Order" name="order">
>>>
>>>
>>>
>>> 4. My unit test looks like:
>>>
>>> import org.jibx.runtime.*;
>>> import java.io.*;
>>> import com.mycompany.orders.xml.*;
>>>
>>> public class TestIt {
>>>
>>> public static void main(String args[])  {
>>>     try {
>>>     IBindingFactory bfact = BindingDirectory.getFactory(Order.class);
>>>     System.out.println("bfact = " + bfact);
>>>     IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
>>>     System.out.println("uctx = " + uctx);
>>>     FileInputStream in = new FileInputStream("order.xml");
>>>     Order order = (Order)uctx.unmarshalDocument(in, null);
>>>     }
>>>     catch (Exception e) {
>>>         e.printStackTrace();
>>>     }
>>>
>>> }
>>>
>>> }
>>>
>>>
>>> 5. Also,  is there a way to query IUnmarshallingContext to get all  
>>> the
>>> mapping names it handles?
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Enter the BlackBerry Developer Challenge
>>> This is your chance to win up to $100,000 in prizes! For a limited  
>>> time,
>>> vendors submitting new applications to BlackBerry App World(TM)  
>>> will have
>>> the opportunity to enter the BlackBerry Developer Challenge. See  
>>> full prize
>>> details at: http://p.sf.net/sfu/Challenge
>>> _______________________________________________
>>> jibx-users mailing list
>>> jibx-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/jibx-users
>>>
>>>       
>> ------------------------------------------------------------------------------
>> Enter the BlackBerry Developer Challenge
>> This is your chance to win up to $100,000 in prizes! For a limited  
>> time,
>> vendors submitting new applications to BlackBerry App World(TM) will  
>> have
>> the opportunity to enter the BlackBerry Developer Challenge. See  
>> full prize
>> details at: http://p.sf.net/sfu/Challenge
>> _______________________________________________
>> jibx-users mailing list
>> jibx-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jibx-users
>>     
>
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge  
> This is your chance to win up to $100,000 in prizes! For a limited time, 
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize  
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>   


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to