You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Stanisław Findeisen <st...@eisenbits.com> on 2011/07/28 19:08:52 UTC

the generated .xsb/.class files prevent Schema loading (and document validation)

Hi

I am running this snippet of code:

XmlObject doc = XmlObject.Factory.parse(xmlFile, someLoadOpts);
SchemaType schemaType = doc.schemaType();
System.err.println("schemaType=" + schemaType);
if (null != schemaType) {
  System.err.println("schemaType.isNoType=" + schemaType.isNoType());
  System.err.println("schemaType.getName=" + schemaType.getName());
}

in a web application (a servlet).

xmlFile is a user submitted file (a String) that I want to parse and
validate.

someLoadOpts is very simple, it is made like this:

XmlOptions someLoadOpts = new XmlOptions();
Map<String, String> namespaces = new HashMap<String, String>();
namespaces.put("", targetNamespace);
someLoadOpts.setLoadSubstituteNamespaces(namespaces);

That's it. It's just about namespace substitution on parsing.

Next, I have an XMLBeans generated JAR (well, at least it looks so --- I
am not the author) which looks to contain the generated Java classes for
the XML Schemas we use. That's ok.
This JAR is always present in the webapp.

Now the question is about the presence of XMLBeans generated .xsb and
.class files in the same webapp.

If they are present, nothing works! In the log I have:

  [java] schemaType=N=
  [java] schemaType.isNoType=true
  [java] schemaType.getName=null

which is clearly the reason why the XML document is not valid and
everything blows up a few lines later.

However if I delete those .xsb and .class files from the webapp (leaving
just the XMLBeans generated JAR, and my stuff), and deploy, everything
works fine!

  [java] schemaType=D=query@http://my-schema-id.mydomain.com/query
  [java] schemaType.isNoType=false
  [java] schemaType.getName=null

I.e., the proper Schema gets loaded and validation is OK!

Why??!

-- 
http://people.eisenbits.com/~stf/
http://www.eisenbits.com/

OpenPGP: E3D9 C030 88F5 D254 434C  6683 17DD 22A0 8A3B 5CC0

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org