Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [XPAND] xpanding for a Type T
[XPAND] xpanding for a Type T [message #545060] Tue, 06 July 2010 14:24 Go to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hi, I am new to XPand. I have managed to create a template which
produces a .xls file compatible with MS -Excel. It basically outputs my
ecore model Classifiers (Worksheet), Attributes (Row header) etc...

Now, I would like to have control in XPand in which order the various
EObject types are outputed. (EReference, EAttribute) which are all
aggregated into the eContents. («EXPAND Content FOREACH eContents»
expands both EReference, EAttribute in whatever order they arrive).

Is there a way to achieve this perhaps Like in OCL, select(v:Type|
expression). I have seen XPand also mixes in OCL syntax. Whould this be
a practical way to achieve what I need?

thanks Christophe


«DEFINE Root FOR ecore::EPackage»
«FILE name + ".xls"»
<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">

<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Verdana"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s21">
<Font ss:FontName="Verdana" ss:Bold="1"/>
<Interior ss:Color="#606060" ss:Pattern="Solid"/>
</Style>
<Style ss:ID="s22">
<Font ss:FontName="Verdana" ss:Color="#FF9900"/>
<Interior ss:Color="#606060" ss:Pattern="Solid"/>
</Style>
<Style ss:ID="s23">
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="2"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="2"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="2"/>
</Borders>
</Style>
<Style ss:ID="s24">
<Interior ss:Color="#606060" ss:Pattern="Solid"/>
</Style>
</Styles>
«EXPAND Class FOREACH eClassifiers»
</Workbook>
«ENDFILE»
«ENDDEFINE»

«DEFINE Class FOR ecore::EClass»
<Worksheet ss:Name="«name»">
<Table>
<Column/>
<Row>
«EXPAND Content FOREACH eContents»
</Row>
</Table>
</Worksheet>
«ENDDEFINE»

«DEFINE Class FOR ecore::EClassifier»
«ENDDEFINE»


«DEFINE Class FOR ecore::EEnum»
«ENDDEFINE»

«DEFINE Annotation FOR ecore::EAnnotation»
<Cell><Data ss:Type="String">«this.source»</Data></Cell>
«ENDDEFINE»

«DEFINE Content FOR emf::EObject»
«ENDDEFINE»

«DEFINE Content FOR ecore::EReference»
«IF this.containment »
<Cell ss:StyleID="s21"><Data ss:Type="String">«this.name»</Data></Cell>
«ELSE»
<Cell ss:StyleID="s22"><Data ss:Type="String">«this.name»</Data></Cell>
«ENDIF»

«ENDDEFINE»

«DEFINE Content FOR ecore::EAttribute»
<Cell><Data ss:Type="String">«this.name»</Data></Cell>
«ENDDEFINE»
Re: [XPAND] xpanding for a Type T [message #545080 is a reply to message #545060] Tue, 06 July 2010 14:58 Go to previous message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Sorry, found the answer in the docs under 'Expressions':

collection.typeSelect(SomeType)

This can simple be added to my collection:

«EXPAND Content FOREACH eContents.typeSelect(ecore::EReference)»
«EXPAND Content FOREACH eContents.typeSelect(ecore::EAttribute)»

Cheers Christophe


Christophe Bouhier wrote:
> Hi, I am new to XPand. I have managed to create a template which
> produces a .xls file compatible with MS -Excel. It basically outputs my
> ecore model Classifiers (Worksheet), Attributes (Row header) etc...
>
> Now, I would like to have control in XPand in which order the various
> EObject types are outputed. (EReference, EAttribute) which are all
> aggregated into the eContents. («EXPAND Content FOREACH eContents»
> expands both EReference, EAttribute in whatever order they arrive).
>
> Is there a way to achieve this perhaps Like in OCL, select(v:Type|
> expression). I have seen XPand also mixes in OCL syntax. Whould this be
> a practical way to achieve what I need?
>
> thanks Christophe
>
>
> «DEFINE Root FOR ecore::EPackage»
> «FILE name + ".xls"»
> <?xml version="1.0"?>
> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
> xmlns:o="urn:schemas-microsoft-com:office:office"
> xmlns:x="urn:schemas-microsoft-com:office:excel"
> xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
> xmlns:html="http://www.w3.org/TR/REC-html40">
>
> <Styles>
> <Style ss:ID="Default" ss:Name="Normal">
> <Alignment ss:Vertical="Bottom"/>
> <Borders/>
> <Font ss:FontName="Verdana"/>
> <Interior/>
> <NumberFormat/>
> <Protection/>
> </Style>
> <Style ss:ID="s21">
> <Font ss:FontName="Verdana" ss:Bold="1"/>
> <Interior ss:Color="#606060" ss:Pattern="Solid"/>
> </Style>
> <Style ss:ID="s22">
> <Font ss:FontName="Verdana" ss:Color="#FF9900"/>
> <Interior ss:Color="#606060" ss:Pattern="Solid"/>
> </Style>
> <Style ss:ID="s23">
> <Borders>
> <Border ss:Position="Bottom" ss:LineStyle="Continuous"
> ss:Weight="2"/>
> <Border ss:Position="Left" ss:LineStyle="Continuous"
> ss:Weight="2"/>
> <Border ss:Position="Right" ss:LineStyle="Continuous"
> ss:Weight="2"/>
> <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="2"/>
> </Borders>
> </Style>
> <Style ss:ID="s24">
> <Interior ss:Color="#606060" ss:Pattern="Solid"/>
> </Style>
> </Styles>
> «EXPAND Class FOREACH eClassifiers»
> </Workbook>
> «ENDFILE»
> «ENDDEFINE»
>
> «DEFINE Class FOR ecore::EClass»
> <Worksheet ss:Name="«name»">
> <Table>
> <Column/>
> <Row>
> «EXPAND Content FOREACH eContents»
> </Row>
> </Table>
> </Worksheet>
> «ENDDEFINE»
>
> «DEFINE Class FOR ecore::EClassifier»
> «ENDDEFINE»
>
>
> «DEFINE Class FOR ecore::EEnum»
> «ENDDEFINE»
>
> «DEFINE Annotation FOR ecore::EAnnotation»
> <Cell><Data ss:Type="String">«this.source»</Data></Cell>
> «ENDDEFINE»
>
> «DEFINE Content FOR emf::EObject»
> «ENDDEFINE»
>
> «DEFINE Content FOR ecore::EReference»
> «IF this.containment »
> <Cell ss:StyleID="s21"><Data
> ss:Type="String">«this.name»</Data></Cell>
> «ELSE»
> <Cell ss:StyleID="s22"><Data
> ss:Type="String">«this.name»</Data></Cell>
> «ENDIF»
>
> «ENDDEFINE»
>
> «DEFINE Content FOR ecore::EAttribute»
> <Cell><Data ss:Type="String">«this.name»</Data></Cell>
> «ENDDEFINE»
>
>
Previous Topic:[Xtend] Editor shows wrong errors
Next Topic:Xpand and Xtend
Goto Forum:
  


Current Time: Thu Apr 18 22:50:26 GMT 2024

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

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

Back to the top