users@jaxb.java.net

Re: NamespacePrefixMapper

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Sat, 14 Nov 2009 18:25:24 +0100

On Sat, Nov 14, 2009 at 5:20 PM, Roland Prähofer <rp_at_memeticdesign.de>wrote:

> Hello!
>
> I have a document with multiple schemas, it's a foxml document for the
> fedora commons document server.
>
> I've created JAXBinding classes with xjc for the foxml schema and
> added some classes for elements in a different namespaces.
> They're all in the same package.
>

Why? Usually the best strategy is to leave the Java classes in the package
that derives from the namespace.


> I'd like to marshall a document assembled in my application,
> so that the prefixes are as desired.
>
>
> I tried to add all the namespace/prefix mappings in the package-info.class:
>
> Of which package? If the foxml classes are compiled into a package, it's
best to leave them and package-info,java as they were generated.

If an element from a namespace other than foxml's is to be inserted
in a place where the foxml schema has xs:any, then is should be
marshalled according to its schema into a content tree, and this
should be inserted as as the object corresponding to the xs:any wildcard.
A second marshal of the foxml tree will include it in the final XML
document.

-W