Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 250449 Details for
Bug 432133
Semantic model based on XML schema generated ecore and handling of DocumentRoot class
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Modified DAnalysisSessionImpl.doAddSemanticResouces with rationalization
DAnalysisSessionImpl.doAddSemanticResource.txt (text/plain), 5.32 KB, created by
John Palof
on 2015-02-02 12:28:58 EST
(
hide
)
Description:
Modified DAnalysisSessionImpl.doAddSemanticResouces with rationalization
Filename:
MIME Type:
Creator:
John Palof
Created:
2015-02-02 12:28:58 EST
Size:
5.32 KB
patch
obsolete
> protected void doAddSemanticResource(final Resource newResource, final ResourceSet set) { > if (new ResourceQuery(newResource).isRepresentationsResource()) { > throw new IllegalArgumentException("A representation file cannot be added as semantic resource."); > } > if (newResource.getResourceSet() != set) { > set.getResources().add(newResource); > } > if (newResource.getContents().size() > 0) { > notifyNewMetamodels(newResource); > > /* Bug 432133 - Semantic model based on XML schema generated ecore and handling of DocumentRoot class > * > * In the case of an XSD generated eCore model a DocumentRoot EClass would > * have been injected. In such cases, the features injected by the EClass > * need to be skipped over to arrive at the EClass representing the root > * element specified by the XSD. While 'DocumentRoot' is the default name > * of the injected EClass, it may be overridden by the ecore:documentRoot attribute. > * > * Excerpts from https://www.eclipse.org/modeling/emf/docs/overviews/XMLSchemaToEcoreMapping.pdf > * > * (section 1.5) > * If there is one or more global element or attribute declaration in the schema, > * then an EClass, representing the document root, is created in the schema's > * EPackage. The name of the document root class is "DocumentRoot" by default. > * > * A document root class will contain one feature for every global attribute > * or element declaration in the schema (see sections 4.7 and 5.8, below). A > * single instance of this class is used as the root object of an XML resource > * (that is, a conforming XML document). This instance will have exactly one of > * its element features set; the one corresponding to the global element at the > * root of the XML document. The features corresponding to global attribute > * declarations will never be set, but are used for setting values in attribute > * wildcard feature maps. > * ... > * End of Excerpts > */ >// final EObject root = newResource.getContents().get(0); //Bug 432133: removed 'final' > EObject root = newResource.getContents().get(0); > > EClass eCls = root.eClass(); > EList<EAnnotation> annotations = eCls.getEAnnotations(); > /* > * Attempt to determine if the eCore model was generated from XSD by inspecting > * the annotation on the root. XSD->ECore will use the ExtendedMetaData as the > * annotation source, set the 'name' to an empty string (since the generated > * DocumentRoot doesn't have an underlying Element name), and have a 'kind' of 'mixed'. > */ > for (EAnnotation annotation : annotations) { > EMap<String, String> details = annotation.getDetails(); > if (annotation.getSource().equals("http:///org/eclipse/emf/ecore/util/ExtendedMetaData") > && details.containsKey("name") > && details.get("name").length()==0 > && details.containsKey("kind") > && "mixed".equals(details.get("kind")) > ) { > /* > * Step over the "mixed", "xMLNSPrefixMap", and "xSISchemaLocation" features > * of the injected DocumentRoot found in an XSD generated ECore model > * > * Excerpts from https://www.eclipse.org/modeling/emf/docs/overviews/XMLSchemaToEcoreMapping.pdf > * > * (section 1.5) > * ... > * The document root EClass looks like one corresponding to a mixed complex type > * (see section 3.4) including a "mixed" feature, and derived implementations for > * the other features in the class. This allows it to maintain comments and white > * space that appears in the document, before the root element. A document root > * class contains two more EMap features, both String to String, to record the > * namespace to prefix mappings (xMLNSPrefixMap) and xsi:schemaLocation mappings > * (xSISchemaLocation) of an XML instance document. > */ > for (int featureID=0; featureID < eCls.getFeatureCount(); featureID++) { > EStructuralFeature eFeature = eCls.getEStructuralFeature(featureID); > String name = eFeature.getName(); > if (!"mixed".equals(name) > && !"xMLNSPrefixMap".equals(name) > && !"xSISchemaLocation".equals(name)){ > root = (EObject)root.eGet(eFeature); > break; > } > } > } > } > for (final DAnalysis analysis : this.allAnalyses()) { > analysis.getModels().add(root); > } > } > registerResourceInCrossReferencer(newResource); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
pierre-charles.david
:
iplog+
Actions:
View
Attachments on
bug 432133
:
241659
|
241660
| 250449