[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.modeling.m2m] Re: [QVT XSD EMF] How to get a xsd complexType from a model
|
Hi David,
You should not set your complex type to 'typeDefinitions' as it's not a
containment reference
and will not get serialized along with the XSDSchema instance
>> typeDefinitions := self.views2Types();
You can easily figure out by hyperlink navigation from 'typeDefinitions'
into the metamodel
browser and check the properties.
Unfortunately, I'm not an expert on XSDSchema metamodel, but I think the
complex types should
go to 'XSDSchema::contents'. By doing so you will face another problem,
which is NPE from
the XSDSchema metamodel, due to getQNamePrefixToNamespaceMap() not
initialized with neccessary stuff.
Both 1) and 2) seem connected to this.
So apparently, a deeper knowledge of XSDSchema will be needed.
I'm not aware of any good example about this but just an idea ;-),
you might have a look at org.eclipse.xsd.ecore.EcoreSchemaBuilder.java,
which produces an XSDSchema from an Ecore EPackage.
Just a small comment on your main(...), no need to have args there.
It is still supported as it came with the original contribution of Borland
QVT.
This kind of manifested the concrete types required by the entry point to
clients,
however, what you create as the output model goes automatically to the
output extent
and is saved to the resource assigned in your launch config.
If you name your out model param explicitly like bellow
transformation interop2xsd(in interop: INTEROP , out xsdOut : XSD);
you can refer to it in object instantiations and send it to the right place
in case of multiple outputs.
Sorry, I have not solved your problem...
Regards,
/Radek
On Thu, 05 Jun 2008 21:03:19 +0200, David <David-392.Li@xxxxxxxxxxxxxxxxx>
wrote:
Hi,
I tried to get a xsd complex type from a model, but failed. The .qvto is
as following:
modeltype INTEROP uses "http://www.test.com/interop";
modeltype XSD uses "http://www.eclipse.org/xsd/2002/XSD";
transformation interop2xsd(in interop: INTEROP , out XSD);
main(in interopModel: INTEROP::InteropSchema, out xsd: XSD::XSDSchema) {
xsd:= interopModel.map interop2Xsd();
}
mapping INTEROP::InteropSchema::interop2Xsd() : XSD::XSDSchema {
targetNamespace := 'http://www.test.com/schedule';
typeDefinitions := self.views2Types();
}
query INTEROP::InteropSchema::views2Types() :
OrderedSet(XSD::XSDTypeDefinition) {
self.views->collect(view | view.view2Type())->asOrderedSet();
}
mapping INTEROP::InteropViewComplexType::view2Type() :
XSD::XSDComplexTypeDefinition
{ -- only set name, no others since I even can not get a complex
type name := self.name;
}
--
The IN parameter:
<?xml version="1.0" encoding="ISO-8859-1"?>
<interop:InteropSchema xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:interop="http://ms.com/interop"
domainName="interoptest" schemaMetaMajorVersion="1"
schemaMetaMinorVersion="4">
<views name="Schedule" version="1">
<elements name="scheduleId" maxOccurs="1" minOccurs="1"
type="xsd:string"/>
<elements name="price" maxOccurs="1" minOccurs="0"
type="xsd:double"/>
</views>
</interop:InteropSchema>
----
However, the OUT is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace='http://www.test.com/schedule'/>
----
The problems are:
1) There is no xmlns:xsd="http://www.w3.org/2001/XMLSchema", how can I
get this generated?
2) Why I can not get a complex type with 'Schedule' named? Do I have to
set more attributes? Since XSD.ecore is quit complex, I am not sure how
to do mapping exactly? Is there any good example?
Thanks for any suggestions.
David
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/