⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 styling.xsl

📁 Copyright&copy 2004 Sergiu Dumitriu, Marta G&icirc rdea, C&#259 t&#259 lin Hri&#355 cu Permission is
💻 XSL
字号:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Template: Styling.xsl

Obtain display properties
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/2000/svg" xmlns:UML="org.omg.xmi.namespace.UML">
	<xsl:output media-type="image/svg+xml" method="xml" indent="yes"/>

	<xsl:template match="text()"/>

	<!-- Test for element's visibility -->
	<xsl:template match="*" mode="isVisible">
		<xsl:if test="@isVisible= 'false'">
			<xsl:attribute name="display"><xsl:text>none</xsl:text></xsl:attribute>
		</xsl:if>
	</xsl:template>

	<!-- Font-family, font-color, font-size -->
	<xsl:template match="*" mode="FontStyle">
		<xsl:choose>
			<xsl:when test="UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement/@typeInfo = 'Name' and (../../../../UML:GraphElement.semanticModel//UML:Class or ../../../../UML:GraphElement.semanticModel//*[@presentation = 'Classifier'] or ../../../../UML:GraphElement.semanticModel//UML:Interface)">
				<xsl:attribute name="font-weight"><xsl:text>bold</xsl:text></xsl:attribute>
			</xsl:when>
			<xsl:when test="../../UML:GraphElement.semanticModel//UML:CallAction">
				<xsl:if test="../../UML:DiagramElement.property/UML:Property[@key='FontSize']">
					<!-- OMG attribute -->
					<xsl:attribute name="font-size">
						<xsl:value-of select="../../UML:DiagramElement.property/UML:Property[@key='FontSize']/@value"/>
					</xsl:attribute>
				</xsl:if>
				<xsl:if test="../../UML:DiagramElement.property/UML:Property[@key='font-size']">
					<!-- Gentleware attribute -->
					<xsl:attribute name="font-size">
						<xsl:value-of select="../../UML:DiagramElement.property/UML:Property[@key='font-size']/@value"/>
					</xsl:attribute>
				</xsl:if>
				<xsl:if test="../../UML:DiagramElement.property/UML:Property[@key='FontColor']">
					<!-- OMG attribute -->
					<xsl:attribute name="fill">
						<xsl:value-of select="../../UML:DiagramElement.property/UML:Property[@key='FontColor']/@value"/>
					</xsl:attribute>
				</xsl:if>
				<xsl:if test="../../UML:DiagramElement.property/UML:Property[@key='font-color']">
					<!-- Gentleware attribute -->
					<xsl:attribute name="fill">
						<xsl:value-of select="../../UML:DiagramElement.property/UML:Property[@key='font-color']/@value"/>
					</xsl:attribute>
				</xsl:if>
				<xsl:if test="../../UML:DiagramElement.property/UML:Property[@key='FontFamily']">
					<!-- OMG attribute -->
					<xsl:attribute name="font-family">
						<xsl:value-of select="../../UML:DiagramElement.property/UML:Property[@key='FontFamily']/@value"/>
					</xsl:attribute>
				</xsl:if>
				<xsl:if test="../../UML:DiagramElement.property/UML:Property[@key='font-family']">
					<!-- Gentleware attribute -->
					<xsl:attribute name="font-family">
						<xsl:value-of select="../../UML:DiagramElement.property/UML:Property[@key='font-family']/@value"/>
					</xsl:attribute>
				</xsl:if>
			</xsl:when>
			<xsl:otherwise>
				<xsl:if test="UML:DiagramElement.property/UML:Property[@key='FontSize']">
					<!-- OMG attribute -->
					<xsl:attribute name="font-size">
						<xsl:value-of select="UML:DiagramElement.property/UML:Property[@key='FontSize']/@value"/>
					</xsl:attribute>
				</xsl:if>
				<xsl:if test="UML:DiagramElement.property/UML:Property[@key='font-size']">
					<!-- Gentleware attribute -->
					<xsl:attribute name="font-size">
						<xsl:value-of select="UML:DiagramElement.property/UML:Property[@key='font-size']/@value"/>
					</xsl:attribute>
				</xsl:if>
				<xsl:if test="UML:DiagramElement.property/UML:Property[@key='FontColor']">
					<!-- OMG attribute -->
					<xsl:attribute name="fill">
						<xsl:value-of select="UML:DiagramElement.property/UML:Property[@key='FontColor']/@value"/>
					</xsl:attribute>
				</xsl:if>
				<xsl:if test="UML:DiagramElement.property/UML:Property[@key='font-color']">
					<!-- Gentleware attribute -->
					<xsl:attribute name="fill">
						<xsl:value-of select="UML:DiagramElement.property/UML:Property[@key='font-color']/@value"/>
					</xsl:attribute>
				</xsl:if>
				<xsl:if test="UML:DiagramElement.property/UML:Property[@key='FontFamily']">
					<!-- OMG attribute -->
					<xsl:attribute name="font-family">
						<xsl:value-of select="UML:DiagramElement.property/UML:Property[@key='FontFamily']/@value"/>
					</xsl:attribute>
				</xsl:if>
				<xsl:if test="UML:DiagramElement.property/UML:Property[@key='font-family']">
					<!-- Gentleware attribute -->
					<xsl:attribute name="font-family">
						<xsl:value-of select="UML:DiagramElement.property/UML:Property[@key='font-family']/@value"/>
					</xsl:attribute>
				</xsl:if>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<!-- Stroke -->
	<xsl:template match="*" mode="StrokeStyle">
		<xsl:param name="SemanticID"/>
		<xsl:if test="UML:DiagramElement.property/UML:Property[@key='ForegroundColor']">
			<xsl:attribute name="stroke">
				<!-- OMG attribute -->
				<xsl:value-of select="UML:DiagramElement.property/UML:Property[@key='ForegroundColor']/@value"/>
			</xsl:attribute>
		</xsl:if>
		<xsl:if test="UML:DiagramElement.property/UML:Property[@key='stroke']">
			<xsl:attribute name="stroke">
				<!-- Gentleware attribute -->
				<xsl:value-of select="UML:DiagramElement.property/UML:Property[@key='stroke']/@value"/>
			</xsl:attribute>
		</xsl:if>
	</xsl:template>

	<!-- Fill -->
    <xsl:template match="*" mode="FillStyle">
		<xsl:param name="SemanticID"/>
        <xsl:attribute name="fill">
            <xsl:choose>
                <xsl:when test="self::UML:Polyline/@closed = 'false'">
					<xsl:text>none</xsl:text>
                </xsl:when>
                <xsl:when test="UML:DiagramElement.property/UML:Property[@key='BackgroundColor']">
					<!-- OMG attribute -->
                    <xsl:value-of select="UML:DiagramElement.property/UML:Property[@key='BackgroundColor']/@value"/>
                </xsl:when>
                <xsl:when test="UML:DiagramElement.property/UML:Property[@key='fill']">
					<!-- Gentleware attribute -->
                    <xsl:value-of select="UML:DiagramElement.property/UML:Property[@key='fill']/@value"/>
                </xsl:when>
                <xsl:when test="UML:GraphElement.semanticModel//UML:Pseudostate">
					<xsl:variable name="Kind" select="key('xmi.id', $SemanticID)/@kind"/>
					<xsl:choose>
						<xsl:when test="$Kind = 'initial' or $Kind = 'junction' or $Kind = 'fork' or $Kind = 'join'"><xsl:text>black</xsl:text></xsl:when>
						<xsl:otherwise><xsl:text>white</xsl:text></xsl:otherwise>
					</xsl:choose>
                </xsl:when>
                <xsl:when test="((UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement/@typeInfo = 'NameCompartment') or (UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement/@typeInfo = 'BodyCompartment'))
					 and (../../UML:GraphElement.semanticModel//UML:Package) and (../../UML:DiagramElement.property/UML:Property[@key = 'BackgroundColor'])">
					<!-- OMG attribute -->
                    <xsl:value-of select="../../UML:DiagramElement.property/UML:Property[@key = 'BackgroundColor']/@value"/>
                </xsl:when>
                <xsl:when test="((UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement/@typeInfo = 'NameCompartment') or (UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement/@typeInfo = 'BodyCompartment'))
					 and (../../UML:GraphElement.semanticModel//UML:Package) and (../../UML:DiagramElement.property/UML:Property[@key = 'fill'])">
					<!-- Gentleware attribute -->
                    <xsl:value-of select="../../UML:DiagramElement.property/UML:Property[@key = 'fill']/@value"/>
                </xsl:when>
                <xsl:when test="(UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[@typeInfo='HeaderCompartment'] or UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[@typeInfo='Activation'])
					 and ../../UML:GraphElement.semanticModel//UML:Object and ../../UML:DiagramElement.property/UML:Property[@key='BackgroundColor']">
					<!-- OMG attribute -->
                    <xsl:value-of select="../../UML:DiagramElement.property/UML:Property[@key='BackgroundColor']/@value"/>
                </xsl:when>
                <xsl:when test="(UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[@typeInfo='HeaderCompartment'] or UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[@typeInfo='Activation'])
					 and ../../UML:GraphElement.semanticModel//UML:Object and ../../UML:DiagramElement.property/UML:Property[@key='fill']">
					<!-- Gentleware attribute -->
                    <xsl:value-of select="../../UML:DiagramElement.property/UML:Property[@key='fill']/@value"/>
                </xsl:when>
                <xsl:when test="(UML:Polyline.waypoints and @closed='true') or UML:Ellipse.center or
UML:GraphElement.contained/UML:GraphNode/UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement/@typeInfo='CompartmentSeparator' or
                                UML:GraphElement.semanticModel//UML:Actor or
                                UML:GraphElement.semanticModel//UML:Collaboration or
                                UML:GraphElement.semanticModel//UML:Object or
                                UML:GraphElement.semanticModel//UML:UseCase or
                                UML:GraphElement.semanticModel//UML:Node or
                                (UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[@typeInfo='NameCompartment'] and ../../UML:GraphElement.semanticModel//UML:Package) or
                                (UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[@typeInfo='BodyCompartment'] and ../../UML:GraphElement.semanticModel//UML:Package) or
                                UML:GraphElement.semanticModel/*[@presentation='Ball']//UML:Interface">
                    <xsl:text>white</xsl:text>
                </xsl:when>
                <xsl:when test="UML:GraphElement.semanticModel//UML:Comment">
                    <xsl:text>yellow</xsl:text>
                </xsl:when>
                <xsl:otherwise>white</xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
        <xsl:if test="UML:DiagramElement.property/UML:Property[@key='Translucent']">
			<!-- OMG attribute -->
            <xsl:attribute name="fill-opacity"><xsl:text>0</xsl:text></xsl:attribute>
        </xsl:if>
        <xsl:if test="UML:DiagramElement.property/UML:Property[@key='fill-opacity']">
			<!-- Gentleware attribute -->
            <xsl:attribute name="fill-opacity">
                <xsl:value-of select="UML:DiagramElement.property/UML:Property[@key='fill-opacity']/@value"/>
            </xsl:attribute>
        </xsl:if>
		<xsl:if test="UML:GraphElement.semanticModel/UML:Uml1SemanticModelBridge//UML:Object or (UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement/@typeInfo = 'HeaderCompartment' and ../../UML:GraphElement.semanticModel/UML:Uml1SemanticModelBridge//UML:Object)">
			<xsl:for-each select="key('xmi.id', $SemanticID)/UML:ModelElement.taggedValue/UML:TaggedValue">
				<xsl:variable name="idref" select=".//*[@xmi.idref]/@xmi.idref"/>
				<xsl:if test="(key('xmi.id', $idref)/@name = 'isActive') and (UML:TaggedValue.dataValue = 'true')">
					<xsl:attribute name="stroke-width"><xsl:text>3px</xsl:text></xsl:attribute>
				</xsl:if>
			</xsl:for-each>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -