Puhong You, Obviously some bugs have been fixed along the way. You could try generating your classes with Castor 0.9.4.3 and see if they unmarshal with 0.9.3. I personally haven't tried this, but if it works then great. Otherwise, you'll need to modify the generated descriptors to remove the namespace declaration for the specific attributes.
--Keith "You, Puhong" wrote: > > I searched the mail archive and failed to find a direct answer to my > question. > > I have a xml schema that looks like this: > > <?xml version="1.0" encoding="UTF-8"?> > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > targetNamespace="http://www.vignette.com/projectA" > xmlns="http://www.vignette.com/projectA"> > <xsd:element name="metadata-store"> > <xsd:complexType> > <xsd:sequence> > <xsd:element ref="metadata-entry" > minOccurs="0" maxOccurs="unbounded"/> > <xsd:element name="reusable-id" > type="xsd:positiveInteger" minOccurs="0" maxOccurs="unbounded"/> > </xsd:sequence> > <xsd:attribute name="next-id" > type="xsd:positiveInteger" use="required"/> > </xsd:complexType> > </xsd:element> > > ..... > </xsd:schema> > > I use castor SourceGenerator to generate java classes (MetadataStore.java, > etc.) from this schema. In my java application, I create/populate an > instance of MetadataStore, then marshal this object to xml file. When > inspecting the xml file, I notice that dynamically generated namespace > prefixes are prepended to all the attribute names: > > <?xml version="1.0"?> > <metadata-store xmlns:ns1="http://www.vignette.com/migration" > ns1:next-id="5"><metadata-entry ns2:template-id="1".../> > > These namespace prefixes cause my subsequent unmarshalling call fails with > validation exception (e.g., missed required attribute: next-id). > > The above behaviors are observed when I use castor 0.9.3.*. > > After I switch to castor 0.9.4, the problem goes away, i.e., the xml file > from marshalling looks like: > > <?xml version="1.0"?> > <metadata-store xmlns="http://www.vignette.com/migration" > next-id="5"><metadata-entry template-id="1".../> > > Unfortunately, I have to use castor 0.9.3.* in order to be compatible with > other components in the same application. > > Is there any way to get rid of the dynamically generated namespace prefixed > from the xml file when marshalling use castor 0.9.3* ? > > Thanks a lot, > > Puhong You > > > > ----------------------------------------------------------- > If you wish to unsubscribe from this mailing, send mail to > [EMAIL PROTECTED] with a subject of: > unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
