Hi Justin,

I looks to me that you are confused because you think that midas/mida are namespace names. They are not: they are arbitrary prefixes that map to namespace names. You haven't told us what the actual namespace name is in your example, but somewhere in your schema you should have something like:

<xs:schema .... xmlns:midas="http://some.place.com/namesaces/someNamespace"; ...>

which maps the prefix "midas" to the namespace name "http://some.place.com/namesaces/someNamespace";. If you don't have such a mapping, adding one may fix your problem.

The namespace name is any URI (full syntax is described in http://tools.ietf.org/html/rfc3986 ). It is quite common to use URL-like strings beginning http://... because they are easy to make unique, but it doesn't necessarily mean that the namespace name is a real URL, or that anything is downloadable from it. (Where no downloadability is implied, I personally prefer to use "tag" URI's as described in http://tools.ietf.org/html/rfc4151 )

Your mapping between "midas" and your namespace name might not be in the top-level <xs:schema> element. It could be in any element, in which case, the prefix applies to that element and all contained elements. It shouldn't matter that XMLBeans has changed the prefix from "midas" to "mida": it should have changed the prefix in any xmlns:midas="..." declaration to xmlns:mida="..." to be consistent. It is the namespace name that must be preserved unchanged. The prefix can be fluid, as long as in the context in which it occurs it is mapped to the correct namespace name.

Having said that, if you want to influence the namespace prefixes, see this FAQ entry: http://wiki.apache.org/xmlbeans/XmlBeansFaq#suggestedPrefixes

I hope that this is helpful,
Peter.

On Wed, 7 Jul 2010, Justin Bailey wrote:

Hi list,

I'm a developer on a major software project and I have just traced down a 
problem to a possible bug or misconfiguration in
XMLBeans.  I can only speculate that XMLBeans does not like plural words.  Let 
me describe the problem, with names changed
to protect "proprietary information"...

Suppose that I have an XSD schema declared approximately like so:

<?xml version="1.0" encoding="UTF-8"?>

  .
  .
  .
  <xs:complexType name="Model">
    <xs:attribute name="id" type="xs:string"/>
    <xs:sequence>
      <xs:element name="Type">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="Statistical" />
            <xs:enumeration value="Heuristic" />
            <xs:enumeration value="Bayesian" />
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  .
  <xs:complexType name="FrotzModel">
    <xs:complexContent>
      <xs:extension base="midas:Model">
      </xs:extension>
    </xs:complexContent>
  </xs:complexType> 
  .
  .
  .
</xs:schema>

etc.  I validate, compile, and jar up the XSD using XMLBeans.  No problem.  I 
then do something like this:

FrotzModel blorb = FrotzModel.Factory.newInstance();
blorb.setID("model id");
blorb.setType(Model.Type.STATISTICAL);

At this point, a printout of the XML structure displays the following:


  <mida:Type>Statistical</mida:Type>
</xml-fragment>

Somehow, XMLBeans thinks "midas" is the plural of "mida" and has helpfully 
dropped the S since I only have one of them.  But
that's not what I want!  Our suite of programs depends on the namespaces being propagated 
correctly, and "mida" clearly does
not equal "midas", resulting in a failed parse of the XML.

I am earnestly hoping that this is a simple configuration option that I am just 
not aware of; I would find it very
surprising if this were a bug.  I am basically a beginner at XSD schemas, so it 
is entirely possible I missed something. 
Nevertheless, it is a show-stopper preventing me from making forward progress.  
I have searched Google, the XMLBeans FAQ,
and the mailing list but have not found anything useful.  I am hopeful that 
this list will provide me with enlightenment. :)

Thanks,
Justin




--
Peter Keller                                     Tel.: +44 (0)1223 353033
Global Phasing Ltd.,                             Fax.: +44 (0)1223 366889
Sheraton House,
Castle Park,
Cambridge CB3 0AX
United Kingdom
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org
For additional commands, e-mail: user-h...@xmlbeans.apache.org

Reply via email to