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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:29:28+00:00 2026-06-17T09:29:28+00:00

I have an xhtml page containing multiple divs. This: <xsl:template match=div[@class = ‘toc’]> selects

  • 0

I have an xhtml page containing multiple divs.
This:

 <xsl:template match="div[@class = 'toc']">

selects divs that interest me (all of them contain unordered lists – ul). Now I would like to select only those divs that contain two levels of ul elements.

In general: how do I select nodes that have specific type of children?

I tried something like this:

<xsl:apply-templates select="body/div[@class = 'toc']/ul/li/ul" />

                   ...

<xsl:template match="div[@class = 'toc']/ul/li/ul">    
  <xsl:apply-templates mode="final_template" select="../../.."/> 
</xsl:template>

<xsl:template name="final_template" match="div">
        ...
</xsl:template>

But it doesn’t work. What is more I believe there must be a cleaner approach to this problem than mine.

  • 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-17T09:29:29+00:00Added an answer on June 17, 2026 at 9:29 am

    In general, to select nodes that have certain children:

    NodeToSelect[childName]
    

    To select nodes that have certain descendants:

    NodeToSelect[.//descendantName]
    

    Please try this path for your situation:

    div[@class = 'toc'][.//ul//ul]
    

    For the XSLT, this is probably a good way to go:

    <xsl:apply-templates select="body/div[@class = 'toc'][.//ul//ul]" mode="twoUlDescendants" />
    
                       ...
    
    <xsl:template match="div" mode="twoUlDescendants">    
       <!-- Work with div here. -->
    </xsl:template>
    

    You can change the name of the mode “twoUlDescendants” to something that more accurately describes the purpose of these particular divs.

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

Sidebar

Related Questions

I have this login.xhtml JSF page: <?xml version=1.0?> <jsp:root version=2.0 xmlns:jsp=http://java.sun.com/JSP/Page xmlns:f=http://java.sun.com/jsf/core xmlns:h=http://java.sun.com/jsf/html> <jsp:directive.page
I have a simple problem on .xhtml page. This expression is not working :-
In my .xhtml page, I have the following form: <ui:composition xmlns:ui=http://java.sun.com/jsf/facelets template=./../template/CustomerTemplate.xhtml xmlns:h=http://java.sun.com/jsf/html xmlns:f=http://java.sun.com/jsf/core
In My .xhtml page I have 2 h:commandButton elements: <h:commandButton immediate=true lang=en class=msbutton action=#{user.changeLanguage()}
I have this xhtml page : <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC -//W3C//DTD
I have xhtml page with simple form. This page is using for several data
I have some code like this in my xhtml page <h:inputText id=cardNumber value=#{bean.cardNumber} required=true
in a JSF facelet page (.xhtml) I have this javascript code <script type=text/javascript> function
I have an XHTML strict page that has an invisible div that is controlled
I have a well formed XHTML page. I want to find the destination URL

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.