users@jaxb.java.net

Re: Namespace Prefix

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 08 Oct 2004 13:33:43 -0700

Ringeman, Ken wrote:
> I have a schema that imports another schema in a different namespace.
> When I generate the code and marshal an object the result is similar to the
> following
>
> <ns1:level0 xmlns:ns1="//ns1">
> ....
> <ns2:level1 xmlns:ns2="//ns2">
> <ns2:level2>data</ns2:level2>
> </ns2:level1>
> ....
> </ns1:level0>
>
> Is there a way to get the following output?
>
> <ns1:level0 xmlns:ns1="//ns1">
> ....
> <ns2:level1 xmlns:ns2="//ns2">
> <level2>data</level2>
> </ns2:level1>
> ....
> </ns1:level0>
>
> where the level2 element is by default in the ns2 namespace.

Those two documents that you just described are different documents. If
the former is valid wrt your schema, the latter is most definitely
invalid (or vice versa)

Maybe you mean you want to generate:

  <ns1:level0 xmlns:ns1="//ns1">
  ....
      <level1 xmlns="//ns2">
          <level2>data</level2>
      </level1>
  ....
  </ns1:level0>

? If so, does NamespacePrefixMapper works? See the namespace-prefix
example in the distribution for details.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net