How process all nodes within a specified parent?

E

Emil Karlen

I am modelling a software system in UML using Umbrello, which stores the
UML-model in a XMI-file (which exact type I only guess).

Now, my goal is to: have a XSL-transformation (which I call the
"script") that, given a name of a "Package"-element lists all
"Interface"-, "Class"- and "Package"-elements underneath it.
My problem is that I won't get the recursion running. The script only
lists the elements directly underneath the package, not elements in
subpackages. I have tried using "//" but it won't work.

I must have missunderstood something. I thought that this would match
any class with the specified package as a parent (independent of depth):

"
<xsl:template match="UML:package[@name=$pkg]//UML:Class">
"

.... and that this would start the recursion:

"
<xsl:template match="UML:package[@name=$pkg]//UML:package">
...
<xsl:apply-templates/>
</xsl:template>
"

My own theory is that the "UML:package[@name=$pkg]//<elem>" uses the
CLOSEST "UML:package"-element when matching, when I want it to mean ANY
ancestor "UML:package"-element.
But this is of course only my own theory.

Please help!
Thansks in advance,
Emil Karlén


Here is the whole "script":

"
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:UML="org.omg/standards/UML"
xmlns="http://www.w3.org/TR/xhtml1/strict">


<xsl:template match="text()"></xsl:template>


<xsl:template match="/">
<xsl:apply-templates select="/XMI/XMI.content/UML:Model"/>
</xsl:template>


<xsl:template match="UML:Model">
<xsl:apply-templates/>
</xsl:template>


<xsl:template match="UML:package[@name=$pkg]//UML:Class">
Class<xsl:text> </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@xmi.id"/>
</xsl:template>


<xsl:template match="UML:package[@name=$pkg]//UML:Interface">
Interface <xsl:value-of select="@name"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@xmi.id"/>
</xsl:template>


<xsl:template match="UML:package[@name=$pkg]//UML:package">
Package <xsl:value-of select="@name"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@xmi.id"/>
<xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet>
"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top