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="UMLackage[@name=$pkg]//UML:Class">
"
.... and that this would start the recursion:
"
<xsl:template match="UMLackage[@name=$pkg]//UMLackage">
...
<xsl:apply-templates/>
</xsl:template>
"
My own theory is that the "UMLackage[@name=$pkg]//<elem>" uses the
CLOSEST "UMLackage"-element when matching, when I want it to mean ANY
ancestor "UMLackage"-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="UMLackage[@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="UMLackage[@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="UMLackage[@name=$pkg]//UMLackage">
Package <xsl:value-of select="@name"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@xmi.id"/>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
"
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="UMLackage[@name=$pkg]//UML:Class">
"
.... and that this would start the recursion:
"
<xsl:template match="UMLackage[@name=$pkg]//UMLackage">
...
<xsl:apply-templates/>
</xsl:template>
"
My own theory is that the "UMLackage[@name=$pkg]//<elem>" uses the
CLOSEST "UMLackage"-element when matching, when I want it to mean ANY
ancestor "UMLackage"-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="UMLackage[@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="UMLackage[@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="UMLackage[@name=$pkg]//UMLackage">
Package <xsl:value-of select="@name"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@xmi.id"/>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
"