Hello.

I am new to Castor and I am having some trouble
setting the default namespace when marshalling an
object.

Code and output follows. I am using Castor-0.9.9.1.

Can anyone shed some light on it?

Mauricio De Diana

Output:
<?xml version="1.0" encoding="UTF-8"?>
<person xmlns=""><name>NAME</name></person>

------------------------------------
CastorTest.java
public class CastorTest {

  public void test() {
    StringWriter sw = new StringWriter();
    try {
      Person p = new Person();
      p.setName("NAME");
      Marshaller marshaller = new Marshaller(sw);
        marshaller.setNamespaceMapping("",
"http://www.test.com.br/X";);
        marshaller.marshal(p);
      } catch (IOException e) {
      } catch (MarshalException e) {
      } catch (ValidationException e) {
      }
      System.out.println(sw.toString());
  }

  public static void main(String[] args) {
    new CastorTest().test();
  }
}

------------------------------------------
Person.java
public class Person {
  private String name;
  public String getName() { return name; }
  public void setName(String name) { this.name = name;
}
}


        



        
                
_______________________________________________________ 
Yahoo! doce lar. Faça do Yahoo! sua homepage. 
http://br.yahoo.com/homepageset.html 


-------------------------------------------------
If you wish to unsubscribe from this list, please 
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to