Hi Justin,
 
I am afraid that you maybe have missed a key aspect of using namespaces in xml
 
It is perfectly legal for midas to be changed to mida as midas or mida is just 
a prefix (shorthand) for a namespace.
What is important is that the prefix is associated with the same namespace.
So prefixes can change while associated namespaces are stable.
 
When XML information is passed between systems the actual prefix is allowed to 
change as long as the prefix (whatever it is called) has the correct 
association.
 
If your code base rely on stable prefixes I am afraid you may be in deep shit.
It is not stable prefixes but stable namespaces you want.
 
This is a common mistake concerning namespaces.
XMLBeans is doing something perfectly legal.
If your code cannot handle legal xml well....
 
/Geir
 

________________________________

From: Justin Bailey [mailto:justinbaile...@yahoo.com] 
Sent: 8. juli 2010 06:39
To: user@xmlbeans.apache.org
Subject: XMLBeans does not correctly propagate namespaces


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




**************************************************************************************The
 contents of this e-mail message and any attachments are confidential and are 
intended solely for the addressee. If you have received this transmission in 
error, please immediately notify the sender by return e-mail and delete this 
message and its attachments. Any unauthorized use, copying or dissemination of 
this transmission is prohibited. Neither the confidentiality nor the integrity 
of this message can be vouched for following transmission on the 
Internet.**************************************************************************************

Reply via email to