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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:30:46+00:00 2026-06-07T17:30:46+00:00

I have to sort and group a certain node and subnodes in my xml

  • 0

I have to sort and group a certain node and subnodes in my xml by an attribute

given xml:

<Rechnung>
<somenodes />
<RechnungArtikelLieferinfos>
    <RechnungArtikelLieferinfo InfoTypLangtext="Folgende Artikel sind vergriffen und leider nicht mehr nachlieferbar:" InfoTypKurztext="NICHT_NACHLIEFERBAR" InfoTyp="2">
        <Artikelposition Absagekennzeichen="Allein im Rückstand" AbsagekennzeichenId="38" Artikeltyp="Beilage" ArtikeltypId="9" Zusatztextkennzeichen="" Zusatztext="" Bestellnummer="12345" Bestellmenge="1.00" Artikelbezeichnung="Angebotsblatt someone de" Katalogkennzeichen="99"/>
    </RechnungArtikelLieferinfo>
    <RechnungArtikelLieferinfo InfoTypLangtext="Folgende Artikel sind im Rückstand:" InfoTypKurztext="RÜCKSTAND" InfoTyp="3">
        <Artikelposition Absagekennzeichen="Allein im Rückstand" AbsagekennzeichenId="38" Artikeltyp="Beilage" ArtikeltypId="9" Zusatztextkennzeichen="" Zusatztext="" Bestellnummer="12345" Bestellmenge="2.00" Artikelbezeichnung="Angebotsblatt someoneother de" Katalogkennzeichen="99"/>
    </RechnungArtikelLieferinfo>          
    <RechnungArtikelLieferinfo InfoTypLangtext="Folgende Artikel sind vergriffen und leider nicht mehr nachlieferbar:" InfoTypKurztext="NICHT_NACHLIEFERBAR" InfoTyp="2">
        <Artikelposition Absagekennzeichen="Allein im Rückstand" AbsagekennzeichenId="38" Artikeltyp="Beilage" ArtikeltypId="9" Zusatztextkennzeichen="" Zusatztext="" Bestellnummer="54321" Bestellmenge="2.00" Artikelbezeichnung="Angebotsblatt something de" Katalogkennzeichen="99"/>
    </RechnungArtikelLieferinfo>  
    <RechnungArtikelLieferinfo InfoTypLangtext="Folgende Artikel sind im Rückstand:" InfoTypKurztext="NICHT_AUF_LAGER" InfoTyp="0">
        <Artikelposition Absagekennzeichen="Allein im Rückstand" AbsagekennzeichenId="38" Artikeltyp="Beilage" ArtikeltypId="9" Zusatztextkennzeichen="" Zusatztext="" Bestellnummer="5555" Bestellmenge="1.00" Artikelbezeichnung="some article" Katalogkennzeichen="99"/>
    </RechnungArtikelLieferinfo>    
</RechnungArtikelLieferinfos>
<somemorenodes />
</Rechnung>

RechnungArtikelLieferinfo is to be sorted by its attribute @Infotyp. On the same RechnungArtikelLieferinfo@Infotyp the Artikelposition-Nodes should be grouped (I hope I’m nmaking sense here, english is not my first language)

expected result:

<Rechnung>
<somenodes />
<RechnungArtikelLieferinfos>
    <RechnungArtikelLieferinfo InfoTypLangtext="Folgende Artikel sind im Rückstand:" InfoTypKurztext="NICHT_AUF_LAGER" InfoTyp="0">
        <Artikelposition Absagekennzeichen="Allein im Rückstand" AbsagekennzeichenId="38" Artikeltyp="Beilage" ArtikeltypId="9" Zusatztextkennzeichen="" Zusatztext="" Bestellnummer="5555" Bestellmenge="1.00" Artikelbezeichnung="some article" Katalogkennzeichen="99"/>
    </RechnungArtikelLieferinfo>  
    <RechnungArtikelLieferinfo InfoTypLangtext="Folgende Artikel sind vergriffen und leider nicht mehr nachlieferbar:" InfoTypKurztext="NICHT_NACHLIEFERBAR" InfoTyp="2">
        <Artikelposition Absagekennzeichen="Allein im Rückstand" AbsagekennzeichenId="38" Artikeltyp="Beilage" ArtikeltypId="9" Zusatztextkennzeichen="" Zusatztext="" Bestellnummer="12345" Bestellmenge="1.00" Artikelbezeichnung="Angebotsblatt someone de" Katalogkennzeichen="99"/>
        <Artikelposition Absagekennzeichen="Allein im Rückstand" AbsagekennzeichenId="38" Artikeltyp="something" ArtikeltypId="9" Zusatztextkennzeichen="" Zusatztext="" Bestellnummer="54321" Bestellmenge="2.00" Artikelbezeichnung="Angebotsblatt something de" Katalogkennzeichen="99"/>
    </RechnungArtikelLieferinfo>
    <RechnungArtikelLieferinfo InfoTypLangtext="Folgende Artikel sind im Rückstand:" InfoTypKurztext="RÜCKSTAND" InfoTyp="3">
        <Artikelposition Absagekennzeichen="Allein im Rückstand" AbsagekennzeichenId="38" Artikeltyp="Beilage" ArtikeltypId="9" Zusatztextkennzeichen="" Zusatztext="" Bestellnummer="44444" Bestellmenge="2.00" Artikelbezeichnung="Angebotsblatt someoneother de" Katalogkennzeichen="99"/>
    </RechnungArtikelLieferinfo>  
</RechnungArtikelLieferinfos>
<somemorenodes />
</Rechnung>

I am new to XSL(T) and read quite some documentation about this. I guess the best way to do this would be using XSLT 2.0 with its grouping options (for-each-group), but I’m somewhat lost after all that reading and more confused than before. Especially as all tutorials assume that you have to reconstruct the structure and I just have to move nodes and childs around without changing them.

Thanks for your help in advance.

  • 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-07T17:30:48+00:00Added an answer on June 7, 2026 at 5:30 pm

    This can be done quite easily with just templates rather than for-each loops (normally best avoided in XSLT).

    Runnable demo at this XML Playground (see output source).

    <!-- kick things off -->
    <xsl:template match="Rechnung/RechnungArtikelLieferinfos">
        <xsl:copy>
            <xsl:apply-templates select='RechnungArtikelLieferinfo[not(preceding-sibling::RechnungArtikelLieferinfo/@InfoTyp = @InfoTyp)]'>
                <xsl:sort select='@InfoTyp' data-type='number' />
            </xsl:apply-templates>
        </xsl:copy>
    </xsl:template>
    
    <!-- RechnungArtikelLieferinfo nodes (unique only) -->
    <xsl:template match='RechnungArtikelLieferinfo'>
    
        <!-- copy node, and... -->
        <xsl:copy>
    
            <!-- ...its attributes/text -->
            <xsl:copy-of select='@*|text()' />
    
            <!-- ...any Artikelposition nodes of same parent @InfoTyp -->
            <xsl:copy-of select='../RechnungArtikelLieferinfo[@InfoTyp = current()/@InfoTyp]/Artikelposition' />
    
        </xsl:copy>
    
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im looking to group and sort a Generic List<>. I have a list of
I have a query that does some magical sort-group-joining that works just fine on
I have a query that retrieves location entities within a certain radius given a
I have a drill down table and I can sort by the Group columns,
I have a list of customer and i need to sort and group the
I have sort of a tricky problem I'm attempting to solve. First of all,
So in nokia we can have sort of Microsoft Silverlight installed to system. We
I have some sort of problem, when it comes to customizing the iPad-launch-lcreens of
I have a sort of plug-in model in which various complex user controls are
I have some sort of recursive function, but I need to parse a string,

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.