Skip to main content

JAXB: W3C spec XSD -> 2 different packages

1 reply [Last post]
lhazlewood
Offline
Joined: 2004-07-10
Points: 0

Hi JAXB gurus - I have an interesting challenge I hope someone can help out with.

I want to have xjc generate Java classes from the W3C specification for XML Encryption. That .xsd is located here:

http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/xenc-schema.xsd

Note that this .xsd additionally imports the W3C XML Digital Signature .xsd.

When I run xjc without any customization, it creates two packages based on the namespaces alone:

org.w3._2001._04.xmlenc_
org.w3._2000._09.xmldsig_

Which is great - just not what I want. I want to customize this so that the objects go in org.w3.xmlenc and org.w3.xmldsig packages respectively.

Also, because this is a W3C spec, I don't want to/can't touch the source .xsd files at all. I need to treat them as static/read-only. I'm putting my JAXB directives in a separate .xjb file.

How do I make this happen based on external .xjb customization files without touching the source .xsd files?

Thanks for any pointers!

Best,

Les

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vgarmash
Offline
Joined: 2005-09-23
Points: 0

You defenitely need to read this part of JAX-WS tutorial: http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/doc...

For you customization file should look like this:
[code]
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jxb:extensionBindingPrefixes="xjc" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
jxb:version="2.1">



generateIsSetMethod="true" fixedAttributeAsConstantProperty="true" />





schemaLocation="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"
node="/xs:schema">







[/code]

I haven't tested it but you should get the idea.