<faqs id="FAQ" title="Frequently Asked Questions">
    <part id="XJC">
        <title>XJC</title>
        <faq id="Multiple">
            <question>I have different schemas and want different packages for those schemas, how do I do this?</question>
            <answer>
                <p>You want to create multiple executions in your plugin declaration. This will allow you
                to have multiple configuration declarations and you can specify the schema and package to
                be used for that execution. Note that you will need to <em>not</em> clear the output
                directory between executions in this case.</p>

                <p>An example is given on the XJC usage page.</p>
            </answer>
        </faq>
    </part>

    <part id="Schemagen">
        <title>Schemagen</title>
        <faq id="Tooling">
            <question>What tool is used by the jaxb2-maven-plugin to generate the XML schema definition files?</question>
            <answer>
                <p>The <em>schemagen</em> tool used by the plugin is part of the JDK distribution since Java 6.</p>

                <p>The jaxb2-maven-plugin provides some augmentations to the generated schema files, such
                as the ability to define a schema prefix and filename for each generated XML schema.</p>
            </answer>
        </faq>
        <faq id="LogMessages">
            <question>How can I see the log messages output by the schemagen tool?</question>
            <answer>
                <p>Run the jaxb2-maven-plugin in debug mode to see logging from the schemagen tool.
                Please refer to the examples for further information.</p>
            </answer>
        </faq>
        <faq id="SeveralGeneratedSchemaFiles">
            <question>How do generated XML schema files correlate to annotated java files?</question>
            <answer>
                <p>The schemagen tool generates one XML schema file <em>per XML namespace</em> it finds within
                the compilation unit (i.e. all annotated Java files selected for XML schema compilation).</p>

                <p>The correlation between java files and generated XML schema files is therefore only indirect;
                a single generated XML schema file can hold the result of annotations within several java files - and
                a single annotated java source file can give rise to definitions scattered over several XML
                schema files.</p>

                 <p>An example is given on the usage page for the schemagen goal.</p>
            </answer>
        </faq>
        <faq id="SchemagenEmptyNamespacePrefix">
            <question>Can I generate XSDs without a namespace prefix on the target namespace?</question>
            <answer>
                <p>The 2.x line of the Jaxb2-Maven-Plugin requires the namespaceURI to relate to at least one
                non-empty value out of the two properties below. Hence, at least one of these values must be
                provided and given a non-empty value:</p>
                <ol>
                    <li>prefix</li>
                    <li>toFile</li>
                </ol>
            </answer>
        </faq>
        <faq id="SchemaGenWhitespace">
                    <question>When I try to generate Schema and any path contain whitespace, I get an
                    Exception</question>
                    <answer>
                        <p>This seems to be caused by internal implementation issues within the SchemaGen tool.
                        The current workaround is to use a path without whitespace.</p>
                    </answer>
                </faq>
        <faq id="Example">
            <question>How can I annotate my java classes to generate XML schema?</question>
            <answer>
                <p>For the full example (including generated XML Schema definitions), please refer to the
                schemagen usage page. Provided below are screenshots of two annotated source files, and a
                constants definition interface.</p>

                <p><strong>Namespaces definition interface</strong>. Simply defines constants for the
                three namespaces used within the two classes below. <br/>
                <source>package se.west.schema;

public interface Namespaces {

    public static final String SOME_NAMESPACE = "http://some/namespace";
    public static final String ANOTHER_NAMESPACE = "http://another/namespace";
    public static final String YET_ANOTHER_NAMESPACE = "http://yet/another/namespace";
}</source></p>

                <p><strong>Class FooBar</strong>. By default, all members are compiled to XML schema with
                 the namespace "http://some/namespace", as defined by the namespace attribute within
                the <code>@XmlType</code> annotation on line 9. The <code>aRequiredElementInAnotherNamespace</code>
                member belongs to the namespace "http://another/namespace", as defined on line 18.
                <br/>
                <source>package se.west.schema;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

@XmlType(namespace = Namespaces.SOME_NAMESPACE,
        propOrder = {"requiredElement", "aRequiredElementInAnotherNamespace",
                "optionalElement", "requiredAttribute", "optionalAttribute"})
@XmlAccessorType(XmlAccessType.FIELD)
public class FooBar {

    @XmlElement(required = true, defaultValue = "requiredElementValue")
    private String requiredElement;

    @XmlElement(namespace = Namespaces.ANOTHER_NAMESPACE, required = true, defaultValue = "requiredElementValue")
    private String aRequiredElementInAnotherNamespace;

    @XmlElement(required = false)
    private String optionalElement;

    @XmlAttribute(required = true)
    private String requiredAttribute;

    @XmlAttribute(required = false)
    private String optionalAttribute;
}</source>
                </p>

                <p><strong>Class FooBaz</strong>. By default, all members are compiled to XML schema with
                 the namespace "http://another/namespace", as defined by the namespace attribute within
                the <code>@XmlType</code> annotation on line 9. The <code>aRequiredElementInYetAnotherNamespace</code>
                member belongs to the namespace "http://yet/another/namespace", as defined on line 18. The
                <code>anOptionalElementInSomeNamespace</code> member belongs to the namespace "http://some/namespace",
                as defined on line 21.
                <br/>

                <source>package se.west.schema;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

@XmlType(namespace = Namespaces.ANOTHER_NAMESPACE,
        propOrder = {"requiredElement", "anOptionalElementInSomeNamespace",
                "aRequiredElementInYetAnotherNamespace", "requiredAttribute", "optionalAttribute"})
@XmlAccessorType(XmlAccessType.FIELD)
public class FooBaz {

    @XmlElement(required = true, defaultValue = "requiredElementValue")
    private String requiredElement;

    @XmlElement(namespace = Namespaces.YET_ANOTHER_NAMESPACE, required = true, defaultValue = "requiredElementValue")
    private String aRequiredElementInYetAnotherNamespace;

    @XmlElement(namespace = Namespaces.SOME_NAMESPACE, required = false)
    private String anOptionalElementInSomeNamespace;

    @XmlAttribute(required = true)
    private String requiredAttribute;

    @XmlAttribute(required = false)
    private String optionalAttribute;
}</source></p>
            </answer>
        </faq>
    </part>
</faqs>
