You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Lea Anne Dobbins <la...@raytheon.com> on 2005/02/11 23:23:39 UTC
Undesirable Namespace Prefixes
OK, I've got a good one here ...
I have 3 schemas that all define types in the same namespace, but define
it as the default namespace with no prefix. All three schemas start with
this schema definition:
<xsd:schema targetNamespace="parser.xml.server.mm.stss.rsc.com"
elementFormDefault="qualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="parser.xml.server.mm.stss.rsc.com">
I created my XMLBeans classes using 1.0.3. I then wrote some code to
generate 2 of the documents from 2 of the schemas. They use an
instantiation of the third as input. The input document was being
generated the "old fashioned" way, with a DOM parser.
I then decided to re-write the generation of the input document using
XMLBeans, since I had all the classes already generated. However, I'm
getting an arbitrary namespace prefix on all my tags!
I'm using the same method to generate all 3 documents - just
xmlDoc.toString(); Why would two of the documents come out with a default
namespace declaration, and the third with an arbitrary prefix? This has
me baffled ...
Here's what XMLBeans generates for the documents that are OK:
<TaskCompletionStatus xmlns="parser.xml.server.mm.stss.rsc.com">
.
.
.
</TaskCompletionStatus>
Here's what I'm getting for my "input" document:
<par:MissionSchedule xmlns:par="parser.xml.server.mm.stss.rsc.com">
.
.
.
</par:MissionSchedule>
I want them both to have the same default namespace declaration!
I tried doing the setUseDefaultNamespace() and the
setSaveAggresiveNamespaces(), and I tried mapping the
"parser.xml.server.mm.stss.rsc.com" to "" as well, using a hashmap and the
setSaveSuggestedPrefixes(names) option. I used the xmlText(opts) to
create the string.
It gets even more interesting ... I read in the document with all the
"par:" prefixes, and generated documents without...
Does anybody have any ideas? This output document cannot have any
prefixes on it - my customer isn't using xmlbeans. I'm about to switch
back to the "old fashioned" method if I can't get it to work.
--------------------------------------------------------
Lea Anne Dobbins
ladobbins@raytheon.com
720-858-5409