| 1 |
/** |
| 2 |
* Copyright (c) 2002-2006 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.util.ArrayList; |
| 15 |
import java.util.Collection; |
| 16 |
import java.util.Iterator; |
| 17 |
import java.util.List; |
| 18 |
|
| 19 |
import org.w3c.dom.Element; |
| 20 |
import org.w3c.dom.Node; |
| 21 |
|
| 22 |
import org.eclipse.emf.common.notify.NotificationChain; |
| 23 |
import org.eclipse.emf.common.util.EList; |
| 24 |
import org.eclipse.emf.ecore.EClass; |
| 25 |
import org.eclipse.emf.ecore.EReference; |
| 26 |
import org.eclipse.emf.ecore.InternalEObject; |
| 27 |
import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
| 28 |
import org.eclipse.emf.ecore.util.EObjectEList; |
| 29 |
import org.eclipse.emf.ecore.util.InternalEList; |
| 30 |
|
| 31 |
import org.eclipse.xsd.XSDAnnotation; |
| 32 |
import org.eclipse.xsd.XSDAttributeGroupDefinition; |
| 33 |
import org.eclipse.xsd.XSDComplexTypeDefinition; |
| 34 |
import org.eclipse.xsd.XSDConcreteComponent; |
| 35 |
import org.eclipse.xsd.XSDDiagnosticSeverity; |
| 36 |
import org.eclipse.xsd.XSDFactory; |
| 37 |
import org.eclipse.xsd.XSDModelGroupDefinition; |
| 38 |
import org.eclipse.xsd.XSDPackage; |
| 39 |
import org.eclipse.xsd.XSDParticle; |
| 40 |
import org.eclipse.xsd.XSDRedefine; |
| 41 |
import org.eclipse.xsd.XSDRedefineContent; |
| 42 |
import org.eclipse.xsd.XSDSchema; |
| 43 |
import org.eclipse.xsd.XSDTypeDefinition; |
| 44 |
import org.eclipse.xsd.util.XSDConstants; |
| 45 |
|
| 46 |
|
| 47 |
/** |
| 48 |
* <!-- begin-user-doc --> |
| 49 |
* An implementation of the model object '<em><b>Redefine</b></em>'. |
| 50 |
* <!-- end-user-doc --> |
| 51 |
* <p> |
| 52 |
* The following features are implemented: |
| 53 |
* </p> |
| 54 |
* <ul> |
| 55 |
* <li>{@link org.eclipse.xsd.impl.XSDRedefineImpl#getAnnotations <em>Annotations</em>}</li> |
| 56 |
* <li>{@link org.eclipse.xsd.impl.XSDRedefineImpl#getContents <em>Contents</em>}</li> |
| 57 |
* </ul> |
| 58 |
* |
| 59 |
* @generated |
| 60 |
*/ |
| 61 |
public class XSDRedefineImpl |
| 62 |
extends XSDSchemaCompositorImpl |
| 63 |
implements XSDRedefine |
| 64 |
{ |
| 65 |
/** |
| 66 |
* The cached value of the '{@link #getAnnotations() <em>Annotations</em>}' reference list. |
| 67 |
* <!-- begin-user-doc --> |
| 68 |
* <!-- end-user-doc --> |
| 69 |
* @see #getAnnotations() |
| 70 |
* @generated |
| 71 |
* @ordered |
| 72 |
*/ |
| 73 |
protected EList<XSDAnnotation> annotations; |
| 74 |
|
| 75 |
/** |
| 76 |
* The cached value of the '{@link #getContents() <em>Contents</em>}' containment reference list. |
| 77 |
* <!-- begin-user-doc --> |
| 78 |
* <!-- end-user-doc --> |
| 79 |
* @see #getContents() |
| 80 |
* @generated |
| 81 |
* @ordered |
| 82 |
*/ |
| 83 |
protected EList<XSDRedefineContent> contents; |
| 84 |
|
| 85 |
public static XSDRedefine createRedefine(Node node) |
| 86 |
{ |
| 87 |
if (XSDConstants.nodeType(node) == XSDConstants.REDEFINE_ELEMENT) |
| 88 |
{ |
| 89 |
XSDRedefine xsdRedefine = XSDFactory.eINSTANCE.createXSDRedefine(); |
| 90 |
xsdRedefine.setElement((Element)node); |
| 91 |
return xsdRedefine; |
| 92 |
} |
| 93 |
|
| 94 |
return null; |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* <!-- begin-user-doc --> |
| 99 |
* <!-- end-user-doc --> |
| 100 |
* @generated |
| 101 |
*/ |
| 102 |
protected XSDRedefineImpl() |
| 103 |
{ |
| 104 |
super(); |
| 105 |
} |
| 106 |
|
| 107 |
/** |
| 108 |
* <!-- begin-user-doc --> |
| 109 |
* <!-- end-user-doc --> |
| 110 |
* @generated |
| 111 |
*/ |
| 112 |
@Override |
| 113 |
protected EClass eStaticClass() |
| 114 |
{ |
| 115 |
return XSDPackage.Literals.XSD_REDEFINE; |
| 116 |
} |
| 117 |
|
| 118 |
/** |
| 119 |
* <!-- begin-user-doc --> |
| 120 |
* <!-- end-user-doc --> |
| 121 |
* @generated |
| 122 |
*/ |
| 123 |
@Override |
| 124 |
public EList<XSDAnnotation> getAnnotations() |
| 125 |
{ |
| 126 |
if (annotations == null) |
| 127 |
{ |
| 128 |
annotations = new EObjectEList<XSDAnnotation>(XSDAnnotation.class, this, XSDPackage.XSD_REDEFINE__ANNOTATIONS); |
| 129 |
} |
| 130 |
return annotations; |
| 131 |
} |
| 132 |
|
| 133 |
/** |
| 134 |
* <!-- begin-user-doc --> |
| 135 |
* <!-- end-user-doc --> |
| 136 |
* @generated |
| 137 |
*/ |
| 138 |
@Override |
| 139 |
public EList<XSDRedefineContent> getContents() |
| 140 |
{ |
| 141 |
if (contents == null) |
| 142 |
{ |
| 143 |
contents = new EObjectContainmentEList<XSDRedefineContent>(XSDRedefineContent.class, this, XSDPackage.XSD_REDEFINE__CONTENTS); |
| 144 |
} |
| 145 |
return contents; |
| 146 |
} |
| 147 |
|
| 148 |
/** |
| 149 |
* <!-- begin-user-doc --> |
| 150 |
* <!-- end-user-doc --> |
| 151 |
* @generated |
| 152 |
*/ |
| 153 |
@Override |
| 154 |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| 155 |
{ |
| 156 |
switch (featureID) |
| 157 |
{ |
| 158 |
case XSDPackage.XSD_REDEFINE__CONTENTS: |
| 159 |
return ((InternalEList<?>)getContents()).basicRemove(otherEnd, msgs); |
| 160 |
} |
| 161 |
return super.eInverseRemove(otherEnd, featureID, msgs); |
| 162 |
} |
| 163 |
|
| 164 |
/** |
| 165 |
* <!-- begin-user-doc --> |
| 166 |
* <!-- end-user-doc --> |
| 167 |
* @generated |
| 168 |
*/ |
| 169 |
@Override |
| 170 |
public Object eGet(int featureID, boolean resolve, boolean coreType) |
| 171 |
{ |
| 172 |
switch (featureID) |
| 173 |
{ |
| 174 |
case XSDPackage.XSD_REDEFINE__ANNOTATIONS: |
| 175 |
return getAnnotations(); |
| 176 |
case XSDPackage.XSD_REDEFINE__CONTENTS: |
| 177 |
return getContents(); |
| 178 |
} |
| 179 |
return super.eGet(featureID, resolve, coreType); |
| 180 |
} |
| 181 |
|
| 182 |
/** |
| 183 |
* <!-- begin-user-doc --> |
| 184 |
* <!-- end-user-doc --> |
| 185 |
* @generated |
| 186 |
*/ |
| 187 |
@SuppressWarnings("unchecked") |
| 188 |
@Override |
| 189 |
public void eSet(int featureID, Object newValue) |
| 190 |
{ |
| 191 |
switch (featureID) |
| 192 |
{ |
| 193 |
case XSDPackage.XSD_REDEFINE__ANNOTATIONS: |
| 194 |
getAnnotations().clear(); |
| 195 |
getAnnotations().addAll((Collection<? extends XSDAnnotation>)newValue); |
| 196 |
return; |
| 197 |
case XSDPackage.XSD_REDEFINE__CONTENTS: |
| 198 |
getContents().clear(); |
| 199 |
getContents().addAll((Collection<? extends XSDRedefineContent>)newValue); |
| 200 |
return; |
| 201 |
} |
| 202 |
super.eSet(featureID, newValue); |
| 203 |
} |
| 204 |
|
| 205 |
/** |
| 206 |
* <!-- begin-user-doc --> |
| 207 |
* <!-- end-user-doc --> |
| 208 |
* @generated |
| 209 |
*/ |
| 210 |
@Override |
| 211 |
public void eUnset(int featureID) |
| 212 |
{ |
| 213 |
switch (featureID) |
| 214 |
{ |
| 215 |
case XSDPackage.XSD_REDEFINE__ANNOTATIONS: |
| 216 |
getAnnotations().clear(); |
| 217 |
return; |
| 218 |
case XSDPackage.XSD_REDEFINE__CONTENTS: |
| 219 |
getContents().clear(); |
| 220 |
return; |
| 221 |
} |
| 222 |
super.eUnset(featureID); |
| 223 |
} |
| 224 |
|
| 225 |
/** |
| 226 |
* <!-- begin-user-doc --> |
| 227 |
* <!-- end-user-doc --> |
| 228 |
* @generated |
| 229 |
*/ |
| 230 |
@Override |
| 231 |
public boolean eIsSet(int featureID) |
| 232 |
{ |
| 233 |
switch (featureID) |
| 234 |
{ |
| 235 |
case XSDPackage.XSD_REDEFINE__ANNOTATIONS: |
| 236 |
return annotations != null && !annotations.isEmpty(); |
| 237 |
case XSDPackage.XSD_REDEFINE__CONTENTS: |
| 238 |
return contents != null && !contents.isEmpty(); |
| 239 |
} |
| 240 |
return super.eIsSet(featureID); |
| 241 |
} |
| 242 |
|
| 243 |
@Override |
| 244 |
public Element createElement() |
| 245 |
{ |
| 246 |
Element newElement = createElement(XSDConstants.REDEFINE_ELEMENT); |
| 247 |
setElement(newElement); |
| 248 |
|
| 249 |
for (XSDRedefineContent xsdRedefineContent : getContents()) |
| 250 |
{ |
| 251 |
Element contentElement = ((XSDConcreteComponentImpl)xsdRedefineContent).createElement(); |
| 252 |
newElement.appendChild(contentElement); |
| 253 |
} |
| 254 |
return newElement; |
| 255 |
} |
| 256 |
|
| 257 |
@Override |
| 258 |
protected void patch() |
| 259 |
{ |
| 260 |
if (getSchemaLocation() != null && getSchemaLocation().length() > 0) |
| 261 |
{ |
| 262 |
XSDSchemaImpl containingSchema = (XSDSchemaImpl)getContainer(); |
| 263 |
String oldPendingSchemaLocation = containingSchema.pendingSchemaLocation; |
| 264 |
if (containingSchema.getSchemaLocation() != null) |
| 265 |
{ |
| 266 |
containingSchema.pendingSchemaLocation = containingSchema.getSchemaLocation(); |
| 267 |
} |
| 268 |
resolve("", getSchemaLocation()); |
| 269 |
containingSchema.pendingSchemaLocation = oldPendingSchemaLocation; |
| 270 |
super.patch(); |
| 271 |
if (oldPendingSchemaLocation == null) |
| 272 |
{ |
| 273 |
List<XSDSchemaImpl> redefinitions = containingSchema.getSchemasToRedefine(); |
| 274 |
containingSchema.schemasToRedefine = null; |
| 275 |
for (XSDSchemaImpl schemaToRedefine : redefinitions) |
| 276 |
{ |
| 277 |
if (schemaToRedefine != containingSchema) |
| 278 |
{ |
| 279 |
schemaToRedefine.forceResolve = true; |
| 280 |
schemaToRedefine.setSchemaLocation(schemaToRedefine.pendingSchemaLocation); |
| 281 |
schemaToRedefine.forceResolve = false; |
| 282 |
schemaToRedefine.pendingSchemaLocation = null; |
| 283 |
} |
| 284 |
} |
| 285 |
} |
| 286 |
} |
| 287 |
else |
| 288 |
{ |
| 289 |
super.patch(); |
| 290 |
} |
| 291 |
} |
| 292 |
|
| 293 |
@Override |
| 294 |
protected void handleResolvedSchema(XSDSchema xsdSchema) |
| 295 |
{ |
| 296 |
if (xsdSchema == null) |
| 297 |
{ |
| 298 |
setResolvedSchema(null); |
| 299 |
setIncorporatedSchema(null); |
| 300 |
} |
| 301 |
else |
| 302 |
{ |
| 303 |
((XSDSchemaImpl)xsdSchema).redefined(this); |
| 304 |
} |
| 305 |
} |
| 306 |
|
| 307 |
@Override |
| 308 |
public void validate() |
| 309 |
{ |
| 310 |
super.validate(); |
| 311 |
|
| 312 |
Element theElement = getElement(); |
| 313 |
if (theElement != null) |
| 314 |
{ |
| 315 |
checkAttributes |
| 316 |
(XSDConstants.PART1, |
| 317 |
"element-redefine", |
| 318 |
theElement, |
| 319 |
new String [] |
| 320 |
{ |
| 321 |
XSDConstants.ID_ATTRIBUTE, |
| 322 |
XSDConstants.SCHEMALOCATION_ATTRIBUTE, |
| 323 |
}); |
| 324 |
|
| 325 |
XSDComplexTypeDefinition xsdComplexTypeDefinition = |
| 326 |
(XSDComplexTypeDefinition)getSchema().getSchemaForSchema().resolveElementDeclaration("redefine").getTypeDefinition(); |
| 327 |
|
| 328 |
checkComplexContent(xsdComplexTypeDefinition, XSDConstants.PART1, "element-redefine", theElement); |
| 329 |
|
| 330 |
checkBuiltInTypeConstraint |
| 331 |
("ID", |
| 332 |
null, |
| 333 |
XSDConstants.PART1, |
| 334 |
"element-redefine", |
| 335 |
theElement, |
| 336 |
XSDConstants.ID_ATTRIBUTE, |
| 337 |
false); |
| 338 |
} |
| 339 |
|
| 340 |
checkBuiltInTypeConstraint |
| 341 |
("anyURI", |
| 342 |
getSchemaLocation(), |
| 343 |
XSDConstants.PART1, |
| 344 |
"element-redefine", |
| 345 |
theElement, |
| 346 |
XSDConstants.SCHEMALOCATION_ATTRIBUTE, |
| 347 |
true); |
| 348 |
|
| 349 |
XSDSchema theResolvedSchema = getResolvedSchema(); |
| 350 |
if (theResolvedSchema == null) |
| 351 |
{ |
| 352 |
boolean hasRedefinitions = false; |
| 353 |
for (XSDRedefineContent content : getContents()) |
| 354 |
{ |
| 355 |
if (!(content instanceof XSDAnnotation)) |
| 356 |
{ |
| 357 |
hasRedefinitions = true; |
| 358 |
break; |
| 359 |
} |
| 360 |
} |
| 361 |
if (hasRedefinitions) |
| 362 |
{ |
| 363 |
createDiagnostic |
| 364 |
(XSDDiagnosticSeverity.ERROR_LITERAL, |
| 365 |
"src-redefine.1", |
| 366 |
getSchemaLocation() == null ? "" : getSchemaLocation()); |
| 367 |
} |
| 368 |
else |
| 369 |
{ |
| 370 |
createDiagnostic |
| 371 |
(XSDDiagnosticSeverity.WARNING_LITERAL, |
| 372 |
"src-redefine.0", |
| 373 |
getSchemaLocation() == null ? "" : getSchemaLocation()); |
| 374 |
} |
| 375 |
} |
| 376 |
else |
| 377 |
{ |
| 378 |
if (theResolvedSchema.eResource() == null || |
| 379 |
theResolvedSchema.getElement() == null || |
| 380 |
XSDConstants.nodeType(theResolvedSchema.getElement()) != XSDConstants.SCHEMA_ELEMENT) |
| 381 |
{ |
| 382 |
createDiagnostic |
| 383 |
(XSDDiagnosticSeverity.ERROR_LITERAL, |
| 384 |
"src-redefine.2", |
| 385 |
getSchemaLocation() == null ? "" : getSchemaLocation()); |
| 386 |
} |
| 387 |
else |
| 388 |
{ |
| 389 |
XSDSchema theSchema = getSchema(); |
| 390 |
if (theSchema.getTargetNamespace() == null ? |
| 391 |
theResolvedSchema.getTargetNamespace() != null : |
| 392 |
!theSchema.getTargetNamespace().equals(theResolvedSchema.getTargetNamespace()) && |
| 393 |
theResolvedSchema.getTargetNamespace() != null) |
| 394 |
{ |
| 395 |
createDiagnostic |
| 396 |
(XSDDiagnosticSeverity.ERROR_LITERAL, |
| 397 |
"src-redefine.3", |
| 398 |
theResolvedSchema.getTargetNamespace() == null ? "" : theResolvedSchema.getTargetNamespace(), |
| 399 |
theSchema.getTargetNamespace() == null ? "" : theSchema.getTargetNamespace()); |
| 400 |
} |
| 401 |
else |
| 402 |
{ |
| 403 |
for (XSDRedefineContent xsdRedefineContent : getContents()) |
| 404 |
{ |
| 405 |
if (xsdRedefineContent instanceof XSDTypeDefinition) |
| 406 |
{ |
| 407 |
XSDTypeDefinition xsdTypeDefinition = (XSDTypeDefinition)xsdRedefineContent; |
| 408 |
XSDTypeDefinition baseType = xsdTypeDefinition.getBaseType(); |
| 409 |
if (baseType == null || |
| 410 |
!baseType.hasSameNameAndTargetNamespace(xsdTypeDefinition) || |
| 411 |
resolveTypeDefinition(xsdTypeDefinition.getName()).getContainer() == null) |
| 412 |
{ |
| 413 |
getDiagnosticTarget(xsdTypeDefinition).createDiagnostic |
| 414 |
(XSDDiagnosticSeverity.ERROR_LITERAL, |
| 415 |
"src-redefine.5", |
| 416 |
xsdTypeDefinition.getName()); |
| 417 |
} |
| 418 |
} |
| 419 |
else if (xsdRedefineContent instanceof XSDModelGroupDefinition) |
| 420 |
{ |
| 421 |
XSDModelGroupDefinition xsdModelGroupDefinition = (XSDModelGroupDefinition)xsdRedefineContent; |
| 422 |
Collection<XSDModelGroupDefinition> selfReferences = new ArrayList<XSDModelGroupDefinition>(); |
| 423 |
for (Iterator<?> j = xsdModelGroupDefinition.eAllContents(); j.hasNext(); ) |
| 424 |
{ |
| 425 |
Object component = j.next(); |
| 426 |
if (component instanceof XSDModelGroupDefinition) |
| 427 |
{ |
| 428 |
XSDModelGroupDefinition otherXSDModelGroupDefinition = (XSDModelGroupDefinition)component; |
| 429 |
if (xsdModelGroupDefinition.hasSameNameAndTargetNamespace |
| 430 |
(otherXSDModelGroupDefinition.getResolvedModelGroupDefinition())) |
| 431 |
{ |
| 432 |
selfReferences.add(otherXSDModelGroupDefinition); |
| 433 |
} |
| 434 |
} |
| 435 |
} |
| 436 |
|
| 437 |
if (selfReferences.isEmpty()) |
| 438 |
{ |
| 439 |
XSDModelGroupDefinition otherXSDModelGroupDefinition = |
| 440 |
(XSDModelGroupDefinition)((XSDSchemaImpl)getContainer()).getRedefinitionMap().get(xsdModelGroupDefinition); |
| 441 |
if (otherXSDModelGroupDefinition == null || otherXSDModelGroupDefinition.getContainer() == null) |
| 442 |
{ |
| 443 |
((XSDConcreteComponentImpl)xsdModelGroupDefinition).createDiagnostic |
| 444 |
(XSDDiagnosticSeverity.ERROR_LITERAL, |
| 445 |
"src-redefine.6.2.1", |
| 446 |
xsdModelGroupDefinition.getName()); |
| 447 |
} |
| 448 |
else |
| 449 |
{ |
| 450 |
XSDParticle xsdParticle = XSDFactory.eINSTANCE.createXSDParticle(); |
| 451 |
xsdParticle.setTerm(xsdModelGroupDefinition.getModelGroup()); |
| 452 |
XSDParticle otherXSDParticle = XSDFactory.eINSTANCE.createXSDParticle(); |
| 453 |
otherXSDParticle.setTerm(otherXSDModelGroupDefinition.getModelGroup()); |
| 454 |
// EATM This doesn't really work for retargeted schemas. |
| 455 |
// |
| 456 |
if (!((XSDParticleImpl)xsdParticle).isSubset(otherXSDParticle, true)) |
| 457 |
{ |
| 458 |
((XSDConcreteComponentImpl)xsdModelGroupDefinition).createDiagnostic |
| 459 |
(XSDDiagnosticSeverity.ERROR_LITERAL, |
| 460 |
"src-redefine.6.2.2"); |
| 461 |
} |
| 462 |
} |
| 463 |
} |
| 464 |
else |
| 465 |
{ |
| 466 |
Iterator<XSDModelGroupDefinition> j = selfReferences.iterator(); |
| 467 |
XSDModelGroupDefinition otherXSDModelGroupDefinition = j.next(); |
| 468 |
XSDParticle xsdParticle = (XSDParticle)otherXSDModelGroupDefinition.getContainer(); |
| 469 |
if (xsdParticle.getMinOccurs() != 1 || xsdParticle.getMaxOccurs() != 1) |
| 470 |
{ |
| 471 |
((XSDConcreteComponentImpl)xsdParticle).createDiagnostic |
| 472 |
(XSDDiagnosticSeverity.ERROR_LITERAL, |
| 473 |
"src-redefine.6.1.2"); |
| 474 |
} |
| 475 |
|
| 476 |
while (j.hasNext()) |
| 477 |
{ |
| 478 |
XSDConcreteComponentImpl xsdConcreteComponent = (XSDConcreteComponentImpl)j.next(); |
| 479 |
xsdConcreteComponent.createDiagnostic |
| 480 |
(XSDDiagnosticSeverity.ERROR_LITERAL, |
| 481 |
"src-redefine.6.1.1"); |
| 482 |
} |
| 483 |
} |
| 484 |
} |
| 485 |
else if (xsdRedefineContent instanceof XSDAttributeGroupDefinition) |
| 486 |
{ |
| 487 |
XSDAttributeGroupDefinition xsdAttributeGroupDefinition = (XSDAttributeGroupDefinition)xsdRedefineContent; |
| 488 |
Collection<XSDAttributeGroupDefinition> selfReferences = new ArrayList<XSDAttributeGroupDefinition>(); |
| 489 |
for (Iterator<?> j = xsdAttributeGroupDefinition.eAllContents(); j.hasNext(); ) |
| 490 |
{ |
| 491 |
Object component = j.next(); |
| 492 |
if (component instanceof XSDAttributeGroupDefinition) |
| 493 |
{ |
| 494 |
XSDAttributeGroupDefinition otherXSDAttributeGroupDefinition = (XSDAttributeGroupDefinition)component; |
| 495 |
if (xsdAttributeGroupDefinition.hasSameNameAndTargetNamespace |
| 496 |
(otherXSDAttributeGroupDefinition.getResolvedAttributeGroupDefinition())) |
| 497 |
{ |
| 498 |
selfReferences.add(otherXSDAttributeGroupDefinition); |
| 499 |
} |
| 500 |
} |
| 501 |
} |
| 502 |
|
| 503 |
if (selfReferences.isEmpty()) |
| 504 |
{ |
| 505 |
XSDAttributeGroupDefinition otherXSDAttributeGroupDefinition = |
| 506 |
(XSDAttributeGroupDefinition)((XSDSchemaImpl)getContainer()).getRedefinitionMap().get(xsdAttributeGroupDefinition); |
| 507 |
if (otherXSDAttributeGroupDefinition == null || otherXSDAttributeGroupDefinition.getContainer() == null) |
| 508 |
{ |
| 509 |
((XSDConcreteComponentImpl)xsdAttributeGroupDefinition).createDiagnostic |
| 510 |
(XSDDiagnosticSeverity.ERROR_LITERAL, |
| 511 |
"src-redefine.7.2.1", |
| 512 |
xsdAttributeGroupDefinition.getName()); |
| 513 |
} |
| 514 |
else |
| 515 |
{ |
| 516 |
// EATM This doesn't really work for retargeted schemas. |
| 517 |
// |
| 518 |
XSDComplexTypeDefinitionImpl.validateAttributeGroup |
| 519 |
((XSDConcreteComponentImpl)xsdAttributeGroupDefinition, |
| 520 |
xsdAttributeGroupDefinition.getAttributeWildcardContent(), |
| 521 |
otherXSDAttributeGroupDefinition.getAttributeUses(), |
| 522 |
xsdAttributeGroupDefinition.getAttributeUses(), |
| 523 |
otherXSDAttributeGroupDefinition.getAttributeWildcard(), |
| 524 |
xsdAttributeGroupDefinition.getAttributeWildcard()); |
| 525 |
} |
| 526 |
} |
| 527 |
else |
| 528 |
{ |
| 529 |
Iterator<?> j = selfReferences.iterator(); |
| 530 |
j.next(); |
| 531 |
while (j.hasNext()) |
| 532 |
{ |
| 533 |
XSDConcreteComponentImpl xsdConcreteComponent = (XSDConcreteComponentImpl)j.next(); |
| 534 |
xsdConcreteComponent.createDiagnostic |
| 535 |
(XSDDiagnosticSeverity.ERROR_LITERAL, |
| 536 |
"src-redefine.7.1"); |
| 537 |
} |
| 538 |
} |
| 539 |
} |
| 540 |
} |
| 541 |
} |
| 542 |
} |
| 543 |
} |
| 544 |
} |
| 545 |
|
| 546 |
@Override |
| 547 |
protected void handleUnreconciledElement(Element child, List<XSDConcreteComponent> newContents, List<XSDConcreteComponent> remainingContents) |
| 548 |
{ |
| 549 |
XSDRedefineContent xsdRedefineContent = XSDRedefineContentImpl.createRedefineContent(child); |
| 550 |
if (xsdRedefineContent != null) |
| 551 |
{ |
| 552 |
newContents.add(xsdRedefineContent); |
| 553 |
} |
| 554 |
} |
| 555 |
|
| 556 |
@Override |
| 557 |
protected void handleReconciliation(List<XSDConcreteComponent> newContents, List<XSDConcreteComponent> remainingContents) |
| 558 |
{ |
| 559 |
if (!remainingContents.isEmpty()) |
| 560 |
{ |
| 561 |
getContents().removeAll(remainingContents); |
| 562 |
} |
| 563 |
|
| 564 |
@SuppressWarnings("unchecked") List<XSDRedefineContent> list = (List<XSDRedefineContent>)(List<?>)newContents; |
| 565 |
setListContentAndOrder(getContents(), list); |
| 566 |
} |
| 567 |
|
| 568 |
@Override |
| 569 |
protected void adoptContent(EReference eReference, XSDConcreteComponent xsdConcreteComponent) |
| 570 |
{ |
| 571 |
super.adoptContent(eReference, xsdConcreteComponent); |
| 572 |
if (xsdConcreteComponent instanceof XSDAnnotation) |
| 573 |
{ |
| 574 |
getAnnotations().add((XSDAnnotation)xsdConcreteComponent); |
| 575 |
} |
| 576 |
} |
| 577 |
|
| 578 |
@Override |
| 579 |
protected void orphanContent(EReference eReference, XSDConcreteComponent xsdConcreteComponent) |
| 580 |
{ |
| 581 |
super.orphanContent(eReference, xsdConcreteComponent); |
| 582 |
if (xsdConcreteComponent instanceof XSDAnnotation) |
| 583 |
{ |
| 584 |
getAnnotations().remove(xsdConcreteComponent); |
| 585 |
} |
| 586 |
} |
| 587 |
|
| 588 |
@Override |
| 589 |
public XSDConcreteComponent cloneConcreteComponent(boolean deep, boolean shareDOM) |
| 590 |
{ |
| 591 |
XSDRedefineImpl clonedRedefine = |
| 592 |
(XSDRedefineImpl)getXSDFactory().createXSDRedefine(); |
| 593 |
clonedRedefine.isReconciling = true; |
| 594 |
|
| 595 |
clonedRedefine.setSchemaLocation(getSchemaLocation()); |
| 596 |
|
| 597 |
if (deep) |
| 598 |
{ |
| 599 |
if (!getContents().isEmpty()) |
| 600 |
{ |
| 601 |
clonedRedefine.getContents().addAll(cloneConcreteComponents(getContents(), true, shareDOM)); |
| 602 |
} |
| 603 |
} |
| 604 |
|
| 605 |
if (shareDOM && getElement() != null) |
| 606 |
{ |
| 607 |
clonedRedefine.setElement(getElement()); |
| 608 |
} |
| 609 |
|
| 610 |
clonedRedefine.isReconciling = shareDOM; |
| 611 |
return clonedRedefine; |
| 612 |
} |
| 613 |
} |