Created
May 28, 2010 19:08
-
-
Save kwharrigan/417583 to your computer and use it in GitHub Desktop.
Topcased Requirements Table XSLT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- | |
/******************************************************************************* | |
* Copyright (c) 2009 RealTime-at-Work. | |
* All rights reserved. This program and the accompanying materials | |
* are made available under the terms of the Eclipse Public License v1.0 | |
* which accompanies this distribution, and is available at | |
* http://www.eclipse.org/legal/epl-v10.html | |
* | |
* Contributors: | |
* Loïc Fejoz - initial transformation. | |
*******************************************************************************/ | |
--> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xmi="http://www.omg.org/XMI" xmlns:sysML="http://www.topcased.org/2.0/sysML" xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML" xmlns:fn="http://www.w3.org/2005/02/xpath-functions"> | |
<xsl:output method="html" version="1.0" indent="yes"/> | |
<xsl:template match="/uml:Model"> | |
<html> | |
<head> | |
<title>table [requirement] <xsl:value-of select='@name'/> [all requirements]</title> | |
<link rel="stylesheet" type="text/css" href="style.css" /> | |
</head> | |
<body> | |
<div class='model package'> | |
<h1><xsl:value-of select='@name'/></h1> | |
<xsl:apply-templates select='packagedElement[@xmi:type="uml:Package"]'> | |
<xsl:with-param name="depth" select="2" /> | |
</xsl:apply-templates> | |
</div> | |
</body> | |
</html> | |
</xsl:template> | |
<xsl:template match="packagedElement[@xmi:type='uml:Package']"> | |
<xsl:param name="depth" /> | |
<xsl:if test='count(descendant::*[@xmi:type="sysML:Requirement"]) > 0'> | |
<div class='package'> | |
<xsl:attribute name="id"> | |
<xsl:value-of select="@xmi:id" /> | |
</xsl:attribute> | |
<xsl:element name="{concat('h', string($depth))}"> | |
<xsl:value-of select='@name'/> | |
</xsl:element> | |
<xsl:if test='count(child::*[@xmi:type="sysML:Requirement"]) > 0'> | |
<table class='requirement-table' border='1'> | |
<tr><th>id</th><th>name</th><th>text</th></tr> | |
<xsl:apply-templates select='descendant::*[@xmi:type="sysML:Requirement"]'> | |
<xsl:sort select='@id'/> | |
</xsl:apply-templates> | |
</table> | |
</xsl:if> | |
<xsl:apply-templates select='packagedElement[@xmi:type="uml:Package"]'> | |
<xsl:with-param name="depth" select="$depth + 1" /> | |
</xsl:apply-templates> | |
</div> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template match='*[@xmi:type="sysML:Requirement"]'> | |
<tr class='requirement'> | |
<xsl:attribute name="id"> | |
<xsl:value-of select="@xmi:id" /> | |
</xsl:attribute> | |
<td><xsl:value-of select="@id" /></td> | |
<td><xsl:value-of select="@name" /></td> | |
<td><xsl:value-of select="@text" /></td> | |
</tr> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From here:http://www.realtimeatwork.com/?page_id=afgikkudwfjy&paged=2
TopCased is a widely used and free SysML editor. Our SysML-Companion can work with it. Unfortunately TopCased is still lacking table notation (see feature request #2157), especially for requirements.
Here is a simple XSL stylesheet (EPL-1.0) that creates an HTML file containing the tables from the XMI file written with TopCased SysML editor.