Serializing EAttribute from Dynamic Model [message #203710] |
Thu, 24 November 2005 16:55 |
Eclipse User |
|
|
|
Originally posted by: fwalsh.tssg.org
Hi,
I'm dynamically creating new non-generated class which I want to seralize
to an XML file. The serialization is working however want the EAttributes
for this class to be serialized as XML elements, not as attributes. Is
there an easy way to do this?? Here is the main parts of the code.The
EAttribute is created as follows:
EAttribute serviceUsageAttr = EcoreFactory.eINSTANCE.createEAttribute();
serviceUsageAttr.setName("numOfNights");
serviceUsageAttr.setEType(EcorePackage.eINSTANCE.getEString( ));
Then I add it into an existing EClass:
subIpdr.getEStructuralFeatures().add(serviceUsageAttr);
Which is then added to a resource and saved:
XMLResourceImpl ipdrXML = new XMLResourceImpl(fileURI);
ipdrXML.getContents().add(ipdr);
options.put(XMLResource.OPTION_EXTENDED_META_DATA,
ExtendedMetaData.INSTANCE);
ipdrXML.save(options);
The XML that is saved:
<?xml version="1.0" encoding="ASCII"?>
<ipdr:DBEIpdrType xmlns:ipdr="http://www.ipdr.org/namespaces/ipdr"
numOfNights="2"/>
The XML that I want:
<?xml version="1.0" encoding="ASCII"?>
<ipdr:DBEIpdrType xmlns:ipdr="http://www.ipdr.org/namespaces/ipdr">
<ipdr:numOfNights>2</ipdr:numOfNights>
</ipdr:DBEIpdrType>
Any help would be greatly appreciated. I can supply the full code if
required.
Thanks,
Frank.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03670 seconds