Search in sources :

Example 1 with XmlNsForm

use of org.eclipse.persistence.jaxb.xmlmodel.XmlNsForm in project eclipselink by eclipse-ee4j.

the class XMLProcessor method processXmlSchema.

/**
 * Process an XmlSchema. This involves creating a NamespaceInfo instance and
 * populating it based on the given XmlSchema.
 *
 * @see NamespaceInfo
 * @see AnnotationsProcessor
 * @return newly created namespace info, or null if schema is null
 */
private NamespaceInfo processXmlSchema(XmlBindings xmlBindings, String packageName) {
    XmlSchema schema = xmlBindings.getXmlSchema();
    if (schema == null) {
        return null;
    }
    // create NamespaceInfo
    NamespaceInfo nsInfo = this.aProcessor.findInfoForNamespace(schema.getNamespace());
    if (nsInfo == null) {
        nsInfo = new NamespaceInfo();
    }
    // process XmlSchema
    XmlNsForm form = schema.getAttributeFormDefault();
    nsInfo.setAttributeFormQualified(form.equals(XmlNsForm.QUALIFIED));
    form = schema.getElementFormDefault();
    nsInfo.setElementFormQualified(form.equals(XmlNsForm.QUALIFIED));
    if (!nsInfo.isElementFormQualified() || nsInfo.isAttributeFormQualified()) {
        aProcessor.setDefaultNamespaceAllowed(false);
    }
    // make sure defaults are set, not null
    nsInfo.setLocation(schema.getLocation() == null ? GENERATE : schema.getLocation());
    String namespace = schema.getNamespace();
    if (namespace == null) {
        namespace = this.aProcessor.getDefaultTargetNamespace();
    }
    nsInfo.setNamespace(namespace == null ? "" : schema.getNamespace());
    NamespaceResolver nsr = new NamespaceResolver();
    // process XmlNs
    for (XmlNs xmlns : schema.getXmlNs()) {
        nsr.put(xmlns.getPrefix(), xmlns.getNamespaceUri());
    }
    nsInfo.setNamespaceResolver(nsr);
    return nsInfo;
}
Also used : XmlSchema(org.eclipse.persistence.jaxb.xmlmodel.XmlSchema) XmlNsForm(org.eclipse.persistence.jaxb.xmlmodel.XmlNsForm) XmlNs(org.eclipse.persistence.jaxb.xmlmodel.XmlSchema.XmlNs) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver)

Aggregations

XmlNsForm (org.eclipse.persistence.jaxb.xmlmodel.XmlNsForm)1 XmlSchema (org.eclipse.persistence.jaxb.xmlmodel.XmlSchema)1 XmlNs (org.eclipse.persistence.jaxb.xmlmodel.XmlSchema.XmlNs)1 NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)1