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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:19:56+00:00 2026-06-05T10:19:56+00:00

I am converting a XML to HTML using XSLT. The output of should have

  • 0

I am converting a XML to HTML using XSLT.
The output of should have 2 HTML files linked with each other.
In the first html there will be a list of data and once I click on a particular data I should get the details of that particular data in other html file. I need to use xslt for this.

I have used Saxon to generate multiple htmls but I am able to perform the linking functionality. Any ideas on how to do this?

My input look like this

<a:file>
<a:id>33</a:id>
<a:name>hello</a:name>
<a:school>mumbai public</a:school>
<a:marks>80</a:marks>
</a:file>
  • 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-05T10:19:58+00:00Added an answer on June 5, 2026 at 10:19 am

    Well Saxon 9 or any XSLT 2.0 processor can generate multiple result documents with one stylesheet, as for linking two documents there is nothing difficult about this, you would simply use an HTML a element with a href attribute linking to the other document.

    If you need help on this for a particular data then please post a small but representative XML input sample and also the HTML you want to create.

    [edit]

    Assuming you have an input document with a couple of those a:file elements and you want to create one main HTML document listing all a:names linking to separate files listing the details you can solve that as follows:

    <xsl:template match="/">
      <xsl:apply-templates select="//a:file" mode="doc"/>
      <html>
        <head>
          <title>Example</title>
        </head>
        <body>
          <h1>Data list</h1>
          <ul>
            <xsl:apply-templates select="//a:file"/>
          </ul>
        </body>
      </html>
    </xsl:template>
    
    <xsl:template match="a:file">
      <li>
        <a href="{a:id}.html">
          <xsl:value-of select="a:name"/>
        </a>
      </li>
    </xsl:template>
    
    <xsl:template match="a:file" mode="doc">
      <xsl:result-document href="{a:id}.html">
        <html>
          <head>
            <title>Details of <xsl:value-of select="a:name"/></title>
          </head>
          <body>
            <table>
              <thead>
                <tr>
                 <xsl:apply-templates mode="thead"/>
                </tr>
              </thead>
              <tbody>
                <tr>
                 <xsl:apply-templates mode="doc"/>
                </tr>
              </tbody>
            </table>
          </body>
        </html>
      </xsl:result-document>
    </xsl:template>
    
    <xsl:template match="a:file/*" mode="doc">
      <td>
        <xsl:value-of select="."/>
      </td>
    </xsl:template>
    
    <xsl:template match="a:file/*" mode="thead">
      <th>
       <xsl:value-of select="local-name()"/>
      </th>
    </xsl:template>
    

    Untested but should give you an idea. If you need more help then please show more details of your input and wanted output, I had to make up the format of both the main HTML result (used a list there) and the details files (used a table there).

    [edit 2]
    Assuming the complete input sample is

    <a:files xmlns:a="http://example.com/a">
    <a:file>
    <a:id>33</a:id>
    <a:name>hello</a:name>
    <a:school>mumbai public</a:school>
    <a:marks>80</a:marks>
    </a:file>
    </a:files>
    

    and the complete stylesheet sample is

    <xsl:stylesheet
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:a="http://example.com/a"
      exclude-result-prefixes="a"
      version="2.0">
    
    <xsl:template match="/">
      <xsl:apply-templates select="//a:file" mode="doc"/>
      <html>
        <head>
          <title>Example</title>
        </head>
        <body>
          <h1>Data list</h1>
          <ul>
            <xsl:apply-templates select="//a:file"/>
          </ul>
        </body>
      </html>
    </xsl:template>
    
    <xsl:template match="a:file">
      <li>
        <a href="{a:id}.html">
          <xsl:value-of select="a:name"/>
        </a>
      </li>
    </xsl:template>
    
    <xsl:template match="a:file" mode="doc">
      <xsl:result-document href="{a:id}.html">
        <html>
          <head>
            <title>Details of <xsl:value-of select="a:name"/></title>
          </head>
          <body>
            <table>
              <thead>
                <tr>
                 <xsl:apply-templates mode="thead"/>
                </tr>
              </thead>
              <tbody>
                <tr>
                 <xsl:apply-templates mode="doc"/>
                </tr>
              </tbody>
            </table>
          </body>
        </html>
      </xsl:result-document>
    </xsl:template>
    
    <xsl:template match="a:file/*" mode="doc">
      <td>
        <xsl:value-of select="."/>
      </td>
    </xsl:template>
    
    <xsl:template match="a:file/*" mode="thead">
      <th>
       <xsl:value-of select="local-name()"/>
      </th>
    </xsl:template>
    
    </xsl:stylesheet>
    

    then when I use Saxon 9.4 HE from the command line doing e.g. java -jar saxon9he.jar input.xml sheet.xsl -o:result.html I get two result files, the main of course being result.html, the other being 33.html which look as follows:

    <html>
       <head>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
          <title>Example</title>
       </head>
       <body>
          <h1>Data list</h1>
          <ul>
             <li><a href="33.html">hello</a></li>
          </ul>
       </body>
    </html>
    
    
    
    
    <html>
       <head>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
          <title>Details of hello</title>
       </head>
       <body>
          <table>
             <thead>
                <tr>
    
                   <th>id</th>
    
                   <th>name</th>
    
                   <th>school</th>
    
                   <th>marks</th>
    
                </tr>
             </thead>
             <tbody>
                <tr>
    
                   <td>33</td>
    
                   <td>hello</td>
    
                   <td>mumbai public</td>
    
                   <td>80</td>
    
                </tr>
             </tbody>
          </table>
       </body>
    </html>
    

    So that works fine for me, both as far as the number of files is concerned as well as for the linking working inside the browser.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am have trouble converting my xml using XSLT back to xml in the
I am converting a xml using xslt. Original XML is <Content> <book> <customData> <CustomDataElement>
I am using XSLT to convert a very large XML document into (X)HTML. For
i am currently using xslt1.0 and jdk1.6.0_10 for converting xml to html..but i couldnt
Possible Duplicates: Converting HTML Files to PDF PDF file generation from XML or HTML
I am converting HTML files into XML. How do I use LINQ to XML
Possible Duplicate: Converting XML to JSON using Python? I'm doing some work on App
I am converting XML children into the element parameters and have a dirty regex
The XML String I am getting from other application is converting & to &amp;
I have written an xsl for converting the trx file of mstest into html.

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.