Thanks Andrew! And Chad for creating the jira :o)
Do you have any thoughts on how to achieve this enhancement in the Source Generator !? In my case I think one solution is to re-use the Marshaller#setNSPrefixAtRoot flag. And maybe it would be necessary to overload Marshaller#marshal with an empty Collection containing the Namespaces and Prefixes when the method returns and without setting the prefixes at the root element (to be used if the object marshalled is part of another context like Castor inside Axis) Cheers, Are T. Tysnes -----Original Message----- From: Andrew Fawcett [mailto:[EMAIL PROTECTED] Sent: 19. mai 2005 16:37 To: [email protected] Subject: RE: [castor-dev] RE: [castor-user] Re: [castor-dev][XML] too many namespace declarations in element attributes Tysnes, I'll be than happy to look into making Castor XML automatically predetermine the namespaces its going to need and thus delcare them itself. Please raise an enhancement request for this and I'll take a look for a future Castor XML release. http://jira.codehaus.org/browse/CASTOR Cheers, Andy. -----Original Message----- From: Tysnes Are Thobias [mailto:[EMAIL PROTECTED] Sent: 18 May 2005 12:30 To: [email protected] Cc: [email protected] Subject: [castor-dev] RE: [castor-user] Re: [castor-dev][XML] too many namespace declarations in element attributes Thanks for your inputs.. :o) I do use the Source Generator and I guess I use the "the built-in marshal() methods" which you don't .. So I guess this is some feature in the Sorce Generator regarding redundant namespace declarations (for my original schemas). Our way of developing Web Services are: 1) Hand-craft schema + wsdl 2) run wsdl2java (Axis 1.2) 3) run Castor Source Generator 4) Implement the Web Service class file 5) deploy and be happy :o) Don't think generating "custom" marshal methods is a good idea.. or maybe I'm wrong ? :o) Cheers, Are T. Tysnes -----Original Message----- From: Gregory Block [mailto:[EMAIL PROTECTED] Sent: 18. mai 2005 13:16 To: [email protected]; Tysnes Are Thobias Cc: [email protected] Subject: Re: [castor-user] Re: [castor-dev][XML] too many namespace declarations in element attributes This can be much cleaner, if you tell the marshaller the namespace of the root, give it the appropriate schemaLocation definitions, and ensure that your mapping file matches the schemaLocation namespaces that you give the marshaller, as my original code snippet does. As I said - it took a while to get all the details licked, but I routinely generate good, clean xml off of predictable, non-"ns0/1/2" namespace names without difficulty. On 18 May 2005, at 11:15, Tysnes Are Thobias wrote: > Hello! > > I have managed to successfylly alter my schema files to remove all the > redundant namespace declarations from the response XML. (test schemas > are found here: > http://www.codecomments.com/Castor/message495418.html) > > What I did was: > > 1) move ArrayElement and ArrayOfArrayElements from MyService.xsd to > myservicecommon.xsd > 2) using "ref" for extensionBaseElement2 instead of "name". In other > words: > a) declare following in common.xsd > > <xsd:element name="extensionBaseElement2" > type="common:GeneralAddressType"/> > > b) re-declare extensionBaseElement2 in extensionBaseElement in > myservicecommon.xsd > from > <xsd:element name="extensionBaseElement2" > type="common:GeneralAddressType" minOccurs="0"/> > to > <xsd:element ref="common:extensionBaseElement2" > minOccurs="0"/> > > > The Response XML now looks like this: > > <soapenv:Envelope > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > <soapenv:Body> > <MyServiceResponse > xmlns="http://www.test.com/webservices/service"> > <MyServiceResponseWrapper > xmlns="http://www.test.com/webservices/service"> > <ns1:elementOne > xmlns:ns1="http://www.test.com/webservices/common"> > <ns1:child1>0</ns1:child1> > <ns1:child2>0</ns1:child2> > <ns1:child3>0</ns1:child3> > <ns1:child4>0</ns1:child4> > </ns1:elementOne> > <ElementTwo> > <elementTwoResponseArray> > <arrayElement > xmlns:ns2="http://www.test.com/webservices/service/common"> > > <ns2:baseElement1>test text</ns2:baseElement1> > > <ns2:baseElement2>888</ns2:baseElement2> > > <ns2:baseElement3>test text</ns2:baseElement3> > > <ns2:extensionBaseElement1>12345678910</ns2:extensionBaseElement1> > > <ns3:extensionBaseElement2 > xmlns:ns3="http://www.test.com/webservices/service/common"> > > <ns3:Addr1>test text</ns3:Addr1> > > <ns3:Addr2>test text</ns3:Addr2> > > <ns3:Zip>0000</ns3:Zip> > > <ns3:City>City</ns3:City> > > </ns3:extensionBaseElement2> > > <ns2:simpleElementOne>1234567</ns2:simpleElementOne> > > <ns2:simpleElementTwo>1234567</ns2:simpleElementTwo> > </arrayElement> > </elementTwoResponseArray> > </ElementTwo> > </MyServiceResponseWrapper> > </MyServiceResponse> > </soapenv:Body> > </soapenv:Envelope> > > And the Client Portal is hopefully more happy with this! > > Any coments on the schema changes and/or the way Source Generator > interpret the original schemas are welcome.. :o) > > Cheers, > Are T. Tysnes > > -----Original Message----- > From: Gregory Block [mailto:[EMAIL PROTECTED] > Sent: 14. mai 2005 18:51 > To: [email protected] > Cc: [email protected] > Subject: [castor-user] Re: [castor-dev][XML] too many namespace > declarations in element attributes > > > 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: > > > > > Hello Castor Developers! > > Would be happy if one developer with knowledge of Castor would help me > solve this issue which I suspect is a feature og the XML Source > Generator > > http://archive.codehaus.org/castor/user/msg00460.html > > The client for our Web Services is BEA WebLogic Portal and they tell > me that the Portal uses 1GB of memory to parse a response containing > 6000 lines.. most of the lines are attributes with new namespace > declarations > shown in the test-example above. > > I haven't confirmed this myself but anyways I have to clean the > response XML. I don't see any reason for all these namespace > declarations on > the > attributes. > > I will be willing to spend some time solving this issue and fix the > Source Generator (if neede). > > So.. It would be nice if someone could confirm this to be an issue > with the Sorce Generator. Nothing would make me more happy than > someone saying I'm using the tools in a wrong way or if there is some > errors in > my schema :o) > > Cheers, > Are T. Tysnes > The information in this message is confidential and may be legally privileged. It may not be disclosed to, or used by, anyone other than the addressee. If you receive this message in error, please advise us immediately. Internet emails are not necessarily secure. CODA does not accept responsibility for changes to any email which occur after the email has been sent. Attachments to this email may contain software viruses, which could damage your systems. CODA has checked the attachments for viruses before sending, but you should virus-check them before opening.

