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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:44:31+00:00 2026-05-14T19:44:31+00:00

I have an XML document with companies listed in it. I want to create

  • 0

I have an XML document with companies listed in it. I want to create a link with XSLT that contains the <link> child of the next node. Sorry if this is confusing..here is some sample XML of what i’m trying to obtain:

<portfolio>

<company>
<name>Dano Industries</name>
<link>dano.xml</link>
</company>

<company>
<name>Mike and Co.</name>
<link>mike.xml</link>
</company>

<company>
<name>Steve Inc.</name>
<link>steve.xml</link>
</company>

</portfolio>

I want two links, “BACK” and “NEXT”. While currently on mike.xml, I want BACK to link to “dano.xml” and NEXT linked to “steve.xml”…etc..and have it dynamically change when on a different page based on the nodes around it. I want to do this because I may add and change the list as I go along, so I don’t want to have to manually re-link everything.

How can I obtain this? Sorry I am new to XSLT, so please explain with solution if possible! Thanks 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-05-14T19:44:32+00:00Added an answer on May 14, 2026 at 7:44 pm

    Based on your comments to Dimitre, I think what you’re going to want to do is use the document() function to access your “master list” XML file.

    What you are actually running the stylesheet on is the individual fragments (dano.xml, mike.xml, steve.xml), right?

    I’ll use “mike.xml” for an example. I don’t know what the fragments look like so I had to make one up. You will need to be able to identify the correct <company> in the master list based on something in the fragment. In my example, the fragment has a <compName> element with the same value as the <name> element in the corresponding company in the master list XML.

    Here is what the “master list” XML, “dano/mike/steve” XML, the stylesheet, and the resulting HTML look like:

    master_list.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <portfolio>
    
       <company>
          <name>Dano Industries</name>
          <link>dano.xml</link>
       </company>
    
       <company>
          <name>Mike and Co.</name>
          <link>mike.xml</link>
       </company>
    
       <company>
          <name>Steve Inc.</name>
          <link>steve.xml</link>
       </company>
    
    </portfolio>
    

    dano.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <fragment>
       <compName>Dano Industries</compName>
       <compInfo>Some info about Dano Industries</compInfo>
    </fragment>
    

    mike.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <fragment>
       <compName>Mike and Co.</compName>
       <compInfo>Some info about Mike and Co.</compInfo>
    </fragment>
    

    steve.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <fragment>
       <compName>Steve Inc.</compName>
       <compInfo>Some info about Steve Inc.</compInfo>
    </fragment>
    

    stylesheet:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output method="html" indent="yes"/>
       <xsl:strip-space elements="*"/>
    
       <xsl:template match="fragment">
          <xsl:variable name="name" select="compName"/>
          <xsl:variable name="previous-file">
             <xsl:value-of select="document('master_list.xml')/portfolio/company[name=$name]/preceding-sibling::company[1]/link"/>
          </xsl:variable>
          <xsl:variable name="next-file">
             <xsl:value-of select="document('master_list.xml')/portfolio/company[name=$name]/following-sibling::company[1]/link"/>
          </xsl:variable>
          <html>
             <xsl:apply-templates/>
             <p>
                <xsl:if test="not($previous-file='')">
                   <a href="{$previous-file}">Back</a>
                </xsl:if>
                <xsl:if test="not($previous-file='') and not($next-file='')">
                   <xsl:text>&#xA0;|&#xA0;</xsl:text>
                </xsl:if>
                <xsl:if test="not($next-file='')">
                   <a href="{$next-file}">Next</a>  
                </xsl:if>
             </p>
          </html>
       </xsl:template>
    
       <xsl:template match="compName">
          <h1><xsl:apply-templates/></h1>
       </xsl:template>
    
       <xsl:template match="compInfo">
          <p><xsl:apply-templates/></p>
       </xsl:template>
    
    </xsl:stylesheet>
    

    HTML for Dano (dano.htm:)

    <html>
       <h1>Dano Industries</h1>
       <p>Some info about Dano Industries</p>
       <p><a href="mike.xml">Next</a></p>
    </html>
    

    HTML for Mike (mike.htm:)

    <html>
       <h1>Mike and Co.</h1>
       <p>Some info about Mike and Co.</p>
       <p><a href="dano.xml">Back</a>&nbsp;|&nbsp;<a href="steve.xml">Next</a></p>
    </html>
    

    HTML for Steve (steve.htm:)

    <html>
       <h1>Steve Inc.</h1>
       <p>Some info about Steve Inc.</p>
       <p><a href="mike.xml">Back</a></p>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml document that contains spaces and equal signs in the node
I have an XML document that contains a series of item nodes that look
I have an XML document that has a TextBlock that contains HTML code. <TextBlock>
I have an xml document that contains some html. <begin-line> <verse-num>6</verse-num>a mixed people<footnote id=f2>
I have an XML document with un-namespaced elements, and I want to use XSLT
I have an XML document that I'm trying to search through. The Main structure
I have an XML document, and I want to print the tag names and
I have an XML document that I generate from an Entity Framework object. The
I have an XML document that I load in and try to search with
I have an XML document that I need to load and in the 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.