我有2个不同的元素:“ edge”和“ containedEdge”,但是对于这两个我都需要对它们做相同的工作。我想为两者使用一个模板。
匹配“ edge或containedEdge”的模板看起来如何?
XML输入:
<packagedElement xmi:type="uml:Activity" xmi:id="EAID_AC000001_2A09_4795_BBF6_189BCF2176FD" name="EA_Activity1" visibility="public">
<edge xmi:type="uml:ControlFlow" xmi:id="EAID_7178621A_9B6C_4fd5_9E5D_AFB31B6DEF24"/>
<subgroup xmi:type="uml:LoopNode" xmi:id="EAID_61782877_58D5_41e6_B4BA_3C79CC4ADCFF">
<containedEdge xmi:type="uml:ControlFlow" xmi:id="EAID_C43E5114_A121_4a58_948C_3F7865CDDE19"/>
<containedEdge xmi:type="uml:ControlFlow" xmi:id="EAID_1300F655_DD16_4303_BD5F_E3180B655DC4"/>
</subgroup>
<edge xmi:type="uml:ControlFlow" xmi:id="EAID_2612A8E5_CBC2_406d_B3F5_255C49DC728F"/>
<edge xmi:type="uml:ControlFlow" xmi:id="EAID_7F330DC1_68BA_48e2_BAE2_15DC5BCAC772"/>
</packagedElement>
我需要使用与此类似的模板,但我认为“或”不应存在:
<xsl:for-each select="packagedElement/edge or packagedElement/subgroup/containedEdge">
<element geometry="SX=0;SY=0;EX=0;EY=0;Path=;" subject="EAID_CONNECTR{substring(@xmi:id, 14, 28)}" style=";Hidden=0;"/>
</xsl:for-each>
答案 0 :(得分:2)
在选择中使用并集:
<xsl:for-each select="packagedElement/edge|packagedElement/subgroup/containedEdge">
<element geometry="SX=0;SY=0;EX=0;EY=0;Path=;" subject="EAID_CONNECTR{substring(@xmi:id, 14, 28)}" style=";Hidden=0;"/>
</xsl:for-each>