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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:03:35+00:00 2026-05-16T23:03:35+00:00

I have two XML files to render one page in XSLT. This is because

  • 0

I have two XML files to render one page in XSLT. This is because I have to separate the language from the data for a multilingual website. I need to relationate data from one and other to print a value.

My index.xml:

<?xml version="1.0" encoding="utf-8"?>
<index>
    <language>en</language>

    <example>
        <category id="1">
            <href>/category/id/1</href>
        </category>
        <category id="2">
            <href>/category/id/2</href>
        </category>
    </example>
</index>

Then I’ve a base.en.xml that looks like:

<?xml version="1.0" encoding="utf-8"?>
<language>
    <category id="1">Category 1</category>
    <category id="2">Category 2</category>
</language>

My incomplete index.xsl:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:param name="language" select="document('index.en.xml'))" /> 

    <xsl:template match="/">
        <html>
            <head>
                <title>Example</title>    
            </head>

            <body>
                <ul>
                    <xsl:apply-templates select="index/example/category" />
                </ul>
            </body>
        </html>
    </xsl:template>

    <xsl:template match="index/example/category">
        <a href="{href}"></a>
    </xsl:template>

</xsl:stylesheet>

Finally the desired output:

<html>
    <head>
        <title>Example</title>
    </head>

    <body>
        <ul>
            <li><a href="/category/id/1">Category 1</a></li>
            <li><a href="/category/id/2">Category 2</a></li>
        </ul>
    </body>
</html>

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-16T23:03:36+00:00Added an answer on May 16, 2026 at 11:03 pm

    Your document() function call in the xsl:param had an extra “)” that was breaking your XSLT.

    Once that is resolved, you can execute XPATH expressions against the language param.

    $language/language/category[current()/@id=@id]

    Inside of your index/example/category template, current() refers to the currently matched index/example/category element. The predicate filter uses it’s @id to select the correct /language/category element.

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output indent="yes" />
    
        <xsl:param name="language" select="document('index.en.xml')" />
    
        <xsl:template match="/">
            <html>
                <head>
                    <title>Example</title>
                </head>
    
                <body>
                    <ul>
                        <xsl:apply-templates select="index/example/category" />
                    </ul>
                </body>
            </html>
        </xsl:template>
    
        <xsl:template match="index/example/category">
            <a href="{href}"><xsl:value-of select="$language/language/category[current()/@id=@id]"/></a>
        </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two layouts(xml files) and I want to flip from one page to
this is my situation: I have two org.w3c.dom.Document created from two xml files. What
I have two xml files, one of them is dev.xml which has this code
I am have two xml files.. I first get one and loop through it
I have created two folders layout and layout-land with two xml files, one for
I have two xml files with the same data but different tags. I need
I have two xml files but one file will contain an extra field. Ideally
I have two xml files which have the same data but different names for
I have two XML files located in res/xml/. One file is a normal XML
I have two xml files and I need to create one xsd for both.

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.