users@jaxb.java.net

Re: how to obtain namespace of the unmarshalled object?

From: Eric Ma <eric.ma_at_db.com>
Date: Tue, 15 Apr 2003 13:32:22 -0400

I basically stole the code from one of your examples and made a few changes:

public class Main {

   public static void main( String[] args ) {
        try {
           JAXBContext jc = JAXBContext.newInstance( "mypackage" );

            Unmarshaller u = jc.createUnmarshaller();

            MyType mt = (MyType)u.unmarshal( new FileInputStream( "myXml.xml" ) );

            Marshaller m = jc.createMarshaller();
            m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
            m.setProperty( "jaxb.schemaLocation", "myNamespace http://my.com");

            m.marshal( mt, new java.io.FileOutputStream("myXml_new.xml") );

        } catch( JAXBException je ) {
            je.printStackTrace();
        } catch( IOException ioe ) {
            ioe.printStackTrace();
        }
    }
}

Eric




                      Kohsuke Kawaguchi
                      <Kohsuke.Kawaguch To: JAXB-INTEREST_at_JAVA.SUN.COM
                      i_at_Sun.COM> cc:
                      Sent by: Subject: Re: how to obtain namespace of the unmarshalled object?
                      Discussion list
                      for the Java
                      Architecture for
                      XML Binding
                      <JAXB-INTEREST_at_JA
                      VA.SUN.COM>


                      04/15/03 12:51 PM
                      Please respond to
                      JAXB-INTEREST






Could you post the relevant part of the source code?

regards,
--
Kohsuke KAWAGUCHI                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
--
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.