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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:35:10+00:00 2026-05-31T04:35:10+00:00

Let this be the xml: … some other parent elements here … <subject group=a>Economy</subject>

  • 0

Let this be the xml:

... some other parent elements here ...
<subject group="a">Economy</subject>
<subject group="b">Math</subject>
<subject group="a">Finance</subject>
<subject group="c">Arts</subject>
... some other elements here 

I would like to process and print a heading where group ‘a’ and ‘b’ is under one heading, and c is in another heading. ‘C’ is not a definite string, it can be ‘d’, ‘d’. I just want to seperate ‘a’ and ‘b’, from anything else. So an example output would be

Main Subjects (a and b)

  • Economy Finance Math

Others

  • Arts

Now, I have this code for the “Others” part:

<xsl:if test="not(subject/@group[. = 'a'] or subject/@group[. = 'b])">
                <h2>Others</h2> 
                <ul>
                    <xsl:for-each select="subject">      
                        <xsl:sort select="./@group"/>
                        <xsl:if test="@group!='a'and @type!='b'">
                            <xsl:apply-templates select="."/>
                        </xsl:if>
                    </xsl:for-each>
                </ul>
</xsl:if> 

This doesn’t work properly. I’ve tried without the not() and with !=

In short i just want to know if there is any element besides those of group a and b. If there is, print something, if there isn’t anything, don’t print out the heading “Others”.

Any help will be appreciated.

  • 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-05-31T04:35:11+00:00Added an answer on May 31, 2026 at 4:35 am
    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="html"/>
      <xsl:template match="/">
        <h2>Main Subjects</h2>
        <ul>
          <xsl:for-each select="//subject[@group/.='a' or @group/.='b']">
            <li>
              <xsl:value-of select="."/>
            </li>
          </xsl:for-each>
        </ul>
        <h2>Others</h2>
        <ul>
          <xsl:for-each select="//subject[not(@group/.='a' or @group/.='b')]">
            <li>
              <xsl:value-of select="."/>
            </li>
          </xsl:for-each>
        </ul>
      </xsl:template>
    </xsl:stylesheet>
    

    EDIT: @group/.='a' or @group ='a' both are fine,

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

Sidebar

Related Questions

Let's say I have some XML like this <channel> <item> <title>This is title 1</title>
Let's suppose I have xml like this one: <Server Active=No> <Url>http://some.url</Url> </Server> C# class
Let's say you have this xml: <yyy:response xmlns:xxx='http://domain.com'> <yyy:success> <yyy:data>some-value</yyy:data> </yyy:success> </yyy:response> How would
Let's say that I've got this xml: <items> <item name=thumb> <downloadStream>test1</downloadStream> <downloadStream>test2</downloadStream> <downloadStream>test3</downloadStream> </item>
I have an XML file, which I open in F# like this: let Bookmarks(xmlFile:string)
let's say, I have this xml file: <?xml version=1.0 encoding=UTF-8 ?> <TimeSeries> <timeZone>1.0</timeZone> <series>
My XPath is a little bit rusty... Let's say I have this simple XML
What's the easiest way in VB.NET to parse this XML? Here's an example of
Let's say I have this XML file. <book> <id>1</id> <title>Harry Potter - bla bla
this is xml let say: <.Sections> <.SECTION ID =4 NAME=GetStudents CONTROL-TYPE=Button LINK=WebForm2.aspx> </SECTION> <.SECTION

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.