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 9134049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:35:33+00:00 2026-06-17T08:35:33+00:00

I have a problem with XPATH. I have an XML structred like this: <root>

  • 0

I have a problem with XPATH.
I have an XML structred like this:

<root>
    <state name="UsUed">
        <transition event-source="this" event="edit()" target="UsEd_editing" />
        ...
    </state>
    <state>
        <transition event-source="this" event="edit()" target="UsEd" />
        <transition event-source="that" event="new()" target="SUed" />
        ...
    </state>
</root>

and I need to get <transition />‘s only with @event-source='this' and distinct @event.

My solution to this point is selecting all <transitions /> with ‘this’ attribute, sorts them by @event then tries to select only distinct ones of them like here

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <xsl:for-each select="//transition[@event-source='this']">
        <xsl:sort select="@event"/>
            <xsl:if https://stackoverflow.com/questions/2812122/distinct-in-xpath>
                <!--Here goes the transformation-->
            </xsl:if>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

But it doesn’t work.

  • 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-06-17T08:35:34+00:00Added an answer on June 17, 2026 at 8:35 am

    For selecting unique items, you can use the preceding axis to compare the current match to previous matches to make sure they aren’t the same. An XPath query like the following should be all you need to select the unique items. I made the assumption that the uniqueness of the @event attribute was limited to other transition elements with the @event-source='this' and not global.

    /root/state/transition[@event-source='this'][not(@event=preceding::transition[@event-source='this']/@event)]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a xml file like this <Document> <Tests> <Test> <Name>A</Name> <Type>Like A</Type> <Members>
Let's say I have xml structure like this <root> <element>some content</element> <element>some content 2</element>
So I have some perl code that goes something like: use strict; use XML::XPath;
I am looking for a Javascript solution to this problem: I have an XML
I have an XML file, part of which looks like this: <wave waveID=1> <well
I have a problem finding elements in XPath that's contains a certain string ignoring
I have problem with my query on C, I’m using the oci8 driver. This
i have a problem moving a XMLDataprovider Binding with XPath from Xaml to code
I have a problem with retrieving information from a XML tree. My XML has
I have this XML: <rootCategories> <category id=1> <category id=2> <category id=3> <category id=4 />

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.