Different elements of the xml are in different namespaces (each in different packages). I have given the mapping package names by using the org.exolab.castor.xml.nspackages attribute in castorbuilder.properties.
To ensure that the java files get generated in their respective folders, "elementFormdefault=qualified" is used in the schema definition. Now the java classes are generated in respective folders.
Now when I unmarshal the object to the xml, is there any way to get back the namespaces. Because presently i am not getting any namespace definitons in the xml But the tags appear with prefixes like n1, n2 etc. without namespace definitons at the beginning of the xml <ns4:StudenId>1</ns4:StudenId>
How can I get the namespace at the beginning of the xml?? Also why can't i get the same namespace that i defined in the xsd(schema) when I unmarshal.
If you are getting elements with namespace prefixes that aren't declared, then that's a bug. But I doubt that such a large and obvious bug would still exist in Castor. Could be wrong though. What does the Castor web site say about that?
And when you do get correct namespace declarations, what matters is that the namespace URI is correct. The namespace prefix is arbitrary and doesn't matter.
Joined: Jan 12, 2008
The problem is something like this:
To ensure that the java files get generated in their respective folders, "elementFormdefault=qualified" needs to be used in the schema definition else the java files get generated in the same folder.
But doing that results in incremental ns-prefixes ns1,ns2 etc in the tags. but no namespace uri appear at the beginging of the xml for these prefixes which results in an invalid xml. (This happens during unmarshalling)....
I was checking out the castor documentation..... I didn't find mention of anything like it yet.