XSLT: how to add conditions (with xsl:if) based on element attributes Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to remove node in XML based on order of precedence and attribute by using XSLT?check condition in xsltchecking condition xsltXSLT - Adding attribute to element in separate templates?merge two elements using xslt based on attribute valuesCondition for two elements XSLTXSLT first occurrence of element based on a particular valuemaking a non logic flat structure hierarchicalCreating an element based on double condition with XSLTMapping dot notation in XMI
How does Belgium enforce obligatory attendance in elections?
Why are my pictures showing a dark band on one edge?
Misunderstanding of Sylow theory
How does a spellshard spellbook work?
Is CEO the "profession" with the most psychopaths?
How could we fake a moon landing now?
If Windows 7 doesn't support WSL, then what is "Subsystem for UNIX-based Applications"?
What would you call this weird metallic apparatus that allows you to lift people?
Do wooden building fires get hotter than 600°C?
Is there public access to the Meteor Crater in Arizona?
What is the chair depicted in Cesare Maccari's 1889 painting "Cicerone denuncia Catilina"?
Random body shuffle every night—can we still function?
One-one communication
An adverb for when you're not exaggerating
Should a wizard buy fine inks every time he want to copy spells into his spellbook?
A letter with no particular backstory
How can I prevent/balance waiting and turtling as a response to cooldown mechanics
Amount of permutations on an NxNxN Rubik's Cube
What is an "asse" in Elizabethan English?
How were pictures turned from film to a big picture in a picture frame before digital scanning?
Electrolysis of water: Which equations to use? (IB Chem)
1-probability to calculate two events in a row
How many time has Arya actually used Needle?
How to compare two different files line by line in unix?
XSLT: how to add conditions (with xsl:if) based on element attributes
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to remove node in XML based on order of precedence and attribute by using XSLT?check condition in xsltchecking condition xsltXSLT - Adding attribute to element in separate templates?merge two elements using xslt based on attribute valuesCondition for two elements XSLTXSLT first occurrence of element based on a particular valuemaking a non logic flat structure hierarchicalCreating an element based on double condition with XSLTMapping dot notation in XMI
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I want to create different elements based on their attributes. This is XML input:
<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
<uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
<packagedElement xmi:type="uml:Package" xmi:id="EAPK_9E00FA41_6F28_4e47_9AE6_2A04EE92CDBB" name="aktivityD" visibility="public">
<packagedElement xmi:type="uml:Activity" xmi:id="EAID_AC000001_6F28_4e47_9AE6_2A04EE92CDBB" name="EA_Activity1" visibility="public">
<node xmi:type="uml:ActivityFinalNode" xmi:id="EAID_6550597C_95E6_4d78_82C8_1E3DF3916946" name="ActivityFinal" visibility="public">
<incoming xmi:idref="EAID_CEB43B7F_ED15_4f03_8D9B_8EF054BD458D"/>
</node>
<node xmi:type="uml:InitialNode" xmi:id="EAID_1EE374C2_0853_4379_A09C_1586F1F70618" name="ActivityInitial" visibility="public">
<outgoing xmi:idref="EAID_A7A0C176_5CCC_4bf2_AED2_AEB05FB741AF"/>
</node>
<edge xmi:type="uml:ControlFlow" xmi:id="EAID_A7A0C176_5CCC_4bf2_AED2_AEB05FB741AF" visibility="public" source="EAID_1EE374C2_0853_4379_A09C_1586F1F70618" target="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6"/>
<group xmi:type="uml:ActivityPartition" xmi:id="EAID_D88F2D66_C7A9_447f_8C87_2D28E2E3906F" name="Partition_1" visibility="public">
<node xmi:idref="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6"/>
</group>
<packagedElement xmi:type="uml:Activity" xmi:id="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6" name="Activity1" visibility="public" isReadOnly="false" isSingleExecution="false"/>
<edge xmi:type="uml:ControlFlow" xmi:id="EAID_CEB43B7F_ED15_4f03_8D9B_8EF054BD458D" visibility="public" source="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6" target="EAID_6550597C_95E6_4d78_82C8_1E3DF3916946"/>
</packagedElement>
</packagedElement>
</uml:Model>
</xmi:XMI>
I use this XSLT:
...
<xsl:template name="model" match="uml:Model">
<xsl:element name="uml:Model">
<xsl:attribute name="xmi:type">
<xsl:value-of select="@xmi:type"/>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="@name" />
</xsl:attribute>
<xsl:attribute name="visibility">
<xsl:value-of select="@visibility" />
</xsl:attribute>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xmi:type='uml:Package']">
<xsl:element name="packagedElement">
<xsl:attribute name="xmi:type">uml:Package</xsl:attribute>
<xsl:attribute name="xmi:id">
<xsl:value-of select="$PackID"></xsl:value-of>
</xsl:attribute>
<xsl:attribute name="name">sequenceD</xsl:attribute>
<xsl:attribute name="visibility">public</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xml:type='uml:Activity']">
<xsl:element name="packagedElement">
<xsl:attribute name ="xmi:type">uml:Collaboration</xsl:attribute>
<xsl:attribute name ="xmi:id">
<xsl:value-of select="@xmi:id"/>
</xsl:attribute>
<xsl:attribute name ="name">EA_Collaboration1</xsl:attribute>
<xsl:attribute name ="visibility">public</xsl:attribute>
</xsl:element>
</xsl:template>
...
I want to know how can I add some conditions to XSLT for these cases:
- if attribute (in input xml) xmi:type is "uml:Package" create that element (in xslt as second template and with those attributes)
- if attribute (in input xml) xmi:type is "uml:Activity" create element which will be under first packagedElement, it will be also packagedElement but will have different attributes
For now this is output XML:
<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmlns:uml="http://schema.omg.org/spec/UML/2.1"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmi:version="2.1">
<xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
<uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
<packagedElement xmi:type="uml:Package"
xmi:id="EAPK_1234567"
name="sequenceD"
visibility="public"/>
</uml:Model>
</xmi:XMI>
I also don´t know how to format text to one row in output XML.
For any help: Thank you!
This is output XML what I want to create:
<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
<uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
<packagedElement xmi:type="uml:Package" xmi:id="EAPK_5947BE3D_D2DE_4dc8_A0C0_A9AC446264DA" name="sequenceD" visibility="public">
<packagedElement xmi:type="uml:Collaboration" xmi:id="EAID_CB000000_E3D_D2DE_4dc8_A0C0_A9AC446264D" name="EA_Collaboration1" visibility="public">
<ownedBehavior xmi:type="uml:Interaction" xmi:id="EAID_IN000000_E3D_D2DE_4dc8_A0C0_A9AC446264D" name="EA_Interaction1" visibility="public">
<lifeline xmi:type="uml:Lifeline" xmi:id="EAID_086AF560_4699_47a6_9E42_508896EE53D0" name="Partition_1" visibility="public" represents="EAID_AT000000_4699_47a6_9E42_508896EE53D0"/>
<lifeline xmi:type="uml:Lifeline" xmi:id="EAID_89C15D36_76EF_42c8_8267_27793BA745F0" name="Partition_2" visibility="public" represents="EAID_AT000000_76EF_42c8_8267_27793BA745F0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000000_4699_47a6_9E42_508896EE53D0" covered="EAID_086AF560_4699_47a6_9E42_508896EE53D0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000001_4699_47a6_9E42_508896EE53D0" covered="EAID_086AF560_4699_47a6_9E42_508896EE53D0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000000_76EF_42c8_8267_27793BA745F0" covered="EAID_89C15D36_76EF_42c8_8267_27793BA745F0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000001_76EF_42c8_8267_27793BA745F0" covered="EAID_89C15D36_76EF_42c8_8267_27793BA745F0"/>
<message xmi:type="uml:Message" xmi:id="EAID_FB6F7794_17CF_42af_870B_4BE2E8CCA386" name="Activity1" messageKind="found" messageSort="synchCall" receiveEvent="EAID_FR000000_4699_47a6_9E42_508896EE53D0"/>
<message xmi:type="uml:Message" xmi:id="EAID_F92A2B3B_C28E_43d5_BDDB_78AD13663BF1" name="Activity2" messageKind="complete" messageSort="synchCall" sendEvent="EAID_FR000001_4699_47a6_9E42_508896EE53D0" receiveEvent="EAID_FR000000_76EF_42c8_8267_27793BA745F0"/>
<message xmi:type="uml:Message" xmi:id="EAID_BCF881AC_1967_429c_85C3_75487A34866A" messageKind="lost" messageSort="synchCall" sendEvent="EAID_FR000001_76EF_42c8_8267_27793BA745F0"/>
</ownedBehavior>
<ownedAttribute xmi:type="uml:Property" xmi:id="EAID_AT000000_4699_47a6_9E42_508896EE53D0"/>
<ownedAttribute xmi:type="uml:Property" xmi:id="EAID_AT000000_76EF_42c8_8267_27793BA745F0"/>
</packagedElement>
<packagedElement xmi:type="uml:Class" xmi:id="EAID_B0D14618_9DE7_43fa_989F_36F68263530A" name="ActivityFinal" visibility="public"/>
<packagedElement xmi:type="uml:Class" xmi:id="EAID_964B5D05_11B6_4ea1_86CD_391C3A60716C" name="ActivityInitial" visibility="public"/>
</packagedElement>
</uml:Model>
</xmi:XMI>
xml xslt uml xslt-1.0 xslt-2.0
add a comment |
I want to create different elements based on their attributes. This is XML input:
<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
<uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
<packagedElement xmi:type="uml:Package" xmi:id="EAPK_9E00FA41_6F28_4e47_9AE6_2A04EE92CDBB" name="aktivityD" visibility="public">
<packagedElement xmi:type="uml:Activity" xmi:id="EAID_AC000001_6F28_4e47_9AE6_2A04EE92CDBB" name="EA_Activity1" visibility="public">
<node xmi:type="uml:ActivityFinalNode" xmi:id="EAID_6550597C_95E6_4d78_82C8_1E3DF3916946" name="ActivityFinal" visibility="public">
<incoming xmi:idref="EAID_CEB43B7F_ED15_4f03_8D9B_8EF054BD458D"/>
</node>
<node xmi:type="uml:InitialNode" xmi:id="EAID_1EE374C2_0853_4379_A09C_1586F1F70618" name="ActivityInitial" visibility="public">
<outgoing xmi:idref="EAID_A7A0C176_5CCC_4bf2_AED2_AEB05FB741AF"/>
</node>
<edge xmi:type="uml:ControlFlow" xmi:id="EAID_A7A0C176_5CCC_4bf2_AED2_AEB05FB741AF" visibility="public" source="EAID_1EE374C2_0853_4379_A09C_1586F1F70618" target="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6"/>
<group xmi:type="uml:ActivityPartition" xmi:id="EAID_D88F2D66_C7A9_447f_8C87_2D28E2E3906F" name="Partition_1" visibility="public">
<node xmi:idref="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6"/>
</group>
<packagedElement xmi:type="uml:Activity" xmi:id="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6" name="Activity1" visibility="public" isReadOnly="false" isSingleExecution="false"/>
<edge xmi:type="uml:ControlFlow" xmi:id="EAID_CEB43B7F_ED15_4f03_8D9B_8EF054BD458D" visibility="public" source="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6" target="EAID_6550597C_95E6_4d78_82C8_1E3DF3916946"/>
</packagedElement>
</packagedElement>
</uml:Model>
</xmi:XMI>
I use this XSLT:
...
<xsl:template name="model" match="uml:Model">
<xsl:element name="uml:Model">
<xsl:attribute name="xmi:type">
<xsl:value-of select="@xmi:type"/>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="@name" />
</xsl:attribute>
<xsl:attribute name="visibility">
<xsl:value-of select="@visibility" />
</xsl:attribute>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xmi:type='uml:Package']">
<xsl:element name="packagedElement">
<xsl:attribute name="xmi:type">uml:Package</xsl:attribute>
<xsl:attribute name="xmi:id">
<xsl:value-of select="$PackID"></xsl:value-of>
</xsl:attribute>
<xsl:attribute name="name">sequenceD</xsl:attribute>
<xsl:attribute name="visibility">public</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xml:type='uml:Activity']">
<xsl:element name="packagedElement">
<xsl:attribute name ="xmi:type">uml:Collaboration</xsl:attribute>
<xsl:attribute name ="xmi:id">
<xsl:value-of select="@xmi:id"/>
</xsl:attribute>
<xsl:attribute name ="name">EA_Collaboration1</xsl:attribute>
<xsl:attribute name ="visibility">public</xsl:attribute>
</xsl:element>
</xsl:template>
...
I want to know how can I add some conditions to XSLT for these cases:
- if attribute (in input xml) xmi:type is "uml:Package" create that element (in xslt as second template and with those attributes)
- if attribute (in input xml) xmi:type is "uml:Activity" create element which will be under first packagedElement, it will be also packagedElement but will have different attributes
For now this is output XML:
<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmlns:uml="http://schema.omg.org/spec/UML/2.1"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmi:version="2.1">
<xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
<uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
<packagedElement xmi:type="uml:Package"
xmi:id="EAPK_1234567"
name="sequenceD"
visibility="public"/>
</uml:Model>
</xmi:XMI>
I also don´t know how to format text to one row in output XML.
For any help: Thank you!
This is output XML what I want to create:
<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
<uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
<packagedElement xmi:type="uml:Package" xmi:id="EAPK_5947BE3D_D2DE_4dc8_A0C0_A9AC446264DA" name="sequenceD" visibility="public">
<packagedElement xmi:type="uml:Collaboration" xmi:id="EAID_CB000000_E3D_D2DE_4dc8_A0C0_A9AC446264D" name="EA_Collaboration1" visibility="public">
<ownedBehavior xmi:type="uml:Interaction" xmi:id="EAID_IN000000_E3D_D2DE_4dc8_A0C0_A9AC446264D" name="EA_Interaction1" visibility="public">
<lifeline xmi:type="uml:Lifeline" xmi:id="EAID_086AF560_4699_47a6_9E42_508896EE53D0" name="Partition_1" visibility="public" represents="EAID_AT000000_4699_47a6_9E42_508896EE53D0"/>
<lifeline xmi:type="uml:Lifeline" xmi:id="EAID_89C15D36_76EF_42c8_8267_27793BA745F0" name="Partition_2" visibility="public" represents="EAID_AT000000_76EF_42c8_8267_27793BA745F0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000000_4699_47a6_9E42_508896EE53D0" covered="EAID_086AF560_4699_47a6_9E42_508896EE53D0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000001_4699_47a6_9E42_508896EE53D0" covered="EAID_086AF560_4699_47a6_9E42_508896EE53D0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000000_76EF_42c8_8267_27793BA745F0" covered="EAID_89C15D36_76EF_42c8_8267_27793BA745F0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000001_76EF_42c8_8267_27793BA745F0" covered="EAID_89C15D36_76EF_42c8_8267_27793BA745F0"/>
<message xmi:type="uml:Message" xmi:id="EAID_FB6F7794_17CF_42af_870B_4BE2E8CCA386" name="Activity1" messageKind="found" messageSort="synchCall" receiveEvent="EAID_FR000000_4699_47a6_9E42_508896EE53D0"/>
<message xmi:type="uml:Message" xmi:id="EAID_F92A2B3B_C28E_43d5_BDDB_78AD13663BF1" name="Activity2" messageKind="complete" messageSort="synchCall" sendEvent="EAID_FR000001_4699_47a6_9E42_508896EE53D0" receiveEvent="EAID_FR000000_76EF_42c8_8267_27793BA745F0"/>
<message xmi:type="uml:Message" xmi:id="EAID_BCF881AC_1967_429c_85C3_75487A34866A" messageKind="lost" messageSort="synchCall" sendEvent="EAID_FR000001_76EF_42c8_8267_27793BA745F0"/>
</ownedBehavior>
<ownedAttribute xmi:type="uml:Property" xmi:id="EAID_AT000000_4699_47a6_9E42_508896EE53D0"/>
<ownedAttribute xmi:type="uml:Property" xmi:id="EAID_AT000000_76EF_42c8_8267_27793BA745F0"/>
</packagedElement>
<packagedElement xmi:type="uml:Class" xmi:id="EAID_B0D14618_9DE7_43fa_989F_36F68263530A" name="ActivityFinal" visibility="public"/>
<packagedElement xmi:type="uml:Class" xmi:id="EAID_964B5D05_11B6_4ea1_86CD_391C3A60716C" name="ActivityInitial" visibility="public"/>
</packagedElement>
</uml:Model>
</xmi:XMI>
xml xslt uml xslt-1.0 xslt-2.0
What does your desired output XML look like?
– zx485
Mar 8 at 22:43
@zx485 I added output excel what I want to create, but there is one extra lifeline (partition)
– Roboros
Mar 12 at 21:41
add a comment |
I want to create different elements based on their attributes. This is XML input:
<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
<uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
<packagedElement xmi:type="uml:Package" xmi:id="EAPK_9E00FA41_6F28_4e47_9AE6_2A04EE92CDBB" name="aktivityD" visibility="public">
<packagedElement xmi:type="uml:Activity" xmi:id="EAID_AC000001_6F28_4e47_9AE6_2A04EE92CDBB" name="EA_Activity1" visibility="public">
<node xmi:type="uml:ActivityFinalNode" xmi:id="EAID_6550597C_95E6_4d78_82C8_1E3DF3916946" name="ActivityFinal" visibility="public">
<incoming xmi:idref="EAID_CEB43B7F_ED15_4f03_8D9B_8EF054BD458D"/>
</node>
<node xmi:type="uml:InitialNode" xmi:id="EAID_1EE374C2_0853_4379_A09C_1586F1F70618" name="ActivityInitial" visibility="public">
<outgoing xmi:idref="EAID_A7A0C176_5CCC_4bf2_AED2_AEB05FB741AF"/>
</node>
<edge xmi:type="uml:ControlFlow" xmi:id="EAID_A7A0C176_5CCC_4bf2_AED2_AEB05FB741AF" visibility="public" source="EAID_1EE374C2_0853_4379_A09C_1586F1F70618" target="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6"/>
<group xmi:type="uml:ActivityPartition" xmi:id="EAID_D88F2D66_C7A9_447f_8C87_2D28E2E3906F" name="Partition_1" visibility="public">
<node xmi:idref="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6"/>
</group>
<packagedElement xmi:type="uml:Activity" xmi:id="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6" name="Activity1" visibility="public" isReadOnly="false" isSingleExecution="false"/>
<edge xmi:type="uml:ControlFlow" xmi:id="EAID_CEB43B7F_ED15_4f03_8D9B_8EF054BD458D" visibility="public" source="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6" target="EAID_6550597C_95E6_4d78_82C8_1E3DF3916946"/>
</packagedElement>
</packagedElement>
</uml:Model>
</xmi:XMI>
I use this XSLT:
...
<xsl:template name="model" match="uml:Model">
<xsl:element name="uml:Model">
<xsl:attribute name="xmi:type">
<xsl:value-of select="@xmi:type"/>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="@name" />
</xsl:attribute>
<xsl:attribute name="visibility">
<xsl:value-of select="@visibility" />
</xsl:attribute>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xmi:type='uml:Package']">
<xsl:element name="packagedElement">
<xsl:attribute name="xmi:type">uml:Package</xsl:attribute>
<xsl:attribute name="xmi:id">
<xsl:value-of select="$PackID"></xsl:value-of>
</xsl:attribute>
<xsl:attribute name="name">sequenceD</xsl:attribute>
<xsl:attribute name="visibility">public</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xml:type='uml:Activity']">
<xsl:element name="packagedElement">
<xsl:attribute name ="xmi:type">uml:Collaboration</xsl:attribute>
<xsl:attribute name ="xmi:id">
<xsl:value-of select="@xmi:id"/>
</xsl:attribute>
<xsl:attribute name ="name">EA_Collaboration1</xsl:attribute>
<xsl:attribute name ="visibility">public</xsl:attribute>
</xsl:element>
</xsl:template>
...
I want to know how can I add some conditions to XSLT for these cases:
- if attribute (in input xml) xmi:type is "uml:Package" create that element (in xslt as second template and with those attributes)
- if attribute (in input xml) xmi:type is "uml:Activity" create element which will be under first packagedElement, it will be also packagedElement but will have different attributes
For now this is output XML:
<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmlns:uml="http://schema.omg.org/spec/UML/2.1"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmi:version="2.1">
<xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
<uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
<packagedElement xmi:type="uml:Package"
xmi:id="EAPK_1234567"
name="sequenceD"
visibility="public"/>
</uml:Model>
</xmi:XMI>
I also don´t know how to format text to one row in output XML.
For any help: Thank you!
This is output XML what I want to create:
<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
<uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
<packagedElement xmi:type="uml:Package" xmi:id="EAPK_5947BE3D_D2DE_4dc8_A0C0_A9AC446264DA" name="sequenceD" visibility="public">
<packagedElement xmi:type="uml:Collaboration" xmi:id="EAID_CB000000_E3D_D2DE_4dc8_A0C0_A9AC446264D" name="EA_Collaboration1" visibility="public">
<ownedBehavior xmi:type="uml:Interaction" xmi:id="EAID_IN000000_E3D_D2DE_4dc8_A0C0_A9AC446264D" name="EA_Interaction1" visibility="public">
<lifeline xmi:type="uml:Lifeline" xmi:id="EAID_086AF560_4699_47a6_9E42_508896EE53D0" name="Partition_1" visibility="public" represents="EAID_AT000000_4699_47a6_9E42_508896EE53D0"/>
<lifeline xmi:type="uml:Lifeline" xmi:id="EAID_89C15D36_76EF_42c8_8267_27793BA745F0" name="Partition_2" visibility="public" represents="EAID_AT000000_76EF_42c8_8267_27793BA745F0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000000_4699_47a6_9E42_508896EE53D0" covered="EAID_086AF560_4699_47a6_9E42_508896EE53D0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000001_4699_47a6_9E42_508896EE53D0" covered="EAID_086AF560_4699_47a6_9E42_508896EE53D0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000000_76EF_42c8_8267_27793BA745F0" covered="EAID_89C15D36_76EF_42c8_8267_27793BA745F0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000001_76EF_42c8_8267_27793BA745F0" covered="EAID_89C15D36_76EF_42c8_8267_27793BA745F0"/>
<message xmi:type="uml:Message" xmi:id="EAID_FB6F7794_17CF_42af_870B_4BE2E8CCA386" name="Activity1" messageKind="found" messageSort="synchCall" receiveEvent="EAID_FR000000_4699_47a6_9E42_508896EE53D0"/>
<message xmi:type="uml:Message" xmi:id="EAID_F92A2B3B_C28E_43d5_BDDB_78AD13663BF1" name="Activity2" messageKind="complete" messageSort="synchCall" sendEvent="EAID_FR000001_4699_47a6_9E42_508896EE53D0" receiveEvent="EAID_FR000000_76EF_42c8_8267_27793BA745F0"/>
<message xmi:type="uml:Message" xmi:id="EAID_BCF881AC_1967_429c_85C3_75487A34866A" messageKind="lost" messageSort="synchCall" sendEvent="EAID_FR000001_76EF_42c8_8267_27793BA745F0"/>
</ownedBehavior>
<ownedAttribute xmi:type="uml:Property" xmi:id="EAID_AT000000_4699_47a6_9E42_508896EE53D0"/>
<ownedAttribute xmi:type="uml:Property" xmi:id="EAID_AT000000_76EF_42c8_8267_27793BA745F0"/>
</packagedElement>
<packagedElement xmi:type="uml:Class" xmi:id="EAID_B0D14618_9DE7_43fa_989F_36F68263530A" name="ActivityFinal" visibility="public"/>
<packagedElement xmi:type="uml:Class" xmi:id="EAID_964B5D05_11B6_4ea1_86CD_391C3A60716C" name="ActivityInitial" visibility="public"/>
</packagedElement>
</uml:Model>
</xmi:XMI>
xml xslt uml xslt-1.0 xslt-2.0
I want to create different elements based on their attributes. This is XML input:
<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
<uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
<packagedElement xmi:type="uml:Package" xmi:id="EAPK_9E00FA41_6F28_4e47_9AE6_2A04EE92CDBB" name="aktivityD" visibility="public">
<packagedElement xmi:type="uml:Activity" xmi:id="EAID_AC000001_6F28_4e47_9AE6_2A04EE92CDBB" name="EA_Activity1" visibility="public">
<node xmi:type="uml:ActivityFinalNode" xmi:id="EAID_6550597C_95E6_4d78_82C8_1E3DF3916946" name="ActivityFinal" visibility="public">
<incoming xmi:idref="EAID_CEB43B7F_ED15_4f03_8D9B_8EF054BD458D"/>
</node>
<node xmi:type="uml:InitialNode" xmi:id="EAID_1EE374C2_0853_4379_A09C_1586F1F70618" name="ActivityInitial" visibility="public">
<outgoing xmi:idref="EAID_A7A0C176_5CCC_4bf2_AED2_AEB05FB741AF"/>
</node>
<edge xmi:type="uml:ControlFlow" xmi:id="EAID_A7A0C176_5CCC_4bf2_AED2_AEB05FB741AF" visibility="public" source="EAID_1EE374C2_0853_4379_A09C_1586F1F70618" target="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6"/>
<group xmi:type="uml:ActivityPartition" xmi:id="EAID_D88F2D66_C7A9_447f_8C87_2D28E2E3906F" name="Partition_1" visibility="public">
<node xmi:idref="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6"/>
</group>
<packagedElement xmi:type="uml:Activity" xmi:id="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6" name="Activity1" visibility="public" isReadOnly="false" isSingleExecution="false"/>
<edge xmi:type="uml:ControlFlow" xmi:id="EAID_CEB43B7F_ED15_4f03_8D9B_8EF054BD458D" visibility="public" source="EAID_6057002D_AC33_4eee_9FF9_9A7F17B830F6" target="EAID_6550597C_95E6_4d78_82C8_1E3DF3916946"/>
</packagedElement>
</packagedElement>
</uml:Model>
</xmi:XMI>
I use this XSLT:
...
<xsl:template name="model" match="uml:Model">
<xsl:element name="uml:Model">
<xsl:attribute name="xmi:type">
<xsl:value-of select="@xmi:type"/>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="@name" />
</xsl:attribute>
<xsl:attribute name="visibility">
<xsl:value-of select="@visibility" />
</xsl:attribute>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xmi:type='uml:Package']">
<xsl:element name="packagedElement">
<xsl:attribute name="xmi:type">uml:Package</xsl:attribute>
<xsl:attribute name="xmi:id">
<xsl:value-of select="$PackID"></xsl:value-of>
</xsl:attribute>
<xsl:attribute name="name">sequenceD</xsl:attribute>
<xsl:attribute name="visibility">public</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xml:type='uml:Activity']">
<xsl:element name="packagedElement">
<xsl:attribute name ="xmi:type">uml:Collaboration</xsl:attribute>
<xsl:attribute name ="xmi:id">
<xsl:value-of select="@xmi:id"/>
</xsl:attribute>
<xsl:attribute name ="name">EA_Collaboration1</xsl:attribute>
<xsl:attribute name ="visibility">public</xsl:attribute>
</xsl:element>
</xsl:template>
...
I want to know how can I add some conditions to XSLT for these cases:
- if attribute (in input xml) xmi:type is "uml:Package" create that element (in xslt as second template and with those attributes)
- if attribute (in input xml) xmi:type is "uml:Activity" create element which will be under first packagedElement, it will be also packagedElement but will have different attributes
For now this is output XML:
<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmlns:uml="http://schema.omg.org/spec/UML/2.1"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmi:version="2.1">
<xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
<uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
<packagedElement xmi:type="uml:Package"
xmi:id="EAPK_1234567"
name="sequenceD"
visibility="public"/>
</uml:Model>
</xmi:XMI>
I also don´t know how to format text to one row in output XML.
For any help: Thank you!
This is output XML what I want to create:
<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
<uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
<packagedElement xmi:type="uml:Package" xmi:id="EAPK_5947BE3D_D2DE_4dc8_A0C0_A9AC446264DA" name="sequenceD" visibility="public">
<packagedElement xmi:type="uml:Collaboration" xmi:id="EAID_CB000000_E3D_D2DE_4dc8_A0C0_A9AC446264D" name="EA_Collaboration1" visibility="public">
<ownedBehavior xmi:type="uml:Interaction" xmi:id="EAID_IN000000_E3D_D2DE_4dc8_A0C0_A9AC446264D" name="EA_Interaction1" visibility="public">
<lifeline xmi:type="uml:Lifeline" xmi:id="EAID_086AF560_4699_47a6_9E42_508896EE53D0" name="Partition_1" visibility="public" represents="EAID_AT000000_4699_47a6_9E42_508896EE53D0"/>
<lifeline xmi:type="uml:Lifeline" xmi:id="EAID_89C15D36_76EF_42c8_8267_27793BA745F0" name="Partition_2" visibility="public" represents="EAID_AT000000_76EF_42c8_8267_27793BA745F0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000000_4699_47a6_9E42_508896EE53D0" covered="EAID_086AF560_4699_47a6_9E42_508896EE53D0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000001_4699_47a6_9E42_508896EE53D0" covered="EAID_086AF560_4699_47a6_9E42_508896EE53D0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000000_76EF_42c8_8267_27793BA745F0" covered="EAID_89C15D36_76EF_42c8_8267_27793BA745F0"/>
<fragment xmi:type="uml:OccurrenceSpecification" xmi:id="EAID_FR000001_76EF_42c8_8267_27793BA745F0" covered="EAID_89C15D36_76EF_42c8_8267_27793BA745F0"/>
<message xmi:type="uml:Message" xmi:id="EAID_FB6F7794_17CF_42af_870B_4BE2E8CCA386" name="Activity1" messageKind="found" messageSort="synchCall" receiveEvent="EAID_FR000000_4699_47a6_9E42_508896EE53D0"/>
<message xmi:type="uml:Message" xmi:id="EAID_F92A2B3B_C28E_43d5_BDDB_78AD13663BF1" name="Activity2" messageKind="complete" messageSort="synchCall" sendEvent="EAID_FR000001_4699_47a6_9E42_508896EE53D0" receiveEvent="EAID_FR000000_76EF_42c8_8267_27793BA745F0"/>
<message xmi:type="uml:Message" xmi:id="EAID_BCF881AC_1967_429c_85C3_75487A34866A" messageKind="lost" messageSort="synchCall" sendEvent="EAID_FR000001_76EF_42c8_8267_27793BA745F0"/>
</ownedBehavior>
<ownedAttribute xmi:type="uml:Property" xmi:id="EAID_AT000000_4699_47a6_9E42_508896EE53D0"/>
<ownedAttribute xmi:type="uml:Property" xmi:id="EAID_AT000000_76EF_42c8_8267_27793BA745F0"/>
</packagedElement>
<packagedElement xmi:type="uml:Class" xmi:id="EAID_B0D14618_9DE7_43fa_989F_36F68263530A" name="ActivityFinal" visibility="public"/>
<packagedElement xmi:type="uml:Class" xmi:id="EAID_964B5D05_11B6_4ea1_86CD_391C3A60716C" name="ActivityInitial" visibility="public"/>
</packagedElement>
</uml:Model>
</xmi:XMI>
xml xslt uml xslt-1.0 xslt-2.0
xml xslt uml xslt-1.0 xslt-2.0
edited Mar 15 at 21:13
Roboros
asked Mar 8 at 21:49
RoborosRoboros
235
235
What does your desired output XML look like?
– zx485
Mar 8 at 22:43
@zx485 I added output excel what I want to create, but there is one extra lifeline (partition)
– Roboros
Mar 12 at 21:41
add a comment |
What does your desired output XML look like?
– zx485
Mar 8 at 22:43
@zx485 I added output excel what I want to create, but there is one extra lifeline (partition)
– Roboros
Mar 12 at 21:41
What does your desired output XML look like?
– zx485
Mar 8 at 22:43
What does your desired output XML look like?
– zx485
Mar 8 at 22:43
@zx485 I added output excel what I want to create, but there is one extra lifeline (partition)
– Roboros
Mar 12 at 21:41
@zx485 I added output excel what I want to create, but there is one extra lifeline (partition)
– Roboros
Mar 12 at 21:41
add a comment |
1 Answer
1
active
oldest
votes
This can be achieved using templates with matches that take into account the xmi:type attribute's value.
<xsl:template name="model" match="uml:Model">
<xsl:element ... >
...
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xmi:type='uml:Package']">
<xsl:element ... >
...
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xmi:type='uml:Activity']">
<xsl:element ... >
...
</xsl:element>
</xsl:template>
...
So should I call its with <xsl:apply-templates select="packagedElement[@xml:type='uml:Activity']"/>
– Roboros
Mar 11 at 20:27
you can do, however in the context of the first template there is only so many things that can be matched next (i.e. another packagedElement within the packageElement that is the current context of the first template). Hence you can keep it open or close it in like you suggest
– muszeo
Mar 12 at 3:24
it is not working. I don´t know where can be a mistake, but it writes only first element.
– Roboros
Mar 12 at 12:10
you mean it's only writing model, or only writing model and the first level packagedElement? Could you post an update w. what your xsl looks like currently?
– muszeo
Mar 12 at 19:31
only model and the first level packagedElement. There is how it looks like behind "For now this is output XML:"
– Roboros
Mar 13 at 14:14
|
show 5 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55071481%2fxslt-how-to-add-conditions-with-xslif-based-on-element-attributes%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This can be achieved using templates with matches that take into account the xmi:type attribute's value.
<xsl:template name="model" match="uml:Model">
<xsl:element ... >
...
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xmi:type='uml:Package']">
<xsl:element ... >
...
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xmi:type='uml:Activity']">
<xsl:element ... >
...
</xsl:element>
</xsl:template>
...
So should I call its with <xsl:apply-templates select="packagedElement[@xml:type='uml:Activity']"/>
– Roboros
Mar 11 at 20:27
you can do, however in the context of the first template there is only so many things that can be matched next (i.e. another packagedElement within the packageElement that is the current context of the first template). Hence you can keep it open or close it in like you suggest
– muszeo
Mar 12 at 3:24
it is not working. I don´t know where can be a mistake, but it writes only first element.
– Roboros
Mar 12 at 12:10
you mean it's only writing model, or only writing model and the first level packagedElement? Could you post an update w. what your xsl looks like currently?
– muszeo
Mar 12 at 19:31
only model and the first level packagedElement. There is how it looks like behind "For now this is output XML:"
– Roboros
Mar 13 at 14:14
|
show 5 more comments
This can be achieved using templates with matches that take into account the xmi:type attribute's value.
<xsl:template name="model" match="uml:Model">
<xsl:element ... >
...
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xmi:type='uml:Package']">
<xsl:element ... >
...
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xmi:type='uml:Activity']">
<xsl:element ... >
...
</xsl:element>
</xsl:template>
...
So should I call its with <xsl:apply-templates select="packagedElement[@xml:type='uml:Activity']"/>
– Roboros
Mar 11 at 20:27
you can do, however in the context of the first template there is only so many things that can be matched next (i.e. another packagedElement within the packageElement that is the current context of the first template). Hence you can keep it open or close it in like you suggest
– muszeo
Mar 12 at 3:24
it is not working. I don´t know where can be a mistake, but it writes only first element.
– Roboros
Mar 12 at 12:10
you mean it's only writing model, or only writing model and the first level packagedElement? Could you post an update w. what your xsl looks like currently?
– muszeo
Mar 12 at 19:31
only model and the first level packagedElement. There is how it looks like behind "For now this is output XML:"
– Roboros
Mar 13 at 14:14
|
show 5 more comments
This can be achieved using templates with matches that take into account the xmi:type attribute's value.
<xsl:template name="model" match="uml:Model">
<xsl:element ... >
...
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xmi:type='uml:Package']">
<xsl:element ... >
...
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xmi:type='uml:Activity']">
<xsl:element ... >
...
</xsl:element>
</xsl:template>
...
This can be achieved using templates with matches that take into account the xmi:type attribute's value.
<xsl:template name="model" match="uml:Model">
<xsl:element ... >
...
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xmi:type='uml:Package']">
<xsl:element ... >
...
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="packagedElement[@xmi:type='uml:Activity']">
<xsl:element ... >
...
</xsl:element>
</xsl:template>
...
edited Apr 13 at 5:44
Roboros
235
235
answered Mar 9 at 4:56
muszeomuszeo
1,615411
1,615411
So should I call its with <xsl:apply-templates select="packagedElement[@xml:type='uml:Activity']"/>
– Roboros
Mar 11 at 20:27
you can do, however in the context of the first template there is only so many things that can be matched next (i.e. another packagedElement within the packageElement that is the current context of the first template). Hence you can keep it open or close it in like you suggest
– muszeo
Mar 12 at 3:24
it is not working. I don´t know where can be a mistake, but it writes only first element.
– Roboros
Mar 12 at 12:10
you mean it's only writing model, or only writing model and the first level packagedElement? Could you post an update w. what your xsl looks like currently?
– muszeo
Mar 12 at 19:31
only model and the first level packagedElement. There is how it looks like behind "For now this is output XML:"
– Roboros
Mar 13 at 14:14
|
show 5 more comments
So should I call its with <xsl:apply-templates select="packagedElement[@xml:type='uml:Activity']"/>
– Roboros
Mar 11 at 20:27
you can do, however in the context of the first template there is only so many things that can be matched next (i.e. another packagedElement within the packageElement that is the current context of the first template). Hence you can keep it open or close it in like you suggest
– muszeo
Mar 12 at 3:24
it is not working. I don´t know where can be a mistake, but it writes only first element.
– Roboros
Mar 12 at 12:10
you mean it's only writing model, or only writing model and the first level packagedElement? Could you post an update w. what your xsl looks like currently?
– muszeo
Mar 12 at 19:31
only model and the first level packagedElement. There is how it looks like behind "For now this is output XML:"
– Roboros
Mar 13 at 14:14
So should I call its with <xsl:apply-templates select="packagedElement[@xml:type='uml:Activity']"/>
– Roboros
Mar 11 at 20:27
So should I call its with <xsl:apply-templates select="packagedElement[@xml:type='uml:Activity']"/>
– Roboros
Mar 11 at 20:27
you can do, however in the context of the first template there is only so many things that can be matched next (i.e. another packagedElement within the packageElement that is the current context of the first template). Hence you can keep it open or close it in like you suggest
– muszeo
Mar 12 at 3:24
you can do, however in the context of the first template there is only so many things that can be matched next (i.e. another packagedElement within the packageElement that is the current context of the first template). Hence you can keep it open or close it in like you suggest
– muszeo
Mar 12 at 3:24
it is not working. I don´t know where can be a mistake, but it writes only first element.
– Roboros
Mar 12 at 12:10
it is not working. I don´t know where can be a mistake, but it writes only first element.
– Roboros
Mar 12 at 12:10
you mean it's only writing model, or only writing model and the first level packagedElement? Could you post an update w. what your xsl looks like currently?
– muszeo
Mar 12 at 19:31
you mean it's only writing model, or only writing model and the first level packagedElement? Could you post an update w. what your xsl looks like currently?
– muszeo
Mar 12 at 19:31
only model and the first level packagedElement. There is how it looks like behind "For now this is output XML:"
– Roboros
Mar 13 at 14:14
only model and the first level packagedElement. There is how it looks like behind "For now this is output XML:"
– Roboros
Mar 13 at 14:14
|
show 5 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55071481%2fxslt-how-to-add-conditions-with-xslif-based-on-element-attributes%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What does your desired output XML look like?
– zx485
Mar 8 at 22:43
@zx485 I added output excel what I want to create, but there is one extra lifeline (partition)
– Roboros
Mar 12 at 21:41