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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:34:31+00:00 2026-05-24T12:34:31+00:00

I have this xml: <Documents> <Header Document_No=Numb1 Warehouse=WH2> <Body Position=1 Quantity=11 /> <Body Position=2

  • 0

I have this xml:

<Documents>
    <Header Document_No="Numb1" Warehouse="WH2">
        <Body Position="1" Quantity="11" />
        <Body Position="2" Quantity="10" />
    </Header>
    <Header Document_No="Numb2" Warehouse="WH1">
        <Body Position="1" Quantity="20"/>
        <Body Position="2" Quantity="13"/>
        <Body Position="3" Quantity="12"/>
    </Header>
</Documents>

My xslt:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output encoding="utf-8" indent="yes" method="xml"/>
    <xsl:template match="/">
        <GroupDocuments>
            <xsl:apply-templates/>
        </GroupDocuments>
    </xsl:template>
    <xsl:template match="Header">
        <Message>
            <Document>
                <Document-Header>
                    <DocNumber>
                        <xsl:value-of select="@Document_No"/>
                    </DocNumber>
                </Document-Header>
                <Lines>
                    <xsl:apply-templates select="Body"/>
                </Lines>
            </Document>
        </Message>
    </xsl:template>
    <xsl:template match="Body">
        <Line>
            <Line-Item>
                <LineNumber>
                    <xsl:value-of select="@Position"/>
                </LineNumber>
                <Quantity>
                    <xsl:value-of select="@Quantity"/>
                </Quantity>
            </Line-Item>
            <Line-Warehouse>
                <Warehouse>
                    <--Where is a problem-->>
                    <xsl:value-of select=""/>
                </Warehouse>
            </Line-Warehouse>
        </Line>
    </xsl:template>

</xsl:stylesheet>

I’m stuck to getting value of warehouse in Line-Warehouse tags, how to take value of warehouse from header when I proceesing Body? Please help to solve it.

result should be:

<?xml version="1.0" encoding="utf-8"?>
<GroupDocuments xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <Message>
        <Document>
            <Document-Header>
                <DocNumber>Numb1</DocNumber>
            </Document-Header>
            <Lines>
                ..............................................
                ............................................
                <Line>
                    <Line-Item>
                        <LineNumber>2</LineNumber>
                        <Quantity>10</Quantity>
                    </Line-Item>
                    <Line-Warehouse>
                        <Warehouse>WH2</Warehouse>
                    </Line-Warehouse>
                </Line>
            </Lines>
        </Document>
    </Message>
    <Message>
        <Document>
            <Document-Header>
                <DocNumber>Numb2</DocNumber>
            </Document-Header>
            <Lines>
                <Line>
                    <Line-Item>
                        <LineNumber>1</LineNumber>
                        <Quantity>20</Quantity>
                    </Line-Item>
                    <Line-Warehouse>
                        <Warehouse>WH1</Warehouse>
                    </Line-Warehouse>
                </Line>
.....................................
.....................................
            </Lines>
        </Document>
    </Message>
</GroupDocuments>
  • 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-24T12:34:32+00:00Added an answer on May 24, 2026 at 12:34 pm

    In the mentioned template the current node is body node. You want select the attribute of its parent.

    Use this simple XPath:

    "../@Warehouse"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this kind of node in my xml document: <parent ...> <a .../>
I am writing an XML document in C#. I have something like this... string
I have an XML document looking similar to this: <items> <item cat=1 owner=14>bla</item> <item
I have an xml document that looks like this. <foo> <bar type=artist/> Bob Marley
I have a xml document like this : <Node1 attrib1=abc> <node1_1> <node1_1_1 attrib2 =
I have an XML document which looks something like this: <meadinkent> <record> <comp_div>MENSWEAR</comp_div> <sty_ret_type>ACCESSORIES</sty_ret_type>
Hi I have an xml document like this <root> <cert id=1> </cert> <cert id=2>
I have got an XML document which looks something like this. <Root> <Info>....</Info> <Info>....</Info>
Say I have a xml document that looks like this <foo> <bar id=9 />
I have a website coded with XML+XSLT that outputs me a full HTML website.

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.