Hey Don,
I can't tell you why this happens, but I can suggest something to work around 
it.
On your XmlOptions try setting
setAggressiveNamespace()
and  setSaveNamespacesFirst 
<file:///H:/svn/xmlbeans/trunk/build/docs/reference/org/apache/xmlbeans/XmlOptions.html#setSaveNamespacesFirst%28%29>
 () 
Good Luck,
-Jacobd

        -----Original Message----- 
        From: Don Stewart [mailto:[EMAIL PROTECTED] 
        Sent: Mon 6/20/2005 9:26 AM 
        To: [email protected] 
        Cc: 
        Subject: Namespace question
        
        
        Hi,
         
        I'm getting an issue with namespaces that I cannot figure out. My 
schema (read customers) defines a namespace:-
         
        xmlns:dt="urn:bla/blabla/Assurance"

         

        Without any XmlOptions I get :-

        <ass:Parent>

            <ass:A/>

            <ass:Foo xmlns:ass="urn:bla/blabla/Assurance" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:type="ass:DetailedBla">

            </ass:Bla>

            <ass:B/>

        </ass:Parent>

         

        When I generate I set the XmlOptions with :-

                XmlOptions xmlOptions = new XmlOptions();
                xmlOptions.setSavePrettyPrintIndent(4);
                xmlOptions.setSavePrettyPrintOffset(4);
                xmlOptions.setSavePrettyPrint();
                xmlOptions.setLoadLineNumbers();
                Map namespaceMap = new HashMap();
                namespaceMap.put("dt", "urn:bla/blabla/Assurance");
                xmlOptions.setLoadSubstituteNamespaces(namespaceMap);
                xmlOptions.setSaveImplicitNamespaces(namespaceMap);

         

        The prefix changes to <dt:Foo>

        All except one inner block that starts as <ass: where the namespace is 
redefined to be the same.

        Now what differs in the generation is that Foo is a derived type so its 
actually a DetailedFoo which I create using the 
DetailedFoo.Factory.newInstance(xmlOptions) method passing in the same 
XmlOptions as above i.e. with the namespace mapping that worked for all the 
other tags. I then use a Parent.setFoo() method to add it to the Parent 
XmlObject. This is because Parent has only a setFoo() and not a 
Parent.setDetailedFoo().

        Can anyone tell me why I end up with :-

        <dt:Parent>

            <dt:A/>

            <ass:Foo xmlns:ass="urn:bla/blabla/Assurance" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:type="ass:DetailedFoo">

            </ass:Foo>

            <dt:B/>

        </dt:Parent>

         

        I realise that the redefinition of the element is causing it to be 
redined but why is this sub-element not subject to remapping the same as the 
other level. Anyone shed some light on this for me ??

         

        Many Thanks

         

        Don

Reply via email to