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
[xsl] Using keys to build a tree represented in XMI
by Christian Solisch other posts by this author
Dec 28 2005 10:32AM messages near this date
Re: [xsl] How to fetch desired data | RE: [xsl] Using keys to build a tree represented in XMI
& XSLT 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:AssociationEnd.participant/UML:Class/@xmi.i
dref"
/> 
<!-- *** </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> 
--~--
Thread:
Christian Solisch
Michael Kay
Florent Georges
Christian Solisch
Christian Solisch

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