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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:14:12+00:00 2026-06-17T17:14:12+00:00

I have the following simplified XML structure: <?xml version="1.0" encoding="utf-8"?> <list> <INVOIC> <M_INVOIC> <G_SG25>

  • 0

I have the following simplified XML structure:

<?xml version="1.0" encoding="utf-8"?>
<list>
<INVOIC>
    <M_INVOIC>
        <G_SG25>
            <S_LIN>
                <id>LIN</id>
                <D_1082>1</D_1082>
                <C_C212>
                    <D_7140>7610400271943</D_7140>
                    <D_7143_3>EN</D_7143_3>
                </C_C212>
            </S_LIN>
        </G_SG25>
        <G_SG25>
            <S_LIN>
                <id>LIN</id>
                <D_1082>2</D_1082>
                <C_C212>
                    <D_7140>1234567890123</D_7140>
                    <D_7143_3>EN</D_7143_3>
                </C_C212>
            </S_LIN>
        </G_SG25>
    </M_INVOIC>
</INVOIC>
<INVOIC>
    <SALESORDER>
        <ET_VBAP>
            <item>
                <VBELN>0010002695</VBELN>
                <POSNR>000010</POSNR>
                <MATNR>000000000000400487</MATNR>
                <EAN11>1234567890123</EAN11>
            </item>
            <item>
                <VBELN>0010002695</VBELN>
                <POSNR>000020</POSNR>
                <MATNR>000000000000002054</MATNR>
                <EAN11>5012454920549</EAN11>
            </item>
            <item>
                <VBELN>0010002695</VBELN>
                <POSNR>000030</POSNR>
                <MATNR>000000000000392104</MATNR>
                <EAN11>3046920921046</EAN11>
            </item>
            <item>
                <VBELN>0010002695</VBELN>
                <POSNR>000040</POSNR>
                <MATNR>000000000000859146</MATNR>
                <EAN11>8003340591469</EAN11>
            </item>
            <item>
                <VBELN>0010002695</VBELN>
                <POSNR>000050</POSNR>
                <MATNR>000000000000727194</MATNR>
                <EAN11>7610400271943</EAN11>
            </item>
        </ET_VBAP>
    </SALESORDER>
</INVOIC>
</list>

my XSLT:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>

<xsl:key name="kByEanPos" match="G_SG25" use="S_LIN/C_C212/D_7140"/>

<xsl:template match="/">
    
    <xsl:variable name="uniqueSet" select="G_SG25[generate-id()=generate-id(key('kByEanPos',S_LIN/C_C212/D_7140))]"/>
    <list>
        <xsl:for-each select="list/INVOIC/M_INVOIC/G_SG25[generate-id()=
            generate-id(key('kByEanPos',S_LIN/C_C212/D_7140))]">
            <ean>
                <xsl:value-of select="parent::M_INVOIC/parent::INVOIC/parent::list/INVOIC/SALESORDER/ET_VBAP/item/MATNR"/>
            </ean>
        </xsl:for-each>
    </list>
</xsl:template>
</xsl:stylesheet>

gives me this XML output:

<?xml version="1.0" encoding="UTF-8"?>
<list>
<ean>000000000000400487</ean>
<ean>000000000000400487</ean>
</list>

But my expected XML output is:

<?xml version="1.0" encoding="UTF-8"?>
<list>
<ean>000000000000727194</ean>
<ean>000000000000400487</ean>
</list>

I am not sure of what I am doing wrong, I can’t find my mistake. I think it has to do with the key that I defined.
Basically I need a key on <D_7140> and then look for that number in the structure below in EAN11 and output the MATNR right before.

  • 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-17T17:14:13+00:00Added an answer on June 17, 2026 at 5:14 pm

    If you are trying to look up item elements based on their EAN11 value, it might be worth considering using a key to do this too

    <xsl:key name="item" match="item" use="EAN11" />
    

    That way, you can reduce your xsl:value-of to just this

    <xsl:value-of select="key('item', S_LIN/C_C212/D_7140)/MATNR"/>
    
    • 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 structure: <?xml version="1.0" encoding="UTF-8" ?> <INVOIC02> <IDOC BEGIN="1">
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" ?> <MATMAS05> <IDOC BEGIN="1"> <E1MARAM
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): <?xml version=1.0 encoding=UTF-8 ?> <products> <product> <artnr>xxx1</artnr> </product>
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 XML: <?xml version=1.0 encoding=UTF-8?> <XmlTest> <Pictures attr=Pic1>Picture 1</Pictures> <Pictures attr=Pic2>Picture
I have following data structure (simplified): A giant list of the class TestClass public
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:

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.