Today we see two strategies for using EMF to parse. XML as an EMF model:
One is through the following code:
Word-break:break-all; padding-top:4px; Border-bottom: #cccccc 1px solid; Background-color: #eeeeee "> Ifileeditorinput modelfile = (ifileeditorinput) geteditorinput ();
URI ResourceURI = Uri.createplatformresourceuri (Modelfile.getfile (). GetFullPath (). toString ())
Resource = Editingdomain.getresourceset (). GetResource (ResourceURI, true); The above approach refers to a adapterfactoryeditingdomain class, but sometimes we do not need to use this class, such as GEF, to have its own editordomain, based on the Model Editor.
Another way is to use a process that is automatically generated by using the EMF model, which is typically under the util package of the model, and the reference code is as follows:
Ifileeditorinput modelfile = (ifileeditorinput) geteditorinput ();
Xmlprocessor processor = new Designxmlprocessor ();
Resource = Processor.load (new InputSource (Modelfile.getfile (). getcontents (), "GBK")), null);
In fact, for EMF, the above two explanations, in the final analysis, need EMF to obtain business model-related parser, for the first way, EMF is how to obtain the business model of the parser. The extension is defined in the plugin.xml of the model, mainly by extension, as shown in the following illustration of the code fragment:
<extension point= "Org.eclipse.emf.ecore.extension_parser" >
<parser
Type= "Design"
class= "Com.neusoft.report.design.util.DesignResourceFactoryImpl"/>
</extension>
In this way, when parsing an. xml file, EMF obtains the parser (Designresourcefactoryimpl) from the Resourcefactory registry and completes the parsing according to the corresponding type. Enter the discussion group discussion.