Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6861171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:30:05+00:00 2026-05-27T02:30:05+00:00

How do I print out the attribute values of all message and lifeline nodes

  • 0

How do I print out the attribute values of all message and lifeline nodes at once?
By “at once”, I mean while printing out a message name, I need to access the lifeline nodes. The only attributes I am concerned about are: lifeline/@name, and message/@name. I am trying to print out the message names, with the lifeline name that the message moves from. You do not have to post an answer to solve how I will associate the message with its start and end lifelines. That’s tricky. I just need to know how to access the lifeline and message attribute values at once. Or if its even possible. The XSLT shows the output format.

For the following XML , just focus on the lifeline, message, and packagedElement nodes. For context, the XML is of a UML model with a sequence diagram. Preserving the order of the sequence messages is not necessary. I am developing on the client side, thus the stylesheet href line is included in the XML. I can’t change the XML beyond the stylesheet href. All of the needed namespaces are included. I am transforming XML to text. I want to print out these values as tab delimited text.

XML:

 <?xml version="1.0" encoding="UTF-8"?>
 <?xml-stylesheet href="multiple nonthreaded iers.xsl" type="text/xsl"?>
 <uml:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"  xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xmi:id="idModel" name="main">
  <packagedElement xmi:type="uml:Package" xmi:id="idPackage" name="ThreadedIERPackage">
    <packagedElement xmi:type="uml:Collaboration" xmi:id="idCollaboration" name="ThreadedIERCollaboration">
      <ownedBehavior xmi:type="uml:Interaction" xmi:id="idInteraction">
        <lifeline xmi:type="uml:Lifeline" xmi:id="_OccJQguaEeGMo_zLRqy_vg" name="Lifeline1"/>
        <lifeline xmi:type="uml:Lifeline" xmi:id="_Oo87QguaEeGMo_zLRqy_vg" name="Lifeline2" coveredBy="_QrWQ2AuaEeGMo_zLRqy_vg _R4-hlQuaEeGMo_zLRqy_vg _QrWQ0guaEeGMo_zLRqy_vg"/><!-- can ignore the last id -->
        <fragment xmi:type="uml:MessageOccurrenceSpecification" xmi:id="_R4-hlQuaEeGMo_zLRqy_vg" name="MessageOccurrenceSpecification2" covered="_Oo87QguaEeGMo_zLRqy_vg" event="_R4-hlguaEeGMo_zLRqy_vg" message="_R4-hlwuaEeGMo_zLRqy_vg"/>
        <fragment xmi:type="uml:MessageOccurrenceSpecification" xmi:id="_QrWQ2AuaEeGMo_zLRqy_vg" name="MessageOccurrenceSpecification1" covered="_Oo87QguaEeGMo_zLRqy_vg" event="_QrWQ2QuaEeGMo_zLRqy_vg" message="_QrWQ2guaEeGMo_zLRqy_vg"/>
        <fragment xmi:type="uml:BehaviorExecutionSpecification" xmi:id="_QrWQ0guaEeGMo_zLRqy_vg" name="BehaviorExecutionSpecification1" covered="_Oo87QguaEeGMo_zLRqy_vg" start="_QrWQ2AuaEeGMo_zLRqy_vg" finish="_R4-hlQuaEeGMo_zLRqy_vg"/>
        <message xmi:type="uml:Message" xmi:id="_QrWQ2guaEeGMo_zLRqy_vg" name="Message1" receiveEvent="_QrWQ2AuaEeGMo_zLRqy_vg"/>
        <message xmi:type="uml:Message" xmi:id="_R4-hlwuaEeGMo_zLRqy_vg" name="Message2" messageSort="reply" sendEvent="_R4-hlQuaEeGMo_zLRqy_vg"/>
      </ownedBehavior>
    </packagedElement>
    <packagedElement xmi:type="uml:CallEvent" xmi:id="_QrWQ2QuaEeGMo_zLRqy_vg" name="CallEvent1"/>
    <packagedElement xmi:type="uml:CallEvent" xmi:id="_R4-hlguaEeGMo_zLRqy_vg" name="CallEvent2"/>
  </packagedElement>
  <profileApplication xmi:type="uml:ProfileApplication" xmi:id="idProfileApplication">
    <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="idProfileAnnotation" source="http://www.eclipse.org/uml2/2.0.0/UML">
      <references xmi:type="ecore:EPackage" href="pathmap://SysMLActivityExtensionsProfile.uml#ProfileContentId"/>
    </eAnnotations>
    <appliedProfile xmi:type="uml:Profile" href="pathmap://SysMLActivityExtensionsProfile.uml#ActivityProfileId"/>
  </profileApplication>
</uml:Model>

XSLT:


<xsl:template match="/">
<xsl:text>#Sending Lifeline (Producer)</xsl:text>
<xsl:value-of select="$tab"/>

<xsl:text>Receiving Lifeline (Consumers)</xsl:text>
<xsl:value-of select="$tab"/>

<xsl:text>Name(s)</xsl:text>
<xsl:value-of select="$tab"/>
<xsl:text>ID</xsl:text>
    <xsl:value-of select="$tab"/>
<xsl:value-of select="$newline"/>
<xsl:apply-templates />

</xsl:template>


<xsl:template match="packagedElement/ownedBehavior"> 
<xsl:for-each select="lifeline"><!-- prints all lifelines-->
    <xsl:value-of select="@name"/><xsl:text>.OE</xsl:text>
    <xsl:value-of select="$tab"/>
</xsl:for-each>

    <xsl:text>OE --> OE</xsl:text>
    <xsl:value-of select="$tab"/>

    <xsl:value-of select="message/@name"/>
    <xsl:value-of select="$tab"/>
</xsl:template>

</xsl:stylesheet>

What I have tried:
I have created a packagedElement/ownedBehavior template to access both nodes (lifeline, message), since they’re both children. However, it doesn’t print out all of the messages or lifelines unless I use a for -each. But, if I use a for-each, then I can only access messages or lifelines, not both.

I have tried using multiple templates, i.e. one for lifeline, and another for message. Example: <xsl:template match="lifeline">. Of course, I can’t access both nodes’ attributes at once. Even, if I use the call template function. I have tried it and it failed.

This is a tricky one, so I appreciate your response.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:30:05+00:00Added an answer on May 27, 2026 at 2:30 am

    In general, use the union operator — | — to select both types of elements in one template:

    <xsl:template match="lifeline|message">
    

    Or:

    <xsl:template match="packagedElement/ownedBehavior"> 
        <xsl:for-each select="lifeline|message">
            <!-- code here -->
        </xsl:for-each>
    </xsl:template>
    

    Alternatively, iterate over one or the other, associating as you go. Example:

    <xsl:template match="packagedElement/ownedBehavior"> 
        <xsl:for-each select="lifeline">
            <xsl:value-of select="../message[<some_condition_here>]"/>
            <!-- code here -->
        </xsl:for-each>
    </xsl:template>
    

    …where <some_condition_here> is a predicate selecting the associated node.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At some point I need to display a disabled (greyed out by disabled=disabled attribute)
I need to print out data into a pre-printed A6 form (1/4 the size
Attempting to print out a list of values from 2 different variables that are
i need to print out numbers 1-100 in a random order. the print statement
I'm trying to print out an attribute value with the following code: ArrayList arrayList=new
Can i print out a url /admin/manage/products/add of a certain view in a template?
I'm trying to print out the date in a certain format: NSDate *today =
I like to print out software requirements so I can easily mark them up,
I want to get print out invoice but also wanna set margins and page
I can print out a date nicely based on the user's locale. But how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.