ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xsl-list
xsl-list
RE: [xsl] Using keys to build a tree represented in XMI
by Michael Kay other posts by this author
Dec 30 2005 10:18AM messages near this date
[xsl] Using keys to build a tree represented in XMI | RE: [xsl] Using keys to build a tree represented in XMI
& XSLT I'm not sure exactly what you're trying to do here, but perhaps I can see
what you are doing wrong.

You have defined this key:

<xsl:key name="aggregation_by_classReference"
match="UML:Association.connection"

so this expression:

key('aggregation_by_classReference',./@xmi.id)

will return zero or more UML:Association.connection elements, and this
expression:

key('aggregation_by_classReference',./@xmi.id)/@xmi.id

will return their @xmi.id attributes.

But there is only one UML:Association.connection element in your sample
data, and it does not have an @xmi.id attribute.

Michael Kay
http://www.saxonica.com/

>  -----Original Message-----
>  From: Christian Solisch [mailto:christian.solisch@[...].de] 
>  Sent: 28 December 2005 18:32
>  To: xsl-list@[...].com
>  Subject: [xsl] Using keys to build a tree represented in XMI
>  
>  Hi community,
>  
>  I am new to XSLT and actually trying to use it for a 
>  transformation of a XMI
>  file. After two weeks of trying I really don´t know how to 
>  proceed. I am not
>  sure, if XSLT is really what I need to get the job done. Any 
>  help (or hint
>  to use anything else ;-) will be really appreciated!
>  
>  I use Saxon 8.6.1 on XSLT 2.0
>  
>  In an UML tool (enterprise architect) I modelled a 
>  tree-structure consisting
>  of classes. They are stereotyped by <<node>> and <<leaf>> and 
>  connected by
>  aggregations. After exporting it to XMI I like to generate 
>  the path for each
>  leaf (leading from root to leaf).
>  
>  After digging out that an aggregation points to both 
>  connected classes and
>  each class references its stereotype, I tried to use keys to 
>  resolve the
>  references. The aggregation´s direction can be seen in the 
>  "aggregation"
>  attribute of each of the two end points ("none" -> 
>  "aggregate"). But after
>  identifying the leaf classes I don´t manage it to follow the 
>  aggregation...
>  
>  Here is my stylesheet:
>  
>  <?xml version="1.0" encoding="UTF-8"?>
>  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>  version="2.0" xmlns:UML="org.omg.xmi.namespace.UML"
>  exclude-result-prefixes="UML">
>  
>  <!-- *** <Keys> ************************************************ -->
>  <xsl:key name="package_by_name" match="UML:Package" use="@name" />
>  <xsl:key name="stereotype_by_name" match="UML:Stereotype" 
>  use="@name" />
>  <xsl:key name="class_by_stereotypeReference" match="UML:Class"
>  use="UML:ModelElement.stereotype/UML:Stereotype/@xmi.idref" />
>  <xsl:key name="class_by_ID" match="UML:Class" use="@xmi.id" />
>  <xsl:key name="aggregation_by_classReference"
>  match="UML:Association.connection"
>  use="UML:AssociationEnd[@aggregation='none']/UML:AssociationEn
>  d.participant/UML:Class/@xmi.idref"
>  />
>  <!-- *** </Keys> *********************************************** -->
>  
>  
>  <xsl:template match="/">
>  <xsl:apply-templates select="key('stereotype_by_name', 'leaf')" />
>  </xsl:template>
>  
>  <xsl:template match="UML:Stereotype">
>  <xsl:apply-templates 
>  select="key('class_by_stereotypeReference', @xmi.id)"/>
>  </xsl:template>
>  
>  <!-- now i should have only leaf classes -->
>  <xsl:template match="UML:Class">
>    <xsl:for-each select="." >
>    <!-- here i have to find the aggregation -->
>    <!-- pointing to this class, actually not working -->
>      <xsl:value-of
>  select="key('aggregation_by_classReference',./@xmi.id)/@xmi.id"/>
>    </xsl:for-each>
>  </xsl:template>
>  </xsl:stylesheet>
>  	
>  A part of the XMI file looks like this:
>  
>  <XMI.content>
>   <UML:Model name="Views" xmi.id="Model_id_1">
>    <UML:Namespace.ownedElement>	
>  	
>     <UML:Stereotype xmi.id="Stereotype_id_1" name="node" 
>  ></UML:Stereotype>
>     <UML:Stereotype xmi.id="Stereotype_id_2" name="leaf" 
>  ></UML:Stereotype>
>  		
>     <UML:Package name="Package_Tree" xmi.id="Package_id_1">
>      <UML:Namespace.ownedElement>
>  
>       <UML:Class name="Node_1" xmi.id="Node_id_1">
>        <UML:ModelElement.stereotype>
>         <UML:Stereotype xmi.idref="Stereotype_id_1"/>
>        </UML:ModelElement.stereotype>
>       </UML:Class>
>  
>       <UML:Association xmi.id="Aggregation_id_1">
>        <UML:Association.connection>
>  
>         <UML:AssociationEnd aggregation="none">
>          <UML:AssociationEnd.participant>
>           <UML:Class xmi.idref="Node_id_2"/>
>          </UML:AssociationEnd.participant>
>         </UML:AssociationEnd>
>  
>         <UML:AssociationEnd aggregation="aggregate">
>          <UML:AssociationEnd.participant>
>           <UML:Class xmi.idref="Node_id_1"/>
>          </UML:AssociationEnd.participant>
>         </UML:AssociationEnd>
>  
>        </UML:Association.connection>
>       </UML:Association>
>  
>       <UML:Class name="Node_2" xmi.id="Node_id_2">
>        <UML:ModelElement.stereotype>
>         <UML:Stereotype xmi.idref="Stereotype_id_2"/>
>        </UML:ModelElement.stereotype>
>       </UML:Class>
>  
>      </UML:Namespace.ownedElement>				
>  		   </UML:Package>
>  
>    </UML:Namespace.ownedElement>
>   </UML:Model>
>  </XMI.content>
>  	
>  So if somebody could help me with some ideas how to follow 
>  the connection
>  between my nodes, I would be very happy!
>  
>  Thanks in advance
>  Christian
>  
>  -- 
>  Telefonieren Sie schon oder sparen Sie noch?
>  NEU: GMX Phone_Flat http://www.gmx.net/de/go/telefonie
>  
>  --~------------------------------------------------------------------
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>  To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
>  or e-mail: <mailto:xsl-list-unsubscribe@[...].com>
>  --~--
>  
>  



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@[...].com> 
--~--
Thread:
Christian Solisch
Michael Kay
Florent Georges
Christian Solisch
Christian Solisch

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved