Subject: RE: [xsl] Using keys to build a tree represented in XMI From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Fri, 30 Dec 2005 18:17:35 -0000 |
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@xxxxxx] > Sent: 28 December 2005 18:32 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > 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 don4t 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 aggregation4s direction can be seen in the > "aggregation" > attribute of each of the two end points ("none" -> > "aggregate"). But after > identifying the leaf classes I don4t 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Using keys to build a tre, Florent Georges | Thread | Re: RE: [xsl] Using keys to build a, Christian Solisch |
Re: RE: [xsl] Using keys to build a, Christian Solisch | Date | Re: [xsl] How to fetch desired data, rob Jackson |
Month |