📄 lines.xsl
字号:
<?xml version="1.0" encoding="UTF-8"?><!--Template: Lines.xslTemplates used for displaying lines--><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:import href="Styling.xsl"/> <xsl:import href="Arrowheads.xsl" /> <xsl:import href="StereotypeCompartment.xsl"/> <xsl:import href="Visibility.xsl"/> <xsl:import href="Multiplicity.xsl"/> <xsl:import href="ExpressionCompartment.xsl"/> <xsl:import href="../StateDiagrams/TransitionDescription.xsl"/> <xsl:import href="../CollaborationDiagrams/StimuliArrows.xsl"/> <xsl:output media-type="image/svg+xml" method="xml" indent="yes" /> <!-- Generalization line, displayed as a simple line with an empty triangle at the endpoint --> <xsl:template name="Generalization_Line"> <xsl:param name="Waypoints" select="UML:GraphEdge.waypoints"/> <xsl:param name="DiagramID" select="@xmi.id"/> <xsl:param name="SemanticID" select="UML:GraphElement.semanticModel/UML:Uml1SemanticModelBridge/UML:Uml1SemanticModelBridge.element/*/@xmi.idref"/> <xsl:variable name="PathData"> <xsl:call-template name="BuildPathData"/> </xsl:variable> <!-- The main Generalization group --> <g transform="translate({UML:GraphElement.position/XMI.field[1]}, {UML:GraphElement.position/XMI.field[2]})"> <xsl:apply-templates select="." mode="FontStyle"/> <xsl:apply-templates select="." mode="StrokeStyle"/> <xsl:apply-templates select="." mode="isVisible" /> <title>Generalization line <xsl:value-of select="$SemanticID"/></title> <desc>Generalization: <xsl:value-of select="key('xmi.id', $SemanticID)/UML:Generalization.child/*/@xmi.idref"/> → <xsl:value-of select="key('xmi.id', $SemanticID)/UML:Generalization.parent/*/@xmi.idref"/></desc> <!-- The generalization marker --> <xsl:call-template name="GeneralizationArrowhead"> <xsl:with-param name="DiagramID" select="$DiagramID" /> </xsl:call-template> <path d="{$PathData}" fill="none" marker-end="url(#GeneralizationArrowhead{$DiagramID})"/> <!-- Display edge properties --> <xsl:call-template name="EdgeText"> <xsl:with-param name="SemanticID" select="$SemanticID"/> </xsl:call-template> </g> </xsl:template> <!-- Dependency line, displayed as a dashed line with a simple arrowhead at the endpoint --> <xsl:template name="Dependency_Line"> <xsl:param name="Waypoints" select="UML:GraphEdge.waypoints"/> <xsl:param name="DiagramID" select="@xmi.id"/> <xsl:param name="SemanticID" select="UML:GraphElement.semanticModel/UML:Uml1SemanticModelBridge/UML:Uml1SemanticModelBridge.element/*/@xmi.idref"/> <xsl:variable name="PathData"> <xsl:call-template name="BuildPathData"/> </xsl:variable> <!-- The main Dependency group --> <g transform="translate({UML:GraphElement.position/XMI.field[1]}, {UML:GraphElement.position/XMI.field[2]})"> <xsl:apply-templates select="." mode="FontStyle"/> <xsl:apply-templates select="." mode="StrokeStyle"/> <xsl:apply-templates select="." mode="isVisible" /> <title>Dependency line <xsl:value-of select="$SemanticID"/></title> <desc>Dependency: <xsl:value-of select="key('xmi.id', $SemanticID)/UML:Dependency.client/*/@xmi.idref"/> → <xsl:value-of select="key('xmi.id', $SemanticID)/UML:Dependency.supplier/*/@xmi.idref"/></desc> <!-- The dependency marker --> <xsl:call-template name="DependencyArrowhead"> <xsl:with-param name="DiagramID" select="$DiagramID" /> </xsl:call-template> <path d="{$PathData}" fill="none" style="stroke-dasharray: 6 10" marker-end="url(#DependencyArrowhead{$DiagramID})" /> <!-- Display edge properties --> <xsl:call-template name="EdgeText"> <xsl:with-param name="SemanticID" select="$SemanticID"/> </xsl:call-template> </g> </xsl:template> <!-- Association line, displayed as a simple line --> <!-- Multiple semantics: aggregation, composition, direction --> <xsl:template name="Association_Line"> <xsl:param name="Waypoints" select="UML:GraphEdge.waypoints"/> <xsl:param name="DiagramID" select="@xmi.id"/> <xsl:param name="SemanticID" select="UML:GraphElement.semanticModel/UML:Uml1SemanticModelBridge/UML:Uml1SemanticModelBridge.element/*/@xmi.idref"/> <xsl:variable name="PathData"> <xsl:call-template name="BuildPathData"/> </xsl:variable> <!-- Determine the type of the association from the AssociationEnds --> <!-- Association direction --> <xsl:variable name="TraversableFrom"> <xsl:value-of select="key('xmi.id', $SemanticID)/UML:Association.connection/UML:AssociationEnd[1]/@isNavigable"></xsl:value-of> </xsl:variable> <xsl:variable name="TraversableTo"> <xsl:value-of select="key('xmi.id', $SemanticID)/UML:Association.connection/UML:AssociationEnd[2]/@isNavigable"></xsl:value-of> </xsl:variable> <xsl:variable name="Traversable"> <xsl:choose> <xsl:when test="($TraversableFrom = 'true') and ($TraversableTo = 'true')"><xsl:text>Both</xsl:text></xsl:when> <xsl:when test="($TraversableFrom = 'true') and ($TraversableTo = 'false')"><xsl:text>From</xsl:text></xsl:when> <xsl:when test="($TraversableFrom = 'false') and ($TraversableTo = 'true')"><xsl:text>To</xsl:text></xsl:when> <xsl:when test="($TraversableFrom = 'false') and ($TraversableTo = 'false')"><xsl:text>None</xsl:text></xsl:when> </xsl:choose> </xsl:variable> <!-- Aggregation --> <xsl:variable name="Aggregation"> <xsl:choose> <xsl:when test="key('xmi.id', $SemanticID)/UML:Association.connection/UML:AssociationEnd[(position() = 1) and (@aggregation = 'aggregate')]"><xsl:text>From</xsl:text></xsl:when> <xsl:when test="key('xmi.id', $SemanticID)/UML:Association.connection/UML:AssociationEnd[(position() = 2) and (@aggregation = 'aggregate')]"><xsl:text>To</xsl:text></xsl:when> </xsl:choose> </xsl:variable> <!-- Composition --> <xsl:variable name="Composition"> <xsl:choose> <xsl:when test="key('xmi.id', $SemanticID)/UML:Association.connection/UML:AssociationEnd[(position() = 1) and (@aggregation = 'composite')]"><xsl:text>From</xsl:text></xsl:when> <xsl:when test="key('xmi.id', $SemanticID)/UML:Association.connection/UML:AssociationEnd[(position() = 2) and (@aggregation = 'composite')]"><xsl:text>To</xsl:text></xsl:when> </xsl:choose> </xsl:variable> <!-- Determine the line's end marker --> <xsl:variable name="marker-end"> <xsl:choose> <xsl:when test="$Traversable = 'To'"> <xsl:choose> <xsl:when test="$Aggregation = 'To'"><xsl:text>DirectedAggregationArrowheadEnd</xsl:text></xsl:when> <xsl:when test="$Composition = 'To'"><xsl:text>DirectedCompositionArrowheadEnd</xsl:text></xsl:when> <xsl:otherwise><xsl:text>DirectedArrowheadEnd</xsl:text></xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:choose> <xsl:when test="$Aggregation = 'To'"><xsl:text>AggregationArrowheadEnd</xsl:text></xsl:when> <xsl:when test="$Composition = 'To'"><xsl:text>CompositionArrowheadEnd</xsl:text></xsl:when> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:variable> <!-- Determine the line's start marker --> <xsl:variable name="marker-start"> <xsl:choose> <xsl:when test="$Traversable = 'From'"> <xsl:choose> <xsl:when test="$Aggregation = 'From'"><xsl:text>DirectedAggregationArrowheadStart</xsl:text></xsl:when> <xsl:when test="$Composition = 'From'"><xsl:text>DirectedCompositionArrowheadStart</xsl:text></xsl:when> <xsl:otherwise><xsl:text>DirectedArrowheadStart</xsl:text></xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:choose> <xsl:when test="$Aggregation = 'From'"><xsl:text>AggregationArrowheadStart</xsl:text></xsl:when> <xsl:when test="$Composition = 'From'"><xsl:text>CompositionArrowheadStart</xsl:text></xsl:when> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:variable> <!-- The main Association group --> <g transform="translate({UML:GraphElement.position/XMI.field[1]}, {UML:GraphElement.position/XMI.field[2]})"> <xsl:apply-templates select="." mode="FontStyle"/> <xsl:apply-templates select="." mode="StrokeStyle"/> <xsl:apply-templates select="." mode="isVisible" /> <title>Association line <xsl:value-of select="$SemanticID"/></title> <desc>Association: <xsl:value-of select="key('xmi.id', $SemanticID)/UML:Association.connection/UML:AssociationEnd[1]/UML:AssociationEnd.participant/*/@xmi.idref"/> <xsl:if test="$Aggregation = 'From'"><xsl:text> (Aggregation)</xsl:text></xsl:if> <xsl:if test="$Composition = 'From'"><xsl:text> (Composition)</xsl:text></xsl:if> <xsl:choose> <xsl:when test="$Traversable = 'Both'"> ↔ </xsl:when> <xsl:when test="$Traversable = 'From'"> → </xsl:when> <xsl:when test="$Traversable = 'To'"> ← </xsl:when> <xsl:when test="$Traversable = 'None'"> — </xsl:when> </xsl:choose> <xsl:value-of select="key('xmi.id', $SemanticID)/UML:Association.connection/UML:AssociationEnd[2]/UML:AssociationEnd.participant/*/@xmi.idref"/> <xsl:if test="$Aggregation = 'To'"><xsl:text> (Aggregation)</xsl:text></xsl:if> <xsl:if test="$Composition = 'To'"><xsl:text> (Composition)</xsl:text></xsl:if> </desc> <xsl:if test="$marker-start != ''"> <xsl:choose> <xsl:when test="$marker-start = 'DirectedArrowheadStart'"> <xsl:call-template name="DirectedArrowheadStart"> <xsl:with-param name="DiagramID" select="$DiagramID" /> </xsl:call-template> </xsl:when> <xsl:when test="$marker-start = 'DirectedAggregationArrowheadStart'"> <xsl:call-template name="DirectedAggregationArrowheadStart"> <xsl:with-param name="DiagramID" select="$DiagramID" /> </xsl:call-template> </xsl:when> <xsl:when test="$marker-start = 'DirectedCompositionArrowheadStart'"> <xsl:call-template name="DirectedCompositionArrowheadStart"> <xsl:with-param name="DiagramID" select="$DiagramID" /> </xsl:call-template> </xsl:when> <xsl:when test="$marker-start = 'AggregationArrowheadStart'"> <xsl:call-template name="AggregationArrowheadStart"> <xsl:with-param name="DiagramID" select="$DiagramID" /> </xsl:call-template> </xsl:when> <xsl:when test="$marker-start = 'CompositionArrowheadStart'"> <xsl:call-template name="CompositionArrowheadStart"> <xsl:with-param name="DiagramID" select="$DiagramID" /> </xsl:call-template> </xsl:when> </xsl:choose> </xsl:if> <xsl:if test="$marker-end != ''"> <xsl:choose> <xsl:when test="$marker-end = 'DirectedArrowheadEnd'"> <xsl:call-template name="DirectedArrowheadEnd"> <xsl:with-param name="DiagramID" select="$DiagramID" /> </xsl:call-template> </xsl:when> <xsl:when test="$marker-end = 'DirectedAggregationArrowheadEnd'"> <xsl:call-template name="DirectedAggregationArrowheadEnd"> <xsl:with-param name="DiagramID" select="$DiagramID" /> </xsl:call-template> </xsl:when> <xsl:when test="$marker-end = 'DirectedCompositionArrowheadEnd'"> <xsl:call-template name="DirectedCompositionArrowheadEnd"> <xsl:with-param name="DiagramID" select="$DiagramID" /> </xsl:call-template> </xsl:when> <xsl:when test="$marker-end = 'AggregationArrowheadEnd'"> <xsl:call-template name="AggregationArrowheadEnd"> <xsl:with-param name="DiagramID" select="$DiagramID" /> </xsl:call-template> </xsl:when> <xsl:when test="$marker-end = 'CompositionArrowheadEnd'"> <xsl:call-template name="CompositionArrowheadEnd"> <xsl:with-param name="DiagramID" select="$DiagramID" /> </xsl:call-template> </xsl:when> </xsl:choose> </xsl:if> <!-- Association line --> <path d="{$PathData}" fill="none"> <xsl:if test="$marker-start != ''"> <xsl:attribute name="marker-start"> <xsl:text>url(#</xsl:text><xsl:value-of select="$marker-start" /><xsl:value-of select="$DiagramID"/><xsl:text>)</xsl:text> </xsl:attribute> </xsl:if> <xsl:if test="$marker-end != ''"> <xsl:attribute name="marker-end"> <xsl:text>url(#</xsl:text><xsl:value-of select="$marker-end" /><xsl:value-of select="$DiagramID"/><xsl:text>)</xsl:text> </xsl:attribute> </xsl:if> </path> <!-- Display edge properties --> <xsl:call-template name="EdgeText"> <xsl:with-param name="SemanticID" select="$SemanticID"/> </xsl:call-template> </g> </xsl:template> <!-- AssociationClassEdge line, displayed as a dashed line --> <xsl:template name="AssociationClassEdge_Line"> <xsl:param name="Waypoints" select="UML:GraphEdge.waypoints"/> <xsl:param name="DiagramID" select="@xmi.id"/> <xsl:param name="SemanticID" select="UML:GraphElement.semanticModel/UML:Uml1SemanticModelBridge/UML:Uml1SemanticModelBridge.element/*/@xmi.idref"/> <xsl:variable name="PathData"> <xsl:call-template name="BuildPathData"/> </xsl:variable> <!-- The main Link group --> <g transform="translate({UML:GraphElement.position/XMI.field[1]}, {UML:GraphElement.position/XMI.field[2]})"> <xsl:apply-templates select="." mode="FontStyle"/> <xsl:apply-templates select="." mode="StrokeStyle"/> <xsl:apply-templates select="." mode="isVisible" /> <title>Link line <xsl:value-of select="$SemanticID"/></title> <desc>Link: <xsl:value-of select="key('xmi.id', $SemanticID)/UML:LinkEnd.instance[1]/*/@xmi.idref"/> ↔ <xsl:value-of select="key('xmi.id', $SemanticID)/UML:LinkEnd.instance[2]/*/@xmi.idref"/></desc> <!-- The Link line --> <path d="{$PathData}" fill="none" stroke-dasharray="6 12"/> </g> </xsl:template> <!-- Abstraction line, displayed as a dashed line with a white triangle at the endpoint --> <xsl:template name="Abstraction_Line"> <xsl:param name="Waypoints" select="UML:GraphEdge.waypoints"/> <xsl:param name="DiagramID" select="@xmi.id"/> <xsl:param name="SemanticID" select="UML:GraphElement.semanticModel/UML:Uml1SemanticModelBridge/UML:Uml1SemanticModelBridge.element/*/@xmi.idref"/> <xsl:variable name="PathData"> <xsl:call-template name="BuildPathData"/>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -