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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:38:44+00:00 2026-06-14T17:38:44+00:00

I have to write an XSLT document which can be used with any XML

  • 0

I have to write an XSLT document which can be used with any XML document and display the results in an HTML table. The columns of the table all depend on how many tags there are in the XML document. I was trying to use

<xsl:value-of select="count(/*/*/)"/> 

to count the number of tags.

But I want that if for instance i have:

  <film>
      <title></title>
      <year></year>
      <actor></actor>
  </film>
  <film>
      <title></title>
      <year></year>
      <actor></actor>
  </film>

the result would be 3 not 6 as it currently being displayed. Any solutions to this problem please?

  • 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-14T17:38:45+00:00Added an answer on June 14, 2026 at 5:38 pm

    I. Supposing:

    1. That you had a well-formed XML document like:

    . . . .

    <films>
      <film>
        <title/>
        <year/>
        <actor/>
      </film>
      <film>
        <title/>
        <year/>
        <actor/>
      </film>
    </films>
    

    and:

    .2. The film elements all have the same number of same-named columns, then you simply need:

     count(/*/*[1]/*)
    

    This produces the number of children elements of the first child -element of the top element of the XML document:

    3
    

    II. Another possibility: different film elements have different number of children and one of them has all children that determine the total number of columns for the table.

    <films>
      <film>
        <title/>
        <year/>
        <actor/>
      </film>
      <film>
        <title/>
        <year/>
        <actor/>
        <rating/>
        <director/>
      </film>
      <film>
        <title/>
        <year/>
        <actor/>
        <rating/>
      </film>
    </films>
    

    Then, using XPath 2.0, use:

    max(/*/*/count(*))
    

    This produces the maximum number of children that a child of the top element of the XML document has:

    5
    

    III. Finally, if it is possible that none of the film elements contain all the elements for the columns, then use (what ABach already proposed):

    count(distinct-values(/*/*/*/name()))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a long document in XML from which I need to produce static
I've got an XML document, which Im trying to add an xslt to in
I have created an xml document and an xslt document and now i want
I'm trying to write an XSLT that will transform an XML document that I
I have to write an XSLT to convert a XML file into another XML
I have an HTML file and i want to convert to XML document only
I have this very simple CODE, which should generate me HTML, but all I
I have write my own view Bar, which extends LinearLayout . My bar has
I'm working on an application so i have write an dll which contain a
I have to write a SNMP module which monitor a certain server application that

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.