namespace « jaxb « Java XML Q&A

Java XML Q&A
Java XML Q&A » jaxb » namespace 

1. JAXB: How do I annotate classes so that they belong to different namespaces?

I want to have JAXB-annotated classes which would be marshalled/unmarshalled to different XML namespaces. What I need is something like:

<someRootElement xmlns="urn:my:ns1"
    xmlns:a="urn:my:ns2" xmlns:b="urn:my:ns3">


How can ...

2. How do I customise jaxb generation?

I have a series of xml messages, all with their own schemas and namespaces. The messages are currently marshalled using JAXB (we still live in a Java 1.4 environment) and we ...

3. REST + json + JAXB + namespaces

I have been trying to wrap my head around POSTing json to a REST service and JAXB namespaces. I am using Resteasy to mark up the server side method. ...

4. JAXB appending unneeded namespace declarations to tags

I'm implementing a homebrew subprotocol of XMPP, and i'm using combination of StAX and JAXB for parsing/marshalling mesages. And when I marshall a message I end up with loads of unneded ...

5. How do I add a namespace attribute to an element in JAXB when marshalling?

I'm working with eBay's LMS (Large Merchant Services) and kept running into the error:

org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it ...

6. JAXB unmarshalling ignoring namespace turns element attributes into null

I'm trying to use JAXB to unmarshal an xml file into objects but have come across a few difficulties. The actual project has a few thousand lines in the xml file ...

7. Duplicate namespace declarations in JAXB generated XML

I am using JAXB to generate XML from Java objects, it's a realtime, quite high message rate application and works fine most of the time. However occassionally and without any ...

8. JAXB lists namespaces in root element (-> each element)

By default, jaxb 2 lists all (all possible required) namespaces in root element during marshalling: Is there a way to ...

9. jaxb namespaces in each element instead of root element during marshalling

By default, jaxb 2 lists all (all possible required) namespaces in root element during marshalling:

<rootElement xmlns="default_ns" xmlns:ns1="ns1" xmlns:ns2="ns2"> <ns1:element/> ...

10. JAXB, how to marshal without a namespace

I have a fairly large repetitive XML to create using JAXB. Storing the whole object in the memory then do the marshaling takes too much memory. Essentially, my XML looks like ...

11. JAXB adding namespace to parent but not to the child elements contained

I put together an XSD and used JAXB to generate classes out of it. Here are my XSDs-

myDoc.xsd :
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns=""

12. JAXB Marshalling and unmarshalling avoiding namespaces

this is a very common problem but I still need a specific solution if someone can please provide me with a solution.

JAXB.unmarshal('file', class);
However because of the namespaces present in the xml ...

13. JAXB marshalling problem - probably namespace related

Given the intitial XML (BPEL) file:

 <?xml version="1.0" encoding="UTF-8"?>


14. XJC namespace problem

I am trying to generate java source files from a package of *.xsd files using the xjc code generation tool. The namespaces used in those *.xsd files are as follows: h*p://
h**p:// ...

15. jaxb - generate classes from single schema in different packages depending on namespace

My requirement is that I have a very big schema and it has many different tags with different namespaces. I want to generate classes from that schema into different packages and ...

16. Jaxb2 : create seperate directorie per namespace

im using maven-jaxb2-plugin to generate from a 1.0xsd file:


17. JAXB annotations to deal with same element name in different namespaces

The problem that I am trying to solve is that JAXB cannot handle the parent and inherited objects of the same name in different namespaces. I have two schemas: schemaA.xsd

<xs:schema xmlns:A="...">
<xs:complexType name="mytype">
<xs:schema xmlns:B="..." ...

18. JAXB generating wrong Namespace

I have a xsd (lets name it as afb) which imports another xsd (lets name it as kts). And I refer to an element of kts.xsd in afb.xsd along with correct ...

19. Controlling namespace prefixes in JAXB

How does jaxb determine the list of namespace prefix declarations whem marshalling an object? I used xjc to compile java classes for ebics (ebics schema). When I create an ...

20. How to unmarshal an XML document using JAXB and a different, but compatible, context

I'm attempting to write a conversion tool that takes a legacy XML document (adhering to oldSchema.xsd) and converts it into a new XML format (adhering to newSchema.xsd). Perhaps I'm going about this ...

21. JAXB Unmarshal Exception

I generated some classes off of an xsd that I made from a web service response that I am calling. I'm getting an Exception when I run a JUnit test class that ...

22. How can i remove namespace from the generated JAXB File?

Here is my code: xsdFile:

<complexType name="Player">
        <element name="Login" type="string"></element>
        <element name="Passwd" type="string"></element>

23. JAXB namespaces missing

I have generated Java classes from XSD, all works fine from a unmarshalling point of view. However, when I marshall from JAXB classes I get the following:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<message xmlns="">

24. JAXB XML Object Marshalling without namespace prefixes

Im working on a java project where i need to read some objects from an XML file, do some processing which will alter the object´s atributes and then write the Object ...

25. JAXB: How can I unmarshal XML without namespaces

I have an XML -----XML -------

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
   <str>the type</str>
   <bool type="boolean">true</bool>        
And I want to unmarshal it to ...

26. java set namespace declaration at the begining

What do I need to set in DocumentBuilderFactory or Document or Marshaller class to move namespace declarations at the begining of produced XMLdocument? For an example my current code produce next ...

27. RESTeasy/JAXB; How do I avoid a namespace being added to an Element in an tag? (List in JAXB)

I'm going to simplify my classes and output as best I can here, but basically what I'm after is I want to add an org.w3c.dom.Element (representing an atom link in this ...

28. How to avoid unnecessary namespace declarations in a marshalled element/tag?

I have a XSD which is not self created but received from another party. So I can't change this XSD because I must ensure comptibility with the other party. Using XJC 2.2 ...

29. Matching namespaces on marshalling / unmarshalling in JAXB

Matching namespaces on marshalling / unmarshalling in JAXB I use JAXB to marshall / unmarshall XML. If I marshall an XML file like this:

<om:RequestCreateEvent xmlns:om="" xmlns:v1="" xmlns:xsi="" xmlns:v11="" xmlns:v12="">

30. JAXB: How to bind element with namespace

He is my XML hosted on remote machine:

<?xml version="1.0" encoding="UTF-8"?>
<store xmlns="">
    <!-- My Book store-->
    <book location="vk 1">

31. How to ignore namespace while unmarshalling an xml

I am trying to unmarshal xml to java objects with JAXB. I have manually created the java bean classes which will be populated after unmarshalling (as I don't have any ...

32. JAXB namespaces, what are the rules for elements and attributes?

in the pile of specs I can't find the most basisc question: I can/must always,

  • annotate the default namespace element with @XmlElement(name="myElement")?
  • annotate foreign namespace element with @XmlElement(name="foreignElement",namespace="http://foreign")?
  • annotate default namespace attributes with ...

33. How to include namespaces in the generated xml using JAXB

Hi all, I have using JAXB to generate XML from a XSD file. So far so good. But i noticed that all the URL's (namespaces in the xsd) are not present ...  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.