users@jaxb.java.net

A Little Fuzzy about JAXB and NameSpaces

From: padawan <russray_2008_at_yahoo.com>
Date: Wed, 25 Jun 2008 09:35:47 -0700 (PDT)

Hello Everyone,

I will be the first to admit I don't know very much concerning JAXB. This is
my first project I am using JAXB. If my questions are trivial, please excuse
my "innocence."

What I have done is create several Domain Objects for use in a Web Service.
I have created schemas for the domain objects. I have the web service
working and the XML response is being built correctly in nearing every case.
I am using annotations to document my JAXB Mapping. However, I have two
problems.

1. The ordering of the elements as described in the schema is not correct.
2. The namesspaces and prefixes are not working as I would expect them.

Here is what I have in the XML created by JAXB.

<ns3:DSIF
      xmlns:ns3="http://localhost/my_metadata_db/schema"
      xmlns:ns4="http://localhost/my_metadata_db/schema/"
      xmlns:ns5="http://localhost/my_metadata_db/schema/myInfo" count="2">



Heres is how I have it declared in the Domain objects:


@XmlRootElement(name="Record",
        namespace="http://localhost/my_metadata_db/schema/myInfo")
public class MyDocument {



What I would suspect is I have not fully annotated the class correctly
because this is how the elements look in the XML for the above declaration:


<Record recordNbr="1">
         <DistStmt>A</DistStmt>
         <Descr>Great Expectations</Descr>
         <NSN>12345</NSN>
         <DocNo>98213-123978</DocNo>
         <Name>BigGuy.pfd</Name>
         <Size>12345</Size>
         <ID>123456</ID>
         <RevDate>2008-06-24T19:36:06.513-05:00</RevDate>
         <Date>2008-06-24T19:36:06.513-05:00</Date>
         <PageCnt>123</PageCnt>
      </Record>



I would suspect the prefix in this case for the above elements would be
"ns5" but it is not. The correct order for any populated element should be:

1. ID
2. Path
3. Name
4. DistStmt
5. NSN
6. DocNo
7. Size
8. RevDate
9. Date
10. PageCnt
11. CRC
12. Hash
13. Platform
14. Type
15. Priority

Can someone be so kind and point me to some documentation that would help be
get the namespaces correctly and how I might order these elements?

Thanks for taking the time to read my post and for any suggestions you may
offer!

Russ

-- 
View this message in context: http://www.nabble.com/A-Little-Fuzzy-about-JAXB-and-NameSpaces-tp18115896p18115896.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.