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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:50:42+00:00 2026-06-01T12:50:42+00:00

I have the following simplified XML structure: <?xml version="1.0" encoding="UTF-8" ?> <INVOIC02> <IDOC BEGIN="1">

  • 0

I have the following simplified XML structure:

<?xml version="1.0" encoding="UTF-8" ?>
<INVOIC02>
<IDOC BEGIN="1">
    <EDI_DC40 SEGMENT="1">
        <TABNAM>EDI_DC40</TABNAM>
    </EDI_DC40>
    <E1EDP01 SEGMENT="1">
        <MENGE>1.000</MENGE>
        <E1EDP19 SEGMENT="1">
            <QUALF>002</QUALF>
            <IDTNR>000000000000718221</IDTNR>
            <KTEXT>Orange</KTEXT>
        </E1EDP19>
        <E1EDP19 SEGMENT="1">
            <QUALF>Z03</QUALF>
            <IDTNR>7610400013079</IDTNR>
        </E1EDP19>
    </E1EDP01>
    <E1EDP01 SEGMENT="1">
        <MENGE>1.000</MENGE>
        <E1EDP19 SEGMENT="1">
            <QUALF>002</QUALF>
            <IDTNR>000000000000718160</IDTNR>
            <KTEXT>Pistache</KTEXT>
        </E1EDP19>     
        <E1EDP19 SEGMENT="1">
            <QUALF>003</QUALF>
            <IDTNR>7610400181600</IDTNR>
        </E1EDP19>
    </E1EDP01>
    <E1EDP01 SEGMENT="1">
        <MENGE>1.000</MENGE>
        <E1EDP19 SEGMENT="1">
            <QUALF>002</QUALF>
            <IDTNR>000000000000718228</IDTNR>
            <KTEXT>Strawberry</KTEXT>
        </E1EDP19>
        <E1EDP19 SEGMENT="1">
            <QUALF>003</QUALF>
            <IDTNR>7610400182287</IDTNR>
        </E1EDP19>
    </E1EDP01>
    <E1EDP01 SEGMENT="1">
        <MENGE>1.000</MENGE>
        <E1EDP19 SEGMENT="1">
            <QUALF>002</QUALF>
            <IDTNR>000000000000718221</IDTNR>
            <KTEXT>Orange</KTEXT>
        </E1EDP19>
        <E1EDP19 SEGMENT="1">
            <QUALF>003</QUALF>
            <IDTNR>7610400182218</IDTNR>
        </E1EDP19>
    </E1EDP01>
    <E1EDP01 SEGMENT="1">
        <MENGE>1.000</MENGE>
        <E1EDP19 SEGMENT="1">
            <QUALF>002</QUALF>
            <IDTNR>000000000000718160</IDTNR>
            <KTEXT>Pistache</KTEXT>
        </E1EDP19>
        <E1EDP19 SEGMENT="1">
            <QUALF>003</QUALF>
            <IDTNR>7610400181600</IDTNR>
        </E1EDP19>
    </E1EDP01>
    <E1EDP01 SEGMENT="1">
        <MENGE>1.000</MENGE>
        <E1EDP19 SEGMENT="1">
            <QUALF>002</QUALF>
            <IDTNR>000000000000718228</IDTNR>
            <KTEXT>Strawberry</KTEXT>
        </E1EDP19>
        <E1EDP19 SEGMENT="1">
            <QUALF>003</QUALF>
            <IDTNR>7610400182287</IDTNR>
        </E1EDP19>
    </E1EDP01>
    <E1EDS01 SEGMENT="1">
        <SUMID>001</SUMID>
        <SUMME>6</SUMME>
    </E1EDS01>
</IDOC>
</INVOIC02>

I need to sort the <E1EDP01 SEGMENT="1"> segments by their <IDTNR> number with QUALF=’002′

So I came up with this XSLT:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform&quot; xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl&quot; version="1.0">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="IDOC">
    <xsl:apply-templates>
        <xsl:sort select="E1EDP19[QUALF='002']/IDTNR"/>
    </xsl:apply-templates>     
</xsl:template>
</xsl:stylesheet>

But in my Output the <E1EDP01> Segments are sorted but are put at the end of my structure:

<?xml version="1.0" encoding="UTF-8"?>
<INVOIC02>
<EDI_DC40 SEGMENT="1">
    <TABNAM>EDI_DC40</TABNAM>
</EDI_DC40>
<E1EDS01 SEGMENT="1">
    <SUMID>001</SUMID>
    <SUMME>6</SUMME>
</E1EDS01>
<E1EDP01 SEGMENT="1">
    <MENGE>1.000</MENGE>
    <E1EDP19 SEGMENT="1">
        <QUALF>002</QUALF>
        <IDTNR>000000000000718160</IDTNR>
        <KTEXT>Pistache</KTEXT>
    </E1EDP19>
    <E1EDP19 SEGMENT="1">
        <QUALF>003</QUALF>
        <IDTNR>7610400181600</IDTNR>
    </E1EDP19>
</E1EDP01>
<E1EDP01 SEGMENT="1">
    <MENGE>1.000</MENGE>
    <E1EDP19 SEGMENT="1">
        <QUALF>002</QUALF>
        <IDTNR>000000000000718160</IDTNR>
        <KTEXT>Pistache</KTEXT>
    </E1EDP19>
    <E1EDP19 SEGMENT="1">
        <QUALF>003</QUALF>
        <IDTNR>7610400181600</IDTNR>
    </E1EDP19>
</E1EDP01>
<E1EDP01 SEGMENT="1">
    <MENGE>1.000</MENGE>
    <E1EDP19 SEGMENT="1">
        <QUALF>002</QUALF>
        <IDTNR>000000000000718221</IDTNR>
        <KTEXT>Orange</KTEXT>
    </E1EDP19>
    <E1EDP19 SEGMENT="1">
        <QUALF>Z03</QUALF>
        <IDTNR>7610400013079</IDTNR>
    </E1EDP19>
</E1EDP01>
<E1EDP01 SEGMENT="1">
    <MENGE>1.000</MENGE>
    <E1EDP19 SEGMENT="1">
        <QUALF>002</QUALF>
        <IDTNR>000000000000718221</IDTNR>
        <KTEXT>Orange</KTEXT>
    </E1EDP19>
    <E1EDP19 SEGMENT="1">
        <QUALF>003</QUALF>
        <IDTNR>7610400182218</IDTNR>
    </E1EDP19>
</E1EDP01>
<E1EDP01 SEGMENT="1">
    <MENGE>1.000</MENGE>
    <E1EDP19 SEGMENT="1">
        <QUALF>002</QUALF>
        <IDTNR>000000000000718228</IDTNR>
        <KTEXT>Strawberry</KTEXT>
    </E1EDP19>
    <E1EDP19 SEGMENT="1">
        <QUALF>003</QUALF>
        <IDTNR>7610400182287</IDTNR>
    </E1EDP19>
</E1EDP01>
<E1EDP01 SEGMENT="1">
    <MENGE>1.000</MENGE>
    <E1EDP19 SEGMENT="1">
        <QUALF>002</QUALF>
        <IDTNR>000000000000718228</IDTNR>
        <KTEXT>Strawberry</KTEXT>
    </E1EDP19>
    <E1EDP19 SEGMENT="1">
        <QUALF>003</QUALF>
        <IDTNR>7610400182287</IDTNR>
    </E1EDP19>
</E1EDP01>
</INVOIC02>

The <E1EDS01> segment comes before the sorted segments but should be at the end. Why is that?

  • 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-01T12:50:44+00:00Added an answer on June 1, 2026 at 12:50 pm

    This happens because you sort everything and non-E1EDP01 elements are going to have empty sort keys.
    instead, you could force their position, like:

    <xsl:template match="IDOC">
        <xsl:apply-templates select="EDI_DC40"/>
        <xsl:apply-templates select="E1EDP01">
            <xsl:sort select="E1EDP19[QUALF='002']/IDTNR"/>
        </xsl:apply-templates>     
        <xsl:apply-templates select="E1EDS01"/>
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following simplified XML: <?xml version="1.0" encoding="UTF-8" ?> <MATMAS05> <IDOC BEGIN="1"> <E1MARAM
I have the following simplified XML structure: <?xml version="1.0" encoding="UTF-8"?> <ExportData> <TransportHeader> <Timestamp>2011-01-16 06:00:33</Timestamp>
I have the following simplified XML: <?xml version="1.0" encoding="UTF-8"?> <ExportData> <Rows> <R> <companyCodestringtrue>101</companyCodestringtrue> <transactionQualifierstring>Sales</transactionQualifierstring>
I have the following simplified XML source: <?xml version=1.0 encoding=UTF-8?> <MVKE> <item> <MANDT>025</MANDT> <MATNR>000000000000000551</MATNR>
I have the following (simplified XML): <?xml version=1.0 encoding=UTF-8 ?> <products> <product> <artnr>xxx1</artnr> </product>
I have a simple xml file that looks like this: <?xml version=1.0 encoding=UTF-8 standalone=yes
I have no control over database schema and have the following (simplified) table structure:
So I have an xml file with the following simplified xml file contents: <CollectionItems>
I have the following (highly simplified) XML document that I am reading into my
I have the following XML (it is simplified and most attributes are omitted): <Document>

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.