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

  • Home
  • SEARCH
  • 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 3627098
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:50:43+00:00 2026-05-18T23:50:43+00:00

My understanding has been that, despite the fact that XSLT’s node-sets are called sets,

  • 0

My understanding has been that, despite the fact that XSLT’s “node-sets” are called “sets”, they are, in fact, ordered lists of nodes (which is why each node is associated with an index). I’ve therefore been trying to use the “|” operator to concatenate node-sets such that the order of the nodes is respected.

What I am attempting to accomplish is something like the following JavaScript code:

[o1,o2,o3].concat([o4,o5,o6])

Which yields:

[o1,o2,o3,o4,o5,o6]

But, consider the following reduced example:

testFlatten.xsl

<?xml version="1.0"?>
<xsl:stylesheet 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
 version="1.0">
 <xsl:output method="xml"/>

 <xsl:template match="/">

  <xsl:variable name="parentTransition" select="//*[@id='parentTransition']"/>
  <xsl:variable name="childTransition" select="//*[@id='childTransition']"/>
  <xsl:variable name="parentThenChildTransitions" select="$parentTransition | $childTransition"/>
  <xsl:variable name="childThenParentTransitions" select="$childTransition | $parentTransition"/>

  <return>
   <parentThenChildTransitions>
    <xsl:copy-of select="$parentThenChildTransitions"/>
   </parentThenChildTransitions>
   <childThenParentTransitions>
    <xsl:copy-of select="$childThenParentTransitions"/>
   </childThenParentTransitions>
  </return>

 </xsl:template>

</xsl:stylesheet>

Given the following input:

<?xml version="1.0"?>
<root>
        <element id="parentTransition"/>

 <element id="childTransition"/>
</root>

Which yields (with xsltproc):

<?xml version="1.0"?>
<return>
    <parentThenChildTransitions>
        <element id="parentTransition"/><element id="childTransition"/>
    </parentThenChildTransitions>
    <childThenParentTransitions>
        <element id="parentTransition"/><element id="childTransition"/>
    </childThenParentTransitions>
</return>

So the “|” operator in fact does not respect the order of the node-set operands. Is there a way I can concatenate node-sets such that order is respected?

  • 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-18T23:50:43+00:00Added an answer on May 18, 2026 at 11:50 pm

    This is actually not an XSLT but an XPath question.

    In XPath 1.0 there isn’t anything similar to a “list” datatype. A node-set is a set and it has no order.

    In XPath 2.0 there is the sequence data type. Any items in a sequence are ordered. This has nothing to do with document order. Also, the same item (or node) can appear more than once in a sequence.

    So, in XSLT 2.0 one just uses the XPath 2.0 sequence concatenation operator ,:

    //*[@id='parentTransition'] , //*[@id='childTransition']
    

    and this evaluates to the sequence of all elements in the document with id attribute 'parentTransition' followed by all elements in the document with id attribute 'childTransition'

    In XSLT it is still possible to access and process nodes not in document order: for example using the <xsl:sort> instruction — however the set of nodes that are processed as result of <xsl:apply-templates> or <xsl:for-each> is a node-list — not a node-set.

    Another example of evaluating nodes not in document order is the position() function within <xsl:apply-templates> or <xsl:for-each> that have a <xsl:sort> child or within a predicate of a location step (of an XPath expression) in which a reverse axis is used (such as ancesstor:: or preceeding::)

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

Sidebar

Related Questions

My understanding of Hibernate is that as objects are loaded from the DB they
This is one thing that has been bugging me for a while about DDD.
My relative is studying programming and has a hard time understanding classes. He has
My understanding is that wxWidgets is for a number of programming languages (C++, Python,
My understanding is that C/C++ produces native code to run on a particular machine
My understanding is that in unix, when memory is freed, the memory doesn't get
My understanding is that you have to write unit tests that isolate functionality. So
First let me state that, despite being a fairly new practitioner of TDD, I'm
A developing consensus among the iPhone developer community is that Apple has recently started
REST has been such a popular buzzword for the last couple of years (or

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.