Some minor corrections: xs should read xsi and the schemaLocation
attribute value is incomplete. The following validates:

<customer phone="888.555.1234" xmlns="http://www.sosnoski.com/ns1";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://www.sosnoski.com/ns1
http://www.sosnoski.com/ns1.xsd";>

See http://www.w3.org/TR/xmlschema-0/#schemaLocation

Regards,
Andreas

Dennis Sosnoski wrote:
> Hi Simone,
> 
> Your sample XML output is not well-formed since it doesn't include the
> declaration for the xs namespace. To be well-formed it should look like
> this:
> 
> <customer phone="888.555.1234"
>          xmlns="http://www.sosnoski.com/ns1";
>       xmlns:xs="http://www.w3.org/2001/XMLSchema-instance";
>         xsi:schemaLocation="http://www.sosnoski.com/ns1_2";>
> 
> To do this in JiBX you'd want to use the binding:
> 
> <binding>
> <namespace uri="http://www.sosnoski.com/ns1_2"; prefix="xsi"
> default="none"/>
>  <mapping name="customer" class="example9.Customer">
>    <namespace uri="http://www.sosnoski.com/ns1"; default="elements"/>
>   <namespace uri="http://www.w3.org/2001/XMLSchema-instance";
> default="none" prefix="xs"/>
>     <value style="attribute"
> ns="http://www.w3.org/2001/XMLSchema-instance"; name="schemaLocation"
> get-method="getSchemaLocation"
>                set-method="setSchemaLocation" usage="optional"/>
>    <structure field="person"/>
>      . . .
>  </mapping>
> </binding>
> 
> JiBX should give an error when you try to use a namespace in the binding
> that hasn't been defined - I'll add a check for that case.
> 
>  - Dennis
> 
> [EMAIL PROTECTED] wrote:
> 
>>
>> Hello all.  I stumbled upon an issue while marshalling my object into
>> xml, and wanted to see if anyone has experienced my problem.
>>  Basically what I'm trying to do is the following:
>>
>> I need to define/declare more than one default namespace for a single
>> mapping.  This seems as though it would be a pretty common occurrence,
>> however I have been unsuccessful.  Here is a sample of the desired
>> output:
>>
>> <customer phone="888.555.1234"
>>           xmlns="http://www.sosnoski.com/ns1";
>>          xsi:schemaLocation="http://www.sosnoski.com/ns1_2";>
>>
>> Here is a snippet of the binding that I am using:
>> <binding>
>>  <namespace uri="http://www.sosnoski.com/ns1_2"; prefix="xsi"
>> default="none"/>
>>   <mapping name="customer" class="example9.Customer">
>>     <namespace uri="http://www.sosnoski.com/ns1"; default="elements"/>
>>      <value style="attribute" ns="http://www.sosnoski.com/ns1_2";
>> name="schemaLocation" get-method="getSchemaLocation"
>>                 set-method="setSchemaLocation" usage="optional"/>
>>     <structure field="person"/>
>>       . . .
>>   </mapping>
>> </binding>
>>
>> Here is the exception I receive:
>>         UnmarshallException:  exception while unmarshalling
>> UnmarshallException: Error unmarshalling XML: Error parsing document
>> (line 2, col 162)
>>         XmlUnmarshaller.unmarshallXml(XmlUnmarshaller.java:80)
>>         TestFxSimpleOption.testDisconfactors(TestFxSimpleOption.java:219)
>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
>> Source)
>>         at java.lang.reflect.Method.invoke(Unknown Source)
>>         at junit.framework.TestCase.runTest(TestCase.java:154)
>>         at junit.framework.TestCase.runBare(TestCase.java:127)
>>         at junit.framework.TestResult$1.protect(TestResult.java:106)
>>         at junit.framework.TestResult.runProtected(TestResult.java:124)
>>         at junit.framework.TestResult.run(TestResult.java:109)
>>         at junit.framework.TestCase.run(TestCase.java:118)
>>         at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>         at junit.framework.TestSuite.run(TestSuite.java:203)
>>         at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:436)
>>
>>         at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:311)
>>
>>         at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
>>
>>
>> with the output xml:
>> <customer phone="888.555.1234"
>>           xmlns="http://www.sosnoski.com/ns1";
>>          xmlns:xsi:schemaLocation="http://www.sosnoski.com/ns1_2";>
>>  
>> Any suggestions/input would be greatly appreciated!
>>
>> Many thanks!
>>
>> Simone




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to