Kiran,
You're missing an important line in your Schema definition. You need to
create a global element somewhere in the schema file, such as:
<xsd:element name="INPUTS" type="gcindividual:INPUTS" />
This specifies the root element of your XML instance and will become the
actual INPUTSDocument object when the file is parsed.
Then you can parse the file with:
XmlOptions opts = new XmlOptions();
Map<String, String> ns = new HashMap<String, String>();
ns.put("", "http://testdomain/gcindividual");
opts.setLoadSubstituteNamespaces(ns);
INPUTSDocument inputsDoc = INPUTSDocument.Factory.parse(
"<INPUTS><ADDRESS> <STREET>50 w washington st</STREET>
</ADDRESS> </INPUTS>", opts);
All the best,
Dave H.
Kiran Kumar wrote:
>Thanks for your response.
>
>I tried with the following options, but it did not work..
>
>I have tried with the following options.. but I was getting the same error..
> XmlOptions xopt = new XmlOptions();
> xopt.setUseDefaultNamespace();
> INPUTSDocument myInputsDoc = INPUTSDocument.Factory.parse(input,xopt);
>
>and also like this..
>
> String namespace = "http://testdomain/gcindividual";
> HashMap m = new HashMap();
> m.put("",namespace);
> xopt.setLoadSubstituteNamespaces(m);
>
>I was getting the same error ==>The document is not a [EMAIL
>PROTECTED]://testdomain/gcindividual <mailto:[EMAIL
>PROTECTED]://testdomain/gcindividual> : document element namespace mismatch
>expected "http://testdomain/gcindividual <http://testdomain/gcindividual> "
>got ""
>
>Thanks
>Kiran
>-------------------------------------------------
>Ph: 312 742 9630
>Email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>
>________________________________
>
>From: Jean-Christophe Pazzaglia [mailto:[EMAIL PROTECTED]
>Sent: Wed 6/22/2005 8:42 AM
>To: [email protected]
>Subject: Re: document element namespace mismatch
>
>
>
>Speciyiyng the default namespace in INPUTS should make it
>(according that you managed to compile your schema before
>and marshalling is your issue)
>
>jc
>
>
>
>>Hi, Anybody has any inputs on my previous question.. Any help is
>>highly appreciated. I have gone through google, could not get any
>>solution.
>>
>>Thanks
>>Kiran
>>------------------------------------------------------------------------
>>*From:* Kiran Kumar [mailto:[EMAIL PROTECTED]
>>*Sent:* Tue 6/21/2005 3:21 PM
>>*To:* [email protected]
>>*Subject:* document element namespace mismatch
>>
>>Hello, I am a newbie to this xmlbeans. I am trying to generate the
>>bean using XML string. My input is some thing like
>>
>><INPUTS> <ADDRESS> <STREET>50 w washington st</STREET> </ADDRESS>
>></INPUTS>
>>
>>I have the XSD like this :
>><xsd:schema xmlns:gcindividual="http://testdomain/gcindividual"
>>xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>>targetNamespace="http://testdomain/gcindividual"
>>elementFormDefault="qualified">
>> <xsd:complexType name="ADDRESS">
>> <xsd:sequence>
>> <xsd:element name="STREET" type="xsd:string"/>
>> </xsd:sequence>
>> </xsd:complexType>
>> <xsd:complexType name="INPUTS">
>> <xsd:sequence>
>> <xsd:element name="ADDRESS" type="gcindividual:ADDRESS"/>
>> </xsd:sequence>
>></xsd>
>>
>>While parsing this into document bean I am getting the error "
>>*document element namespace mismatch expected ...*". I always get the
>>input in String format so I will not have namespace prefix.. Is there
>>anyway we can tell XMLBeans to ignore namespaces ?
>>
>>Thanks
>>Kiran
>>
>>
>>
>
>--
>Jean-Christophe Pazzaglia, PhD <[EMAIL PROTECTED]>
>Corporate communications
>Tel: (+33) 4-93-00-26-78
>PGP Key available : http://www.eurecom.fr/~pazzagli/publickey.pgp
>--
>Institut Eurécom - Office 029
>http://www.eurecom.fr/
>2229 Route des CrĂȘtes
>BP 193
>06904 Sophia Antipolis, France
>Fax: (+33) 4-93-00-26-27
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>------------------------------------------------
>
>This e-mail, and any attachments thereto, is confidential and is intended only
>for the individual(s) named. If you are not the intended recipient, please
>let us know by e-mail reply and delete it from your system; do not copy/save
>this e-mail or disclose its contents to anyone. E-mail transmissions cannot
>be guaranteed to be secure or error-free as the transmission could be
>interrupted, corrupted, lost, destroyed, altered, arrive late or contain
>viruses. ObjectWave does not accept liability for any errors or omissions in
>the contents of this e-mail which arise as a result of e-mail transmission.
>The views expressed in this e-mail do not necessarily reflect those of
>ObjectWave or its affiliates.
>
>------------------------------------------------
>
>
>
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]