<XMLFile xsi:noNamespaceSchemaLocation="My_xsd_file.xsd" FileName="Example.xml" SchemaVersion="1.10" xmlns:xsi="http://www.w3 dot org/2001/XMLSchema-instance"> <Version>2.1</Version> <AdditionalInformation someAttribute="someValue" /> <AdditionalInformation> <SomeChildElement> <ChildA>Some content</ChildA> <ChildB>Some content</ChildB> </SomeChildElement> </AdditionalInformation> </XMLFile>
for (EReference reference : object.eClass().getEAllReferences()) { if (reference.getName().toLowerCase().equals(childNode.getNodeName().toLowerCase())) { EClass type = Utils.getInstantiableEClass(reference.getEReferenceType()); if (type != null && reference.isChangeable()) { if (reference.isMany()) { EList list = (EList)object.eGet(reference); EObject obj = EcoreUtil.create(type); if(obj.getClass().equals(EObjectImpl.class)) { obj = xmlFactory.createAnyType(); } //recursiveImport(childNode, obj); list.add(obj); ...
if (object instanceof AnyType) { NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node childNode = children.item(i); switch (childNode.getNodeType()) { case Node.ELEMENT_NODE: AnyType childObj = xmlFactory.createAnyType(); recursiveImport(childNode, childObj); Entry entry = FeatureMapUtil.createEntry(xmlPackage.getAnyType_Any(), childObj); ((FeatureMap) object.eGet(xmlPackage.getAnyType_Any())).add(entry); // throws exception ((AnyType) object).getAny().add(entry); // throws exception ...
Exception in thread "main" java.lang.ClassCastException: The feature 'any's type 'EFeatureMapEntry' does not permit a value of type 'AnyType' at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$BasicFeatureMapEntry.validate(EStructuralFeatureImpl.java:3213) at org.eclipse.emf.ecore.util.FeatureMapUtil.createEntry(FeatureMapUtil.java:174)