Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » How can I get the DocumentRoot?(Q about EMF)
How can I get the DocumentRoot?(Q about EMF) [message #169427] Tue, 05 September 2006 08:42
caoshan is currently offline caoshanFriend
Messages: 2
Registered: July 2009
Junior Member
I use EMF generate an Encore model from some schema files, such like below:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" ......>
<element name="module" type="scdl:Module"/>
<element name="component" type="scdl:Component"/>
<complexType name="Module">
<complexContent>
.......
</complexContent>
</complexType>
<complexType name="component">
<complexContent>
........
</complexContent>
</complexType>
.....
</schema>
There are 2 kinds of xml files which correspond module element and
component element respectively.

I want to parser a component element which can be loaded from a xml file.
But I can't get the namespace attibutes.
I find it could get XMLNSPrefixMap if I get a DocumentRoot first.(From API)
How could I get the object of DocumentRoot type?

It could be parserd as a Component but can't be DocumentRoot when I load
the file like the following way(If I change Component to DocumentRoot ,it
will occur error):

Resource resource = new
XMLResourceImpl(URI.createFileURI(new
File(filelocation).getAbsolutePath()));
XMLResource.XMLInfo info = new XMLInfoImpl();
info.setXMLRepresentation(XMLResource.XMLInfo.ELEMENT);
info.setName("component");
XMLResource.XMLMap map = new XMLMapImpl();
map.add(ScaPackage.eINSTANCE.getComponent(), info);
Map options = new HashMap();
options.put(XMLResource.OPTION_XML_MAP, map);
try {
resource.load(options);
} catch (IOException e) {
e.printStackTrace();
}
Component component = (Component)resource.getContents().get(0);


Thanks for any help!
Previous Topic:Remote IDE
Next Topic:Project builds fine in Eclipse, but not from command line
Goto Forum:
  


Current Time: Fri Apr 26 00:15:33 GMT 2024

Powered by FUDForum. Page generated in 0.07614 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top