Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How process all nodes within a specified parent?

Reply
Thread Tools

How process all nodes within a specified parent?

 
 
Emil Karlen
Guest
Posts: n/a
 
      07-09-2004
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"
xmlnssl="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>
"

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text nodes and element nodes query asd Java 3 05-23-2005 10:01 AM
finding nodes that don't match other nodes mlybarger@gmail.com XML 2 01-27-2005 07:26 PM
Looking A Nodes From Within Nodes Johnny Ooi XML 10 11-14-2004 06:55 PM
selecting nodes between other nodes Timo Nentwig XML 1 06-17-2004 04:54 AM
Reality check: Is it sensible to link XML nodes to other XML nodes in the same file? gavnosis XML 0 08-02-2003 08:22 AM



Advertisments