title: How to set the namespace of marshalled xml using camel jaxb?
body: <p>For starters, I'm creating some routes using Camel ver 2.15 (in Fuse 6.2.1).</p>
  
  <p>In my route, i'm trying to create a XML from a pojo that was generated using cxf-xjc maven plugin (cxf-xjc read some xsd somewhere then from the xsd, the pojos with jaxb annotations were produced). </p>
  
  <p>The pojos are TempProject and TempProjects.</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(
  name = "",
  propOrder = {"ecode", "tempName"}
  )
  @XmlRootElement(
  name = "TempProject"
  )
  public class TempProject implements Serializable {
  @XmlElement(
      name = "Ecode",
      required = true
  )
  protected String ecode;
  @XmlElement(
      name = "TempName",
      required = true
  )
  protected String tempName;
  
  public TempProject() {
  }
  
  public String getEcode() {
      return this.ecode;
  }
  
  public void setEcode(String value) {
      this.ecode = value;
  }
  
  public String getTempName() {
      return this.tempName;
  }
  
  public void setTempName(String value) {
      this.tempName = value;
  }
  }
  
  
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(
  name = "",
  propOrder = {"tempProjects"}
  )
  @XmlRootElement(
  name = "TempProjects"
  )
  public class TempProjects implements Serializable {
  @XmlElement(
      name = "TempProject",
      required = true
  )
  protected List&lt;TempProject&gt; tempProjects;
  
  public TempProjects() {
  }
  
  public List&lt;TempProject&gt; getTempProjects() {
      if (this.tempProjects == null) {
          this.tempProjects = new ArrayList();
      }
  
      return this.tempProjects;
  }
  }
  </code></pre>
  
  <p>I can generate the xml using this code:</p>
  
  <pre><code> JAXBContext jaxbContext = JAXBContext.newInstance(new Class[]{TempProjects.class}); 
   jaxbContext.createMarshaller();
   JaxbDataFormat jaxbDataFormat = new JaxbDataFormat(jaxbContext); //import org.apache.camel.converter.jaxb.JaxbDataFormat;
  </code></pre>
  
  <p>I call</p>
  
  <pre><code>.marshal(jaxbDataFormat)
  </code></pre>
  
  <p>in my route to effect the marshalling from the pojo to xml.</p>
  
  <p>The generated xml is posted below:</p>
  
  <pre><code>&lt;TempProjects xmlns="http://blah.blah/foo/schema/v2"&gt;
  &lt;TempProject&gt;
      &lt;Ecode&gt;1&lt;/Ecode&gt;
      &lt;TempName&gt;Tempname1&lt;/TempName&gt;
  &lt;/TempProject&gt;
  &lt;TempProject&gt;
      &lt;Ecode&gt;2&lt;/Ecode&gt;
      &lt;TempName&gt;Tempname2&lt;/TempName&gt;
  &lt;/TempProject&gt;
  </code></pre>
  
  <p></p>
  
  <p>How can i generate a marshalled xml that will have a namespace like this...</p>
  
  <pre><code>&lt;TempProjects xmlns:myprefix="http://blah.blah/foo/schema/v2"&gt;
  </code></pre>
  
  <p>Reason being why I needed a namespaceprefix is because I plan to <em>split</em> the values (e.g. Ecode) in the xml using xpath and I needed a namespaceprefix to do that (thats what ive researched, i might be wrong). </p>
  
  <p>My planned code in my route is </p>
  
  <pre><code>.marshal(jaxbDataFormat)
  .split( xpath("/TempProjects/TempProject/Ecode/text()").namespaces(ns1), 
  new ProjectIdsAggregator()) //the above xpath doesn't work because it doesn't have a namespace prefix
  
  //Namespaces ns1 = new Namespaces("myprefix", "http://blah.blah/foo/schema/v2" );
  </code></pre>
  
  <p>I looked at jaxbDataFormat.setNamespacePrefixRef("myprefix"), but i got an error (<em>org.apache.camel.NoSuchBeanException: No bean could be found in the registry for: myprefix of type: java.util.Map</em>)</p>
  
  <p>I'm actually quite new in the apache camel routing world, so i might be missing some basic stuff. </p>