One thing that I noticed when reading your schema example and messages is that 
you have not defined a top level element. That is to say there is no acceptable 
root element of a message/document that has been defined to be of type "Model" 
or "FrotzModel". This is why you are getting (xml-fragment) objects instead of 
(some-frontz-model-element) from the XMLBean objects, and may be why they are 
having problems parsing it.

XML requires you to define both types and global instances (elements) of an XML 
message. If you did have an element defined in the schema, say <element 
name="frotzModel" type="midas:FrontzModel"/>, then you could use the XMLBean 
object of type FrontzModelDocument to create "frontzModel" messages and 
distribute them.

I know my message may sound a bit cryptic, and it probably doesn't have enough 
references to be that useful, but maybe somebody else will see what I'm talking 
about and explain it a bit better.

Best Regards
-Duane

From: Justin Bailey [mailto:justinbaile...@yahoo.com]
Sent: Thursday, July 08, 2010 12:13 PM
To: user@xmlbeans.apache.org
Subject: Re: XMLBeans does not correctly propagate namespaces

Thanks Peter and Geir for your responses.  I apologize for the confusion; it 
looks like my email randomly omitted crucial lines of XML in my message.  Here 
is the missing XSD header, with parentheses instead of angle brackets.  (We're 
not using example.com; I just did a search & replace for our company name.)

(xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:midas="http://example.com/midas/"; 
targetNamespace="http://example.com/midas/"; elementFormDefault="qualified")

The XML fragment got its header lopped off as well.  I'll just paste the whole 
thing here again, with parentheses:

(xml-fragment id="model id" xmlns:mida="http://example.com/midas/";)
  (mida:Type)Statistical(/mida:Type)
(/xml-fragment)

It makes sense to me that the namespace is the important part and the prefix 
can be changed.  I think the prefixes ought to be consistent for sanity's sake, 
but since our code works, I can tolerate it.  It is only when we send it off as 
an XML message that the problem arises; the customer says that the XML fails to 
parse as intended.  (I'm not sure what parsing library they're using, but it 
isn't XMLBeans.)  We verified this by manually sending XML as text to the 
customer, and editing the prefixes by hand.  The midas prefix works; the mida 
prefix does not.

Peter, thank you for that FAQ link; I did not realize it applied to my problem. 
 I will try the code snippet found there.  Unfortunately, the link in the FAQ 
entry is dead, so I can't check the post for further information.

Justin

Reply via email to