How process all nodes within a specified parent?

Discussion in 'XML' started by Emil Karlen, Jul 9, 2004.

  1. Emil Karlen

    Emil Karlen Guest

    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>
    "
     
    Emil Karlen, Jul 9, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. asd
    Replies:
    3
    Views:
    452
    Arnaud Berger
    May 23, 2005
  2. Johnny Ooi

    Looking A Nodes From Within Nodes

    Johnny Ooi, Nov 13, 2004, in forum: XML
    Replies:
    10
    Views:
    666
    Johnny Ooi
    Nov 14, 2004
  3. Claudio Jolowicz
    Replies:
    2
    Views:
    793
    David Carlisle
    Feb 17, 2005
  4. Al Hatch
    Replies:
    3
    Views:
    1,007
    Johannes Koch
    Jun 5, 2006
  5. johkar
    Replies:
    2
    Views:
    893
    johkar
    May 29, 2009
Loading...

Share This Page