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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:30:30+00:00 2026-06-03T01:30:30+00:00

Hi I am looking for an XSLT for generating HTML as shown below. Following

  • 0

Hi I am looking for an XSLT for generating HTML as shown below.
Following are the details of the transformations.
Please provide your inputs.

For each PageGroup I need to create an

In HTML an Li element should be populated.

    <li>
        <a>Test</a>
    </li>

And under each Pagegroup for every Page Ul should be populated.
<ul>
        <li>
            <a>Test Role 1</a>
        </li>
        <li>
            <a>Test Role 2</a>
        </li>
</ul>

XML:

<menuitems>
    <pagegroup title="Test">
        <pages id="1" url="Test1.aspx" description="Tes 1" type="1" role="Test Role 1"/>
        <pages id="2" url="Test2.aspx" description="Tes 2" type="1" role="Test Role 2"/>
        <pagegroup title="Projects">
            <pages id="4" url="Test 2 3.aspx" description="Test 2 3" type="1" role="Rol 3"/>
            <pages id="4" url="Test 2 5.aspx" description="Test 2 5" type="1" role="Rol 4"/>
        </pagegroup>
    </pagegroup>
</menuitems>

Output HTML expecting

<ul>
    <li>
        <a>Test</a>
    </li>
    <ul>
        <li>
            <a>Test Role 1</a>
        </li>
        <li>
            <a>Test Role 2</a>
        </li>
        <ul>
            <li>
                <a>Projects</a>
            </li>
            <ul>
                <li>
                    <a>Test 2 3</a>
                </li>
                <li>
                    <a>Test 2 5</a>
                </li>
            </ul>
        </ul>
    </ul>
</ul>

XSLT Tried

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
            <xsl:template match="pagegroup">
                        <ul>
                                    <xsl:apply-templates select="pages"/>
                                    <li>
                                    <xsl:value-of select="@title"/>
                                    </li>
                        </ul>
            </xsl:template>
            <xsl:template match="pages">
                        <li>
                                    <xsl:value-of select="@role"/>
                                    <xsl:if test="pagegroup">
                                                <ul>
                                                            <xsl:apply-templates select="pages"/>
                                                            <li>
                                                            <xsl:value-of select="@title" />
                                                            </li>
                                                </ul>
                                    </xsl:if>
                        </li>
            </xsl:template>
</xsl:stylesheet>
  • 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-03T01:30:31+00:00Added an answer on June 3, 2026 at 1:30 am

    You are not too far off. The main issue is that in your template to match pagegroup you are doing this…

    <xsl:apply-templates select="pages"/>
    

    When really you want to be doing this, to match both pages and pagegroups

    <xsl:apply-templates/>
    

    Try the following XSLT

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
       <xsl:template match="pagegroup">
          <ul>
             <li>
                <xsl:value-of select="@title"/>
             </li>
             <ul>
                <xsl:apply-templates/>
             </ul>
          </ul>
       </xsl:template>
       <xsl:template match="pages">
          <li>
             <xsl:value-of select="@role"/>
          </li>
       </xsl:template>
    </xsl:stylesheet>
    

    When applied to your XML, the following is output

    <ul>
       <li>Test</li>
       <ul>
          <li>Test Role 1</li>
          <li>Test Role 2</li>
          <ul>
             <li>Projects</li>
             <ul>
                <li>Rol 3</li>
                <li>Rol 4</li>
             </ul>
          </ul>
       </ul>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for an xslt that does the following: With the input xml of,
I am looking to make an XSLT that will transform the input XML below:
As stated I'm looking for a free lightweight xslt editor with following functionalities: Intellisense
I am looking to sort an XML structure using XSLT using xsltproc: The xml
Looking to use XSLT to transform my XML. The sample XML is as follows:
I am looking for an XSLT snippet that can modify the value of a
I am looking to offload some processing to the client via client side XSLT.
Im looking for a XSLT (1.0) stylesheet. I have input similar to this: <?xml
How can I generate a UUID with pure XSLT? Basically looking for a way
I am looking for a mechanism to transform dataobjects into HTML. The elements in

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.