You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Justin Bailey <ju...@yahoo.com> on 2010/07/08 06:39:04 UTC

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



      

RE: XMLBeans does not correctly propagate namespaces

Posted by Paul Gillen <pa...@gmail.com>.
Seems like a poor idea for standards organizations to require that which is
technically arbitrary.  Which have done so?  Can you supply references?   

 =p=

 

From: Scott Hinkelman [mailto:scott.hinkelman@oracle.com] 
Sent: Friday, July 09, 2010 1:12 PM
To: user@xmlbeans.apache.org
Subject: RE: XMLBeans does not correctly propagate namespaces

 

Please be aware that while at the XML/namespace technology level prefixes
are technically arbitrary, from a higher business perspective several
standards organizations have standardized them associate with specific name
space names for consistency and some increase in interoperability.

 

Thanks,

Scott
---------------
Scott R. Hinkelman
Software Standards Architect
AIA Standards Architecture and Strategy
Oracle Corporation
Mobile:  512.415.8490

 

From: Duane Zamrok [mailto:zamrok@cubrc.org] 
Sent: Thursday, July 08, 2010 6:05 PM
To: user@xmlbeans.apache.org
Subject: RE: XMLBeans does not correctly propagate namespaces

 

None the less, if XMLBeans does not present a means by which to dictate the
namespaces (which I'm almost positive it does through the Dom Nodes) then
that is a shortcoming, if only small.

 

 

 

From: Wing Yew Poon [mailto:wing.yew.poon@oracle.com] 
Sent: Thursday, July 08, 2010 5:51 PM
To: user@xmlbeans.apache.org
Subject: RE: XMLBeans does not correctly propagate namespaces

 

Justin,

as Peter has clearly explained, prefixes are arbitrary; they are not what is
important; namespaces are what matters.

It appears that some people are hung up over the prefixes that get used to
represent the namespaces ("the correct namespace prefix"). If your (or your
customer's) code relies on some fixed prefixes, then, as Geir wrote, "I am
afraid you may be in deep shit." That deep shit is not the fault of
XMLBeans; it is the fault of bad code/software.

- Wing Yew

 

  _____  

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

Follow-up...

After some more searching, I found this thread which seems to describe
exactly what the problem is:
http://www.opensubscriber.com/message/user@xmlbeans.apache.org/1601039.html

So it looks like this is a deficiency in XMLBeans, which is very
disappointing. :(  Anyway, I have resolved the issue by adding a regular
expression parser which inspects the prefix that XMLBeans assigns to the
namespace, then replaces it with the expected prefix.  It's not what I would
have preferred, but it does solve the problem.

Thanks to the people who were kind enough to reply and provide assistance.
I remain hopeful that this functionality will be added to XMLBeans in the
future, since XMLBeans is in all other respects a very good library.

Thanks,
Justin

 


RE: XMLBeans does not correctly propagate namespaces

Posted by Ge...@dnv.com.
Scott,
 
>From a standard organization perspective defining XML schemas it is a "best practice" to consistently use the same prefix for a specific namespace across the full schema domain of the standard organization. This practice increase human readability of the XML schemas and sometimes xml documents conforming to the schemas.
 
However:
 
This practice is really for information only intended for us dumb humans and not for code processing the xml documents.
 
If a standard organization requires that a specific prefix SHALL be used to represent a specific namespace in xml documents based on the XML Schemas of the organization a solid foundation for non-interoperability is created. In principle the practice moves the semantic content of the namespace from the namespace to the prefix i.e. a misuse the namespace concept altogether.
 
Namespaces can easily be created in a globally unique manner, prefixes can not.  
Basic XML Schemas from various organisations are very often used as components when building new higher level business oriented XML Schemas.
If one requires that a specific prefix shall be used it is difficult to avoid clashes between prefixes. It is the namespace that shall resolve such clashes not the prefix.  
 
Scott,
Can you please provide examples of standard organisations (and standards) that standardize use of prefixes beyond human readability ?
Med vennlig hilsen / Best regards, 
for Det Norske Veritas AS
Geir Øvsttun 
_______________________________

Principal Information Architect 
Division Sustainability & Innovation

Web: www.dnv.com <http://www.dnv.com/> 


________________________________

From: Scott Hinkelman [mailto:scott.hinkelman@oracle.com] 
Sent: 9. juli 2010 13:12
To: user@xmlbeans.apache.org
Subject: RE: XMLBeans does not correctly propagate namespaces



Please be aware that while at the XML/namespace technology level prefixes are technically arbitrary, from a higher business perspective several standards organizations have standardized them associate with specific name space names for consistency and some increase in interoperability.

 

Thanks,

Scott
---------------
Scott R. Hinkelman
Software Standards Architect
AIA Standards Architecture and Strategy
Oracle Corporation
Mobile:  512.415.8490



 

From: Duane Zamrok [mailto:zamrok@cubrc.org] 
Sent: Thursday, July 08, 2010 6:05 PM
To: user@xmlbeans.apache.org
Subject: RE: XMLBeans does not correctly propagate namespaces

 

None the less, if XMLBeans does not present a means by which to dictate the namespaces (which I'm almost positive it does through the Dom Nodes) then that is a shortcoming, if only small.

 

 

 

From: Wing Yew Poon [mailto:wing.yew.poon@oracle.com] 
Sent: Thursday, July 08, 2010 5:51 PM
To: user@xmlbeans.apache.org
Subject: RE: XMLBeans does not correctly propagate namespaces

 

Justin,

as Peter has clearly explained, prefixes are arbitrary; they are not what is important; namespaces are what matters.

It appears that some people are hung up over the prefixes that get used to represent the namespaces ("the correct namespace prefix"). If your (or your customer's) code relies on some fixed prefixes, then, as Geir wrote, "I am afraid you may be in deep shit." That deep shit is not the fault of XMLBeans; it is the fault of bad code/software.

- Wing Yew

 

________________________________

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

Follow-up...

After some more searching, I found this thread which seems to describe exactly what the problem is:
http://www.opensubscriber.com/message/user@xmlbeans.apache.org/1601039.html

So it looks like this is a deficiency in XMLBeans, which is very disappointing. :(  Anyway, I have resolved the issue by adding a regular expression parser which inspects the prefix that XMLBeans assigns to the namespace, then replaces it with the expected prefix.  It's not what I would have preferred, but it does solve the problem.

Thanks to the people who were kind enough to reply and provide assistance.  I remain hopeful that this functionality will be added to XMLBeans in the future, since XMLBeans is in all other respects a very good library.

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.**************************************************************************************


RE: XMLBeans does not correctly propagate namespaces

Posted by Scott Hinkelman <sc...@oracle.com>.
Please be aware that while at the XML/namespace technology level prefixes are technically arbitrary, from a higher business perspective several standards organizations have standardized them associate with specific name space names for consistency and some increase in interoperability.

 

Thanks,

Scott
---------------
Scott R. Hinkelman
Software Standards Architect
AIA Standards Architecture and Strategy
Oracle Corporation
Mobile:  512.415.8490



 

From: Duane Zamrok [mailto:zamrok@cubrc.org] 
Sent: Thursday, July 08, 2010 6:05 PM
To: user@xmlbeans.apache.org
Subject: RE: XMLBeans does not correctly propagate namespaces

 

None the less, if XMLBeans does not present a means by which to dictate the namespaces (which I'm almost positive it does through the Dom Nodes) then that is a shortcoming, if only small.

 

 

 

From: Wing Yew Poon [mailto:wing.yew.poon@oracle.com] 
Sent: Thursday, July 08, 2010 5:51 PM
To: user@xmlbeans.apache.org
Subject: RE: XMLBeans does not correctly propagate namespaces

 

Justin,

as Peter has clearly explained, prefixes are arbitrary; they are not what is important; namespaces are what matters.

It appears that some people are hung up over the prefixes that get used to represent the namespaces ("the correct namespace prefix"). If your (or your customer's) code relies on some fixed prefixes, then, as Geir wrote, "I am afraid you may be in deep shit." That deep shit is not the fault of XMLBeans; it is the fault of bad code/software.

- Wing Yew

 

  _____  

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

Follow-up...

After some more searching, I found this thread which seems to describe exactly what the problem is:
http://www.opensubscriber.com/message/user@xmlbeans.apache.org/1601039.html

So it looks like this is a deficiency in XMLBeans, which is very disappointing. :(  Anyway, I have resolved the issue by adding a regular expression parser which inspects the prefix that XMLBeans assigns to the namespace, then replaces it with the expected prefix.  It's not what I would have preferred, but it does solve the problem.

Thanks to the people who were kind enough to reply and provide assistance.  I remain hopeful that this functionality will be added to XMLBeans in the future, since XMLBeans is in all other respects a very good library.

Thanks,
Justin

 

RE: XMLBeans does not correctly propagate namespaces

Posted by Duane Zamrok <za...@cubrc.org>.
None the less, if XMLBeans does not present a means by which to dictate the namespaces (which I'm almost positive it does through the Dom Nodes) then that is a shortcoming, if only small.



From: Wing Yew Poon [mailto:wing.yew.poon@oracle.com]
Sent: Thursday, July 08, 2010 5:51 PM
To: user@xmlbeans.apache.org
Subject: RE: XMLBeans does not correctly propagate namespaces

Justin,
as Peter has clearly explained, prefixes are arbitrary; they are not what is important; namespaces are what matters.
It appears that some people are hung up over the prefixes that get used to represent the namespaces ("the correct namespace prefix"). If your (or your customer's) code relies on some fixed prefixes, then, as Geir wrote, "I am afraid you may be in deep shit." That deep shit is not the fault of XMLBeans; it is the fault of bad code/software.
- Wing Yew

________________________________
From: Justin Bailey [mailto:justinbailey85@yahoo.com]
Sent: Thursday, July 08, 2010 2:08 PM
To: user@xmlbeans.apache.org
Subject: Re: XMLBeans does not correctly propagate namespaces
Follow-up...

After some more searching, I found this thread which seems to describe exactly what the problem is:
http://www.opensubscriber.com/message/user@xmlbeans.apache.org/1601039.html

So it looks like this is a deficiency in XMLBeans, which is very disappointing. :(  Anyway, I have resolved the issue by adding a regular expression parser which inspects the prefix that XMLBeans assigns to the namespace, then replaces it with the expected prefix.  It's not what I would have preferred, but it does solve the problem.

Thanks to the people who were kind enough to reply and provide assistance.  I remain hopeful that this functionality will be added to XMLBeans in the future, since XMLBeans is in all other respects a very good library.

Thanks,
Justin


RE: XMLBeans does not correctly propagate namespaces

Posted by Wing Yew Poon <wi...@oracle.com>.
Justin,
as Peter has clearly explained, prefixes are arbitrary; they are not what is important; namespaces are what matters.
It appears that some people are hung up over the prefixes that get used to represent the namespaces ("the correct namespace prefix"). If your (or your customer's) code relies on some fixed prefixes, then, as Geir wrote, "I am afraid you may be in deep shit." That deep shit is not the fault of XMLBeans; it is the fault of bad code/software.
- Wing Yew

  _____  

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


Follow-up...

After some more searching, I found this thread which seems to describe exactly what the problem is:
http://www.opensubscriber.com/message/user@xmlbeans.apache.org/1601039.html

So it looks like this is a deficiency in XMLBeans, which is very disappointing. :(  Anyway, I have resolved the issue by adding a regular expression parser which inspects the prefix that XMLBeans assigns to the namespace, then replaces it with the expected prefix.  It's not what I would have preferred, but it does solve the problem.

Thanks to the people who were kind enough to reply and provide assistance.  I remain hopeful that this functionality will be added to XMLBeans in the future, since XMLBeans is in all other respects a very good library.

Thanks,
Justin


Re: XMLBeans does not correctly propagate namespaces

Posted by Justin Bailey <ju...@yahoo.com>.
Follow-up...

After some more searching, I found this thread which seems to describe exactly 
what the problem is:
http://www.opensubscriber.com/message/user@xmlbeans.apache.org/1601039.html

So it looks like this is a deficiency in XMLBeans, which is very disappointing. 
:(  Anyway, I have resolved the issue by adding a regular expression parser 
which inspects the prefix that XMLBeans assigns to the namespace, then replaces 
it with the expected prefix.  It's not what I would have preferred, but it does 
solve the problem.

Thanks to the people who were kind enough to reply and provide assistance.  I 
remain hopeful that this functionality will be added to XMLBeans in the future, 
since XMLBeans is in all other respects a very good library.

Thanks,
Justin



      

Re: XMLBeans does not correctly propagate namespaces

Posted by Justin Bailey <ju...@yahoo.com>.
Hi Duane,

Thanks for your email.  I should clarify that what I posted was only a fragment 
of the entire XSD schema, containing only the parts pertaining to my question.  
If I had pasted the entire XSD, it would have been far too long and IMHO would 
have contributed to a high noise-to-signal ratio.  Rest assured that what I sent 
to the customer was a full XML document, not a fragment.  As I said in one of my 
previous posts, doing a simple textual replace of xml:mida to xml:midas allowed 
them to parse the document correctly.

To provide an update, Peter's suggestion of XmlOptions seems to be on the right 
track: it results in the XML fragments being displayed with the correct 
namespace prefix.  But despite working on the XML fragments, it does not seem to 
work on the full XML document.  The method is called 
"setSaveSuggestedPrefixes"... could it be refusing my "suggestion"? :(

Justin





________________________________
From: Duane Zamrok <za...@cubrc.org>
To: "user@xmlbeans.apache.org" <us...@xmlbeans.apache.org>
Sent: Thu, July 8, 2010 2:48:26 PM
Subject: RE: XMLBeans does not correctly propagate namespaces

  
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:justinbailey85@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


      

RE: XMLBeans does not correctly propagate namespaces

Posted by Duane Zamrok <za...@cubrc.org>.
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:justinbailey85@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


Re: XMLBeans does not correctly propagate namespaces

Posted by Justin Bailey <ju...@yahoo.com>.
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


      

Re: XMLBeans does not correctly propagate namespaces

Posted by Peter Keller <pk...@globalphasing.com>.
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

RE: XMLBeans does not correctly propagate namespaces

Posted by Ge...@dnv.com.
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:justinbailey85@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.**************************************************************************************