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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:43:00+00:00 2026-06-04T10:43:00+00:00

I have a complicated XML and I am trying to write a XSL transformation

  • 0

I have a complicated XML and I am trying to write a XSL transformation to convert it to HTML. Could someone please help me with it?

Here is the XML

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="Mbooks.xsl"?>
<project>
  <books>
    <bookName>Eclpise</bookName>
    <bookCount>3</bookCount>
    <Data>
      <NEW>
        <bookNumber>book3687110</bookNumber>
        <ISBN>927fd6ca660e5a9</ISBN>
        <Isbninfo>
          <IsbninfoDetails>
            <IsbninfoName>new book</IsbninfoName>
            <IsbninfoVersion>version 1</IsbninfoVersion>
          </IsbninfoDetails>
          <IsbninfoDetails>
            <IsbninfoName> new book 1</IsbninfoName>
            <IsbninfoVersion>version 2</IsbninfoVersion>
          </IsbninfoDetails>
        </Isbninfo>
      </NEW>
      <NEW>
        <bookNumber>book3674796</bookNumber>
        <ISBN>6fa276825144</ISBN>
        <Isbninfo>
          <IsbninfoDetails>
            <IsbninfoName>new book 3</IsbninfoName>
            <IsbninfoVersion>version 3</IsbninfoVersion>
          </IsbninfoDetails>
          <IsbninfoDetails>
            <IsbninfoName>new book 4</IsbninfoName>
            <IsbninfoVersion>version 4</IsbninfoVersion>
          </IsbninfoDetails>
        </Isbninfo>
      </NEW>
    </Data>
  </books>
  <books>
    <bookName>ORACLE</bookName>
    <bookCount>0</bookCount>
    <Data>
    </Data>
  </books>
  <books>
    <bookName>MUSIC</bookName>
    <bookCount>0</bookCount>
    <Data>

    </Data>
  </books>
</project>

Here is the XSLT.

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet 
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/">
    <html>
      <body>
        <h2>BOOK_INFORMATION </h2>
        <table style="display: inline-block; border: 1px solid; float: left; ">
          <tr bgcolor="#FFA500">
            <th>book Name</th>
            <th>book_Count</th>
            <th>book_Number</th>
            <th>ISBN</th>
            <th>Isbninfo_Name</th>
            <th>Isbninfo_Version</th>
          </tr>

          <xsl:for-each select="project/books">
            <tr>
              <td>
                <xsl:value-of select="bookName"/>
              </td>
              <td>
                <xsl:value-of select="bookCount"/>
              </td>
            </tr>
          </xsl:for-each>

        </table>

      </body>
    </html>
  </xsl:template>

</xsl:stylesheet>

I am not sure how would I get the other information: I want it all in one table. I tried doing <xsl:for-each> inside the for each but it does not work.

  • 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-04T10:43:02+00:00Added an answer on June 4, 2026 at 10:43 am

    Try this XSLT:

    <xsl:stylesheet 
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
      <xsl:template match="text()">
      </xsl:template>
    
      <xsl:template match="IsbninfoDetails">
        <tr>
          <td>
            <xsl:value-of select="../../../../bookName"/>
          </td>
          <td>
            <xsl:value-of select="../../../../bookCount"/>
          </td>
          <td>
            <xsl:value-of select="../../bookNumber"/>
          </td>
          <td>
            <xsl:value-of select="../../ISBN"/>
          </td>
          <td>
            <xsl:value-of select="IsbninfoName"/>
          </td>
          <td>
            <xsl:value-of select="IsbninfoVersion"/>
          </td>
        </tr>
      </xsl:template>
    
      <xsl:template match="books[not(Data/NEW)]">
        <tr>
          <td>
            <xsl:value-of select="bookName"/>
          </td>
          <td>
            <xsl:value-of select="bookCount"/>
          </td>
        </tr>
      </xsl:template>
    
      <xsl:template match="NEW[not(Isbninfo/IsbninfoDetails)]">
        <tr>
          <td>
            <xsl:value-of select="../../bookName"/>
          </td>
          <td>
            <xsl:value-of select="../../bookCount"/>
          </td>
          <td>
            <xsl:value-of select="bookNumber"/>
          </td>
          <td>
            <xsl:value-of select="ISBN"/>
          </td>
        </tr>
      </xsl:template>
    
      <xsl:template match="/">
        <html>
          <body>
            <h2>BOOK_INFORMATION </h2>
            <table style="display: inline-block; border: 1px solid; float: left; ">
              <tr bgcolor="#FFA500">
                <th>book Name</th>
                <th>book_Count</th>
                <th>book_Number</th>
                <th>ISBN</th>
                <th>Isbninfo_Name</th>
                <th>Isbninfo_Version</th>
              </tr>
              <xsl:apply-templates/>
            </table>
    
          </body>
        </html>
      </xsl:template>
    
    </xsl:stylesheet>
    

    applied to your example produces this:

    <html>
      <body>
        <h2>BOOK_INFORMATION </h2>
        <table style="display: inline-block; border: 1px solid; float: left; ">
          <tr bgcolor="#FFA500">
            <th>book Name</th>
            <th>book_Count</th>
            <th>book_Number</th>
            <th>ISBN</th>
            <th>Isbninfo_Name</th>
            <th>Isbninfo_Version</th>
          </tr>
          <tr>
            <td>Eclpise</td>
            <td>3</td>
            <td>book3687110</td>
            <td>927fd6ca660e5a9</td>
            <td>new book</td>
            <td>version 1</td>
          </tr>
          <tr>
            <td>Eclpise</td>
            <td>3</td>
            <td>book3687110</td>
            <td>927fd6ca660e5a9</td>
            <td> new book 1</td>
            <td>version 2</td>
          </tr>
          <tr>
            <td>Eclpise</td>
            <td>3</td>
            <td>book3674796</td>
            <td>6fa276825144</td>
            <td>new book 3</td>
            <td>version 3</td>
          </tr>
          <tr>
            <td>Eclpise</td>
            <td>3</td>
            <td>book3674796</td>
            <td>6fa276825144</td>
            <td>new book 4</td>
            <td>version 4</td>
          </tr>
          <tr>
            <td>ORACLE</td>
            <td>0</td>
          </tr>
          <tr>
            <td>MUSIC</td>
            <td>0</td>
          </tr>
        </table>
      </body>
    </html>
    

    The idea is to have different templates that match the various possible level of details found in the XML – each template generating a table row with more or less cells.

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

Sidebar

Related Questions

I can't believe how unbelievably complicated this has been... I have the following XML...
I have this complicated slider that utilizes tons of animation. I'm trying to find
I have some complicated, problem to be solved. Now I need to write such
I have a complicated problem, and I need help. I have a base case,
I have a complicated nested form (Ryan Bates' version) with .live() attached to some
I have the following XML file: <xml version=1.0 encoding=utf-8?> <Data> <Parameter1>1</Parameter1> </Data> I want
I have a XML like this: <?xml version=1.0 encoding=UTF-8?> <nodes> <n c=value2/> <n>Has a
I have a series of complicated XML files from Amazon showing order reports. A
I'm working with a complicated xml schema, for which I have created a class
We have an odd problem, we are tranforming a pretty complicated XML file using

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.