org.eclipse.xsd.impl.XSDSchemaImpl Maven / Gradle / Ivy
/**
* Copyright (c) 2002-2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* IBM - Initial API and implementation
*/
package org.eclipse.xsd.impl;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.StringTokenizer;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.EventTarget;
import org.w3c.dom.events.MutationEvent;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.UniqueEList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.xsd.XSDAnnotation;
import org.eclipse.xsd.XSDAttributeDeclaration;
import org.eclipse.xsd.XSDAttributeGroupDefinition;
import org.eclipse.xsd.XSDComplexTypeDefinition;
import org.eclipse.xsd.XSDComponent;
import org.eclipse.xsd.XSDConcreteComponent;
import org.eclipse.xsd.XSDDiagnostic;
import org.eclipse.xsd.XSDDiagnosticSeverity;
import org.eclipse.xsd.XSDDisallowedSubstitutions;
import org.eclipse.xsd.XSDElementDeclaration;
import org.eclipse.xsd.XSDFactory;
import org.eclipse.xsd.XSDForm;
import org.eclipse.xsd.XSDIdentityConstraintDefinition;
import org.eclipse.xsd.XSDImport;
import org.eclipse.xsd.XSDInclude;
import org.eclipse.xsd.XSDModelGroupDefinition;
import org.eclipse.xsd.XSDNamedComponent;
import org.eclipse.xsd.XSDNotationDeclaration;
import org.eclipse.xsd.XSDPackage;
import org.eclipse.xsd.XSDPlugin;
import org.eclipse.xsd.XSDProhibitedSubstitutions;
import org.eclipse.xsd.XSDRedefine;
import org.eclipse.xsd.XSDRedefineContent;
import org.eclipse.xsd.XSDSchema;
import org.eclipse.xsd.XSDSchemaCompositor;
import org.eclipse.xsd.XSDSchemaContent;
import org.eclipse.xsd.XSDSchemaDirective;
import org.eclipse.xsd.XSDSimpleTypeDefinition;
import org.eclipse.xsd.XSDTypeDefinition;
import org.eclipse.xsd.util.XSDConstants;
import org.eclipse.xsd.util.XSDParser;
import org.eclipse.xsd.util.XSDResourceFactoryImpl;
import org.eclipse.xsd.util.XSDResourceImpl;
import org.eclipse.xsd.util.XSDSwitch;
/**
*
* An implementation of the model object 'Schema'.
*
*
* The following features are implemented:
*
*
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getDocument Document}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getSchemaLocation Schema Location}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getTargetNamespace Target Namespace}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getAttributeFormDefault Attribute Form Default}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getElementFormDefault Element Form Default}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getFinalDefault Final Default}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getBlockDefault Block Default}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getVersion Version}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getContents Contents}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getElementDeclarations Element Declarations}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getAttributeDeclarations Attribute Declarations}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getAttributeGroupDefinitions Attribute Group Definitions}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getTypeDefinitions Type Definitions}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getModelGroupDefinitions Model Group Definitions}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getIdentityConstraintDefinitions Identity Constraint Definitions}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getNotationDeclarations Notation Declarations}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getAnnotations Annotations}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getAllDiagnostics All Diagnostics}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getReferencingDirectives Referencing Directives}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getRootVersion Root Version}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getOriginalVersion Original Version}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getIncorporatedVersions Incorporated Versions}
* - {@link org.eclipse.xsd.impl.XSDSchemaImpl#getSchemaForSchema Schema For Schema}
*
*
* @generated
*/
public class XSDSchemaImpl
extends XSDScopeImpl
implements XSDSchema
{
/**
* The default value of the '{@link #getDocument() Document}' attribute.
*
*
* @see #getDocument()
* @generated
* @ordered
*/
protected static final Document DOCUMENT_EDEFAULT = null;
/**
* The cached value of the '{@link #getDocument() Document}' attribute.
*
*
* @see #getDocument()
* @generated
* @ordered
*/
protected Document document = DOCUMENT_EDEFAULT;
/**
* The default value of the '{@link #getSchemaLocation() Schema Location}' attribute.
*
*
* @see #getSchemaLocation()
* @generated
* @ordered
*/
protected static final String SCHEMA_LOCATION_EDEFAULT = null;
/**
* The cached value of the '{@link #getSchemaLocation() Schema Location}' attribute.
*
*
* @see #getSchemaLocation()
* @generated
* @ordered
*/
protected String schemaLocation = SCHEMA_LOCATION_EDEFAULT;
/**
* The default value of the '{@link #getTargetNamespace() Target Namespace}' attribute.
*
*
* @see #getTargetNamespace()
* @generated
* @ordered
*/
protected static final String TARGET_NAMESPACE_EDEFAULT = null;
/**
* The cached value of the '{@link #getTargetNamespace() Target Namespace}' attribute.
*
*
* @see #getTargetNamespace()
* @generated
* @ordered
*/
protected String targetNamespace = TARGET_NAMESPACE_EDEFAULT;
/**
* The default value of the '{@link #getAttributeFormDefault() Attribute Form Default}' attribute.
*
*
* @see #getAttributeFormDefault()
* @generated
* @ordered
*/
protected static final XSDForm ATTRIBUTE_FORM_DEFAULT_EDEFAULT = XSDForm.UNQUALIFIED_LITERAL;
/**
* The offset of the flags representing the value of the '{@link #getAttributeFormDefault() Attribute Form Default}' attribute.
*
*
* @generated
* @ordered
*/
protected static final int ATTRIBUTE_FORM_DEFAULT_EFLAG_OFFSET = 8;
/**
* The flags representing the default value of the '{@link #getAttributeFormDefault() Attribute Form Default}' attribute.
*
*
* @generated
* @ordered
*/
protected static final int ATTRIBUTE_FORM_DEFAULT_EFLAG_DEFAULT = ATTRIBUTE_FORM_DEFAULT_EDEFAULT.ordinal() << ATTRIBUTE_FORM_DEFAULT_EFLAG_OFFSET;
/**
* The array of enumeration values for '{@link XSDForm Form}'
*
*
* @generated
* @ordered
*/
private static final XSDForm[] ATTRIBUTE_FORM_DEFAULT_EFLAG_VALUES = XSDForm.values();
/**
* The flag representing the value of the '{@link #getAttributeFormDefault() Attribute Form Default}' attribute.
*
*
* @see #getAttributeFormDefault()
* @generated
* @ordered
*/
protected static final int ATTRIBUTE_FORM_DEFAULT_EFLAG = 1 << ATTRIBUTE_FORM_DEFAULT_EFLAG_OFFSET;
/**
* The flag representing whether the Attribute Form Default attribute has been set.
*
*
* @generated
* @ordered
*/
protected static final int ATTRIBUTE_FORM_DEFAULT_ESETFLAG = 1 << 9;
/**
* The default value of the '{@link #getElementFormDefault() Element Form Default}' attribute.
*
*
* @see #getElementFormDefault()
* @generated
* @ordered
*/
protected static final XSDForm ELEMENT_FORM_DEFAULT_EDEFAULT = XSDForm.UNQUALIFIED_LITERAL;
/**
* The offset of the flags representing the value of the '{@link #getElementFormDefault() Element Form Default}' attribute.
*
*
* @generated
* @ordered
*/
protected static final int ELEMENT_FORM_DEFAULT_EFLAG_OFFSET = 10;
/**
* The flags representing the default value of the '{@link #getElementFormDefault() Element Form Default}' attribute.
*
*
* @generated
* @ordered
*/
protected static final int ELEMENT_FORM_DEFAULT_EFLAG_DEFAULT = ELEMENT_FORM_DEFAULT_EDEFAULT.ordinal() << ELEMENT_FORM_DEFAULT_EFLAG_OFFSET;
/**
* The array of enumeration values for '{@link XSDForm Form}'
*
*
* @generated
* @ordered
*/
private static final XSDForm[] ELEMENT_FORM_DEFAULT_EFLAG_VALUES = XSDForm.values();
/**
* The flag representing the value of the '{@link #getElementFormDefault() Element Form Default}' attribute.
*
*
* @see #getElementFormDefault()
* @generated
* @ordered
*/
protected static final int ELEMENT_FORM_DEFAULT_EFLAG = 1 << ELEMENT_FORM_DEFAULT_EFLAG_OFFSET;
/**
* The flag representing whether the Element Form Default attribute has been set.
*
*
* @generated
* @ordered
*/
protected static final int ELEMENT_FORM_DEFAULT_ESETFLAG = 1 << 11;
/**
* The cached value of the '{@link #getFinalDefault() Final Default}' attribute list.
*
*
* @see #getFinalDefault()
* @generated
* @ordered
*/
protected EList finalDefault;
/**
* The cached value of the '{@link #getBlockDefault() Block Default}' attribute list.
*
*
* @see #getBlockDefault()
* @generated
* @ordered
*/
protected EList blockDefault;
/**
* The default value of the '{@link #getVersion() Version}' attribute.
*
*
* @see #getVersion()
* @generated
* @ordered
*/
protected static final String VERSION_EDEFAULT = null;
/**
* The cached value of the '{@link #getVersion() Version}' attribute.
*
*
* @see #getVersion()
* @generated
* @ordered
*/
protected String version = VERSION_EDEFAULT;
/**
* The cached value of the '{@link #getContents() Contents}' containment reference list.
*
*
* @see #getContents()
* @generated
* @ordered
*/
protected EList contents;
/**
* The cached value of the '{@link #getElementDeclarations() Element Declarations}' reference list.
*
*
* @see #getElementDeclarations()
* @generated
* @ordered
*/
protected EList elementDeclarations;
/**
* The cached value of the '{@link #getAttributeDeclarations() Attribute Declarations}' reference list.
*
*
* @see #getAttributeDeclarations()
* @generated
* @ordered
*/
protected EList attributeDeclarations;
/**
* The cached value of the '{@link #getAttributeGroupDefinitions() Attribute Group Definitions}' reference list.
*
*
* @see #getAttributeGroupDefinitions()
* @generated
* @ordered
*/
protected EList attributeGroupDefinitions;
/**
* The cached value of the '{@link #getTypeDefinitions() Type Definitions}' reference list.
*
*
* @see #getTypeDefinitions()
* @generated
* @ordered
*/
protected EList typeDefinitions;
/**
* The cached value of the '{@link #getModelGroupDefinitions() Model Group Definitions}' reference list.
*
*
* @see #getModelGroupDefinitions()
* @generated
* @ordered
*/
protected EList modelGroupDefinitions;
/**
* The cached value of the '{@link #getIdentityConstraintDefinitions() Identity Constraint Definitions}' reference list.
*
*
* @see #getIdentityConstraintDefinitions()
* @generated
* @ordered
*/
protected EList identityConstraintDefinitions;
/**
* The cached value of the '{@link #getNotationDeclarations() Notation Declarations}' reference list.
*
*
* @see #getNotationDeclarations()
* @generated
* @ordered
*/
protected EList notationDeclarations;
/**
* The cached value of the '{@link #getAnnotations() Annotations}' reference list.
*
*
* @see #getAnnotations()
* @generated
* @ordered
*/
protected EList annotations;
/**
* The cached value of the '{@link #getAllDiagnostics() All Diagnostics}' reference list.
*
*
* @see #getAllDiagnostics()
* @generated
* @ordered
*/
protected EList allDiagnostics;
/**
* The cached value of the '{@link #getReferencingDirectives() Referencing Directives}' reference list.
*
*
* @see #getReferencingDirectives()
* @generated
* @ordered
*/
protected EList referencingDirectives;
/**
* The cached value of the '{@link #getIncorporatedVersions() Incorporated Versions}' containment reference list.
*
*
* @see #getIncorporatedVersions()
* @generated
* @ordered
*/
protected EList incorporatedVersions;
public static XSDSchema createSchema(Node node)
{
XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
// if (XSDConstants.nodeType(node) == XSDConstants.SCHEMA_ELEMENT)
{
// Force the loading of the "meta" schema for schema instance instance.
//
String schemaForSchemaNamespace = node.getNamespaceURI();
getSchemaForSchema(schemaForSchemaNamespace);
xsdSchema.setElement((Element)node);
}
return xsdSchema;
}
public static synchronized XSDSchema createMetaSchema(Node node)
{
if (XSDConstants.nodeType(node) == XSDConstants.SCHEMA_ELEMENT)
{
XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
String schemaForSchemaNamespace = node.getNamespaceURI();
if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(schemaForSchemaNamespace))
{
if (xsdMagicSchemaForSchema2001 == null)
{
xsdMagicSchemaForSchema2001 = xsdSchema;
}
else if (xsdSchemaForSchema2001 == null)
{
xsdSchemaForSchema2001 = xsdSchema;
}
else
{
// System.out.println("Bad meta loading.");
}
}
else if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2000_10.equals(schemaForSchemaNamespace))
{
if (xsdMagicSchemaForSchema2000_10 == null)
{
xsdMagicSchemaForSchema2000_10 = xsdSchema;
}
else if (xsdSchemaForSchema2000_10 == null)
{
xsdSchemaForSchema2000_10 = xsdSchema;
}
else
{
// System.out.println("Bad meta loading.");
}
}
else if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_1999.equals(schemaForSchemaNamespace))
{
if (xsdMagicSchemaForSchema1999 == null)
{
xsdMagicSchemaForSchema1999 = xsdSchema;
}
else if (xsdSchemaForSchema1999 == null)
{
xsdSchemaForSchema1999 = xsdSchema;
}
else
{
// System.out.println("Bad meta loading.");
}
}
xsdSchema.setElement((Element)node);
return xsdSchema;
}
return null;
}
protected static ResourceSet globalResourceSet;
protected static XSDSchema xsdMagicSchemaForSchema2001;
protected static XSDSchema xsdSchemaForSchema2001;
protected static XSDSchema xsdSchemaInstance2001;
protected static XSDSchema xsdMagicSchemaForSchema2000_10;
protected static XSDSchema xsdSchemaForSchema2000_10;
protected static XSDSchema xsdMagicSchemaForSchema1999;
protected static XSDSchema xsdSchemaForSchema1999;
public static synchronized ResourceSet getGlobalResourceSet()
{
if (globalResourceSet == null)
{
globalResourceSet = createResourceSet();
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString();
globalResourceSet.getURIConverter().getURIMap().put
(URI.createURI("http://www.w3.org/2001/xml.xsd"),
URI.createURI(baseURL + "cache/www.w3.org/2001/xml.xsd"));
}
return globalResourceSet;
}
public static ResourceSet createResourceSet()
{
ResourceSet result = new ResourceSetImpl();
result.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl());
return result;
}
public static synchronized XSDSchema getMagicSchemaForSchema(String namespace)
{
if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(namespace))
{
if (xsdMagicSchemaForSchema2001 == null)
{
try
{
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString();
getGlobalResourceSet().getLoadOptions().put("XSD_MAGIC_XML_SCHEMA", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
getGlobalResourceSet().getResource
(URI.createURI(baseURL + "cache/www.w3.org/2001/MagicXMLSchema.xsd"), true);
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
getGlobalResourceSet().getLoadOptions().remove("XSD_MAGIC_XML_SCHEMA");
}
}
return xsdMagicSchemaForSchema2001;
}
else if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2000_10.equals(namespace))
{
if (xsdMagicSchemaForSchema2000_10 == null)
{
try
{
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString();
getGlobalResourceSet().getLoadOptions().put("XSD_MAGIC_XML_SCHEMA", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2000_10);
getGlobalResourceSet().getResource
(URI.createURI(baseURL + "cache/www.w3.org/2000/10/MagicXMLSchema.xsd"), true);
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
getGlobalResourceSet().getLoadOptions().remove("XSD_MAGIC_XML_SCHEMA");
}
}
return xsdMagicSchemaForSchema2000_10;
}
else if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_1999.equals(namespace))
{
if (xsdMagicSchemaForSchema1999 == null)
{
try
{
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString();
getGlobalResourceSet().getLoadOptions().put("XSD_MAGIC_XML_SCHEMA", XSDConstants.SCHEMA_FOR_SCHEMA_URI_1999);
getGlobalResourceSet().getResource
(URI.createURI(baseURL + "cache/www.w3.org/1999/MagicXMLSchema.xsd"), true);
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
getGlobalResourceSet().getLoadOptions().remove("XSD_MAGIC_XML_SCHEMA");
}
}
return xsdMagicSchemaForSchema1999;
}
return null;
}
public static synchronized XSDSchema getSchemaForSchema(String namespace)
{
if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(namespace))
{
if (xsdSchemaForSchema2001 == null)
{
try
{
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString();
getMagicSchemaForSchema(namespace);
getGlobalResourceSet().getLoadOptions().put("XSD_XML_SCHEMA", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
getGlobalResourceSet().getResource
(URI.createURI(baseURL + "cache/www.w3.org/2001/XMLSchema.xsd"), true);
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
getGlobalResourceSet().getLoadOptions().remove("XSD_XML_SCHEMA");
}
}
return xsdSchemaForSchema2001;
}
else if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2000_10.equals(namespace))
{
if (xsdSchemaForSchema2000_10 == null)
{
try
{
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString();
getMagicSchemaForSchema(namespace);
getGlobalResourceSet().getLoadOptions().put("XSD_XML_SCHEMA", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2000_10);
getGlobalResourceSet().getResource
(URI.createURI(baseURL + "cache/www.w3.org/2000/10/XMLSchema.xsd"), true);
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
getGlobalResourceSet().getLoadOptions().remove("XSD_XML_SCHEMA");
}
}
return xsdSchemaForSchema2000_10;
}
else if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_1999.equals(namespace))
{
if (xsdSchemaForSchema1999 == null)
{
try
{
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString();
getMagicSchemaForSchema(namespace);
getGlobalResourceSet().getLoadOptions().put("XSD_XML_SCHEMA", XSDConstants.SCHEMA_FOR_SCHEMA_URI_1999);
getGlobalResourceSet().getResource
(URI.createURI(baseURL + "cache/www.w3.org/1999/XMLSchema.xsd"), true);
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
getGlobalResourceSet().getLoadOptions().remove("XSD_XML_SCHEMA");
}
}
return xsdSchemaForSchema1999;
}
return null;
}
public static synchronized XSDSchema getSchemaInstance(String namespace)
{
if (XSDConstants.SCHEMA_INSTANCE_URI_2001.equals(namespace))
{
if (xsdSchemaInstance2001 == null)
{
try
{
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString();
getSchemaForSchema(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
getGlobalResourceSet().getLoadOptions().put("XSD_SCHEMA_INSTANCE", XSDConstants.SCHEMA_INSTANCE_URI_2001);
Resource schemaInstance2001Resource =
getGlobalResourceSet().getResource
(URI.createURI(baseURL + "cache/www.w3.org/2001/XMLSchema-instance.xsd"), true);
xsdSchemaInstance2001 = ((XSDResourceImpl)schemaInstance2001Resource).getSchema();
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
getGlobalResourceSet().getLoadOptions().remove("XSD_SCHEMA_INSTANCE");
}
}
return xsdSchemaInstance2001;
}
return null;
}
protected Map qNamePrefixToNamespaceMap =
new HashMap()
{
private static final long serialVersionUID = 1L;
@Override
public String put(String key, String value)
{
if ("".equals(key))
{
throw new IllegalArgumentException("The default prefix should represented as null rather than as a zero length String");
}
if (value == null)
{
value = "";
}
String result = super.put(key, value);
if (!isReconciling)
{
Element theElement = getElement();
if (theElement != null)
{
String xmlnsAttribute = "xmlns";
if (key != null)
{
xmlnsAttribute += ":" + key;
}
theElement.setAttributeNS(XSDConstants.XMLNS_URI_2000, xmlnsAttribute, value);
}
}
return result;
}
@Override
public String get(Object key)
{
String result = super.get(key);
return "".equals(result) ? null : result;
}
@Override
public String remove(Object key)
{
String result = super.remove(key);
if (!isReconciling)
{
if (result != null)
{
if (key == null)
{
key = "xmlns";
}
Element theElement = getElement();
if (theElement != null &&
theElement.hasAttributeNS(XSDConstants.XMLNS_URI_2000, (String)key))
{
theElement.removeAttributeNS(XSDConstants.XMLNS_URI_2000, (String)key);
}
}
}
return result;
}
};
protected String schemaForSchemaQNamePrefix;
protected boolean hasRetargetedNamespace = false;
/**
*
*
* @generated
*/
protected XSDSchemaImpl()
{
super();
eFlags |= ATTRIBUTE_FORM_DEFAULT_EFLAG_DEFAULT;
eFlags |= ELEMENT_FORM_DEFAULT_EFLAG_DEFAULT;
}
/**
*
*
* @generated
*/
@Override
protected EClass eStaticClass()
{
return XSDPackage.Literals.XSD_SCHEMA;
}
/**
*
*
* @generated
*/
@Override
public Document getDocument()
{
return document;
}
/**
*
*
* @generated
*/
@Override
public void setDocument(Document newDocument)
{
Document oldDocument = document;
document = newDocument;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_SCHEMA__DOCUMENT, oldDocument, document));
}
/**
*
*
* @generated
*/
@Override
public String getSchemaLocation()
{
return schemaLocation;
}
/**
*
*
* @generated
*/
@Override
public void setSchemaLocation(String newSchemaLocation)
{
String oldSchemaLocation = schemaLocation;
schemaLocation = newSchemaLocation;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_SCHEMA__SCHEMA_LOCATION, oldSchemaLocation, schemaLocation));
}
/**
*
*
* @generated
*/
@Override
public String getTargetNamespace()
{
return targetNamespace;
}
/**
*
*
* @generated
*/
@Override
public void setTargetNamespace(String newTargetNamespace)
{
String oldTargetNamespace = targetNamespace;
targetNamespace = newTargetNamespace;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_SCHEMA__TARGET_NAMESPACE, oldTargetNamespace, targetNamespace));
}
/**
*
*
* @generated
*/
@Override
public XSDForm getAttributeFormDefault()
{
return ATTRIBUTE_FORM_DEFAULT_EFLAG_VALUES[(eFlags & ATTRIBUTE_FORM_DEFAULT_EFLAG) >>> ATTRIBUTE_FORM_DEFAULT_EFLAG_OFFSET];
}
/**
*
*
* @generated
*/
@Override
public void setAttributeFormDefault(XSDForm newAttributeFormDefault)
{
XSDForm oldAttributeFormDefault = ATTRIBUTE_FORM_DEFAULT_EFLAG_VALUES[(eFlags & ATTRIBUTE_FORM_DEFAULT_EFLAG) >>> ATTRIBUTE_FORM_DEFAULT_EFLAG_OFFSET];
if (newAttributeFormDefault == null) newAttributeFormDefault = ATTRIBUTE_FORM_DEFAULT_EDEFAULT;
eFlags = eFlags & ~ATTRIBUTE_FORM_DEFAULT_EFLAG | newAttributeFormDefault.ordinal() << ATTRIBUTE_FORM_DEFAULT_EFLAG_OFFSET;
boolean oldAttributeFormDefaultESet = (eFlags & ATTRIBUTE_FORM_DEFAULT_ESETFLAG) != 0;
eFlags |= ATTRIBUTE_FORM_DEFAULT_ESETFLAG;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_SCHEMA__ATTRIBUTE_FORM_DEFAULT, oldAttributeFormDefault, newAttributeFormDefault, !oldAttributeFormDefaultESet));
}
/**
*
*
* @generated
*/
@Override
public void unsetAttributeFormDefault()
{
XSDForm oldAttributeFormDefault = ATTRIBUTE_FORM_DEFAULT_EFLAG_VALUES[(eFlags & ATTRIBUTE_FORM_DEFAULT_EFLAG) >>> ATTRIBUTE_FORM_DEFAULT_EFLAG_OFFSET];
boolean oldAttributeFormDefaultESet = (eFlags & ATTRIBUTE_FORM_DEFAULT_ESETFLAG) != 0;
eFlags = eFlags & ~ATTRIBUTE_FORM_DEFAULT_EFLAG | ATTRIBUTE_FORM_DEFAULT_EFLAG_DEFAULT;
eFlags &= ~ATTRIBUTE_FORM_DEFAULT_ESETFLAG;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.UNSET, XSDPackage.XSD_SCHEMA__ATTRIBUTE_FORM_DEFAULT, oldAttributeFormDefault, ATTRIBUTE_FORM_DEFAULT_EDEFAULT, oldAttributeFormDefaultESet));
}
/**
*
*
* @generated
*/
@Override
public boolean isSetAttributeFormDefault()
{
return (eFlags & ATTRIBUTE_FORM_DEFAULT_ESETFLAG) != 0;
}
/**
*
*
* @generated
*/
@Override
public XSDForm getElementFormDefault()
{
return ELEMENT_FORM_DEFAULT_EFLAG_VALUES[(eFlags & ELEMENT_FORM_DEFAULT_EFLAG) >>> ELEMENT_FORM_DEFAULT_EFLAG_OFFSET];
}
/**
*
*
* @generated
*/
@Override
public void setElementFormDefault(XSDForm newElementFormDefault)
{
XSDForm oldElementFormDefault = ELEMENT_FORM_DEFAULT_EFLAG_VALUES[(eFlags & ELEMENT_FORM_DEFAULT_EFLAG) >>> ELEMENT_FORM_DEFAULT_EFLAG_OFFSET];
if (newElementFormDefault == null) newElementFormDefault = ELEMENT_FORM_DEFAULT_EDEFAULT;
eFlags = eFlags & ~ELEMENT_FORM_DEFAULT_EFLAG | newElementFormDefault.ordinal() << ELEMENT_FORM_DEFAULT_EFLAG_OFFSET;
boolean oldElementFormDefaultESet = (eFlags & ELEMENT_FORM_DEFAULT_ESETFLAG) != 0;
eFlags |= ELEMENT_FORM_DEFAULT_ESETFLAG;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_SCHEMA__ELEMENT_FORM_DEFAULT, oldElementFormDefault, newElementFormDefault, !oldElementFormDefaultESet));
}
/**
*
*
* @generated
*/
@Override
public void unsetElementFormDefault()
{
XSDForm oldElementFormDefault = ELEMENT_FORM_DEFAULT_EFLAG_VALUES[(eFlags & ELEMENT_FORM_DEFAULT_EFLAG) >>> ELEMENT_FORM_DEFAULT_EFLAG_OFFSET];
boolean oldElementFormDefaultESet = (eFlags & ELEMENT_FORM_DEFAULT_ESETFLAG) != 0;
eFlags = eFlags & ~ELEMENT_FORM_DEFAULT_EFLAG | ELEMENT_FORM_DEFAULT_EFLAG_DEFAULT;
eFlags &= ~ELEMENT_FORM_DEFAULT_ESETFLAG;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.UNSET, XSDPackage.XSD_SCHEMA__ELEMENT_FORM_DEFAULT, oldElementFormDefault, ELEMENT_FORM_DEFAULT_EDEFAULT, oldElementFormDefaultESet));
}
/**
*
*
* @generated
*/
@Override
public boolean isSetElementFormDefault()
{
return (eFlags & ELEMENT_FORM_DEFAULT_ESETFLAG) != 0;
}
/**
*
*
* @generated
*/
@Override
public EList getFinalDefault()
{
if (finalDefault == null)
{
finalDefault = new EDataTypeUniqueEList.Unsettable(XSDProhibitedSubstitutions.class, this, XSDPackage.XSD_SCHEMA__FINAL_DEFAULT);
}
return finalDefault;
}
/**
*
*
* @generated
*/
@Override
public void unsetFinalDefault()
{
if (finalDefault != null) ((InternalEList.Unsettable>)finalDefault).unset();
}
/**
*
*
* @generated
*/
@Override
public boolean isSetFinalDefault()
{
return finalDefault != null && ((InternalEList.Unsettable>)finalDefault).isSet();
}
/**
*
*
* @generated
*/
@Override
public EList getBlockDefault()
{
if (blockDefault == null)
{
blockDefault = new EDataTypeUniqueEList.Unsettable(XSDDisallowedSubstitutions.class, this, XSDPackage.XSD_SCHEMA__BLOCK_DEFAULT);
}
return blockDefault;
}
/**
*
*
* @generated
*/
@Override
public void unsetBlockDefault()
{
if (blockDefault != null) ((InternalEList.Unsettable>)blockDefault).unset();
}
/**
*
*
* @generated
*/
@Override
public boolean isSetBlockDefault()
{
return blockDefault != null && ((InternalEList.Unsettable>)blockDefault).isSet();
}
/**
*
*
* @generated
*/
@Override
public String getVersion()
{
return version;
}
/**
*
*
* @generated
*/
@Override
public void setVersion(String newVersion)
{
String oldVersion = version;
version = newVersion;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_SCHEMA__VERSION, oldVersion, version));
}
/**
*
*
* @generated
*/
@Override
public EList getContents()
{
if (contents == null)
{
contents = new EObjectContainmentEList(XSDSchemaContent.class, this, XSDPackage.XSD_SCHEMA__CONTENTS);
}
return contents;
}
/**
*
*
* @generated NOT
*/
public EList getElementDeclarations()
{
if (elementDeclarations == null)
{
elementDeclarations = new XSDNamedComponentImpl.XSDNamedComponentList(XSDElementDeclaration.class, this, XSDPackage.XSD_SCHEMA__ELEMENT_DECLARATIONS);
}
return elementDeclarations;
}
/**
*
*
* @generated NOT
*/
public EList getAttributeDeclarations()
{
if (attributeDeclarations == null)
{
attributeDeclarations = new XSDNamedComponentImpl.XSDNamedComponentList(XSDAttributeDeclaration.class, this, XSDPackage.XSD_SCHEMA__ATTRIBUTE_DECLARATIONS);
}
return attributeDeclarations;
}
/**
*
*
* @generated NOT
*/
public EList getAttributeGroupDefinitions()
{
if (attributeGroupDefinitions == null)
{
attributeGroupDefinitions = new XSDNamedComponentImpl.XSDNamedComponentList(XSDAttributeGroupDefinition.class, this, XSDPackage.XSD_SCHEMA__ATTRIBUTE_GROUP_DEFINITIONS);
}
return attributeGroupDefinitions;
}
/**
*
*
* @generated NOT
*/
public EList getTypeDefinitions()
{
if (typeDefinitions == null)
{
typeDefinitions = new XSDNamedComponentImpl.XSDNamedComponentList(XSDTypeDefinition.class, this, XSDPackage.XSD_SCHEMA__TYPE_DEFINITIONS);
}
return typeDefinitions;
}
/**
*
*
* @generated NOT
*/
public EList getModelGroupDefinitions()
{
if (modelGroupDefinitions == null)
{
modelGroupDefinitions = new XSDNamedComponentImpl.XSDNamedComponentList(XSDModelGroupDefinition.class, this, XSDPackage.XSD_SCHEMA__MODEL_GROUP_DEFINITIONS);
}
return modelGroupDefinitions;
}
/**
*
*
* @generated NOT
*/
public EList getIdentityConstraintDefinitions()
{
if (identityConstraintDefinitions == null)
{
identityConstraintDefinitions = new XSDNamedComponentImpl.XSDNamedComponentList(XSDIdentityConstraintDefinition.class, this, XSDPackage.XSD_SCHEMA__IDENTITY_CONSTRAINT_DEFINITIONS);
}
return identityConstraintDefinitions;
}
/**
*
*
* @generated NOT
*/
public EList getNotationDeclarations()
{
if (notationDeclarations == null)
{
notationDeclarations = new XSDNamedComponentImpl.XSDNamedComponentList(XSDNotationDeclaration.class, this, XSDPackage.XSD_SCHEMA__NOTATION_DECLARATIONS);
}
return notationDeclarations;
}
/**
*
*
* @generated
*/
@Override
public EList getAnnotations()
{
if (annotations == null)
{
annotations = new EObjectEList(XSDAnnotation.class, this, XSDPackage.XSD_SCHEMA__ANNOTATIONS);
}
return annotations;
}
/**
*
*
* @generated
*/
@Override
public EList getAllDiagnostics()
{
if (allDiagnostics == null)
{
allDiagnostics = new EObjectEList(XSDDiagnostic.class, this, XSDPackage.XSD_SCHEMA__ALL_DIAGNOSTICS);
}
return allDiagnostics;
}
/**
*
*
* @generated
*/
@Override
public EList getReferencingDirectives()
{
if (referencingDirectives == null)
{
referencingDirectives = new EObjectEList(XSDSchemaDirective.class, this, XSDPackage.XSD_SCHEMA__REFERENCING_DIRECTIVES);
}
return referencingDirectives;
}
public boolean hasRetargetedNamespace()
{
return hasRetargetedNamespace;
}
public XSDSchema getOriginalVersion()
{
for (XSDSchemaDirective xsdSchemaDirective : getReferencingDirectives())
{
if (xsdSchemaDirective instanceof XSDSchemaCompositor)
{
XSDSchemaCompositor xsdSchemaCompositor = (XSDSchemaCompositor)xsdSchemaDirective;
if (xsdSchemaCompositor.getResolvedSchema() != xsdSchemaCompositor.getIncorporatedSchema())
{
return xsdSchemaCompositor.getResolvedSchema();
}
}
}
return this;
}
/**
*
*
* @generated
*/
@Override
public EList getIncorporatedVersions()
{
if (incorporatedVersions == null)
{
incorporatedVersions = new EObjectContainmentEList(XSDSchema.class, this, XSDPackage.XSD_SCHEMA__INCORPORATED_VERSIONS);
}
return incorporatedVersions;
}
/*
public Set getIncorporatedVersions()
{
Set result = new HashSet();
for (Iterator i = getReferencingDirectives().iterator(); i.hasNext(); )
{
XSDSchemaDirective xsdSchemaDirective = (XSDSchemaDirective)i.next();
if (xsdSchemaDirective instanceof XSDSchemaCompositor)
{
XSDSchemaCompositor xsdSchemaCompositor = (XSDSchemaCompositor)xsdSchemaDirective;
if (xsdSchemaCompositor.getResolvedSchema() != xsdSchemaCompositor.getIncorporatedSchema())
{
result.add(xsdSchemaCompositor.getIncorporatedSchema());
}
}
}
return result;
}
*/
public XSDSchema getRootVersion()
{
XSDSchema result = this;
for (XSDSchema originalVersion = result.getOriginalVersion();
result != originalVersion;
originalVersion = result.getOriginalVersion())
{
result = originalVersion;
}
return result;
}
/**
* This returns the map defined by the xmlns attributes of the underlying XML representation.
*/
public Map getQNamePrefixToNamespaceMap()
{
return qNamePrefixToNamespaceMap;
}
/**
* This returns the QName prefix used to reference the schema for schema;
* it must be a key in {@link #getQNamePrefixToNamespaceMap}.
*/
public String getSchemaForSchemaQNamePrefix()
{
return schemaForSchemaQNamePrefix;
}
/**
* This sets the QName prefix used to reference the schema for schema;
* it must be a key in {@link #getQNamePrefixToNamespaceMap} that maps to a valid schema for schema namespace.
* It can also be used to rename the prefix, one it's established.
*/
public void setSchemaForSchemaQNamePrefix(String qNamePrefix)
{
String oldSchemaForSchemaQNamePrefix = schemaForSchemaQNamePrefix;
String oldSchemaForSchemaNamespace = getSchemaForSchemaNamespace();
this.schemaForSchemaQNamePrefix = qNamePrefix;
String newSchemaForSchemaNamespace = getSchemaForSchemaNamespace();
// Rename it if there was an old one but no new one.
//
if (XSDConstants.isSchemaForSchemaNamespace(oldSchemaForSchemaNamespace) &&
!XSDConstants.isSchemaForSchemaNamespace(newSchemaForSchemaNamespace))
{
getQNamePrefixToNamespaceMap().remove(oldSchemaForSchemaQNamePrefix);
getQNamePrefixToNamespaceMap().put(qNamePrefix, oldSchemaForSchemaNamespace);
if (getElement() != null && XSDConstants.isSchemaForSchemaNamespace(getSchemaForSchemaNamespace()))
{
updatePrefix(getElement(), getSchemaForSchemaNamespace(), oldSchemaForSchemaQNamePrefix, qNamePrefix);
updateElement();
}
}
}
/**
* This returns (String)getQNamePrefixToNamespaceMap().get(getSchemaForSchemaQNamePrefix());
* you can't set this directly.
*/
public String getSchemaForSchemaNamespace()
{
return getQNamePrefixToNamespaceMap().get(getSchemaForSchemaQNamePrefix());
}
public String getStringBlockDefault()
{
if (isSetBlockDefault())
{
StringBuffer result = new StringBuffer();
for (Object literal : getBlockDefault())
{
if (result.length() != 0)
{
result.append(' ');
}
if (literal.toString().equals("all"))
{
result.append("#all");
}
else
{
result.append(literal);
}
}
return result.toString();
}
else
{
return null;
}
}
public void setStringBlockDefault(String blockDefault)
{
if (blockDefault == null)
{
unsetBlockDefault();
}
else
{
List newBlockDefault = new ArrayList();
for (StringTokenizer stringTokenizer = new StringTokenizer(blockDefault); stringTokenizer.hasMoreTokens(); )
{
String token = stringTokenizer.nextToken();
if (token.equals("#all"))
{
token = "all";
}
XSDDisallowedSubstitutions literal = XSDDisallowedSubstitutions.get(token);
if (literal != null)
{
newBlockDefault.add(literal);
}
}
if (!newBlockDefault.equals(getBlockDefault()))
{
Collection oldContents = new ArrayList(getBlockDefault());
oldContents.removeAll(newBlockDefault);
getBlockDefault().removeAll(oldContents);
setListContentAndOrder(getBlockDefault(), newBlockDefault);
}
else if (newBlockDefault.isEmpty() && !isSetBlockDefault())
{
getBlockDefault().clear();
}
}
}
public String getStringFinalDefault()
{
if (isSetFinalDefault())
{
StringBuffer result = new StringBuffer();
for (Object literal : getFinalDefault())
{
if (result.length() != 0)
{
result.append(' ');
}
if (literal.toString().equals("all"))
{
result.append("#all");
}
else
{
result.append(literal);
}
}
return result.toString();
}
else
{
return null;
}
}
public void setStringFinalDefault(String finalDefault)
{
if (finalDefault == null)
{
unsetFinalDefault();
}
else
{
List newFinalDefault = new ArrayList();
for (StringTokenizer stringTokenizer = new StringTokenizer(finalDefault); stringTokenizer.hasMoreTokens(); )
{
String token = stringTokenizer.nextToken();
if (token.equals("#all"))
{
token = "all";
}
XSDProhibitedSubstitutions literal = XSDProhibitedSubstitutions.get(token);
if (literal != null)
{
newFinalDefault.add(literal);
}
}
if (!newFinalDefault.equals(getFinalDefault()))
{
Collection oldContents = new ArrayList(getFinalDefault());
oldContents.removeAll(newFinalDefault);
getFinalDefault().removeAll(oldContents);
setListContentAndOrder(getFinalDefault(), newFinalDefault);
}
else if (newFinalDefault.isEmpty() && !isSetFinalDefault())
{
getFinalDefault().clear();
}
}
}
@Override
public Element createElement()
{
Element newElement = createElement(XSDConstants.SCHEMA_ELEMENT);
setElement(newElement);
return newElement;
}
@Override
protected void traverseToRootForPatching()
{
if (!isReconciling && isIncrementalUpdate)
{
isReconciling = true;
patch();
isReconciling = false;
}
}
protected Collection circularResolveDependencies;
protected void computeSchemasToPatch(XSDSchema root, List schemasToPatch)
{
schemasToPatch.add(root);
for (int i = 0; i < schemasToPatch.size(); ++i)
{
XSDSchema xsdSchema = schemasToPatch.get(i);
for (XSDSchemaContent content : xsdSchema.getContents())
{
if (content instanceof XSDSchemaDirective)
{
if (content instanceof XSDSchemaCompositor)
{
XSDSchemaCompositor xsdSchemaCompositor = (XSDSchemaCompositor)content;
XSDSchemaImpl xsdIncorporatedSchema = (XSDSchemaImpl)xsdSchemaCompositor.getIncorporatedSchema();
if (xsdIncorporatedSchema != null && !schemasToPatch.contains(xsdIncorporatedSchema))
{
xsdIncorporatedSchema.patchContents();
schemasToPatch.add(xsdIncorporatedSchema);
}
}
}
else if (!(content instanceof XSDAnnotation))
{
break;
}
}
}
}
@Override
protected void patch()
{
circularResolveDependencies = new HashSet();
if (XSDConstants.isSchemaForSchemaNamespace(getTargetNamespace()))
{
XSDSchema magicSchemaForSchema = getMagicSchemaForSchema(getTargetNamespace());
if (magicSchemaForSchema != this)
{
XSDNamedComponentImpl.addToSortedList
(getTypeDefinitions(), magicSchemaForSchema.getTypeDefinitions().get(0));
}
}
else
{
Collection xsiSchemas = resolveSchema(XSDConstants.SCHEMA_INSTANCE_URI_2001);
if (xsiSchemas.size() == 1)
{
XSDNamedComponentImpl.mergeToSortedList
(getAttributeDeclarations(),
xsiSchemas.iterator().next().getAttributeDeclarations());
}
}
for (Iterator i = getReferencingDirectives().iterator(); i.hasNext(); )
{
XSDSchemaDirective xsdSchemaDirective = i.next();
if (xsdSchemaDirective.getContainer() == null ||
xsdSchemaDirective.getResolvedSchema() != this &&
(!(xsdSchemaDirective instanceof XSDSchemaCompositor) ||
((XSDSchemaCompositor)xsdSchemaDirective).getIncorporatedSchema() != this))
{
i.remove();
}
}
super.patch();
List schemasToPatch = new ArrayList();
computeSchemasToPatch(this, schemasToPatch);
if (circularResolveDependencies != null)
{
Collection localCircularResolveDependencies = circularResolveDependencies;
circularResolveDependencies = null;
for (XSDSchemaImpl circularSchema : localCircularResolveDependencies)
{
if (circularSchema != this)
{
circularSchema.patch();
}
}
}
if (schemaLocation != null)
{
for (int i = 0, size = schemasToPatch.size(); i < size; ++i)
{
XSDSchemaImpl xsdSchema = (XSDSchemaImpl)schemasToPatch.get(i);
xsdSchema.analyze();
}
}
}
protected void patchContents()
{
incorporatingSchemas = null;
super.patch();
}
@Override
protected void traverseToRootForAnalysis()
{
if (!isReconciling && isIncrementalUpdate)
{
isReconciling = true;
analyze();
isReconciling = false;
}
}
@Override
protected boolean analyze()
{
return super.analyze();
}
@Override
public void validate()
{
super.validate();
Element theElement = getElement();
if (theElement != null)
{
if (XSDConstants.nodeType(element) != XSDConstants.SCHEMA_ELEMENT)
{
createDiagnostic
(XSDDiagnosticSeverity.ERROR_LITERAL,
"content-valid.1",
(element.getNamespaceURI() == null ? "" : element.getNamespaceURI()) + "#" + element.getLocalName(),
XSDPlugin.INSTANCE.getString("_UI_XML_SCHEMA_name"),
"schema");
}
else
{
if (getContainer() == null || !eContainmentFeature().isTransient())
{
checkAttributes
(XSDConstants.PART1,
"element-complexType",
theElement,
new String []
{
XSDConstants.ATTRIBUTEFORMDEFAULT_ATTRIBUTE,
XSDConstants.BLOCKDEFAULT_ATTRIBUTE,
XSDConstants.ELEMENTFORMDEFAULT_ATTRIBUTE,
XSDConstants.FINALDEFAULT_ATTRIBUTE,
XSDConstants.ID_ATTRIBUTE,
XSDConstants.TARGETNAMESPACE_ATTRIBUTE,
XSDConstants.VERSION_ATTRIBUTE
});
XSDComplexTypeDefinition xsdComplexTypeDefinition =
(XSDComplexTypeDefinition)getSchemaForSchema().resolveElementDeclaration("schema").getTypeDefinition();
checkComplexContent
(xsdComplexTypeDefinition,
XSDConstants.PART1,
"element-schema",
theElement);
checkAttributeTypeConstraint
(xsdComplexTypeDefinition,
"attributeFormDefault",
null,
XSDConstants.PART1,
"element-schema",
theElement,
XSDConstants.ATTRIBUTEFORMDEFAULT_ATTRIBUTE,
false);
checkAttributeTypeConstraint
(xsdComplexTypeDefinition,
"blockDefault",
null,
XSDConstants.PART1,
"element-schema",
theElement,
XSDConstants.BLOCKDEFAULT_ATTRIBUTE,
false);
checkAttributeTypeConstraint
(xsdComplexTypeDefinition,
"elementFormDefault",
null,
XSDConstants.PART1,
"element-schema",
theElement,
XSDConstants.ELEMENTFORMDEFAULT_ATTRIBUTE,
false);
checkAttributeTypeConstraint
(xsdComplexTypeDefinition,
"finalDefault",
null,
XSDConstants.PART1,
"element-schema",
theElement,
XSDConstants.FINALDEFAULT_ATTRIBUTE,
false);
checkBuiltInTypeConstraint
("ID",
null,
XSDConstants.PART1,
"element-schema",
theElement,
XSDConstants.ID_ATTRIBUTE,
false);
}
}
}
if (getSchemaForSchema() != null)
{
checkBuiltInTypeConstraint
("anyURI",
getTargetNamespace(),
XSDConstants.PART1,
"element-schema",
theElement,
XSDConstants.TARGETNAMESPACE_ATTRIBUTE,
false);
checkBuiltInTypeConstraint
("token",
getVersion(),
XSDConstants.PART1,
"element-schema",
theElement,
XSDConstants.VERSION_ATTRIBUTE,
false);
validateNoDuplicates("attribute_noun", getAttributeDeclarations());
validateNoDuplicates("attributeGroup_noun", getAttributeGroupDefinitions());
validateNoDuplicates("modelGroup_noun", getModelGroupDefinitions());
validateNoDuplicates("element_noun", getElementDeclarations());
validateNoDuplicates("type_noun", getTypeDefinitions());
validateNoDuplicates("identityConstraint_noun", getIdentityConstraintDefinitions());
validateNoDuplicates("notation_noun", getNotationDeclarations());
}
}
public void validateNoDuplicates(String componentNoun, EList extends XSDNamedComponent> xsdNamedComponents)
{
String name = null;
String targetNamespace = null;
for (XSDNamedComponent xsdNamedComponent : xsdNamedComponents)
{
if (xsdNamedComponent.hasNameAndTargetNamespace(name, targetNamespace))
{
getDiagnosticTarget(xsdNamedComponent).createDiagnostic
(XSDDiagnosticSeverity.ERROR_LITERAL,
"coss-schema.2",
XSDPlugin.INSTANCE.getString(componentNoun),
xsdNamedComponent.getURI());
}
name = xsdNamedComponent.getName();
targetNamespace = xsdNamedComponent.getTargetNamespace();
}
}
protected void updateSortedList(XSDNamedComponent xsdNamedComponent)
{
new XSDSwitch