Re: [xsl] Displaying column headers only if variable changes

Subject: Re: [xsl] Displaying column headers only if variable changes
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
Date: Wed, 13 Feb 2002 02:22:09 +0100
> Any ideas of what I can do to get around this? Or any idea how I can
> output the xml so I can see what it looks like?

Hello Brian,

you are creating reports from Magic Draw files. These are in XMI format,
which is a special XML format for describing UML. You can look these file
without problems. As fas as I know - I worked with such files around a half
year ago - the standard file format of Magic Draw is XMI, but it is ZIPped.
But you can save the files as pure XMI.

The other way would be copying the whole XML to the output:

    <xsl:template match="/">
        <xsl:copy-of select="."/>

But I can tell you: The files are really big and you will need a lot of time
to come through the structure.

> Thanks, that worked perfectly. Only problem now is that if I have a "type"
that doesn't have any diagrams on it, I still get the title for that type,
like this:
> Class Diagrams
> Use Case Diagrams
>  diagram 1
>  diagram 2
> Activity Diagrams
>  diagram 1
>  diagram 2
> Sequence Diagrams
> Neither class nor sequence have any diagrams, but I still got the heading
> in the report. I guess that means ( I can't see the XML unfortunately),
> that its coming from the XML somehow.

You have to ways for avoiding empty types. Either changing the key, so that
the index is only about types, which have diagrams, or changing the first
for-each statement, so that it goes only about types, which have diagrams.
The first way is the more exact I think, when you don't need the empty
types. I don't know the exact tree, but it's something like the follwoing.

<xsl:key name="elements[which have child-nodes, which identify diagrams]"
match="element" use="type"/>

Maybe it's easily: elements[].



> <xsl:key name="elements" match="element" use="type"/>
> <xsl:for-each select="element[count( . | key('elements', type)[1] ) = 1]">
>     <xsl:value-of select="type"/>
>     <xsl:for-each select="key('elements', type)">
>         <xsl:value-of select=""/>
>     </xsl:for-each>
> </xsl:for-each>

 XSL-List info and archive:

Current Thread