Thanks a lot Dave... It works now.. As you suggested I just kept the default
namespace and removed the other stuff.. This approach is working fine...
With a little workaround the other approach is also working fine.. I am
actually building web services using OC4J.. it gives the input (XML string) to
Service End point in 'Element' (org.w3c.dom.Element)... If I use the parse
method which takes Element and XmlOptions as input, the xmloptions which we set
some how doesn't work.. but If I convert Element into String then it works..
Here is the code...
XmlObject xmlObj = XmlObject.Factory.parse(input); // input is of type
Element
StringWriter swElement = new StringWriter();
xmlElements.save(swElement); // Save the Element into StringWriter..
// Set the XML Options
XmlOptions xopt = new XmlOptions();
String namespace = "http://testdomain/corange";
HashMap m = new HashMap();
m.put("",namespace);
xopt.setLoadSubstituteNamespaces(m);
// parse (first parameter is String)
INPUTSDocument myInputsDoc =
INPUTSDocument.Factory.parse(swElement.toString(),xopt);
// Following one doesn't work with same xml options.
// INPUTSDocument myInputsDoc = INPUTSDocument.Factory.parse(input,xopt);
Thanks
Kiran
-------------------------------------------------
Ph: 312 742 9630
Email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
________________________________
From: Dave Harrison [mailto:[EMAIL PROTECTED]
Sent: Thu 6/23/2005 4:30 PM
To: [email protected]
Subject: Re: Unable to marshal the XML
Ah, didn't read this before responding to your last post, but I'd have a
stab at the problem being defining the default namespace wrongly.
To define a default namespace use xmlns="http://testdomain/corange".
This will ensure elements that aren't qualified with a namespace prefix
will belong to the http://testdomain/corange namespace.
In fact The whole namespace line doesn't look good. Replace the whole
<INPUTS... with
<INPUTS xmlns="http://testdomain/corange" >
Let me know if this sorts your problem with the NPE. Take a look at the
XML Schema Primer bit on Namespaces too:
http://www.w3.org/TR/xmlschema-0/#NS
Dave H.
Kiran Kumar wrote:
> Hi,
>
> I am trying to create a bean from an xml string using xmlbeans.. I am
> getting the following error.. I am forming the correct XML which
> matches the xsd.. Any thoughts when will we get this kind of error?
>
> *java.lang.NullPointerException*
> * at
> org.apache.xmlbeans.impl.store.Root$LoadContext.checkNameAttr(Root.java:1428)
> at org.apache.xmlbeans.impl.store.Root$LoadContext.attr(Root.java:1558)
> at org.apache.xmlbeans.impl.store.Root.loadNode(Root.java:1808)
> at org.apache.xmlbeans.impl.store.Root.loadXml(Root.java:1849)
> at
> org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:356)
> at testdomain.corange.INPUTSDocument$Factory.parse(Unknown Source)
> *
> My input XML is
> <INPUTS targetNamespace="http://testdomain/corange"
> xmlns:corange="http://testdomain/corange"
> xmlns:xmlns="http://testdomain/corange"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <ADDRESS>
> <STREET>7500 GREENVIEW AVE</STREET>
> <STREET>7600 GREENVIEW AVE</STREET>
> </ADDRESS>
> <GEOCODING_TARGET>1</GEOCODING_TARGET>
> <APPLICATION_ID>TEST</APPLICATION_ID>
> <OBJECT_LAYER>CIP_POINTS</OBJECT_LAYER>
> <EXTERNAL_ID>18283</EXTERNAL_ID>
> <ACTUAL_LOGICAL>false</ACTUAL_LOGICAL>
> </INPUTS>
>
> Thanks
> Kiran
> -------------------------------------------------
> Ph: 312 742 9630
> Email: [EMAIL PROTECTED] <mailto:[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]
<<winmail.dat>>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

