Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVT XSD EMF] How to get a xsd complexType from a model
[QVT XSD EMF] How to get a xsd complexType from a model [message #83721] Thu, 05 June 2008 19:03 Go to next message
Eclipse UserFriend
Originally posted by: David-392.Li.MorganStanley.com

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
Re: [QVT XSD EMF] How to get a xsd complexType from a model [message #83767 is a reply to message #83721] Fri, 06 June 2008 13:51 Go to previous messageGo to next message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
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 :=3D 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 Borla=
nd =

QVT.
This kind of manifested the concrete types required by the entry point t=
o =

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 pl=
ace
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@MorganStanley.co=
m> =

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:=3D interopModel.map interop2Xsd();
> }
>
> mapping INTEROP::InteropSchema::interop2Xsd() : XSD::XSDSchema {
> targetNamespace :=3D 'http://www.test.com/schedule';
> typeDefinitions :=3D 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 :=3D self.name;
> }
>
> --
> The IN parameter:
>
> <?xml version=3D"1.0" encoding=3D"ISO-8859-1"?>
> <interop:InteropSchema xmi:version=3D"2.0" =

> xmlns:xmi=3D"http://www.omg.org/XMI" xmlns:interop=3D"http://ms.com/in=
terop" =

> domainName=3D"interoptest" schemaMetaMajorVersion=3D"1" =

> schemaMetaMinorVersion=3D"4">
> <views name=3D"Schedule" version=3D"1">
> <elements name=3D"scheduleId" maxOccurs=3D"1" minOccurs=3D"1" =

> type=3D"xsd:string"/>
> <elements name=3D"price" maxOccurs=3D"1" minOccurs=3D"0" =

> type=3D"xsd:double"/>
> </views>
> </interop:InteropSchema>
>
> ----
>
> However, the OUT is as follows:
>
> <?xml version=3D"1.0" encoding=3D"UTF-8"?>
> <schema targetNamespace=3D'http://www.test.com/schedule'/>
> ----
>
> The problems are:
> 1) There is no xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema", how ca=
n 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 ho=
w =

> 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/
Re: [QVT XSD EMF] How to get a xsd complexType from a model [message #83797 is a reply to message #83767] Fri, 06 June 2008 14:25 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Radek,

Comments below.

Radek Dvorak wrote:
> 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.
It's good for people to look in XSDPrototypicalSchema since this class
shows pretty much an example of how to create every type of thing XSD
supports.
>
> 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.
Yes, you need to decide which schema for schema namespace to use and
likely want to choose a prefix.
>
> So apparently, a deeper knowledge of XSDSchema will be needed.
XSDPrototypicalSchema and XSDMainExample are good references.
> 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...
I can try to help on the XSD angle but I know nothing about QVT...
>
> Regards,
> /Radek
>
>
>
> On Thu, 05 Jun 2008 21:03:19 +0200, David
> <David-392.Li@MorganStanley.com> 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
>>
>>
>>
>>
>
>
>
Previous Topic:[ATL] problem with with xmi output
Next Topic:[ATL] Generate Output Elements at runtime/dynamically
Goto Forum:
  


Current Time: Wed Apr 24 23:54:20 GMT 2024

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

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

Back to the top