| 1 |
/** |
| 2 |
* Copyright (c) 2002-2007 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v2.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v20.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* IBM - Initial API and implementation |
| 10 |
*/ |
| 11 |
package org.eclipse.xsd.impl; |
| 12 |
|
| 13 |
|
| 14 |
import java.io.Serializable; |
| 15 |
import java.util.ArrayList; |
| 16 |
import java.util.Collection; |
| 17 |
import java.util.Collections; |
| 18 |
import java.util.HashMap; |
| 19 |
import java.util.HashSet; |
| 20 |
import java.util.Iterator; |
| 21 |
import java.util.List; |
| 22 |
import java.util.ListIterator; |
| 23 |
import java.util.Map; |
| 24 |
import java.util.StringTokenizer; |
| 25 |
|
| 26 |
import org.w3c.dom.Attr; |
| 27 |
import org.w3c.dom.Document; |
| 28 |
import org.w3c.dom.Element; |
| 29 |
import org.w3c.dom.NamedNodeMap; |
| 30 |
import org.w3c.dom.Node; |
| 31 |
import org.w3c.dom.events.Event; |
| 32 |
import org.w3c.dom.events.EventListener; |
| 33 |
import org.w3c.dom.events.EventTarget; |
| 34 |
import org.w3c.dom.events.MutationEvent; |
| 35 |
|
| 36 |
import org.eclipse.emf.common.notify.Notification; |
| 37 |
import org.eclipse.emf.common.notify.NotificationChain; |
| 38 |
import org.eclipse.emf.common.util.EList; |
| 39 |
import org.eclipse.emf.common.util.UniqueEList; |
| 40 |
import org.eclipse.emf.common.util.URI; |
| 41 |
import org.eclipse.emf.ecore.EAttribute; |
| 42 |
import org.eclipse.emf.ecore.EClass; |
| 43 |
import org.eclipse.emf.ecore.EReference; |
| 44 |
import org.eclipse.emf.ecore.InternalEObject; |
| 45 |
import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 46 |
import org.eclipse.emf.ecore.resource.Resource; |
| 47 |
import org.eclipse.emf.ecore.resource.ResourceSet; |
| 48 |
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; |
| 49 |
import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; |
| 50 |
import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
| 51 |
import org.eclipse.emf.ecore.util.EObjectEList; |
| 52 |
import org.eclipse.emf.ecore.util.InternalEList; |
| 53 |
|
| 54 |
import org.eclipse.xsd.XSDAnnotation; |
| 55 |
import org.eclipse.xsd.XSDAttributeDeclaration; |
| 56 |
import org.eclipse.xsd.XSDAttributeGroupDefinition; |
| 57 |
import org.eclipse.xsd.XSDComplexTypeDefinition; |
| 58 |
import org.eclipse.xsd.XSDComponent; |
| 59 |
import org.eclipse.xsd.XSDConcreteComponent; |
| 60 |
import org.eclipse.xsd.XSDDiagnostic; |
| 61 |
import org.eclipse.xsd.XSDDiagnosticSeverity; |
| 62 |
import org.eclipse.xsd.XSDDisallowedSubstitutions; |
| 63 |
import org.eclipse.xsd.XSDElementDeclaration; |
| 64 |
import org.eclipse.xsd.XSDFactory; |
| 65 |
import org.eclipse.xsd.XSDForm; |
| 66 |
import org.eclipse.xsd.XSDIdentityConstraintDefinition; |
| 67 |
import org.eclipse.xsd.XSDImport; |
| 68 |
import org.eclipse.xsd.XSDInclude; |
| 69 |
import org.eclipse.xsd.XSDModelGroupDefinition; |
| 70 |
import org.eclipse.xsd.XSDNamedComponent; |
| 71 |
import org.eclipse.xsd.XSDNotationDeclaration; |
| 72 |
import org.eclipse.xsd.XSDPackage; |
| 73 |
import org.eclipse.xsd.XSDPlugin; |
| 74 |
import org.eclipse.xsd.XSDProhibitedSubstitutions; |
| 75 |
import org.eclipse.xsd.XSDRedefine; |
| 76 |
import org.eclipse.xsd.XSDRedefineContent; |
| 77 |
import org.eclipse.xsd.XSDSchema; |
| 78 |
import org.eclipse.xsd.XSDSchemaCompositor; |
| 79 |
import org.eclipse.xsd.XSDSchemaContent; |
| 80 |
import org.eclipse.xsd.XSDSchemaDirective; |
| 81 |
import org.eclipse.xsd.XSDSimpleTypeDefinition; |
| 82 |
import org.eclipse.xsd.XSDTypeDefinition; |
| 83 |
import org.eclipse.xsd.util.XSDConstants; |
| 84 |
import org.eclipse.xsd.util.XSDParser; |
| 85 |
import org.eclipse.xsd.util.XSDResourceFactoryImpl; |
| 86 |
import org.eclipse.xsd.util.XSDResourceImpl; |
| 87 |
import org.eclipse.xsd.util.XSDSwitch; |
| 88 |
|
| 89 |
|
| 90 |
/** |
| 91 |
* <!-- begin-user-doc --> |
| 92 |
* An implementation of the model object '<em><b>Schema</b></em>'. |
| 93 |
* <!-- end-user-doc --> |
| 94 |
* <p> |
| 95 |
* The following features are implemented: |
| 96 |
* </p> |
| 97 |
* <ul> |
| 98 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getDocument <em>Document</em>}</li> |
| 99 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getSchemaLocation <em>Schema Location</em>}</li> |
| 100 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getTargetNamespace <em>Target Namespace</em>}</li> |
| 101 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getAttributeFormDefault <em>Attribute Form Default</em>}</li> |
| 102 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getElementFormDefault <em>Element Form Default</em>}</li> |
| 103 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getFinalDefault <em>Final Default</em>}</li> |
| 104 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getBlockDefault <em>Block Default</em>}</li> |
| 105 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getVersion <em>Version</em>}</li> |
| 106 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getContents <em>Contents</em>}</li> |
| 107 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getElementDeclarations <em>Element Declarations</em>}</li> |
| 108 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getAttributeDeclarations <em>Attribute Declarations</em>}</li> |
| 109 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getAttributeGroupDefinitions <em>Attribute Group Definitions</em>}</li> |
| 110 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getTypeDefinitions <em>Type Definitions</em>}</li> |
| 111 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getModelGroupDefinitions <em>Model Group Definitions</em>}</li> |
| 112 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getIdentityConstraintDefinitions <em>Identity Constraint Definitions</em>}</li> |
| 113 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getNotationDeclarations <em>Notation Declarations</em>}</li> |
| 114 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getAnnotations <em>Annotations</em>}</li> |
| 115 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getAllDiagnostics <em>All Diagnostics</em>}</li> |
| 116 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getReferencingDirectives <em>Referencing Directives</em>}</li> |
| 117 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getRootVersion <em>Root Version</em>}</li> |
| 118 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getOriginalVersion <em>Original Version</em>}</li> |
| 119 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getIncorporatedVersions <em>Incorporated Versions</em>}</li> |
| 120 |
* <li>{@link org.eclipse.xsd.impl.XSDSchemaImpl#getSchemaForSchema <em>Schema For Schema</em>}</li> |
| 121 |
* </ul> |
| 122 |
* |
| 123 |
* @generated |
| 124 |
*/ |
| 125 |
public class XSDSchemaImpl |
| 126 |
extends XSDScopeImpl |
| 127 |
implements XSDSchema |
| 128 |
{ |
| 129 |
/** |
| 130 |
* The default value of the '{@link #getDocument() <em>Document</em>}' attribute. |
| 131 |
* <!-- begin-user-doc --> |
| 132 |
* <!-- end-user-doc --> |
| 133 |
* @see #getDocument() |
| 134 |
* @generated |
| 135 |
* @ordered |
| 136 |
*/ |
| 137 |
protected static final Document DOCUMENT_EDEFAULT = null; |
| 138 |
|
| 139 |
/** |
| 140 |
* The cached value of the '{@link #getDocument() <em>Document</em>}' attribute. |
| 141 |
* <!-- begin-user-doc --> |
| 142 |
* <!-- end-user-doc --> |
| 143 |
* @see #getDocument() |
| 144 |
* @generated |
| 145 |
* @ordered |
| 146 |
*/ |
| 147 |
protected Document document = DOCUMENT_EDEFAULT; |
| 148 |
|
| 149 |
/** |
| 150 |
* The default value of the '{@link #getSchemaLocation() <em>Schema Location</em>}' attribute. |
| 151 |
* <!-- begin-user-doc --> |
| 152 |
* <!-- end-user-doc --> |
| 153 |
* @see #getSchemaLocation() |
| 154 |
* @generated |
| 155 |
* @ordered |
| 156 |
*/ |
| 157 |
protected static final String SCHEMA_LOCATION_EDEFAULT = null; |
| 158 |
|
| 159 |
/** |
| 160 |
* The cached value of the '{@link #getSchemaLocation() <em>Schema Location</em>}' attribute. |
| 161 |
* <!-- begin-user-doc --> |
| 162 |
* <!-- end-user-doc --> |
| 163 |
* @see #getSchemaLocation() |
| 164 |
* @generated |
| 165 |
* @ordered |
| 166 |
*/ |
| 167 |
protected String schemaLocation = SCHEMA_LOCATION_EDEFAULT; |
| 168 |
|
| 169 |
/** |
| 170 |
* The default value of the '{@link #getTargetNamespace() <em>Target Namespace</em>}' attribute. |
| 171 |
* <!-- begin-user-doc --> |
| 172 |
* <!-- end-user-doc --> |
| 173 |
* @see #getTargetNamespace() |
| 174 |
* @generated |
| 175 |
* @ordered |
| 176 |
*/ |
| 177 |
protected static final String TARGET_NAMESPACE_EDEFAULT = null; |
| 178 |
|
| 179 |
/** |
| 180 |
* The cached value of the '{@link #getTargetNamespace() <em>Target Namespace</em>}' attribute. |
| 181 |
* <!-- begin-user-doc --> |
| 182 |
* <!-- end-user-doc --> |
| 183 |
* @see #getTargetNamespace() |
| 184 |
* @generated |
| 185 |
* @ordered |
| 186 |
*/ |
| 187 |
protected String targetNamespace = TARGET_NAMESPACE_EDEFAULT; |
| 188 |
|
| 189 |
/** |
| 190 |
* The default value of the '{@link #getAttributeFormDefault() <em>Attribute Form Default</em>}' attribute. |
| 191 |
* <!-- begin-user-doc --> |
| 192 |
* <!-- end-user-doc --> |
| 193 |
* @see #getAttributeFormDefault() |
| 194 |
* @generated |
| 195 |
* @ordered |
| 196 |
*/ |
| 197 |
protected static final XSDForm ATTRIBUTE_FORM_DEFAULT_EDEFAULT = XSDForm.UNQUALIFIED_LITERAL; |
| 198 |
|
| 199 |
/** |
| 200 |
* The offset of the flags representing the value of the '{@link #getAttributeFormDefault() <em>Attribute Form Default</em>}' attribute. |
| 201 |
* <!-- begin-user-doc --> |
| 202 |
* <!-- end-user-doc --> |
| 203 |
* @generated |
| 204 |
* @ordered |
| 205 |
*/ |
| 206 |
protected static final int ATTRIBUTE_FORM_DEFAULT_EFLAG_OFFSET = 8; |
| 207 |
|
| 208 |
/** |
| 209 |
* The flags representing the default value of the '{@link #getAttributeFormDefault() <em>Attribute Form Default</em>}' attribute. |
| 210 |
* <!-- begin-user-doc --> |
| 211 |
* <!-- end-user-doc --> |
| 212 |
* @generated |
| 213 |
* @ordered |
| 214 |
*/ |
| 215 |
protected static final int ATTRIBUTE_FORM_DEFAULT_EFLAG_DEFAULT = ATTRIBUTE_FORM_DEFAULT_EDEFAULT.ordinal() << ATTRIBUTE_FORM_DEFAULT_EFLAG_OFFSET; |
| 216 |
|
| 217 |
/** |
| 218 |
* The array of enumeration values for '{@link XSDForm Form}' |
| 219 |
* <!-- begin-user-doc --> |
| 220 |
* <!-- end-user-doc --> |
| 221 |
* @generated |
| 222 |
* @ordered |
| 223 |
*/ |
| 224 |
private static final XSDForm[] ATTRIBUTE_FORM_DEFAULT_EFLAG_VALUES = XSDForm.values(); |
| 225 |
|
| 226 |
/** |
| 227 |
* The flag representing the value of the '{@link #getAttributeFormDefault() <em>Attribute Form Default</em>}' attribute. |
| 228 |
* <!-- begin-user-doc --> |
| 229 |
* <!-- end-user-doc --> |
| 230 |
* @see #getAttributeFormDefault() |
| 231 |
* @generated |
| 232 |
* @ordered |
| 233 |
*/ |
| 234 |
protected static final int ATTRIBUTE_FORM_DEFAULT_EFLAG = 1 << ATTRIBUTE_FORM_DEFAULT_EFLAG_OFFSET; |
| 235 |
|
| 236 |
/** |
| 237 |
* The flag representing whether the Attribute Form Default attribute has been set. |
| 238 |
* <!-- begin-user-doc --> |
| 239 |
* <!-- end-user-doc --> |
| 240 |
* @generated |
| 241 |
* @ordered |
| 242 |
*/ |
| 243 |
protected static final int ATTRIBUTE_FORM_DEFAULT_ESETFLAG = 1 << 9; |
| 244 |
|
| 245 |
/** |
| 246 |
* The default value of the '{@link #getElementFormDefault() <em>Element Form Default</em>}' attribute. |
| 247 |
* <!-- begin-user-doc --> |
| 248 |
* <!-- end-user-doc --> |
| 249 |
* @see #getElementFormDefault() |
| 250 |
* @generated |
| 251 |
* @ordered |
| 252 |
*/ |
| 253 |
protected static final XSDForm ELEMENT_FORM_DEFAULT_EDEFAULT = XSDForm.UNQUALIFIED_LITERAL; |
| 254 |
|
| 255 |
/** |
| 256 |
* The offset of the flags representing the value of the '{@link #getElementFormDefault() <em>Element Form Default</em>}' attribute. |
| 257 |
* <!-- begin-user-doc --> |
| 258 |
* <!-- end-user-doc --> |
| 259 |
* @generated |
| 260 |
* @ordered |
| 261 |
*/ |
| 262 |
protected static final int ELEMENT_FORM_DEFAULT_EFLAG_OFFSET = 10; |
| 263 |
|
| 264 |
/** |
| 265 |
* The flags representing the default value of the '{@link #getElementFormDefault() <em>Element Form Default</em>}' attribute. |
| 266 |
* <!-- begin-user-doc --> |
| 267 |
* <!-- end-user-doc --> |
| 268 |
* @generated |
| 269 |
* @ordered |
| 270 |
*/ |
| 271 |
protected static final int ELEMENT_FORM_DEFAULT_EFLAG_DEFAULT = ELEMENT_FORM_DEFAULT_EDEFAULT.ordinal() << ELEMENT_FORM_DEFAULT_EFLAG_OFFSET; |
| 272 |
|
| 273 |
/** |
| 274 |
* The array of enumeration values for '{@link XSDForm Form}' |
| 275 |
* <!-- begin-user-doc --> |
| 276 |
* <!-- end-user-doc --> |
| 277 |
* @generated |
| 278 |
* @ordered |
| 279 |
*/ |
| 280 |
private static final XSDForm[] ELEMENT_FORM_DEFAULT_EFLAG_VALUES = XSDForm.values(); |
| 281 |
|
| 282 |
/** |
| 283 |
* The flag representing the value of the '{@link #getElementFormDefault() <em>Element Form Default</em>}' attribute. |
| 284 |
* <!-- begin-user-doc --> |
| 285 |
* <!-- end-user-doc --> |
| 286 |
* @see #getElementFormDefault() |
| 287 |
* @generated |
| 288 |
* @ordered |
| 289 |
*/ |
| 290 |
protected static final int ELEMENT_FORM_DEFAULT_EFLAG = 1 << ELEMENT_FORM_DEFAULT_EFLAG_OFFSET; |
| 291 |
|
| 292 |
/** |
| 293 |
* The flag representing whether the Element Form Default attribute has been set. |
| 294 |
* <!-- begin-user-doc --> |
| 295 |
* <!-- end-user-doc --> |
| 296 |
* @generated |
| 297 |
* @ordered |
| 298 |
*/ |
| 299 |
protected static final int ELEMENT_FORM_DEFAULT_ESETFLAG = 1 << 11; |
| 300 |
|
| 301 |
/** |
| 302 |
* The cached value of the '{@link #getFinalDefault() <em>Final Default</em>}' attribute list. |
| 303 |
* <!-- begin-user-doc --> |
| 304 |
* <!-- end-user-doc --> |
| 305 |
* @see #getFinalDefault() |
| 306 |
* @generated |
| 307 |
* @ordered |
| 308 |
*/ |
| 309 |
protected EList<XSDProhibitedSubstitutions> finalDefault; |
| 310 |
|
| 311 |
/** |
| 312 |
* The cached value of the '{@link #getBlockDefault() <em>Block Default</em>}' attribute list. |
| 313 |
* <!-- begin-user-doc --> |
| 314 |
* <!-- end-user-doc --> |
| 315 |
* @see #getBlockDefault() |
| 316 |
* @generated |
| 317 |
* @ordered |
| 318 |
*/ |
| 319 |
protected EList<XSDDisallowedSubstitutions> blockDefault; |
| 320 |
|
| 321 |
/** |
| 322 |
* The default value of the '{@link #getVersion() <em>Version</em>}' attribute. |
| 323 |
* <!-- begin-user-doc --> |
| 324 |
* <!-- end-user-doc --> |
| 325 |
* @see #getVersion() |
| 326 |
* @generated |
| 327 |
* @ordered |
| 328 |
*/ |
| 329 |
protected static final String VERSION_EDEFAULT = null; |
| 330 |
|
| 331 |
/** |
| 332 |
* The cached value of the '{@link #getVersion() <em>Version</em>}' attribute. |
| 333 |
* <!-- begin-user-doc --> |
| 334 |
* <!-- end-user-doc --> |
| 335 |
* @see #getVersion() |
| 336 |
* @generated |
| 337 |
* @ordered |
| 338 |
*/ |
| 339 |
protected String version = VERSION_EDEFAULT; |
| 340 |
|
| 341 |
/** |
| 342 |
* The cached value of the '{@link #getContents() <em>Contents</em>}' containment reference list. |
| 343 |
* <!-- begin-user-doc --> |
| 344 |
* <!-- end-user-doc --> |
| 345 |
* @see #getContents() |
| 346 |
* @generated |
| 347 |
* @ordered |
| 348 |
*/ |
| 349 |
protected EList<XSDSchemaContent> contents; |
| 350 |
|
| 351 |
/** |
| 352 |
* The cached value of the '{@link #getElementDeclarations() <em>Element Declarations</em>}' reference list. |
| 353 |
* <!-- begin-user-doc --> |
| 354 |
* <!-- end-user-doc --> |
| 355 |
* @see #getElementDeclarations() |
| 356 |
* @generated |
| 357 |
* @ordered |
| 358 |
*/ |
| 359 |
protected EList<XSDElementDeclaration> elementDeclarations; |
| 360 |
|
| 361 |
/** |
| 362 |
* The cached value of the '{@link #getAttributeDeclarations() <em>Attribute Declarations</em>}' reference list. |
| 363 |
* <!-- begin-user-doc --> |
| 364 |
* <!-- end-user-doc --> |
| 365 |
* @see #getAttributeDeclarations() |
| 366 |
* @generated |
| 367 |
* @ordered |
| 368 |
*/ |
| 369 |
protected EList<XSDAttributeDeclaration> attributeDeclarations; |
| 370 |
|
| 371 |
/** |
| 372 |
* The cached value of the '{@link #getAttributeGroupDefinitions() <em>Attribute Group Definitions</em>}' reference list. |
| 373 |
* <!-- begin-user-doc --> |
| 374 |
* <!-- end-user-doc --> |
| 375 |
* @see #getAttributeGroupDefinitions() |
| 376 |
* @generated |
| 377 |
* @ordered |
| 378 |
*/ |
| 379 |
protected EList<XSDAttributeGroupDefinition> attributeGroupDefinitions; |
| 380 |
|
| 381 |
/** |
| 382 |
* The cached value of the '{@link #getTypeDefinitions() <em>Type Definitions</em>}' reference list. |
| 383 |
* <!-- begin-user-doc --> |
| 384 |
* <!-- end-user-doc --> |
| 385 |
* @see #getTypeDefinitions() |
| 386 |
* @generated |
| 387 |
* @ordered |
| 388 |
*/ |
| 389 |
protected EList<XSDTypeDefinition> typeDefinitions; |
| 390 |
|
| 391 |
/** |
| 392 |
* The cached value of the '{@link #getModelGroupDefinitions() <em>Model Group Definitions</em>}' reference list. |
| 393 |
* <!-- begin-user-doc --> |
| 394 |
* <!-- end-user-doc --> |
| 395 |
* @see #getModelGroupDefinitions() |
| 396 |
* @generated |
| 397 |
* @ordered |
| 398 |
*/ |
| 399 |
protected EList<XSDModelGroupDefinition> modelGroupDefinitions; |
| 400 |
|
| 401 |
/** |
| 402 |
* The cached value of the '{@link #getIdentityConstraintDefinitions() <em>Identity Constraint Definitions</em>}' reference list. |
| 403 |
* <!-- begin-user-doc --> |
| 404 |
* <!-- end-user-doc --> |
| 405 |
* @see #getIdentityConstraintDefinitions() |
| 406 |
* @generated |
| 407 |
* @ordered |
| 408 |
*/ |
| 409 |
protected EList<XSDIdentityConstraintDefinition> identityConstraintDefinitions; |
| 410 |
|
| 411 |
/** |
| 412 |
* The cached value of the '{@link #getNotationDeclarations() <em>Notation Declarations</em>}' reference list. |
| 413 |
* <!-- begin-user-doc --> |
| 414 |
* <!-- end-user-doc --> |
| 415 |
* @see #getNotationDeclarations() |
| 416 |
* @generated |
| 417 |
* @ordered |
| 418 |
*/ |
| 419 |
protected EList<XSDNotationDeclaration> notationDeclarations; |
| 420 |
|
| 421 |
/** |
| 422 |
* The cached value of the '{@link #getAnnotations() <em>Annotations</em>}' reference list. |
| 423 |
* <!-- begin-user-doc --> |
| 424 |
* <!-- end-user-doc --> |
| 425 |
* @see #getAnnotations() |
| 426 |
* @generated |
| 427 |
* @ordered |
| 428 |
*/ |
| 429 |
protected EList<XSDAnnotation> annotations; |
| 430 |
|
| 431 |
/** |
| 432 |
* The cached value of the '{@link #getAllDiagnostics() <em>All Diagnostics</em>}' reference list. |
| 433 |
* <!-- begin-user-doc --> |
| 434 |
* <!-- end-user-doc --> |
| 435 |
* @see #getAllDiagnostics() |
| 436 |
* @generated |
| 437 |
* @ordered |
| 438 |
*/ |
| 439 |
protected EList<XSDDiagnostic> allDiagnostics; |
| 440 |
|
| 441 |
/** |
| 442 |
* The cached value of the '{@link #getReferencingDirectives() <em>Referencing Directives</em>}' reference list. |
| 443 |
* <!-- begin-user-doc --> |
| 444 |
* <!-- end-user-doc --> |
| 445 |
* @see #getReferencingDirectives() |
| 446 |
* @generated |
| 447 |
* @ordered |
| 448 |
*/ |
| 449 |
protected EList<XSDSchemaDirective> referencingDirectives; |
| 450 |
|
| 451 |
/** |
| 452 |
* The cached value of the '{@link #getIncorporatedVersions() <em>Incorporated Versions</em>}' containment reference list. |
| 453 |
* <!-- begin-user-doc --> |
| 454 |
* <!-- end-user-doc --> |
| 455 |
* @see #getIncorporatedVersions() |
| 456 |
* @generated |
| 457 |
* @ordered |
| 458 |
*/ |
| 459 |
protected EList<XSDSchema> incorporatedVersions; |
| 460 |
|
| 461 |
public static XSDSchema createSchema(Node node) |
| 462 |
{ |
| 463 |
XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema(); |
| 464 |
|
| 465 |
// if (XSDConstants.nodeType(node) == XSDConstants.SCHEMA_ELEMENT) |
| 466 |
{ |
| 467 |
// Force the loading of the "meta" schema for schema instance instance. |
| 468 |
// |
| 469 |
String schemaForSchemaNamespace = node.getNamespaceURI(); |
| 470 |
getSchemaForSchema(schemaForSchemaNamespace); |
| 471 |
|
| 472 |
xsdSchema.setElement((Element)node); |
| 473 |
} |
| 474 |
|
| 475 |
return xsdSchema; |
| 476 |
} |
| 477 |
|
| 478 |
public static synchronized XSDSchema createMetaSchema(Node node) |
| 479 |
{ |
| 480 |
if (XSDConstants.nodeType(node) == XSDConstants.SCHEMA_ELEMENT) |
| 481 |
{ |
| 482 |
XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema(); |
| 483 |
|
| 484 |
String schemaForSchemaNamespace = node.getNamespaceURI(); |
| 485 |
if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(schemaForSchemaNamespace)) |
| 486 |
{ |
| 487 |
if (xsdMagicSchemaForSchema2001 == null) |
| 488 |
{ |
| 489 |
xsdMagicSchemaForSchema2001 = xsdSchema; |
| 490 |
} |
| 491 |
else if (xsdSchemaForSchema2001 == null) |
| 492 |
{ |
| 493 |
xsdSchemaForSchema2001 = xsdSchema; |
| 494 |
} |
| 495 |
else |
| 496 |
{ |
| 497 |
// System.out.println("Bad meta loading."); |
| 498 |
} |
| 499 |
} |
| 500 |
else if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2000_10.equals(schemaForSchemaNamespace)) |
| 501 |
{ |
| 502 |
if (xsdMagicSchemaForSchema2000_10 == null) |
| 503 |
{ |
| 504 |
xsdMagicSchemaForSchema2000_10 = xsdSchema; |
| 505 |
} |
| 506 |
else if (xsdSchemaForSchema2000_10 == null) |
| 507 |
{ |
| 508 |
xsdSchemaForSchema2000_10 = xsdSchema; |
| 509 |
} |
| 510 |
else |
| 511 |
{ |
| 512 |
// System.out.println("Bad meta loading."); |
| 513 |
} |
| 514 |
} |
| 515 |
else if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_1999.equals(schemaForSchemaNamespace)) |
| 516 |
{ |
| 517 |
if (xsdMagicSchemaForSchema1999 == null) |
| 518 |
{ |
| 519 |
xsdMagicSchemaForSchema1999 = xsdSchema; |
| 520 |
} |
| 521 |
else if (xsdSchemaForSchema1999 == null) |
| 522 |
{ |
| 523 |
xsdSchemaForSchema1999 = xsdSchema; |
| 524 |
} |
| 525 |
else |
| 526 |
{ |
| 527 |
// System.out.println("Bad meta loading."); |
| 528 |
} |
| 529 |
} |
| 530 |
|
| 531 |
|
| 532 |
xsdSchema.setElement((Element)node); |
| 533 |
return xsdSchema; |
| 534 |
} |
| 535 |
|
| 536 |
return null; |
| 537 |
} |
| 538 |
|
| 539 |
protected static ResourceSet globalResourceSet; |
| 540 |
|
| 541 |
protected static XSDSchema xsdMagicSchemaForSchema2001; |
| 542 |
protected static XSDSchema xsdSchemaForSchema2001; |
| 543 |
protected static XSDSchema xsdSchemaInstance2001; |
| 544 |
|
| 545 |
protected static XSDSchema xsdMagicSchemaForSchema2000_10; |
| 546 |
protected static XSDSchema xsdSchemaForSchema2000_10; |
| 547 |
|
| 548 |
protected static XSDSchema xsdMagicSchemaForSchema1999; |
| 549 |
protected static XSDSchema xsdSchemaForSchema1999; |
| 550 |
|
| 551 |
public static synchronized ResourceSet getGlobalResourceSet() |
| 552 |
{ |
| 553 |
if (globalResourceSet == null) |
| 554 |
{ |
| 555 |
globalResourceSet = createResourceSet(); |
| 556 |
|
| 557 |
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString(); |
| 558 |
globalResourceSet.getURIConverter().getURIMap().put |
| 559 |
(URI.createURI("http://www.w3.org/2001/xml.xsd"), |
| 560 |
URI.createURI(baseURL + "cache/www.w3.org/2001/xml.xsd")); |
| 561 |
} |
| 562 |
|
| 563 |
return globalResourceSet; |
| 564 |
} |
| 565 |
|
| 566 |
public static ResourceSet createResourceSet() |
| 567 |
{ |
| 568 |
ResourceSet result = new ResourceSetImpl(); |
| 569 |
result.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl()); |
| 570 |
return result; |
| 571 |
} |
| 572 |
|
| 573 |
public static synchronized XSDSchema getMagicSchemaForSchema(String namespace) |
| 574 |
{ |
| 575 |
if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(namespace)) |
| 576 |
{ |
| 577 |
if (xsdMagicSchemaForSchema2001 == null) |
| 578 |
{ |
| 579 |
try |
| 580 |
{ |
| 581 |
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString(); |
| 582 |
getGlobalResourceSet().getLoadOptions().put("XSD_MAGIC_XML_SCHEMA", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); |
| 583 |
getGlobalResourceSet().getResource |
| 584 |
(URI.createURI(baseURL + "cache/www.w3.org/2001/MagicXMLSchema.xsd"), true); |
| 585 |
} |
| 586 |
catch (Exception exception) |
| 587 |
{ |
| 588 |
exception.printStackTrace(); |
| 589 |
} |
| 590 |
finally |
| 591 |
{ |
| 592 |
getGlobalResourceSet().getLoadOptions().remove("XSD_MAGIC_XML_SCHEMA"); |
| 593 |
} |
| 594 |
} |
| 595 |
|
| 596 |
return xsdMagicSchemaForSchema2001; |
| 597 |
} |
| 598 |
else if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2000_10.equals(namespace)) |
| 599 |
{ |
| 600 |
if (xsdMagicSchemaForSchema2000_10 == null) |
| 601 |
{ |
| 602 |
try |
| 603 |
{ |
| 604 |
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString(); |
| 605 |
getGlobalResourceSet().getLoadOptions().put("XSD_MAGIC_XML_SCHEMA", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2000_10); |
| 606 |
getGlobalResourceSet().getResource |
| 607 |
(URI.createURI(baseURL + "cache/www.w3.org/2000/10/MagicXMLSchema.xsd"), true); |
| 608 |
} |
| 609 |
catch (Exception exception) |
| 610 |
{ |
| 611 |
exception.printStackTrace(); |
| 612 |
} |
| 613 |
finally |
| 614 |
{ |
| 615 |
getGlobalResourceSet().getLoadOptions().remove("XSD_MAGIC_XML_SCHEMA"); |
| 616 |
} |
| 617 |
} |
| 618 |
|
| 619 |
return xsdMagicSchemaForSchema2000_10; |
| 620 |
} |
| 621 |
else if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_1999.equals(namespace)) |
| 622 |
{ |
| 623 |
if (xsdMagicSchemaForSchema1999 == null) |
| 624 |
{ |
| 625 |
try |
| 626 |
{ |
| 627 |
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString(); |
| 628 |
getGlobalResourceSet().getLoadOptions().put("XSD_MAGIC_XML_SCHEMA", XSDConstants.SCHEMA_FOR_SCHEMA_URI_1999); |
| 629 |
getGlobalResourceSet().getResource |
| 630 |
(URI.createURI(baseURL + "cache/www.w3.org/1999/MagicXMLSchema.xsd"), true); |
| 631 |
} |
| 632 |
catch (Exception exception) |
| 633 |
{ |
| 634 |
exception.printStackTrace(); |
| 635 |
} |
| 636 |
finally |
| 637 |
{ |
| 638 |
getGlobalResourceSet().getLoadOptions().remove("XSD_MAGIC_XML_SCHEMA"); |
| 639 |
} |
| 640 |
} |
| 641 |
|
| 642 |
return xsdMagicSchemaForSchema1999; |
| 643 |
} |
| 644 |
|
| 645 |
return null; |
| 646 |
} |
| 647 |
|
| 648 |
public static synchronized XSDSchema getSchemaForSchema(String namespace) |
| 649 |
{ |
| 650 |
if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(namespace)) |
| 651 |
{ |
| 652 |
if (xsdSchemaForSchema2001 == null) |
| 653 |
{ |
| 654 |
try |
| 655 |
{ |
| 656 |
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString(); |
| 657 |
getMagicSchemaForSchema(namespace); |
| 658 |
getGlobalResourceSet().getLoadOptions().put("XSD_XML_SCHEMA", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); |
| 659 |
getGlobalResourceSet().getResource |
| 660 |
(URI.createURI(baseURL + "cache/www.w3.org/2001/XMLSchema.xsd"), true); |
| 661 |
} |
| 662 |
catch (Exception exception) |
| 663 |
{ |
| 664 |
exception.printStackTrace(); |
| 665 |
} |
| 666 |
finally |
| 667 |
{ |
| 668 |
getGlobalResourceSet().getLoadOptions().remove("XSD_XML_SCHEMA"); |
| 669 |
} |
| 670 |
} |
| 671 |
return xsdSchemaForSchema2001; |
| 672 |
} |
| 673 |
else if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2000_10.equals(namespace)) |
| 674 |
{ |
| 675 |
if (xsdSchemaForSchema2000_10 == null) |
| 676 |
{ |
| 677 |
try |
| 678 |
{ |
| 679 |
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString(); |
| 680 |
getMagicSchemaForSchema(namespace); |
| 681 |
getGlobalResourceSet().getLoadOptions().put("XSD_XML_SCHEMA", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2000_10); |
| 682 |
getGlobalResourceSet().getResource |
| 683 |
(URI.createURI(baseURL + "cache/www.w3.org/2000/10/XMLSchema.xsd"), true); |
| 684 |
} |
| 685 |
catch (Exception exception) |
| 686 |
{ |
| 687 |
exception.printStackTrace(); |
| 688 |
} |
| 689 |
finally |
| 690 |
{ |
| 691 |
getGlobalResourceSet().getLoadOptions().remove("XSD_XML_SCHEMA"); |
| 692 |
} |
| 693 |
} |
| 694 |
return xsdSchemaForSchema2000_10; |
| 695 |
} |
| 696 |
else if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_1999.equals(namespace)) |
| 697 |
{ |
| 698 |
if (xsdSchemaForSchema1999 == null) |
| 699 |
{ |
| 700 |
try |
| 701 |
{ |
| 702 |
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString(); |
| 703 |
getMagicSchemaForSchema(namespace); |
| 704 |
getGlobalResourceSet().getLoadOptions().put("XSD_XML_SCHEMA", XSDConstants.SCHEMA_FOR_SCHEMA_URI_1999); |
| 705 |
getGlobalResourceSet().getResource |
| 706 |
(URI.createURI(baseURL + "cache/www.w3.org/1999/XMLSchema.xsd"), true); |
| 707 |
} |
| 708 |
catch (Exception exception) |
| 709 |
{ |
| 710 |
exception.printStackTrace(); |
| 711 |
} |
| 712 |
finally |
| 713 |
{ |
| 714 |
getGlobalResourceSet().getLoadOptions().remove("XSD_XML_SCHEMA"); |
| 715 |
} |
| 716 |
} |
| 717 |
return xsdSchemaForSchema1999; |
| 718 |
} |
| 719 |
return null; |
| 720 |
} |
| 721 |
|
| 722 |
public static synchronized XSDSchema getSchemaInstance(String namespace) |
| 723 |
{ |
| 724 |
if (XSDConstants.SCHEMA_INSTANCE_URI_2001.equals(namespace)) |
| 725 |
{ |
| 726 |
if (xsdSchemaInstance2001 == null) |
| 727 |
{ |
| 728 |
try |
| 729 |
{ |
| 730 |
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString(); |
| 731 |
getSchemaForSchema(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); |
| 732 |
getGlobalResourceSet().getLoadOptions().put("XSD_SCHEMA_INSTANCE", XSDConstants.SCHEMA_INSTANCE_URI_2001); |
| 733 |
Resource schemaInstance2001Resource = |
| 734 |
getGlobalResourceSet().getResource |
| 735 |
(URI.createURI(baseURL + "cache/www.w3.org/2001/XMLSchema-instance.xsd"), true); |
| 736 |
xsdSchemaInstance2001 = ((XSDResourceImpl)schemaInstance2001Resource).getSchema(); |
| 737 |
} |
| 738 |
catch (Exception exception) |
| 739 |
{ |
| 740 |
exception.printStackTrace(); |
| 741 |
} |
| 742 |
finally |
| 743 |
{ |
| 744 |
getGlobalResourceSet().getLoadOptions().remove("XSD_SCHEMA_INSTANCE"); |
| 745 |
} |
| 746 |
} |
| 747 |
return xsdSchemaInstance2001; |
| 748 |
} |
| 749 |
return null; |
| 750 |
} |
| 751 |
|
| 752 |
protected Map<String, String> qNamePrefixToNamespaceMap = |
| 753 |
new HashMap<String, String>() |
| 754 |
{ |
| 755 |
private static final long serialVersionUID = 1L; |
| 756 |
|
| 757 |
@Override |
| 758 |
public String put(String key, String value) |
| 759 |
{ |
| 760 |
if ("".equals(key)) |
| 761 |
{ |
| 762 |
throw new IllegalArgumentException("The default prefix should represented as null rather than as a zero length String"); |
| 763 |
} |
| 764 |
|
| 765 |
if (value == null) |
| 766 |
{ |
| 767 |
value = ""; |
| 768 |
} |
| 769 |
String result = super.put(key, value); |
| 770 |
if (!isReconciling) |
| 771 |
{ |
| 772 |
Element theElement = getElement(); |
| 773 |
if (theElement != null) |
| 774 |
{ |
| 775 |
String xmlnsAttribute = "xmlns"; |
| 776 |
if (key != null) |
| 777 |
{ |
| 778 |
xmlnsAttribute += ":" + key; |
| 779 |
} |
| 780 |
theElement.setAttributeNS(XSDConstants.XMLNS_URI_2000, xmlnsAttribute, value); |
| 781 |
} |
| 782 |
} |
| 783 |
return result; |
| 784 |
} |
| 785 |
|
| 786 |
@Override |
| 787 |
public String get(Object key) |
| 788 |
{ |
| 789 |
String result = super.get(key); |
| 790 |
return "".equals(result) ? null : result; |
| 791 |
} |
| 792 |
|
| 793 |
@Override |
| 794 |
public String remove(Object key) |
| 795 |
{ |
| 796 |
String result = super.remove(key); |
| 797 |
if (!isReconciling) |
| 798 |
{ |
| 799 |
if (result != null) |
| 800 |
{ |
| 801 |
if (key == null) |
| 802 |
{ |
| 803 |
key = "xmlns"; |
| 804 |
} |
| 805 |
Element theElement = getElement(); |
| 806 |
if (theElement != null && |
| 807 |
theElement.hasAttributeNS(XSDConstants.XMLNS_URI_2000, (String)key)) |
| 808 |
{ |
| 809 |
theElement.removeAttributeNS(XSDConstants.XMLNS_URI_2000, (String)key); |
| 810 |
} |
| 811 |
} |
| 812 |
} |
| 813 |
return result; |
| 814 |
} |
| 815 |
}; |
| 816 |
|
| 817 |
protected String schemaForSchemaQNamePrefix; |
| 818 |
|
| 819 |
protected boolean hasRetargetedNamespace = false; |
| 820 |
|
| 821 |
/** |
| 822 |
* <!-- begin-user-doc --> |
| 823 |
* <!-- end-user-doc --> |
| 824 |
* @generated |
| 825 |
*/ |
| 826 |
protected XSDSchemaImpl() |
| 827 |
{ |
| 828 |
super(); |
| 829 |
eFlags |= ATTRIBUTE_FORM_DEFAULT_EFLAG_DEFAULT; |
| 830 |
eFlags |= ELEMENT_FORM_DEFAULT_EFLAG_DEFAULT; |
| 831 |
} |
| 832 |
|
| 833 |
/** |
| 834 |
* <!-- begin-user-doc --> |
| 835 |
* <!-- end-user-doc --> |
| 836 |
* @generated |
| 837 |
*/ |
| 838 |
@Override |
| 839 |
protected EClass eStaticClass() |
| 840 |
{ |
| 841 |
return XSDPackage.Literals.XSD_SCHEMA; |
| 842 |
} |
| 843 |
|
| 844 |
/** |
| 845 |
* <!-- begin-user-doc --> |
| 846 |
* <!-- end-user-doc --> |
| 847 |
* @generated |
| 848 |
*/ |
| 849 |
@Override |
| 850 |
public Document getDocument() |
| 851 |
{ |
| 852 |
return document; |
| 853 |
} |
| 854 |
|
| 855 |
/** |
| 856 |
* <!-- begin-user-doc --> |
| 857 |
* <!-- end-user-doc --> |
| 858 |
* @generated |
| 859 |
*/ |
| 860 |
@Override |
| 861 |
public void setDocument(Document newDocument) |
| 862 |
{ |
| 863 |
Document oldDocument = document; |
| 864 |
document = newDocument; |
| 865 |
if (eNotificationRequired()) |
| 866 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_SCHEMA__DOCUMENT, oldDocument, document)); |
| 867 |
} |
| 868 |
|
| 869 |
/** |
| 870 |
* <!-- begin-user-doc --> |
| 871 |
* <!-- end-user-doc --> |
| 872 |
* @generated |
| 873 |
*/ |
| 874 |
@Override |
| 875 |
public String getSchemaLocation() |
| 876 |
{ |
| 877 |
return schemaLocation; |
| 878 |
} |
| 879 |
|
| 880 |
/** |
| 881 |
* <!-- begin-user-doc --> |
| 882 |
* <!-- end-user-doc --> |
| 883 |
* @generated |
| 884 |
*/ |
| 885 |
@Override |
| 886 |
public void setSchemaLocation(String newSchemaLocation) |
| 887 |
{ |
| 888 |
String oldSchemaLocation = schemaLocation; |
| 889 |
schemaLocation = newSchemaLocation; |
| 890 |
if (eNotificationRequired()) |
| 891 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_SCHEMA__SCHEMA_LOCATION, oldSchemaLocation, schemaLocation)); |
| 892 |
} |
| 893 |
|
| 894 |
/** |
| 895 |
* <!-- begin-user-doc --> |
| 896 |
* <!-- end-user-doc --> |
| 897 |
* @generated |
| 898 |
*/ |
| 899 |
@Override |
| 900 |
public String getTargetNamespace() |
| 901 |
{ |
| 902 |
return targetNamespace; |
| 903 |
} |
| 904 |
|
| 905 |
/** |
| 906 |
* <!-- begin-user-doc --> |
| 907 |
* <!-- end-user-doc --> |
| 908 |
* @generated |
| 909 |
*/ |
| 910 |
@Override |
| 911 |
public void setTargetNamespace(String newTargetNamespace) |
| 912 |
{ |
| 913 |
String oldTargetNamespace = targetNamespace; |
| 914 |
targetNamespace = newTargetNamespace; |
| 915 |
if (eNotificationRequired()) |
| 916 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_SCHEMA__TARGET_NAMESPACE, oldTargetNamespace, targetNamespace)); |
| 917 |
} |
| 918 |
|
| 919 |
/** |
| 920 |
* <!-- begin-user-doc --> |
| 921 |
* <!-- end-user-doc --> |
| 922 |
* @generated |
| 923 |
*/ |
| 924 |
@Override |
| 925 |
public XSDForm getAttributeFormDefault() |
| 926 |
{ |
| 927 |
return ATTRIBUTE_FORM_DEFAULT_EFLAG_VALUES[(eFlags & ATTRIBUTE_FORM_DEFAULT_EFLAG) >>> ATTRIBUTE_FORM_DEFAULT_EFLAG_OFFSET]; |
| 928 |
} |
| 929 |
|
| 930 |
/** |
| 931 |
* <!-- begin-user-doc --> |
| 932 |
* <!-- end-user-doc --> |
| 933 |
* @generated |
| 934 |
*/ |
| 935 |
@Override |
| 936 |
public void setAttributeFormDefault(XSDForm newAttributeFormDefault) |
| 937 |
{ |
| 938 |
XSDForm oldAttributeFormDefault = ATTRIBUTE_FORM_DEFAULT_EFLAG_VALUES[(eFlags & ATTRIBUTE_FORM_DEFAULT_EFLAG) >>> ATTRIBUTE_FORM_DEFAULT_EFLAG_OFFSET]; |
| 939 |
if (newAttributeFormDefault == null) newAttributeFormDefault = ATTRIBUTE_FORM_DEFAULT_EDEFAULT; |
| 940 |
eFlags = eFlags & ~ATTRIBUTE_FORM_DEFAULT_EFLAG | newAttributeFormDefault.ordinal() << ATTRIBUTE_FORM_DEFAULT_EFLAG_OFFSET; |
| 941 |
boolean oldAttributeFormDefaultESet = (eFlags & ATTRIBUTE_FORM_DEFAULT_ESETFLAG) != 0; |
| 942 |
eFlags |= ATTRIBUTE_FORM_DEFAULT_ESETFLAG; |
| 943 |
if (eNotificationRequired()) |
| 944 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_SCHEMA__ATTRIBUTE_FORM_DEFAULT, oldAttributeFormDefault, newAttributeFormDefault, !oldAttributeFormDefaultESet)); |
| 945 |
} |
| 946 |
|
| 947 |
/** |
| 948 |
* <!-- begin-user-doc --> |
| 949 |
* <!-- end-user-doc --> |
| 950 |
* @generated |
| 951 |
*/ |
| 952 |
@Override |
| 953 |
public void unsetAttributeFormDefault() |
| 954 |
{ |
| 955 |
XSDForm oldAttributeFormDefault = ATTRIBUTE_FORM_DEFAULT_EFLAG_VALUES[(eFlags & ATTRIBUTE_FORM_DEFAULT_EFLAG) >>> ATTRIBUTE_FORM_DEFAULT_EFLAG_OFFSET]; |
| 956 |
boolean oldAttributeFormDefaultESet = (eFlags & ATTRIBUTE_FORM_DEFAULT_ESETFLAG) != 0; |
| 957 |
eFlags = eFlags & ~ATTRIBUTE_FORM_DEFAULT_EFLAG | ATTRIBUTE_FORM_DEFAULT_EFLAG_DEFAULT; |
| 958 |
eFlags &= ~ATTRIBUTE_FORM_DEFAULT_ESETFLAG; |
| 959 |
if (eNotificationRequired()) |
| 960 |
eNotify(new ENotificationImpl(this, Notification.UNSET, XSDPackage.XSD_SCHEMA__ATTRIBUTE_FORM_DEFAULT, oldAttributeFormDefault, ATTRIBUTE_FORM_DEFAULT_EDEFAULT, oldAttributeFormDefaultESet)); |
| 961 |
} |
| 962 |
|
| 963 |
/** |
| 964 |
* <!-- begin-user-doc --> |
| 965 |
* <!-- end-user-doc --> |
| 966 |
* @generated |
| 967 |
*/ |
| 968 |
@Override |
| 969 |
public boolean isSetAttributeFormDefault() |
| 970 |
{ |
| 971 |
return (eFlags & ATTRIBUTE_FORM_DEFAULT_ESETFLAG) != 0; |
| 972 |
} |
| 973 |
|
| 974 |
/** |
| 975 |
* <!-- begin-user-doc --> |
| 976 |
* <!-- end-user-doc --> |
| 977 |
* @generated |
| 978 |
*/ |
| 979 |
@Override |
| 980 |
public XSDForm getElementFormDefault() |
| 981 |
{ |
| 982 |
return ELEMENT_FORM_DEFAULT_EFLAG_VALUES[(eFlags & ELEMENT_FORM_DEFAULT_EFLAG) >>> ELEMENT_FORM_DEFAULT_EFLAG_OFFSET]; |
| 983 |
} |
| 984 |
|
| 985 |
/** |
| 986 |
* <!-- begin-user-doc --> |
| 987 |
* <!-- end-user-doc --> |
| 988 |
* @generated |
| 989 |
*/ |
| 990 |
@Override |
| 991 |
public void setElementFormDefault(XSDForm newElementFormDefault) |
| 992 |
{ |
| 993 |
XSDForm oldElementFormDefault = ELEMENT_FORM_DEFAULT_EFLAG_VALUES[(eFlags & ELEMENT_FORM_DEFAULT_EFLAG) >>> ELEMENT_FORM_DEFAULT_EFLAG_OFFSET]; |
| 994 |
if (newElementFormDefault == null) newElementFormDefault = ELEMENT_FORM_DEFAULT_EDEFAULT; |
| 995 |
eFlags = eFlags & ~ELEMENT_FORM_DEFAULT_EFLAG | newElementFormDefault.ordinal() << ELEMENT_FORM_DEFAULT_EFLAG_OFFSET; |
| 996 |
boolean oldElementFormDefaultESet = (eFlags & ELEMENT_FORM_DEFAULT_ESETFLAG) != 0; |
| 997 |
eFlags |= ELEMENT_FORM_DEFAULT_ESETFLAG; |
| 998 |
if (eNotificationRequired()) |
| 999 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_SCHEMA__ELEMENT_FORM_DEFAULT, oldElementFormDefault, newElementFormDefault, !oldElementFormDefaultESet)); |
| 1000 |
} |
| 1001 |
|
| 1002 |
/** |
| 1003 |
* <!-- begin-user-doc --> |
| 1004 |
* <!-- end-user-doc --> |
| 1005 |
* @generated |
| 1006 |
*/ |
| 1007 |
@Override |
| 1008 |
public void unsetElementFormDefault() |
| 1009 |
{ |
| 1010 |
XSDForm oldElementFormDefault = ELEMENT_FORM_DEFAULT_EFLAG_VALUES[(eFlags & ELEMENT_FORM_DEFAULT_EFLAG) >>> ELEMENT_FORM_DEFAULT_EFLAG_OFFSET]; |
| 1011 |
boolean oldElementFormDefaultESet = (eFlags & ELEMENT_FORM_DEFAULT_ESETFLAG) != 0; |
| 1012 |
eFlags = eFlags & ~ELEMENT_FORM_DEFAULT_EFLAG | ELEMENT_FORM_DEFAULT_EFLAG_DEFAULT; |
| 1013 |
eFlags &= ~ELEMENT_FORM_DEFAULT_ESETFLAG; |
| 1014 |
if (eNotificationRequired()) |
| 1015 |
eNotify(new ENotificationImpl(this, Notification.UNSET, XSDPackage.XSD_SCHEMA__ELEMENT_FORM_DEFAULT, oldElementFormDefault, ELEMENT_FORM_DEFAULT_EDEFAULT, oldElementFormDefaultESet)); |
| 1016 |
} |
| 1017 |
|
| 1018 |
/** |
| 1019 |
* <!-- begin-user-doc --> |
| 1020 |
* <!-- end-user-doc --> |
| 1021 |
* @generated |
| 1022 |
*/ |
| 1023 |
@Override |
| 1024 |
public boolean isSetElementFormDefault() |
| 1025 |
{ |
| 1026 |
return (eFlags & ELEMENT_FORM_DEFAULT_ESETFLAG) != 0; |
| 1027 |
} |
| 1028 |
|
| 1029 |
/** |
| 1030 |
* <!-- begin-user-doc --> |
| 1031 |
* <!-- end-user-doc --> |
| 1032 |
* @generated |
| 1033 |
*/ |
| 1034 |
@Override |
| 1035 |
public EList<XSDProhibitedSubstitutions> getFinalDefault() |
| 1036 |
{ |
| 1037 |
if (finalDefault == null) |
| 1038 |
{ |
| 1039 |
finalDefault = new EDataTypeUniqueEList.Unsettable<XSDProhibitedSubstitutions>(XSDProhibitedSubstitutions.class, this, XSDPackage.XSD_SCHEMA__FINAL_DEFAULT); |
| 1040 |
} |
| 1041 |
return finalDefault; |
| 1042 |
} |
| 1043 |
|
| 1044 |
/** |
| 1045 |
* <!-- begin-user-doc --> |
| 1046 |
* <!-- end-user-doc --> |
| 1047 |
* @generated |
| 1048 |
*/ |
| 1049 |
@Override |
| 1050 |
public void unsetFinalDefault() |
| 1051 |
{ |
| 1052 |
if (finalDefault != null) ((InternalEList.Unsettable<?>)finalDefault).unset(); |
| 1053 |
} |
| 1054 |
|
| 1055 |
/** |
| 1056 |
* <!-- begin-user-doc --> |
| 1057 |
* <!-- end-user-doc --> |
| 1058 |
* @generated |
| 1059 |
*/ |
| 1060 |
@Override |
| 1061 |
public boolean isSetFinalDefault() |
| 1062 |
{ |
| 1063 |
return finalDefault != null && ((InternalEList.Unsettable<?>)finalDefault).isSet(); |
| 1064 |
} |
| 1065 |
|
| 1066 |
/** |
| 1067 |
* <!-- begin-user-doc --> |
| 1068 |
* <!-- end-user-doc --> |
| 1069 |
* @generated |
| 1070 |
*/ |
| 1071 |
@Override |
| 1072 |
public EList<XSDDisallowedSubstitutions> getBlockDefault() |
| 1073 |
{ |
| 1074 |
if (blockDefault == null) |
| 1075 |
{ |
| 1076 |
blockDefault = new EDataTypeUniqueEList.Unsettable<XSDDisallowedSubstitutions>(XSDDisallowedSubstitutions.class, this, XSDPackage.XSD_SCHEMA__BLOCK_DEFAULT); |
| 1077 |
} |
| 1078 |
return blockDefault; |
| 1079 |
} |
| 1080 |
|
| 1081 |
/** |
| 1082 |
* <!-- begin-user-doc --> |
| 1083 |
* <!-- end-user-doc --> |
| 1084 |
* @generated |
| 1085 |
*/ |
| 1086 |
@Override |
| 1087 |
public void unsetBlockDefault() |
| 1088 |
{ |
| 1089 |
if (blockDefault != null) ((InternalEList.Unsettable<?>)blockDefault).unset(); |
| 1090 |
} |
| 1091 |
|
| 1092 |
/** |
| 1093 |
* <!-- begin-user-doc --> |
| 1094 |
* <!-- end-user-doc --> |
| 1095 |
* @generated |
| 1096 |
*/ |
| 1097 |
@Override |
| 1098 |
public boolean isSetBlockDefault() |
| 1099 |
{ |
| 1100 |
return blockDefault != null && ((InternalEList.Unsettable<?>)blockDefault).isSet(); |
| 1101 |
} |
| 1102 |
|
| 1103 |
/** |
| 1104 |
* <!-- begin-user-doc --> |
| 1105 |
* <!-- end-user-doc --> |
| 1106 |
* @generated |
| 1107 |
*/ |
| 1108 |
@Override |
| 1109 |
public String getVersion() |
| 1110 |
{ |
| 1111 |
return version; |
| 1112 |
} |
| 1113 |
|
| 1114 |
/** |
| 1115 |
* <!-- begin-user-doc --> |
| 1116 |
* <!-- end-user-doc --> |
| 1117 |
* @generated |
| 1118 |
*/ |
| 1119 |
@Override |
| 1120 |
public void setVersion(String newVersion) |
| 1121 |
{ |
| 1122 |
String oldVersion = version; |
| 1123 |
version = newVersion; |
| 1124 |
if (eNotificationRequired()) |
| 1125 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_SCHEMA__VERSION, oldVersion, version)); |
| 1126 |
} |
| 1127 |
|
| 1128 |
/** |
| 1129 |
* <!-- begin-user-doc --> |
| 1130 |
* <!-- end-user-doc --> |
| 1131 |
* @generated |
| 1132 |
*/ |
| 1133 |
@Override |
| 1134 |
public EList<XSDSchemaContent> getContents() |
| 1135 |
{ |
| 1136 |
if (contents == null) |
| 1137 |
{ |
| 1138 |
contents = new EObjectContainmentEList<XSDSchemaContent>(XSDSchemaContent.class, this, XSDPackage.XSD_SCHEMA__CONTENTS); |
| 1139 |
} |
| 1140 |
return contents; |
| 1141 |
} |
| 1142 |
|
| 1143 |
/** |
| 1144 |
* <!-- begin-user-doc --> |
| 1145 |
* <!-- end-user-doc --> |
| 1146 |
* @generated NOT |
| 1147 |
*/ |
| 1148 |
public EList<XSDElementDeclaration> getElementDeclarations() |
| 1149 |
{ |
| 1150 |
if (elementDeclarations == null) |
| 1151 |
{ |
| 1152 |
elementDeclarations = new XSDNamedComponentImpl.XSDNamedComponentList<XSDElementDeclaration>(XSDElementDeclaration.class, this, XSDPackage.XSD_SCHEMA__ELEMENT_DECLARATIONS); |
| 1153 |
} |
| 1154 |
return elementDeclarations; |
| 1155 |
} |
| 1156 |
|
| 1157 |
/** |
| 1158 |
* <!-- begin-user-doc --> |
| 1159 |
* <!-- end-user-doc --> |
| 1160 |
* @generated NOT |
| 1161 |
*/ |
| 1162 |
public EList<XSDAttributeDeclaration> getAttributeDeclarations() |
| 1163 |
{ |
| 1164 |
if (attributeDeclarations == null) |
| 1165 |
{ |
| 1166 |
attributeDeclarations = new XSDNamedComponentImpl.XSDNamedComponentList<XSDAttributeDeclaration>(XSDAttributeDeclaration.class, this, XSDPackage.XSD_SCHEMA__ATTRIBUTE_DECLARATIONS); |
| 1167 |
} |
| 1168 |
return attributeDeclarations; |
| 1169 |
} |
| 1170 |
|
| 1171 |
/** |
| 1172 |
* <!-- begin-user-doc --> |
| 1173 |
* <!-- end-user-doc --> |
| 1174 |
* @generated NOT |
| 1175 |
*/ |
| 1176 |
public EList<XSDAttributeGroupDefinition> getAttributeGroupDefinitions() |
| 1177 |
{ |
| 1178 |
if (attributeGroupDefinitions == null) |
| 1179 |
{ |
| 1180 |
attributeGroupDefinitions = new XSDNamedComponentImpl.XSDNamedComponentList<XSDAttributeGroupDefinition>(XSDAttributeGroupDefinition.class, this, XSDPackage.XSD_SCHEMA__ATTRIBUTE_GROUP_DEFINITIONS); |
| 1181 |
} |
| 1182 |
return attributeGroupDefinitions; |
| 1183 |
} |
| 1184 |
|
| 1185 |
/** |
| 1186 |
* <!-- begin-user-doc --> |
| 1187 |
* <!-- end-user-doc --> |
| 1188 |
* @generated NOT |
| 1189 |
*/ |
| 1190 |
public EList<XSDTypeDefinition> getTypeDefinitions() |
| 1191 |
{ |
| 1192 |
if (typeDefinitions == null) |
| 1193 |
{ |
| 1194 |
typeDefinitions = new XSDNamedComponentImpl.XSDNamedComponentList<XSDTypeDefinition>(XSDTypeDefinition.class, this, XSDPackage.XSD_SCHEMA__TYPE_DEFINITIONS); |
| 1195 |
} |
| 1196 |
return typeDefinitions; |
| 1197 |
} |
| 1198 |
|
| 1199 |
/** |
| 1200 |
* <!-- begin-user-doc --> |
| 1201 |
* <!-- end-user-doc --> |
| 1202 |
* @generated NOT |
| 1203 |
*/ |
| 1204 |
public EList<XSDModelGroupDefinition> getModelGroupDefinitions() |
| 1205 |
{ |
| 1206 |
if (modelGroupDefinitions == null) |
| 1207 |
{ |
| 1208 |
modelGroupDefinitions = new XSDNamedComponentImpl.XSDNamedComponentList<XSDModelGroupDefinition>(XSDModelGroupDefinition.class, this, XSDPackage.XSD_SCHEMA__MODEL_GROUP_DEFINITIONS); |
| 1209 |
} |
| 1210 |
return modelGroupDefinitions; |
| 1211 |
} |
| 1212 |
|
| 1213 |
/** |
| 1214 |
* <!-- begin-user-doc --> |
| 1215 |
* <!-- end-user-doc --> |
| 1216 |
* @generated NOT |
| 1217 |
*/ |
| 1218 |
public EList<XSDIdentityConstraintDefinition> getIdentityConstraintDefinitions() |
| 1219 |
{ |
| 1220 |
if (identityConstraintDefinitions == null) |
| 1221 |
{ |
| 1222 |
identityConstraintDefinitions = new XSDNamedComponentImpl.XSDNamedComponentList<XSDIdentityConstraintDefinition>(XSDIdentityConstraintDefinition.class, this, XSDPackage.XSD_SCHEMA__IDENTITY_CONSTRAINT_DEFINITIONS); |
| 1223 |
} |
| 1224 |
return identityConstraintDefinitions; |
| 1225 |
} |
| 1226 |
|
| 1227 |
/** |
| 1228 |
* <!-- begin-user-doc --> |
| 1229 |
* <!-- end-user-doc --> |
| 1230 |
* @generated NOT |
| 1231 |
*/ |
| 1232 |
public EList<XSDNotationDeclaration> getNotationDeclarations() |
| 1233 |
{ |
| 1234 |
if (notationDeclarations == null) |
| 1235 |
{ |
| 1236 |
notationDeclarations = new XSDNamedComponentImpl.XSDNamedComponentList<XSDNotationDeclaration>(XSDNotationDeclaration.class, this, XSDPackage.XSD_SCHEMA__NOTATION_DECLARATIONS); |
| 1237 |
} |
| 1238 |
return notationDeclarations; |
| 1239 |
} |
| 1240 |
|
| 1241 |
/** |
| 1242 |
* <!-- begin-user-doc --> |
| 1243 |
* <!-- end-user-doc --> |
| 1244 |
* @generated |
| 1245 |
*/ |
| 1246 |
@Override |
| 1247 |
public EList<XSDAnnotation> getAnnotations() |
| 1248 |
{ |
| 1249 |
if (annotations == null) |
| 1250 |
{ |
| 1251 |
annotations = new EObjectEList<XSDAnnotation>(XSDAnnotation.class, this, XSDPackage.XSD_SCHEMA__ANNOTATIONS); |
| 1252 |
} |
| 1253 |
return annotations; |
| 1254 |
} |
| 1255 |
|
| 1256 |
/** |
| 1257 |
* <!-- begin-user-doc --> |
| 1258 |
* <!-- end-user-doc --> |
| 1259 |
* @generated |
| 1260 |
*/ |
| 1261 |
@Override |
| 1262 |
public EList<XSDDiagnostic> getAllDiagnostics() |
| 1263 |
{ |
| 1264 |
if (allDiagnostics == null) |
| 1265 |
{ |
| 1266 |
allDiagnostics = new EObjectEList<XSDDiagnostic>(XSDDiagnostic.class, this, XSDPackage.XSD_SCHEMA__ALL_DIAGNOSTICS); |
| 1267 |
} |
| 1268 |
return allDiagnostics; |
| 1269 |
} |
| 1270 |
|
| 1271 |
/** |
| 1272 |
* <!-- begin-user-doc --> |
| 1273 |
* <!-- end-user-doc --> |
| 1274 |
* @generated |
| 1275 |
*/ |
| 1276 |
@Override |
| 1277 |
public EList<XSDSchemaDirective> getReferencingDirectives() |
| 1278 |
{ |
| 1279 |
if (referencingDirectives == null) |
| 1280 |
{ |
| 1281 |
referencingDirectives = new EObjectEList<XSDSchemaDirective>(XSDSchemaDirective.class, this, XSDPackage.XSD_SCHEMA__REFERENCING_DIRECTIVES); |
| 1282 |
} |
| 1283 |
return referencingDirectives; |
| 1284 |
} |
| 1285 |
|
| 1286 |
public boolean hasRetargetedNamespace() |
| 1287 |
{ |
| 1288 |
return hasRetargetedNamespace; |
| 1289 |
} |
| 1290 |
|
| 1291 |
public XSDSchema getOriginalVersion() |
| 1292 |
{ |
| 1293 |
for (XSDSchemaDirective xsdSchemaDirective : getReferencingDirectives()) |
| 1294 |
{ |
| 1295 |
if (xsdSchemaDirective instanceof XSDSchemaCompositor) |
| 1296 |
{ |
| 1297 |
XSDSchemaCompositor xsdSchemaCompositor = (XSDSchemaCompositor)xsdSchemaDirective; |
| 1298 |
if (xsdSchemaCompositor.getResolvedSchema() != xsdSchemaCompositor.getIncorporatedSchema()) |
| 1299 |
{ |
| 1300 |
return xsdSchemaCompositor.getResolvedSchema(); |
| 1301 |
} |
| 1302 |
} |
| 1303 |
} |
| 1304 |
return this; |
| 1305 |
} |
| 1306 |
|
| 1307 |
/** |
| 1308 |
* <!-- begin-user-doc --> |
| 1309 |
* <!-- end-user-doc --> |
| 1310 |
* @generated |
| 1311 |
*/ |
| 1312 |
@Override |
| 1313 |
public EList<XSDSchema> getIncorporatedVersions() |
| 1314 |
{ |
| 1315 |
if (incorporatedVersions == null) |
| 1316 |
{ |
| 1317 |
incorporatedVersions = new EObjectContainmentEList<XSDSchema>(XSDSchema.class, this, XSDPackage.XSD_SCHEMA__INCORPORATED_VERSIONS); |
| 1318 |
} |
| 1319 |
return incorporatedVersions; |
| 1320 |
} |
| 1321 |
|
| 1322 |
/* |
| 1323 |
public Set getIncorporatedVersions() |
| 1324 |
{ |
| 1325 |
Set result = new HashSet(); |
| 1326 |
for (Iterator i = getReferencingDirectives().iterator(); i.hasNext(); ) |
| 1327 |
{ |
| 1328 |
XSDSchemaDirective xsdSchemaDirective = (XSDSchemaDirective)i.next(); |
| 1329 |
if (xsdSchemaDirective instanceof XSDSchemaCompositor) |
| 1330 |
{ |
| 1331 |
XSDSchemaCompositor xsdSchemaCompositor = (XSDSchemaCompositor)xsdSchemaDirective; |
| 1332 |
if (xsdSchemaCompositor.getResolvedSchema() != xsdSchemaCompositor.getIncorporatedSchema()) |
| 1333 |
{ |
| 1334 |
result.add(xsdSchemaCompositor.getIncorporatedSchema()); |
| 1335 |
} |
| 1336 |
} |
| 1337 |
} |
| 1338 |
return result; |
| 1339 |
} |
| 1340 |
*/ |
| 1341 |
|
| 1342 |
public XSDSchema getRootVersion() |
| 1343 |
{ |
| 1344 |
XSDSchema result = this; |
| 1345 |
for (XSDSchema originalVersion = result.getOriginalVersion(); |
| 1346 |
result != originalVersion; |
| 1347 |
originalVersion = result.getOriginalVersion()) |
| 1348 |
{ |
| 1349 |
result = originalVersion; |
| 1350 |
} |
| 1351 |
return result; |
| 1352 |
} |
| 1353 |
|
| 1354 |
/** |
| 1355 |
* This returns the map defined by the xmlns attributes of the underlying XML representation. |
| 1356 |
*/ |
| 1357 |
public Map<String, String> getQNamePrefixToNamespaceMap() |
| 1358 |
{ |
| 1359 |
return qNamePrefixToNamespaceMap; |
| 1360 |
} |
| 1361 |
|
| 1362 |
/** |
| 1363 |
* This returns the QName prefix used to reference the schema for schema; |
| 1364 |
* it must be a key in {@link #getQNamePrefixToNamespaceMap}. |
| 1365 |
*/ |
| 1366 |
public String getSchemaForSchemaQNamePrefix() |
| 1367 |
{ |
| 1368 |
return schemaForSchemaQNamePrefix; |
| 1369 |
} |
| 1370 |
|
| 1371 |
/** |
| 1372 |
* This sets the QName prefix used to reference the schema for schema; |
| 1373 |
* it must be a key in {@link #getQNamePrefixToNamespaceMap} that maps to a valid schema for schema namespace. |
| 1374 |
* It can also be used to rename the prefix, one it's established. |
| 1375 |
*/ |
| 1376 |
public void setSchemaForSchemaQNamePrefix(String qNamePrefix) |
| 1377 |
{ |
| 1378 |
String oldSchemaForSchemaQNamePrefix = schemaForSchemaQNamePrefix; |
| 1379 |
String oldSchemaForSchemaNamespace = getSchemaForSchemaNamespace(); |
| 1380 |
this.schemaForSchemaQNamePrefix = qNamePrefix; |
| 1381 |
String newSchemaForSchemaNamespace = getSchemaForSchemaNamespace(); |
| 1382 |
|
| 1383 |
// Rename it if there was an old one but no new one. |
| 1384 |
// |
| 1385 |
if (XSDConstants.isSchemaForSchemaNamespace(oldSchemaForSchemaNamespace) && |
| 1386 |
!XSDConstants.isSchemaForSchemaNamespace(newSchemaForSchemaNamespace)) |
| 1387 |
{ |
| 1388 |
getQNamePrefixToNamespaceMap().remove(oldSchemaForSchemaQNamePrefix); |
| 1389 |
getQNamePrefixToNamespaceMap().put(qNamePrefix, oldSchemaForSchemaNamespace); |
| 1390 |
|
| 1391 |
if (getElement() != null && XSDConstants.isSchemaForSchemaNamespace(getSchemaForSchemaNamespace())) |
| 1392 |
{ |
| 1393 |
updatePrefix(getElement(), getSchemaForSchemaNamespace(), oldSchemaForSchemaQNamePrefix, qNamePrefix); |
| 1394 |
updateElement(); |
| 1395 |
} |
| 1396 |
} |
| 1397 |
} |
| 1398 |
|
| 1399 |
/** |
| 1400 |
* This returns (String)getQNamePrefixToNamespaceMap().get(getSchemaForSchemaQNamePrefix()); |
| 1401 |
* you can't set this directly. |
| 1402 |
*/ |
| 1403 |
public String getSchemaForSchemaNamespace() |
| 1404 |
{ |
| 1405 |
return getQNamePrefixToNamespaceMap().get(getSchemaForSchemaQNamePrefix()); |
| 1406 |
} |
| 1407 |
|
| 1408 |
public String getStringBlockDefault() |
| 1409 |
{ |
| 1410 |
if (isSetBlockDefault()) |
| 1411 |
{ |
| 1412 |
StringBuffer result = new StringBuffer(); |
| 1413 |
for (Object literal : getBlockDefault()) |
| 1414 |
{ |
| 1415 |
if (result.length() != 0) |
| 1416 |
{ |
| 1417 |
result.append(' '); |
| 1418 |
} |
| 1419 |
if (literal.toString().equals("all")) |
| 1420 |
{ |
| 1421 |
result.append("#all"); |
| 1422 |
} |
| 1423 |
else |
| 1424 |
{ |
| 1425 |
result.append(literal); |
| 1426 |
} |
| 1427 |
} |
| 1428 |
return result.toString(); |
| 1429 |
} |
| 1430 |
else |
| 1431 |
{ |
| 1432 |
return null; |
| 1433 |
} |
| 1434 |
} |
| 1435 |
|
| 1436 |
public void setStringBlockDefault(String blockDefault) |
| 1437 |
{ |
| 1438 |
if (blockDefault == null) |
| 1439 |
{ |
| 1440 |
unsetBlockDefault(); |
| 1441 |
} |
| 1442 |
else |
| 1443 |
{ |
| 1444 |
List<XSDDisallowedSubstitutions> newBlockDefault = new ArrayList<XSDDisallowedSubstitutions>(); |
| 1445 |
for (StringTokenizer stringTokenizer = new StringTokenizer(blockDefault); stringTokenizer.hasMoreTokens(); ) |
| 1446 |
{ |
| 1447 |
String token = stringTokenizer.nextToken(); |
| 1448 |
if (token.equals("#all")) |
| 1449 |
{ |
| 1450 |
token = "all"; |
| 1451 |
} |
| 1452 |
XSDDisallowedSubstitutions literal = XSDDisallowedSubstitutions.get(token); |
| 1453 |
if (literal != null) |
| 1454 |
{ |
| 1455 |
newBlockDefault.add(literal); |
| 1456 |
} |
| 1457 |
} |
| 1458 |
if (!newBlockDefault.equals(getBlockDefault())) |
| 1459 |
{ |
| 1460 |
Collection<XSDDisallowedSubstitutions> oldContents = new ArrayList<XSDDisallowedSubstitutions>(getBlockDefault()); |
| 1461 |
oldContents.removeAll(newBlockDefault); |
| 1462 |
getBlockDefault().removeAll(oldContents); |
| 1463 |
setListContentAndOrder(getBlockDefault(), newBlockDefault); |
| 1464 |
} |
| 1465 |
else if (newBlockDefault.isEmpty() && !isSetBlockDefault()) |
| 1466 |
{ |
| 1467 |
getBlockDefault().clear(); |
| 1468 |
} |
| 1469 |
} |
| 1470 |
} |
| 1471 |
|
| 1472 |
public String getStringFinalDefault() |
| 1473 |
{ |
| 1474 |
if (isSetFinalDefault()) |
| 1475 |
{ |
| 1476 |
StringBuffer result = new StringBuffer(); |
| 1477 |
for (Object literal : getFinalDefault()) |
| 1478 |
{ |
| 1479 |
if (result.length() != 0) |
| 1480 |
{ |
| 1481 |
result.append(' '); |
| 1482 |
} |
| 1483 |
if (literal.toString().equals("all")) |
| 1484 |
{ |
| 1485 |
result.append("#all"); |
| 1486 |
} |
| 1487 |
else |
| 1488 |
{ |
| 1489 |
result.append(literal); |
| 1490 |
} |
| 1491 |
} |
| 1492 |
return result.toString(); |
| 1493 |
} |
| 1494 |
else |
| 1495 |
{ |
| 1496 |
return null; |
| 1497 |
} |
| 1498 |
} |
| 1499 |
|
| 1500 |
public void setStringFinalDefault(String finalDefault) |
| 1501 |
{ |
| 1502 |
if (finalDefault == null) |
| 1503 |
{ |
| 1504 |
unsetFinalDefault(); |
| 1505 |
} |
| 1506 |
else |
| 1507 |
{ |
| 1508 |
List<XSDProhibitedSubstitutions> newFinalDefault = new ArrayList<XSDProhibitedSubstitutions>(); |
| 1509 |
for (StringTokenizer stringTokenizer = new StringTokenizer(finalDefault); stringTokenizer.hasMoreTokens(); ) |
| 1510 |
{ |
| 1511 |
String token = stringTokenizer.nextToken(); |
| 1512 |
if (token.equals("#all")) |
| 1513 |
{ |
| 1514 |
token = "all"; |
| 1515 |
} |
| 1516 |
XSDProhibitedSubstitutions literal = XSDProhibitedSubstitutions.get(token); |
| 1517 |
if (literal != null) |
| 1518 |
{ |
| 1519 |
newFinalDefault.add(literal); |
| 1520 |
} |
| 1521 |
} |
| 1522 |
if (!newFinalDefault.equals(getFinalDefault())) |
| 1523 |
{ |
| 1524 |
Collection<XSDProhibitedSubstitutions> oldContents = new ArrayList<XSDProhibitedSubstitutions>(getFinalDefault()); |
| 1525 |
oldContents.removeAll(newFinalDefault); |
| 1526 |
getFinalDefault().removeAll(oldContents); |
| 1527 |
setListContentAndOrder(getFinalDefault(), newFinalDefault); |
| 1528 |
} |
| 1529 |
else if (newFinalDefault.isEmpty() && !isSetFinalDefault()) |
| 1530 |
{ |
| 1531 |
getFinalDefault().clear(); |
| 1532 |
} |
| 1533 |
} |
| 1534 |
} |
| 1535 |
|
| 1536 |
@Override |
| 1537 |
public Element createElement() |
| 1538 |
{ |
| 1539 |
Element newElement = createElement(XSDConstants.SCHEMA_ELEMENT); |
| 1540 |
setElement(newElement); |
| 1541 |
return newElement; |
| 1542 |
} |
| 1543 |
|
| 1544 |
@Override |
| 1545 |
protected void traverseToRootForPatching() |
| 1546 |
{ |
| 1547 |
if (!isReconciling && isIncrementalUpdate) |
| 1548 |
{ |
| 1549 |
isReconciling = true; |
| 1550 |
patch(); |
| 1551 |
isReconciling = false; |
| 1552 |
} |
| 1553 |
} |
| 1554 |
|
| 1555 |
protected Collection<XSDSchemaImpl> circularResolveDependencies; |
| 1556 |
|
| 1557 |
protected void computeSchemasToPatch(XSDSchema root, List<XSDSchema> schemasToPatch) |
| 1558 |
{ |
| 1559 |
schemasToPatch.add(root); |
| 1560 |
for (int i = 0; i < schemasToPatch.size(); ++i) |
| 1561 |
{ |
| 1562 |
XSDSchema xsdSchema = schemasToPatch.get(i); |
| 1563 |
for (XSDSchemaContent content : xsdSchema.getContents()) |
| 1564 |
{ |
| 1565 |
if (content instanceof XSDSchemaDirective) |
| 1566 |
{ |
| 1567 |
if (content instanceof XSDSchemaCompositor) |
| 1568 |
{ |
| 1569 |
XSDSchemaCompositor xsdSchemaCompositor = (XSDSchemaCompositor)content; |
| 1570 |
XSDSchemaImpl xsdIncorporatedSchema = (XSDSchemaImpl)xsdSchemaCompositor.getIncorporatedSchema(); |
| 1571 |
if (xsdIncorporatedSchema != null && !schemasToPatch.contains(xsdIncorporatedSchema)) |
| 1572 |
{ |
| 1573 |
xsdIncorporatedSchema.patchContents(); |
| 1574 |
schemasToPatch.add(xsdIncorporatedSchema); |
| 1575 |
} |
| 1576 |
} |
| 1577 |
} |
| 1578 |
else if (!(content instanceof XSDAnnotation)) |
| 1579 |
{ |
| 1580 |
break; |
| 1581 |
} |
| 1582 |
} |
| 1583 |
} |
| 1584 |
} |
| 1585 |
|
| 1586 |
@Override |
| 1587 |
protected void patch() |
| 1588 |
{ |
| 1589 |
circularResolveDependencies = new HashSet<XSDSchemaImpl>(); |
| 1590 |
|
| 1591 |
if (XSDConstants.isSchemaForSchemaNamespace(getTargetNamespace())) |
| 1592 |
{ |
| 1593 |
XSDSchema magicSchemaForSchema = getMagicSchemaForSchema(getTargetNamespace()); |
| 1594 |
if (magicSchemaForSchema != this) |
| 1595 |
{ |
| 1596 |
XSDNamedComponentImpl.addToSortedList |
| 1597 |
(getTypeDefinitions(), magicSchemaForSchema.getTypeDefinitions().get(0)); |
| 1598 |
} |
| 1599 |
} |
| 1600 |
else |
| 1601 |
{ |
| 1602 |
Collection<XSDSchema> xsiSchemas = resolveSchema(XSDConstants.SCHEMA_INSTANCE_URI_2001); |
| 1603 |
if (xsiSchemas.size() == 1) |
| 1604 |
{ |
| 1605 |
XSDNamedComponentImpl.mergeToSortedList |
| 1606 |
(getAttributeDeclarations(), |
| 1607 |
xsiSchemas.iterator().next().getAttributeDeclarations()); |
| 1608 |
} |
| 1609 |
} |
| 1610 |
|
| 1611 |
for (Iterator<XSDSchemaDirective> i = getReferencingDirectives().iterator(); i.hasNext(); ) |
| 1612 |
{ |
| 1613 |
XSDSchemaDirective xsdSchemaDirective = i.next(); |
| 1614 |
if (xsdSchemaDirective.getContainer() == null || |
| 1615 |
xsdSchemaDirective.getResolvedSchema() != this && |
| 1616 |
(!(xsdSchemaDirective instanceof XSDSchemaCompositor) || |
| 1617 |
((XSDSchemaCompositor)xsdSchemaDirective).getIncorporatedSchema() != this)) |
| 1618 |
{ |
| 1619 |
i.remove(); |
| 1620 |
} |
| 1621 |
} |
| 1622 |
|
| 1623 |
super.patch(); |
| 1624 |
|
| 1625 |
List<XSDSchema> schemasToPatch = new ArrayList<XSDSchema>(); |
| 1626 |
computeSchemasToPatch(this, schemasToPatch); |
| 1627 |
|
| 1628 |
if (circularResolveDependencies != null) |
| 1629 |
{ |
| 1630 |
Collection<XSDSchemaImpl> localCircularResolveDependencies = circularResolveDependencies; |
| 1631 |
circularResolveDependencies = null; |
| 1632 |
for (XSDSchemaImpl circularSchema : localCircularResolveDependencies) |
| 1633 |
{ |
| 1634 |
if (circularSchema != this) |
| 1635 |
{ |
| 1636 |
circularSchema.patch(); |
| 1637 |
} |
| 1638 |
} |
| 1639 |
} |
| 1640 |
|
| 1641 |
if (schemaLocation != null) |
| 1642 |
{ |
| 1643 |
for (int i = 0, size = schemasToPatch.size(); i < size; ++i) |
| 1644 |
{ |
| 1645 |
XSDSchemaImpl xsdSchema = (XSDSchemaImpl)schemasToPatch.get(i); |
| 1646 |
xsdSchema.analyze(); |
| 1647 |
} |
| 1648 |
} |
| 1649 |
} |
| 1650 |
|
| 1651 |
protected void patchContents() |
| 1652 |
{ |
| 1653 |
incorporatingSchemas = null; |
| 1654 |
super.patch(); |
| 1655 |
} |
| 1656 |
|
| 1657 |
@Override |
| 1658 |
protected void traverseToRootForAnalysis() |
| 1659 |
{ |
| 1660 |
if (!isReconciling && isIncrementalUpdate) |
| 1661 |
{ |
| 1662 |
isReconciling = true; |
| 1663 |
analyze(); |
| 1664 |
isReconciling = false; |
| 1665 |
} |
| 1666 |
} |
| 1667 |
|
| 1668 |
@Override |
| 1669 |
protected boolean analyze() |
| 1670 |
{ |
| 1671 |
return super.analyze(); |
| 1672 |
} |
| 1673 |
|
| 1674 |
@Override |
| 1675 |
public void validate() |
| 1676 |
{ |
| 1677 |
super.validate(); |
| 1678 |
|
| 1679 |
Element theElement = getElement(); |
| 1680 |
if (theElement != null) |
| 1681 |
{ |
| 1682 |
if (XSDConstants.nodeType(element) != XSDConstants.SCHEMA_ELEMENT) |
| 1683 |
{ |
| 1684 |
createDiagnostic |
| 1685 |
(XSDDiagnosticSeverity.ERROR_LITERAL, |
| 1686 |
"content-valid.1", |
| 1687 |
(element.getNamespaceURI() == null ? "" : element.getNamespaceURI()) + "#" + element.getLocalName(), |
| 1688 |
XSDPlugin.INSTANCE.getString("_UI_XML_SCHEMA_name"), |
| 1689 |
"schema"); |
| 1690 |
} |
| 1691 |
else |
| 1692 |
{ |
| 1693 |
if (getContainer() == null || !eContainmentFeature().isTransient()) |
| 1694 |
{ |
| 1695 |
checkAttributes |
| 1696 |
(XSDConstants.PART1, |
| 1697 |
"element-complexType", |
| 1698 |
theElement, |
| 1699 |
new String [] |
| 1700 |
{ |
| 1701 |
XSDConstants.ATTRIBUTEFORMDEFAULT_ATTRIBUTE, |
| 1702 |
XSDConstants.BLOCKDEFAULT_ATTRIBUTE, |
| 1703 |
XSDConstants.ELEMENTFORMDEFAULT_ATTRIBUTE, |
| 1704 |
XSDConstants.FINALDEFAULT_ATTRIBUTE, |
| 1705 |
XSDConstants.ID_ATTRIBUTE, |
| 1706 |
XSDConstants.TARGETNAMESPACE_ATTRIBUTE, |
| 1707 |
XSDConstants.VERSION_ATTRIBUTE |
| 1708 |
}); |
| 1709 |
|
| 1710 |
XSDComplexTypeDefinition xsdComplexTypeDefinition = |
| 1711 |
(XSDComplexTypeDefinition)getSchemaForSchema().resolveElementDeclaration("schema").getTypeDefinition(); |
| 1712 |
|
| 1713 |
checkComplexContent |
| 1714 |
(xsdComplexTypeDefinition, |
| 1715 |
XSDConstants.PART1, |
| 1716 |
"element-schema", |
| 1717 |
theElement); |
| 1718 |
|
| 1719 |
checkAttributeTypeConstraint |
| 1720 |
(xsdComplexTypeDefinition, |
| 1721 |
"attributeFormDefault", |
| 1722 |
null, |
| 1723 |
XSDConstants.PART1, |
| 1724 |
"element-schema", |
| 1725 |
theElement, |
| 1726 |
XSDConstants.ATTRIBUTEFORMDEFAULT_ATTRIBUTE, |
| 1727 |
false); |
| 1728 |
|
| 1729 |
checkAttributeTypeConstraint |
| 1730 |
(xsdComplexTypeDefinition, |
| 1731 |
"blockDefault", |
| 1732 |
null, |
| 1733 |
XSDConstants.PART1, |
| 1734 |
"element-schema", |
| 1735 |
theElement, |
| 1736 |
XSDConstants.BLOCKDEFAULT_ATTRIBUTE, |
| 1737 |
false); |
| 1738 |
|
| 1739 |
checkAttributeTypeConstraint |
| 1740 |
(xsdComplexTypeDefinition, |
| 1741 |
"elementFormDefault", |
| 1742 |
null, |
| 1743 |
XSDConstants.PART1, |
| 1744 |
"element-schema", |
| 1745 |
theElement, |
| 1746 |
XSDConstants.ELEMENTFORMDEFAULT_ATTRIBUTE, |
| 1747 |
false); |
| 1748 |
|
| 1749 |
checkAttributeTypeConstraint |
| 1750 |
(xsdComplexTypeDefinition, |
| 1751 |
"finalDefault", |
| 1752 |
null, |
| 1753 |
XSDConstants.PART1, |
| 1754 |
"element-schema", |
| 1755 |
theElement, |
| 1756 |
XSDConstants.FINALDEFAULT_ATTRIBUTE, |
| 1757 |
false); |
| 1758 |
|
| 1759 |
checkBuiltInTypeConstraint |
| 1760 |
("ID", |
| 1761 |
null, |
| 1762 |
XSDConstants.PART1, |
| 1763 |
"element-schema", |
| 1764 |
theElement, |
| 1765 |
XSDConstants.ID_ATTRIBUTE, |
| 1766 |
false); |
| 1767 |
} |
| 1768 |
} |
| 1769 |
} |
| 1770 |
|
| 1771 |
if (getSchemaForSchema() != null) |
| 1772 |
{ |
| 1773 |
checkBuiltInTypeConstraint |
| 1774 |
("anyURI", |
| 1775 |
getTargetNamespace(), |
| 1776 |
XSDConstants.PART1, |
| 1777 |
"element-schema", |
| 1778 |
theElement, |
| 1779 |
XSDConstants.TARGETNAMESPACE_ATTRIBUTE, |
| 1780 |
false); |
| 1781 |
|
| 1782 |
checkBuiltInTypeConstraint |
| 1783 |
("token", |
| 1784 |
getVersion(), |
| 1785 |
XSDConstants.PART1, |
| 1786 |
"element-schema", |
| 1787 |
theElement, |
| 1788 |
XSDConstants.VERSION_ATTRIBUTE, |
| 1789 |
false); |
| 1790 |
|
| 1791 |
validateNoDuplicates("attribute_noun", getAttributeDeclarations()); |
| 1792 |
validateNoDuplicates("attributeGroup_noun", getAttributeGroupDefinitions()); |
| 1793 |
validateNoDuplicates("modelGroup_noun", getModelGroupDefinitions()); |
| 1794 |
validateNoDuplicates("element_noun", getElementDeclarations()); |
| 1795 |
validateNoDuplicates("type_noun", getTypeDefinitions()); |
| 1796 |
validateNoDuplicates("identityConstraint_noun", getIdentityConstraintDefinitions()); |
| 1797 |
validateNoDuplicates("notation_noun", getNotationDeclarations()); |
| 1798 |
} |
| 1799 |
} |
| 1800 |
|
| 1801 |
public void validateNoDuplicates(String componentNoun, EList<? extends XSDNamedComponent> xsdNamedComponents) |
| 1802 |
{ |
| 1803 |
String name = null; |
| 1804 |
String targetNamespace = null; |
| 1805 |
|
| 1806 |
|
| 1807 |
for (XSDNamedComponent xsdNamedComponent : xsdNamedComponents) |
| 1808 |
{ |
| 1809 |
if (xsdNamedComponent.hasNameAndTargetNamespace(name, targetNamespace)) |
| 1810 |
{ |
| 1811 |
getDiagnosticTarget(xsdNamedComponent).createDiagnostic |
| 1812 |
(XSDDiagnosticSeverity.ERROR_LITERAL, |
| 1813 |
"coss-schema.2", |
| 1814 |
XSDPlugin.INSTANCE.getString(componentNoun), |
| 1815 |
xsdNamedComponent.getURI()); |
| 1816 |
} |
| 1817 |
|
| 1818 |
name = xsdNamedComponent.getName(); |
| 1819 |
targetNamespace = xsdNamedComponent.getTargetNamespace(); |
| 1820 |
} |
| 1821 |
} |
| 1822 |
|
| 1823 |
protected void updateSortedList(XSDNamedComponent xsdNamedComponent) |
| 1824 |
{ |
| 1825 |
new XSDSwitch<Object>() |
| 1826 |
{ |
| 1827 |
@Override |
| 1828 |
public Object caseXSDElementDeclaration(XSDElementDeclaration xsdElementDeclaration) |
| 1829 |
{ |
| 1830 |
if (getElementDeclarations().remove(xsdElementDeclaration)) |
| 1831 |
{ |
| 1832 |
XSDNamedComponentImpl.addToSortedList(getElementDeclarations(), xsdElementDeclaration); |
| 1833 |
} |
| 1834 |
return this; |
| 1835 |
} |
| 1836 |
@Override |
| 1837 |
public Object caseXSDAttributeDeclaration(XSDAttributeDeclaration xsdAttributeDeclaration) |
| 1838 |
{ |
| 1839 |
if (getAttributeDeclarations().remove(xsdAttributeDeclaration)) |
| 1840 |
{ |
| 1841 |
XSDNamedComponentImpl.addToSortedList(getAttributeDeclarations(), xsdAttributeDeclaration); |
| 1842 |
} |
| 1843 |
return this; |
| 1844 |
} |
| 1845 |
@Override |
| 1846 |
public Object caseXSDAttributeGroupDefinition(XSDAttributeGroupDefinition xsdAttributeGroupDefinition) |
| 1847 |
{ |
| 1848 |
if (getAttributeGroupDefinitions().remove(xsdAttributeGroupDefinition)) |
| 1849 |
{ |
| 1850 |
XSDNamedComponentImpl.addToSortedList(getAttributeGroupDefinitions(), xsdAttributeGroupDefinition); |
| 1851 |
} |
| 1852 |
return this; |
| 1853 |
} |
| 1854 |
@Override |
| 1855 |
public Object caseXSDTypeDefinition(XSDTypeDefinition xsdTypeDefinition) |
| 1856 |
{ |
| 1857 |
if (getTypeDefinitions().remove(xsdTypeDefinition)) |
| 1858 |
{ |
| 1859 |
XSDNamedComponentImpl.addToSortedList(getTypeDefinitions(), xsdTypeDefinition); |
| 1860 |
} |
| 1861 |
return this; |
| 1862 |
} |
| 1863 |
@Override |
| 1864 |
public Object caseXSDModelGroupDefinition(XSDModelGroupDefinition xsdModelGroupDefinition) |
| 1865 |
{ |
| 1866 |
if (getModelGroupDefinitions().remove(xsdModelGroupDefinition)) |
| 1867 |
{ |
| 1868 |
XSDNamedComponentImpl.addToSortedList(getModelGroupDefinitions(), xsdModelGroupDefinition); |
| 1869 |
} |
| 1870 |
return this; |
| 1871 |
} |
| 1872 |
@Override |
| 1873 |
public Object caseXSDNotationDeclaration(XSDNotationDeclaration xsdNotationDeclaration) |
| 1874 |
{ |
| 1875 |
if (getNotationDeclarations().remove(xsdNotationDeclaration)) |
| 1876 |
{ |
| 1877 |
XSDNamedComponentImpl.addToSortedList(getNotationDeclarations(), xsdNotationDeclaration); |
| 1878 |
} |
| 1879 |
return this; |
| 1880 |
} |
| 1881 |
@Override |
| 1882 |
public Object caseXSDIdentityConstraintDefinition(XSDIdentityConstraintDefinition xsdIdentityConstraintDefinition) |
| 1883 |
{ |
| 1884 |
if (getIdentityConstraintDefinitions().remove(xsdIdentityConstraintDefinition)) |
| 1885 |
{ |
| 1886 |
XSDNamedComponentImpl.addToSortedList(getIdentityConstraintDefinitions(), xsdIdentityConstraintDefinition); |
| 1887 |
} |
| 1888 |
return this; |
| 1889 |
} |
| 1890 |
}.doSwitch(xsdNamedComponent); |
| 1891 |
} |
| 1892 |
|
| 1893 |
@Override |
| 1894 |
protected void adoptContent(EReference eReference, XSDConcreteComponent xsdConcreteComponent) |
| 1895 |
{ |
| 1896 |
super.adoptContent(eReference, xsdConcreteComponent); |
| 1897 |
if (eReference == XSDPackage.Literals.XSD_SCHEMA__CONTENTS) |
| 1898 |
{ |
| 1899 |
new XSDSwitch<Object>() |
| 1900 |
{ |
| 1901 |
@Override |
| 1902 |
public Object caseXSDElementDeclaration(XSDElementDeclaration xsdElementDeclaration) |
| 1903 |
{ |
| 1904 |
XSDNamedComponentImpl.addToSortedList(getElementDeclarations(), xsdElementDeclaration); |
| 1905 |
return this; |
| 1906 |
} |
| 1907 |
@Override |
| 1908 |
public Object caseXSDAttributeDeclaration(XSDAttributeDeclaration xsdAttributeDeclaration) |
| 1909 |
{ |
| 1910 |
XSDNamedComponentImpl.addToSortedList(getAttributeDeclarations(), xsdAttributeDeclaration); |
| 1911 |
return this; |
| 1912 |
} |
| 1913 |
@Override |
| 1914 |
public Object caseXSDAttributeGroupDefinition(XSDAttributeGroupDefinition xsdAttributeGroupDefinition) |
| 1915 |
{ |
| 1916 |
XSDNamedComponentImpl.addToSortedList(getAttributeGroupDefinitions(), xsdAttributeGroupDefinition); |
| 1917 |
return this; |
| 1918 |
} |
| 1919 |
@Override |
| 1920 |
public Object caseXSDTypeDefinition(XSDTypeDefinition xsdTypeDefinition) |
| 1921 |
{ |
| 1922 |
XSDNamedComponentImpl.addToSortedList(getTypeDefinitions(), xsdTypeDefinition); |
| 1923 |
return this; |
| 1924 |
} |
| 1925 |
@Override |
| 1926 |
public Object caseXSDModelGroupDefinition(XSDModelGroupDefinition xsdModelGroupDefinition) |
| 1927 |
{ |
| 1928 |
XSDNamedComponentImpl.addToSortedList(getModelGroupDefinitions(), xsdModelGroupDefinition); |
| 1929 |
return this; |
| 1930 |
} |
| 1931 |
@Override |
| 1932 |
public Object caseXSDNotationDeclaration(XSDNotationDeclaration xsdNotationDeclaration) |
| 1933 |
{ |
| 1934 |
XSDNamedComponentImpl.addToSortedList(getNotationDeclarations(), xsdNotationDeclaration); |
| 1935 |
return this; |
| 1936 |
} |
| 1937 |
@Override |
| 1938 |
public Object caseXSDAnnotation(XSDAnnotation xsdAnnotation) |
| 1939 |
{ |
| 1940 |
getAnnotations().add(xsdAnnotation); |
| 1941 |
return this; |
| 1942 |
} |
| 1943 |
}.doSwitch(xsdConcreteComponent); |
| 1944 |
|
| 1945 |
traverseToRootForPatching(); |
| 1946 |
} |
| 1947 |
} |
| 1948 |
|
| 1949 |
@Override |
| 1950 |
protected void orphanContent(EReference eReference, XSDConcreteComponent xsdConcreteComponent) |
| 1951 |
{ |
| 1952 |
super.orphanContent(eReference, xsdConcreteComponent); |
| 1953 |
if (eReference == XSDPackage.Literals.XSD_SCHEMA__CONTENTS) |
| 1954 |
{ |
| 1955 |
new XSDSwitch<Object>() |
| 1956 |
{ |
| 1957 |
@Override |
| 1958 |
public Object caseXSDElementDeclaration(XSDElementDeclaration xsdElementDeclaration) |
| 1959 |
{ |
| 1960 |
getElementDeclarations().remove(xsdElementDeclaration); |
| 1961 |
return this; |
| 1962 |
} |
| 1963 |
@Override |
| 1964 |
public Object caseXSDAttributeDeclaration(XSDAttributeDeclaration xsdAttributeDeclaration) |
| 1965 |
{ |
| 1966 |
getAttributeDeclarations().remove(xsdAttributeDeclaration); |
| 1967 |
return this; |
| 1968 |
} |
| 1969 |
@Override |
| 1970 |
public Object caseXSDAttributeGroupDefinition(XSDAttributeGroupDefinition xsdAttributeGroupDefinition) |
| 1971 |
{ |
| 1972 |
getAttributeGroupDefinitions().remove(xsdAttributeGroupDefinition); |
| 1973 |
return this; |
| 1974 |
} |
| 1975 |
@Override |
| 1976 |
public Object caseXSDTypeDefinition(XSDTypeDefinition xsdTypeDefinition) |
| 1977 |
{ |
| 1978 |
getTypeDefinitions().remove(xsdTypeDefinition); |
| 1979 |
return this; |
| 1980 |
} |
| 1981 |
@Override |
| 1982 |
public Object caseXSDModelGroupDefinition(XSDModelGroupDefinition xsdModelGroupDefinition) |
| 1983 |
{ |
| 1984 |
getModelGroupDefinitions().remove(xsdModelGroupDefinition); |
| 1985 |
return this; |
| 1986 |
} |
| 1987 |
@Override |
| 1988 |
public Object caseXSDNotationDeclaration(XSDNotationDeclaration xsdNotationDeclaration) |
| 1989 |
{ |
| 1990 |
getNotationDeclarations().remove(xsdNotationDeclaration); |
| 1991 |
return this; |
| 1992 |
} |
| 1993 |
@Override |
| 1994 |
public Object caseXSDAnnotation(XSDAnnotation xsdAnnotation) |
| 1995 |
{ |
| 1996 |
getAnnotations().remove(xsdAnnotation); |
| 1997 |
return this; |
| 1998 |
} |
| 1999 |
}.doSwitch(xsdConcreteComponent); |
| 2000 |
|
| 2001 |
traverseToRootForPatching(); |
| 2002 |
} |
| 2003 |
} |
| 2004 |
|
| 2005 |
@Override |
| 2006 |
protected void reconcileAttributes(Element changedElement) |
| 2007 |
{ |
| 2008 |
super.reconcileAttributes(changedElement); |
| 2009 |
|
| 2010 |
if (changedElement == getElement()) |
| 2011 |
{ |
| 2012 |
if (changedElement.hasAttributeNS(null, XSDConstants.VERSION_ATTRIBUTE)) |
| 2013 |
{ |
| 2014 |
String newVersion = changedElement.getAttributeNS(null, XSDConstants.VERSION_ATTRIBUTE); |
| 2015 |
if (!newVersion.equals(getVersion())) |
| 2016 |
{ |
| 2017 |
setVersion(newVersion); |
| 2018 |
} |
| 2019 |
} |
| 2020 |
else if (getVersion() != null) |
| 2021 |
{ |
| 2022 |
setVersion(null); |
| 2023 |
} |
| 2024 |
|
| 2025 |
if (changedElement.hasAttributeNS(null, XSDConstants.TARGETNAMESPACE_ATTRIBUTE)) |
| 2026 |
{ |
| 2027 |
String newTargetNamespace = changedElement.getAttributeNS(null, XSDConstants.TARGETNAMESPACE_ATTRIBUTE); |
| 2028 |
if (!newTargetNamespace.equals(getTargetNamespace())) |
| 2029 |
{ |
| 2030 |
setTargetNamespace(newTargetNamespace); |
| 2031 |
} |
| 2032 |
} |
| 2033 |
else if (getTargetNamespace() != null) |
| 2034 |
{ |
| 2035 |
setTargetNamespace(null); |
| 2036 |
} |
| 2037 |
|
| 2038 |
if (changedElement.hasAttributeNS(null, XSDConstants.ATTRIBUTEFORMDEFAULT_ATTRIBUTE)) |
| 2039 |
{ |
| 2040 |
XSDForm newAttributeFormDefault = XSDForm.get(changedElement.getAttributeNS(null, XSDConstants.ATTRIBUTEFORMDEFAULT_ATTRIBUTE)); |
| 2041 |
if (!isSetAttributeFormDefault() || newAttributeFormDefault != getAttributeFormDefault()) |
| 2042 |
{ |
| 2043 |
setAttributeFormDefault(newAttributeFormDefault); |
| 2044 |
} |
| 2045 |
} |
| 2046 |
else if (isSetAttributeFormDefault()) |
| 2047 |
{ |
| 2048 |
unsetAttributeFormDefault(); |
| 2049 |
} |
| 2050 |
if (changedElement.hasAttributeNS(null, XSDConstants.ELEMENTFORMDEFAULT_ATTRIBUTE)) |
| 2051 |
{ |
| 2052 |
XSDForm newElementFormDefault = XSDForm.get(changedElement.getAttributeNS(null, XSDConstants.ELEMENTFORMDEFAULT_ATTRIBUTE)); |
| 2053 |
if (!isSetElementFormDefault() || newElementFormDefault != getElementFormDefault()) |
| 2054 |
{ |
| 2055 |
setElementFormDefault(newElementFormDefault); |
| 2056 |
} |
| 2057 |
} |
| 2058 |
else if (isSetElementFormDefault()) |
| 2059 |
{ |
| 2060 |
unsetElementFormDefault(); |
| 2061 |
} |
| 2062 |
|
| 2063 |
if (changedElement.hasAttributeNS(null, XSDConstants.BLOCKDEFAULT_ATTRIBUTE)) |
| 2064 |
{ |
| 2065 |
setStringBlockDefault(changedElement.getAttributeNS(null, XSDConstants.BLOCKDEFAULT_ATTRIBUTE)); |
| 2066 |
} |
| 2067 |
else if (isSetBlockDefault()) |
| 2068 |
{ |
| 2069 |
unsetBlockDefault(); |
| 2070 |
} |
| 2071 |
|
| 2072 |
if (changedElement.hasAttributeNS(null, XSDConstants.FINALDEFAULT_ATTRIBUTE)) |
| 2073 |
{ |
| 2074 |
setStringFinalDefault(changedElement.getAttributeNS(null, XSDConstants.FINALDEFAULT_ATTRIBUTE)); |
| 2075 |
} |
| 2076 |
else if (isSetFinalDefault()) |
| 2077 |
{ |
| 2078 |
unsetFinalDefault(); |
| 2079 |
} |
| 2080 |
|
| 2081 |
Map<String, String> theQNamePrefixToNamespaceMap = getQNamePrefixToNamespaceMap(); |
| 2082 |
theQNamePrefixToNamespaceMap.clear(); |
| 2083 |
for (Element currentElement = changedElement; ; ) |
| 2084 |
{ |
| 2085 |
NamedNodeMap attributes = currentElement.getAttributes(); |
| 2086 |
for (int i = 0, size = attributes.getLength(); i < size; ++i) |
| 2087 |
{ |
| 2088 |
Attr attr = (Attr)attributes.item(i); |
| 2089 |
String name = attr.getNodeName(); |
| 2090 |
if (name.startsWith("xmlns")) |
| 2091 |
{ |
| 2092 |
String value = attr.getNodeValue(); |
| 2093 |
int index = name.indexOf(":"); |
| 2094 |
String key = index == -1 || index == name.length() - 1? null : name.substring(index + 1); |
| 2095 |
if (!theQNamePrefixToNamespaceMap.containsKey(key)) |
| 2096 |
{ |
| 2097 |
theQNamePrefixToNamespaceMap.put(key, value); |
| 2098 |
} |
| 2099 |
} |
| 2100 |
} |
| 2101 |
Node parent = currentElement.getParentNode(); |
| 2102 |
if (parent instanceof Element) |
| 2103 |
{ |
| 2104 |
currentElement = (Element)parent; |
| 2105 |
} |
| 2106 |
else |
| 2107 |
{ |
| 2108 |
break; |
| 2109 |
} |
| 2110 |
} |
| 2111 |
|
| 2112 |
String nodeName = changedElement.getNodeName(); |
| 2113 |
int index = nodeName.indexOf(":"); |
| 2114 |
setSchemaForSchemaQNamePrefix(index == -1 ? null : nodeName.substring(0, index)); |
| 2115 |
} |
| 2116 |
} |
| 2117 |
|
| 2118 |
@Override |
| 2119 |
protected void handleUnreconciledElement(Element child, List<XSDConcreteComponent> newContents, List<XSDConcreteComponent> remainingContents) |
| 2120 |
{ |
| 2121 |
XSDSchemaContent xsdSchemaContent = XSDSchemaContentImpl.createSchemaContent(child); |
| 2122 |
if (xsdSchemaContent != null) |
| 2123 |
{ |
| 2124 |
newContents.add(xsdSchemaContent); |
| 2125 |
} |
| 2126 |
} |
| 2127 |
|
| 2128 |
@Override |
| 2129 |
protected void handleReconciliation(List<XSDConcreteComponent> newContents, List<XSDConcreteComponent> remainingContents) |
| 2130 |
{ |
| 2131 |
if (!remainingContents.isEmpty()) |
| 2132 |
{ |
| 2133 |
getContents().removeAll(remainingContents); |
| 2134 |
} |
| 2135 |
|
| 2136 |
@SuppressWarnings("unchecked") List<XSDSchemaContent> list = (List<XSDSchemaContent>)(List<?>)newContents; |
| 2137 |
setListContentAndOrder(getContents(), list); |
| 2138 |
} |
| 2139 |
|
| 2140 |
public XSDConcreteComponent getCorrespondingComponent(Node node) |
| 2141 |
{ |
| 2142 |
// We consider all parents so that they can handle other contained nodes that otherwise don't correspond to a component. |
| 2143 |
// |
| 2144 |
List<Element> parents = new ArrayList<Element>(); |
| 2145 |
|
| 2146 |
if (node.getNodeType() == Node.ATTRIBUTE_NODE) |
| 2147 |
{ |
| 2148 |
node = ((Attr)node).getOwnerElement(); |
| 2149 |
} |
| 2150 |
else |
| 2151 |
{ |
| 2152 |
// Skip ahead to an element. |
| 2153 |
// |
| 2154 |
for (Node scanNode = node; scanNode != null; scanNode = scanNode.getNextSibling()) |
| 2155 |
{ |
| 2156 |
if (scanNode.getNodeType() == Node.ELEMENT_NODE) |
| 2157 |
{ |
| 2158 |
node = scanNode; |
| 2159 |
break; |
| 2160 |
} |
| 2161 |
} |
| 2162 |
|
| 2163 |
// Skip back to an element. |
| 2164 |
// |
| 2165 |
for (Node scanNode = node; scanNode != null; scanNode = scanNode.getPreviousSibling()) |
| 2166 |
{ |
| 2167 |
if (scanNode.getNodeType() == Node.ELEMENT_NODE) |
| 2168 |
{ |
| 2169 |
node = scanNode; |
| 2170 |
break; |
| 2171 |
} |
| 2172 |
} |
| 2173 |
} |
| 2174 |
|
| 2175 |
// Navigate out through the elements. |
| 2176 |
// |
| 2177 |
for (Node parent = node; parent != null; parent = parent.getParentNode()) |
| 2178 |
{ |
| 2179 |
if (parent.getNodeType() == Node.ELEMENT_NODE) |
| 2180 |
{ |
| 2181 |
parents.add((Element)parent); |
| 2182 |
} |
| 2183 |
} |
| 2184 |
|
| 2185 |
XSDConcreteComponent bestXSDConcreteComponent = getBestConcreteComponent(parents); |
| 2186 |
return bestXSDConcreteComponent; |
| 2187 |
} |
| 2188 |
|
| 2189 |
protected Map<String, XSDSimpleTypeDefinition> simpleTypeIdMap; |
| 2190 |
public Map<String, XSDSimpleTypeDefinition> getSimpleTypeIdMap() |
| 2191 |
{ |
| 2192 |
if (simpleTypeIdMap == null) |
| 2193 |
{ |
| 2194 |
simpleTypeIdMap = new HashMap<String, XSDSimpleTypeDefinition>(); |
| 2195 |
for (XSDTypeDefinition xsdTypeDefinition : getTypeDefinitions()) |
| 2196 |
{ |
| 2197 |
if (xsdTypeDefinition instanceof XSDSimpleTypeDefinition) |
| 2198 |
{ |
| 2199 |
Element theElement = xsdTypeDefinition.getElement(); |
| 2200 |
if (theElement != null) |
| 2201 |
{ |
| 2202 |
if (theElement.hasAttributeNS(null, XSDConstants.ID_ATTRIBUTE) && xsdTypeDefinition instanceof XSDSimpleTypeDefinition) |
| 2203 |
{ |
| 2204 |
simpleTypeIdMap.put(theElement.getAttributeNS(null, XSDConstants.ID_ATTRIBUTE), (XSDSimpleTypeDefinition)xsdTypeDefinition); |
| 2205 |
} |
| 2206 |
} |
| 2207 |
} |
| 2208 |
} |
| 2209 |
} |
| 2210 |
return simpleTypeIdMap; |
| 2211 |
} |
| 2212 |
|
| 2213 |
protected List<XSDSchema> incorporatingSchemas; |
| 2214 |
|
| 2215 |
protected List<XSDSchema> getIncorporatingSchemas() |
| 2216 |
{ |
| 2217 |
if (incorporatingSchemas == null) |
| 2218 |
{ |
| 2219 |
List<XSDSchema> visited = new UniqueEList.FastCompare<XSDSchema>(); |
| 2220 |
visited.add(this); |
| 2221 |
incorporatingSchemas = new ArrayList<XSDSchema>(); |
| 2222 |
for (int i = 0; i < visited.size(); ++i) |
| 2223 |
{ |
| 2224 |
XSDSchemaImpl xsdSchema = (XSDSchemaImpl)visited.get(i); |
| 2225 |
incorporatingSchemas.add(xsdSchema); |
| 2226 |
for (XSDSchemaDirective xsdSchemaDirective : xsdSchema.getReferencingDirectives()) |
| 2227 |
{ |
| 2228 |
if (xsdSchemaDirective instanceof XSDSchemaCompositor && ((XSDSchemaCompositor)xsdSchemaDirective).getIncorporatedSchema() == xsdSchema) |
| 2229 |
{ |
| 2230 |
XSDSchemaImpl incorporatingSchema = (XSDSchemaImpl)xsdSchemaDirective.getSchema(); |
| 2231 |
if (incorporatingSchema != null && visited.add(incorporatingSchema)) |
| 2232 |
{ |
| 2233 |
incorporatingSchemas.add(incorporatingSchema); |
| 2234 |
visited.addAll(incorporatingSchema.getIncorporatingSchemas()); |
| 2235 |
} |
| 2236 |
} |
| 2237 |
} |
| 2238 |
} |
| 2239 |
} |
| 2240 |
return incorporatingSchemas; |
| 2241 |
} |
| 2242 |
|
| 2243 |
/** |
| 2244 |
* This returns set of schemas with the given namespace as it's target namespace. |
| 2245 |
*/ |
| 2246 |
public Collection<XSDSchema> resolveSchema(String namespace) |
| 2247 |
{ |
| 2248 |
if ("".equals(namespace)) |
| 2249 |
{ |
| 2250 |
namespace = null; |
| 2251 |
} |
| 2252 |
|
| 2253 |
if (namespace == null ? getTargetNamespace() == null || "".equals(getTargetNamespace()) || hasRetargetedNamespace() : namespace.equals(getTargetNamespace())) |
| 2254 |
{ |
| 2255 |
return getIncorporatingSchemas(); |
| 2256 |
} |
| 2257 |
else if (XSDConstants.isSchemaInstanceNamespace(namespace)) |
| 2258 |
{ |
| 2259 |
return Collections.singleton(getSchemaInstance(namespace)); |
| 2260 |
} |
| 2261 |
else |
| 2262 |
{ |
| 2263 |
Collection<XSDSchema> result = new ArrayList<XSDSchema>(); |
| 2264 |
for (XSDSchemaContent xsdSchemaContent : getContents()) |
| 2265 |
{ |
| 2266 |
if (xsdSchemaContent instanceof XSDSchemaDirective) |
| 2267 |
{ |
| 2268 |
if (xsdSchemaContent instanceof XSDImport) |
| 2269 |
{ |
| 2270 |
XSDImport xsdImport = (XSDImport)xsdSchemaContent; |
| 2271 |
String importNamespace = xsdImport.getNamespace(); |
| 2272 |
if (namespace == null ? importNamespace == null || "".equals(importNamespace): namespace.equals(importNamespace)) |
| 2273 |
{ |
| 2274 |
XSDSchema importedSchema = ((XSDImportImpl)xsdImport).importSchema(); |
| 2275 |
if (importedSchema != null) |
| 2276 |
{ |
| 2277 |
result.add(importedSchema); |
| 2278 |
Collection<XSDSchemaImpl> circular = ((XSDSchemaImpl)importedSchema).circularResolveDependencies; |
| 2279 |
if (circular != null) |
| 2280 |
{ |
| 2281 |
circular.add(this); |
| 2282 |
} |
| 2283 |
} |
| 2284 |
} |
| 2285 |
} |
| 2286 |
} |
| 2287 |
else if (!(xsdSchemaContent instanceof XSDAnnotation)) |
| 2288 |
{ |
| 2289 |
break; |
| 2290 |
} |
| 2291 |
} |
| 2292 |
|
| 2293 |
return result; |
| 2294 |
} |
| 2295 |
} |
| 2296 |
|
| 2297 |
/** |
| 2298 |
* This is a helper method for searching for a name in one of the schemas named component relations. |
| 2299 |
*/ |
| 2300 |
protected XSDNamedComponent resolveNamedComponent(EReference namedComponentsRefReference, String namespace, String localName) |
| 2301 |
{ |
| 2302 |
if ("".equals(namespace)) |
| 2303 |
{ |
| 2304 |
namespace = null; |
| 2305 |
} |
| 2306 |
|
| 2307 |
Collection<XSDSchema> resolvedSchemas = resolveSchema(namespace); |
| 2308 |
for (XSDSchema resolvedSchema : resolvedSchemas) |
| 2309 |
{ |
| 2310 |
@SuppressWarnings("unchecked") List<XSDNamedComponent> list = (List<XSDNamedComponent>)resolvedSchema.eGet(namedComponentsRefReference); |
| 2311 |
XSDNamedComponent xsdNamedComponent = XSDNamedComponentImpl.findInSortedList(list, namespace, localName); |
| 2312 |
if (xsdNamedComponent == null && namespace == null && resolvedSchemas.contains(this) && resolvedSchema.getTargetNamespace() != null) |
| 2313 |
{ |
| 2314 |
xsdNamedComponent = XSDNamedComponentImpl.findInSortedList(list, getTargetNamespace(), localName); |
| 2315 |
|
| 2316 |
} |
| 2317 |
if (xsdNamedComponent != null) |
| 2318 |
{ |
| 2319 |
return xsdNamedComponent; |
| 2320 |
} |
| 2321 |
} |
| 2322 |
return null; |
| 2323 |
} |
| 2324 |
|
| 2325 |
@Override |
| 2326 |
public XSDAttributeDeclaration resolveAttributeDeclaration(String namespace, String localName) |
| 2327 |
{ |
| 2328 |
XSDAttributeDeclaration result = |
| 2329 |
(XSDAttributeDeclaration)resolveNamedComponent(XSDPackage.Literals.XSD_SCHEMA__ATTRIBUTE_DECLARATIONS, namespace, localName); |
| 2330 |
if (result == null) |
| 2331 |
{ |
| 2332 |
result = createUnresolvedAttributeDeclaration(namespace, localName); |
| 2333 |
} |
| 2334 |
return result; |
| 2335 |
} |
| 2336 |
|
| 2337 |
@Override |
| 2338 |
public XSDAttributeGroupDefinition resolveAttributeGroupDefinition(String namespace, String localName) |
| 2339 |
{ |
| 2340 |
XSDAttributeGroupDefinition result = |
| 2341 |
(XSDAttributeGroupDefinition)resolveNamedComponent |
| 2342 |
(XSDPackage.Literals.XSD_SCHEMA__ATTRIBUTE_GROUP_DEFINITIONS, namespace, localName); |
| 2343 |
if (result == null) |
| 2344 |
{ |
| 2345 |
result = createUnresolvedAttributeGroupDefinition(namespace, localName); |
| 2346 |
} |
| 2347 |
return result; |
| 2348 |
} |
| 2349 |
|
| 2350 |
@Override |
| 2351 |
public XSDElementDeclaration resolveElementDeclaration(String namespace, String localName) |
| 2352 |
{ |
| 2353 |
XSDElementDeclaration result = |
| 2354 |
(XSDElementDeclaration)resolveNamedComponent(XSDPackage.Literals.XSD_SCHEMA__ELEMENT_DECLARATIONS, namespace, localName); |
| 2355 |
if (result == null) |
| 2356 |
{ |
| 2357 |
result = createUnresolvedElementDeclaration(namespace, localName); |
| 2358 |
} |
| 2359 |
return result; |
| 2360 |
} |
| 2361 |
|
| 2362 |
@Override |
| 2363 |
public XSDTypeDefinition resolveTypeDefinition(String namespace, String localName) |
| 2364 |
{ |
| 2365 |
XSDTypeDefinition result = |
| 2366 |
(XSDTypeDefinition)resolveNamedComponent(XSDPackage.Literals.XSD_SCHEMA__TYPE_DEFINITIONS, namespace, localName); |
| 2367 |
if (result == null && |
| 2368 |
XSDConstants.isSchemaForSchemaNamespace(namespace) && |
| 2369 |
!XSDConstants.isSchemaForSchemaNamespace(getTargetNamespace())) |
| 2370 |
{ |
| 2371 |
result = getSchemaForSchema(namespace).resolveTypeDefinition(namespace, localName); |
| 2372 |
} |
| 2373 |
if (result == null) |
| 2374 |
{ |
| 2375 |
result = createUnresolvedTypeDefinition(namespace, localName); |
| 2376 |
} |
| 2377 |
return result; |
| 2378 |
} |
| 2379 |
|
| 2380 |
@Override |
| 2381 |
public XSDSimpleTypeDefinition resolveSimpleTypeDefinition(String namespace, String localName) |
| 2382 |
{ |
| 2383 |
XSDTypeDefinition xsdTypeDefinition = |
| 2384 |
(XSDTypeDefinition)resolveNamedComponent(XSDPackage.Literals.XSD_SCHEMA__TYPE_DEFINITIONS, namespace, localName); |
| 2385 |
XSDSimpleTypeDefinition result = |
| 2386 |
xsdTypeDefinition instanceof XSDSimpleTypeDefinition ? (XSDSimpleTypeDefinition)xsdTypeDefinition : null; |
| 2387 |
if (result == null) |
| 2388 |
{ |
| 2389 |
if (XSDConstants.isSchemaForSchemaNamespace(namespace)) |
| 2390 |
{ |
| 2391 |
if ("anyType".equals(localName) || "anySimpleType".equals(localName)) |
| 2392 |
{ |
| 2393 |
XSDSchema magicSchemaForSchema = getMagicSchemaForSchema(namespace); |
| 2394 |
if (magicSchemaForSchema == this) |
| 2395 |
{ |
| 2396 |
EList<XSDTypeDefinition> typeDefinitions = magicSchemaForSchema.getTypeDefinitions(); |
| 2397 |
if (typeDefinitions.size() > 0) |
| 2398 |
{ |
| 2399 |
result = (XSDSimpleTypeDefinition)typeDefinitions.get(0); |
| 2400 |
} |
| 2401 |
} |
| 2402 |
else |
| 2403 |
{ |
| 2404 |
result = magicSchemaForSchema.resolveSimpleTypeDefinition(namespace, localName); |
| 2405 |
} |
| 2406 |
} |
| 2407 |
else if (!XSDConstants.isSchemaForSchemaNamespace(getTargetNamespace())) |
| 2408 |
{ |
| 2409 |
XSDSchema schemaForSchema = getSchemaForSchema(namespace); |
| 2410 |
result = schemaForSchema.resolveSimpleTypeDefinition(namespace, localName); |
| 2411 |
} |
| 2412 |
} |
| 2413 |
} |
| 2414 |
|
| 2415 |
if (result == null) |
| 2416 |
{ |
| 2417 |
result = createUnresolvedSimpleTypeDefinition(namespace, localName); |
| 2418 |
} |
| 2419 |
return result; |
| 2420 |
} |
| 2421 |
|
| 2422 |
@Override |
| 2423 |
public XSDComplexTypeDefinition resolveComplexTypeDefinition(String namespace, String localName) |
| 2424 |
{ |
| 2425 |
XSDTypeDefinition xsdTypeDefinition = |
| 2426 |
(XSDTypeDefinition)resolveNamedComponent(XSDPackage.Literals.XSD_SCHEMA__TYPE_DEFINITIONS, namespace, localName); |
| 2427 |
XSDComplexTypeDefinition result = |
| 2428 |
xsdTypeDefinition instanceof XSDComplexTypeDefinition ? (XSDComplexTypeDefinition)xsdTypeDefinition : null; |
| 2429 |
if (result == null && |
| 2430 |
XSDConstants.isSchemaForSchemaNamespace(namespace) && |
| 2431 |
!XSDConstants.isSchemaForSchemaNamespace(getTargetNamespace())) |
| 2432 |
{ |
| 2433 |
result = getSchemaForSchema(namespace).resolveComplexTypeDefinition(namespace, localName); |
| 2434 |
} |
| 2435 |
if (result == null) |
| 2436 |
{ |
| 2437 |
result = createUnresolvedComplexTypeDefinition(namespace, localName); |
| 2438 |
} |
| 2439 |
return result; |
| 2440 |
} |
| 2441 |
|
| 2442 |
@Override |
| 2443 |
public XSDModelGroupDefinition resolveModelGroupDefinition(String namespace, String localName) |
| 2444 |
{ |
| 2445 |
XSDModelGroupDefinition result = |
| 2446 |
(XSDModelGroupDefinition)resolveNamedComponent(XSDPackage.Literals.XSD_SCHEMA__MODEL_GROUP_DEFINITIONS, namespace, localName); |
| 2447 |
if (result == null) |
| 2448 |
{ |
| 2449 |
result = createUnresolvedModelGroupDefinition(namespace, localName); |
| 2450 |
} |
| 2451 |
|
| 2452 |
return result; |
| 2453 |
} |
| 2454 |
|
| 2455 |
@Override |
| 2456 |
public XSDIdentityConstraintDefinition resolveIdentityConstraintDefinition(String namespace, String localName) |
| 2457 |
{ |
| 2458 |
XSDIdentityConstraintDefinition result = |
| 2459 |
(XSDIdentityConstraintDefinition)resolveNamedComponent(XSDPackage.Literals.XSD_SCHEMA__IDENTITY_CONSTRAINT_DEFINITIONS, namespace, localName); |
| 2460 |
if (result == null) |
| 2461 |
{ |
| 2462 |
result = createUnresolvedIdentityConstraintDefinition(namespace, localName); |
| 2463 |
} |
| 2464 |
return result; |
| 2465 |
} |
| 2466 |
|
| 2467 |
@Override |
| 2468 |
public XSDNotationDeclaration resolveNotationDeclaration(String namespace, String localName) |
| 2469 |
{ |
| 2470 |
XSDNotationDeclaration result = |
| 2471 |
(XSDNotationDeclaration) resolveNamedComponent(XSDPackage.Literals.XSD_SCHEMA__NOTATION_DECLARATIONS, namespace, localName); |
| 2472 |
if (result == null) |
| 2473 |
{ |
| 2474 |
result = createUnresolvedNotationDeclaration(namespace, localName); |
| 2475 |
} |
| 2476 |
return result; |
| 2477 |
} |
| 2478 |
|
| 2479 |
@Override |
| 2480 |
protected void changeAttribute(EAttribute eAttribute) |
| 2481 |
{ |
| 2482 |
if (eAttribute == XSDPackage.Literals.XSD_SCHEMA__SCHEMA_LOCATION) |
| 2483 |
{ |
| 2484 |
patch(); |
| 2485 |
} |
| 2486 |
else |
| 2487 |
{ |
| 2488 |
super.changeAttribute(eAttribute); |
| 2489 |
Element theElement = getElement(); |
| 2490 |
if (theElement != null) |
| 2491 |
{ |
| 2492 |
if (eAttribute == null || eAttribute == XSDPackage.Literals.XSD_SCHEMA__VERSION) |
| 2493 |
{ |
| 2494 |
niceSetAttribute |
| 2495 |
(theElement, |
| 2496 |
XSDConstants.VERSION_ATTRIBUTE, |
| 2497 |
getVersion()); |
| 2498 |
if (eAttribute != null) |
| 2499 |
{ |
| 2500 |
traverseToRootForPatching(); |
| 2501 |
} |
| 2502 |
} |
| 2503 |
if (eAttribute == null || eAttribute == XSDPackage.Literals.XSD_SCHEMA__TARGET_NAMESPACE) |
| 2504 |
{ |
| 2505 |
niceSetAttribute |
| 2506 |
(theElement, |
| 2507 |
XSDConstants.TARGETNAMESPACE_ATTRIBUTE, |
| 2508 |
getTargetNamespace()); |
| 2509 |
if (eAttribute != null) |
| 2510 |
{ |
| 2511 |
if (!isReconciling && isIncrementalUpdate) |
| 2512 |
{ |
| 2513 |
for (Object content : getContents()) |
| 2514 |
{ |
| 2515 |
if (content instanceof XSDNamedComponentImpl) |
| 2516 |
{ |
| 2517 |
((XSDNamedComponentImpl)content).patchTargetNamespaceAttribute(); |
| 2518 |
} |
| 2519 |
} |
| 2520 |
reset(); |
| 2521 |
} |
| 2522 |
} |
| 2523 |
} |
| 2524 |
if (eAttribute == null || eAttribute == XSDPackage.Literals.XSD_SCHEMA__ATTRIBUTE_FORM_DEFAULT) |
| 2525 |
{ |
| 2526 |
niceSetAttribute |
| 2527 |
(theElement, |
| 2528 |
XSDConstants.ATTRIBUTEFORMDEFAULT_ATTRIBUTE, |
| 2529 |
isSetAttributeFormDefault() ? getAttributeFormDefault().getName() : null); |
| 2530 |
if (eAttribute != null) |
| 2531 |
{ |
| 2532 |
traverseToRootForPatching(); |
| 2533 |
} |
| 2534 |
} |
| 2535 |
if (eAttribute == null || eAttribute == XSDPackage.Literals.XSD_SCHEMA__ELEMENT_FORM_DEFAULT) |
| 2536 |
{ |
| 2537 |
niceSetAttribute |
| 2538 |
(theElement, |
| 2539 |
XSDConstants.ELEMENTFORMDEFAULT_ATTRIBUTE, |
| 2540 |
isSetElementFormDefault() ? getElementFormDefault().getName() : null); |
| 2541 |
if (eAttribute != null) |
| 2542 |
{ |
| 2543 |
traverseToRootForPatching(); |
| 2544 |
} |
| 2545 |
} |
| 2546 |
if (eAttribute == null || eAttribute == XSDPackage.Literals.XSD_SCHEMA__BLOCK_DEFAULT) |
| 2547 |
{ |
| 2548 |
niceSetAttribute |
| 2549 |
(theElement, |
| 2550 |
XSDConstants.BLOCKDEFAULT_ATTRIBUTE, |
| 2551 |
getStringBlockDefault()); |
| 2552 |
if (eAttribute != null) |
| 2553 |
{ |
| 2554 |
traverseToRootForPatching(); |
| 2555 |
} |
| 2556 |
} |
| 2557 |
if (eAttribute == null || eAttribute == XSDPackage.Literals.XSD_SCHEMA__FINAL_DEFAULT) |
| 2558 |
{ |
| 2559 |
niceSetAttribute |
| 2560 |
(theElement, |
| 2561 |
XSDConstants.FINALDEFAULT_ATTRIBUTE, |
| 2562 |
getStringFinalDefault()); |
| 2563 |
if (eAttribute != null) |
| 2564 |
{ |
| 2565 |
traverseToRootForPatching(); |
| 2566 |
} |
| 2567 |
} |
| 2568 |
} |
| 2569 |
} |
| 2570 |
} |
| 2571 |
|
| 2572 |
@Override |
| 2573 |
protected void changeReference(EReference eReference) |
| 2574 |
{ |
| 2575 |
super.changeReference(eReference); |
| 2576 |
if (eReference == XSDPackage.Literals.XSD_SCHEMA__REFERENCING_DIRECTIVES) |
| 2577 |
{ |
| 2578 |
boolean newHasRetargetedNamespace = false; |
| 2579 |
for (XSDSchemaDirective xsdSchemaDirective : getReferencingDirectives()) |
| 2580 |
{ |
| 2581 |
if (xsdSchemaDirective instanceof XSDSchemaCompositor) |
| 2582 |
{ |
| 2583 |
XSDSchemaCompositor xsdSchemaCompositor = (XSDSchemaCompositor)xsdSchemaDirective; |
| 2584 |
if (xsdSchemaCompositor.getResolvedSchema() != xsdSchemaCompositor.getIncorporatedSchema() && |
| 2585 |
xsdSchemaCompositor.getResolvedSchema().getTargetNamespace() == null) |
| 2586 |
{ |
| 2587 |
newHasRetargetedNamespace = true; |
| 2588 |
break; |
| 2589 |
} |
| 2590 |
} |
| 2591 |
} |
| 2592 |
hasRetargetedNamespace = newHasRetargetedNamespace; |
| 2593 |
} |
| 2594 |
} |
| 2595 |
|
| 2596 |
/* |
| 2597 |
public void unsetElement() |
| 2598 |
{ |
| 2599 |
Element oldElement = getElement(); |
| 2600 |
if (oldElement instanceof EventTarget) |
| 2601 |
{ |
| 2602 |
EventTarget oldEventTarget = ((EventTarget)oldElement); |
| 2603 |
oldEventTarget.removeEventListener("DOMNodeInserted", getEventListener(), true); |
| 2604 |
oldEventTarget.removeEventListener("DOMNodeRemoved", getEventListener(), true); |
| 2605 |
oldEventTarget.removeEventListener("DOMAttrModified", getEventListener(), true); |
| 2606 |
} |
| 2607 |
super.unsetElement(); |
| 2608 |
} |
| 2609 |
*/ |
| 2610 |
|
| 2611 |
@Override |
| 2612 |
public void setElement(Element element) |
| 2613 |
{ |
| 2614 |
Element oldElement = getElement(); |
| 2615 |
if (oldElement instanceof EventTarget) |
| 2616 |
{ |
| 2617 |
EventTarget oldEventTarget = ((EventTarget)oldElement); |
| 2618 |
oldEventTarget.removeEventListener("DOMNodeInserted", getEventListener(), true); |
| 2619 |
oldEventTarget.removeEventListener("DOMNodeRemoved", getEventListener(), true); |
| 2620 |
oldEventTarget.removeEventListener("DOMAttrModified", getEventListener(), true); |
| 2621 |
} |
| 2622 |
super.setElement(element); |
| 2623 |
if (element instanceof EventTarget) |
| 2624 |
{ |
| 2625 |
EventTarget eventTarget = ((EventTarget)element); |
| 2626 |
eventTarget.addEventListener("DOMNodeInserted", getEventListener(), true); |
| 2627 |
eventTarget.addEventListener("DOMNodeRemoved", getEventListener(), true); |
| 2628 |
eventTarget.addEventListener("DOMAttrModified", getEventListener(), true); |
| 2629 |
} |
| 2630 |
if (element != null) |
| 2631 |
{ |
| 2632 |
document = element.getOwnerDocument(); |
| 2633 |
} |
| 2634 |
} |
| 2635 |
|
| 2636 |
public XSDSchema getSchemaForSchema() |
| 2637 |
{ |
| 2638 |
return getSchemaForSchema(getSchemaForSchemaNamespace()); |
| 2639 |
} |
| 2640 |
|
| 2641 |
/** |
| 2642 |
* <!-- begin-user-doc --> |
| 2643 |
* <!-- end-user-doc --> |
| 2644 |
* @generated |
| 2645 |
*/ |
| 2646 |
@Override |
| 2647 |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| 2648 |
{ |
| 2649 |
switch (featureID) |
| 2650 |
{ |
| 2651 |
case XSDPackage.XSD_SCHEMA__CONTENTS: |
| 2652 |
return ((InternalEList<?>)getContents()).basicRemove(otherEnd, msgs); |
| 2653 |
case XSDPackage.XSD_SCHEMA__INCORPORATED_VERSIONS: |
| 2654 |
return ((InternalEList<?>)getIncorporatedVersions()).basicRemove(otherEnd, msgs); |
| 2655 |
} |
| 2656 |
return super.eInverseRemove(otherEnd, featureID, msgs); |
| 2657 |
} |
| 2658 |
|
| 2659 |
/** |
| 2660 |
* <!-- begin-user-doc --> |
| 2661 |
* <!-- end-user-doc --> |
| 2662 |
* @generated |
| 2663 |
*/ |
| 2664 |
@Override |
| 2665 |
public Object eGet(int featureID, boolean resolve, boolean coreType) |
| 2666 |
{ |
| 2667 |
switch (featureID) |
| 2668 |
{ |
| 2669 |
case XSDPackage.XSD_SCHEMA__DOCUMENT: |
| 2670 |
return getDocument(); |
| 2671 |
case XSDPackage.XSD_SCHEMA__SCHEMA_LOCATION: |
| 2672 |
return getSchemaLocation(); |
| 2673 |
case XSDPackage.XSD_SCHEMA__TARGET_NAMESPACE: |
| 2674 |
return getTargetNamespace(); |
| 2675 |
case XSDPackage.XSD_SCHEMA__ATTRIBUTE_FORM_DEFAULT: |
| 2676 |
return getAttributeFormDefault(); |
| 2677 |
case XSDPackage.XSD_SCHEMA__ELEMENT_FORM_DEFAULT: |
| 2678 |
return getElementFormDefault(); |
| 2679 |
case XSDPackage.XSD_SCHEMA__FINAL_DEFAULT: |
| 2680 |
return getFinalDefault(); |
| 2681 |
case XSDPackage.XSD_SCHEMA__BLOCK_DEFAULT: |
| 2682 |
return getBlockDefault(); |
| 2683 |
case XSDPackage.XSD_SCHEMA__VERSION: |
| 2684 |
return getVersion(); |
| 2685 |
case XSDPackage.XSD_SCHEMA__CONTENTS: |
| 2686 |
return getContents(); |
| 2687 |
case XSDPackage.XSD_SCHEMA__ELEMENT_DECLARATIONS: |
| 2688 |
return getElementDeclarations(); |
| 2689 |
case XSDPackage.XSD_SCHEMA__ATTRIBUTE_DECLARATIONS: |
| 2690 |
return getAttributeDeclarations(); |
| 2691 |
case XSDPackage.XSD_SCHEMA__ATTRIBUTE_GROUP_DEFINITIONS: |
| 2692 |
return getAttributeGroupDefinitions(); |
| 2693 |
case XSDPackage.XSD_SCHEMA__TYPE_DEFINITIONS: |
| 2694 |
return getTypeDefinitions(); |
| 2695 |
case XSDPackage.XSD_SCHEMA__MODEL_GROUP_DEFINITIONS: |
| 2696 |
return getModelGroupDefinitions(); |
| 2697 |
case XSDPackage.XSD_SCHEMA__IDENTITY_CONSTRAINT_DEFINITIONS: |
| 2698 |
return getIdentityConstraintDefinitions(); |
| 2699 |
case XSDPackage.XSD_SCHEMA__NOTATION_DECLARATIONS: |
| 2700 |
return getNotationDeclarations(); |
| 2701 |
case XSDPackage.XSD_SCHEMA__ANNOTATIONS: |
| 2702 |
return getAnnotations(); |
| 2703 |
case XSDPackage.XSD_SCHEMA__ALL_DIAGNOSTICS: |
| 2704 |
return getAllDiagnostics(); |
| 2705 |
case XSDPackage.XSD_SCHEMA__REFERENCING_DIRECTIVES: |
| 2706 |
return getReferencingDirectives(); |
| 2707 |
case XSDPackage.XSD_SCHEMA__ROOT_VERSION: |
| 2708 |
return getRootVersion(); |
| 2709 |
case XSDPackage.XSD_SCHEMA__ORIGINAL_VERSION: |
| 2710 |
return getOriginalVersion(); |
| 2711 |
case XSDPackage.XSD_SCHEMA__INCORPORATED_VERSIONS: |
| 2712 |
return getIncorporatedVersions(); |
| 2713 |
case XSDPackage.XSD_SCHEMA__SCHEMA_FOR_SCHEMA: |
| 2714 |
return getSchemaForSchema(); |
| 2715 |
} |
| 2716 |
return super.eGet(featureID, resolve, coreType); |
| 2717 |
} |
| 2718 |
|
| 2719 |
/** |
| 2720 |
* <!-- begin-user-doc --> |
| 2721 |
* <!-- end-user-doc --> |
| 2722 |
* @generated |
| 2723 |
*/ |
| 2724 |
@SuppressWarnings("unchecked") |
| 2725 |
@Override |
| 2726 |
public void eSet(int featureID, Object newValue) |
| 2727 |
{ |
| 2728 |
switch (featureID) |
| 2729 |
{ |
| 2730 |
case XSDPackage.XSD_SCHEMA__DOCUMENT: |
| 2731 |
setDocument((Document)newValue); |
| 2732 |
return; |
| 2733 |
case XSDPackage.XSD_SCHEMA__SCHEMA_LOCATION: |
| 2734 |
setSchemaLocation((String)newValue); |
| 2735 |
return; |
| 2736 |
case XSDPackage.XSD_SCHEMA__TARGET_NAMESPACE: |
| 2737 |
setTargetNamespace((String)newValue); |
| 2738 |
return; |
| 2739 |
case XSDPackage.XSD_SCHEMA__ATTRIBUTE_FORM_DEFAULT: |
| 2740 |
setAttributeFormDefault((XSDForm)newValue); |
| 2741 |
return; |
| 2742 |
case XSDPackage.XSD_SCHEMA__ELEMENT_FORM_DEFAULT: |
| 2743 |
setElementFormDefault((XSDForm)newValue); |
| 2744 |
return; |
| 2745 |
case XSDPackage.XSD_SCHEMA__FINAL_DEFAULT: |
| 2746 |
getFinalDefault().clear(); |
| 2747 |
getFinalDefault().addAll((Collection<? extends XSDProhibitedSubstitutions>)newValue); |
| 2748 |
return; |
| 2749 |
case XSDPackage.XSD_SCHEMA__BLOCK_DEFAULT: |
| 2750 |
getBlockDefault().clear(); |
| 2751 |
getBlockDefault().addAll((Collection<? extends XSDDisallowedSubstitutions>)newValue); |
| 2752 |
return; |
| 2753 |
case XSDPackage.XSD_SCHEMA__VERSION: |
| 2754 |
setVersion((String)newValue); |
| 2755 |
return; |
| 2756 |
case XSDPackage.XSD_SCHEMA__CONTENTS: |
| 2757 |
getContents().clear(); |
| 2758 |
getContents().addAll((Collection<? extends XSDSchemaContent>)newValue); |
| 2759 |
return; |
| 2760 |
case XSDPackage.XSD_SCHEMA__ELEMENT_DECLARATIONS: |
| 2761 |
getElementDeclarations().clear(); |
| 2762 |
getElementDeclarations().addAll((Collection<? extends XSDElementDeclaration>)newValue); |
| 2763 |
return; |
| 2764 |
case XSDPackage.XSD_SCHEMA__ATTRIBUTE_DECLARATIONS: |
| 2765 |
getAttributeDeclarations().clear(); |
| 2766 |
getAttributeDeclarations().addAll((Collection<? extends XSDAttributeDeclaration>)newValue); |
| 2767 |
return; |
| 2768 |
case XSDPackage.XSD_SCHEMA__ATTRIBUTE_GROUP_DEFINITIONS: |
| 2769 |
getAttributeGroupDefinitions().clear(); |
| 2770 |
getAttributeGroupDefinitions().addAll((Collection<? extends XSDAttributeGroupDefinition>)newValue); |
| 2771 |
return; |
| 2772 |
case XSDPackage.XSD_SCHEMA__TYPE_DEFINITIONS: |
| 2773 |
getTypeDefinitions().clear(); |
| 2774 |
getTypeDefinitions().addAll((Collection<? extends XSDTypeDefinition>)newValue); |
| 2775 |
return; |
| 2776 |
case XSDPackage.XSD_SCHEMA__MODEL_GROUP_DEFINITIONS: |
| 2777 |
getModelGroupDefinitions().clear(); |
| 2778 |
getModelGroupDefinitions().addAll((Collection<? extends XSDModelGroupDefinition>)newValue); |
| 2779 |
return; |
| 2780 |
case XSDPackage.XSD_SCHEMA__IDENTITY_CONSTRAINT_DEFINITIONS: |
| 2781 |
getIdentityConstraintDefinitions().clear(); |
| 2782 |
getIdentityConstraintDefinitions().addAll((Collection<? extends XSDIdentityConstraintDefinition>)newValue); |
| 2783 |
return; |
| 2784 |
case XSDPackage.XSD_SCHEMA__NOTATION_DECLARATIONS: |
| 2785 |
getNotationDeclarations().clear(); |
| 2786 |
getNotationDeclarations().addAll((Collection<? extends XSDNotationDeclaration>)newValue); |
| 2787 |
return; |
| 2788 |
case XSDPackage.XSD_SCHEMA__ANNOTATIONS: |
| 2789 |
getAnnotations().clear(); |
| 2790 |
getAnnotations().addAll((Collection<? extends XSDAnnotation>)newValue); |
| 2791 |
return; |
| 2792 |
case XSDPackage.XSD_SCHEMA__ALL_DIAGNOSTICS: |
| 2793 |
getAllDiagnostics().clear(); |
| 2794 |
getAllDiagnostics().addAll((Collection<? extends XSDDiagnostic>)newValue); |
| 2795 |
return; |
| 2796 |
case XSDPackage.XSD_SCHEMA__REFERENCING_DIRECTIVES: |
| 2797 |
getReferencingDirectives().clear(); |
| 2798 |
getReferencingDirectives().addAll((Collection<? extends XSDSchemaDirective>)newValue); |
| 2799 |
return; |
| 2800 |
case XSDPackage.XSD_SCHEMA__INCORPORATED_VERSIONS: |
| 2801 |
getIncorporatedVersions().clear(); |
| 2802 |
getIncorporatedVersions().addAll((Collection<? extends XSDSchema>)newValue); |
| 2803 |
return; |
| 2804 |
} |
| 2805 |
super.eSet(featureID, newValue); |
| 2806 |
} |
| 2807 |
|
| 2808 |
/** |
| 2809 |
* <!-- begin-user-doc --> |
| 2810 |
* <!-- end-user-doc --> |
| 2811 |
* @generated |
| 2812 |
*/ |
| 2813 |
@Override |
| 2814 |
public void eUnset(int featureID) |
| 2815 |
{ |
| 2816 |
switch (featureID) |
| 2817 |
{ |
| 2818 |
case XSDPackage.XSD_SCHEMA__DOCUMENT: |
| 2819 |
setDocument(DOCUMENT_EDEFAULT); |
| 2820 |
return; |
| 2821 |
case XSDPackage.XSD_SCHEMA__SCHEMA_LOCATION: |
| 2822 |
setSchemaLocation(SCHEMA_LOCATION_EDEFAULT); |
| 2823 |
return; |
| 2824 |
case XSDPackage.XSD_SCHEMA__TARGET_NAMESPACE: |
| 2825 |
setTargetNamespace(TARGET_NAMESPACE_EDEFAULT); |
| 2826 |
return; |
| 2827 |
case XSDPackage.XSD_SCHEMA__ATTRIBUTE_FORM_DEFAULT: |
| 2828 |
unsetAttributeFormDefault(); |
| 2829 |
return; |
| 2830 |
case XSDPackage.XSD_SCHEMA__ELEMENT_FORM_DEFAULT: |
| 2831 |
unsetElementFormDefault(); |
| 2832 |
return; |
| 2833 |
case XSDPackage.XSD_SCHEMA__FINAL_DEFAULT: |
| 2834 |
unsetFinalDefault(); |
| 2835 |
return; |
| 2836 |
case XSDPackage.XSD_SCHEMA__BLOCK_DEFAULT: |
| 2837 |
unsetBlockDefault(); |
| 2838 |
return; |
| 2839 |
case XSDPackage.XSD_SCHEMA__VERSION: |
| 2840 |
setVersion(VERSION_EDEFAULT); |
| 2841 |
return; |
| 2842 |
case XSDPackage.XSD_SCHEMA__CONTENTS: |
| 2843 |
getContents().clear(); |
| 2844 |
return; |
| 2845 |
case XSDPackage.XSD_SCHEMA__ELEMENT_DECLARATIONS: |
| 2846 |
getElementDeclarations().clear(); |
| 2847 |
return; |
| 2848 |
case XSDPackage.XSD_SCHEMA__ATTRIBUTE_DECLARATIONS: |
| 2849 |
getAttributeDeclarations().clear(); |
| 2850 |
return; |
| 2851 |
case XSDPackage.XSD_SCHEMA__ATTRIBUTE_GROUP_DEFINITIONS: |
| 2852 |
getAttributeGroupDefinitions().clear(); |
| 2853 |
return; |
| 2854 |
case XSDPackage.XSD_SCHEMA__TYPE_DEFINITIONS: |
| 2855 |
getTypeDefinitions().clear(); |
| 2856 |
return; |
| 2857 |
case XSDPackage.XSD_SCHEMA__MODEL_GROUP_DEFINITIONS: |
| 2858 |
getModelGroupDefinitions().clear(); |
| 2859 |
return; |
| 2860 |
case XSDPackage.XSD_SCHEMA__IDENTITY_CONSTRAINT_DEFINITIONS: |
| 2861 |
getIdentityConstraintDefinitions().clear(); |
| 2862 |
return; |
| 2863 |
case XSDPackage.XSD_SCHEMA__NOTATION_DECLARATIONS: |
| 2864 |
getNotationDeclarations().clear(); |
| 2865 |
return; |
| 2866 |
case XSDPackage.XSD_SCHEMA__ANNOTATIONS: |
| 2867 |
getAnnotations().clear(); |
| 2868 |
return; |
| 2869 |
case XSDPackage.XSD_SCHEMA__ALL_DIAGNOSTICS: |
| 2870 |
getAllDiagnostics().clear(); |
| 2871 |
return; |
| 2872 |
case XSDPackage.XSD_SCHEMA__REFERENCING_DIRECTIVES: |
| 2873 |
getReferencingDirectives().clear(); |
| 2874 |
return; |
| 2875 |
case XSDPackage.XSD_SCHEMA__INCORPORATED_VERSIONS: |
| 2876 |
getIncorporatedVersions().clear(); |
| 2877 |
return; |
| 2878 |
} |
| 2879 |
super.eUnset(featureID); |
| 2880 |
} |
| 2881 |
|
| 2882 |
/** |
| 2883 |
* <!-- begin-user-doc --> |
| 2884 |
* <!-- end-user-doc --> |
| 2885 |
* @generated |
| 2886 |
*/ |
| 2887 |
@Override |
| 2888 |
public boolean eIsSet(int featureID) |
| 2889 |
{ |
| 2890 |
switch (featureID) |
| 2891 |
{ |
| 2892 |
case XSDPackage.XSD_SCHEMA__DOCUMENT: |
| 2893 |
return DOCUMENT_EDEFAULT == null ? document != null : !DOCUMENT_EDEFAULT.equals(document); |
| 2894 |
case XSDPackage.XSD_SCHEMA__SCHEMA_LOCATION: |
| 2895 |
return SCHEMA_LOCATION_EDEFAULT == null ? schemaLocation != null : !SCHEMA_LOCATION_EDEFAULT.equals(schemaLocation); |
| 2896 |
case XSDPackage.XSD_SCHEMA__TARGET_NAMESPACE: |
| 2897 |
return TARGET_NAMESPACE_EDEFAULT == null ? targetNamespace != null : !TARGET_NAMESPACE_EDEFAULT.equals(targetNamespace); |
| 2898 |
case XSDPackage.XSD_SCHEMA__ATTRIBUTE_FORM_DEFAULT: |
| 2899 |
return isSetAttributeFormDefault(); |
| 2900 |
case XSDPackage.XSD_SCHEMA__ELEMENT_FORM_DEFAULT: |
| 2901 |
return isSetElementFormDefault(); |
| 2902 |
case XSDPackage.XSD_SCHEMA__FINAL_DEFAULT: |
| 2903 |
return isSetFinalDefault(); |
| 2904 |
case XSDPackage.XSD_SCHEMA__BLOCK_DEFAULT: |
| 2905 |
return isSetBlockDefault(); |
| 2906 |
case XSDPackage.XSD_SCHEMA__VERSION: |
| 2907 |
return VERSION_EDEFAULT == null ? version != null : !VERSION_EDEFAULT.equals(version); |
| 2908 |
case XSDPackage.XSD_SCHEMA__CONTENTS: |
| 2909 |
return contents != null && !contents.isEmpty(); |
| 2910 |
case XSDPackage.XSD_SCHEMA__ELEMENT_DECLARATIONS: |
| 2911 |
return elementDeclarations != null && !elementDeclarations.isEmpty(); |
| 2912 |
case XSDPackage.XSD_SCHEMA__ATTRIBUTE_DECLARATIONS: |
| 2913 |
return attributeDeclarations != null && !attributeDeclarations.isEmpty(); |
| 2914 |
case XSDPackage.XSD_SCHEMA__ATTRIBUTE_GROUP_DEFINITIONS: |
| 2915 |
return attributeGroupDefinitions != null && !attributeGroupDefinitions.isEmpty(); |
| 2916 |
case XSDPackage.XSD_SCHEMA__TYPE_DEFINITIONS: |
| 2917 |
return typeDefinitions != null && !typeDefinitions.isEmpty(); |
| 2918 |
case XSDPackage.XSD_SCHEMA__MODEL_GROUP_DEFINITIONS: |
| 2919 |
return modelGroupDefinitions != null && !modelGroupDefinitions.isEmpty(); |
| 2920 |
case XSDPackage.XSD_SCHEMA__IDENTITY_CONSTRAINT_DEFINITIONS: |
| 2921 |
return identityConstraintDefinitions != null && !identityConstraintDefinitions.isEmpty(); |
| 2922 |
case XSDPackage.XSD_SCHEMA__NOTATION_DECLARATIONS: |
| 2923 |
return notationDeclarations != null && !notationDeclarations.isEmpty(); |
| 2924 |
case XSDPackage.XSD_SCHEMA__ANNOTATIONS: |
| 2925 |
return annotations != null && !annotations.isEmpty(); |
| 2926 |
case XSDPackage.XSD_SCHEMA__ALL_DIAGNOSTICS: |
| 2927 |
return allDiagnostics != null && !allDiagnostics.isEmpty(); |
| 2928 |
case XSDPackage.XSD_SCHEMA__REFERENCING_DIRECTIVES: |
| 2929 |
return referencingDirectives != null && !referencingDirectives.isEmpty(); |
| 2930 |
case XSDPackage.XSD_SCHEMA__ROOT_VERSION: |
| 2931 |
return getRootVersion() != null; |
| 2932 |
case XSDPackage.XSD_SCHEMA__ORIGINAL_VERSION: |
| 2933 |
return getOriginalVersion() != null; |
| 2934 |
case XSDPackage.XSD_SCHEMA__INCORPORATED_VERSIONS: |
| 2935 |
return incorporatedVersions != null && !incorporatedVersions.isEmpty(); |
| 2936 |
case XSDPackage.XSD_SCHEMA__SCHEMA_FOR_SCHEMA: |
| 2937 |
return getSchemaForSchema() != null; |
| 2938 |
} |
| 2939 |
return super.eIsSet(featureID); |
| 2940 |
} |
| 2941 |
|
| 2942 |
/** |
| 2943 |
* <!-- begin-user-doc --> |
| 2944 |
* <!-- end-user-doc --> |
| 2945 |
* @generated |
| 2946 |
*/ |
| 2947 |
@Override |
| 2948 |
public String toString() |
| 2949 |
{ |
| 2950 |
if (eIsProxy()) return super.toString(); |
| 2951 |
|
| 2952 |
StringBuilder result = new StringBuilder(super.toString()); |
| 2953 |
result.append(" (document: "); |
| 2954 |
result.append(document); |
| 2955 |
result.append(", schemaLocation: "); |
| 2956 |
result.append(schemaLocation); |
| 2957 |
result.append(", targetNamespace: "); |
| 2958 |
result.append(targetNamespace); |
| 2959 |
result.append(", attributeFormDefault: "); |
| 2960 |
if ((eFlags & ATTRIBUTE_FORM_DEFAULT_ESETFLAG) != 0) result.append(ATTRIBUTE_FORM_DEFAULT_EFLAG_VALUES[(eFlags & ATTRIBUTE_FORM_DEFAULT_EFLAG) >>> ATTRIBUTE_FORM_DEFAULT_EFLAG_OFFSET]); else result.append("<unset>"); |
| 2961 |
result.append(", elementFormDefault: "); |
| 2962 |
if ((eFlags & ELEMENT_FORM_DEFAULT_ESETFLAG) != 0) result.append(ELEMENT_FORM_DEFAULT_EFLAG_VALUES[(eFlags & ELEMENT_FORM_DEFAULT_EFLAG) >>> ELEMENT_FORM_DEFAULT_EFLAG_OFFSET]); else result.append("<unset>"); |
| 2963 |
result.append(", finalDefault: "); |
| 2964 |
result.append(finalDefault); |
| 2965 |
result.append(", blockDefault: "); |
| 2966 |
result.append(blockDefault); |
| 2967 |
result.append(", version: "); |
| 2968 |
result.append(version); |
| 2969 |
result.append(')'); |
| 2970 |
return result.toString(); |
| 2971 |
} |
| 2972 |
|
| 2973 |
public XSDSchema getMagicSchemaForSchema() |
| 2974 |
{ |
| 2975 |
return getMagicSchemaForSchema(getSchemaForSchemaNamespace()); |
| 2976 |
} |
| 2977 |
|
| 2978 |
protected EventListener eventListener; |
| 2979 |
protected Node deletionNode; |
| 2980 |
|
| 2981 |
public Node getDeletionNode() |
| 2982 |
{ |
| 2983 |
return deletionNode; |
| 2984 |
} |
| 2985 |
|
| 2986 |
private static class DummyEventListener implements EventListener, Serializable |
| 2987 |
{ |
| 2988 |
private static final long serialVersionUID = 1L; |
| 2989 |
|
| 2990 |
public void handleEvent(Event arg0) |
| 2991 |
{ |
| 2992 |
// Ignore. |
| 2993 |
} |
| 2994 |
} |
| 2995 |
|
| 2996 |
protected EventListener getEventListener() |
| 2997 |
{ |
| 2998 |
if (eventListener == null) |
| 2999 |
{ |
| 3000 |
class XSDSchemaEventListener implements EventListener, Serializable |
| 3001 |
{ |
| 3002 |
private static final long serialVersionUID = 1L; |
| 3003 |
|
| 3004 |
public void handleEvent(Event event) |
| 3005 |
{ |
| 3006 |
if (event instanceof MutationEvent) |
| 3007 |
{ |
| 3008 |
MutationEvent mutationEvent = (MutationEvent)event; |
| 3009 |
if (mutationEvent.getTarget() instanceof Node) |
| 3010 |
{ |
| 3011 |
Node node = (Node)mutationEvent.getTarget(); |
| 3012 |
while (node.getNodeType() != Node.ELEMENT_NODE) |
| 3013 |
{ |
| 3014 |
node = node.getParentNode(); |
| 3015 |
} |
| 3016 |
if (mutationEvent.getAttrChange() == 0) |
| 3017 |
{ |
| 3018 |
XSDConcreteComponent listener = getCorrespondingComponent(node.getParentNode()); |
| 3019 |
if (listener != null) |
| 3020 |
{ |
| 3021 |
if (event.getType().equals("DOMNodeRemoved")) |
| 3022 |
{ |
| 3023 |
deletionNode = (Node)event.getTarget(); |
| 3024 |
} |
| 3025 |
Node parent = node.getParentNode(); |
| 3026 |
if (parent.getNodeType() == Node.ELEMENT_NODE) |
| 3027 |
{ |
| 3028 |
listener.elementContentsChanged((Element)parent); |
| 3029 |
} |
| 3030 |
deletionNode = null; |
| 3031 |
} |
| 3032 |
} |
| 3033 |
else |
| 3034 |
{ |
| 3035 |
XSDConcreteComponent listener = getCorrespondingComponent(node); |
| 3036 |
if (listener != null) |
| 3037 |
{ |
| 3038 |
listener.elementAttributesChanged((Element)node); |
| 3039 |
} |
| 3040 |
} |
| 3041 |
} |
| 3042 |
} |
| 3043 |
} |
| 3044 |
|
| 3045 |
public Object writeReplace() |
| 3046 |
{ |
| 3047 |
return new DummyEventListener(); |
| 3048 |
} |
| 3049 |
} |
| 3050 |
eventListener = new XSDSchemaEventListener(); |
| 3051 |
} |
| 3052 |
return eventListener; |
| 3053 |
} |
| 3054 |
|
| 3055 |
public Document updateDocument() |
| 3056 |
{ |
| 3057 |
document = XSDParser.createDocument(); |
| 3058 |
return document; |
| 3059 |
} |
| 3060 |
|
| 3061 |
protected boolean isIncrementalUpdate = true; |
| 3062 |
|
| 3063 |
public void setIncrementalUpdate(boolean isIncrementalUpdate) |
| 3064 |
{ |
| 3065 |
this.isIncrementalUpdate = isIncrementalUpdate; |
| 3066 |
traverseToRootForPatching(); |
| 3067 |
} |
| 3068 |
|
| 3069 |
public boolean isIncrementalUpdate() |
| 3070 |
{ |
| 3071 |
return isIncrementalUpdate; |
| 3072 |
} |
| 3073 |
|
| 3074 |
public void update() |
| 3075 |
{ |
| 3076 |
boolean oldIsIncrementalUpdate = isIncrementalUpdate; |
| 3077 |
isIncrementalUpdate = true; |
| 3078 |
traverseToRootForPatching(); |
| 3079 |
isIncrementalUpdate = oldIsIncrementalUpdate; |
| 3080 |
} |
| 3081 |
|
| 3082 |
public void update(boolean force) |
| 3083 |
{ |
| 3084 |
forceResolve = force; |
| 3085 |
update(); |
| 3086 |
forceResolve = false; |
| 3087 |
} |
| 3088 |
|
| 3089 |
@Override |
| 3090 |
public void reset() |
| 3091 |
{ |
| 3092 |
super.reset(); |
| 3093 |
|
| 3094 |
redefinitionMap.clear(); |
| 3095 |
|
| 3096 |
reset(getAttributeDeclarations()); |
| 3097 |
reset(getAttributeGroupDefinitions()); |
| 3098 |
reset(getElementDeclarations()); |
| 3099 |
reset(getModelGroupDefinitions()); |
| 3100 |
reset(getTypeDefinitions()); |
| 3101 |
reset(getNotationDeclarations()); |
| 3102 |
reset(getIdentityConstraintDefinitions()); |
| 3103 |
|
| 3104 |
forceResolve = true; |
| 3105 |
update(); |
| 3106 |
forceResolve = false; |
| 3107 |
} |
| 3108 |
|
| 3109 |
protected void reset(List<? extends XSDConcreteComponent> components) |
| 3110 |
{ |
| 3111 |
for (Iterator<? extends XSDConcreteComponent> i = components.iterator(); i.hasNext(); ) |
| 3112 |
{ |
| 3113 |
XSDConcreteComponent xsdConcreteComponent = i.next(); |
| 3114 |
if (xsdConcreteComponent.getSchema() != this) |
| 3115 |
{ |
| 3116 |
i.remove(); |
| 3117 |
} |
| 3118 |
} |
| 3119 |
} |
| 3120 |
|
| 3121 |
protected String pendingSchemaLocation; |
| 3122 |
public String getPendingSchemaLocation() |
| 3123 |
{ |
| 3124 |
return pendingSchemaLocation; |
| 3125 |
} |
| 3126 |
|
| 3127 |
protected List<XSDSchemaImpl> schemasToRedefine; |
| 3128 |
public List<XSDSchemaImpl> getSchemasToRedefine() |
| 3129 |
{ |
| 3130 |
if (schemasToRedefine == null) |
| 3131 |
{ |
| 3132 |
schemasToRedefine = new UniqueEList<XSDSchemaImpl>(); |
| 3133 |
schemasToRedefine.add(this); |
| 3134 |
} |
| 3135 |
return schemasToRedefine; |
| 3136 |
} |
| 3137 |
|
| 3138 |
protected Map<XSDComponent, XSDComponent> redefinitionMap = new HashMap<XSDComponent, XSDComponent>(); |
| 3139 |
public Map<XSDComponent, XSDComponent> getRedefinitionMap() |
| 3140 |
{ |
| 3141 |
return redefinitionMap; |
| 3142 |
} |
| 3143 |
|
| 3144 |
public XSDSchema imported(XSDImport xsdImport) |
| 3145 |
{ |
| 3146 |
xsdImport.setResolvedSchema(this); |
| 3147 |
getReferencingDirectives().add(xsdImport); |
| 3148 |
propogateComponents(xsdImport.getSchema()); |
| 3149 |
|
| 3150 |
return this; |
| 3151 |
} |
| 3152 |
|
| 3153 |
public void propogateComponents(XSDSchema otherXSDSchema) |
| 3154 |
{ |
| 3155 |
otherXSDSchema.getAnnotations().addAll(getAnnotations()); |
| 3156 |
|
| 3157 |
XSDNamedComponentImpl.mergeToSortedList |
| 3158 |
(otherXSDSchema.getAttributeDeclarations(), getAttributeDeclarations()); |
| 3159 |
XSDNamedComponentImpl.mergeToSortedList |
| 3160 |
(otherXSDSchema.getAttributeGroupDefinitions(), getAttributeGroupDefinitions()); |
| 3161 |
XSDNamedComponentImpl.mergeToSortedList |
| 3162 |
(otherXSDSchema.getElementDeclarations(), getElementDeclarations()); |
| 3163 |
XSDNamedComponentImpl.mergeToSortedList |
| 3164 |
(otherXSDSchema.getModelGroupDefinitions(), getModelGroupDefinitions()); |
| 3165 |
XSDNamedComponentImpl.mergeToSortedList |
| 3166 |
(otherXSDSchema.getTypeDefinitions(), getTypeDefinitions()); |
| 3167 |
XSDNamedComponentImpl.mergeToSortedList |
| 3168 |
(otherXSDSchema.getNotationDeclarations(), getNotationDeclarations()); |
| 3169 |
XSDNamedComponentImpl.mergeToSortedList |
| 3170 |
(otherXSDSchema.getIdentityConstraintDefinitions(), getIdentityConstraintDefinitions()); |
| 3171 |
} |
| 3172 |
|
| 3173 |
public XSDSchema redefined(XSDRedefine xsdRedefine) |
| 3174 |
{ |
| 3175 |
XSDSchema redefiningSchema = xsdRedefine.getSchema(); |
| 3176 |
xsdRedefine.setResolvedSchema(this); |
| 3177 |
getReferencingDirectives().add(xsdRedefine); |
| 3178 |
if (redefiningSchema != this && |
| 3179 |
(getTargetNamespace() == null || getTargetNamespace().equals(redefiningSchema.getTargetNamespace()))) |
| 3180 |
{ |
| 3181 |
for (XSDSchema incorporatedVersion : getIncorporatedVersions()) |
| 3182 |
{ |
| 3183 |
if (incorporatedVersion.getTargetNamespace() == null ? |
| 3184 |
redefiningSchema.getTargetNamespace() == null : |
| 3185 |
incorporatedVersion.getTargetNamespace().equals(redefiningSchema.getTargetNamespace())) |
| 3186 |
{ |
| 3187 |
for (ListIterator<XSDSchemaDirective> i = incorporatedVersion.getReferencingDirectives().listIterator(); i.hasNext(); ) |
| 3188 |
{ |
| 3189 |
XSDSchemaDirective xsdSchemaDirective = i.next(); |
| 3190 |
// This was commented out to fix 72109, i.e., to prevent stack overflow. |
| 3191 |
// There really does need to be some kind of guard here in the general case. |
| 3192 |
// But it's very challenging to fix this, so it's better to not overflow |
| 3193 |
// and to have some other unreported corner case be wrong. |
| 3194 |
// Returning a previous results in the same thing being redefined multiple times, which is also no good. |
| 3195 |
// I'll add a guard to avoid overflow. |
| 3196 |
if (xsdRedefine.getSchema() == xsdSchemaDirective.getSchema() || getIncorporatedVersions().size() > 10) |
| 3197 |
{ |
| 3198 |
((XSDSchemaImpl)incorporatedVersion).incorporate(xsdRedefine); |
| 3199 |
return incorporatedVersion; |
| 3200 |
} |
| 3201 |
} |
| 3202 |
} |
| 3203 |
} |
| 3204 |
|
| 3205 |
XSDSchemaImpl redefinedSchema = (XSDSchemaImpl)cloneConcreteComponent(true, true); |
| 3206 |
|
| 3207 |
if (redefinedSchema.getTargetNamespace() == null && redefiningSchema.getTargetNamespace() != null) |
| 3208 |
{ |
| 3209 |
redefinedSchema.patch(); |
| 3210 |
redefinedSchema.setTargetNamespace(redefiningSchema.getTargetNamespace()); |
| 3211 |
redefinedSchema.patch(); |
| 3212 |
} |
| 3213 |
|
| 3214 |
// Change includes to redefines so that clones are created. |
| 3215 |
// |
| 3216 |
for (ListIterator<XSDSchemaContent> i = redefinedSchema.getContents().listIterator(); i.hasNext(); ) |
| 3217 |
{ |
| 3218 |
Object component = i.next(); |
| 3219 |
if (component instanceof XSDInclude) |
| 3220 |
{ |
| 3221 |
redefinedSchema.isReconciling = true; |
| 3222 |
i.remove(); |
| 3223 |
XSDRedefine xsdRedefineReplaced = XSDFactory.eINSTANCE.createXSDRedefine(); |
| 3224 |
xsdRedefineReplaced.setSchemaLocation(((XSDInclude)component).getSchemaLocation()); |
| 3225 |
i.add(xsdRedefineReplaced); |
| 3226 |
redefinedSchema.isReconciling = false; |
| 3227 |
} |
| 3228 |
} |
| 3229 |
|
| 3230 |
redefinedSchema.pendingSchemaLocation = getSchemaLocation(); |
| 3231 |
getIncorporatedVersions().add(redefinedSchema); |
| 3232 |
redefinedSchema.incorporate(xsdRedefine); |
| 3233 |
return redefinedSchema; |
| 3234 |
} |
| 3235 |
|
| 3236 |
return this; |
| 3237 |
} |
| 3238 |
|
| 3239 |
public XSDSchema included(XSDInclude xsdInclude) |
| 3240 |
{ |
| 3241 |
XSDSchema includingSchema = xsdInclude.getSchema(); |
| 3242 |
xsdInclude.setResolvedSchema(this); |
| 3243 |
getReferencingDirectives().add(xsdInclude); |
| 3244 |
if (getTargetNamespace() == null || getTargetNamespace().equals(includingSchema.getTargetNamespace())) |
| 3245 |
{ |
| 3246 |
if (includingSchema.getTargetNamespace() != null && getTargetNamespace() == null) |
| 3247 |
{ |
| 3248 |
for (XSDSchema xsdSchema : getIncorporatedVersions()) |
| 3249 |
{ |
| 3250 |
XSDSchemaImpl incorporatedVersion = (XSDSchemaImpl)xsdSchema; |
| 3251 |
if (includingSchema.getTargetNamespace().equals(incorporatedVersion.getTargetNamespace())) |
| 3252 |
{ |
| 3253 |
if (incorporatedVersion.getReferencingDirectives().isEmpty()) |
| 3254 |
{ |
| 3255 |
incorporatedVersion.incorporate(xsdInclude); |
| 3256 |
return incorporatedVersion; |
| 3257 |
} |
| 3258 |
for (XSDSchemaDirective xsdSchemaDirective : incorporatedVersion.getReferencingDirectives()) |
| 3259 |
{ |
| 3260 |
if (xsdSchemaDirective instanceof XSDInclude) |
| 3261 |
{ |
| 3262 |
incorporatedVersion.incorporate(xsdInclude); |
| 3263 |
return incorporatedVersion; |
| 3264 |
} |
| 3265 |
} |
| 3266 |
} |
| 3267 |
} |
| 3268 |
XSDSchemaImpl includedSchema = (XSDSchemaImpl)cloneConcreteComponent(true, true); |
| 3269 |
includedSchema.patch(); |
| 3270 |
includedSchema.setTargetNamespace(includingSchema.getTargetNamespace()); |
| 3271 |
includedSchema.patch(); |
| 3272 |
getIncorporatedVersions().add(includedSchema); |
| 3273 |
includedSchema.incorporate(xsdInclude); |
| 3274 |
return includedSchema; |
| 3275 |
} |
| 3276 |
else |
| 3277 |
{ |
| 3278 |
incorporate(xsdInclude); |
| 3279 |
} |
| 3280 |
} |
| 3281 |
return this; |
| 3282 |
} |
| 3283 |
|
| 3284 |
protected void incorporate(XSDSchemaCompositor xsdSchemaCompositor) |
| 3285 |
{ |
| 3286 |
xsdSchemaCompositor.setIncorporatedSchema(this); |
| 3287 |
XSDSchema redefiningSchema = xsdSchemaCompositor.getSchema(); |
| 3288 |
getReferencingDirectives().add(xsdSchemaCompositor); |
| 3289 |
|
| 3290 |
if (getTargetNamespace() == null && redefiningSchema.getTargetNamespace() != null) |
| 3291 |
{ |
| 3292 |
setTargetNamespace(redefiningSchema.getTargetNamespace()); |
| 3293 |
} |
| 3294 |
|
| 3295 |
if (getPendingSchemaLocation() != null) |
| 3296 |
{ |
| 3297 |
for (Object component : getContents()) |
| 3298 |
{ |
| 3299 |
if (component instanceof XSDSchemaDirective) |
| 3300 |
{ |
| 3301 |
((XSDConcreteComponentImpl)component).patch(); |
| 3302 |
} |
| 3303 |
} |
| 3304 |
} |
| 3305 |
|
| 3306 |
if (xsdSchemaCompositor instanceof XSDRedefine) |
| 3307 |
{ |
| 3308 |
XSDSwitch<Object> xsdSwitch = |
| 3309 |
new XSDSwitch<Object>() |
| 3310 |
{ |
| 3311 |
@Override |
| 3312 |
public Object caseXSDAttributeGroupDefinition(XSDAttributeGroupDefinition xsdAttributeGroupDefinition) |
| 3313 |
{ |
| 3314 |
XSDAttributeGroupDefinition redefinedAttributeGroupDefinition = |
| 3315 |
resolveAttributeGroupDefinition(xsdAttributeGroupDefinition.getName()); |
| 3316 |
for (XSDSchemaImpl schemaToRedefine : getSchemasToRedefine()) |
| 3317 |
{ |
| 3318 |
int index = schemaToRedefine.getAttributeGroupDefinitions().indexOf(redefinedAttributeGroupDefinition); |
| 3319 |
if (index != -1) |
| 3320 |
{ |
| 3321 |
schemaToRedefine.getAttributeGroupDefinitions().set(index, xsdAttributeGroupDefinition); |
| 3322 |
schemaToRedefine.redefinitionMap.put(xsdAttributeGroupDefinition, redefinedAttributeGroupDefinition); |
| 3323 |
} |
| 3324 |
} |
| 3325 |
return this; |
| 3326 |
} |
| 3327 |
@Override |
| 3328 |
public Object caseXSDSimpleTypeDefinition(XSDSimpleTypeDefinition xsdSimpleTypeDefinition) |
| 3329 |
{ |
| 3330 |
XSDSimpleTypeDefinition redefinedSimpleTypeDefinition = |
| 3331 |
resolveSimpleTypeDefinition(xsdSimpleTypeDefinition.getName()); |
| 3332 |
for (XSDSchemaImpl schemaToRedefine : getSchemasToRedefine()) |
| 3333 |
{ |
| 3334 |
int index = schemaToRedefine.getTypeDefinitions().indexOf(redefinedSimpleTypeDefinition); |
| 3335 |
if (index != -1) |
| 3336 |
{ |
| 3337 |
schemaToRedefine.getTypeDefinitions().set(index, xsdSimpleTypeDefinition); |
| 3338 |
schemaToRedefine.redefinitionMap.put(xsdSimpleTypeDefinition, redefinedSimpleTypeDefinition); |
| 3339 |
} |
| 3340 |
} |
| 3341 |
return this; |
| 3342 |
} |
| 3343 |
@Override |
| 3344 |
public Object caseXSDComplexTypeDefinition(XSDComplexTypeDefinition xsdComplexTypeDefinition) |
| 3345 |
{ |
| 3346 |
XSDComplexTypeDefinition redefinedComplexTypeDefinition = |
| 3347 |
resolveComplexTypeDefinition(xsdComplexTypeDefinition.getName()); |
| 3348 |
if (xsdComplexTypeDefinition != redefinedComplexTypeDefinition) |
| 3349 |
{ |
| 3350 |
for (XSDSchemaImpl schemaToRedefine : getSchemasToRedefine()) |
| 3351 |
{ |
| 3352 |
int index = schemaToRedefine.getTypeDefinitions().indexOf(redefinedComplexTypeDefinition); |
| 3353 |
if (index != -1) |
| 3354 |
{ |
| 3355 |
schemaToRedefine.getTypeDefinitions().set(index, xsdComplexTypeDefinition); |
| 3356 |
schemaToRedefine.redefinitionMap.put(xsdComplexTypeDefinition, redefinedComplexTypeDefinition); |
| 3357 |
} |
| 3358 |
} |
| 3359 |
} |
| 3360 |
return this; |
| 3361 |
} |
| 3362 |
@Override |
| 3363 |
public Object caseXSDModelGroupDefinition(XSDModelGroupDefinition xsdModelGroupDefinition) |
| 3364 |
{ |
| 3365 |
XSDModelGroupDefinition redefinedModelGroupDefinition = |
| 3366 |
resolveModelGroupDefinition(xsdModelGroupDefinition.getName()); |
| 3367 |
for (XSDSchemaImpl schemaToRedefine : getSchemasToRedefine()) |
| 3368 |
{ |
| 3369 |
int index = schemaToRedefine.getModelGroupDefinitions().indexOf(redefinedModelGroupDefinition); |
| 3370 |
if (index != -1) |
| 3371 |
{ |
| 3372 |
schemaToRedefine.getModelGroupDefinitions().set(index, xsdModelGroupDefinition); |
| 3373 |
schemaToRedefine.redefinitionMap.put(xsdModelGroupDefinition, redefinedModelGroupDefinition); |
| 3374 |
} |
| 3375 |
} |
| 3376 |
return this; |
| 3377 |
} |
| 3378 |
}; |
| 3379 |
|
| 3380 |
for (XSDRedefineContent xsdRedefineContent : ((XSDRedefine)xsdSchemaCompositor).getContents()) |
| 3381 |
{ |
| 3382 |
xsdSwitch.doSwitch(xsdRedefineContent); |
| 3383 |
} |
| 3384 |
} |
| 3385 |
|
| 3386 |
if (((XSDSchemaImpl)redefiningSchema).getPendingSchemaLocation() != null) |
| 3387 |
{ |
| 3388 |
((XSDSchemaImpl)redefiningSchema).getSchemasToRedefine().addAll(getSchemasToRedefine()); |
| 3389 |
} |
| 3390 |
|
| 3391 |
propogateComponents(redefiningSchema); |
| 3392 |
|
| 3393 |
if (getPendingSchemaLocation() == null) |
| 3394 |
{ |
| 3395 |
patch(); |
| 3396 |
} |
| 3397 |
|
| 3398 |
((XSDSchemaImpl)redefiningSchema).getRedefinitionMap().putAll(getRedefinitionMap()); |
| 3399 |
} |
| 3400 |
|
| 3401 |
@Override |
| 3402 |
public XSDConcreteComponent cloneConcreteComponent(boolean deep, boolean shareDOM) |
| 3403 |
{ |
| 3404 |
XSDSchemaImpl clonedSchema = (XSDSchemaImpl)getXSDFactory().createXSDSchema(); |
| 3405 |
clonedSchema.isReconciling = true; |
| 3406 |
|
| 3407 |
clonedSchema.setTargetNamespace(getTargetNamespace()); |
| 3408 |
|
| 3409 |
if (isSetAttributeFormDefault()) |
| 3410 |
{ |
| 3411 |
clonedSchema.setAttributeFormDefault(getAttributeFormDefault()); |
| 3412 |
} |
| 3413 |
if (isSetElementFormDefault()) |
| 3414 |
{ |
| 3415 |
clonedSchema.setElementFormDefault(getElementFormDefault()); |
| 3416 |
} |
| 3417 |
if (isSetFinalDefault()) |
| 3418 |
{ |
| 3419 |
if (!getFinalDefault().isEmpty()) |
| 3420 |
{ |
| 3421 |
clonedSchema.getFinalDefault().addAll(getFinalDefault()); |
| 3422 |
} |
| 3423 |
else |
| 3424 |
{ |
| 3425 |
clonedSchema.getFinalDefault().clear(); |
| 3426 |
} |
| 3427 |
} |
| 3428 |
if (isSetBlockDefault()) |
| 3429 |
{ |
| 3430 |
if (!getBlockDefault().isEmpty()) |
| 3431 |
{ |
| 3432 |
clonedSchema.getBlockDefault().addAll(getBlockDefault()); |
| 3433 |
} |
| 3434 |
else |
| 3435 |
{ |
| 3436 |
clonedSchema.getBlockDefault().clear(); |
| 3437 |
} |
| 3438 |
} |
| 3439 |
|
| 3440 |
// clonedSchema.setSchemaLocation(getSchemaLocation()); |
| 3441 |
|
| 3442 |
clonedSchema.setSchemaForSchemaQNamePrefix(getSchemaForSchemaQNamePrefix()); |
| 3443 |
clonedSchema.getQNamePrefixToNamespaceMap().putAll(getQNamePrefixToNamespaceMap()); |
| 3444 |
|
| 3445 |
if (deep) |
| 3446 |
{ |
| 3447 |
if (!getContents().isEmpty()) |
| 3448 |
{ |
| 3449 |
clonedSchema.getContents().addAll(cloneConcreteComponents(getContents(), true, shareDOM)); |
| 3450 |
} |
| 3451 |
} |
| 3452 |
|
| 3453 |
if (shareDOM && getElement() != null) |
| 3454 |
{ |
| 3455 |
clonedSchema.setElement(getElement()); |
| 3456 |
} |
| 3457 |
|
| 3458 |
clonedSchema.isReconciling = shareDOM; |
| 3459 |
return clonedSchema; |
| 3460 |
} |
| 3461 |
} |