users@jaxb2-commons.java.net

jabx xsd to classes and xml marshalling issues due to two namespaces

From: eagle <eagleoffire_at_gmail.com>
Date: Thu, 5 Mar 2009 12:20:18 +0100

Hello everyone,
I am stack using jaxb and I ask for some help.
My final objective is being able of marshalling and unmarshalling
xml-s that follows the structure of this xsd:
http://www.ipdr.org/public/VoIP3.5-A.0.1.xsd
I have already generated the classes with xjc:
xjc VoIP3.5-A.0.1.xsd
This generates the following class tree:
parsing a schema...
compiling a schema...
org\ipdr\namespaces\voip\IPDRVoIPType.java
org\ipdr\namespaces\voip\ObjectFactory.java
org\ipdr\namespaces\voip\package-info.java
org\ipdr\namespaces\ipdr\IPDRDoc.java
org\ipdr\namespaces\ipdr\IPDRDocEnd.java
org\ipdr\namespaces\ipdr\IPDRType.java
org\ipdr\namespaces\ipdr\ObjectFactory.java
org\ipdr\namespaces\ipdr\package-info.java
Note that if you are behind a proxy and it is not configured it may fail.

I have also try to put all in the same package:
Xjc –p a VoIP3.5-A.0.1.xsd
This generates:
parsing a schema...
compiling a schema...
a\IPDRDoc.java
a\IPDRDocEnd.java
a\IPDRType.java
a\IPDRVoIPType.java
a\ObjectFactory.java
a\package-info.java

This is fine for now. Next step, I have the following xml:
<?xml version="1.0" encoding="UTF-8"?>

<!-- Assumptions:
Call is being made from cell phone to IP
Call is terminated (normally) by the called side
Optional and Conditional fields are included based on the type of call made
Fields that did not include specific values (in the ipdr spec) have been
populated with information based on SS7 equivalents
IMSI/ESN/PIN/HLRID values are fictitious -->

<IPDRDoc xmlns="http://www.ipdr.org/namespaces/ipdr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ipdr.org/public/VoIP3.5-A.0.1.xsd"
IPDRRecorderInfo ="apex.virtualsummit.com"
version="3.5-A.0.1">

<IPDR>
<seqNum>123</seqNum>
<IPDRCreationTime>2000-02-01T07:00:00Z</IPDRCreationTime>
<subscriberId>Vendor Phone-1</subscriberId>
<ipAddress>172.17.17.10</ipAddress>
<hostName>cisco.gateway.234</hostName>
<imsiIngress>247478674378574</imsiIngress>
<esnIngress>33375629401</esnIngress>
<serviceConsumerType>EU</serviceConsumerType>
<pin>6294621</pin>
<startAccessTime>2000-11-25T09:45:30Z</startAccessTime>
<startTime>2000-11-25T09:45:45Z</startTime>
<endTime>2000-11-25T10:00:30</endTime>
<timeZoneOffset>-480</timeZoneOffset> <callDuration>885</callDuration>
<type>V</type>
<feature>H</feature>
<incomingCodec>G711Alaw</incomingCodec>
<disconnectReason>normalCallClearing</disconnectReason>
<averageLatency>145</averageLatency>
<ani>214-924-0258</ani>
<originalDestinationId>408-830-3711</originalDestinationId>
<ipAddressEgressDevice>199.171.210.211</ipAddressEgressDevice>
<portNumber>17779</portNumber>
<homeLocationIdIgress>FF01ABD6</homeLocationIdIgress>
<callCompletionCode>200</callCompletionCode>
<uniqueCallId>id45678</uniqueCallId>
</IPDR>
</IPDRDoc>

And I have the following classes:

public static void main(String[] args) {
               // TODO Auto-generated method stub



               //JAXBContext jc =
JAXBContext.newInstance("org.ipdr.namespaces.voip:voip.namespaces.ipdr.org");
               try {
                       JAXBContext jc = JAXBContext.newInstance("a");


                       // create an Unmarshaller
                       Unmarshaller u = jc.createUnmarshaller();


       IPDRDoc voip = (IPDRDoc) u.unmarshal(new File( "files/example.xml" ));


       System.out.println("ok");

               } catch (JAXBException e) {
                       // TODO Auto-generated catch block
                       e.printStackTrace();
               }




               System.out.println("Agur mundua!");

       }

This reads only the attributes of the IPDRType and not the attributes
of IPDRVoIPType. I have tried to modify the heritage of classes
without lack.
Any ideas?
Thanks