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;
}
Aggregations