Can't tell you if it's source generator or not, but I routinely use Castor to generate XML without having any messy namespace problems. The trick, I believe, is to make sure that you report to the marshaller object all of those namespaces you wish to use and map, and ensure that all of the appropriate namespaces are present in your mapping files. But I don't use SourceGenerator, and can't tell you whether or not it behaves differently; I suspect not, unless you're using the built-in marshal() methods, in which case, my advice is "Don't Do That".� :) From my "XMLManager" service in my current codebase: � �� �� �� �� �� �� �� �// Attach schemas. � � � � � � � � � � � � if (schemaLocation!=null) { m.setSchemaLocation(schemaLocation); } � � � � � � � � � � � � if (nnschemaLocation!=null) { m.setNoNamespaceSchemaLocation(nnsch emaLocation); } � � � � � � � � � � � � if (rootElement!=null) { m.setRootElement(rootElement); } � � � � � � � � � � � � // Configure namespace mappings. � � � � � � � � � � � � try { � � � � � � � � � � � � � � � � Config namespaceCfg = cf.getConfig(cfg, xmlNamespaceKey); � � � � � � � � � � � � � � � � Map map = namespaceCfg.getMap(); � � � � � � � � � � � � � � � � if (map!=null) { � � � � � � � � � � � � � � � � � � � � Iterator it = map.keySet().iterator(); � � � � � � � � � � � � � � � � � � � � while(it.hasNext()) { � � � � � � � � � � � � � � � � � � � � � � � � String key = (String)it.next(); � � � � � � � � � � � � � � � � � � � � � � � � m.setNamespaceMapping(key, (String)map.get (key)); � � � � � � � � � � � � � � � � � � � � } � � � � � � � � � � � � � � � � } � � � � � � � � � � � � } catch (ConfigNotFoundException e) { � � � � � � � � � � � � � � � � // Not an error. � � � � � � � � � � � � } � � �� �� �� �� �� �� � Just make sure that whenever you have namespaces which are in need of configuring, they're provided to the unmarshaller.� The config, in this case, contains a 'map' structure, where key is the namespace to use, and the value is the actual namespace url. So, in general, when I marshal hand-rolled objects (we never use SourceGen) �1) setSchemaLocation() �2) setNoNamespaceSchemaLocation() when appropriate �3) add namespace mappings via setNamespaceMapping(ns, url). �4) Fire and forget. Should Just Work (TM). Sending to [email protected] as well, as I've seen someone else mention this recently... On 14 May 2005, at 13:34, Tysnes Are Thobias wrote:
|
- RE: [castor-user] Re: [castor-dev][XML] too many namesp... Gregory Block
- RE: [castor-user] Re: [castor-dev][XML] too many n... Tysnes Are Thobias
- Re: [castor-user] Re: [castor-dev][XML] too ma... Gregory Block
- [castor-user] [jdo] castor and dbcp Andreas Vombach
- Re: [castor-user] [jdo] castor and dbc... Brice Ruth
- Re: [castor-user] [jdo] castor an... Andreas Vombach

