This week's book giveaway is in the Reactive Progamming forum. We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line! See this thread for details.
I am using XmlBean. I've compiled my schema and generated classes and interfaces which I am using
comfortably in my application. Problem is that I had created the schema using namespace but the xml
which I am getting doesn't have any namespace. So everytime when I try to validate
the xml ,it returns false.
Is there any way in which I can tell it to ignore the namespace and then validate?
XYZDocument is the class which is generated when I compile the schema using scomp command.
I don't see setNamespaceAware(flag) method which could be invoked on it.
There're some methods associated palying with namespace in XmlOption class which I can use
but don't know how.
I can insert namespace in the xmlString programatically but that would be the crude way of
well I've inserted the namespace crudely in the xml string but I am afraid to show it to my system analyst.
He sure gonna not like it.
posted 10 years ago
I don't know how I did it but I think I pulled it off. Here goes the solution...
XmlOption xmlOption=new XmlOption();
Map<String,String> map=new HashMap<String,String>();
map.put("","http://www.abc.com/sud/xyz"); //"http://www.abc.com/sud/xyz" is the namespace that i was using
XYZDocument xyzDoc = XYZDocument .Factory.parse(xmlString,xmlOption);
Now it doesn't complain that namespace not found in xml file.